@solibo/solibo-ui 2.2.8 → 2.2.9
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/assets/index43.css +1 -1
- package/dist/components/editor/index.cjs +1 -1
- package/dist/components/editor/index.js +433 -372
- package/dist/components/messages/index.cjs +1 -1
- package/dist/components/messages/index.js +63 -62
- package/dist/index.d.ts +8 -2
- package/dist/tokens.json +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index15.css');const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index15.css');const p=require("react/jsx-runtime"),q=require("classix"),m=require("react"),j=require("../editor/index.cjs"),A=require("../list/index.cjs"),B=require("../tooltip/index.cjs"),D=require("../message/index.cjs"),H="_messages_88pw2_1",P="_fill_88pw2_22",y={messages:H,fill:P};function k(R){const v=m.useRef(null),a=m.useRef(()=>{});return m.useLayoutEffect(()=>{const e=v.current;if(!e)return;let c=!0,d=e.scrollTop,s;const i=()=>{const t=e.getBoundingClientRect().top,o=Array.from(e.children).find(x=>x instanceof HTMLElement&&x.getBoundingClientRect().bottom>t);s=o?{element:o,offset:o.getBoundingClientRect().top-t}:void 0},g=()=>{if(Math.abs(e.scrollTop-d)<=.5)return!1;const t=Math.max(0,e.scrollHeight-e.clientHeight);return!(d>t&&Math.abs(e.scrollTop-t)<=.5)},l=()=>{if(g()&&(c=!1,i()),c)e.scrollTop=e.scrollHeight;else if(s!=null&&s.element.isConnected&&e.contains(s.element)){const o=s.element.getBoundingClientRect().top-e.getBoundingClientRect().top-s.offset;Math.abs(o)>.5&&(e.scrollTop+=o)}d=e.scrollTop,i()};a.current=l;const r=()=>{c=!1,i()},h=()=>{g()&&(c=!1),d=e.scrollTop,i()},E=t=>{t.target===e&&r()},w=t=>{const o=t.target;o instanceof Element&&o.closest('input, textarea, select, [contenteditable="true"]')||["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "].includes(t.key)&&r()},n=typeof ResizeObserver>"u"?void 0:new ResizeObserver(l),u=()=>{n==null||n.disconnect(),n==null||n.observe(e),Array.from(e.children).forEach(t=>n==null?void 0:n.observe(t)),l()},L=new MutationObserver(u);return L.observe(e,{childList:!0,subtree:!0,characterData:!0}),u(),e.addEventListener("scroll",h,{passive:!0}),e.addEventListener("wheel",r,{passive:!0}),e.addEventListener("touchmove",r,{passive:!0}),e.addEventListener("pointerdown",E),e.addEventListener("keydown",w),e.addEventListener("load",l,!0),e.addEventListener("error",l,!0),()=>{a.current=()=>{},n==null||n.disconnect(),L.disconnect(),e.removeEventListener("scroll",h),e.removeEventListener("wheel",r),e.removeEventListener("touchmove",r),e.removeEventListener("pointerdown",E),e.removeEventListener("keydown",w),e.removeEventListener("load",l,!0),e.removeEventListener("error",l,!0)}},[]),m.useLayoutEffect(()=>a.current(),[R]),v}const C=({autofocus:R=!0,fill:v=!1,files:a,handleUpload:e,inlineImages:c,maxEditorRows:d=5,message:s="",messages:i,minEditorRows:g=1,onChange:l,onFilesChange:r,onInlineImagesChange:h,onSubmit:E,placeholder:w,resizableEditor:n=!1,sending:u,submitLabel:L="Send message",tooltipLabel:t})=>{var _;const[o,x]=m.useState([]),b=a??o,M=(_=i[i.length-1])==null?void 0:_.id,T=k(M),S=s.replace(/<[^>]*>/g,"").replace(/ /g," ").trim()==="";return p.jsxs("div",{className:q(y.messages,v&&y.fill),"data-component":"messages",children:[p.jsx(A.List,{"data-message-list":!0,ref:T,tabIndex:0,children:i.map(f=>p.jsx(D.Message,{...f},f.id))}),t&&p.jsx(B.Tooltip,{variant:"static",children:t}),p.jsx(j.Editor,{autofocus:R,content:s,disabled:u||S&&b.length===0&&!(c!=null&&c.length),files:b,inlineImages:c,isSubmitting:u,maxRows:d,minRows:g,onChange:l,onFilesChange:f=>{a===void 0&&x(f),r==null||r(f)},onInlineImagesChange:h,onSubmit:E,onUpload:e,placeholder:w,resizable:n?"top":!1,submitLabel:L})]})};exports.Messages=C;
|
|
@@ -1,98 +1,99 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
3
|
-
import { useRef as
|
|
4
|
-
import { Editor as
|
|
5
|
-
import { List as
|
|
6
|
-
import { Tooltip as
|
|
7
|
-
import { Message as
|
|
8
|
-
import '../../assets/index15.css';const
|
|
9
|
-
messages:
|
|
10
|
-
fill:
|
|
1
|
+
import { jsxs as B, jsx as L } from "react/jsx-runtime";
|
|
2
|
+
import D from "classix";
|
|
3
|
+
import { useRef as T, useLayoutEffect as y, useState as H } from "react";
|
|
4
|
+
import { Editor as k } from "../editor/index.js";
|
|
5
|
+
import { List as C } from "../list/index.js";
|
|
6
|
+
import { Tooltip as P } from "../tooltip/index.js";
|
|
7
|
+
import { Message as U } from "../message/index.js";
|
|
8
|
+
import '../../assets/index15.css';const j = "_messages_88pw2_1", q = "_fill_88pw2_22", x = {
|
|
9
|
+
messages: j,
|
|
10
|
+
fill: q
|
|
11
11
|
};
|
|
12
|
-
function
|
|
13
|
-
const
|
|
12
|
+
function K(R) {
|
|
13
|
+
const m = T(null), a = T(() => {
|
|
14
14
|
});
|
|
15
|
-
return
|
|
16
|
-
const e =
|
|
15
|
+
return y(() => {
|
|
16
|
+
const e = m.current;
|
|
17
17
|
if (!e) return;
|
|
18
|
-
let l = !0, d = e.scrollTop,
|
|
18
|
+
let l = !0, d = e.scrollTop, s;
|
|
19
19
|
const i = () => {
|
|
20
|
-
const
|
|
21
|
-
|
|
20
|
+
const t = e.getBoundingClientRect().top, n = Array.from(e.children).find((E) => E instanceof HTMLElement && E.getBoundingClientRect().bottom > t);
|
|
21
|
+
s = n ? {
|
|
22
22
|
element: n,
|
|
23
|
-
offset: n.getBoundingClientRect().top -
|
|
23
|
+
offset: n.getBoundingClientRect().top - t
|
|
24
24
|
} : void 0;
|
|
25
|
-
},
|
|
25
|
+
}, p = () => {
|
|
26
26
|
if (Math.abs(e.scrollTop - d) <= 0.5) return !1;
|
|
27
|
-
const
|
|
28
|
-
return !(d >
|
|
27
|
+
const t = Math.max(0, e.scrollHeight - e.clientHeight);
|
|
28
|
+
return !(d > t && Math.abs(e.scrollTop - t) <= 0.5);
|
|
29
29
|
}, c = () => {
|
|
30
|
-
if (
|
|
30
|
+
if (p() && (l = !1, i()), l)
|
|
31
31
|
e.scrollTop = e.scrollHeight;
|
|
32
|
-
else if (
|
|
33
|
-
const n =
|
|
32
|
+
else if (s != null && s.element.isConnected && e.contains(s.element)) {
|
|
33
|
+
const n = s.element.getBoundingClientRect().top - e.getBoundingClientRect().top - s.offset;
|
|
34
34
|
Math.abs(n) > 0.5 && (e.scrollTop += n);
|
|
35
35
|
}
|
|
36
36
|
d = e.scrollTop, i();
|
|
37
37
|
};
|
|
38
38
|
a.current = c;
|
|
39
|
-
const
|
|
39
|
+
const r = () => {
|
|
40
40
|
l = !1, i();
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
},
|
|
46
|
-
const n =
|
|
47
|
-
n instanceof Element && n.closest('input, textarea, select, [contenteditable="true"]') || ["ArrowUp", "ArrowDown", "PageUp", "PageDown", "Home", "End", " "].includes(
|
|
48
|
-
},
|
|
49
|
-
|
|
50
|
-
},
|
|
51
|
-
return
|
|
41
|
+
}, v = () => {
|
|
42
|
+
p() && (l = !1), d = e.scrollTop, i();
|
|
43
|
+
}, g = (t) => {
|
|
44
|
+
t.target === e && r();
|
|
45
|
+
}, h = (t) => {
|
|
46
|
+
const n = t.target;
|
|
47
|
+
n instanceof Element && n.closest('input, textarea, select, [contenteditable="true"]') || ["ArrowUp", "ArrowDown", "PageUp", "PageDown", "Home", "End", " "].includes(t.key) && r();
|
|
48
|
+
}, o = typeof ResizeObserver > "u" ? void 0 : new ResizeObserver(c), f = () => {
|
|
49
|
+
o == null || o.disconnect(), o == null || o.observe(e), Array.from(e.children).forEach((t) => o == null ? void 0 : o.observe(t)), c();
|
|
50
|
+
}, w = new MutationObserver(f);
|
|
51
|
+
return w.observe(e, {
|
|
52
52
|
childList: !0,
|
|
53
53
|
subtree: !0,
|
|
54
54
|
characterData: !0
|
|
55
|
-
}),
|
|
55
|
+
}), f(), e.addEventListener("scroll", v, {
|
|
56
56
|
passive: !0
|
|
57
|
-
}), e.addEventListener("wheel",
|
|
57
|
+
}), e.addEventListener("wheel", r, {
|
|
58
58
|
passive: !0
|
|
59
|
-
}), e.addEventListener("touchmove",
|
|
59
|
+
}), e.addEventListener("touchmove", r, {
|
|
60
60
|
passive: !0
|
|
61
|
-
}), e.addEventListener("pointerdown",
|
|
61
|
+
}), e.addEventListener("pointerdown", g), e.addEventListener("keydown", h), e.addEventListener("load", c, !0), e.addEventListener("error", c, !0), () => {
|
|
62
62
|
a.current = () => {
|
|
63
|
-
},
|
|
63
|
+
}, o == null || o.disconnect(), w.disconnect(), e.removeEventListener("scroll", v), e.removeEventListener("wheel", r), e.removeEventListener("touchmove", r), e.removeEventListener("pointerdown", g), e.removeEventListener("keydown", h), e.removeEventListener("load", c, !0), e.removeEventListener("error", c, !0);
|
|
64
64
|
};
|
|
65
|
-
}, []),
|
|
65
|
+
}, []), y(() => a.current(), [R]), m;
|
|
66
66
|
}
|
|
67
|
-
const
|
|
67
|
+
const W = ({
|
|
68
68
|
autofocus: R = !0,
|
|
69
|
-
fill:
|
|
69
|
+
fill: m = !1,
|
|
70
70
|
files: a,
|
|
71
71
|
handleUpload: e,
|
|
72
72
|
inlineImages: l,
|
|
73
73
|
maxEditorRows: d = 5,
|
|
74
|
-
message:
|
|
74
|
+
message: s = "",
|
|
75
75
|
messages: i,
|
|
76
|
-
minEditorRows:
|
|
76
|
+
minEditorRows: p = 1,
|
|
77
77
|
onChange: c,
|
|
78
|
-
onFilesChange:
|
|
79
|
-
onInlineImagesChange:
|
|
80
|
-
onSubmit:
|
|
81
|
-
placeholder:
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
78
|
+
onFilesChange: r,
|
|
79
|
+
onInlineImagesChange: v,
|
|
80
|
+
onSubmit: g,
|
|
81
|
+
placeholder: h,
|
|
82
|
+
resizableEditor: o = !1,
|
|
83
|
+
sending: f,
|
|
84
|
+
submitLabel: w = "Send message",
|
|
85
|
+
tooltipLabel: t
|
|
85
86
|
}) => {
|
|
86
|
-
var
|
|
87
|
-
const [
|
|
88
|
-
return /* @__PURE__ */
|
|
89
|
-
/* @__PURE__ */ L(
|
|
90
|
-
|
|
91
|
-
/* @__PURE__ */ L(
|
|
92
|
-
a === void 0 &&
|
|
93
|
-
}, onInlineImagesChange:
|
|
87
|
+
var M;
|
|
88
|
+
const [n, E] = H([]), b = a ?? n, S = (M = i[i.length - 1]) == null ? void 0 : M.id, _ = K(S), A = s.replace(/<[^>]*>/g, "").replace(/ /g, " ").trim() === "";
|
|
89
|
+
return /* @__PURE__ */ B("div", { className: D(x.messages, m && x.fill), "data-component": "messages", children: [
|
|
90
|
+
/* @__PURE__ */ L(C, { "data-message-list": !0, ref: _, tabIndex: 0, children: i.map((u) => /* @__PURE__ */ L(U, { ...u }, u.id)) }),
|
|
91
|
+
t && /* @__PURE__ */ L(P, { variant: "static", children: t }),
|
|
92
|
+
/* @__PURE__ */ L(k, { autofocus: R, content: s, disabled: f || A && b.length === 0 && !(l != null && l.length), files: b, inlineImages: l, isSubmitting: f, maxRows: d, minRows: p, onChange: c, onFilesChange: (u) => {
|
|
93
|
+
a === void 0 && E(u), r == null || r(u);
|
|
94
|
+
}, onInlineImagesChange: v, onSubmit: g, onUpload: e, placeholder: h, resizable: o ? "top" : !1, submitLabel: w })
|
|
94
95
|
] });
|
|
95
96
|
};
|
|
96
97
|
export {
|
|
97
|
-
|
|
98
|
+
W as Messages
|
|
98
99
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -304,7 +304,7 @@ declare type DropzoneProps = {
|
|
|
304
304
|
variant?: 'default' | 'minimal';
|
|
305
305
|
};
|
|
306
306
|
|
|
307
|
-
export declare const Editor: ({ autofocus, autolink, content, disabled, errorMessage, fill, files, inline, inlineImages, invalid, isSubmitting, maxRows, minRows, onChange, onFilesChange, onInlineImagesChange, onSubmit, onUpload, placeholder, required, submitLabel, }: EditorProps) => JSX.Element;
|
|
307
|
+
export declare const Editor: ({ autofocus, autolink, content, disabled, errorMessage, fill, files, inline, inlineImages, invalid, isSubmitting, maxRows, minRows, onChange, onFilesChange, onInlineImagesChange, onSubmit, onUpload, placeholder, required, resizable, submitLabel, }: EditorProps) => JSX.Element;
|
|
308
308
|
|
|
309
309
|
export declare type EditorProps = {
|
|
310
310
|
autofocus?: boolean;
|
|
@@ -327,6 +327,10 @@ export declare type EditorProps = {
|
|
|
327
327
|
onUpload?: (files: FileList) => Promise<void> | void;
|
|
328
328
|
placeholder?: string;
|
|
329
329
|
required?: boolean;
|
|
330
|
+
/** Enables vertical resizing: true uses the native bottom grip, 'top' uses a top
|
|
331
|
+
* handle that grows upward. Ignored with fill. Automatic sizing keeps minRows/maxRows
|
|
332
|
+
* until resized; manual expansion is not capped by maxRows. */
|
|
333
|
+
resizable?: boolean | 'top';
|
|
330
334
|
submitLabel?: string;
|
|
331
335
|
};
|
|
332
336
|
|
|
@@ -810,7 +814,7 @@ export declare type MessageOptions = {
|
|
|
810
814
|
type?: 'default' | 'minimal' | 'system' | 'user';
|
|
811
815
|
};
|
|
812
816
|
|
|
813
|
-
export declare const Messages: ({ autofocus, fill, files, handleUpload, inlineImages, maxEditorRows, message, messages, minEditorRows, onChange, onFilesChange, onInlineImagesChange, onSubmit, placeholder, sending, submitLabel, tooltipLabel, }: MessagesProps) => JSX.Element;
|
|
817
|
+
export declare const Messages: ({ autofocus, fill, files, handleUpload, inlineImages, maxEditorRows, message, messages, minEditorRows, onChange, onFilesChange, onInlineImagesChange, onSubmit, placeholder, resizableEditor, sending, submitLabel, tooltipLabel, }: MessagesProps) => JSX.Element;
|
|
814
818
|
|
|
815
819
|
export declare type MessagesProps = {
|
|
816
820
|
autofocus?: boolean;
|
|
@@ -827,6 +831,8 @@ export declare type MessagesProps = {
|
|
|
827
831
|
onInlineImagesChange?: (images: PendingInlineImage[]) => void;
|
|
828
832
|
onSubmit: () => Promise<void> | void;
|
|
829
833
|
placeholder?: string;
|
|
834
|
+
/** Adds a top handle: drag upward to grow beyond maxEditorRows. Automatic sizing is preserved until dragged. */
|
|
835
|
+
resizableEditor?: boolean;
|
|
830
836
|
sending: boolean;
|
|
831
837
|
submitLabel?: string;
|
|
832
838
|
tooltipLabel?: string;
|
package/dist/tokens.json
CHANGED