@crowdstrike/glide-core 0.15.1 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accordion.d.ts +1 -1
- package/dist/accordion.js +1 -1
- package/dist/accordion.styles.js +17 -15
- package/dist/button-group.d.ts +1 -2
- package/dist/button-group.js +1 -1
- package/dist/button.d.ts +0 -11
- package/dist/button.js +1 -1
- package/dist/checkbox-group.d.ts +3 -3
- package/dist/checkbox-group.js +1 -1
- package/dist/checkbox.d.ts +3 -3
- package/dist/checkbox.js +17 -37
- package/dist/checkbox.styles.js +1 -12
- package/dist/drawer.d.ts +2 -5
- package/dist/drawer.js +1 -1
- package/dist/drawer.styles.js +0 -2
- package/dist/dropdown.d.ts +4 -3
- package/dist/dropdown.js +29 -43
- package/dist/dropdown.option.js +1 -1
- package/dist/dropdown.styles.js +1 -0
- package/dist/icons/checked.js +1 -1
- package/dist/icons/chevron.d.ts +2 -0
- package/dist/icons/chevron.js +1 -0
- package/dist/icons/magnifying-glass.d.ts +1 -1
- package/dist/icons/magnifying-glass.js +1 -1
- package/dist/icons/pencil.js +1 -1
- package/dist/icons/x.d.ts +2 -0
- package/dist/icons/x.js +1 -0
- package/dist/inline-alert.d.ts +5 -5
- package/dist/inline-alert.js +1 -1
- package/dist/inline-alert.styles.js +9 -5
- package/dist/input.d.ts +3 -3
- package/dist/input.js +38 -61
- package/dist/label.js +1 -1
- package/dist/label.styles.js +5 -1
- package/dist/library/localize.d.ts +1 -2
- package/dist/library/localize.test.js +1 -3
- package/dist/library/mouse.d.ts +2 -0
- package/dist/library/mouse.js +1 -0
- package/dist/library/ow.test.js +0 -1
- package/dist/menu.d.ts +3 -1
- package/dist/menu.js +1 -1
- package/dist/menu.options.d.ts +1 -1
- package/dist/modal.d.ts +5 -8
- package/dist/modal.icon-button.d.ts +2 -7
- package/dist/modal.icon-button.styles.js +3 -3
- package/dist/modal.js +1 -1
- package/dist/modal.styles.js +50 -45
- package/dist/popover.d.ts +28 -0
- package/dist/popover.js +1 -0
- package/dist/popover.styles.js +119 -0
- package/dist/radio-group.d.ts +11 -11
- package/dist/radio-group.js +11 -9
- package/dist/radio-group.radio.d.ts +25 -0
- package/dist/radio-group.radio.js +1 -0
- package/dist/radio-group.radio.styles.d.ts +2 -0
- package/dist/{radio.styles.js → radio-group.radio.styles.js} +25 -37
- package/dist/radio-group.styles.js +1 -5
- package/dist/split-button.d.ts +2 -1
- package/dist/split-button.secondary-button.js +1 -1
- package/dist/split-button.secondary-button.styles.js +6 -9
- package/dist/tab.d.ts +1 -2
- package/dist/tab.group.d.ts +0 -3
- package/dist/tab.group.js +1 -1
- package/dist/tab.group.styles.js +61 -55
- package/dist/tab.panel.d.ts +4 -4
- package/dist/tab.panel.js +1 -1
- package/dist/tab.styles.js +8 -8
- package/dist/tag.d.ts +1 -1
- package/dist/tag.js +1 -1
- package/dist/tag.styles.js +9 -5
- package/dist/textarea.d.ts +3 -3
- package/dist/textarea.js +1 -1
- package/dist/toasts.toast.js +1 -1
- package/dist/toasts.toast.styles.js +6 -3
- package/dist/toggle.d.ts +2 -2
- package/dist/toggle.js +1 -1
- package/dist/toggle.styles.js +8 -10
- package/dist/tooltip.d.ts +3 -1
- package/dist/tooltip.js +1 -1
- package/dist/tooltip.styles.js +8 -11
- 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/dist/tree.d.ts +1 -2
- package/dist/tree.item.d.ts +0 -2
- package/dist/tree.item.js +1 -1
- package/dist/tree.item.menu.d.ts +2 -2
- package/dist/tree.item.menu.js +1 -1
- package/dist/tree.item.styles.js +41 -48
- package/dist/tree.js +1 -1
- package/package.json +11 -10
- package/dist/icons/informational.d.ts +0 -2
- package/dist/icons/informational.js +0 -1
- package/dist/radio.d.ts +0 -20
- package/dist/radio.js +0 -1
- /package/dist/{radio.styles.d.ts → popover.styles.d.ts} +0 -0
package/dist/label.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
var __decorate=this&&this.__decorate||function(e,t,o,l){var i,s=arguments.length,r=s<3?t:null===l?l=Object.getOwnPropertyDescriptor(t,o):l;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,o,l);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(r=(s<3?i(r):s>3?i(t,o,r):i(t,o))||r);return s>3&&r&&Object.defineProperty(t,o,r),r};import"./tooltip.js";import{LitElement,html
|
1
|
+
var __decorate=this&&this.__decorate||function(e,t,o,l){var i,s=arguments.length,r=s<3?t:null===l?l=Object.getOwnPropertyDescriptor(t,o):l;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,o,l);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(r=(s<3?i(r):s>3?i(t,o,r):i(t,o))||r);return s>3&&r&&Object.defineProperty(t,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{styleMap}from"lit/directives/style-map.js";import ow,{owSlot}from"./library/ow.js";import styles from"./label.styles.js";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.hasDescription=!1,this.hasSummarySlot=!1,this.hasTooltipSlot=!1,this.isLabelTooltip=!1,this.label="",this.#e=createRef(),this.#t=createRef(),this.#o=createRef(),this.#l=createRef(),this.#i=createRef(),this.#s=createRef()}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:"closed"}}static{this.styles=styles}firstUpdated(){owSlot(this.#t.value),owSlot(this.#e.value);const e=new ResizeObserver((()=>{this.hasDescription=Boolean(this.#o.value&&this.#o.value.offsetHeight>0)}));this.#o.value&&e.observe(this.#o.value)}render(){return html`<div class="${classMap({component:!0,horizontal:"horizontal"===this.orientation,vertical:"vertical"===this.orientation,left:"left"===this.split,middle:"middle"===this.split,"hidden-label":this.hide})}"><div class="${classMap({tooltips:!0,hidden:this.hide,left:"left"===this.split,middle:"middle"===this.split})}" part="private-tooltips"><glide-core-tooltip class="${classMap({"optional-tooltip":!0,vertical:"vertical"===this.orientation,visible:this.hasTooltipSlot})}" placement="${"vertical"===this.orientation?"right":"bottom"}"><span class="optional-tooltip-target" slot="target" tabindex="0">${icons.information}</span><slot name="tooltip" @slotchange="${this.#r}" ${ref(this.#s)}></slot></glide-core-tooltip><glide-core-tooltip class="label-tooltip" placement="right" ?disabled="${!this.isLabelTooltip}"><div class="${classMap({label:!0,disabled:this.disabled})}" data-test="label" slot="target" ${ref(this.#l)}><slot @slotchange="${this.#a}" ${ref(this.#t)}></slot>${this.required?html`<span aria-hidden="true" class="required-symbol">*</span>`:""}</div><div aria-hidden="true">${this.label}</div></glide-core-tooltip></div><div class="control-and-summary" part="private-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.#e)}></slot><slot class="${classMap({summary:!0,error:this.error})}" name="summary" @slotchange="${this.#d}" ${ref(this.#i)}></slot></div><slot class="${classMap({description:!0,content:this.hasDescription,error:this.error,tooltip:this.hasTooltipSlot})}" id="description" name="description" ${ref(this.#o)}></slot></div>`}#e;#t;#o;#l;#i;#s;#n(){owSlot(this.#e.value)}#a(){owSlot(this.#t.value);const e=this.#t.value?.assignedElements().at(0),t=this.#l.value;ow(e,ow.object.instanceOf(Element)),ow(t,ow.object.instanceOf(HTMLElement)),e.textContent&&(this.label=e.textContent);new ResizeObserver((()=>{this.isLabelTooltip=e.getBoundingClientRect().width>t.getBoundingClientRect().width})).observe(t)}#d(){const e=this.#i.value?.assignedNodes({flatten:!0});this.hasSummarySlot=Boolean(e&&e.length>0)}#r(){const e=this.#s.value?.assignedNodes({flatten:!0});this.hasTooltipSlot=Boolean(e&&e.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([property()],GlideCoreLabel.prototype,"split",void 0),__decorate([state()],GlideCoreLabel.prototype,"hasDescription",void 0),__decorate([state()],GlideCoreLabel.prototype,"hasSummarySlot",void 0),__decorate([state()],GlideCoreLabel.prototype,"hasTooltipSlot",void 0),__decorate([state()],GlideCoreLabel.prototype,"isLabelTooltip",void 0),__decorate([state()],GlideCoreLabel.prototype,"label",void 0),GlideCoreLabel=__decorate([customElement("glide-core-private-label")],GlideCoreLabel);export default GlideCoreLabel;const icons={information:html`<svg style="${styleMap({height:"1rem",width:"1rem"})}" 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>`};
|
package/dist/label.styles.js
CHANGED
@@ -71,7 +71,7 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";import
|
|
71
71
|
.optional-tooltip-target {
|
72
72
|
background-color: transparent;
|
73
73
|
border: none;
|
74
|
-
border-radius:
|
74
|
+
border-radius: 50%;
|
75
75
|
color: var(--glide-core-text-body-1);
|
76
76
|
|
77
77
|
/*
|
@@ -82,6 +82,10 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";import
|
|
82
82
|
|
83
83
|
display: flex;
|
84
84
|
padding: 0;
|
85
|
+
|
86
|
+
&:focus-visible {
|
87
|
+
outline-offset: 0;
|
88
|
+
}
|
85
89
|
}
|
86
90
|
|
87
91
|
.label {
|
@@ -8,13 +8,12 @@ export interface Translation extends DefaultTranslation {
|
|
8
8
|
$dir: 'ltr' | 'rtl';
|
9
9
|
close: string;
|
10
10
|
dismiss: string;
|
11
|
-
open: string;
|
12
11
|
selectAll: string;
|
13
|
-
moreInformation: string;
|
14
12
|
notifications: string;
|
15
13
|
nextTab: string;
|
16
14
|
previousTab: string;
|
17
15
|
noResults: string;
|
16
|
+
tooltip: string;
|
18
17
|
announcedCharacterCount: (current: number, maximum: number) => string;
|
19
18
|
displayedCharacterCount: (current: number, maximum: number) => string;
|
20
19
|
clearEntry: (label: string) => string;
|
@@ -24,9 +24,7 @@ GlideCoreMockComponent = __decorate([
|
|
24
24
|
customElement('mock-component')
|
25
25
|
], GlideCoreMockComponent);
|
26
26
|
it('can call any term from en translation if locale is Japanese', async () => {
|
27
|
-
const component = await fixture(
|
28
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
29
|
-
html `<mock-component></mock-component>`);
|
27
|
+
const component = await fixture(html `<mock-component></mock-component>`);
|
30
28
|
component.lang = 'ja';
|
31
29
|
expect(component.localize.lang()).to.equal('ja');
|
32
30
|
const keys = Object.keys(en);
|
@@ -0,0 +1,2 @@
|
|
1
|
+
export declare function click(element: Element | null | undefined, position?: 'top' | 'right' | 'bottom' | 'left' | 'outside' | 'center'): Promise<void>;
|
2
|
+
export declare function hover(element: Element | null | undefined, position?: 'top' | 'right' | 'bottom' | 'left' | 'outside' | 'center'): Promise<void>;
|
@@ -0,0 +1 @@
|
|
1
|
+
import{assert}from"@open-wc/testing";import{resetMouse,sendMouse}from"@web/test-runner-commands";export function click(t,e="center"){return mouse(t,e,"click")}export function hover(t,e="center"){return mouse(t,e,"move")}async function mouse(t,e="center",o){assert(t);const{height:i,width:r,x:c,y:n}=t.getBoundingClientRect();await sendMouse({type:o,position:"top"===e?[Math.ceil(c+r/2),Math.ceil(n)]:"right"===e?[Math.floor(c+r),Math.ceil(n+i/2)]:"bottom"===e?[Math.ceil(c+r/2),Math.floor(n+i)]:"left"===e?[Math.ceil(c),Math.ceil(n+i/2)]:"outside"===e?[Math.floor(c-1),Math.floor(n-1)]:[Math.ceil(c+r/2),Math.ceil(n+i/2)]}),afterEach((async()=>{await resetMouse()}))}
|
package/dist/library/ow.test.js
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
package/dist/menu.d.ts
CHANGED
@@ -6,8 +6,10 @@ declare global {
|
|
6
6
|
}
|
7
7
|
}
|
8
8
|
/**
|
9
|
+
* @event toggle
|
10
|
+
*
|
9
11
|
* @slot - One of `<glide-core-menu-options>`.
|
10
|
-
* @slot target -
|
12
|
+
* @slot target - The element to which the menu will anchor, which can be any focusable element.
|
11
13
|
*/
|
12
14
|
export default class GlideCoreMenu extends LitElement {
|
13
15
|
#private;
|
package/dist/menu.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
var __decorate=this&&this.__decorate||function(e,t,i,o){var n,s=arguments.length,l=s<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,t,i,o);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(l=(s<3?n(l):s>3?n(t,i,l):n(t,i))||l);return s>3&&l&&Object.defineProperty(t,i,l),l};import{LitElement,html}from"lit";import{autoUpdate,computePosition,flip,offset}from"@floating-ui/dom";import{createRef,ref}from"lit/directives/ref.js";import{customElement,property}from"lit/decorators.js";import{nanoid}from"nanoid";import GlideCoreMenuButton from"./menu.button.js";import GlideCoreMenuLink from"./menu.link.js";import GlideCoreMenuOptions from"./menu.options.js";import ow,{owSlot,owSlotType}from"./library/ow.js";import styles from"./menu.styles.js";let GlideCoreMenu=class GlideCoreMenu extends LitElement{constructor(){super(...arguments),this.placement="bottom-start",this.#e=createRef(),this.#t=createRef(),this.#i=!1,this.#o=!1,this.#n=!1,this.#s=!1,this.#l=!1,this.#a="large",this.#r=createRef(),this.#c=()=>{this.#o?this.#o=!1:this.#n?this.#n=!1:this.#l?this.#l=!1:(this.open=!1,this.#d&&(this.#d.ariaActivedescendant=""))}}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:"closed"}}static{this.styles=styles}get offset(){return this.#h??Number.parseFloat(window.getComputedStyle(document.body).getPropertyValue("--glide-core-spacing-xxs"))*Number.parseFloat(window.getComputedStyle(document.documentElement).fontSize)}set offset(e){this.#h=e}get open(){return this.#s}set open(e){this.#s=e,e&&!this.isTargetDisabled?this.#p():this.#
|
1
|
+
var __decorate=this&&this.__decorate||function(e,t,i,o){var n,s=arguments.length,l=s<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,t,i,o);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(l=(s<3?n(l):s>3?n(t,i,l):n(t,i))||l);return s>3&&l&&Object.defineProperty(t,i,l),l};import{LitElement,html}from"lit";import{autoUpdate,computePosition,flip,offset}from"@floating-ui/dom";import{createRef,ref}from"lit/directives/ref.js";import{customElement,property}from"lit/decorators.js";import{nanoid}from"nanoid";import GlideCoreMenuButton from"./menu.button.js";import GlideCoreMenuLink from"./menu.link.js";import GlideCoreMenuOptions from"./menu.options.js";import ow,{owSlot,owSlotType}from"./library/ow.js";import styles from"./menu.styles.js";let GlideCoreMenu=class GlideCoreMenu extends LitElement{constructor(){super(...arguments),this.placement="bottom-start",this.#e=createRef(),this.#t=createRef(),this.#i=!1,this.#o=!1,this.#n=!1,this.#s=!1,this.#l=!1,this.#a="large",this.#r=createRef(),this.#c=()=>{this.#o?this.#o=!1:this.#n?this.#n=!1:this.#l?this.#l=!1:(this.open=!1,this.#d&&(this.#d.ariaActivedescendant=""))}}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:"closed"}}static{this.styles=styles}get offset(){return this.#h??Number.parseFloat(window.getComputedStyle(document.body).getPropertyValue("--glide-core-spacing-xxs"))*Number.parseFloat(window.getComputedStyle(document.documentElement).fontSize)}set offset(e){this.#h=e}get open(){return this.#s}set open(e){const t=e!==this.#s;this.#s=e,e&&t&&!this.isTargetDisabled?(this.#p(),this.dispatchEvent(new Event("toggle",{bubbles:!0,composed:!0}))):t&&(this.#u(),this.dispatchEvent(new Event("toggle",{bubbles:!0,composed:!0})))}get size(){return this.#a}set size(e){this.#a=e,this.#d&&(this.#d.privateSize=e)}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this.#c,{capture:!0})}createRenderRoot(){return this.#f=super.createRenderRoot(),this.#f}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this.#c,{capture:!0})}firstUpdated(){ow(this.#d,ow.object.instanceOf(GlideCoreMenuOptions)),owSlot(this.#t.value),owSlot(this.#r.value),owSlotType(this.#t.value,[GlideCoreMenuOptions]),this.#t.value.popover="manual",this.open&&!this.isTargetDisabled&&this.#p(),this.#r.value.addEventListener("mouseup",(()=>{this.#l=!0})),this.#t.value.addEventListener("mousedown",(e=>{e.target===this.#t.value&&e.preventDefault()})),this.#t.value.addEventListener("mouseup",(e=>{if(e.target!==this.#t.value){if(e.target instanceof Element){const t=e.target?.closest("glide-core-menu-link");t?.disabled&&(this.#n=!0)}}else this.#o=!0}))}get isTargetDisabled(){const e=this.#m&&"disabled"in this.#m&&this.#m.disabled,t=this.#m&&"true"===this.#m.ariaDisabled;return Boolean(e)||Boolean(t)}render(){return html`<div class="component" @focusout="${this.#E}" ${ref(this.#e)}><slot class="target-slot" name="target" @click="${this.#v}" @keydown="${this.#g}" @slotchange="${this.#S}" ${ref(this.#r)}></slot><slot class="default-slot" @click="${this.#C}" @focusin="${this.#b}" @keydown="${this.#g}" @mouseover="${this.#w}" @private-disabled="${this.#k}" @private-slot-change="${this.#y}" @slotchange="${this.#O}" ${ref(this.#t)}></slot></div>`}#R;#e;#t;#i;#o;#n;#s;#l;#h;#f;#a;#r;get#D(){return this.#M?.find((({privateActive:e})=>e))}#c;#A(e){this.#m&&"focus"in this.#m&&this.#m?.focus(e)}#u(){this.#R?.(),this.#d&&(this.#d.ariaActivedescendant=""),this.#m&&(this.#m.ariaExpanded="false"),this.#t.value?.hidePopover()}get#d(){const e=this.#t.value?.assignedElements().at(0);return e instanceof GlideCoreMenuOptions?e:null}#E(e){const t=e.relatedTarget instanceof HTMLElement&&this.#f?.contains(e.relatedTarget),i=e.relatedTarget instanceof GlideCoreMenuOptions,o=e.relatedTarget instanceof GlideCoreMenuButton||e.relatedTarget instanceof GlideCoreMenuLink;t||i||o||(this.open=!1)}#O(){ow(this.#d,ow.object.instanceOf(GlideCoreMenuOptions)),owSlot(this.#t.value),owSlotType(this.#t.value,[GlideCoreMenuOptions]),this.#d.privateSize=this.size}#C(e){e.target!==this.#t.value&&(this.open=!1)}#b(e){(e.target instanceof GlideCoreMenuButton||e.target instanceof GlideCoreMenuLink)&&this.#D&&this.#d&&!e.target.disabled&&(this.#D.privateActive=!1,e.target.privateActive=!0,this.#d.ariaActivedescendant=e.target.id)}#w(e){if((e.target instanceof GlideCoreMenuLink||e.target instanceof GlideCoreMenuButton)&&!e.target.disabled){if(this.#M)for(const t of this.#M)t.privateActive=t===e.target;this.#d&&(this.#d.ariaActivedescendant=e.target.id)}}#k(){if(this.#M&&this.#D){const e=this.#M.indexOf(this.#D);this.#D.privateActive=!1;const t=this.#M?.find(((t,i)=>!t.disabled&&i>e));if(t)return void(t.privateActive=!0);const i=this.#M.findLast(((t,i)=>!t.disabled&&i<e));i&&(i.privateActive=!0)}}#y(){const e=this.#M?.find((e=>!e.disabled));!this.#D&&e&&(e.privateActive=!0)}#g(e){ow(this.#d,ow.object.instanceOf(GlideCoreMenuOptions));const t=this.#m instanceof HTMLSpanElement||this.#m instanceof HTMLDivElement;if([" ","Enter"].includes(e.key)&&this.open)return" "===e.key&&t&&e.preventDefault(),this.open=!1,this.#A(),this.#D?.click(),void(this.#i=!0);if([" ","Enter"].includes(e.key)&&t)return e.preventDefault(),void(this.open=!0);if(["Escape"].includes(e.key)&&this.open)return e.preventDefault(),this.open=!1,void this.#A();if(["ArrowUp","ArrowDown"].includes(e.key)&&!this.open&&this.#D)return e.preventDefault(),this.open=!0,void(this.#d.ariaActivedescendant=this.#D.id);if(this.open){ow(this.#M,ow.array),ow(this.#d,ow.object.instanceOf(GlideCoreMenuOptions)),ow(this.#D,ow.object.is((e=>e instanceof GlideCoreMenuButton||e instanceof GlideCoreMenuLink)));const t=this.#M.indexOf(this.#D);if("ArrowUp"===e.key&&!e.metaKey){e.preventDefault();const i=this.#M.findLast(((e,i)=>!e.disabled&&i<t));return void(i&&(this.#D.privateActive=!1,this.#d.ariaActivedescendant=i.id,i.privateActive=!0))}if("ArrowDown"===e.key&&!e.metaKey){e.preventDefault();const i=this.#M.find(((e,i)=>!e.disabled&&i>t));return void(i&&(this.#D.privateActive=!1,this.#d.ariaActivedescendant=i.id,i.privateActive=!0))}if("ArrowUp"===e.key&&e.metaKey||"Home"===e.key||"PageUp"===e.key){e.preventDefault();const t=[...this.#M].reverse().findLast((e=>!e.disabled));return void(t&&(this.#D.privateActive=!1,this.#d.ariaActivedescendant=t.id,t.privateActive=!0))}if("ArrowDown"===e.key&&e.metaKey||"End"===e.key||"PageDown"===e.key){e.preventDefault();const t=[...this.#M].findLast((e=>!e.disabled));return void(t&&(this.#D.privateActive=!1,this.#d.ariaActivedescendant=t.id,t.privateActive=!0))}}}#S(){owSlot(this.#r.value),ow(this.#m,ow.object.instanceOf(Element)),ow(this.#d,ow.object.instanceOf(GlideCoreMenuOptions));new MutationObserver((()=>{this.open&&!this.isTargetDisabled?this.#p():this.#u()})).observe(this.#m,{attributes:!0,attributeFilter:["aria-disabled","disabled"]}),this.#m.ariaHasPopup="true",this.#m.id=nanoid(),this.#m.setAttribute("aria-controls",this.#d.id),this.#d.ariaLabelledby=this.#m.id;(this.#m instanceof HTMLSpanElement||this.#m instanceof HTMLDivElement)&&this.#m instanceof HTMLElement&&(this.#m.tabIndex=0),this.open&&!this.isTargetDisabled?this.#p():this.#u()}#v(){this.isTargetDisabled?this.#u():this.#i?this.#i=!1:this.#M&&this.#M.length>0&&(this.open=!this.open)}get#M(){let e=this.#t.value?.assignedElements()?.at(0)?.children;const t=e?.[0];if(t instanceof HTMLSlotElement&&(e=t.assignedElements()),e)return[...e].filter((e=>e instanceof GlideCoreMenuLink||e instanceof GlideCoreMenuButton))}#p(){this.#R?.(),this.#m&&this.#t.value&&(this.#R=autoUpdate(this.#m,this.#t.value,(()=>{(async()=>{if(this.#m&&this.#t.value){const{x:e,y:t,placement:i}=await computePosition(this.#m,this.#t.value,{placement:this.placement,middleware:[offset(this.offset),flip()]});this.#t.value.dataset.placement=i,Object.assign(this.#t.value.style,{left:`${e}px`,top:`${t}px`})}this.#t.value?.showPopover(),this.#d&&this.#D?.id&&(this.#d.ariaActivedescendant=this.#D.id),this.#m&&(this.#m.ariaExpanded="true")})()})))}get#m(){return this.#r.value?.assignedElements().at(0)}};__decorate([property({reflect:!0,type:Number})],GlideCoreMenu.prototype,"offset",null),__decorate([property({reflect:!0,type:Boolean})],GlideCoreMenu.prototype,"open",null),__decorate([property({reflect:!0})],GlideCoreMenu.prototype,"placement",void 0),__decorate([property({reflect:!0})],GlideCoreMenu.prototype,"size",null),GlideCoreMenu=__decorate([customElement("glide-core-menu")],GlideCoreMenu);export default GlideCoreMenu;
|
package/dist/menu.options.d.ts
CHANGED
@@ -5,7 +5,7 @@ declare global {
|
|
5
5
|
}
|
6
6
|
}
|
7
7
|
/**
|
8
|
-
* @slot - One or more of
|
8
|
+
* @slot - One or more of `<glide-core-menu-button>` or `<glide-core-menu-link>`.
|
9
9
|
*/
|
10
10
|
export default class GlideCoreMenuOptions extends LitElement {
|
11
11
|
#private;
|
package/dist/modal.d.ts
CHANGED
@@ -6,9 +6,9 @@ declare global {
|
|
6
6
|
}
|
7
7
|
}
|
8
8
|
/**
|
9
|
-
* @event
|
9
|
+
* @event toggle
|
10
10
|
*
|
11
|
-
* @slot - The content of the modal.
|
11
|
+
* @slot - The primary content of the modal.
|
12
12
|
* @slot header-actions - One or more of `<glide-core-modal-icon-button>`.
|
13
13
|
* @slot primary - One of `<glide-core-button>`.
|
14
14
|
* @slot secondary - One of `<glide-core-button>`.
|
@@ -18,16 +18,13 @@ export default class GlideCoreModal extends LitElement {
|
|
18
18
|
#private;
|
19
19
|
static shadowRootOptions: ShadowRootInit;
|
20
20
|
static styles: import("lit").CSSResult[];
|
21
|
-
label: string;
|
22
21
|
backButton: boolean;
|
22
|
+
label?: string;
|
23
|
+
get open(): boolean;
|
24
|
+
set open(isOpen: boolean);
|
23
25
|
size?: 'small' | 'medium' | 'large' | 'xlarge';
|
24
|
-
close(): void;
|
25
26
|
connectedCallback(): void;
|
26
27
|
disconnectedCallback(): void;
|
27
28
|
firstUpdated(): void;
|
28
29
|
render(): import("lit").TemplateResult<1>;
|
29
|
-
/**
|
30
|
-
* Method called by consumers to open the Modal.
|
31
|
-
*/
|
32
|
-
showModal(): void;
|
33
30
|
}
|
@@ -6,13 +6,8 @@ declare global {
|
|
6
6
|
}
|
7
7
|
}
|
8
8
|
/**
|
9
|
-
* @slot - The content of the button. Should only be an icon. The icon should also
|
10
|
-
* "label" attribute for accessibility
|
11
|
-
*
|
12
|
-
* @example
|
13
|
-
* <glide-core-modal-icon-button slot="header-actions">
|
14
|
-
* <!-- icon here -->
|
15
|
-
* </glide-core-modal-icon-button>
|
9
|
+
* @slot - The content of the button. Should only be an icon. The icon should also use the
|
10
|
+
* "label" attribute for accessibility.
|
16
11
|
*/
|
17
12
|
export default class GlideCoreModalIconButton extends LitElement {
|
18
13
|
#private;
|
package/dist/modal.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
var __decorate=this&&this.__decorate||function(e,t,o,l){var n,
|
1
|
+
var __decorate=this&&this.__decorate||function(e,t,o,l){var n,i=arguments.length,r=i<3?t:null===l?l=Object.getOwnPropertyDescriptor(t,o):l;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,o,l);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(r=(i<3?n(r):i>3?n(t,o,r):n(t,o))||r);return i>3&&r&&Object.defineProperty(t,o,r),r};import"./modal.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}from"lit/decorators.js";import{styleMap}from"lit/directives/style-map.js";import{when}from"lit/directives/when.js";import GlideCoreButton from"./button.js";import GlideCoreModalIconButton from"./modal.icon-button.js";import GlideCoreModalTertiaryIcon from"./modal.tertiary-icon.js";import ow,{owSlot,owSlotType}from"./library/ow.js";import styles from"./modal.styles.js";import xIcon from"./icons/x.js";const globalStylesheet=new CSSStyleSheet;globalStylesheet.insertRule("\n .private-glide-core-modal-lock-scroll {\n scrollbar-gutter: stable !important;\n overflow: hidden !important;\n }\n");let GlideCoreModal=class GlideCoreModal extends LitElement{constructor(){super(...arguments),this.backButton=!1,this.size="medium",this.#e=createRef(),this.#t=createRef(),this.#o=createRef(),this.#l=createRef(),this.#n=createRef(),this.#i=createRef(),this.#r=createRef(),this.#a=createRef(),this.#s=!1,this.#c=new LocalizeController(this)}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:"closed"}}static{this.styles=styles}get open(){return this.#s}set open(e){const t=e!==this.#s;this.#s=e,e&&t?(this.#d(),this.dispatchEvent(new Event("toggle",{bubbles:!0,composed:!0}))):t&&(this.#m(),this.dispatchEvent(new Event("toggle",{bubbles:!0,composed:!0})))}connectedCallback(){super.connectedCallback();document.adoptedStyleSheets.includes(globalStylesheet)||document.adoptedStyleSheets.push(globalStylesheet)}disconnectedCallback(){super.disconnectedCallback(),document.documentElement.classList.remove("private-glide-core-modal-lock-scroll"),document.adoptedStyleSheets=document.adoptedStyleSheets.filter((e=>e!==globalStylesheet))}firstUpdated(){owSlot(this.#l.value),owSlotType(this.#a.value,[GlideCoreModalIconButton]),owSlotType(this.#n.value,[GlideCoreButton]),owSlotType(this.#i.value,[GlideCoreButton]),owSlotType(this.#r.value,[GlideCoreModalTertiaryIcon,GlideCoreButton]),this.open&&this.#d()}render(){return html`<dialog class="${classMap({component:!0,small:"small"===this.size,medium:"medium"===this.size,large:"large"===this.size,xlarge:"xlarge"===this.size})}" data-test="component" @keydown="${this.#h}" @click="${this.#f}" ${ref(this.#o)}><header class="header"><h2 class="label" data-test="heading" id="heading">${when(this.backButton,(()=>html`<glide-core-modal-icon-button aria-label="${this.#c.term("dismiss")}" class="back-button" data-test="back-button" @click="${this.#u}" ${ref(this.#e)}>${icons.back}</glide-core-modal-icon-button>`))} ${this.label}</h2><div class="header-actions" role="toolbar"><slot name="header-actions" @slotchange="${this.#p}" ${ref(this.#a)}></slot><glide-core-modal-icon-button aria-label="${this.#c.term("close")}" class="close-button" data-test="close-button" @click="${this.#u}" ${ref(this.#t)}>${xIcon}</glide-core-modal-icon-button></div></header><article aria-labelledby="heading" class="body" role="region"><slot @slotchange="${this.#y}" ${ref(this.#l)}></slot></article><footer><menu class="actions"><li class="action"><slot class="tertiary-slot" name="tertiary" @slotchange="${this.#S}" ${ref(this.#r)}></slot></li><li class="action"><slot name="secondary" @slotchange="${this.#C}" ${ref(this.#i)}></slot></li><li class="action"><slot name="primary" @slotchange="${this.#b}" ${ref(this.#n)}></slot></li></menu></footer></dialog>`}#e;#t;#o;#l;#n;#i;#r;#a;#s;#c;#m(){document.documentElement.classList.remove("private-glide-core-modal-lock-scroll"),this.#o.value?.close()}#u(){this.open=!1}#f(e){if(this.#o.value){const{height:t,width:o,top:l,left:n}=this.#o.value.getBoundingClientRect();l<=e.clientY&&e.clientY<=l+t&&n<=e.clientX&&e.clientX<=n+o||(this.open=!1)}}#h(e){"Escape"===e.key&&(this.open=!1,e.preventDefault())}#y(){ow(this.#o.value,ow.object.instanceOf(HTMLDialogElement)),owSlot(this.#l.value)}#b(){owSlotType(this.#n.value,[GlideCoreButton])}#C(){owSlotType(this.#i.value,[GlideCoreButton])}#S(){ow(this.#o.value,ow.object.instanceOf(HTMLDialogElement)),owSlotType(this.#r.value,[GlideCoreModalTertiaryIcon,GlideCoreButton])}#p(){owSlotType(this.#a.value,[GlideCoreModalIconButton])}#d(){document.documentElement.classList.add("private-glide-core-modal-lock-scroll"),this.#o.value?.showModal()}};__decorate([property({attribute:"back-button",type:Boolean,reflect:!0})],GlideCoreModal.prototype,"backButton",void 0),__decorate([property({reflect:!0})],GlideCoreModal.prototype,"label",void 0),__decorate([property({reflect:!0,type:Boolean})],GlideCoreModal.prototype,"open",null),__decorate([property({reflect:!0})],GlideCoreModal.prototype,"size",void 0),GlideCoreModal=__decorate([customElement("glide-core-modal")],GlideCoreModal);export default GlideCoreModal;const icons={back:html`<svg style="${styleMap({height:"1.25rem",width:"1.25rem"})}" viewBox="0 0 24 24" fill="none"><path d="M12 18C11.4477 18 11 18.4477 11 19C11 19.5523 11.4477 20 12 20V18ZM20 14.5C20 16.433 18.433 18 16.5 18V20C19.5376 20 22 17.5376 22 14.5H20ZM16.5 11C18.433 11 20 12.567 20 14.5H22C22 11.4624 19.5376 9 16.5 9V11ZM16.5 18H12V20H16.5V18ZM16.5 9H3V11H16.5V9Z" fill="currentColor"/><path d="M7 6L3 10L7 14" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>`};
|
package/dist/modal.styles.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export default[css`
|
2
|
-
${focusOutline(".
|
2
|
+
${focusOutline(".component:focus-visible")}
|
3
3
|
`,css`
|
4
4
|
/* When browser support improves, we can have nicer animations with https://caniuse.com/mdn-css_at-rules_starting-style */
|
5
5
|
@keyframes backdrop-fade-in {
|
@@ -31,12 +31,27 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export
|
|
31
31
|
border-radius: 0.5rem;
|
32
32
|
box-shadow: var(--glide-core-shadow-lg);
|
33
33
|
font-family: var(--glide-core-body-xs-font-family);
|
34
|
-
inline-size: 35rem;
|
35
34
|
max-block-size: 75vh;
|
36
35
|
max-inline-size: 80vw;
|
37
36
|
opacity: 0;
|
38
37
|
padding: 1.25rem;
|
39
38
|
|
39
|
+
&.small {
|
40
|
+
inline-size: 22.5rem;
|
41
|
+
}
|
42
|
+
|
43
|
+
&.medium {
|
44
|
+
inline-size: 35rem;
|
45
|
+
}
|
46
|
+
|
47
|
+
&.large {
|
48
|
+
inline-size: 53.75rem;
|
49
|
+
}
|
50
|
+
|
51
|
+
&.xlarge {
|
52
|
+
inline-size: 69.375rem;
|
53
|
+
}
|
54
|
+
|
40
55
|
&[open] {
|
41
56
|
opacity: 1;
|
42
57
|
|
@@ -50,9 +65,6 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export
|
|
50
65
|
}
|
51
66
|
|
52
67
|
&::backdrop {
|
53
|
-
/* prefix required for Safari */
|
54
|
-
/* stylelint-disable-next-line property-no-vendor-prefix */
|
55
|
-
-webkit-backdrop-filter: blur(3px);
|
56
68
|
backdrop-filter: blur(3px);
|
57
69
|
background-color: rgba(0 0 0 / 40%);
|
58
70
|
|
@@ -69,22 +81,6 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export
|
|
69
81
|
}
|
70
82
|
}
|
71
83
|
|
72
|
-
.small {
|
73
|
-
inline-size: 22.5rem;
|
74
|
-
}
|
75
|
-
|
76
|
-
.medium {
|
77
|
-
inline-size: 35rem;
|
78
|
-
}
|
79
|
-
|
80
|
-
.large {
|
81
|
-
inline-size: 53.75rem;
|
82
|
-
}
|
83
|
-
|
84
|
-
.xlarge {
|
85
|
-
inline-size: 69.375rem;
|
86
|
-
}
|
87
|
-
|
88
84
|
.header {
|
89
85
|
align-items: center;
|
90
86
|
display: flex;
|
@@ -100,7 +96,8 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export
|
|
100
96
|
gap: var(--glide-core-spacing-xs);
|
101
97
|
inline-size: 100%;
|
102
98
|
line-height: 1.875rem;
|
103
|
-
margin: 0;
|
99
|
+
margin-block-end: 0;
|
100
|
+
margin-block-start: 0;
|
104
101
|
overflow: hidden;
|
105
102
|
text-overflow: ellipsis;
|
106
103
|
white-space: nowrap;
|
@@ -110,11 +107,32 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export
|
|
110
107
|
align-items: center;
|
111
108
|
display: flex;
|
112
109
|
gap: 0.625rem;
|
113
|
-
|
110
|
+
|
111
|
+
::slotted(*) {
|
112
|
+
/*
|
113
|
+
Flex so the actions don't sit on the baseline of ".header" and can be
|
114
|
+
vertically centered.
|
115
|
+
*/
|
116
|
+
display: flex;
|
117
|
+
}
|
118
|
+
}
|
119
|
+
|
120
|
+
.back-button {
|
121
|
+
/*
|
122
|
+
Flex so the icon doesn't sit on the baseline and extend the height of
|
123
|
+
".back-button", making the icon not vertically centered relative to ".label".
|
124
|
+
*/
|
125
|
+
display: flex;
|
114
126
|
}
|
115
127
|
|
116
|
-
.
|
117
|
-
|
128
|
+
.close-button {
|
129
|
+
--size: 1.25rem;
|
130
|
+
|
131
|
+
/*
|
132
|
+
Flex so the icon doesn't sit on the baseline and extend the height of
|
133
|
+
".close-button", making the icon not vertically centered relative to ".label".
|
134
|
+
*/
|
135
|
+
display: flex;
|
118
136
|
}
|
119
137
|
|
120
138
|
.body {
|
@@ -128,36 +146,23 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export
|
|
128
146
|
}
|
129
147
|
}
|
130
148
|
|
131
|
-
.footer {
|
132
|
-
align-items: center;
|
133
|
-
display: flex;
|
134
|
-
}
|
135
|
-
|
136
149
|
.actions {
|
150
|
+
align-items: center;
|
137
151
|
display: flex;
|
138
152
|
gap: var(--glide-core-spacing-xs);
|
139
|
-
|
140
|
-
/* Reset the default menu styles */
|
141
153
|
list-style-type: none;
|
142
154
|
margin: 0;
|
143
|
-
margin-inline-start: auto;
|
144
155
|
padding: 0;
|
145
156
|
}
|
146
157
|
|
147
|
-
.
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
list-style-type: none;
|
152
|
-
margin: 0;
|
153
|
-
padding: 0;
|
154
|
-
}
|
155
|
-
|
156
|
-
.flex {
|
157
|
-
display: flex;
|
158
|
+
.action {
|
159
|
+
&:first-of-type {
|
160
|
+
margin-inline-end: auto;
|
161
|
+
}
|
158
162
|
}
|
159
163
|
|
160
|
-
.
|
164
|
+
.tertiary-slot {
|
161
165
|
align-items: center;
|
166
|
+
display: flex;
|
162
167
|
}
|
163
168
|
`];
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { LitElement } from 'lit';
|
2
|
+
declare global {
|
3
|
+
interface HTMLElementTagNameMap {
|
4
|
+
'glide-core-popover': GlideCorePopover;
|
5
|
+
}
|
6
|
+
}
|
7
|
+
/**
|
8
|
+
* @event toggle
|
9
|
+
*
|
10
|
+
* @slot - The content of the popover.
|
11
|
+
* @slot target - The element to which the popover will anchor, which can be any focusable element.
|
12
|
+
*/
|
13
|
+
export default class GlideCorePopover extends LitElement {
|
14
|
+
#private;
|
15
|
+
static shadowRootOptions: ShadowRootInit;
|
16
|
+
static styles: import("lit").CSSResult[];
|
17
|
+
get disabled(): boolean;
|
18
|
+
set disabled(isDisabled: boolean);
|
19
|
+
get offset(): number;
|
20
|
+
set offset(offset: number);
|
21
|
+
get open(): boolean;
|
22
|
+
set open(isOpen: boolean);
|
23
|
+
placement?: 'bottom' | 'left' | 'right' | 'top';
|
24
|
+
connectedCallback(): void;
|
25
|
+
firstUpdated(): void;
|
26
|
+
render(): import("lit").TemplateResult<1>;
|
27
|
+
private effectivePlacement;
|
28
|
+
}
|
package/dist/popover.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
var __decorate=this&&this.__decorate||function(e,t,o,l){var i,r=arguments.length,a=r<3?t:null===l?l=Object.getOwnPropertyDescriptor(t,o):l;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,o,l);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(r<3?i(a):r>3?i(t,o,a):i(t,o))||a);return r>3&&a&&Object.defineProperty(t,o,a),a};import{LitElement,html}from"lit";import{arrow,autoUpdate,computePosition,flip,limitShift,offset,shift}from"@floating-ui/dom";import{choose}from"lit/directives/choose.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 ow,{owSlot}from"./library/ow.js";import styles from"./popover.styles.js";let GlideCorePopover=class GlideCorePopover extends LitElement{constructor(){super(...arguments),this.effectivePlacement=this.placement??"bottom",this.#e=createRef(),this.#t=createRef(),this.#o=!1,this.#l=!1,this.#i=!1,this.#r=!1,this.#a=!1,this.#s=createRef(),this.#n=createRef(),this.#f=()=>{if(this.#l||this.#a||this.#o)return this.#l=!1,this.#a=!1,void(this.#o=!1);this.open=!1}}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:"closed"}}static{this.styles=styles}get disabled(){return this.#i}set disabled(e){this.#i=e,this.open&&!e?this.#d():this.#p()}get offset(){return this.#h??Number.parseFloat(window.getComputedStyle(document.body).getPropertyValue("--glide-core-spacing-xxs"))*Number.parseFloat(window.getComputedStyle(document.documentElement).fontSize)}set offset(e){this.#h=e}get open(){return this.#r}set open(e){const t=e!==this.#r;this.#r=e,e&&t&&!this.disabled?(this.#d(),this.dispatchEvent(new Event("toggle",{bubbles:!0,composed:!0}))):t&&(this.#p(),this.dispatchEvent(new Event("toggle",{bubbles:!0,composed:!0})))}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this.#f,{capture:!0})}firstUpdated(){owSlot(this.#t.value),owSlot(this.#n.value),ow(this.#s.value,ow.object.instanceOf(HTMLElement)),this.#s.value.popover="manual",this.open&&!this.disabled&&this.#d(),this.#t.value.addEventListener("mouseup",(()=>{this.#l=!0})),this.#n.value.addEventListener("mouseup",(()=>{this.#a=!0})),this.#e.value?.addEventListener("mouseup",(()=>{this.#o=!0})),this.#n.value.addEventListener("keydown",(e=>{"Enter"!==e.key&&" "!==e.key||(this.#a=!0)}))}render(){return html`<div class="component"><slot class="target-slot" data-test="target-slot" name="target" @click="${this.#m}" @keydown="${this.#c}" @slotchange="${this.#u}" ${ref(this.#n)}></slot><div class="${classMap({popover:!0,[this.effectivePlacement]:!0})}" id="popover" data-test="popover" ${ref(this.#s)}><div class="${classMap({arrow:!0,[this.effectivePlacement]:!0})}" data-test="arrow" ${ref(this.#e)}>${choose(this.effectivePlacement,[["top",()=>icons.topArrow],["right",()=>icons.rightArrow],["bottom",()=>icons.bottomArrow],["left",()=>icons.leftArrow]])}</div><slot class="default-slot" @slotchange="${this.#v}" ${ref(this.#t)}></slot></div></div>`}#e;#g;#t;#o;#l;#i;#r;#a;#h;#s;#n;#f;#p(){this.#s.value?.hidePopover(),this.#_&&(this.#_.ariaExpanded="false"),this.#g?.()}#v(){owSlot(this.#t.value)}#u(){owSlot(this.#n.value)}#m(){this.open=!this.open}#c(e){"Escape"===e.key&&(this.open=!1)}get#_(){return this.#n.value?.assignedElements().at(0)}#d(){this.disabled||(this.#g?.(),this.#n.value&&this.#s.value&&(this.#g=autoUpdate(this.#n.value,this.#s.value,(()=>{(async()=>{if(this.#n.value&&this.#s.value&&this.#e.value){const e=Number.parseFloat(window.getComputedStyle(this.#s.value).padding),{x:t,y:o,placement:l,middlewareData:i}=await computePosition(this.#n.value,this.#s.value,{placement:this.placement,middleware:[offset(this.offset-e-2),flip({fallbackStrategy:"initialPlacement"}),shift({limiter:limitShift({offset:30})}),arrow({element:this.#e.value})]});Object.assign(this.#s.value.style,{left:`${t}px`,top:`${o}px`}),Object.assign(this.#e.value.style,{left:i.arrow?.x?i.arrow.x-e+"px":null,top:i.arrow?.y?i.arrow.y-e+"px":null}),this.effectivePlacement=l,this.#s.value.showPopover(),this.#_&&(this.#_.ariaExpanded="true")}})()}))))}};__decorate([property({reflect:!0,type:Boolean})],GlideCorePopover.prototype,"disabled",null),__decorate([property({reflect:!0,type:Number})],GlideCorePopover.prototype,"offset",null),__decorate([property({reflect:!0,type:Boolean})],GlideCorePopover.prototype,"open",null),__decorate([property()],GlideCorePopover.prototype,"placement",void 0),__decorate([state()],GlideCorePopover.prototype,"effectivePlacement",void 0),GlideCorePopover=__decorate([customElement("glide-core-popover")],GlideCorePopover);export default GlideCorePopover;const icons={topArrow:html`<svg aria-hidden="true" viewBox="0 0 16 9" fill="none"><mask id="mask0_13064_691" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0"><path d="M16 6.99382e-07V9L0 9L3.93402e-07 0L16 6.99382e-07Z" fill="#D9D9D9"/></mask><g mask="url(#mask0_13064_691)"><g filter="url(#filter0_d_13064_691)"><path d="M8.76822 5.603C8.36842 6.13234 7.63157 6.13233 7.23178 5.60299L3 0L13 9.19407e-07L8.76822 5.603Z" fill="currentColor"/></g></g><defs><filter id="filter0_d_13064_691" x="2" y="0" width="0.75rem" height="0.625rem" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/><feOffset dy="3"/><feGaussianBlur stdDeviation="0.5"/><feComposite in2="hardAlpha" operator="out"/><feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.06 0"/><feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_13064_691"/><feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_13064_691" result="shape"/></filter></defs></svg>`,rightArrow:html`<svg aria-hidden="true" viewBox="0 0 9 16" fill="none"><mask id="mask0_13064_688" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0"><path d="M9 16H1.39876e-06L0 7.86805e-07L9 0L9 16Z" fill="#D9D9D9"/></mask><g mask="url(#mask0_13064_688)"><g filter="url(#filter0_d_13064_688)"><path d="M3.397 8.76822C2.86766 8.36843 2.86767 7.63157 3.39701 7.23178L9 3V13L3.397 8.76822Z" fill="currentColor"/></g></g><defs><filter id="filter0_d_13064_688" x="2" y="3" width="0.5rem" height="0.875rem" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/><feOffset dy="3"/><feGaussianBlur stdDeviation="0.5"/><feComposite in2="hardAlpha" operator="out"/><feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.06 0"/><feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_13064_688"/><feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_13064_688" result="shape"/></filter></defs></svg>`,bottomArrow:html`<svg aria-hidden="true" viewBox="0 0 16 9" fill="none"><mask id="mask0_13064_685" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0"><path d="M0 9L1.07324e-07 0L16 1.90798e-07V9H0Z" fill="#D9D9D9"/></mask><g mask="url(#mask0_13064_685)"><g filter="url(#filter0_dd_13064_685)"><path d="M7.23178 3.397C7.63157 2.86766 8.36843 2.86767 8.76822 3.39701L13 9L3 9L7.23178 3.397Z" fill="currentColor"/></g></g><defs><filter id="filter0_dd_13064_685" x="-5" y="-2" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/><feOffset dy="3"/><feGaussianBlur stdDeviation="4"/><feComposite in2="hardAlpha" operator="out"/><feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.15 0"/><feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_13064_685"/><feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/><feOffset dy="-1"/><feGaussianBlur stdDeviation="1"/><feComposite in2="hardAlpha" operator="out"/><feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.06 0"/><feBlend mode="normal" in2="effect1_dropShadow_13064_685" result="effect2_dropShadow_13064_685"/><feBlend mode="normal" in="SourceGraphic" in2="effect2_dropShadow_13064_685" result="shape"/></filter></defs></svg>`,leftArrow:html`<svg aria-hidden="true" viewBox="0 0 9 16" fill="none"><mask id="mask0_12969_88361" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0"><path d="M0 0H9V16H0V0Z" fill="#D9D9D9"/></mask><g mask="url(#mask0_12969_88361)"><g filter="url(#filter0_d_12969_88361)"><path d="M5.603 7.23178C6.13234 7.63157 6.13233 8.36843 5.60299 8.76822L0 13L4.82293e-07 3L5.603 7.23178Z" fill="currentColor"/></g></g><defs><filter id="filter0_d_12969_88361" x="-1" y="3" width="0.5rem" height="0.875rem" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/><feOffset dy="3"/><feGaussianBlur stdDeviation="0.5"/><feComposite in2="hardAlpha" operator="out"/><feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.06 0"/><feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_12969_88361"/><feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_12969_88361" result="shape"/></filter></defs></svg>`};
|
@@ -0,0 +1,119 @@
|
|
1
|
+
import{css}from"lit";import focusOutline from"./styles/focus-outline.js";import opacityAndScaleAnimation from"./styles/opacity-and-scale-animation.js";export default[css`
|
2
|
+
${opacityAndScaleAnimation(".popover:popover-open")}
|
3
|
+
${focusOutline(".target:focus-visible")}
|
4
|
+
`,css`
|
5
|
+
:host {
|
6
|
+
/* https://github.com/CrowdStrike/glide-core/pull/307/files#r1718545771 */
|
7
|
+
display: inline-block;
|
8
|
+
}
|
9
|
+
|
10
|
+
.component {
|
11
|
+
/* https://github.com/CrowdStrike/glide-core/pull/119#issuecomment-2113314591 */
|
12
|
+
display: flex;
|
13
|
+
|
14
|
+
/* https://css-tricks.com/flexbox-truncated-text/#aa-the-solution-is-min-width-0-on-the-flex-child */
|
15
|
+
min-inline-size: 0;
|
16
|
+
position: relative;
|
17
|
+
}
|
18
|
+
|
19
|
+
.target-slot {
|
20
|
+
/*
|
21
|
+
Collapses additional whitespace from the slot's line height so the popover is vertically
|
22
|
+
centered against its target.
|
23
|
+
*/
|
24
|
+
display: flex;
|
25
|
+
|
26
|
+
/* Allows the consumer to style the target with an ellipsis when its text is truncated. */
|
27
|
+
inline-size: 100%;
|
28
|
+
position: relative;
|
29
|
+
|
30
|
+
::slotted svg {
|
31
|
+
display: block;
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
.popover {
|
36
|
+
background-color: transparent;
|
37
|
+
border: none;
|
38
|
+
inset: unset;
|
39
|
+
padding: var(--glide-core-spacing-xs);
|
40
|
+
position: absolute;
|
41
|
+
|
42
|
+
&:popover-open {
|
43
|
+
display: flex;
|
44
|
+
|
45
|
+
/*
|
46
|
+
Elements with a "popover" attribute don't allow overflow. So the arrow can't
|
47
|
+
be positioned with "position: absolute". Relative positioning is used instead.
|
48
|
+
Flex is used to get the arrow on the correct side of the popover. Floating UI
|
49
|
+
handles the rest.
|
50
|
+
|
51
|
+
A simple "transform" could replace Floating UI for the arrow if not for a Chrome
|
52
|
+
bug with "popover" when "scale()" is animated on the popover or a container within
|
53
|
+
it. With "transform" on the arrow, the arrow is initially offset by a couple pixels
|
54
|
+
before landing in the correct position when the animation finishes. It only happens
|
55
|
+
when the popover is left or right of its target.
|
56
|
+
*/
|
57
|
+
&.top {
|
58
|
+
flex-direction: column-reverse;
|
59
|
+
}
|
60
|
+
|
61
|
+
&.right {
|
62
|
+
flex-direction: row-reverse;
|
63
|
+
}
|
64
|
+
|
65
|
+
&.bottom {
|
66
|
+
flex-direction: column;
|
67
|
+
}
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
.arrow {
|
72
|
+
--arrow-height: 0.5625rem;
|
73
|
+
--arrow-width: 1rem;
|
74
|
+
|
75
|
+
color: var(--glide-core-surface-modal);
|
76
|
+
display: flex;
|
77
|
+
position: relative;
|
78
|
+
|
79
|
+
&.top,
|
80
|
+
&.bottom {
|
81
|
+
block-size: var(--arrow-height);
|
82
|
+
inline-size: var(--arrow-width);
|
83
|
+
}
|
84
|
+
|
85
|
+
&.right,
|
86
|
+
&.left {
|
87
|
+
block-size: var(--arrow-width);
|
88
|
+
inline-size: var(--arrow-height);
|
89
|
+
order: 2;
|
90
|
+
}
|
91
|
+
}
|
92
|
+
|
93
|
+
.default-slot {
|
94
|
+
background-color: var(--glide-core-surface-modal);
|
95
|
+
border-radius: var(--glide-core-spacing-xs);
|
96
|
+
|
97
|
+
/*
|
98
|
+
".popover" can't overflow because the Popover API won't allow it. And
|
99
|
+
a shadow counts as overflow. So make sure to adjust the padding on
|
100
|
+
".popover" when changing this shadow so ".popover" has enough room for it.
|
101
|
+
*/
|
102
|
+
box-shadow:
|
103
|
+
0 3px 8px 0 rgba(0 0 0 / 15%),
|
104
|
+
0 3px 1px 0 rgba(0 0 0 / 6%);
|
105
|
+
box-sizing: border-box;
|
106
|
+
color: var(--glide-core-text-body-1);
|
107
|
+
display: flex;
|
108
|
+
font-family: var(--glide-core-body-md-font-family);
|
109
|
+
font-size: var(--glide-core-body-sm-font-size);
|
110
|
+
font-style: var(--glide-core-body-sm-font-style);
|
111
|
+
font-weight: var(--glide-core-body-sm-font-weight);
|
112
|
+
inset-block-start: 50%;
|
113
|
+
line-height: var(--glide-core-body-sm-line-height);
|
114
|
+
max-inline-size: 23.75rem;
|
115
|
+
min-block-size: 2rem;
|
116
|
+
min-inline-size: 5rem;
|
117
|
+
padding: var(--glide-core-spacing-sm);
|
118
|
+
}
|
119
|
+
`];
|