@elliemae/ds-chat-container 3.6.0-next.0
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/cjs/ChatContainer.js +174 -0
- package/dist/cjs/ChatContainer.js.map +7 -0
- package/dist/cjs/ChatContainerDataTestids.js +42 -0
- package/dist/cjs/ChatContainerDataTestids.js.map +7 -0
- package/dist/cjs/index.js +35 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/parts/chat-composer/ChatContainerComposer.js +195 -0
- package/dist/cjs/parts/chat-composer/ChatContainerComposer.js.map +7 -0
- package/dist/cjs/parts/chat-composer/index.js +33 -0
- package/dist/cjs/parts/chat-composer/index.js.map +7 -0
- package/dist/cjs/parts/chat-composer/styled.js +99 -0
- package/dist/cjs/parts/chat-composer/styled.js.map +7 -0
- package/dist/cjs/parts/chat-container-messages-list/ChatContainerMessagesList.js +146 -0
- package/dist/cjs/parts/chat-container-messages-list/ChatContainerMessagesList.js.map +7 -0
- package/dist/cjs/parts/chat-container-messages-list/index.js +33 -0
- package/dist/cjs/parts/chat-container-messages-list/index.js.map +7 -0
- package/dist/cjs/parts/chat-container-messages-list/styled.js +110 -0
- package/dist/cjs/parts/chat-container-messages-list/styled.js.map +7 -0
- package/dist/cjs/parts/chat-container-messages-list/useActionRef.js +61 -0
- package/dist/cjs/parts/chat-container-messages-list/useActionRef.js.map +7 -0
- package/dist/cjs/parts/chat-container-messages-list/useChatContainerMessageList.js +106 -0
- package/dist/cjs/parts/chat-container-messages-list/useChatContainerMessageList.js.map +7 -0
- package/dist/cjs/parts/chat-container-messages-list/useFocusAndScrollHelpers.js +93 -0
- package/dist/cjs/parts/chat-container-messages-list/useFocusAndScrollHelpers.js.map +7 -0
- package/dist/cjs/parts/chat-container-messages-list/useGetNewMessages.js +46 -0
- package/dist/cjs/parts/chat-container-messages-list/useGetNewMessages.js.map +7 -0
- package/dist/cjs/parts/chat-container-messages-list/useGlobalEventListener.js +59 -0
- package/dist/cjs/parts/chat-container-messages-list/useGlobalEventListener.js.map +7 -0
- package/dist/cjs/parts/chat-container-messages-list/useKeyboard.js +151 -0
- package/dist/cjs/parts/chat-container-messages-list/useKeyboard.js.map +7 -0
- package/dist/cjs/parts/index.js +27 -0
- package/dist/cjs/parts/index.js.map +7 -0
- package/dist/cjs/react-desc-prop-types.js +184 -0
- package/dist/cjs/react-desc-prop-types.js.map +7 -0
- package/dist/cjs/styled.js +109 -0
- package/dist/cjs/styled.js.map +7 -0
- package/dist/esm/ChatContainer.js +153 -0
- package/dist/esm/ChatContainer.js.map +7 -0
- package/dist/esm/ChatContainerDataTestids.js +16 -0
- package/dist/esm/ChatContainerDataTestids.js.map +7 -0
- package/dist/esm/index.js +9 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/parts/chat-composer/ChatContainerComposer.js +175 -0
- package/dist/esm/parts/chat-composer/ChatContainerComposer.js.map +7 -0
- package/dist/esm/parts/chat-composer/index.js +7 -0
- package/dist/esm/parts/chat-composer/index.js.map +7 -0
- package/dist/esm/parts/chat-composer/styled.js +73 -0
- package/dist/esm/parts/chat-composer/styled.js.map +7 -0
- package/dist/esm/parts/chat-container-messages-list/ChatContainerMessagesList.js +128 -0
- package/dist/esm/parts/chat-container-messages-list/ChatContainerMessagesList.js.map +7 -0
- package/dist/esm/parts/chat-container-messages-list/index.js +7 -0
- package/dist/esm/parts/chat-container-messages-list/index.js.map +7 -0
- package/dist/esm/parts/chat-container-messages-list/styled.js +84 -0
- package/dist/esm/parts/chat-container-messages-list/styled.js.map +7 -0
- package/dist/esm/parts/chat-container-messages-list/useActionRef.js +35 -0
- package/dist/esm/parts/chat-container-messages-list/useActionRef.js.map +7 -0
- package/dist/esm/parts/chat-container-messages-list/useChatContainerMessageList.js +84 -0
- package/dist/esm/parts/chat-container-messages-list/useChatContainerMessageList.js.map +7 -0
- package/dist/esm/parts/chat-container-messages-list/useFocusAndScrollHelpers.js +67 -0
- package/dist/esm/parts/chat-container-messages-list/useFocusAndScrollHelpers.js.map +7 -0
- package/dist/esm/parts/chat-container-messages-list/useGetNewMessages.js +20 -0
- package/dist/esm/parts/chat-container-messages-list/useGetNewMessages.js.map +7 -0
- package/dist/esm/parts/chat-container-messages-list/useGlobalEventListener.js +33 -0
- package/dist/esm/parts/chat-container-messages-list/useGlobalEventListener.js.map +7 -0
- package/dist/esm/parts/chat-container-messages-list/useKeyboard.js +125 -0
- package/dist/esm/parts/chat-container-messages-list/useKeyboard.js.map +7 -0
- package/dist/esm/parts/index.js +4 -0
- package/dist/esm/parts/index.js.map +7 -0
- package/dist/esm/react-desc-prop-types.js +158 -0
- package/dist/esm/react-desc-prop-types.js.map +7 -0
- package/dist/esm/styled.js +83 -0
- package/dist/esm/styled.js.map +7 -0
- package/package.json +162 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var useFocusAndScrollHelpers_exports = {};
|
|
26
|
+
__export(useFocusAndScrollHelpers_exports, {
|
|
27
|
+
useFocusAndScrollHelpers: () => useFocusAndScrollHelpers
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(useFocusAndScrollHelpers_exports);
|
|
30
|
+
var React = __toESM(require("react"));
|
|
31
|
+
var import_react = __toESM(require("react"));
|
|
32
|
+
var import_lodash = require("lodash");
|
|
33
|
+
const useFocusAndScrollHelpers = ({
|
|
34
|
+
propsWithDefault: { onScrollEnds },
|
|
35
|
+
useVirtualHelpers: { scrollToIndex: vScroll },
|
|
36
|
+
pendingOnScroll,
|
|
37
|
+
virtualListRef
|
|
38
|
+
}) => {
|
|
39
|
+
const onScrollStop = import_react.default.useMemo(
|
|
40
|
+
() => (0, import_lodash.debounce)(() => {
|
|
41
|
+
if (document.visibilityState === "hidden") {
|
|
42
|
+
pendingOnScroll.current = true;
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
if (!virtualListRef.current)
|
|
46
|
+
return [];
|
|
47
|
+
pendingOnScroll.current = false;
|
|
48
|
+
const { bottom, top } = virtualListRef.current?.getBoundingClientRect() || {};
|
|
49
|
+
const list = virtualListRef.current.querySelectorAll('[data-element="chat-element-list-item"]');
|
|
50
|
+
const indexList = [];
|
|
51
|
+
list.forEach((item) => {
|
|
52
|
+
const { top: itemTop } = item.getBoundingClientRect();
|
|
53
|
+
const itemPadding = 10;
|
|
54
|
+
if (itemTop + itemPadding < bottom && itemTop + itemPadding > top)
|
|
55
|
+
indexList.push(item.dataset.index || "");
|
|
56
|
+
});
|
|
57
|
+
if (onScrollEnds)
|
|
58
|
+
onScrollEnds(indexList);
|
|
59
|
+
return indexList;
|
|
60
|
+
}, 500),
|
|
61
|
+
[onScrollEnds, pendingOnScroll, virtualListRef]
|
|
62
|
+
);
|
|
63
|
+
const onlyFocus = import_react.default.useCallback(
|
|
64
|
+
(index) => {
|
|
65
|
+
virtualListRef.current?.querySelector(`[data-index="${index}"]`)?.focus();
|
|
66
|
+
},
|
|
67
|
+
[virtualListRef]
|
|
68
|
+
);
|
|
69
|
+
const scrollAndFocus = import_react.default.useCallback(
|
|
70
|
+
(index) => {
|
|
71
|
+
vScroll(index, { align: "center" });
|
|
72
|
+
setTimeout(() => {
|
|
73
|
+
onlyFocus(index.toString());
|
|
74
|
+
}, 300);
|
|
75
|
+
onScrollStop();
|
|
76
|
+
},
|
|
77
|
+
[onScrollStop, onlyFocus, vScroll]
|
|
78
|
+
);
|
|
79
|
+
const checkPendingOnScroll = import_react.default.useCallback(() => {
|
|
80
|
+
if (pendingOnScroll.current === true)
|
|
81
|
+
onScrollStop();
|
|
82
|
+
}, [onScrollStop, pendingOnScroll]);
|
|
83
|
+
return import_react.default.useMemo(
|
|
84
|
+
() => ({
|
|
85
|
+
onScrollStop,
|
|
86
|
+
onlyFocus,
|
|
87
|
+
scrollAndFocus,
|
|
88
|
+
checkPendingOnScroll
|
|
89
|
+
}),
|
|
90
|
+
[onScrollStop, onlyFocus, scrollAndFocus, checkPendingOnScroll]
|
|
91
|
+
);
|
|
92
|
+
};
|
|
93
|
+
//# sourceMappingURL=useFocusAndScrollHelpers.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/parts/chat-container-messages-list/useFocusAndScrollHelpers.ts", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable complexity */\n/* eslint-disable jsx-a11y/no-noninteractive-tabindex */\n/* eslint-disable max-lines */\nimport React from 'react';\nimport { useVirtual } from 'react-virtual';\nimport { debounce } from 'lodash';\nimport { DSChatT } from '../../react-desc-prop-types';\n\ntype UseFocusAndScrollHelpersArgs = {\n propsWithDefault: DSChatT.MessagesListProps;\n useVirtualHelpers: ReturnType<typeof useVirtual>;\n pendingOnScroll: React.MutableRefObject<boolean>;\n virtualListRef: React.MutableRefObject<HTMLDivElement | undefined>;\n};\n\nexport const useFocusAndScrollHelpers = ({\n propsWithDefault: { onScrollEnds },\n useVirtualHelpers: { scrollToIndex: vScroll },\n pendingOnScroll,\n virtualListRef,\n}: UseFocusAndScrollHelpersArgs) => {\n const onScrollStop = React.useMemo(\n () =>\n debounce((): string[] => {\n if (document.visibilityState === 'hidden') {\n pendingOnScroll.current = true;\n return [];\n }\n if (!virtualListRef.current) return [];\n pendingOnScroll.current = false;\n const { bottom, top } = virtualListRef.current?.getBoundingClientRect() || {};\n\n const list = virtualListRef.current.querySelectorAll<HTMLElement>('[data-element=\"chat-element-list-item\"]');\n const indexList: Array<string> = [];\n list.forEach((item: HTMLElement) => {\n const { top: itemTop } = item.getBoundingClientRect();\n\n const itemPadding = 10;\n if (itemTop + itemPadding < bottom && itemTop + itemPadding > top) indexList.push(item.dataset.index || '');\n });\n if (onScrollEnds) onScrollEnds(indexList);\n return indexList;\n }, 500),\n [onScrollEnds, pendingOnScroll, virtualListRef],\n ) as () => string[];\n\n const onlyFocus = React.useCallback(\n (index: string) => {\n (virtualListRef.current?.querySelector(`[data-index=\"${index}\"]`) as HTMLDivElement)?.focus();\n },\n [virtualListRef],\n );\n\n const scrollAndFocus = React.useCallback(\n (index: number) => {\n vScroll(index, { align: 'center' });\n setTimeout(() => {\n onlyFocus(index.toString());\n }, 300);\n onScrollStop();\n },\n [onScrollStop, onlyFocus, vScroll],\n );\n\n const checkPendingOnScroll = React.useCallback(() => {\n if (pendingOnScroll.current === true) onScrollStop();\n }, [onScrollStop, pendingOnScroll]);\n\n return React.useMemo(\n () => ({\n onScrollStop,\n onlyFocus,\n scrollAndFocus,\n checkPendingOnScroll,\n }),\n [onScrollStop, onlyFocus, scrollAndFocus, checkPendingOnScroll],\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AAC;AAClC,iBAAW,MAAM;AACf,kBAAU,MAAM,SAAS,CAAC;AAAA,MAC5B,GAAG,GAAG;AACN,mBAAa;AAAA,IACf;AAAA,IACA,CAAC,cAAc,WAAW,OAAO;AAAA,EACnC;AAEA,QAAM,uBAAuB,aAAAA,QAAM,YAAY,MAAM;AACnD,QAAI,gBAAgB,YAAY;AAAM,mBAAa;AAAA,EACrD,GAAG,CAAC,cAAc,eAAe,CAAC;AAElC,SAAO,aAAAA,QAAM;AAAA,IACX,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,CAAC,cAAc,WAAW,gBAAgB,oBAAoB;AAAA,EAChE;AACF;",
|
|
6
|
+
"names": ["React"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var useGetNewMessages_exports = {};
|
|
26
|
+
__export(useGetNewMessages_exports, {
|
|
27
|
+
useGetNewMessages: () => useGetNewMessages
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(useGetNewMessages_exports);
|
|
30
|
+
var React = __toESM(require("react"));
|
|
31
|
+
var import_react = require("react");
|
|
32
|
+
const useGetNewMessages = (messages) => {
|
|
33
|
+
const [seenMessages, setSeenMessages] = (0, import_react.useState)({});
|
|
34
|
+
const newMessages = (0, import_react.useMemo)(() => {
|
|
35
|
+
const list = [];
|
|
36
|
+
messages.forEach((message) => {
|
|
37
|
+
if (!(message.dsId in seenMessages)) {
|
|
38
|
+
list.push(message);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
setSeenMessages(Object.fromEntries(messages.map((m) => [m.dsId, true])));
|
|
42
|
+
return list;
|
|
43
|
+
}, [messages]);
|
|
44
|
+
return newMessages;
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=useGetNewMessages.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/parts/chat-container-messages-list/useGetNewMessages.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import { useMemo, useState } from 'react';\nimport type { DSChatBubbleT } from '@elliemae/ds-chat-bubble';\n\nexport const useGetNewMessages = (messages: DSChatBubbleT.Props[]) => {\n const [seenMessages, setSeenMessages] = useState<Record<DSChatBubbleT.Props['dsId'], true>>({});\n const newMessages = useMemo(() => {\n const list: DSChatBubbleT.Props[] = [];\n messages.forEach((message) => {\n if (!(message.dsId in seenMessages)) {\n list.push(message);\n }\n });\n setSeenMessages(Object.fromEntries(messages.map((m) => [m.dsId, true])));\n return list;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [messages]);\n\n return newMessages;\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAkC;AAG3B,MAAM,oBAAoB,CAAC,aAAoC;AACpE,QAAM,CAAC,cAAc,eAAe,QAAI,uBAAoD,CAAC,CAAC;AAC9F,QAAM,kBAAc,sBAAQ,MAAM;AAChC,UAAM,OAA8B,CAAC;AACrC,aAAS,QAAQ,CAAC,YAAY;AAC5B,UAAI,EAAE,QAAQ,QAAQ,eAAe;AACnC,aAAK,KAAK,OAAO;AAAA,MACnB;AAAA,IACF,CAAC;AACD,oBAAgB,OAAO,YAAY,SAAS,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC,CAAC,CAAC;AACvE,WAAO;AAAA,EAET,GAAG,CAAC,QAAQ,CAAC;AAEb,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var useGlobalEventListener_exports = {};
|
|
26
|
+
__export(useGlobalEventListener_exports, {
|
|
27
|
+
useGlobalEventListener: () => useGlobalEventListener
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(useGlobalEventListener_exports);
|
|
30
|
+
var React = __toESM(require("react"));
|
|
31
|
+
var import_react = __toESM(require("react"));
|
|
32
|
+
const useGlobalEventListener = ({
|
|
33
|
+
propsWithDefault: { onScrollEnds },
|
|
34
|
+
virtualListRef,
|
|
35
|
+
onScrollStop,
|
|
36
|
+
checkPendingOnScroll
|
|
37
|
+
}) => {
|
|
38
|
+
import_react.default.useEffect(() => {
|
|
39
|
+
let handlerCallback;
|
|
40
|
+
const localVirtualRef = virtualListRef.current;
|
|
41
|
+
const onScroll = () => {
|
|
42
|
+
if (handlerCallback)
|
|
43
|
+
clearTimeout(handlerCallback);
|
|
44
|
+
handlerCallback = setTimeout(onScrollStop, 300);
|
|
45
|
+
};
|
|
46
|
+
if (onScrollEnds) {
|
|
47
|
+
virtualListRef.current?.addEventListener("scroll", onScroll);
|
|
48
|
+
}
|
|
49
|
+
document.addEventListener("visibilitychange", checkPendingOnScroll);
|
|
50
|
+
return () => {
|
|
51
|
+
if (handlerCallback)
|
|
52
|
+
clearTimeout(handlerCallback);
|
|
53
|
+
if (onScrollEnds && localVirtualRef)
|
|
54
|
+
localVirtualRef.removeEventListener("scroll", onScroll);
|
|
55
|
+
document.removeEventListener("visibilitychange", checkPendingOnScroll);
|
|
56
|
+
};
|
|
57
|
+
}, [onScrollStop, onScrollEnds, checkPendingOnScroll, virtualListRef]);
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=useGlobalEventListener.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/parts/chat-container-messages-list/useGlobalEventListener.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import React from 'react';\nimport { type DSChatT } from '../../react-desc-prop-types';\n\ntype UseGlobalEventListenerArgs = {\n propsWithDefault: DSChatT.MessagesListProps;\n virtualListRef: React.MutableRefObject<HTMLDivElement | undefined>;\n onScrollStop: () => string[];\n checkPendingOnScroll: GenericFunc;\n};\n\nexport const useGlobalEventListener = ({\n propsWithDefault: { onScrollEnds },\n virtualListRef,\n onScrollStop,\n checkPendingOnScroll,\n}: UseGlobalEventListenerArgs) => {\n React.useEffect(() => {\n let handlerCallback: ReturnType<typeof setTimeout>;\n const localVirtualRef = virtualListRef.current;\n const onScroll = () => {\n if (handlerCallback) clearTimeout(handlerCallback);\n handlerCallback = setTimeout(onScrollStop, 300);\n };\n if (onScrollEnds) {\n virtualListRef.current?.addEventListener('scroll', onScroll);\n }\n document.addEventListener('visibilitychange', checkPendingOnScroll);\n return () => {\n if (handlerCallback) clearTimeout(handlerCallback);\n if (onScrollEnds && localVirtualRef) localVirtualRef.removeEventListener('scroll', onScroll);\n document.removeEventListener('visibilitychange', checkPendingOnScroll);\n };\n }, [onScrollStop, onScrollEnds, checkPendingOnScroll, virtualListRef]);\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAkB;AAUX,MAAM,yBAAyB,CAAC;AAAA,EACrC,kBAAkB,EAAE,aAAa;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AACF,MAAkC;AAChC,eAAAA,QAAM,UAAU,MAAM;AACpB,QAAI;AACJ,UAAM,kBAAkB,eAAe;AACvC,UAAM,WAAW,MAAM;AACrB,UAAI;AAAiB,qBAAa,eAAe;AACjD,wBAAkB,WAAW,cAAc,GAAG;AAAA,IAChD;AACA,QAAI,cAAc;AAChB,qBAAe,SAAS,iBAAiB,UAAU,QAAQ;AAAA,IAC7D;AACA,aAAS,iBAAiB,oBAAoB,oBAAoB;AAClE,WAAO,MAAM;AACX,UAAI;AAAiB,qBAAa,eAAe;AACjD,UAAI,gBAAgB;AAAiB,wBAAgB,oBAAoB,UAAU,QAAQ;AAC3F,eAAS,oBAAoB,oBAAoB,oBAAoB;AAAA,IACvE;AAAA,EACF,GAAG,CAAC,cAAc,cAAc,sBAAsB,cAAc,CAAC;AACvE;",
|
|
6
|
+
"names": ["React"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var useKeyboard_exports = {};
|
|
26
|
+
__export(useKeyboard_exports, {
|
|
27
|
+
useKeyboard: () => useKeyboard
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(useKeyboard_exports);
|
|
30
|
+
var React = __toESM(require("react"));
|
|
31
|
+
var import_react = __toESM(require("react"));
|
|
32
|
+
const getIsNumber = (val) => Number.isInteger(val);
|
|
33
|
+
const useKeyboard = ({
|
|
34
|
+
propsWithDefault: { hasMoreItems, messages, bannerPosition, bannerRef },
|
|
35
|
+
actionRef,
|
|
36
|
+
virtualListRef,
|
|
37
|
+
loadMoreRef,
|
|
38
|
+
scrollAndFocus,
|
|
39
|
+
onlyFocus,
|
|
40
|
+
onScrollStop
|
|
41
|
+
}) => {
|
|
42
|
+
const handleKey = import_react.default.useCallback(
|
|
43
|
+
(e) => {
|
|
44
|
+
const { key, currentTarget } = e;
|
|
45
|
+
const index = currentTarget.dataset?.index ? Number(currentTarget.dataset.index) : void 0;
|
|
46
|
+
const isIndexNumber = getIsNumber(index);
|
|
47
|
+
e.stopPropagation();
|
|
48
|
+
switch (key) {
|
|
49
|
+
case "ArrowUp":
|
|
50
|
+
e.preventDefault();
|
|
51
|
+
if (index && index > 0) {
|
|
52
|
+
(virtualListRef.current?.querySelector(`[data-index="${index - 1}"]`)).focus();
|
|
53
|
+
} else if (hasMoreItems === "top") {
|
|
54
|
+
loadMoreRef.current?.focus();
|
|
55
|
+
}
|
|
56
|
+
break;
|
|
57
|
+
case "ArrowDown":
|
|
58
|
+
e.preventDefault();
|
|
59
|
+
if (messages?.length && isIndexNumber && index < messages.length - 1) {
|
|
60
|
+
(virtualListRef.current?.querySelector(`[data-index="${index + 1}"]`)).focus();
|
|
61
|
+
}
|
|
62
|
+
break;
|
|
63
|
+
case "Home":
|
|
64
|
+
e.preventDefault();
|
|
65
|
+
scrollAndFocus(0);
|
|
66
|
+
break;
|
|
67
|
+
case "End":
|
|
68
|
+
e.preventDefault();
|
|
69
|
+
if (messages?.length)
|
|
70
|
+
scrollAndFocus(messages.length - 1);
|
|
71
|
+
break;
|
|
72
|
+
case "Tab":
|
|
73
|
+
if (hasMoreItems === "bottom" && !e.shiftKey) {
|
|
74
|
+
e.preventDefault();
|
|
75
|
+
loadMoreRef.current?.focus();
|
|
76
|
+
} else if (hasMoreItems === "top" && e.shiftKey) {
|
|
77
|
+
e.preventDefault();
|
|
78
|
+
loadMoreRef.current?.focus();
|
|
79
|
+
} else if (!e.shiftKey) {
|
|
80
|
+
if (bannerPosition) {
|
|
81
|
+
e.preventDefault();
|
|
82
|
+
bannerRef?.current?.focusOnWrapper();
|
|
83
|
+
}
|
|
84
|
+
} else {
|
|
85
|
+
e.preventDefault();
|
|
86
|
+
virtualListRef.current?.focus();
|
|
87
|
+
}
|
|
88
|
+
break;
|
|
89
|
+
default:
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
[hasMoreItems, messages.length, scrollAndFocus, virtualListRef, loadMoreRef, bannerPosition, bannerRef]
|
|
94
|
+
);
|
|
95
|
+
const handleListKey = import_react.default.useCallback(
|
|
96
|
+
(e) => {
|
|
97
|
+
const { key } = e;
|
|
98
|
+
switch (key) {
|
|
99
|
+
case "ArrowUp":
|
|
100
|
+
e.preventDefault();
|
|
101
|
+
if (document.activeElement !== loadMoreRef.current) {
|
|
102
|
+
const id = onScrollStop()?.shift();
|
|
103
|
+
if (id)
|
|
104
|
+
onlyFocus(id);
|
|
105
|
+
}
|
|
106
|
+
break;
|
|
107
|
+
case "ArrowDown":
|
|
108
|
+
e.preventDefault();
|
|
109
|
+
if (document.activeElement === loadMoreRef.current) {
|
|
110
|
+
virtualListRef.current?.querySelector(`[data-index="0"]`)?.focus();
|
|
111
|
+
} else {
|
|
112
|
+
const id = onScrollStop()?.pop();
|
|
113
|
+
if (id)
|
|
114
|
+
onlyFocus(id);
|
|
115
|
+
}
|
|
116
|
+
break;
|
|
117
|
+
case "Home":
|
|
118
|
+
e.preventDefault();
|
|
119
|
+
scrollAndFocus(0);
|
|
120
|
+
break;
|
|
121
|
+
case "End":
|
|
122
|
+
e.preventDefault();
|
|
123
|
+
if (messages?.length)
|
|
124
|
+
scrollAndFocus(messages.length - 1);
|
|
125
|
+
break;
|
|
126
|
+
case "Tab":
|
|
127
|
+
if (document.activeElement !== loadMoreRef.current) {
|
|
128
|
+
if (hasMoreItems === "bottom" && !e.shiftKey) {
|
|
129
|
+
e.preventDefault();
|
|
130
|
+
loadMoreRef.current?.focus();
|
|
131
|
+
} else if (!e.shiftKey) {
|
|
132
|
+
e.preventDefault();
|
|
133
|
+
actionRef.current?.focusToComposer?.();
|
|
134
|
+
}
|
|
135
|
+
} else if (!e.shiftKey) {
|
|
136
|
+
e.preventDefault();
|
|
137
|
+
actionRef.current?.focusToComposer?.();
|
|
138
|
+
} else {
|
|
139
|
+
e.preventDefault();
|
|
140
|
+
virtualListRef.current?.focus();
|
|
141
|
+
}
|
|
142
|
+
break;
|
|
143
|
+
default:
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
[actionRef, hasMoreItems, loadMoreRef, messages.length, onScrollStop, onlyFocus, scrollAndFocus, virtualListRef]
|
|
148
|
+
);
|
|
149
|
+
return import_react.default.useMemo(() => ({ handleKey, handleListKey }), [handleKey, handleListKey]);
|
|
150
|
+
};
|
|
151
|
+
//# sourceMappingURL=useKeyboard.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/parts/chat-container-messages-list/useKeyboard.ts", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable complexity */\n/* eslint-disable jsx-a11y/no-noninteractive-tabindex */\n/* eslint-disable max-lines */\nimport React from 'react';\nimport { DSChatT } from '../../react-desc-prop-types';\n\ntype UseKeyboardArgs = {\n propsWithDefault: DSChatT.MessagesListProps;\n actionRef: DSChatT.ActionRef;\n virtualListRef: React.MutableRefObject<HTMLDivElement | undefined>;\n loadMoreRef: React.MutableRefObject<HTMLButtonElement | undefined>;\n scrollAndFocus: (index: number, opts?: DSChatT.ScrollToIndexOptions) => void;\n onlyFocus: (index: string) => void;\n onScrollStop: () => string[];\n // useVirtualHelpers: ReturnType<typeof useVirtual>;\n};\n\nconst getIsNumber = (val: unknown): val is number => Number.isInteger(val);\n\nexport const useKeyboard = ({\n propsWithDefault: { hasMoreItems, messages, bannerPosition, bannerRef },\n actionRef,\n virtualListRef,\n loadMoreRef,\n scrollAndFocus,\n onlyFocus,\n onScrollStop,\n}: UseKeyboardArgs) => {\n const handleKey = React.useCallback(\n (e: React.KeyboardEvent<HTMLElement>) => {\n const { key, currentTarget } = e;\n const index = currentTarget.dataset?.index ? Number(currentTarget.dataset.index) : undefined;\n const isIndexNumber = getIsNumber(index);\n e.stopPropagation();\n switch (key) {\n case 'ArrowUp':\n e.preventDefault();\n if (index && index > 0) {\n (virtualListRef.current?.querySelector(`[data-index=\"${index - 1}\"]`) as HTMLDivElement).focus();\n } else if (hasMoreItems === 'top') {\n loadMoreRef.current?.focus();\n }\n break;\n case 'ArrowDown':\n e.preventDefault();\n if (messages?.length && isIndexNumber && index < messages.length - 1) {\n (virtualListRef.current?.querySelector(`[data-index=\"${index + 1}\"]`) as HTMLDivElement).focus();\n }\n break;\n case 'Home':\n e.preventDefault();\n scrollAndFocus(0);\n break;\n case 'End':\n e.preventDefault();\n if (messages?.length) scrollAndFocus(messages.length - 1);\n break;\n case 'Tab':\n if (hasMoreItems === 'bottom' && !e.shiftKey) {\n e.preventDefault();\n loadMoreRef.current?.focus();\n } else if (hasMoreItems === 'top' && e.shiftKey) {\n e.preventDefault();\n loadMoreRef.current?.focus();\n } else if (!e.shiftKey) {\n if (bannerPosition) {\n e.preventDefault();\n bannerRef?.current?.focusOnWrapper();\n }\n } else {\n e.preventDefault();\n virtualListRef.current?.focus();\n }\n break;\n default:\n break;\n }\n },\n [hasMoreItems, messages.length, scrollAndFocus, virtualListRef, loadMoreRef, bannerPosition, bannerRef],\n );\n const handleListKey = React.useCallback(\n (e: React.KeyboardEvent) => {\n const { key } = e;\n switch (key) {\n case 'ArrowUp':\n e.preventDefault();\n if (document.activeElement !== loadMoreRef.current) {\n const id = onScrollStop()?.shift();\n if (id) onlyFocus(id);\n }\n break;\n case 'ArrowDown':\n e.preventDefault();\n if (document.activeElement === loadMoreRef.current) {\n (virtualListRef.current?.querySelector(`[data-index=\"0\"]`) as HTMLDivElement)?.focus();\n } else {\n const id = onScrollStop()?.pop();\n if (id) onlyFocus(id);\n }\n break;\n case 'Home':\n e.preventDefault();\n scrollAndFocus(0);\n break;\n case 'End':\n e.preventDefault();\n if (messages?.length) scrollAndFocus(messages.length - 1);\n break;\n case 'Tab':\n if (document.activeElement !== loadMoreRef.current) {\n if (hasMoreItems === 'bottom' && !e.shiftKey) {\n e.preventDefault();\n loadMoreRef.current?.focus();\n } else if (!e.shiftKey) {\n e.preventDefault();\n actionRef.current?.focusToComposer?.();\n }\n } else if (!e.shiftKey) {\n e.preventDefault();\n actionRef.current?.focusToComposer?.();\n } else {\n e.preventDefault();\n virtualListRef.current?.focus();\n }\n break;\n default:\n break;\n }\n },\n [actionRef, hasMoreItems, loadMoreRef, messages.length, onScrollStop, onlyFocus, scrollAndFocus, virtualListRef],\n );\n\n return React.useMemo(() => ({ handleKey, handleListKey }), [handleKey, handleListKey]);\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;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AAA,UAChC;AACA;AAAA;AAEA;AAAA;AAAA,IAEN;AAAA,IACA,CAAC,WAAW,cAAc,aAAa,SAAS,QAAQ,cAAc,WAAW,gBAAgB,cAAc;AAAA,EACjH;AAEA,SAAO,aAAAA,QAAM,QAAQ,OAAO,EAAE,WAAW,cAAc,IAAI,CAAC,WAAW,aAAa,CAAC;AACvF;",
|
|
6
|
+
"names": ["React"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
17
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
19
|
+
mod
|
|
20
|
+
));
|
|
21
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
|
+
var parts_exports = {};
|
|
23
|
+
module.exports = __toCommonJS(parts_exports);
|
|
24
|
+
var React = __toESM(require("react"));
|
|
25
|
+
__reExport(parts_exports, require("./chat-composer/ChatContainerComposer"), module.exports);
|
|
26
|
+
__reExport(parts_exports, require("./chat-container-messages-list/ChatContainerMessagesList"), module.exports);
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/parts/index.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["export * from './chat-composer/ChatContainerComposer';\nexport * from './chat-container-messages-list/ChatContainerMessagesList';\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;ACAA,YAAuB;ADAvB,0BAAc,kDAAd;AACA,0BAAc,qEADd;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var react_desc_prop_types_exports = {};
|
|
26
|
+
__export(react_desc_prop_types_exports, {
|
|
27
|
+
ChatComposerPropTypes: () => ChatComposerPropTypes,
|
|
28
|
+
ChatContainerMessagesListPropTypes: () => ChatContainerMessagesListPropTypes,
|
|
29
|
+
ChatContainerPropTypes: () => ChatContainerPropTypes,
|
|
30
|
+
defaultProps: () => defaultProps,
|
|
31
|
+
defaultPropsComposer: () => defaultPropsComposer,
|
|
32
|
+
defaultPropsMessagesList: () => defaultPropsMessagesList
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(react_desc_prop_types_exports);
|
|
35
|
+
var React = __toESM(require("react"));
|
|
36
|
+
var import_ds_utilities = require("@elliemae/ds-utilities");
|
|
37
|
+
var import_ds_banner = require("@elliemae/ds-banner");
|
|
38
|
+
function noop(..._args) {
|
|
39
|
+
}
|
|
40
|
+
const defaultPropsComposer = {
|
|
41
|
+
placeholder: "Type your message",
|
|
42
|
+
inputValue: "",
|
|
43
|
+
ariaMaxLengthMessage: "",
|
|
44
|
+
onChange: noop,
|
|
45
|
+
onResize: noop,
|
|
46
|
+
onSend: noop,
|
|
47
|
+
onFocus: noop,
|
|
48
|
+
onBlur: noop,
|
|
49
|
+
onKeyDown: noop,
|
|
50
|
+
maxHeight: 0,
|
|
51
|
+
inputMaxLength: void 0,
|
|
52
|
+
maxLengthMessage: void 0,
|
|
53
|
+
buttonDisabled: false,
|
|
54
|
+
dataTestid: "ds-chat-composer",
|
|
55
|
+
actionRef: void 0
|
|
56
|
+
};
|
|
57
|
+
const ChatComposerPropTypes = {
|
|
58
|
+
placeholder: import_ds_utilities.PropTypes.string.description("Input Placeholder").defaultValue(defaultPropsComposer.placeholder),
|
|
59
|
+
inputValue: import_ds_utilities.PropTypes.string.description("Input value").defaultValue(defaultPropsComposer.inputValue),
|
|
60
|
+
ariaMaxLengthMessage: import_ds_utilities.PropTypes.string.description("Aria message for Max length message when exceeded").defaultValue(defaultPropsComposer.maxLengthMessage),
|
|
61
|
+
maxLengthMessage: import_ds_utilities.PropTypes.string.description("Max length message").defaultValue(defaultPropsComposer.maxLengthMessage),
|
|
62
|
+
onChange: import_ds_utilities.PropTypes.func.description("Called when the user types").defaultValue(defaultPropsComposer.onChange),
|
|
63
|
+
onResize: import_ds_utilities.PropTypes.func.description("Called the input changes his height").defaultValue(defaultPropsComposer.onResize),
|
|
64
|
+
onSend: import_ds_utilities.PropTypes.func.description("Called when the click send").defaultValue(defaultPropsComposer.onSend),
|
|
65
|
+
onFocus: import_ds_utilities.PropTypes.func.description("Input focus").defaultValue(defaultPropsComposer.onFocus),
|
|
66
|
+
onBlur: import_ds_utilities.PropTypes.func.description("Input blur").defaultValue(defaultPropsComposer.onBlur),
|
|
67
|
+
onKeyDown: import_ds_utilities.PropTypes.func.description("Input on key down").defaultValue(defaultPropsComposer.onKeyDown),
|
|
68
|
+
maxHeight: import_ds_utilities.PropTypes.number.description("Max height of the composer. Use 0 for no limit").defaultValue(defaultPropsComposer.onBlur),
|
|
69
|
+
inputMaxLength: import_ds_utilities.PropTypes.number.description("Max length of the composer. `undefined` for no limit").defaultValue(defaultPropsComposer.inputMaxLength),
|
|
70
|
+
buttonDisabled: import_ds_utilities.PropTypes.bool.description("Control the disabled for the send button").defaultValue(defaultPropsComposer.buttonDisabled),
|
|
71
|
+
dataTestid: import_ds_utilities.PropTypes.string.description("Data testid").defaultValue(defaultPropsComposer.placeholder),
|
|
72
|
+
actionRef: import_ds_utilities.PropTypes.object.description(
|
|
73
|
+
`Reference:
|
|
74
|
+
{
|
|
75
|
+
scrollToIndex?: (n: number, opts: { align: 'end' | 'center' | 'start' }) => void,
|
|
76
|
+
getMessagesInView?: () => number[],
|
|
77
|
+
focusToIndex?: (n: number) => void,
|
|
78
|
+
focusToList?: () => void,
|
|
79
|
+
focusToComposer?: () => void,
|
|
80
|
+
focusToSend?: () => void,
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
`
|
|
84
|
+
).defaultValue(defaultPropsComposer.actionRef)
|
|
85
|
+
};
|
|
86
|
+
const defaultPropsMessagesList = {
|
|
87
|
+
messages: [],
|
|
88
|
+
actionRef: { current: {} },
|
|
89
|
+
getMoreMessages: noop,
|
|
90
|
+
sendingMessages: void 0,
|
|
91
|
+
sendingText: "Sending",
|
|
92
|
+
bannerPosition: void 0,
|
|
93
|
+
bannerRef: void 0
|
|
94
|
+
};
|
|
95
|
+
const ChatContainerMessagesListPropTypes = {
|
|
96
|
+
...import_ds_utilities.globalAttributesPropTypes,
|
|
97
|
+
messages: import_ds_utilities.PropTypes.arrayOf(import_ds_utilities.PropTypes.object).description("The array of out-of-the-box items you want to render inside the ChatMessageList").defaultValue(defaultPropsMessagesList.messages),
|
|
98
|
+
actionRef: import_ds_utilities.PropTypes.object.description(
|
|
99
|
+
`Reference:
|
|
100
|
+
{
|
|
101
|
+
scrollToIndex?: (n: number, opts: { align: 'end' | 'center' | 'start' }) => void,
|
|
102
|
+
getMessagesInView: () => number[],
|
|
103
|
+
focusToIndex: (n: number) => void,
|
|
104
|
+
focusToIndexWithoutScroll: (n: number) => void,
|
|
105
|
+
focusToList: () => void,
|
|
106
|
+
focusToComposer: () => void,
|
|
107
|
+
focusToSend: () => void,
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
`
|
|
111
|
+
).defaultValue(defaultPropsMessagesList.actionRef),
|
|
112
|
+
onScrollEnds: import_ds_utilities.PropTypes.func.description(`Called when the scroll stops.`),
|
|
113
|
+
isLoading: import_ds_utilities.PropTypes.oneOf(["top", "bottom", void 0]).description(
|
|
114
|
+
"Keeps the load more space while the loading is in progress"
|
|
115
|
+
),
|
|
116
|
+
hasMoreItems: import_ds_utilities.PropTypes.oneOf(["top", "bottom", void 0]).description(
|
|
117
|
+
"Show Load More button at the `top` or `bottom` of the container"
|
|
118
|
+
),
|
|
119
|
+
getMoreMessages: import_ds_utilities.PropTypes.func.description("Called when the user clicks on load more").defaultValue(defaultPropsMessagesList.getMoreMessages),
|
|
120
|
+
sendingMessages: import_ds_utilities.PropTypes.oneOfType([import_ds_utilities.PropTypes.arrayOf(import_ds_utilities.PropTypes.string), import_ds_utilities.PropTypes.arrayOf(import_ds_utilities.PropTypes.number)]).description("Array of ids of sending messages").defaultValue(defaultPropsMessagesList.sendingMessages),
|
|
121
|
+
sendingText: import_ds_utilities.PropTypes.string.description("Label description for messages in sending status").defaultValue(defaultPropsMessagesList.sendingText)
|
|
122
|
+
};
|
|
123
|
+
const defaultProps = {
|
|
124
|
+
messagesListProps: defaultPropsMessagesList,
|
|
125
|
+
composerProps: defaultPropsComposer,
|
|
126
|
+
actionRef: void 0,
|
|
127
|
+
autoScroll: false,
|
|
128
|
+
device: "desktop",
|
|
129
|
+
isLoading: void 0,
|
|
130
|
+
hasMoreItems: void 0,
|
|
131
|
+
getMoreMessages: noop,
|
|
132
|
+
bannerPosition: void 0,
|
|
133
|
+
bannerProps: {
|
|
134
|
+
type: import_ds_banner.BANNER_TYPES.INFO,
|
|
135
|
+
label: "Unread Messages",
|
|
136
|
+
viewLabel: "View",
|
|
137
|
+
onView: noop,
|
|
138
|
+
onClose: noop
|
|
139
|
+
},
|
|
140
|
+
sendingMessages: void 0,
|
|
141
|
+
sendingText: "Sending"
|
|
142
|
+
};
|
|
143
|
+
const ChatContainerPropTypes = {
|
|
144
|
+
...import_ds_utilities.globalAttributesPropTypes,
|
|
145
|
+
messagesListProps: import_ds_utilities.PropTypes.object.description('ChatMessageList props "messages" / "onScrollEnds"').defaultValue(defaultProps.messagesListProps),
|
|
146
|
+
composerProps: import_ds_utilities.PropTypes.object.description("Composer configuration").defaultValue(defaultProps.composerProps),
|
|
147
|
+
autoScroll: import_ds_utilities.PropTypes.bool.description("Auto scroll to bottom on resize").defaultValue(defaultProps.autoScroll),
|
|
148
|
+
device: import_ds_utilities.PropTypes.string.description("Option to render mobile or desktop style composer").defaultValue(defaultProps.device),
|
|
149
|
+
isLoading: import_ds_utilities.PropTypes.oneOf(["top", "bottom", void 0]).description(
|
|
150
|
+
"Show Loading messages indicator at the `top` or `bottom` of the container"
|
|
151
|
+
),
|
|
152
|
+
hasMoreItems: import_ds_utilities.PropTypes.oneOf(["top", "bottom", void 0]).description(
|
|
153
|
+
"Show Load More button at the `top` or `bottom` of the container"
|
|
154
|
+
),
|
|
155
|
+
getMoreMessages: import_ds_utilities.PropTypes.func.description("Called when the user clicks on load more").defaultValue(defaultProps.getMoreMessages),
|
|
156
|
+
bannerPosition: import_ds_utilities.PropTypes.oneOf(["top", "bottom", void 0]).description(
|
|
157
|
+
"Show Loading messages indicator at the `top` or `bottom` of the container"
|
|
158
|
+
),
|
|
159
|
+
bannerProps: import_ds_utilities.PropTypes.object.description(
|
|
160
|
+
`Banner configuration:
|
|
161
|
+
label: string;
|
|
162
|
+
viewLabel: string;
|
|
163
|
+
type: BANNER_TYPES;
|
|
164
|
+
onView: () => void;
|
|
165
|
+
onClose: () => void;
|
|
166
|
+
`
|
|
167
|
+
).defaultValue(defaultProps.bannerProps),
|
|
168
|
+
sendingMessages: import_ds_utilities.PropTypes.oneOfType([import_ds_utilities.PropTypes.arrayOf(import_ds_utilities.PropTypes.string), import_ds_utilities.PropTypes.arrayOf(import_ds_utilities.PropTypes.number)]).description("Array of ids of sending messages").defaultValue(defaultProps.sendingMessages),
|
|
169
|
+
sendingText: import_ds_utilities.PropTypes.string.description("Label description for messages in sending status").defaultValue(defaultProps.sendingText),
|
|
170
|
+
actionRef: import_ds_utilities.PropTypes.object.description(
|
|
171
|
+
`Reference:
|
|
172
|
+
{
|
|
173
|
+
scrollToIndex: (n: number) => void,
|
|
174
|
+
getMessagesInView: () => number[],
|
|
175
|
+
focusToIndex: (n: number) => void,
|
|
176
|
+
focusToList: () => void,
|
|
177
|
+
focusToComposer: () => void,
|
|
178
|
+
focusToSend: () => void,
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
`
|
|
182
|
+
).defaultValue(defaultProps.actionRef)
|
|
183
|
+
};
|
|
184
|
+
//# sourceMappingURL=react-desc-prop-types.js.map
|