@aws-amplify/ui-react-core 2.1.22 → 2.1.23
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/esm/index.mjs +1 -5
- package/dist/index.js +1 -162
- package/dist/types/index.d.ts +1 -1
- package/package.json +2 -2
- package/dist/esm/InAppMessaging/context/InAppMessagingContext/InAppMessagingContext.mjs +0 -5
- package/dist/esm/InAppMessaging/context/InAppMessagingProvider/InAppMessagingProvider.mjs +0 -25
- package/dist/esm/InAppMessaging/hooks/useInAppMessaging/useInAppMessaging.mjs +0 -18
- package/dist/esm/InAppMessaging/hooks/useMessage/useMessage.mjs +0 -78
- package/dist/esm/InAppMessaging/hooks/useMessage/utils.mjs +0 -43
- package/dist/esm/InAppMessaging/utils/handleMessageAction.mjs +0 -16
- package/dist/types/InAppMessaging/context/InAppMessagingContext/InAppMessagingContext.d.ts +0 -9
- package/dist/types/InAppMessaging/context/InAppMessagingContext/index.d.ts +0 -1
- package/dist/types/InAppMessaging/context/InAppMessagingProvider/InAppMessagingProvider.d.ts +0 -5
- package/dist/types/InAppMessaging/context/InAppMessagingProvider/index.d.ts +0 -1
- package/dist/types/InAppMessaging/context/index.d.ts +0 -2
- package/dist/types/InAppMessaging/hooks/index.d.ts +0 -2
- package/dist/types/InAppMessaging/hooks/useInAppMessaging/index.d.ts +0 -1
- package/dist/types/InAppMessaging/hooks/useInAppMessaging/useInAppMessaging.d.ts +0 -7
- package/dist/types/InAppMessaging/hooks/useMessage/index.d.ts +0 -1
- package/dist/types/InAppMessaging/hooks/useMessage/types.d.ts +0 -18
- package/dist/types/InAppMessaging/hooks/useMessage/useMessage.d.ts +0 -9
- package/dist/types/InAppMessaging/hooks/useMessage/utils.d.ts +0 -9
- package/dist/types/InAppMessaging/index.d.ts +0 -4
- package/dist/types/InAppMessaging/types.d.ts +0 -52
- package/dist/types/InAppMessaging/utils/handleMessageAction.d.ts +0 -9
- package/dist/types/InAppMessaging/utils/index.d.ts +0 -1
package/dist/esm/index.mjs
CHANGED
|
@@ -4,11 +4,7 @@ export { default as useAuthenticator } from './Authenticator/hooks/useAuthentica
|
|
|
4
4
|
export { default as useAuthenticatorRoute } from './Authenticator/hooks/useAuthenticatorRoute/useAuthenticatorRoute.mjs';
|
|
5
5
|
export { default as useAuthenticatorInitMachine } from './Authenticator/hooks/useAuthenticatorInitMachine/useAuthenticatorInitMachine.mjs';
|
|
6
6
|
export { isComponentRouteKey as isAuthenticatorComponentRouteKey, resolveAuthenticatorComponents } from './Authenticator/hooks/utils.mjs';
|
|
7
|
-
export { default as
|
|
8
|
-
export { default as useMessage } from './InAppMessaging/hooks/useMessage/useMessage.mjs';
|
|
9
|
-
import './InAppMessaging/context/InAppMessagingContext/InAppMessagingContext.mjs';
|
|
10
|
-
export { default as InAppMessagingProvider } from './InAppMessaging/context/InAppMessagingProvider/InAppMessagingProvider.mjs';
|
|
11
|
-
export { default as handleMessageAction } from './InAppMessaging/utils/handleMessageAction.mjs';
|
|
7
|
+
export { default as RenderNothing } from './components/RenderNothing/RenderNothing.mjs';
|
|
12
8
|
export { default as usePreviousValue } from './hooks/usePreviousValue.mjs';
|
|
13
9
|
export { default as useHasValueUpdated } from './hooks/useHasValueUpdated.mjs';
|
|
14
10
|
export { templateJoin } from './utils/index.mjs';
|
package/dist/index.js
CHANGED
|
@@ -6,8 +6,6 @@ var React = require('react');
|
|
|
6
6
|
var react = require('@xstate/react');
|
|
7
7
|
var awsAmplify = require('aws-amplify');
|
|
8
8
|
var ui = require('@aws-amplify/ui');
|
|
9
|
-
var notifications = require('@aws-amplify/notifications');
|
|
10
|
-
var core = require('@aws-amplify/core');
|
|
11
9
|
|
|
12
10
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
11
|
|
|
@@ -460,162 +458,6 @@ function useAuthenticatorInitMachine(data) {
|
|
|
460
458
|
}, [initializeMachine, route, data]);
|
|
461
459
|
}
|
|
462
460
|
|
|
463
|
-
const InAppMessagingContext = React.createContext(null);
|
|
464
|
-
|
|
465
|
-
const { InAppMessaging: InAppMessaging$1 } = notifications.Notifications;
|
|
466
|
-
function InAppMessagingProvider({ children, }) {
|
|
467
|
-
const [message, setMessage] = React.useState(null);
|
|
468
|
-
React.useEffect(() => {
|
|
469
|
-
const listener = InAppMessaging$1.onMessageReceived((message) => {
|
|
470
|
-
setMessage(message);
|
|
471
|
-
});
|
|
472
|
-
return listener.remove;
|
|
473
|
-
}, []);
|
|
474
|
-
const clearMessage = React.useCallback(() => {
|
|
475
|
-
setMessage(null);
|
|
476
|
-
}, []);
|
|
477
|
-
const value = React.useMemo(() => ({
|
|
478
|
-
clearMessage,
|
|
479
|
-
displayMessage: setMessage,
|
|
480
|
-
message,
|
|
481
|
-
}), [clearMessage, message]);
|
|
482
|
-
return (React__default["default"].createElement(InAppMessagingContext.Provider, { value: value }, children));
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
/**
|
|
486
|
-
* Utility hook used to access the InAppMessagingContext values
|
|
487
|
-
*
|
|
488
|
-
* @returns {InAppMessagingContextType} InAppMessaging context values
|
|
489
|
-
*/
|
|
490
|
-
function useInAppMessaging() {
|
|
491
|
-
const inAppMessagingContext = React.useContext(InAppMessagingContext);
|
|
492
|
-
if (!inAppMessagingContext) {
|
|
493
|
-
throw new Error('InAppMessagingContext is empty, did you forget the InAppMessagingProvider?');
|
|
494
|
-
}
|
|
495
|
-
return inAppMessagingContext;
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
const logger$2 = new core.ConsoleLogger('Notifications.InAppMessaging');
|
|
499
|
-
const positions = {
|
|
500
|
-
BOTTOM_BANNER: 'bottom',
|
|
501
|
-
MIDDLE_BANNER: 'middle',
|
|
502
|
-
TOP_BANNER: 'top',
|
|
503
|
-
};
|
|
504
|
-
const getPositionProp = (layout) => positions[layout];
|
|
505
|
-
const getActionHandler = (actionParams, onMessageAction, onActionCallback) => ({
|
|
506
|
-
onAction() {
|
|
507
|
-
try {
|
|
508
|
-
onMessageAction(actionParams);
|
|
509
|
-
}
|
|
510
|
-
catch (e) {
|
|
511
|
-
logger$2.error(`Message action failure: ${e}`);
|
|
512
|
-
}
|
|
513
|
-
finally {
|
|
514
|
-
onActionCallback();
|
|
515
|
-
}
|
|
516
|
-
},
|
|
517
|
-
});
|
|
518
|
-
const getButtonProps = (_a, onMessageAction, onActionCallback) => {
|
|
519
|
-
var { action, url } = _a, baseButtonProps = __rest(_a, ["action", "url"]);
|
|
520
|
-
return (Object.assign(Object.assign({}, baseButtonProps), getActionHandler({ action, url }, onMessageAction, onActionCallback)));
|
|
521
|
-
};
|
|
522
|
-
const getContentProps = (content, onMessageAction, onActionCallback) => {
|
|
523
|
-
const props = {};
|
|
524
|
-
if (!content) {
|
|
525
|
-
return props;
|
|
526
|
-
}
|
|
527
|
-
const { primaryButton, secondaryButton } = content, restContent = __rest(content, ["primaryButton", "secondaryButton"]);
|
|
528
|
-
if (primaryButton) {
|
|
529
|
-
props.primaryButton = getButtonProps(primaryButton, onMessageAction, onActionCallback);
|
|
530
|
-
}
|
|
531
|
-
if (secondaryButton) {
|
|
532
|
-
props.secondaryButton = getButtonProps(secondaryButton, onMessageAction, onActionCallback);
|
|
533
|
-
}
|
|
534
|
-
return Object.assign(Object.assign({}, props), restContent);
|
|
535
|
-
};
|
|
536
|
-
|
|
537
|
-
const EMPTY_PROPS = Object.freeze({});
|
|
538
|
-
const logger$1 = new core.ConsoleLogger('Notifications.InAppMessaging');
|
|
539
|
-
const { InAppMessaging } = notifications.Notifications;
|
|
540
|
-
/**
|
|
541
|
-
* Utility hook for parsing a message and retrieving its corresponding UI component and props
|
|
542
|
-
*
|
|
543
|
-
* @param {UseMessageParams} props - platform specific UI components, action handler, and styles
|
|
544
|
-
* @returns {UseMessage} message UI component and props
|
|
545
|
-
*/
|
|
546
|
-
function useMessage({ components, onMessageAction, }) {
|
|
547
|
-
const { clearMessage, message } = useInAppMessaging();
|
|
548
|
-
const { BannerMessage, CarouselMessage, FullScreenMessage, ModalMessage } = components;
|
|
549
|
-
if (ui.isNil(message)) {
|
|
550
|
-
return {
|
|
551
|
-
Component: RenderNothing,
|
|
552
|
-
props: EMPTY_PROPS,
|
|
553
|
-
};
|
|
554
|
-
}
|
|
555
|
-
const { content, layout } = message;
|
|
556
|
-
const onActionCallback = () => {
|
|
557
|
-
InAppMessaging.notifyMessageInteraction(message, notifications.InAppMessageInteractionEvent.MESSAGE_ACTION_TAKEN);
|
|
558
|
-
clearMessage();
|
|
559
|
-
};
|
|
560
|
-
const onClose = () => {
|
|
561
|
-
InAppMessaging.notifyMessageInteraction(message, notifications.InAppMessageInteractionEvent.MESSAGE_DISMISSED);
|
|
562
|
-
clearMessage();
|
|
563
|
-
};
|
|
564
|
-
const onDisplay = () => {
|
|
565
|
-
InAppMessaging.notifyMessageInteraction(message, notifications.InAppMessageInteractionEvent.MESSAGE_DISPLAYED);
|
|
566
|
-
};
|
|
567
|
-
switch (layout) {
|
|
568
|
-
case 'BOTTOM_BANNER':
|
|
569
|
-
case 'MIDDLE_BANNER':
|
|
570
|
-
case 'TOP_BANNER': {
|
|
571
|
-
const props = Object.assign(Object.assign({}, getContentProps(content === null || content === void 0 ? void 0 : content[0], onMessageAction, onActionCallback)), { layout,
|
|
572
|
-
onClose,
|
|
573
|
-
onDisplay, position: getPositionProp(layout) });
|
|
574
|
-
return { Component: BannerMessage, props };
|
|
575
|
-
}
|
|
576
|
-
case 'CAROUSEL': {
|
|
577
|
-
const props = {
|
|
578
|
-
data: content === null || content === void 0 ? void 0 : content.map((item) => getContentProps(item, onMessageAction, onActionCallback)),
|
|
579
|
-
layout,
|
|
580
|
-
onClose,
|
|
581
|
-
onDisplay,
|
|
582
|
-
};
|
|
583
|
-
return { Component: CarouselMessage, props };
|
|
584
|
-
}
|
|
585
|
-
case 'FULL_SCREEN': {
|
|
586
|
-
const props = Object.assign(Object.assign({}, getContentProps(content === null || content === void 0 ? void 0 : content[0], onMessageAction, onActionCallback)), { layout,
|
|
587
|
-
onClose,
|
|
588
|
-
onDisplay });
|
|
589
|
-
return { Component: FullScreenMessage, props };
|
|
590
|
-
}
|
|
591
|
-
case 'MODAL': {
|
|
592
|
-
const props = Object.assign(Object.assign({}, getContentProps(content === null || content === void 0 ? void 0 : content[0], onMessageAction, onActionCallback)), { layout,
|
|
593
|
-
onClose,
|
|
594
|
-
onDisplay });
|
|
595
|
-
return { Component: ModalMessage, props };
|
|
596
|
-
}
|
|
597
|
-
default: {
|
|
598
|
-
logger$1.info(`Received unknown InAppMessage layout: ${layout}`);
|
|
599
|
-
return {
|
|
600
|
-
Component: RenderNothing,
|
|
601
|
-
props: EMPTY_PROPS,
|
|
602
|
-
};
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
const logger = new core.ConsoleLogger('Notifications.InAppMessaging');
|
|
608
|
-
const handleMessageAction = ({ action, handleMessageLinkAction, url, }) => {
|
|
609
|
-
logger.info(`Handle action: ${action}`);
|
|
610
|
-
if (action === 'LINK' || action === 'DEEP_LINK') {
|
|
611
|
-
if (!ui.isString(url)) {
|
|
612
|
-
logger.warn(`url must be of type string. Received: ${url}`);
|
|
613
|
-
return;
|
|
614
|
-
}
|
|
615
|
-
handleMessageLinkAction(url);
|
|
616
|
-
}
|
|
617
|
-
};
|
|
618
|
-
|
|
619
461
|
function usePreviousValue(value) {
|
|
620
462
|
const previous = React.useRef();
|
|
621
463
|
// update ref post render
|
|
@@ -640,8 +482,7 @@ function templateJoin(values, template) {
|
|
|
640
482
|
}
|
|
641
483
|
|
|
642
484
|
exports.AuthenticatorProvider = AuthenticatorProvider;
|
|
643
|
-
exports.
|
|
644
|
-
exports.handleMessageAction = handleMessageAction;
|
|
485
|
+
exports.RenderNothing = RenderNothing;
|
|
645
486
|
exports.isAuthenticatorComponentRouteKey = isComponentRouteKey;
|
|
646
487
|
exports.resolveAuthenticatorComponents = resolveAuthenticatorComponents;
|
|
647
488
|
exports.templateJoin = templateJoin;
|
|
@@ -649,6 +490,4 @@ exports.useAuthenticator = useAuthenticator;
|
|
|
649
490
|
exports.useAuthenticatorInitMachine = useAuthenticatorInitMachine;
|
|
650
491
|
exports.useAuthenticatorRoute = useAuthenticatorRoute;
|
|
651
492
|
exports.useHasValueUpdated = useHasValueUpdated;
|
|
652
|
-
exports.useInAppMessaging = useInAppMessaging;
|
|
653
|
-
exports.useMessage = useMessage;
|
|
654
493
|
exports.usePreviousValue = usePreviousValue;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { AuthenticatorComponentDefaults, AuthenticatorComponentDefaultProps, AuthenticatorComponentOverrides, AuthenticatorFooterComponent, AuthenticatorFormFieldsComponent, AuthenticatorHeaderComponent, AuthenticatorLegacyField, AuthenticatorMachineContext, AuthenticatorProvider, AuthenticatorRouteComponentKey, AuthenticatorRouteComponentName, isAuthenticatorComponentRouteKey, resolveAuthenticatorComponents, useAuthenticator, useAuthenticatorRoute, UseAuthenticator, useAuthenticatorInitMachine, UseAuthenticatorRoute, } from './Authenticator';
|
|
2
|
-
export {
|
|
2
|
+
export { RenderNothing } from './components';
|
|
3
3
|
export { useHasValueUpdated, usePreviousValue } from './hooks';
|
|
4
4
|
export { templateJoin } from './utils';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-amplify/ui-react-core",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.23",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/esm/index.mjs",
|
|
6
6
|
"react-native": "dist/index.js",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"typecheck": "tsc --noEmit"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@aws-amplify/ui": "5.6.
|
|
34
|
+
"@aws-amplify/ui": "5.6.4",
|
|
35
35
|
"@xstate/react": "3.0.1",
|
|
36
36
|
"lodash": "4.17.21",
|
|
37
37
|
"xstate": "^4.33.6"
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect, useCallback, useMemo } from 'react';
|
|
2
|
-
import { Notifications } from '@aws-amplify/notifications';
|
|
3
|
-
import InAppMessagingContext from '../InAppMessagingContext/InAppMessagingContext.mjs';
|
|
4
|
-
|
|
5
|
-
const { InAppMessaging } = Notifications;
|
|
6
|
-
function InAppMessagingProvider({ children, }) {
|
|
7
|
-
const [message, setMessage] = useState(null);
|
|
8
|
-
useEffect(() => {
|
|
9
|
-
const listener = InAppMessaging.onMessageReceived((message) => {
|
|
10
|
-
setMessage(message);
|
|
11
|
-
});
|
|
12
|
-
return listener.remove;
|
|
13
|
-
}, []);
|
|
14
|
-
const clearMessage = useCallback(() => {
|
|
15
|
-
setMessage(null);
|
|
16
|
-
}, []);
|
|
17
|
-
const value = useMemo(() => ({
|
|
18
|
-
clearMessage,
|
|
19
|
-
displayMessage: setMessage,
|
|
20
|
-
message,
|
|
21
|
-
}), [clearMessage, message]);
|
|
22
|
-
return (React.createElement(InAppMessagingContext.Provider, { value: value }, children));
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export { InAppMessagingProvider as default };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { useContext } from 'react';
|
|
2
|
-
import InAppMessagingContext from '../../context/InAppMessagingContext/InAppMessagingContext.mjs';
|
|
3
|
-
import '@aws-amplify/notifications';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Utility hook used to access the InAppMessagingContext values
|
|
7
|
-
*
|
|
8
|
-
* @returns {InAppMessagingContextType} InAppMessaging context values
|
|
9
|
-
*/
|
|
10
|
-
function useInAppMessaging() {
|
|
11
|
-
const inAppMessagingContext = useContext(InAppMessagingContext);
|
|
12
|
-
if (!inAppMessagingContext) {
|
|
13
|
-
throw new Error('InAppMessagingContext is empty, did you forget the InAppMessagingProvider?');
|
|
14
|
-
}
|
|
15
|
-
return inAppMessagingContext;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export { useInAppMessaging as default };
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { ConsoleLogger } from '@aws-amplify/core';
|
|
2
|
-
import { InAppMessageInteractionEvent, Notifications } from '@aws-amplify/notifications';
|
|
3
|
-
import { isNil } from '@aws-amplify/ui';
|
|
4
|
-
import RenderNothing from '../../../components/RenderNothing/RenderNothing.mjs';
|
|
5
|
-
import useInAppMessaging from '../useInAppMessaging/useInAppMessaging.mjs';
|
|
6
|
-
import { getContentProps, getPositionProp } from './utils.mjs';
|
|
7
|
-
|
|
8
|
-
const EMPTY_PROPS = Object.freeze({});
|
|
9
|
-
const logger = new ConsoleLogger('Notifications.InAppMessaging');
|
|
10
|
-
const { InAppMessaging } = Notifications;
|
|
11
|
-
/**
|
|
12
|
-
* Utility hook for parsing a message and retrieving its corresponding UI component and props
|
|
13
|
-
*
|
|
14
|
-
* @param {UseMessageParams} props - platform specific UI components, action handler, and styles
|
|
15
|
-
* @returns {UseMessage} message UI component and props
|
|
16
|
-
*/
|
|
17
|
-
function useMessage({ components, onMessageAction, }) {
|
|
18
|
-
const { clearMessage, message } = useInAppMessaging();
|
|
19
|
-
const { BannerMessage, CarouselMessage, FullScreenMessage, ModalMessage } = components;
|
|
20
|
-
if (isNil(message)) {
|
|
21
|
-
return {
|
|
22
|
-
Component: RenderNothing,
|
|
23
|
-
props: EMPTY_PROPS,
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
const { content, layout } = message;
|
|
27
|
-
const onActionCallback = () => {
|
|
28
|
-
InAppMessaging.notifyMessageInteraction(message, InAppMessageInteractionEvent.MESSAGE_ACTION_TAKEN);
|
|
29
|
-
clearMessage();
|
|
30
|
-
};
|
|
31
|
-
const onClose = () => {
|
|
32
|
-
InAppMessaging.notifyMessageInteraction(message, InAppMessageInteractionEvent.MESSAGE_DISMISSED);
|
|
33
|
-
clearMessage();
|
|
34
|
-
};
|
|
35
|
-
const onDisplay = () => {
|
|
36
|
-
InAppMessaging.notifyMessageInteraction(message, InAppMessageInteractionEvent.MESSAGE_DISPLAYED);
|
|
37
|
-
};
|
|
38
|
-
switch (layout) {
|
|
39
|
-
case 'BOTTOM_BANNER':
|
|
40
|
-
case 'MIDDLE_BANNER':
|
|
41
|
-
case 'TOP_BANNER': {
|
|
42
|
-
const props = Object.assign(Object.assign({}, getContentProps(content === null || content === void 0 ? void 0 : content[0], onMessageAction, onActionCallback)), { layout,
|
|
43
|
-
onClose,
|
|
44
|
-
onDisplay, position: getPositionProp(layout) });
|
|
45
|
-
return { Component: BannerMessage, props };
|
|
46
|
-
}
|
|
47
|
-
case 'CAROUSEL': {
|
|
48
|
-
const props = {
|
|
49
|
-
data: content === null || content === void 0 ? void 0 : content.map((item) => getContentProps(item, onMessageAction, onActionCallback)),
|
|
50
|
-
layout,
|
|
51
|
-
onClose,
|
|
52
|
-
onDisplay,
|
|
53
|
-
};
|
|
54
|
-
return { Component: CarouselMessage, props };
|
|
55
|
-
}
|
|
56
|
-
case 'FULL_SCREEN': {
|
|
57
|
-
const props = Object.assign(Object.assign({}, getContentProps(content === null || content === void 0 ? void 0 : content[0], onMessageAction, onActionCallback)), { layout,
|
|
58
|
-
onClose,
|
|
59
|
-
onDisplay });
|
|
60
|
-
return { Component: FullScreenMessage, props };
|
|
61
|
-
}
|
|
62
|
-
case 'MODAL': {
|
|
63
|
-
const props = Object.assign(Object.assign({}, getContentProps(content === null || content === void 0 ? void 0 : content[0], onMessageAction, onActionCallback)), { layout,
|
|
64
|
-
onClose,
|
|
65
|
-
onDisplay });
|
|
66
|
-
return { Component: ModalMessage, props };
|
|
67
|
-
}
|
|
68
|
-
default: {
|
|
69
|
-
logger.info(`Received unknown InAppMessage layout: ${layout}`);
|
|
70
|
-
return {
|
|
71
|
-
Component: RenderNothing,
|
|
72
|
-
props: EMPTY_PROPS,
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export { EMPTY_PROPS, useMessage as default };
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { __rest } from '../../../node_modules/tslib/tslib.es6.mjs';
|
|
2
|
-
import { ConsoleLogger } from '@aws-amplify/core';
|
|
3
|
-
|
|
4
|
-
const logger = new ConsoleLogger('Notifications.InAppMessaging');
|
|
5
|
-
const positions = {
|
|
6
|
-
BOTTOM_BANNER: 'bottom',
|
|
7
|
-
MIDDLE_BANNER: 'middle',
|
|
8
|
-
TOP_BANNER: 'top',
|
|
9
|
-
};
|
|
10
|
-
const getPositionProp = (layout) => positions[layout];
|
|
11
|
-
const getActionHandler = (actionParams, onMessageAction, onActionCallback) => ({
|
|
12
|
-
onAction() {
|
|
13
|
-
try {
|
|
14
|
-
onMessageAction(actionParams);
|
|
15
|
-
}
|
|
16
|
-
catch (e) {
|
|
17
|
-
logger.error(`Message action failure: ${e}`);
|
|
18
|
-
}
|
|
19
|
-
finally {
|
|
20
|
-
onActionCallback();
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
const getButtonProps = (_a, onMessageAction, onActionCallback) => {
|
|
25
|
-
var { action, url } = _a, baseButtonProps = __rest(_a, ["action", "url"]);
|
|
26
|
-
return (Object.assign(Object.assign({}, baseButtonProps), getActionHandler({ action, url }, onMessageAction, onActionCallback)));
|
|
27
|
-
};
|
|
28
|
-
const getContentProps = (content, onMessageAction, onActionCallback) => {
|
|
29
|
-
const props = {};
|
|
30
|
-
if (!content) {
|
|
31
|
-
return props;
|
|
32
|
-
}
|
|
33
|
-
const { primaryButton, secondaryButton } = content, restContent = __rest(content, ["primaryButton", "secondaryButton"]);
|
|
34
|
-
if (primaryButton) {
|
|
35
|
-
props.primaryButton = getButtonProps(primaryButton, onMessageAction, onActionCallback);
|
|
36
|
-
}
|
|
37
|
-
if (secondaryButton) {
|
|
38
|
-
props.secondaryButton = getButtonProps(secondaryButton, onMessageAction, onActionCallback);
|
|
39
|
-
}
|
|
40
|
-
return Object.assign(Object.assign({}, props), restContent);
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export { getActionHandler, getContentProps, getPositionProp };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ConsoleLogger } from '@aws-amplify/core';
|
|
2
|
-
import { isString } from '@aws-amplify/ui';
|
|
3
|
-
|
|
4
|
-
const logger = new ConsoleLogger('Notifications.InAppMessaging');
|
|
5
|
-
const handleMessageAction = ({ action, handleMessageLinkAction, url, }) => {
|
|
6
|
-
logger.info(`Handle action: ${action}`);
|
|
7
|
-
if (action === 'LINK' || action === 'DEEP_LINK') {
|
|
8
|
-
if (!isString(url)) {
|
|
9
|
-
logger.warn(`url must be of type string. Received: ${url}`);
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
handleMessageLinkAction(url);
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export { handleMessageAction as default };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { Message } from '../../types';
|
|
3
|
-
export interface InAppMessagingContextType {
|
|
4
|
-
clearMessage: () => void;
|
|
5
|
-
displayMessage: (message: Message) => void;
|
|
6
|
-
message: Message | null;
|
|
7
|
-
}
|
|
8
|
-
declare const InAppMessagingContext: import("react").Context<InAppMessagingContextType | null>;
|
|
9
|
-
export default InAppMessagingContext;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as InAppMessagingContext, InAppMessagingContextType, } from './InAppMessagingContext';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as InAppMessagingProvider } from './InAppMessagingProvider';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as useInAppMessaging } from './useInAppMessaging';
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { InAppMessagingContextType } from '../../context';
|
|
2
|
-
/**
|
|
3
|
-
* Utility hook used to access the InAppMessagingContext values
|
|
4
|
-
*
|
|
5
|
-
* @returns {InAppMessagingContextType} InAppMessaging context values
|
|
6
|
-
*/
|
|
7
|
-
export default function useInAppMessaging(): InAppMessagingContextType;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as useMessage } from './useMessage';
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { BannerMessageCommonProps, BannerMessageComponent, CarouselMessageCommonProps, CarouselMessageComponent, FullScreenMessageCommonProps, FullScreenMessageComponent, ModalMessageCommonProps, ModalMessageComponent, OnMessageAction } from '../../types';
|
|
2
|
-
interface Components<PlatformStyleProps> {
|
|
3
|
-
BannerMessage: BannerMessageComponent<PlatformStyleProps>;
|
|
4
|
-
CarouselMessage: CarouselMessageComponent<PlatformStyleProps>;
|
|
5
|
-
FullScreenMessage: FullScreenMessageComponent<PlatformStyleProps>;
|
|
6
|
-
ModalMessage: ModalMessageComponent<PlatformStyleProps>;
|
|
7
|
-
}
|
|
8
|
-
export interface UseMessageParams<PlatformStyleProps> {
|
|
9
|
-
components: Components<PlatformStyleProps>;
|
|
10
|
-
onMessageAction: OnMessageAction;
|
|
11
|
-
}
|
|
12
|
-
type MessageComponent<PlatformStyleProps> = BannerMessageComponent<PlatformStyleProps> | CarouselMessageComponent<PlatformStyleProps> | FullScreenMessageComponent<PlatformStyleProps> | ModalMessageComponent<PlatformStyleProps>;
|
|
13
|
-
type MessageProps<PlatformStyleProps> = BannerMessageCommonProps<PlatformStyleProps> | CarouselMessageCommonProps<PlatformStyleProps> | FullScreenMessageCommonProps<PlatformStyleProps> | ModalMessageCommonProps<PlatformStyleProps>;
|
|
14
|
-
export interface UseMessage<PlatformStyleProps> {
|
|
15
|
-
Component: MessageComponent<PlatformStyleProps>;
|
|
16
|
-
props: MessageProps<PlatformStyleProps>;
|
|
17
|
-
}
|
|
18
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { UseMessage, UseMessageParams } from './types';
|
|
2
|
-
export declare const EMPTY_PROPS: Readonly<{}>;
|
|
3
|
-
/**
|
|
4
|
-
* Utility hook for parsing a message and retrieving its corresponding UI component and props
|
|
5
|
-
*
|
|
6
|
-
* @param {UseMessageParams} props - platform specific UI components, action handler, and styles
|
|
7
|
-
* @returns {UseMessage} message UI component and props
|
|
8
|
-
*/
|
|
9
|
-
export default function useMessage<PlatformStyleProps>({ components, onMessageAction, }: UseMessageParams<PlatformStyleProps>): UseMessage<PlatformStyleProps>;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { BannerMessageLayouts, MessageAction, MessageComponentPosition, MessageContent, MessageContentProps, OnMessageAction } from '../../types';
|
|
2
|
-
export declare const getPositionProp: (layout: BannerMessageLayouts) => MessageComponentPosition;
|
|
3
|
-
export declare const getActionHandler: (actionParams: {
|
|
4
|
-
action: MessageAction;
|
|
5
|
-
url?: string;
|
|
6
|
-
}, onMessageAction: OnMessageAction, onActionCallback: () => void) => {
|
|
7
|
-
onAction: () => void;
|
|
8
|
-
};
|
|
9
|
-
export declare const getContentProps: (content: MessageContent, onMessageAction: OnMessageAction, onActionCallback: () => void) => MessageContentProps;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { InAppMessage, InAppMessageAction, InAppMessageButton, InAppMessageContent, InAppMessageImage, InAppMessageLayout, InAppMessageStyle, InAppMessageTextAlign } from '@aws-amplify/notifications';
|
|
3
|
-
export type Message = InAppMessage;
|
|
4
|
-
export type MessageAction = InAppMessageAction;
|
|
5
|
-
export type MessageButton = InAppMessageButton;
|
|
6
|
-
export type MessageContent = InAppMessageContent;
|
|
7
|
-
export type MessageImage = InAppMessageImage;
|
|
8
|
-
export type MessageLayout = InAppMessageLayout;
|
|
9
|
-
export type MessageStyle = InAppMessageStyle;
|
|
10
|
-
export type MessageTextAlign = InAppMessageTextAlign;
|
|
11
|
-
export type OnMessageAction = (params: {
|
|
12
|
-
action: MessageAction;
|
|
13
|
-
url?: string | undefined;
|
|
14
|
-
}) => void;
|
|
15
|
-
export interface MessageButtonProps extends Omit<MessageButton, 'action' | 'url'> {
|
|
16
|
-
onAction: () => void;
|
|
17
|
-
}
|
|
18
|
-
export interface MessageContentProps extends Omit<MessageContent, 'primaryButton' | 'secondaryButton'> {
|
|
19
|
-
primaryButton?: MessageButtonProps;
|
|
20
|
-
secondaryButton?: MessageButtonProps;
|
|
21
|
-
}
|
|
22
|
-
export interface MessageComponentBaseProps<Style = unknown> extends MessageCommonProps<Style>, MessageContentProps {
|
|
23
|
-
}
|
|
24
|
-
export interface MessageCommonProps<PlatformStyleProps> {
|
|
25
|
-
layout: MessageLayout;
|
|
26
|
-
onClose?: () => void;
|
|
27
|
-
onDisplay?: () => void;
|
|
28
|
-
style?: PlatformStyleProps;
|
|
29
|
-
}
|
|
30
|
-
export type BannerMessageLayouts = 'BOTTOM_BANNER' | 'MIDDLE_BANNER' | 'TOP_BANNER';
|
|
31
|
-
export type MessageComponentPosition = 'bottom' | 'middle' | 'top';
|
|
32
|
-
export interface BannerMessageCommonProps<PlatformStyleProps> extends MessageCommonProps<PlatformStyleProps>, MessageContentProps {
|
|
33
|
-
position?: MessageComponentPosition;
|
|
34
|
-
}
|
|
35
|
-
export interface CarouselMessageCommonProps<PlatformStyleProps> extends MessageCommonProps<PlatformStyleProps> {
|
|
36
|
-
data?: MessageContentProps[];
|
|
37
|
-
}
|
|
38
|
-
export interface FullScreenMessageCommonProps<PlatformStyleProps> extends MessageCommonProps<PlatformStyleProps>, MessageContentProps {
|
|
39
|
-
}
|
|
40
|
-
export interface ModalMessageCommonProps<PlatformStyleProps> extends MessageCommonProps<PlatformStyleProps>, MessageContentProps {
|
|
41
|
-
}
|
|
42
|
-
export interface MessagePayloadStyle {
|
|
43
|
-
body?: MessageStyle;
|
|
44
|
-
container?: MessageStyle;
|
|
45
|
-
header?: MessageStyle;
|
|
46
|
-
primaryButton?: MessageStyle;
|
|
47
|
-
secondaryButton?: MessageStyle;
|
|
48
|
-
}
|
|
49
|
-
export type BannerMessageComponent<PlatformStyleProps> = React.ComponentType<BannerMessageCommonProps<PlatformStyleProps>>;
|
|
50
|
-
export type CarouselMessageComponent<PlatformStyleProps> = React.ComponentType<CarouselMessageCommonProps<PlatformStyleProps>>;
|
|
51
|
-
export type FullScreenMessageComponent<PlatformStyleProps> = React.ComponentType<FullScreenMessageCommonProps<PlatformStyleProps>>;
|
|
52
|
-
export type ModalMessageComponent<PlatformStyleProps> = React.ComponentType<ModalMessageCommonProps<PlatformStyleProps>>;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { MessageAction } from '../types';
|
|
2
|
-
export type HandleMessageLinkAction = (url: string) => void | Promise<void>;
|
|
3
|
-
interface HandleMessageActionParams {
|
|
4
|
-
action: MessageAction;
|
|
5
|
-
handleMessageLinkAction: HandleMessageLinkAction;
|
|
6
|
-
url: string | undefined;
|
|
7
|
-
}
|
|
8
|
-
declare const handleMessageAction: ({ action, handleMessageLinkAction, url, }: HandleMessageActionParams) => void;
|
|
9
|
-
export default handleMessageAction;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as handleMessageAction, HandleMessageLinkAction, } from './handleMessageAction';
|