@tugitark/react-widget 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/index.d.ts +3 -0
- package/index.js +30 -2
- package/package.json +6 -4
- package/Widget.tsx +0 -38
package/index.d.ts
ADDED
package/index.js
CHANGED
|
@@ -1,7 +1,35 @@
|
|
|
1
1
|
// Copyright (c) 2026, TugiTark. All rights reserved.
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
|
|
5
|
+
import render from '@tugitark/declarative-widget';
|
|
6
|
+
|
|
7
|
+
function Widget(props) {
|
|
8
|
+
// Is this the first time this component has been rendered ever?
|
|
9
|
+
const [firstTime, setFirstTime] = useState(true);
|
|
10
|
+
|
|
11
|
+
function onNotification(hasNotification: boolean) {
|
|
12
|
+
if (props.jwtFn == null && props.user == null) {
|
|
13
|
+
if (firstTime) {
|
|
14
|
+
// Replicate FAQ internal behaviour at a per-component level.
|
|
15
|
+
props.onNotification?.(hasNotification);
|
|
16
|
+
}
|
|
17
|
+
} else {
|
|
18
|
+
props.onNotification?.(hasNotification);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function onReady() {
|
|
23
|
+
if (firstTime) {
|
|
24
|
+
setFirstTime(false);
|
|
25
|
+
props.onReady?.();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
render({ ...props, onReady, onNotification });
|
|
30
|
+
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
4
33
|
|
|
5
|
-
import Widget from './Widget.tsx';
|
|
6
34
|
export default Widget;
|
|
7
35
|
|
package/package.json
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tugitark/react-widget",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Wraps the tugitark widget in a React component.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"release": "npm publish --access public"
|
|
7
7
|
},
|
|
8
8
|
"files": [
|
|
9
|
-
"
|
|
9
|
+
"index.d.ts",
|
|
10
10
|
"index.js",
|
|
11
11
|
"index.md"
|
|
12
12
|
],
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@tugitark/declarative-widget": "^1.0.
|
|
15
|
-
|
|
14
|
+
"@tugitark/declarative-widget": "^1.0.2"
|
|
15
|
+
},
|
|
16
|
+
"peerDependencies": {
|
|
17
|
+
"react": ">=0.0.0"
|
|
16
18
|
},
|
|
17
19
|
"keywords": [
|
|
18
20
|
"Typescript",
|
package/Widget.tsx
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2026, TugiTark. All rights reserved.
|
|
2
|
-
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { useState } from 'react';
|
|
5
|
-
|
|
6
|
-
import render, { Props } from '@tugitark/declarative-widget';
|
|
7
|
-
|
|
8
|
-
function Widget(props: Props) {
|
|
9
|
-
// Is this the first time this component has been rendered ever?
|
|
10
|
-
const [firstTime, setFirstTime] = useState(true);
|
|
11
|
-
|
|
12
|
-
function onNotification(hasNotification: boolean) {
|
|
13
|
-
if (props.jwtFn == null && props.user == null) {
|
|
14
|
-
if (firstTime) {
|
|
15
|
-
// Replicate FAQ internal behaviour at a per-component level.
|
|
16
|
-
props.onNotification?.(hasNotification);
|
|
17
|
-
}
|
|
18
|
-
} else {
|
|
19
|
-
props.onNotification?.(hasNotification);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function onReady() {
|
|
24
|
-
if (firstTime) {
|
|
25
|
-
setFirstTime(false);
|
|
26
|
-
props.onReady?.();
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
render({ ...props, onReady, onNotification });
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<></>
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export default Widget;
|
|
38
|
-
|