@seamly/web-ui 24.3.0-alpha.1 → 24.3.0-beta.1
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/build/dist/lib/index.debug.js +92 -74
- package/build/dist/lib/index.debug.js.map +1 -1
- package/build/dist/lib/index.debug.min.js +1 -1
- package/build/dist/lib/index.debug.min.js.map +1 -1
- package/build/dist/lib/index.js +57 -39
- package/build/dist/lib/index.js.map +1 -1
- package/build/dist/lib/index.min.js +1 -1
- package/build/dist/lib/index.min.js.map +1 -1
- package/build/dist/lib/style-guide.js +2 -1
- package/build/dist/lib/style-guide.js.map +1 -1
- package/build/dist/lib/style-guide.min.js +1 -1
- package/build/dist/lib/style-guide.min.js.map +1 -1
- package/package.json +1 -1
- package/src/javascripts/core/index.ts +4 -1
- package/src/javascripts/core/ui/components/conversation/event/choice-prompt.tsx +15 -9
- package/src/javascripts/core/ui/components/conversation/event/conversation-suggestions.tsx +8 -6
- package/src/javascripts/core/ui/components/conversation/event/hooks/use-event-link-click-handler.ts +5 -3
- package/src/javascripts/core/ui/components/core/seamly-instance-functions-loader.ts +5 -2
- package/src/javascripts/core/ui/components/suggestions/index.tsx +9 -6
- package/src/javascripts/core/ui/hooks/use-seamly-commands.ts +1 -7
- package/src/javascripts/style-guide/components/static-core.tsx +3 -3
package/package.json
CHANGED
|
@@ -67,6 +67,7 @@ export { default as Engine } from 'lib/engine'
|
|
|
67
67
|
export { default as ExternalApi } from 'lib/external-api'
|
|
68
68
|
export { default as SeamlyFileUpload } from 'ui/components/core/seamly-file-upload'
|
|
69
69
|
export { default as SeamlyActivityMonitor } from 'ui/components/core/seamly-activity-monitor'
|
|
70
|
+
export { default as SeamlyActivityEventContext } from 'ui/components/core/seamly-activity-event-context'
|
|
70
71
|
export { timeout } from 'ui/hooks/focus-helper-hooks'
|
|
71
72
|
|
|
72
73
|
export { default as appReducer } from 'domains/app/slice'
|
|
@@ -92,9 +93,11 @@ export type {
|
|
|
92
93
|
export { default as translationReducer } from 'domains/translations/slice'
|
|
93
94
|
export { default as visibilityReducer } from 'domains/visibility/slice'
|
|
94
95
|
export {
|
|
96
|
+
getSearchParamsByKeys,
|
|
95
97
|
getUrlSearchParams,
|
|
96
98
|
getUrlSearchString,
|
|
97
|
-
|
|
99
|
+
initResetSearchParams,
|
|
100
|
+
replaceSearchParams,
|
|
98
101
|
} from 'lib/url-helpers'
|
|
99
102
|
|
|
100
103
|
// Used by: Client
|
|
@@ -20,7 +20,8 @@ import type { MessageChoicePrompt } from 'domains/store/store.types'
|
|
|
20
20
|
export const useChoicePrompt = (event: MessageChoicePrompt) => {
|
|
21
21
|
const { payload } = event
|
|
22
22
|
const [showOptions, setShowOptions] = useState(false)
|
|
23
|
-
const {
|
|
23
|
+
const { addMessageBubble, addDivider, emitEvent, sendAction } =
|
|
24
|
+
useSeamlyCommands()
|
|
24
25
|
const { activeServiceSessionId } = useSeamlyServiceInfo()
|
|
25
26
|
const lastEventId = useLastMessageEventId()
|
|
26
27
|
const { body } = useTranslatedEventData(event)
|
|
@@ -53,21 +54,26 @@ export const useChoicePrompt = (event: MessageChoicePrompt) => {
|
|
|
53
54
|
|
|
54
55
|
const onChoiceClickHandler = (choice) => {
|
|
55
56
|
const transactionId = randomId()
|
|
56
|
-
|
|
57
|
-
if (chooseAgain) {
|
|
58
|
-
addDivider('new_topic', transactionId)
|
|
59
|
-
}
|
|
60
|
-
addMessageBubble(choice.text, transactionId)
|
|
61
|
-
sendAction({
|
|
57
|
+
const action = {
|
|
62
58
|
type: actionTypes.pickChoice,
|
|
63
59
|
originMessage: payload.id,
|
|
64
60
|
choice: {
|
|
65
|
-
id: choice.id,
|
|
66
61
|
chooseAgain,
|
|
62
|
+
id: choice.id,
|
|
67
63
|
},
|
|
68
64
|
transactionId,
|
|
69
|
-
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (chooseAgain) {
|
|
68
|
+
addDivider('new_topic', transactionId)
|
|
69
|
+
}
|
|
70
|
+
addMessageBubble(choice.text, transactionId)
|
|
71
|
+
sendAction(action)
|
|
70
72
|
setShowOptions(false)
|
|
73
|
+
emitEvent(`action.${action.type}`, {
|
|
74
|
+
...action,
|
|
75
|
+
choice: { ...action.choice, text: choice.text },
|
|
76
|
+
})
|
|
71
77
|
}
|
|
72
78
|
|
|
73
79
|
const onChooseAgainClickHandler = () => {
|
|
@@ -26,7 +26,7 @@ const ConversationSuggestions = ({ event, ...props }) => {
|
|
|
26
26
|
const [isExpanded, setIsExpanded] = useState(true)
|
|
27
27
|
const dispatch = useAppDispatch()
|
|
28
28
|
const userHasResponded = useUserHasResponded()
|
|
29
|
-
const {
|
|
29
|
+
const { addMessageBubble, emitEvent, sendAction } = useSeamlyCommands()
|
|
30
30
|
const { suggestions, payload } = useSuggestions(event)
|
|
31
31
|
const { showSuggestions } = useConfig()
|
|
32
32
|
const events = useEvents()
|
|
@@ -58,9 +58,7 @@ const ConversationSuggestions = ({ event, ...props }) => {
|
|
|
58
58
|
dispatch(setHasResponded(true))
|
|
59
59
|
|
|
60
60
|
const transactionId = randomId()
|
|
61
|
-
|
|
62
|
-
// @todo Refactor to 'suggestionclick'
|
|
63
|
-
sendAction({
|
|
61
|
+
const action = {
|
|
64
62
|
type: actionTypes.custom,
|
|
65
63
|
originMessage: payload.id,
|
|
66
64
|
body: {
|
|
@@ -71,10 +69,14 @@ const ConversationSuggestions = ({ event, ...props }) => {
|
|
|
71
69
|
},
|
|
72
70
|
},
|
|
73
71
|
transactionId,
|
|
74
|
-
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// @todo Refactor to 'suggestionclick'
|
|
75
|
+
sendAction(action)
|
|
75
76
|
addMessageBubble(question, transactionId)
|
|
77
|
+
emitEvent(`action.${action.type}`, action)
|
|
76
78
|
},
|
|
77
|
-
[dispatch,
|
|
79
|
+
[addMessageBubble, dispatch, emitEvent, payload.id, sendAction],
|
|
78
80
|
)
|
|
79
81
|
|
|
80
82
|
if (
|
package/src/javascripts/core/ui/components/conversation/event/hooks/use-event-link-click-handler.ts
CHANGED
|
@@ -2,11 +2,11 @@ import { useSeamlyCommands } from 'ui/hooks/seamly-hooks'
|
|
|
2
2
|
import { actionTypes } from 'ui/utils/seamly-utils'
|
|
3
3
|
|
|
4
4
|
const useEventLinkClickHandler = ({ originMessage, transactionId }) => {
|
|
5
|
-
const { sendAction } = useSeamlyCommands()
|
|
5
|
+
const { emitEvent, sendAction } = useSeamlyCommands()
|
|
6
6
|
|
|
7
7
|
const eventClick = (e) => {
|
|
8
8
|
if (e.target && e.target.dataset.linkId) {
|
|
9
|
-
|
|
9
|
+
const action = {
|
|
10
10
|
type: actionTypes.navigate,
|
|
11
11
|
originMessage,
|
|
12
12
|
transactionId,
|
|
@@ -14,7 +14,9 @@ const useEventLinkClickHandler = ({ originMessage, transactionId }) => {
|
|
|
14
14
|
id: e.target.dataset.linkId,
|
|
15
15
|
url: e.target.getAttribute('href'),
|
|
16
16
|
},
|
|
17
|
-
}
|
|
17
|
+
}
|
|
18
|
+
sendAction(action)
|
|
19
|
+
emitEvent(`action.${action.type}`, action)
|
|
18
20
|
}
|
|
19
21
|
}
|
|
20
22
|
|
|
@@ -40,7 +40,8 @@ function useSeamlyInstanceFunction(functionName, fn, deps: any[] = []) {
|
|
|
40
40
|
|
|
41
41
|
const SeamlyInstanceFunctionsLoader = () => {
|
|
42
42
|
const config = useConfig()
|
|
43
|
-
const {
|
|
43
|
+
const { emitEvent, sendAction, sendContext, sendMessage } =
|
|
44
|
+
useSeamlyCommands()
|
|
44
45
|
const dispatch = useAppDispatch()
|
|
45
46
|
const { setVisibility, visible } = useVisibility()
|
|
46
47
|
const currentVisibility = useRef(visible)
|
|
@@ -105,7 +106,9 @@ const SeamlyInstanceFunctionsLoader = () => {
|
|
|
105
106
|
useSeamlyInstanceFunction(
|
|
106
107
|
'sendCustomAction',
|
|
107
108
|
(actionType, body) => {
|
|
108
|
-
|
|
109
|
+
const action = { type: 'custom', body: { type: actionType, body } }
|
|
110
|
+
sendAction(action)
|
|
111
|
+
emitEvent(`action.${action.type}`, action)
|
|
109
112
|
},
|
|
110
113
|
[api.send],
|
|
111
114
|
)
|
|
@@ -31,7 +31,7 @@ const Suggestions = ({ isAside = false }) => {
|
|
|
31
31
|
// generic hooks
|
|
32
32
|
const { isInline } = useSeamlyLayoutMode()
|
|
33
33
|
const { t } = useI18n()
|
|
34
|
-
const {
|
|
34
|
+
const { addMessageBubble, emitEvent, sendAction } = useSeamlyCommands()
|
|
35
35
|
const { isOpen, setVisibility } = useVisibility()
|
|
36
36
|
const { showSuggestions } = useConfig()
|
|
37
37
|
// a11y hooks
|
|
@@ -104,9 +104,7 @@ const Suggestions = ({ isAside = false }) => {
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
const transactionId = randomId()
|
|
107
|
-
|
|
108
|
-
// @todo Refactor to 'suggestionclick'
|
|
109
|
-
sendAction({
|
|
107
|
+
const action = {
|
|
110
108
|
type: actionTypes.custom,
|
|
111
109
|
originMessage: payload.id,
|
|
112
110
|
body: {
|
|
@@ -117,8 +115,12 @@ const Suggestions = ({ isAside = false }) => {
|
|
|
117
115
|
},
|
|
118
116
|
},
|
|
119
117
|
transactionId,
|
|
120
|
-
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// @todo Refactor to 'suggestionclick'
|
|
121
|
+
sendAction(action)
|
|
121
122
|
addMessageBubble(question, transactionId)
|
|
123
|
+
emitEvent(`action.${action.type}`, action)
|
|
122
124
|
|
|
123
125
|
if (!isOpen) {
|
|
124
126
|
setVisibility({ visibility: visibilityStates.open })
|
|
@@ -129,13 +131,14 @@ const Suggestions = ({ isAside = false }) => {
|
|
|
129
131
|
addMessageBubble,
|
|
130
132
|
continueChat,
|
|
131
133
|
endCountdown,
|
|
134
|
+
emitEvent,
|
|
132
135
|
focusSkiplinkTarget,
|
|
133
136
|
hasCountdown,
|
|
134
137
|
hasPrompt,
|
|
138
|
+
isOpen,
|
|
135
139
|
payload,
|
|
136
140
|
sendAction,
|
|
137
141
|
setVisibility,
|
|
138
|
-
isOpen,
|
|
139
142
|
],
|
|
140
143
|
)
|
|
141
144
|
|
|
@@ -8,7 +8,6 @@ import { addEvent, setEvents, setInitialState } from 'domains/store/slice'
|
|
|
8
8
|
import { visibilityStates } from 'domains/visibility/constants'
|
|
9
9
|
import { useVisibility } from 'domains/visibility/hooks'
|
|
10
10
|
import { randomId } from 'lib/id'
|
|
11
|
-
import { actionTypes } from 'ui/utils/seamly-utils'
|
|
12
11
|
import useSeamlyEventBusContext from './event-bus-hooks'
|
|
13
12
|
import {
|
|
14
13
|
useSeamlyApiContext,
|
|
@@ -192,13 +191,8 @@ const useSeamlyCommands = () => {
|
|
|
192
191
|
}
|
|
193
192
|
|
|
194
193
|
api.send('action', body)
|
|
195
|
-
|
|
196
|
-
const { type } = body
|
|
197
|
-
if (type !== actionTypes.typing && type !== actionTypes.read) {
|
|
198
|
-
emitEvent(`action.${type}`, body)
|
|
199
|
-
}
|
|
200
194
|
},
|
|
201
|
-
[api
|
|
195
|
+
[api],
|
|
202
196
|
)
|
|
203
197
|
|
|
204
198
|
const sendContext = useCallback(
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
SeamlyEventBusContext,
|
|
8
8
|
SeamlyLiveRegionContext,
|
|
9
9
|
SeamlyStoreProvider,
|
|
10
|
-
SeamlyActivityMonitor,
|
|
11
10
|
SeamlyFileUpload,
|
|
12
11
|
API,
|
|
13
12
|
configReducer,
|
|
@@ -27,6 +26,7 @@ import {
|
|
|
27
26
|
ReduxStore,
|
|
28
27
|
translationReducer,
|
|
29
28
|
visibilityReducer,
|
|
29
|
+
SeamlyActivityEventContext,
|
|
30
30
|
} from '@seamly/web-ui'
|
|
31
31
|
|
|
32
32
|
const bareApi = {
|
|
@@ -137,9 +137,9 @@ const SeamlyStaticCore: FC<StaticCoreProps> = ({
|
|
|
137
137
|
<SeamlyApiContext.Provider value={bareApi}>
|
|
138
138
|
<SeamlyLiveRegionContext.Provider value={liveMsgRef.current}>
|
|
139
139
|
<ComponentFilter>
|
|
140
|
-
<
|
|
140
|
+
<SeamlyActivityEventContext.Provider value={() => {}}>
|
|
141
141
|
<SeamlyFileUpload>{children}</SeamlyFileUpload>
|
|
142
|
-
</
|
|
142
|
+
</SeamlyActivityEventContext.Provider>
|
|
143
143
|
</ComponentFilter>
|
|
144
144
|
</SeamlyLiveRegionContext.Provider>
|
|
145
145
|
</SeamlyApiContext.Provider>
|