@getspot/spot-widget-react 0.0.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.
@@ -0,0 +1,14 @@
1
+
2
+ > @getspot/spot-widget-react@0.0.0 build /builds/getspot/spot-widget/packages/react
3
+ > vite build
4
+
5
+ The CJS build of Vite's Node API is deprecated. See https://vite.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.
6
+ vite v5.4.18 building for production...
7
+ transforming...
8
+ ✓ 1 modules transformed.
9
+ No name was provided for external module "@getspot/spot-widget" in "output.globals" – guessing "SpotWidget".
10
+ rendering chunks...
11
+ computing gzip size...
12
+ dist/react-spot-widget.umd.js 0.52 kB │ gzip: 0.32 kB
13
+ dist/react-spot-widget.es.js 0.41 kB │ gzip: 0.26 kB
14
+ ✓ built in 179ms
@@ -0,0 +1,19 @@
1
+ import o, { useRef as c, useEffect as n } from "react";
2
+ import f from "@getspot/spot-widget";
3
+ const d = ({ options: t }) => {
4
+ const e = c(null);
5
+ return n(() => {
6
+ if (e.current) {
7
+ const r = new f({
8
+ location: e.current,
9
+ ...t
10
+ });
11
+ return () => {
12
+ r.destroy();
13
+ };
14
+ }
15
+ }, [t]), /* @__PURE__ */ o.createElement("div", { ref: e });
16
+ };
17
+ export {
18
+ d as default
19
+ };
@@ -0,0 +1 @@
1
+ (function(e,t){typeof exports=="object"&&typeof module<"u"?module.exports=t(require("react"),require("@getspot/spot-widget")):typeof define=="function"&&define.amd?define(["react","@getspot/spot-widget"],t):(e=typeof globalThis<"u"?globalThis:e||self,e.ReactSpotWidget=t(e.React,e.SpotWidget))})(this,function(e,t){"use strict";return({options:n})=>{const i=e.useRef(null);return e.useEffect(()=>{if(i.current){const d=new t({location:i.current,...n});return()=>{d.destroy()}}},[n]),e.createElement("div",{ref:i})}});
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "@getspot/spot-widget-react",
3
+ "version": "0.0.0",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "main": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "dependencies": {
10
+ "@getspot/spot-widget": "0.0.0"
11
+ },
12
+ "peerDependencies": {
13
+ "react": "^18.0.0",
14
+ "react-dom": "^18.0.0"
15
+ },
16
+ "devDependencies": {
17
+ "vite": "^5.0.0",
18
+ "@vitejs/plugin-react": "^4.0.0"
19
+ },
20
+ "scripts": {
21
+ "build": "vite build"
22
+ }
23
+ }
@@ -0,0 +1,23 @@
1
+ import React, { useEffect, useRef } from "react";
2
+ import SpotWidget from "@getspot/spot-widget";
3
+
4
+ const ReactSpotWidget = ({ options }) => {
5
+ const widgetRef = useRef(null);
6
+
7
+ useEffect(() => {
8
+ if (widgetRef.current) {
9
+ const widget = new SpotWidget({
10
+ location: widgetRef.current,
11
+ ...options,
12
+ });
13
+
14
+ return () => {
15
+ widget.destroy();
16
+ };
17
+ }
18
+ }, [options]);
19
+
20
+ return <div ref={widgetRef}></div>;
21
+ };
22
+
23
+ export default ReactSpotWidget;
package/vite.config.js ADDED
@@ -0,0 +1,23 @@
1
+ import { defineConfig } from "vite";
2
+ import path from "path";
3
+
4
+ export default defineConfig({
5
+ build: {
6
+ outDir: "dist",
7
+ lib: {
8
+ entry: path.resolve(__dirname, "src/ReactSpotWidget.jsx"),
9
+ name: "ReactSpotWidget",
10
+ fileName: (format) => `react-spot-widget.${format}.js`,
11
+ formats: ["umd", "es"],
12
+ },
13
+ rollupOptions: {
14
+ external: ["react", "react-dom", "@getspot/spot-widget"],
15
+ output: {
16
+ globals: {
17
+ react: "React",
18
+ "react-dom": "ReactDOM",
19
+ },
20
+ },
21
+ },
22
+ },
23
+ });