@mantine/notifications
Version:
Mantine notifications system
1 lines • 1.23 kB
Source Map (JSON)
{"version":3,"file":"get-grouped-notifications.cjs","names":[],"sources":["../../src/get-grouped-notifications/get-grouped-notifications.ts"],"sourcesContent":["import { NotificationData, NotificationPosition } from '../notifications.store';\n\nexport type GroupedNotifications = Record<NotificationPosition, NotificationData[]>;\n\nexport const positions: NotificationPosition[] = [\n 'bottom-center',\n 'bottom-left',\n 'bottom-right',\n 'top-center',\n 'top-left',\n 'top-right',\n];\n\nexport function getGroupedNotifications(\n notifications: NotificationData[],\n defaultPosition: NotificationPosition\n) {\n return notifications.reduce<GroupedNotifications>(\n (acc, notification) => {\n acc[notification.position || defaultPosition].push(notification);\n return acc;\n },\n positions.reduce<GroupedNotifications>((acc, item) => {\n acc[item] = [];\n return acc;\n }, {} as GroupedNotifications)\n );\n}\n"],"mappings":";;AAIA,MAAa,YAAoC;CAC/C;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,SAAgB,wBACd,eACA,iBACA;CACA,OAAO,cAAc,QAClB,KAAK,iBAAiB;EACrB,IAAI,aAAa,YAAY,iBAAiB,KAAK,YAAY;EAC/D,OAAO;CACT,GACA,UAAU,QAA8B,KAAK,SAAS;EACpD,IAAI,QAAQ,CAAC;EACb,OAAO;CACT,GAAG,CAAC,CAAyB,CAC/B;AACF"}