@asgard-js/react 0.0.1 → 0.0.3-8.canary-1
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 +523 -4
- package/dist/components/chatbot/chatbot-body/chatbot-body.d.ts.map +1 -0
- package/dist/components/{conversation-message-renderer → chatbot/chatbot-body}/conversation-message-renderer.d.ts +2 -2
- package/dist/components/chatbot/chatbot-body/conversation-message-renderer.d.ts.map +1 -0
- package/dist/components/chatbot/chatbot-body/index.d.ts +2 -0
- package/dist/components/chatbot/chatbot-body/index.d.ts.map +1 -0
- package/dist/components/chatbot/chatbot-container/chatbot-container.d.ts +10 -0
- package/dist/components/chatbot/chatbot-container/chatbot-container.d.ts.map +1 -0
- package/dist/components/chatbot/chatbot-container/chatbot-full-screen-container.d.ts +4 -0
- package/dist/components/chatbot/chatbot-container/chatbot-full-screen-container.d.ts.map +1 -0
- package/dist/components/chatbot/chatbot-footer/chatbot-footer.d.ts.map +1 -0
- package/dist/components/chatbot/chatbot-footer/index.d.ts +2 -0
- package/dist/components/chatbot/chatbot-footer/index.d.ts.map +1 -0
- package/dist/components/chatbot/chatbot-footer/speech-input-button.d.ts +10 -0
- package/dist/components/chatbot/chatbot-footer/speech-input-button.d.ts.map +1 -0
- package/dist/components/chatbot/chatbot-header/chatbot-header.d.ts +12 -0
- package/dist/components/chatbot/chatbot-header/chatbot-header.d.ts.map +1 -0
- package/dist/components/chatbot/chatbot-header/index.d.ts +2 -0
- package/dist/components/chatbot/chatbot-header/index.d.ts.map +1 -0
- package/dist/components/chatbot/chatbot.d.ts +27 -6
- package/dist/components/chatbot/chatbot.d.ts.map +1 -1
- package/dist/components/chatbot/profile-icon.d.ts +8 -0
- package/dist/components/chatbot/profile-icon.d.ts.map +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/templates/avatar/avatar.d.ts +5 -1
- package/dist/components/templates/avatar/avatar.d.ts.map +1 -1
- package/dist/components/templates/button-template/button-template.d.ts +2 -2
- package/dist/components/templates/button-template/button-template.d.ts.map +1 -1
- package/dist/components/templates/button-template/card.d.ts +8 -2
- package/dist/components/templates/button-template/card.d.ts.map +1 -1
- package/dist/components/templates/carousel-template/carousel-template.d.ts +2 -2
- package/dist/components/templates/carousel-template/carousel-template.d.ts.map +1 -1
- package/dist/components/templates/chart-template/chart-template.d.ts +9 -0
- package/dist/components/templates/chart-template/chart-template.d.ts.map +1 -0
- package/dist/components/templates/chart-template/index.d.ts +2 -0
- package/dist/components/templates/chart-template/index.d.ts.map +1 -0
- package/dist/components/templates/hint-template/hint-template.d.ts +2 -2
- package/dist/components/templates/hint-template/hint-template.d.ts.map +1 -1
- package/dist/components/templates/image-template/image-template.d.ts +9 -0
- package/dist/components/templates/image-template/image-template.d.ts.map +1 -0
- package/dist/components/templates/image-template/index.d.ts +2 -0
- package/dist/components/templates/image-template/index.d.ts.map +1 -0
- package/dist/components/templates/index.d.ts +2 -1
- package/dist/components/templates/index.d.ts.map +1 -1
- package/dist/components/templates/quick-replies/quick-replies.d.ts.map +1 -1
- package/dist/components/templates/template-box/template-box-content.d.ts.map +1 -1
- package/dist/components/templates/template-box/template-box.d.ts +5 -1
- package/dist/components/templates/template-box/template-box.d.ts.map +1 -1
- package/dist/components/templates/text-template/bot-typing-box.d.ts +9 -0
- package/dist/components/templates/text-template/bot-typing-box.d.ts.map +1 -0
- package/dist/components/templates/text-template/bot-typing-placeholder.d.ts +8 -0
- package/dist/components/templates/text-template/bot-typing-placeholder.d.ts.map +1 -0
- package/dist/components/templates/text-template/index.d.ts +2 -0
- package/dist/components/templates/text-template/index.d.ts.map +1 -1
- package/dist/components/templates/text-template/text-template.d.ts +2 -2
- package/dist/components/templates/text-template/text-template.d.ts.map +1 -1
- package/dist/components/templates/time/time.d.ts.map +1 -1
- package/dist/context/asgard-app-initialization-context.d.ts +54 -0
- package/dist/context/asgard-app-initialization-context.d.ts.map +1 -0
- package/dist/context/asgard-service-context.d.ts +25 -10
- package/dist/context/asgard-service-context.d.ts.map +1 -1
- package/dist/context/asgard-template-context.d.ts +28 -0
- package/dist/context/asgard-template-context.d.ts.map +1 -0
- package/dist/context/asgard-theme-context.d.ts +127 -0
- package/dist/context/asgard-theme-context.d.ts.map +1 -0
- package/dist/context/index.d.ts +5 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/hooks/index.d.ts +8 -1
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/use-asgard-service-client.d.ts +1 -1
- package/dist/hooks/use-asgard-service-client.d.ts.map +1 -1
- package/dist/hooks/use-channel.d.ts +16 -22
- package/dist/hooks/use-channel.d.ts.map +1 -1
- package/dist/hooks/use-deep-compare-memo.d.ts +7 -0
- package/dist/hooks/use-deep-compare-memo.d.ts.map +1 -0
- package/dist/hooks/use-is-on-screen-keyboard-open.d.ts +2 -0
- package/dist/hooks/use-is-on-screen-keyboard-open.d.ts.map +1 -0
- package/dist/hooks/use-on-screen-keyboard-scroll-fix.d.ts +2 -0
- package/dist/hooks/use-on-screen-keyboard-scroll-fix.d.ts.map +1 -0
- package/dist/hooks/use-prevent-over-scrolling.d.ts +4 -0
- package/dist/hooks/use-prevent-over-scrolling.d.ts.map +1 -0
- package/dist/hooks/use-react-markdown-renderer.d.ts +11 -0
- package/dist/hooks/use-react-markdown-renderer.d.ts.map +1 -0
- package/dist/hooks/use-resize-observer.d.ts +9 -0
- package/dist/hooks/use-resize-observer.d.ts.map +1 -0
- package/dist/hooks/use-update-vh.d.ts +4 -0
- package/dist/hooks/use-update-vh.d.ts.map +1 -0
- package/dist/hooks/use-viewport-size.d.ts +6 -0
- package/dist/hooks/use-viewport-size.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +77819 -478
- package/dist/models/bot-provider.d.ts +26 -0
- package/dist/models/bot-provider.d.ts.map +1 -0
- package/dist/style.css +1 -1
- package/dist/test-setup.d.ts +2 -0
- package/dist/test-setup.d.ts.map +1 -0
- package/dist/utils/deep-merge.d.ts +3 -0
- package/dist/utils/deep-merge.d.ts.map +1 -0
- package/dist/utils/extractors.d.ts +2 -0
- package/dist/utils/extractors.d.ts.map +1 -0
- package/dist/utils/is.d.ts +8 -0
- package/dist/utils/is.d.ts.map +1 -0
- package/dist/utils/selectors.d.ts +4 -0
- package/dist/utils/selectors.d.ts.map +1 -0
- package/dist/utils/uri-validation.d.ts +20 -0
- package/dist/utils/uri-validation.d.ts.map +1 -0
- package/eslint.config.cjs +12 -0
- package/package.json +39 -3
- 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 +121 -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 +49 -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 +75 -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/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 +145 -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-react-markdown-renderer.tsx +266 -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 +26 -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 +63 -0
- package/tsconfig.spec.json +36 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/vite.config.ts +63 -0
- package/dist/components/chatbot/chatbot-body.d.ts.map +0 -1
- package/dist/components/chatbot/chatbot-footer.d.ts.map +0 -1
- package/dist/components/chatbot/chatbot-header.d.ts +0 -4
- package/dist/components/chatbot/chatbot-header.d.ts.map +0 -1
- package/dist/components/conversation-message-renderer/conversation-message-renderer.d.ts.map +0 -1
- package/dist/components/conversation-message-renderer/index.d.ts +0 -2
- package/dist/components/conversation-message-renderer/index.d.ts.map +0 -1
- package/dist/components/message-box/message-box.d.ts +0 -9
- package/dist/components/message-box/message-box.d.ts.map +0 -1
- package/dist/components/templates/bot-typing-box/bot-typing-box.d.ts +0 -4
- package/dist/components/templates/bot-typing-box/bot-typing-box.d.ts.map +0 -1
- package/dist/components/templates/bot-typing-box/index.d.ts +0 -2
- package/dist/components/templates/bot-typing-box/index.d.ts.map +0 -1
- package/dist/components/templates/bot-typing-box/resize-observer-box.d.ts +0 -9
- package/dist/components/templates/bot-typing-box/resize-observer-box.d.ts.map +0 -1
- package/dist/hooks/use-chatbot-typing.d.ts +0 -11
- package/dist/hooks/use-chatbot-typing.d.ts.map +0 -1
- /package/dist/components/chatbot/{chatbot-body.d.ts → chatbot-body/chatbot-body.d.ts} +0 -0
- /package/dist/components/chatbot/{chatbot-footer.d.ts → chatbot-footer/chatbot-footer.d.ts} +0 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { ClientConfig } from '@asgard-js/core';
|
|
2
|
+
import { annotationSelectorFromBotProviderMetadata } from '../utils/selectors';
|
|
3
|
+
|
|
4
|
+
export type BotProviderMetadataResponse = {
|
|
5
|
+
name: string;
|
|
6
|
+
namespace: string;
|
|
7
|
+
uid: string;
|
|
8
|
+
resourceVersion: string;
|
|
9
|
+
generation: number;
|
|
10
|
+
creationTimestamp: string;
|
|
11
|
+
labels: Record<string, string>;
|
|
12
|
+
annotations: Record<string, string>;
|
|
13
|
+
managedFields: Array<{
|
|
14
|
+
manager: string;
|
|
15
|
+
operation: string;
|
|
16
|
+
apiVersion: string;
|
|
17
|
+
time: string;
|
|
18
|
+
fieldsType: string;
|
|
19
|
+
fieldsV1: Record<string, unknown>;
|
|
20
|
+
subresource: string;
|
|
21
|
+
}>;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const stubGetAsgardBotProviderMetadata =
|
|
25
|
+
async (): Promise<BotProviderMetadataResponse> => {
|
|
26
|
+
return {
|
|
27
|
+
name: '',
|
|
28
|
+
namespace: '',
|
|
29
|
+
uid: '',
|
|
30
|
+
resourceVersion: '0',
|
|
31
|
+
generation: 0,
|
|
32
|
+
creationTimestamp: new Date().toISOString(),
|
|
33
|
+
labels: {},
|
|
34
|
+
annotations: {
|
|
35
|
+
'asgard-ai.com/additional-annotation': JSON.stringify({
|
|
36
|
+
embedConfig: {
|
|
37
|
+
theme: {
|
|
38
|
+
chatbot: {},
|
|
39
|
+
botMessage: {},
|
|
40
|
+
userMessage: {},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
}),
|
|
44
|
+
},
|
|
45
|
+
managedFields: [],
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const stubGetAnnotations = async (): Promise<Record<string, unknown>> => {
|
|
50
|
+
const metadata = await stubGetAsgardBotProviderMetadata();
|
|
51
|
+
|
|
52
|
+
return annotationSelectorFromBotProviderMetadata(metadata);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const getBotProviderModels = (
|
|
56
|
+
config: ClientConfig
|
|
57
|
+
): {
|
|
58
|
+
getAsgardBotProviderMetadata: () => Promise<BotProviderMetadataResponse>;
|
|
59
|
+
getAnnotations: () => Promise<Record<string, unknown>>;
|
|
60
|
+
} => {
|
|
61
|
+
if (!config.botProviderEndpoint) {
|
|
62
|
+
// eslint-disable-next-line no-console
|
|
63
|
+
console.warn(
|
|
64
|
+
'[getBotProviderModels] botProviderEndpoint is not defined in config. ' +
|
|
65
|
+
'Bot provider features will be disabled. Consider providing botProviderEndpoint for full functionality.'
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
getAsgardBotProviderMetadata: stubGetAsgardBotProviderMetadata,
|
|
70
|
+
getAnnotations: stubGetAnnotations,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const headers: Record<string, string> = {};
|
|
75
|
+
|
|
76
|
+
if (config.apiKey) {
|
|
77
|
+
headers['x-api-key'] = config.apiKey;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async function getAsgardBotProviderMetadata(): Promise<BotProviderMetadataResponse> {
|
|
81
|
+
const response = await fetch(`${config.botProviderEndpoint}/metadata`, {
|
|
82
|
+
method: 'GET',
|
|
83
|
+
headers: {
|
|
84
|
+
...headers,
|
|
85
|
+
'Content-Type': 'application/json',
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
if (!response.ok) {
|
|
90
|
+
throw new Error(`Failed to fetch metadata: ${response.statusText}`);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const json: { data: BotProviderMetadataResponse } = await response.json();
|
|
94
|
+
|
|
95
|
+
return json.data;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async function getAnnotations(): Promise<Record<string, unknown>> {
|
|
99
|
+
const metadata = await getAsgardBotProviderMetadata();
|
|
100
|
+
|
|
101
|
+
return annotationSelectorFromBotProviderMetadata(metadata);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
getAsgardBotProviderMetadata,
|
|
106
|
+
getAnnotations,
|
|
107
|
+
};
|
|
108
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@forward './styles';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@forward './colors';
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
$blue-colors: (
|
|
2
|
+
#edf0fd,
|
|
3
|
+
#d3dbfa,
|
|
4
|
+
#b0bef6,
|
|
5
|
+
#6882ef,
|
|
6
|
+
#8b9ff2,
|
|
7
|
+
#4767eb,
|
|
8
|
+
#3c58c8,
|
|
9
|
+
#3249a7,
|
|
10
|
+
#283b86,
|
|
11
|
+
#202e6a
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
$orange-colors: (
|
|
15
|
+
#ffeded,
|
|
16
|
+
#ffd4d5,
|
|
17
|
+
#ffb2b3,
|
|
18
|
+
#ff8f90,
|
|
19
|
+
#ff6d6f,
|
|
20
|
+
#ff4d4f,
|
|
21
|
+
#d94143,
|
|
22
|
+
#b53738,
|
|
23
|
+
#912c2d,
|
|
24
|
+
#732324
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
$green-colors: (
|
|
28
|
+
#eef9e8,
|
|
29
|
+
#d5f1c8,
|
|
30
|
+
#b5e69d,
|
|
31
|
+
#92da6f,
|
|
32
|
+
#71cf43,
|
|
33
|
+
#52c41a,
|
|
34
|
+
#46a716,
|
|
35
|
+
#3a8b12,
|
|
36
|
+
#2f700f,
|
|
37
|
+
#25580c,
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
$yellow-colors: (
|
|
41
|
+
#fef7eb,
|
|
42
|
+
#fdebcf,
|
|
43
|
+
#fcdba9,
|
|
44
|
+
#facb82,
|
|
45
|
+
#f8bb5c,
|
|
46
|
+
#f7ac38,
|
|
47
|
+
#d29230,
|
|
48
|
+
#af7a28,
|
|
49
|
+
#8d6220,
|
|
50
|
+
#6f4d19,
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
$grey-colors: (
|
|
54
|
+
#f3f3f3,
|
|
55
|
+
#e2e2e2,
|
|
56
|
+
#cbcbcb,
|
|
57
|
+
#b2b2b2,
|
|
58
|
+
#9b9b9b,
|
|
59
|
+
#585858,
|
|
60
|
+
#717171,
|
|
61
|
+
#5e5e5e,
|
|
62
|
+
#4c4c4c,
|
|
63
|
+
#3c3c3c
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
$colors-map: (
|
|
67
|
+
blue: $blue-colors,
|
|
68
|
+
orange: $orange-colors,
|
|
69
|
+
green: $green-colors,
|
|
70
|
+
yellow: $yellow-colors,
|
|
71
|
+
grey: $grey-colors
|
|
72
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@forward './palette';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
@use 'sass:map';
|
|
2
|
+
@use './variables';
|
|
3
|
+
|
|
4
|
+
$prefix: asg-color;
|
|
5
|
+
|
|
6
|
+
@mixin generate-state-colors($map: variables.$state-colors-map) {
|
|
7
|
+
@each $state, $colors-map in $map {
|
|
8
|
+
|
|
9
|
+
$main-color: map.get($colors-map, main);
|
|
10
|
+
$light-color: map.get($colors-map, light);
|
|
11
|
+
$dark-color: map.get($colors-map, dark);
|
|
12
|
+
|
|
13
|
+
--#{$prefix}-#{$state}: #{$main-color};
|
|
14
|
+
--#{$prefix}-#{$state}-light: #{$light-color};
|
|
15
|
+
--#{$prefix}-#{$state}-dark: #{$dark-color};
|
|
16
|
+
--#{$prefix}-#{$state}-on-#{$state}: #ffffff;
|
|
17
|
+
--#{$prefix}-#{$state}-hover-bg: #{rgba($light-color, 0.15)};
|
|
18
|
+
--#{$prefix}-#{$state}-selected-bg: #{rgba($main-color, 0.20)};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@mixin generate() {
|
|
23
|
+
@include generate-state-colors();
|
|
24
|
+
|
|
25
|
+
--#{$prefix}-action-active: #ffffff;
|
|
26
|
+
--#{$prefix}-action-inactive: #8c8c8c;
|
|
27
|
+
--#{$prefix}-action-disabled: #595959;
|
|
28
|
+
--#{$prefix}-action-disabled-bg: #393939;
|
|
29
|
+
|
|
30
|
+
--#{$prefix}-text-primary: #ffffff;
|
|
31
|
+
--#{$prefix}-text-secondary: #8c8c8c;
|
|
32
|
+
--#{$prefix}-text-disabled: #595959;
|
|
33
|
+
--#{$prefix}-text-placeholder: #8c8c8c;
|
|
34
|
+
|
|
35
|
+
--#{$prefix}-bg: #141414;
|
|
36
|
+
--#{$prefix}-surface: #1f1f1f;
|
|
37
|
+
--#{$prefix}-divider: #333333;
|
|
38
|
+
--#{$prefix}-border: #434343;
|
|
39
|
+
|
|
40
|
+
--#{$prefix}-overlay-dark: #{rgba(#000000, 0.5)};
|
|
41
|
+
--#{$prefix}-overlay-light: #{rgba(#1f1f1f, 0.9)};
|
|
42
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
@use 'sass:list';
|
|
2
|
+
@use '../colors/variables';
|
|
3
|
+
|
|
4
|
+
$primary-colors: (
|
|
5
|
+
main: list.nth(variables.$blue-colors, 6),
|
|
6
|
+
light: list.nth(variables.$blue-colors, 5),
|
|
7
|
+
dark: list.nth(variables.$blue-colors, 8),
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
$secondary-colors: (
|
|
11
|
+
main: list.nth(variables.$grey-colors, 6),
|
|
12
|
+
light: list.nth(variables.$grey-colors, 4),
|
|
13
|
+
dark: list.nth(variables.$grey-colors, 9),
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
$error-colors: (
|
|
17
|
+
main: list.nth(variables.$orange-colors, 6),
|
|
18
|
+
light: list.nth(variables.$orange-colors, 5),
|
|
19
|
+
dark: list.nth(variables.$orange-colors, 7),
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
$warning-colors: (
|
|
23
|
+
main: list.nth(variables.$yellow-colors, 6),
|
|
24
|
+
light: list.nth(variables.$yellow-colors, 5),
|
|
25
|
+
dark: list.nth(variables.$yellow-colors, 8),
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
$success-colors: (
|
|
29
|
+
main: list.nth(variables.$green-colors, 6),
|
|
30
|
+
light: list.nth(variables.$green-colors, 5),
|
|
31
|
+
dark: list.nth(variables.$green-colors, 8),
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
$state-colors-map: (
|
|
35
|
+
primary: $primary-colors,
|
|
36
|
+
secondary: $secondary-colors,
|
|
37
|
+
error: $error-colors,
|
|
38
|
+
warning: $warning-colors,
|
|
39
|
+
success: $success-colors,
|
|
40
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@forward './radius';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@forward './spacing';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@forward './map';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
@use 'sass:meta';
|
|
2
|
+
@use 'sass:list';
|
|
3
|
+
@use 'sass:map';
|
|
4
|
+
|
|
5
|
+
@mixin generate-vars($prefix, $data) {
|
|
6
|
+
$map: null;
|
|
7
|
+
|
|
8
|
+
@if meta.type-of($data) == "list" {
|
|
9
|
+
$map: ();
|
|
10
|
+
@for $i from 1 through list.length($data) {
|
|
11
|
+
$map: map.merge($map, ($i: list.nth($data, $i)));
|
|
12
|
+
}
|
|
13
|
+
} @else if meta.type-of($data) == "map" {
|
|
14
|
+
$map: $data;
|
|
15
|
+
} @else {
|
|
16
|
+
@warn "generate-vars: The provided data is neither a list nor a map. (type: #{meta.type-of($data)})";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@each $index, $item in $map {
|
|
20
|
+
--#{$prefix}-#{$index}: #{$item};
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export function isObject(item: unknown): item is Record<string, unknown> {
|
|
2
|
+
return item !== null && typeof item === 'object' && !Array.isArray(item);
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function deepMerge<T extends Record<string, unknown>, U extends Record<string, unknown>>(
|
|
6
|
+
target: T,
|
|
7
|
+
source: U
|
|
8
|
+
): T & U {
|
|
9
|
+
const output = { ...target } as T & U;
|
|
10
|
+
|
|
11
|
+
if (!source) return output;
|
|
12
|
+
|
|
13
|
+
for (const [key, value] of Object.entries(source)) {
|
|
14
|
+
if (!isObject(value)) {
|
|
15
|
+
(output as Record<string, unknown>)[key] = value;
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
(output as Record<string, unknown>)[key] = deepMerge(
|
|
20
|
+
isObject((output as Record<string, unknown>)[key]) ? (output as Record<string, unknown>)[key] as Record<string, unknown> : {},
|
|
21
|
+
value as Record<string, unknown>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return output;
|
|
26
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export function extractRefs(obj: unknown): unknown[] {
|
|
2
|
+
const refs: unknown[] = [];
|
|
3
|
+
|
|
4
|
+
function traverse(o: unknown): void {
|
|
5
|
+
if (o && typeof o === 'object') {
|
|
6
|
+
if (Array.isArray(o)) {
|
|
7
|
+
for (const item of o) traverse(item);
|
|
8
|
+
} else {
|
|
9
|
+
for (const key of Object.keys(o))
|
|
10
|
+
traverse((o as Record<string, unknown>)[key]);
|
|
11
|
+
}
|
|
12
|
+
} else {
|
|
13
|
+
refs.push(o);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
traverse(obj);
|
|
18
|
+
|
|
19
|
+
return refs;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './format-time';
|
package/src/utils/is.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Performs a deep equality check between two values (primitive, array, plain object).
|
|
3
|
+
* - Functions are compared by reference.
|
|
4
|
+
* - No circular reference support.
|
|
5
|
+
* - Returns true if deeply equal, false otherwise.
|
|
6
|
+
*/
|
|
7
|
+
export function isEqual(a: unknown, b: unknown): boolean {
|
|
8
|
+
// Check for strict equality first (handles primitives and reference equality)
|
|
9
|
+
if (a === b) {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Handle null cases
|
|
14
|
+
if (a === null || b === null) {
|
|
15
|
+
return a === b;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Compare types
|
|
19
|
+
if (typeof a !== typeof b) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Handle arrays
|
|
24
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
25
|
+
if (a.length !== b.length) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
for (let i = 0; i < a.length; i++) {
|
|
30
|
+
if (!isEqual(a[i], b[i])) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// If one is array and the other is not
|
|
39
|
+
if (Array.isArray(a) || Array.isArray(b)) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Handle objects (but not functions)
|
|
44
|
+
if (typeof a === 'object' && typeof b === 'object') {
|
|
45
|
+
const aKeys = Object.keys(a as object);
|
|
46
|
+
const bKeys = Object.keys(b as object);
|
|
47
|
+
if (aKeys.length !== bKeys.length) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
for (const key of aKeys) {
|
|
52
|
+
// Use Object.prototype.hasOwnProperty.call to be safe
|
|
53
|
+
if (!Object.prototype.hasOwnProperty.call(b, key)) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (
|
|
58
|
+
!isEqual(
|
|
59
|
+
(a as Record<string, unknown>)[key],
|
|
60
|
+
(b as Record<string, unknown>)[key]
|
|
61
|
+
)
|
|
62
|
+
) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Fallback for functions, symbols, etc. (compare by reference)
|
|
71
|
+
return a === b;
|
|
72
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BotProviderMetadataResponse } from '../models/bot-provider';
|
|
2
|
+
|
|
3
|
+
export const annotationSelectorFromBotProviderMetadata = (
|
|
4
|
+
value: BotProviderMetadataResponse
|
|
5
|
+
): Record<string, unknown> => {
|
|
6
|
+
return JSON.parse(value.annotations['asgard-ai.com/additional-annotation']);
|
|
7
|
+
};
|