popup-button-plugin 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -2
- package/dist/popup-button.d.ts +12 -2
- package/dist/popup-button.js +19 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,6 +10,18 @@ See the full design write-up and integration steps in
|
|
|
10
10
|
[popup-button-prd.md](./popup-button-prd.md) and
|
|
11
11
|
[popup-button-integration-guide.md](./popup-button-integration-guide.md).
|
|
12
12
|
|
|
13
|
+
## Supported languages / frameworks (tested)
|
|
14
|
+
|
|
15
|
+
| Language / Framework | Supported | Example |
|
|
16
|
+
|---|---|---|
|
|
17
|
+
| Plain HTML | ✅ | `examples/html/` |
|
|
18
|
+
| React | ✅ | `examples/react-app/` |
|
|
19
|
+
| Vue | ✅ | `examples/vue-app/` |
|
|
20
|
+
| Svelte | ✅ | `examples/svelte-app/` |
|
|
21
|
+
| Angular | ✅ | `examples/angular-app/` |
|
|
22
|
+
| Flutter | ❌ not supported | — |
|
|
23
|
+
| React Native | ❌ not supported | — |
|
|
24
|
+
|
|
13
25
|
## Quick start
|
|
14
26
|
|
|
15
27
|
```bash
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { registerButtonContent, getButtonContent, unregisterButtonContent } from './popup-registry';
|
|
2
|
-
export type { PopupContent } from './popup-registry';
|
|
3
|
-
export { PopupButton } from './popup-button';
|
|
1
|
+
export { registerButtonContent, getButtonContent, unregisterButtonContent } from './popup-registry.js';
|
|
2
|
+
export type { PopupContent } from './popup-registry.js';
|
|
3
|
+
export { PopupButton } from './popup-button.js';
|
package/dist/index.js
CHANGED
|
@@ -2,5 +2,6 @@
|
|
|
2
2
|
// 1. Registers the <popup-button> custom element (side effect of
|
|
3
3
|
// the import below — customElements.define runs once).
|
|
4
4
|
// 2. Gives the app the registry functions it needs to call.
|
|
5
|
-
|
|
6
|
-
export {
|
|
5
|
+
// ".js" extensions required here too, same reason as in popup-button.ts.
|
|
6
|
+
export { registerButtonContent, getButtonContent, unregisterButtonContent } from './popup-registry.js';
|
|
7
|
+
export { PopupButton } from './popup-button.js';
|
package/dist/popup-button.d.ts
CHANGED
|
@@ -9,8 +9,18 @@ export declare class PopupButton extends HTMLElement {
|
|
|
9
9
|
connectedCallback(): void;
|
|
10
10
|
/** Reads the `name` HTML attribute, e.g. <popup-button name="save-info">. */
|
|
11
11
|
private get buttonName();
|
|
12
|
-
/**
|
|
13
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Reads the `label` HTML attribute (button text), with a default.
|
|
14
|
+
*
|
|
15
|
+
* NOTE: named `buttonLabel`, NOT `label` — React 19 sets custom
|
|
16
|
+
* element props as real DOM properties (`el.label = '...'`) when
|
|
17
|
+
* the property exists on the element. A getter-only `label` here
|
|
18
|
+
* (no setter) would make that assignment throw
|
|
19
|
+
* "Cannot set property label ... which has only a getter" and
|
|
20
|
+
* crash the whole React render. Avoid naming internal accessors
|
|
21
|
+
* the same as attributes a framework might try to set directly.
|
|
22
|
+
*/
|
|
23
|
+
private get buttonLabel();
|
|
14
24
|
/** Runs when the visible <button> inside our shadow DOM is clicked. */
|
|
15
25
|
private handleButtonClick;
|
|
16
26
|
/** Runs when the popup's close button or backdrop is clicked. */
|
package/dist/popup-button.js
CHANGED
|
@@ -19,7 +19,12 @@
|
|
|
19
19
|
// DOM + CSS, so our button/modal styles can't leak out, and page
|
|
20
20
|
// styles can't accidentally break our popup.
|
|
21
21
|
// =====================================================================
|
|
22
|
-
|
|
22
|
+
// NOTE the explicit ".js" extension: native browser <script type="module">
|
|
23
|
+
// imports require the real file extension (unlike bundlers such as
|
|
24
|
+
// Vite/webpack, which resolve extensionless imports for you). Without
|
|
25
|
+
// this, plain-HTML usage (our main selling point — no build tool
|
|
26
|
+
// needed) breaks with a 404 on this import.
|
|
27
|
+
import { getButtonContent } from './popup-registry.js';
|
|
23
28
|
export class PopupButton extends HTMLElement {
|
|
24
29
|
constructor() {
|
|
25
30
|
super();
|
|
@@ -63,8 +68,18 @@ export class PopupButton extends HTMLElement {
|
|
|
63
68
|
var _a;
|
|
64
69
|
return (_a = this.getAttribute('name')) !== null && _a !== void 0 ? _a : '';
|
|
65
70
|
}
|
|
66
|
-
/**
|
|
67
|
-
|
|
71
|
+
/**
|
|
72
|
+
* Reads the `label` HTML attribute (button text), with a default.
|
|
73
|
+
*
|
|
74
|
+
* NOTE: named `buttonLabel`, NOT `label` — React 19 sets custom
|
|
75
|
+
* element props as real DOM properties (`el.label = '...'`) when
|
|
76
|
+
* the property exists on the element. A getter-only `label` here
|
|
77
|
+
* (no setter) would make that assignment throw
|
|
78
|
+
* "Cannot set property label ... which has only a getter" and
|
|
79
|
+
* crash the whole React render. Avoid naming internal accessors
|
|
80
|
+
* the same as attributes a framework might try to set directly.
|
|
81
|
+
*/
|
|
82
|
+
get buttonLabel() {
|
|
68
83
|
var _a;
|
|
69
84
|
return (_a = this.getAttribute('label')) !== null && _a !== void 0 ? _a : 'Click me';
|
|
70
85
|
}
|
|
@@ -77,7 +92,7 @@ export class PopupButton extends HTMLElement {
|
|
|
77
92
|
const shadow = this.shadowRoot;
|
|
78
93
|
shadow.innerHTML = `
|
|
79
94
|
<style>${STYLES}</style>
|
|
80
|
-
<button class="btn">${escapeHtml(this.
|
|
95
|
+
<button class="btn">${escapeHtml(this.buttonLabel)}</button>
|
|
81
96
|
${this.isOpen ? this.renderPopupMarkup() : ''}
|
|
82
97
|
`;
|
|
83
98
|
// Re-attach listeners every render, since innerHTML = '...' above
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "popup-button-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "A tiny, standalone, framework-free button-with-popup web component: register content by name, and <popup-button name=\"...\"> automatically shows it when clicked.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|