@websolutespa/bom-llm 0.2.5 → 0.2.7

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/umd/index.js CHANGED
@@ -8135,7 +8135,7 @@
8135
8135
  }
8136
8136
  var jsxRuntimeExports = jsxRuntime.exports;
8137
8137
 
8138
- const [useLayout, LayoutContextProvider] = createGenericContext();
8138
+ const [useLayout_, LayoutContextProvider] = createGenericContext();
8139
8139
  function LayoutProvider(_ref) {
8140
8140
  let {
8141
8141
  children,
@@ -8147,6 +8147,7 @@
8147
8147
  children: children
8148
8148
  });
8149
8149
  }
8150
+ const useLayout = useLayout_;
8150
8151
 
8151
8152
  function useAutosizeTextArea(textAreaRef, value) {
8152
8153
  reactExports.useEffect(() => {
@@ -19875,6 +19876,21 @@
19875
19876
  }
19876
19877
  }
19877
19878
 
19879
+ const LLM_MINIMIZED_KEY = 'llm-minimized';
19880
+ function getPersistedMinimized() {
19881
+ try {
19882
+ return sessionStorage.getItem(LLM_MINIMIZED_KEY) === 'true';
19883
+ } catch {
19884
+ return false;
19885
+ }
19886
+ }
19887
+ function persistMinimized(minimized) {
19888
+ try {
19889
+ sessionStorage.setItem(LLM_MINIMIZED_KEY, String(minimized));
19890
+ } catch {
19891
+ // error
19892
+ }
19893
+ }
19878
19894
  const createLlmViewStore = _ref => {
19879
19895
  let {
19880
19896
  threadId,
@@ -19905,6 +19921,7 @@
19905
19921
  fixed: false,
19906
19922
  idle: true,
19907
19923
  visible: false,
19924
+ minimized: getPersistedMinimized(),
19908
19925
  scrollable: false,
19909
19926
  direction: 0
19910
19927
  };
@@ -20030,9 +20047,11 @@
20030
20047
  },
20031
20048
  send: async (prompt, onMessage, onEnd) => {
20032
20049
  await send(prompt, () => {
20050
+ persistMinimized(false);
20033
20051
  set({
20034
20052
  skipCustomIntro: true,
20035
- opened: true
20053
+ opened: true,
20054
+ minimized: false
20036
20055
  });
20037
20056
  setTimeout(() => {
20038
20057
  }, 50);
@@ -20053,8 +20072,10 @@
20053
20072
  pushDataLayer({
20054
20073
  event: opened ? 'llm_open' : 'llm_close'
20055
20074
  });
20075
+ persistMinimized(false);
20056
20076
  return {
20057
- opened
20077
+ opened,
20078
+ minimized: false
20058
20079
  };
20059
20080
  });
20060
20081
  },
@@ -20082,6 +20103,12 @@
20082
20103
  introed
20083
20104
  }));
20084
20105
  },
20106
+ setMinimized: minimized => {
20107
+ persistMinimized(minimized);
20108
+ set(state => ({
20109
+ minimized
20110
+ }));
20111
+ },
20085
20112
  setVisible: visible => set(state => ({
20086
20113
  visible
20087
20114
  })),
@@ -32885,6 +32912,10 @@ void main(void) {
32885
32912
  wrapper
32886
32913
  } = _ref;
32887
32914
  const label = useLabel();
32915
+ const streaming = useLlm(state => state.streaming);
32916
+ const {
32917
+ clear
32918
+ } = useLlm(state => state.actions);
32888
32919
  const {
32889
32920
  send
32890
32921
  } = useLlmView(state => state.actions);
@@ -32892,7 +32923,8 @@ void main(void) {
32892
32923
  setWrapper
32893
32924
  } = useActions();
32894
32925
  const onAction = async action => {
32895
- const prompt = action.message || `${action.label}: ${JSON.stringify(wrapper.actions)}`;
32926
+ const prompt = action.message || action.label;
32927
+ clear();
32896
32928
  await send(prompt, response => {
32897
32929
  // console.log('PageActions.onChunk', response.chunks);
32898
32930
  }, response => {
@@ -32910,7 +32942,11 @@ void main(void) {
32910
32942
  }), wrapper.actions.map(x => /*#__PURE__*/jsxRuntimeExports.jsxs("button", {
32911
32943
  type: "button",
32912
32944
  className: getClassNames(style$h.action),
32913
- onClick: () => onAction(x),
32945
+ disabled: streaming,
32946
+ onClick: e => {
32947
+ e.stopPropagation();
32948
+ onAction(x);
32949
+ },
32914
32950
  children: [/*#__PURE__*/jsxRuntimeExports.jsx(ActionIcon, {
32915
32951
  action: x
32916
32952
  }), /*#__PURE__*/jsxRuntimeExports.jsx("span", {
@@ -40825,6 +40861,9 @@ void main(void) {
40825
40861
  removeHistory
40826
40862
  } = useLlm(state => state.actions);
40827
40863
  // console.log('item', item);
40864
+ if (!item.user) {
40865
+ return;
40866
+ }
40828
40867
  return /*#__PURE__*/jsxRuntimeExports.jsxs("div", {
40829
40868
  className: getClassNames(style$e.history),
40830
40869
  onClick: () => setHistory(item),
@@ -41342,7 +41381,11 @@ void main(void) {
41342
41381
  const PageSubmit = () => {
41343
41382
  const label = useLabel();
41344
41383
  useLlm(state => state.components);
41384
+ const streaming = useLlm(state => state.streaming);
41345
41385
  const prompt = useLlm(state => state.prompt);
41386
+ const {
41387
+ clear
41388
+ } = useLlm(state => state.actions);
41346
41389
  const {
41347
41390
  send
41348
41391
  } = useLlmView(state => state.actions);
@@ -41351,6 +41394,7 @@ void main(void) {
41351
41394
  if (!prompt) {
41352
41395
  return;
41353
41396
  }
41397
+ clear();
41354
41398
  await send(prompt, response => {
41355
41399
  // console.log('PagePrompt.onChunk', response.chunks);
41356
41400
  }, response => {
@@ -41360,7 +41404,7 @@ void main(void) {
41360
41404
  return /*#__PURE__*/jsxRuntimeExports.jsx("button", {
41361
41405
  type: "submit",
41362
41406
  className: getClassNames(style$5.submit),
41363
- "aria-disabled": !prompt,
41407
+ disabled: !prompt || streaming,
41364
41408
  "aria-label": label('llm.sendPrompt'),
41365
41409
  onClick: onSubmit,
41366
41410
  children: /*#__PURE__*/jsxRuntimeExports.jsx(IconLlmArrowUp, {})
@@ -41405,7 +41449,8 @@ void main(void) {
41405
41449
  const prompt = useLlm(state => state.prompt);
41406
41450
  const streaming = useLlm(state => state.streaming);
41407
41451
  const {
41408
- setPrompt
41452
+ setPrompt,
41453
+ clear
41409
41454
  } = useLlm(state => state.actions);
41410
41455
  const {
41411
41456
  send
@@ -41416,6 +41461,7 @@ void main(void) {
41416
41461
  if (!prompt) {
41417
41462
  return;
41418
41463
  }
41464
+ clear();
41419
41465
  await send(prompt, response => {
41420
41466
  // console.log('PagePrompt.onChunk', response.chunks);
41421
41467
  }, response => {
@@ -41427,7 +41473,7 @@ void main(void) {
41427
41473
  setPrompt(prompt);
41428
41474
  };
41429
41475
  const onKeyDown = event => {
41430
- if (event.code == 'Enter' && !event.shiftKey) {
41476
+ if (event.code == 'Enter' && !event.shiftKey && !streaming) {
41431
41477
  onSubmit(event);
41432
41478
  }
41433
41479
  };
@@ -42216,6 +42262,32 @@ void main(void) {
42216
42262
  });
42217
42263
  };
42218
42264
 
42265
+ const MinimizeButton = _ref => {
42266
+ let {
42267
+ onClick,
42268
+ label
42269
+ } = _ref;
42270
+ return /*#__PURE__*/jsxRuntimeExports.jsx("button", {
42271
+ type: "button",
42272
+ className: "llm__trigger-minimize",
42273
+ onClick: onClick,
42274
+ "aria-label": label,
42275
+ children: /*#__PURE__*/jsxRuntimeExports.jsx("svg", {
42276
+ width: "16",
42277
+ height: "16",
42278
+ viewBox: "0 0 16 16",
42279
+ fill: "none",
42280
+ xmlns: "http://www.w3.org/2000/svg",
42281
+ children: /*#__PURE__*/jsxRuntimeExports.jsx("path", {
42282
+ d: "M4 6L8 10L12 6",
42283
+ stroke: "currentColor",
42284
+ strokeWidth: "1.5",
42285
+ strokeLinecap: "round",
42286
+ strokeLinejoin: "round"
42287
+ })
42288
+ })
42289
+ });
42290
+ };
42219
42291
  const Trigger = () => {
42220
42292
  const theme = useLlm(state => state.theme);
42221
42293
  const {
@@ -42223,16 +42295,21 @@ void main(void) {
42223
42295
  } = useLlm(state => state.components);
42224
42296
  const app = useLlm(state => state.app);
42225
42297
  const opened = useLlmView(state => state.opened);
42298
+ const minimized = useLlmView(state => state.minimized);
42226
42299
  const {
42227
- open
42300
+ open,
42301
+ setMinimized
42228
42302
  } = useLlmView(state => state.actions);
42229
42303
  const label = useLabel();
42304
+ const enableMinimize = app?.contents.enableMinimize;
42230
42305
  const collapsedWelcomeText = messageMapper(app?.contents.collapsedWelcomeText);
42231
42306
  const collapsedWelcomeTextCta = messageMapper(app?.contents.collapsedWelcomeTextCta);
42232
42307
  const collapsedWelcomeTextHover = messageMapper(app?.contents.collapsedWelcomeTextHover);
42233
42308
  const position = theme.trigger?.position || 'bottom';
42234
42309
  return /*#__PURE__*/jsxRuntimeExports.jsxs(motion.nav, {
42235
- className: getClassNames('llm__trigger', '-' + position),
42310
+ className: getClassNames('llm__trigger', '-' + position, {
42311
+ '-minimized': minimized
42312
+ }),
42236
42313
  initial: {
42237
42314
  y: '200%',
42238
42315
  opacity: 0
@@ -42246,7 +42323,7 @@ void main(void) {
42246
42323
  opacity: 0
42247
42324
  },
42248
42325
  transition: {
42249
- duration: .4
42326
+ duration: 0.4
42250
42327
  },
42251
42328
  "aria-label": "Trigger"
42252
42329
  /*
@@ -42262,14 +42339,20 @@ void main(void) {
42262
42339
  children: [/*#__PURE__*/jsxRuntimeExports.jsx(Blob, {}), /*#__PURE__*/jsxRuntimeExports.jsx("span", {
42263
42340
  children: label('llm.button')
42264
42341
  })]
42265
- }), !opened && (collapsedWelcomeText || collapsedWelcomeTextCta || collapsedWelcomeTextHover) && /*#__PURE__*/jsxRuntimeExports.jsxs("div", {
42342
+ }), !opened && !minimized && (collapsedWelcomeText || collapsedWelcomeTextCta || collapsedWelcomeTextHover) && /*#__PURE__*/jsxRuntimeExports.jsxs("div", {
42266
42343
  className: "llm__trigger-popup -llm-t-body2",
42267
42344
  children: [(collapsedWelcomeText || collapsedWelcomeTextCta) && /*#__PURE__*/jsxRuntimeExports.jsxs(motion.div, {
42268
42345
  className: "llm__trigger-message",
42269
42346
  exit: {
42270
42347
  opacity: 0
42271
42348
  },
42272
- children: [/*#__PURE__*/jsxRuntimeExports.jsx(Canvas, {}), collapsedWelcomeText, collapsedWelcomeTextCta && /*#__PURE__*/jsxRuntimeExports.jsx("button", {
42349
+ children: [/*#__PURE__*/jsxRuntimeExports.jsx(Canvas, {}), collapsedWelcomeText, enableMinimize && /*#__PURE__*/jsxRuntimeExports.jsx(MinimizeButton, {
42350
+ onClick: e => {
42351
+ e.stopPropagation();
42352
+ setMinimized(true);
42353
+ },
42354
+ label: label('llm.minimize') || 'Minimize'
42355
+ }), collapsedWelcomeTextCta && /*#__PURE__*/jsxRuntimeExports.jsx("button", {
42273
42356
  type: "button",
42274
42357
  className: "llm__trigger-cta",
42275
42358
  children: collapsedWelcomeTextCta
@@ -45245,6 +45328,7 @@ ${Object.entries(vars).map(_ref2 => {
45245
45328
  decorateUrl,
45246
45329
  label,
45247
45330
  onAction,
45331
+ onMessage,
45248
45332
  ...options
45249
45333
  } = sanitizedConfig;
45250
45334
  const theme = getThemes([customTheme], config.defaultTheme);
@@ -45484,6 +45568,7 @@ ${Object.entries(vars).map(_ref2 => {
45484
45568
  if (typeof onMessage === 'function') {
45485
45569
  onMessage(response);
45486
45570
  }
45571
+ state.actions.onMessage(response);
45487
45572
  },
45488
45573
  // onEnd
45489
45574
  response => {
@@ -45785,6 +45870,12 @@ ${Object.entries(vars).map(_ref2 => {
45785
45870
  }
45786
45871
  return;
45787
45872
  },
45873
+ onMessage: async message => {
45874
+ if (typeof onMessage === 'function') {
45875
+ return await onMessage(message);
45876
+ }
45877
+ return;
45878
+ },
45788
45879
  clear: () => {
45789
45880
  const {
45790
45881
  abort
@@ -46396,6 +46487,13 @@ ${Object.entries(vars).map(_ref2 => {
46396
46487
  id: data.market,
46397
46488
  title: data.market
46398
46489
  }],
46490
+ app: {
46491
+ id: 'app',
46492
+ brand: {
46493
+ name: 'Mixer',
46494
+ social: []
46495
+ }
46496
+ },
46399
46497
  menu: {},
46400
46498
  topLevelHrefs: {},
46401
46499
  topLevelRoutes: {}