@crowdstrike/glide-core 0.5.2 → 0.6.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.
Files changed (100) hide show
  1. package/README.md +11 -1
  2. package/dist/accordion.styles.js +1 -0
  3. package/dist/button-group.button.js +1 -1
  4. package/dist/button-group.button.styles.js +2 -1
  5. package/dist/button.d.ts +3 -2
  6. package/dist/button.js +1 -1
  7. package/dist/button.styles.js +1 -1
  8. package/dist/button.test.basics.js +6 -0
  9. package/dist/checkbox.js +1 -1
  10. package/dist/checkbox.styles.js +4 -1
  11. package/dist/drawer.js +1 -1
  12. package/dist/drawer.styles.js +1 -5
  13. package/dist/drawer.test.floating-components.d.ts +1 -0
  14. package/dist/drawer.test.floating-components.js +51 -0
  15. package/dist/dropdown.js +1 -1
  16. package/dist/dropdown.option.js +1 -1
  17. package/dist/dropdown.option.test.interactions.multiple.js +1 -6
  18. package/dist/dropdown.styles.js +1 -0
  19. package/dist/dropdown.test.focus.js +11 -1
  20. package/dist/dropdown.test.interactions.filterable.js +64 -0
  21. package/dist/icon-button.d.ts +3 -2
  22. package/dist/icon-button.js +1 -1
  23. package/dist/icon-button.styles.js +9 -9
  24. package/dist/icon-button.test.basics.js +13 -6
  25. package/dist/input.js +1 -1
  26. package/dist/input.styles.js +1 -0
  27. package/dist/label.js +1 -1
  28. package/dist/label.styles.js +11 -13
  29. package/dist/library/localize.d.ts +17 -0
  30. package/dist/library/localize.js +1 -0
  31. package/dist/library/set-containing-block.d.ts +15 -0
  32. package/dist/library/set-containing-block.js +1 -0
  33. package/dist/menu.button.js +1 -1
  34. package/dist/menu.d.ts +5 -4
  35. package/dist/menu.js +1 -1
  36. package/dist/menu.link.js +1 -1
  37. package/dist/menu.options.d.ts +22 -0
  38. package/dist/menu.options.js +1 -0
  39. package/dist/menu.options.styles.d.ts +2 -0
  40. package/dist/menu.options.styles.js +33 -0
  41. package/dist/menu.options.test.basics.d.ts +2 -0
  42. package/dist/menu.options.test.basics.js +43 -0
  43. package/dist/menu.stories.d.ts +1 -0
  44. package/dist/menu.styles.js +3 -27
  45. package/dist/menu.test.basics.d.ts +1 -0
  46. package/dist/menu.test.basics.js +67 -45
  47. package/dist/menu.test.focus.js +34 -16
  48. package/dist/menu.test.interactions.d.ts +1 -0
  49. package/dist/menu.test.interactions.js +315 -173
  50. package/dist/modal.js +1 -1
  51. package/dist/modal.styles.js +1 -4
  52. package/dist/modal.tertiary-icon.d.ts +1 -0
  53. package/dist/modal.tertiary-icon.js +1 -1
  54. package/dist/modal.test.floating-components.d.ts +1 -0
  55. package/dist/modal.test.floating-components.js +62 -0
  56. package/dist/radio-group.js +1 -1
  57. package/dist/radio-group.styles.js +18 -22
  58. package/dist/radio.styles.js +11 -28
  59. package/dist/split-button.d.ts +3 -0
  60. package/dist/split-button.js +1 -1
  61. package/dist/split-button.styles.js +0 -1
  62. package/dist/split-button.test.basics.js +16 -1
  63. package/dist/split-container.d.ts +1 -0
  64. package/dist/split-container.js +1 -1
  65. package/dist/split-container.styles.js +2 -0
  66. package/dist/split-container.test.basics.js +11 -16
  67. package/dist/styles/focus-outline.js +1 -1
  68. package/dist/styles/variables.css +1 -1
  69. package/dist/tab.js +1 -1
  70. package/dist/tab.styles.js +79 -54
  71. package/dist/tag.js +1 -1
  72. package/dist/tag.styles.js +1 -0
  73. package/dist/tag.test.basics.js +1 -1
  74. package/dist/tag.test.translations.d.ts +1 -0
  75. package/dist/tag.test.translations.js +25 -0
  76. package/dist/textarea.styles.js +2 -1
  77. package/dist/toasts.js +1 -1
  78. package/dist/toasts.toast.js +1 -1
  79. package/dist/toggle.js +1 -1
  80. package/dist/toggle.test.basics.js +4 -0
  81. package/dist/toggle.test.states.js +8 -0
  82. package/dist/tooltip.d.ts +2 -0
  83. package/dist/tooltip.js +1 -1
  84. package/dist/tooltip.styles.js +2 -0
  85. package/dist/translations/en.d.ts +3 -0
  86. package/dist/translations/en.js +1 -0
  87. package/dist/translations/fr.d.ts +3 -0
  88. package/dist/translations/fr.js +1 -0
  89. package/dist/translations/ja.d.ts +3 -0
  90. package/dist/translations/ja.js +1 -0
  91. package/dist/tree.d.ts +1 -0
  92. package/dist/tree.item.d.ts +3 -1
  93. package/dist/tree.item.js +1 -1
  94. package/dist/tree.item.menu.d.ts +2 -0
  95. package/dist/tree.item.menu.js +1 -1
  96. package/dist/tree.item.menu.test.basics.js +6 -7
  97. package/dist/tree.item.styles.js +22 -7
  98. package/dist/tree.js +1 -1
  99. package/dist/tree.stories.d.ts +1 -0
  100. package/package.json +19 -13
@@ -1,14 +1,14 @@
1
1
  import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export default[css`
2
2
  :host {
3
3
  /* Contains elements with "padding" and "width". Inline by default. */
4
- display: inline-block;
4
+ display: inline-flex;
5
5
  }
6
6
 
7
7
  .component {
8
8
  align-items: center;
9
9
  block-size: var(--size, 1.625rem);
10
10
  border-color: transparent;
11
- border-radius: var(--glide-core-spacing-xs);
11
+ border-radius: 0.5rem;
12
12
  border-style: solid;
13
13
  border-width: 1px;
14
14
  cursor: pointer;
@@ -26,11 +26,10 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export
26
26
 
27
27
  &:focus-visible {
28
28
  ${focusOutline};
29
- outline-offset: 3px;
30
29
  }
31
30
 
32
31
  &:disabled {
33
- cursor: default;
32
+ cursor: not-allowed;
34
33
  opacity: 1;
35
34
  }
36
35
 
@@ -61,12 +60,11 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export
61
60
 
62
61
  &.secondary {
63
62
  background-color: var(--glide-core-surface-page);
64
- border-color: var(--glide-core-border-primary);
65
- color: var(--icon-color, var(--glide-core-icon-primary));
63
+ border-color: transparent;
64
+ color: var(--icon-color, var(--glide-core-icon-default));
66
65
 
67
66
  &:disabled {
68
67
  background-color: transparent;
69
- border-color: var(--glide-core-border-base-light);
70
68
  color: var(--glide-core-icon-tertiary-disabled);
71
69
  }
72
70
 
@@ -79,18 +77,20 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export
79
77
  &:not(:active):hover:not(:disabled) {
80
78
  background-color: var(--glide-core-surface-hover);
81
79
  border-color: transparent;
82
- box-shadow: var(--glide-core-glow-sm);
83
80
  color: var(--glide-core-icon-primary);
84
81
  }
85
82
  }
86
83
 
87
84
  &.tertiary {
88
85
  background-color: transparent;
86
+ block-size: var(--size, 1rem);
89
87
  border-color: transparent;
90
88
  color: var(--icon-color, var(--glide-core-icon-default));
89
+ inline-size: var(--size, 1rem);
90
+ padding: 0;
91
91
 
92
92
  &:focus-visible {
93
- outline-offset: 0;
93
+ border-radius: 0.0625rem;
94
94
  }
95
95
 
96
96
  &:disabled {
@@ -1,6 +1,6 @@
1
1
  import './icon-button.js';
2
2
  import { ArgumentError } from 'ow';
3
- import { expect, fixture, html } from '@open-wc/testing';
3
+ import { assert, expect, fixture, html } from '@open-wc/testing';
4
4
  import GlideCoreIconButton from './icon-button.js';
5
5
  import sinon from 'sinon';
6
6
  GlideCoreIconButton.shadowRootOptions.mode = 'open';
@@ -30,11 +30,18 @@ it('has defaults', async () => {
30
30
  const component = await fixture(html `<glide-core-icon-button label="test-icon-button"
31
31
  >${icon}</glide-core-icon-button
32
32
  >`);
33
- expect(component.shadowRoot?.querySelector('button')?.type).to.equal('button');
34
- expect(component.shadowRoot?.querySelector('button')?.disabled).to.equal(false);
35
- expect([
36
- ...component.shadowRoot.querySelector('button').classList,
37
- ]).to.deep.equal(['component', 'primary']);
33
+ const button = component.shadowRoot?.querySelector('button');
34
+ assert(button);
35
+ expect(component.ariaControls).to.equal(null);
36
+ expect(component.ariaExpanded).to.equal(null);
37
+ expect(component.ariaHasPopup).to.equal(null);
38
+ expect(component.disabled).to.equal(false);
39
+ expect(component.variant).to.equal('primary');
40
+ expect(button.getAttribute('aria-controls')).to.equal(null);
41
+ expect(button.ariaExpanded).to.equal(null);
42
+ expect(button.ariaHasPopup).to.equal(null);
43
+ expect(button.disabled).to.equal(false);
44
+ expect([...button.classList]).to.deep.equal(['component', 'primary']);
38
45
  });
39
46
  it('delegates focus', async () => {
40
47
  const component = await fixture(html `<glide-core-icon-button label="test-icon-button"
package/dist/input.js CHANGED
@@ -1 +1 @@
1
- var __decorate=this&&this.__decorate||function(e,t,i,o){var s,r=arguments.length,a=r<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--)(s=e[l])&&(a=(r<3?s(a):r>3?s(t,i,a):s(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a};import"./icon-button.js";import"./label.js";import{LitElement,html,nothing}from"lit";import{classMap}from"lit/directives/class-map.js";import{createRef,ref}from"lit/directives/ref.js";import{customElement,property,queryAssignedNodes,state}from"lit/decorators.js";import{ifDefined}from"lit/directives/if-defined.js";import magnifyingGlassIcon from"./icons/magnifying-glass.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.#e.validity}get willValidate(){return this.#e.willValidate}blur(){this.#t?.blur()}checkValidity(){return this.isCheckingValidity=!0,this.#e.checkValidity()}disconnectedCallback(){super.disconnectedCallback(),this.form?.removeEventListener("formdata",this.#i)}firstUpdated(){this.#o()}formAssociatedCallback(){this.form?.addEventListener("formdata",this.#i)}formResetCallback(){this.value=this.getAttribute("value")??""}get isTypeSearch(){return"search"===this.type}get hasClearIcon(){return this.clearable&&!this.disabled&&!this.readonly}get isClearIconVisible(){return this.hasClearIcon&&this.value.length>0}render(){return html`<glide-core-label orientation="${this.orientation}" ?disabled="${this.disabled}" ?error="${this.#s||this.#r}" ?hide="${this.hideLabel}" ?required="${this.required}"><slot name="tooltip" slot="tooltip"></slot><label for="input">${this.label}</label><div class="${classMap({"input-box":!0,focused:this.hasFocus,empty:""===this.value,disabled:this.disabled,readonly:this.readonly&&!this.disabled,error:this.#s||this.#r})}" slot="control"><slot name="prefix"></slot><input aria-describedby="meta" 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.#a}" @blur="${this.#l}" @change="${this.#n}" @input="${this.#d}" ${ref(this.#p)}> ${this.hasClearIcon?html`<glide-core-icon-button variant="tertiary" class="${classMap({"clear-icon-button":!0,"clear-icon-button--visible":this.isClearIconVisible})}" aria-label="Clear entry" @click="${this.#h}" tabindex="-1"><slot name="clear-icon"><svg 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></slot></glide-core-icon-button>`:""} ${"password"===this.type&&this.passwordToggle&&!this.disabled?html`<glide-core-icon-button variant="tertiary" class="password-toggle" aria-label="${this.passwordVisible?"Hide password":"Show password"}" aria-controls="input" aria-expanded="${this.passwordVisible?"true":"false"}" @click="${this.#c}" tabindex="-1">${this.passwordVisible?html`<svg 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 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>`:""}<div class="suffix">${this.isTypeSearch?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.#r})}">${this.valueCharacterCount}/${this.maxlength}</div>`:nothing}</div></glide-core-label>`}reportValidity(){return this.#e.reportValidity()}get valueCharacterCount(){return this.value.length}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.isReportValidityOrSubmit=!1,this.passwordVisible=!1,this.#p=createRef(),this.#i=({formData:e})=>{this.name&&this.value&&!this.disabled&&e.append(this.name,this.value)},this.#e=this.attachInternals(),this.addEventListener("invalid",(e=>{e?.preventDefault(),this.isCheckingValidity||(this.isReportValidityOrSubmit=!0,this.focus())}))}#p;#e;#i;get#r(){return Boolean(this.maxlength&&this.valueCharacterCount>this.maxlength)}get#s(){return!this.disabled&&!this.validity?.valid&&this.isReportValidityOrSubmit}get#t(){return this.#p.value}#l(){this.hasFocus=!1}#n(e){this.value=this.#t.value,this.#o(),this.dispatchEvent(new Event(e.type,e))}#h(e){this.value="",this.dispatchEvent(new Event("clear",{bubbles:!0})),this.#t?.focus(),this.#o(),e.stopPropagation()}#a(){this.hasFocus=!0}#d(){const e=this.#t.value;this.value=e,this.#o()}#c(){this.passwordVisible=!this.passwordVisible}async#o(){await this.updateComplete,this.#e.setValidity(this.#t?.validity,this.#t?.validationMessage,this.#t)}};__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({type:Number,converter:e=>e&&Number.parseInt(e,10)})],GlideCoreInput.prototype,"maxlength",void 0),__decorate([queryAssignedNodes({slot:"description"})],GlideCoreInput.prototype,"descriptionNodes",void 0),__decorate([queryAssignedNodes({slot:"prefix"})],GlideCoreInput.prototype,"prefixIconNodes",void 0),__decorate([queryAssignedNodes({slot:"suffix"})],GlideCoreInput.prototype,"suffixIconNodes",void 0),__decorate([state()],GlideCoreInput.prototype,"hasFocus",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 s,r=arguments.length,a=r<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--)(s=e[l])&&(a=(r<3?s(a):r>3?s(t,i,a):s(t,i))||a);return r>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,queryAssignedNodes,state}from"lit/decorators.js";import{ifDefined}from"lit/directives/if-defined.js";import magnifyingGlassIcon from"./icons/magnifying-glass.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.#e.validity}get willValidate(){return this.#e.willValidate}blur(){this.#t?.blur()}checkValidity(){return this.isCheckingValidity=!0,this.#e.checkValidity()}disconnectedCallback(){super.disconnectedCallback(),this.form?.removeEventListener("formdata",this.#i)}firstUpdated(){this.#o()}formAssociatedCallback(){this.form?.addEventListener("formdata",this.#i)}formResetCallback(){this.value=this.getAttribute("value")??""}get isTypeSearch(){return"search"===this.type}get hasClearIcon(){return this.clearable&&!this.disabled&&!this.readonly}get isClearIconVisible(){return this.hasClearIcon&&this.value.length>0}render(){return html`<glide-core-label orientation="${this.orientation}" ?disabled="${this.disabled}" ?error="${this.#s||this.#r}" ?hide="${this.hideLabel}" ?required="${this.required}"><slot name="tooltip" slot="tooltip"></slot><label for="input">${this.label}</label><div class="${classMap({"input-box":!0,focused:this.hasFocus,empty:""===this.value,disabled:this.disabled,readonly:this.readonly&&!this.disabled,error:this.#s||this.#r})}" slot="control"><slot name="prefix"></slot><input aria-describedby="meta" 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.#a}" @blur="${this.#l}" @change="${this.#n}" @input="${this.#d}" ${ref(this.#p)}> ${this.hasClearIcon?html`<glide-core-icon-button variant="tertiary" class="${classMap({"clear-icon-button":!0,"clear-icon-button--visible":this.isClearIconVisible})}" aria-label="${this.#h.term("clearEntry")}" @click="${this.#c}" tabindex="-1"><slot name="clear-icon"><svg 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></slot></glide-core-icon-button>`:""} ${"password"===this.type&&this.passwordToggle&&!this.disabled?html`<glide-core-icon-button variant="tertiary" class="password-toggle" aria-label="${this.passwordVisible?"Hide password":"Show password"}" aria-controls="input" aria-expanded="${this.passwordVisible?"true":"false"}" @click="${this.#u}" tabindex="-1">${this.passwordVisible?html`<svg 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 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>`:""}<div class="suffix">${this.isTypeSearch?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.#r})}">${this.valueCharacterCount}/${this.maxlength}</div>`:nothing}</div></glide-core-label>`}reportValidity(){return this.#e.reportValidity()}get valueCharacterCount(){return this.value.length}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.isReportValidityOrSubmit=!1,this.passwordVisible=!1,this.#p=createRef(),this.#h=new LocalizeController(this),this.#i=({formData:e})=>{this.name&&this.value&&!this.disabled&&e.append(this.name,this.value)},this.#e=this.attachInternals(),this.addEventListener("invalid",(e=>{e?.preventDefault(),this.isCheckingValidity||(this.isReportValidityOrSubmit=!0,this.focus())}))}#p;#e;#h;#i;get#r(){return Boolean(this.maxlength&&this.valueCharacterCount>this.maxlength)}get#s(){return!this.disabled&&!this.validity?.valid&&this.isReportValidityOrSubmit}get#t(){return this.#p.value}#l(){this.hasFocus=!1}#n(e){this.value=this.#t.value,this.#o(),this.dispatchEvent(new Event(e.type,e))}#c(e){this.value="",this.dispatchEvent(new Event("clear",{bubbles:!0})),this.#t?.focus(),this.#o(),e.stopPropagation()}#a(){this.hasFocus=!0}#d(){const e=this.#t.value;this.value=e,this.#o()}#u(){this.passwordVisible=!this.passwordVisible}async#o(){await this.updateComplete,this.#e.setValidity(this.#t?.validity,this.#t?.validationMessage,this.#t)}};__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({type:Number,converter:e=>e&&Number.parseInt(e,10)})],GlideCoreInput.prototype,"maxlength",void 0),__decorate([queryAssignedNodes({slot:"description"})],GlideCoreInput.prototype,"descriptionNodes",void 0),__decorate([queryAssignedNodes({slot:"prefix"})],GlideCoreInput.prototype,"prefixIconNodes",void 0),__decorate([queryAssignedNodes({slot:"suffix"})],GlideCoreInput.prototype,"suffixIconNodes",void 0),__decorate([state()],GlideCoreInput.prototype,"hasFocus",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;
@@ -58,6 +58,7 @@ import{css}from"lit";export default css`
58
58
  }
59
59
 
60
60
  input {
61
+ background-color: transparent;
61
62
  border: none;
62
63
  color: inherit;
63
64
  cursor: inherit;
package/dist/label.js CHANGED
@@ -1 +1 @@
1
- var __decorate=this&&this.__decorate||function(t,e,o,l){var i,s=arguments.length,r=s<3?e:null===l?l=Object.getOwnPropertyDescriptor(e,o):l;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,o,l);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(r=(s<3?i(r):s>3?i(e,o,r):i(e,o))||r);return s>3&&r&&Object.defineProperty(e,o,r),r};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{owSlot}from"./library/ow.js";import styles from"./label.styles.js";import{svg}from"lit/static-html.js";const infoCircleIcon=svg`<svg aria-label="More information" width="16" height="16" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2"/><path d="M12 16L12 12" stroke="currentColor" stroke-width="2" stroke-linecap="round"/><circle cx="12" cy="8" r="1" fill="currentColor"/></svg>`;let GlideCoreLabel=class GlideCoreLabel extends LitElement{constructor(){super(...arguments),this.disabled=!1,this.error=!1,this.hide=!1,this.orientation="horizontal",this.required=!1,this.hasDescriptionSlot=!1,this.hasSummarySlot=!1,this.hasTooltipSlot=!1,this.#t=createRef(),this.#e=createRef(),this.#o=createRef(),this.#l=createRef(),this.#i=createRef()}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:"closed"}}static{this.styles=styles}firstUpdated(){owSlot(this.#e.value),owSlot(this.#t.value)}render(){return html`<div class="${classMap({component:!0,horizontal:"horizontal"===this.orientation,vertical:"vertical"===this.orientation,"hidden-label":this.hide})}"><div class="${classMap({"tooltip-and-label":!0,hidden:this.hide})}" part="tooltip-and-label-container"><div class="tooltip-and-label"><glide-core-tooltip class="${classMap({tooltip:!0,vertical:"vertical"===this.orientation,visible:this.hasTooltipSlot})}" placement="${"vertical"===this.orientation?"right":"bottom"}"><span class="tooltip-target" slot="target" tabindex="0">${infoCircleIcon}</span><slot class="${classMap({tooltip:!0,visible:this.hasTooltipSlot})}" name="tooltip" @slotchange="${this.#s}" ${ref(this.#i)}></slot></glide-core-tooltip><div class="${classMap({label:!0,disabled:this.disabled})}" data-test="label"><slot @slotchange="${this.#r}" ${ref(this.#e)}></slot>${this.required?html`<span aria-hidden="true" class="required-symbol">*</span>`:""}</div></div></div><div class="control-and-summary"><slot class="${classMap({control:!0,error:this.error,disabled:this.disabled,vertical:"vertical"===this.orientation,summaryless:!this.hasSummarySlot,"hidden-label":this.hide})}" name="control" @slotchange="${this.#a}" ${ref(this.#t)}></slot><slot class="${classMap({summary:!0,error:this.error})}" name="summary" @slotchange="${this.#n}" ${ref(this.#l)}></slot></div><slot class="${classMap({description:!0,visible:this.hasDescriptionSlot,error:this.error,tooltip:this.hasTooltipSlot})}" id="description" name="description" @slotchange="${this.#c}" ${ref(this.#o)}></slot></div>`}#t;#e;#o;#l;#i;#a(){owSlot(this.#t.value)}#r(){owSlot(this.#e.value)}#c(){const t=this.#o.value?.assignedNodes({flatten:!0});this.hasDescriptionSlot=Boolean(t&&t.length>0)}#n(){const t=this.#l.value?.assignedNodes({flatten:!0});this.hasSummarySlot=Boolean(t&&t.length>0)}#s(){const t=this.#i.value?.assignedNodes({flatten:!0});this.hasTooltipSlot=Boolean(t&&t.length>0)}};__decorate([property({reflect:!0,type:Boolean})],GlideCoreLabel.prototype,"disabled",void 0),__decorate([property({reflect:!0,type:Boolean})],GlideCoreLabel.prototype,"error",void 0),__decorate([property({reflect:!0,type:Boolean})],GlideCoreLabel.prototype,"hide",void 0),__decorate([property({reflect:!0})],GlideCoreLabel.prototype,"orientation",void 0),__decorate([property({reflect:!0,type:Boolean})],GlideCoreLabel.prototype,"required",void 0),__decorate([state()],GlideCoreLabel.prototype,"hasDescriptionSlot",void 0),__decorate([state()],GlideCoreLabel.prototype,"hasSummarySlot",void 0),__decorate([state()],GlideCoreLabel.prototype,"hasTooltipSlot",void 0),GlideCoreLabel=__decorate([customElement("glide-core-label")],GlideCoreLabel);export default GlideCoreLabel;
1
+ var __decorate=this&&this.__decorate||function(t,e,o,l){var i,r=arguments.length,s=r<3?e:null===l?l=Object.getOwnPropertyDescriptor(e,o):l;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,o,l);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(r<3?i(s):r>3?i(e,o,s):i(e,o))||s);return r>3&&s&&Object.defineProperty(e,o,s),s};import"./tooltip.js";import{LitElement,html}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{owSlot}from"./library/ow.js";import styles from"./label.styles.js";import{svg}from"lit";const infoCircleIcon=svg`<circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2"><path d="M12 16L12 12" stroke="currentColor" stroke-width="2" stroke-linecap="round"><circle cx="12" cy="8" r="1" fill="currentColor">`;let GlideCoreLabel=class GlideCoreLabel extends LitElement{constructor(){super(...arguments),this.disabled=!1,this.error=!1,this.hide=!1,this.orientation="horizontal",this.required=!1,this.hasDescriptionSlot=!1,this.hasSummarySlot=!1,this.hasTooltipSlot=!1,this.#t=createRef(),this.#e=createRef(),this.#o=createRef(),this.#l=new LocalizeController(this),this.#i=createRef(),this.#r=createRef()}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:"closed"}}static{this.styles=styles}firstUpdated(){owSlot(this.#e.value),owSlot(this.#t.value)}render(){return html`<div class="${classMap({component:!0,horizontal:"horizontal"===this.orientation,vertical:"vertical"===this.orientation,"hidden-label":this.hide})}"><div class="${classMap({"tooltip-and-label":!0,hidden:this.hide})}" part="tooltip-and-label-container"><div class="tooltip-and-label"><glide-core-tooltip class="${classMap({tooltip:!0,vertical:"vertical"===this.orientation,visible:this.hasTooltipSlot})}" placement="${"vertical"===this.orientation?"right":"bottom"}"><span class="tooltip-target" slot="target" tabindex="0"><svg aria-label="${this.#l.term("moreInformation")}" width="16" height="16" viewBox="0 0 24 24" fill="none">${infoCircleIcon}</svg></span><slot class="${classMap({tooltip:!0,visible:this.hasTooltipSlot})}" name="tooltip" @slotchange="${this.#s}" ${ref(this.#r)}></slot></glide-core-tooltip><div class="${classMap({label:!0,disabled:this.disabled})}" data-test="label"><slot @slotchange="${this.#a}" ${ref(this.#e)}></slot>${this.required?html`<span aria-hidden="true" class="required-symbol">*</span>`:""}</div></div></div><div class="control-and-summary"><slot class="${classMap({control:!0,error:this.error,disabled:this.disabled,vertical:"vertical"===this.orientation,summaryless:!this.hasSummarySlot,"hidden-label":this.hide})}" name="control" @slotchange="${this.#n}" ${ref(this.#t)}></slot><slot class="${classMap({summary:!0,error:this.error})}" name="summary" @slotchange="${this.#c}" ${ref(this.#i)}></slot></div><slot class="${classMap({description:!0,visible:this.hasDescriptionSlot,error:this.error,tooltip:this.hasTooltipSlot})}" id="description" name="description" @slotchange="${this.#d}" ${ref(this.#o)}></slot></div>`}#t;#e;#o;#l;#i;#r;#n(){owSlot(this.#t.value)}#a(){owSlot(this.#e.value)}#d(){const t=this.#o.value?.assignedNodes({flatten:!0});this.hasDescriptionSlot=Boolean(t&&t.length>0)}#c(){const t=this.#i.value?.assignedNodes({flatten:!0});this.hasSummarySlot=Boolean(t&&t.length>0)}#s(){const t=this.#r.value?.assignedNodes({flatten:!0});this.hasTooltipSlot=Boolean(t&&t.length>0)}};__decorate([property({reflect:!0,type:Boolean})],GlideCoreLabel.prototype,"disabled",void 0),__decorate([property({reflect:!0,type:Boolean})],GlideCoreLabel.prototype,"error",void 0),__decorate([property({reflect:!0,type:Boolean})],GlideCoreLabel.prototype,"hide",void 0),__decorate([property({reflect:!0})],GlideCoreLabel.prototype,"orientation",void 0),__decorate([property({reflect:!0,type:Boolean})],GlideCoreLabel.prototype,"required",void 0),__decorate([state()],GlideCoreLabel.prototype,"hasDescriptionSlot",void 0),__decorate([state()],GlideCoreLabel.prototype,"hasSummarySlot",void 0),__decorate([state()],GlideCoreLabel.prototype,"hasTooltipSlot",void 0),GlideCoreLabel=__decorate([customElement("glide-core-label")],GlideCoreLabel);export default GlideCoreLabel;
@@ -1,4 +1,4 @@
1
- import{css}from"lit";import visuallyHidden from"./styles/visually-hidden.js";export default[css`
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
4
  column-gap: var(--glide-core-spacing-sm);
@@ -52,23 +52,21 @@ import{css}from"lit";import visuallyHidden from"./styles/visually-hidden.js";exp
52
52
  .tooltip-target {
53
53
  background-color: transparent;
54
54
  border: none;
55
-
56
- /* TODO
57
- We want the focus outline to wrap neatly around the trigger. Tooltip should
58
- probably wrap its default slot in a SPAN with "tabindex=0" and include the
59
- below styles so every consumer doesn't have to.
60
- */
61
- border-radius: 50%;
55
+ border-radius: 0.0625rem;
62
56
  color: var(--glide-core-text-body-1);
63
57
 
64
58
  /*
65
- Any "display" that's not inline-level will do. We don't want the button to
66
- acquire a line box, which will make it taller than its content and thus
67
- make it difficult to center vertically with the label.
68
- */
59
+ Any "display" that's not inline-level will do. We don't want the button to
60
+ acquire a line box, which will make it taller than its content and thus
61
+ make it difficult to center vertically with the label.
62
+ */
63
+
69
64
  display: flex;
70
- outline-offset: 1px;
71
65
  padding: 0;
66
+
67
+ &:focus-visible {
68
+ ${focusOutline};
69
+ }
72
70
  }
73
71
 
74
72
  .label {
@@ -0,0 +1,17 @@
1
+ import { LocalizeController as DefaultLocalizationController } from '@shoelace-style/localize';
2
+ import type { Translation as DefaultTranslation } from '@shoelace-style/localize';
3
+ export declare class LocalizeController extends DefaultLocalizationController<Translation> {
4
+ }
5
+ export interface Translation extends DefaultTranslation {
6
+ $code: string;
7
+ $name: string;
8
+ $dir: 'ltr' | 'rtl';
9
+ close: string;
10
+ dismiss: string;
11
+ open: string;
12
+ selectAll: string;
13
+ clearEntry: string;
14
+ moreInformation: string;
15
+ notifications: string;
16
+ removeTag: (name: string) => string;
17
+ }
@@ -0,0 +1 @@
1
+ import{LocalizeController as DefaultLocalizationController,registerTranslation}from"@shoelace-style/localize";import en from"../translations/en.js";import fr from"../translations/fr.js";import ja from"../translations/ja.js";export class LocalizeController extends DefaultLocalizationController{static{registerTranslation(en,ja,fr)}}
@@ -0,0 +1,15 @@
1
+ interface Arguments {
2
+ elements: Element[];
3
+ containingBlock: Element;
4
+ }
5
+ /**
6
+ * Sets the containing block for all child elements that might contain
7
+ * floating-ui components (i.e. tooltips, popovers, or menus),
8
+ * for cases where the containing block element is inside a closed shadow DOM,
9
+ * and therefore wouldn't be able to be detected by floating-ui's getOffsetParent calculations.
10
+ * Necessary when the containing block has something like a backdrop-filter
11
+ * https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
12
+ * https://github.com/floating-ui/floating-ui/issues/2955
13
+ */
14
+ export declare function setContainingBlock({ elements, containingBlock }: Arguments): void;
15
+ export {};
@@ -0,0 +1 @@
1
+ import GlideCoreMenu from"../menu.js";import GlideCoreTooltip from"../tooltip.js";import GlideCoreTree from"../tree.js";export function setContainingBlock({elements:o,containingBlock:e}){const i=o.filter((o=>o instanceof GlideCoreTooltip||o instanceof GlideCoreMenu||o instanceof GlideCoreTree));for(const o of i)o.setContainingBlock(e)}
@@ -1 +1 @@
1
- var __decorate=this&&this.__decorate||function(t,e,o,r){var i,n=arguments.length,s=n<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,o,r);else for(var l=t.length-1;l>=0;l--)(i=t[l])&&(s=(n<3?i(s):n>3?i(e,o,s):i(e,o))||s);return n>3&&s&&Object.defineProperty(e,o,s),s};import{LitElement,html}from"lit";import{classMap}from"lit/directives/class-map.js";import{customElement,property}from"lit/decorators.js";import styles from"./menu.button.styles.js";let GlideCoreMenuButton=class GlideCoreMenuButton extends LitElement{constructor(){super(...arguments),this.privateActive=!1,this.#t=window.crypto.randomUUID()}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:"closed"}}static{this.styles=styles}connectedCallback(){super.connectedCallback(),this.id=this.#t,this.role="menuitem",this.tabIndex=-1}render(){return html`<button class="${classMap({component:!0,active:this.privateActive})}" data-test="component" type="button"><slot name="icon"></slot>${this.label}</button>`}#t};__decorate([property({reflect:!0})],GlideCoreMenuButton.prototype,"label",void 0),__decorate([property({type:Boolean})],GlideCoreMenuButton.prototype,"privateActive",void 0),GlideCoreMenuButton=__decorate([customElement("glide-core-menu-button")],GlideCoreMenuButton);export default GlideCoreMenuButton;
1
+ var __decorate=this&&this.__decorate||function(t,e,o,r){var n,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,o,r);else for(var l=t.length-1;l>=0;l--)(n=t[l])&&(s=(i<3?n(s):i>3?n(e,o,s):n(e,o))||s);return i>3&&s&&Object.defineProperty(e,o,s),s};import{LitElement,html}from"lit";import{classMap}from"lit/directives/class-map.js";import{customElement,property}from"lit/decorators.js";import{nanoid}from"nanoid";import styles from"./menu.button.styles.js";let GlideCoreMenuButton=class GlideCoreMenuButton extends LitElement{constructor(){super(...arguments),this.privateActive=!1,this.#t=nanoid()}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:"closed"}}static{this.styles=styles}connectedCallback(){super.connectedCallback(),this.id=this.#t,this.role="menuitem",this.tabIndex=-1}render(){return html`<button class="${classMap({component:!0,active:this.privateActive})}" data-test="component" type="button"><slot name="icon"></slot>${this.label}</button>`}#t};__decorate([property({reflect:!0})],GlideCoreMenuButton.prototype,"label",void 0),__decorate([property({type:Boolean})],GlideCoreMenuButton.prototype,"privateActive",void 0),GlideCoreMenuButton=__decorate([customElement("glide-core-menu-button")],GlideCoreMenuButton);export default GlideCoreMenuButton;
package/dist/menu.d.ts CHANGED
@@ -8,7 +8,7 @@ declare global {
8
8
  /**
9
9
  * @description A basic menu.
10
10
  *
11
- * @slot - One or more of <glide-core-menu-link> or <glide-core-menu-button>.
11
+ * @slot - <glide-core-menu-options>.
12
12
  * @slot target - A focusable element against which Menu will be positioned. Opens and closes Menu when interacted with.
13
13
  */
14
14
  export default class GlideCoreMenu extends LitElement {
@@ -18,14 +18,15 @@ export default class GlideCoreMenu extends LitElement {
18
18
  get open(): boolean;
19
19
  set open(isOpen: boolean);
20
20
  placement: Placement;
21
- size: 'small' | 'large';
22
- private get activeOption();
21
+ containingBlock?: Element;
22
+ get size(): 'small' | 'large';
23
+ set size(size: 'small' | 'large');
23
24
  connectedCallback(): void;
24
25
  createRenderRoot(): ShadowRoot;
25
26
  disconnectedCallback(): void;
26
27
  firstUpdated(): void;
27
28
  focus(): void;
28
29
  render(): import("lit").TemplateResult<1>;
29
- private ariaActivedescendant;
30
+ setContainingBlock(containingBlock: Element): void;
30
31
  private isTargetDisabled;
31
32
  }
package/dist/menu.js CHANGED
@@ -1 +1 @@
1
- var __decorate=this&&this.__decorate||function(e,t,i,n){var o,s=arguments.length,a=s<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,n);else for(var l=e.length-1;l>=0;l--)(o=e[l])&&(a=(s<3?o(a):s>3?o(t,i,a):o(t,i))||a);return s>3&&a&&Object.defineProperty(t,i,a),a};import{LitElement,html}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{owSlot,owSlotType}from"./library/ow.js";import GlideCoreMenuButton from"./menu.button.js";import GlideCoreMenuLink from"./menu.link.js";import styles from"./menu.styles.js";let GlideCoreMenu=class GlideCoreMenu extends LitElement{constructor(){super(...arguments),this.placement="bottom-start",this.size="large",this.ariaActivedescendant="",this.isTargetDisabled=!1,this.#e=createRef(),this.#t=createRef(),this.#i=!1,this.#n=!1,this.#o=createRef(),this.#s=createRef(),this.#a=e=>{e.target&&this.contains(e.target)||(this.open=!1,this.ariaActivedescendant="")}}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:"closed"}}static{this.styles=styles}get open(){return this.#n}set open(e){this.#n=e,e&&!this.isTargetDisabled?(this.#l(),this.ariaActivedescendant=this.activeOption?.id??""):(this.#r?.(),this.ariaActivedescendant=""),this.#c&&(this.#c.ariaExpanded=e&&!this.isTargetDisabled?"true":"false")}get activeOption(){return this.#d?.find((({privateActive:e})=>e))}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this.#a,{capture:!0})}createRenderRoot(){return this.#p=super.createRenderRoot(),this.#p}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this.#a,{capture:!0})}firstUpdated(){owSlot(this.#t.value),owSlot(this.#s.value),owSlotType(this.#t.value,[GlideCoreMenuButton,GlideCoreMenuLink,Text]);const e=this.#d.at(0);this.open&&e&&(this.#l(),e.privateActive=!0,this.ariaActivedescendant=e.id)}focus(){this.#c&&"focus"in this.#c&&this.#c?.focus()}render(){return html`<div class="component" @focusout="${this.#h}" ${ref(this.#e)}><div class="container" id="container"><slot name="target" @click="${this.#u}" @keydown="${this.#m}" @slotchange="${this.#f}" ${ref(this.#s)}></slot></div><div aria-activedescendant="${this.ariaActivedescendant}" aria-labelledby="container" class="${classMap({menu:!0,large:"large"===this.size,small:"small"===this.size,visible:this.open&&!this.isTargetDisabled})}" data-test="menu" role="menu" tabindex="-1" ${ref(this.#o)}><slot @click="${this.#v}" @focusin="${this.#g}" @keydown="${this.#m}" @mouseover="${this.#E}" @slotchange="${this.#y}" ${ref(this.#t)}></slot></div></div>`}#r;#e;#t;#i;#n;#o;#p;#s;#a;#y(){owSlot(this.#t.value),owSlotType(this.#t.value,[GlideCoreMenuButton,GlideCoreMenuLink,Text]);const e=this.#d.at(0);e&&(e.privateActive=!0)}#v(){this.open=!1,this.ariaActivedescendant=""}#g(e){(e.target instanceof GlideCoreMenuButton||e.target instanceof GlideCoreMenuLink)&&this.activeOption&&(this.activeOption.privateActive=!1,e.target.privateActive=!0,this.ariaActivedescendant=e.target.id)}#E(e){if(e.target instanceof GlideCoreMenuLink||e.target instanceof GlideCoreMenuButton){for(const t of this.#d)t.privateActive=t===e.target;this.ariaActivedescendant=e.target.id}}#h(e){const t=e.relatedTarget instanceof HTMLElement&&this.#p?.contains(e.relatedTarget),i=e.relatedTarget instanceof HTMLElement&&this.contains(e.relatedTarget);t||i||(this.open=!1)}#m(e){if([" ","Enter","Escape"].includes(e.key)&&this.open)return this.open=!1,this.ariaActivedescendant="",this.focus(),void(this.#i=!0);if([" ","ArrowUp","ArrowDown"].includes(e.key)&&!this.open&&this.activeOption)return e.preventDefault(),this.open=!0,void(this.ariaActivedescendant=this.activeOption.id);if(this.open&&this.activeOption){const t=this.#d.indexOf(this.activeOption);if("ArrowUp"===e.key&&!e.metaKey){e.preventDefault();const i=this.#d.at(t-1);return void(i&&0!==t&&(this.activeOption.privateActive=!1,this.ariaActivedescendant=i.id,i.privateActive=!0))}if("ArrowDown"===e.key&&!e.metaKey){e.preventDefault();const i=this.#d.at(t+1);return void(i&&(this.activeOption.privateActive=!1,this.ariaActivedescendant=i.id,i.privateActive=!0))}if("ArrowUp"===e.key&&e.metaKey||"Home"===e.key||"PageUp"===e.key){e.preventDefault();const t=this.#d.at(0);return void(t&&(this.activeOption.privateActive=!1,this.ariaActivedescendant=t.id,t.privateActive=!0))}if("ArrowDown"===e.key&&e.metaKey||"End"===e.key||"PageDown"===e.key){e.preventDefault();const t=this.#d.at(-1);return void(t&&(this.activeOption.privateActive=!1,this.ariaActivedescendant=t.id,t.privateActive=!0))}}}#f(){owSlot(this.#s.value);const e=this.#c&&"disabled"in this.#c&&this.#c.disabled,t=this.#c&&"true"===this.#c.ariaDisabled;this.isTargetDisabled=Boolean(e)||Boolean(t),this.#c&&this.#o.value&&(this.#c.ariaHasPopup="true",this.#c.ariaExpanded=this.open&&!this.isTargetDisabled?"true":"false")}#u(){this.isTargetDisabled||this.#i?this.#i=!1:(this.#c instanceof HTMLElement&&(this.#c.ariaExpanded=this.open?"true":"false"),this.open=!this.open,this.open&&this.activeOption?this.ariaActivedescendant=this.activeOption.id:this.open||(this.ariaActivedescendant="",this.focus()))}get#d(){return(this.#t.value?.assignedElements({flatten:!0})??[]).filter((e=>e instanceof GlideCoreMenuLink||e instanceof GlideCoreMenuButton))}#l(){this.#c&&this.#o.value&&(this.#r=autoUpdate(this.#c,this.#o.value,(()=>{(async()=>{if(this.#c&&this.#o.value){const{x:e,y:t,placement:i}=await computePosition(this.#c,this.#o.value,{placement:this.placement,middleware:[offset({mainAxis:16*Number.parseFloat(window.getComputedStyle(document.body).getPropertyValue("--glide-core-spacing-xxs"))}),flip()]});this.#o.value.dataset.placement=i,Object.assign(this.#o.value.style,{left:`${e}px`,top:`${t}px`})}})()})))}get#c(){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",void 0),__decorate([state()],GlideCoreMenu.prototype,"ariaActivedescendant",void 0),__decorate([state()],GlideCoreMenu.prototype,"isTargetDisabled",void 0),GlideCoreMenu=__decorate([customElement("glide-core-menu")],GlideCoreMenu);export default GlideCoreMenu;
1
+ var __decorate=this&&this.__decorate||function(t,e,i,o){var n,s=arguments.length,a=s<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,i,o);else for(var l=t.length-1;l>=0;l--)(n=t[l])&&(a=(s<3?n(a):s>3?n(e,i,a):n(e,i))||a);return s>3&&a&&Object.defineProperty(e,i,a),a};import{LitElement,html}from"lit";import{autoUpdate,computePosition,flip,offset,platform}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{nanoid}from"nanoid";import{offsetParent}from"composed-offset-position";import{owSlot,owSlotType}from"./library/ow.js";import GlideCoreMenuButton from"./menu.button.js";import GlideCoreMenuLink from"./menu.link.js";import GlideCoreMenuOptions from"./menu.options.js";import styles from"./menu.styles.js";let GlideCoreMenu=class GlideCoreMenu extends LitElement{constructor(){super(...arguments),this.placement="bottom-start",this.isTargetDisabled=!1,this.#t=createRef(),this.#e=createRef(),this.#i=!1,this.#o=!1,this.#n="large",this.#s=createRef(),this.#a=t=>{t.target&&this.contains(t.target)||(this.open=!1,this.#l&&(this.#l.ariaActivedescendant=""))}}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:"closed"}}static{this.styles=styles}get open(){return this.#o}set open(t){this.#o=t,t&&!this.isTargetDisabled&&this.#l?(this.#r(),this.#l.ariaActivedescendant=this.#c?.id??""):this.#l&&(this.#p?.(),this.#l.ariaActivedescendant=""),this.#h&&(this.#h.ariaExpanded=t&&!this.isTargetDisabled?"true":"false")}get size(){return this.#n}set size(t){this.#n=t,this.#l&&(this.#l.privateSize=t)}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this.#a,{capture:!0})}createRenderRoot(){return this.#d=super.createRenderRoot(),this.#d}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this.#a,{capture:!0})}firstUpdated(){owSlot(this.#e.value),owSlot(this.#s.value),owSlotType(this.#e.value,[GlideCoreMenuOptions]);const t=this.#m?.at(0);this.open&&t&&this.#l&&(this.#r(),t.privateActive=!0,this.#l.ariaActivedescendant=t.id)}focus(){this.#h&&"focus"in this.#h&&this.#h?.focus()}render(){return html`<div class="component" @focusout="${this.#f}" ${ref(this.#t)}><slot class="target-slot" name="target" @click="${this.#u}" @keydown="${this.#E}" @slotchange="${this.#g}" ${ref(this.#s)}></slot><slot class="${classMap({"default-slot":!0,visible:this.open&&!this.isTargetDisabled})}" @click="${this.#v}" @focusin="${this.#S}" @keydown="${this.#E}" @mouseover="${this.#y}" @slotchange="${this.#C}" ${ref(this.#e)}></slot></div>`}setContainingBlock(t){this.containingBlock=t}#p;#t;#e;#i;#o;#d;#n;#s;get#c(){return this.#m?.find((({privateActive:t})=>t))}get#l(){const t=this.#e.value?.assignedElements().at(0);return t||null}#a;#C(){owSlot(this.#e.value),owSlotType(this.#e.value,[GlideCoreMenuOptions]);const t=this.#m?.at(0);t&&(t.privateActive=!0),this.#l&&(this.#l.privateSize=this.size)}#v(){this.open=!1,this.#l&&(this.#l.ariaActivedescendant="")}#S(t){(t.target instanceof GlideCoreMenuButton||t.target instanceof GlideCoreMenuLink)&&this.#c&&this.#l&&(this.#c.privateActive=!1,t.target.privateActive=!0,this.#l.ariaActivedescendant=t.target.id)}#y(t){if(t.target instanceof GlideCoreMenuLink||t.target instanceof GlideCoreMenuButton){if(this.#m)for(const e of this.#m)e.privateActive=e===t.target;this.#l&&(this.#l.ariaActivedescendant=t.target.id)}}#f(t){const e=t.relatedTarget instanceof HTMLElement&&this.#d?.contains(t.relatedTarget),i=t.relatedTarget instanceof HTMLElement&&this.contains(t.relatedTarget);e||i||(this.open=!1)}#E(t){if([" ","Enter","Escape"].includes(t.key)&&this.open&&this.#l)return this.open=!1,this.#l.ariaActivedescendant="",this.focus(),void(this.#i=!0);if([" ","ArrowUp","ArrowDown"].includes(t.key)&&!this.open&&this.#c&&this.#l)return t.preventDefault(),this.open=!0,void(this.#l.ariaActivedescendant=this.#c.id);if(this.open&&this.#c&&this.#m){const e=this.#m.indexOf(this.#c);if("ArrowUp"===t.key&&!t.metaKey){t.preventDefault();const i=this.#m?.at(e-1);return void(i&&0!==e&&this.#l&&(this.#c.privateActive=!1,this.#l.ariaActivedescendant=i.id,i.privateActive=!0))}if("ArrowDown"===t.key&&!t.metaKey&&this.#l){t.preventDefault();const i=this.#m?.at(e+1);return void(i&&(this.#c.privateActive=!1,this.#l.ariaActivedescendant=i.id,i.privateActive=!0))}if("ArrowUp"===t.key&&t.metaKey||"Home"===t.key||"PageUp"===t.key){t.preventDefault();const e=this.#m?.at(0);return void(e&&this.#l&&(this.#c.privateActive=!1,this.#l.ariaActivedescendant=e.id,e.privateActive=!0))}if("ArrowDown"===t.key&&t.metaKey||"End"===t.key||"PageDown"===t.key){t.preventDefault();const e=this.#m?.at(-1);return void(e&&this.#l&&(this.#c.privateActive=!1,this.#l.ariaActivedescendant=e.id,e.privateActive=!0))}}}#g(){owSlot(this.#s.value);const t=this.#h&&"disabled"in this.#h&&this.#h.disabled,e=this.#h&&"true"===this.#h.ariaDisabled;this.isTargetDisabled=Boolean(t)||Boolean(e),this.#h&&this.#l&&(this.#h.ariaHasPopup="true",this.#h.ariaExpanded=this.open&&!this.isTargetDisabled?"true":"false",this.#h.id=nanoid(),this.#h.setAttribute("aria-controls",this.#l.id),this.#l.ariaLabelledby=this.#h.id)}#u(){this.isTargetDisabled||this.#i?this.#i=!1:(this.#h instanceof HTMLElement&&(this.#h.ariaExpanded=this.open?"true":"false"),this.open=!this.open,this.open&&this.#c&&this.#l?this.#l.ariaActivedescendant=this.#c.id:!this.open&&this.#l&&(this.#l.ariaActivedescendant="",this.focus()))}get#m(){const t=this.#e.value?.assignedElements()?.at(0)?.children;if(t)return[...t].filter((t=>t instanceof GlideCoreMenuLink||t instanceof GlideCoreMenuButton))}#r(){this.#h&&this.#e.value&&(this.#p=autoUpdate(this.#h,this.#e.value,(()=>{(async()=>{if(this.#h&&this.#e.value){const{x:t,y:e,placement:i}=await computePosition(this.#h,this.#e.value,{platform:{...platform,getOffsetParent:t=>this.containingBlock??platform.getOffsetParent(t,offsetParent)},placement:this.placement,middleware:[offset({mainAxis:16*Number.parseFloat(window.getComputedStyle(document.body).getPropertyValue("--glide-core-spacing-xxs"))}),flip()]});this.#e.value.dataset.placement=i,Object.assign(this.#e.value.style,{left:`${t}px`,top:`${e}px`})}})()})))}get#h(){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([state()],GlideCoreMenu.prototype,"containingBlock",void 0),__decorate([property({reflect:!0})],GlideCoreMenu.prototype,"size",null),__decorate([state()],GlideCoreMenu.prototype,"isTargetDisabled",void 0),GlideCoreMenu=__decorate([customElement("glide-core-menu")],GlideCoreMenu);export default GlideCoreMenu;
package/dist/menu.link.js CHANGED
@@ -1 +1 @@
1
- var __decorate=this&&this.__decorate||function(e,t,o,i){var r,n=arguments.length,l=n<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,t,o,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(l=(n<3?r(l):n>3?r(t,o,l):r(t,o))||l);return n>3&&l&&Object.defineProperty(t,o,l),l};import{LitElement,html}from"lit";import{classMap}from"lit/directives/class-map.js";import{customElement,property}from"lit/decorators.js";import{ifDefined}from"lit/directives/if-defined.js";import styles from"./menu.link.styles.js";let GlideCoreMenuLink=class GlideCoreMenuLink extends LitElement{constructor(){super(...arguments),this.privateActive=!1,this.#e=window.crypto.randomUUID()}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:"closed"}}static{this.styles=styles}connectedCallback(){super.connectedCallback(),this.id=this.#e,this.role="menuitem",this.tabIndex=-1}render(){return html`<a class="${classMap({component:!0,active:this.privateActive})}" data-test="component" href="${ifDefined(this.url)}"><slot name="icon"></slot>${this.label}</a>`}#e};__decorate([property({reflect:!0})],GlideCoreMenuLink.prototype,"label",void 0),__decorate([property({reflect:!0})],GlideCoreMenuLink.prototype,"url",void 0),__decorate([property({type:Boolean})],GlideCoreMenuLink.prototype,"privateActive",void 0),GlideCoreMenuLink=__decorate([customElement("glide-core-menu-link")],GlideCoreMenuLink);export default GlideCoreMenuLink;
1
+ var __decorate=this&&this.__decorate||function(e,t,i,o){var r,n=arguments.length,l=n<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 s=e.length-1;s>=0;s--)(r=e[s])&&(l=(n<3?r(l):n>3?r(t,i,l):r(t,i))||l);return n>3&&l&&Object.defineProperty(t,i,l),l};import{LitElement,html}from"lit";import{classMap}from"lit/directives/class-map.js";import{customElement,property}from"lit/decorators.js";import{ifDefined}from"lit/directives/if-defined.js";import{nanoid}from"nanoid";import styles from"./menu.link.styles.js";let GlideCoreMenuLink=class GlideCoreMenuLink extends LitElement{constructor(){super(...arguments),this.privateActive=!1,this.#e=nanoid()}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:"closed"}}static{this.styles=styles}connectedCallback(){super.connectedCallback(),this.id=this.#e,this.role="menuitem",this.tabIndex=-1}render(){return html`<a class="${classMap({component:!0,active:this.privateActive})}" data-test="component" href="${ifDefined(this.url)}"><slot name="icon"></slot>${this.label}</a>`}#e};__decorate([property({reflect:!0})],GlideCoreMenuLink.prototype,"label",void 0),__decorate([property({reflect:!0})],GlideCoreMenuLink.prototype,"url",void 0),__decorate([property({type:Boolean})],GlideCoreMenuLink.prototype,"privateActive",void 0),GlideCoreMenuLink=__decorate([customElement("glide-core-menu-link")],GlideCoreMenuLink);export default GlideCoreMenuLink;
@@ -0,0 +1,22 @@
1
+ import { LitElement } from 'lit';
2
+ declare global {
3
+ interface HTMLElementTagNameMap {
4
+ 'glide-core-menu-options': GlideCoreMenuOptions;
5
+ }
6
+ }
7
+ /**
8
+ * @description An options container for use within a <glide-core-menu>.
9
+ *
10
+ * @slot - One or more of <glide-core-menu-link> or <glide-core-menu-button>.
11
+ */
12
+ export default class GlideCoreMenuOptions extends LitElement {
13
+ #private;
14
+ static shadowRootOptions: ShadowRootInit;
15
+ static styles: import("lit").CSSResult[];
16
+ ariaActivedescendant: string;
17
+ ariaLabelledby: string;
18
+ privateSize: 'small' | 'large';
19
+ connectedCallback(): void;
20
+ firstUpdated(): void;
21
+ render(): import("lit").TemplateResult<1>;
22
+ }
@@ -0,0 +1 @@
1
+ var __decorate=this&&this.__decorate||function(e,t,o,i){var l,r=arguments.length,n=r<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,o,i);else for(var a=e.length-1;a>=0;a--)(l=e[a])&&(n=(r<3?l(n):r>3?l(t,o,n):l(t,o))||n);return r>3&&n&&Object.defineProperty(t,o,n),n};import{LitElement,html}from"lit";import{classMap}from"lit/directives/class-map.js";import{createRef,ref}from"lit/directives/ref.js";import{customElement,property,state}from"lit/decorators.js";import{nanoid}from"nanoid";import{owSlot,owSlotType}from"./library/ow.js";import GlideCoreMenuButton from"./menu.button.js";import GlideCoreMenuLink from"./menu.link.js";import styles from"./menu.options.styles.js";let GlideCoreMenuOptions=class GlideCoreMenuOptions extends LitElement{constructor(){super(...arguments),this.ariaActivedescendant="",this.ariaLabelledby="",this.privateSize="large",this.#e=createRef(),this.#t=nanoid()}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:"closed"}}static{this.styles=styles}connectedCallback(){super.connectedCallback(),this.id=this.#t,this.role="menu",this.tabIndex=-1}firstUpdated(){owSlot(this.#e.value),owSlotType(this.#e.value,[GlideCoreMenuButton,GlideCoreMenuLink,Text])}render(){return html`<div class="${classMap({component:!0,large:"large"===this.privateSize,small:"small"===this.privateSize})}" role="none"><slot @slotchange="${this.#o}" ${ref(this.#e)}></slot></div>`}#e;#t;#o(){owSlot(this.#e.value),owSlotType(this.#e.value,[GlideCoreMenuButton,GlideCoreMenuLink,Text])}};__decorate([property({attribute:"aria-activedescendant",reflect:!0})],GlideCoreMenuOptions.prototype,"ariaActivedescendant",void 0),__decorate([property({attribute:"aria-labelledby",reflect:!0})],GlideCoreMenuOptions.prototype,"ariaLabelledby",void 0),__decorate([state()],GlideCoreMenuOptions.prototype,"privateSize",void 0),GlideCoreMenuOptions=__decorate([customElement("glide-core-menu-options")],GlideCoreMenuOptions);export default GlideCoreMenuOptions;
@@ -0,0 +1,2 @@
1
+ declare const _default: import("lit").CSSResult[];
2
+ export default _default;
@@ -0,0 +1,33 @@
1
+ import{css}from"lit";export default[css`
2
+ :host {
3
+ display: inline-block;
4
+ inline-size: 100%;
5
+ }
6
+
7
+ .component {
8
+ &.large {
9
+ --gap: var(--glide-core-spacing-sm);
10
+ --padding-inline: var(--glide-core-spacing-sm);
11
+ --padding-block: var(--glide-core-spacing-xxs);
12
+
13
+ font-family: var(--glide-core-body-sm-font-family);
14
+ font-size: var(--glide-core-body-sm-font-size);
15
+ font-style: var(--glide-core-body-sm-font-style);
16
+ font-weight: var(--glide-core-body-sm-font-weight);
17
+ line-height: var(--glide-core-body-sm-line-height);
18
+ }
19
+
20
+ &.small {
21
+ --gap: var(--glide-core-spacing-xs);
22
+ --padding-inline: var(--glide-core-spacing-xs);
23
+ --padding-block: var(--glide-core-spacing-xxxs);
24
+ --size: 0.75rem;
25
+
26
+ font-family: var(--glide-core-body-xs-font-family);
27
+ font-size: var(--glide-core-body-xs-font-size);
28
+ font-style: var(--glide-core-body-xs-font-style);
29
+ font-weight: var(--glide-core-body-xs-font-weight);
30
+ line-height: var(--glide-core-body-xs-line-height);
31
+ }
32
+ }
33
+ `];
@@ -0,0 +1,2 @@
1
+ import './menu.button.js';
2
+ import './menu.link.js';
@@ -0,0 +1,43 @@
1
+ import './menu.button.js';
2
+ import './menu.link.js';
3
+ import { ArgumentError } from 'ow';
4
+ import { expect, fixture, html } from '@open-wc/testing';
5
+ import { repeat } from 'lit/directives/repeat.js';
6
+ import GlideCoreMenu from './menu.js';
7
+ import GlideCoreMenuOptions from './menu.options.js';
8
+ import expectArgumentError from './library/expect-argument-error.js';
9
+ import sinon from 'sinon';
10
+ GlideCoreMenu.shadowRootOptions.mode = 'open';
11
+ it('throws if it does not have a default slot', async () => {
12
+ const spy = sinon.spy();
13
+ try {
14
+ await fixture(html `<glide-core-menu-options></glide-core-menu-options>`);
15
+ }
16
+ catch (error) {
17
+ if (error instanceof ArgumentError) {
18
+ spy();
19
+ }
20
+ }
21
+ expect(spy.called).to.be.true;
22
+ });
23
+ it('throws if the default slot is the incorrect type', async () => {
24
+ await expectArgumentError(() => {
25
+ return fixture(html `<glide-core-menu-options>
26
+ <option>Option</option>
27
+ </glide-core-menu-options>`);
28
+ });
29
+ });
30
+ it('does not throw if the default slot only contains whitespace', async () => {
31
+ const spy = sinon.spy();
32
+ try {
33
+ await fixture(html `<glide-core-menu-options>
34
+ ${repeat([], () => html `<glide-core-menu-link label="Link"></glide-core-menu-link>`)}
35
+ </glide-core-menu-options>`);
36
+ }
37
+ catch (error) {
38
+ if (error instanceof ArgumentError) {
39
+ spy();
40
+ }
41
+ }
42
+ expect(spy.notCalled).to.be.true;
43
+ });
@@ -2,6 +2,7 @@ import './icons/storybook.js';
2
2
  import './menu.button.js';
3
3
  import './menu.js';
4
4
  import './menu.link.js';
5
+ import './menu.options.js';
5
6
  import type { Meta, StoryObj } from '@storybook/web-components';
6
7
  declare const meta: Meta;
7
8
  export default meta;
@@ -9,17 +9,18 @@ import{css}from"lit";export default[css`
9
9
  display: flex;
10
10
  }
11
11
 
12
- .container {
12
+ .target-slot {
13
13
  display: flex;
14
14
  position: relative;
15
15
  }
16
16
 
17
- .menu {
17
+ .default-slot {
18
18
  background-color: var(--glide-core-surface-modal);
19
19
  border: 1px solid var(--glide-core-surface-modal);
20
20
  border-radius: var(--glide-core-spacing-xs);
21
21
  box-shadow: var(--glide-core-shadow-lg);
22
22
  box-sizing: border-box;
23
+ display: flex;
23
24
  inline-size: max-content;
24
25
  inset-block-start: 0;
25
26
  inset-inline-start: 0;
@@ -39,30 +40,5 @@ import{css}from"lit";export default[css`
39
40
  &.visible {
40
41
  visibility: visible;
41
42
  }
42
-
43
- &.large {
44
- --gap: var(--glide-core-spacing-sm);
45
- --padding-inline: var(--glide-core-spacing-sm);
46
- --padding-block: var(--glide-core-spacing-xxs);
47
-
48
- font-family: var(--glide-core-body-sm-font-family);
49
- font-size: var(--glide-core-body-sm-font-size);
50
- font-style: var(--glide-core-body-sm-font-style);
51
- font-weight: var(--glide-core-body-sm-font-weight);
52
- line-height: var(--glide-core-body-sm-line-height);
53
- }
54
-
55
- &.small {
56
- --gap: var(--glide-core-spacing-xs);
57
- --padding-inline: var(--glide-core-spacing-xs);
58
- --padding-block: var(--glide-core-spacing-xxxs);
59
- --size: 0.75rem;
60
-
61
- font-family: var(--glide-core-body-xs-font-family);
62
- font-size: var(--glide-core-body-xs-font-size);
63
- font-style: var(--glide-core-body-xs-font-style);
64
- font-weight: var(--glide-core-body-xs-font-weight);
65
- line-height: var(--glide-core-body-xs-line-height);
66
- }
67
43
  }
68
44
  `];
@@ -1 +1,2 @@
1
1
  import './menu.button.js';
2
+ import './menu.link.js';