@crowdstrike/glide-core 0.9.0 → 0.9.1
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.d.ts +7 -3
- package/dist/button-group.button.d.ts +1 -4
- package/dist/button-group.button.styles.js +1 -0
- package/dist/button-group.d.ts +3 -0
- package/dist/button.d.ts +3 -0
- package/dist/checkbox-group.d.ts +6 -2
- package/dist/checkbox-group.stories.d.ts +1 -1
- package/dist/checkbox.d.ts +5 -4
- package/dist/checkbox.js +1 -1
- package/dist/checkbox.stories.d.ts +1 -1
- package/dist/checkbox.test.basics.js +15 -6
- package/dist/checkbox.test.events.js +12 -4
- package/dist/checkbox.test.focus.js +1 -1
- package/dist/checkbox.test.form.js +1 -0
- package/dist/checkbox.test.interactions.js +44 -7
- package/dist/drawer.d.ts +5 -5
- package/dist/drawer.stories.d.ts +0 -1
- package/dist/dropdown.d.ts +3 -2
- package/dist/icon-button.d.ts +2 -0
- package/dist/input.d.ts +4 -3
- package/dist/input.js +1 -1
- package/dist/label.styles.js +7 -4
- package/dist/library/localize.d.ts +1 -0
- package/dist/menu.js +1 -1
- package/dist/menu.test.events.js +197 -7
- package/dist/menu.test.interactions.js +2 -2
- package/dist/modal.stories.d.ts +1 -0
- package/dist/modal.tertiary-icon.test.basics.js +2 -2
- package/dist/radio-group.d.ts +4 -3
- package/dist/radio-group.stories.d.ts +1 -1
- package/dist/radio.d.ts +1 -2
- package/dist/radio.js +1 -1
- package/dist/split-container.d.ts +1 -1
- package/dist/status-indicator.d.ts +1 -1
- package/dist/tabs.stories.d.ts +1 -0
- package/dist/tag.d.ts +3 -6
- package/dist/textarea.d.ts +4 -3
- package/dist/toggle.d.ts +3 -3
- package/dist/toggle.js +1 -1
- package/dist/toggle.stories.d.ts +1 -1
- package/dist/toggle.test.interactions.js +26 -0
- package/dist/tooltip.d.ts +2 -2
- package/dist/translations/en.js +1 -1
- package/dist/translations/fr.js +1 -1
- package/dist/translations/ja.js +1 -1
- package/dist/tree.d.ts +1 -1
- package/dist/tree.item.d.ts +0 -3
- package/dist/tree.item.icon-button.d.ts +1 -0
- package/dist/tree.item.icon-button.js +1 -1
- package/dist/tree.item.icon-button.test.basics.js +9 -0
- package/dist/tree.item.js +1 -1
- package/dist/tree.item.menu.d.ts +2 -0
- package/dist/tree.item.menu.js +1 -1
- package/dist/tree.item.menu.test.basics.js +15 -0
- package/dist/tree.item.styles.js +2 -0
- package/dist/tree.item.test.basics.d.ts +2 -1
- package/dist/tree.item.test.basics.js +46 -4
- package/dist/tree.js +1 -1
- package/dist/tree.test.focus.js +91 -4
- package/package.json +2 -1
package/dist/accordion.d.ts
CHANGED
@@ -5,10 +5,14 @@ declare global {
|
|
5
5
|
}
|
6
6
|
}
|
7
7
|
/**
|
8
|
-
* @
|
9
|
-
*
|
8
|
+
* @description An accordion with optional icons.
|
9
|
+
*
|
10
|
+
* @event toggle - `(event: "toggle", listener: (event: CustomEvent<{ newState: "open" | "closed", oldState: "open" | "closed" }>) => void) => void`.
|
11
|
+
* Emitted when the Accordion opens or closes.
|
12
|
+
*
|
13
|
+
* @slot - The content of the accordion.
|
10
14
|
* @slot prefix - An optional icon to display before the label.
|
11
|
-
* @slot suffix -
|
15
|
+
* @slot suffix - Optional icons to display after the label.
|
12
16
|
*/
|
13
17
|
export default class GlideCoreAccordion extends LitElement {
|
14
18
|
#private;
|
@@ -7,11 +7,8 @@ declare global {
|
|
7
7
|
/**
|
8
8
|
* @description A button with a label and optional icon for use in a `<glide-core-button-group>`.
|
9
9
|
*
|
10
|
-
* @event change - Dispatched when the button is selected.
|
11
|
-
* @event input - Dispatched when the button is selected.
|
12
|
-
|
13
|
-
* @slot prefix - An icon.
|
14
10
|
* @slot - A label.
|
11
|
+
* @slot prefix - An optional icon to display before the label.
|
15
12
|
*/
|
16
13
|
export default class GlideCoreButtonGroupButton extends LitElement {
|
17
14
|
#private;
|
@@ -30,6 +30,7 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";import
|
|
30
30
|
.component {
|
31
31
|
align-items: center;
|
32
32
|
appearance: none;
|
33
|
+
background-color: var(--glide-core-surface-page);
|
33
34
|
cursor: pointer;
|
34
35
|
display: flex;
|
35
36
|
font-family: var(--glide-core-font-sans);
|
package/dist/button-group.d.ts
CHANGED
@@ -7,6 +7,9 @@ declare global {
|
|
7
7
|
/**
|
8
8
|
* @description A button group.
|
9
9
|
*
|
10
|
+
* @event change - `(event: Event) => void`
|
11
|
+
* @event input - `(event: Event) => void`
|
12
|
+
*
|
10
13
|
* @slot - One or more of `<glide-core-button-group-button>`.
|
11
14
|
*/
|
12
15
|
export default class GlideCoreButtonGroup extends LitElement {
|
package/dist/button.d.ts
CHANGED
@@ -5,6 +5,9 @@ declare global {
|
|
5
5
|
}
|
6
6
|
}
|
7
7
|
/**
|
8
|
+
*
|
9
|
+
* @description A group of buttons that work like radios—with labels and optional icons.
|
10
|
+
*
|
8
11
|
* @slot - A label for the contents of the button.
|
9
12
|
* @slot prefix - An optional icon slot to display before the label.
|
10
13
|
* @slot suffix - An optional icon slot to display after the label.
|
package/dist/checkbox-group.d.ts
CHANGED
@@ -6,7 +6,11 @@ declare global {
|
|
6
6
|
}
|
7
7
|
}
|
8
8
|
/**
|
9
|
-
* @description A group of checkboxes with a label and optional
|
9
|
+
* @description A group of checkboxes with a label and optional description and tooltip. Participates in forms and validation via `FormData` and various methods.
|
10
|
+
*
|
11
|
+
* @event change - `(event: Event) => void`
|
12
|
+
* @event input - `(event: Event) => void`
|
13
|
+
* @event invalid - `(event: Event) => void`
|
10
14
|
*
|
11
15
|
* @slot - One or more of `<glide-core-checkbox>`.
|
12
16
|
* @slot description - Additional information or context.
|
@@ -26,7 +30,7 @@ export default class GlideCoreCheckboxGroup extends LitElement {
|
|
26
30
|
get required(): boolean;
|
27
31
|
set required(isRequired: boolean);
|
28
32
|
summary?: string;
|
29
|
-
value: string[];
|
33
|
+
value: readonly string[];
|
30
34
|
checkValidity(): boolean;
|
31
35
|
disconnectedCallback(): void;
|
32
36
|
firstUpdated(): void;
|
@@ -3,5 +3,5 @@ import type { Meta, StoryObj } from '@storybook/web-components';
|
|
3
3
|
declare const meta: Meta;
|
4
4
|
export default meta;
|
5
5
|
export declare const Vertical: StoryObj;
|
6
|
-
export declare const
|
6
|
+
export declare const VerticalWithTooltip: StoryObj;
|
7
7
|
export declare const VerticalWithError: StoryObj;
|
package/dist/checkbox.d.ts
CHANGED
@@ -9,9 +9,10 @@ declare global {
|
|
9
9
|
/**
|
10
10
|
* @description A checkbox with a label and optional tooltip, summary, and description. Participates in forms and validation via `FormData` and various methods.
|
11
11
|
*
|
12
|
-
* @event change -
|
13
|
-
* @event input -
|
14
|
-
|
12
|
+
* @event change - `(event: Event) => void`
|
13
|
+
* @event input - `(event: Event) => void`
|
14
|
+
* @event invalid - `(event: Event) => void`
|
15
|
+
*
|
15
16
|
* @slot description - Additional information or context.
|
16
17
|
* @slot tooltip - Content for the tooltip.
|
17
18
|
*/
|
@@ -35,7 +36,7 @@ export default class GlideCoreCheckbox extends LitElement {
|
|
35
36
|
privateVariant?: 'minimal';
|
36
37
|
required: boolean;
|
37
38
|
summary?: string;
|
38
|
-
value
|
39
|
+
value: string;
|
39
40
|
isReportValidityOrSubmit: boolean;
|
40
41
|
get form(): HTMLFormElement | null;
|
41
42
|
blur(): void;
|
package/dist/checkbox.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
var __decorate=this&&this.__decorate||function(e,t,i,o){var r,a=arguments.length,s=a<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,i,o);else for(var l=e.length-1;l>=0;l--)(r=e[l])&&(s=(a<3?r(s):a>3?r(t,i,s):r(t,i))||s);return a>3&&s&&Object.defineProperty(t,i,s),s};import"./label.js";import"./tooltip.js";import{LitElement,html}from"lit";import{classMap}from"lit/directives/class-map.js";import{createRef,ref}from"lit/directives/ref.js";import{customElement,property,state}from"lit/decorators.js";import{ifDefined}from"lit/directives/if-defined.js";import{when}from"lit/directives/when.js";import checkedIcon from"./icons/checked.js";import styles from"./checkbox.styles.js";const indeterminateIcon=html`<svg width="14" height="14" viewBox="0 0 14 14" fill="none" class="indeterminate-icon"><rect x="0.5" y="0.5" width="13" height="13" rx="3.5"/><path d="M3 5C3 3.89543 3.89543 3 5 3H9.79289C10.2383 3 10.4614 3.53857 10.1464 3.85355L3.85355 10.1464C3.53857 10.4614 3 10.2383 3 9.79289V5Z" fill="currentColor"/></svg>`;let GlideCoreCheckbox=class GlideCoreCheckbox extends LitElement{static{this.formAssociated=!0}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:"closed"}}static{this.styles=styles}get label(){return this.#e}set label(e){this.#e=e,setTimeout((()=>{this.#t()}))}get form(){return this.#i.form}blur(){this.#o.value?.blur()}checkValidity(){this.isCheckingValidity=!0;const e=this.#i.checkValidity();return this.isCheckingValidity=!1,e}click(){this.#o.value?.click()}connectedCallback(){super.connectedCallback(),this.#r=new IntersectionObserver((()=>{this.checkVisibility()&&this.#t()})),this.#r.observe(this)}disconnectedCallback(){super.disconnectedCallback(),this.form?.removeEventListener("formdata",this.#a),this.#r?.disconnect()}get validity(){return"minimal"===this.privateVariant||(this.required&&!this.checked?this.#i.setValidity({valueMissing:!0}," ",this.#o.value):this.#i.setValidity({})),this.#i.validity}focus(e){this.#o.value?.focus(e)}formAssociatedCallback(){this.form?.addEventListener("formdata",this.#a)}formResetCallback(){this.checked=""===this.getAttribute("checked"),this.indeterminate=""===this.getAttribute("indeterminate")}render(){return html`<div class="component" data-test="component">${when("minimal"===this.privateVariant,(()=>html`<label class="label-and-input-and-checkbox" part="private-label-and-input-and-checkbox"><div class="input-and-checkbox"><input aria-invalid="${this.#s}" data-test="input" type="checkbox" .checked="${this.checked}" .inert="${this.internallyInert}" ?disabled="${this.disabled}" ?required="${this.required}" @change="${this.#l}" ${ref(this.#o)}><div class="${classMap({checkbox:!0,disabled:this.disabled,error:this.#s})}"><div class="checked-icon">${checkedIcon}</div>${indeterminateIcon}</div></div><glide-core-tooltip class="label-tooltip" offset="${this.privateLabelTooltipOffset}" ?disabled="${!this.isLabelOverflow}" ?open="${this.privateShowLabelTooltip}"><div aria-hidden="true" data-test="tooltip">${this.label}</div><div class="label" slot="target" ${ref(this.#n)}>${this.label}</div></glide-core-tooltip></label>`),(()=>html`<glide-core-private-label orientation="${this.orientation}" split="${ifDefined(this.privateSplit??void 0)}" ?disabled="${this.disabled}" ?error="${this.#s}" ?hide="${this.hideLabel}" ?required="${this.required}"><slot name="tooltip" slot="tooltip"></slot><label for="input">${this.label}</label><div class="input-and-checkbox" slot="control"><input aria-describedby="summary description" aria-invalid="${this.#s}" data-test="input" id="input" type="checkbox" .checked="${this.checked}" ?disabled="${this.disabled}" ?required="${this.required}" @change="${this.#l}" @blur="${this.#d}" ${ref(this.#o)}><div class="${classMap({checkbox:!0,disabled:this.disabled,error:this.#s})}"><div class="checked-icon">${checkedIcon}</div>${indeterminateIcon}</div></div><div id="summary" slot="summary">${this.summary}</div><slot id="description" name="description" slot="description"></slot></glide-core-private-label>`))}</div>`}reportValidity(){this.isReportValidityOrSubmit=!0;const e=this.#i.reportValidity();return this.requestUpdate(),e}setValidity(e,t,i){return this.#i.setValidity(e,t,i)}get willValidate(){return this.#i.willValidate}updated(){this.#o.value&&(this.#o.value.indeterminate=this.indeterminate)}constructor(){super(),this.checked=!1,this.internallyInert=!1,this.disabled=!1,this.hideLabel=!1,this.indeterminate=!1,this.orientation="horizontal",this.privateLabelTooltipOffset=4,this.privateShowLabelTooltip=!1,this.required=!1,this.value="",this.isReportValidityOrSubmit=!1,this.isBlurring=!1,this.isCheckingValidity=!1,this.isLabelOverflow=!1,this.#o=createRef(),this.#e="",this.#n=createRef(),this.#a=({formData:e})=>{this.checked&&this.name&&this.value&&!this.disabled&&e.append(this.name,this.value)},this.#i=this.attachInternals(),this.addEventListener("invalid",(e=>{if(e?.preventDefault(),this.isCheckingValidity||this.isBlurring)return;this.isReportValidityOrSubmit=!0;this.form?.querySelector(":invalid")===this&&this.focus()}))}#o;#i;#r;#e;#n;#a;get#s(){return"minimal"===this.privateVariant?!this.validity.valid&&this.isReportValidityOrSubmit:this.required&&!this.disabled&&!this.validity.valid&&this.isReportValidityOrSubmit}#d(){this.isBlurring=!0,this.reportValidity(),this.isBlurring=!1}#l(e){e.target instanceof HTMLInputElement&&(this.checked=e.target.checked),this.indeterminate=!1,this.dispatchEvent(new Event(e.type,e))}#t(){this.#n.value&&(this.isLabelOverflow=this.#n.value.scrollWidth>this.#n.value.clientWidth)}};__decorate([property({type:Boolean})],GlideCoreCheckbox.prototype,"checked",void 0),__decorate([property({attribute:"internally-inert",type:Boolean})],GlideCoreCheckbox.prototype,"internallyInert",void 0),__decorate([property({reflect:!0,type:Boolean})],GlideCoreCheckbox.prototype,"disabled",void 0),__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})],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()],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,"value",void 0),__decorate([state()],GlideCoreCheckbox.prototype,"isReportValidityOrSubmit",void 0),__decorate([state()],GlideCoreCheckbox.prototype,"isBlurring",void 0),__decorate([state()],GlideCoreCheckbox.prototype,"isCheckingValidity",void 0),__decorate([state()],GlideCoreCheckbox.prototype,"isLabelOverflow",void 0),GlideCoreCheckbox=__decorate([customElement("glide-core-checkbox")],GlideCoreCheckbox);export default GlideCoreCheckbox;
|
1
|
+
var __decorate=this&&this.__decorate||function(e,t,i,o){var r,a=arguments.length,s=a<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,i,o);else for(var l=e.length-1;l>=0;l--)(r=e[l])&&(s=(a<3?r(s):a>3?r(t,i,s):r(t,i))||s);return a>3&&s&&Object.defineProperty(t,i,s),s};import"./label.js";import"./tooltip.js";import{LitElement,html}from"lit";import{classMap}from"lit/directives/class-map.js";import{createRef,ref}from"lit/directives/ref.js";import{customElement,property,state}from"lit/decorators.js";import{ifDefined}from"lit/directives/if-defined.js";import{when}from"lit/directives/when.js";import checkedIcon from"./icons/checked.js";import styles from"./checkbox.styles.js";const indeterminateIcon=html`<svg width="14" height="14" viewBox="0 0 14 14" fill="none" class="indeterminate-icon"><rect x="0.5" y="0.5" width="13" height="13" rx="3.5"/><path d="M3 5C3 3.89543 3.89543 3 5 3H9.79289C10.2383 3 10.4614 3.53857 10.1464 3.85355L3.85355 10.1464C3.53857 10.4614 3 10.2383 3 9.79289V5Z" fill="currentColor"/></svg>`;let GlideCoreCheckbox=class GlideCoreCheckbox extends LitElement{static{this.formAssociated=!0}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:"closed"}}static{this.styles=styles}get label(){return this.#e}set label(e){this.#e=e,setTimeout((()=>{this.#t()}))}get form(){return this.#i.form}blur(){this.#o.value?.blur()}checkValidity(){this.isCheckingValidity=!0;const e=this.#i.checkValidity();return this.isCheckingValidity=!1,e}click(){this.#o.value?.click()}connectedCallback(){super.connectedCallback(),this.#r=new IntersectionObserver((()=>{this.checkVisibility()&&this.#t()})),this.#r.observe(this)}disconnectedCallback(){super.disconnectedCallback(),this.form?.removeEventListener("formdata",this.#a),this.#r?.disconnect()}get validity(){return"minimal"===this.privateVariant||(this.required&&!this.checked?this.#i.setValidity({valueMissing:!0}," ",this.#o.value):this.#i.setValidity({})),this.#i.validity}focus(e){this.#o.value?.focus(e)}formAssociatedCallback(){this.form?.addEventListener("formdata",this.#a)}formResetCallback(){this.checked=""===this.getAttribute("checked"),this.indeterminate=""===this.getAttribute("indeterminate")}render(){return html`<div class="component" data-test="component">${when("minimal"===this.privateVariant,(()=>html`<label class="label-and-input-and-checkbox" part="private-label-and-input-and-checkbox"><div class="input-and-checkbox"><input aria-invalid="${this.#s}" data-test="input" type="checkbox" .checked="${this.checked}" .inert="${this.internallyInert}" ?disabled="${this.disabled}" ?required="${this.required}" @change="${this.#l}" @input="${this.#l}" ${ref(this.#o)}><div class="${classMap({checkbox:!0,disabled:this.disabled,error:this.#s})}"><div class="checked-icon">${checkedIcon}</div>${indeterminateIcon}</div></div><glide-core-tooltip class="label-tooltip" offset="${this.privateLabelTooltipOffset}" ?disabled="${!this.isLabelOverflow}" ?open="${this.privateShowLabelTooltip}"><div aria-hidden="true" data-test="tooltip">${this.label}</div><div class="label" slot="target" ${ref(this.#n)}>${this.label}</div></glide-core-tooltip></label>`),(()=>html`<glide-core-private-label orientation="${this.orientation}" split="${ifDefined(this.privateSplit??void 0)}" ?disabled="${this.disabled}" ?error="${this.#s}" ?hide="${this.hideLabel}" ?required="${this.required}"><slot name="tooltip" slot="tooltip"></slot><label for="input">${this.label}</label><div class="input-and-checkbox" slot="control"><input aria-describedby="summary description" aria-invalid="${this.#s}" data-test="input" id="input" type="checkbox" .checked="${this.checked}" ?disabled="${this.disabled}" ?required="${this.required}" @change="${this.#l}" @input="${this.#l}" @blur="${this.#d}" ${ref(this.#o)}><div class="${classMap({checkbox:!0,disabled:this.disabled,error:this.#s})}"><div class="checked-icon">${checkedIcon}</div>${indeterminateIcon}</div></div><div id="summary" slot="summary">${this.summary}</div><slot id="description" name="description" slot="description"></slot></glide-core-private-label>`))}</div>`}reportValidity(){this.isReportValidityOrSubmit=!0;const e=this.#i.reportValidity();return this.requestUpdate(),e}setValidity(e,t,i){return this.#i.setValidity(e,t,i)}get willValidate(){return this.#i.willValidate}updated(){this.#o.value&&(this.#o.value.indeterminate=this.indeterminate)}constructor(){super(),this.checked=!1,this.internallyInert=!1,this.disabled=!1,this.hideLabel=!1,this.indeterminate=!1,this.orientation="horizontal",this.privateLabelTooltipOffset=4,this.privateShowLabelTooltip=!1,this.required=!1,this.value="",this.isReportValidityOrSubmit=!1,this.isBlurring=!1,this.isCheckingValidity=!1,this.isLabelOverflow=!1,this.#o=createRef(),this.#e="",this.#n=createRef(),this.#a=({formData:e})=>{this.checked&&this.name&&this.value&&!this.disabled&&e.append(this.name,this.value)},this.#i=this.attachInternals(),this.addEventListener("invalid",(e=>{if(e?.preventDefault(),this.isCheckingValidity||this.isBlurring)return;this.isReportValidityOrSubmit=!0;this.form?.querySelector(":invalid")===this&&this.focus()}))}#o;#i;#r;#e;#n;#a;get#s(){return"minimal"===this.privateVariant?!this.validity.valid&&this.isReportValidityOrSubmit:this.required&&!this.disabled&&!this.validity.valid&&this.isReportValidityOrSubmit}#d(){this.isBlurring=!0,this.reportValidity(),this.isBlurring=!1}#l(e){e.target instanceof HTMLInputElement&&(this.checked=e.target.checked),this.indeterminate=!1,"change"===e.type&&this.dispatchEvent(new Event(e.type,e))}#t(){this.#n.value&&(this.isLabelOverflow=this.#n.value.scrollWidth>this.#n.value.clientWidth)}};__decorate([property({type:Boolean})],GlideCoreCheckbox.prototype,"checked",void 0),__decorate([property({attribute:"internally-inert",type:Boolean})],GlideCoreCheckbox.prototype,"internallyInert",void 0),__decorate([property({reflect:!0,type:Boolean})],GlideCoreCheckbox.prototype,"disabled",void 0),__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})],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()],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,"value",void 0),__decorate([state()],GlideCoreCheckbox.prototype,"isReportValidityOrSubmit",void 0),__decorate([state()],GlideCoreCheckbox.prototype,"isBlurring",void 0),__decorate([state()],GlideCoreCheckbox.prototype,"isCheckingValidity",void 0),__decorate([state()],GlideCoreCheckbox.prototype,"isLabelOverflow",void 0),GlideCoreCheckbox=__decorate([customElement("glide-core-checkbox")],GlideCoreCheckbox);export default GlideCoreCheckbox;
|
@@ -5,5 +5,5 @@ export declare const Horizontal: StoryObj;
|
|
5
5
|
export declare const HorizontalWithTooltip: StoryObj;
|
6
6
|
export declare const HorizontalWithError: StoryObj;
|
7
7
|
export declare const Vertical: StoryObj;
|
8
|
-
export declare const
|
8
|
+
export declare const VerticalWithTooltip: StoryObj;
|
9
9
|
export declare const VerticalWithError: StoryObj;
|
@@ -50,12 +50,18 @@ it('can have a description', async () => {
|
|
50
50
|
expect(assignedElements?.at(0)?.textContent).to.equal('Description');
|
51
51
|
});
|
52
52
|
it('can have a name', async () => {
|
53
|
-
const component = await fixture(html `<glide-core-checkbox
|
53
|
+
const component = await fixture(html `<glide-core-checkbox
|
54
|
+
label="Label"
|
55
|
+
name="name"
|
56
|
+
></glide-core-checkbox> `);
|
54
57
|
expect(component.getAttribute('name')).to.equal('name');
|
55
58
|
expect(component.name).to.equal('name');
|
56
59
|
});
|
57
60
|
it('can have a summary', async () => {
|
58
|
-
const component = await fixture(html `<glide-core-checkbox
|
61
|
+
const component = await fixture(html `<glide-core-checkbox
|
62
|
+
label="Label"
|
63
|
+
summary="Summary"
|
64
|
+
></glide-core-checkbox> `);
|
59
65
|
expect(component.getAttribute('summary')).to.equal('Summary');
|
60
66
|
expect(component.summary).to.equal('Summary');
|
61
67
|
});
|
@@ -69,22 +75,25 @@ it('can have a tooltip', async () => {
|
|
69
75
|
expect(assignedElements?.at(0)?.textContent).to.equal('Tooltip');
|
70
76
|
});
|
71
77
|
it('can be checked', async () => {
|
72
|
-
const component = await fixture(html `<glide-core-checkbox checked></glide-core-checkbox> `);
|
78
|
+
const component = await fixture(html `<glide-core-checkbox label="Label" checked></glide-core-checkbox> `);
|
73
79
|
expect(component.hasAttribute('checked')).to.be.true;
|
74
80
|
expect(component.checked).to.equal(true);
|
75
81
|
});
|
76
82
|
it('can be disabled', async () => {
|
77
|
-
const component = await fixture(html `<glide-core-checkbox disabled></glide-core-checkbox> `);
|
83
|
+
const component = await fixture(html `<glide-core-checkbox label="Label" disabled></glide-core-checkbox> `);
|
78
84
|
expect(component.hasAttribute('disabled')).to.be.true;
|
79
85
|
expect(component.disabled).to.equal(true);
|
80
86
|
});
|
81
87
|
it('can be indeterminate', async () => {
|
82
|
-
const component = await fixture(html `<glide-core-checkbox
|
88
|
+
const component = await fixture(html `<glide-core-checkbox
|
89
|
+
label="Label"
|
90
|
+
indeterminate
|
91
|
+
></glide-core-checkbox> `);
|
83
92
|
expect(component.hasAttribute('indeterminate')).to.be.true;
|
84
93
|
expect(component.indeterminate).to.equal(true);
|
85
94
|
});
|
86
95
|
it('can be required', async () => {
|
87
|
-
const component = await fixture(html `<glide-core-checkbox required></glide-core-checkbox> `);
|
96
|
+
const component = await fixture(html `<glide-core-checkbox label="Label" required></glide-core-checkbox> `);
|
88
97
|
expect(component.hasAttribute('required')).to.be.true;
|
89
98
|
expect(component.required).to.equal(true);
|
90
99
|
});
|
@@ -31,7 +31,7 @@ it('dispatches an "input" event when clicked', async () => {
|
|
31
31
|
});
|
32
32
|
it('dispatches an "invalid" event on submit when required and unchecked', async () => {
|
33
33
|
const form = document.createElement('form');
|
34
|
-
const component = await fixture(html `<glide-core-checkbox required></glide-core-checkbox>`, { parentNode: form });
|
34
|
+
const component = await fixture(html `<glide-core-checkbox label="Label" required></glide-core-checkbox>`, { parentNode: form });
|
35
35
|
setTimeout(() => form.requestSubmit());
|
36
36
|
const event = await oneEvent(component, 'invalid');
|
37
37
|
expect(event instanceof Event).to.be.true;
|
@@ -45,7 +45,7 @@ it('dispatches an "invalid" event after `checkValidity` is called when required
|
|
45
45
|
});
|
46
46
|
it('dispatches an "invalid" event after `reportValidity` is called when required and unchecked', async () => {
|
47
47
|
const form = document.createElement('form');
|
48
|
-
const component = await fixture(html `<glide-core-checkbox required></glide-core-checkbox>`, { parentNode: form });
|
48
|
+
const component = await fixture(html `<glide-core-checkbox label="Label" required></glide-core-checkbox>`, { parentNode: form });
|
49
49
|
setTimeout(() => component.reportValidity());
|
50
50
|
const event = await oneEvent(component, 'invalid');
|
51
51
|
expect(event instanceof Event).to.be.true;
|
@@ -61,7 +61,11 @@ it('does not dispatch an "invalid" event after `checkValidity` is called when no
|
|
61
61
|
});
|
62
62
|
it('does not dispatch an "invalid" event after `checkValidity` is called when required and unchecked but disabled', async () => {
|
63
63
|
const form = document.createElement('form');
|
64
|
-
const component = await fixture(html `<glide-core-checkbox
|
64
|
+
const component = await fixture(html `<glide-core-checkbox
|
65
|
+
label="Label"
|
66
|
+
disabled
|
67
|
+
required
|
68
|
+
></glide-core-checkbox>`, { parentNode: form });
|
65
69
|
const spy = sinon.spy();
|
66
70
|
component.addEventListener('invalid', spy);
|
67
71
|
component.checkValidity();
|
@@ -79,7 +83,11 @@ it('does not dispatch an "invalid" event when `reportValidity` is called when no
|
|
79
83
|
});
|
80
84
|
it('does not dispatch an "invalid" event when `reportValidity` is called when required and unchecked but disabled', async () => {
|
81
85
|
const form = document.createElement('form');
|
82
|
-
const component = await fixture(html `<glide-core-checkbox
|
86
|
+
const component = await fixture(html `<glide-core-checkbox
|
87
|
+
label="Label"
|
88
|
+
disabled
|
89
|
+
required
|
90
|
+
></glide-core-checkbox>`, { parentNode: form });
|
83
91
|
const spy = sinon.spy();
|
84
92
|
component.addEventListener('invalid', spy);
|
85
93
|
component.reportValidity();
|
@@ -37,7 +37,7 @@ it('does not focus the input after `checkValidity` is called', async () => {
|
|
37
37
|
expect(component.shadowRoot?.activeElement).to.equal(null);
|
38
38
|
});
|
39
39
|
it('blurs the input and reports validity if `blur` is called', async () => {
|
40
|
-
const component = await fixture(html `<glide-core-checkbox required></glide-core-checkbox>`);
|
40
|
+
const component = await fixture(html `<glide-core-checkbox label="Label" required></glide-core-checkbox>`);
|
41
41
|
component.focus();
|
42
42
|
const input = component.shadowRoot?.querySelector('[data-test="input"]');
|
43
43
|
expect(component.shadowRoot?.activeElement).to.equal(input);
|
@@ -42,6 +42,7 @@ it('has `formData` value when checked', async () => {
|
|
42
42
|
it('has `formData` value when checked and indeterminate', async () => {
|
43
43
|
const form = document.createElement('form');
|
44
44
|
await fixture(html `<glide-core-checkbox
|
45
|
+
label="Label"
|
45
46
|
name="name"
|
46
47
|
value="value"
|
47
48
|
checked
|
@@ -3,21 +3,24 @@ import { aTimeout, elementUpdated, expect, fixture, html, } from '@open-wc/testi
|
|
3
3
|
import GlideCoreCheckbox from './checkbox.js';
|
4
4
|
GlideCoreCheckbox.shadowRootOptions.mode = 'open';
|
5
5
|
it('is checked after being clicked', async () => {
|
6
|
-
const component = await fixture(html `<glide-core-checkbox></glide-core-checkbox>`);
|
6
|
+
const component = await fixture(html `<glide-core-checkbox label="Label"></glide-core-checkbox>`);
|
7
7
|
component.click();
|
8
8
|
await elementUpdated(component);
|
9
9
|
expect(component.checked).to.equal(true);
|
10
10
|
expect(component.hasAttribute('checked')).to.be.false;
|
11
11
|
});
|
12
12
|
it('is unchecked after being clicked', async () => {
|
13
|
-
const component = await fixture(html `<glide-core-checkbox checked></glide-core-checkbox>`);
|
13
|
+
const component = await fixture(html `<glide-core-checkbox label="Label" checked></glide-core-checkbox>`);
|
14
14
|
component.click();
|
15
15
|
await elementUpdated(component);
|
16
16
|
expect(component.checked).to.equal(false);
|
17
17
|
expect(component.hasAttribute('checked')).to.be.true;
|
18
18
|
});
|
19
19
|
it('is checked and not indeterminate after being clicked when unchecked and indeterminate', async () => {
|
20
|
-
const component = await fixture(html `<glide-core-checkbox
|
20
|
+
const component = await fixture(html `<glide-core-checkbox
|
21
|
+
label="Label"
|
22
|
+
indeterminate
|
23
|
+
></glide-core-checkbox>`);
|
21
24
|
component.click();
|
22
25
|
await elementUpdated(component);
|
23
26
|
const input = component.shadowRoot?.querySelector('[data-test="input"]');
|
@@ -28,7 +31,11 @@ it('is checked and not indeterminate after being clicked when unchecked and inde
|
|
28
31
|
expect(component.hasAttribute('indeterminate')).to.be.true;
|
29
32
|
});
|
30
33
|
it('is unchecked and not indeterminate after being clicked when checked and indeterminate', async () => {
|
31
|
-
const component = await fixture(html `<glide-core-checkbox
|
34
|
+
const component = await fixture(html `<glide-core-checkbox
|
35
|
+
label="Label"
|
36
|
+
checked
|
37
|
+
indeterminate
|
38
|
+
></glide-core-checkbox>`);
|
32
39
|
component.click();
|
33
40
|
await elementUpdated(component);
|
34
41
|
const input = component.shadowRoot?.querySelector('[data-test="input"]');
|
@@ -39,21 +46,51 @@ it('is unchecked and not indeterminate after being clicked when checked and inde
|
|
39
46
|
expect(component.hasAttribute('indeterminate')).to.be.true;
|
40
47
|
});
|
41
48
|
it('is still checked after being clicked when checked but disabled', async () => {
|
42
|
-
const component = await fixture(html `<glide-core-checkbox
|
49
|
+
const component = await fixture(html `<glide-core-checkbox
|
50
|
+
label="Label"
|
51
|
+
checked
|
52
|
+
disabled
|
53
|
+
></glide-core-checkbox>`);
|
43
54
|
component.click();
|
44
55
|
await elementUpdated(component);
|
45
56
|
expect(component.checked).to.equal(true);
|
46
57
|
expect(component.hasAttribute('checked')).to.be.true;
|
47
58
|
});
|
48
59
|
it('is still unchecked after being clicked when unchecked and disabled', async () => {
|
49
|
-
const component = await fixture(html `<glide-core-checkbox disabled></glide-core-checkbox>`);
|
60
|
+
const component = await fixture(html `<glide-core-checkbox label="Label" disabled></glide-core-checkbox>`);
|
61
|
+
component.click();
|
62
|
+
await elementUpdated(component);
|
63
|
+
expect(component.hasAttribute('checked')).to.be.false;
|
64
|
+
expect(component.checked).to.equal(false);
|
65
|
+
});
|
66
|
+
it('is unchecked after being clicked then forcibly unchecked via a "input" listener', async () => {
|
67
|
+
const component = await fixture(html `<glide-core-checkbox label="Label"></glide-core-checkbox>`);
|
68
|
+
component.addEventListener('input', async () => {
|
69
|
+
await component.updateComplete;
|
70
|
+
component.checked = false;
|
71
|
+
});
|
72
|
+
component.click();
|
73
|
+
await elementUpdated(component);
|
74
|
+
expect(component.hasAttribute('checked')).to.be.false;
|
75
|
+
expect(component.checked).to.equal(false);
|
76
|
+
});
|
77
|
+
it('is unchecked after being clicked then forcibly unchecked via an "change" listener', async () => {
|
78
|
+
const component = await fixture(html `<glide-core-checkbox label="Label"></glide-core-checkbox>`);
|
79
|
+
component.addEventListener('change', async () => {
|
80
|
+
await component.updateComplete;
|
81
|
+
component.checked = false;
|
82
|
+
});
|
50
83
|
component.click();
|
51
84
|
await elementUpdated(component);
|
52
85
|
expect(component.hasAttribute('checked')).to.be.false;
|
53
86
|
expect(component.checked).to.equal(false);
|
54
87
|
});
|
55
88
|
it('is still indeterminate after being clicked when unchecked and disabled', async () => {
|
56
|
-
const component = await fixture(html `<glide-core-checkbox
|
89
|
+
const component = await fixture(html `<glide-core-checkbox
|
90
|
+
label="Label"
|
91
|
+
disabled
|
92
|
+
indeterminate
|
93
|
+
></glide-core-checkbox>`);
|
57
94
|
component.click();
|
58
95
|
await elementUpdated(component);
|
59
96
|
const input = component.shadowRoot?.querySelector('[data-test="input"]');
|
package/dist/drawer.d.ts
CHANGED
@@ -5,13 +5,13 @@ declare global {
|
|
5
5
|
}
|
6
6
|
}
|
7
7
|
/**
|
8
|
-
* @cssprop [--width] - Sets the width of the Drawer when open.
|
9
8
|
*
|
10
|
-
* @
|
11
|
-
* @event open - Emitted when the Drawer opens.
|
9
|
+
* @description A drawer for arbitrary content.
|
12
10
|
*
|
13
|
-
* @
|
14
|
-
*
|
11
|
+
* @cssprop [--width] - The width the drawer.
|
12
|
+
*
|
13
|
+
* @event close
|
14
|
+
* @event open
|
15
15
|
*
|
16
16
|
* @slot - The content of the Drawer.
|
17
17
|
*/
|
package/dist/drawer.stories.d.ts
CHANGED
package/dist/dropdown.d.ts
CHANGED
@@ -11,8 +11,9 @@ declare global {
|
|
11
11
|
/**
|
12
12
|
* @description A dropdown with optional description and tooltip. Participates in forms and validation via `FormData` and various methods.
|
13
13
|
*
|
14
|
-
* @event change -
|
15
|
-
* @event input -
|
14
|
+
* @event change - `(event: Event) => void`
|
15
|
+
* @event input - `(event: Event) => void`
|
16
|
+
* @event invalid - `(event: Event) => void`
|
16
17
|
*
|
17
18
|
* @slot - One or more of `<glide-core-dropdown-option>`.
|
18
19
|
* @slot tooltip - Content for the tooltip.
|
package/dist/icon-button.d.ts
CHANGED
package/dist/input.d.ts
CHANGED
@@ -11,9 +11,10 @@ type SupportedTypes = (typeof SUPPORTED_TYPES)[number];
|
|
11
11
|
/**
|
12
12
|
* @description An input with a label and optional description and tooltip. Participates in forms and validation via `FormData` and various methods.
|
13
13
|
*
|
14
|
-
* @event change - (
|
15
|
-
* @event input - (
|
16
|
-
|
14
|
+
* @event change - `(event: Event) => void`
|
15
|
+
* @event input - `(event: Event) => void`
|
16
|
+
* @event invalid - `(event: Event) => void`
|
17
|
+
*
|
17
18
|
* @slot tooltip - Content for the tooltip.
|
18
19
|
* @slot description - Additional information or context.
|
19
20
|
* @slot prefix - An optional icon slot to display before the input.
|
package/dist/input.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
var __decorate=this&&this.__decorate||function(e,t,i,o){var r,s=arguments.length,a=s<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,o);else for(var l=e.length-1;l>=0;l--)(r=e[l])&&(a=(s<3?r(a):s>3?r(t,i,a):r(t,i))||a);return s>3&&a&&Object.defineProperty(t,i,a),a};import"./icon-button.js";import"./label.js";import{LitElement,html,nothing}from"lit";import{LocalizeController}from"./library/localize.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{ifDefined}from"lit/directives/if-defined.js";import magnifyingGlassIcon from"./icons/magnifying-glass.js";import ow from"./library/ow.js";import styles from"./input.styles.js";export const SUPPORTED_TYPES=["email","number","password","search","tel","text","url"];let GlideCoreInput=class GlideCoreInput extends LitElement{static{this.formAssociated=!0}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:"closed",delegatesFocus:!0}}static{this.styles=styles}get form(){return this.#e.form}get validity(){return!this.required||this.value||this.disabled?this.#t?this.#e.setValidity({tooLong:!0}," ",this.#i.value):this.#e.setValidity({}):this.#e.setValidity({valueMissing:!0}," ",this.#i.value),this.#e.validity}get willValidate(){return this.#e.willValidate}blur(){this.#i.value?.blur()}checkValidity(){this.isCheckingValidity=!0;const e=this.#e.checkValidity();return this.isCheckingValidity=!1,e}disconnectedCallback(){super.disconnectedCallback(),this.form?.removeEventListener("formdata",this.#o)}formAssociatedCallback(){this.form?.addEventListener("formdata",this.#o)}formResetCallback(){this.value=this.getAttribute("value")??""}get hasClearIcon(){return this.clearable&&!this.disabled&&!this.readonly}get isClearIconVisible(){return this.hasClearIcon&&this.value.length>0}render(){return html`<glide-core-private-label class="${classMap({left:"left"===this.privateSplit,middle:"middle"===this.privateSplit})}" orientation="${this.orientation}" split="${ifDefined(this.privateSplit??void 0)}" ?disabled="${this.disabled}" ?error="${this.#r||this.#t}" ?hide="${this.hideLabel}" ?required="${this.required}"><slot name="tooltip" slot="tooltip"></slot><label for="input">${this.label}</label><div class="${classMap({"input-container":!0,focused:this.hasFocus,empty:""===this.value,disabled:this.disabled,readonly:this.readonly&&!this.disabled,error:this.#r||this.#t})}" slot="control"><slot name="prefix"></slot><input aria-describedby="meta" aria-invalid="${this.#r||this.#t}" id="input" type="${"password"===this.type&&this.passwordVisible?"text":this.type}" .value="${this.value}" placeholder="${ifDefined(this.placeholder)}" autocapitalize="${ifDefined(this.autocapitalize)}" spellcheck="${this.spellcheck}" ?required="${this.required}" ?readonly="${this.readonly}" ?disabled="${this.disabled}" @focus="${this.#s}" @blur="${this.#a}" @change="${this.#l}" @input="${this.#n}" ${ref(this.#i)}> ${this.hasClearIcon?html`<glide-core-icon-button variant="tertiary" class="${classMap({"clear-icon-button":!0,"clear-icon-button--visible":this.isClearIconVisible})}" data-test="clear-button" label="${this.#d.term("clearEntry",this.label)}" @click="${this.#h}"><svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor"><path d="M6 6L18 18" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M18 6L6 18" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></glide-core-icon-button>`:nothing} ${"password"===this.type&&this.passwordToggle&&!this.disabled?html`<glide-core-icon-button variant="tertiary" class="password-toggle" data-test="password-toggle" label="${this.passwordVisible?"Hide password":"Show password"}" aria-controls="input" aria-expanded="${this.passwordVisible?"true":"false"}" @click="${this.#p}">${this.passwordVisible?html`<svg aria-hidden="true" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M3.98 8.223A10.477 10.477 0 0 0 1.934 12C3.226 16.338 7.244 19.5 12 19.5c.993 0 1.953-.138 2.863-.395M6.228 6.228A10.451 10.451 0 0 1 12 4.5c4.756 0 8.773 3.162 10.065 7.498a10.522 10.522 0 0 1-4.293 5.774M6.228 6.228 3 3m3.228 3.228 3.65 3.65m7.894 7.894L21 21m-3.228-3.228-3.65-3.65m0 0a3 3 0 1 0-4.243-4.243m4.242 4.242L9.88 9.88"/></svg>`:html`<svg aria-hidden="true" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M2.036 12.322a1.012 1.012 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178Z"/><path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"/></svg>`}</glide-core-icon-button>`:nothing}<div class="suffix">${"search"===this.type?magnifyingGlassIcon:html`<slot name="suffix"></slot>`}</div></div><div class="meta" id="meta" slot="description"><slot class="description" name="description"></slot>${this.maxlength?html`<div class="${classMap({"character-count":!0,error:this.#t})}" data-test="character-count-container"><span aria-hidden="true" data-test="character-count-text">${this.#d.term("displayedCharacterCount",this.#c,this.maxlength)} </span><span class="hidden" data-test="character-count-announcement">${this.#d.term("announcedCharacterCount",this.#c,this.maxlength)}</span></div>`:nothing}</div></glide-core-private-label>`}reportValidity(){this.isReportValidityOrSubmit=!0;const e=this.#e.reportValidity();return this.requestUpdate(),e}constructor(){super(),this.type="text",this.value="",this.hideLabel=!1,this.orientation="horizontal",this.clearable=!1,this.spellcheck=!1,this.autocapitalize="on",this.passwordToggle=!1,this.required=!1,this.readonly=!1,this.disabled=!1,this.hasFocus=!1,this.isBlurring=!1,this.isCheckingValidity=!1,this.isReportValidityOrSubmit=!1,this.passwordVisible=!1,this.#i=createRef(),this.#d=new LocalizeController(this),this.#o=({formData:e})=>{this.name&&this.value&&!this.disabled&&e.append(this.name,this.value)},this.#e=this.attachInternals(),this.addEventListener("invalid",(e=>{if(e?.preventDefault(),this.isCheckingValidity||this.isBlurring)return;this.isReportValidityOrSubmit=!0;this.form?.querySelector(":invalid")===this&&this.focus()}))}#i;#e;#d;get#c(){return this.value.length}#o;get#t(){return Boolean(!this.disabled&&!this.readonly&&this.maxlength&&this.#c>this.maxlength)}get#r(){return!this.disabled&&!this.validity?.valid&&this.isReportValidityOrSubmit}#a(){this.isBlurring=!0,this.reportValidity(),this.isBlurring=!1,this.hasFocus=!1}#l(e){ow(this.#i.value,ow.object.instanceOf(HTMLInputElement)),this.value=this.#i.value?.value,this.dispatchEvent(new Event(e.type,e))}#h(e){this.value="",this.dispatchEvent(new Event("clear",{bubbles:!0})),this.#i.value?.focus(),e.stopPropagation()}#s(){this.hasFocus=!0}#n(){ow(this.#i.value,ow.object.instanceOf(HTMLInputElement)),this.value=this.#i.value.value}#p(){this.passwordVisible=!this.passwordVisible}};__decorate([property()],GlideCoreInput.prototype,"type",void 0),__decorate([property({reflect:!0})],GlideCoreInput.prototype,"name",void 0),__decorate([property()],GlideCoreInput.prototype,"value",void 0),__decorate([property()],GlideCoreInput.prototype,"label",void 0),__decorate([property({attribute:"hide-label",type:Boolean})],GlideCoreInput.prototype,"hideLabel",void 0),__decorate([property({reflect:!0})],GlideCoreInput.prototype,"orientation",void 0),__decorate([property()],GlideCoreInput.prototype,"placeholder",void 0),__decorate([property({type:Boolean})],GlideCoreInput.prototype,"clearable",void 0),__decorate([property({type:Boolean})],GlideCoreInput.prototype,"spellcheck",void 0),__decorate([property()],GlideCoreInput.prototype,"autocapitalize",void 0),__decorate([property({attribute:"password-toggle",type:Boolean})],GlideCoreInput.prototype,"passwordToggle",void 0),__decorate([property({reflect:!0,type:Boolean})],GlideCoreInput.prototype,"required",void 0),__decorate([property({type:Boolean})],GlideCoreInput.prototype,"readonly",void 0),__decorate([property({type:Boolean})],GlideCoreInput.prototype,"disabled",void 0),__decorate([property()],GlideCoreInput.prototype,"privateSplit",void 0),__decorate([property({type:Number,converter:e=>e&&Number.parseInt(e,10)})],GlideCoreInput.prototype,"maxlength",void 0),__decorate([state()],GlideCoreInput.prototype,"hasFocus",void 0),__decorate([state()],GlideCoreInput.prototype,"isBlurring",void 0),__decorate([state()],GlideCoreInput.prototype,"isCheckingValidity",void 0),__decorate([state()],GlideCoreInput.prototype,"isReportValidityOrSubmit",void 0),__decorate([state()],GlideCoreInput.prototype,"passwordVisible",void 0),GlideCoreInput=__decorate([customElement("glide-core-input")],GlideCoreInput);export default GlideCoreInput;
|
1
|
+
var __decorate=this&&this.__decorate||function(e,t,i,o){var r,s=arguments.length,a=s<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,o);else for(var l=e.length-1;l>=0;l--)(r=e[l])&&(a=(s<3?r(a):s>3?r(t,i,a):r(t,i))||a);return s>3&&a&&Object.defineProperty(t,i,a),a};import"./icon-button.js";import"./label.js";import{LitElement,html,nothing}from"lit";import{LocalizeController}from"./library/localize.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{ifDefined}from"lit/directives/if-defined.js";import magnifyingGlassIcon from"./icons/magnifying-glass.js";import ow from"./library/ow.js";import styles from"./input.styles.js";export const SUPPORTED_TYPES=["email","number","password","search","tel","text","url"];let GlideCoreInput=class GlideCoreInput extends LitElement{static{this.formAssociated=!0}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:"closed",delegatesFocus:!0}}static{this.styles=styles}get form(){return this.#e.form}get validity(){return!this.required||this.value||this.disabled?this.#t?this.#e.setValidity({tooLong:!0}," ",this.#i.value):this.#e.setValidity({}):this.#e.setValidity({valueMissing:!0}," ",this.#i.value),this.#e.validity}get willValidate(){return this.#e.willValidate}blur(){this.#i.value?.blur()}checkValidity(){this.isCheckingValidity=!0;const e=this.#e.checkValidity();return this.isCheckingValidity=!1,e}disconnectedCallback(){super.disconnectedCallback(),this.form?.removeEventListener("formdata",this.#o)}formAssociatedCallback(){this.form?.addEventListener("formdata",this.#o)}formResetCallback(){this.value=this.getAttribute("value")??""}get hasClearIcon(){return this.clearable&&!this.disabled&&!this.readonly}get isClearIconVisible(){return this.hasClearIcon&&this.value.length>0}render(){return html`<glide-core-private-label class="${classMap({left:"left"===this.privateSplit,middle:"middle"===this.privateSplit})}" orientation="${this.orientation}" split="${ifDefined(this.privateSplit??void 0)}" ?disabled="${this.disabled}" ?error="${this.#r||this.#t}" ?hide="${this.hideLabel}" ?required="${this.required}"><slot name="tooltip" slot="tooltip"></slot><label for="input">${this.label}</label><div class="${classMap({"input-container":!0,focused:this.hasFocus,empty:""===this.value,disabled:this.disabled,readonly:this.readonly&&!this.disabled,error:this.#r||this.#t})}" slot="control"><slot name="prefix"></slot><input aria-describedby="meta" aria-invalid="${this.#r||this.#t}" id="input" type="${"password"===this.type&&this.passwordVisible?"text":this.type}" .value="${this.value}" placeholder="${ifDefined(this.placeholder)}" autocapitalize="${ifDefined(this.autocapitalize)}" spellcheck="${this.spellcheck}" ?required="${this.required}" ?readonly="${this.readonly}" ?disabled="${this.disabled}" @focus="${this.#s}" @blur="${this.#a}" @change="${this.#l}" @input="${this.#n}" ${ref(this.#i)}> ${this.hasClearIcon?html`<glide-core-icon-button variant="tertiary" class="${classMap({"clear-icon-button":!0,"clear-icon-button--visible":this.isClearIconVisible})}" data-test="clear-button" label="${this.#d.term("clearEntry",this.label)}" @click="${this.#h}"><svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor"><path d="M6 6L18 18" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M18 6L6 18" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></glide-core-icon-button>`:nothing} ${"password"===this.type&&this.passwordToggle&&!this.disabled?html`<glide-core-icon-button variant="tertiary" class="password-toggle" data-test="password-toggle" label="${this.passwordVisible?"Hide password":"Show password"}" aria-controls="input" aria-expanded="${this.passwordVisible?"true":"false"}" @click="${this.#p}">${this.passwordVisible?html`<svg aria-hidden="true" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M3.98 8.223A10.477 10.477 0 0 0 1.934 12C3.226 16.338 7.244 19.5 12 19.5c.993 0 1.953-.138 2.863-.395M6.228 6.228A10.451 10.451 0 0 1 12 4.5c4.756 0 8.773 3.162 10.065 7.498a10.522 10.522 0 0 1-4.293 5.774M6.228 6.228 3 3m3.228 3.228 3.65 3.65m7.894 7.894L21 21m-3.228-3.228-3.65-3.65m0 0a3 3 0 1 0-4.243-4.243m4.242 4.242L9.88 9.88"/></svg>`:html`<svg aria-hidden="true" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M2.036 12.322a1.012 1.012 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178Z"/><path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"/></svg>`}</glide-core-icon-button>`:nothing}<div class="suffix">${"search"===this.type?magnifyingGlassIcon:html`<slot name="suffix"></slot>`}</div></div><div class="meta" id="meta" slot="description"><slot class="description" name="description"></slot>${this.maxlength?html`<div class="${classMap({"character-count":!0,error:this.#t})}" data-test="character-count-container"><span aria-hidden="true" data-test="character-count-text">${this.#d.term("displayedCharacterCount",this.#c,this.maxlength)} </span><span class="hidden" data-test="character-count-announcement">${this.#d.term("announcedCharacterCount",this.#c,this.maxlength)}</span></div>`:nothing}</div></glide-core-private-label>`}reportValidity(){this.isReportValidityOrSubmit=!0;const e=this.#e.reportValidity();return this.requestUpdate(),e}constructor(){super(),this.type="text",this.value="",this.hideLabel=!1,this.orientation="horizontal",this.clearable=!1,this.spellcheck=!1,this.autocapitalize="on",this.passwordToggle=!1,this.required=!1,this.readonly=!1,this.disabled=!1,this.hasFocus=!1,this.isBlurring=!1,this.isCheckingValidity=!1,this.isReportValidityOrSubmit=!1,this.passwordVisible=!1,this.#i=createRef(),this.#d=new LocalizeController(this),this.#o=({formData:e})=>{this.name&&this.value&&!this.disabled&&e.append(this.name,this.value)},this.#e=this.attachInternals(),this.addEventListener("invalid",(e=>{if(e?.preventDefault(),this.isCheckingValidity||this.isBlurring)return;this.isReportValidityOrSubmit=!0;this.form?.querySelector(":invalid")===this&&this.focus()}))}#i;#e;#d;get#c(){return this.value.length}#o;get#t(){return Boolean(!this.disabled&&!this.readonly&&this.maxlength&&this.#c>this.maxlength)}get#r(){return!this.disabled&&!this.validity?.valid&&this.isReportValidityOrSubmit}#a(){this.isBlurring=!0,this.reportValidity(),this.isBlurring=!1,this.hasFocus=!1}#l(e){ow(this.#i.value,ow.object.instanceOf(HTMLInputElement)),this.value=this.#i.value?.value,this.dispatchEvent(new Event(e.type,e))}#h(e){this.value="",this.dispatchEvent(new Event("clear",{bubbles:!0})),this.#i.value?.focus(),e.stopPropagation()}#s(){this.hasFocus=!0}#n(){ow(this.#i.value,ow.object.instanceOf(HTMLInputElement)),this.value=this.#i.value.value}#p(){this.passwordVisible=!this.passwordVisible}};__decorate([property()],GlideCoreInput.prototype,"type",void 0),__decorate([property({reflect:!0})],GlideCoreInput.prototype,"name",void 0),__decorate([property()],GlideCoreInput.prototype,"value",void 0),__decorate([property()],GlideCoreInput.prototype,"label",void 0),__decorate([property({attribute:"hide-label",type:Boolean})],GlideCoreInput.prototype,"hideLabel",void 0),__decorate([property({reflect:!0})],GlideCoreInput.prototype,"orientation",void 0),__decorate([property()],GlideCoreInput.prototype,"placeholder",void 0),__decorate([property({type:Boolean})],GlideCoreInput.prototype,"clearable",void 0),__decorate([property({reflect:!0,type:Boolean})],GlideCoreInput.prototype,"spellcheck",void 0),__decorate([property()],GlideCoreInput.prototype,"autocapitalize",void 0),__decorate([property({attribute:"password-toggle",type:Boolean})],GlideCoreInput.prototype,"passwordToggle",void 0),__decorate([property({reflect:!0,type:Boolean})],GlideCoreInput.prototype,"required",void 0),__decorate([property({type:Boolean})],GlideCoreInput.prototype,"readonly",void 0),__decorate([property({type:Boolean})],GlideCoreInput.prototype,"disabled",void 0),__decorate([property()],GlideCoreInput.prototype,"privateSplit",void 0),__decorate([property({type:Number,converter:e=>e&&Number.parseInt(e,10)})],GlideCoreInput.prototype,"maxlength",void 0),__decorate([state()],GlideCoreInput.prototype,"hasFocus",void 0),__decorate([state()],GlideCoreInput.prototype,"isBlurring",void 0),__decorate([state()],GlideCoreInput.prototype,"isCheckingValidity",void 0),__decorate([state()],GlideCoreInput.prototype,"isReportValidityOrSubmit",void 0),__decorate([state()],GlideCoreInput.prototype,"passwordVisible",void 0),GlideCoreInput=__decorate([customElement("glide-core-input")],GlideCoreInput);export default GlideCoreInput;
|
package/dist/label.styles.js
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
import{css}from"lit";import focusOutline from"./styles/focus-outline.js";import visuallyHidden from"./styles/visually-hidden.js";export default[css`
|
2
2
|
.component {
|
3
3
|
&.horizontal {
|
4
|
+
--column-gap: var(--glide-core-spacing-sm);
|
5
|
+
|
4
6
|
column-gap: var(--glide-core-spacing-sm);
|
5
7
|
display: grid;
|
6
8
|
grid-template-columns: auto minmax(min-content, 1fr);
|
@@ -16,7 +18,9 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";import
|
|
16
18
|
}
|
17
19
|
|
18
20
|
&.middle {
|
19
|
-
grid-template-columns: 50%
|
21
|
+
grid-template-columns: calc(50% - var(--column-gap) / 2) calc(
|
22
|
+
50% - var(--column-gap) / 2
|
23
|
+
);
|
20
24
|
}
|
21
25
|
|
22
26
|
&.hidden-label {
|
@@ -31,12 +35,11 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";import
|
|
31
35
|
display: flex;
|
32
36
|
|
33
37
|
/*
|
34
|
-
|
35
|
-
Layout. Also allows for an ellipsis on the label. See the linked comment for why it's "3ch"
|
38
|
+
Allows for an ellipsis on the label. See the linked comment for why it's "3ch"
|
36
39
|
instead of "0".
|
37
40
|
|
38
|
-
- https://css-tricks.com/flexbox-truncated-text/#aa-the-solution-is-min-width-0-on-the-flex-child
|
39
41
|
- https://github.com/CrowdStrike/glide-core/pull/317#issuecomment-2297025365
|
42
|
+
- https://css-tricks.com/flexbox-truncated-text/#aa-the-solution-is-min-width-0-on-the-flex-child
|
40
43
|
*/
|
41
44
|
min-inline-size: 3ch;
|
42
45
|
|
package/dist/menu.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
var __decorate=this&&this.__decorate||function(e,t,i,o){var n,s=arguments.length,l=s<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,t,i,o);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(l=(s<3?n(l):s>3?n(t,i,l):n(t,i))||l);return s>3&&l&&Object.defineProperty(t,i,l),l};import{LitElement,html}from"lit";import{autoUpdate,computePosition,flip,offset}from"@floating-ui/dom";import{createRef,ref}from"lit/directives/ref.js";import{customElement,property}from"lit/decorators.js";import{nanoid}from"nanoid";import GlideCoreMenuButton from"./menu.button.js";import GlideCoreMenuLink from"./menu.link.js";import GlideCoreMenuOptions from"./menu.options.js";import ow,{owSlot,owSlotType}from"./library/ow.js";import styles from"./menu.styles.js";let GlideCoreMenu=class GlideCoreMenu extends LitElement{constructor(){super(...arguments),this.placement="bottom-start",this.#e=createRef(),this.#t=createRef(),this.#i=!1,this.#o=!1,this.#n="large",this.#s=createRef(),this.#l=e=>{e.target&&e.target instanceof Node&&this.contains(e.target)||(this.open=!1,this.#a&&(this.#a.ariaActivedescendant=""))}}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:"closed"}}static{this.styles=styles}get open(){return this.#o}set open(e){this.#o=e,e&&!this.isTargetDisabled?this.#r():this.#c()}get size(){return this.#n}set size(e){this.#n=e,this.#a&&(this.#a.privateSize=e)}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this.#l,{capture:!0})}createRenderRoot(){return this.#d=super.createRenderRoot(),this.#d}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this.#l,{capture:!0})}firstUpdated(){ow(this.#a,ow.object.instanceOf(GlideCoreMenuOptions)),owSlot(this.#t.value),owSlot(this.#s.value),owSlotType(this.#t.value,[GlideCoreMenuOptions]),this.#t.value.popover="manual";const e=this.#h?.at(0);this.open&&e&&!this.isTargetDisabled&&(e.privateActive=!0,this.#r())}focus(e){this.#p&&"focus"in this.#p&&this.#p?.focus(e)}get isTargetDisabled(){const e=this.#p&&"disabled"in this.#p&&this.#p.disabled,t=this.#p&&"true"===this.#p.ariaDisabled;return Boolean(e)||Boolean(t)}render(){return html`<div class="component" @focusout="${this.#
|
1
|
+
var __decorate=this&&this.__decorate||function(e,t,i,o){var n,s=arguments.length,l=s<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,t,i,o);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(l=(s<3?n(l):s>3?n(t,i,l):n(t,i))||l);return s>3&&l&&Object.defineProperty(t,i,l),l};import{LitElement,html}from"lit";import{autoUpdate,computePosition,flip,offset}from"@floating-ui/dom";import{createRef,ref}from"lit/directives/ref.js";import{customElement,property}from"lit/decorators.js";import{nanoid}from"nanoid";import GlideCoreMenuButton from"./menu.button.js";import GlideCoreMenuLink from"./menu.link.js";import GlideCoreMenuOptions from"./menu.options.js";import ow,{owSlot,owSlotType}from"./library/ow.js";import styles from"./menu.styles.js";let GlideCoreMenu=class GlideCoreMenu extends LitElement{constructor(){super(...arguments),this.placement="bottom-start",this.#e=createRef(),this.#t=createRef(),this.#i=!1,this.#o=!1,this.#n="large",this.#s=createRef(),this.#l=e=>{e.target&&e.target instanceof Node&&this.contains(e.target)||(this.open=!1,this.#a&&(this.#a.ariaActivedescendant=""))}}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:"closed"}}static{this.styles=styles}get open(){return this.#o}set open(e){this.#o=e,e&&!this.isTargetDisabled?this.#r():this.#c()}get size(){return this.#n}set size(e){this.#n=e,this.#a&&(this.#a.privateSize=e)}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this.#l,{capture:!0})}createRenderRoot(){return this.#d=super.createRenderRoot(),this.#d}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this.#l,{capture:!0})}firstUpdated(){ow(this.#a,ow.object.instanceOf(GlideCoreMenuOptions)),owSlot(this.#t.value),owSlot(this.#s.value),owSlotType(this.#t.value,[GlideCoreMenuOptions]),this.#t.value.popover="manual";const e=this.#h?.at(0);this.open&&e&&!this.isTargetDisabled&&(e.privateActive=!0,this.#r())}focus(e){this.#p&&"focus"in this.#p&&this.#p?.focus(e)}get isTargetDisabled(){const e=this.#p&&"disabled"in this.#p&&this.#p.disabled,t=this.#p&&"true"===this.#p.ariaDisabled;return Boolean(e)||Boolean(t)}render(){return html`<div class="component" @focusout="${this.#u}" ${ref(this.#e)}><slot class="target-slot" name="target" @click="${this.#m}" @keydown="${this.#f}" @slotchange="${this.#E}" ${ref(this.#s)}></slot><slot class="default-slot" @click="${this.#v}" @focusin="${this.#g}" @keydown="${this.#f}" @mouseover="${this.#w}" @slotchange="${this.#S}" ${ref(this.#t)}></slot></div>`}#C;#e;#t;#i;#o;#d;#n;#s;get#y(){return this.#h?.find((({privateActive:e})=>e))}#l;#c(){this.#C?.(),this.#a&&(this.#a.ariaActivedescendant=""),this.#p&&(this.#p.ariaExpanded="false"),this.#t.value?.hidePopover()}get#a(){const e=this.#t.value?.assignedElements().at(0);return e instanceof GlideCoreMenuOptions?e:null}#S(){ow(this.#a,ow.object.instanceOf(GlideCoreMenuOptions)),owSlot(this.#t.value),owSlotType(this.#t.value,[GlideCoreMenuOptions]);const e=this.#h?.at(0);e&&(e.privateActive=!0),this.#a.privateSize=this.size}#v(){this.open=!1}#g(e){(e.target instanceof GlideCoreMenuButton||e.target instanceof GlideCoreMenuLink)&&this.#y&&this.#a&&(e.target.privateActive=!0,this.#y.privateActive=!1,this.#a.ariaActivedescendant=e.target.id)}#w(e){if(e.target instanceof GlideCoreMenuLink||e.target instanceof GlideCoreMenuButton){if(this.#h)for(const t of this.#h)t.privateActive=t===e.target;this.#a&&(this.#a.ariaActivedescendant=e.target.id)}}#u(e){const t=e.relatedTarget instanceof HTMLElement&&this.#d?.contains(e.relatedTarget),i=e.relatedTarget instanceof GlideCoreMenuOptions,o=e.relatedTarget instanceof GlideCoreMenuButton||e.relatedTarget instanceof GlideCoreMenuLink;t||i||o||(this.open=!1)}#f(e){if(ow(this.#a,ow.object.instanceOf(GlideCoreMenuOptions)),[" ","Enter"].includes(e.key)&&this.open)return this.open=!1,this.focus(),this.#y?.dispatchEvent(new PointerEvent("click",{bubbles:!0})),void(this.#i=!0);if(["Escape"].includes(e.key)&&this.open)return this.open=!1,void this.focus();if([" ","ArrowUp","ArrowDown"].includes(e.key)&&!this.open&&this.#y)return e.preventDefault(),this.open=!0,void(this.#a.ariaActivedescendant=this.#y.id);if(this.open){ow(this.#h,ow.array),ow(this.#a,ow.object.instanceOf(GlideCoreMenuOptions)),ow(this.#y,ow.object.is((e=>e instanceof GlideCoreMenuButton||e instanceof GlideCoreMenuLink)));const t=this.#h.indexOf(this.#y);if("ArrowUp"===e.key&&!e.metaKey){e.preventDefault();const i=this.#h.at(t-1);return void(i&&0!==t&&(this.#y.privateActive=!1,this.#a.ariaActivedescendant=i.id,i.privateActive=!0))}if("ArrowDown"===e.key&&!e.metaKey){e.preventDefault();const i=this.#h.at(t+1);return void(i&&(this.#y.privateActive=!1,this.#a.ariaActivedescendant=i.id,i.privateActive=!0))}if("ArrowUp"===e.key&&e.metaKey||"Home"===e.key||"PageUp"===e.key){e.preventDefault();const t=this.#h.at(0);return void(t&&(this.#y.privateActive=!1,this.#a.ariaActivedescendant=t.id,t.privateActive=!0))}if("ArrowDown"===e.key&&e.metaKey||"End"===e.key||"PageDown"===e.key){e.preventDefault();const t=this.#h.at(-1);return void(t&&(this.#y.privateActive=!1,this.#a.ariaActivedescendant=t.id,t.privateActive=!0))}}}#E(){owSlot(this.#s.value),ow(this.#p,ow.object.instanceOf(Element)),ow(this.#a,ow.object.instanceOf(GlideCoreMenuOptions));new MutationObserver((e=>{e.some((e=>"disabled"===e.attributeName||"aria-disabled"===e.attributeName))&&(this.open&&!this.isTargetDisabled?this.#r():this.#c())})).observe(this.#p,{attributes:!0}),this.#p.ariaHasPopup="true",this.#p.id=nanoid(),this.#p.setAttribute("aria-controls",this.#a.id),this.#a.ariaLabelledby=this.#p.id,this.open&&!this.isTargetDisabled?this.#r():this.#c()}#m(){this.isTargetDisabled?this.#c():this.#i?this.#i=!1:this.#h&&this.#h.length>0&&(this.open=!this.open)}get#h(){let e=this.#t.value?.assignedElements()?.at(0)?.children;const t=e?.[0];if(t instanceof HTMLSlotElement&&(e=t.assignedElements()),e)return[...e].filter((e=>e instanceof GlideCoreMenuLink||e instanceof GlideCoreMenuButton))}#r(){this.#C?.(),this.#p&&this.#t.value&&(this.#C=autoUpdate(this.#p,this.#t.value,(()=>{(async()=>{if(this.#p&&this.#t.value){const{x:e,y:t,placement:i}=await computePosition(this.#p,this.#t.value,{placement:this.placement,middleware:[offset({mainAxis:Number.parseFloat(window.getComputedStyle(document.body).getPropertyValue("--glide-core-spacing-xxs"))*Number.parseFloat(window.getComputedStyle(document.documentElement).fontSize)}),flip()]});this.#t.value.dataset.placement=i,Object.assign(this.#t.value.style,{left:`${e}px`,top:`${t}px`})}this.#t.value?.showPopover(),this.#a&&this.#y?.id&&(this.#a.ariaActivedescendant=this.#y.id),this.#p&&(this.#p.ariaExpanded="true")})()})))}get#p(){return this.#s.value?.assignedElements().at(0)}};__decorate([property({reflect:!0,type:Boolean})],GlideCoreMenu.prototype,"open",null),__decorate([property({reflect:!0})],GlideCoreMenu.prototype,"placement",void 0),__decorate([property({reflect:!0})],GlideCoreMenu.prototype,"size",null),GlideCoreMenu=__decorate([customElement("glide-core-menu")],GlideCoreMenu);export default GlideCoreMenu;
|