@tugitark/react-widget 1.3.2 → 1.4.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/index.d.ts +4 -3
- package/index.js +1 -37
- package/package.json +12 -5
package/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import type { Props } from '@tugitark/declarative-widget';
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type { Props, TugiWidget, WidgetInitializeOptions, WidgetFreeVersionOptions, TugiWidgetEvents, WidgetFreeSection } from '@tugitark/declarative-widget';
|
|
2
|
+
export type { Props, TugiWidget, WidgetInitializeOptions, WidgetFreeVersionOptions, TugiWidgetEvents, WidgetFreeSection, };
|
|
3
|
+
declare function TugiWidget(props: Props): any;
|
|
4
|
+
export default TugiWidget;
|
package/index.js
CHANGED
|
@@ -1,37 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { useState, useCallback } from 'react';
|
|
4
|
-
|
|
5
|
-
import render from '@tugitark/declarative-widget';
|
|
6
|
-
|
|
7
|
-
function Widget({ onNotification, onReady, ...props }) {
|
|
8
|
-
// Is this the first time this component has been rendered ever?
|
|
9
|
-
const [firstTime, setFirstTime] = useState(true);
|
|
10
|
-
|
|
11
|
-
// Is this the free (FAQ) version of the widget?
|
|
12
|
-
const isFree = props.jwtFn == null && props.user == null;
|
|
13
|
-
|
|
14
|
-
props.onNotification = useCallback((hasNotification) => {
|
|
15
|
-
if (isFree && !firstTime) {
|
|
16
|
-
// Replicate FAQ internal behaviour at a per-component level.
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
onNotification && onNotification(hasNotification);
|
|
20
|
-
}, [onNotification, firstTime, isFree]);
|
|
21
|
-
|
|
22
|
-
props.onReady = useCallback(() => {
|
|
23
|
-
// This is called every time the widget re-mounts internally. However, we only want to
|
|
24
|
-
// notify the caller the first time it re-mounts after this component was created.
|
|
25
|
-
if (firstTime) {
|
|
26
|
-
setFirstTime(false);
|
|
27
|
-
onReady && onReady();
|
|
28
|
-
}
|
|
29
|
-
}, [onReady, firstTime]);
|
|
30
|
-
|
|
31
|
-
render(props);
|
|
32
|
-
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export default Widget;
|
|
37
|
-
|
|
1
|
+
import{useState as s,useCallback as u}from"react";import v from"@tugitark/declarative-widget";function c(i){var n=s(!0),e=n[0],o=n[1],r=i.onNotification,a=i.onReady,t=Object.assign({},i),f=t.jwtFn==null&&t.user==null;return t.onNotification=u(function(l){f&&!e||r&&r(l)},[r,e,f]),t.onReady=u(function(){e&&(o(!1),a&&a())},[a,e,o]),v(t),null}export default c;
|
package/package.json
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tugitark/react-widget",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Wraps the tugitark widget in a React component.",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"
|
|
6
|
+
"build": "npx esbuild index.ts --target=es6 --outfile=index.js && sed -i 's/\\bconst\\b/var/g' index.js && sed -i 's/\\blet\\b/var/g' index.js && npx esbuild index.js --allow-overwrite --minify --target=es5 --outfile=index.js && npx tsc --noErrorTruncation --declaration --emitDeclarationOnly --target es6 --module nodenext --moduleResolution nodenext --outDir . index.ts",
|
|
7
|
+
"release": "npm publish --access public",
|
|
8
|
+
"prerelease": "npm run build"
|
|
7
9
|
},
|
|
8
10
|
"files": [
|
|
9
11
|
"index.d.ts",
|
|
@@ -12,9 +14,14 @@
|
|
|
12
14
|
],
|
|
13
15
|
"dependencies": {
|
|
14
16
|
"@tugitark/declarative-widget": "^1.0.2"
|
|
15
|
-
},
|
|
16
|
-
"peerDependencies": {
|
|
17
|
-
"react": ">=0.0.0"
|
|
17
|
+
},
|
|
18
|
+
"peerDependencies": {
|
|
19
|
+
"react": ">=0.0.0"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"esbuild": "^0.27.2",
|
|
23
|
+
"react": "^19.2.3",
|
|
24
|
+
"typescript": "^5.9.3"
|
|
18
25
|
},
|
|
19
26
|
"keywords": [
|
|
20
27
|
"Typescript",
|