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,MAAMkC,EAAiBlC,EAAUmC,eACjC,OAAOlF,IAAAA,cAACiF,EAAcE,OAAAC,OAAA,GAAKrC,EAAU7C,MAAK,CAAEmF,IAAKtC,EAAU7C,MAAM8B,aAAaR,UAStFP,yBACJ,MAAMqE,EAAgBlF,KAAKO,qBAE3B,QAAsB+B,IAAlB4C,EACA,OAGJ,IAAIC,EAAc,EAKlB,OAJI/C,EAAAA,GAASC,YACT8C,EAAc7F,OAAO6F,aAGlBC,KAAKC,IAAID,KAAKE,IAAIJ,EAAc5E,aAAc4E,EAAc5E,aAAe6E,GAAcD,EAAc7E,cAM1GM,mBACJ,MAAM4E,EAASvF,KAAKa,yBACpBb,KAAK2D,SAAS,CAAErC,IAAKiE,KArND5F,EAAAoE,WAAqB,yBAyNjD,2GC9QO,MAAMyB,EAA+D1F,GACjEF,EAAAA,cAAC6F,EAAAA,OAAMV,OAAAC,OAAA,GAAKlF,EAAMmE,WAAYnE,EAAMsE,mBAG/C,WCdAsB,EAAOC,QAAU/F,cCAjB8F,EAAOC,QAAUC","sources":["webpack://Msdyn365.Commerce.Online/./lib/notifications-list/module-registration.js?a20b","webpack://Msdyn365.Commerce.Online/./src/modules/notifications-list/notifications-list.tsx?8377","webpack://Msdyn365.Commerce.Online/./src/modules/notifications-list/notifications-list.view.tsx?d466","webpack://Msdyn365.Commerce.Online/external var \"React\"?0d3b","webpack://Msdyn365.Commerce.Online/external var \"ReactDOM\"?853b"],"sourcesContent":["const binding = { modules: {}, dataActions: {} };\n\n (binding.modules['notifications-list'] = {\n c: () => require('@msdyn365-commerce-modules/notifications-lists/dist/lib/modules/notifications-list/notifications-list'),\n $type: 'contentModule',\n da: [],\n \n iNM: true,\n ns: '@msdyn365-commerce-modules',\n n: 'notifications-list',\n p: 'notifications-lists',\n \n pdp: '',\n \n \n md: 'node_modules/@msdyn365-commerce-modules/notifications-lists/dist/lib/modules/notifications-list'\n });\n \n\n \n window.__bindings__ = window.__bindings__ || {};\n window.__bindings__.modules = {\n ...window.__bindings__.modules || {},\n ...binding.modules\n };\n \n window.__bindings__.dataActions = {\n ...window.__bindings__.dataActions || {},\n ...binding.dataActions\n };\n export const viewDictionary = {};\n viewDictionary['@msdyn365-commerce-modules|notifications-lists|modules|notifications-list|notifications-list'] = {\n c: () => require('@msdyn365-commerce-modules/notifications-lists/dist/lib/modules/notifications-list/notifications-list.view.js'),\n cn: '@msdyn365-commerce-modules-notifications-lists-notifications-list'\n };\nwindow.__bindings__ = window.__bindings__ || {};\nwindow.__bindings__.viewDictionary = {\n ...window.__bindings__.viewDictionary || {},\n ...viewDictionary\n };","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport MsDyn365 from '@msdyn365-commerce/core';\nimport {\n INotificationComponentsList,\n INotificationComponentsListState,\n INotificationComponentType,\n NotificationComponentsListsManager,\n NotificationEvents,\n NotificationFeedType\n} from '@msdyn365-commerce-modules/notifications-core';\nimport { ArrayExtensions, ObjectExtensions, Random } from '@msdyn365-commerce-modules/retail-actions';\nimport { IModuleProps } from '@msdyn365-commerce-modules/utilities';\nimport classnames from 'classnames';\nimport React from 'react';\n\nimport { INotificationsListProps } from './notifications-list.props.autogenerated';\n\n/**\n * View for the notifications list which specifies the container and notifications items.\n */\nexport interface INotificationsListViewProps extends INotificationsListProps<{}> {\n container: IModuleProps;\n notificationsList: React.ReactNode;\n}\n\n/**\n * Configuration to make the list stickable to the page without overlapping any content on top.\n */\nexport interface INotificationComponentStickyConfiguration {\n /**\n * Minimum offset for top (default for the page).\n */\n minTopOffset: number;\n\n /**\n * Maximum offset for top (to limit the top offset while scrolling).\n */\n maxTopOffset: number;\n}\n\n/**\n * Stickable notification list state which defines the top position of the list at the moment.\n */\nexport interface IStickableNotificationComponentsListState extends INotificationComponentsListState {\n /**\n * The top position of the list on the page.\n */\n top?: number;\n}\n\n/**\n * A notification list which is operated by notification manager.\n * It is responsible for rendering the received notifications.\n */\nexport class NotificationComponentsList extends React.Component, IStickableNotificationComponentsListState>\n implements INotificationComponentsList {\n /**\n * The class name to use.\n */\n private static readonly _className: string = 'msc-notifications-list';\n\n /**\n * The feed which the list is responsible for displaying.\n */\n public readonly feed: NotificationFeedType;\n\n /**\n * Configuration which specifies if and how the list should be stickable.\n * If undefined, the configuration will not be used at all. And list will not be stickable.\n */\n private readonly _stickyConfiguration?: INotificationComponentStickyConfiguration;\n\n /**\n * The list of notification which should be shown in the list at the moment.\n * @remarks Should be used to retrieve the latest list of notifications\n * as the list from the state is updated only after rendering.\n */\n private _notificationsComponentList: INotificationComponentType[];\n\n /**\n * Unique identifier of the list.\n * Uses format 'NotificationComponentsList-GUID';.\n */\n private _instanceId?: string;\n\n /**\n * Initializes instance with the given props.\n * @param props - The configuration of the list.\n */\n public constructor(props: INotificationsListProps<{}>) {\n super(props);\n\n this.feed = props.config.feed;\n\n if (\n !ObjectExtensions.isNullOrUndefined(props.config.minTopOffset) &&\n !ObjectExtensions.isNullOrUndefined(props.config.maxTopOffset)\n ) {\n this._stickyConfiguration = {\n minTopOffset: props.config.minTopOffset,\n maxTopOffset: props.config.maxTopOffset\n };\n }\n\n this._notificationsComponentList = [];\n\n this.state = {\n notificationsComponentList: []\n };\n\n this._handleTopUpdate = this._handleTopUpdate.bind(this);\n this._getCurrentTopPosition = this._getCurrentTopPosition.bind(this);\n }\n\n /**\n * Specifies if the component should be re-rendered.\n * @param nextProps - The next configuration the component is receiving.\n * @param nextState - The next state the component is receiving.\n * @returns True if component should be re-rendered, false if component should not be changed.\n */\n public shouldComponentUpdate(\n nextProps: Readonly>,\n nextState: Readonly\n ): boolean {\n const isPropsDifferent =\n this.feed !== nextProps.config.feed ||\n this.props.config.maxNotificationsCount !== nextProps.config.maxNotificationsCount ||\n this.props.config.maxTopOffset !== nextProps.config.maxTopOffset ||\n this.props.config.minTopOffset !== nextProps.config.minTopOffset ||\n this.props.config.className !== nextProps.config.className ||\n this.props.id !== nextProps.id;\n const isStateDifferent =\n this.state.top !== nextState.top ||\n this.state.notificationsComponentList.length !== nextState.notificationsComponentList.length ||\n this.state.notificationsComponentList.every(value =>\n nextState.notificationsComponentList.find(otherValue => otherValue.props.notification.id === value.props.notification.id)\n );\n return isPropsDifferent || isStateDifferent;\n }\n\n /**\n * Adds the current instance to the global list of instances so that it becomes available for the notification manager.\n * In case the list is specified to be stickable, also subscribes to the scroll event to update the offsets.\n */\n public componentDidMount(): void {\n NotificationComponentsListsManager.subscribe(this);\n\n this._instanceId = `NotificationComponentsList-${Random.Guid.generateGuid()}`;\n\n if (MsDyn365.isBrowser && this._stickyConfiguration !== undefined) {\n window.addEventListener('scroll', this._handleTopUpdate);\n }\n }\n\n /**\n * Remove the instance from the global list of instances so that it becomes unavailable for the notification manager.\n * Unsubscribes itself from the notification events and scroll event.\n */\n public componentWillUnmount(): void {\n NotificationComponentsListsManager.unsubscribe(this);\n\n this._notificationsComponentList.forEach(component =>\n component.props.notification.events.getValue(NotificationEvents.RemovedFromList)?.unsubscribe(this._instanceId!)\n );\n\n if (MsDyn365.isBrowser && this._stickyConfiguration !== undefined) {\n window.removeEventListener('scroll', this._handleTopUpdate);\n }\n }\n\n /**\n * Adds a new notification to the list.\n * @param {INotificationComponentType} notificationComponent Data required to render the notification. @see INotificationComponentType.\n */\n public addNotificationComponent(notificationComponent: INotificationComponentType): void {\n if (this._instanceId === undefined) {\n return;\n }\n\n if (\n !ObjectExtensions.isNullOrUndefined(this.props.config.maxNotificationsCount) &&\n this._notificationsComponentList.length >= this.props.config.maxNotificationsCount\n ) {\n throw new Error('Notifications limit reached, cannot show more notifications.');\n }\n\n // Subscribe to the remove event to filter the removed notifications out from the list.\n notificationComponent.props.notification.events.getValue(NotificationEvents.RemovedFromList)?.subscribe({\n instanceId: this._instanceId,\n handler: () => {\n notificationComponent.props.notification.events\n .getValue(NotificationEvents.RemovedFromList)\n ?.unsubscribe(this._instanceId!);\n const newList = this._notificationsComponentList.filter(component => component !== notificationComponent);\n this._notificationsComponentList = newList;\n this.setState({ notificationsComponentList: this._notificationsComponentList });\n }\n });\n\n // Prepend the notification as newest should come to the top.\n this._notificationsComponentList.unshift(notificationComponent);\n this.setState({ notificationsComponentList: this._notificationsComponentList });\n this._handleTopUpdate();\n }\n\n public render(): React.ReactNode {\n const className = classnames(\n NotificationComponentsList._className,\n `${NotificationComponentsList._className}__${this.feed}`,\n this.props.config.className\n );\n\n const viewProps: INotificationsListViewProps = {\n ...this.props,\n container: {\n moduleProps: this.props,\n className,\n id: this._instanceId,\n style: { top: this.state.top }\n },\n notificationsList: this._renderNotificationsList()\n };\n\n return this.props.renderView(viewProps);\n }\n\n /**\n * Renders the list of notifications.\n * @returns React node with a list of notifications.\n */\n private _renderNotificationsList(): React.ReactNode {\n const hasNotifications = ArrayExtensions.hasElements(this.state.notificationsComponentList);\n const containerClassName = classnames(\n `${NotificationComponentsList._className}__scrollable`,\n hasNotifications\n ? `${NotificationComponentsList._className}__has-notifications`\n : `${NotificationComponentsList._className}__empty`\n );\n\n return (\n
\n {this.state.notificationsComponentList.map(component => {\n const ComponentClass = component.componentClass;\n return ;\n })}\n
\n );\n }\n\n /**\n * Retrieves current top offset position by looking at scroll position and rounding it to the stickable limits.\n */\n private _getCurrentTopPosition(): number | undefined {\n const configuration = this._stickyConfiguration;\n\n if (configuration === undefined) {\n return undefined;\n }\n\n let pageYOffset = 0;\n if (MsDyn365.isBrowser) {\n pageYOffset = window.pageYOffset;\n }\n\n return Math.max(Math.min(configuration.maxTopOffset, configuration.maxTopOffset - pageYOffset), configuration.minTopOffset);\n }\n\n /**\n * Updates the top offset on scroll event to make the list stickable.\n */\n private _handleTopUpdate(): void {\n const newTop = this._getCurrentTopPosition();\n this.setState({ top: newTop });\n }\n}\n\nexport default NotificationComponentsList;\n","/*!\n * Copyright (c) Microsoft Corporation.\n * All rights reserved. See LICENSE in the project root for license information.\n */\n\nimport { Module } from '@msdyn365-commerce-modules/utilities';\nimport * as React from 'react';\n\nimport { INotificationsListViewProps } from './notifications-list';\n\nexport const NotificationsListView: React.FC = props => {\n return {props.notificationsList};\n};\n\nexport default NotificationsListView;\n","module.exports = React;","module.exports = ReactDOM;"],"names":["binding","modules","dataActions","c","require","$type","da","iNM","ns","n","p","pdp","md","window","__bindings__","_objectSpread","viewDictionary","cn","NotificationComponentsList","React","constructor","props","super","this","feed","config","ObjectExtensions","isNullOrUndefined","minTopOffset","maxTopOffset","_stickyConfiguration","_notificationsComponentList","state","notificationsComponentList","_handleTopUpdate","bind","_getCurrentTopPosition","shouldComponentUpdate","nextProps","nextState","isPropsDifferent","maxNotificationsCount","className","id","isStateDifferent","top","length","every","value","find","otherValue","notification","componentDidMount","NotificationComponentsListsManager","subscribe","_instanceId","Random","Guid","generateGuid","MsDyn365","isBrowser","undefined","addEventListener","componentWillUnmount","unsubscribe","forEach","component","_component$props$noti","events","getValue","NotificationEvents","RemovedFromList","removeEventListener","addNotificationComponent","notificationComponent","_notificationComponen","Error","instanceId","handler","_notificationComponen2","newList","filter","setState","unshift","render","classnames","_className","viewProps","container","moduleProps","style","notificationsList","_renderNotificationsList","renderView","hasNotifications","ArrayExtensions","hasElements","containerClassName","maxHeight","map","ComponentClass","componentClass","Object","assign","key","configuration","pageYOffset","Math","max","min","newTop","NotificationsListView","Module","module","exports","ReactDOM"],"sourceRoot":""}