@enquio/react-popup 1.0.1
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 +96 -0
- package/dist/index.d.mts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +40 -0
- package/dist/index.mjs +13 -0
- package/package.json +48 -0
package/README.md
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# @enquio/react
|
|
2
|
+
|
|
3
|
+
React wrapper component for the Enquio popup Web Component. Provides a React-idiomatic interface to integrate Enquio popups into your React applications.
|
|
4
|
+
|
|
5
|
+
## 📦 Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @enquio/react
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## ✅ Requirements
|
|
12
|
+
|
|
13
|
+
- **React**: >=17
|
|
14
|
+
- **React-DOM**: >=17
|
|
15
|
+
|
|
16
|
+
## 🚀 Quick Start
|
|
17
|
+
|
|
18
|
+
### Basic Usage
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
import { EnquioPopup } from '@enquio/react';
|
|
22
|
+
|
|
23
|
+
export default function App() {
|
|
24
|
+
return (
|
|
25
|
+
<div>
|
|
26
|
+
<h1>My App</h1>
|
|
27
|
+
<EnquioPopup projectId="your-project-id" />
|
|
28
|
+
</div>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## 📖 API
|
|
34
|
+
|
|
35
|
+
### `EnquioPopup`
|
|
36
|
+
|
|
37
|
+
A React component that renders the Enquio popup Web Component.
|
|
38
|
+
|
|
39
|
+
#### Props
|
|
40
|
+
|
|
41
|
+
| Prop | Type | Required | Description |
|
|
42
|
+
|------|------|----------|-------------|
|
|
43
|
+
| `projectId` | `string` | Yes | Your Enquio project ID |
|
|
44
|
+
|
|
45
|
+
#### Example
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
<EnquioPopup projectId="abc-123-def-456" />
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## 🔧 Advanced Usage
|
|
52
|
+
|
|
53
|
+
### Using Refs
|
|
54
|
+
|
|
55
|
+
You can access the underlying DOM element using React refs:
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
import { useRef, useEffect } from 'react';
|
|
59
|
+
import { EnquioPopup } from '@enquio/react';
|
|
60
|
+
|
|
61
|
+
export default function App() {
|
|
62
|
+
const popupRef = useRef<HTMLElement>(null);
|
|
63
|
+
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
// Access custom element directly if needed
|
|
66
|
+
if (popupRef.current) {
|
|
67
|
+
console.log('Popup ready:', popupRef.current);
|
|
68
|
+
}
|
|
69
|
+
}, []);
|
|
70
|
+
|
|
71
|
+
return <enquio-popup ref={popupRef} project-id="your-project-id" />;
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### With TypeScript
|
|
76
|
+
|
|
77
|
+
The component is fully typed:
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
import { EnquioPopup } from '@enquio/react';
|
|
81
|
+
import type { ReactElement } from 'react';
|
|
82
|
+
|
|
83
|
+
export default function App(): ReactElement {
|
|
84
|
+
return <EnquioPopup projectId="your-project-id" />;
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## 🔗 Dependencies
|
|
89
|
+
|
|
90
|
+
- `@enquio/core`: Core script loader
|
|
91
|
+
- `react`: Peer dependency (must be installed separately)
|
|
92
|
+
- `react-dom`: Peer dependency (must be installed separately)
|
|
93
|
+
|
|
94
|
+
## 📝 License
|
|
95
|
+
|
|
96
|
+
MIT © Enquio Team
|
package/dist/index.d.mts
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
EnquioPopup: () => EnquioPopup
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
|
+
|
|
27
|
+
// src/EnquioPopup.tsx
|
|
28
|
+
var import_react = require("react");
|
|
29
|
+
var import_popup_core = require("@enquio/popup-core");
|
|
30
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
31
|
+
function EnquioPopup({ projectId }) {
|
|
32
|
+
(0, import_react.useEffect)(() => {
|
|
33
|
+
(0, import_popup_core.loadEnquioScript)().then(() => customElements.whenDefined("enquio-popup")).catch(console.error);
|
|
34
|
+
}, []);
|
|
35
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("enquio-popup", { "project-id": projectId });
|
|
36
|
+
}
|
|
37
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
+
0 && (module.exports = {
|
|
39
|
+
EnquioPopup
|
|
40
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/EnquioPopup.tsx
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
import { loadEnquioScript } from "@enquio/popup-core";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
function EnquioPopup({ projectId }) {
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
loadEnquioScript().then(() => customElements.whenDefined("enquio-popup")).catch(console.error);
|
|
8
|
+
}, []);
|
|
9
|
+
return /* @__PURE__ */ jsx("enquio-popup", { "project-id": projectId });
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
EnquioPopup
|
|
13
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@enquio/react-popup",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "React popup component for Enquio Web Component",
|
|
5
|
+
"main": "dist/index.cjs",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/skutam/EnquioWrappers.git",
|
|
15
|
+
"directory": "packages/react"
|
|
16
|
+
},
|
|
17
|
+
"homepage": "https://github.com/skutam/EnquioWrappers#readme",
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/skutam/EnquioWrappers/issues"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"enquio",
|
|
23
|
+
"popup",
|
|
24
|
+
"react",
|
|
25
|
+
"web-component",
|
|
26
|
+
"component"
|
|
27
|
+
],
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"author": "Enquio Team",
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"react": ">=17",
|
|
32
|
+
"react-dom": ">=17"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/react": "^18.2.0",
|
|
36
|
+
"@types/react-dom": "^18.2.0",
|
|
37
|
+
"tsup": "^8.0.0",
|
|
38
|
+
"typescript": "^5.3.0"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@enquio/popup-core": "1.0.0"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsup",
|
|
45
|
+
"clean": "rm -rf dist",
|
|
46
|
+
"prepublishOnly": "npm run build"
|
|
47
|
+
}
|
|
48
|
+
}
|