@asgard-js/react 0.0.31 → 0.0.32-canary.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/.babelrc +12 -0
- package/README.md +10 -12
- package/dist/components/templates/button-template/card.d.ts.map +1 -1
- package/dist/context/asgard-template-context.d.ts.map +1 -1
- package/dist/index.js +46355 -9679
- package/eslint.config.cjs +12 -0
- package/package.json +9 -7
- package/src/components/chatbot/chatbot-body/chatbot-body.module.scss +13 -0
- package/src/components/chatbot/chatbot-body/chatbot-body.tsx +45 -0
- package/src/components/chatbot/chatbot-body/conversation-message-renderer.tsx +55 -0
- package/src/components/chatbot/chatbot-body/index.ts +1 -0
- package/src/components/chatbot/chatbot-container/chatbot-container.module.scss +41 -0
- package/src/components/chatbot/chatbot-container/chatbot-container.tsx +49 -0
- package/src/components/chatbot/chatbot-container/chatbot-full-screen-container.tsx +54 -0
- package/src/components/chatbot/chatbot-footer/chatbot-footer.module.scss +67 -0
- package/src/components/chatbot/chatbot-footer/chatbot-footer.tsx +140 -0
- package/src/components/chatbot/chatbot-footer/index.ts +1 -0
- package/src/components/chatbot/chatbot-footer/speech-input-button.tsx +132 -0
- package/src/components/chatbot/chatbot-header/chatbot-header.module.scss +48 -0
- package/src/components/chatbot/chatbot-header/chatbot-header.tsx +98 -0
- package/src/components/chatbot/chatbot-header/index.ts +1 -0
- package/src/components/chatbot/chatbot.spec.tsx +8 -0
- package/src/components/chatbot/chatbot.tsx +118 -0
- package/src/components/chatbot/profile-icon.tsx +26 -0
- package/src/components/index.ts +2 -0
- package/src/components/templates/avatar/avatar.module.scss +6 -0
- package/src/components/templates/avatar/avatar.tsx +28 -0
- package/src/components/templates/avatar/index.ts +1 -0
- package/src/components/templates/button-template/button-template.module.scss +0 -0
- package/src/components/templates/button-template/button-template.tsx +45 -0
- package/src/components/templates/button-template/card.module.scss +58 -0
- package/src/components/templates/button-template/card.spec.tsx +213 -0
- package/src/components/templates/button-template/card.tsx +123 -0
- package/src/components/templates/button-template/index.ts +1 -0
- package/src/components/templates/carousel-template/carousel-template.module.scss +15 -0
- package/src/components/templates/carousel-template/carousel-template.tsx +48 -0
- package/src/components/templates/carousel-template/index.ts +1 -0
- package/src/components/templates/chart-template/chart-template.module.scss +52 -0
- package/src/components/templates/chart-template/chart-template.tsx +76 -0
- package/src/components/templates/chart-template/index.ts +1 -0
- package/src/components/templates/hint-template/hint-template.module.scss +39 -0
- package/src/components/templates/hint-template/hint-template.tsx +71 -0
- package/src/components/templates/hint-template/index.ts +1 -0
- package/src/components/templates/image-template/image-template.module.scss +67 -0
- package/src/components/templates/image-template/image-template.tsx +58 -0
- package/src/components/templates/image-template/index.ts +1 -0
- package/src/components/templates/index.ts +10 -0
- package/src/components/templates/quick-replies/index.ts +1 -0
- package/src/components/templates/quick-replies/quick-replies.module.scss +16 -0
- package/src/components/templates/quick-replies/quick-replies.tsx +44 -0
- package/src/components/templates/template-box/index.ts +2 -0
- package/src/components/templates/template-box/template-box-content.module.scss +13 -0
- package/src/components/templates/template-box/template-box-content.tsx +30 -0
- package/src/components/templates/template-box/template-box.module.scss +19 -0
- package/src/components/templates/template-box/template-box.tsx +48 -0
- package/src/components/templates/text-template/bot-typing-box.tsx +81 -0
- package/src/components/templates/text-template/bot-typing-placeholder.tsx +28 -0
- package/src/components/templates/text-template/index.ts +3 -0
- package/src/components/templates/text-template/text-template.module.scss +131 -0
- package/src/components/templates/text-template/text-template.tsx +90 -0
- package/src/components/templates/text-template/use-react-markdown-renderer.spec.tsx +758 -0
- package/src/components/templates/text-template/use-react-markdown-renderer.tsx +264 -0
- package/src/components/templates/time/index.ts +1 -0
- package/src/components/templates/time/time.module.scss +6 -0
- package/src/components/templates/time/time.tsx +34 -0
- package/src/context/asgard-app-initialization-context.tsx +154 -0
- package/src/context/asgard-service-context.tsx +139 -0
- package/src/context/asgard-template-context.tsx +83 -0
- package/src/context/asgard-theme-context.tsx +401 -0
- package/src/context/index.ts +4 -0
- package/src/hooks/index.ts +11 -0
- package/src/hooks/use-asgard-service-client.ts +68 -0
- package/src/hooks/use-channel.ts +154 -0
- package/src/hooks/use-debounce.ts +18 -0
- package/src/hooks/use-deep-compare-memo.ts +19 -0
- package/src/hooks/use-is-on-screen-keyboard-open.ts +43 -0
- package/src/hooks/use-on-screen-keyboard-scroll-fix.ts +15 -0
- package/src/hooks/use-prevent-over-scrolling.ts +77 -0
- package/src/hooks/use-resize-observer.tsx +27 -0
- package/src/hooks/use-update-vh.ts +30 -0
- package/src/hooks/use-viewport-size.ts +51 -0
- package/src/icons/add_a_photo.svg +3 -0
- package/src/icons/bot.svg +14 -0
- package/src/icons/close.svg +3 -0
- package/src/icons/distance.svg +3 -0
- package/src/icons/mic.svg +3 -0
- package/src/icons/photo_library.svg +3 -0
- package/src/icons/profile.svg +28 -0
- package/src/icons/refresh.svg +3 -0
- package/src/icons/send.svg +3 -0
- package/src/icons/stop.svg +22 -0
- package/src/icons/volume_up.svg +3 -0
- package/src/index.ts +4 -0
- package/src/models/bot-provider.ts +108 -0
- package/src/styles/_index.scss +1 -0
- package/src/styles/_styles.scss +11 -0
- package/src/styles/colors/_colors.scss +10 -0
- package/src/styles/colors/_index.scss +1 -0
- package/src/styles/colors/_variables.scss +72 -0
- package/src/styles/palette/_index.scss +1 -0
- package/src/styles/palette/_palette.scss +42 -0
- package/src/styles/palette/_variables.scss +40 -0
- package/src/styles/radius/_index.scss +1 -0
- package/src/styles/radius/_radius.scss +8 -0
- package/src/styles/radius/_variables.scss +12 -0
- package/src/styles/spacing/_index.scss +1 -0
- package/src/styles/spacing/_spacing.scss +8 -0
- package/src/styles/spacing/_variables.scss +13 -0
- package/src/styles/utils/_index.scss +1 -0
- package/src/styles/utils/_map.scss +22 -0
- package/src/test-setup.ts +1 -0
- package/src/utils/deep-merge.ts +23 -0
- package/src/utils/extractors.ts +20 -0
- package/src/utils/format-time.ts +8 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/is.ts +72 -0
- package/src/utils/selectors.ts +7 -0
- package/src/utils/uri-validation.spec.ts +208 -0
- package/src/utils/uri-validation.ts +103 -0
- package/tsconfig.json +16 -0
- package/tsconfig.lib.json +62 -0
- package/tsconfig.spec.json +36 -0
- package/vite.config.ts +63 -0
package/.babelrc
ADDED
package/README.md
CHANGED
|
@@ -94,6 +94,7 @@ export default App;
|
|
|
94
94
|
**Important**: The `endpoint` configuration option is deprecated. Use `botProviderEndpoint` instead for simplified configuration.
|
|
95
95
|
|
|
96
96
|
### Before (Deprecated)
|
|
97
|
+
|
|
97
98
|
```javascript
|
|
98
99
|
config: {
|
|
99
100
|
apiKey: 'your-api-key',
|
|
@@ -103,15 +104,17 @@ config: {
|
|
|
103
104
|
```
|
|
104
105
|
|
|
105
106
|
### After (Recommended)
|
|
107
|
+
|
|
106
108
|
```javascript
|
|
107
109
|
config: {
|
|
108
|
-
apiKey: 'your-api-key',
|
|
110
|
+
apiKey: 'your-api-key',
|
|
109
111
|
botProviderEndpoint: 'https://api.asgard-ai.com/ns/{namespace}/bot-provider/{botProviderId}',
|
|
110
112
|
// SSE endpoint is automatically derived as: botProviderEndpoint + '/message/sse'
|
|
111
113
|
}
|
|
112
114
|
```
|
|
113
115
|
|
|
114
116
|
**Benefits:**
|
|
117
|
+
|
|
115
118
|
- Simplified configuration with single endpoint
|
|
116
119
|
- Reduced chance of configuration errors
|
|
117
120
|
- Automatic endpoint derivation
|
|
@@ -229,13 +232,13 @@ export interface AsgardThemeContextValue {
|
|
|
229
232
|
HintMessageTemplate: Partial<{ style: CSSProperties }>;
|
|
230
233
|
ImageMessageTemplate: Partial<{ style: CSSProperties }>;
|
|
231
234
|
ChartMessageTemplate: Partial<{ style: CSSProperties }>;
|
|
232
|
-
ButtonMessageTemplate: Partial<{
|
|
235
|
+
ButtonMessageTemplate: Partial<{
|
|
233
236
|
style: CSSProperties;
|
|
234
237
|
button?: {
|
|
235
238
|
style: CSSProperties;
|
|
236
239
|
};
|
|
237
240
|
}>;
|
|
238
|
-
CarouselMessageTemplate: Partial<{
|
|
241
|
+
CarouselMessageTemplate: Partial<{
|
|
239
242
|
style: CSSProperties;
|
|
240
243
|
card: {
|
|
241
244
|
style: CSSProperties;
|
|
@@ -396,29 +399,22 @@ The React package includes comprehensive tests using Vitest and React Testing Li
|
|
|
396
399
|
|
|
397
400
|
```sh
|
|
398
401
|
# Run tests once
|
|
399
|
-
npm test
|
|
400
|
-
# or
|
|
401
402
|
yarn test:react
|
|
402
403
|
|
|
403
404
|
# Run tests in watch mode
|
|
404
|
-
npm run test:watch
|
|
405
|
-
# or
|
|
406
405
|
yarn test:react:watch
|
|
407
406
|
|
|
408
407
|
# Run tests with UI
|
|
409
|
-
npm run test:ui
|
|
410
|
-
# or
|
|
411
408
|
yarn test:react:ui
|
|
412
409
|
|
|
413
410
|
# Run tests with coverage
|
|
414
|
-
npm run test:coverage
|
|
415
|
-
# or
|
|
416
411
|
yarn test:react:coverage
|
|
417
412
|
```
|
|
418
413
|
|
|
419
414
|
### Test Structure
|
|
420
415
|
|
|
421
416
|
Tests are located alongside source files with `.spec.tsx` extensions:
|
|
417
|
+
|
|
422
418
|
- `src/components/chatbot/chatbot.spec.tsx` - React component tests
|
|
423
419
|
- Test environment: jsdom with React Testing Library
|
|
424
420
|
- Setup file: `src/test-setup.ts` (includes jest-dom)
|
|
@@ -427,6 +423,7 @@ Tests are located alongside source files with `.spec.tsx` extensions:
|
|
|
427
423
|
### Writing Tests
|
|
428
424
|
|
|
429
425
|
The package uses Vitest for testing with the following setup:
|
|
426
|
+
|
|
430
427
|
- TypeScript support
|
|
431
428
|
- jsdom environment for DOM APIs
|
|
432
429
|
- React Testing Library for component testing
|
|
@@ -435,6 +432,7 @@ The package uses Vitest for testing with the following setup:
|
|
|
435
432
|
- Coverage reporting with v8 provider
|
|
436
433
|
|
|
437
434
|
Example test structure:
|
|
435
|
+
|
|
438
436
|
```javascript
|
|
439
437
|
import { describe, it, expect } from 'vitest';
|
|
440
438
|
import { render } from '@testing-library/react';
|
|
@@ -494,7 +492,7 @@ yarn watch:react
|
|
|
494
492
|
yarn serve:react-demo
|
|
495
493
|
```
|
|
496
494
|
|
|
497
|
-
Setup your npm
|
|
495
|
+
Setup your npm registry token for yarn publishing:
|
|
498
496
|
|
|
499
497
|
```sh
|
|
500
498
|
cd ~/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card.d.ts","sourceRoot":"","sources":["../../../../src/components/templates/button-template/card.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EAGT,aAAa,EACd,MAAM,OAAO,CAAC;AAEf,OAAO,EAEL,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,iBAAiB,CAAC;AAMzB,UAAU,SAAS;IACjB,QAAQ,EAAE,qBAAqB,GAAG,uBAAuB,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;IAC7E,WAAW,CAAC,EAAE;QACZ,KAAK,CAAC,EAAE,aAAa,CAAC;QACtB,MAAM,CAAC,EAAE;YACP,KAAK,CAAC,EAAE,aAAa,CAAC;SACvB,CAAC;KACH,CAAC;CACH;AAED,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"card.d.ts","sourceRoot":"","sources":["../../../../src/components/templates/button-template/card.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EAGT,aAAa,EACd,MAAM,OAAO,CAAC;AAEf,OAAO,EAEL,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,iBAAiB,CAAC;AAMzB,UAAU,SAAS;IACjB,QAAQ,EAAE,qBAAqB,GAAG,uBAAuB,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;IAC7E,WAAW,CAAC,EAAE;QACZ,KAAK,CAAC,EAAE,aAAa,CAAC;QACtB,MAAM,CAAC,EAAE;YACP,KAAK,CAAC,EAAE,aAAa,CAAC;SACvB,CAAC;KACH,CAAC;CACH;AAED,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,CA8FhD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asgard-template-context.d.ts","sourceRoot":"","sources":["../../src/context/asgard-template-context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EACjB,SAAS,EAGV,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,wBAAwB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAE5E,MAAM,WAAW,0BAA0B;IACzC,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,wBAAwB,KAAK,IAAI,CAAC;IAC3D,oBAAoB,CAAC,EAAE,CAAC,OAAO,EAAE,wBAAwB,KAAK,SAAS,CAAC;IACxE,kBAAkB,CAAC,EAAE,CACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,EACE,GAAG,GACJ,EAAE;QACD,GAAG,EAAE;YACH,WAAW,EAAE,CACX,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC,KAC/C,IAAI,CAAC;SACX,CAAC;KACH,KACE,IAAI,CAAC;IACV,iBAAiB,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;CAC7D;AAED,eAAO,MAAM,qBAAqB,qDAKhC,CAAC;AAEH,UAAU,kCAAmC,SAAQ,iBAAiB;IACpE,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,wBAAwB,KAAK,IAAI,CAAC;IAC3D,oBAAoB,CAAC,EAAE,CAAC,OAAO,EAAE,wBAAwB,KAAK,SAAS,CAAC;IACxE,kBAAkB,CAAC,EAAE,CACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,EACE,GAAG,GACJ,EAAE;QACD,GAAG,EAAE;YACH,WAAW,EAAE,CACX,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC,KAC/C,IAAI,CAAC;SACX,CAAC;KACH,KACE,IAAI,CAAC;IACV,iBAAiB,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;CAC7D;AAED,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,kCAAkC,GACxC,SAAS,
|
|
1
|
+
{"version":3,"file":"asgard-template-context.d.ts","sourceRoot":"","sources":["../../src/context/asgard-template-context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EACjB,SAAS,EAGV,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,wBAAwB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAE5E,MAAM,WAAW,0BAA0B;IACzC,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,wBAAwB,KAAK,IAAI,CAAC;IAC3D,oBAAoB,CAAC,EAAE,CAAC,OAAO,EAAE,wBAAwB,KAAK,SAAS,CAAC;IACxE,kBAAkB,CAAC,EAAE,CACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,EACE,GAAG,GACJ,EAAE;QACD,GAAG,EAAE;YACH,WAAW,EAAE,CACX,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC,KAC/C,IAAI,CAAC;SACX,CAAC;KACH,KACE,IAAI,CAAC;IACV,iBAAiB,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;CAC7D;AAED,eAAO,MAAM,qBAAqB,qDAKhC,CAAC;AAEH,UAAU,kCAAmC,SAAQ,iBAAiB;IACpE,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,wBAAwB,KAAK,IAAI,CAAC;IAC3D,oBAAoB,CAAC,EAAE,CAAC,OAAO,EAAE,wBAAwB,KAAK,SAAS,CAAC;IACxE,kBAAkB,CAAC,EAAE,CACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,EACE,GAAG,GACJ,EAAE;QACD,GAAG,EAAE;YACH,WAAW,EAAE,CACX,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC,KAC/C,IAAI,CAAC;SACX,CAAC;KACH,KACE,IAAI,CAAC;IACV,iBAAiB,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;CAC7D;AAED,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,kCAAkC,GACxC,SAAS,CAwBX;AAED,wBAAgB,wBAAwB,IAAI,0BAA0B,CAErE"}
|