@crowdstrike/glide-core 0.12.0 → 0.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dropdown.d.ts +1 -0
- package/dist/dropdown.js +43 -27
- package/dist/dropdown.option.d.ts +3 -0
- package/dist/dropdown.option.js +1 -1
- package/dist/dropdown.option.styles.js +79 -16
- package/dist/dropdown.option.test.basics.js +4 -33
- package/dist/dropdown.option.test.basics.multiple.js +9 -0
- package/dist/dropdown.option.test.basics.single.js +8 -0
- package/dist/dropdown.option.test.interactions.multiple.js +12 -0
- package/dist/dropdown.option.test.interactions.single.js +11 -0
- package/dist/dropdown.styles.js +20 -17
- package/dist/dropdown.test.events.js +67 -0
- package/dist/dropdown.test.events.single.js +87 -0
- package/dist/dropdown.test.focus.filterable.js +2 -2
- package/dist/dropdown.test.focus.js +2 -2
- package/dist/dropdown.test.focus.multiple.js +14 -8
- package/dist/dropdown.test.focus.single.js +6 -6
- package/dist/dropdown.test.form.js +22 -0
- package/dist/dropdown.test.interactions.filterable.js +3 -3
- package/dist/dropdown.test.interactions.js +175 -3
- package/dist/dropdown.test.interactions.multiple.js +74 -5
- package/dist/dropdown.test.interactions.single.js +42 -13
- package/dist/icons/pencil.d.ts +2 -0
- package/dist/icons/pencil.js +1 -0
- package/dist/library/localize.d.ts +2 -0
- package/dist/menu.js +1 -1
- package/dist/menu.options.js +1 -1
- package/dist/menu.options.test.events.d.ts +1 -0
- package/dist/menu.options.test.events.js +19 -0
- package/dist/menu.test.interactions.d.ts +1 -0
- package/dist/menu.test.interactions.js +38 -0
- package/dist/tab.group.d.ts +8 -1
- package/dist/tab.group.js +1 -1
- package/dist/tab.group.styles.js +11 -1
- package/dist/tab.group.test.basics.js +77 -1
- package/dist/tab.panel.js +1 -1
- package/dist/tab.panel.styles.js +18 -0
- package/dist/tag.d.ts +2 -0
- package/dist/tag.js +1 -1
- package/dist/tag.styles.js +46 -5
- package/dist/tag.test.basics.js +1 -1
- package/dist/tag.test.events.js +76 -3
- package/dist/tag.test.focus.js +1 -1
- package/dist/translations/en.js +1 -1
- package/dist/translations/fr.d.ts +1 -1
- package/dist/translations/fr.js +1 -1
- package/dist/translations/ja.d.ts +1 -1
- package/dist/translations/ja.js +1 -1
- package/package.json +1 -1
@@ -0,0 +1,19 @@
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
2
|
+
import './menu.button.js';
|
3
|
+
import { expect, fixture, html, oneEvent } from '@open-wc/testing';
|
4
|
+
import GlideCoreMenu from './menu.js';
|
5
|
+
import GlideCoreMenuOptions from './menu.options.js';
|
6
|
+
GlideCoreMenu.shadowRootOptions.mode = 'open';
|
7
|
+
it('dispatches a "private-slot-change" event', async () => {
|
8
|
+
const component = await fixture(html `<glide-core-menu-options>
|
9
|
+
<glide-core-menu-button label="One"></glide-core-menu-button>
|
10
|
+
</glide-core-menu-options>`);
|
11
|
+
setTimeout(() => {
|
12
|
+
const option = document.createElement('glide-core-menu-button');
|
13
|
+
option.label = 'Label';
|
14
|
+
component.append(option);
|
15
|
+
});
|
16
|
+
const event = await oneEvent(component, 'private-slot-change');
|
17
|
+
expect(event instanceof Event).to.be.true;
|
18
|
+
expect(event.bubbles).to.be.true;
|
19
|
+
});
|
@@ -5,6 +5,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
5
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7
7
|
};
|
8
|
+
import './menu.button.js';
|
8
9
|
import './menu.link.js';
|
9
10
|
import './menu.options.js';
|
10
11
|
import { LitElement } from 'lit';
|
@@ -1016,6 +1017,43 @@ it('does not wrap on ArrowDown', async () => {
|
|
1016
1017
|
await sendKeys({ up: 'Meta' });
|
1017
1018
|
expect(options[1].privateActive).to.be.true;
|
1018
1019
|
});
|
1020
|
+
it('sets the first option as active when optionless and an option is dynamically added', async () => {
|
1021
|
+
const component = await fixture(html `
|
1022
|
+
<glide-core-menu>
|
1023
|
+
<button slot="target">Target</button>
|
1024
|
+
<glide-core-menu-options> </glide-core-menu-options>
|
1025
|
+
</glide-core-menu>
|
1026
|
+
`);
|
1027
|
+
const option = document.createElement('glide-core-menu-button');
|
1028
|
+
option.label = 'Label';
|
1029
|
+
component.querySelector('glide-core-menu-options')?.append(option);
|
1030
|
+
await elementUpdated(component);
|
1031
|
+
expect(option?.privateActive).to.be.true;
|
1032
|
+
});
|
1033
|
+
it('retains its active option when an option is dynamically added', async () => {
|
1034
|
+
const component = await fixture(html `
|
1035
|
+
<glide-core-menu>
|
1036
|
+
<button slot="target">Target</button>
|
1037
|
+
|
1038
|
+
<glide-core-menu-options>
|
1039
|
+
<glide-core-menu-button label="One"></glide-core-menu-button>
|
1040
|
+
<glide-core-menu-button label="Two"></glide-core-menu-button>
|
1041
|
+
</glide-core-menu-options>
|
1042
|
+
</glide-core-menu>
|
1043
|
+
`);
|
1044
|
+
component
|
1045
|
+
.querySelectorAll('glide-core-menu-button')[1]
|
1046
|
+
?.dispatchEvent(new MouseEvent('mouseover', { bubbles: true }));
|
1047
|
+
await elementUpdated(component);
|
1048
|
+
const button = document.createElement('glide-core-menu-button');
|
1049
|
+
button.label = 'Three';
|
1050
|
+
component.querySelector('glide-core-menu-options')?.append(button);
|
1051
|
+
await elementUpdated(component);
|
1052
|
+
const options = component.querySelectorAll('glide-core-menu-button');
|
1053
|
+
expect(options[0]?.privateActive).to.be.false;
|
1054
|
+
expect(options[1]?.privateActive).to.be.true;
|
1055
|
+
expect(options[2]?.privateActive).to.be.false;
|
1056
|
+
});
|
1019
1057
|
it('has `set offset()` coverage', async () => {
|
1020
1058
|
const component = await fixture(html `
|
1021
1059
|
<glide-core-menu>
|
package/dist/tab.group.d.ts
CHANGED
@@ -8,7 +8,14 @@ declare global {
|
|
8
8
|
}
|
9
9
|
}
|
10
10
|
/**
|
11
|
-
* @
|
11
|
+
* @cssprop [--panel-padding-inline-end]
|
12
|
+
* @cssprop [--panel-padding-inline-start]
|
13
|
+
* @cssprop [--tabs-padding-block-end]
|
14
|
+
* @cssprop [--tabs-padding-block-start]
|
15
|
+
* @cssprop [--tabs-padding-inline-end]
|
16
|
+
* @cssprop [--tabs-padding-inline-start]
|
17
|
+
*
|
18
|
+
* @slot - One or more of `<glide-core-tab-panel>`.
|
12
19
|
* @slot nav - One or more of `<glide-core-tab>`.
|
13
20
|
*/
|
14
21
|
export default class GlideCoreTabGroup extends LitElement {
|
package/dist/tab.group.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
var __decorate=this&&this.__decorate||function(t,e,s,o){var i,l=arguments.length,a=l<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,s):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,s,o);else for(var r=t.length-1;r>=0;r--)(i=t[r])&&(a=(l<3?i(a):l>3?i(e,s,a):i(e,s))||a);return l>3&&a&&Object.defineProperty(e,s,a),a};import"./icon-button.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,queryAssignedElements,state}from"lit/decorators.js";import{when}from"lit/directives/when.js";import GlideCoreTab from"./tab.js";import GlideCoreTabPanel from"./tab.panel.js";import ow,{owSlotType}from"./library/ow.js";import styles from"./tab.group.styles.js";let GlideCoreTabGroup=class GlideCoreTabGroup extends LitElement{constructor(){super(...arguments),this.sticky=!1,this.isAfterFirstUpdated=!1,this.isDisableOverflowStartButton=!1,this.isDisableOverflowEndButton=!1,this.isShowOverflowButtons=!1,this.#t=createRef(),this.#e=null,this.#s=100,this.#o=createRef(),this.#i=new LocalizeController(this),this.#l=createRef(),this.#a=1,this.#r=createRef(),this.#n=createRef(),this.#c=null,this.#h=null,this.#b=null,this.#u=null,this.#d=createRef()}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:"closed"}}static{this.styles=styles}get activeTab(){return this.#e}set activeTab(t){this.#c=this.#e,this.#e=t}disconnectedCallback(){this.#h?.disconnect(),this.#h=null}firstUpdated(){owSlotType(this.#l.value,[GlideCoreTab]),owSlotType(this.#o.value,[GlideCoreTabPanel]),this.#f()}render(){return html`<div class="component" @click="${this.#v}" @keydown="${this.#m}" ${ref(this.#t)}><div class="${classMap({"tab-container":!0,sticky:this.sticky})}">${when(this.isShowOverflowButtons,(()=>html`<button style="height: ${this.#d.value?.clientHeight}px" class="${classMap({overflow:!0,disabled:this.isDisableOverflowStartButton})}" @click="${this.#p}" tabindex="-1" aria-label="${this.#i.term("previousTab")}" data-test="overflow-start-button" ${ref(this.#n)} ?disabled="${this.isDisableOverflowStartButton}"><svg aria-hidden="true" width="18" height="18" viewBox="0 0 24 24" fill="none"><path d="M15 6L9 12L15 18" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></button>`))}<div role="tablist" class="${classMap({"tab-group":!0,animated:this.isAfterFirstUpdated})}" ${ref(this.#d)} @scroll="${this.#w}" @focusout="${this.#T}" tabindex="-1"><slot name="nav" @slotchange="${this.#E}" ${ref(this.#l)}></slot></div>${when(this.isShowOverflowButtons,(()=>html`<button style="height: ${this.#d.value?.clientHeight}px" class="${classMap({overflow:!0,disabled:this.isDisableOverflowEndButton})}" @click="${this.#R}" tabindex="-1" aria-label="${this.#i.term("nextTab")}" data-test="overflow-end-button" ${ref(this.#r)} ?disabled="${this.isDisableOverflowEndButton}"><svg aria-hidden="true" width="18" height="18" viewBox="0 0 24 24" fill="none"><path d="M9 18L15 12L9 6" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></button>`))}</div><slot @slotchange="${this.#g}" ${ref(this.#o)}></slot></div>`}updated(){this.#y()}#t;#e;#s;#o;#i;#l;#a;#r;#n;#c;#h;#b;#u;#d;#v(t){const e=t.target.closest("glide-core-tab");e&&e instanceof GlideCoreTab&&!e.disabled&&this.#S(e)}#R(){this.#O("right")}#p(){this.#O("left")}#g(){owSlotType(this.#o.value,[GlideCoreTabPanel])}#T(){for(const[,t]of this.tabElements.entries())t.tabIndex=t===this.activeTab?0:-1}#m(t){const e=t.target.closest("glide-core-tab");if(["Enter"," "].includes(t.key)&&e&&e instanceof GlideCoreTab&&!e.disabled&&(this.#S(e),t.preventDefault()),["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(t.key)){const e=this.tabElements.find((t=>t.matches(":focus")));if("glide-core-tab"===e?.tagName.toLowerCase()){let s=this.tabElements.indexOf(e);switch(t.key){case"Home":s=0;break;case"End":s=this.tabElements.length-1;break;case"ArrowLeft":s--;break;case"ArrowRight":s++}s<0&&(s=this.tabElements.length-1),s>this.tabElements.length-1&&(s=0),this.tabElements[s].focus({preventScroll:!1});for(const[,t]of this.tabElements.entries())t.tabIndex=this.tabElements[s]===t?0:-1;this.#B(),t.preventDefault()}}}#E(){owSlotType(this.#l.value,[GlideCoreTab]),this.#y(),this.#C(),this.#B()}#w(){this.#u&&clearTimeout(this.#u),this.#u=setTimeout((()=>{this.#B()}),this.#s)}#O(t){const e="right"===t?1:-1;ow(this.#d.value,ow.object.instanceOf(HTMLElement));const s=e*this.#d.value?.clientWidth*.5;this.#d.value?.scrollBy({left:s,top:0})}#C(){for(const[t,e]of this.tabElements.entries())this.activeTab||0!==t?(e.active=this.activeTab===e,e.tabIndex=this.activeTab===e?0:-1):(this.activeTab=e,this.activeTab.active=!0,this.activeTab.tabIndex=0);for(const t of this.panelElements){const e=this.activeTab?.getAttribute("panel"),s=t.getAttribute("name");t.isActive=s===e,t.tabIndex=s===e?0:-1}if(this.activeTab!==this.#c&&this.activeTab&&this.tabElements.length>0&&this.#t.value){const t=Number.parseInt(window.getComputedStyle(this.activeTab).getPropertyValue("padding-inline-start")),e=this.activeTab===this.tabElements.at(0)?t:this.activeTab.offsetLeft-this.tabElements[0].offsetLeft;this.#t.value.style.setProperty("--active-tab-indicator-translate",`${e}px`);const s=this.activeTab===this.tabElements.at(0)||this.activeTab===this.tabElements.at(-1)?t:0,{width:o}=this.activeTab.getBoundingClientRect();this.#t.value.style.setProperty("--active-tab-indicator-width",o-s+"px"),this.isAfterFirstUpdated=!0}}#L(){const t=this.#d.value,e=t?.getBoundingClientRect();if(ow(t,ow.object.instanceOf(HTMLElement)),e){const{width:s}=e,o=t.scrollLeft+s,i=t.scrollWidth;this.isDisableOverflowEndButton=i-o<=this.#a}}#B(){const t=this.#d.value,e=t?.getBoundingClientRect();if(t&&e){const{width:s}=e;this.isShowOverflowButtons=t.scrollWidth-s>this.#a}this.#G(),this.#L()}#G(){ow(this.#d.value,ow.object.instanceOf(HTMLElement)),this.isDisableOverflowStartButton=this.#d.value.scrollLeft<=0}#f(){this.#h=new ResizeObserver((t=>{t?.at(0)?.target===this.#d.value&&(this.#b&&clearTimeout(this.#b),this.#b=setTimeout((()=>{this.#B()}),this.#s))})),ow(this.#d.value,ow.object.instanceOf(HTMLElement)),this.#h.observe(this.#d.value)}#y(){for(const t of this.tabElements){const e=this.panelElements.filter((e=>e.name===t.panel))?.at(0);e?.getAttribute("id")&&(t.setAttribute("aria-controls",e.getAttribute("id")),e.setAttribute("aria-labelledby",t.getAttribute("id")))}}#S(t){this.activeTab=t,this.#C(),this.dispatchEvent(new CustomEvent("tab-show",{bubbles:!0,detail:{panel:t.panel}}))}};__decorate([property({type:Boolean,reflect:!0})],GlideCoreTabGroup.prototype,"sticky",void 0),__decorate([state()],GlideCoreTabGroup.prototype,"activeTab",null),__decorate([state()],GlideCoreTabGroup.prototype,"isAfterFirstUpdated",void 0),__decorate([state()],GlideCoreTabGroup.prototype,"isDisableOverflowStartButton",void 0),__decorate([state()],GlideCoreTabGroup.prototype,"isDisableOverflowEndButton",void 0),__decorate([state()],GlideCoreTabGroup.prototype,"isShowOverflowButtons",void 0),__decorate([queryAssignedElements()],GlideCoreTabGroup.prototype,"panelElements",void 0),__decorate([queryAssignedElements({slot:"nav"})],GlideCoreTabGroup.prototype,"tabElements",void 0),GlideCoreTabGroup=__decorate([customElement("glide-core-tab-group")],GlideCoreTabGroup);export default GlideCoreTabGroup;
|
1
|
+
var __decorate=this&&this.__decorate||function(t,e,s,o){var i,l=arguments.length,a=l<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,s):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,s,o);else for(var r=t.length-1;r>=0;r--)(i=t[r])&&(a=(l<3?i(a):l>3?i(e,s,a):i(e,s))||a);return l>3&&a&&Object.defineProperty(e,s,a),a};import"./icon-button.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,queryAssignedElements,state}from"lit/decorators.js";import{when}from"lit/directives/when.js";import GlideCoreTab from"./tab.js";import GlideCoreTabPanel from"./tab.panel.js";import ow,{owSlotType}from"./library/ow.js";import styles from"./tab.group.styles.js";let GlideCoreTabGroup=class GlideCoreTabGroup extends LitElement{constructor(){super(...arguments),this.sticky=!1,this.isAfterFirstUpdated=!1,this.isDisableOverflowStartButton=!1,this.isDisableOverflowEndButton=!1,this.isShowOverflowButtons=!1,this.#t=createRef(),this.#e=null,this.#s=100,this.#o=createRef(),this.#i=new LocalizeController(this),this.#l=createRef(),this.#a=1,this.#r=createRef(),this.#n=createRef(),this.#c=null,this.#h=null,this.#b=null,this.#u=null,this.#d=createRef()}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:"closed"}}static{this.styles=styles}get activeTab(){return this.#e}set activeTab(t){this.#c=this.#e,this.#e=t}disconnectedCallback(){this.#h?.disconnect(),this.#h=null}firstUpdated(){owSlotType(this.#l.value,[GlideCoreTab]),owSlotType(this.#o.value,[GlideCoreTabPanel]),this.#f()}render(){return html`<div class="component" @click="${this.#v}" @keydown="${this.#m}" ${ref(this.#t)}><div class="${classMap({"tab-container":!0,sticky:this.sticky})}" data-test="tab-container">${when(this.isShowOverflowButtons,(()=>html`<button style="height: ${this.#d.value?.clientHeight}px" class="${classMap({overflow:!0,disabled:this.isDisableOverflowStartButton})}" @click="${this.#p}" tabindex="-1" aria-label="${this.#i.term("previousTab")}" data-test="overflow-start-button" ${ref(this.#n)} ?disabled="${this.isDisableOverflowStartButton}"><svg aria-hidden="true" width="18" height="18" viewBox="0 0 24 24" fill="none"><path d="M15 6L9 12L15 18" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></button>`))}<div role="tablist" class="${classMap({"tab-group":!0,animated:this.isAfterFirstUpdated})}" ${ref(this.#d)} @scroll="${this.#w}" @focusout="${this.#T}" tabindex="-1"><slot name="nav" @slotchange="${this.#E}" ${ref(this.#l)}></slot></div>${when(this.isShowOverflowButtons,(()=>html`<button style="height: ${this.#d.value?.clientHeight}px" class="${classMap({overflow:!0,disabled:this.isDisableOverflowEndButton})}" @click="${this.#R}" tabindex="-1" aria-label="${this.#i.term("nextTab")}" data-test="overflow-end-button" ${ref(this.#r)} ?disabled="${this.isDisableOverflowEndButton}"><svg aria-hidden="true" width="18" height="18" viewBox="0 0 24 24" fill="none"><path d="M9 18L15 12L9 6" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></button>`))}</div><slot @slotchange="${this.#g}" ${ref(this.#o)}></slot></div>`}updated(){this.#y()}#t;#e;#s;#o;#i;#l;#a;#r;#n;#c;#h;#b;#u;#d;#v(t){const e=t.target.closest("glide-core-tab");e&&e instanceof GlideCoreTab&&!e.disabled&&this.#S(e)}#R(){this.#O("right")}#p(){this.#O("left")}#g(){owSlotType(this.#o.value,[GlideCoreTabPanel])}#T(){for(const[,t]of this.tabElements.entries())t.tabIndex=t===this.activeTab?0:-1}#m(t){const e=t.target.closest("glide-core-tab");if(["Enter"," "].includes(t.key)&&e&&e instanceof GlideCoreTab&&!e.disabled&&(this.#S(e),t.preventDefault()),["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(t.key)){const e=this.tabElements.find((t=>t.matches(":focus")));if("glide-core-tab"===e?.tagName.toLowerCase()){let s=this.tabElements.indexOf(e);switch(t.key){case"Home":s=0;break;case"End":s=this.tabElements.length-1;break;case"ArrowLeft":s--;break;case"ArrowRight":s++}s<0&&(s=this.tabElements.length-1),s>this.tabElements.length-1&&(s=0),this.tabElements[s].focus({preventScroll:!1});for(const[,t]of this.tabElements.entries())t.tabIndex=this.tabElements[s]===t?0:-1;this.#B(),t.preventDefault()}}}#E(){owSlotType(this.#l.value,[GlideCoreTab]),this.#y(),this.#C(),this.#B()}#w(){this.#u&&clearTimeout(this.#u),this.#u=setTimeout((()=>{this.#B()}),this.#s)}#O(t){const e="right"===t?1:-1;ow(this.#d.value,ow.object.instanceOf(HTMLElement));const s=e*this.#d.value?.clientWidth*.5;this.#d.value?.scrollBy({left:s,top:0})}#C(){for(const[t,e]of this.tabElements.entries())this.activeTab||0!==t?(e.active=this.activeTab===e,e.tabIndex=this.activeTab===e?0:-1):(this.activeTab=e,this.activeTab.active=!0,this.activeTab.tabIndex=0);for(const t of this.panelElements){const e=this.activeTab?.getAttribute("panel"),s=t.getAttribute("name");t.isActive=s===e,t.tabIndex=s===e?0:-1}if(this.activeTab!==this.#c&&this.activeTab&&this.tabElements.length>0&&this.#t.value){const t=Number.parseInt(window.getComputedStyle(this.activeTab).getPropertyValue("padding-inline-start")),e=this.activeTab===this.tabElements.at(0)?t:this.activeTab.offsetLeft-this.tabElements[0].offsetLeft;this.#t.value.style.setProperty("--active-tab-indicator-translate",`${e}px`);const s=this.activeTab===this.tabElements.at(0)||this.activeTab===this.tabElements.at(-1)?t:0,{width:o}=this.activeTab.getBoundingClientRect();this.#t.value.style.setProperty("--active-tab-indicator-width",o-s+"px"),this.isAfterFirstUpdated=!0}}#L(){const t=this.#d.value,e=t?.getBoundingClientRect();if(ow(t,ow.object.instanceOf(HTMLElement)),e){const{width:s}=e,o=t.scrollLeft+s,i=t.scrollWidth;this.isDisableOverflowEndButton=i-o<=this.#a}}#B(){const t=this.#d.value,e=t?.getBoundingClientRect();if(t&&e){const{width:s}=e;this.isShowOverflowButtons=t.scrollWidth-s>this.#a}this.#G(),this.#L()}#G(){ow(this.#d.value,ow.object.instanceOf(HTMLElement)),this.isDisableOverflowStartButton=this.#d.value.scrollLeft<=0}#f(){this.#h=new ResizeObserver((t=>{t?.at(0)?.target===this.#d.value&&(this.#b&&clearTimeout(this.#b),this.#b=setTimeout((()=>{this.#B()}),this.#s))})),ow(this.#d.value,ow.object.instanceOf(HTMLElement)),this.#h.observe(this.#d.value)}#y(){for(const t of this.tabElements){const e=this.panelElements.filter((e=>e.name===t.panel))?.at(0);e?.getAttribute("id")&&(t.setAttribute("aria-controls",e.getAttribute("id")),e.setAttribute("aria-labelledby",t.getAttribute("id")))}}#S(t){this.activeTab=t,this.#C(),this.dispatchEvent(new CustomEvent("tab-show",{bubbles:!0,detail:{panel:t.panel}}))}};__decorate([property({type:Boolean,reflect:!0})],GlideCoreTabGroup.prototype,"sticky",void 0),__decorate([state()],GlideCoreTabGroup.prototype,"activeTab",null),__decorate([state()],GlideCoreTabGroup.prototype,"isAfterFirstUpdated",void 0),__decorate([state()],GlideCoreTabGroup.prototype,"isDisableOverflowStartButton",void 0),__decorate([state()],GlideCoreTabGroup.prototype,"isDisableOverflowEndButton",void 0),__decorate([state()],GlideCoreTabGroup.prototype,"isShowOverflowButtons",void 0),__decorate([queryAssignedElements()],GlideCoreTabGroup.prototype,"panelElements",void 0),__decorate([queryAssignedElements({slot:"nav"})],GlideCoreTabGroup.prototype,"tabElements",void 0),GlideCoreTabGroup=__decorate([customElement("glide-core-tab-group")],GlideCoreTabGroup);export default GlideCoreTabGroup;
|
package/dist/tab.group.styles.js
CHANGED
@@ -5,13 +5,23 @@ import{css}from"lit";export default[css`
|
|
5
5
|
flex-direction: column;
|
6
6
|
|
7
7
|
& .tab-container {
|
8
|
-
background-color: var(--glide-core-surface-page);
|
9
8
|
border-block-end: 1px solid var(--glide-core-border-base-lighter);
|
10
9
|
box-sizing: border-box;
|
11
10
|
display: flex;
|
11
|
+
padding-block-end: var(--tabs-padding-block-end);
|
12
|
+
|
13
|
+
/* Better to be explicit with start and end than using the shorthand property */
|
14
|
+
/* stylelint-disable-next-line declaration-block-no-redundant-longhand-properties */
|
15
|
+
padding-block-start: var(--tabs-padding-block-start);
|
16
|
+
padding-inline-end: var(--tabs-padding-inline-end);
|
17
|
+
|
18
|
+
/* Better to be explicit with start and end than using the shorthand property */
|
19
|
+
/* stylelint-disable-next-line declaration-block-no-redundant-longhand-properties */
|
20
|
+
padding-inline-start: var(--tabs-padding-inline-start);
|
12
21
|
}
|
13
22
|
|
14
23
|
& .sticky {
|
24
|
+
background-color: var(--glide-core-surface-page);
|
15
25
|
inset-block-start: 0;
|
16
26
|
position: sticky;
|
17
27
|
}
|
@@ -2,7 +2,7 @@
|
|
2
2
|
import './tab.group.js';
|
3
3
|
import './tab.js';
|
4
4
|
import './tab.panel.js';
|
5
|
-
import { expect, fixture, html, oneEvent, waitUntil } from '@open-wc/testing';
|
5
|
+
import { assert, expect, fixture, html, oneEvent, waitUntil, } from '@open-wc/testing';
|
6
6
|
import { sendKeys } from '@web/test-runner-commands';
|
7
7
|
import GlideCoreTabGroup from './tab.group.js';
|
8
8
|
import GlideCoreTabPanel from './tab.panel.js';
|
@@ -130,6 +130,82 @@ it('can use left/right, home and end keys to focus on tabs', async () => {
|
|
130
130
|
await sendKeys({ press: 'Enter' });
|
131
131
|
expect(thirdTab.active).to.be.true;
|
132
132
|
});
|
133
|
+
it('sets padding-inline-start of the Tab Group via `--tabs-padding-inline-start`', async () => {
|
134
|
+
const component = await fixture(html `
|
135
|
+
<glide-core-tab-group style="--tabs-padding-inline-start: 100px;">
|
136
|
+
<glide-core-tab slot="nav" panel="1">Tab 1</glide-core-tab>
|
137
|
+
|
138
|
+
<glide-core-tab-panel name="1">Content for Tab 1</glide-core-tab-panel>
|
139
|
+
</glide-core-tab-group>
|
140
|
+
`);
|
141
|
+
const tabContainer = component?.shadowRoot?.querySelector('[data-test="tab-container"]');
|
142
|
+
assert(tabContainer);
|
143
|
+
expect(window.getComputedStyle(tabContainer).paddingInline).to.equal('100px 0px');
|
144
|
+
});
|
145
|
+
it('sets padding-inline-end of the Tab Group via `--tabs-padding-inline-end`', async () => {
|
146
|
+
const component = await fixture(html `
|
147
|
+
<glide-core-tab-group style="--tabs-padding-inline-end: 100px;">
|
148
|
+
<glide-core-tab slot="nav" panel="1">Tab 1</glide-core-tab>
|
149
|
+
|
150
|
+
<glide-core-tab-panel name="1">Content for Tab 1</glide-core-tab-panel>
|
151
|
+
</glide-core-tab-group>
|
152
|
+
`);
|
153
|
+
const tabContainer = component?.shadowRoot?.querySelector('[data-test="tab-container"]');
|
154
|
+
assert(tabContainer);
|
155
|
+
expect(window.getComputedStyle(tabContainer).paddingInline).to.equal('0px 100px');
|
156
|
+
});
|
157
|
+
it('sets padding-block-start of the Tab Group via `--tabs-padding-block-start`', async () => {
|
158
|
+
const component = await fixture(html `
|
159
|
+
<glide-core-tab-group style="--tabs-padding-block-start: 100px;">
|
160
|
+
<glide-core-tab slot="nav" panel="1">Tab 1</glide-core-tab>
|
161
|
+
|
162
|
+
<glide-core-tab-panel name="1">Content for Tab 1</glide-core-tab-panel>
|
163
|
+
</glide-core-tab-group>
|
164
|
+
`);
|
165
|
+
const tabContainer = component?.shadowRoot?.querySelector('[data-test="tab-container"]');
|
166
|
+
assert(tabContainer);
|
167
|
+
expect(window.getComputedStyle(tabContainer).paddingBlock).to.equal('100px 0px');
|
168
|
+
});
|
169
|
+
it('sets padding-block-end of the Tab Group via `--tabs-padding-block-end`', async () => {
|
170
|
+
const component = await fixture(html `
|
171
|
+
<glide-core-tab-group style="--tabs-padding-block-end: 100px;">
|
172
|
+
<glide-core-tab slot="nav" panel="1">Tab 1</glide-core-tab>
|
173
|
+
|
174
|
+
<glide-core-tab-panel name="1">Content for Tab 1</glide-core-tab-panel>
|
175
|
+
</glide-core-tab-group>
|
176
|
+
`);
|
177
|
+
const tabContainer = component?.shadowRoot?.querySelector('[data-test="tab-container"]');
|
178
|
+
assert(tabContainer);
|
179
|
+
expect(window.getComputedStyle(tabContainer).paddingBlock).to.equal('0px 100px');
|
180
|
+
});
|
181
|
+
it('sets padding-inline-start of the Tab Panel via `--panel-padding-inline-start`', async () => {
|
182
|
+
const component = await fixture(html `
|
183
|
+
<glide-core-tab-group style="--panel-padding-inline-start: 100px;">
|
184
|
+
<glide-core-tab slot="nav" panel="1">Tab 1</glide-core-tab>
|
185
|
+
|
186
|
+
<glide-core-tab-panel name="1">Content for Tab 1</glide-core-tab-panel>
|
187
|
+
</glide-core-tab-group>
|
188
|
+
`);
|
189
|
+
const tabPanel = component
|
190
|
+
?.querySelector('glide-core-tab-panel')
|
191
|
+
?.shadowRoot?.querySelector('[data-test="tab-panel"]');
|
192
|
+
assert(tabPanel);
|
193
|
+
expect(window.getComputedStyle(tabPanel).paddingInline).to.equal('100px 0px');
|
194
|
+
});
|
195
|
+
it('sets padding-inline-end of the Tab Panel via `--panel-padding-inline-end`', async () => {
|
196
|
+
const component = await fixture(html `
|
197
|
+
<glide-core-tab-group style="--panel-padding-inline-end: 100px;">
|
198
|
+
<glide-core-tab slot="nav" panel="1">Tab 1</glide-core-tab>
|
199
|
+
|
200
|
+
<glide-core-tab-panel name="1">Content for Tab 1</glide-core-tab-panel>
|
201
|
+
</glide-core-tab-group>
|
202
|
+
`);
|
203
|
+
const tabPanel = component
|
204
|
+
?.querySelector('glide-core-tab-panel')
|
205
|
+
?.shadowRoot?.querySelector('[data-test="tab-panel"]');
|
206
|
+
assert(tabPanel);
|
207
|
+
expect(window.getComputedStyle(tabPanel).paddingInline).to.equal('0px 100px');
|
208
|
+
});
|
133
209
|
it('throws an error when an element other than `glide-core-tab` is a child of the `nav` slot', async () => {
|
134
210
|
await expectArgumentError(() => {
|
135
211
|
return fixture(html `
|
package/dist/tab.panel.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{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"./tab.panel.styles.js";let GlideCoreTabPanel=class GlideCoreTabPanel extends LitElement{constructor(){super(...arguments),this.name="",this.isActive=!0,this.#e=nanoid()}static{this.instanceCount=0}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:"closed"}}static{this.styles=styles}firstUpdated(){this.setAttribute("role","tabpanel"),this.id=this.#e}render(){return html`<div class="${classMap({component:!0,hidden:!this.isActive})}"><slot></slot></div>`}updated(e){super.updated(e),e.has("isActive")&&this.setAttribute("aria-hidden",this.isActive?"false":"true")}#e};__decorate([property({reflect:!0})],GlideCoreTabPanel.prototype,"name",void 0),__decorate([property({type:Boolean})],GlideCoreTabPanel.prototype,"isActive",void 0),GlideCoreTabPanel=__decorate([customElement("glide-core-tab-panel")],GlideCoreTabPanel);export default GlideCoreTabPanel;
|
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{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"./tab.panel.styles.js";let GlideCoreTabPanel=class GlideCoreTabPanel extends LitElement{constructor(){super(...arguments),this.name="",this.isActive=!0,this.#e=nanoid()}static{this.instanceCount=0}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:"closed"}}static{this.styles=styles}firstUpdated(){this.setAttribute("role","tabpanel"),this.id=this.#e}render(){return html`<div class="${classMap({component:!0,hidden:!this.isActive})}" data-test="tab-panel"><slot></slot></div>`}updated(e){super.updated(e),e.has("isActive")&&this.setAttribute("aria-hidden",this.isActive?"false":"true")}#e};__decorate([property({reflect:!0})],GlideCoreTabPanel.prototype,"name",void 0),__decorate([property({type:Boolean})],GlideCoreTabPanel.prototype,"isActive",void 0),GlideCoreTabPanel=__decorate([customElement("glide-core-tab-panel")],GlideCoreTabPanel);export default GlideCoreTabPanel;
|
package/dist/tab.panel.styles.js
CHANGED
@@ -9,5 +9,23 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";import
|
|
9
9
|
.component {
|
10
10
|
font-family: var(--glide-core-font-sans);
|
11
11
|
outline: none;
|
12
|
+
|
13
|
+
/*
|
14
|
+
Prefixing the CSS custom property with "panel" will
|
15
|
+
ensure we are robust. Imagine cases where consumers
|
16
|
+
have set "--padding-inline-start" or "--padding-inline-end"
|
17
|
+
already and now we require these variables to adjust
|
18
|
+
padding within our panels. Adding the prefix of "panel"
|
19
|
+
should ensure uniqueness to our component.
|
20
|
+
|
21
|
+
A second reason we prefix this is so that consumers
|
22
|
+
can set these properties on the parent Tab Group
|
23
|
+
and it will apply to all child panels for convenience.
|
24
|
+
*/
|
25
|
+
padding-inline-end: var(--panel-padding-inline-end);
|
26
|
+
|
27
|
+
/* Better to be explicit with start and end than using the shorthand property */
|
28
|
+
/* stylelint-disable-next-line declaration-block-no-redundant-longhand-properties */
|
29
|
+
padding-inline-start: var(--panel-padding-inline-start);
|
12
30
|
}
|
13
31
|
`];
|
package/dist/tag.d.ts
CHANGED
@@ -15,9 +15,11 @@ export default class GlideCoreTag extends LitElement {
|
|
15
15
|
static styles: import("lit").CSSResult[];
|
16
16
|
disabled: boolean;
|
17
17
|
label?: string;
|
18
|
+
privateEditable: boolean;
|
18
19
|
removable: boolean;
|
19
20
|
size: 'small' | 'medium' | 'large';
|
20
21
|
click(): void;
|
21
22
|
firstUpdated(): void;
|
23
|
+
focus(): void;
|
22
24
|
render(): import("lit").TemplateResult<1>;
|
23
25
|
}
|
package/dist/tag.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
var __decorate=this&&this.__decorate||function(e,t,o,i){var l
|
1
|
+
var __decorate=this&&this.__decorate||function(e,t,o,i){var s,l=arguments.length,a=l<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,o,i);else for(var r=e.length-1;r>=0;r--)(s=e[r])&&(a=(l<3?s(a):l>3?s(t,o,a):s(t,o))||a);return l>3&&a&&Object.defineProperty(t,o,a),a};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}from"lit/decorators.js";import{when}from"lit/directives/when.js";import pencilIcon from"./icons/pencil.js";import styles from"./tag.styles.js";let GlideCoreTag=class GlideCoreTag extends LitElement{constructor(){super(...arguments),this.disabled=!1,this.privateEditable=!1,this.removable=!1,this.size="medium",this.#e=createRef(),this.#t=!1,this.#o=new LocalizeController(this),this.#i=createRef()}static{this.shadowRootOptions={...LitElement.shadowRootOptions,delegatesFocus:!0,mode:"closed"}}static{this.styles=styles}click(){this.#i.value?.click()}firstUpdated(){this.#e.value?.addEventListener("animationend",(()=>{this.#e.value?.classList.remove("added")}),{once:!0})}focus(){this.#i.value?.focus()}render(){return html`<div class="${classMap({component:!0,added:!0,disabled:this.disabled,[this.size]:!0})}" data-test="component" ${ref(this.#e)}><slot class="${classMap({"icon-slot":!0,[this.size]:!0})}" name="icon"></slot>${this.label} ${when(this.privateEditable,(()=>html`<button aria-label="${this.#o.term("editTag",this.label)}" class="${classMap({"edit-button":!0,[this.size]:!0,disabled:this.disabled})}" data-test="edit-button" ?disabled="${this.disabled}" type="button" @click="${this.#s}" @keydown="${this.#l}">${pencilIcon}</button>`))} ${when(this.removable,(()=>html`<button aria-label="${this.#o.term("removeTag",this.label)}" class="${classMap({"removal-button":!0,[this.size]:!0,disabled:this.disabled})}" data-test="removal-button" type="button" ?disabled="${this.disabled}" @click="${this.#a}" @keydown="${this.#r}" ${ref(this.#i)}><svg width="14" height="14" viewBox="0 0 14 14" fill="none"><path d="M10.5 3.5L3.5 10.5M3.5 3.5L10.5 10.5" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/></svg></button>`))}</div>`}#e;#t;#o;#i;#s(){this.#t?this.#t=!1:this.dispatchEvent(new Event("edit",{bubbles:!0,composed:!0}))}#l(e){["Enter"," "].includes(e.key)&&(this.#t=!0,this.dispatchEvent(new Event("edit",{bubbles:!0,composed:!0})))}#a(){this.#t?this.#t=!1:(setTimeout((()=>{this.remove()}),200),this.#e.value?.classList.add("removed"),this.dispatchEvent(new Event("remove",{bubbles:!0,composed:!0})))}#r(e){["Enter"," "].includes(e.key)&&(this.#t=!0,setTimeout((()=>{this.remove()}),200),this.#e.value?.classList.add("removed"),this.dispatchEvent(new Event("remove",{bubbles:!0,composed:!0})))}};__decorate([property({reflect:!0,type:Boolean})],GlideCoreTag.prototype,"disabled",void 0),__decorate([property({reflect:!0})],GlideCoreTag.prototype,"label",void 0),__decorate([property({attribute:"private-editable",reflect:!0,type:Boolean})],GlideCoreTag.prototype,"privateEditable",void 0),__decorate([property({reflect:!0,type:Boolean})],GlideCoreTag.prototype,"removable",void 0),__decorate([property({reflect:!0})],GlideCoreTag.prototype,"size",void 0),GlideCoreTag=__decorate([customElement("glide-core-tag")],GlideCoreTag);export default GlideCoreTag;
|
package/dist/tag.styles.js
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export default[css`
|
2
|
-
${focusOutline("button:focus-visible")}
|
2
|
+
${focusOutline(".edit-button:focus-visible")}
|
3
|
+
${focusOutline(".removal-button:focus-visible")}
|
3
4
|
`,css`
|
4
5
|
.component {
|
5
6
|
align-items: center;
|
@@ -65,19 +66,16 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export
|
|
65
66
|
}
|
66
67
|
}
|
67
68
|
|
68
|
-
.button {
|
69
|
+
.removal-button {
|
69
70
|
align-items: center;
|
70
71
|
background-color: transparent;
|
71
|
-
block-size: var(--glide-core-spacing-sm);
|
72
72
|
border: none;
|
73
73
|
border-radius: 0.0625rem;
|
74
74
|
color: var(--glide-core-icon-display);
|
75
75
|
cursor: pointer;
|
76
76
|
display: flex;
|
77
|
-
inline-size: var(--glide-core-spacing-sm);
|
78
77
|
justify-content: center;
|
79
78
|
margin: 0;
|
80
|
-
margin-inline-start: 0.375rem;
|
81
79
|
padding: 0;
|
82
80
|
transition: color 200ms ease-in-out;
|
83
81
|
|
@@ -87,6 +85,12 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export
|
|
87
85
|
margin-inline-start: var(--glide-core-spacing-xs);
|
88
86
|
}
|
89
87
|
|
88
|
+
&.medium {
|
89
|
+
block-size: var(--glide-core-spacing-sm);
|
90
|
+
inline-size: var(--glide-core-spacing-sm);
|
91
|
+
margin-inline-start: 0.375rem;
|
92
|
+
}
|
93
|
+
|
90
94
|
&.small {
|
91
95
|
block-size: 0.625rem;
|
92
96
|
inline-size: 0.6215rem;
|
@@ -138,4 +142,41 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export
|
|
138
142
|
justify-content: center;
|
139
143
|
}
|
140
144
|
}
|
145
|
+
|
146
|
+
.edit-button {
|
147
|
+
background-color: transparent;
|
148
|
+
border: none;
|
149
|
+
border-radius: 0.0625rem;
|
150
|
+
display: flex;
|
151
|
+
padding: 0;
|
152
|
+
|
153
|
+
&.large {
|
154
|
+
margin-inline-start: var(--glide-core-spacing-xs);
|
155
|
+
}
|
156
|
+
|
157
|
+
&.medium {
|
158
|
+
--size: 0.75rem;
|
159
|
+
|
160
|
+
margin-inline-start: 0.375rem;
|
161
|
+
}
|
162
|
+
|
163
|
+
&.small {
|
164
|
+
--size: 0.625rem;
|
165
|
+
|
166
|
+
margin-inline-start: var(--glide-core-spacing-xxs);
|
167
|
+
}
|
168
|
+
|
169
|
+
&.disabled {
|
170
|
+
color: var(--glide-core-icon-tertiary-disabled);
|
171
|
+
cursor: not-allowed;
|
172
|
+
}
|
173
|
+
|
174
|
+
&:focus {
|
175
|
+
outline: none;
|
176
|
+
}
|
177
|
+
|
178
|
+
&:hover:not(.disabled) {
|
179
|
+
color: var(--glide-core-icon-primary-hover);
|
180
|
+
}
|
181
|
+
}
|
141
182
|
`];
|
package/dist/tag.test.basics.js
CHANGED
@@ -22,7 +22,7 @@ it('has defaults', async () => {
|
|
22
22
|
});
|
23
23
|
it('can be removed', async () => {
|
24
24
|
const component = await fixture(html `<glide-core-tag label="Label" removable></glide-core-tag>`);
|
25
|
-
const button = component.shadowRoot?.querySelector('[data-test="button"]');
|
25
|
+
const button = component.shadowRoot?.querySelector('[data-test="removal-button"]');
|
26
26
|
expect(button?.checkVisibility()).to.be.true;
|
27
27
|
expect(button?.getAttribute('aria-label')).to.equal('Remove tag: Label');
|
28
28
|
});
|
package/dist/tag.test.events.js
CHANGED
@@ -1,20 +1,93 @@
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
2
2
|
import './tag.js';
|
3
3
|
import { expect, fixture, html, oneEvent } from '@open-wc/testing';
|
4
|
+
import { sendKeys } from '@web/test-runner-commands';
|
4
5
|
import GlideCoreTag from './tag.js';
|
5
6
|
import sinon from 'sinon';
|
6
7
|
GlideCoreTag.shadowRootOptions.mode = 'open';
|
7
|
-
it('dispatches one "remove" event', async () => {
|
8
|
+
it('dispatches one "remove" event on click', async () => {
|
8
9
|
const component = await fixture(html `<glide-core-tag label="Label" removable></glide-core-tag>`);
|
10
|
+
setTimeout(() => {
|
11
|
+
component.shadowRoot
|
12
|
+
?.querySelector('[data-test="removal-button"]')
|
13
|
+
?.click();
|
14
|
+
});
|
9
15
|
const spy = sinon.spy();
|
10
16
|
component.addEventListener('remove', spy);
|
17
|
+
const event = await oneEvent(component, 'remove');
|
18
|
+
expect(event instanceof Event).to.be.true;
|
19
|
+
expect(event.bubbles).to.be.true;
|
20
|
+
expect(event.composed).to.be.true;
|
21
|
+
expect(spy.callCount).to.equal(1);
|
22
|
+
});
|
23
|
+
it('dispatches one "remove" event on Enter ', async () => {
|
24
|
+
const component = await fixture(html `<glide-core-tag label="Label" removable></glide-core-tag>`);
|
25
|
+
component.shadowRoot
|
26
|
+
?.querySelector('[data-test="removal-button"]')
|
27
|
+
?.focus();
|
28
|
+
sendKeys({ press: 'Enter' });
|
29
|
+
const spy = sinon.spy();
|
30
|
+
component.addEventListener('remove', spy);
|
31
|
+
const event = await oneEvent(component, 'remove');
|
32
|
+
expect(event instanceof Event).to.be.true;
|
33
|
+
expect(event.bubbles).to.be.true;
|
34
|
+
expect(event.composed).to.be.true;
|
35
|
+
expect(spy.callCount).to.equal(1);
|
36
|
+
});
|
37
|
+
it('dispatches one "remove" event on Space ', async () => {
|
38
|
+
const component = await fixture(html `<glide-core-tag label="Label" removable></glide-core-tag>`);
|
39
|
+
component.shadowRoot
|
40
|
+
?.querySelector('[data-test="removal-button"]')
|
41
|
+
?.focus();
|
42
|
+
sendKeys({ press: ' ' });
|
43
|
+
const spy = sinon.spy();
|
44
|
+
component.addEventListener('remove', spy);
|
45
|
+
const event = await oneEvent(component, 'remove');
|
46
|
+
expect(event instanceof Event).to.be.true;
|
47
|
+
expect(event.bubbles).to.be.true;
|
48
|
+
expect(event.composed).to.be.true;
|
49
|
+
expect(spy.callCount).to.equal(1);
|
50
|
+
});
|
51
|
+
it('dispatches one "edit" event on click', async () => {
|
52
|
+
const component = await fixture(html `<glide-core-tag label="Label" private-editable></glide-core-tag>`);
|
11
53
|
setTimeout(() => {
|
12
54
|
component.shadowRoot
|
13
|
-
?.querySelector('[data-test="button"]')
|
55
|
+
?.querySelector('[data-test="edit-button"]')
|
14
56
|
?.click();
|
15
57
|
});
|
16
|
-
const
|
58
|
+
const spy = sinon.spy();
|
59
|
+
component.addEventListener('edit', spy);
|
60
|
+
const event = await oneEvent(component, 'edit');
|
61
|
+
expect(event instanceof Event).to.be.true;
|
62
|
+
expect(event.bubbles).to.be.true;
|
63
|
+
expect(event.composed).to.be.true;
|
64
|
+
expect(spy.callCount).to.equal(1);
|
65
|
+
});
|
66
|
+
it('dispatches one "edit" event on Enter ', async () => {
|
67
|
+
const component = await fixture(html `<glide-core-tag label="Label" private-editable></glide-core-tag>`);
|
68
|
+
component.shadowRoot
|
69
|
+
?.querySelector('[data-test="edit-button"]')
|
70
|
+
?.focus();
|
71
|
+
sendKeys({ press: 'Enter' });
|
72
|
+
const spy = sinon.spy();
|
73
|
+
component.addEventListener('edit', spy);
|
74
|
+
const event = await oneEvent(component, 'edit');
|
75
|
+
expect(event instanceof Event).to.be.true;
|
76
|
+
expect(event.bubbles).to.be.true;
|
77
|
+
expect(event.composed).to.be.true;
|
78
|
+
expect(spy.callCount).to.equal(1);
|
79
|
+
});
|
80
|
+
it('dispatches one "edit" event on Space ', async () => {
|
81
|
+
const component = await fixture(html `<glide-core-tag label="Label" private-editable></glide-core-tag>`);
|
82
|
+
component.shadowRoot
|
83
|
+
?.querySelector('[data-test="edit-button"]')
|
84
|
+
?.focus();
|
85
|
+
sendKeys({ press: ' ' });
|
86
|
+
const spy = sinon.spy();
|
87
|
+
component.addEventListener('edit', spy);
|
88
|
+
const event = await oneEvent(component, 'edit');
|
17
89
|
expect(event instanceof Event).to.be.true;
|
18
90
|
expect(event.bubbles).to.be.true;
|
91
|
+
expect(event.composed).to.be.true;
|
19
92
|
expect(spy.callCount).to.equal(1);
|
20
93
|
});
|
package/dist/tag.test.focus.js
CHANGED
@@ -5,6 +5,6 @@ GlideCoreTag.shadowRootOptions.mode = 'open';
|
|
5
5
|
it('calling `focus()` focuses the button', async () => {
|
6
6
|
const component = await fixture(html `<glide-core-tag label="Label" removable></glide-core-tag>`);
|
7
7
|
component.focus();
|
8
|
-
const button = component.shadowRoot?.querySelector('[data-test="button"]');
|
8
|
+
const button = component.shadowRoot?.querySelector('[data-test="removal-button"]');
|
9
9
|
expect(component.shadowRoot?.activeElement).to.equal(button);
|
10
10
|
});
|
package/dist/translations/en.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
const translation={$code:"en",$name:"English",$dir:"ltr",close:"Close",dismiss:"Dismiss",open:"Open",selectAll:"Select all",moreInformation:"More information",notifications:"Notifications",nextTab:"Next tab",previousTab:"Previous tab",announcedCharacterCount:(
|
1
|
+
const translation={$code:"en",$name:"English",$dir:"ltr",close:"Close",dismiss:"Dismiss",open:"Open",selectAll:"Select all",moreInformation:"More information",notifications:"Notifications",nextTab:"Next tab",previousTab:"Previous tab",announcedCharacterCount:(t,o)=>`Character count ${t} of ${o}`,displayedCharacterCount:(t,o)=>`${t}/${o}`,clearEntry:t=>`Clear ${t} entry`,editOption:t=>`Edit option: ${t}`,editTag:t=>`Edit tag: ${t}`,removeTag:t=>`Remove tag: ${t}`,actionsFor:t=>`Actions for ${t}`};export default translation;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { Translation } from '../library/localize.js';
|
2
|
-
export declare const PENDING_STRINGS: readonly [];
|
2
|
+
export declare const PENDING_STRINGS: readonly ["editOption", "editTag"];
|
3
3
|
type PendingTranslation = (typeof PENDING_STRINGS)[number];
|
4
4
|
declare const translation: Omit<Translation, PendingTranslation>;
|
5
5
|
export default translation;
|
package/dist/translations/fr.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const PENDING_STRINGS=[];const translation={$code:"fr",$name:"French",$dir:"ltr",close:"Fermer",dismiss:"Congédier",open:"Ouvrir",selectAll:"Tout sélectionner",moreInformation:"Plus d’informations",notifications:"Notifications",nextTab:"Onglet suivant",previousTab:"Onglet précédent",announcedCharacterCount:(e,
|
1
|
+
export const PENDING_STRINGS=["editOption","editTag"];const translation={$code:"fr",$name:"French",$dir:"ltr",close:"Fermer",dismiss:"Congédier",open:"Ouvrir",selectAll:"Tout sélectionner",moreInformation:"Plus d’informations",notifications:"Notifications",nextTab:"Onglet suivant",previousTab:"Onglet précédent",announcedCharacterCount:(e,t)=>`Nombre de caractères ${e} de ${t}`,displayedCharacterCount:(e,t)=>`${e}/${t}`,clearEntry:e=>`Effacer l'entrée ${e}`,removeTag:e=>`Supprimer la balise : ${e}`,actionsFor:e=>`Actions pour ${e}`};export default translation;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { Translation } from '../library/localize.js';
|
2
|
-
export declare const PENDING_STRINGS: readonly [];
|
2
|
+
export declare const PENDING_STRINGS: readonly ["editOption", "editTag"];
|
3
3
|
type PendingTranslation = (typeof PENDING_STRINGS)[number];
|
4
4
|
declare const translation: Omit<Translation, PendingTranslation>;
|
5
5
|
export default translation;
|
package/dist/translations/ja.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const PENDING_STRINGS=[];const translation={$code:"ja",$name:"Japanese",$dir:"ltr",close:"閉じる",dismiss:"無視",open:"オープン",selectAll:"すべて選択",moreInformation:"詳細情報",notifications:"通知",nextTab:"Onglet suivant",previousTab:"Onglet précédent",announcedCharacterCount:(
|
1
|
+
export const PENDING_STRINGS=["editOption","editTag"];const translation={$code:"ja",$name:"Japanese",$dir:"ltr",close:"閉じる",dismiss:"無視",open:"オープン",selectAll:"すべて選択",moreInformation:"詳細情報",notifications:"通知",nextTab:"Onglet suivant",previousTab:"Onglet précédent",announcedCharacterCount:(t,e)=>`${e} 文字数の${t}`,displayedCharacterCount:(t,e)=>`${t}/${e}`,clearEntry:t=>`${t}エントリのクリア`,removeTag:t=>`タグを削除: ${t}`,actionsFor:t=>`${t}のアクション`};export default translation;
|
package/package.json
CHANGED