@crowdstrike/glide-core 0.22.0 → 0.24.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/accordion.styles.js +22 -21
- package/dist/button-group.button.styles.js +46 -22
- package/dist/button-group.styles.js +7 -7
- package/dist/button.d.ts +3 -0
- package/dist/button.js +1 -1
- package/dist/button.styles.js +62 -42
- package/dist/checkbox-group.js +6 -5
- package/dist/checkbox-group.styles.js +5 -5
- package/dist/checkbox.d.ts +10 -2
- package/dist/checkbox.js +23 -17
- package/dist/checkbox.styles.js +46 -28
- package/dist/drawer.styles.js +6 -4
- package/dist/dropdown.d.ts +1 -1
- package/dist/dropdown.js +20 -18
- package/dist/dropdown.option.js +1 -1
- package/dist/dropdown.option.styles.js +26 -28
- package/dist/dropdown.styles.js +64 -58
- package/dist/icon-button.styles.js +44 -23
- package/dist/inline-alert.js +1 -1
- package/dist/inline-alert.styles.js +24 -21
- package/dist/input.styles.js +33 -25
- package/dist/label.styles.js +22 -27
- package/dist/menu.button.styles.js +6 -4
- package/dist/menu.js +1 -1
- package/dist/menu.link.styles.js +6 -4
- package/dist/menu.options.styles.js +12 -16
- package/dist/menu.styles.js +9 -6
- package/dist/modal.styles.js +16 -13
- package/dist/popover.js +1 -1
- package/dist/popover.styles.js +14 -14
- 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/radio-group.radio.styles.js +31 -11
- package/dist/radio-group.styles.js +8 -10
- package/dist/split-button.primary-button.styles.js +41 -26
- package/dist/split-button.secondary-button.styles.js +61 -21
- package/dist/styles/focus-outline.js +1 -1
- package/dist/styles/variables.css +1 -1
- package/dist/tab.group.styles.js +6 -5
- package/dist/tab.panel.styles.js +1 -1
- package/dist/tab.styles.js +8 -7
- package/dist/tag.styles.js +27 -26
- package/dist/textarea.styles.js +22 -18
- package/dist/toasts.styles.js +2 -2
- package/dist/toasts.toast.styles.js +20 -20
- package/dist/toggle.styles.js +15 -7
- package/dist/tooltip.container.styles.js +14 -13
- package/dist/tooltip.js +1 -1
- package/dist/tooltip.styles.js +1 -1
- package/package.json +8 -9
- package/dist/library/get-parent-class-name.d.ts +0 -3
- package/dist/library/get-parent-class-name.js +0 -1
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 a,r=arguments.length,o=r<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--)(a=e[l])&&(o=(r<3?a(o):r>3?a(t,i,o):a(t,i))||o);return r>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.#a}set value(e){const t=this.#a;this.#a=e,this.dispatchEvent(new CustomEvent("private-value-change",{bubbles:!0,detail:{old:t,new:e}}))}get form(){return this.#r.form}checkValidity(){this.isCheckingValidity=!0;const e=this.#r.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.#r.validity:this.required&&!this.checked?(this.#r.setValidity({customError:Boolean(this.validityMessage),valueMissing:!0}," ",this.#o.value),this.#r.validity):this.required&&this.#r.validity.valueMissing&&this.checked?(this.#r.setValidity({}),this.#r.validity):(this.required||!this.#r.validity.valueMissing||this.checked||this.#r.setValidity({}),this.#r.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,22 +82,28 @@ 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}
|
97
97
|
</div>
|
98
98
|
</div>
|
99
99
|
|
100
|
-
${when(this.summary,(()=>html`<div
|
100
|
+
${when(this.summary,(()=>html`<div
|
101
|
+
class=${classMap({summary:!0,disabled:this.disabled})}
|
102
|
+
id="summary"
|
103
|
+
slot="summary"
|
104
|
+
>
|
105
|
+
${this.summary}
|
106
|
+
</div>`))}
|
101
107
|
|
102
108
|
<div id="description" slot="description">
|
103
109
|
<!--
|
@@ -105,7 +111,7 @@ var __decorate=this&&this.__decorate||function(e,t,i,r){var o,a=arguments.length
|
|
105
111
|
@type {Element | string}
|
106
112
|
-->
|
107
113
|
<slot
|
108
|
-
class=${classMap({description:!0,hidden:Boolean(this.#
|
114
|
+
class=${classMap({description:!0,hidden:Boolean(this.#d&&this.validityMessage)})}
|
109
115
|
name="description"
|
110
116
|
>
|
111
117
|
<!--
|
@@ -114,14 +120,14 @@ var __decorate=this&&this.__decorate||function(e,t,i,r){var o,a=arguments.length
|
|
114
120
|
-->
|
115
121
|
</slot>
|
116
122
|
|
117
|
-
${when(this.#
|
123
|
+
${when(this.#d&&this.validityMessage,(()=>html`<span
|
118
124
|
class="validity-message"
|
119
125
|
data-test="validity-message"
|
120
126
|
>${unsafeHTML(this.validityMessage)}</span
|
121
127
|
>`))}
|
122
128
|
</div>
|
123
129
|
</glide-core-private-label>`))}
|
124
|
-
</div>`}reportValidity(){this.privateIsReportValidityOrSubmit=!0;const e=this.#r.reportValidity();return this.requestUpdate(),e}resetValidityFeedback(){this.privateIsReportValidityOrSubmit=!1}setCustomValidity(e){this.validityMessage=e,""===e?this.#r.setValidity({customError:!1},"",this.#o.value):this.#r.setValidity({customError:!0,valueMissing:this.#r.validity.valueMissing}," ",this.#o.value)}setValidity(e,t){this.validityMessage=t,this.#r.setValidity(e," ",this.#o.value)}updated(){this.#o.value&&(this.#o.value.indeterminate=this.indeterminate)}constructor(){super(),this.
|
130
|
+
</div>`}reportValidity(){this.privateIsReportValidityOrSubmit=!0;const e=this.#r.reportValidity();return this.requestUpdate(),e}resetValidityFeedback(){this.privateIsReportValidityOrSubmit=!1}setCustomValidity(e){this.validityMessage=e,""===e?this.#r.setValidity({customError:!1},"",this.#o.value):this.#r.setValidity({customError:!0,valueMissing:this.#r.validity.valueMissing}," ",this.#o.value)}setValidity(e,t){this.validityMessage=t,this.#r.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.#a="",this.#n=({formData:e})=>{this.checked&&this.name&&this.value&&!this.disabled&&e.append(this.name,this.value)},this.#r=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;#r;#l;#e;#t;#i;#p;#a;#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
131
|
<svg
|
126
132
|
aria-hidden="true"
|
127
133
|
style=${styleMap({height:"0.875rem",width:"0.875rem"})}
|
package/dist/checkbox.styles.js
CHANGED
@@ -8,27 +8,23 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export
|
|
8
8
|
line-height: 100%;
|
9
9
|
|
10
10
|
&.large {
|
11
|
-
column-gap: var(--glide-core-spacing-sm);
|
12
|
-
font-family: var(--glide-core-
|
13
|
-
font-size: var(--glide-core-
|
14
|
-
font-
|
15
|
-
font-variant: var(--glide-core-body-sm-font-variant);
|
16
|
-
font-weight: var(--glide-core-body-sm-font-weight);
|
11
|
+
column-gap: var(--glide-core-spacing-base-sm);
|
12
|
+
font-family: var(--glide-core-typography-family-primary);
|
13
|
+
font-size: var(--glide-core-typography-size-body-default);
|
14
|
+
font-weight: var(--glide-core-typography-weight-regular);
|
17
15
|
}
|
18
16
|
|
19
17
|
&.small {
|
20
|
-
column-gap: var(--glide-core-spacing-xs);
|
21
|
-
font-family: var(--glide-core-
|
22
|
-
font-size: var(--glide-core-
|
23
|
-
font-
|
24
|
-
font-variant: var(--glide-core-body-xs-font-variant);
|
25
|
-
font-weight: var(--glide-core-body-xs-font-weight);
|
18
|
+
column-gap: var(--glide-core-spacing-base-xs);
|
19
|
+
font-family: var(--glide-core-typography-family-primary);
|
20
|
+
font-size: var(--glide-core-typography-size-body-small);
|
21
|
+
font-weight: var(--glide-core-typography-weight-regular);
|
26
22
|
}
|
27
23
|
}
|
28
24
|
|
29
25
|
.input-and-checkbox-and-summary {
|
30
26
|
display: flex;
|
31
|
-
gap: var(--glide-core-spacing-sm);
|
27
|
+
gap: var(--glide-core-spacing-base-sm);
|
32
28
|
}
|
33
29
|
|
34
30
|
.input-and-checkbox {
|
@@ -46,11 +42,16 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export
|
|
46
42
|
|
47
43
|
.checkbox {
|
48
44
|
align-items: center;
|
45
|
+
background-color: var(
|
46
|
+
--glide-core-private-color-checkbox-surface-background-idle
|
47
|
+
);
|
49
48
|
block-size: 100%;
|
50
|
-
border: 1px solid var(--glide-core-
|
51
|
-
border-radius:
|
49
|
+
border: 1px solid var(--glide-core-color-interactive-stroke-contrast);
|
50
|
+
border-radius: var(--glide-core-rounding-base-radius-xs);
|
52
51
|
box-sizing: border-box;
|
53
|
-
color: var(
|
52
|
+
color: var(
|
53
|
+
--glide-core-private-color-checkbox-surface-background-selected--default
|
54
|
+
);
|
54
55
|
display: flex;
|
55
56
|
flex-shrink: 0; /* Don't shrink when the summary wraps. */
|
56
57
|
inline-size: 100%;
|
@@ -63,11 +64,11 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export
|
|
63
64
|
}
|
64
65
|
|
65
66
|
&.error:not(.disabled) {
|
66
|
-
border-color: var(--glide-core-
|
67
|
+
border-color: var(--glide-core-color-error-stroke-primary);
|
67
68
|
}
|
68
69
|
|
69
70
|
&:not(.disabled):hover {
|
70
|
-
box-shadow: var(--glide-core-
|
71
|
+
box-shadow: var(--glide-core-effect-hovered);
|
71
72
|
}
|
72
73
|
}
|
73
74
|
|
@@ -82,8 +83,8 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export
|
|
82
83
|
position: absolute;
|
83
84
|
|
84
85
|
&:not(:disabled):hover ~ .checkbox {
|
85
|
-
border-color: var(--glide-core-
|
86
|
-
box-shadow: var(--glide-core-
|
86
|
+
border-color: var(--glide-core-color-interactive-stroke-focus);
|
87
|
+
box-shadow: var(--glide-core-effect-hovered);
|
87
88
|
}
|
88
89
|
|
89
90
|
&:checked:not(:indeterminate) ~ .checkbox .checked-icon {
|
@@ -95,18 +96,31 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export
|
|
95
96
|
}
|
96
97
|
|
97
98
|
&:disabled:not(:is(:checked, :indeterminate)) ~ .checkbox {
|
98
|
-
background-color: var(
|
99
|
-
|
99
|
+
background-color: var(
|
100
|
+
--glide-core-private-color-checkbox-surface-background-idle
|
101
|
+
);
|
102
|
+
border-color: var(
|
103
|
+
--glide-core-private-color-checkbox-icon-default--disabled
|
104
|
+
);
|
100
105
|
}
|
101
106
|
|
102
107
|
&:is(:checked, :indeterminate):not(:disabled) ~ .checkbox {
|
103
|
-
background-color: var(--glide-core-
|
108
|
+
background-color: var(--glide-core-color-interactive-icon-active);
|
104
109
|
border-color: transparent;
|
105
110
|
}
|
106
111
|
|
107
112
|
&:is(:checked, :indeterminate):disabled ~ .checkbox {
|
108
|
-
background-color: var(
|
113
|
+
background-color: var(
|
114
|
+
--glide-core-private-color-checkbox-icon-default--disabled
|
115
|
+
);
|
109
116
|
border-color: transparent;
|
117
|
+
|
118
|
+
.indeterminate-icon {
|
119
|
+
fill: var(--glide-core-private-color-checkbox-icon-default--disabled);
|
120
|
+
stroke: var(
|
121
|
+
--glide-core-private-color-checkbox-icon-default--disabled
|
122
|
+
);
|
123
|
+
}
|
110
124
|
}
|
111
125
|
|
112
126
|
&:checked ~ .checkbox > .checked-icon {
|
@@ -162,13 +176,13 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export
|
|
162
176
|
|
163
177
|
.indeterminate-icon {
|
164
178
|
display: none;
|
165
|
-
fill: var(--glide-core-icon-active);
|
166
|
-
stroke: var(--glide-core-icon-active);
|
179
|
+
fill: var(--glide-core-color-interactive-icon-active);
|
180
|
+
stroke: var(--glide-core-color-interactive-icon-active);
|
167
181
|
}
|
168
182
|
|
169
183
|
.icon-and-label {
|
170
184
|
align-items: center;
|
171
|
-
column-gap: var(--glide-core-spacing-xs);
|
185
|
+
column-gap: var(--glide-core-spacing-base-xs);
|
172
186
|
display: flex;
|
173
187
|
overflow: hidden;
|
174
188
|
}
|
@@ -183,7 +197,7 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export
|
|
183
197
|
white-space: nowrap;
|
184
198
|
|
185
199
|
&.disabled {
|
186
|
-
color: var(--glide-core-icon-
|
200
|
+
color: var(--glide-core-color-interactive-icon-default--disabled);
|
187
201
|
}
|
188
202
|
}
|
189
203
|
|
@@ -195,6 +209,10 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export
|
|
195
209
|
}
|
196
210
|
}
|
197
211
|
|
212
|
+
.summary.disabled {
|
213
|
+
color: var(--glide-core-color-interactive-text-default--disabled);
|
214
|
+
}
|
215
|
+
|
198
216
|
.validity-message {
|
199
217
|
display: block;
|
200
218
|
}
|
package/dist/drawer.styles.js
CHANGED
@@ -5,12 +5,15 @@ import{css}from"lit";export default[css`
|
|
5
5
|
}
|
6
6
|
|
7
7
|
.component {
|
8
|
-
background-color: var(
|
8
|
+
background-color: var(
|
9
|
+
--glide-core-private-color-template-surface-container-detail
|
10
|
+
);
|
9
11
|
block-size: 0;
|
10
12
|
border-end-start-radius: 0.625rem;
|
11
13
|
border-start-start-radius: 0.625rem;
|
12
|
-
box-shadow:
|
13
|
-
|
14
|
+
box-shadow: 0 4px 60px 0
|
15
|
+
var(--glide-core-color-effect-color-elevation-detail-panel);
|
16
|
+
font-family: var(--glide-core-typography-family-primary);
|
14
17
|
inline-size: 0;
|
15
18
|
inset: 0;
|
16
19
|
max-inline-size: 100%;
|
@@ -20,7 +23,6 @@ import{css}from"lit";export default[css`
|
|
20
23
|
visibility: hidden;
|
21
24
|
|
22
25
|
&.pinned {
|
23
|
-
background-color: var(--glide-core-surface-base-xlightest);
|
24
26
|
box-shadow: none;
|
25
27
|
}
|
26
28
|
|
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-base-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;
|