@malto/react 0.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/LICENSE +21 -0
- package/README.md +15 -0
- package/dist/index.cjs +86 -0
- package/dist/index.d.cts +14 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +48 -0
- package/package.json +69 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Malto.io
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# @malto/react
|
|
2
|
+
|
|
3
|
+
React / Next.js wrapper for the [Malto](https://malto.io) feedback widget.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install @malto/react
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import { MaltoFeedback } from "@malto/react";
|
|
11
|
+
|
|
12
|
+
<MaltoFeedback apiKey="pk_live_xxx" mode="bubble" />
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
For full docs see the [monorepo README](https://github.com/malto-io/malto-sdk).
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var sdk = require('@malto/sdk');
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
|
|
8
|
+
// src/index.tsx
|
|
9
|
+
function MaltoFeedback(props) {
|
|
10
|
+
const containerRef = react.useRef(null);
|
|
11
|
+
const widgetRef = react.useRef(null);
|
|
12
|
+
react.useEffect(() => {
|
|
13
|
+
if (typeof window === "undefined") return;
|
|
14
|
+
const config = {
|
|
15
|
+
...props,
|
|
16
|
+
target: props.mode === "inline" || props.mode === "trigger" ? containerRef.current ?? void 0 : void 0
|
|
17
|
+
};
|
|
18
|
+
const widget = new sdk.MaltoWidget(config);
|
|
19
|
+
widgetRef.current = widget;
|
|
20
|
+
void widget.mount();
|
|
21
|
+
return () => {
|
|
22
|
+
widget.unmount();
|
|
23
|
+
widgetRef.current = null;
|
|
24
|
+
};
|
|
25
|
+
}, [
|
|
26
|
+
props.apiKey,
|
|
27
|
+
props.apiUrl,
|
|
28
|
+
props.mode,
|
|
29
|
+
props.position,
|
|
30
|
+
props.primaryColor,
|
|
31
|
+
props.triggerLabel,
|
|
32
|
+
props.identify?.externalUserId,
|
|
33
|
+
props.identify?.email,
|
|
34
|
+
props.identify?.hash
|
|
35
|
+
]);
|
|
36
|
+
if (props.mode === "inline" || props.mode === "trigger") {
|
|
37
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: containerRef, className: props.className });
|
|
38
|
+
}
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
function useMalto() {
|
|
42
|
+
return {
|
|
43
|
+
open: () => widgetRefSingleton?.open(),
|
|
44
|
+
close: () => widgetRefSingleton?.close()
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
var widgetRefSingleton = null;
|
|
48
|
+
|
|
49
|
+
Object.defineProperty(exports, "MaltoApiError", {
|
|
50
|
+
enumerable: true,
|
|
51
|
+
get: function () { return sdk.MaltoApiError; }
|
|
52
|
+
});
|
|
53
|
+
Object.defineProperty(exports, "MaltoClient", {
|
|
54
|
+
enumerable: true,
|
|
55
|
+
get: function () { return sdk.MaltoClient; }
|
|
56
|
+
});
|
|
57
|
+
Object.defineProperty(exports, "MaltoWidget", {
|
|
58
|
+
enumerable: true,
|
|
59
|
+
get: function () { return sdk.MaltoWidget; }
|
|
60
|
+
});
|
|
61
|
+
Object.defineProperty(exports, "close", {
|
|
62
|
+
enumerable: true,
|
|
63
|
+
get: function () { return sdk.close; }
|
|
64
|
+
});
|
|
65
|
+
Object.defineProperty(exports, "destroy", {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function () { return sdk.destroy; }
|
|
68
|
+
});
|
|
69
|
+
Object.defineProperty(exports, "identify", {
|
|
70
|
+
enumerable: true,
|
|
71
|
+
get: function () { return sdk.identify; }
|
|
72
|
+
});
|
|
73
|
+
Object.defineProperty(exports, "init", {
|
|
74
|
+
enumerable: true,
|
|
75
|
+
get: function () { return sdk.init; }
|
|
76
|
+
});
|
|
77
|
+
Object.defineProperty(exports, "open", {
|
|
78
|
+
enumerable: true,
|
|
79
|
+
get: function () { return sdk.open; }
|
|
80
|
+
});
|
|
81
|
+
Object.defineProperty(exports, "reset", {
|
|
82
|
+
enumerable: true,
|
|
83
|
+
get: function () { return sdk.reset; }
|
|
84
|
+
});
|
|
85
|
+
exports.MaltoFeedback = MaltoFeedback;
|
|
86
|
+
exports.useMalto = useMalto;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { MaltoConfig } from '@malto/sdk';
|
|
3
|
+
export { BoardInfo, CommentItem, FeedbackItem, IdentifyPayload, MaltoApiError, MaltoClient, MaltoConfig, MaltoWidget, ReleaseItem, SdkFeature, SdkMode, SdkPosition, SessionResponse, WidgetSettings, close, destroy, identify, init, open, reset } from '@malto/sdk';
|
|
4
|
+
|
|
5
|
+
type MaltoWidgetProps = Omit<MaltoConfig, "target"> & {
|
|
6
|
+
className?: string;
|
|
7
|
+
};
|
|
8
|
+
declare function MaltoFeedback(props: MaltoWidgetProps): react_jsx_runtime.JSX.Element | null;
|
|
9
|
+
declare function useMalto(): {
|
|
10
|
+
open: () => void | undefined;
|
|
11
|
+
close: () => void | undefined;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { MaltoFeedback, type MaltoWidgetProps, useMalto };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { MaltoConfig } from '@malto/sdk';
|
|
3
|
+
export { BoardInfo, CommentItem, FeedbackItem, IdentifyPayload, MaltoApiError, MaltoClient, MaltoConfig, MaltoWidget, ReleaseItem, SdkFeature, SdkMode, SdkPosition, SessionResponse, WidgetSettings, close, destroy, identify, init, open, reset } from '@malto/sdk';
|
|
4
|
+
|
|
5
|
+
type MaltoWidgetProps = Omit<MaltoConfig, "target"> & {
|
|
6
|
+
className?: string;
|
|
7
|
+
};
|
|
8
|
+
declare function MaltoFeedback(props: MaltoWidgetProps): react_jsx_runtime.JSX.Element | null;
|
|
9
|
+
declare function useMalto(): {
|
|
10
|
+
open: () => void | undefined;
|
|
11
|
+
close: () => void | undefined;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { MaltoFeedback, type MaltoWidgetProps, useMalto };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useRef, useEffect } from 'react';
|
|
3
|
+
import { MaltoWidget } from '@malto/sdk';
|
|
4
|
+
export { MaltoApiError, MaltoClient, MaltoWidget, close, destroy, identify, init, open, reset } from '@malto/sdk';
|
|
5
|
+
import { jsx } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
// src/index.tsx
|
|
8
|
+
function MaltoFeedback(props) {
|
|
9
|
+
const containerRef = useRef(null);
|
|
10
|
+
const widgetRef = useRef(null);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (typeof window === "undefined") return;
|
|
13
|
+
const config = {
|
|
14
|
+
...props,
|
|
15
|
+
target: props.mode === "inline" || props.mode === "trigger" ? containerRef.current ?? void 0 : void 0
|
|
16
|
+
};
|
|
17
|
+
const widget = new MaltoWidget(config);
|
|
18
|
+
widgetRef.current = widget;
|
|
19
|
+
void widget.mount();
|
|
20
|
+
return () => {
|
|
21
|
+
widget.unmount();
|
|
22
|
+
widgetRef.current = null;
|
|
23
|
+
};
|
|
24
|
+
}, [
|
|
25
|
+
props.apiKey,
|
|
26
|
+
props.apiUrl,
|
|
27
|
+
props.mode,
|
|
28
|
+
props.position,
|
|
29
|
+
props.primaryColor,
|
|
30
|
+
props.triggerLabel,
|
|
31
|
+
props.identify?.externalUserId,
|
|
32
|
+
props.identify?.email,
|
|
33
|
+
props.identify?.hash
|
|
34
|
+
]);
|
|
35
|
+
if (props.mode === "inline" || props.mode === "trigger") {
|
|
36
|
+
return /* @__PURE__ */ jsx("div", { ref: containerRef, className: props.className });
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
function useMalto() {
|
|
41
|
+
return {
|
|
42
|
+
open: () => widgetRefSingleton?.open(),
|
|
43
|
+
close: () => widgetRefSingleton?.close()
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
var widgetRefSingleton = null;
|
|
47
|
+
|
|
48
|
+
export { MaltoFeedback, useMalto };
|
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@malto/react",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "React / Next.js wrapper for the Malto.io feedback widget.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://github.com/malto-io/malto-sdk",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/malto-io/malto-sdk.git",
|
|
10
|
+
"directory": "packages/react"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/malto-io/malto-sdk/issues"
|
|
14
|
+
},
|
|
15
|
+
"author": "Malto.io <hello@malto.io>",
|
|
16
|
+
"keywords": [
|
|
17
|
+
"malto",
|
|
18
|
+
"feedback",
|
|
19
|
+
"react",
|
|
20
|
+
"nextjs",
|
|
21
|
+
"widget",
|
|
22
|
+
"sdk"
|
|
23
|
+
],
|
|
24
|
+
"type": "module",
|
|
25
|
+
"main": "./dist/index.cjs",
|
|
26
|
+
"module": "./dist/index.js",
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"import": "./dist/index.js",
|
|
32
|
+
"require": "./dist/index.cjs"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist",
|
|
37
|
+
"README.md",
|
|
38
|
+
"LICENSE"
|
|
39
|
+
],
|
|
40
|
+
"sideEffects": false,
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public",
|
|
43
|
+
"provenance": false
|
|
44
|
+
},
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=18"
|
|
47
|
+
},
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"react": ">=17 <20",
|
|
50
|
+
"react-dom": ">=17 <20"
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"@malto/sdk": "^0.1.0"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@types/react": "^19.0.0",
|
|
57
|
+
"@types/react-dom": "^19.0.0",
|
|
58
|
+
"react": "^19.0.0",
|
|
59
|
+
"react-dom": "^19.0.0",
|
|
60
|
+
"tsup": "^8.5.1",
|
|
61
|
+
"typescript": "^5.7.3"
|
|
62
|
+
},
|
|
63
|
+
"scripts": {
|
|
64
|
+
"build": "tsup",
|
|
65
|
+
"dev": "tsup --watch",
|
|
66
|
+
"typecheck": "tsc --noEmit",
|
|
67
|
+
"clean": "rm -rf dist"
|
|
68
|
+
}
|
|
69
|
+
}
|