@websolutespa/bom-llm 0.0.55 → 0.0.57

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @websolutespa/bom-llm
2
2
 
3
+ ## 0.0.57
4
+
5
+ ### Patch Changes
6
+
7
+ - Added: Action, LlmChunkAction, onAction handler
8
+
9
+ ## 0.0.56
10
+
11
+ ### Patch Changes
12
+
13
+ - Fixing: mock default
14
+
3
15
  ## 0.0.55
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -131,6 +131,23 @@ decorateUrl method can be a promise.
131
131
  bomLlm(options);
132
132
  ```
133
133
 
134
+ ### Handling external actions
135
+
136
+ You can handle the click event of the generated cta action with the onAction handler.
137
+
138
+ ```js
139
+ const searchParams = new URLSearchParams(window.location.search);
140
+ const options = {
141
+ appKey: 'MY_APP_KEY',
142
+ apiKey: 'MY_API_KEY',
143
+ threadId: searchParams.get('llmThreadId'),
144
+ onAction: (item) => {
145
+ console.log('onAction', item.id, item.title);
146
+ },
147
+ };
148
+ bomLlm(options);
149
+ ```
150
+
134
151
  ### Supported types
135
152
 
136
153
  Currently available types are:
package/dist/index.d.ts CHANGED
@@ -4,6 +4,11 @@ type DeepPartial<T> = T extends object ? {
4
4
  type LlmItem = Record<string, any> & {
5
5
  type: string;
6
6
  };
7
+ type LlmAction = Record<string, any> & {
8
+ type: 'action' | 'actionItem';
9
+ id: string | number;
10
+ title: string;
11
+ };
7
12
  type LlmTheme = any;
8
13
  type IMedia = Record<string, unknown> & {
9
14
  abstract?: string;
@@ -86,6 +91,7 @@ type LlmMock = {
86
91
  };
87
92
  type LlmTest = undefined | boolean | DeepPartial<LlmMock>;
88
93
  type LlmDecorateUrl = (item: LlmItem) => (string | void) | Promise<string | void>;
94
+ type LlmOnAction = (item: LlmAction) => (void) | Promise<boolean | void>;
89
95
  type LlmViewOptions = {
90
96
  threadId?: string;
91
97
  preview?: boolean;
@@ -99,6 +105,7 @@ type LlmOptions = {
99
105
  apiKey: string;
100
106
  appKey: string;
101
107
  decorateUrl?: LlmDecorateUrl;
108
+ onAction?: LlmOnAction;
102
109
  test?: LlmTest;
103
110
  customTheme?: Partial<LlmTheme>;
104
111
  locale?: string;
@@ -934,7 +934,7 @@ llm-embed {
934
934
  .llm .llm__header-wrapper {
935
935
  display: flex;
936
936
  justify-content: space-between;
937
- padding: 0 var(--llm-size-5, 2.5rem);
937
+ padding: 0 min(var(--llm-size-5, 2.5rem), clamp(20px * var(--s, 1), 20px * var(--s, 1) + (var(--u, 1vw) * 100 - 375px) / 1545 * 90 * var(--s, 1), 110px * var(--s, 1)));
938
938
  align-items: center;
939
939
  height: 70px;
940
940
  z-index: 2;
@@ -1241,6 +1241,16 @@ llm-embed {
1241
1241
  .llm .llm__intro-blob > div {
1242
1242
  height: 100%;
1243
1243
  }
1244
+ .llm.-chat .llm__intro-blob {
1245
+ width: 50px;
1246
+ height: 50px;
1247
+ }
1248
+ @media (min-width: 1440px) {
1249
+ .llm.-chat .llm__intro-blob {
1250
+ width: 60px;
1251
+ height: 60px;
1252
+ }
1253
+ }
1244
1254
  @media (min-width: 1024px) {
1245
1255
  .llm .llm__intro-wrapper {
1246
1256
  justify-content: space-between;
@@ -1252,6 +1262,9 @@ llm-embed {
1252
1262
  gap: var(--llm-size-5, 2.5rem);
1253
1263
  color: var(--llm-color-title-foreground);
1254
1264
  }
1265
+ .llm.-chat .llm__intro-text {
1266
+ gap: var(--llm-size-3, 1.5rem);
1267
+ }
1255
1268
  .llm .llm__intro-hints {
1256
1269
  margin-top: var(--llm-size-5, 2.5rem);
1257
1270
  }
@@ -1260,6 +1273,9 @@ llm-embed {
1260
1273
  margin-top: 0;
1261
1274
  }
1262
1275
  }
1276
+ .llm.-chat .llm__intro-hints {
1277
+ margin-top: var(--llm-size-3, 1.5rem);
1278
+ }
1263
1279
  .llm .llm__customIntro {
1264
1280
  position: absolute;
1265
1281
  top: 0;
@@ -1286,7 +1302,7 @@ llm-embed {
1286
1302
  }
1287
1303
  }
1288
1304
  .llm .llm__hints .swiper-wrapper {
1289
- padding: 1px 0;
1305
+ padding: 4px 0;
1290
1306
  }
1291
1307
  .llm .llm__hints .swiper-slide {
1292
1308
  height: auto;
@@ -1357,6 +1373,7 @@ llm-embed {
1357
1373
  }
1358
1374
  .llm .llm__hint-title.column {
1359
1375
  flex-direction: column;
1376
+ width: 100%;
1360
1377
  }
1361
1378
  .llm .llm__hint-title i {
1362
1379
  flex-shrink: 0;
@@ -1369,6 +1386,7 @@ llm-embed {
1369
1386
  fill: currentColor;
1370
1387
  }
1371
1388
  .llm .llm__hint-body {
1389
+ width: 100%;
1372
1390
  line-height: 140%;
1373
1391
  }
1374
1392
 
@@ -2049,6 +2067,21 @@ llm-embed {
2049
2067
  border-radius: 12px;
2050
2068
  padding: var(--llm-size-3, 1.5rem) var(--llm-size-4, 2rem);
2051
2069
  }
2070
+ .llm.-chat .llm__message--user .llm__text {
2071
+ display: flex;
2072
+ flex-direction: column;
2073
+ }
2074
+ .llm.-chat .llm__message--user .llm__text .llm__text-body {
2075
+ align-self: flex-end;
2076
+ padding: 0.5em 0;
2077
+ padding: var(--llm-pill-padding, 8px);
2078
+ border: var(--llm-pill-border);
2079
+ border-radius: var(--llm-pill-border-radius);
2080
+ background: var(--llm-pill-background);
2081
+ color: var(--llm-pill-foreground);
2082
+ font-family: var(--llm-pill-font-family);
2083
+ text-align: right;
2084
+ }
2052
2085
  .llm .llm__message--assistant .llm__inner--text:first-child .llm__text .llm__text-body, .llm .llm__message--assistant .llm__inner--text:first-child .llm__text .llm__text-body > p, .llm .llm__message--assistant .llm__inner--text:first-child .llm__text .llm__text-body > h2,
2053
2086
  .llm .llm__message--assistant .llm__inner--string:first-child .llm__text .llm__text-body,
2054
2087
  .llm .llm__message--assistant .llm__inner--string:first-child .llm__text .llm__text-body > p,
@@ -4368,6 +4401,13 @@ llm-embed {
4368
4401
  transform: rotate(90deg);
4369
4402
  }
4370
4403
 
4404
+ .llm .llm__actions {
4405
+ display: flex;
4406
+ gap: var(--llm-size-4, 2rem);
4407
+ padding-top: var(--llm-size-2, 1rem);
4408
+ margin-top: auto;
4409
+ }
4410
+
4371
4411
  /**
4372
4412
  * Swiper 8.4.7
4373
4413
  * Most modern mobile touch slider and framework with hardware accelerated transitions