@elliemae/ds-chat-container 3.80.0-next.8 → 3.80.0-next.81
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/DSChatContainerDefinitions.js +7 -1
- package/dist/cjs/DSChatContainerDefinitions.js.map +2 -2
- package/dist/cjs/parts/chat-composer/ChatContainerComposer.js +0 -1
- package/dist/cjs/parts/chat-composer/ChatContainerComposer.js.map +2 -2
- package/dist/cjs/parts/chat-composer/styled.js +4 -0
- package/dist/cjs/parts/chat-composer/styled.js.map +2 -2
- package/dist/cjs/parts/chat-container-messages-list/ChatContainerMessagesList.js +134 -69
- package/dist/cjs/parts/chat-container-messages-list/ChatContainerMessagesList.js.map +2 -2
- package/dist/cjs/parts/chat-container-messages-list/styled.js +33 -35
- package/dist/cjs/parts/chat-container-messages-list/styled.js.map +2 -2
- package/dist/cjs/parts/chat-container-messages-list/useActionRef.js +2 -5
- package/dist/cjs/parts/chat-container-messages-list/useActionRef.js.map +2 -2
- package/dist/cjs/parts/chat-container-messages-list/useChatContainerMessageList.js +33 -20
- package/dist/cjs/parts/chat-container-messages-list/useChatContainerMessageList.js.map +2 -2
- package/dist/cjs/parts/chat-container-messages-list/useFocusAndScrollHelpers.js +38 -43
- package/dist/cjs/parts/chat-container-messages-list/useFocusAndScrollHelpers.js.map +2 -2
- package/dist/cjs/parts/chat-container-messages-list/useGlobalEventListener.js.map +1 -1
- package/dist/cjs/parts/chat-container-messages-list/useKeyboard.js +8 -15
- package/dist/cjs/parts/chat-container-messages-list/useKeyboard.js.map +2 -2
- package/dist/cjs/parts/chat-container-messages-list/useMessageFocusTracker.js +132 -0
- package/dist/cjs/parts/chat-container-messages-list/useMessageFocusTracker.js.map +7 -0
- package/dist/cjs/react-desc-prop-types.js +39 -23
- package/dist/cjs/react-desc-prop-types.js.map +2 -2
- package/dist/cjs/typescript-testing/typescript-chat-container-valid.js +31 -0
- package/dist/cjs/typescript-testing/typescript-chat-container-valid.js.map +2 -2
- package/dist/esm/DSChatContainerDefinitions.js +7 -1
- package/dist/esm/DSChatContainerDefinitions.js.map +2 -2
- package/dist/esm/parts/chat-composer/ChatContainerComposer.js +0 -1
- package/dist/esm/parts/chat-composer/ChatContainerComposer.js.map +2 -2
- package/dist/esm/parts/chat-composer/styled.js +4 -0
- package/dist/esm/parts/chat-composer/styled.js.map +2 -2
- package/dist/esm/parts/chat-container-messages-list/ChatContainerMessagesList.js +135 -72
- package/dist/esm/parts/chat-container-messages-list/ChatContainerMessagesList.js.map +2 -2
- package/dist/esm/parts/chat-container-messages-list/styled.js +33 -35
- package/dist/esm/parts/chat-container-messages-list/styled.js.map +2 -2
- package/dist/esm/parts/chat-container-messages-list/useActionRef.js +2 -5
- package/dist/esm/parts/chat-container-messages-list/useActionRef.js.map +2 -2
- package/dist/esm/parts/chat-container-messages-list/useChatContainerMessageList.js +33 -20
- package/dist/esm/parts/chat-container-messages-list/useChatContainerMessageList.js.map +2 -2
- package/dist/esm/parts/chat-container-messages-list/useFocusAndScrollHelpers.js +39 -44
- package/dist/esm/parts/chat-container-messages-list/useFocusAndScrollHelpers.js.map +2 -2
- package/dist/esm/parts/chat-container-messages-list/useGlobalEventListener.js.map +1 -1
- package/dist/esm/parts/chat-container-messages-list/useKeyboard.js +8 -15
- package/dist/esm/parts/chat-container-messages-list/useKeyboard.js.map +2 -2
- package/dist/esm/parts/chat-container-messages-list/useMessageFocusTracker.js +102 -0
- package/dist/esm/parts/chat-container-messages-list/useMessageFocusTracker.js.map +7 -0
- package/dist/esm/react-desc-prop-types.js +40 -24
- package/dist/esm/react-desc-prop-types.js.map +2 -2
- package/dist/esm/typescript-testing/typescript-chat-container-valid.js +31 -0
- package/dist/esm/typescript-testing/typescript-chat-container-valid.js.map +2 -2
- package/dist/types/DSChatContainerDefinitions.d.ts +8 -0
- package/dist/types/parts/chat-container-messages-list/styled.d.ts +18 -5
- package/dist/types/parts/chat-container-messages-list/useActionRef.d.ts +4 -6
- package/dist/types/parts/chat-container-messages-list/useChatContainerMessageList.d.ts +7 -3
- package/dist/types/parts/chat-container-messages-list/useFocusAndScrollHelpers.d.ts +9 -6
- package/dist/types/parts/chat-container-messages-list/useGlobalEventListener.d.ts +1 -1
- package/dist/types/parts/chat-container-messages-list/useKeyboard.d.ts +7 -3
- package/dist/types/parts/chat-container-messages-list/useMessageFocusTracker.d.ts +52 -0
- package/dist/types/react-desc-prop-types.d.ts +800 -789
- package/package.json +17 -17
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/react-desc-prop-types.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\nimport type { useVirtual } from 'react-virtual';\nimport { PropTypes, globalAttributesPropTypes } from '@elliemae/ds-props-helpers';\nimport { BANNER_TYPES } from '@elliemae/ds-banner';\nimport { type DSChatBubbleT } from '@elliemae/ds-chat-bubble';\nimport { type DSButtonT } from '@elliemae/ds-button-v2';\n\n// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars\nfunction noop<T extends unknown[]>(..._args: T): void {}\nexport declare namespace DSChatT {\n interface ChatBannerProps {\n label: string;\n viewLabel: string;\n type?: 'info' | 'success' | 'danger' | 'warning';\n onView: () => void;\n onClose: () => void;\n }\n export type ScrollToIndexOptions = Parameters<ReturnType<typeof useVirtual>['scrollToIndex']>[1];\n export type ActionRef = React.MutableRefObject<{\n scrollToIndex?: (index: number, opts?: ScrollToIndexOptions) => void;\n focusToIndex?: (index: number, opts?: ScrollToIndexOptions) => void;\n getMessagesInView?: () => string[];\n focusToIndexWithoutScroll?: (index: string) => void;\n focusToList?: () => void;\n focusToComposer?: () => void;\n focusToSend?: () => void;\n focusOnBanner?: () => void;\n focusOnBannerLink?: () => void;\n }>;\n\n export interface ComposerProps extends Record<string, unknown> {\n placeholder?: string;\n inputValue?: string;\n ariaMaxLengthMessage?: string;\n maxLengthMessage?: string;\n onChange: (value: string) => void;\n onResize?: (value: number) => void;\n onSend: (e: Parameters<Required<DSButtonT.Props>['onClick']>[0]) => void;\n onFocus?: (e: React.FocusEvent<HTMLTextAreaElement>) => void;\n onBlur?: (e: React.FocusEvent<HTMLTextAreaElement>) => void;\n onKeyDown?: (e: React.KeyboardEvent) => void;\n maxHeight?: number;\n inputMaxLength?: number;\n buttonDisabled: boolean;\n dataTestid?: string;\n actionRef?: ActionRef;\n }\n\n export interface MessagesListProps extends Record<string, unknown> {\n messages: DSChatBubbleT.Props[];\n actionRef: ActionRef;\n onScrollEnds?: (indexList: string[]) => void;\n isLoading?: 'top' | 'bottom';\n hasMoreItems?: 'top' | 'bottom';\n getMoreMessages: () => void;\n sendingMessages?: Array<string | number>;\n sendingText: string;\n bannerPosition?: 'top' | 'bottom';\n bannerRef?: React.MutableRefObject<{\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n focusOnWrapper: (...args: any[]) => void;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n focusOnLink: (...args: any[]) => void;\n }>;\n }\n\n export interface ContainerProps extends Record<string, unknown> {\n messagesListProps: Pick<MessagesListProps, 'messages' | 'onScrollEnds'>;\n composerProps: ComposerProps;\n actionRef?: ActionRef;\n autoScroll: boolean;\n device: 'desktop' | 'mobile';\n isLoading?: 'top' | 'bottom';\n hasMoreItems?: 'top' | 'bottom';\n getMoreMessages: () => void;\n bannerPosition?: 'top' | 'bottom';\n bannerProps?: ChatBannerProps;\n sendingMessages?: string[] | number[];\n sendingText: string;\n }\n\n export interface GetPaddingT {\n hasMoreItems: string | undefined;\n bannerPosition: string | undefined;\n isLoading: string | undefined;\n }\n}\n\nexport interface TextAreaProps {\n height: string | number;\n style: React.CSSProperties;\n}\n\nexport const defaultPropsComposer: DSChatT.ComposerProps = {\n placeholder: 'Type your message',\n inputValue: '',\n ariaMaxLengthMessage: '',\n onChange: noop,\n onResize: noop,\n onSend: noop,\n onFocus: noop,\n onBlur: noop,\n onKeyDown: noop,\n maxHeight: 0,\n inputMaxLength: undefined,\n maxLengthMessage: undefined,\n buttonDisabled: false,\n dataTestid: 'ds-chat-composer',\n actionRef: undefined,\n};\n\nexport const ChatComposerPropTypes = {\n placeholder: PropTypes.string.description('Input Placeholder').defaultValue(defaultPropsComposer.placeholder),\n inputValue: PropTypes.string.description('Input value').defaultValue(defaultPropsComposer.inputValue),\n ariaMaxLengthMessage: PropTypes.string\n .description('Aria message for Max length message when exceeded')\n .defaultValue(defaultPropsComposer.maxLengthMessage),\n maxLengthMessage: PropTypes.string\n .description('Max length message')\n .defaultValue(defaultPropsComposer.maxLengthMessage),\n onChange: PropTypes.func.description('Called when the user types').defaultValue(defaultPropsComposer.onChange),\n onResize: PropTypes.func\n .description('Called the input changes his height')\n .defaultValue(defaultPropsComposer.onResize),\n onSend: PropTypes.func.description('Called when the click send').defaultValue(defaultPropsComposer.onSend),\n onFocus: PropTypes.func.description('Input focus').defaultValue(defaultPropsComposer.onFocus),\n onBlur: PropTypes.func.description('Input blur').defaultValue(defaultPropsComposer.onBlur),\n onKeyDown: PropTypes.func.description('Input on key down').defaultValue(defaultPropsComposer.onKeyDown),\n maxHeight: PropTypes.number\n .description('Max height of the composer. Use 0 for no limit')\n .defaultValue(defaultPropsComposer.onBlur),\n inputMaxLength: PropTypes.number\n .description('Max length of the composer. `undefined` for no limit')\n .defaultValue(defaultPropsComposer.inputMaxLength),\n buttonDisabled: PropTypes.bool\n .description('Control the disabled for the send button')\n .defaultValue(defaultPropsComposer.buttonDisabled),\n dataTestid: PropTypes.string.description('Data testid').defaultValue(defaultPropsComposer.placeholder),\n actionRef: PropTypes.object\n .description(\n `Reference: \n { \n scrollToIndex?: (n: number, opts: { align: 'end' | 'center' | 'start' }) => void,\n getMessagesInView?: () => number[],\n focusToIndex?: (n: number) => void,\n focusToList?: () => void,\n focusToComposer?: () => void,\n focusToSend?: () => void,\n }\n \n `,\n )\n .defaultValue(defaultPropsComposer.actionRef),\n};\n\nexport const defaultPropsMessagesList: DSChatT.MessagesListProps = {\n messages: [],\n actionRef: { current: {} },\n // we don't want this to exist \"by default\" since this loads document.addEventListener\n // the code is already checking for this callback existence everytime it's invoked anyway\n // onScrollEnds: () => [],\n getMoreMessages: noop,\n sendingMessages: undefined,\n sendingText: 'Sending',\n bannerPosition: undefined,\n bannerRef: undefined,\n};\n\nexport const ChatContainerMessagesListPropTypes = {\n ...globalAttributesPropTypes,\n\n messages: PropTypes.arrayOf(PropTypes.object)\n .description('The array of out-of-the-box items you want to render inside the ChatMessageList')\n .defaultValue(defaultPropsMessagesList.messages),\n actionRef: PropTypes.object\n .description(\n `Reference: \n { \n scrollToIndex?: (n: number, opts: { align: 'end' | 'center' | 'start' }) => void,\n getMessagesInView: () => number[],\n focusToIndex: (n: number) => void,\n focusToIndexWithoutScroll: (n: number) => void,\n focusToList: () => void,\n focusToComposer: () => void,\n focusToSend: () => void,\n }\n \n `,\n )\n .defaultValue(defaultPropsMessagesList.actionRef),\n onScrollEnds: PropTypes.func.description(`Called when the scroll stops.`),\n isLoading: PropTypes.oneOf(['top', 'bottom', undefined]).description(\n 'Keeps the load more space while the loading is in progress',\n ),\n hasMoreItems: PropTypes.oneOf(['top', 'bottom', undefined]).description(\n 'Show Load More button at the `top` or `bottom` of the container',\n ),\n getMoreMessages: PropTypes.func\n .description('Called when the user clicks on load more')\n .defaultValue(defaultPropsMessagesList.getMoreMessages),\n sendingMessages: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.arrayOf(PropTypes.number)])\n .description('Array of ids of sending messages')\n .defaultValue(defaultPropsMessagesList.sendingMessages),\n sendingText: PropTypes.string\n .description('Label description for messages in sending status')\n .defaultValue(defaultPropsMessagesList.sendingText),\n};\n\nexport const defaultProps: DSChatT.ContainerProps = {\n messagesListProps: defaultPropsMessagesList,\n composerProps: defaultPropsComposer,\n actionRef: undefined,\n autoScroll: false,\n device: 'desktop',\n isLoading: undefined,\n hasMoreItems: undefined,\n getMoreMessages: noop,\n bannerPosition: undefined,\n bannerProps: {\n type: BANNER_TYPES.INFO,\n label: 'Unread Messages',\n viewLabel: 'View',\n onView: noop,\n onClose: noop,\n },\n sendingMessages: undefined,\n sendingText: 'Sending',\n};\n\nexport const ChatContainerPropTypes = {\n ...globalAttributesPropTypes,\n messagesListProps: PropTypes.object\n .description('ChatMessageList props \"messages\" / \"onScrollEnds\"')\n .defaultValue(defaultProps.messagesListProps),\n composerProps: PropTypes.object.description('Composer configuration').defaultValue(defaultProps.composerProps),\n autoScroll: PropTypes.bool.description('Auto scroll to bottom on resize').defaultValue(defaultProps.autoScroll),\n device: PropTypes.string\n .description('Option to render mobile or desktop style composer')\n .defaultValue(defaultProps.device),\n isLoading: PropTypes.oneOf(['top', 'bottom', undefined]).description(\n 'Show Loading messages indicator at the `top` or `bottom` of the container',\n ),\n hasMoreItems: PropTypes.oneOf(['top', 'bottom', undefined]).description(\n 'Show Load More button at the `top` or `bottom` of the container',\n ),\n getMoreMessages: PropTypes.func\n .description('Called when the user clicks on load more')\n .defaultValue(defaultProps.getMoreMessages),\n bannerPosition: PropTypes.oneOf(['top', 'bottom', undefined]).description(\n 'Show Loading messages indicator at the `top` or `bottom` of the container',\n ),\n bannerProps: PropTypes.object\n .description(\n `Banner configuration:\n label: string;\n viewLabel: string;\n type: BANNER_TYPES;\n onView: () => void;\n onClose: () => void;\n `,\n )\n .defaultValue(defaultProps.bannerProps),\n sendingMessages: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.arrayOf(PropTypes.number)])\n .description('Array of ids of sending messages')\n .defaultValue(defaultProps.sendingMessages),\n sendingText: PropTypes.string\n .description('Label description for messages in sending status')\n .defaultValue(defaultProps.sendingText),\n actionRef: PropTypes.object\n .description(\n `Reference: \n { \n scrollToIndex: (n: number) => void,\n getMessagesInView: () => number[],\n focusToIndex: (n: number) => void,\n focusToList: () => void,\n focusToComposer: () => void,\n focusToSend: () => void,\n }\n \n `,\n )\n .defaultValue(defaultProps.actionRef),\n};\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACEvB,SAAS,WAAW,iCAAiC;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\nimport type { DSFastListT } from '@elliemae/ds-fast-list';\nimport { PropTypes, getPropsPerSlotPropTypes, globalAttributesPropTypes } from '@elliemae/ds-props-helpers';\nimport type { TypescriptHelpersT } from '@elliemae/ds-typescript-helpers';\nimport { BANNER_TYPES } from '@elliemae/ds-banner';\nimport { type DSChatBubbleT } from '@elliemae/ds-chat-bubble';\nimport { type DSButtonT } from '@elliemae/ds-button-v2';\nimport { DSChatContainerSlotName, DSChatContainerSlots } from './DSChatContainerDefinitions.js';\n\n// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars\nfunction noop<T extends unknown[]>(..._args: T): void {}\nexport declare namespace DSChatT {\n interface ChatBannerProps {\n label: string;\n viewLabel: string;\n type?: 'info' | 'success' | 'danger' | 'warning';\n onView: () => void;\n onClose: () => void;\n }\n /**\n * Kept with its published shape \u2014 react-virtual v2's optional `scrollToIndex` options: `{ align }` with `align`\n * required, or `undefined` \u2014 so code written against it keeps compiling.\n */\n export type ScrollToIndexOptions = DSFastListT.ScrollToOptions | undefined;\n /** What `scrollToIndex` and `focusToIndex` accept: `align` is optional and `behavior` can request a smooth scroll. */\n export type ScrollActionOptions = DSFastListT.ScrollActionOptions;\n export type ActionRef = React.MutableRefObject<{\n /** Method syntax on purpose: an `actionRef` typed with the published `ScrollToIndexOptions` stays assignable. */\n scrollToIndex?(index: number, opts?: ScrollActionOptions): void;\n focusToIndex?(index: number, opts?: ScrollActionOptions): void;\n getMessagesInView?: () => string[];\n focusToIndexWithoutScroll?: (index: string) => void;\n focusToList?: () => void;\n focusToComposer?: () => void;\n focusToSend?: () => void;\n focusOnBanner?: () => void;\n focusOnBannerLink?: () => void;\n }>;\n\n export interface ComposerProps extends Record<string, unknown> {\n placeholder?: string;\n inputValue?: string;\n ariaMaxLengthMessage?: string;\n maxLengthMessage?: string;\n onChange: (value: string) => void;\n onResize?: (value: number) => void;\n onSend: (e: Parameters<Required<DSButtonT.Props>['onClick']>[0]) => void;\n onFocus?: (e: React.FocusEvent<HTMLTextAreaElement>) => void;\n onBlur?: (e: React.FocusEvent<HTMLTextAreaElement>) => void;\n onKeyDown?: (e: React.KeyboardEvent) => void;\n maxHeight?: number;\n inputMaxLength?: number;\n buttonDisabled: boolean;\n dataTestid?: string;\n actionRef?: ActionRef;\n }\n\n export type MessagesListSlotProps = TypescriptHelpersT.PropsForGlobalOnSlots<\n typeof DSChatContainerSlotName,\n typeof DSChatContainerSlots\n >;\n\n export interface MessagesListProps extends Record<string, unknown>, MessagesListSlotProps {\n messages: DSChatBubbleT.Props[];\n actionRef: ActionRef;\n onScrollEnds?: (indexList: string[]) => void;\n isLoading?: 'top' | 'bottom';\n hasMoreItems?: 'top' | 'bottom';\n getMoreMessages: () => void;\n sendingMessages?: Array<string | number>;\n sendingText: string;\n bannerPosition?: 'top' | 'bottom';\n bannerRef?: React.MutableRefObject<{\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n focusOnWrapper: (...args: any[]) => void;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n focusOnLink: (...args: any[]) => void;\n }>;\n }\n\n export interface ContainerProps extends Record<string, unknown> {\n messagesListProps: Pick<MessagesListProps, 'messages' | 'onScrollEnds'> & MessagesListSlotProps;\n composerProps: ComposerProps;\n actionRef?: ActionRef;\n autoScroll: boolean;\n device: 'desktop' | 'mobile';\n isLoading?: 'top' | 'bottom';\n hasMoreItems?: 'top' | 'bottom';\n getMoreMessages: () => void;\n bannerPosition?: 'top' | 'bottom';\n bannerProps?: ChatBannerProps;\n sendingMessages?: string[] | number[];\n sendingText: string;\n }\n\n export interface GetPaddingT {\n hasMoreItems: string | undefined;\n bannerPosition: string | undefined;\n isLoading: string | undefined;\n }\n}\n\nexport interface TextAreaProps {\n height: string | number;\n style: React.CSSProperties;\n}\n\nexport const defaultPropsComposer: DSChatT.ComposerProps = {\n placeholder: 'Type your message',\n inputValue: '',\n ariaMaxLengthMessage: '',\n onChange: noop,\n onResize: noop,\n onSend: noop,\n onFocus: noop,\n onBlur: noop,\n onKeyDown: noop,\n maxHeight: 0,\n inputMaxLength: undefined,\n maxLengthMessage: undefined,\n buttonDisabled: false,\n dataTestid: 'ds-chat-composer',\n actionRef: undefined,\n};\n\nexport const ChatComposerPropTypes = {\n placeholder: PropTypes.string.description('Input Placeholder').defaultValue(defaultPropsComposer.placeholder),\n inputValue: PropTypes.string.description('Input value').defaultValue(defaultPropsComposer.inputValue),\n ariaMaxLengthMessage: PropTypes.string\n .description('Aria message for Max length message when exceeded')\n .defaultValue(defaultPropsComposer.ariaMaxLengthMessage),\n maxLengthMessage: PropTypes.string\n .description('Max length message')\n .defaultValue(defaultPropsComposer.maxLengthMessage),\n onChange: PropTypes.func.description('Called when the user types').defaultValue(defaultPropsComposer.onChange),\n onResize: PropTypes.func\n .description('Called the input changes his height')\n .defaultValue(defaultPropsComposer.onResize),\n onSend: PropTypes.func.description('Called when the click send').defaultValue(defaultPropsComposer.onSend),\n onFocus: PropTypes.func.description('Input focus').defaultValue(defaultPropsComposer.onFocus),\n onBlur: PropTypes.func.description('Input blur').defaultValue(defaultPropsComposer.onBlur),\n onKeyDown: PropTypes.func.description('Input on key down').defaultValue(defaultPropsComposer.onKeyDown),\n maxHeight: PropTypes.number\n .description('Max height of the composer. Use 0 for no limit')\n .defaultValue(defaultPropsComposer.maxHeight),\n inputMaxLength: PropTypes.number\n .description('Max length of the composer. `undefined` for no limit')\n .defaultValue(defaultPropsComposer.inputMaxLength),\n buttonDisabled: PropTypes.bool\n .description('Control the disabled for the send button')\n .defaultValue(defaultPropsComposer.buttonDisabled),\n dataTestid: PropTypes.string.description('Data testid').defaultValue(defaultPropsComposer.dataTestid),\n actionRef: PropTypes.object\n .description(\n `Reference: \n { \n scrollToIndex?: (n: number, opts?: { align?: 'start' | 'center' | 'end' | 'auto', behavior?: 'auto' | 'smooth' }) => void,\n focusToIndex?: (n: number, opts?: { align?: 'start' | 'center' | 'end' | 'auto', behavior?: 'auto' | 'smooth' }) => void,\n getMessagesInView?: () => string[],\n focusToIndexWithoutScroll?: (n: string) => void,\n focusToList?: () => void,\n focusToComposer?: () => void,\n focusToSend?: () => void,\n focusOnBanner?: () => void,\n focusOnBannerLink?: () => void,\n }\n \n `,\n )\n .defaultValue(defaultPropsComposer.actionRef),\n};\n\nexport const defaultPropsMessagesList: DSChatT.MessagesListProps = {\n messages: [],\n actionRef: { current: {} },\n // we don't want this to exist \"by default\" since this loads document.addEventListener\n // the code is already checking for this callback existence everytime it's invoked anyway\n // onScrollEnds: () => [],\n getMoreMessages: noop,\n sendingMessages: undefined,\n sendingText: 'Sending',\n bannerPosition: undefined,\n bannerRef: undefined,\n};\n\nexport const ChatContainerMessagesListPropTypes = {\n ...getPropsPerSlotPropTypes(DSChatContainerSlotName, DSChatContainerSlots),\n ...globalAttributesPropTypes,\n\n messages: PropTypes.arrayOf(PropTypes.object)\n .description('The array of out-of-the-box items you want to render inside the ChatMessageList')\n .defaultValue(defaultPropsMessagesList.messages),\n actionRef: PropTypes.object\n .description(\n `Reference: \n { \n scrollToIndex?: (n: number, opts?: { align?: 'start' | 'center' | 'end' | 'auto', behavior?: 'auto' | 'smooth' }) => void,\n focusToIndex?: (n: number, opts?: { align?: 'start' | 'center' | 'end' | 'auto', behavior?: 'auto' | 'smooth' }) => void,\n getMessagesInView?: () => string[],\n focusToIndexWithoutScroll?: (n: string) => void,\n focusToList?: () => void,\n focusToComposer?: () => void,\n focusToSend?: () => void,\n focusOnBanner?: () => void,\n focusOnBannerLink?: () => void,\n }\n \n `,\n )\n .defaultValue(defaultPropsMessagesList.actionRef),\n onScrollEnds: PropTypes.func.description(`Called when the scroll stops.`),\n isLoading: PropTypes.oneOf(['top', 'bottom', undefined]).description(\n 'Keeps the load more space while the loading is in progress',\n ),\n hasMoreItems: PropTypes.oneOf(['top', 'bottom', undefined]).description(\n 'Show Load More button at the `top` or `bottom` of the container',\n ),\n getMoreMessages: PropTypes.func\n .description(\n 'Called when the user clicks on load more. When older messages are added at the start of `messages`, the list keeps its scroll offset, so the messages in view shift; call `actionRef.current.scrollToIndex` after updating `messages` to bring the user back to where they were',\n )\n .defaultValue(defaultPropsMessagesList.getMoreMessages),\n sendingMessages: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.arrayOf(PropTypes.number)])\n .description('Array of ids of sending messages')\n .defaultValue(defaultPropsMessagesList.sendingMessages),\n sendingText: PropTypes.string\n .description('Label description for messages in sending status')\n .defaultValue(defaultPropsMessagesList.sendingText),\n};\n\nexport const defaultProps: DSChatT.ContainerProps = {\n messagesListProps: defaultPropsMessagesList,\n composerProps: defaultPropsComposer,\n actionRef: undefined,\n autoScroll: false,\n device: 'desktop',\n isLoading: undefined,\n hasMoreItems: undefined,\n getMoreMessages: noop,\n bannerPosition: undefined,\n bannerProps: {\n type: BANNER_TYPES.INFO,\n label: 'Unread Messages',\n viewLabel: 'View',\n onView: noop,\n onClose: noop,\n },\n sendingMessages: undefined,\n sendingText: 'Sending',\n};\n\nexport const ChatContainerPropTypes = {\n ...globalAttributesPropTypes,\n messagesListProps: PropTypes.object\n .description(\n 'ChatMessageList props \"messages\" / \"onScrollEnds\", plus the \"dsChatcontainerMessagesListScrollArea\" slot prop (object or function) for the scroll area',\n )\n .defaultValue(defaultProps.messagesListProps),\n composerProps: PropTypes.object.description('Composer configuration').defaultValue(defaultProps.composerProps),\n autoScroll: PropTypes.bool.description('Auto scroll to bottom on resize').defaultValue(defaultProps.autoScroll),\n device: PropTypes.string\n .description('Option to render mobile or desktop style composer')\n .defaultValue(defaultProps.device),\n isLoading: PropTypes.oneOf(['top', 'bottom', undefined]).description(\n 'Show Loading messages indicator at the `top` or `bottom` of the container',\n ),\n hasMoreItems: PropTypes.oneOf(['top', 'bottom', undefined]).description(\n 'Show Load More button at the `top` or `bottom` of the container',\n ),\n getMoreMessages: PropTypes.func\n .description(\n 'Called when the user clicks on load more. When older messages are added at the start of `messages`, the list keeps its scroll offset, so the messages in view shift; call `actionRef.current.scrollToIndex` after updating `messages` to bring the user back to where they were',\n )\n .defaultValue(defaultProps.getMoreMessages),\n bannerPosition: PropTypes.oneOf(['top', 'bottom', undefined]).description(\n 'Show the unread messages banner (configured with `bannerProps`) at the `top` or `bottom` of the container',\n ),\n bannerProps: PropTypes.object\n .description(\n `Banner configuration:\n label: string;\n viewLabel: string;\n type: BANNER_TYPES;\n onView: () => void;\n onClose: () => void;\n `,\n )\n .defaultValue(defaultProps.bannerProps),\n sendingMessages: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.arrayOf(PropTypes.number)])\n .description('Array of ids of sending messages')\n .defaultValue(defaultProps.sendingMessages),\n sendingText: PropTypes.string\n .description('Label description for messages in sending status')\n .defaultValue(defaultProps.sendingText),\n actionRef: PropTypes.object\n .description(\n `Reference: \n { \n scrollToIndex?: (n: number, opts?: { align?: 'start' | 'center' | 'end' | 'auto', behavior?: 'auto' | 'smooth' }) => void,\n focusToIndex?: (n: number, opts?: { align?: 'start' | 'center' | 'end' | 'auto', behavior?: 'auto' | 'smooth' }) => void,\n getMessagesInView?: () => string[],\n focusToIndexWithoutScroll?: (n: string) => void,\n focusToList?: () => void,\n focusToComposer?: () => void,\n focusToSend?: () => void,\n focusOnBanner?: () => void,\n focusOnBannerLink?: () => void,\n }\n \n `,\n )\n .defaultValue(defaultProps.actionRef),\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACEvB,SAAS,WAAW,0BAA0B,iCAAiC;AAE/E,SAAS,oBAAoB;AAG7B,SAAS,yBAAyB,4BAA4B;AAG9D,SAAS,QAA6B,OAAgB;AAAC;AAiGhD,MAAM,uBAA8C;AAAA,EACzD,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,sBAAsB;AAAA,EACtB,UAAU;AAAA,EACV,UAAU;AA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AC5G,YAAY,kCAAkC,EAC9C,aAAa,aAAa,eAAe;AAAA,EAC5C,aAAa,UAAU,OACpB,YAAY,kDAAkD,EAC9D,aAAa,aAAa,WAAW;AAAA,EACxC,WAAW,UAAU,OAClB;AAAA,IACC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcF,EACC,aAAa,aAAa,SAAS;AACxC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -53,6 +53,19 @@ const testDefinitionAsConst = {
|
|
|
53
53
|
},
|
|
54
54
|
sendingText: "Sending..."
|
|
55
55
|
};
|
|
56
|
+
const actionRef = { current: {} };
|
|
57
|
+
const scrollOptionsAlign = { align: "end" };
|
|
58
|
+
const scrollOptionsBehavior = { behavior: "smooth" };
|
|
59
|
+
const scrollOptionsBoth = { align: "start", behavior: "auto" };
|
|
60
|
+
const publishedScrollOptions = { align: "center" };
|
|
61
|
+
const publishedAlign = publishedScrollOptions.align;
|
|
62
|
+
const publishedNoScrollOptions = void 0;
|
|
63
|
+
const handleScrollToIndexWithPublishedOptions = () => actionRef.current.scrollToIndex?.(1, publishedScrollOptions);
|
|
64
|
+
const handleScrollToIndex = () => actionRef.current.scrollToIndex?.(1);
|
|
65
|
+
const handleScrollToIndexWithAlign = () => actionRef.current.scrollToIndex?.(1, { align: "end" });
|
|
66
|
+
const handleScrollToIndexWithBehavior = () => actionRef.current.scrollToIndex?.(1, { behavior: "smooth" });
|
|
67
|
+
const handleFocusToIndexWithBoth = () => actionRef.current.focusToIndex?.(1, { align: "start", behavior: "auto" });
|
|
68
|
+
const handleGetMessagesInView = () => actionRef.current.getMessagesInView?.() ?? [];
|
|
56
69
|
const ExampleUsageComponent = () => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
57
70
|
/* @__PURE__ */ jsx(ChatContainer, { ...testExplicitDefinition }),
|
|
58
71
|
/* @__PURE__ */ jsx(ChatContainer, { ...testInferedTypeCompatibility }),
|
|
@@ -76,6 +89,24 @@ const ExampleUsageComponent = () => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
|
76
89
|
},
|
|
77
90
|
sendingText: "Sending..."
|
|
78
91
|
}
|
|
92
|
+
),
|
|
93
|
+
/* @__PURE__ */ jsx(ChatContainer, { ...testExplicitDefinition, actionRef }),
|
|
94
|
+
/* @__PURE__ */ jsx(
|
|
95
|
+
ChatContainer,
|
|
96
|
+
{
|
|
97
|
+
...testExplicitDefinition,
|
|
98
|
+
messagesListProps: { messages, dsChatcontainerMessagesListScrollArea: { "aria-describedby": "description" } }
|
|
99
|
+
}
|
|
100
|
+
),
|
|
101
|
+
/* @__PURE__ */ jsx(
|
|
102
|
+
ChatContainer,
|
|
103
|
+
{
|
|
104
|
+
...testExplicitDefinition,
|
|
105
|
+
messagesListProps: {
|
|
106
|
+
messages,
|
|
107
|
+
dsChatcontainerMessagesListScrollArea: () => ({ "aria-describedby": "description" })
|
|
108
|
+
}
|
|
109
|
+
}
|
|
79
110
|
)
|
|
80
111
|
] });
|
|
81
112
|
//# sourceMappingURL=typescript-chat-container-valid.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/typescript-testing/typescript-chat-container-valid.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */\nimport type { DSChatBubbleT } from '@elliemae/ds-chat-bubble';\nimport { ChatContainer } from '../index.js';\nimport type { DSChatT } from '../index.js';\n\n// test we expose the namespace and the namespace follows our deliverable conventions\ntype ComponentPropsForApp = DSChatT.ContainerProps;\n\nconst messages: DSChatBubbleT.Props[] = [];\n\n// using the explicit type definition, if there is an error, it will be marked on the key that is wrong\nconst testExplicitDefinition: ComponentPropsForApp = {\n messagesListProps: {\n messages,\n },\n composerProps: {\n onChange: () => {},\n onSend: () => {},\n buttonDisabled: false,\n },\n autoScroll: false,\n device: 'desktop',\n getMoreMessages: () => {},\n sendingText: 'Sending...',\n};\n\n// using the \"as\" syntax, if there is an error, it will be marking the whole object as wrong because it is not compatible with the type\nconst testInferedTypeCompatibility = {\n messagesListProps: {\n messages,\n },\n composerProps: {\n onChange: () => {},\n onSend: () => {},\n buttonDisabled: false,\n },\n autoScroll: false,\n device: 'desktop',\n getMoreMessages: () => {},\n sendingText: 'Sending...',\n} as ComponentPropsForApp;\n\nconst testDefinitionAsConst = {\n messagesListProps: {\n messages,\n },\n composerProps: {\n onChange: () => {},\n onSend: () => {},\n buttonDisabled: false,\n },\n autoScroll: false,\n device: 'desktop',\n getMoreMessages: () => {},\n sendingText: 'Sending...',\n} as const;\n\nconst ExampleUsageComponent = () => (\n <>\n {/* works with explicitly casted props, all syntaxes */}\n <ChatContainer {...testExplicitDefinition} />\n <ChatContainer {...testInferedTypeCompatibility} />\n <ChatContainer {...testDefinitionAsConst} />\n {/* works with inline values */}\n <ChatContainer\n messagesListProps={{\n messages,\n }}\n composerProps={{\n onChange: () => {},\n onSend: () => {},\n buttonDisabled: false,\n }}\n autoScroll={false}\n device=\"desktop\"\n getMoreMessages={() => {}}\n sendingText=\"Sending...\"\n />\n </>\n);\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */\nimport type { DSChatBubbleT } from '@elliemae/ds-chat-bubble';\nimport { ChatContainer } from '../index.js';\nimport type { DSChatT } from '../index.js';\n\n// test we expose the namespace and the namespace follows our deliverable conventions\ntype ComponentPropsForApp = DSChatT.ContainerProps;\n\nconst messages: DSChatBubbleT.Props[] = [];\n\n// using the explicit type definition, if there is an error, it will be marked on the key that is wrong\nconst testExplicitDefinition: ComponentPropsForApp = {\n messagesListProps: {\n messages,\n },\n composerProps: {\n onChange: () => {},\n onSend: () => {},\n buttonDisabled: false,\n },\n autoScroll: false,\n device: 'desktop',\n getMoreMessages: () => {},\n sendingText: 'Sending...',\n};\n\n// using the \"as\" syntax, if there is an error, it will be marking the whole object as wrong because it is not compatible with the type\nconst testInferedTypeCompatibility = {\n messagesListProps: {\n messages,\n },\n composerProps: {\n onChange: () => {},\n onSend: () => {},\n buttonDisabled: false,\n },\n autoScroll: false,\n device: 'desktop',\n getMoreMessages: () => {},\n sendingText: 'Sending...',\n} as ComponentPropsForApp;\n\nconst testDefinitionAsConst = {\n messagesListProps: {\n messages,\n },\n composerProps: {\n onChange: () => {},\n onSend: () => {},\n buttonDisabled: false,\n },\n autoScroll: false,\n device: 'desktop',\n getMoreMessages: () => {},\n sendingText: 'Sending...',\n} as const;\n\n// the public actionRef, including the scroll options (both `align` and `behavior` are optional)\nconst actionRef: DSChatT.ActionRef = { current: {} };\nconst scrollOptionsAlign: DSChatT.ScrollActionOptions = { align: 'end' };\nconst scrollOptionsBehavior: DSChatT.ScrollActionOptions = { behavior: 'smooth' };\nconst scrollOptionsBoth: DSChatT.ScrollActionOptions = { align: 'start', behavior: 'auto' };\n// ScrollToIndexOptions keeps its published shape: `{ align }` with `align` required, or `undefined`\nconst publishedScrollOptions: NonNullable<DSChatT.ScrollToIndexOptions> = { align: 'center' };\nconst publishedAlign: 'start' | 'center' | 'end' | 'auto' = publishedScrollOptions.align;\nconst publishedNoScrollOptions: DSChatT.ScrollToIndexOptions = undefined;\nconst handleScrollToIndexWithPublishedOptions = () => actionRef.current.scrollToIndex?.(1, publishedScrollOptions);\nconst handleScrollToIndex = () => actionRef.current.scrollToIndex?.(1);\nconst handleScrollToIndexWithAlign = () => actionRef.current.scrollToIndex?.(1, { align: 'end' });\nconst handleScrollToIndexWithBehavior = () => actionRef.current.scrollToIndex?.(1, { behavior: 'smooth' });\nconst handleFocusToIndexWithBoth = () => actionRef.current.focusToIndex?.(1, { align: 'start', behavior: 'auto' });\nconst handleGetMessagesInView: () => string[] = () => actionRef.current.getMessagesInView?.() ?? [];\n\nconst ExampleUsageComponent = () => (\n <>\n {/* works with explicitly casted props, all syntaxes */}\n <ChatContainer {...testExplicitDefinition} />\n <ChatContainer {...testInferedTypeCompatibility} />\n <ChatContainer {...testDefinitionAsConst} />\n {/* works with inline values */}\n <ChatContainer\n messagesListProps={{\n messages,\n }}\n composerProps={{\n onChange: () => {},\n onSend: () => {},\n buttonDisabled: false,\n }}\n autoScroll={false}\n device=\"desktop\"\n getMoreMessages={() => {}}\n sendingText=\"Sending...\"\n />\n <ChatContainer {...testExplicitDefinition} actionRef={actionRef} />\n {/* the message list scroll area slot, in object and function form, through messagesListProps */}\n <ChatContainer\n {...testExplicitDefinition}\n messagesListProps={{ messages, dsChatcontainerMessagesListScrollArea: { 'aria-describedby': 'description' } }}\n />\n <ChatContainer\n {...testExplicitDefinition}\n messagesListProps={{\n messages,\n dsChatcontainerMessagesListScrollArea: () => ({ 'aria-describedby': 'description' }),\n }}\n />\n </>\n);\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;AC0ErB,mBAEE,KAFF;AAxEF,SAAS,qBAAqB;AAM9B,MAAM,WAAkC,CAAC;AAGzC,MAAM,yBAA+C;AAAA,EACnD,mBAAmB;AAAA,IACjB;AAAA,EACF;AAAA,EACA,eAAe;AAAA,IACb,UAAU,MAAM;AAAA,IAAC;AAAA,IACjB,QAAQ,MAAM;AAAA,IAAC;AAAA,IACf,gBAAgB;AAAA,EAClB;AAAA,EACA,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,iBAAiB,MAAM;AAAA,EAAC;AAAA,EACxB,aAAa;AACf;AAGA,MAAM,+BAA+B;AAAA,EACnC,mBAAmB;AAAA,IACjB;AAAA,EACF;AAAA,EACA,eAAe;AAAA,IACb,UAAU,MAAM;AAAA,IAAC;AAAA,IACjB,QAAQ,MAAM;AAAA,IAAC;AAAA,IACf,gBAAgB;AAAA,EAClB;AAAA,EACA,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,iBA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MACF;AAAA,MACA,eAAe;AAAA,QACb,UAAU,MAAM;AAAA,QAAC;AAAA,QACjB,QAAQ,MAAM;AAAA,QAAC;AAAA,QACf,gBAAgB;AAAA,MAClB;AAAA,MACA,YAAY;AAAA,MACZ,QAAO;AAAA,MACP,iBAAiB,MAAM;AAAA,MAAC;AAAA,MACxB,aAAY;AAAA;AAAA,EACd;AAAA,EACA,oBAAC,iBAAe,GAAG,wBAAwB,WAAsB;AAAA,EAEjE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,mBAAmB,EAAE,UAAU,uCAAuC,EAAE,oBAAoB,cAAc,EAAE;AAAA;AAAA,EAC9G;AAAA,EACA;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,mBAAmB;AAAA,QACjB;AAAA,QACA,uCAAuC,OAAO,EAAE,oBAAoB,cAAc;AAAA,MACpF;AAAA;AAAA,EACF;AAAA,GACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
export declare const DSChatContainerName = "DSChatcontainername";
|
|
2
2
|
export declare const DSChatContainerComposerName = "DSChatcontainercomposer";
|
|
3
3
|
export declare const DSChatContainerMessagesList = "DSChatcontainermessageslist";
|
|
4
|
+
/**
|
|
5
|
+
* Slot system: the main component and its parts share one slot owner name, each part with its own slot
|
|
6
|
+
* names (the convention of the `ds-chat-container-compliance` change, which moves these into `src/constants/`).
|
|
7
|
+
*/
|
|
8
|
+
export declare const DSChatContainerSlotName = "DSChatcontainer";
|
|
9
|
+
export declare const DSChatContainerSlots: {
|
|
10
|
+
readonly MESSAGES_LIST_SCROLL_AREA: "messages-list-scroll-area";
|
|
11
|
+
};
|
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
import type { DSChatBubbleT } from '@elliemae/ds-chat-bubble';
|
|
2
2
|
export declare const StyledWrapper: import("styled-components").StyledComponent<"div", import("@elliemae/ds-system").Theme, object & import("@elliemae/ds-system").OwnerInterface & import("@elliemae/ds-system").InnerRefInterface<"div">, never>;
|
|
3
3
|
export declare const StyledWrapperListItem: import("styled-components").StyledComponent<"div", import("@elliemae/ds-system").Theme, Partial<DSChatBubbleT.Props> & import("@elliemae/ds-system").OwnerInterface & import("@elliemae/ds-system").InnerRefInterface<"div">, never>;
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* The scroll container is DSFastList's own container, so its horizontal padding and overflow rules are
|
|
6
|
+
* applied through the class that `styled(DSFastList)` forwards to it. `&&` doubles the class so these
|
|
7
|
+
* rules win over the container's own `overflow: auto` regardless of style injection order.
|
|
8
|
+
*
|
|
9
|
+
* No padding-top here on purpose: the scroll container is also the virtualizer's scroll element, and
|
|
10
|
+
* the virtualizer compares the raw `scrollTop` with its own content-relative item positions with no
|
|
11
|
+
* awareness of CSS padding, so a CSS top-padding would desync `getVisibleItems()` near the top boundary
|
|
12
|
+
* by roughly the padding's own size. The equivalent top space is passed as the virtualizer's
|
|
13
|
+
* `paddingStart` instead (see useChatContainerMessageList.ts).
|
|
14
|
+
*/
|
|
15
|
+
export declare const StyledFastList: import("styled-components").StyledComponent<{
|
|
16
|
+
<T extends object>(props: import("@elliemae/ds-fast-list").DSFastListT.Props<T>): React.JSX.Element;
|
|
17
|
+
displayName: string;
|
|
18
|
+
}, import("@elliemae/ds-system").Theme, object & import("@elliemae/ds-system").OwnerInterface & import("@elliemae/ds-system").InnerRefInterface<{
|
|
19
|
+
<T extends object>(props: import("@elliemae/ds-fast-list").DSFastListT.Props<T>): React.JSX.Element;
|
|
20
|
+
displayName: string;
|
|
21
|
+
}>, never>;
|
|
5
22
|
export declare const StyledNewMessagesHiddenContainer: import("styled-components").StyledComponent<"div", import("@elliemae/ds-system").Theme, object & import("@elliemae/ds-system").OwnerInterface & import("@elliemae/ds-system").InnerRefInterface<"div">, never>;
|
|
6
|
-
export declare const StyledChatContainerContentListScroll: import("styled-components").StyledComponent<"div", import("@elliemae/ds-system").Theme, {
|
|
7
|
-
height: string;
|
|
8
|
-
} & import("@elliemae/ds-system").OwnerInterface & import("@elliemae/ds-system").InnerRefInterface<"div">, never>;
|
|
9
23
|
export declare const StyledLoadMoreContainer: import("styled-components").StyledComponent<"div", import("@elliemae/ds-system").Theme, {
|
|
10
24
|
hasMoreItems?: "top" | "bottom";
|
|
11
25
|
} & import("@elliemae/ds-system").OwnerInterface & import("@elliemae/ds-system").InnerRefInterface<"div">, never>;
|
|
12
|
-
export declare const ListItem: import("styled-components").StyledComponent<"div", import("@elliemae/ds-system").Theme, object & import("@elliemae/ds-system").OwnerInterface & import("@elliemae/ds-system").InnerRefInterface<"div">, never>;
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { useVirtual } from 'react-virtual';
|
|
3
2
|
import type { DSChatT } from '../../react-desc-prop-types.js';
|
|
4
3
|
type UseActionRefArgs = {
|
|
5
4
|
actionRef: DSChatT.ActionRef;
|
|
6
|
-
|
|
7
|
-
virtualListRef: React.MutableRefObject<HTMLDivElement |
|
|
8
|
-
updateCache: () => void;
|
|
5
|
+
vScroll: (index: number, opts?: DSChatT.ScrollActionOptions) => void;
|
|
6
|
+
virtualListRef: React.MutableRefObject<HTMLDivElement | null>;
|
|
9
7
|
getMessagesInView: () => string[];
|
|
10
8
|
onlyFocus: (index: string) => void;
|
|
11
|
-
scrollAndFocus: (index: number, opts?: DSChatT.
|
|
9
|
+
scrollAndFocus: (index: number, opts?: DSChatT.ScrollActionOptions) => void;
|
|
12
10
|
};
|
|
13
|
-
export declare const useActionRef: ({ actionRef,
|
|
11
|
+
export declare const useActionRef: ({ actionRef, vScroll, virtualListRef, getMessagesInView, onlyFocus, scrollAndFocus, }: UseActionRefArgs) => void;
|
|
14
12
|
export {};
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useGetGlobalAttributes } from '@elliemae/ds-props-helpers';
|
|
3
|
-
import {
|
|
3
|
+
import type { DSFastListT } from '@elliemae/ds-fast-list';
|
|
4
4
|
import { useKeyboard } from './useKeyboard.js';
|
|
5
|
+
import { useMessageFocusTracker } from './useMessageFocusTracker.js';
|
|
5
6
|
import type { DSChatT } from '../../react-desc-prop-types.js';
|
|
6
7
|
type UseChatContainerMessageList = (props: DSChatT.MessagesListProps) => {
|
|
7
8
|
propsWithDefault: DSChatT.MessagesListProps;
|
|
8
9
|
globalAttributes: ReturnType<typeof useGetGlobalAttributes>;
|
|
9
|
-
|
|
10
|
+
fastListActionRef: React.MutableRefObject<DSFastListT.ActionRef>;
|
|
11
|
+
paddingStart: number;
|
|
12
|
+
paddingEnd: number;
|
|
10
13
|
loadMoreRef: React.MutableRefObject<HTMLButtonElement | undefined>;
|
|
11
|
-
virtualListRef: React.MutableRefObject<HTMLDivElement |
|
|
14
|
+
virtualListRef: React.MutableRefObject<HTMLDivElement | null>;
|
|
15
|
+
focusTracker: ReturnType<typeof useMessageFocusTracker>;
|
|
12
16
|
} & ReturnType<typeof useKeyboard>;
|
|
13
17
|
export declare const useChatContainerMessageList: UseChatContainerMessageList;
|
|
14
18
|
export {};
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { DSFastListT } from '@elliemae/ds-fast-list';
|
|
3
3
|
import type { DSChatT } from '../../react-desc-prop-types.js';
|
|
4
|
+
import type { MessageId } from './useMessageFocusTracker.js';
|
|
4
5
|
type UseFocusAndScrollHelpersArgs = {
|
|
5
6
|
propsWithDefault: DSChatT.MessagesListProps;
|
|
6
|
-
|
|
7
|
+
fastListActionRef: React.MutableRefObject<DSFastListT.ActionRef>;
|
|
7
8
|
pendingOnScroll: React.MutableRefObject<boolean>;
|
|
8
|
-
|
|
9
|
+
trackFocusMessage: (messageId: MessageId, options?: {
|
|
10
|
+
preventScroll?: boolean;
|
|
11
|
+
}) => void;
|
|
9
12
|
};
|
|
10
|
-
export declare const useFocusAndScrollHelpers: ({ propsWithDefault: { onScrollEnds
|
|
13
|
+
export declare const useFocusAndScrollHelpers: ({ propsWithDefault: { onScrollEnds, messages }, fastListActionRef, pendingOnScroll, trackFocusMessage, }: UseFocusAndScrollHelpersArgs) => {
|
|
14
|
+
vScroll: (index: number, opts?: DSChatT.ScrollActionOptions) => void;
|
|
11
15
|
onScrollStop: () => string[];
|
|
12
|
-
updateCache: import("lodash").DebouncedFuncLeading<() => void>;
|
|
13
16
|
getMessagesInView: () => string[];
|
|
14
17
|
onlyFocus: (index: string) => void;
|
|
15
|
-
scrollAndFocus: (index: number) => void;
|
|
18
|
+
scrollAndFocus: (index: number, opts?: DSChatT.ScrollActionOptions) => void;
|
|
16
19
|
checkPendingOnScroll: () => void;
|
|
17
20
|
};
|
|
18
21
|
export {};
|
|
@@ -3,7 +3,7 @@ import { type TypescriptHelpersT } from '@elliemae/ds-typescript-helpers';
|
|
|
3
3
|
import { type DSChatT } from '../../react-desc-prop-types.js';
|
|
4
4
|
type UseGlobalEventListenerArgs = {
|
|
5
5
|
propsWithDefault: DSChatT.MessagesListProps;
|
|
6
|
-
virtualListRef: React.MutableRefObject<HTMLDivElement |
|
|
6
|
+
virtualListRef: React.MutableRefObject<HTMLDivElement | null>;
|
|
7
7
|
onScrollStop: () => string[];
|
|
8
8
|
checkPendingOnScroll: TypescriptHelpersT.GenericFunc;
|
|
9
9
|
};
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { DSChatT } from '../../react-desc-prop-types.js';
|
|
3
|
+
import type { MessageId } from './useMessageFocusTracker.js';
|
|
3
4
|
type UseKeyboardArgs = {
|
|
4
5
|
propsWithDefault: DSChatT.MessagesListProps;
|
|
5
6
|
actionRef: DSChatT.ActionRef;
|
|
6
|
-
virtualListRef: React.MutableRefObject<HTMLDivElement |
|
|
7
|
+
virtualListRef: React.MutableRefObject<HTMLDivElement | null>;
|
|
7
8
|
loadMoreRef: React.MutableRefObject<HTMLButtonElement | undefined>;
|
|
8
|
-
scrollAndFocus: (index: number, opts?: DSChatT.
|
|
9
|
+
scrollAndFocus: (index: number, opts?: DSChatT.ScrollActionOptions) => void;
|
|
9
10
|
onlyFocus: (index: string) => void;
|
|
10
11
|
getMessagesInView: () => string[];
|
|
12
|
+
trackFocusMessage: (messageId: MessageId, options?: {
|
|
13
|
+
preventScroll?: boolean;
|
|
14
|
+
}) => void;
|
|
11
15
|
};
|
|
12
|
-
export declare const useKeyboard: ({ propsWithDefault: { hasMoreItems, messages, bannerPosition, bannerRef }, actionRef, virtualListRef, loadMoreRef, scrollAndFocus, onlyFocus, getMessagesInView, }: UseKeyboardArgs) => {
|
|
16
|
+
export declare const useKeyboard: ({ propsWithDefault: { hasMoreItems, messages, bannerPosition, bannerRef }, actionRef, virtualListRef, loadMoreRef, scrollAndFocus, onlyFocus, getMessagesInView, trackFocusMessage, }: UseKeyboardArgs) => {
|
|
13
17
|
handleKey: (e: React.KeyboardEvent<HTMLElement>) => void;
|
|
14
18
|
handleListKey: (e: React.KeyboardEvent) => void;
|
|
15
19
|
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/** Focus identity of a message, from `getMessageFocusId`. */
|
|
3
|
+
export type MessageId = string;
|
|
4
|
+
/**
|
|
5
|
+
* Identity the focus intent is kept by: the message's `dsId`, which survives index shifts. `dsId` is required by
|
|
6
|
+
* the types but not at runtime, so a message without one falls back to its index (the focus then follows the
|
|
7
|
+
* position, as it did before the focus tracker) instead of matching every other id-less message. The two forms
|
|
8
|
+
* carry different prefixes so a `dsId` can never equal an index fallback, and the type of the `dsId` is kept so
|
|
9
|
+
* `3` and `'3'` stay different messages, as with a direct comparison.
|
|
10
|
+
*/
|
|
11
|
+
export declare const getMessageFocusId: (message: {
|
|
12
|
+
dsId?: string | number | null;
|
|
13
|
+
}, index: number) => MessageId;
|
|
14
|
+
/**
|
|
15
|
+
* Target by position, for a request made before the message exists in the rendered list (for example
|
|
16
|
+
* `focusToIndex` called right after the consumer adds a message): the item at that index focuses itself when it
|
|
17
|
+
* mounts, and its real focus then moves the intent to its identity.
|
|
18
|
+
*/
|
|
19
|
+
export declare const getMessagePositionId: (index: number) => MessageId;
|
|
20
|
+
export type MessageFocusRequest = {
|
|
21
|
+
/** Identity of the message to focus, from `getMessageFocusId`. */
|
|
22
|
+
messageId: MessageId;
|
|
23
|
+
/** Incremented by every explicit request, so asking again for the current target focuses it again. */
|
|
24
|
+
requestId: number;
|
|
25
|
+
/** `true` when the caller scrolls to the message itself, so focusing must not scroll as well. */
|
|
26
|
+
preventScroll: boolean;
|
|
27
|
+
};
|
|
28
|
+
type TrackFocusOptions = {
|
|
29
|
+
preventScroll?: boolean;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Message focus through the focus-tracker pattern: handlers declare which message should have the focus, and
|
|
33
|
+
* only that message's `ItemRenderer` focuses itself from its ref callback, once React has committed it. Nothing
|
|
34
|
+
* here moves the focus directly.
|
|
35
|
+
*
|
|
36
|
+
* Removing a focused message never clears the intent: React does not dispatch `onBlur` for a focused node it
|
|
37
|
+
* removes itself (measured for a prepend and for a message scrolled out of the virtual window). The intent is
|
|
38
|
+
* cleared by real focus moves: leaving the list (`handleFocusOut`), a `focusin` on a non-message element of the
|
|
39
|
+
* list, any `focusin` outside the list while an intent exists (also when the focus was on the page, where no
|
|
40
|
+
* event crosses the list), and a remount that finds the focus elsewhere (`mayTakeFocus`).
|
|
41
|
+
*/
|
|
42
|
+
export declare const useMessageFocusTracker: (virtualListRef: React.MutableRefObject<HTMLDivElement | null>) => {
|
|
43
|
+
focusRequest: MessageFocusRequest | null;
|
|
44
|
+
trackFocusMessage: (messageId: MessageId, { preventScroll }?: TrackFocusOptions) => void;
|
|
45
|
+
trackFocusResetter: () => void;
|
|
46
|
+
trackFocusedMessage: (messageId: MessageId) => void;
|
|
47
|
+
mayTakeFocus: (requestId: number, target: Element | null) => "request" | "restore" | null;
|
|
48
|
+
markFulfilled: (requestId: number) => void;
|
|
49
|
+
handleFocusOut: (e: React.FocusEvent<HTMLElement>) => void;
|
|
50
|
+
listRootRef: (node: HTMLElement | null) => void;
|
|
51
|
+
};
|
|
52
|
+
export {};
|