@websolutespa/bom-llm 0.0.52 → 0.0.54
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 +12 -0
- package/README.md +5 -0
- package/dist/index.d.ts +1 -0
- package/dist/umd/index.css +34 -2
- package/dist/umd/index.js +119 -12
- package/dist/umd/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -74,6 +74,11 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
74
74
|
Using imperatively.
|
|
75
75
|
|
|
76
76
|
```js
|
|
77
|
+
const options = {
|
|
78
|
+
appKey: 'MY_APP_KEY',
|
|
79
|
+
apiKey: 'MY_API_KEY',
|
|
80
|
+
imperative: true, // hide trigger button
|
|
81
|
+
};
|
|
77
82
|
const llm = bomLlm(options);
|
|
78
83
|
// using open command imperatively
|
|
79
84
|
setTimeout(() => {
|
package/dist/index.d.ts
CHANGED
package/dist/umd/index.css
CHANGED
|
@@ -1890,10 +1890,18 @@ llm-embed {
|
|
|
1890
1890
|
left: 0;
|
|
1891
1891
|
bottom: 0;
|
|
1892
1892
|
*/
|
|
1893
|
+
padding: 10px 15px;
|
|
1893
1894
|
display: flex;
|
|
1895
|
+
flex-direction: column;
|
|
1894
1896
|
justify-content: center;
|
|
1895
1897
|
align-items: center;
|
|
1896
|
-
|
|
1898
|
+
gap: 4px;
|
|
1899
|
+
text-align: justify;
|
|
1900
|
+
}
|
|
1901
|
+
@media (min-width: 1024px) {
|
|
1902
|
+
.llm .llm__prompt-footer {
|
|
1903
|
+
flex-direction: row;
|
|
1904
|
+
}
|
|
1897
1905
|
}
|
|
1898
1906
|
.llm .llm__prompt-powered-by {
|
|
1899
1907
|
margin: 0;
|
|
@@ -1931,7 +1939,7 @@ llm-embed {
|
|
|
1931
1939
|
font-size: 11px;
|
|
1932
1940
|
line-height: 1.1;
|
|
1933
1941
|
color: var(--llm-color-foreground);
|
|
1934
|
-
opacity: 0.
|
|
1942
|
+
opacity: 0.8;
|
|
1935
1943
|
transition: opacity ease-in-out 250ms;
|
|
1936
1944
|
}
|
|
1937
1945
|
.llm .llm__prompt-powered-by:focus, .llm .llm__prompt-powered-by:focus-visible {
|
|
@@ -4273,6 +4281,30 @@ llm-embed {
|
|
|
4273
4281
|
left: -1px;
|
|
4274
4282
|
}
|
|
4275
4283
|
|
|
4284
|
+
.llm .llm__scroll-proposition {
|
|
4285
|
+
position: absolute;
|
|
4286
|
+
display: flex;
|
|
4287
|
+
justify-content: center;
|
|
4288
|
+
align-items: center;
|
|
4289
|
+
top: -50px;
|
|
4290
|
+
left: 50%;
|
|
4291
|
+
width: var(--llm-scroll-proposition-size);
|
|
4292
|
+
height: var(--llm-scroll-proposition-size);
|
|
4293
|
+
border-radius: var(--llm-scroll-proposition-border-radius);
|
|
4294
|
+
font-size: var(--llm-scroll-proposition-border-radius);
|
|
4295
|
+
z-index: 1000;
|
|
4296
|
+
transform: translateX(-50%);
|
|
4297
|
+
background: var(--llm-scroll-proposition-background);
|
|
4298
|
+
color: var(--llm-scroll-proposition-foreground);
|
|
4299
|
+
box-shadow: var(--llm-scroll-proposition-box-shadow);
|
|
4300
|
+
cursor: pointer;
|
|
4301
|
+
}
|
|
4302
|
+
.llm .llm__scroll-proposition svg {
|
|
4303
|
+
width: var(--llm-scroll-proposition-border-radius);
|
|
4304
|
+
height: var(--llm-scroll-proposition-border-radius);
|
|
4305
|
+
transform: rotate(90deg);
|
|
4306
|
+
}
|
|
4307
|
+
|
|
4276
4308
|
/**
|
|
4277
4309
|
* Swiper 8.4.7
|
|
4278
4310
|
* Most modern mobile touch slider and framework with hardware accelerated transitions
|
package/dist/umd/index.js
CHANGED
|
@@ -18065,6 +18065,13 @@
|
|
|
18065
18065
|
accent: "var(--llm-color-base-100)",
|
|
18066
18066
|
borderRadius: "8px"
|
|
18067
18067
|
};
|
|
18068
|
+
var scrollProposition = {
|
|
18069
|
+
size: "32px",
|
|
18070
|
+
borderRadius: "16px",
|
|
18071
|
+
background: "var(--llm-color-neutral-100)",
|
|
18072
|
+
foreground: "var(--llm-color-neutral-900)",
|
|
18073
|
+
boxShadow: "0 6px 8px -4px rgba(0, 0, 0, 0.5)"
|
|
18074
|
+
};
|
|
18068
18075
|
var promptSubmit = {
|
|
18069
18076
|
background: "var(--llm-trigger-background)",
|
|
18070
18077
|
foreground: "var(--llm-trigger-foreground)"
|
|
@@ -18145,6 +18152,7 @@
|
|
|
18145
18152
|
hintIcon: hintIcon,
|
|
18146
18153
|
pill: pill,
|
|
18147
18154
|
input: input,
|
|
18155
|
+
scrollProposition: scrollProposition,
|
|
18148
18156
|
promptSubmit: promptSubmit,
|
|
18149
18157
|
checkbox: checkbox,
|
|
18150
18158
|
user: user,
|
|
@@ -22707,6 +22715,7 @@ ${Object.entries(vars).map(_ref2 => {
|
|
|
22707
22715
|
let {
|
|
22708
22716
|
threadId,
|
|
22709
22717
|
dismissable = true,
|
|
22718
|
+
imperative = false,
|
|
22710
22719
|
skipCustomIntro = false,
|
|
22711
22720
|
opened,
|
|
22712
22721
|
embedded,
|
|
@@ -22716,6 +22725,7 @@ ${Object.entries(vars).map(_ref2 => {
|
|
|
22716
22725
|
const props = {
|
|
22717
22726
|
opened: opened != null ? opened : embedded != null || threadId != null ? true : false,
|
|
22718
22727
|
dismissable: embedded ? false : dismissable,
|
|
22728
|
+
imperative,
|
|
22719
22729
|
skipCustomIntro: skipCustomIntro,
|
|
22720
22730
|
embedded: embedded || false,
|
|
22721
22731
|
introed: skipCustomIntro ? true : false,
|
|
@@ -22723,6 +22733,7 @@ ${Object.entries(vars).map(_ref2 => {
|
|
|
22723
22733
|
fixed: false,
|
|
22724
22734
|
idle: true,
|
|
22725
22735
|
visible: false,
|
|
22736
|
+
scrollable: false,
|
|
22726
22737
|
direction: 0
|
|
22727
22738
|
};
|
|
22728
22739
|
let scroller_ = undefined;
|
|
@@ -22737,12 +22748,14 @@ ${Object.entries(vars).map(_ref2 => {
|
|
|
22737
22748
|
const scrolled = targetScroll > 100;
|
|
22738
22749
|
const fixed = direction == -1 && scrolled;
|
|
22739
22750
|
const hidden = direction == 1 && scrolled;
|
|
22751
|
+
const scrollable = limit - targetScroll > 100;
|
|
22740
22752
|
const state = get();
|
|
22741
|
-
if (state.hidden !== hidden || state.fixed !== fixed || state.direction !== direction) {
|
|
22753
|
+
if (state.hidden !== hidden || state.fixed !== fixed || state.direction !== direction || state.scrollable !== scrollable) {
|
|
22742
22754
|
set(state => ({
|
|
22743
22755
|
hidden,
|
|
22744
22756
|
fixed,
|
|
22745
|
-
direction
|
|
22757
|
+
direction,
|
|
22758
|
+
scrollable
|
|
22746
22759
|
}));
|
|
22747
22760
|
}
|
|
22748
22761
|
// console.log('onScrollerScroll', event, event.progress, event.direction);
|
|
@@ -22871,6 +22884,9 @@ ${Object.entries(vars).map(_ref2 => {
|
|
|
22871
22884
|
setVisible: visible => set(state => ({
|
|
22872
22885
|
visible
|
|
22873
22886
|
})),
|
|
22887
|
+
setScrollable: scrollable => set(state => ({
|
|
22888
|
+
scrollable
|
|
22889
|
+
})),
|
|
22874
22890
|
setScroller: scroller => {
|
|
22875
22891
|
if (scroller_ !== scroller) {
|
|
22876
22892
|
if (scroller_) {
|
|
@@ -30392,7 +30408,12 @@ void main(void) {
|
|
|
30392
30408
|
})]
|
|
30393
30409
|
}), /*#__PURE__*/jsxRuntimeExports.jsxs("nav", {
|
|
30394
30410
|
className: "llm__prompt-footer",
|
|
30395
|
-
children: [/*#__PURE__*/jsxRuntimeExports.
|
|
30411
|
+
children: [disclaimer && /*#__PURE__*/jsxRuntimeExports.jsx("div", {
|
|
30412
|
+
className: "llm__prompt-disclaimer",
|
|
30413
|
+
dangerouslySetInnerHTML: {
|
|
30414
|
+
__html: disclaimer
|
|
30415
|
+
}
|
|
30416
|
+
}), /*#__PURE__*/jsxRuntimeExports.jsxs("a", {
|
|
30396
30417
|
className: "llm__prompt-powered-by",
|
|
30397
30418
|
href: "https://www.websolute.com/",
|
|
30398
30419
|
target: "_blank",
|
|
@@ -30403,11 +30424,6 @@ void main(void) {
|
|
|
30403
30424
|
}), " ", /*#__PURE__*/jsxRuntimeExports.jsx(IconWebsolute, {
|
|
30404
30425
|
"aria-label": "Websolute"
|
|
30405
30426
|
})]
|
|
30406
|
-
}), disclaimer && /*#__PURE__*/jsxRuntimeExports.jsx("div", {
|
|
30407
|
-
className: "llm__prompt-disclaimer",
|
|
30408
|
-
dangerouslySetInnerHTML: {
|
|
30409
|
-
__html: disclaimer
|
|
30410
|
-
}
|
|
30411
30427
|
})]
|
|
30412
30428
|
})]
|
|
30413
30429
|
});
|
|
@@ -30470,7 +30486,8 @@ void main(void) {
|
|
|
30470
30486
|
const app = useLlm(state => state.app);
|
|
30471
30487
|
const introed = useLlmView(state => state.introed);
|
|
30472
30488
|
const {
|
|
30473
|
-
setScroller
|
|
30489
|
+
setScroller,
|
|
30490
|
+
setScrollable
|
|
30474
30491
|
} = useLlmView(state => state.actions);
|
|
30475
30492
|
const allowScroll = !app?.contents.customIntro || introed;
|
|
30476
30493
|
reactExports.useEffect(() => {
|
|
@@ -30543,6 +30560,33 @@ void main(void) {
|
|
|
30543
30560
|
}
|
|
30544
30561
|
return () => {};
|
|
30545
30562
|
}, []);
|
|
30563
|
+
reactExports.useEffect(() => {
|
|
30564
|
+
// console.log('useCanvasOffscreen', canvasRef.current);
|
|
30565
|
+
if (isBrowser$1 && innerRef.current && scrollerRef.current) {
|
|
30566
|
+
const scroller = scrollerRef.current;
|
|
30567
|
+
const element = innerRef.current;
|
|
30568
|
+
const target = element.querySelector('.llm__content');
|
|
30569
|
+
const onResize = _ref2 => {
|
|
30570
|
+
// const entryHeight = entry.contentRect.height;
|
|
30571
|
+
const limit = element.scrollHeight - element.offsetHeight;
|
|
30572
|
+
const targetScroll = element.scrollTop;
|
|
30573
|
+
// const scrollable = limit - targetScroll > 100;
|
|
30574
|
+
// console.log('onResize', limit, targetScroll, scrollable);
|
|
30575
|
+
scroller.emit('scroll', {
|
|
30576
|
+
limit,
|
|
30577
|
+
targetScroll,
|
|
30578
|
+
direction: 0
|
|
30579
|
+
});
|
|
30580
|
+
};
|
|
30581
|
+
const resizeObserver = new ResizeObserver(onResize);
|
|
30582
|
+
resizeObserver.observe(target);
|
|
30583
|
+
return () => {
|
|
30584
|
+
resizeObserver.disconnect();
|
|
30585
|
+
};
|
|
30586
|
+
} else {
|
|
30587
|
+
return () => {};
|
|
30588
|
+
}
|
|
30589
|
+
}, [innerRef]);
|
|
30546
30590
|
const classNames = getClassNames('llm__scroller', {
|
|
30547
30591
|
'-scroller-disabled': !allowScroll
|
|
30548
30592
|
});
|
|
@@ -30553,6 +30597,60 @@ void main(void) {
|
|
|
30553
30597
|
});
|
|
30554
30598
|
};
|
|
30555
30599
|
|
|
30600
|
+
const slideIn = function (direction, percent) {
|
|
30601
|
+
if (direction === void 0) {
|
|
30602
|
+
direction = 1;
|
|
30603
|
+
}
|
|
30604
|
+
if (percent === void 0) {
|
|
30605
|
+
percent = 30;
|
|
30606
|
+
}
|
|
30607
|
+
return {
|
|
30608
|
+
hidden: {
|
|
30609
|
+
y: `${percent * direction}%`,
|
|
30610
|
+
opacity: 0
|
|
30611
|
+
},
|
|
30612
|
+
show: {
|
|
30613
|
+
y: 0,
|
|
30614
|
+
opacity: 1,
|
|
30615
|
+
transition: {
|
|
30616
|
+
type: 'tween',
|
|
30617
|
+
duration: .3
|
|
30618
|
+
}
|
|
30619
|
+
},
|
|
30620
|
+
exit: {
|
|
30621
|
+
y: `${percent * direction}%`,
|
|
30622
|
+
opacity: 0,
|
|
30623
|
+
transition: {
|
|
30624
|
+
type: 'tween',
|
|
30625
|
+
duration: .2
|
|
30626
|
+
}
|
|
30627
|
+
}
|
|
30628
|
+
};
|
|
30629
|
+
};
|
|
30630
|
+
function ScrollProposition() {
|
|
30631
|
+
const label = useLabel();
|
|
30632
|
+
// const hasChunks = useLlm(state => state.chunks != null);
|
|
30633
|
+
const scrollable = useLlmView(state => state.scrollable);
|
|
30634
|
+
const {
|
|
30635
|
+
scrollToBottom
|
|
30636
|
+
} = useLlmView(state => state.actions);
|
|
30637
|
+
const onClick = () => {
|
|
30638
|
+
scrollToBottom();
|
|
30639
|
+
};
|
|
30640
|
+
return /*#__PURE__*/jsxRuntimeExports.jsx(AnimatePresence, {
|
|
30641
|
+
children: scrollable && /*#__PURE__*/jsxRuntimeExports.jsx(motion.button, {
|
|
30642
|
+
className: "llm__scroll-proposition",
|
|
30643
|
+
"aria-label": label('llm.scrollToBottom'),
|
|
30644
|
+
onClick: onClick,
|
|
30645
|
+
variants: slideIn(-1),
|
|
30646
|
+
initial: "hidden",
|
|
30647
|
+
animate: "show",
|
|
30648
|
+
exit: "exit",
|
|
30649
|
+
children: /*#__PURE__*/jsxRuntimeExports.jsx(IconLlmArrowRight, {})
|
|
30650
|
+
})
|
|
30651
|
+
});
|
|
30652
|
+
}
|
|
30653
|
+
|
|
30556
30654
|
const Dialog = _ref => {
|
|
30557
30655
|
let {
|
|
30558
30656
|
children,
|
|
@@ -33760,6 +33858,7 @@ void main(void) {
|
|
|
33760
33858
|
});
|
|
33761
33859
|
const shouldShowPrompt = !app?.contents.customIntro || introed;
|
|
33762
33860
|
const trapRef = reactExports.useRef(null);
|
|
33861
|
+
// !!! do not remove
|
|
33763
33862
|
useFocusTrap(trapRef, {
|
|
33764
33863
|
disabled: embedded
|
|
33765
33864
|
});
|
|
@@ -33791,13 +33890,13 @@ void main(void) {
|
|
|
33791
33890
|
children: [app && !theme.canvas.enabled && /*#__PURE__*/jsxRuntimeExports.jsx("div", {
|
|
33792
33891
|
className: "llm__underlay",
|
|
33793
33892
|
"aria-hidden": true
|
|
33794
|
-
}), /*#__PURE__*/jsxRuntimeExports.
|
|
33893
|
+
}), /*#__PURE__*/jsxRuntimeExports.jsxs(motion.main, {
|
|
33795
33894
|
className: "llm__bottom",
|
|
33796
33895
|
variants: slideIn(1),
|
|
33797
33896
|
initial: "hidden",
|
|
33798
33897
|
animate: "show",
|
|
33799
33898
|
exit: "exit",
|
|
33800
|
-
children: /*#__PURE__*/jsxRuntimeExports.jsx(Prompt, {})
|
|
33899
|
+
children: [/*#__PURE__*/jsxRuntimeExports.jsx(ScrollProposition, {}), /*#__PURE__*/jsxRuntimeExports.jsx(Prompt, {})]
|
|
33801
33900
|
})]
|
|
33802
33901
|
})]
|
|
33803
33902
|
}, "main-container");
|
|
@@ -33888,6 +33987,7 @@ void main(void) {
|
|
|
33888
33987
|
const opened = useLlmView(state => state.opened);
|
|
33889
33988
|
const introed = useLlmView(state => state.introed);
|
|
33890
33989
|
const embedded = useLlmView(state => state.embedded);
|
|
33990
|
+
const imperative = useLlmView(state => state.imperative);
|
|
33891
33991
|
reactExports.useImperativeHandle(ref, () => ({
|
|
33892
33992
|
open: () => {
|
|
33893
33993
|
open();
|
|
@@ -33907,7 +34007,7 @@ void main(void) {
|
|
|
33907
34007
|
document.documentElement.style.overflow = opened ? 'hidden' : 'auto';
|
|
33908
34008
|
}
|
|
33909
34009
|
}, [opened, embedded]);
|
|
33910
|
-
const shouldShowTrigger = !opened && !idle && !embed || app?.contents.customIntro && !introed;
|
|
34010
|
+
const shouldShowTrigger = !opened && !idle && !embed && !imperative || app?.contents.customIntro && !introed;
|
|
33911
34011
|
const classNames = getClassNames('llm', {
|
|
33912
34012
|
'-open': opened,
|
|
33913
34013
|
'-embedded': embedded,
|
|
@@ -34285,6 +34385,12 @@ void main(void) {
|
|
|
34285
34385
|
en: "Hide",
|
|
34286
34386
|
it: "Nascondi"
|
|
34287
34387
|
}
|
|
34388
|
+
}, {
|
|
34389
|
+
id: "llm.scrollToBottom",
|
|
34390
|
+
text: {
|
|
34391
|
+
en: "Scroll to bottom",
|
|
34392
|
+
it: "Scorri in fondo"
|
|
34393
|
+
}
|
|
34288
34394
|
}];
|
|
34289
34395
|
|
|
34290
34396
|
const App = _a => {
|
|
@@ -34365,6 +34471,7 @@ void main(void) {
|
|
|
34365
34471
|
// console.log('App', llmRef.current, instance);
|
|
34366
34472
|
Object.assign(instance, llmRef.current);
|
|
34367
34473
|
}
|
|
34474
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
34368
34475
|
}, []);
|
|
34369
34476
|
return jsxRuntimeExports.jsx(ErrorBoundary, {
|
|
34370
34477
|
FallbackComponent: ErrorHandler,
|