@c2n/overlay 0.0.6

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/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@c2n/overlay",
3
+ "version": "0.0.6",
4
+ "type": "module",
5
+ "main": "dist/overlay.js",
6
+ "exports": {
7
+ ".": {
8
+ "default": "./dist/overlay.js",
9
+ "types": "./types/src/overlay.d.ts"
10
+ },
11
+ "./custom-elements.json": "./custom-elements.json"
12
+ },
13
+ "files": [
14
+ "dist",
15
+ "types"
16
+ ],
17
+ "keywords": [
18
+ "overlay",
19
+ "web component",
20
+ "lit"
21
+ ],
22
+ "author": "code2nguyen@gmail.com",
23
+ "publishConfig": {
24
+ "registry": "https://registry.npmjs.org",
25
+ "access": "public"
26
+ },
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "https://github.com/code2nguyen/web-components.git"
30
+ },
31
+ "scripts": {
32
+ "dev": "vite",
33
+ "build": "wireit",
34
+ "type-check": "wireit"
35
+ },
36
+ "wireit": {
37
+ "type-check": {
38
+ "dependencies": [
39
+ "../../core:build"
40
+ ],
41
+ "command": "tsc -p tsconfig.lib.json --composite false"
42
+ },
43
+ "build": {
44
+ "dependencies": [
45
+ "type-check"
46
+ ],
47
+ "command": "vite build"
48
+ }
49
+ },
50
+ "dependencies": {
51
+ "@c2n/core": "0.0.6",
52
+ "@floating-ui/dom": "1.8.0",
53
+ "lit": "3.3.3"
54
+ },
55
+ "devDependencies": {
56
+ "@c2n/config": "*"
57
+ },
58
+ "customElements": "custom-elements.json",
59
+ "gitHead": "2921054bc75299da66dad11c1e374246ff88a51e"
60
+ }
@@ -0,0 +1,62 @@
1
+ import { LitElement, type PropertyValues } from 'lit';
2
+ import { type Placement } from '@floating-ui/dom';
3
+ export type { Placement };
4
+ /**
5
+ * Anchored popup built on the browser Popover API: the element sits in the top layer, opens and light-dismisses
6
+ * natively (Escape, click outside) and is positioned next to its anchor with floating-ui. The anchor is found in
7
+ * this order: the `anchor` property (an element), the `anchor` attribute (an element id in the same tree), or the
8
+ * element whose `popovertarget` points at this overlay's `id`. The overlay only positions itself; the content brings
9
+ * its own surface (background, border, shadow), so it fits menus, pickers and cards alike.
10
+ *
11
+ * The preferred `placement` may flip or shift to stay in the viewport; the placement actually used is exposed as the
12
+ * `current-placement` attribute, and the space available on that side as `--c2-overlay--available-height` /
13
+ * `--c2-overlay--available-width` custom properties (use them to cap a scrolling list).
14
+ *
15
+ * @tag c2-overlay
16
+ *
17
+ * @slot - Content of the overlay.
18
+ *
19
+ * @event {ToggleEvent} toggle - Native popover toggle: `newState` is `open` or `closed`.
20
+ * @event {ToggleEvent} beforetoggle - Native, cancelable, fired before the state changes.
21
+ *
22
+ * @cssproperty {pixel} [--c2-overlay--offset-y=8px] - Distance between the anchor and the overlay along the main axis.
23
+ * @cssproperty {pixel} [--c2-overlay--offset-x=0px] - Shift along the cross axis (towards the end for `*-start`, the start for `*-end`).
24
+ * @cssproperty {pixel} [--c2-overlay--viewport-padding=8px] - Minimum gap kept between the overlay and the viewport edges.
25
+ * @cssproperty {time} [--c2-overlay--transition-duration=150ms] - Open/close fade and scale; `0ms` disables it.
26
+ * @cssproperty {color} [--c2-overlay__backdrop--background=transparent] - The `::backdrop` behind the popover.
27
+ */
28
+ export declare class Overlay extends LitElement {
29
+ static styles: import("lit").CSSResult;
30
+ /** Open state, kept in sync with the native popover (setting it shows or hides the popover). */
31
+ open: boolean;
32
+ /** Preferred placement (floating-ui names). The one in use is reflected as `current-placement`. */
33
+ placement: Placement;
34
+ /** Do not flip across the cross axis when there is no room (only along the main axis). */
35
+ disabledCrossAxis: boolean;
36
+ /** Make the overlay exactly as wide as the anchor. */
37
+ fitTarget: boolean;
38
+ /** By default the overlay is at least as wide as its anchor; set this to size it by its content only. */
39
+ freeWidth: boolean;
40
+ /** Anchor element, or (attribute) the id of the anchor. Falls back to the element whose `popovertarget` is this overlay's id. */
41
+ anchor: string | HTMLElement | undefined;
42
+ private cleanupPosition;
43
+ constructor();
44
+ connectedCallback(): void;
45
+ disconnectedCallback(): void;
46
+ /** The resolved anchor element, if any. */
47
+ get anchorElement(): HTMLElement | null;
48
+ private handleBeforeToggle;
49
+ private handleToggle;
50
+ private readPixels;
51
+ private startPositioning;
52
+ private stopPositioning;
53
+ private updatePosition;
54
+ updated(changed: PropertyValues<this>): void;
55
+ render(): import("lit-html").TemplateResult<1>;
56
+ }
57
+ declare global {
58
+ interface HTMLElementTagNameMap {
59
+ 'c2-overlay': Overlay;
60
+ }
61
+ }
62
+ //# sourceMappingURL=overlay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../src/overlay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAmB,KAAK,cAAc,EAAE,MAAM,KAAK,CAAA;AAGtE,OAAO,EAA0D,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAGzG,YAAY,EAAE,SAAS,EAAE,CAAA;AAEzB;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBACa,OAAQ,SAAQ,UAAU;IACrC,OAAgB,MAAM,0BAAoB;IAE1C,gGAAgG;IACpD,IAAI,UAAQ;IAExD,mGAAmG;IACtE,SAAS,EAAE,SAAS,CAAiB;IAElE,0FAA0F;IACZ,iBAAiB,UAAQ;IAEvG,sDAAsD;IACA,SAAS,UAAQ;IAEvE,yGAAyG;IACnD,SAAS,UAAQ;IAEvE,iIAAiI;IACrH,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAAY;IAEhE,OAAO,CAAC,eAAe,CAA4B;;IAU1C,iBAAiB;IAKjB,oBAAoB;IAK7B,2CAA2C;IAC3C,IAAI,aAAa,IAAI,WAAW,GAAG,IAAI,CAetC;IAED,OAAO,CAAC,kBAAkB,CAGzB;IAED,OAAO,CAAC,YAAY,CAEnB;IAED,OAAO,CAAC,UAAU;IAKlB,OAAO,CAAC,gBAAgB;IAOxB,OAAO,CAAC,eAAe;YAKT,cAAc;IA8BnB,OAAO,CAAC,OAAO,EAAE,cAAc,CAAC,IAAI,CAAC;IAarC,MAAM;CAGhB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,YAAY,EAAE,OAAO,CAAA;KACtB;CACF"}