@limetech/lime-elements 40.4.0 → 40.4.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.
@@ -124,6 +124,7 @@ export declare class Menu {
124
124
  private selectedMenuItem?;
125
125
  private shouldRestoreFocusOnClose;
126
126
  private readonly normalizedHotkeyCache;
127
+ private readonly triggersDisabledByMenu;
127
128
  private cachedSubMenuSource;
128
129
  private cachedSubMenuItems;
129
130
  constructor();
@@ -133,6 +134,8 @@ export declare class Menu {
133
134
  connectedCallback(): void;
134
135
  disconnectedCallback(): void;
135
136
  protected openWatcher(newValue: boolean): void;
137
+ private setupGlobalHandlers;
138
+ private teardownGlobalHandlers;
136
139
  private readonly handleDocumentKeyDown;
137
140
  private isFromTextInput;
138
141
  private hasModifier;
@@ -157,6 +160,14 @@ export declare class Menu {
157
160
  private readonly goForward;
158
161
  private readonly goBack;
159
162
  private readonly setTriggerAttributes;
163
+ /**
164
+ * `disabled` has to be removed rather than set to `false`, because the
165
+ * presence of the attribute is what disables the element. Only the one the
166
+ * menu put there may go: a consumer can disable their own trigger, and
167
+ * stripping that attribute would re-enable it on every render.
168
+ * @param element - the slotted trigger element
169
+ */
170
+ private readonly setTriggerDisabled;
160
171
  private readonly onClose;
161
172
  private readonly onTriggerClick;
162
173
  private readonly handleSelect;
@@ -63,9 +63,16 @@ export declare class Popover {
63
63
  private shouldRestoreFocusOnClose;
64
64
  constructor();
65
65
  protected watchOpen(): void;
66
- componentWillLoad(): void;
66
+ connectedCallback(): void;
67
+ disconnectedCallback(): void;
67
68
  componentDidRender(): void;
68
69
  private setupGlobalHandlers;
70
+ /**
71
+ * The capture flag has to be given again: `removeEventListener` only
72
+ * matches a listener registered with the same one, so leaving it out here
73
+ * left the click listener on `document` for good.
74
+ */
75
+ private teardownGlobalHandlers;
69
76
  render(): any;
70
77
  private globalClickListener;
71
78
  private getCssProperties;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@limetech/lime-elements",
3
- "version": "40.4.0",
3
+ "version": "40.4.2",
4
4
  "description": "Lime Elements",
5
5
  "author": "Lime Technologies",
6
6
  "license": "Apache-2.0",
@@ -1 +0,0 @@
1
- import{r as e,c as o,h as t,a as r}from"./p-Bnc9lzk2.js";import{c as i}from"./p-JbKhhoXs.js";import{E as s}from"./p-C4_9qUMP.js";import{f as a,z as n}from"./p-D0F7gOYG.js";import"./p-ByzvFNMm.js";import"./p-9W8bTt2G.js";import"./p-DbBZn7JO.js";import"./p-BcJ-TDVt.js";import"./p-BJQylLSL.js";import"./p-CZ30nDJE.js";function c(e,o){var t;if(e.contains(o)||(null===(t=e.shadowRoot)||void 0===t?void 0:t.contains(o)))return!0;const r=function(e){const o=e.closest(".limel-portal--container");if(o)return o.portalSource;return e.getRootNode().host}(o);return!!r&&c(e,r)}const p=class{constructor(t){e(this,t),this.close=o(this,"close",7),this.open=!1,this.shouldRestoreFocusOnClose=!1,this.handleGlobalKeyPress=e=>{e.key===s&&(e.stopPropagation(),e.preventDefault(),this.requestCloseAndRestoreFocus())},this.requestCloseAndRestoreFocus=()=>{this.shouldRestoreFocusOnClose=!0,this.close.emit()},this.setTriggerRef=e=>{this.triggerSlot=e},this.focusTrigger=()=>{var e,o;const t=null===(o=null===(e=this.triggerSlot)||void 0===e?void 0:e.assignedElements())||void 0===o?void 0:o[0];a(t)},this.setTriggerAttributes=e=>{const o={"aria-haspopup":!0,"aria-expanded":this.open,"aria-controls":this.portalId,role:"button"};for(const[t,r]of Object.entries(o))r?e.setAttribute(t,String(r)):e.removeAttribute(t)},this.portalId=i(),this.globalClickListener=this.globalClickListener.bind(this)}watchOpen(){this.setupGlobalHandlers(),!this.open&&this.shouldRestoreFocusOnClose&&(this.shouldRestoreFocusOnClose=!1,setTimeout(this.focusTrigger,0))}componentWillLoad(){this.setupGlobalHandlers()}componentDidRender(){this.triggerSlot&&this.triggerSlot.assignedElements().forEach(this.setTriggerAttributes)}setupGlobalHandlers(){this.open?(document.addEventListener("click",this.globalClickListener,{capture:!0}),document.addEventListener("keydown",this.handleGlobalKeyPress)):(document.removeEventListener("click",this.globalClickListener),document.removeEventListener("keydown",this.handleGlobalKeyPress))}render(){const e=this.getCssProperties(),o=getComputedStyle(this.host).getPropertyValue("--popover-z-index");return t("div",{key:"096e54a6fdc88f6571884bf0a642c67f144d3bbf",class:"trigger-anchor"},t("slot",{key:"ddc46b8755f6463dc2320198aefc50ef759f9de4",name:"trigger",ref:this.setTriggerRef}),t("limel-portal",{key:"89cce45b2218a2a5087f30f4d524d2c1b2041de2",visible:this.open,containerId:this.portalId,containerStyle:{"z-index":o},openDirection:this.openDirection},t("limel-popover-surface",{key:"a1d1edfb24fdbef9109adef03f8d77e6cced87c7",contentCollection:this.host.children,style:e})))}globalClickListener(e){const o=c(this.host,e.target);this.open&&!o&&(e.stopPropagation(),e.preventDefault(),this.close.emit())}getCssProperties(){const e=["--popover-surface-width","--popover-body-background-color","--popover-border-radius","--popover-box-shadow"],o=getComputedStyle(this.host),t=e.map((e=>o.getPropertyValue(e)));return n(e,t)}get host(){return r(this)}static get watchers(){return{open:[{watchOpen:0}]}}};p.style=".trigger-anchor{display:inline-block;position:relative}";const l=class{constructor(o){e(this,o)}componentDidLoad(){this.appendElement()}render(){return t("div",{key:"c3f7cda21c76bdd39eba1e8e4e28503561d28a7e",class:"limel-popover-surface",tabindex:"0"})}appendElement(){const e=this.host.shadowRoot.querySelector(".limel-popover-surface"),o=[...this.contentCollection];for(const t of o)"trigger"!==t.slot&&e.append(t)}get host(){return r(this)}};l.style='@charset "UTF-8";:host(limel-popover-surface){isolation:isolate;position:relative;display:flex;width:var(--popover-surface-width, auto);max-height:inherit;max-width:calc(100vw - 2rem);margin:0 0.25rem}.limel-popover-surface{flex:1;min-width:0;min-height:0;border-radius:var(--popover-border-radius, 0.75rem);box-shadow:var(--popover-box-shadow, var(--shadow-depth-16));backdrop-filter:blur(0.3125rem);-webkit-backdrop-filter:blur(0.3125rem)}.limel-popover-surface:after{transition:opacity 0.4s ease;pointer-events:none;content:"";position:absolute;top:0;right:0;bottom:0;left:0;z-index:-1;opacity:0.95;border-radius:var(--popover-border-radius, 0.75rem);background-color:var(--popover-body-background-color, var(--lime-elevated-surface-background-color))}.limel-popover-surface:focus{outline:none}.limel-popover-surface:focus-visible{outline:none;box-shadow:var(--shadow-depth-8-focused)}.limel-popover-surface:focus:after,.limel-popover-surface:focus-within:after{opacity:1}.limel-popover-surface>*{box-sizing:border-box}';export{p as limel_popover,l as limel_popover_surface}