@hitachivantara/uikit-react-lab 3.41.0 → 3.41.3
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/CHANGELOG.md +27 -0
- package/dist/NotificationPanel/NotificationPanel.d.ts +1 -1
- package/dist/NotificationPanel/NotificationPanel.js +2 -2
- package/dist/NotificationPanel/NotificationPanel.js.map +1 -1
- package/dist/legacy/NotificationPanel/NotificationPanel.d.ts +1 -1
- package/dist/legacy/NotificationPanel/NotificationPanel.js +2 -2
- package/dist/legacy/NotificationPanel/NotificationPanel.js.map +1 -1
- package/dist/modern/NotificationPanel/NotificationPanel.d.ts +1 -1
- package/dist/modern/NotificationPanel/NotificationPanel.js +2 -2
- package/dist/modern/NotificationPanel/NotificationPanel.js.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,33 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [3.41.3](https://github.com/lumada-design/hv-uikit-react/compare/@hitachivantara/uikit-react-lab@3.41.2...@hitachivantara/uikit-react-lab@3.41.3) (2022-04-08)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @hitachivantara/uikit-react-lab
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [3.41.2](https://github.com/lumada-design/hv-uikit-react/compare/@hitachivantara/uikit-react-lab@3.41.1...@hitachivantara/uikit-react-lab@3.41.2) (2022-04-07)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* **NavigationComponent:** send event object to menu item click callback ([#2727](https://github.com/lumada-design/hv-uikit-react/issues/2727)) ([#2728](https://github.com/lumada-design/hv-uikit-react/issues/2728)) ([ba0ae57](https://github.com/lumada-design/hv-uikit-react/commit/ba0ae5755a82e57914898b1d921b2f59225c10c3))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## [3.41.1](https://github.com/lumada-design/hv-uikit-react/compare/@hitachivantara/uikit-react-lab@3.41.0...@hitachivantara/uikit-react-lab@3.41.1) (2022-04-05)
|
|
26
|
+
|
|
27
|
+
**Note:** Version bump only for package @hitachivantara/uikit-react-lab
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
6
33
|
# [3.41.0](https://github.com/lumada-design/hv-uikit-react/compare/@hitachivantara/uikit-react-lab@3.40.0...@hitachivantara/uikit-react-lab@3.41.0) (2022-04-02)
|
|
7
34
|
|
|
8
35
|
|
|
@@ -209,11 +209,11 @@ var HvNotificationPanel = function HvNotificationPanel(_ref3) {
|
|
|
209
209
|
var dList = (0, _toConsumableArray2.default)(actions.values);
|
|
210
210
|
return /*#__PURE__*/_react.default.createElement(_uikitReactCore.HvDropDownMenu, (0, _extends2.default)({
|
|
211
211
|
expanded: expand,
|
|
212
|
-
onClick: function onClick(
|
|
212
|
+
onClick: function onClick(event, item) {
|
|
213
213
|
var _item$callback;
|
|
214
214
|
|
|
215
215
|
setHighlighted(undefined);
|
|
216
|
-
item === null || item === void 0 ? void 0 : (_item$callback = item.callback) === null || _item$callback === void 0 ? void 0 : _item$callback.call(item, notificationId);
|
|
216
|
+
item === null || item === void 0 ? void 0 : (_item$callback = item.callback) === null || _item$callback === void 0 ? void 0 : _item$callback.call(item, event, notificationId);
|
|
217
217
|
},
|
|
218
218
|
dataList: dList,
|
|
219
219
|
onToggle: function onToggle(event, s) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/NotificationPanel/NotificationPanel.js"],"names":["DEFAULT_LABELS","notificationGroupHeader","newNotifications","olderNotifications","notificationIndicator","label","buttonLabel","getGenericLocale","locale","includes","substr","indexOf","importAndLoadLocale","then","dayjs","catch","genericLocale","console","warn","HvNotificationPanel","id","className","classes","open","footer","notifications","hasNewNotifications","emptyStatePanelTitle","emptyStatePanelMessage","emptyStatePanelIcon","labelsProp","labels","newNotificationsButtonAction","localeProp","others","localeFromProvider","undefined","highlighted","setHighlighted","isExpanded","setIsExpanded","isLocaleLoaded","setIsLocaleLoaded","isMounted","generateNotificationsActions","notificationId","onToggle","actions","expand","dList","values","e","item","callback","event","s","dropDownMenuProps","notificationElementGenerator","notificationsToRender","map","notification","notificationIsHighlighted","title","isRead","icon","date","onClick","onKeyPress","hasNotifications","length","renderNotifications","root","closed","panel","emptyState","actionBarRoot","actionBar","propTypes","PropTypes","string","bool","shape","notificationsIndicator","isRequired","arrayOf","oneOfType","number","object","element","func","action","instanceOf","Object","node","styles","name"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AASA;;AAEA;;AACA;;AACA;;;;;;;;AAEA,IAAMA,cAAc,GAAG;AACrBC,EAAAA,uBAAuB,EAAE;AACvBC,IAAAA,gBAAgB,EAAE,KADK;AAEvBC,IAAAA,kBAAkB,EAAE;AAFG,GADJ;AAKrBC,EAAAA,qBAAqB,EAAE;AACrBC,IAAAA,KAAK,EAAE,4BADc;AAErBC,IAAAA,WAAW,EAAE;AAFQ;AALF,CAAvB;AAWA;AACA;AACA;AACA;AACA;AACA;;AACO,IAAMC,gBAAgB,GAAG,SAAnBA,gBAAmB,CAACC,MAAD;AAAA,SAC9BA,MAAM,CAACC,QAAP,CAAgB,GAAhB,KAAwBD,MAAM,CAACE,MAAP,CAAc,CAAd,EAAiBF,MAAM,CAACG,OAAP,CAAe,GAAf,CAAjB,CADM;AAAA,CAAzB;AAGP;AACA;AACA;AACA;AACA;AACA;;;;;AACA,IAAMC,mBAAmB;AAAA,qFAAG,kBAAOJ,MAAP;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBACpB,uCAAuBA,MAAvB;AAAA;AAAA,eACHK,IAD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AAE+B,mBAAUG,KAAV,CAAgB;AACvB5E,MAAAA,KAAK,EAAEyE,mBAAUE,IADM;AAEvBU,MAAAA,MAAM,EAAEZ,mBAAUC,MAFK;AAGvB1B,MAAAA,QAAQ,EAAEyB,mBAAUW,IAHG;AAIvBjC,MAAAA,iBAAiB,EAAEsB,mBAAUa,UAAV,CAAqBC,MAArB;AAJI,KAAhB;AATK,GAAhB,CADa,CAvDe;;AAyE9B;AACF;AACA;AACElE,EAAAA,mBAAmB,EAAEoD,mBAAUE,IA5ED;;AA6E9B;AACF;AACA;AACExD,EAAAA,MAAM,EAAEsD,mBAAUe,IAhFY;;AAiF9B;AACF;AACA;AACElE,EAAAA,oBAAoB,EAAEmD,mBAAUC,MApFF;;AAqF9B;AACF;AACA;AACEnD,EAAAA,sBAAsB,EAAEkD,mBAAUC,MAxFJ;;AAyF9B;AACF;AACA;AACElD,EAAAA,mBAAmB,EAAEiD,mBAAUe,IA5FD;;AA6F9B;AACF;AACA;AACE9D,EAAAA,MAAM,EAAE+C,mBAAUG,KAAV,CAAgB;AACtB;AACJ;AACA;AACIhF,IAAAA,uBAAuB,EAAE;AACvBE,MAAAA,kBAAkB,EAAE2E,mBAAUC,MADP;AAEvB7E,MAAAA,gBAAgB,EAAE4E,mBAAUC;AAFL,KAJH;;AAQtB;AACJ;AACA;AACI3E,IAAAA,qBAAqB,EAAE;AACrBC,MAAAA,KAAK,EAAEyE,mBAAUC,MADI;AAErBzE,MAAAA,WAAW,EAAEwE,mBAAUC;AAFF;AAXD,GAAhB,CAhGsB;;AAgH9B;AACF;AACA;AACE/C,EAAAA,4BAA4B,EAAE8C,mBAAUW,IAnHV;;AAoH9B;AACF;AACA;AACEjF,EAAAA,MAAM,EAAEsE,mBAAUC;AAvHY,CAAhC;;eA0He,sBAAWe,eAAX,EAAmB;AAAEC,EAAAA,IAAI,EAAE;AAAR,CAAnB,EAAoD5E,mBAApD,C","sourcesContent":["import React, { useState, useEffect } from \"react\";\nimport PropTypes from \"prop-types\";\nimport clsx from \"clsx\";\nimport dayjs from \"dayjs\";\nimport { deprecatedPropType, withStyles } from \"@material-ui/core\";\nimport {\n HvPanel,\n HvActionBar,\n HvDropDownMenu,\n setId,\n useLabels,\n useLocale,\n} from \"@hitachivantara/uikit-react-core\";\n\nimport styles from \"./styles\";\n\nimport Notification from \"./Notification\";\nimport EmptyStatePanel from \"./EmptyStatePanel\";\nimport NotificationsIndicator from \"./NotificationsIndicator\";\n\nconst DEFAULT_LABELS = {\n notificationGroupHeader: {\n newNotifications: \"New\",\n olderNotifications: \"Earlier\",\n },\n notificationIndicator: {\n label: \"You have new notifications\",\n buttonLabel: \"Update\",\n },\n};\n\n/**\n * Obtains a simplified locale, if possible, e.g: \"en-US\" returns \"en\".\n *\n * @param {string} locale - The locale to be used\n * @returns The more generic locale if found\n */\nexport const getGenericLocale = (locale) =>\n locale.includes(\"-\") && locale.substr(0, locale.indexOf(\"-\"));\n\n/**\n * Imports and load the received locale in order to be used by dayjs. If the provided locale or a generic one\n * obtained is not possible to load, then dayjs will fallback to its default.\n *\n * @param {string} locale - The locale to be used\n */\nconst importAndLoadLocale = async (locale) => {\n await import(`dayjs/locale/${locale}.js`)\n .then(() => {\n dayjs.locale(locale);\n })\n .catch(async () => {\n const genericLocale = getGenericLocale(locale);\n await import(`dayjs/locale/${genericLocale}.js`)\n .then(() => dayjs.locale(genericLocale))\n // eslint-disable-next-line no-console\n .catch(() => console.warn(`Unable to load locale: ${locale}. Falling back to the default`));\n });\n};\n\n/**\n * Notification Panel displays all of read and unread notifications. Still in development\n */\nconst HvNotificationPanel = ({\n id,\n className,\n classes,\n open,\n footer,\n notifications,\n hasNewNotifications = false,\n emptyStatePanelTitle = \"No notifications\",\n emptyStatePanelMessage = \"You currently have no notifications.\",\n emptyStatePanelIcon,\n labels: labelsProp,\n newNotificationsButtonAction,\n locale: localeProp,\n ...others\n}) => {\n const localeFromProvider = useLocale();\n\n const locale = localeProp || localeFromProvider;\n\n const [highlighted, setHighlighted] = useState(undefined);\n const [isExpanded, setIsExpanded] = useState(false);\n const [isLocaleLoaded, setIsLocaleLoaded] = useState(false);\n\n useEffect(() => {\n // We're using this mount logic to avoid potential memory leak problems.\n let isMounted = true;\n\n if (!isLocaleLoaded) {\n importAndLoadLocale(locale).then(() => {\n if (isMounted) {\n setIsLocaleLoaded(true);\n }\n });\n }\n return () => {\n isMounted = false;\n };\n });\n\n const labels = useLabels(DEFAULT_LABELS, labelsProp);\n\n const generateNotificationsActions = (notificationId, onToggle, actions) => {\n const expand = notificationId === highlighted;\n const dList = [...actions.values];\n return (\n <HvDropDownMenu\n expanded={expand}\n onClick={(e, item) => {\n setHighlighted(undefined);\n item?.callback?.(notificationId);\n }}\n dataList={dList}\n onToggle={(event, s) => {\n onToggle?.(event, s);\n if (s) {\n setHighlighted(notificationId);\n } else {\n setHighlighted(undefined);\n }\n setIsExpanded(!isExpanded);\n }}\n {...actions.dropDownMenuProps}\n />\n );\n };\n\n const notificationElementGenerator = (notificationsToRender) => {\n return notificationsToRender.map((notification) => {\n const notificationIsHighlighted = highlighted === notification.id;\n return (\n <Notification\n key={notification.id}\n notificationId={notification.id}\n title={notification.title}\n isRead={notification.isRead}\n icon={notification.icon}\n date={notification.date}\n onClick={notification.onClick}\n onKeyPress={notification.onKeyPress}\n rightContainer={generateNotificationsActions(\n notification.id,\n notification.onToggle,\n notification.actions\n )}\n isHighlighted={notificationIsHighlighted}\n locale={locale}\n />\n );\n });\n };\n\n const hasNotifications = notifications.length > 0;\n\n const renderNotifications = (notificationsToRender) =>\n notificationElementGenerator(notificationsToRender);\n\n return (\n <HvPanel\n id={id}\n className={clsx(className, classes.root, {\n [classes.closed]: open === false,\n [classes.open]: open,\n })}\n {...others}\n >\n {hasNewNotifications && (\n <NotificationsIndicator\n labels={labels.notificationIndicator}\n onClick={newNotificationsButtonAction}\n />\n )}\n {hasNotifications ? (\n <div className={classes.panel}>\n {notifications.length > 0 && renderNotifications(notifications)}\n </div>\n ) : (\n <EmptyStatePanel\n id={setId(id, \"empty-state\")}\n title={emptyStatePanelTitle}\n message={emptyStatePanelMessage}\n icon={emptyStatePanelIcon}\n className={classes.emptyState}\n />\n )}\n {footer && (\n <HvActionBar\n id={setId(id, \"action-bar\")}\n classes={{\n root: classes.actionBarRoot,\n }}\n className={classes.actionBar}\n >\n {footer}\n </HvActionBar>\n )}\n </HvPanel>\n );\n};\n\nHvNotificationPanel.propTypes = {\n /**\n * Id to be applied to the root node of the panel.\n */\n id: PropTypes.string,\n /**\n * Class names to be applied to the root element.\n */\n className: PropTypes.string,\n /**\n * 'true' if panel is open or 'false' if the panel is not open\n *\n * @deprecated This logic should be external, i.e. using the HvAppSwitcherPanel inside a Drawer component.\n */\n open: deprecatedPropType(PropTypes.bool),\n /**\n * A Jss Object used to override or extend the styles applied.\n */\n classes: PropTypes.shape({\n /**\n * styles object applied to the root\n */\n root: PropTypes.string,\n /**\n * styles object applied to the root when closed\n */\n closed: PropTypes.string,\n /**\n * styles object applied to the root when open\n */\n open: PropTypes.string,\n /**\n * styles object applied to the panel\n */\n panel: PropTypes.string,\n /**\n * styles object applied to the action bar\n */\n actionBar: PropTypes.string,\n /**\n * styles object applied to the root of the action bar\n */\n actionBarRoot: PropTypes.string,\n /**\n * styles object applied to the new notification indicator\n */\n notificationsIndicator: PropTypes.string,\n /**\n * styles object applied to the empty state panel\n */\n emptyState: PropTypes.string,\n }).isRequired,\n /**\n * The properties of the notifications to be rendered in the Panel.\n */\n notifications: PropTypes.arrayOf(\n PropTypes.shape({\n id: PropTypes.string.isRequired,\n title: PropTypes.string.isRequired,\n isRead: PropTypes.bool.isRequired,\n date: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object]).isRequired,\n icon: PropTypes.element,\n onClick: PropTypes.func,\n onKeyPress: PropTypes.func,\n onToggle: PropTypes.func,\n actions: PropTypes.shape({\n label: PropTypes.bool,\n action: PropTypes.string,\n callback: PropTypes.func,\n dropDownMenuProps: PropTypes.instanceOf(Object),\n }),\n })\n ),\n /**\n * Whether to render the new notifications indicator\n */\n hasNewNotifications: PropTypes.bool,\n /**\n * Action buttons to render in footer\n */\n footer: PropTypes.node,\n /**\n * Title of the EmptyStatePanel\n */\n emptyStatePanelTitle: PropTypes.string,\n /**\n * Message of the EmptyStatePanel\n */\n emptyStatePanelMessage: PropTypes.string,\n /**\n * Empty Panel custom Icon\n */\n emptyStatePanelIcon: PropTypes.node,\n /**\n * Labels to apply to the Panel\n */\n labels: PropTypes.shape({\n /**\n * Labels to apply to the groups separating newer and older notifications\n */\n notificationGroupHeader: {\n olderNotifications: PropTypes.string,\n newNotifications: PropTypes.string,\n },\n /**\n * Labels to apply to the element of the New Notifications Indicator\n */\n notificationIndicator: {\n label: PropTypes.string,\n buttonLabel: PropTypes.string,\n },\n }),\n /**\n * Function to be supplied to the notification update button\n */\n newNotificationsButtonAction: PropTypes.func,\n /**\n * The locale to be used on the notification date, if undefined it will use the one from the HvProvider\n */\n locale: PropTypes.string,\n};\n\nexport default withStyles(styles, { name: \"HvNotificationPanel\" })(HvNotificationPanel);\n"],"file":"NotificationPanel.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/NotificationPanel/NotificationPanel.js"],"names":["DEFAULT_LABELS","notificationGroupHeader","newNotifications","olderNotifications","notificationIndicator","label","buttonLabel","getGenericLocale","locale","includes","substr","indexOf","importAndLoadLocale","then","dayjs","catch","genericLocale","console","warn","HvNotificationPanel","id","className","classes","open","footer","notifications","hasNewNotifications","emptyStatePanelTitle","emptyStatePanelMessage","emptyStatePanelIcon","labelsProp","labels","newNotificationsButtonAction","localeProp","others","localeFromProvider","undefined","highlighted","setHighlighted","isExpanded","setIsExpanded","isLocaleLoaded","setIsLocaleLoaded","isMounted","generateNotificationsActions","notificationId","onToggle","actions","expand","dList","values","event","item","callback","s","dropDownMenuProps","notificationElementGenerator","notificationsToRender","map","notification","notificationIsHighlighted","title","isRead","icon","date","onClick","onKeyPress","hasNotifications","length","renderNotifications","root","closed","panel","emptyState","actionBarRoot","actionBar","propTypes","PropTypes","string","bool","shape","notificationsIndicator","isRequired","arrayOf","oneOfType","number","object","element","func","action","instanceOf","Object","node","styles","name"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AASA;;AAEA;;AACA;;AACA;;;;;;;;AAEA,IAAMA,cAAc,GAAG;AACrBC,EAAAA,uBAAuB,EAAE;AACvBC,IAAAA,gBAAgB,EAAE,KADK;AAEvBC,IAAAA,kBAAkB,EAAE;AAFG,GADJ;AAKrBC,EAAAA,qBAAqB,EAAE;AACrBC,IAAAA,KAAK,EAAE,4BADc;AAErBC,IAAAA,WAAW,EAAE;AAFQ;AALF,CAAvB;AAWA;AACA;AACA;AACA;AACA;AACA;;AACO,IAAMC,gBAAgB,GAAG,SAAnBA,gBAAmB,CAACC,MAAD;AAAA,SAC9BA,MAAM,CAACC,QAAP,CAAgB,GAAhB,KAAwBD,MAAM,CAACE,MAAP,CAAc,CAAd,EAAiBF,MAAM,CAACG,OAAP,CAAe,GAAf,CAAjB,CADM;AAAA,CAAzB;AAGP;AACA;AACA;AACA;AACA;AACA;;;;;AACA,IAAMC,mBAAmB;AAAA,qFAAG,kBAAOJ,MAAP;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBACpB,uCAAuBA,MAAvB;AAAA;AAAA,eACHK,IADG,CACE,YAAM;AACVC,6BAAMN,MAAN,CAAaA,MAAb;AACD,aAHG,EAIHO,KAJG,uFAIG;AAAA;AAAA;AAAA;AAAA;AAAA;AACCC,sBAAAA,aADD,GACiBT,gBAAgB,CAACC,MAAD,CADjC;AAAA;AAAA,6BAEC,uCAAuBQ,aAAvB;AAAA;AAAA,yBACHH,IADG,CACE;AAAA,+BAAMC,eAAMN,MAAN,CAAaQ,aAAb,CAAN;AAAA,uBADF,EAEJ;AAFI,uBAGHD,KAHG,CAGG;AAAA,+BAAME,OAAO,CAACC,IAAR,kCAAuCV,MAAvC,mCAA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AAAA,MAAM,EAAEqD,mBAAUe,IAhFY;;AAiF9B;AACF;AACA;AACEjE,EAAAA,oBAAoB,EAAEkD,mBAAUC,MApFF;;AAqF9B;AACF;AACA;AACElD,EAAAA,sBAAsB,EAAEiD,mBAAUC,MAxFJ;;AAyF9B;AACF;AACA;AACEjD,EAAAA,mBAAmB,EAAEgD,mBAAUe,IA5FD;;AA6F9B;AACF;AACA;AACE7D,EAAAA,MAAM,EAAE8C,mBAAUG,KAAV,CAAgB;AACtB;AACJ;AACA;AACI/E,IAAAA,uBAAuB,EAAE;AACvBE,MAAAA,kBAAkB,EAAE0E,mBAAUC,MADP;AAEvB5E,MAAAA,gBAAgB,EAAE2E,mBAAUC;AAFL,KAJH;;AAQtB;AACJ;AACA;AACI1E,IAAAA,qBAAqB,EAAE;AACrBC,MAAAA,KAAK,EAAEwE,mBAAUC,MADI;AAErBxE,MAAAA,WAAW,EAAEuE,mBAAUC;AAFF;AAXD,GAAhB,CAhGsB;;AAgH9B;AACF;AACA;AACE9C,EAAAA,4BAA4B,EAAE6C,mBAAUW,IAnHV;;AAoH9B;AACF;AACA;AACEhF,EAAAA,MAAM,EAAEqE,mBAAUC;AAvHY,CAAhC;;eA0He,sBAAWe,eAAX,EAAmB;AAAEC,EAAAA,IAAI,EAAE;AAAR,CAAnB,EAAoD3E,mBAApD,C","sourcesContent":["import React, { useState, useEffect } from \"react\";\nimport PropTypes from \"prop-types\";\nimport clsx from \"clsx\";\nimport dayjs from \"dayjs\";\nimport { deprecatedPropType, withStyles } from \"@material-ui/core\";\nimport {\n HvPanel,\n HvActionBar,\n HvDropDownMenu,\n setId,\n useLabels,\n useLocale,\n} from \"@hitachivantara/uikit-react-core\";\n\nimport styles from \"./styles\";\n\nimport Notification from \"./Notification\";\nimport EmptyStatePanel from \"./EmptyStatePanel\";\nimport NotificationsIndicator from \"./NotificationsIndicator\";\n\nconst DEFAULT_LABELS = {\n notificationGroupHeader: {\n newNotifications: \"New\",\n olderNotifications: \"Earlier\",\n },\n notificationIndicator: {\n label: \"You have new notifications\",\n buttonLabel: \"Update\",\n },\n};\n\n/**\n * Obtains a simplified locale, if possible, e.g: \"en-US\" returns \"en\".\n *\n * @param {string} locale - The locale to be used\n * @returns The more generic locale if found\n */\nexport const getGenericLocale = (locale) =>\n locale.includes(\"-\") && locale.substr(0, locale.indexOf(\"-\"));\n\n/**\n * Imports and load the received locale in order to be used by dayjs. If the provided locale or a generic one\n * obtained is not possible to load, then dayjs will fallback to its default.\n *\n * @param {string} locale - The locale to be used\n */\nconst importAndLoadLocale = async (locale) => {\n await import(`dayjs/locale/${locale}.js`)\n .then(() => {\n dayjs.locale(locale);\n })\n .catch(async () => {\n const genericLocale = getGenericLocale(locale);\n await import(`dayjs/locale/${genericLocale}.js`)\n .then(() => dayjs.locale(genericLocale))\n // eslint-disable-next-line no-console\n .catch(() => console.warn(`Unable to load locale: ${locale}. Falling back to the default`));\n });\n};\n\n/**\n * Notification Panel displays all of read and unread notifications. Still in development\n */\nconst HvNotificationPanel = ({\n id,\n className,\n classes,\n open,\n footer,\n notifications,\n hasNewNotifications = false,\n emptyStatePanelTitle = \"No notifications\",\n emptyStatePanelMessage = \"You currently have no notifications.\",\n emptyStatePanelIcon,\n labels: labelsProp,\n newNotificationsButtonAction,\n locale: localeProp,\n ...others\n}) => {\n const localeFromProvider = useLocale();\n\n const locale = localeProp || localeFromProvider;\n\n const [highlighted, setHighlighted] = useState(undefined);\n const [isExpanded, setIsExpanded] = useState(false);\n const [isLocaleLoaded, setIsLocaleLoaded] = useState(false);\n\n useEffect(() => {\n // We're using this mount logic to avoid potential memory leak problems.\n let isMounted = true;\n\n if (!isLocaleLoaded) {\n importAndLoadLocale(locale).then(() => {\n if (isMounted) {\n setIsLocaleLoaded(true);\n }\n });\n }\n return () => {\n isMounted = false;\n };\n });\n\n const labels = useLabels(DEFAULT_LABELS, labelsProp);\n\n const generateNotificationsActions = (notificationId, onToggle, actions) => {\n const expand = notificationId === highlighted;\n const dList = [...actions.values];\n return (\n <HvDropDownMenu\n expanded={expand}\n onClick={(event, item) => {\n setHighlighted(undefined);\n item?.callback?.(event, notificationId);\n }}\n dataList={dList}\n onToggle={(event, s) => {\n onToggle?.(event, s);\n if (s) {\n setHighlighted(notificationId);\n } else {\n setHighlighted(undefined);\n }\n setIsExpanded(!isExpanded);\n }}\n {...actions.dropDownMenuProps}\n />\n );\n };\n\n const notificationElementGenerator = (notificationsToRender) => {\n return notificationsToRender.map((notification) => {\n const notificationIsHighlighted = highlighted === notification.id;\n return (\n <Notification\n key={notification.id}\n notificationId={notification.id}\n title={notification.title}\n isRead={notification.isRead}\n icon={notification.icon}\n date={notification.date}\n onClick={notification.onClick}\n onKeyPress={notification.onKeyPress}\n rightContainer={generateNotificationsActions(\n notification.id,\n notification.onToggle,\n notification.actions\n )}\n isHighlighted={notificationIsHighlighted}\n locale={locale}\n />\n );\n });\n };\n\n const hasNotifications = notifications.length > 0;\n\n const renderNotifications = (notificationsToRender) =>\n notificationElementGenerator(notificationsToRender);\n\n return (\n <HvPanel\n id={id}\n className={clsx(className, classes.root, {\n [classes.closed]: open === false,\n [classes.open]: open,\n })}\n {...others}\n >\n {hasNewNotifications && (\n <NotificationsIndicator\n labels={labels.notificationIndicator}\n onClick={newNotificationsButtonAction}\n />\n )}\n {hasNotifications ? (\n <div className={classes.panel}>\n {notifications.length > 0 && renderNotifications(notifications)}\n </div>\n ) : (\n <EmptyStatePanel\n id={setId(id, \"empty-state\")}\n title={emptyStatePanelTitle}\n message={emptyStatePanelMessage}\n icon={emptyStatePanelIcon}\n className={classes.emptyState}\n />\n )}\n {footer && (\n <HvActionBar\n id={setId(id, \"action-bar\")}\n classes={{\n root: classes.actionBarRoot,\n }}\n className={classes.actionBar}\n >\n {footer}\n </HvActionBar>\n )}\n </HvPanel>\n );\n};\n\nHvNotificationPanel.propTypes = {\n /**\n * Id to be applied to the root node of the panel.\n */\n id: PropTypes.string,\n /**\n * Class names to be applied to the root element.\n */\n className: PropTypes.string,\n /**\n * 'true' if panel is open or 'false' if the panel is not open\n *\n * @deprecated This logic should be external, i.e. using the HvAppSwitcherPanel inside a Drawer component.\n */\n open: deprecatedPropType(PropTypes.bool),\n /**\n * A Jss Object used to override or extend the styles applied.\n */\n classes: PropTypes.shape({\n /**\n * styles object applied to the root\n */\n root: PropTypes.string,\n /**\n * styles object applied to the root when closed\n */\n closed: PropTypes.string,\n /**\n * styles object applied to the root when open\n */\n open: PropTypes.string,\n /**\n * styles object applied to the panel\n */\n panel: PropTypes.string,\n /**\n * styles object applied to the action bar\n */\n actionBar: PropTypes.string,\n /**\n * styles object applied to the root of the action bar\n */\n actionBarRoot: PropTypes.string,\n /**\n * styles object applied to the new notification indicator\n */\n notificationsIndicator: PropTypes.string,\n /**\n * styles object applied to the empty state panel\n */\n emptyState: PropTypes.string,\n }).isRequired,\n /**\n * The properties of the notifications to be rendered in the Panel.\n */\n notifications: PropTypes.arrayOf(\n PropTypes.shape({\n id: PropTypes.string.isRequired,\n title: PropTypes.string.isRequired,\n isRead: PropTypes.bool.isRequired,\n date: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object]).isRequired,\n icon: PropTypes.element,\n onClick: PropTypes.func,\n onKeyPress: PropTypes.func,\n onToggle: PropTypes.func,\n actions: PropTypes.shape({\n label: PropTypes.bool,\n action: PropTypes.string,\n callback: PropTypes.func,\n dropDownMenuProps: PropTypes.instanceOf(Object),\n }),\n })\n ),\n /**\n * Whether to render the new notifications indicator\n */\n hasNewNotifications: PropTypes.bool,\n /**\n * Action buttons to render in footer\n */\n footer: PropTypes.node,\n /**\n * Title of the EmptyStatePanel\n */\n emptyStatePanelTitle: PropTypes.string,\n /**\n * Message of the EmptyStatePanel\n */\n emptyStatePanelMessage: PropTypes.string,\n /**\n * Empty Panel custom Icon\n */\n emptyStatePanelIcon: PropTypes.node,\n /**\n * Labels to apply to the Panel\n */\n labels: PropTypes.shape({\n /**\n * Labels to apply to the groups separating newer and older notifications\n */\n notificationGroupHeader: {\n olderNotifications: PropTypes.string,\n newNotifications: PropTypes.string,\n },\n /**\n * Labels to apply to the element of the New Notifications Indicator\n */\n notificationIndicator: {\n label: PropTypes.string,\n buttonLabel: PropTypes.string,\n },\n }),\n /**\n * Function to be supplied to the notification update button\n */\n newNotificationsButtonAction: PropTypes.func,\n /**\n * The locale to be used on the notification date, if undefined it will use the one from the HvProvider\n */\n locale: PropTypes.string,\n};\n\nexport default withStyles(styles, { name: \"HvNotificationPanel\" })(HvNotificationPanel);\n"],"file":"NotificationPanel.js"}
|
|
@@ -160,11 +160,11 @@ var HvNotificationPanel = function HvNotificationPanel(_ref3) {
|
|
|
160
160
|
|
|
161
161
|
return /*#__PURE__*/React.createElement(HvDropDownMenu, _extends({
|
|
162
162
|
expanded: expand,
|
|
163
|
-
onClick: function onClick(
|
|
163
|
+
onClick: function onClick(event, item) {
|
|
164
164
|
var _item$callback;
|
|
165
165
|
|
|
166
166
|
setHighlighted(undefined);
|
|
167
|
-
item === null || item === void 0 ? void 0 : (_item$callback = item.callback) === null || _item$callback === void 0 ? void 0 : _item$callback.call(item, notificationId);
|
|
167
|
+
item === null || item === void 0 ? void 0 : (_item$callback = item.callback) === null || _item$callback === void 0 ? void 0 : _item$callback.call(item, event, notificationId);
|
|
168
168
|
},
|
|
169
169
|
dataList: dList,
|
|
170
170
|
onToggle: function onToggle(event, s) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/NotificationPanel/NotificationPanel.js"],"names":["React","useState","useEffect","PropTypes","clsx","dayjs","deprecatedPropType","withStyles","HvPanel","HvActionBar","HvDropDownMenu","setId","useLabels","useLocale","styles","Notification","EmptyStatePanel","NotificationsIndicator","DEFAULT_LABELS","notificationGroupHeader","newNotifications","olderNotifications","notificationIndicator","label","buttonLabel","getGenericLocale","locale","includes","substr","indexOf","importAndLoadLocale","then","catch","genericLocale","console","warn","HvNotificationPanel","id","className","classes","open","footer","notifications","hasNewNotifications","emptyStatePanelTitle","emptyStatePanelMessage","emptyStatePanelIcon","labelsProp","labels","newNotificationsButtonAction","localeProp","others","localeFromProvider","undefined","highlighted","setHighlighted","isExpanded","setIsExpanded","isLocaleLoaded","setIsLocaleLoaded","isMounted","generateNotificationsActions","notificationId","onToggle","actions","expand","dList","values","e","item","callback","event","s","dropDownMenuProps","notificationElementGenerator","notificationsToRender","map","notification","notificationIsHighlighted","title","isRead","icon","date","onClick","onKeyPress","hasNotifications","length","renderNotifications","root","closed","panel","emptyState","actionBarRoot","actionBar","propTypes","string","bool","shape","notificationsIndicator","isRequired","arrayOf","oneOfType","number","object","element","func","action","instanceOf","Object","node","name"],"mappings":";;;;;;;;;;;;;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,SAA1B,QAA2C,OAA3C;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,IAAP,MAAiB,MAAjB;AACA,OAAOC,KAAP,MAAkB,OAAlB;AACA,SAASC,kBAAT,EAA6BC,UAA7B,QAA+C,mBAA/C;AACA,SACEC,OADF,EAEEC,WAFF,EAGEC,cAHF,EAIEC,KAJF,EAKEC,SALF,EAMEC,SANF,QAOO,kCAPP;AASA,OAAOC,MAAP,MAAmB,UAAnB;AAEA,OAAOC,YAAP,MAAyB,gBAAzB;AACA,OAAOC,eAAP,MAA4B,mBAA5B;AACA,OAAOC,sBAAP,MAAmC,0BAAnC;AAEA,IAAMC,cAAc,GAAG;AACrBC,EAAAA,uBAAuB,EAAE;AACvBC,IAAAA,gBAAgB,EAAE,KADK;AAEvBC,IAAAA,kBAAkB,EAAE;AAFG,GADJ;AAKrBC,EAAAA,qBAAqB,EAAE;AACrBC,IAAAA,KAAK,EAAE,4BADc;AAErBC,IAAAA,WAAW,EAAE;AAFQ;AALF,CAAvB;AAWA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,IAAMC,gBAAgB,GAAG,SAAnBA,gBAAmB,CAACC,MAAD;AAAA,SAC9BA,MAAM,CAACC,QAAP,CAAgB,GAAhB,KAAwBD,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9E,IAAAA,uBAAuB,EAAE;AACvBE,MAAAA,kBAAkB,EAAElB,SAAS,CAAC4F,MADP;AAEvB3E,MAAAA,gBAAgB,EAAEjB,SAAS,CAAC4F;AAFL,KAJH;;AAQtB;AACJ;AACA;AACIzE,IAAAA,qBAAqB,EAAE;AACrBC,MAAAA,KAAK,EAAEpB,SAAS,CAAC4F,MADI;AAErBvE,MAAAA,WAAW,EAAErB,SAAS,CAAC4F;AAFF;AAXD,GAAhB,CAhGsB;;AAgH9B;AACF;AACA;AACE9C,EAAAA,4BAA4B,EAAE9C,SAAS,CAACsG,IAnHV;;AAoH9B;AACF;AACA;AACE/E,EAAAA,MAAM,EAAEvB,SAAS,CAAC4F;AAvHY,CAAhC;AA0HA,eAAexF,UAAU,CAACO,MAAD,EAAS;AAAEgG,EAAAA,IAAI,EAAE;AAAR,CAAT,CAAV,CAAoD1E,mBAApD,CAAf","sourcesContent":["import React, { useState, useEffect } from \"react\";\nimport PropTypes from \"prop-types\";\nimport clsx from \"clsx\";\nimport dayjs from \"dayjs\";\nimport { deprecatedPropType, withStyles } from \"@material-ui/core\";\nimport {\n HvPanel,\n HvActionBar,\n HvDropDownMenu,\n setId,\n useLabels,\n useLocale,\n} from \"@hitachivantara/uikit-react-core\";\n\nimport styles from \"./styles\";\n\nimport Notification from \"./Notification\";\nimport EmptyStatePanel from \"./EmptyStatePanel\";\nimport NotificationsIndicator from \"./NotificationsIndicator\";\n\nconst DEFAULT_LABELS = {\n notificationGroupHeader: {\n newNotifications: \"New\",\n olderNotifications: \"Earlier\",\n },\n notificationIndicator: {\n label: \"You have new notifications\",\n buttonLabel: \"Update\",\n },\n};\n\n/**\n * Obtains a simplified locale, if possible, e.g: \"en-US\" returns \"en\".\n *\n * @param {string} locale - The locale to be used\n * @returns The more generic locale if found\n */\nexport const getGenericLocale = (locale) =>\n locale.includes(\"-\") && locale.substr(0, locale.indexOf(\"-\"));\n\n/**\n * Imports and load the received locale in order to be used by dayjs. If the provided locale or a generic one\n * obtained is not possible to load, then dayjs will fallback to its default.\n *\n * @param {string} locale - The locale to be used\n */\nconst importAndLoadLocale = async (locale) => {\n await import(`dayjs/locale/${locale}.js`)\n .then(() => {\n dayjs.locale(locale);\n })\n .catch(async () => {\n const genericLocale = getGenericLocale(locale);\n await import(`dayjs/locale/${genericLocale}.js`)\n .then(() => dayjs.locale(genericLocale))\n // eslint-disable-next-line no-console\n .catch(() => console.warn(`Unable to load locale: ${locale}. Falling back to the default`));\n });\n};\n\n/**\n * Notification Panel displays all of read and unread notifications. Still in development\n */\nconst HvNotificationPanel = ({\n id,\n className,\n classes,\n open,\n footer,\n notifications,\n hasNewNotifications = false,\n emptyStatePanelTitle = \"No notifications\",\n emptyStatePanelMessage = \"You currently have no notifications.\",\n emptyStatePanelIcon,\n labels: labelsProp,\n newNotificationsButtonAction,\n locale: localeProp,\n ...others\n}) => {\n const localeFromProvider = useLocale();\n\n const locale = localeProp || localeFromProvider;\n\n const [highlighted, setHighlighted] = useState(undefined);\n const [isExpanded, setIsExpanded] = useState(false);\n const [isLocaleLoaded, setIsLocaleLoaded] = useState(false);\n\n useEffect(() => {\n // We're using this mount logic to avoid potential memory leak problems.\n let isMounted = true;\n\n if (!isLocaleLoaded) {\n importAndLoadLocale(locale).then(() => {\n if (isMounted) {\n setIsLocaleLoaded(true);\n }\n });\n }\n return () => {\n isMounted = false;\n };\n });\n\n const labels = useLabels(DEFAULT_LABELS, labelsProp);\n\n const generateNotificationsActions = (notificationId, onToggle, actions) => {\n const expand = notificationId === highlighted;\n const dList = [...actions.values];\n return (\n <HvDropDownMenu\n expanded={expand}\n onClick={(e, item) => {\n setHighlighted(undefined);\n item?.callback?.(notificationId);\n }}\n dataList={dList}\n onToggle={(event, s) => {\n onToggle?.(event, s);\n if (s) {\n setHighlighted(notificationId);\n } else {\n setHighlighted(undefined);\n }\n setIsExpanded(!isExpanded);\n }}\n {...actions.dropDownMenuProps}\n />\n );\n };\n\n const notificationElementGenerator = (notificationsToRender) => {\n return notificationsToRender.map((notification) => {\n const notificationIsHighlighted = highlighted === notification.id;\n return (\n <Notification\n key={notification.id}\n notificationId={notification.id}\n title={notification.title}\n isRead={notification.isRead}\n icon={notification.icon}\n date={notification.date}\n onClick={notification.onClick}\n onKeyPress={notification.onKeyPress}\n rightContainer={generateNotificationsActions(\n notification.id,\n notification.onToggle,\n notification.actions\n )}\n isHighlighted={notificationIsHighlighted}\n locale={locale}\n />\n );\n });\n };\n\n const hasNotifications = notifications.length > 0;\n\n const renderNotifications = (notificationsToRender) =>\n notificationElementGenerator(notificationsToRender);\n\n return (\n <HvPanel\n id={id}\n className={clsx(className, classes.root, {\n [classes.closed]: open === false,\n [classes.open]: open,\n })}\n {...others}\n >\n {hasNewNotifications && (\n <NotificationsIndicator\n labels={labels.notificationIndicator}\n onClick={newNotificationsButtonAction}\n />\n )}\n {hasNotifications ? (\n <div className={classes.panel}>\n {notifications.length > 0 && renderNotifications(notifications)}\n </div>\n ) : (\n <EmptyStatePanel\n id={setId(id, \"empty-state\")}\n title={emptyStatePanelTitle}\n message={emptyStatePanelMessage}\n icon={emptyStatePanelIcon}\n className={classes.emptyState}\n />\n )}\n {footer && (\n <HvActionBar\n id={setId(id, \"action-bar\")}\n classes={{\n root: classes.actionBarRoot,\n }}\n className={classes.actionBar}\n >\n {footer}\n </HvActionBar>\n )}\n </HvPanel>\n );\n};\n\nHvNotificationPanel.propTypes = {\n /**\n * Id to be applied to the root node of the panel.\n */\n id: PropTypes.string,\n /**\n * Class names to be applied to the root element.\n */\n className: PropTypes.string,\n /**\n * 'true' if panel is open or 'false' if the panel is not open\n *\n * @deprecated This logic should be external, i.e. using the HvAppSwitcherPanel inside a Drawer component.\n */\n open: deprecatedPropType(PropTypes.bool),\n /**\n * A Jss Object used to override or extend the styles applied.\n */\n classes: PropTypes.shape({\n /**\n * styles object applied to the root\n */\n root: PropTypes.string,\n /**\n * styles object applied to the root when closed\n */\n closed: PropTypes.string,\n /**\n * styles object applied to the root when open\n */\n open: PropTypes.string,\n /**\n * styles object applied to the panel\n */\n panel: PropTypes.string,\n /**\n * styles object applied to the action bar\n */\n actionBar: PropTypes.string,\n /**\n * styles object applied to the root of the action bar\n */\n actionBarRoot: PropTypes.string,\n /**\n * styles object applied to the new notification indicator\n */\n notificationsIndicator: PropTypes.string,\n /**\n * styles object applied to the empty state panel\n */\n emptyState: PropTypes.string,\n }).isRequired,\n /**\n * The properties of the notifications to be rendered in the Panel.\n */\n notifications: PropTypes.arrayOf(\n PropTypes.shape({\n id: PropTypes.string.isRequired,\n title: PropTypes.string.isRequired,\n isRead: PropTypes.bool.isRequired,\n date: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object]).isRequired,\n icon: PropTypes.element,\n onClick: PropTypes.func,\n onKeyPress: PropTypes.func,\n onToggle: PropTypes.func,\n actions: PropTypes.shape({\n label: PropTypes.bool,\n action: PropTypes.string,\n callback: PropTypes.func,\n dropDownMenuProps: PropTypes.instanceOf(Object),\n }),\n })\n ),\n /**\n * Whether to render the new notifications indicator\n */\n hasNewNotifications: PropTypes.bool,\n /**\n * Action buttons to render in footer\n */\n footer: PropTypes.node,\n /**\n * Title of the EmptyStatePanel\n */\n emptyStatePanelTitle: PropTypes.string,\n /**\n * Message of the EmptyStatePanel\n */\n emptyStatePanelMessage: PropTypes.string,\n /**\n * Empty Panel custom Icon\n */\n emptyStatePanelIcon: PropTypes.node,\n /**\n * Labels to apply to the Panel\n */\n labels: PropTypes.shape({\n /**\n * Labels to apply to the groups separating newer and older notifications\n */\n notificationGroupHeader: {\n olderNotifications: PropTypes.string,\n newNotifications: PropTypes.string,\n },\n /**\n * Labels to apply to the element of the New Notifications Indicator\n */\n notificationIndicator: {\n label: PropTypes.string,\n buttonLabel: PropTypes.string,\n },\n }),\n /**\n * Function to be supplied to the notification update button\n */\n newNotificationsButtonAction: PropTypes.func,\n /**\n * The locale to be used on the notification date, if undefined it will use the one from the HvProvider\n */\n locale: PropTypes.string,\n};\n\nexport default withStyles(styles, { name: \"HvNotificationPanel\" })(HvNotificationPanel);\n"],"file":"NotificationPanel.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/NotificationPanel/NotificationPanel.js"],"names":["React","useState","useEffect","PropTypes","clsx","dayjs","deprecatedPropType","withStyles","HvPanel","HvActionBar","HvDropDownMenu","setId","useLabels","useLocale","styles","Notification","EmptyStatePanel","NotificationsIndicator","DEFAULT_LABELS","notificationGroupHeader","newNotifications","olderNotifications","notificationIndicator","label","buttonLabel","getGenericLocale","locale","includes","substr","indexOf","importAndLoadLocale","then","catch","genericLocale","console","warn","HvNotificationPanel","id","className","classes","open","footer","notifications","hasNewNotifications","emptyStatePanelTitle","emptyStatePanelMessage","emptyStatePanelIcon","labelsProp","labels","newNotificationsButtonAction","localeProp","others","localeFromProvider","undefined","highlighted","setHighlighted","isExpanded","setIsExpanded","isLocaleLoaded","setIsLocaleLoaded","isMounted","generateNotificationsActions","notificationId","onToggle","actions","expand","dList","values","event","item","callback","s","dropDownMenuProps","notificationElementGenerator","notificationsToRender","map","notification","notificationIsHighlighted","title","isRead","icon","date","onClick","onKeyPress","hasNotifications","length","renderNotifications","root","closed","panel","emptyState","actionBarRoot","actionBar","propTypes","string","bool","shape","notificationsIndicator","isRequired","arrayOf","oneOfType","number","object","element","func","action","instanceOf","Object","node","name"],"mappings":";;;;;;;;;;;;;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,SAA1B,QAA2C,OAA3C;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,IAAP,MAAiB,MAAjB;AACA,OAAOC,KAAP,MAAkB,OAAlB;AACA,SAASC,kBAAT,EAA6BC,UAA7B,QAA+C,mBAA/C;AACA,SACEC,OADF,EAEEC,WAFF,EAGEC,cAHF,EAIEC,KAJF,EAKEC,SALF,EAMEC,SANF,QAOO,kCAPP;AASA,OAAOC,MAAP,MAAmB,UAAnB;AAEA,OAAOC,YAAP,MAAyB,gBAAzB;AACA,OAAOC,eAAP,MAA4B,mBAA5B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E,EAAAA,mBAAmB,EAAExC,SAAS,CAAC4F,IA5ED;;AA6E9B;AACF;AACA;AACEtD,EAAAA,MAAM,EAAEtC,SAAS,CAACyG,IAhFY;;AAiF9B;AACF;AACA;AACEhE,EAAAA,oBAAoB,EAAEzC,SAAS,CAAC2F,MApFF;;AAqF9B;AACF;AACA;AACEjD,EAAAA,sBAAsB,EAAE1C,SAAS,CAAC2F,MAxFJ;;AAyF9B;AACF;AACA;AACEhD,EAAAA,mBAAmB,EAAE3C,SAAS,CAACyG,IA5FD;;AA6F9B;AACF;AACA;AACE5D,EAAAA,MAAM,EAAE7C,SAAS,CAAC6F,KAAV,CAAgB;AACtB;AACJ;AACA;AACI7E,IAAAA,uBAAuB,EAAE;AACvBE,MAAAA,kBAAkB,EAAElB,SAAS,CAAC2F,MADP;AAEvB1E,MAAAA,gBAAgB,EAAEjB,SAAS,CAAC2F;AAFL,KAJH;;AAQtB;AACJ;AACA;AACIxE,IAAAA,qBAAqB,EAAE;AACrBC,MAAAA,KAAK,EAAEpB,SAAS,CAAC2F,MADI;AAErBtE,MAAAA,WAAW,EAAErB,SAAS,CAAC2F;AAFF;AAXD,GAAhB,CAhGsB;;AAgH9B;AACF;AACA;AACE7C,EAAAA,4BAA4B,EAAE9C,SAAS,CAACqG,IAnHV;;AAoH9B;AACF;AACA;AACE9E,EAAAA,MAAM,EAAEvB,SAAS,CAAC2F;AAvHY,CAAhC;AA0HA,eAAevF,UAAU,CAACO,MAAD,EAAS;AAAE+F,EAAAA,IAAI,EAAE;AAAR,CAAT,CAAV,CAAoDzE,mBAApD,CAAf","sourcesContent":["import React, { useState, useEffect } from \"react\";\nimport PropTypes from \"prop-types\";\nimport clsx from \"clsx\";\nimport dayjs from \"dayjs\";\nimport { deprecatedPropType, withStyles } from \"@material-ui/core\";\nimport {\n HvPanel,\n HvActionBar,\n HvDropDownMenu,\n setId,\n useLabels,\n useLocale,\n} from \"@hitachivantara/uikit-react-core\";\n\nimport styles from \"./styles\";\n\nimport Notification from \"./Notification\";\nimport EmptyStatePanel from \"./EmptyStatePanel\";\nimport NotificationsIndicator from \"./NotificationsIndicator\";\n\nconst DEFAULT_LABELS = {\n notificationGroupHeader: {\n newNotifications: \"New\",\n olderNotifications: \"Earlier\",\n },\n notificationIndicator: {\n label: \"You have new notifications\",\n buttonLabel: \"Update\",\n },\n};\n\n/**\n * Obtains a simplified locale, if possible, e.g: \"en-US\" returns \"en\".\n *\n * @param {string} locale - The locale to be used\n * @returns The more generic locale if found\n */\nexport const getGenericLocale = (locale) =>\n locale.includes(\"-\") && locale.substr(0, locale.indexOf(\"-\"));\n\n/**\n * Imports and load the received locale in order to be used by dayjs. If the provided locale or a generic one\n * obtained is not possible to load, then dayjs will fallback to its default.\n *\n * @param {string} locale - The locale to be used\n */\nconst importAndLoadLocale = async (locale) => {\n await import(`dayjs/locale/${locale}.js`)\n .then(() => {\n dayjs.locale(locale);\n })\n .catch(async () => {\n const genericLocale = getGenericLocale(locale);\n await import(`dayjs/locale/${genericLocale}.js`)\n .then(() => dayjs.locale(genericLocale))\n // eslint-disable-next-line no-console\n .catch(() => console.warn(`Unable to load locale: ${locale}. Falling back to the default`));\n });\n};\n\n/**\n * Notification Panel displays all of read and unread notifications. Still in development\n */\nconst HvNotificationPanel = ({\n id,\n className,\n classes,\n open,\n footer,\n notifications,\n hasNewNotifications = false,\n emptyStatePanelTitle = \"No notifications\",\n emptyStatePanelMessage = \"You currently have no notifications.\",\n emptyStatePanelIcon,\n labels: labelsProp,\n newNotificationsButtonAction,\n locale: localeProp,\n ...others\n}) => {\n const localeFromProvider = useLocale();\n\n const locale = localeProp || localeFromProvider;\n\n const [highlighted, setHighlighted] = useState(undefined);\n const [isExpanded, setIsExpanded] = useState(false);\n const [isLocaleLoaded, setIsLocaleLoaded] = useState(false);\n\n useEffect(() => {\n // We're using this mount logic to avoid potential memory leak problems.\n let isMounted = true;\n\n if (!isLocaleLoaded) {\n importAndLoadLocale(locale).then(() => {\n if (isMounted) {\n setIsLocaleLoaded(true);\n }\n });\n }\n return () => {\n isMounted = false;\n };\n });\n\n const labels = useLabels(DEFAULT_LABELS, labelsProp);\n\n const generateNotificationsActions = (notificationId, onToggle, actions) => {\n const expand = notificationId === highlighted;\n const dList = [...actions.values];\n return (\n <HvDropDownMenu\n expanded={expand}\n onClick={(event, item) => {\n setHighlighted(undefined);\n item?.callback?.(event, notificationId);\n }}\n dataList={dList}\n onToggle={(event, s) => {\n onToggle?.(event, s);\n if (s) {\n setHighlighted(notificationId);\n } else {\n setHighlighted(undefined);\n }\n setIsExpanded(!isExpanded);\n }}\n {...actions.dropDownMenuProps}\n />\n );\n };\n\n const notificationElementGenerator = (notificationsToRender) => {\n return notificationsToRender.map((notification) => {\n const notificationIsHighlighted = highlighted === notification.id;\n return (\n <Notification\n key={notification.id}\n notificationId={notification.id}\n title={notification.title}\n isRead={notification.isRead}\n icon={notification.icon}\n date={notification.date}\n onClick={notification.onClick}\n onKeyPress={notification.onKeyPress}\n rightContainer={generateNotificationsActions(\n notification.id,\n notification.onToggle,\n notification.actions\n )}\n isHighlighted={notificationIsHighlighted}\n locale={locale}\n />\n );\n });\n };\n\n const hasNotifications = notifications.length > 0;\n\n const renderNotifications = (notificationsToRender) =>\n notificationElementGenerator(notificationsToRender);\n\n return (\n <HvPanel\n id={id}\n className={clsx(className, classes.root, {\n [classes.closed]: open === false,\n [classes.open]: open,\n })}\n {...others}\n >\n {hasNewNotifications && (\n <NotificationsIndicator\n labels={labels.notificationIndicator}\n onClick={newNotificationsButtonAction}\n />\n )}\n {hasNotifications ? (\n <div className={classes.panel}>\n {notifications.length > 0 && renderNotifications(notifications)}\n </div>\n ) : (\n <EmptyStatePanel\n id={setId(id, \"empty-state\")}\n title={emptyStatePanelTitle}\n message={emptyStatePanelMessage}\n icon={emptyStatePanelIcon}\n className={classes.emptyState}\n />\n )}\n {footer && (\n <HvActionBar\n id={setId(id, \"action-bar\")}\n classes={{\n root: classes.actionBarRoot,\n }}\n className={classes.actionBar}\n >\n {footer}\n </HvActionBar>\n )}\n </HvPanel>\n );\n};\n\nHvNotificationPanel.propTypes = {\n /**\n * Id to be applied to the root node of the panel.\n */\n id: PropTypes.string,\n /**\n * Class names to be applied to the root element.\n */\n className: PropTypes.string,\n /**\n * 'true' if panel is open or 'false' if the panel is not open\n *\n * @deprecated This logic should be external, i.e. using the HvAppSwitcherPanel inside a Drawer component.\n */\n open: deprecatedPropType(PropTypes.bool),\n /**\n * A Jss Object used to override or extend the styles applied.\n */\n classes: PropTypes.shape({\n /**\n * styles object applied to the root\n */\n root: PropTypes.string,\n /**\n * styles object applied to the root when closed\n */\n closed: PropTypes.string,\n /**\n * styles object applied to the root when open\n */\n open: PropTypes.string,\n /**\n * styles object applied to the panel\n */\n panel: PropTypes.string,\n /**\n * styles object applied to the action bar\n */\n actionBar: PropTypes.string,\n /**\n * styles object applied to the root of the action bar\n */\n actionBarRoot: PropTypes.string,\n /**\n * styles object applied to the new notification indicator\n */\n notificationsIndicator: PropTypes.string,\n /**\n * styles object applied to the empty state panel\n */\n emptyState: PropTypes.string,\n }).isRequired,\n /**\n * The properties of the notifications to be rendered in the Panel.\n */\n notifications: PropTypes.arrayOf(\n PropTypes.shape({\n id: PropTypes.string.isRequired,\n title: PropTypes.string.isRequired,\n isRead: PropTypes.bool.isRequired,\n date: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object]).isRequired,\n icon: PropTypes.element,\n onClick: PropTypes.func,\n onKeyPress: PropTypes.func,\n onToggle: PropTypes.func,\n actions: PropTypes.shape({\n label: PropTypes.bool,\n action: PropTypes.string,\n callback: PropTypes.func,\n dropDownMenuProps: PropTypes.instanceOf(Object),\n }),\n })\n ),\n /**\n * Whether to render the new notifications indicator\n */\n hasNewNotifications: PropTypes.bool,\n /**\n * Action buttons to render in footer\n */\n footer: PropTypes.node,\n /**\n * Title of the EmptyStatePanel\n */\n emptyStatePanelTitle: PropTypes.string,\n /**\n * Message of the EmptyStatePanel\n */\n emptyStatePanelMessage: PropTypes.string,\n /**\n * Empty Panel custom Icon\n */\n emptyStatePanelIcon: PropTypes.node,\n /**\n * Labels to apply to the Panel\n */\n labels: PropTypes.shape({\n /**\n * Labels to apply to the groups separating newer and older notifications\n */\n notificationGroupHeader: {\n olderNotifications: PropTypes.string,\n newNotifications: PropTypes.string,\n },\n /**\n * Labels to apply to the element of the New Notifications Indicator\n */\n notificationIndicator: {\n label: PropTypes.string,\n buttonLabel: PropTypes.string,\n },\n }),\n /**\n * Function to be supplied to the notification update button\n */\n newNotificationsButtonAction: PropTypes.func,\n /**\n * The locale to be used on the notification date, if undefined it will use the one from the HvProvider\n */\n locale: PropTypes.string,\n};\n\nexport default withStyles(styles, { name: \"HvNotificationPanel\" })(HvNotificationPanel);\n"],"file":"NotificationPanel.js"}
|
|
@@ -97,11 +97,11 @@ const HvNotificationPanel = _ref => {
|
|
|
97
97
|
const dList = [...actions.values];
|
|
98
98
|
return /*#__PURE__*/React.createElement(HvDropDownMenu, _extends({
|
|
99
99
|
expanded: expand,
|
|
100
|
-
onClick: (
|
|
100
|
+
onClick: (event, item) => {
|
|
101
101
|
var _item$callback;
|
|
102
102
|
|
|
103
103
|
setHighlighted(undefined);
|
|
104
|
-
item === null || item === void 0 ? void 0 : (_item$callback = item.callback) === null || _item$callback === void 0 ? void 0 : _item$callback.call(item, notificationId);
|
|
104
|
+
item === null || item === void 0 ? void 0 : (_item$callback = item.callback) === null || _item$callback === void 0 ? void 0 : _item$callback.call(item, event, notificationId);
|
|
105
105
|
},
|
|
106
106
|
dataList: dList,
|
|
107
107
|
onToggle: (event, s) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/NotificationPanel/NotificationPanel.js"],"names":["React","useState","useEffect","PropTypes","clsx","dayjs","deprecatedPropType","withStyles","HvPanel","HvActionBar","HvDropDownMenu","setId","useLabels","useLocale","styles","Notification","EmptyStatePanel","NotificationsIndicator","DEFAULT_LABELS","notificationGroupHeader","newNotifications","olderNotifications","notificationIndicator","label","buttonLabel","getGenericLocale","locale","includes","substr","indexOf","importAndLoadLocale","then","catch","genericLocale","console","warn","HvNotificationPanel","id","className","classes","open","footer","notifications","hasNewNotifications","emptyStatePanelTitle","emptyStatePanelMessage","emptyStatePanelIcon","labels","labelsProp","newNotificationsButtonAction","localeProp","others","localeFromProvider","highlighted","setHighlighted","undefined","isExpanded","setIsExpanded","isLocaleLoaded","setIsLocaleLoaded","isMounted","generateNotificationsActions","notificationId","onToggle","actions","expand","dList","values","e","item","callback","event","s","dropDownMenuProps","notificationElementGenerator","notificationsToRender","map","notification","notificationIsHighlighted","title","isRead","icon","date","onClick","onKeyPress","hasNotifications","length","renderNotifications","root","closed","panel","emptyState","actionBarRoot","actionBar","propTypes","string","bool","shape","notificationsIndicator","isRequired","arrayOf","oneOfType","number","object","element","func","action","instanceOf","Object","node","name"],"mappings":";;;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,SAA1B,QAA2C,OAA3C;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,IAAP,MAAiB,MAAjB;AACA,OAAOC,KAAP,MAAkB,OAAlB;AACA,SAASC,kBAAT,EAA6BC,UAA7B,QAA+C,mBAA/C;AACA,SACEC,OADF,EAEEC,WAFF,EAGEC,cAHF,EAIEC,KAJF,EAKEC,SALF,EAMEC,SANF,QAOO,kCAPP;AASA,OAAOC,MAAP,MAAmB,UAAnB;AAEA,OAAOC,YAAP,MAAyB,gBAAzB;AACA,OAAOC,eAAP,MAA4B,mBAA5B;AACA,OAAOC,sBAAP,MAAmC,0BAAnC;AAEA,MAAMC,cAAc,GAAG;AACrBC,EAAAA,uBAAuB,EAAE;AACvBC,IAAAA,gBAAgB,EAAE,KADK;AAEvBC,IAAAA,kBAAkB,EAAE;AAFG,GADJ;AAKrBC,EAAAA,qBAAqB,EAAE;AACrBC,IAAAA,KAAK,EAAE,4BADc;AAErBC,IAAAA,WAAW,EAAE;AAFQ;AALF,CAAvB;AAWA;AACA;AACA;AAC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CAACsG,IAnHV;;AAoH9B;AACF;AACA;AACE/E,EAAAA,MAAM,EAAEvB,SAAS,CAAC4F;AAvHY,CAAhC;AA0HA,eAAexF,UAAU,CAACO,MAAD,EAAS;AAAEgG,EAAAA,IAAI,EAAE;AAAR,CAAT,CAAV,CAAoD1E,mBAApD,CAAf","sourcesContent":["import React, { useState, useEffect } from \"react\";\nimport PropTypes from \"prop-types\";\nimport clsx from \"clsx\";\nimport dayjs from \"dayjs\";\nimport { deprecatedPropType, withStyles } from \"@material-ui/core\";\nimport {\n HvPanel,\n HvActionBar,\n HvDropDownMenu,\n setId,\n useLabels,\n useLocale,\n} from \"@hitachivantara/uikit-react-core\";\n\nimport styles from \"./styles\";\n\nimport Notification from \"./Notification\";\nimport EmptyStatePanel from \"./EmptyStatePanel\";\nimport NotificationsIndicator from \"./NotificationsIndicator\";\n\nconst DEFAULT_LABELS = {\n notificationGroupHeader: {\n newNotifications: \"New\",\n olderNotifications: \"Earlier\",\n },\n notificationIndicator: {\n label: \"You have new notifications\",\n buttonLabel: \"Update\",\n },\n};\n\n/**\n * Obtains a simplified locale, if possible, e.g: \"en-US\" returns \"en\".\n *\n * @param {string} locale - The locale to be used\n * @returns The more generic locale if found\n */\nexport const getGenericLocale = (locale) =>\n locale.includes(\"-\") && locale.substr(0, locale.indexOf(\"-\"));\n\n/**\n * Imports and load the received locale in order to be used by dayjs. If the provided locale or a generic one\n * obtained is not possible to load, then dayjs will fallback to its default.\n *\n * @param {string} locale - The locale to be used\n */\nconst importAndLoadLocale = async (locale) => {\n await import(`dayjs/locale/${locale}.js`)\n .then(() => {\n dayjs.locale(locale);\n })\n .catch(async () => {\n const genericLocale = getGenericLocale(locale);\n await import(`dayjs/locale/${genericLocale}.js`)\n .then(() => dayjs.locale(genericLocale))\n // eslint-disable-next-line no-console\n .catch(() => console.warn(`Unable to load locale: ${locale}. Falling back to the default`));\n });\n};\n\n/**\n * Notification Panel displays all of read and unread notifications. Still in development\n */\nconst HvNotificationPanel = ({\n id,\n className,\n classes,\n open,\n footer,\n notifications,\n hasNewNotifications = false,\n emptyStatePanelTitle = \"No notifications\",\n emptyStatePanelMessage = \"You currently have no notifications.\",\n emptyStatePanelIcon,\n labels: labelsProp,\n newNotificationsButtonAction,\n locale: localeProp,\n ...others\n}) => {\n const localeFromProvider = useLocale();\n\n const locale = localeProp || localeFromProvider;\n\n const [highlighted, setHighlighted] = useState(undefined);\n const [isExpanded, setIsExpanded] = useState(false);\n const [isLocaleLoaded, setIsLocaleLoaded] = useState(false);\n\n useEffect(() => {\n // We're using this mount logic to avoid potential memory leak problems.\n let isMounted = true;\n\n if (!isLocaleLoaded) {\n importAndLoadLocale(locale).then(() => {\n if (isMounted) {\n setIsLocaleLoaded(true);\n }\n });\n }\n return () => {\n isMounted = false;\n };\n });\n\n const labels = useLabels(DEFAULT_LABELS, labelsProp);\n\n const generateNotificationsActions = (notificationId, onToggle, actions) => {\n const expand = notificationId === highlighted;\n const dList = [...actions.values];\n return (\n <HvDropDownMenu\n expanded={expand}\n onClick={(e, item) => {\n setHighlighted(undefined);\n item?.callback?.(notificationId);\n }}\n dataList={dList}\n onToggle={(event, s) => {\n onToggle?.(event, s);\n if (s) {\n setHighlighted(notificationId);\n } else {\n setHighlighted(undefined);\n }\n setIsExpanded(!isExpanded);\n }}\n {...actions.dropDownMenuProps}\n />\n );\n };\n\n const notificationElementGenerator = (notificationsToRender) => {\n return notificationsToRender.map((notification) => {\n const notificationIsHighlighted = highlighted === notification.id;\n return (\n <Notification\n key={notification.id}\n notificationId={notification.id}\n title={notification.title}\n isRead={notification.isRead}\n icon={notification.icon}\n date={notification.date}\n onClick={notification.onClick}\n onKeyPress={notification.onKeyPress}\n rightContainer={generateNotificationsActions(\n notification.id,\n notification.onToggle,\n notification.actions\n )}\n isHighlighted={notificationIsHighlighted}\n locale={locale}\n />\n );\n });\n };\n\n const hasNotifications = notifications.length > 0;\n\n const renderNotifications = (notificationsToRender) =>\n notificationElementGenerator(notificationsToRender);\n\n return (\n <HvPanel\n id={id}\n className={clsx(className, classes.root, {\n [classes.closed]: open === false,\n [classes.open]: open,\n })}\n {...others}\n >\n {hasNewNotifications && (\n <NotificationsIndicator\n labels={labels.notificationIndicator}\n onClick={newNotificationsButtonAction}\n />\n )}\n {hasNotifications ? (\n <div className={classes.panel}>\n {notifications.length > 0 && renderNotifications(notifications)}\n </div>\n ) : (\n <EmptyStatePanel\n id={setId(id, \"empty-state\")}\n title={emptyStatePanelTitle}\n message={emptyStatePanelMessage}\n icon={emptyStatePanelIcon}\n className={classes.emptyState}\n />\n )}\n {footer && (\n <HvActionBar\n id={setId(id, \"action-bar\")}\n classes={{\n root: classes.actionBarRoot,\n }}\n className={classes.actionBar}\n >\n {footer}\n </HvActionBar>\n )}\n </HvPanel>\n );\n};\n\nHvNotificationPanel.propTypes = {\n /**\n * Id to be applied to the root node of the panel.\n */\n id: PropTypes.string,\n /**\n * Class names to be applied to the root element.\n */\n className: PropTypes.string,\n /**\n * 'true' if panel is open or 'false' if the panel is not open\n *\n * @deprecated This logic should be external, i.e. using the HvAppSwitcherPanel inside a Drawer component.\n */\n open: deprecatedPropType(PropTypes.bool),\n /**\n * A Jss Object used to override or extend the styles applied.\n */\n classes: PropTypes.shape({\n /**\n * styles object applied to the root\n */\n root: PropTypes.string,\n /**\n * styles object applied to the root when closed\n */\n closed: PropTypes.string,\n /**\n * styles object applied to the root when open\n */\n open: PropTypes.string,\n /**\n * styles object applied to the panel\n */\n panel: PropTypes.string,\n /**\n * styles object applied to the action bar\n */\n actionBar: PropTypes.string,\n /**\n * styles object applied to the root of the action bar\n */\n actionBarRoot: PropTypes.string,\n /**\n * styles object applied to the new notification indicator\n */\n notificationsIndicator: PropTypes.string,\n /**\n * styles object applied to the empty state panel\n */\n emptyState: PropTypes.string,\n }).isRequired,\n /**\n * The properties of the notifications to be rendered in the Panel.\n */\n notifications: PropTypes.arrayOf(\n PropTypes.shape({\n id: PropTypes.string.isRequired,\n title: PropTypes.string.isRequired,\n isRead: PropTypes.bool.isRequired,\n date: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object]).isRequired,\n icon: PropTypes.element,\n onClick: PropTypes.func,\n onKeyPress: PropTypes.func,\n onToggle: PropTypes.func,\n actions: PropTypes.shape({\n label: PropTypes.bool,\n action: PropTypes.string,\n callback: PropTypes.func,\n dropDownMenuProps: PropTypes.instanceOf(Object),\n }),\n })\n ),\n /**\n * Whether to render the new notifications indicator\n */\n hasNewNotifications: PropTypes.bool,\n /**\n * Action buttons to render in footer\n */\n footer: PropTypes.node,\n /**\n * Title of the EmptyStatePanel\n */\n emptyStatePanelTitle: PropTypes.string,\n /**\n * Message of the EmptyStatePanel\n */\n emptyStatePanelMessage: PropTypes.string,\n /**\n * Empty Panel custom Icon\n */\n emptyStatePanelIcon: PropTypes.node,\n /**\n * Labels to apply to the Panel\n */\n labels: PropTypes.shape({\n /**\n * Labels to apply to the groups separating newer and older notifications\n */\n notificationGroupHeader: {\n olderNotifications: PropTypes.string,\n newNotifications: PropTypes.string,\n },\n /**\n * Labels to apply to the element of the New Notifications Indicator\n */\n notificationIndicator: {\n label: PropTypes.string,\n buttonLabel: PropTypes.string,\n },\n }),\n /**\n * Function to be supplied to the notification update button\n */\n newNotificationsButtonAction: PropTypes.func,\n /**\n * The locale to be used on the notification date, if undefined it will use the one from the HvProvider\n */\n locale: PropTypes.string,\n};\n\nexport default withStyles(styles, { name: \"HvNotificationPanel\" })(HvNotificationPanel);\n"],"file":"NotificationPanel.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/NotificationPanel/NotificationPanel.js"],"names":["React","useState","useEffect","PropTypes","clsx","dayjs","deprecatedPropType","withStyles","HvPanel","HvActionBar","HvDropDownMenu","setId","useLabels","useLocale","styles","Notification","EmptyStatePanel","NotificationsIndicator","DEFAULT_LABELS","notificationGroupHeader","newNotifications","olderNotifications","notificationIndicator","label","buttonLabel","getGenericLocale","locale","includes","substr","indexOf","importAndLoadLocale","then","catch","genericLocale","console","warn","HvNotificationPanel","id","className","classes","open","footer","notifications","hasNewNotifications","emptyStatePanelTitle","emptyStatePanelMessage","emptyStatePanelIcon","labels","labelsProp","newNotificationsButtonAction","localeProp","others","localeFromProvider","highlighted","setHighlighted","undefined","isExpanded","setIsExpanded","isLocaleLoaded","setIsLocaleLoaded","isMounted","generateNotificationsActions","notificationId","onToggle","actions","expand","dList","values","event","item","callback","s","dropDownMenuProps","notificationElementGenerator","notificationsToRender","map","notification","notificationIsHighlighted","title","isRead","icon","date","onClick","onKeyPress","hasNotifications","length","renderNotifications","root","closed","panel","emptyState","actionBarRoot","actionBar","propTypes","string","bool","shape","notificationsIndicator","isRequired","arrayOf","oneOfType","number","object","element","func","action","instanceOf","Object","node","name"],"mappings":";;;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,SAA1B,QAA2C,OAA3C;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,IAAP,MAAiB,MAAjB;AACA,OAAOC,KAAP,MAAkB,OAAlB;AACA,SAASC,kBAAT,EAA6BC,UAA7B,QAA+C,mBAA/C;AACA,SACEC,OADF,EAEEC,WAFF,EAGEC,cAHF,EAIEC,KAJF,EAKEC,SALF,EAMEC,SANF,QAOO,kCAPP;AASA,OAAOC,MAAP,MAAmB,UAAnB;AAEA,OAAOC,YAAP,MAAyB,gBAAzB;AACA,OAAOC,eAAP,MAA4B,mBAA5B;AACA,OAAOC,sBAAP,MAAmC,0BAAnC;AAEA,MAAMC,cAAc,GAAG;AACrBC,EAAAA,uBAAuB,EAAE;AACvBC,IAAAA,gBAAgB,EAAE,KADK;AAEvBC,IAAAA,kBAAkB,EAAE;AAFG,GADJ;AAKrBC,EAAAA,qBAAqB,EAAE;AACrBC,IAAAA,KAAK,EAAE,4BADc;AAErBC,IAAAA,WAAW,EAAE;AAFQ;AALF,CAAvB;AAWA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,gBAAgB,GAAIC,MAAD,IAC9BA,MAAM,CAACC,QAAP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2F;AAvHY,CAAhC;AA0HA,eAAevF,UAAU,CAACO,MAAD,EAAS;AAAE+F,EAAAA,IAAI,EAAE;AAAR,CAAT,CAAV,CAAoDzE,mBAApD,CAAf","sourcesContent":["import React, { useState, useEffect } from \"react\";\nimport PropTypes from \"prop-types\";\nimport clsx from \"clsx\";\nimport dayjs from \"dayjs\";\nimport { deprecatedPropType, withStyles } from \"@material-ui/core\";\nimport {\n HvPanel,\n HvActionBar,\n HvDropDownMenu,\n setId,\n useLabels,\n useLocale,\n} from \"@hitachivantara/uikit-react-core\";\n\nimport styles from \"./styles\";\n\nimport Notification from \"./Notification\";\nimport EmptyStatePanel from \"./EmptyStatePanel\";\nimport NotificationsIndicator from \"./NotificationsIndicator\";\n\nconst DEFAULT_LABELS = {\n notificationGroupHeader: {\n newNotifications: \"New\",\n olderNotifications: \"Earlier\",\n },\n notificationIndicator: {\n label: \"You have new notifications\",\n buttonLabel: \"Update\",\n },\n};\n\n/**\n * Obtains a simplified locale, if possible, e.g: \"en-US\" returns \"en\".\n *\n * @param {string} locale - The locale to be used\n * @returns The more generic locale if found\n */\nexport const getGenericLocale = (locale) =>\n locale.includes(\"-\") && locale.substr(0, locale.indexOf(\"-\"));\n\n/**\n * Imports and load the received locale in order to be used by dayjs. If the provided locale or a generic one\n * obtained is not possible to load, then dayjs will fallback to its default.\n *\n * @param {string} locale - The locale to be used\n */\nconst importAndLoadLocale = async (locale) => {\n await import(`dayjs/locale/${locale}.js`)\n .then(() => {\n dayjs.locale(locale);\n })\n .catch(async () => {\n const genericLocale = getGenericLocale(locale);\n await import(`dayjs/locale/${genericLocale}.js`)\n .then(() => dayjs.locale(genericLocale))\n // eslint-disable-next-line no-console\n .catch(() => console.warn(`Unable to load locale: ${locale}. Falling back to the default`));\n });\n};\n\n/**\n * Notification Panel displays all of read and unread notifications. Still in development\n */\nconst HvNotificationPanel = ({\n id,\n className,\n classes,\n open,\n footer,\n notifications,\n hasNewNotifications = false,\n emptyStatePanelTitle = \"No notifications\",\n emptyStatePanelMessage = \"You currently have no notifications.\",\n emptyStatePanelIcon,\n labels: labelsProp,\n newNotificationsButtonAction,\n locale: localeProp,\n ...others\n}) => {\n const localeFromProvider = useLocale();\n\n const locale = localeProp || localeFromProvider;\n\n const [highlighted, setHighlighted] = useState(undefined);\n const [isExpanded, setIsExpanded] = useState(false);\n const [isLocaleLoaded, setIsLocaleLoaded] = useState(false);\n\n useEffect(() => {\n // We're using this mount logic to avoid potential memory leak problems.\n let isMounted = true;\n\n if (!isLocaleLoaded) {\n importAndLoadLocale(locale).then(() => {\n if (isMounted) {\n setIsLocaleLoaded(true);\n }\n });\n }\n return () => {\n isMounted = false;\n };\n });\n\n const labels = useLabels(DEFAULT_LABELS, labelsProp);\n\n const generateNotificationsActions = (notificationId, onToggle, actions) => {\n const expand = notificationId === highlighted;\n const dList = [...actions.values];\n return (\n <HvDropDownMenu\n expanded={expand}\n onClick={(event, item) => {\n setHighlighted(undefined);\n item?.callback?.(event, notificationId);\n }}\n dataList={dList}\n onToggle={(event, s) => {\n onToggle?.(event, s);\n if (s) {\n setHighlighted(notificationId);\n } else {\n setHighlighted(undefined);\n }\n setIsExpanded(!isExpanded);\n }}\n {...actions.dropDownMenuProps}\n />\n );\n };\n\n const notificationElementGenerator = (notificationsToRender) => {\n return notificationsToRender.map((notification) => {\n const notificationIsHighlighted = highlighted === notification.id;\n return (\n <Notification\n key={notification.id}\n notificationId={notification.id}\n title={notification.title}\n isRead={notification.isRead}\n icon={notification.icon}\n date={notification.date}\n onClick={notification.onClick}\n onKeyPress={notification.onKeyPress}\n rightContainer={generateNotificationsActions(\n notification.id,\n notification.onToggle,\n notification.actions\n )}\n isHighlighted={notificationIsHighlighted}\n locale={locale}\n />\n );\n });\n };\n\n const hasNotifications = notifications.length > 0;\n\n const renderNotifications = (notificationsToRender) =>\n notificationElementGenerator(notificationsToRender);\n\n return (\n <HvPanel\n id={id}\n className={clsx(className, classes.root, {\n [classes.closed]: open === false,\n [classes.open]: open,\n })}\n {...others}\n >\n {hasNewNotifications && (\n <NotificationsIndicator\n labels={labels.notificationIndicator}\n onClick={newNotificationsButtonAction}\n />\n )}\n {hasNotifications ? (\n <div className={classes.panel}>\n {notifications.length > 0 && renderNotifications(notifications)}\n </div>\n ) : (\n <EmptyStatePanel\n id={setId(id, \"empty-state\")}\n title={emptyStatePanelTitle}\n message={emptyStatePanelMessage}\n icon={emptyStatePanelIcon}\n className={classes.emptyState}\n />\n )}\n {footer && (\n <HvActionBar\n id={setId(id, \"action-bar\")}\n classes={{\n root: classes.actionBarRoot,\n }}\n className={classes.actionBar}\n >\n {footer}\n </HvActionBar>\n )}\n </HvPanel>\n );\n};\n\nHvNotificationPanel.propTypes = {\n /**\n * Id to be applied to the root node of the panel.\n */\n id: PropTypes.string,\n /**\n * Class names to be applied to the root element.\n */\n className: PropTypes.string,\n /**\n * 'true' if panel is open or 'false' if the panel is not open\n *\n * @deprecated This logic should be external, i.e. using the HvAppSwitcherPanel inside a Drawer component.\n */\n open: deprecatedPropType(PropTypes.bool),\n /**\n * A Jss Object used to override or extend the styles applied.\n */\n classes: PropTypes.shape({\n /**\n * styles object applied to the root\n */\n root: PropTypes.string,\n /**\n * styles object applied to the root when closed\n */\n closed: PropTypes.string,\n /**\n * styles object applied to the root when open\n */\n open: PropTypes.string,\n /**\n * styles object applied to the panel\n */\n panel: PropTypes.string,\n /**\n * styles object applied to the action bar\n */\n actionBar: PropTypes.string,\n /**\n * styles object applied to the root of the action bar\n */\n actionBarRoot: PropTypes.string,\n /**\n * styles object applied to the new notification indicator\n */\n notificationsIndicator: PropTypes.string,\n /**\n * styles object applied to the empty state panel\n */\n emptyState: PropTypes.string,\n }).isRequired,\n /**\n * The properties of the notifications to be rendered in the Panel.\n */\n notifications: PropTypes.arrayOf(\n PropTypes.shape({\n id: PropTypes.string.isRequired,\n title: PropTypes.string.isRequired,\n isRead: PropTypes.bool.isRequired,\n date: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object]).isRequired,\n icon: PropTypes.element,\n onClick: PropTypes.func,\n onKeyPress: PropTypes.func,\n onToggle: PropTypes.func,\n actions: PropTypes.shape({\n label: PropTypes.bool,\n action: PropTypes.string,\n callback: PropTypes.func,\n dropDownMenuProps: PropTypes.instanceOf(Object),\n }),\n })\n ),\n /**\n * Whether to render the new notifications indicator\n */\n hasNewNotifications: PropTypes.bool,\n /**\n * Action buttons to render in footer\n */\n footer: PropTypes.node,\n /**\n * Title of the EmptyStatePanel\n */\n emptyStatePanelTitle: PropTypes.string,\n /**\n * Message of the EmptyStatePanel\n */\n emptyStatePanelMessage: PropTypes.string,\n /**\n * Empty Panel custom Icon\n */\n emptyStatePanelIcon: PropTypes.node,\n /**\n * Labels to apply to the Panel\n */\n labels: PropTypes.shape({\n /**\n * Labels to apply to the groups separating newer and older notifications\n */\n notificationGroupHeader: {\n olderNotifications: PropTypes.string,\n newNotifications: PropTypes.string,\n },\n /**\n * Labels to apply to the element of the New Notifications Indicator\n */\n notificationIndicator: {\n label: PropTypes.string,\n buttonLabel: PropTypes.string,\n },\n }),\n /**\n * Function to be supplied to the notification update button\n */\n newNotificationsButtonAction: PropTypes.func,\n /**\n * The locale to be used on the notification date, if undefined it will use the one from the HvProvider\n */\n locale: PropTypes.string,\n};\n\nexport default withStyles(styles, { name: \"HvNotificationPanel\" })(HvNotificationPanel);\n"],"file":"NotificationPanel.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hitachivantara/uikit-react-lab",
|
|
3
|
-
"version": "3.41.
|
|
3
|
+
"version": "3.41.3",
|
|
4
4
|
"description": "A collection of contributed React components for the Hitachi Vantara's Design System.",
|
|
5
5
|
"homepage": "https://github.com/lumada-design/hv-uikit-react",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@babel/runtime": "^7.16.3",
|
|
49
|
-
"@hitachivantara/uikit-react-core": "^3.62.
|
|
50
|
-
"@hitachivantara/uikit-react-icons": "^3.8.
|
|
49
|
+
"@hitachivantara/uikit-react-core": "^3.62.2",
|
|
50
|
+
"@hitachivantara/uikit-react-icons": "^3.8.4",
|
|
51
51
|
"@types/react-table": "^7.7.8",
|
|
52
52
|
"clsx": "^1.1.1",
|
|
53
53
|
"core-js": "^3.19.1",
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"publishConfig": {
|
|
84
84
|
"access": "public"
|
|
85
85
|
},
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "9af429525d19434e7e0922a1f64268fb095587f3"
|
|
87
87
|
}
|