@seamly/web-ui 22.2.0 → 22.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/components.js +269 -138
- package/build/dist/lib/components.js.map +1 -1
- package/build/dist/lib/components.min.js +1 -1
- package/build/dist/lib/components.min.js.map +1 -1
- package/build/dist/lib/hooks.js +217 -41
- package/build/dist/lib/hooks.js.map +1 -1
- package/build/dist/lib/hooks.min.js +1 -1
- package/build/dist/lib/hooks.min.js.map +1 -1
- package/build/dist/lib/index.debug.js +43 -21
- 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.LICENSE.txt +12 -4
- package/build/dist/lib/index.debug.min.js.map +1 -1
- package/build/dist/lib/index.js +257 -133
- 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/standalone.js +265 -133
- package/build/dist/lib/standalone.js.map +1 -1
- package/build/dist/lib/standalone.min.js +1 -1
- package/build/dist/lib/standalone.min.js.map +1 -1
- package/build/dist/lib/style-guide.js +274 -134
- 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/build/dist/lib/styles.css +1 -1
- package/build/dist/lib/utils.js +325 -171
- package/build/dist/lib/utils.js.map +1 -1
- package/build/dist/lib/utils.min.js +1 -1
- package/build/dist/lib/utils.min.js.map +1 -1
- package/package.json +1 -1
- package/src/javascripts/api/errors/seamly-api-error.ts +0 -1
- package/src/javascripts/api/index.ts +16 -8
- package/src/javascripts/domains/app/actions.ts +8 -3
- package/src/javascripts/domains/interrupt/selectors.ts +3 -2
- package/src/javascripts/domains/interrupt/slice.ts +2 -0
- package/src/javascripts/domains/redux/create-debounced-async-thunk.ts +109 -0
- package/src/javascripts/domains/redux/redux.types.ts +2 -1
- package/src/javascripts/domains/store/actions.ts +38 -0
- package/src/javascripts/domains/visibility/actions.ts +4 -1
- package/src/javascripts/style-guide/states.js +18 -1
- package/src/javascripts/ui/components/conversation/event/{card-component.js → card-component.tsx} +6 -4
- package/src/javascripts/ui/components/conversation/event/event-participant.js +1 -1
- package/src/javascripts/ui/components/core/seamly-event-subscriber.ts +14 -30
- package/src/javascripts/ui/components/view/window-view/window-open-button.js +8 -3
- package/src/javascripts/ui/hooks/use-session-expired-command.ts +31 -2
- package/src/stylesheets/5-components/_message-count.scss +11 -9
|
@@ -12499,7 +12499,8 @@ class API {
|
|
|
12499
12499
|
});
|
|
12500
12500
|
}
|
|
12501
12501
|
getConversationUrl() {
|
|
12502
|
-
|
|
12502
|
+
const conversationUrl = this.store.get('conversationUrl');
|
|
12503
|
+
return conversationUrl;
|
|
12503
12504
|
}
|
|
12504
12505
|
hasConversation() {
|
|
12505
12506
|
return !!this.getConversationUrl();
|
|
@@ -12608,7 +12609,7 @@ class API {
|
|
|
12608
12609
|
if (error.status >= 500) {
|
|
12609
12610
|
throw new SeamlyGeneralError(error);
|
|
12610
12611
|
}
|
|
12611
|
-
throw error;
|
|
12612
|
+
throw new ApiError(error);
|
|
12612
12613
|
}
|
|
12613
12614
|
});
|
|
12614
12615
|
}
|
|
@@ -12718,7 +12719,7 @@ class API {
|
|
|
12718
12719
|
if (error.status >= 500) {
|
|
12719
12720
|
throw new SeamlyGeneralError(error);
|
|
12720
12721
|
}
|
|
12721
|
-
throw error;
|
|
12722
|
+
throw new ApiError(error);
|
|
12722
12723
|
}
|
|
12723
12724
|
});
|
|
12724
12725
|
}
|
|
@@ -12780,15 +12781,17 @@ class API {
|
|
|
12780
12781
|
}
|
|
12781
12782
|
}
|
|
12782
12783
|
_API_ready = new (weak_map_default())(), _API_externalId = new (weak_map_default())(), _API_conversationAuthToken = new (weak_map_default())(), _API_layoutMode = new (weak_map_default())(), _API_config = new (weak_map_default())(), _API_getLocale = new (weak_map_default())(), _API_instances = new (weak_set_default())(), _API_getAccessToken = function _API_getAccessToken() {
|
|
12783
|
-
|
|
12784
|
+
const accessToken = this.store.get('accessToken');
|
|
12785
|
+
return accessToken;
|
|
12784
12786
|
}, _API_setAccessToken = function _API_setAccessToken(accessToken) {
|
|
12785
12787
|
this.store.set('accessToken', accessToken);
|
|
12786
12788
|
}, _API_setConversationUrl = function _API_setConversationUrl(url) {
|
|
12787
12789
|
this.store.set('conversationUrl', url);
|
|
12788
12790
|
}, _API_getChannelTopic = function _API_getChannelTopic() {
|
|
12791
|
+
const channelTopic = this.store.get('channelTopic') || this.store.get('channelName');
|
|
12789
12792
|
// The `channelName` fallback is needed for seamless client upgrades.
|
|
12790
12793
|
// TODO: Remove when all clients have been upgraded past v20.
|
|
12791
|
-
return
|
|
12794
|
+
return channelTopic;
|
|
12792
12795
|
}, _API_setChannelTopic = function _API_setChannelTopic(topic) {
|
|
12793
12796
|
this.store.set('channelTopic', topic);
|
|
12794
12797
|
}, _API_getUrlPrefix = function _API_getUrlPrefix(protocol) {
|
|
@@ -12859,7 +12862,7 @@ _API_ready = new (weak_map_default())(), _API_externalId = new (weak_map_default
|
|
|
12859
12862
|
return {
|
|
12860
12863
|
clientName: "@seamly/web-ui",
|
|
12861
12864
|
clientVariant: api_classPrivateFieldGet(this, _API_layoutMode, "f"),
|
|
12862
|
-
clientVersion: "22.
|
|
12865
|
+
clientVersion: "22.3.0-beta.1",
|
|
12863
12866
|
currentUrl: window.location.toString(),
|
|
12864
12867
|
screenResolution: `${window.screen.width}x${window.screen.height}`,
|
|
12865
12868
|
timezone: getTimeZone(),
|
|
@@ -16709,6 +16712,64 @@ const setLocale = createAsyncThunk('setLocale', (locale, _ref) => {
|
|
|
16709
16712
|
return true;
|
|
16710
16713
|
}
|
|
16711
16714
|
});
|
|
16715
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/redux/create-debounced-async-thunk.ts
|
|
16716
|
+
|
|
16717
|
+
|
|
16718
|
+
|
|
16719
|
+
/**
|
|
16720
|
+
* A debounced analogue of the `createAsyncThunk` from `@reduxjs/toolkit`
|
|
16721
|
+
* @param typePrefix - a string action type value
|
|
16722
|
+
* @param payloadCreator - a callback function that should return a promise containing the result of some asynchronous logic
|
|
16723
|
+
* @param debounceOptions - the debounce options object
|
|
16724
|
+
*/
|
|
16725
|
+
const createDebouncedAsyncThunk = (typePrefix, payloadCreator, debounceOptions) => {
|
|
16726
|
+
const {
|
|
16727
|
+
wait = 300,
|
|
16728
|
+
maxWait = 0,
|
|
16729
|
+
leading = false
|
|
16730
|
+
} = debounceOptions !== null && debounceOptions !== void 0 ? debounceOptions : {};
|
|
16731
|
+
let debounceTimer = null;
|
|
16732
|
+
let maxWaitTimer = null;
|
|
16733
|
+
let resolve;
|
|
16734
|
+
const cancel = () => {
|
|
16735
|
+
if (resolve) {
|
|
16736
|
+
resolve(false);
|
|
16737
|
+
resolve = undefined;
|
|
16738
|
+
}
|
|
16739
|
+
};
|
|
16740
|
+
const invoke = () => {
|
|
16741
|
+
clearTimeout(maxWaitTimer);
|
|
16742
|
+
maxWaitTimer = undefined;
|
|
16743
|
+
if (resolve) {
|
|
16744
|
+
resolve(true);
|
|
16745
|
+
resolve = undefined;
|
|
16746
|
+
}
|
|
16747
|
+
};
|
|
16748
|
+
const debounceExecutionCondition = () => {
|
|
16749
|
+
const immediate = leading && !debounceTimer;
|
|
16750
|
+
// Start debounced condition resolution
|
|
16751
|
+
clearTimeout(debounceTimer);
|
|
16752
|
+
debounceTimer = set_timeout_default()(() => {
|
|
16753
|
+
invoke();
|
|
16754
|
+
debounceTimer = null;
|
|
16755
|
+
}, wait);
|
|
16756
|
+
if (immediate) {
|
|
16757
|
+
return true;
|
|
16758
|
+
}
|
|
16759
|
+
cancel();
|
|
16760
|
+
// Start max wait condition resolution
|
|
16761
|
+
if (maxWait && !maxWaitTimer) {
|
|
16762
|
+
maxWaitTimer = set_timeout_default()(invoke, maxWait);
|
|
16763
|
+
}
|
|
16764
|
+
return new (promise_default())(res => {
|
|
16765
|
+
resolve = res;
|
|
16766
|
+
});
|
|
16767
|
+
};
|
|
16768
|
+
return createAsyncThunk(typePrefix, payloadCreator, {
|
|
16769
|
+
condition: debounceExecutionCondition
|
|
16770
|
+
});
|
|
16771
|
+
};
|
|
16772
|
+
/* harmony default export */ var create_debounced_async_thunk = (createDebouncedAsyncThunk);
|
|
16712
16773
|
;// CONCATENATED MODULE: ./node_modules/reselect/es/defaultMemoize.js
|
|
16713
16774
|
// Cache implementation based on Erik Rasmussen's `lru-memoize`:
|
|
16714
16775
|
// https://github.com/erikras/lru-memoize
|
|
@@ -17294,8 +17355,9 @@ const setVisibility = createAsyncThunk('setVisibility', (requestedVisibility, _r
|
|
|
17294
17355
|
if (previousVisibility === calculatedVisibility) {
|
|
17295
17356
|
return undefined;
|
|
17296
17357
|
}
|
|
17358
|
+
const visibility = api.store.get(StoreKey);
|
|
17297
17359
|
// Store the user-requested visibility in order to reinitialize after refresh
|
|
17298
|
-
api.store.set(StoreKey, assign_default()(assign_default()({},
|
|
17360
|
+
api.store.set(StoreKey, assign_default()(assign_default()({}, visibility || {}), {
|
|
17299
17361
|
[layoutMode]: requestedVisibility
|
|
17300
17362
|
}));
|
|
17301
17363
|
if (requestedVisibility) {
|
|
@@ -17363,6 +17425,7 @@ var app_actions_awaiter = undefined && undefined.__awaiter || function (thisArg,
|
|
|
17363
17425
|
|
|
17364
17426
|
|
|
17365
17427
|
|
|
17428
|
+
|
|
17366
17429
|
const initializeApp = createAsyncThunk('initializeApp', (_, _ref) => {
|
|
17367
17430
|
let {
|
|
17368
17431
|
extra: {
|
|
@@ -17431,7 +17494,7 @@ const initializeApp = createAsyncThunk('initializeApp', (_, _ref) => {
|
|
|
17431
17494
|
}
|
|
17432
17495
|
});
|
|
17433
17496
|
});
|
|
17434
|
-
const resetApp =
|
|
17497
|
+
const resetApp = create_debounced_async_thunk('resetApp', (_, _ref2) => {
|
|
17435
17498
|
let {
|
|
17436
17499
|
dispatch,
|
|
17437
17500
|
extra: {
|
|
@@ -17440,7 +17503,7 @@ const resetApp = createAsyncThunk('resetApp', (_, _ref2) => {
|
|
|
17440
17503
|
} = _ref2;
|
|
17441
17504
|
return app_actions_awaiter(void 0, void 0, void 0, function* () {
|
|
17442
17505
|
yield api.disconnect();
|
|
17443
|
-
|
|
17506
|
+
api.clearStore();
|
|
17444
17507
|
dispatch(resetConfig());
|
|
17445
17508
|
yield dispatch(initializeConfig());
|
|
17446
17509
|
try {
|
|
@@ -17448,11 +17511,14 @@ const resetApp = createAsyncThunk('resetApp', (_, _ref2) => {
|
|
|
17448
17511
|
locale
|
|
17449
17512
|
} = yield dispatch(initializeApp()).unwrap();
|
|
17450
17513
|
yield dispatch(setLocale(locale));
|
|
17451
|
-
} catch (
|
|
17514
|
+
} catch (e) {
|
|
17452
17515
|
// nothing to do
|
|
17453
17516
|
}
|
|
17454
17517
|
dispatch(initializeVisibility());
|
|
17455
17518
|
});
|
|
17519
|
+
}, {
|
|
17520
|
+
wait: 2000,
|
|
17521
|
+
leading: true
|
|
17456
17522
|
});
|
|
17457
17523
|
;// CONCATENATED MODULE: ./src/javascripts/domains/app/hooks.js
|
|
17458
17524
|
|
|
@@ -17491,12 +17557,80 @@ const {
|
|
|
17491
17557
|
setHasResponded
|
|
17492
17558
|
} = appSlice.actions;
|
|
17493
17559
|
/* harmony default export */ var app_slice = (appSlice.reducer);
|
|
17560
|
+
;// CONCATENATED MODULE: ./src/javascripts/domains/store/actions.ts
|
|
17561
|
+
|
|
17562
|
+
var store_actions_awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
17563
|
+
function adopt(value) {
|
|
17564
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
17565
|
+
resolve(value);
|
|
17566
|
+
});
|
|
17567
|
+
}
|
|
17568
|
+
return new (P || (P = (promise_default())))(function (resolve, reject) {
|
|
17569
|
+
function fulfilled(value) {
|
|
17570
|
+
try {
|
|
17571
|
+
step(generator.next(value));
|
|
17572
|
+
} catch (e) {
|
|
17573
|
+
reject(e);
|
|
17574
|
+
}
|
|
17575
|
+
}
|
|
17576
|
+
function rejected(value) {
|
|
17577
|
+
try {
|
|
17578
|
+
step(generator["throw"](value));
|
|
17579
|
+
} catch (e) {
|
|
17580
|
+
reject(e);
|
|
17581
|
+
}
|
|
17582
|
+
}
|
|
17583
|
+
function step(result) {
|
|
17584
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
17585
|
+
}
|
|
17586
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
17587
|
+
});
|
|
17588
|
+
};
|
|
17589
|
+
|
|
17590
|
+
const getConversation = createAsyncThunk('getConversation', (_, _ref) => {
|
|
17591
|
+
let {
|
|
17592
|
+
extra: {
|
|
17593
|
+
api
|
|
17594
|
+
},
|
|
17595
|
+
rejectWithValue
|
|
17596
|
+
} = _ref;
|
|
17597
|
+
return store_actions_awaiter(void 0, void 0, void 0, function* () {
|
|
17598
|
+
try {
|
|
17599
|
+
return api.getConversation();
|
|
17600
|
+
} catch (error) {
|
|
17601
|
+
return rejectWithValue({
|
|
17602
|
+
name: error === null || error === void 0 ? void 0 : error.name,
|
|
17603
|
+
message: error === null || error === void 0 ? void 0 : error.message,
|
|
17604
|
+
langKey: error === null || error === void 0 ? void 0 : error.langKey,
|
|
17605
|
+
action: error === null || error === void 0 ? void 0 : error.action,
|
|
17606
|
+
originalEvent: error === null || error === void 0 ? void 0 : error.originalEvent,
|
|
17607
|
+
originalError: error === null || error === void 0 ? void 0 : error.originalError
|
|
17608
|
+
});
|
|
17609
|
+
}
|
|
17610
|
+
});
|
|
17611
|
+
}, {
|
|
17612
|
+
condition(payload, _ref2) {
|
|
17613
|
+
let {
|
|
17614
|
+
getState
|
|
17615
|
+
} = _ref2;
|
|
17616
|
+
var _a;
|
|
17617
|
+
const {
|
|
17618
|
+
state: {
|
|
17619
|
+
events
|
|
17620
|
+
}
|
|
17621
|
+
} = getState();
|
|
17622
|
+
const lastEvent = events[events.length - 1];
|
|
17623
|
+
const payloadLastEventId = (_a = payload === null || payload === void 0 ? void 0 : payload.lastEvent) === null || _a === void 0 ? void 0 : _a.id;
|
|
17624
|
+
return lastEvent && payloadLastEventId !== lastEvent.payload.id;
|
|
17625
|
+
}
|
|
17626
|
+
});
|
|
17494
17627
|
;// CONCATENATED MODULE: ./src/javascripts/domains/interrupt/slice.ts
|
|
17495
17628
|
|
|
17496
17629
|
|
|
17497
17630
|
|
|
17498
17631
|
|
|
17499
17632
|
|
|
17633
|
+
|
|
17500
17634
|
const slice_initialState = {
|
|
17501
17635
|
error: undefined
|
|
17502
17636
|
};
|
|
@@ -17510,7 +17644,7 @@ const interruptSlice = createSlice({
|
|
|
17510
17644
|
clearInterrupt: () => slice_initialState
|
|
17511
17645
|
},
|
|
17512
17646
|
extraReducers: builder => {
|
|
17513
|
-
builder.addCase(initializeConfig.pending, () => slice_initialState).addMatcher(isAnyOf(initializeApp.rejected, initializeConfig.rejected, setLocale.rejected, setVisibility.rejected, initializeVisibility.rejected), (state, _ref) => {
|
|
17647
|
+
builder.addCase(initializeConfig.pending, () => slice_initialState).addMatcher(isAnyOf(initializeApp.rejected, initializeConfig.rejected, setLocale.rejected, setVisibility.rejected, initializeVisibility.rejected, getConversation.rejected), (state, _ref) => {
|
|
17514
17648
|
let {
|
|
17515
17649
|
payload
|
|
17516
17650
|
} = _ref;
|
|
@@ -20093,6 +20227,10 @@ function useInterrupt() {
|
|
|
20093
20227
|
|
|
20094
20228
|
|
|
20095
20229
|
|
|
20230
|
+
|
|
20231
|
+
|
|
20232
|
+
|
|
20233
|
+
|
|
20096
20234
|
function useSessionExpiredCommand() {
|
|
20097
20235
|
const {
|
|
20098
20236
|
meta: {
|
|
@@ -20100,13 +20238,35 @@ function useSessionExpiredCommand() {
|
|
|
20100
20238
|
action
|
|
20101
20239
|
}
|
|
20102
20240
|
} = useInterrupt();
|
|
20241
|
+
const dispatch = useAppDispatch();
|
|
20103
20242
|
const seamlyCommands = use_seamly_commands();
|
|
20104
20243
|
const isExpiredError = (originalError === null || originalError === void 0 ? void 0 : originalError.name) === 'SeamlySessionExpiredError';
|
|
20244
|
+
const limit = (0,hooks_module/* useRef */.sO)(0);
|
|
20245
|
+
const limitTimer = (0,hooks_module/* useRef */.sO)(null);
|
|
20105
20246
|
(0,hooks_module/* useEffect */.d4)(() => {
|
|
20106
20247
|
if (isExpiredError && seamlyCommands[action]) {
|
|
20248
|
+
if (limit.current >= 10) {
|
|
20249
|
+
limitTimer.current = set_timeout_default()(() => {
|
|
20250
|
+
limit.current = 0;
|
|
20251
|
+
}, 10000);
|
|
20252
|
+
const error = new SeamlyGeneralError();
|
|
20253
|
+
dispatch(setInterrupt({
|
|
20254
|
+
name: error.name,
|
|
20255
|
+
message: error.message,
|
|
20256
|
+
langKey: error.langKey,
|
|
20257
|
+
originalEvent: error.originalEvent,
|
|
20258
|
+
originalError: error.originalError,
|
|
20259
|
+
action: error.action
|
|
20260
|
+
}));
|
|
20261
|
+
return () => {};
|
|
20262
|
+
}
|
|
20263
|
+
limit.current += 1;
|
|
20107
20264
|
seamlyCommands[action]();
|
|
20108
20265
|
}
|
|
20109
|
-
|
|
20266
|
+
return () => {
|
|
20267
|
+
if (limitTimer.current) clearTimeout(limitTimer.current);
|
|
20268
|
+
};
|
|
20269
|
+
}, [action, seamlyCommands, isExpiredError, dispatch]);
|
|
20110
20270
|
}
|
|
20111
20271
|
;// CONCATENATED MODULE: ./src/javascripts/ui/hooks/use-seamly-chat.ts
|
|
20112
20272
|
|
|
@@ -20987,7 +21147,7 @@ const EventParticipant = _ref => {
|
|
|
20987
21147
|
})
|
|
20988
21148
|
}));
|
|
20989
21149
|
}
|
|
20990
|
-
if (showName) {
|
|
21150
|
+
if (showName && participantName) {
|
|
20991
21151
|
authorInfo.push(o("span", {
|
|
20992
21152
|
className: css_className('message__author-name'),
|
|
20993
21153
|
children: participantName
|
|
@@ -21071,109 +21231,61 @@ function MessageContainer(_ref) {
|
|
|
21071
21231
|
});
|
|
21072
21232
|
}
|
|
21073
21233
|
/* harmony default export */ var message_container = (MessageContainer);
|
|
21074
|
-
;// CONCATENATED MODULE: ./src/javascripts/ui/components/conversation/event/card-component.
|
|
21075
|
-
|
|
21234
|
+
;// CONCATENATED MODULE: ./src/javascripts/ui/components/conversation/event/card-component.tsx
|
|
21076
21235
|
|
|
21077
21236
|
|
|
21078
21237
|
|
|
21079
21238
|
|
|
21080
21239
|
|
|
21081
|
-
const CardComponent =
|
|
21082
|
-
|
|
21083
|
-
|
|
21084
|
-
|
|
21085
|
-
|
|
21086
|
-
|
|
21087
|
-
|
|
21088
|
-
|
|
21089
|
-
|
|
21090
|
-
|
|
21091
|
-
|
|
21092
|
-
|
|
21093
|
-
|
|
21094
|
-
|
|
21095
|
-
|
|
21096
|
-
emitEvent
|
|
21097
|
-
} = use_seamly_commands();
|
|
21098
|
-
const descriptionId = useGeneratedId();
|
|
21099
|
-
const isMounted = (0,hooks_module/* useRef */.sO)();
|
|
21100
|
-
const CardActionComponent = action.type === cardTypes.navigate ? 'a' : 'button';
|
|
21101
|
-
const emitCardEvent = (0,hooks_module/* useCallback */.I4)(() => emitEvent(`action.${actionTypes.clickCard}`, {
|
|
21102
|
-
type: actionTypes.clickCta,
|
|
21103
|
-
originMessage: id,
|
|
21104
|
-
action
|
|
21105
|
-
}), [emitEvent, id, action]);
|
|
21106
|
-
const handleClick = (0,hooks_module/* useCallback */.I4)(() => {
|
|
21107
|
-
emitCardEvent();
|
|
21108
|
-
if (action.type === cardTypes.ask) {
|
|
21109
|
-
sendMessage({
|
|
21110
|
-
body: action.ask
|
|
21111
|
-
});
|
|
21112
|
-
} else if (action.type === cardTypes.topic) {
|
|
21113
|
-
const {
|
|
21114
|
-
topic: name,
|
|
21115
|
-
fallbackMessage
|
|
21116
|
-
} = action;
|
|
21117
|
-
sendAction({
|
|
21118
|
-
type: actionTypes.setTopic,
|
|
21119
|
-
body: {
|
|
21120
|
-
name,
|
|
21121
|
-
fallbackMessage
|
|
21240
|
+
const CardComponent = ({ id, action, buttonText, description, hasFocus, image, title, isCarouselItem, }) => {
|
|
21241
|
+
const cardRef = (0,hooks_module/* useRef */.sO)(null);
|
|
21242
|
+
const { sendMessage, sendAction, emitEvent } = use_seamly_commands();
|
|
21243
|
+
const descriptionId = useGeneratedId();
|
|
21244
|
+
const isMounted = (0,hooks_module/* useRef */.sO)(false);
|
|
21245
|
+
const CardActionComponent = action.type === cardTypes.navigate ? 'a' : 'button';
|
|
21246
|
+
const emitCardEvent = (0,hooks_module/* useCallback */.I4)(() => emitEvent(`action.${actionTypes.clickCard}`, {
|
|
21247
|
+
type: actionTypes.clickCta,
|
|
21248
|
+
originMessage: id,
|
|
21249
|
+
action,
|
|
21250
|
+
}), [emitEvent, id, action]);
|
|
21251
|
+
const handleClick = (0,hooks_module/* useCallback */.I4)(() => {
|
|
21252
|
+
emitCardEvent();
|
|
21253
|
+
if (action.type === cardTypes.ask) {
|
|
21254
|
+
sendMessage({ body: action.ask });
|
|
21122
21255
|
}
|
|
21123
|
-
|
|
21124
|
-
|
|
21125
|
-
|
|
21126
|
-
|
|
21127
|
-
|
|
21128
|
-
|
|
21129
|
-
target: action.newTab ? '_blank' : '_self',
|
|
21130
|
-
onClick: emitCardEvent
|
|
21131
|
-
} : {
|
|
21132
|
-
onClick: handleClick
|
|
21133
|
-
}, [action, handleClick, emitCardEvent]);
|
|
21134
|
-
(0,hooks_module/* useEffect */.d4)(() => {
|
|
21135
|
-
if (isCarouselItem) {
|
|
21136
|
-
if (hasFocus && isMounted.current) {
|
|
21137
|
-
window.requestAnimationFrame(() => cardRef.current.focus());
|
|
21138
|
-
} else {
|
|
21139
|
-
cardRef.current.blur();
|
|
21140
|
-
}
|
|
21141
|
-
}
|
|
21142
|
-
isMounted.current = true;
|
|
21143
|
-
}, [hasFocus, isCarouselItem]);
|
|
21144
|
-
return o("div", {
|
|
21145
|
-
className: css_className('card__wrapper'),
|
|
21146
|
-
id: id,
|
|
21147
|
-
tabIndex: "-1" // set tabIndex of -1 so card can be focussed
|
|
21148
|
-
,
|
|
21149
|
-
ref: cardRef,
|
|
21150
|
-
children: [o("img", {
|
|
21151
|
-
className: css_className('card__image'),
|
|
21152
|
-
src: image,
|
|
21153
|
-
alt: ""
|
|
21154
|
-
}), o("div", {
|
|
21155
|
-
className: css_className('card__content'),
|
|
21156
|
-
id: id,
|
|
21157
|
-
children: [title && o("h2", {
|
|
21158
|
-
className: css_className('card__title'),
|
|
21159
|
-
children: title
|
|
21160
|
-
}), description && o("div", {
|
|
21161
|
-
className: css_className('card__description'),
|
|
21162
|
-
dangerouslySetInnerHTML: {
|
|
21163
|
-
__html: description
|
|
21256
|
+
else if (action.type === cardTypes.topic) {
|
|
21257
|
+
const { topic: name, fallbackMessage } = action;
|
|
21258
|
+
sendAction({
|
|
21259
|
+
type: actionTypes.setTopic,
|
|
21260
|
+
body: { name, fallbackMessage },
|
|
21261
|
+
});
|
|
21164
21262
|
}
|
|
21165
|
-
|
|
21166
|
-
|
|
21167
|
-
|
|
21168
|
-
|
|
21169
|
-
|
|
21170
|
-
|
|
21171
|
-
|
|
21172
|
-
|
|
21173
|
-
|
|
21174
|
-
|
|
21263
|
+
}, [sendMessage, action, sendAction, emitCardEvent]);
|
|
21264
|
+
const actionProps = (0,hooks_module/* useMemo */.Ye)(() => action.type === cardTypes.navigate
|
|
21265
|
+
? {
|
|
21266
|
+
href: action.link,
|
|
21267
|
+
rel: 'noopener noreferrer',
|
|
21268
|
+
target: action.newTab ? '_blank' : '_self',
|
|
21269
|
+
onClick: emitCardEvent,
|
|
21270
|
+
}
|
|
21271
|
+
: {
|
|
21272
|
+
onClick: handleClick,
|
|
21273
|
+
}, [action, handleClick, emitCardEvent]);
|
|
21274
|
+
(0,hooks_module/* useEffect */.d4)(() => {
|
|
21275
|
+
if (isCarouselItem) {
|
|
21276
|
+
if (hasFocus && isMounted.current) {
|
|
21277
|
+
window.requestAnimationFrame(() => cardRef.current.focus());
|
|
21278
|
+
}
|
|
21279
|
+
else {
|
|
21280
|
+
cardRef.current.blur();
|
|
21281
|
+
}
|
|
21282
|
+
}
|
|
21283
|
+
isMounted.current = true;
|
|
21284
|
+
}, [hasFocus, isCarouselItem]);
|
|
21285
|
+
return (o("div", { className: css_className('card__wrapper'), id: id, tabIndex: -1, ref: cardRef, children: [image ? (o("img", { className: css_className('card__image'), src: image, alt: "" })) : null, o("div", { className: css_className('card__content'), id: id, children: [title && o("h2", { className: css_className('card__title'), children: title }), description && (o("div", { className: css_className('card__description'), dangerouslySetInnerHTML: { __html: description } })), o(CardActionComponent, Object.assign({ tabIndex: isCarouselItem && !hasFocus ? -1 : undefined, className: css_className('button', 'button--primary'), "aria-describedby": descriptionId }, actionProps, { children: buttonText }))] })] }));
|
|
21175
21286
|
};
|
|
21176
21287
|
/* harmony default export */ var card_component = (CardComponent);
|
|
21288
|
+
|
|
21177
21289
|
;// CONCATENATED MODULE: ./src/javascripts/ui/components/conversation/event/card-message.js
|
|
21178
21290
|
|
|
21179
21291
|
|
|
@@ -24398,6 +24510,34 @@ const SeamlyActivityMonitor = ({ children }) => {
|
|
|
24398
24510
|
|
|
24399
24511
|
|
|
24400
24512
|
|
|
24513
|
+
|
|
24514
|
+
var seamly_event_subscriber_awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
24515
|
+
function adopt(value) {
|
|
24516
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
24517
|
+
resolve(value);
|
|
24518
|
+
});
|
|
24519
|
+
}
|
|
24520
|
+
return new (P || (P = (promise_default())))(function (resolve, reject) {
|
|
24521
|
+
function fulfilled(value) {
|
|
24522
|
+
try {
|
|
24523
|
+
step(generator.next(value));
|
|
24524
|
+
} catch (e) {
|
|
24525
|
+
reject(e);
|
|
24526
|
+
}
|
|
24527
|
+
}
|
|
24528
|
+
function rejected(value) {
|
|
24529
|
+
try {
|
|
24530
|
+
step(generator["throw"](value));
|
|
24531
|
+
} catch (e) {
|
|
24532
|
+
reject(e);
|
|
24533
|
+
}
|
|
24534
|
+
}
|
|
24535
|
+
function step(result) {
|
|
24536
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
24537
|
+
}
|
|
24538
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24539
|
+
});
|
|
24540
|
+
};
|
|
24401
24541
|
var seamly_event_subscriber_rest = undefined && undefined.__rest || function (s, e) {
|
|
24402
24542
|
var t = {};
|
|
24403
24543
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && index_of_default()(e).call(e, p) < 0) t[p] = s[p];
|
|
@@ -24418,13 +24558,13 @@ var seamly_event_subscriber_rest = undefined && undefined.__rest || function (s,
|
|
|
24418
24558
|
|
|
24419
24559
|
|
|
24420
24560
|
|
|
24561
|
+
|
|
24421
24562
|
const EMITTABLE_MESSAGE_TYPES = ['text', 'choice_prompt', 'image', 'video'];
|
|
24422
24563
|
const SeamlyEventSubscriber = () => {
|
|
24423
24564
|
const api = useSeamlyApiContext();
|
|
24424
24565
|
const syncChannelRef = (0,hooks_module/* useRef */.sO)();
|
|
24425
24566
|
const messageChannelRef = (0,hooks_module/* useRef */.sO)();
|
|
24426
|
-
const dispatch =
|
|
24427
|
-
const events = useEvents();
|
|
24567
|
+
const dispatch = useAppDispatch();
|
|
24428
24568
|
const eventBus = (0,hooks_module/* useContext */.qp)(SeamlyEventBusContext);
|
|
24429
24569
|
const prevEmittedEventId = (0,hooks_module/* useRef */.sO)(null);
|
|
24430
24570
|
const {
|
|
@@ -24673,31 +24813,19 @@ const SeamlyEventSubscriber = () => {
|
|
|
24673
24813
|
if (syncChannelRef.current) {
|
|
24674
24814
|
(_a = api.conversation.channel) === null || _a === void 0 ? void 0 : _a.off('sync', syncChannelRef.current);
|
|
24675
24815
|
}
|
|
24676
|
-
syncChannelRef.current = api.conversation.channel.on('sync', payload => {
|
|
24677
|
-
|
|
24678
|
-
|
|
24679
|
-
const payloadLastEventId = (_a = payload === null || payload === void 0 ? void 0 : payload.lastEvent) === null || _a === void 0 ? void 0 : _a.id;
|
|
24680
|
-
if (lastEvent && payloadLastEventId === lastEvent.payload.id) {
|
|
24681
|
-
return payload;
|
|
24682
|
-
}
|
|
24683
|
-
return api.getConversation().then(history => {
|
|
24816
|
+
syncChannelRef.current = api.conversation.channel.on('sync', payload => seamly_event_subscriber_awaiter(void 0, void 0, void 0, function* () {
|
|
24817
|
+
try {
|
|
24818
|
+
const history = yield dispatch(getConversation(payload)).unwrap();
|
|
24684
24819
|
if (!history) return;
|
|
24685
24820
|
dispatch(setHistory(history));
|
|
24686
|
-
}
|
|
24687
|
-
|
|
24688
|
-
|
|
24689
|
-
|
|
24690
|
-
langKey: error === null || error === void 0 ? void 0 : error.langKey,
|
|
24691
|
-
action: error === null || error === void 0 ? void 0 : error.action,
|
|
24692
|
-
originalEvent: error === null || error === void 0 ? void 0 : error.originalEvent,
|
|
24693
|
-
originalError: error === null || error === void 0 ? void 0 : error.originalError
|
|
24694
|
-
}));
|
|
24695
|
-
});
|
|
24696
|
-
});
|
|
24821
|
+
} catch (_e) {
|
|
24822
|
+
// nothing to do, the error is handled in the thunk
|
|
24823
|
+
}
|
|
24824
|
+
}));
|
|
24697
24825
|
return true;
|
|
24698
24826
|
});
|
|
24699
24827
|
}
|
|
24700
|
-
}, [api, api.connectionInfo, api.conversation.channel,
|
|
24828
|
+
}, [api, api.connectionInfo, api.conversation.channel, dispatch]);
|
|
24701
24829
|
return null;
|
|
24702
24830
|
};
|
|
24703
24831
|
/* harmony default export */ var seamly_event_subscriber = (SeamlyEventSubscriber);
|
|
@@ -28380,10 +28508,14 @@ const WindowOpenButton = _ref => {
|
|
|
28380
28508
|
"aria-label": ariaLabel,
|
|
28381
28509
|
"aria-hidden": isOpen,
|
|
28382
28510
|
onClick: handleClick,
|
|
28383
|
-
children: [o(
|
|
28384
|
-
|
|
28385
|
-
|
|
28386
|
-
children:
|
|
28511
|
+
children: [o(in_out_transition, {
|
|
28512
|
+
isActive: !!count,
|
|
28513
|
+
transitionStartState: transitionStartStates.notRendered,
|
|
28514
|
+
children: o("span", {
|
|
28515
|
+
className: css_className('message-count'),
|
|
28516
|
+
"aria-hidden": "true",
|
|
28517
|
+
children: count
|
|
28518
|
+
})
|
|
28387
28519
|
}), o(ButtonIcon, {})]
|
|
28388
28520
|
})
|
|
28389
28521
|
});
|