@enquio/react-popup 1.0.1 → 1.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.
package/README.md CHANGED
@@ -1,96 +1,74 @@
1
- # @enquio/react
1
+ # @enquio/react-popup
2
2
 
3
- React wrapper component for the Enquio popup Web Component. Provides a React-idiomatic interface to integrate Enquio popups into your React applications.
3
+ See the [installation prerequisites](../../docs/installation.md), [support matrix](../../docs/support-matrix.md) and [troubleshooting](../../docs/troubleshooting.md). Registry commands assume a matching published release; local verification uses tarballs and does not establish npm/CDN availability.
4
4
 
5
- ## 📦 Installation
5
+ React wrapper for the Enquio popup Web Component.
6
6
 
7
- ```bash
8
- npm install @enquio/react
7
+ ```sh
8
+ npm install @enquio/react-popup
9
9
  ```
10
10
 
11
- ## ✅ Requirements
11
+ <!-- example:react -->
12
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';
13
+ ```tsx
14
+ import { EnquioPopup } from '@enquio/react-popup';
22
15
 
23
16
  export default function App() {
24
- return (
25
- <div>
26
- <h1>My App</h1>
27
- <EnquioPopup projectId="your-project-id" />
28
- </div>
29
- );
17
+ return <EnquioPopup projectId="YOUR_PROJECT_ID" />;
30
18
  }
31
19
  ```
32
20
 
33
- ## 📖 API
21
+ `projectId` is a required string. Updating it updates the custom element's `project-id` attribute. The wrapper loads the shared runtime on mount; StrictMode and remount share the loader's initialization. Failures are caught without error UI, with diagnostics provided by the [core loader](../core/README.md). After a transport failure, a later mount can retry.
34
22
 
35
- ### `EnquioPopup`
23
+ For consent, mount the component only after the host grants permission and unmount it on revocation. Place it outside transformed/clipped ancestors. Use one installation method per document; see the [compatibility contract](../../../EnquioClient/docs/integrations/embed-compatibility.md).
36
24
 
37
- A React component that renders the Enquio popup Web Component.
25
+ ## Distribution and types
38
26
 
39
- #### Props
27
+ Both ESM and CommonJS entrypoints include TypeScript declarations:
40
28
 
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" />
29
+ ```js
30
+ import { EnquioPopup } from '@enquio/react-popup';
49
31
  ```
50
32
 
51
- ## 🔧 Advanced Usage
33
+ ```js
34
+ const { EnquioPopup } = require('@enquio/react-popup');
35
+ ```
52
36
 
53
- ### Using Refs
37
+ React and React DOM are peer dependencies; the shared `@enquio/popup-core` loader is a dependency. The component does not install a global JSX declaration for the raw custom element or expose a ref prop.
54
38
 
55
- You can access the underlying DOM element using React refs:
39
+ ## Verified compatibility
56
40
 
57
- ```typescript
58
- import { useRef, useEffect } from 'react';
59
- import { EnquioPopup } from '@enquio/react';
41
+ Peer range: React and React DOM `>=17.0.0 <20`, using matching runtime versions.
60
42
 
61
- export default function App() {
62
- const popupRef = useRef<HTMLElement>(null);
43
+ Locally verified on 2026-09-25 with Node 24.21.0, TypeScript 5.9.3 and Chromium, Firefox and WebKit through Playwright 1.62.1:
63
44
 
64
- useEffect(() => {
65
- // Access custom element directly if needed
66
- if (popupRef.current) {
67
- console.log('Popup ready:', popupRef.current);
68
- }
69
- }, []);
45
+ | React / React DOM | @types/react | @types/react-dom |
46
+ | ----------------- | ------------ | ---------------- |
47
+ | 17.0.0 | 17.0.89 | 17.0.26 |
48
+ | 18.0.0 | 18.3.28 | 18.3.7 |
49
+ | 19.0.0 | 19.3.0 | 19.3.0 |
50
+ | 19.3.0 | 19.3.0 | 19.3.0 |
70
51
 
71
- return <enquio-popup ref={popupRef} project-id="your-project-id" />;
72
- }
73
- ```
52
+ This covers representative versions and each major's lower runtime boundary, not every version in the peer range.
74
53
 
75
- ### With TypeScript
54
+ From the workspace root:
76
55
 
77
- The component is fully typed:
56
+ ```sh
57
+ npm ci
58
+ npx playwright install chromium firefox webkit
59
+ npm run test:react-package
60
+ ```
78
61
 
79
- ```typescript
80
- import { EnquioPopup } from '@enquio/react';
81
- import type { ReactElement } from 'react';
62
+ The command builds and packs core and React, installs the tarballs into clean temporary consumers outside the workspace, and tests:
82
63
 
83
- export default function App(): ReactElement {
84
- return <EnquioPopup projectId="your-project-id" />;
85
- }
86
- ```
64
+ - All declared entrypoints, native ESM import and CommonJS require without browser globals.
65
+ - TypeScript Node16, NodeNext and Bundler resolution with `skipLibCheck: false`, JSX usage, and invalid/missing `projectId` rejection.
66
+ - Development StrictMode, project changes, unmount/remount before and after readiness, delayed registration, and transport failure/retry without duplicate runtime initialization or unhandled errors.
87
67
 
88
- ## 🔗 Dependencies
68
+ The runner needs npm registry access and the three installed Playwright engines. It removes its temporary consumers on success and retains them for inspection on failure. Browser tests use a simulated remote runtime with the real packaged loader; they do not verify a published npm release, live CDN or Next.js SSR/hydration. See the [Next.js example and Docker tests](../../docs/ssr-examples.md).
89
69
 
90
- - `@enquio/core`: Core script loader
91
- - `react`: Peer dependency (must be installed separately)
92
- - `react-dom`: Peer dependency (must be installed separately)
70
+ MIT Copyright Enquio Team
93
71
 
94
- ## 📝 License
72
+ ## SSR framework example
95
73
 
96
- MIT © Enquio Team
74
+ The ESM and CommonJS package entries preserve `"use client"`. Import the package directly from a Next App Router server layout. See the [runnable examples](../../docs/ssr-examples.md) and [support matrix](../../docs/support-matrix.md) for exact scope.
@@ -1,4 +1,6 @@
1
+ "use client";
1
2
  "use strict";
3
+ "use client";
2
4
  var __defProp = Object.defineProperty;
3
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -27,12 +29,12 @@ module.exports = __toCommonJS(index_exports);
27
29
  // src/EnquioPopup.tsx
28
30
  var import_react = require("react");
29
31
  var import_popup_core = require("@enquio/popup-core");
30
- var import_jsx_runtime = require("react/jsx-runtime");
31
32
  function EnquioPopup({ projectId }) {
32
33
  (0, import_react.useEffect)(() => {
33
- (0, import_popup_core.loadEnquioScript)().then(() => customElements.whenDefined("enquio-popup")).catch(console.error);
34
+ void (0, import_popup_core.loadEnquioScript)().catch(() => {
35
+ });
34
36
  }, []);
35
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("enquio-popup", { "project-id": projectId });
37
+ return (0, import_react.createElement)("enquio-popup", { "project-id": projectId });
36
38
  }
37
39
  // Annotate the CommonJS export names for ESM import in node:
38
40
  0 && (module.exports = {
package/dist/index.mjs CHANGED
@@ -1,12 +1,15 @@
1
+ "use client";
2
+ "use client";
3
+
1
4
  // src/EnquioPopup.tsx
2
- import { useEffect } from "react";
5
+ import { createElement, useEffect } from "react";
3
6
  import { loadEnquioScript } from "@enquio/popup-core";
4
- import { jsx } from "react/jsx-runtime";
5
7
  function EnquioPopup({ projectId }) {
6
8
  useEffect(() => {
7
- loadEnquioScript().then(() => customElements.whenDefined("enquio-popup")).catch(console.error);
9
+ void loadEnquioScript().catch(() => {
10
+ });
8
11
  }, []);
9
- return /* @__PURE__ */ jsx("enquio-popup", { "project-id": projectId });
12
+ return createElement("enquio-popup", { "project-id": projectId });
10
13
  }
11
14
  export {
12
15
  EnquioPopup
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enquio/react-popup",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "React popup component for Enquio Web Component",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -28,8 +28,8 @@
28
28
  "license": "MIT",
29
29
  "author": "Enquio Team",
30
30
  "peerDependencies": {
31
- "react": ">=17",
32
- "react-dom": ">=17"
31
+ "react": ">=17.0.0 <20",
32
+ "react-dom": ">=17.0.0 <20"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/react": "^18.2.0",
@@ -38,11 +38,23 @@
38
38
  "typescript": "^5.3.0"
39
39
  },
40
40
  "dependencies": {
41
- "@enquio/popup-core": "1.0.0"
41
+ "@enquio/popup-core": "1.1.0"
42
42
  },
43
43
  "scripts": {
44
44
  "build": "tsup",
45
45
  "clean": "rm -rf dist",
46
46
  "prepublishOnly": "npm run build"
47
+ },
48
+ "exports": {
49
+ ".": {
50
+ "import": {
51
+ "types": "./dist/index.d.mts",
52
+ "default": "./dist/index.mjs"
53
+ },
54
+ "require": {
55
+ "types": "./dist/index.d.ts",
56
+ "default": "./dist/index.cjs"
57
+ }
58
+ }
47
59
  }
48
60
  }