@bytexbyte/nxtlinq-ai-agent-sdk 1.6.24 → 1.6.26
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/dist/components/context/ChatBotContext.d.ts.map +1 -1
- package/dist/components/context/ChatBotContext.js +24 -30
- package/dist/components/types/ChatBotTypes.d.ts.map +1 -1
- package/dist/components/ui/BerifyMeModal.d.ts +0 -5
- package/dist/components/ui/BerifyMeModal.d.ts.map +1 -1
- package/dist/components/ui/BerifyMeModal.js +5 -7
- package/dist/components/ui/ChatBotUI.d.ts.map +1 -1
- package/dist/components/ui/ChatBotUI.js +4 -3
- package/dist/components/ui/MessageInput.d.ts.map +1 -1
- package/dist/components/ui/MessageInput.js +3 -2
- package/dist/components/ui/MessageList.d.ts.map +1 -1
- package/dist/components/ui/MessageList.js +2 -1
- package/dist/components/ui/ModelSelector.d.ts.map +1 -1
- package/dist/components/ui/ModelSelector.js +4 -5
- package/dist/components/ui/PermissionForm.d.ts.map +1 -1
- package/dist/components/ui/PermissionForm.js +86 -40
- package/dist/core/utils/walletTextUtils.d.ts +14 -0
- package/dist/core/utils/walletTextUtils.d.ts.map +1 -0
- package/dist/core/utils/walletTextUtils.js +23 -0
- package/package.json +1 -1
- package/umd/nxtlinq-ai-agent.umd.js +171 -165
|
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/reac
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { css } from '@emotion/react';
|
|
5
5
|
import { useChatBot } from '../context/ChatBotContext';
|
|
6
|
+
import * as walletTextUtils from '../../core/utils/walletTextUtils';
|
|
6
7
|
import { actionButton } from './styles/isolatedStyles';
|
|
7
8
|
export const PermissionForm = ({ onClose }) => {
|
|
8
9
|
const { hitAddress, permissions, setPermissions, setIsDisabled, onSave, onConnectWallet, onSignIn, isNeedSignInWithWallet, walletInfo, onVerifyWallet, serviceId, nxtlinqApi, permissionGroup, isAITLoading, isWalletLoading = false, refreshAIT, props } = useChatBot();
|
|
@@ -10,12 +11,29 @@ export const PermissionForm = ({ onClose }) => {
|
|
|
10
11
|
const [isSaving, setIsSaving] = React.useState(false);
|
|
11
12
|
const [tempPermissions, setTempPermissions] = React.useState(permissions);
|
|
12
13
|
const [hasUserInteracted, setHasUserInteracted] = React.useState(false);
|
|
14
|
+
// Check if ALL permission is selected
|
|
15
|
+
const isAllSelected = tempPermissions.includes('ALL');
|
|
13
16
|
// Update temp permissions when permissions change, but only if user hasn't interacted
|
|
14
17
|
React.useEffect(() => {
|
|
15
18
|
if (!hasUserInteracted) {
|
|
16
19
|
setTempPermissions(permissions);
|
|
17
20
|
}
|
|
18
21
|
}, [permissions, hasUserInteracted]);
|
|
22
|
+
// When ALL is selected, automatically select all other permissions
|
|
23
|
+
// This handles cases where ALL is set from initial permissions or when availablePermissions loads
|
|
24
|
+
React.useEffect(() => {
|
|
25
|
+
if (isAllSelected && availablePermissions.length > 0) {
|
|
26
|
+
const allPermissionLabels = availablePermissions.map(p => p.label);
|
|
27
|
+
const currentPermissionSet = new Set(tempPermissions);
|
|
28
|
+
// Check if all permissions are already selected
|
|
29
|
+
const hasAllPermissions = allPermissionLabels.every(label => currentPermissionSet.has(label));
|
|
30
|
+
if (!hasAllPermissions) {
|
|
31
|
+
// Add all permissions (this will include ALL and all others)
|
|
32
|
+
setTempPermissions([...allPermissionLabels].sort());
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
36
|
+
}, [isAllSelected, availablePermissions.length]);
|
|
19
37
|
const fetchAvailablePermissions = async () => {
|
|
20
38
|
if (!serviceId)
|
|
21
39
|
return;
|
|
@@ -143,7 +161,7 @@ export const PermissionForm = ({ onClose }) => {
|
|
|
143
161
|
margin-bottom: 24px !important;
|
|
144
162
|
font-size: 16px !important;
|
|
145
163
|
color: #666 !important;
|
|
146
|
-
`, children:
|
|
164
|
+
`, children: walletTextUtils.getWalletText('Checking wallet status...', serviceId) })] }), _jsx("style", { children: `
|
|
147
165
|
@keyframes spin {
|
|
148
166
|
0% { transform: rotate(0deg); }
|
|
149
167
|
100% { transform: rotate(360deg); }
|
|
@@ -223,7 +241,7 @@ export const PermissionForm = ({ onClose }) => {
|
|
|
223
241
|
margin-bottom: 24px !important;
|
|
224
242
|
font-size: 16px !important;
|
|
225
243
|
color: #666 !important;
|
|
226
|
-
`, children:
|
|
244
|
+
`, children: walletTextUtils.getWalletText('Please connect your wallet first', serviceId) }), _jsx("button", { onClick: onConnectWallet, disabled: Boolean(hitAddress), css: css `
|
|
227
245
|
${actionButton}
|
|
228
246
|
padding: 12px 24px !important;
|
|
229
247
|
background-color: ${Boolean(hitAddress) ? '#28a745' : '#007bff'} !important;
|
|
@@ -238,14 +256,14 @@ export const PermissionForm = ({ onClose }) => {
|
|
|
238
256
|
&:hover:not(:disabled) {
|
|
239
257
|
background-color: #0056b3 !important;
|
|
240
258
|
}
|
|
241
|
-
`, children: Boolean(hitAddress) ? 'Connected' : 'Connect Wallet' })] })) : isNeedSignInWithWallet ? (_jsxs("div", { css: css `
|
|
259
|
+
`, children: Boolean(hitAddress) ? 'Connected' : walletTextUtils.getWalletText('Connect Wallet', serviceId) })] })) : isNeedSignInWithWallet ? (_jsxs("div", { css: css `
|
|
242
260
|
text-align: center !important;
|
|
243
261
|
padding: 32px 0 !important;
|
|
244
262
|
`, children: [_jsxs("div", { css: css `margin-bottom: 24px !important;`, children: [_jsx("h4", { css: css `
|
|
245
263
|
margin-bottom: 12px !important;
|
|
246
264
|
font-size: 16px !important;
|
|
247
265
|
color: #666 !important;
|
|
248
|
-
`, children:
|
|
266
|
+
`, children: walletTextUtils.getWalletText('Connected Wallet', serviceId) }), _jsx("p", { css: css `
|
|
249
267
|
word-break: break-all !important;
|
|
250
268
|
background-color: #f8f9fa !important;
|
|
251
269
|
padding: 12px !important;
|
|
@@ -279,7 +297,7 @@ export const PermissionForm = ({ onClose }) => {
|
|
|
279
297
|
margin-bottom: 12px !important;
|
|
280
298
|
font-size: 16px !important;
|
|
281
299
|
color: #666 !important;
|
|
282
|
-
`, children:
|
|
300
|
+
`, children: walletTextUtils.getWalletText('Connected Wallet', serviceId) }), _jsx("p", { css: css `
|
|
283
301
|
word-break: break-all !important;
|
|
284
302
|
background-color: #f8f9fa !important;
|
|
285
303
|
padding: 12px !important;
|
|
@@ -292,8 +310,8 @@ export const PermissionForm = ({ onClose }) => {
|
|
|
292
310
|
font-size: 16px !important;
|
|
293
311
|
color: #666 !important;
|
|
294
312
|
`, children: isWalletVerified && !isWalletVerifiedWithBerifyme
|
|
295
|
-
? 'Your wallet is verified with custom method, but Berify.me verification is required to continue.'
|
|
296
|
-
: 'Please verify your wallet with Berify.me to continue' }), _jsx("button", { onClick: () => onVerifyWallet('berifyme'), css: css `
|
|
313
|
+
? walletTextUtils.getWalletText('Your wallet is verified with custom method, but Berify.me verification is required to continue.', serviceId)
|
|
314
|
+
: walletTextUtils.getWalletText('Please verify your wallet with Berify.me to continue', serviceId) }), _jsx("button", { onClick: () => onVerifyWallet('berifyme'), css: css `
|
|
297
315
|
${actionButton}
|
|
298
316
|
padding: 12px 24px !important;
|
|
299
317
|
background-color: #007bff !important;
|
|
@@ -303,11 +321,11 @@ export const PermissionForm = ({ onClose }) => {
|
|
|
303
321
|
&:hover {
|
|
304
322
|
background-color: #0056b3 !important;
|
|
305
323
|
}
|
|
306
|
-
`, children:
|
|
324
|
+
`, children: walletTextUtils.getWalletText('Verify your wallet', serviceId) })] })) : (_jsxs(_Fragment, { children: [_jsxs("div", { css: css `margin-bottom: 24px !important;`, children: [_jsx("h4", { css: css `
|
|
307
325
|
margin-bottom: 12px !important;
|
|
308
326
|
font-size: 16px !important;
|
|
309
327
|
color: #666 !important;
|
|
310
|
-
`, children:
|
|
328
|
+
`, children: walletTextUtils.getWalletText('Connected Wallet', serviceId) }), _jsx("p", { css: css `
|
|
311
329
|
word-break: break-all !important;
|
|
312
330
|
background-color: #f8f9fa !important;
|
|
313
331
|
padding: 12px !important;
|
|
@@ -342,37 +360,65 @@ export const PermissionForm = ({ onClose }) => {
|
|
|
342
360
|
overflow-y: auto !important;
|
|
343
361
|
overflow-x: hidden !important;
|
|
344
362
|
min-height: 0 !important;
|
|
345
|
-
`, children: availablePermissions.map((permission) =>
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
363
|
+
`, children: availablePermissions.map((permission) => {
|
|
364
|
+
const isAllPermission = permission.label === 'ALL';
|
|
365
|
+
const isOtherPermissionDisabled = isAllSelected && !isAllPermission;
|
|
366
|
+
const isChecked = isAllSelected && !isAllPermission
|
|
367
|
+
? true
|
|
368
|
+
: tempPermissions.includes(permission.label);
|
|
369
|
+
return (_jsx("div", { css: css `margin-bottom: 12px !important;`, children: _jsxs("label", { css: css `
|
|
370
|
+
display: flex !important;
|
|
371
|
+
align-items: center !important;
|
|
372
|
+
gap: 12px !important;
|
|
373
|
+
cursor: ${isAITLoading || isOtherPermissionDisabled ? 'not-allowed' : 'pointer'} !important;
|
|
374
|
+
padding: 8px !important;
|
|
375
|
+
border-radius: 6px !important;
|
|
376
|
+
transition: background-color 0.2s !important;
|
|
377
|
+
opacity: ${isAITLoading || isOtherPermissionDisabled ? 0.6 : 1} !important;
|
|
378
|
+
|
|
379
|
+
&:hover {
|
|
380
|
+
background-color: ${!isAITLoading && !isOtherPermissionDisabled ? '#e9ecef' : 'transparent'} !important;
|
|
381
|
+
}
|
|
382
|
+
`, children: [_jsx("input", { type: "checkbox", checked: isChecked, onChange: () => {
|
|
383
|
+
if (!isAITLoading) {
|
|
384
|
+
if (isAllPermission) {
|
|
385
|
+
// Handle ALL permission toggle
|
|
386
|
+
if (isAllSelected) {
|
|
387
|
+
// Unchecking ALL - keep all other permissions selected
|
|
388
|
+
// Get all permission labels except ALL
|
|
389
|
+
const allOtherPermissions = availablePermissions
|
|
390
|
+
.map(p => p.label)
|
|
391
|
+
.filter(label => label !== 'ALL');
|
|
392
|
+
setTempPermissions(allOtherPermissions.sort());
|
|
393
|
+
}
|
|
394
|
+
else {
|
|
395
|
+
// Checking ALL - add all permissions
|
|
396
|
+
const allPermissionLabels = availablePermissions.map(p => p.label);
|
|
397
|
+
setTempPermissions(allPermissionLabels.sort());
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
else {
|
|
401
|
+
// Handle other permissions (only if ALL is not selected)
|
|
402
|
+
if (!isAllSelected) {
|
|
403
|
+
const newPermissions = tempPermissions.includes(permission.label)
|
|
404
|
+
? tempPermissions.filter(p => p !== permission.label)
|
|
405
|
+
: [...tempPermissions, permission.label].sort();
|
|
406
|
+
setTempPermissions(newPermissions);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
setHasUserInteracted(true);
|
|
410
|
+
setIsDisabled(false);
|
|
411
|
+
}
|
|
412
|
+
}, disabled: isAITLoading || isOtherPermissionDisabled, css: css `
|
|
413
|
+
margin: 0 !important;
|
|
414
|
+
width: 18px !important;
|
|
415
|
+
height: 18px !important;
|
|
416
|
+
cursor: ${isAITLoading || isOtherPermissionDisabled ? 'not-allowed' : 'pointer'} !important;
|
|
417
|
+
` }), _jsx("span", { css: css `
|
|
418
|
+
font-size: 14px !important;
|
|
419
|
+
color: ${isOtherPermissionDisabled ? '#999' : '#333'} !important;
|
|
420
|
+
`, children: permission.label })] }) }, permission.id));
|
|
421
|
+
}) }))] }), _jsxs("div", { css: css `
|
|
376
422
|
display: flex !important;
|
|
377
423
|
justify-content: flex-end !important;
|
|
378
424
|
gap: 12px !important;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adilas Service ID constant
|
|
3
|
+
*/
|
|
4
|
+
export declare const ADILAS_SERVICE_ID = "e48fc2b9-a7d1-49e3-85cb-9d621a0bf774";
|
|
5
|
+
/**
|
|
6
|
+
* Check if the given serviceId is the Adilas service
|
|
7
|
+
*/
|
|
8
|
+
export declare const isAdilasService: (serviceId: string | undefined | null) => boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Replace "wallet" with "account" in text when serviceId is Adilas service
|
|
11
|
+
* Preserves the original case of the word
|
|
12
|
+
*/
|
|
13
|
+
export declare const getWalletText: (defaultText: string, serviceId: string | undefined | null) => string;
|
|
14
|
+
//# sourceMappingURL=walletTextUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walletTextUtils.d.ts","sourceRoot":"","sources":["../../../src/core/utils/walletTextUtils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,iBAAiB,yCAAyC,CAAC;AAExE;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,WAAW,MAAM,GAAG,SAAS,GAAG,IAAI,KAAG,OAEtE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,aAAa,GAAI,aAAa,MAAM,EAAE,WAAW,MAAM,GAAG,SAAS,GAAG,IAAI,KAAG,MAQzF,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adilas Service ID constant
|
|
3
|
+
*/
|
|
4
|
+
export const ADILAS_SERVICE_ID = 'e48fc2b9-a7d1-49e3-85cb-9d621a0bf774';
|
|
5
|
+
/**
|
|
6
|
+
* Check if the given serviceId is the Adilas service
|
|
7
|
+
*/
|
|
8
|
+
export const isAdilasService = (serviceId) => {
|
|
9
|
+
return serviceId ? serviceId.trim() === ADILAS_SERVICE_ID : false;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Replace "wallet" with "account" in text when serviceId is Adilas service
|
|
13
|
+
* Preserves the original case of the word
|
|
14
|
+
*/
|
|
15
|
+
export const getWalletText = (defaultText, serviceId) => {
|
|
16
|
+
if (!isAdilasService(serviceId))
|
|
17
|
+
return defaultText;
|
|
18
|
+
// Replace wallet with account, preserving case
|
|
19
|
+
return defaultText.replace(/\bwallet\b/gi, (match) => {
|
|
20
|
+
// Preserve original case: 'Wallet' -> 'Account', 'wallet' -> 'account'
|
|
21
|
+
return match.charAt(0) === 'W' ? 'Account' : 'account';
|
|
22
|
+
});
|
|
23
|
+
};
|
package/package.json
CHANGED