@crowdstrike/glide-core 0.22.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/checkbox-group.js +6 -5
- package/dist/checkbox.d.ts +10 -2
- package/dist/checkbox.js +16 -16
- package/dist/dropdown.d.ts +1 -1
- package/dist/dropdown.js +20 -18
- package/dist/dropdown.option.js +1 -1
- package/dist/radio-group.js +15 -15
- package/dist/radio-group.radio.d.ts +2 -1
- package/dist/radio-group.radio.js +1 -1
- package/dist/tab.styles.js +1 -0
- package/package.json +1 -1
package/dist/checkbox-group.js
CHANGED
@@ -24,11 +24,12 @@ var __decorate=this&&this.__decorate||function(e,t,i,o){var s,r=arguments.length
|
|
24
24
|
>
|
25
25
|
<slot
|
26
26
|
class="default-slot"
|
27
|
-
@change=${this.#n}
|
28
|
-
@private-
|
29
|
-
@
|
27
|
+
@private-checked-change=${this.#n}
|
28
|
+
@private-disabled-change=${this.#c}
|
29
|
+
@private-value-change=${this.#h}
|
30
|
+
@slotchange=${this.#p}
|
30
31
|
${assertSlot([GlideCoreCheckbox])}
|
31
|
-
${ref(this.#
|
32
|
+
${ref(this.#u)}
|
32
33
|
>
|
33
34
|
<!--
|
34
35
|
@type {GlideCoreCheckbox}
|
@@ -53,4 +54,4 @@ var __decorate=this&&this.__decorate||function(e,t,i,o){var s,r=arguments.length
|
|
53
54
|
>`))}
|
54
55
|
</div>
|
55
56
|
</glide-core-private-label>
|
56
|
-
</div>`}reportValidity(){this.isReportValidityOrSubmit=!0;const e=this.#o.reportValidity();return this.requestUpdate(),e}resetValidityFeedback(){this.isReportValidityOrSubmit=!1}setCustomValidity(e){this.validityMessage=e,""===e?this.#o.setValidity({customError:!1},"",this.#l.value):this.#o.setValidity({customError:!0,valueMissing:this.#o.validity.valueMissing}," ",this.#l.value)}setValidity(e,t){this.validityMessage=t,this.#o.setValidity(e," ",this.#l.value)}constructor(){super(),this.hideLabel=!1,this.name="",this.orientation="horizontal",this.version=packageJson.version,this.isBlurring=!1,this.isCheckingValidity=!1,this.isReportValidityOrSubmit=!1,this.#l=createRef(),this.#
|
57
|
+
</div>`}reportValidity(){this.isReportValidityOrSubmit=!0;const e=this.#o.reportValidity();return this.requestUpdate(),e}resetValidityFeedback(){this.isReportValidityOrSubmit=!1}setCustomValidity(e){this.validityMessage=e,""===e?this.#o.setValidity({customError:!1},"",this.#l.value):this.#o.setValidity({customError:!0,valueMissing:this.#o.validity.valueMissing}," ",this.#l.value)}setValidity(e,t){this.validityMessage=t,this.#o.setValidity(e," ",this.#l.value)}constructor(){super(),this.hideLabel=!1,this.name="",this.orientation="horizontal",this.version=packageJson.version,this.isBlurring=!1,this.isCheckingValidity=!1,this.isReportValidityOrSubmit=!1,this.#l=createRef(),this.#u=createRef(),this.#e=!1,this.#i=!1,this.#s=[],this.#r=({formData:e})=>{this.name&&this.value.length>0&&!this.disabled&&e.append(this.name,JSON.stringify(this.value))},this.#o=this.attachInternals(),this.addEventListener("invalid",(e=>{if(e?.preventDefault(),this.isCheckingValidity||this.isBlurring)return;this.isReportValidityOrSubmit=!0;this.form?.querySelector(":invalid")===this&&this.focus()}))}#l;#u;#o;#e;#i;#s;get#t(){return this.#u.value?this.#u.value.assignedElements().filter((e=>e instanceof GlideCoreCheckbox)):[]}#r;get#d(){return!this.disabled&&!this.validity.valid&&this.isReportValidityOrSubmit}#b(){for(const e of this.#t)e.privateIsReportValidityOrSubmit=!0}#a(e){const t=e.relatedTarget;t&&t instanceof GlideCoreCheckbox&&this.#t.includes(t)||this.#b()}#n(e){e.target instanceof GlideCoreCheckbox&&e.target.checked&&e.target.value?this.#s=[...this.value,e.target.value]:e.target instanceof GlideCoreCheckbox&&!e.target.checked&&(this.#s=this.value.filter((t=>e.target instanceof GlideCoreCheckbox&&t!==e.target.value)))}#c(e){if(e.target instanceof GlideCoreCheckbox&&e.target.disabled&&e.target.checked){const t=this.#s.lastIndexOf(e.target.value);this.#s.splice(t,t+1)}else e.target instanceof GlideCoreCheckbox&&e.target.checked&&e.target.value&&this.#s.push(e.target.value)}#h(e){e.target instanceof GlideCoreCheckbox&&e.target.checked&&e.detail.new?this.value=this.#s.map((t=>t===e.detail.old?e.detail.new:t)):e.target instanceof GlideCoreCheckbox&&e.target.checked&&(this.value=this.#s.filter((t=>t!==e.detail.old)))}#p(){this.#s=this.#t.filter((({checked:e,disabled:t,value:i})=>e&&!t&&""!==i)).map((({value:e})=>e))}};__decorate([property({reflect:!0,type:Boolean})],GlideCoreCheckboxGroup.prototype,"disabled",null),__decorate([property({attribute:"hide-label",type:Boolean})],GlideCoreCheckboxGroup.prototype,"hideLabel",void 0),__decorate([property({reflect:!0}),required],GlideCoreCheckboxGroup.prototype,"label",void 0),__decorate([property({reflect:!0})],GlideCoreCheckboxGroup.prototype,"name",void 0),__decorate([property({reflect:!0})],GlideCoreCheckboxGroup.prototype,"orientation",void 0),__decorate([property()],GlideCoreCheckboxGroup.prototype,"privateSplit",void 0),__decorate([property({reflect:!0,type:Boolean})],GlideCoreCheckboxGroup.prototype,"required",null),__decorate([property({reflect:!0})],GlideCoreCheckboxGroup.prototype,"summary",void 0),__decorate([property({reflect:!0})],GlideCoreCheckboxGroup.prototype,"tooltip",void 0),__decorate([property({type:Array})],GlideCoreCheckboxGroup.prototype,"value",null),__decorate([property({reflect:!0})],GlideCoreCheckboxGroup.prototype,"version",void 0),__decorate([state()],GlideCoreCheckboxGroup.prototype,"isBlurring",void 0),__decorate([state()],GlideCoreCheckboxGroup.prototype,"isCheckingValidity",void 0),__decorate([state()],GlideCoreCheckboxGroup.prototype,"isReportValidityOrSubmit",void 0),__decorate([state()],GlideCoreCheckboxGroup.prototype,"validityMessage",void 0),GlideCoreCheckboxGroup=__decorate([customElement("glide-core-checkbox-group"),final],GlideCoreCheckboxGroup);export default GlideCoreCheckboxGroup;
|
package/dist/checkbox.d.ts
CHANGED
@@ -58,9 +58,17 @@ export default class GlideCoreCheckbox extends LitElement implements FormControl
|
|
58
58
|
static formAssociated: boolean;
|
59
59
|
static shadowRootOptions: ShadowRootInit;
|
60
60
|
static styles: import("lit").CSSResult[];
|
61
|
-
|
61
|
+
/**
|
62
|
+
@default false
|
63
|
+
*/
|
64
|
+
get checked(): boolean;
|
65
|
+
set checked(isChecked: boolean);
|
62
66
|
privateInternallyInert: boolean;
|
63
|
-
|
67
|
+
/**
|
68
|
+
* @default false
|
69
|
+
*/
|
70
|
+
get disabled(): boolean;
|
71
|
+
set disabled(isDisabled: boolean);
|
64
72
|
hideLabel: boolean;
|
65
73
|
indeterminate: boolean;
|
66
74
|
/**
|
package/dist/checkbox.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
var __decorate=this&&this.__decorate||function(e,t,i,
|
1
|
+
var __decorate=this&&this.__decorate||function(e,t,i,s){var r,a=arguments.length,o=a<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var l=e.length-1;l>=0;l--)(r=e[l])&&(o=(a<3?r(o):a>3?r(t,i,o):r(t,i))||o);return a>3&&o&&Object.defineProperty(t,i,o),o};import"./label.js";import"./tooltip.js";import{html,LitElement}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{ifDefined}from"lit/directives/if-defined.js";import{styleMap}from"lit/directives/style-map.js";import{when}from"lit/directives/when.js";import{unsafeHTML}from"lit/directives/unsafe-html.js";import packageJson from"../package.json"with{type:"json"};import checkedIcon from"./icons/checked.js";import styles from"./checkbox.styles.js";import shadowRootMode from"./library/shadow-root-mode.js";import final from"./library/final.js";import required from"./library/required.js";let GlideCoreCheckbox=class GlideCoreCheckbox extends LitElement{static{this.formAssociated=!0}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:shadowRootMode}}static{this.styles=styles}get checked(){return this.#e}set checked(e){const t=e!==this.#e;this.#e=e,t&&this.dispatchEvent(new Event("private-checked-change",{bubbles:!0}))}get disabled(){return this.#t}set disabled(e){this.#t=e,this.dispatchEvent(new Event("private-disabled-change",{bubbles:!0}))}get label(){return this.#i}set label(e){this.#i=e,setTimeout((()=>{this.#s()}))}get value(){return this.#r}set value(e){const t=this.#r;this.#r=e,this.dispatchEvent(new CustomEvent("private-value-change",{bubbles:!0,detail:{old:t,new:e}}))}get form(){return this.#a.form}checkValidity(){this.isCheckingValidity=!0;const e=this.#a.checkValidity();return this.isCheckingValidity=!1,e}click(){this.#o.value?.click()}connectedCallback(){super.connectedCallback(),this.#l=new IntersectionObserver((()=>{this.checkVisibility()&&this.#s()})),this.#l.observe(this)}disconnectedCallback(){super.disconnectedCallback(),this.form?.removeEventListener("formdata",this.#n),this.#l?.disconnect()}get validity(){return"minimal"===this.privateVariant?this.#a.validity:this.required&&!this.checked?(this.#a.setValidity({customError:Boolean(this.validityMessage),valueMissing:!0}," ",this.#o.value),this.#a.validity):this.required&&this.#a.validity.valueMissing&&this.checked?(this.#a.setValidity({}),this.#a.validity):(this.required||!this.#a.validity.valueMissing||this.checked||this.#a.setValidity({}),this.#a.validity)}focus(e){this.#o.value?.focus(e)}formAssociatedCallback(){this.form?.addEventListener("formdata",this.#n)}formResetCallback(){this.checked=""===this.getAttribute("checked"),this.indeterminate=""===this.getAttribute("indeterminate")}render(){return html`<div class="component" data-test="component">
|
2
2
|
${when("minimal"===this.privateVariant,(()=>html`
|
3
3
|
<label
|
4
4
|
class=${classMap({"label-and-input-and-checkbox":!0,[this.privateSize]:!0})}
|
@@ -8,7 +8,7 @@ var __decorate=this&&this.__decorate||function(e,t,i,r){var o,a=arguments.length
|
|
8
8
|
class=${classMap({"input-and-checkbox":!0,disabled:this.disabled})}
|
9
9
|
>
|
10
10
|
<input
|
11
|
-
aria-invalid=${this.#
|
11
|
+
aria-invalid=${this.#d}
|
12
12
|
class="input"
|
13
13
|
data-test="input"
|
14
14
|
type="checkbox"
|
@@ -16,9 +16,9 @@ var __decorate=this&&this.__decorate||function(e,t,i,r){var o,a=arguments.length
|
|
16
16
|
.inert=${this.privateInternallyInert}
|
17
17
|
?disabled=${this.disabled}
|
18
18
|
?required=${this.required}
|
19
|
-
@change=${this.#
|
20
|
-
@input=${this.#
|
21
|
-
@keydown=${this.#
|
19
|
+
@change=${this.#h}
|
20
|
+
@input=${this.#h}
|
21
|
+
@keydown=${this.#c}
|
22
22
|
${ref(this.#o)}
|
23
23
|
/>
|
24
24
|
|
@@ -47,7 +47,7 @@ var __decorate=this&&this.__decorate||function(e,t,i,r){var o,a=arguments.length
|
|
47
47
|
<div
|
48
48
|
class=${classMap({label:!0,disabled:this.disabled})}
|
49
49
|
slot="target"
|
50
|
-
${ref(this.#
|
50
|
+
${ref(this.#p)}
|
51
51
|
>
|
52
52
|
${this.label}
|
53
53
|
</div>
|
@@ -60,7 +60,7 @@ var __decorate=this&&this.__decorate||function(e,t,i,r){var o,a=arguments.length
|
|
60
60
|
split=${ifDefined(this.privateSplit??void 0)}
|
61
61
|
tooltip=${ifDefined(this.tooltip)}
|
62
62
|
?disabled=${this.disabled}
|
63
|
-
?error=${this.#
|
63
|
+
?error=${this.#d}
|
64
64
|
?hide=${this.hideLabel}
|
65
65
|
?required=${this.required}
|
66
66
|
>
|
@@ -74,7 +74,7 @@ var __decorate=this&&this.__decorate||function(e,t,i,r){var o,a=arguments.length
|
|
74
74
|
<div class="input-and-checkbox" slot="control">
|
75
75
|
<input
|
76
76
|
aria-describedby="summary description"
|
77
|
-
aria-invalid=${this.#
|
77
|
+
aria-invalid=${this.#d}
|
78
78
|
class="input"
|
79
79
|
data-test="input"
|
80
80
|
id="input"
|
@@ -82,15 +82,15 @@ var __decorate=this&&this.__decorate||function(e,t,i,r){var o,a=arguments.length
|
|
82
82
|
.checked=${this.checked}
|
83
83
|
?disabled=${this.disabled}
|
84
84
|
?required=${this.required}
|
85
|
-
@blur=${this.#
|
86
|
-
@change=${this.#
|
87
|
-
@input=${this.#
|
88
|
-
@keydown=${this.#
|
85
|
+
@blur=${this.#b}
|
86
|
+
@change=${this.#h}
|
87
|
+
@input=${this.#h}
|
88
|
+
@keydown=${this.#c}
|
89
89
|
${ref(this.#o)}
|
90
90
|
/>
|
91
91
|
|
92
92
|
<div
|
93
|
-
class=${classMap({checkbox:!0,disabled:this.disabled,error:this.#
|
93
|
+
class=${classMap({checkbox:!0,disabled:this.disabled,error:this.#d})}
|
94
94
|
>
|
95
95
|
<div class="checked-icon">${checkedIcon}</div>
|
96
96
|
${icons.indeterminate}
|
@@ -105,7 +105,7 @@ var __decorate=this&&this.__decorate||function(e,t,i,r){var o,a=arguments.length
|
|
105
105
|
@type {Element | string}
|
106
106
|
-->
|
107
107
|
<slot
|
108
|
-
class=${classMap({description:!0,hidden:Boolean(this.#
|
108
|
+
class=${classMap({description:!0,hidden:Boolean(this.#d&&this.validityMessage)})}
|
109
109
|
name="description"
|
110
110
|
>
|
111
111
|
<!--
|
@@ -114,14 +114,14 @@ var __decorate=this&&this.__decorate||function(e,t,i,r){var o,a=arguments.length
|
|
114
114
|
-->
|
115
115
|
</slot>
|
116
116
|
|
117
|
-
${when(this.#
|
117
|
+
${when(this.#d&&this.validityMessage,(()=>html`<span
|
118
118
|
class="validity-message"
|
119
119
|
data-test="validity-message"
|
120
120
|
>${unsafeHTML(this.validityMessage)}</span
|
121
121
|
>`))}
|
122
122
|
</div>
|
123
123
|
</glide-core-private-label>`))}
|
124
|
-
</div>`}reportValidity(){this.privateIsReportValidityOrSubmit=!0;const e=this.#
|
124
|
+
</div>`}reportValidity(){this.privateIsReportValidityOrSubmit=!0;const e=this.#a.reportValidity();return this.requestUpdate(),e}resetValidityFeedback(){this.privateIsReportValidityOrSubmit=!1}setCustomValidity(e){this.validityMessage=e,""===e?this.#a.setValidity({customError:!1},"",this.#o.value):this.#a.setValidity({customError:!0,valueMissing:this.#a.validity.valueMissing}," ",this.#o.value)}setValidity(e,t){this.validityMessage=t,this.#a.setValidity(e," ",this.#o.value)}updated(){this.#o.value&&(this.#o.value.indeterminate=this.indeterminate)}constructor(){super(),this.privateInternallyInert=!1,this.hideLabel=!1,this.indeterminate=!1,this.orientation="horizontal",this.name="",this.privateLabelTooltipOffset=4,this.privateShowLabelTooltip=!1,this.privateDisableLabelTooltip=!1,this.privateSize="large",this.required=!1,this.privateIsReportValidityOrSubmit=!1,this.version=packageJson.version,this.isBlurring=!1,this.isCheckingValidity=!1,this.isLabelOverflow=!1,this.#o=createRef(),this.#e=!1,this.#t=!1,this.#p=createRef(),this.#r="",this.#n=({formData:e})=>{this.checked&&this.name&&this.value&&!this.disabled&&e.append(this.name,this.value)},this.#a=this.attachInternals(),this.addEventListener("invalid",(e=>{if(e?.preventDefault(),this.isCheckingValidity||this.isBlurring)return;this.privateIsReportValidityOrSubmit=!0;this.form?.querySelector(":invalid")===this&&this.focus()}))}#o;#a;#l;#e;#t;#i;#p;#r;#n;get#d(){return"minimal"===this.privateVariant?!this.validity.valid&&this.privateIsReportValidityOrSubmit:!this.disabled&&!this.validity.valid&&this.privateIsReportValidityOrSubmit}#b(){this.isBlurring=!0,this.reportValidity(),this.isBlurring=!1}#h(e){e.target instanceof HTMLInputElement&&(this.checked=e.target.checked),this.indeterminate=!1,"change"===e.type&&this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}#c(e){"Enter"===e.key&&this.form?.requestSubmit()}#s(){this.#p.value&&(this.isLabelOverflow=this.#p.value.scrollWidth>this.#p.value.clientWidth)}};__decorate([property({type:Boolean})],GlideCoreCheckbox.prototype,"checked",null),__decorate([property({attribute:"private-internally-inert",type:Boolean})],GlideCoreCheckbox.prototype,"privateInternallyInert",void 0),__decorate([property({reflect:!0,type:Boolean})],GlideCoreCheckbox.prototype,"disabled",null),__decorate([property({attribute:"hide-label",type:Boolean})],GlideCoreCheckbox.prototype,"hideLabel",void 0),__decorate([property({type:Boolean})],GlideCoreCheckbox.prototype,"indeterminate",void 0),__decorate([property({reflect:!0}),required],GlideCoreCheckbox.prototype,"label",null),__decorate([property({reflect:!0})],GlideCoreCheckbox.prototype,"orientation",void 0),__decorate([property({reflect:!0})],GlideCoreCheckbox.prototype,"name",void 0),__decorate([property({attribute:"private-label-tooltip-offset",reflect:!0,type:Number})],GlideCoreCheckbox.prototype,"privateLabelTooltipOffset",void 0),__decorate([property({attribute:"private-show-label-tooltip",reflect:!0,type:Boolean})],GlideCoreCheckbox.prototype,"privateShowLabelTooltip",void 0),__decorate([property({attribute:"private-disable-label-tooltip",reflect:!0,type:Boolean})],GlideCoreCheckbox.prototype,"privateDisableLabelTooltip",void 0),__decorate([property({attribute:"private-size"})],GlideCoreCheckbox.prototype,"privateSize",void 0),__decorate([property()],GlideCoreCheckbox.prototype,"privateSplit",void 0),__decorate([property({attribute:"private-variant"})],GlideCoreCheckbox.prototype,"privateVariant",void 0),__decorate([property({reflect:!0,type:Boolean})],GlideCoreCheckbox.prototype,"required",void 0),__decorate([property({reflect:!0})],GlideCoreCheckbox.prototype,"summary",void 0),__decorate([property({reflect:!0})],GlideCoreCheckbox.prototype,"tooltip",void 0),__decorate([property({reflect:!0})],GlideCoreCheckbox.prototype,"value",null),__decorate([property({type:Boolean})],GlideCoreCheckbox.prototype,"privateIsReportValidityOrSubmit",void 0),__decorate([property({reflect:!0})],GlideCoreCheckbox.prototype,"version",void 0),__decorate([state()],GlideCoreCheckbox.prototype,"isBlurring",void 0),__decorate([state()],GlideCoreCheckbox.prototype,"isCheckingValidity",void 0),__decorate([state()],GlideCoreCheckbox.prototype,"isLabelOverflow",void 0),__decorate([state()],GlideCoreCheckbox.prototype,"validityMessage",void 0),GlideCoreCheckbox=__decorate([customElement("glide-core-checkbox"),final],GlideCoreCheckbox);export default GlideCoreCheckbox;const icons={indeterminate:html`
|
125
125
|
<svg
|
126
126
|
aria-hidden="true"
|
127
127
|
style=${styleMap({height:"0.875rem",width:"0.875rem"})}
|
package/dist/dropdown.d.ts
CHANGED
@@ -34,7 +34,7 @@ declare global {
|
|
34
34
|
*
|
35
35
|
* @slot {GlideCoreDropdownOption}
|
36
36
|
* @slot {Element | string} [description] - Additional information or context
|
37
|
-
* @slot {Element} [icon:value] - Icons for the selected option or options. Slot one icon per
|
37
|
+
* @slot {Element} [icon:value] - Icons for the selected option or options. Slot one icon per Dropdown Option. `<value>` should be equal to the `value` of each Dropdown Option.
|
38
38
|
*
|
39
39
|
* @fires {Event} add
|
40
40
|
* @fires {Event} change
|
package/dist/dropdown.js
CHANGED
@@ -1,4 +1,4 @@
|
|
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"./icon-button.js";import"./label.js";import"./tooltip.js";import{html,LitElement}from"lit";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{styleMap}from"lit/directives/style-map.js";import{unsafeHTML}from"lit/directives/unsafe-html.js";import{when}from"lit/directives/when.js";import packageJson from"../package.json"with{type:"json"};import onResize from"./library/on-resize.js";import GlideCoreDropdownOption from"./dropdown.option.js";import{LocalizeController}from"./library/localize.js";import GlideCoreTag from"./tag.js";import chevronIcon from"./icons/chevron.js";import magnifyingGlassIcon from"./icons/magnifying-glass.js";import pencilIcon from"./icons/pencil.js";import styles from"./dropdown.styles.js";import assertSlot from"./library/assert-slot.js";import shadowRootMode from"./library/shadow-root-mode.js";import final from"./library/final.js";import required from"./library/required.js";let GlideCoreDropdown=class GlideCoreDropdown extends LitElement{static{this.formAssociated=!0}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:shadowRootMode}}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?this.#l.value&&this.selectedOptions[0]?.label&&(this.#l.value.value=this.selectedOptions[0].label,this.inputValue=this.selectedOptions[0].label,this.isInputOverflow=this.#l.value.scrollWidth>this.#l.value.clientWidth):this.#s!==e&&this.#o(),this.#s=e}get open(){return this.#n}set open(e){const t=e!==this.#n;if(this.#n=e,e&&t&&!this.disabled)return this.#i(),void this.dispatchEvent(new Event("toggle",{bubbles:!0,composed:!0}));if(!this.open&&t){!this.multiple&&this.#l.value&&this.selectedOptions[0]?.label?(this.#l.value.value=this.selectedOptions[0].label,this.inputValue=this.selectedOptions[0].label):(!this.multiple&&this.#l.value&&0===this.selectedOptions.length||this.multiple&&this.#l.value)&&(this.#l.value.value="",this.inputValue=""),this.isFiltering=!1,this.isNoResults=!1,this.isShowSingleSelectIcon=Boolean(this.selectedOptions.at(0)?.value);for(const e of this.#a)e.hidden=!1;this.#t(),this.dispatchEvent(new Event("toggle",{bubbles:!0,composed:!0}))}}get multiple(){return this.#r}set multiple(e){const t=this.#r&&!e,i=!this.#r&&e;this.#r=e,this.isShowSingleSelectIcon=!1;for(const i of this.#a)i.privateMultiple=e,t&&i!==this.lastSelectedOption&&(i.selected=!1);t&&this.lastSelectedOption?.value?this.value=[this.lastSelectedOption.value]:i&&this.lastSelectedOption&&(this.#l.value&&(this.#l.value.value=""),this.lastSelectedOption.privateUpdateCheckbox(),this.#p())}get size(){return this.#d}set size(e){if(this.#d=e,this.#h)for(const t of this.#h)t.privateSize=e}get value(){return this.#c}set value(e){if(this.#c=e,!this.multiple&&e.length>1)throw new Error("Only one value is allowed when not `multiple`.");this.#u=!0;for(const t of this.#a)t.selected=e.some((e=>e&&e===t.value)),t.selected&&t.disabled&&(t.disabled=!1);this.#u=!1,!this.multiple&&0===this.value.length&&this.#l.value&&(this.#l.value.value="")}get activeOption(){return this.#h?.find((({privateActive:e})=>e))}checkValidity(){this.isCheckingValidity=!0;const e=this.#v.checkValidity();return this.isCheckingValidity=!1,e}click(){this.filterable||this.isFilterable?(this.#l.value?.click(),this.#l.value?.select()):this.#m.value?.click()}get selectedOptions(){return this.#a.filter((e=>e instanceof GlideCoreDropdownOption&&e.selected))}get lastSelectedOption(){return this.#a.findLast((e=>e.selected))}get isAllSelected(){return this.#a.length>0&&this.#a.filter((({selected:e})=>e)).length===this.#a.filter((({disabled:e})=>!e)).length}get isSomeSelected(){return this.#a.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.#f,{capture:!0})}createRenderRoot(){return this.#g=super.createRenderRoot(),this.#g}disconnectedCallback(){super.disconnectedCallback(),this.form?.removeEventListener("formdata",this.#b),document.removeEventListener("click",this.#f,{capture:!0})}async filter(e){return this.#a.filter((({label:t})=>t?.toLowerCase().includes(e.toLowerCase().trim())))}firstUpdated(){this.#O.value&&(this.#O.value.popover="manual"),this.open&&!this.disabled&&this.#i(),!this.multiple&&this.lastSelectedOption&&this.#l.value&&this.lastSelectedOption.label&&(this.#l.value.value=this.lastSelectedOption.label);if(this.#a.every((({selected:e})=>!e)))for(const e of this.#a)e.selected=this.value.some((t=>""!==t&&t===e.value)),e.selected&&e.disabled&&(e.disabled=!1)}focus(e){this.filterable||this.isFilterable?this.#l.value?.focus(e):this.#m.value?.focus(e)}get form(){return this.#v.form}get validity(){return this.required&&0===this.selectedOptions.length?(this.#v.setValidity({customError:Boolean(this.validityMessage),valueMissing:!0}," ",this.filterable||this.isFilterable?this.#l.value:this.#m.value),this.#v.validity):this.required&&this.#v.validity.valueMissing&&this.selectedOptions.length>0?(this.#v.setValidity({}),this.#v.validity):this.#v.validity}formAssociatedCallback(){this.form?.addEventListener("formdata",this.#b)}formResetCallback(){for(const e of this.#a){e.hasAttribute("selected")||(e.selected=!1)}const e=this.#a.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"./icon-button.js";import"./label.js";import"./tooltip.js";import{html,LitElement}from"lit";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{styleMap}from"lit/directives/style-map.js";import{unsafeHTML}from"lit/directives/unsafe-html.js";import{when}from"lit/directives/when.js";import packageJson from"../package.json"with{type:"json"};import onResize from"./library/on-resize.js";import GlideCoreDropdownOption from"./dropdown.option.js";import{LocalizeController}from"./library/localize.js";import GlideCoreTag from"./tag.js";import chevronIcon from"./icons/chevron.js";import magnifyingGlassIcon from"./icons/magnifying-glass.js";import pencilIcon from"./icons/pencil.js";import styles from"./dropdown.styles.js";import assertSlot from"./library/assert-slot.js";import shadowRootMode from"./library/shadow-root-mode.js";import final from"./library/final.js";import required from"./library/required.js";let GlideCoreDropdown=class GlideCoreDropdown extends LitElement{static{this.formAssociated=!0}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:shadowRootMode}}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?this.#l.value&&this.selectedOptions[0]?.label&&(this.#l.value.value=this.selectedOptions[0].label,this.inputValue=this.selectedOptions[0].label,this.isInputOverflow=this.#l.value.scrollWidth>this.#l.value.clientWidth):this.#s!==e&&this.#o(),this.#s=e}get open(){return this.#n}set open(e){const t=e!==this.#n;if(this.#n=e,e&&t&&!this.disabled)return this.#i(),void this.dispatchEvent(new Event("toggle",{bubbles:!0,composed:!0}));if(!this.open&&t){!this.multiple&&this.#l.value&&this.selectedOptions[0]?.label?(this.#l.value.value=this.selectedOptions[0].label,this.inputValue=this.selectedOptions[0].label):(!this.multiple&&this.#l.value&&0===this.selectedOptions.length||this.multiple&&this.#l.value)&&(this.#l.value.value="",this.inputValue=""),this.isFiltering=!1,this.isNoResults=!1,this.isShowSingleSelectIcon=Boolean(this.selectedOptions.at(0)?.value);for(const e of this.#a)e.hidden=!1;this.#t(),this.dispatchEvent(new Event("toggle",{bubbles:!0,composed:!0}))}}get multiple(){return this.#r}set multiple(e){const t=this.#r&&!e,i=!this.#r&&e;this.#r=e,this.isShowSingleSelectIcon=!1;for(const i of this.#a)i.privateMultiple=e,t&&i!==this.lastSelectedOption&&(i.selected=!1);t&&this.lastSelectedOption?.value?this.value=[this.lastSelectedOption.value]:i&&this.lastSelectedOption&&(this.#l.value&&(this.#l.value.value=""),this.lastSelectedOption.privateUpdateCheckbox(),this.#p())}get size(){return this.#d}set size(e){if(this.#d=e,this.#h)for(const t of this.#h)t.privateSize=e}get value(){return this.#c}set value(e){if(this.#c=e,!this.multiple&&e.length>1)throw new Error("Only one value is allowed when not `multiple`.");this.#u=!0;for(const t of this.#a)t.selected=e.some((e=>e&&e===t.value)),t.selected&&t.disabled&&(t.disabled=!1);this.#u=!1,!this.multiple&&0===this.value.length&&this.#l.value&&(this.#l.value.value="")}get activeOption(){return this.#h?.find((({privateActive:e})=>e))}checkValidity(){this.isCheckingValidity=!0;const e=this.#v.checkValidity();return this.isCheckingValidity=!1,e}click(){this.filterable||this.isFilterable?(this.#l.value?.click(),this.#l.value?.select()):this.#m.value?.click()}get selectedOptions(){return this.#a.filter((e=>e instanceof GlideCoreDropdownOption&&e.selected&&!e.disabled))}get lastSelectedOption(){return this.#a.findLast((e=>e.selected))}get isAllSelected(){return this.#a.length>0&&this.#a.filter((({selected:e})=>e)).length===this.#a.filter((({disabled:e})=>!e)).length}get isSomeSelected(){return this.#a.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.#f,{capture:!0})}createRenderRoot(){return this.#g=super.createRenderRoot(),this.#g}disconnectedCallback(){super.disconnectedCallback(),this.form?.removeEventListener("formdata",this.#b),document.removeEventListener("click",this.#f,{capture:!0})}async filter(e){return this.#a.filter((({label:t})=>t?.toLowerCase().includes(e.toLowerCase().trim())))}firstUpdated(){this.#O.value&&(this.#O.value.popover="manual"),this.open&&!this.disabled&&this.#i(),!this.multiple&&this.lastSelectedOption&&this.#l.value&&this.lastSelectedOption.label&&(this.#l.value.value=this.lastSelectedOption.label);if(this.#a.every((({selected:e})=>!e)))for(const e of this.#a)e.selected=this.value.some((t=>""!==t&&t===e.value)),e.selected&&e.disabled&&(e.disabled=!1)}focus(e){this.filterable||this.isFilterable?this.#l.value?.focus(e):this.#m.value?.focus(e)}get form(){return this.#v.form}get validity(){return this.required&&0===this.selectedOptions.length?(this.#v.setValidity({customError:Boolean(this.validityMessage),valueMissing:!0}," ",this.filterable||this.isFilterable?this.#l.value:this.#m.value),this.#v.validity):this.required&&this.#v.validity.valueMissing&&this.selectedOptions.length>0?(this.#v.setValidity({}),this.#v.validity):this.#v.validity}formAssociatedCallback(){this.form?.addEventListener("formdata",this.#b)}formResetCallback(){for(const e of this.#a){e.hasAttribute("selected")||(e.selected=!1)}const e=this.#a.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
|
@mouseup=${this.#E}
|
4
4
|
${onResize(this.#p.bind(this))}
|
@@ -27,7 +27,7 @@ var __decorate=this&&this.__decorate||function(e,t,i,s){var l,o=arguments.length
|
|
27
27
|
class=${classMap({dropdown:!0,quiet:"quiet"===this.variant,disabled:this.disabled,error:this.#w,readonly:this.readonly,multiple:this.multiple})}
|
28
28
|
@click=${this.#S}
|
29
29
|
@mousedown=${this.#$}
|
30
|
-
${ref(this.#
|
30
|
+
${ref(this.#D)}
|
31
31
|
>
|
32
32
|
<span class="selected-option-labels" id="selected-option-labels">
|
33
33
|
${this.selectedOptions.map((({label:e})=>html`<span data-test="selected-option-label">
|
@@ -38,7 +38,7 @@ var __decorate=this&&this.__decorate||function(e,t,i,s){var l,o=arguments.length
|
|
38
38
|
${when(this.multiple&&this.selectedOptions.length>0,(()=>html`<ul
|
39
39
|
aria-describedby="tag-overflow-text"
|
40
40
|
class="tags"
|
41
|
-
${ref(this.#
|
41
|
+
${ref(this.#I)}
|
42
42
|
>
|
43
43
|
${repeat(this.selectedOptions,(({id:e})=>e),(({id:e,editable:t,label:i,value:s},l)=>html`<li
|
44
44
|
class=${classMap({"tag-container":!0,hidden:l>this.tagOverflowLimit-1})}
|
@@ -64,7 +64,8 @@ var __decorate=this&&this.__decorate||function(e,t,i,s){var l,o=arguments.length
|
|
64
64
|
>
|
65
65
|
<!--
|
66
66
|
Icons for the selected option or options.
|
67
|
-
Slot one icon per
|
67
|
+
Slot one icon per Dropdown Option.
|
68
|
+
\`<value>\` should be equal to the \`value\` of each Dropdown Option.
|
68
69
|
|
69
70
|
@name icon:value
|
70
71
|
@type {Element}
|
@@ -115,8 +116,8 @@ var __decorate=this&&this.__decorate||function(e,t,i,s){var l,o=arguments.length
|
|
115
116
|
?readonly=${this.readonly}
|
116
117
|
@blur=${this.#_}
|
117
118
|
@focus=${this.#L}
|
118
|
-
@input=${this.#
|
119
|
-
@keydown=${this.#
|
119
|
+
@input=${this.#G}
|
120
|
+
@keydown=${this.#B}
|
120
121
|
${onResize(this.#V.bind(this))}
|
121
122
|
${ref(this.#l)}
|
122
123
|
/>
|
@@ -228,10 +229,11 @@ var __decorate=this&&this.__decorate||function(e,t,i,s){var l,o=arguments.length
|
|
228
229
|
@focusin=${this.#W}
|
229
230
|
@mousedown=${this.#K}
|
230
231
|
@mouseover=${this.#J}
|
231
|
-
@private-
|
232
|
-
@private-
|
233
|
-
@private-
|
234
|
-
@private-
|
232
|
+
@private-disabled-change=${this.#Q}
|
233
|
+
@private-editable-change=${this.#X}
|
234
|
+
@private-label-change=${this.#Y}
|
235
|
+
@private-selected-change=${this.#Z}
|
236
|
+
@private-value-change=${this.#ee}
|
235
237
|
>
|
236
238
|
<glide-core-dropdown-option
|
237
239
|
class="select-all"
|
@@ -241,14 +243,14 @@ var __decorate=this&&this.__decorate||function(e,t,i,s){var l,o=arguments.length
|
|
241
243
|
private-multiple
|
242
244
|
?hidden=${!this.selectAll||!this.multiple||this.isFiltering}
|
243
245
|
?private-indeterminate=${this.isSomeSelected&&!this.isAllSelected}
|
244
|
-
${ref(this.#
|
246
|
+
${ref(this.#te)}
|
245
247
|
></glide-core-dropdown-option>
|
246
248
|
|
247
249
|
<slot
|
248
250
|
class="default-slot"
|
249
|
-
@slotchange=${this.#
|
251
|
+
@slotchange=${this.#ie}
|
250
252
|
${assertSlot([GlideCoreDropdownOption,Text])}
|
251
|
-
${ref(this.#
|
253
|
+
${ref(this.#se)}
|
252
254
|
>
|
253
255
|
<!--
|
254
256
|
@required
|
@@ -268,10 +270,10 @@ var __decorate=this&&this.__decorate||function(e,t,i,s){var l,o=arguments.length
|
|
268
270
|
class=${classMap({"add-button":!0,[this.size]:!0})}
|
269
271
|
data-test="add-button"
|
270
272
|
type="button"
|
271
|
-
@click=${this.#
|
272
|
-
@focusin=${this.#
|
273
|
-
@mouseover=${this.#
|
274
|
-
${ref(this.#
|
273
|
+
@click=${this.#le}
|
274
|
+
@focusin=${this.#oe}
|
275
|
+
@mouseover=${this.#ne}
|
276
|
+
${ref(this.#ae)}
|
275
277
|
>
|
276
278
|
${icons.plus} ${this.addButtonLabel}
|
277
279
|
</button>
|
@@ -295,7 +297,7 @@ var __decorate=this&&this.__decorate||function(e,t,i,s){var l,o=arguments.length
|
|
295
297
|
>`))}
|
296
298
|
</div>
|
297
299
|
</glide-core-private-label>
|
298
|
-
</div>`}reportValidity(){this.isReportValidityOrSubmit=!0;const e=this.#v.reportValidity();return this.requestUpdate(),e}resetValidityFeedback(){this.isReportValidityOrSubmit=!1}setCustomValidity(e){this.validityMessage=e,""===e?this.#v.setValidity({customError:!1},"",this.filterable||this.isFilterable?this.#l.value:this.#m.value):this.#v.setValidity({customError:!0,valueMissing:this.#v.validity.valueMissing}," ",this.filterable||this.isFilterable?this.#l.value:this.#m.value)}setValidity(e,t){this.validityMessage=t,this.#v.setValidity(e," ",this.filterable||this.isFilterable?this.#l.value:this.#m.value)}constructor(){super(),this.hideLabel=!1,this.name="",this.orientation="horizontal",this.readonly=!1,this.selectAll=!1,this.required=!1,this.version=packageJson.version,this.ariaActivedescendant="",this.inputValue="",this.isBlurring=!1,this.isCheckingValidity=!1,this.isCommunicateItemCountToScreenreaders=!1,this.isFilterable=!1,this.isFiltering=!1,this.isInputOverflow=!1,this.isInputTooltipOpen=!1,this.isInternalLabelOverflow=!1,this.isInternalLabelTooltipOpen=!1,this.isNoResults=!1,this.isReportValidityOrSubmit=!1,this.isShowSingleSelectIcon=!1,this.itemCount=0,this.tagOverflowLimit=0,this.#ne=createRef(),this.#y=createRef(),this.#ie=createRef(),this.#I=createRef(),this.#q=createRef(),this.#l=createRef(),this.#N=createRef(),this.#ae=!1,this.#e=!1,this.#re=!1,this.#s=!1,this.#r=!1,this.#n=!1,this.#pe=!1,this.#de=!1,this.#he=!1,this.#ce=!1,this.#u=!1,this.#M=new LocalizeController(this),this.#O=createRef(),this.#m=createRef(),this.#ee=createRef(),this.#d="large",this.#D=createRef(),this.#c=[],this.#f=()=>{this.#ae?setTimeout((()=>{this.#ae=!1})):this.open=!1},this.#b=({formData:e})=>{this.name&&this.value.length>0&&!this.disabled&&e.append(this.name,JSON.stringify(this.value))},this.#v=this.attachInternals(),this.addEventListener("invalid",(e=>{if(e?.preventDefault(),this.isCheckingValidity||this.isBlurring)return;this.isReportValidityOrSubmit=!0;this.form?.querySelector(":invalid")===this&&this.focus()}))}#ne;#ue;#y;#ie;#I;#q;#l;#N;#v;#ae;#e;#re;#s;#r;#n;#pe;#de;#he;#ce;#u;#M;#O;#ve;#m;#ee;#g;#d;#D;#c;#f;#b;#t(){this.#ue?.(),this.#O.value?.hidePopover(),this.ariaActivedescendant="",this.activeOption&&(this.#ve=this.activeOption,this.activeOption.privateIsTooltipOpen=!1,this.activeOption.privateActive=!1)}get#w(){return!this.disabled&&!this.validity.valid&&this.isReportValidityOrSubmit}#se(){this.open=!1,this.dispatchEvent(new Event("add",{bubbles:!0,composed:!0}))}#le(){this.activeOption&&(this.activeOption.privateIsTooltipOpen=!1,this.#ve=this.activeOption,this.activeOption.privateActive=!1)}#oe(){this.activeOption&&!this.#pe&&(this.#ve=this.activeOption,this.activeOption.privateActive=!1)}#E(){this.#ae=!0}async#te(){this.isFilterable=this.#a.length>10,this.tagOverflowLimit=this.selectedOptions.length;for(const e of this.#a)e.privateSize=this.size,e.privateMultiple=this.multiple;const e=this.#me?.find((e=>!e.disabled));!this.activeOption&&this.lastSelectedOption?(this.lastSelectedOption.privateActive=!0,this.#ve=this.lastSelectedOption,this.ariaActivedescendant=this.open?this.lastSelectedOption.id:""):!this.activeOption&&e&&(this.#ve=e,this.ariaActivedescendant=this.open?e.id:"",e.privateActive=!0),this.#ee.value&&(this.#ee.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(),await this.updateComplete,!this.multiple&&this.#l.value&&this.lastSelectedOption?.label?(this.#l.value.value=this.lastSelectedOption.label,this.inputValue=this.lastSelectedOption.label,this.isInputOverflow=this.#l.value.scrollWidth>this.#l.value.clientWidth):!this.multiple&&this.#l.value&&(this.#l.value.value="",this.inputValue="",this.isInputOverflow=this.#l.value.scrollWidth>this.#l.value.clientWidth)}#R(e){this.open&&this.#ve&&e.relatedTarget===this.#ne.value&&(this.#ve.privateActive=!0,this.#ve.privateIsTooltipOpen=!this.#ve.editable)}#A(e){(null===e.relatedTarget||e.relatedTarget instanceof Node&&!this.#g?.contains(e.relatedTarget)&&!this.contains(e.relatedTarget))&&!this.#re&&(this.open=!1,this.isBlurring=!0,this.reportValidity(),this.isBlurring=!1)}#C(e){if(this.disabled||this.readonly)return;if(("Enter"===e.key||" "===e.key)&&e.target===this.#q.value)return void(this.#ae=!0);if(!this.open&&"Enter"===e.key)return void this.form?.requestSubmit();if(this.open&&"ArrowUp"===e.key&&this.#g?.activeElement===this.#ne.value)return this.focus(),void(this.#ve&&(this.#ve.privateActive=!0,this.#ve.privateIsEditActive=this.#ve.editable,this.#ve.privateIsTooltipOpen=!this.#ve.privateIsEditActive));if(this.open&&"ArrowDown"===e.key&&this.#g?.activeElement===this.#ne.value)return void e.preventDefault();if(this.open&&"ArrowDown"===e.key&&this.addButtonLabel&&this.activeOption===this.#fe?.at(-1)&&(!this.activeOption?.editable||this.activeOption?.privateIsEditActive))return e.preventDefault(),this.activeOption&&(this.#ve=this.activeOption,this.activeOption.privateIsTooltipOpen=!1,this.activeOption.privateActive=!1),void this.#ne.value?.focus();if("Escape"===e.key)return e.preventDefault(),this.open=!1,void(this.#g?.activeElement===this.#ne.value&&this.focus());const t=e.target===this.#m.value||e.target===this.#l.value||e.target instanceof GlideCoreDropdownOption;if(!this.multiple||t){if(!this.open&&[" ","ArrowUp","ArrowDown"].includes(e.key))return e.preventDefault(),this.open=!0,void(this.activeOption&&(this.activeOption.privateIsTooltipOpen=!this.activeOption.privateIsEditActive));if(this.activeOption&&this.open){if("Enter"===e.key||" "===e.key){if(this.activeOption.privateIsEditActive)return this.activeOption.privateEdit(),void(this.open=!1);if("Enter"===e.key&&this.#fe&&this.#fe.length>0||" "===e.key&&!this.filterable&&!this.isFilterable)return this.#ce=!0,e.preventDefault(),this.isFiltering=!1,this.activeOption.selected=!this.multiple||!this.activeOption.selected,this.activeOption===this.#ee.value&&this.#ge(),this.#ce=!1,this.#o(),this.multiple||(this.open=!1),this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),void this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}const t=this.#me?.indexOf(this.activeOption);if("ArrowUp"===e.key&&!e.metaKey&&this.#me&&"number"==typeof t){e.preventDefault();const i=this.#me.findLast(((e,i)=>!e.disabled&&i<t));return void(this.activeOption?.privateIsEditActive?(this.activeOption.privateIsEditActive=!1,this.activeOption.privateIsTooltipOpen=!0):i&&0!==t&&(this.activeOption.privateIsEditActive=!1,this.activeOption.privateIsTooltipOpen=!1,this.activeOption.privateActive=!1,this.ariaActivedescendant=i.id,this.#ve=i,i.privateActive=!0,i.privateIsEditActive=i.editable,i.privateIsTooltipOpen=!i.editable,i.scrollIntoView({block:"center"})))}if("ArrowDown"===e.key&&!e.metaKey&&this.#me&&"number"==typeof t){e.preventDefault();const i=this.#me.find(((e,i)=>!e.disabled&&i>t));return void(this.activeOption.editable&&!this.activeOption.privateIsEditActive?(this.activeOption.privateIsEditActive=!0,this.activeOption.privateIsTooltipOpen=!1):i&&(this.activeOption.privateIsEditActive=!1,this.activeOption.privateIsTooltipOpen=!1,this.activeOption.privateActive=!1,this.ariaActivedescendant=i.id,this.#ve=i,i.privateActive=!0,i.privateIsTooltipOpen=!0,i.scrollIntoView({block:"center"})))}if(("ArrowUp"===e.key&&e.metaKey||"Home"===e.key||"PageUp"===e.key)&&this.#me){e.preventDefault();const t=[...this.#me].reverse().findLast((e=>!e.disabled));return void(t&&(this.activeOption.privateIsEditActive=!1,this.activeOption.privateIsTooltipOpen=!1,this.activeOption.privateActive=!1,this.ariaActivedescendant=t.id,this.#ve=t,t.privateActive=!0,t.privateIsTooltipOpen=!0,t.scrollIntoView({block:"nearest"})))}if(("ArrowDown"===e.key&&e.metaKey||"End"===e.key||"PageDown"===e.key)&&this.#me){e.preventDefault();const t=[...this.#me].findLast((e=>!e.disabled));return void(t&&this.activeOption&&(this.activeOption.privateIsEditActive=!1,this.activeOption.privateIsTooltipOpen=!1,this.activeOption.privateActive=!1,this.ariaActivedescendant=t.id,this.#ve=t,t.privateActive=!0,t.privateIsTooltipOpen=!0,t.scrollIntoView({block:"nearest"})))}}}}#S(e){if(this.disabled||this.readonly)return;if(this.#re)return void(this.#re=!1);if(e.target instanceof Node&&this.#q.value?.contains(e.target))return void this.selectedOptions[0]?.privateEdit();const t=this.filterable||this.isFilterable;if(this.#ce||!this.open||t&&!(e.target instanceof Element&&this.#m.value?.contains(e.target)))return 0!==e.detail?(this.open=!0,this.focus(),this.#pe=!0,void setTimeout((()=>{this.#pe=!1}))):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()}#j(){this.open=!1}#_(){this.isCommunicateItemCountToScreenreaders=!1,this.isInputTooltipOpen=!1}#L(){this.#l.value?.select(),this.isInputTooltipOpen=!0}async#B(e){let t;if(e.stopPropagation(),this.open=!0,this.isShowSingleSelectIcon=!1,this.#l.value?.value&&(this.inputValue=this.#l.value.value),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.#l.value)try{t=await this.filter(this.#l.value.value)}catch{}if(t){for(const e of this.#a)e.hidden=!t.includes(e);const e=this.#fe?.at(0);e&&this.activeOption?.hidden&&(this.activeOption.privateActive=!1,this.#ve=e,this.ariaActivedescendant=e.id,e.privateActive=!0),this.isNoResults=!this.#fe||0===this.#fe.length,this.isCommunicateItemCountToScreenreaders=!0,this.#fe&&(this.itemCount=this.#fe.length)}}#G(e){const t=this.selectedOptions.findLast(((e,t)=>t<=this.tagOverflowLimit-1));if(t&&"Backspace"===e.key&&!e.metaKey&&this.multiple&&this.#l.value&&0===this.#l.value.selectionStart)return this.#re=!0,t.selected=!1,void(this.#re=!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){this.#re=!0;for(const e of i)e.selected=!1;this.#re=!1}else;}#V(){this.#l.value&&(this.isInputOverflow=this.#l.value.scrollWidth-1>this.#l.value.clientWidth)}#z(){this.#N.value&&(this.isInternalLabelOverflow=this.#N.value.scrollWidth>this.#N.value.clientWidth)}get#a(){return this.#ie.value?.assignedElements().filter((e=>e instanceof GlideCoreDropdownOption))??[]}get#h(){const e=this.#ie.value?.assignedElements().filter((e=>e instanceof GlideCoreDropdownOption));if(e&&this.#ee.value)return[this.#ee.value,...e]}get#fe(){return this.#ie.value?.assignedElements().filter((e=>e instanceof GlideCoreDropdownOption&&!e.hidden))}get#me(){const e=this.#ie.value?.assignedElements().filter((e=>e instanceof GlideCoreDropdownOption&&!e.hidden));return this.#ee.value&&!this.#ee.value.hidden&&e?[this.#ee.value,...e]:e}#U(e){e.target instanceof GlideCoreDropdownOption&&(e.target.selected=!e.target.selected),e.target===this.#ee.value&&this.#ge(),this.#o()}#P(e){if(e.target instanceof Element){const t=e.target.closest("glide-core-dropdown-option");if(t instanceof GlideCoreDropdownOption&&t.disabled)return;if(t instanceof GlideCoreDropdownOption&&t.privateIsEditActive)return t.privateEdit(),void(this.open=!1);if(t&&!t.selected)return t.selected=!0,this.#o(),this.multiple||(this.open=!1),this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),void this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}));if(t?.selected&&!this.multiple)return void(this.open=!1)}}#Q(){this.requestUpdate()}#W(e){e.target instanceof GlideCoreDropdownOption&&(this.activeOption&&(this.activeOption.privateActive=!1),e.target.privateActive=!0,this.#ve=e.target)}#X(){this.selectedOptions.length>0&&(this.multiple?(this.requestUpdate(),this.updateComplete.then((()=>{this.#p()}))):(this.filterable||this.isFilterable)&&this.#l.value&&this.selectedOptions[0]?.label?(this.#l.value.value=this.selectedOptions[0].label,this.inputValue=this.selectedOptions[0].label,this.isInputOverflow=this.#l.value.scrollWidth>this.#l.value.clientWidth):this.requestUpdate())}#K(e){(this.filterable||this.isFilterable)&&e.preventDefault()}#J(e){if(e.target instanceof GlideCoreDropdownOption&&this.#me){if(e.target.disabled)return;this.activeOption&&(this.activeOption.privateIsTooltipOpen=!1,this.activeOption.privateActive=!1),this.ariaActivedescendant=e.target.id,this.#ve=e.target,e.target.privateActive=!0,e.target.privateIsEditActive=!1,this.#g?.activeElement===this.#ne.value&&this.focus()}}#Y(e){if(!this.multiple)for(const t of this.#a)t!==e.target&&e.target instanceof GlideCoreDropdownOption&&e.target.selected&&t.selected&&e.target!==this.#ee.value&&(t.selected=!1);e.target!==this.#ee.value&&!this.#he&&this.#ee.value&&(this.#ee.value.selected=this.isAllSelected),this.isShowSingleSelectIcon=!this.multiple&&Boolean(this.selectedOptions.at(0)?.value),e.target instanceof GlideCoreDropdownOption&&(this.multiple&&!this.#u?(this.#c=e.target.selected&&e.target.value&&!e.target.disabled?[...this.value,e.target.value]:this.value.filter((t=>e.target instanceof GlideCoreDropdownOption&&t!==e.target.value)),this.#l.value&&!this.#re&&(this.isFiltering=!1,this.#l.value.value="",this.inputValue="")):this.multiple||!e.target.selected||e.target.disabled||(this.#c=e.target.value?[e.target.value]:[],this.#l.value&&e.target.label&&(this.isFiltering=!1,this.#l.value.value=e.target.label,this.inputValue=e.target.label))),this.#l.value&&(this.isInputOverflow=this.#l.value.scrollWidth>this.#l.value.clientWidth),this.requestUpdate(),this.updateComplete.then((()=>{this.#p()}))}#Z(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]:[])}#x(){this.isInternalLabelTooltipOpen=!0}#H(){this.isInternalLabelTooltipOpen=!1}#k(){this.#re=!0,this.open=!1}async#F(e){this.#re=!0;for(const t of this.#a)t.id===e&&(t.selected=!1,this.#c=this.value.filter((e=>e!==t.value)));const t=this.#D.value?.querySelectorAll("glide-core-tag");if(t&&this.selectedOptions.length>0){const i=[...t].findIndex((t=>t.dataset.id===e)),s=t[i<t.length-1?i+1:i-1];await this.updateComplete,setTimeout((()=>{s?.focus(),this.#re=!1}))}else setTimeout((()=>{this.focus(),this.#re=!1}));this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}#T(e){e.stopPropagation()}#ge(){this.#he=!0;for(const e of this.#a)!this.#ee.value?.selected||e.selected||e.disabled?!this.#ee.value?.selected&&e.selected&&(e.selected=!1):e.selected=!0;this.#he=!1}async#p(){if(this.#y.value){const e=this.#y.value.scrollWidth>this.#y.value.clientWidth;e&&this.tagOverflowLimit>1?(this.tagOverflowLimit=this.tagOverflowLimit-1,await this.updateComplete,this.#p()):!e&&!this.#de&&this.tagOverflowLimit<this.selectedOptions.length?(this.tagOverflowLimit=this.tagOverflowLimit+1,this.#de=!0,await this.updateComplete,this.#p()):this.#de=!1}}#i(){this.#a.length>0&&(this.#ue?.(),this.#ve&&(this.#ve.privateActive=!0,this.ariaActivedescendant=this.#ve.id),this.#I.value&&this.#O.value&&(this.#ue=autoUpdate(this.#I.value,this.#O.value,(()=>{(async()=>{if(this.#I.value&&this.#O.value){const{x:e,y:t,placement:i}=await computePosition(this.#I.value,this.#O.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.#O.value.dataset.placement=i,Object.assign(this.#O.value.style,{left:`${e}px`,top:`${t}px`}),this.#O.value?.showPopover()}})()}))))}#o(){if((this.filterable||this.isFilterable)&&this.#l.value){this.isFiltering=!1;for(const e of this.#a)e.hidden=!1}}};__decorate([property({attribute:"add-button-label",reflect:!0})],GlideCoreDropdown.prototype,"addButtonLabel",void 0),__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}),required],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,type:Boolean})],GlideCoreDropdown.prototype,"required",void 0),__decorate([property({reflect:!0,type:Boolean})],GlideCoreDropdown.prototype,"multiple",null),__decorate([property({reflect:!0})],GlideCoreDropdown.prototype,"size",null),__decorate([property({reflect:!0})],GlideCoreDropdown.prototype,"tooltip",void 0),__decorate([property({type:Array})],GlideCoreDropdown.prototype,"value",null),__decorate([property({reflect:!0})],GlideCoreDropdown.prototype,"variant",void 0),__decorate([property({reflect:!0})],GlideCoreDropdown.prototype,"version",void 0),__decorate([state()],GlideCoreDropdown.prototype,"ariaActivedescendant",void 0),__decorate([state()],GlideCoreDropdown.prototype,"inputValue",void 0),__decorate([state()],GlideCoreDropdown.prototype,"isBlurring",void 0),__decorate([state()],GlideCoreDropdown.prototype,"isCheckingValidity",void 0),__decorate([state()],GlideCoreDropdown.prototype,"isCommunicateItemCountToScreenreaders",void 0),__decorate([state()],GlideCoreDropdown.prototype,"isFilterable",void 0),__decorate([state()],GlideCoreDropdown.prototype,"isFiltering",void 0),__decorate([state()],GlideCoreDropdown.prototype,"isInputOverflow",void 0),__decorate([state()],GlideCoreDropdown.prototype,"isInputTooltipOpen",void 0),__decorate([state()],GlideCoreDropdown.prototype,"isInternalLabelOverflow",void 0),__decorate([state()],GlideCoreDropdown.prototype,"isInternalLabelTooltipOpen",void 0),__decorate([state()],GlideCoreDropdown.prototype,"isNoResults",void 0),__decorate([state()],GlideCoreDropdown.prototype,"isReportValidityOrSubmit",void 0),__decorate([state()],GlideCoreDropdown.prototype,"isShowSingleSelectIcon",void 0),__decorate([state()],GlideCoreDropdown.prototype,"itemCount",void 0),__decorate([state()],GlideCoreDropdown.prototype,"tagOverflowLimit",void 0),__decorate([state()],GlideCoreDropdown.prototype,"validityMessage",void 0),GlideCoreDropdown=__decorate([customElement("glide-core-dropdown"),final],GlideCoreDropdown);export default GlideCoreDropdown;const icons={plus:html`
|
300
|
+
</div>`}reportValidity(){this.isReportValidityOrSubmit=!0;const e=this.#v.reportValidity();return this.requestUpdate(),e}resetValidityFeedback(){this.isReportValidityOrSubmit=!1}setCustomValidity(e){this.validityMessage=e,""===e?this.#v.setValidity({customError:!1},"",this.filterable||this.isFilterable?this.#l.value:this.#m.value):this.#v.setValidity({customError:!0,valueMissing:this.#v.validity.valueMissing}," ",this.filterable||this.isFilterable?this.#l.value:this.#m.value)}setValidity(e,t){this.validityMessage=t,this.#v.setValidity(e," ",this.filterable||this.isFilterable?this.#l.value:this.#m.value)}constructor(){super(),this.hideLabel=!1,this.name="",this.orientation="horizontal",this.readonly=!1,this.selectAll=!1,this.required=!1,this.version=packageJson.version,this.ariaActivedescendant="",this.inputValue="",this.isBlurring=!1,this.isCheckingValidity=!1,this.isCommunicateItemCountToScreenreaders=!1,this.isFilterable=!1,this.isFiltering=!1,this.isInputOverflow=!1,this.isInputTooltipOpen=!1,this.isInternalLabelOverflow=!1,this.isInternalLabelTooltipOpen=!1,this.isNoResults=!1,this.isReportValidityOrSubmit=!1,this.isShowSingleSelectIcon=!1,this.itemCount=0,this.tagOverflowLimit=0,this.#ae=createRef(),this.#y=createRef(),this.#se=createRef(),this.#D=createRef(),this.#q=createRef(),this.#l=createRef(),this.#N=createRef(),this.#re=!1,this.#e=!1,this.#pe=!1,this.#s=!1,this.#r=!1,this.#n=!1,this.#de=!1,this.#he=!1,this.#ce=!1,this.#ue=!1,this.#u=!1,this.#M=new LocalizeController(this),this.#O=createRef(),this.#m=createRef(),this.#te=createRef(),this.#d="large",this.#I=createRef(),this.#c=[],this.#f=()=>{this.#re?setTimeout((()=>{this.#re=!1})):this.open=!1},this.#b=({formData:e})=>{this.name&&this.value.length>0&&!this.disabled&&e.append(this.name,JSON.stringify(this.value))},this.#v=this.attachInternals(),this.addEventListener("invalid",(e=>{if(e?.preventDefault(),this.isCheckingValidity||this.isBlurring)return;this.isReportValidityOrSubmit=!0;this.form?.querySelector(":invalid")===this&&this.focus()}))}#ae;#ve;#y;#se;#D;#q;#l;#N;#v;#re;#e;#pe;#s;#r;#n;#de;#he;#ce;#ue;#u;#M;#O;#me;#m;#te;#g;#d;#I;#c;#f;#b;#t(){this.#ve?.(),this.#O.value?.hidePopover(),this.ariaActivedescendant="",this.activeOption&&(this.#me=this.activeOption,this.activeOption.privateIsTooltipOpen=!1,this.activeOption.privateActive=!1)}get#w(){return!this.disabled&&!this.validity.valid&&this.isReportValidityOrSubmit}#le(){this.open=!1,this.dispatchEvent(new Event("add",{bubbles:!0,composed:!0}))}#oe(){this.activeOption&&(this.activeOption.privateIsTooltipOpen=!1,this.#me=this.activeOption,this.activeOption.privateActive=!1)}#ne(){this.activeOption&&!this.#de&&(this.#me=this.activeOption,this.activeOption.privateActive=!1)}#E(){this.#re=!0}async#ie(){this.isFilterable=this.#a.length>10,this.tagOverflowLimit=this.selectedOptions.length;for(const e of this.#a)e.privateSize=this.size,e.privateMultiple=this.multiple;const e=this.#fe?.find((e=>!e.disabled));!this.activeOption&&this.lastSelectedOption?(this.lastSelectedOption.privateActive=!0,this.#me=this.lastSelectedOption,this.ariaActivedescendant=this.open?this.lastSelectedOption.id:""):!this.activeOption&&e&&(this.#me=e,this.ariaActivedescendant=this.open?e.id:"",e.privateActive=!0),this.#te.value&&(this.#te.value.selected=this.isAllSelected),this.multiple?this.#c=this.selectedOptions.filter((e=>Boolean(e.value)&&!e.disabled)).map((({value:e})=>e)):this.lastSelectedOption?.value&&!this.lastSelectedOption.disabled&&(this.#c=[this.lastSelectedOption.value]),this.requestUpdate(),await this.updateComplete,!this.multiple&&this.#l.value&&this.lastSelectedOption?.label?(this.#l.value.value=this.lastSelectedOption.label,this.inputValue=this.lastSelectedOption.label,this.isInputOverflow=this.#l.value.scrollWidth>this.#l.value.clientWidth):!this.multiple&&this.#l.value&&(this.#l.value.value="",this.inputValue="",this.isInputOverflow=this.#l.value.scrollWidth>this.#l.value.clientWidth)}#R(e){this.open&&this.#me&&e.relatedTarget===this.#ae.value&&(this.#me.privateActive=!0,this.#me.privateIsTooltipOpen=!this.#me.editable)}#A(e){(null===e.relatedTarget||e.relatedTarget instanceof Node&&!this.#g?.contains(e.relatedTarget)&&!this.contains(e.relatedTarget))&&!this.#pe&&(this.open=!1,this.isBlurring=!0,this.reportValidity(),this.isBlurring=!1)}#C(e){if(this.disabled||this.readonly)return;if(("Enter"===e.key||" "===e.key)&&e.target===this.#q.value)return void(this.#re=!0);if(!this.open&&"Enter"===e.key)return void this.form?.requestSubmit();if(this.open&&"ArrowUp"===e.key&&this.#g?.activeElement===this.#ae.value)return this.focus(),void(this.#me&&(this.#me.privateActive=!0,this.#me.privateIsEditActive=this.#me.editable,this.#me.privateIsTooltipOpen=!this.#me.privateIsEditActive));if(this.open&&"ArrowDown"===e.key&&this.#g?.activeElement===this.#ae.value)return void e.preventDefault();if(this.open&&"ArrowDown"===e.key&&this.addButtonLabel&&this.activeOption===this.#ge?.at(-1)&&(!this.activeOption?.editable||this.activeOption?.privateIsEditActive))return e.preventDefault(),this.activeOption&&(this.#me=this.activeOption,this.activeOption.privateIsTooltipOpen=!1,this.activeOption.privateActive=!1),void this.#ae.value?.focus();if("Escape"===e.key)return e.preventDefault(),this.open=!1,void(this.#g?.activeElement===this.#ae.value&&this.focus());const t=e.target===this.#m.value||e.target===this.#l.value||e.target instanceof GlideCoreDropdownOption;if(!this.multiple||t){if(!this.open&&[" ","ArrowUp","ArrowDown"].includes(e.key))return e.preventDefault(),this.open=!0,void(this.activeOption&&(this.activeOption.privateIsTooltipOpen=!this.activeOption.privateIsEditActive));if(this.activeOption&&this.open){if("Enter"===e.key||" "===e.key){if(this.activeOption.privateIsEditActive)return this.activeOption.privateEdit(),void(this.open=!1);if("Enter"===e.key&&this.#ge&&this.#ge.length>0||" "===e.key&&!this.filterable&&!this.isFilterable)return this.#ue=!0,e.preventDefault(),this.isFiltering=!1,this.activeOption.selected=!this.multiple||!this.activeOption.selected,this.activeOption===this.#te.value&&this.#be(),this.#ue=!1,this.#o(),this.multiple||(this.open=!1),this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),void this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}const t=this.#fe?.indexOf(this.activeOption);if("ArrowUp"===e.key&&!e.metaKey&&this.#fe&&"number"==typeof t){e.preventDefault();const i=this.#fe.findLast(((e,i)=>!e.disabled&&i<t));return void(this.activeOption?.privateIsEditActive?(this.activeOption.privateIsEditActive=!1,this.activeOption.privateIsTooltipOpen=!0):i&&0!==t&&(this.activeOption.privateIsEditActive=!1,this.activeOption.privateIsTooltipOpen=!1,this.activeOption.privateActive=!1,this.ariaActivedescendant=i.id,this.#me=i,i.privateActive=!0,i.privateIsEditActive=i.editable,i.privateIsTooltipOpen=!i.editable,i.scrollIntoView({block:"center"})))}if("ArrowDown"===e.key&&!e.metaKey&&this.#fe&&"number"==typeof t){e.preventDefault();const i=this.#fe.find(((e,i)=>!e.disabled&&i>t));return void(this.activeOption.editable&&!this.activeOption.privateIsEditActive?(this.activeOption.privateIsEditActive=!0,this.activeOption.privateIsTooltipOpen=!1):i&&(this.activeOption.privateIsEditActive=!1,this.activeOption.privateIsTooltipOpen=!1,this.activeOption.privateActive=!1,this.ariaActivedescendant=i.id,this.#me=i,i.privateActive=!0,i.privateIsTooltipOpen=!0,i.scrollIntoView({block:"center"})))}if(("ArrowUp"===e.key&&e.metaKey||"Home"===e.key||"PageUp"===e.key)&&this.#fe){e.preventDefault();const t=[...this.#fe].reverse().findLast((e=>!e.disabled));return void(t&&(this.activeOption.privateIsEditActive=!1,this.activeOption.privateIsTooltipOpen=!1,this.activeOption.privateActive=!1,this.ariaActivedescendant=t.id,this.#me=t,t.privateActive=!0,t.privateIsTooltipOpen=!0,t.scrollIntoView({block:"nearest"})))}if(("ArrowDown"===e.key&&e.metaKey||"End"===e.key||"PageDown"===e.key)&&this.#fe){e.preventDefault();const t=[...this.#fe].findLast((e=>!e.disabled));return void(t&&this.activeOption&&(this.activeOption.privateIsEditActive=!1,this.activeOption.privateIsTooltipOpen=!1,this.activeOption.privateActive=!1,this.ariaActivedescendant=t.id,this.#me=t,t.privateActive=!0,t.privateIsTooltipOpen=!0,t.scrollIntoView({block:"nearest"})))}}}}#S(e){if(this.disabled||this.readonly)return;if(this.#pe)return void(this.#pe=!1);if(e.target instanceof Node&&this.#q.value?.contains(e.target))return void this.selectedOptions[0]?.privateEdit();const t=this.filterable||this.isFilterable;if(this.#ue||!this.open||t&&!(e.target instanceof Element&&this.#m.value?.contains(e.target)))return 0!==e.detail?(this.open=!0,this.focus(),this.#de=!0,void setTimeout((()=>{this.#de=!1}))):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()}#j(){this.open=!1}#_(){this.isCommunicateItemCountToScreenreaders=!1,this.isInputTooltipOpen=!1}#L(){this.#l.value?.select(),this.isInputTooltipOpen=!0}async#G(e){let t;if(e.stopPropagation(),this.open=!0,this.isShowSingleSelectIcon=!1,this.#l.value?.value&&(this.inputValue=this.#l.value.value),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.#l.value)try{t=await this.filter(this.#l.value.value)}catch{}if(t){for(const e of this.#a)e.hidden=!t.includes(e);const e=this.#ge?.at(0);e&&this.activeOption?.hidden&&(this.activeOption.privateActive=!1,this.#me=e,this.ariaActivedescendant=e.id,e.privateActive=!0),this.isNoResults=!this.#ge||0===this.#ge.length,this.isCommunicateItemCountToScreenreaders=!0,this.#ge&&(this.itemCount=this.#ge.length)}}#B(e){const t=this.selectedOptions.findLast(((e,t)=>t<=this.tagOverflowLimit-1));if(t&&"Backspace"===e.key&&!e.metaKey&&this.multiple&&this.#l.value&&0===this.#l.value.selectionStart)return this.#pe=!0,t.selected=!1,void(this.#pe=!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){this.#pe=!0;for(const e of i)e.selected=!1;this.#pe=!1}else;}#V(){this.#l.value&&(this.isInputOverflow=this.#l.value.scrollWidth-1>this.#l.value.clientWidth)}#z(){this.#N.value&&(this.isInternalLabelOverflow=this.#N.value.scrollWidth>this.#N.value.clientWidth)}get#a(){return this.#se.value?.assignedElements().filter((e=>e instanceof GlideCoreDropdownOption))??[]}get#h(){const e=this.#se.value?.assignedElements().filter((e=>e instanceof GlideCoreDropdownOption));if(e&&this.#te.value)return[this.#te.value,...e]}get#ge(){return this.#se.value?.assignedElements().filter((e=>e instanceof GlideCoreDropdownOption&&!e.hidden))}get#fe(){const e=this.#se.value?.assignedElements().filter((e=>e instanceof GlideCoreDropdownOption&&!e.hidden));return this.#te.value&&!this.#te.value.hidden&&e?[this.#te.value,...e]:e}#U(e){e.target instanceof GlideCoreDropdownOption&&(e.target.selected=!e.target.selected),e.target===this.#te.value&&this.#be(),this.#o()}#P(e){if(e.target instanceof Element){const t=e.target.closest("glide-core-dropdown-option");if(t instanceof GlideCoreDropdownOption&&t.disabled)return;if(t instanceof GlideCoreDropdownOption&&t.privateIsEditActive)return t.privateEdit(),void(this.open=!1);if(t&&!t.selected)return t.selected=!0,this.#o(),this.multiple||(this.open=!1),this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),void this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}));if(t?.selected&&!this.multiple)return void(this.open=!1)}}#Q(e){if(e.target instanceof GlideCoreDropdownOption&&e.target.disabled&&e.target.selected){const t=this.#c.lastIndexOf(e.target.value);this.#c.splice(t,t+1)}else this.multiple&&e.target instanceof GlideCoreDropdownOption&&e.target.selected&&e.target.value?this.#c.push(e.target.value):e.target instanceof GlideCoreDropdownOption&&e.target.selected&&e.target.value&&e.target===this.lastSelectedOption&&(this.#c=[e.target.value]);this.requestUpdate()}#X(){this.requestUpdate()}#W(e){e.target instanceof GlideCoreDropdownOption&&(this.activeOption&&(this.activeOption.privateActive=!1),e.target.privateActive=!0,this.#me=e.target)}#Y(){this.selectedOptions.length>0&&(this.multiple?(this.requestUpdate(),this.updateComplete.then((()=>{this.#p()}))):(this.filterable||this.isFilterable)&&this.#l.value&&this.selectedOptions[0]?.label?(this.#l.value.value=this.selectedOptions[0].label,this.inputValue=this.selectedOptions[0].label,this.isInputOverflow=this.#l.value.scrollWidth>this.#l.value.clientWidth):this.requestUpdate())}#K(e){(this.filterable||this.isFilterable)&&e.preventDefault()}#J(e){if(e.target instanceof GlideCoreDropdownOption&&this.#fe){if(e.target.disabled)return;this.activeOption&&(this.activeOption.privateIsTooltipOpen=!1,this.activeOption.privateActive=!1),this.ariaActivedescendant=e.target.id,this.#me=e.target,e.target.privateActive=!0,e.target.privateIsEditActive=!1,this.#g?.activeElement===this.#ae.value&&this.focus()}}#Z(e){if(!this.multiple)for(const t of this.#a)t!==e.target&&e.target instanceof GlideCoreDropdownOption&&e.target.selected&&t.selected&&e.target!==this.#te.value&&(t.selected=!1);e.target!==this.#te.value&&!this.#ce&&this.#te.value&&(this.#te.value.selected=this.isAllSelected),this.isShowSingleSelectIcon=!this.multiple&&Boolean(this.selectedOptions.at(0)?.value),e.target instanceof GlideCoreDropdownOption&&(this.multiple&&!this.#u?(this.#c=e.target.selected&&e.target.value&&!e.target.disabled?[...this.value,e.target.value]:this.value.filter((t=>e.target instanceof GlideCoreDropdownOption&&t!==e.target.value)),this.#l.value&&!this.#pe&&(this.isFiltering=!1,this.#l.value.value="",this.inputValue="")):this.multiple||!e.target.selected||e.target.disabled||(this.#c=e.target.value?[e.target.value]:[],this.#l.value&&e.target.label&&(this.isFiltering=!1,this.#l.value.value=e.target.label,this.inputValue=e.target.label))),this.#l.value&&(this.isInputOverflow=this.#l.value.scrollWidth>this.#l.value.clientWidth),this.requestUpdate(),this.updateComplete.then((()=>{this.#p()}))}#ee(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]:[])}#x(){this.isInternalLabelTooltipOpen=!0}#H(){this.isInternalLabelTooltipOpen=!1}#k(){this.#pe=!0,this.open=!1}async#F(e){this.#pe=!0;for(const t of this.#a)t.id===e&&(t.selected=!1,this.#c=this.value.filter((e=>e!==t.value)));const t=this.#I.value?.querySelectorAll("glide-core-tag");if(t&&this.selectedOptions.length>0){const i=[...t].findIndex((t=>t.dataset.id===e)),s=t[i<t.length-1?i+1:i-1];await this.updateComplete,setTimeout((()=>{s?.focus(),this.#pe=!1}))}else setTimeout((()=>{this.focus(),this.#pe=!1}));this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}#T(e){e.stopPropagation()}#be(){this.#ce=!0;for(const e of this.#a)!this.#te.value?.selected||e.selected||e.disabled?!this.#te.value?.selected&&e.selected&&(e.selected=!1):e.selected=!0;this.#ce=!1}async#p(){if(this.#y.value){const e=this.#y.value.scrollWidth>this.#y.value.clientWidth;e&&this.tagOverflowLimit>1?(this.tagOverflowLimit=this.tagOverflowLimit-1,await this.updateComplete,this.#p()):!e&&!this.#he&&this.tagOverflowLimit<this.selectedOptions.length?(this.tagOverflowLimit=this.tagOverflowLimit+1,this.#he=!0,await this.updateComplete,this.#p()):this.#he=!1}}#i(){this.#a.length>0&&(this.#ve?.(),this.#me&&(this.#me.privateActive=!0,this.ariaActivedescendant=this.#me.id),this.#D.value&&this.#O.value&&(this.#ve=autoUpdate(this.#D.value,this.#O.value,(()=>{(async()=>{if(this.#D.value&&this.#O.value){const{x:e,y:t,placement:i}=await computePosition(this.#D.value,this.#O.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.#O.value.dataset.placement=i,Object.assign(this.#O.value.style,{left:`${e}px`,top:`${t}px`}),this.#O.value?.showPopover()}})()}))))}#o(){if((this.filterable||this.isFilterable)&&this.#l.value){this.isFiltering=!1;for(const e of this.#a)e.hidden=!1}}};__decorate([property({attribute:"add-button-label",reflect:!0})],GlideCoreDropdown.prototype,"addButtonLabel",void 0),__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}),required],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,type:Boolean})],GlideCoreDropdown.prototype,"required",void 0),__decorate([property({reflect:!0,type:Boolean})],GlideCoreDropdown.prototype,"multiple",null),__decorate([property({reflect:!0})],GlideCoreDropdown.prototype,"size",null),__decorate([property({reflect:!0})],GlideCoreDropdown.prototype,"tooltip",void 0),__decorate([property({type:Array})],GlideCoreDropdown.prototype,"value",null),__decorate([property({reflect:!0})],GlideCoreDropdown.prototype,"variant",void 0),__decorate([property({reflect:!0})],GlideCoreDropdown.prototype,"version",void 0),__decorate([state()],GlideCoreDropdown.prototype,"ariaActivedescendant",void 0),__decorate([state()],GlideCoreDropdown.prototype,"inputValue",void 0),__decorate([state()],GlideCoreDropdown.prototype,"isBlurring",void 0),__decorate([state()],GlideCoreDropdown.prototype,"isCheckingValidity",void 0),__decorate([state()],GlideCoreDropdown.prototype,"isCommunicateItemCountToScreenreaders",void 0),__decorate([state()],GlideCoreDropdown.prototype,"isFilterable",void 0),__decorate([state()],GlideCoreDropdown.prototype,"isFiltering",void 0),__decorate([state()],GlideCoreDropdown.prototype,"isInputOverflow",void 0),__decorate([state()],GlideCoreDropdown.prototype,"isInputTooltipOpen",void 0),__decorate([state()],GlideCoreDropdown.prototype,"isInternalLabelOverflow",void 0),__decorate([state()],GlideCoreDropdown.prototype,"isInternalLabelTooltipOpen",void 0),__decorate([state()],GlideCoreDropdown.prototype,"isNoResults",void 0),__decorate([state()],GlideCoreDropdown.prototype,"isReportValidityOrSubmit",void 0),__decorate([state()],GlideCoreDropdown.prototype,"isShowSingleSelectIcon",void 0),__decorate([state()],GlideCoreDropdown.prototype,"itemCount",void 0),__decorate([state()],GlideCoreDropdown.prototype,"tagOverflowLimit",void 0),__decorate([state()],GlideCoreDropdown.prototype,"validityMessage",void 0),GlideCoreDropdown=__decorate([customElement("glide-core-dropdown"),final],GlideCoreDropdown);export default GlideCoreDropdown;const icons={plus:html`
|
299
301
|
<svg
|
300
302
|
aria-hidden="true"
|
301
303
|
viewBox="0 0 16 16"
|
package/dist/dropdown.option.js
CHANGED
@@ -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{html,LitElement}from"lit";import{ifDefined}from"lit/directives/if-defined.js";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 packageJson from"../package.json"with{type:"json"};import checkedIcon from"./icons/checked.js";import pencilIcon from"./icons/pencil.js";import styles from"./dropdown.option.styles.js";import shadowRootMode from"./library/shadow-root-mode.js";import final from"./library/final.js";import required from"./library/required.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.privateIsTooltipOpen=!1,this.version=packageJson.version,this.isLabelOverflow=!1,this.#e=createRef(),this.#t=createRef(),this.#i=nanoid(),this.#o=!1,this.#l=!1,this.#s=createRef(),this.#r=!1,this.#a=""}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:shadowRootMode}}static{this.styles=styles}get disabled(){return this.#o}set disabled(e){this.role=e?"none":"option",this.#o=e}get editable(){return this.#l}set editable(e){this.#l=e,this.dispatchEvent(new Event("private-editable-change",{bubbles:!0}))}get label(){return this.#n}set label(e){this.#n=e,setTimeout((()=>{this.#
|
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{html,LitElement}from"lit";import{ifDefined}from"lit/directives/if-defined.js";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 packageJson from"../package.json"with{type:"json"};import checkedIcon from"./icons/checked.js";import pencilIcon from"./icons/pencil.js";import styles from"./dropdown.option.styles.js";import shadowRootMode from"./library/shadow-root-mode.js";import final from"./library/final.js";import required from"./library/required.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.privateIsTooltipOpen=!1,this.version=packageJson.version,this.isLabelOverflow=!1,this.#e=createRef(),this.#t=createRef(),this.#i=nanoid(),this.#o=!1,this.#l=!1,this.#s=createRef(),this.#r=!1,this.#a=""}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:shadowRootMode}}static{this.styles=styles}get disabled(){return this.#o}set disabled(e){this.role=e?"none":"option",this.#o=e,this.#e.value?.checked&&e?this.#e.value.checked=!1:this.#e.value&&this.selected&&!e&&(this.#e.value.checked=!0),this.ariaSelected=!e&&this.selected?"true":"false",this.dispatchEvent(new Event("private-disabled-change",{bubbles:!0}))}get editable(){return this.#l}set editable(e){this.#l=e,this.dispatchEvent(new Event("private-editable-change",{bubbles:!0}))}get label(){return this.#n}set label(e){this.#n=e,setTimeout((()=>{this.#d()})),this.dispatchEvent(new Event("private-label-change",{bubbles:!0}))}get selected(){return this.#r}set selected(e){this.#r=e,this.ariaSelected=!this.disabled&&e?"true":"false",this.isMultiple&&this.#e.value&&(this.#e.value.checked=e),this.dispatchEvent(new Event("private-selected-change",{bubbles:!0}))}get isMultiple(){return this.privateMultiple||this.closest("glide-core-dropdown")?.multiple}get lastSelectedOption(){const e=this.parentElement?.querySelectorAll("glide-core-dropdown-option");if(e&&e.length>0)return[...e].findLast((e=>e.selected))}click(){this.privateMultiple?this.#e.value?.click():this.#t.value?.click()}connectedCallback(){super.connectedCallback(),this.id=this.#i,this.ariaSelected=!this.disabled&&this.selected?"true":"false",this.role=this.disabled?"none":"option",this.tabIndex=-1,this.#p=new IntersectionObserver((()=>{this.checkVisibility()&&this.#d()})),this.#p.observe(this)}disconnectedCallback(){super.disconnectedCallback(),this.#p?.disconnect()}firstUpdated(){this.#e.value&&(this.#e.value.checked=this.selected&&!this.disabled)}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}privateEdit(){this.dispatchEvent(new Event("edit",{bubbles:!0,composed:!0}))}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,disabled:this.disabled,[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}" @click="${this.#c}" private-internally-inert ?disabled="${this.disabled}" ?indeterminate="${this.privateIndeterminate}" ?private-show-label-tooltip="${this.privateIsTooltipOpen}" ?private-disable-label-tooltip="${this.disabled}" ${ref(this.#e)}><slot class="${classMap({"checkbox-icon-slot":!0,[this.privateSize]:!0})}" name="icon" slot="private-icon"></slot></glide-core-checkbox>${when(this.editable,(()=>html`<button class="${classMap({"edit-button":!0,active:this.privateIsEditActive,disabled:this.disabled,multiple:Boolean(this.isMultiple),[this.privateSize]:!0})}" data-test="edit-button" type="button" @mouseover="${this.#h}" @mouseout="${this.#b}">${pencilIcon}</button>`))}`),(()=>html`<div class="${classMap({option:!0,disabled:this.disabled,editable:this.editable,[this.privateSize]:!0})}"><slot class="${classMap({"icon-slot":!0,[this.privateSize]:!0})}" name="icon"></slot><glide-core-tooltip class="tooltip" data-test="tooltip" label="${ifDefined(this.label)}" offset="${10}" ?disabled="${!this.isLabelOverflow||this.disabled}" ?open="${this.privateIsTooltipOpen}" screenreader-hidden @toggle="${this.#v}"><div class="label" data-test="label" slot="target" ${ref(this.#s)}>${this.label}</div></glide-core-tooltip>${when(this.selected&&this===this.lastSelectedOption&&!this.disabled,(()=>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.privateActive&&this.privateIsEditActive,disabled:this.disabled,[this.privateSize]:!0})}" data-test="edit-button" type="button" @mouseover="${this.#h}" @mouseout="${this.#b}">${pencilIcon}</button>`))}</div>`))}</div>`}#e;#t;#i;#p;#o;#l;#n;#s;#r;#a;#c(e){e.stopPropagation()}#b(){this.privateIsEditActive=!1}#h(){this.privateIsEditActive=!0}#v(e){e.stopPropagation()}#d(){this.#s.value&&(this.isLabelOverflow=this.#s.value.scrollWidth>this.#s.value.clientWidth)}};__decorate([property({reflect:!0,type:Boolean})],GlideCoreDropdownOption.prototype,"disabled",null),__decorate([property({reflect:!0,type:Boolean})],GlideCoreDropdownOption.prototype,"editable",null),__decorate([property({reflect:!0}),required],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([property({type:Boolean})],GlideCoreDropdownOption.prototype,"privateActive",void 0),__decorate([property({type:Boolean})],GlideCoreDropdownOption.prototype,"privateIsTooltipOpen",void 0),__decorate([property({reflect:!0})],GlideCoreDropdownOption.prototype,"version",void 0),__decorate([state()],GlideCoreDropdownOption.prototype,"isMultiple",null),__decorate([state()],GlideCoreDropdownOption.prototype,"lastSelectedOption",null),__decorate([property({reflect:!0})],GlideCoreDropdownOption.prototype,"value",null),__decorate([state()],GlideCoreDropdownOption.prototype,"isLabelOverflow",void 0),GlideCoreDropdownOption=__decorate([customElement("glide-core-dropdown-option"),final],GlideCoreDropdownOption);export default GlideCoreDropdownOption;
|
package/dist/radio-group.js
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
var __decorate=this&&this.__decorate||function(e,t,i,a){var o
|
1
|
+
var __decorate=this&&this.__decorate||function(e,t,i,a){var s,o=arguments.length,r=o<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,i,a);else for(var d=e.length-1;d>=0;d--)(s=e[d])&&(r=(o<3?s(r):o>3?s(t,i,r):s(t,i))||r);return o>3&&r&&Object.defineProperty(t,i,r),r};import"./label.js";import"./tooltip.js";import{html,LitElement}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{ifDefined}from"lit/directives/if-defined.js";import{unsafeHTML}from"lit/directives/unsafe-html.js";import{when}from"lit/directives/when.js";import packageJson from"../package.json"with{type:"json"};import GlideCoreRadioGroupRadio from"./radio-group.radio.js";import styles from"./radio-group.styles.js";import assertSlot from"./library/assert-slot.js";import shadowRootMode from"./library/shadow-root-mode.js";import final from"./library/final.js";import required from"./library/required.js";let GlideCoreRadioGroup=class GlideCoreRadioGroup extends LitElement{static{this.formAssociated=!0}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:shadowRootMode}}static{this.styles=styles}get disabled(){return this.#e}set disabled(e){this.#e=e;const t=this.#t.findLast((e=>e.checked));for(const i of this.#t){this.#i=!0,i.disabled=e,this.#i=!1;const a=this.#t.find((e=>!e.disabled));e?i.tabIndex=-1:i===t?i.tabIndex=0:t||i!==a||(i.tabIndex=0)}e?this.#a="":t&&(this.#a=t.value)}get required(){return this.#s}set required(e){this.#s=e;for(const t of this.#t)t.privateRequired=e}get value(){return this.#a}set value(e){if(this.#a=e,!this.#o)for(const t of this.#t){const i=Boolean(""!==e&&t.value===e);t.checked=!!i,t.tabIndex=i?0:-1,t.checked&&t.disabled&&(t.disabled=!1)}}checkValidity(){this.isCheckingValidity=!0;const e=this.#r.checkValidity();return this.isCheckingValidity=!1,e}disconnectedCallback(){super.disconnectedCallback(),this.form?.removeEventListener("formdata",this.#d)}firstUpdated(){for(const e of this.#t)e.privateRequired=this.required,e.tabIndex=-1,this.disabled&&(e.disabled=this.disabled);const e=this.#t.findLast((({checked:e,disabled:t})=>e&&!t));if(e)return this.#a=e.value,this.disabled||(e.tabIndex=0),this.#o=!0,this.setAttribute("value",e.value),void(this.#o=!1);if(!e&&""!==this.value){const e=this.#t.findLast((({value:e})=>e===this.value));return!this.disabled&&e?.disabled&&(e.disabled=!1),void(e&&(e.checked=!0,e.tabIndex=0))}const t=this.#t.find((({disabled:e})=>!e));t&&(t.tabIndex=0)}focus(e){const t=this.#t.find((({checked:e,disabled:t})=>e&&!t))??this.#t.find((({tabIndex:e})=>0===e));t?.focus(e)}get form(){return this.#r.form}get validity(){const e=this.#t.some((({checked:e})=>e));return!this.required||e||this.disabled?this.required&&this.#r.validity.valueMissing&&e?(this.#r.setValidity({}),this.#r.validity):this.required&&this.disabled&&!e?(this.#r.setValidity({valueMissing:!0}," ",this.#l.value),this.#r.validity):(this.required||!this.#r.validity.valueMissing||e||this.#r.setValidity({}),this.#r.validity):(this.#r.setValidity({customError:Boolean(this.validityMessage),valueMissing:!0}," ",this.#l.value),this.#r.validity)}formAssociatedCallback(){this.form?.addEventListener("formdata",this.#d)}formResetCallback(){this.value=this.getAttribute("value")??""}render(){return html`
|
2
2
|
<div
|
3
3
|
class="component"
|
4
|
-
@click=${this.#
|
5
|
-
@keydown=${this.#
|
6
|
-
${ref(this.#
|
4
|
+
@click=${this.#n}
|
5
|
+
@keydown=${this.#h}
|
6
|
+
${ref(this.#l)}
|
7
7
|
>
|
8
8
|
<glide-core-private-label
|
9
9
|
label=${ifDefined(this.label)}
|
@@ -11,26 +11,26 @@ var __decorate=this&&this.__decorate||function(e,t,i,a){var o,s=arguments.length
|
|
11
11
|
split=${ifDefined(this.privateSplit??void 0)}
|
12
12
|
tooltip=${ifDefined(this.tooltip)}
|
13
13
|
?disabled=${this.disabled}
|
14
|
-
?error=${this.#
|
14
|
+
?error=${this.#c}
|
15
15
|
?hide=${this.hideLabel}
|
16
16
|
?required=${this.required}
|
17
17
|
>
|
18
18
|
<label id="label" data-test="label"> ${this.label} </label>
|
19
19
|
|
20
20
|
<div
|
21
|
-
class=${classMap({"radio-container":!0,invalid:this.#
|
21
|
+
class=${classMap({"radio-container":!0,invalid:this.#c})}
|
22
22
|
role="radiogroup"
|
23
23
|
slot="control"
|
24
24
|
aria-labelledby="label description"
|
25
25
|
>
|
26
26
|
<slot
|
27
|
-
@focusout=${this.#
|
28
|
-
@private-checked-change=${this.#
|
29
|
-
@private-disabled-change=${this.#
|
30
|
-
@private-value-change=${this.#
|
31
|
-
@slotchange=${this.#
|
27
|
+
@focusout=${this.#u}
|
28
|
+
@private-checked-change=${this.#p}
|
29
|
+
@private-disabled-change=${this.#f}
|
30
|
+
@private-value-change=${this.#m}
|
31
|
+
@slotchange=${this.#b}
|
32
32
|
${assertSlot([GlideCoreRadioGroupRadio])}
|
33
|
-
${ref(this.#
|
33
|
+
${ref(this.#g)}
|
34
34
|
>
|
35
35
|
<!-- @type {GlideCoreRadio} -->
|
36
36
|
</slot>
|
@@ -38,7 +38,7 @@ var __decorate=this&&this.__decorate||function(e,t,i,a){var o,s=arguments.length
|
|
38
38
|
|
39
39
|
<div id="description" slot="description">
|
40
40
|
<slot
|
41
|
-
class=${classMap({"description-slot":!0,hidden:Boolean(this.#
|
41
|
+
class=${classMap({"description-slot":!0,hidden:Boolean(this.#c&&this.validityMessage)})}
|
42
42
|
name="description"
|
43
43
|
>
|
44
44
|
<!--
|
@@ -47,10 +47,10 @@ var __decorate=this&&this.__decorate||function(e,t,i,a){var o,s=arguments.length
|
|
47
47
|
-->
|
48
48
|
</slot>
|
49
49
|
|
50
|
-
${when(this.#
|
50
|
+
${when(this.#c&&this.validityMessage,(()=>html`<div data-test="validity-message">
|
51
51
|
${unsafeHTML(this.validityMessage)}
|
52
52
|
</div>`))}
|
53
53
|
</div>
|
54
54
|
</glide-core-private-label>
|
55
55
|
</div>
|
56
|
-
`}reportValidity(){this.isReportValidityOrSubmit=!0;const e=this.#
|
56
|
+
`}reportValidity(){this.isReportValidityOrSubmit=!0;const e=this.#r.reportValidity();return this.requestUpdate(),e}resetValidityFeedback(){this.isReportValidityOrSubmit=!1}setCustomValidity(e){this.validityMessage=e,""===e?this.#r.setValidity({customError:!1},"",this.#l.value):this.#r.setValidity({customError:!0,valueMissing:this.#r.validity.valueMissing}," ",this.#l.value)}setValidity(e,t){this.validityMessage=t,this.#r.setValidity(e," ",this.#l.value)}constructor(){super(),this.hideLabel=!1,this.name="",this.orientation="horizontal",this.version=packageJson.version,this.isBlurring=!1,this.isCheckingValidity=!1,this.isReportValidityOrSubmit=!1,this.#l=createRef(),this.#g=createRef(),this.#e=!1,this.#i=!1,this.#s=!1,this.#o=!1,this.#a="",this.#d=({formData:e})=>{this.name&&this.value.length>0&&!this.disabled&&e.append(this.name,this.value)},this.#r=this.attachInternals(),this.addEventListener("invalid",(e=>{if(e.preventDefault(),!this.isCheckingValidity){if(e?.preventDefault(),this.isCheckingValidity||this.isBlurring)return;this.isReportValidityOrSubmit=!0;this.form?.querySelector(":invalid")===this&&this.focus()}}))}#l;#g;#r;#e;#i;#s;#o;#a;#d;get#c(){const e=!this.disabled&&!this.validity.valid&&this.isReportValidityOrSubmit;for(const t of this.#t)t.privateInvalid=e;return e}#v(e){this.#t.find((({tabIndex:e})=>0===e))?.setAttribute("tabindex","-1"),this.#a=e.value,e.checked=!0,e.tabIndex=0,e.focus()}#n(e){if(!this.disabled)if(e.target instanceof GlideCoreRadioGroupRadio&&e.target.disabled){const e=this.#t.find((({checked:e})=>e));e?.focus()}else if(e.target instanceof GlideCoreRadioGroupRadio&&!e.target.disabled){const t=this.#t.filter((t=>t!==e.target));for(const e of t)e.checked=!1,e.tabIndex=-1;this.#v(e.target)}}#h(e){if(!(this.disabled||e.target instanceof GlideCoreRadioGroupRadio&&e.target?.disabled)&&e.target instanceof GlideCoreRadioGroupRadio)switch(e.key){case"Enter":this.form?.requestSubmit();break;case"ArrowUp":case"ArrowLeft":{e.preventDefault();const t=this.#t.slice(0,this.#t.indexOf(e.target)).findLast((e=>!e.disabled)),i=this.#t.findLast((e=>!e.disabled));t&&t!==e.target?(this.#R(e.target),this.#v(t)):i&&i!==e.target&&(this.#R(e.target),this.#v(i));break}case"ArrowDown":case"ArrowRight":{e.preventDefault();const t=this.#t.find(((t,i)=>!t.disabled&&e.target instanceof GlideCoreRadioGroupRadio&&i>this.#t.indexOf(e.target))),i=this.#t.find((e=>!e.disabled));t&&t!==e.target?(this.#R(e.target),this.#v(t)):i&&i!==e.target&&(this.#R(e.target),this.#v(i));break}case" ":if(e.preventDefault(),!e.target.disabled&&!e.target.checked){this.#v(e.target);for(const t of this.#t)t!==e.target&&this.#R(t)}}}#b(){const e=this.#t.findLast((({checked:e,disabled:t})=>e&&!t));e&&(this.#a=e.value)}#u(e){(null===e.relatedTarget||e.relatedTarget instanceof Node&&!this.contains(e.relatedTarget))&&(this.isBlurring=!0,this.reportValidity(),this.isBlurring=!1)}get#t(){return this.#g.value?this.#g.value.assignedElements().filter((e=>e instanceof GlideCoreRadioGroupRadio)):[]}#p(e){if(e.target instanceof GlideCoreRadioGroupRadio&&e.target.checked&&!e.detail.old&&e.detail.new){const t=this.#t.find((({tabIndex:e})=>0===e));t&&t!==e.target&&this.#R(t),this.#a=e.target.value,e.target.tabIndex=e.target.disabled?-1:0}}#f(e){if(!this.#i){if(e.target instanceof GlideCoreRadioGroupRadio&&e.target.disabled){const t=this.#t.findLast((e=>e.checked&&!e.disabled));e.target.checked&&!t?this.#a="":t&&(this.#a=t.value);const i=this.#t.find(((t,i)=>!t.disabled&&e.target instanceof GlideCoreRadioGroupRadio&&i>this.#t.indexOf(e.target)));if(i&&0===e.target.tabIndex)return i.tabIndex=0,void(e.target.tabIndex=-1);const a=this.#t.find((e=>!e.disabled));if(a&&0===e.target.tabIndex)return a.tabIndex=0,void(e.target.tabIndex=-1)}if(e.target instanceof GlideCoreRadioGroupRadio&&!this.disabled){this.#t.some((({tabIndex:e})=>0===e))||(e.target.tabIndex=0);const t=this.#t.findLast((e=>e.checked&&!e.disabled));e.target===t&&(this.#a=e.target.value)}else;}}#m(e){const t=this.#t.findLast((e=>e.checked&&!this.disabled));e.target instanceof GlideCoreRadioGroupRadio&&e.target.checked&&e.detail.new&&e.target===t?this.#a=e.target.value:e.target instanceof GlideCoreRadioGroupRadio&&e.target.checked&&e.target===t&&(this.#a="")}#R(e){e.checked=!1,e.tabIndex=-1}};__decorate([property({reflect:!0,type:Boolean})],GlideCoreRadioGroup.prototype,"disabled",null),__decorate([property({attribute:"hide-label",type:Boolean})],GlideCoreRadioGroup.prototype,"hideLabel",void 0),__decorate([property({reflect:!0}),required],GlideCoreRadioGroup.prototype,"label",void 0),__decorate([property({reflect:!0})],GlideCoreRadioGroup.prototype,"name",void 0),__decorate([property({reflect:!0})],GlideCoreRadioGroup.prototype,"orientation",void 0),__decorate([property()],GlideCoreRadioGroup.prototype,"privateSplit",void 0),__decorate([property({reflect:!0})],GlideCoreRadioGroup.prototype,"tooltip",void 0),__decorate([property({reflect:!0,type:Boolean})],GlideCoreRadioGroup.prototype,"required",null),__decorate([property()],GlideCoreRadioGroup.prototype,"value",null),__decorate([property({reflect:!0})],GlideCoreRadioGroup.prototype,"version",void 0),__decorate([state()],GlideCoreRadioGroup.prototype,"isBlurring",void 0),__decorate([state()],GlideCoreRadioGroup.prototype,"isCheckingValidity",void 0),__decorate([state()],GlideCoreRadioGroup.prototype,"isReportValidityOrSubmit",void 0),__decorate([state()],GlideCoreRadioGroup.prototype,"validityMessage",void 0),GlideCoreRadioGroup=__decorate([customElement("glide-core-radio-group"),final],GlideCoreRadioGroup);export default GlideCoreRadioGroup;
|
@@ -29,7 +29,7 @@ export default class GlideCoreRadioGroupRadio extends LitElement {
|
|
29
29
|
* @default false
|
30
30
|
*/
|
31
31
|
get disabled(): boolean;
|
32
|
-
set disabled(
|
32
|
+
set disabled(isDisabled: boolean);
|
33
33
|
get privateInvalid(): boolean;
|
34
34
|
set privateInvalid(invalid: boolean);
|
35
35
|
/**
|
@@ -46,5 +46,6 @@ export default class GlideCoreRadioGroupRadio extends LitElement {
|
|
46
46
|
set value(value: string);
|
47
47
|
readonly version: string;
|
48
48
|
firstUpdated(): void;
|
49
|
+
private get lastCheckedRadio();
|
49
50
|
render(): import("lit").TemplateResult<1>;
|
50
51
|
}
|
@@ -1 +1 @@
|
|
1
|
-
var __decorate=this&&this.__decorate||function(e,t,i,
|
1
|
+
var __decorate=this&&this.__decorate||function(e,t,i,a){var r,o=arguments.length,d=o<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)d=Reflect.decorate(e,t,i,a);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(d=(o<3?r(d):o>3?r(t,i,d):r(t,i))||d);return o>3&&d&&Object.defineProperty(t,i,d),d};import{html,LitElement}from"lit";import{classMap}from"lit/directives/class-map.js";import{customElement,property,state}from"lit/decorators.js";import packageJson from"../package.json"with{type:"json"};import styles from"./radio-group.radio.styles.js";import shadowRootMode from"./library/shadow-root-mode.js";import final from"./library/final.js";import required from"./library/required.js";let GlideCoreRadioGroupRadio=class GlideCoreRadioGroupRadio extends LitElement{constructor(){super(...arguments),this.version=packageJson.version,this.#e=!1,this.#t=!1,this.#i=!1,this.#a=!1,this.#r=""}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:shadowRootMode}}static{this.styles=styles}get checked(){return this.#e}set checked(e){const t=this.#e;this.#e=e,this.ariaChecked=e&&!this.disabled?"true":"false",e&&t!==e&&(this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))),this.dispatchEvent(new CustomEvent("private-checked-change",{bubbles:!0,detail:{old:t,new:e}}))}get disabled(){return this.#t}set disabled(e){this.#t=e,this.ariaDisabled=e.toString(),this.ariaChecked=this.checked&&!e?"true":"false",this.dispatchEvent(new CustomEvent("private-disabled-change",{bubbles:!0}))}get privateInvalid(){return this.#i}set privateInvalid(e){this.#i=e,this.ariaInvalid=e.toString()}get label(){return this.#o}set label(e){this.#o=e,this.ariaLabel=e.toString()}get privateRequired(){return this.#a}set privateRequired(e){this.#a=e,this.ariaRequired=e.toString()}get value(){return this.#r}set value(e){const t=this.#r;this.#r=e,this.dispatchEvent(new CustomEvent("private-value-change",{bubbles:!0,detail:{old:t,new:e}}))}firstUpdated(){this.ariaChecked=this.checked&&!this.disabled&&this===this.lastCheckedRadio?"true":"false",this.ariaDisabled=this.disabled.toString(),this.ariaInvalid=this.privateInvalid.toString(),this.ariaRequired=this.privateRequired.toString(),this.role="radio",this.label&&(this.ariaLabel=this.label)}get lastCheckedRadio(){const e=this.parentElement?.querySelectorAll("glide-core-radio-group-radio");if(e&&e.length>0)return[...e].findLast((e=>e.checked))}render(){return html`<div class="component" data-test="component"><div class="${classMap({circle:!0,checked:this.checked&&this===this.lastCheckedRadio&&!this.disabled,disabled:this.disabled,animate:this.hasUpdated})}" data-test="radio"></div>${this.#o}</div>`}#e;#t;#o;#i;#a;#r};__decorate([property({type:Boolean,reflect:!0})],GlideCoreRadioGroupRadio.prototype,"checked",null),__decorate([property({type:Boolean,reflect:!0})],GlideCoreRadioGroupRadio.prototype,"disabled",null),__decorate([property({type:Boolean})],GlideCoreRadioGroupRadio.prototype,"privateInvalid",null),__decorate([property({reflect:!0}),required],GlideCoreRadioGroupRadio.prototype,"label",null),__decorate([property({type:Boolean,reflect:!0})],GlideCoreRadioGroupRadio.prototype,"privateRequired",null),__decorate([property()],GlideCoreRadioGroupRadio.prototype,"value",null),__decorate([property({reflect:!0})],GlideCoreRadioGroupRadio.prototype,"version",void 0),__decorate([state()],GlideCoreRadioGroupRadio.prototype,"lastCheckedRadio",null),GlideCoreRadioGroupRadio=__decorate([customElement("glide-core-radio-group-radio"),final],GlideCoreRadioGroupRadio);export default GlideCoreRadioGroupRadio;
|
package/dist/tab.styles.js
CHANGED