@neovici/cosmoz-dropdown 4.4.2 → 5.1.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.
@@ -0,0 +1,349 @@
1
+ declare global {
2
+ interface HTMLElement {
3
+ connectedCallback(): void;
4
+ disconnectedCallback(): void;
5
+ }
6
+ }
7
+ export declare const connectable: (base?: {
8
+ new (): HTMLElement;
9
+ prototype: HTMLElement;
10
+ }) => {
11
+ new (): {
12
+ connectedCallback(): void;
13
+ disconnectedCallback(): void;
14
+ accessKey: string;
15
+ readonly accessKeyLabel: string;
16
+ autocapitalize: string;
17
+ dir: string;
18
+ draggable: boolean;
19
+ hidden: boolean;
20
+ inert: boolean;
21
+ innerText: string;
22
+ lang: string;
23
+ readonly offsetHeight: number;
24
+ readonly offsetLeft: number;
25
+ readonly offsetParent: Element | null;
26
+ readonly offsetTop: number;
27
+ readonly offsetWidth: number;
28
+ outerText: string;
29
+ popover: string | null;
30
+ spellcheck: boolean;
31
+ title: string;
32
+ translate: boolean;
33
+ writingSuggestions: string;
34
+ attachInternals(): ElementInternals;
35
+ click(): void;
36
+ hidePopover(): void;
37
+ showPopover(): void;
38
+ togglePopover(force?: boolean): boolean;
39
+ addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
40
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
41
+ removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
42
+ removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
43
+ readonly attributes: NamedNodeMap;
44
+ readonly classList: DOMTokenList;
45
+ className: string;
46
+ readonly clientHeight: number;
47
+ readonly clientLeft: number;
48
+ readonly clientTop: number;
49
+ readonly clientWidth: number;
50
+ readonly currentCSSZoom: number;
51
+ id: string;
52
+ innerHTML: string;
53
+ readonly localName: string;
54
+ readonly namespaceURI: string | null;
55
+ onfullscreenchange: ((this: Element, ev: Event) => any) | null;
56
+ onfullscreenerror: ((this: Element, ev: Event) => any) | null;
57
+ outerHTML: string;
58
+ readonly ownerDocument: Document;
59
+ readonly part: DOMTokenList;
60
+ readonly prefix: string | null;
61
+ readonly scrollHeight: number;
62
+ scrollLeft: number;
63
+ scrollTop: number;
64
+ readonly scrollWidth: number;
65
+ readonly shadowRoot: ShadowRoot | null;
66
+ slot: string;
67
+ readonly tagName: string;
68
+ attachShadow(init: ShadowRootInit): ShadowRoot;
69
+ checkVisibility(options?: CheckVisibilityOptions): boolean;
70
+ closest<K extends keyof HTMLElementTagNameMap>(selector: K): HTMLElementTagNameMap[K] | null;
71
+ closest<K extends keyof SVGElementTagNameMap>(selector: K): SVGElementTagNameMap[K] | null;
72
+ closest<K extends keyof MathMLElementTagNameMap>(selector: K): MathMLElementTagNameMap[K] | null;
73
+ closest<E extends Element = Element>(selectors: string): E | null;
74
+ computedStyleMap(): StylePropertyMapReadOnly;
75
+ getAttribute(qualifiedName: string): string | null;
76
+ getAttributeNS(namespace: string | null, localName: string): string | null;
77
+ getAttributeNames(): string[];
78
+ getAttributeNode(qualifiedName: string): Attr | null;
79
+ getAttributeNodeNS(namespace: string | null, localName: string): Attr | null;
80
+ getBoundingClientRect(): DOMRect;
81
+ getClientRects(): DOMRectList;
82
+ getElementsByClassName(classNames: string): HTMLCollectionOf<Element>;
83
+ getElementsByTagName<K extends keyof HTMLElementTagNameMap>(qualifiedName: K): HTMLCollectionOf<HTMLElementTagNameMap[K]>;
84
+ getElementsByTagName<K extends keyof SVGElementTagNameMap>(qualifiedName: K): HTMLCollectionOf<SVGElementTagNameMap[K]>;
85
+ getElementsByTagName<K extends keyof MathMLElementTagNameMap>(qualifiedName: K): HTMLCollectionOf<MathMLElementTagNameMap[K]>;
86
+ getElementsByTagName<K extends keyof HTMLElementDeprecatedTagNameMap>(qualifiedName: K): HTMLCollectionOf<HTMLElementDeprecatedTagNameMap[K]>;
87
+ getElementsByTagName(qualifiedName: string): HTMLCollectionOf<Element>;
88
+ getElementsByTagNameNS(namespaceURI: "http://www.w3.org/1999/xhtml", localName: string): HTMLCollectionOf<HTMLElement>;
89
+ getElementsByTagNameNS(namespaceURI: "http://www.w3.org/2000/svg", localName: string): HTMLCollectionOf<SVGElement>;
90
+ getElementsByTagNameNS(namespaceURI: "http://www.w3.org/1998/Math/MathML", localName: string): HTMLCollectionOf<MathMLElement>;
91
+ getElementsByTagNameNS(namespace: string | null, localName: string): HTMLCollectionOf<Element>;
92
+ getHTML(options?: GetHTMLOptions): string;
93
+ hasAttribute(qualifiedName: string): boolean;
94
+ hasAttributeNS(namespace: string | null, localName: string): boolean;
95
+ hasAttributes(): boolean;
96
+ hasPointerCapture(pointerId: number): boolean;
97
+ insertAdjacentElement(where: InsertPosition, element: Element): Element | null;
98
+ insertAdjacentHTML(position: InsertPosition, string: string): void;
99
+ insertAdjacentText(where: InsertPosition, data: string): void;
100
+ matches(selectors: string): boolean;
101
+ releasePointerCapture(pointerId: number): void;
102
+ removeAttribute(qualifiedName: string): void;
103
+ removeAttributeNS(namespace: string | null, localName: string): void;
104
+ removeAttributeNode(attr: Attr): Attr;
105
+ requestFullscreen(options?: FullscreenOptions): Promise<void>;
106
+ requestPointerLock(options?: PointerLockOptions): Promise<void>;
107
+ scroll(options?: ScrollToOptions): void;
108
+ scroll(x: number, y: number): void;
109
+ scrollBy(options?: ScrollToOptions): void;
110
+ scrollBy(x: number, y: number): void;
111
+ scrollIntoView(arg?: boolean | ScrollIntoViewOptions): void;
112
+ scrollTo(options?: ScrollToOptions): void;
113
+ scrollTo(x: number, y: number): void;
114
+ setAttribute(qualifiedName: string, value: string): void;
115
+ setAttributeNS(namespace: string | null, qualifiedName: string, value: string): void;
116
+ setAttributeNode(attr: Attr): Attr | null;
117
+ setAttributeNodeNS(attr: Attr): Attr | null;
118
+ setHTMLUnsafe(html: string): void;
119
+ setPointerCapture(pointerId: number): void;
120
+ toggleAttribute(qualifiedName: string, force?: boolean): boolean;
121
+ webkitMatchesSelector(selectors: string): boolean;
122
+ readonly baseURI: string;
123
+ readonly childNodes: NodeListOf<ChildNode>;
124
+ readonly firstChild: ChildNode | null;
125
+ readonly isConnected: boolean;
126
+ readonly lastChild: ChildNode | null;
127
+ readonly nextSibling: ChildNode | null;
128
+ readonly nodeName: string;
129
+ readonly nodeType: number;
130
+ nodeValue: string | null;
131
+ readonly parentElement: HTMLElement | null;
132
+ readonly parentNode: ParentNode | null;
133
+ readonly previousSibling: ChildNode | null;
134
+ textContent: string | null;
135
+ appendChild<T extends Node>(node: T): T;
136
+ cloneNode(deep?: boolean): Node;
137
+ compareDocumentPosition(other: Node): number;
138
+ contains(other: Node | null): boolean;
139
+ getRootNode(options?: GetRootNodeOptions): Node;
140
+ hasChildNodes(): boolean;
141
+ insertBefore<T extends Node>(node: T, child: Node | null): T;
142
+ isDefaultNamespace(namespace: string | null): boolean;
143
+ isEqualNode(otherNode: Node | null): boolean;
144
+ isSameNode(otherNode: Node | null): boolean;
145
+ lookupNamespaceURI(prefix: string | null): string | null;
146
+ lookupPrefix(namespace: string | null): string | null;
147
+ normalize(): void;
148
+ removeChild<T extends Node>(child: T): T;
149
+ replaceChild<T extends Node>(node: Node, child: T): T;
150
+ readonly ELEMENT_NODE: 1;
151
+ readonly ATTRIBUTE_NODE: 2;
152
+ readonly TEXT_NODE: 3;
153
+ readonly CDATA_SECTION_NODE: 4;
154
+ readonly ENTITY_REFERENCE_NODE: 5;
155
+ readonly ENTITY_NODE: 6;
156
+ readonly PROCESSING_INSTRUCTION_NODE: 7;
157
+ readonly COMMENT_NODE: 8;
158
+ readonly DOCUMENT_NODE: 9;
159
+ readonly DOCUMENT_TYPE_NODE: 10;
160
+ readonly DOCUMENT_FRAGMENT_NODE: 11;
161
+ readonly NOTATION_NODE: 12;
162
+ readonly DOCUMENT_POSITION_DISCONNECTED: 1;
163
+ readonly DOCUMENT_POSITION_PRECEDING: 2;
164
+ readonly DOCUMENT_POSITION_FOLLOWING: 4;
165
+ readonly DOCUMENT_POSITION_CONTAINS: 8;
166
+ readonly DOCUMENT_POSITION_CONTAINED_BY: 16;
167
+ readonly DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: 32;
168
+ dispatchEvent(event: Event): boolean;
169
+ ariaAtomic: string | null;
170
+ ariaAutoComplete: string | null;
171
+ ariaBrailleLabel: string | null;
172
+ ariaBrailleRoleDescription: string | null;
173
+ ariaBusy: string | null;
174
+ ariaChecked: string | null;
175
+ ariaColCount: string | null;
176
+ ariaColIndex: string | null;
177
+ ariaColIndexText: string | null;
178
+ ariaColSpan: string | null;
179
+ ariaCurrent: string | null;
180
+ ariaDescription: string | null;
181
+ ariaDisabled: string | null;
182
+ ariaExpanded: string | null;
183
+ ariaHasPopup: string | null;
184
+ ariaHidden: string | null;
185
+ ariaInvalid: string | null;
186
+ ariaKeyShortcuts: string | null;
187
+ ariaLabel: string | null;
188
+ ariaLevel: string | null;
189
+ ariaLive: string | null;
190
+ ariaModal: string | null;
191
+ ariaMultiLine: string | null;
192
+ ariaMultiSelectable: string | null;
193
+ ariaOrientation: string | null;
194
+ ariaPlaceholder: string | null;
195
+ ariaPosInSet: string | null;
196
+ ariaPressed: string | null;
197
+ ariaReadOnly: string | null;
198
+ ariaRequired: string | null;
199
+ ariaRoleDescription: string | null;
200
+ ariaRowCount: string | null;
201
+ ariaRowIndex: string | null;
202
+ ariaRowIndexText: string | null;
203
+ ariaRowSpan: string | null;
204
+ ariaSelected: string | null;
205
+ ariaSetSize: string | null;
206
+ ariaSort: string | null;
207
+ ariaValueMax: string | null;
208
+ ariaValueMin: string | null;
209
+ ariaValueNow: string | null;
210
+ ariaValueText: string | null;
211
+ role: string | null;
212
+ animate(keyframes: Keyframe[] | PropertyIndexedKeyframes | null, options?: number | KeyframeAnimationOptions): Animation;
213
+ getAnimations(options?: GetAnimationsOptions): Animation[];
214
+ after(...nodes: (Node | string)[]): void;
215
+ before(...nodes: (Node | string)[]): void;
216
+ remove(): void;
217
+ replaceWith(...nodes: (Node | string)[]): void;
218
+ readonly nextElementSibling: Element | null;
219
+ readonly previousElementSibling: Element | null;
220
+ readonly childElementCount: number;
221
+ readonly children: HTMLCollection;
222
+ readonly firstElementChild: Element | null;
223
+ readonly lastElementChild: Element | null;
224
+ append(...nodes: (Node | string)[]): void;
225
+ prepend(...nodes: (Node | string)[]): void;
226
+ querySelector<K extends keyof HTMLElementTagNameMap>(selectors: K): HTMLElementTagNameMap[K] | null;
227
+ querySelector<K extends keyof SVGElementTagNameMap>(selectors: K): SVGElementTagNameMap[K] | null;
228
+ querySelector<K extends keyof MathMLElementTagNameMap>(selectors: K): MathMLElementTagNameMap[K] | null;
229
+ querySelector<K extends keyof HTMLElementDeprecatedTagNameMap>(selectors: K): HTMLElementDeprecatedTagNameMap[K] | null;
230
+ querySelector<E extends Element = Element>(selectors: string): E | null;
231
+ querySelectorAll<K extends keyof HTMLElementTagNameMap>(selectors: K): NodeListOf<HTMLElementTagNameMap[K]>;
232
+ querySelectorAll<K extends keyof SVGElementTagNameMap>(selectors: K): NodeListOf<SVGElementTagNameMap[K]>;
233
+ querySelectorAll<K extends keyof MathMLElementTagNameMap>(selectors: K): NodeListOf<MathMLElementTagNameMap[K]>;
234
+ querySelectorAll<K extends keyof HTMLElementDeprecatedTagNameMap>(selectors: K): NodeListOf<HTMLElementDeprecatedTagNameMap[K]>;
235
+ querySelectorAll<E extends Element = Element>(selectors: string): NodeListOf<E>;
236
+ replaceChildren(...nodes: (Node | string)[]): void;
237
+ readonly assignedSlot: HTMLSlotElement | null;
238
+ readonly attributeStyleMap: StylePropertyMap;
239
+ readonly style: CSSStyleDeclaration;
240
+ contentEditable: string;
241
+ enterKeyHint: string;
242
+ inputMode: string;
243
+ readonly isContentEditable: boolean;
244
+ onabort: ((this: GlobalEventHandlers, ev: UIEvent) => any) | null;
245
+ onanimationcancel: ((this: GlobalEventHandlers, ev: AnimationEvent) => any) | null;
246
+ onanimationend: ((this: GlobalEventHandlers, ev: AnimationEvent) => any) | null;
247
+ onanimationiteration: ((this: GlobalEventHandlers, ev: AnimationEvent) => any) | null;
248
+ onanimationstart: ((this: GlobalEventHandlers, ev: AnimationEvent) => any) | null;
249
+ onauxclick: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
250
+ onbeforeinput: ((this: GlobalEventHandlers, ev: InputEvent) => any) | null;
251
+ onbeforetoggle: ((this: GlobalEventHandlers, ev: Event) => any) | null;
252
+ onblur: ((this: GlobalEventHandlers, ev: FocusEvent) => any) | null;
253
+ oncancel: ((this: GlobalEventHandlers, ev: Event) => any) | null;
254
+ oncanplay: ((this: GlobalEventHandlers, ev: Event) => any) | null;
255
+ oncanplaythrough: ((this: GlobalEventHandlers, ev: Event) => any) | null;
256
+ onchange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
257
+ onclick: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
258
+ onclose: ((this: GlobalEventHandlers, ev: Event) => any) | null;
259
+ oncontextlost: ((this: GlobalEventHandlers, ev: Event) => any) | null;
260
+ oncontextmenu: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
261
+ oncontextrestored: ((this: GlobalEventHandlers, ev: Event) => any) | null;
262
+ oncopy: ((this: GlobalEventHandlers, ev: ClipboardEvent) => any) | null;
263
+ oncuechange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
264
+ oncut: ((this: GlobalEventHandlers, ev: ClipboardEvent) => any) | null;
265
+ ondblclick: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
266
+ ondrag: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
267
+ ondragend: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
268
+ ondragenter: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
269
+ ondragleave: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
270
+ ondragover: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
271
+ ondragstart: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
272
+ ondrop: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
273
+ ondurationchange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
274
+ onemptied: ((this: GlobalEventHandlers, ev: Event) => any) | null;
275
+ onended: ((this: GlobalEventHandlers, ev: Event) => any) | null;
276
+ onerror: OnErrorEventHandler;
277
+ onfocus: ((this: GlobalEventHandlers, ev: FocusEvent) => any) | null;
278
+ onformdata: ((this: GlobalEventHandlers, ev: FormDataEvent) => any) | null;
279
+ ongotpointercapture: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
280
+ oninput: ((this: GlobalEventHandlers, ev: Event) => any) | null;
281
+ oninvalid: ((this: GlobalEventHandlers, ev: Event) => any) | null;
282
+ onkeydown: ((this: GlobalEventHandlers, ev: KeyboardEvent) => any) | null;
283
+ onkeypress: ((this: GlobalEventHandlers, ev: KeyboardEvent) => any) | null;
284
+ onkeyup: ((this: GlobalEventHandlers, ev: KeyboardEvent) => any) | null;
285
+ onload: ((this: GlobalEventHandlers, ev: Event) => any) | null;
286
+ onloadeddata: ((this: GlobalEventHandlers, ev: Event) => any) | null;
287
+ onloadedmetadata: ((this: GlobalEventHandlers, ev: Event) => any) | null;
288
+ onloadstart: ((this: GlobalEventHandlers, ev: Event) => any) | null;
289
+ onlostpointercapture: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
290
+ onmousedown: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
291
+ onmouseenter: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
292
+ onmouseleave: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
293
+ onmousemove: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
294
+ onmouseout: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
295
+ onmouseover: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
296
+ onmouseup: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
297
+ onpaste: ((this: GlobalEventHandlers, ev: ClipboardEvent) => any) | null;
298
+ onpause: ((this: GlobalEventHandlers, ev: Event) => any) | null;
299
+ onplay: ((this: GlobalEventHandlers, ev: Event) => any) | null;
300
+ onplaying: ((this: GlobalEventHandlers, ev: Event) => any) | null;
301
+ onpointercancel: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
302
+ onpointerdown: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
303
+ onpointerenter: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
304
+ onpointerleave: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
305
+ onpointermove: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
306
+ onpointerout: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
307
+ onpointerover: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
308
+ onpointerup: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null;
309
+ onprogress: ((this: GlobalEventHandlers, ev: ProgressEvent) => any) | null;
310
+ onratechange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
311
+ onreset: ((this: GlobalEventHandlers, ev: Event) => any) | null;
312
+ onresize: ((this: GlobalEventHandlers, ev: UIEvent) => any) | null;
313
+ onscroll: ((this: GlobalEventHandlers, ev: Event) => any) | null;
314
+ onscrollend: ((this: GlobalEventHandlers, ev: Event) => any) | null;
315
+ onsecuritypolicyviolation: ((this: GlobalEventHandlers, ev: SecurityPolicyViolationEvent) => any) | null;
316
+ onseeked: ((this: GlobalEventHandlers, ev: Event) => any) | null;
317
+ onseeking: ((this: GlobalEventHandlers, ev: Event) => any) | null;
318
+ onselect: ((this: GlobalEventHandlers, ev: Event) => any) | null;
319
+ onselectionchange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
320
+ onselectstart: ((this: GlobalEventHandlers, ev: Event) => any) | null;
321
+ onslotchange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
322
+ onstalled: ((this: GlobalEventHandlers, ev: Event) => any) | null;
323
+ onsubmit: ((this: GlobalEventHandlers, ev: SubmitEvent) => any) | null;
324
+ onsuspend: ((this: GlobalEventHandlers, ev: Event) => any) | null;
325
+ ontimeupdate: ((this: GlobalEventHandlers, ev: Event) => any) | null;
326
+ ontoggle: ((this: GlobalEventHandlers, ev: Event) => any) | null;
327
+ ontouchcancel?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined;
328
+ ontouchend?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined;
329
+ ontouchmove?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined;
330
+ ontouchstart?: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined;
331
+ ontransitioncancel: ((this: GlobalEventHandlers, ev: TransitionEvent) => any) | null;
332
+ ontransitionend: ((this: GlobalEventHandlers, ev: TransitionEvent) => any) | null;
333
+ ontransitionrun: ((this: GlobalEventHandlers, ev: TransitionEvent) => any) | null;
334
+ ontransitionstart: ((this: GlobalEventHandlers, ev: TransitionEvent) => any) | null;
335
+ onvolumechange: ((this: GlobalEventHandlers, ev: Event) => any) | null;
336
+ onwaiting: ((this: GlobalEventHandlers, ev: Event) => any) | null;
337
+ onwebkitanimationend: ((this: GlobalEventHandlers, ev: Event) => any) | null;
338
+ onwebkitanimationiteration: ((this: GlobalEventHandlers, ev: Event) => any) | null;
339
+ onwebkitanimationstart: ((this: GlobalEventHandlers, ev: Event) => any) | null;
340
+ onwebkittransitionend: ((this: GlobalEventHandlers, ev: Event) => any) | null;
341
+ onwheel: ((this: GlobalEventHandlers, ev: WheelEvent) => any) | null;
342
+ autofocus: boolean;
343
+ readonly dataset: DOMStringMap;
344
+ nonce?: string;
345
+ tabIndex: number;
346
+ blur(): void;
347
+ focus(options?: FocusOptions): void;
348
+ };
349
+ };
@@ -0,0 +1,10 @@
1
+ export const connectable = (base = HTMLElement) => class extends base {
2
+ connectedCallback() {
3
+ super.connectedCallback?.();
4
+ this.dispatchEvent(new CustomEvent('connected'));
5
+ }
6
+ disconnectedCallback() {
7
+ super.disconnectedCallback?.();
8
+ this.dispatchEvent(new CustomEvent('disconnected'));
9
+ }
10
+ };
@@ -0,0 +1 @@
1
+ export declare const Content: () => import("lit-html").TemplateResult<1>;
@@ -0,0 +1,31 @@
1
+ import { component, css } from '@pionjs/pion';
2
+ import { html } from 'lit-html';
3
+ import { connectable } from './connectable';
4
+ const style = css `
5
+ :host {
6
+ position: fixed;
7
+ left: -9999999999px;
8
+ min-width: 72px;
9
+ box-sizing: border-box;
10
+ padding: var(--cosmoz-dropdown-spacing, 0px);
11
+ z-index: var(--cosmoz-dropdown-z-index, 2);
12
+ }
13
+ :host(:popover-open) {
14
+ margin: 0;
15
+ border: 0;
16
+ padding: 0;
17
+ overflow: visible;
18
+ }
19
+ .wrap {
20
+ background: var(--cosmoz-dropdown-bg-color, #fff);
21
+ box-shadow: var(
22
+ --cosmoz-dropdown-box-shadow,
23
+ 0px 3px 4px 2px rgba(0, 0, 0, 0.1)
24
+ );
25
+ }
26
+ ::slotted(*) {
27
+ display: block;
28
+ }
29
+ `;
30
+ export const Content = () => html `<div class="wrap" part="wrap"><slot></slot></div>`;
31
+ customElements.define('cosmoz-dropdown-content', connectable(component(Content, { styleSheets: [style] })));
@@ -0,0 +1,5 @@
1
+ import { Props as DropdownProps } from './cosmoz-dropdown';
2
+ export declare const List: () => import("lit-html").TemplateResult<1>;
3
+ type MenuProps = Pick<DropdownProps, 'placement'>;
4
+ export declare const Menu: ({ placement }: MenuProps) => import("lit-html").TemplateResult<1>;
5
+ export {};
@@ -0,0 +1,50 @@
1
+ import { css, component } from '@pionjs/pion';
2
+ import { html } from 'lit-html';
3
+ const style = css `
4
+ :host {
5
+ display: contents;
6
+ max-height: var(--cosmoz-dropdown-menu-max-height, calc(96vh - 64px));
7
+ overflow-y: auto;
8
+ }
9
+ ::slotted(:not(slot)) {
10
+ display: block;
11
+ --paper-button_-_display: block;
12
+ box-sizing: border-box;
13
+ padding: 10px 24px;
14
+ background: transparent;
15
+ color: var(--cosmoz-dropdown-menu-color, #101010);
16
+ transition:
17
+ background 0.25s,
18
+ color 0.25s;
19
+ border: none;
20
+ cursor: pointer;
21
+ font-size: 14px;
22
+ line-height: 20px;
23
+ text-align: left;
24
+ margin: 0;
25
+ width: 100%;
26
+ }
27
+
28
+ ::slotted(:not(slot):hover) {
29
+ background: var(
30
+ --cosmoz-dropdown-menu-hover-color,
31
+ var(--cosmoz-selection-color, rgba(58, 145, 226, 0.1))
32
+ );
33
+ }
34
+
35
+ ::slotted(:not(slot)[disabled]) {
36
+ opacity: 0.5;
37
+ pointer-events: none;
38
+ }
39
+ `;
40
+ export const List = () => html ` <slot></slot> `;
41
+ customElements.define('cosmoz-dropdown-list', component(List, { styleSheets: [style] }));
42
+ export const Menu = ({ placement }) => html ` <cosmoz-dropdown
43
+ .placement=${placement}
44
+ part="dropdown"
45
+ exportparts="anchor, button, content, wrap, dropdown"
46
+ >
47
+ <slot name="button" slot="button"></slot>
48
+ <cosmoz-dropdown-list><slot></slot></cosmoz-dropdown-list>
49
+ </cosmoz-dropdown>`;
50
+ customElements.define('cosmoz-dropdown-menu', component(Menu));
@@ -1,13 +1,10 @@
1
- import { TemplateResult } from 'lit-html';
2
- import { Placement } from './use-position';
3
1
  import { UseFocusOpts } from './use-focus';
4
- interface ContentProps {
5
- anchor: HTMLElement;
2
+ import { Content } from './cosmoz-dropdown-content';
3
+ import { Placement, Strategy } from './use-floating';
4
+ export interface Props extends UseFocusOpts {
6
5
  placement?: Placement;
7
- render?: () => TemplateResult;
6
+ strategy?: Strategy;
7
+ render: () => unknown;
8
8
  }
9
- declare const Content: (host: HTMLElement & ContentProps) => TemplateResult<1>;
10
- interface DropdownProps extends UseFocusOpts, Pick<ContentProps, 'placement' | 'render'> {
11
- }
12
- declare const Dropdown: (host: HTMLElement & DropdownProps) => TemplateResult<1>;
9
+ declare const Dropdown: (host: HTMLElement & Props) => import("lit-html").TemplateResult<1>;
13
10
  export { Dropdown, Content };
@@ -1,104 +1,69 @@
1
- import { component, useCallback } from '@pionjs/pion';
1
+ import { component, css } from '@pionjs/pion';
2
2
  import { html, nothing } from 'lit-html';
3
3
  import { when } from 'lit-html/directives/when.js';
4
4
  import { ref } from 'lit-html/directives/ref.js';
5
- import { usePosition } from './use-position';
5
+ import { styleMap } from 'lit-html/directives/style-map.js';
6
+ import { guard } from 'lit-html/directives/guard.js';
6
7
  import { useHostFocus } from './use-focus';
8
+ import { Content } from './cosmoz-dropdown-content';
9
+ import { useFloating } from './use-floating';
7
10
  const preventDefault = (e) => e.preventDefault();
8
- const supportsPopover = () => {
9
- // eslint-disable-next-line no-prototype-builtins
10
- return HTMLElement.prototype.hasOwnProperty('popover');
11
- };
12
- const showPopover = (popover) => {
13
- const popoverElement = popover;
14
- if (supportsPopover()) {
15
- requestAnimationFrame(() => {
16
- popoverElement?.showPopover();
17
- });
18
- }
19
- };
20
- const Content = (host) => {
21
- const { anchor, placement, render } = host;
22
- usePosition({ anchor, placement, host });
23
- return html ` <style>
24
- :host {
25
- position: fixed;
26
- left: -9999999999px;
27
- min-width: 72px;
28
- box-sizing: border-box;
29
- padding: var(--cosmoz-dropdown-spacing, 0px);
30
- z-index: var(--cosmoz-dropdown-z-index, 2);
31
- }
32
- :host(:popover-open) {
33
- margin: 0;
34
- border: 0;
35
- padding: 0;
36
- overflow: visible;
37
- }
38
- .wrap {
39
- background: var(--cosmoz-dropdown-bg-color, #fff);
40
- box-shadow: var(
41
- --cosmoz-dropdown-box-shadow,
42
- 0px 3px 4px 2px rgba(0, 0, 0, 0.1)
43
- );
44
- }
45
- ::slotted(*) {
46
- display: block;
47
- }
48
- </style>
49
- <div class="wrap" part="wrap"><slot></slot>${render?.() || nothing}</div>`;
50
- };
11
+ const style = css `
12
+ .anchor {
13
+ pointer-events: none;
14
+ padding: var(--cosmoz-dropdown-anchor-spacing);
15
+ }
16
+ button {
17
+ border: none;
18
+ cursor: pointer;
19
+ position: relative;
20
+ pointer-events: auto;
21
+ outline: none;
22
+ background: var(
23
+ --cosmoz-dropdown-button-bg-color,
24
+ var(--cosmoz-button-bg-color, #101010)
25
+ );
26
+ color: var(
27
+ --cosmoz-dropdown-button-color,
28
+ var(--cosmoz-button-color, #fff)
29
+ );
30
+ border-radius: var(--cosmoz-dropdown-button-radius, 50%);
31
+ width: var(
32
+ --cosmoz-dropdown-button-width,
33
+ var(--cosmoz-dropdown-button-size, 40px)
34
+ );
35
+ height: var(
36
+ --cosmoz-dropdown-button-height,
37
+ var(--cosmoz-dropdown-button-size, 40px)
38
+ );
39
+ padding: var(--cosmoz-dropdown-button-padding);
40
+ }
41
+ button:hover {
42
+ background: var(
43
+ --cosmoz-dropdown-button-hover-bg-color,
44
+ var(--cosmoz-button-hover-bg-color, #3a3f44)
45
+ );
46
+ }
47
+ ::slotted(svg) {
48
+ pointer-events: none;
49
+ }
50
+ @-moz-document url-prefix() {
51
+ #content {
52
+ left: auto;
53
+ }
54
+ }
55
+ `;
51
56
  const Dropdown = (host) => {
52
- const { placement, render } = host, anchor = useCallback(() => host.shadowRoot.querySelector('.anchor'), []), { active, onToggle } = useHostFocus(host);
53
- return html ` <style>
54
- .anchor {
55
- pointer-events: none;
56
- padding: var(--cosmoz-dropdown-anchor-spacing);
57
- }
58
- button {
59
- border: none;
60
- cursor: pointer;
61
- position: relative;
62
- pointer-events: auto;
63
- outline: none;
64
- background: var(
65
- --cosmoz-dropdown-button-bg-color,
66
- var(--cosmoz-button-bg-color, #101010)
67
- );
68
- color: var(
69
- --cosmoz-dropdown-button-color,
70
- var(--cosmoz-button-color, #fff)
71
- );
72
- border-radius: var(--cosmoz-dropdown-button-radius, 50%);
73
- width: var(
74
- --cosmoz-dropdown-button-width,
75
- var(--cosmoz-dropdown-button-size, 40px)
76
- );
77
- height: var(
78
- --cosmoz-dropdown-button-height,
79
- var(--cosmoz-dropdown-button-size, 40px)
80
- );
81
- padding: var(--cosmoz-dropdown-button-padding);
82
- }
83
- button:hover {
84
- background: var(
85
- --cosmoz-dropdown-button-hover-bg-color,
86
- var(--cosmoz-button-hover-bg-color, #3a3f44)
87
- );
88
- }
89
- ::slotted(svg) {
90
- pointer-events: none;
91
- }
92
- @-moz-document url-prefix() {
93
- #content {
94
- left: auto;
95
- }
96
- }
97
- </style>
98
- <div class="anchor" part="anchor">
57
+ const { placement, strategy, render } = host;
58
+ const { active, onToggle } = useHostFocus(host);
59
+ const { styles, setReference, setFloating } = useFloating({
60
+ placement,
61
+ strategy,
62
+ });
63
+ return html ` <div class="anchor" part="anchor" ${ref(setReference)}>
99
64
  <button
100
- @click=${onToggle}
101
65
  @mousedown=${preventDefault}
66
+ @click=${onToggle}
102
67
  part="button"
103
68
  id="dropdownButton"
104
69
  >
@@ -106,68 +71,15 @@ const Dropdown = (host) => {
106
71
  </button>
107
72
  </div>
108
73
  ${when(active, () => html `<cosmoz-dropdown-content
109
- ${ref(showPopover)}
110
74
  popover
111
75
  id="content"
112
76
  part="content"
113
77
  exportparts="wrap, content"
114
- .anchor=${anchor}
115
- .placement=${placement}
116
- .render=${render}
117
- >
118
- <slot></slot>
119
- </cosmoz-dropdown-content>`)}`;
78
+ style="${styleMap(styles)}"
79
+ @connected=${(e) => e.target.showPopover?.()}
80
+ ${ref(setFloating)}
81
+ ><slot></slot>${guard([render], () => render?.() || nothing)}</cosmoz-dropdown-content
82
+ > `)}`;
120
83
  };
121
- const List = () => html `
122
- <style>
123
- :host {
124
- display: contents;
125
- max-height: var(--cosmoz-dropdown-menu-max-height, calc(96vh - 64px));
126
- overflow-y: auto;
127
- }
128
- ::slotted(:not(slot)) {
129
- display: block;
130
- --paper-button_-_display: block;
131
- box-sizing: border-box;
132
- padding: 10px 24px;
133
- background: transparent;
134
- color: var(--cosmoz-dropdown-menu-color, #101010);
135
- transition:
136
- background 0.25s,
137
- color 0.25s;
138
- border: none;
139
- cursor: pointer;
140
- font-size: 14px;
141
- line-height: 20px;
142
- text-align: left;
143
- margin: 0;
144
- width: 100%;
145
- }
146
-
147
- ::slotted(:not(slot):hover) {
148
- background: var(
149
- --cosmoz-dropdown-menu-hover-color,
150
- var(--cosmoz-selection-color, rgba(58, 145, 226, 0.1))
151
- );
152
- }
153
-
154
- ::slotted(:not(slot)[disabled]) {
155
- opacity: 0.5;
156
- pointer-events: none;
157
- }
158
- </style>
159
- <slot></slot>
160
- `;
161
- const Menu = ({ placement }) => html ` <cosmoz-dropdown
162
- .placement=${placement}
163
- part="dropdown"
164
- exportparts="anchor, button, content, wrap, dropdown"
165
- >
166
- <slot name="button" slot="button"></slot>
167
- <cosmoz-dropdown-list><slot></slot></cosmoz-dropdown-list>
168
- </cosmoz-dropdown>`;
169
- customElements.define('cosmoz-dropdown-content', component(Content));
170
- customElements.define('cosmoz-dropdown', component(Dropdown));
171
- customElements.define('cosmoz-dropdown-list', component(List));
172
- customElements.define('cosmoz-dropdown-menu', component(Menu));
84
+ customElements.define('cosmoz-dropdown', component(Dropdown, { styleSheets: [style] }));
173
85
  export { Dropdown, Content };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
- export * from './cosmoz-dropdown';
2
1
  export * from './use-focus';
3
2
  export * from './use-position';
3
+ export * from './cosmoz-dropdown-menu';
4
+ export * from './cosmoz-dropdown';
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
- export * from './cosmoz-dropdown';
2
1
  export * from './use-focus';
3
2
  export * from './use-position';
3
+ export * from './cosmoz-dropdown-menu';
4
+ export * from './cosmoz-dropdown';
@@ -0,0 +1,15 @@
1
+ import { ComputePositionConfig, Placement, Strategy } from '@floating-ui/dom';
2
+ interface UseFloating extends Pick<ComputePositionConfig, 'placement' | 'strategy' | 'middleware'> {
3
+ }
4
+ export declare const useFloating: ({ placement, strategy, middleware, }: UseFloating) => {
5
+ setReference: (el?: Element) => void;
6
+ setFloating: (el?: Element) => void;
7
+ styles: {
8
+ left: string;
9
+ top: string;
10
+ } | {
11
+ left?: undefined;
12
+ top?: undefined;
13
+ };
14
+ };
15
+ export type { Placement, Strategy };
@@ -0,0 +1,29 @@
1
+ import { useCallback, useEffect, useMemo, useState } from '@pionjs/pion';
2
+ import { autoUpdate, computePosition, flip, shift, } from '@floating-ui/dom';
3
+ const defaultMiddleware = [
4
+ flip({
5
+ fallbackAxisSideDirection: 'start',
6
+ crossAxis: false,
7
+ }),
8
+ shift(),
9
+ ];
10
+ export const useFloating = ({ placement = 'bottom-start', strategy, middleware = defaultMiddleware, }) => {
11
+ const [[reference, floating], setRefs] = useState([]);
12
+ const [position, setPosition] = useState();
13
+ useEffect(() => {
14
+ if (!reference || !(floating instanceof HTMLElement)) {
15
+ setPosition(undefined);
16
+ return;
17
+ }
18
+ return autoUpdate(reference, floating, () => computePosition(reference, floating, {
19
+ placement,
20
+ strategy,
21
+ middleware,
22
+ }).then(setPosition));
23
+ }, [reference, floating, placement, strategy, middleware]);
24
+ return {
25
+ setReference: useCallback((el) => setRefs(([, _]) => [el, _]), []),
26
+ setFloating: useCallback((el) => setRefs(([_]) => [_, el]), []),
27
+ styles: useMemo(() => position ? { left: `${position.x}px`, top: `${position.y}px` } : {}, [position?.x, position?.y]),
28
+ };
29
+ };
@@ -1,4 +1,3 @@
1
- /// <reference path="../types/position.d.ts" />
2
1
  import type { Placement } from 'position.js';
3
2
  export declare const defaultPlacement: readonly ["bottom-left", "bottom-right", "bottom", "top-left", "top-right", "top"];
4
3
  export { Placement };
package/package.json CHANGED
@@ -1,102 +1,109 @@
1
1
  {
2
- "name": "@neovici/cosmoz-dropdown",
3
- "version": "4.4.2",
4
- "description": "A simple dropdown web component",
5
- "keywords": [
6
- "lit-html",
7
- "web-components"
8
- ],
9
- "homepage": "https://github.com/neovici/cosmoz-dropdown#readme",
10
- "bugs": {
11
- "url": "https://github.com/neovici/cosmoz-dropdown/issues"
12
- },
13
- "repository": {
14
- "type": "git",
15
- "url": "git+https://github.com/neovici/cosmoz-dropdown.git"
16
- },
17
- "license": "Apache-2.0",
18
- "author": "",
19
- "main": "dist/index.js",
20
- "directories": {
21
- "test": "test"
22
- },
23
- "scripts": {
24
- "lint": "tsc && eslint --cache .",
25
- "build": "tsc -p tsconfig.build.json",
26
- "start": "wds",
27
- "test": "wtr --coverage",
28
- "test:watch": "wtr --watch",
29
- "storybook:start": "storybook dev -p 8000",
30
- "storybook:build": "storybook build",
31
- "storybook:deploy": "storybook-to-ghpages",
32
- "storybook:preview": "npm run storybook:build && http-server -d ./storybook-static/",
33
- "prepare": "husky install"
34
- },
35
- "release": {
36
- "plugins": [
37
- "@semantic-release/commit-analyzer",
38
- "@semantic-release/release-notes-generator",
39
- "@semantic-release/changelog",
40
- "@semantic-release/github",
41
- "@semantic-release/npm",
42
- "@semantic-release/git"
43
- ],
44
- "branch": "master",
45
- "preset": "conventionalcommits"
46
- },
47
- "publishConfig": {
48
- "access": "public"
49
- },
50
- "files": [
51
- "dist/",
52
- "types"
53
- ],
54
- "commitlint": {
55
- "extends": [
56
- "@commitlint/config-conventional"
57
- ],
58
- "rules": {
59
- "body-max-line-length": [
60
- 1,
61
- "always",
62
- 100
63
- ]
64
- }
65
- },
66
- "exports": {
67
- ".": "./dist/index.js",
68
- "./use-focus": "./dist/use-focus.js",
69
- "./use-position": "./dist/use-position.js",
70
- "./src/use-focus.js": "./dist/use-focus.js",
71
- "./src/use-position.js": "./dist/use-position.js"
72
- },
73
- "dependencies": {
74
- "@neovici/cosmoz-utils": "^6.8.1",
75
- "@pionjs/pion": "^2.5.2",
76
- "lit-html": "^3.1.2",
77
- "position.js": "^1.1.0"
78
- },
79
- "devDependencies": {
80
- "@commitlint/cli": "^19.2.1",
81
- "@commitlint/config-conventional": "^19.1.0",
82
- "@neovici/cfg": "^1.51.0",
83
- "@open-wc/testing": "^4.0.0",
84
- "@semantic-release/changelog": "^6.0.0",
85
- "@semantic-release/git": "^10.0.0",
86
- "@storybook/addon-essentials": "^7.0.0",
87
- "@storybook/addon-links": "^7.0.0",
88
- "@storybook/storybook-deployer": "^2.8.5",
89
- "@storybook/web-components": "7.6.17",
90
- "@types/mocha": "^10.0.6",
91
- "@web/storybook-builder": "^0.1.9",
92
- "@web/storybook-framework-web-components": "^0.1.1",
93
- "esbuild": "^0.20.2",
94
- "http-server": "^14.1.1",
95
- "husky": "^9.0.11",
96
- "rollup-plugin-esbuild": "^6.1.1",
97
- "semantic-release": "^23.0.7",
98
- "sinon": "^17.0.0",
99
- "storybook": "^7.0.0",
100
- "typescript": "^5.4.3"
101
- }
2
+ "name": "@neovici/cosmoz-dropdown",
3
+ "version": "5.1.0",
4
+ "description": "A simple dropdown web component",
5
+ "keywords": [
6
+ "lit-html",
7
+ "web-components"
8
+ ],
9
+ "homepage": "https://github.com/neovici/cosmoz-dropdown#readme",
10
+ "bugs": {
11
+ "url": "https://github.com/neovici/cosmoz-dropdown/issues"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/neovici/cosmoz-dropdown.git"
16
+ },
17
+ "license": "Apache-2.0",
18
+ "author": "",
19
+ "main": "dist/index.js",
20
+ "directories": {
21
+ "test": "test"
22
+ },
23
+ "scripts": {
24
+ "lint": "tsc && eslint --cache .",
25
+ "build": "tsc -p tsconfig.build.json",
26
+ "start": "wds",
27
+ "test": "wtr --coverage",
28
+ "test:watch": "wtr --watch",
29
+ "storybook:start": "storybook dev -p 8000",
30
+ "storybook:build": "storybook build",
31
+ "storybook:deploy": "storybook-to-ghpages",
32
+ "storybook:preview": "npm run storybook:build && http-server -d ./storybook-static/",
33
+ "prepare": "husky"
34
+ },
35
+ "release": {
36
+ "plugins": [
37
+ "@semantic-release/commit-analyzer",
38
+ "@semantic-release/release-notes-generator",
39
+ "@semantic-release/changelog",
40
+ "@semantic-release/github",
41
+ "@semantic-release/npm",
42
+ "@semantic-release/git"
43
+ ],
44
+ "branch": "master",
45
+ "preset": "conventionalcommits"
46
+ },
47
+ "publishConfig": {
48
+ "access": "public"
49
+ },
50
+ "files": [
51
+ "dist/",
52
+ "types"
53
+ ],
54
+ "commitlint": {
55
+ "extends": [
56
+ "@commitlint/config-conventional"
57
+ ],
58
+ "rules": {
59
+ "body-max-line-length": [
60
+ 1,
61
+ "always",
62
+ 100
63
+ ]
64
+ }
65
+ },
66
+ "exports": {
67
+ ".": "./dist/index.js",
68
+ "./use-focus": "./dist/use-focus.js",
69
+ "./use-position": "./dist/use-position.js",
70
+ "./use-floating": "./dist/use-floating.js",
71
+ "./connectable": "./dist/connectable.js",
72
+ "./src/use-focus.js": "./dist/use-focus.js",
73
+ "./src/use-position.js": "./dist/use-position.js"
74
+ },
75
+ "dependencies": {
76
+ "@floating-ui/dom": "^1.6.12",
77
+ "@neovici/cosmoz-utils": "^6.8.1",
78
+ "@pionjs/pion": "^2.5.2",
79
+ "lit-html": "^3.1.2",
80
+ "position.js": "^1.1.0"
81
+ },
82
+ "devDependencies": {
83
+ "@commitlint/cli": "^19.2.1",
84
+ "@commitlint/config-conventional": "^19.1.0",
85
+ "@neovici/cfg": "^1.51.0",
86
+ "@open-wc/testing": "^4.0.0",
87
+ "@semantic-release/changelog": "^6.0.0",
88
+ "@semantic-release/git": "^10.0.0",
89
+ "@storybook/addon-essentials": "^7.0.0",
90
+ "@storybook/addon-links": "^7.0.0",
91
+ "@storybook/storybook-deployer": "^2.8.5",
92
+ "@storybook/web-components": "7.6.17",
93
+ "@types/mocha": "^10.0.6",
94
+ "@types/node": "^22.10.2",
95
+ "@web/storybook-builder": "^0.1.9",
96
+ "@web/storybook-framework-web-components": "^0.1.1",
97
+ "esbuild": "^0.24.0",
98
+ "http-server": "^14.1.1",
99
+ "husky": "^9.0.11",
100
+ "rollup-plugin-esbuild": "^6.1.1",
101
+ "semantic-release": "^24.0.0",
102
+ "sinon": "^19.0.0",
103
+ "storybook": "^7.0.0",
104
+ "typescript": "^5.4.3"
105
+ },
106
+ "overrides": {
107
+ "conventional-changelog-conventionalcommits": ">= 8.0.0"
108
+ }
102
109
  }