@camunda/camunda-composite-components 0.0.41 → 0.0.42

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.
Files changed (64) hide show
  1. package/README.md +2 -1
  2. package/lib/esm/api/api.d.ts +19 -19
  3. package/lib/esm/api/api.js +65 -67
  4. package/lib/esm/api/endpoints.const.d.ts +12 -12
  5. package/lib/esm/api/endpoints.const.js +24 -25
  6. package/lib/esm/api/jwt.utils.d.ts +3 -3
  7. package/lib/esm/api/jwt.utils.js +23 -21
  8. package/lib/esm/api/notifications.d.ts +64 -35
  9. package/lib/esm/api/notifications.js +168 -159
  10. package/lib/esm/components/c3-empty-state/c3-empty-state.d.ts +8 -2
  11. package/lib/esm/components/c3-empty-state/c3-empty-state.js +58 -17
  12. package/lib/esm/components/c3-empty-state/c3-empty-state.types.d.ts +19 -19
  13. package/lib/esm/components/c3-empty-state/c3-empty-state.types.js +1 -1
  14. package/lib/esm/components/c3-navigation/c3-info-button.d.ts +3 -3
  15. package/lib/esm/components/c3-navigation/c3-info-button.js +13 -5
  16. package/lib/esm/components/c3-navigation/c3-navigation-actions/c3-action-buttons.d.ts +5 -5
  17. package/lib/esm/components/c3-navigation/c3-navigation-actions/c3-action-buttons.js +21 -8
  18. package/lib/esm/components/c3-navigation/c3-navigation-actions/c3-action-buttons.types.d.ts +5 -5
  19. package/lib/esm/components/c3-navigation/c3-navigation-actions/c3-action-buttons.types.js +1 -1
  20. package/lib/esm/components/c3-navigation/c3-navigation-appbar.d.ts +3 -3
  21. package/lib/esm/components/c3-navigation/c3-navigation-appbar.js +157 -68
  22. package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-info-sidebar.d.ts +5 -5
  23. package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-info-sidebar.js +58 -37
  24. package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-navigation-sidebar-element.d.ts +9 -9
  25. package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-navigation-sidebar-element.js +56 -33
  26. package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-navigation-sidebar.d.ts +8 -8
  27. package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-navigation-sidebar.js +114 -54
  28. package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-navigation-sidebar.types.d.ts +70 -60
  29. package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-navigation-sidebar.types.js +1 -1
  30. package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-notification-sidebar.d.ts +4 -4
  31. package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-notification-sidebar.js +142 -88
  32. package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-org-sidebar.d.ts +5 -5
  33. package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-org-sidebar.js +105 -51
  34. package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-sidebar-state-provider.d.ts +26 -24
  35. package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-sidebar-state-provider.js +38 -25
  36. package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-user-sidebar.d.ts +5 -5
  37. package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-user-sidebar.js +125 -43
  38. package/lib/esm/components/c3-navigation/c3-navigation-sidebar/components.d.ts +6 -1
  39. package/lib/esm/components/c3-navigation/c3-navigation-sidebar/components.js +4 -4
  40. package/lib/esm/components/c3-navigation/c3-navigation.d.ts +13 -2
  41. package/lib/esm/components/c3-navigation/c3-navigation.js +210 -88
  42. package/lib/esm/components/c3-navigation/c3-navigation.types.d.ts +69 -63
  43. package/lib/esm/components/c3-navigation/c3-navigation.types.js +1 -1
  44. package/lib/esm/components/c3-navigation/c3-notification-provider/c3-notification-container.d.ts +30 -13
  45. package/lib/esm/components/c3-navigation/c3-notification-provider/c3-notification-container.js +114 -70
  46. package/lib/esm/components/c3-navigation/c3-notification-provider/c3-notification-provider.d.ts +29 -27
  47. package/lib/esm/components/c3-navigation/c3-notification-provider/c3-notification-provider.js +118 -90
  48. package/lib/esm/components/c3-navigation/helpers.d.ts +5 -3
  49. package/lib/esm/components/c3-navigation/helpers.js +53 -49
  50. package/lib/esm/components/c3-navigation/index.d.ts +4 -2
  51. package/lib/esm/components/c3-navigation/index.js +3 -3
  52. package/lib/esm/components/c3-navigation/story-helpers.d.ts +23 -18
  53. package/lib/esm/components/c3-navigation/story-helpers.js +189 -186
  54. package/lib/esm/components/c3-navigation/story-templates.d.ts +8 -8
  55. package/lib/esm/components/c3-navigation/story-templates.js +66 -33
  56. package/lib/esm/components/c3-user-configuration/c3-user-configuration-provider.d.ts +20 -16
  57. package/lib/esm/components/c3-user-configuration/c3-user-configuration-provider.js +9 -4
  58. package/lib/esm/icons/c3-icons.d.ts +7 -5
  59. package/lib/esm/icons/c3-icons.js +82 -14
  60. package/lib/esm/icons/c3-icons.types.d.ts +1 -1
  61. package/lib/esm/icons/c3-icons.types.js +1 -1
  62. package/lib/esm/index.d.ts +14 -9
  63. package/lib/esm/index.js +4 -4
  64. package/package.json +2 -1
@@ -1,107 +1,151 @@
1
- import React, { useState } from "react";
2
- import styled from "styled-components";
3
- import { Button, Link, Tile } from "@carbon/react";
4
- import { Close } from "@carbon/react/icons";
5
- const NotificationTile = styled(Tile) `
1
+ import React, { useState } from "react"
2
+ import styled from "styled-components"
3
+ import { Button, Link, Tile } from "@carbon/react"
4
+ import { Close } from "@carbon/react/icons"
5
+ const NotificationTile = styled(Tile)`
6
6
  box-shadow: inset 0px -1px 0px var(--cds-border-subtle-01);
7
- `;
8
- const CloseButton = styled(Button) `
7
+ `
8
+ const CloseButton = styled(Button)`
9
9
  margin-right: -1rem;
10
10
  visibility: ${({ $show }) => ($show ? "visible" : "hidden")};
11
- `;
12
- const UnreadNotificationHeader = styled.div `
11
+ `
12
+ const UnreadNotificationHeader = styled.div`
13
13
  display: flex;
14
14
  align-items: center;
15
15
  width: 100%;
16
- `;
17
- const Dot = styled.div `
16
+ `
17
+ const Dot = styled.div`
18
18
  background: var(--cds-interactive);
19
19
  width: 5px;
20
20
  height: 5px;
21
21
  border-radius: 50%;
22
22
  margin-left: -9px;
23
23
  margin-right: 4px;
24
- `;
25
- const Timestamp = styled.p `
24
+ `
25
+ const Timestamp = styled.p`
26
26
  color: var(--cds-text-helper);
27
27
  font-size: var(--cds-label-01-font-size);
28
28
  font-weight: var(--cds-label-01-font-weight);
29
29
  line-height: var(--cds-label-01-line-height);
30
30
  letter-spacing: var(--cds-label-01-letter-spacing);
31
- `;
32
- const NotificationHeader = styled.div `
31
+ `
32
+ const NotificationHeader = styled.div`
33
33
  width: 100%;
34
34
  min-height: 2rem;
35
35
  display: flex;
36
36
  align-items: flex-end;
37
37
  justify-content: space-between;
38
38
  margin-top: -1rem;
39
- `;
40
- export const NotificationTitle = styled.p `
39
+ `
40
+ export const NotificationTitle = styled.p`
41
41
  color: var(--cds-text-primary);
42
42
  font-size: var(--cds-heading-compact-01-font-size);
43
43
  font-weight: var(--cds-heading-compact-01-font-weight);
44
44
  line-height: var(--cds-heading-compact-01-line-height);
45
45
  letter-spacing: var(--cds-heading-compact-01-letter-spacing);
46
46
  margin-top: var(--cds-spacing-01);
47
- `;
48
- export const NotificationDescription = styled.p `
47
+ `
48
+ export const NotificationDescription = styled.p`
49
49
  color: var(--cds-text-primary);
50
50
  font-size: var(--cds-helper-text-01-font-size);
51
51
  font-weight: var(--cds-helper-text-01-font-weight);
52
52
  line-height: var(--cds-helper-text-01-line-height);
53
53
  letter-spacing: var(--cds-helper-text-01-letter-spacing);
54
54
  margin-top: var(--cds-spacing-01);
55
- `;
56
- export const LinkContainer = styled.div `
55
+ `
56
+ export const LinkContainer = styled.div`
57
57
  margin-top: 0.5rem;
58
- `;
58
+ `
59
59
  const getReadableTimestamp = (timestamp) => {
60
- const date = new Date(timestamp);
61
- // eslint-disable-next-line
62
- // @ts-ignore
63
- const minutesAgo = Math.floor(Math.abs(new Date() - date) / 1000 / 60);
64
- if (minutesAgo === 0) {
65
- return "New";
66
- }
67
- if (minutesAgo < 60) {
68
- return `${minutesAgo}min ago`;
69
- }
70
- const hoursAgo = Math.floor(minutesAgo / 60);
71
- if (hoursAgo < 24) {
72
- return `${hoursAgo}hr ago`;
73
- }
74
- return date.toDateString();
75
- };
76
- const C3NotificationContainer = ({ description, state, timestamp, title, onDismiss, meta, onLinkClick, originalOnLinkClick, unread = false, }) => {
77
- const [isHovering, setIsHovering] = useState(false);
78
- const dismissNotification = (e) => {
79
- e.stopPropagation();
80
- onDismiss();
81
- };
82
- const handleLinkClick = (event) => {
83
- if (originalOnLinkClick && onLinkClick) {
84
- event.preventDefault();
85
- onLinkClick(meta);
86
- return false;
87
- }
88
- return true;
89
- };
90
- return (React.createElement(NotificationTile, { onMouseEnter: () => {
91
- setIsHovering(true);
92
- }, onMouseLeave: () => {
93
- setIsHovering(false);
94
- } },
95
- React.createElement(UnreadNotificationHeader, null,
96
- (state === "new" || unread) && React.createElement(Dot, null),
97
- React.createElement(NotificationHeader, null,
98
- React.createElement(Timestamp, null, getReadableTimestamp(timestamp)),
99
- // eslint-disable-next-line
100
- // @ts-ignore
101
- React.createElement(CloseButton, { kind: "ghost", hasIconOnly: true, iconDescription: "Dismiss", align: "bottom-right", renderIcon: Close, onClick: dismissNotification, size: "sm", "$show": isHovering }))),
102
- React.createElement(NotificationTitle, null, title),
103
- React.createElement(NotificationDescription, null, description),
104
- meta && (React.createElement(LinkContainer, null,
105
- React.createElement(Link, { href: meta.href, onClick: handleLinkClick, visited: true, style: { fontSize: "var(--cds-helper-text-01-font-size)" } }, meta.label)))));
106
- };
107
- export default C3NotificationContainer;
60
+ const date = new Date(timestamp)
61
+ // eslint-disable-next-line
62
+ // @ts-ignore
63
+ const minutesAgo = Math.floor(Math.abs(new Date() - date) / 1000 / 60)
64
+ if (minutesAgo === 0) {
65
+ return "New"
66
+ }
67
+ if (minutesAgo < 60) {
68
+ return `${minutesAgo}min ago`
69
+ }
70
+ const hoursAgo = Math.floor(minutesAgo / 60)
71
+ if (hoursAgo < 24) {
72
+ return `${hoursAgo}hr ago`
73
+ }
74
+ return date.toDateString()
75
+ }
76
+ const C3NotificationContainer = ({
77
+ description,
78
+ state,
79
+ timestamp,
80
+ title,
81
+ onDismiss,
82
+ meta,
83
+ onLinkClick,
84
+ originalOnLinkClick,
85
+ unread = false,
86
+ }) => {
87
+ const [isHovering, setIsHovering] = useState(false)
88
+ const dismissNotification = (e) => {
89
+ e.stopPropagation()
90
+ onDismiss()
91
+ }
92
+ const handleLinkClick = (event) => {
93
+ if (originalOnLinkClick && onLinkClick) {
94
+ event.preventDefault()
95
+ onLinkClick(meta)
96
+ return false
97
+ }
98
+ return true
99
+ }
100
+ return React.createElement(
101
+ NotificationTile,
102
+ {
103
+ onMouseEnter: () => {
104
+ setIsHovering(true)
105
+ },
106
+ onMouseLeave: () => {
107
+ setIsHovering(false)
108
+ },
109
+ },
110
+ React.createElement(
111
+ UnreadNotificationHeader,
112
+ null,
113
+ (state === "new" || unread) && React.createElement(Dot, null),
114
+ React.createElement(
115
+ NotificationHeader,
116
+ null,
117
+ React.createElement(Timestamp, null, getReadableTimestamp(timestamp)),
118
+ // eslint-disable-next-line
119
+ // @ts-ignore
120
+ React.createElement(CloseButton, {
121
+ kind: "ghost",
122
+ hasIconOnly: true,
123
+ iconDescription: "Dismiss",
124
+ align: "bottom-right",
125
+ renderIcon: Close,
126
+ onClick: dismissNotification,
127
+ size: "sm",
128
+ $show: isHovering,
129
+ }),
130
+ ),
131
+ ),
132
+ React.createElement(NotificationTitle, null, title),
133
+ React.createElement(NotificationDescription, null, description),
134
+ meta &&
135
+ React.createElement(
136
+ LinkContainer,
137
+ null,
138
+ React.createElement(
139
+ Link,
140
+ {
141
+ href: meta.href,
142
+ onClick: handleLinkClick,
143
+ visited: true,
144
+ style: { fontSize: "var(--cds-helper-text-01-font-size)" },
145
+ },
146
+ meta.label,
147
+ ),
148
+ ),
149
+ )
150
+ }
151
+ export default C3NotificationContainer
@@ -1,30 +1,32 @@
1
- import React, { ComponentType, FC, ReactNode } from "react";
2
- import { AnalyticsEvent, Notification } from "../../../api/notifications";
1
+ import React, { ComponentType, FC, ReactNode } from "react"
2
+ import { AnalyticsEvent, Notification } from "../../../api/notifications"
3
3
  export declare type LinkProps = {
4
- label?: string;
5
- href?: string;
6
- entity?: {
7
- id: string;
8
- type: string;
9
- };
10
- parentEntity?: {
11
- id: string;
12
- type: string;
13
- };
14
- };
4
+ label?: string
5
+ href?: string
6
+ entity?: {
7
+ id: string
8
+ type: string
9
+ }
10
+ parentEntity?: {
11
+ id: string
12
+ type: string
13
+ }
14
+ }
15
15
  export declare type C3NotificationContextValue = {
16
- enabled: boolean;
17
- notifications: Notification[];
18
- markAsRead: (notification: Notification) => void;
19
- markAllAsRead: (notifications: Notification[]) => void;
20
- dismiss: (notification: Notification) => void;
21
- dismissAll: (notifications: Notification[]) => void;
22
- analytics: (event: AnalyticsEvent, id?: string) => void;
23
- };
24
- export declare const C3NotificationContext: React.Context<C3NotificationContextValue>;
16
+ enabled: boolean
17
+ notifications: Notification[]
18
+ markAsRead: (notification: Notification) => void
19
+ markAllAsRead: (notifications: Notification[]) => void
20
+ dismiss: (notification: Notification) => void
21
+ dismissAll: (notifications: Notification[]) => void
22
+ analytics: (event: AnalyticsEvent, id?: string) => void
23
+ }
24
+ export declare const C3NotificationContext: React.Context<C3NotificationContextValue>
25
25
  export declare type C3NotificationProviderProps = {
26
- children?: ReactNode;
27
- };
28
- declare const C3NotificationProvider: FC<C3NotificationProviderProps>;
29
- export declare function withNotifications<P>(Component: ComponentType<P>): ComponentType<P>;
30
- export default C3NotificationProvider;
26
+ children?: ReactNode
27
+ }
28
+ declare const C3NotificationProvider: FC<C3NotificationProviderProps>
29
+ export declare function withNotifications<P>(
30
+ Component: ComponentType<P>,
31
+ ): ComponentType<P>
32
+ export default C3NotificationProvider
@@ -1,93 +1,121 @@
1
- import React, { useContext, useEffect, useState, } from "react";
2
- import { NotificationService, } from "../../../api/notifications";
3
- import { C3UserConfigurationContext } from "../../c3-user-configuration/c3-user-configuration-provider";
1
+ import React, { useContext, useEffect, useState } from "react"
2
+ import { NotificationService } from "../../../api/notifications"
3
+ import { C3UserConfigurationContext } from "../../c3-user-configuration/c3-user-configuration-provider"
4
4
  export const C3NotificationContext = React.createContext({
5
- enabled: false,
6
- notifications: [],
7
- markAsRead: () => undefined,
8
- markAllAsRead: () => undefined,
9
- dismiss: () => undefined,
10
- dismissAll: () => undefined,
11
- analytics: () => undefined,
12
- });
13
- const C3NotificationProvider = ({ children, }) => {
14
- const [notifications, setNotifications] = useState([]);
15
- const [isFetched, setFetched] = useState(false);
16
- const [activeOrganizationId, setActiveOrganizationId] = useState("");
17
- const [isEventStreamAvailable, setEventStreamAvailable] = useState(false);
18
- const config = useContext(C3UserConfigurationContext);
19
- const enabled = !!config;
20
- // if the organization changes, we need to reset the state
21
- if (enabled && config.activeOrganizationId !== activeOrganizationId) {
22
- setActiveOrganizationId(config.activeOrganizationId);
23
- setFetched(false);
24
- setNotifications([]);
25
- }
26
- if (enabled && !isFetched && config.userToken) {
27
- NotificationService.getNotifications(config).then((response) => {
28
- setNotifications(response);
29
- setFetched(true);
30
- });
31
- }
32
- if (enabled && isFetched && !isEventStreamAvailable) {
33
- setEventStreamAvailable(true);
34
- NotificationService.notificationsStream(config, (notification) => {
35
- if (notification.orgId === activeOrganizationId) {
36
- setNotifications((allNotifications) => NotificationService.updateNotifications(allNotifications, notification));
37
- }
38
- });
39
- }
40
- useEffect(() => {
41
- if (enabled && config.userToken) {
42
- NotificationService.getNotifications(config).then((response) => {
43
- setNotifications(response);
44
- setFetched(true);
45
- });
46
- }
47
- }, [config?.userToken]);
48
- const changeState = (newState, { uuid, state }) => {
49
- if (enabled && state !== newState) {
50
- setNotifications((allNotifications) => NotificationService.updateNotificationState(allNotifications, uuid, newState));
51
- NotificationService.changeState(config, uuid, newState);
52
- }
53
- };
54
- const changeManyStates = (newState, notifications) => {
55
- if (enabled) {
56
- const notificationIds = notifications
57
- .filter((notification) => notification.state !== newState)
58
- .map((notification) => notification.uuid);
59
- if (notificationIds.length > 0) {
60
- setNotifications((allNotifications) => NotificationService.updateNotificationStates(allNotifications, notificationIds, newState));
61
- NotificationService.changeManyStates(config, notificationIds, newState);
62
- }
63
- }
64
- };
65
- const markAsRead = (notification) => changeState("read", notification);
66
- const markAllAsRead = (notifications) => changeManyStates("read", notifications);
67
- const dismiss = (notification) => changeState("dismiss", notification);
68
- const dismissAll = (notifications) => changeManyStates("dismiss", notifications);
69
- const analytics = (event, id) => {
70
- if (enabled && config.userToken) {
71
- NotificationService.sendAnalyticsEvent(config, {
72
- event,
73
- id,
74
- });
75
- }
76
- };
77
- return (React.createElement(C3NotificationContext.Provider, { value: {
78
- enabled,
79
- notifications,
80
- markAsRead,
81
- markAllAsRead,
82
- dismiss,
83
- dismissAll,
84
- analytics,
85
- } }, children));
86
- };
5
+ enabled: false,
6
+ notifications: [],
7
+ markAsRead: () => undefined,
8
+ markAllAsRead: () => undefined,
9
+ dismiss: () => undefined,
10
+ dismissAll: () => undefined,
11
+ analytics: () => undefined,
12
+ })
13
+ const C3NotificationProvider = ({ children }) => {
14
+ const [notifications, setNotifications] = useState([])
15
+ const [isFetched, setFetched] = useState(false)
16
+ const [activeOrganizationId, setActiveOrganizationId] = useState("")
17
+ const [isEventStreamAvailable, setEventStreamAvailable] = useState(false)
18
+ const config = useContext(C3UserConfigurationContext)
19
+ const enabled = !!config
20
+ // if the organization changes, we need to reset the state
21
+ if (enabled && config.activeOrganizationId !== activeOrganizationId) {
22
+ setActiveOrganizationId(config.activeOrganizationId)
23
+ setFetched(false)
24
+ setNotifications([])
25
+ }
26
+ if (enabled && !isFetched && config.userToken) {
27
+ NotificationService.getNotifications(config).then((response) => {
28
+ setNotifications(response)
29
+ setFetched(true)
30
+ })
31
+ }
32
+ if (enabled && isFetched && !isEventStreamAvailable) {
33
+ setEventStreamAvailable(true)
34
+ NotificationService.notificationsStream(config, (notification) => {
35
+ if (notification.orgId === activeOrganizationId) {
36
+ setNotifications((allNotifications) =>
37
+ NotificationService.updateNotifications(
38
+ allNotifications,
39
+ notification,
40
+ ),
41
+ )
42
+ }
43
+ })
44
+ }
45
+ useEffect(() => {
46
+ if (enabled && config.userToken) {
47
+ NotificationService.getNotifications(config).then((response) => {
48
+ setNotifications(response)
49
+ setFetched(true)
50
+ })
51
+ }
52
+ }, [config?.userToken])
53
+ const changeState = (newState, { uuid, state }) => {
54
+ if (enabled && state !== newState) {
55
+ setNotifications((allNotifications) =>
56
+ NotificationService.updateNotificationState(
57
+ allNotifications,
58
+ uuid,
59
+ newState,
60
+ ),
61
+ )
62
+ NotificationService.changeState(config, uuid, newState)
63
+ }
64
+ }
65
+ const changeManyStates = (newState, notifications) => {
66
+ if (enabled) {
67
+ const notificationIds = notifications
68
+ .filter((notification) => notification.state !== newState)
69
+ .map((notification) => notification.uuid)
70
+ if (notificationIds.length > 0) {
71
+ setNotifications((allNotifications) =>
72
+ NotificationService.updateNotificationStates(
73
+ allNotifications,
74
+ notificationIds,
75
+ newState,
76
+ ),
77
+ )
78
+ NotificationService.changeManyStates(config, notificationIds, newState)
79
+ }
80
+ }
81
+ }
82
+ const markAsRead = (notification) => changeState("read", notification)
83
+ const markAllAsRead = (notifications) =>
84
+ changeManyStates("read", notifications)
85
+ const dismiss = (notification) => changeState("dismiss", notification)
86
+ const dismissAll = (notifications) =>
87
+ changeManyStates("dismiss", notifications)
88
+ const analytics = (event, id) => {
89
+ if (enabled && config.userToken) {
90
+ NotificationService.sendAnalyticsEvent(config, {
91
+ event,
92
+ id,
93
+ })
94
+ }
95
+ }
96
+ return React.createElement(
97
+ C3NotificationContext.Provider,
98
+ {
99
+ value: {
100
+ enabled,
101
+ notifications,
102
+ markAsRead,
103
+ markAllAsRead,
104
+ dismiss,
105
+ dismissAll,
106
+ analytics,
107
+ },
108
+ },
109
+ children,
110
+ )
111
+ }
87
112
  export function withNotifications(Component) {
88
- return function WithNamespace(props) {
89
- return (React.createElement(C3NotificationProvider, null,
90
- React.createElement(Component, { ...props })));
91
- };
113
+ return function WithNamespace(props) {
114
+ return React.createElement(
115
+ C3NotificationProvider,
116
+ null,
117
+ React.createElement(Component, { ...props }),
118
+ )
119
+ }
92
120
  }
93
- export default C3NotificationProvider;
121
+ export default C3NotificationProvider
@@ -1,3 +1,5 @@
1
- export declare function useOnClickOutside(handler: (e: Event) => void): ((node: unknown) => void)[];
2
- export declare function executeMediaQuery(mediaQuery: string): MediaQueryList;
3
- export declare function useMediaQuery(mediaQuery: string): boolean;
1
+ export declare function useOnClickOutside(
2
+ handler: (e: Event) => void,
3
+ ): ((node: unknown) => void)[]
4
+ export declare function executeMediaQuery(mediaQuery: string): MediaQueryList
5
+ export declare function useMediaQuery(mediaQuery: string): boolean
@@ -1,55 +1,59 @@
1
- import { useCallback, useEffect, useRef, useState } from "react";
1
+ import { useCallback, useEffect, useRef, useState } from "react"
2
2
  export function useOnClickOutside(handler) {
3
- const panelRef = useRef(null);
4
- const iconRef = useRef(null);
5
- const listener = (event) => {
6
- if (!panelRef.current ||
7
- !iconRef.current ||
8
- (event.target instanceof Node &&
9
- (panelRef.current.contains(event.target) ||
10
- iconRef.current.contains(event.target)))) {
11
- return;
12
- }
13
- handler(event);
14
- };
15
- const setListener = () => {
16
- document.addEventListener("mousedown", listener);
17
- document.addEventListener("touchstart", listener);
18
- };
19
- useEffect(() => {
20
- return () => {
21
- document.removeEventListener("mousedown", listener);
22
- document.removeEventListener("touchstart", listener);
23
- };
24
- }, []);
25
- const setPanelRef = useCallback((node) => {
26
- if (node && node instanceof HTMLElement) {
27
- panelRef.current = node;
28
- setListener();
29
- }
30
- }, []);
31
- const setIconRef = useCallback((node) => {
32
- if (node && node instanceof HTMLElement) {
33
- iconRef.current = node;
34
- setListener();
35
- }
36
- }, []);
37
- return [setPanelRef, setIconRef];
3
+ const panelRef = useRef(null)
4
+ const iconRef = useRef(null)
5
+ const listener = (event) => {
6
+ if (
7
+ !panelRef.current ||
8
+ !iconRef.current ||
9
+ (event.target instanceof Node &&
10
+ (panelRef.current.contains(event.target) ||
11
+ iconRef.current.contains(event.target)))
12
+ ) {
13
+ return
14
+ }
15
+ handler(event)
16
+ }
17
+ const setListener = () => {
18
+ document.addEventListener("mousedown", listener)
19
+ document.addEventListener("touchstart", listener)
20
+ }
21
+ useEffect(() => {
22
+ return () => {
23
+ document.removeEventListener("mousedown", listener)
24
+ document.removeEventListener("touchstart", listener)
25
+ }
26
+ }, [])
27
+ const setPanelRef = useCallback((node) => {
28
+ if (node && node instanceof HTMLElement) {
29
+ panelRef.current = node
30
+ setListener()
31
+ }
32
+ }, [])
33
+ const setIconRef = useCallback((node) => {
34
+ if (node && node instanceof HTMLElement) {
35
+ iconRef.current = node
36
+ setListener()
37
+ }
38
+ }, [])
39
+ return [setPanelRef, setIconRef]
38
40
  }
39
41
  export function executeMediaQuery(mediaQuery) {
40
- return window.matchMedia(mediaQuery);
42
+ return window.matchMedia(mediaQuery)
41
43
  }
42
44
  export function useMediaQuery(mediaQuery) {
43
- const [isMatched, setIsMatched] = useState(executeMediaQuery(mediaQuery).matches);
44
- useEffect(() => {
45
- const query = executeMediaQuery(mediaQuery);
46
- const listener = (event) => {
47
- setIsMatched(event.matches);
48
- };
49
- query.addEventListener("change", listener);
50
- return () => {
51
- query.removeEventListener("change", listener);
52
- };
53
- }, []);
54
- return isMatched;
45
+ const [isMatched, setIsMatched] = useState(
46
+ executeMediaQuery(mediaQuery).matches,
47
+ )
48
+ useEffect(() => {
49
+ const query = executeMediaQuery(mediaQuery)
50
+ const listener = (event) => {
51
+ setIsMatched(event.matches)
52
+ }
53
+ query.addEventListener("change", listener)
54
+ return () => {
55
+ query.removeEventListener("change", listener)
56
+ }
57
+ }, [])
58
+ return isMatched
55
59
  }
@@ -1,3 +1,5 @@
1
1
  /// <reference types="react" />
2
- declare const _default: import("react").ComponentType<import("./c3-navigation.types").C3NavigationProps>;
3
- export default _default;
2
+ declare const _default: import("react").ComponentType<
3
+ import("./c3-navigation.types").C3NavigationProps
4
+ >
5
+ export default _default
@@ -1,3 +1,3 @@
1
- import { C3Navigation } from "./c3-navigation";
2
- import { withNotifications } from "./c3-notification-provider/c3-notification-provider";
3
- export default withNotifications(C3Navigation);
1
+ import { C3Navigation } from "./c3-navigation"
2
+ import { withNotifications } from "./c3-notification-provider/c3-notification-provider"
3
+ export default withNotifications(C3Navigation)