@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
package/README.md CHANGED
@@ -53,4 +53,5 @@ return (
53
53
 
54
54
  ## <a name="c4list"></a> (incomplete) List of adopters of C3+C4
55
55
 
56
- - [console-team](https://confluence.camunda.com/display/HAN/Console+Team) started this, their C4 repo can be found [here](https://github.com/camunda-cloud/camunda-console-composite-components)
56
+ - [Console team](https://confluence.camunda.com/display/HAN/Console+Team) started this, their C4 repo can be found [here](https://github.com/camunda-cloud/camunda-cloud-management-apps/tree/main/packages/c4)
57
+ - [Identity team](https://github.com/camunda/team-identity): [c4-identity](https://github.com/camunda-cloud/c4-identity)
@@ -1,23 +1,23 @@
1
- import { Endpoints, Stage } from "./endpoints.const";
1
+ import { Endpoints, Stage } from "./endpoints.const"
2
2
  export declare class HttpError extends Error {
3
- status: number;
4
- constructor(message: string, status: number);
3
+ status: number
4
+ constructor(message: string, status: number)
5
5
  }
6
6
  export interface RequestPayload {
7
- base?: "notifications";
8
- stage?: Stage;
9
- endpoints?: Endpoints;
10
- url: string;
11
- method: "get" | "post" | "put" | "delete" | "patch";
12
- headers?: {
13
- [key: string]: string;
14
- };
15
- type?: "json" | "text" | "none";
16
- responseType?: "json" | "text" | "none";
17
- camundaAuth?: {
18
- token: string;
19
- refreshTokenMethod: () => Promise<string>;
20
- };
21
- body?: any;
7
+ base?: "notifications"
8
+ stage?: Stage
9
+ endpoints?: Endpoints
10
+ url: string
11
+ method: "get" | "post" | "put" | "delete" | "patch"
12
+ headers?: {
13
+ [key: string]: string
14
+ }
15
+ type?: "json" | "text" | "none"
16
+ responseType?: "json" | "text" | "none"
17
+ camundaAuth?: {
18
+ token: string
19
+ refreshTokenMethod: () => Promise<string>
20
+ }
21
+ body?: any
22
22
  }
23
- export declare function request(payload: RequestPayload): Promise<any>;
23
+ export declare function request(payload: RequestPayload): Promise<any>
@@ -1,71 +1,69 @@
1
- import { getEndpoint, NOTIFICATIONS } from "./endpoints.const";
2
- import { JWTUtils } from "./jwt.utils";
1
+ import { getEndpoint, NOTIFICATIONS } from "./endpoints.const"
2
+ import { JWTUtils } from "./jwt.utils"
3
3
  export class HttpError extends Error {
4
- status;
5
- constructor(message, status) {
6
- super(message);
7
- this.status = status;
8
- }
4
+ status
5
+ constructor(message, status) {
6
+ super(message)
7
+ this.status = status
8
+ }
9
9
  }
10
10
  export async function request(payload) {
11
- const headers = {};
12
- if (payload.camundaAuth) {
13
- if (JWTUtils.isExpired(payload.camundaAuth.token)) {
14
- const newToken = await payload.camundaAuth.refreshTokenMethod();
15
- headers.Authorization = `Bearer ${newToken}`;
16
- }
17
- else {
18
- headers.Authorization = `Bearer ${payload.camundaAuth.token}`;
19
- }
20
- }
21
- const type = payload.type ?? "json";
22
- if (type) {
23
- switch (type) {
24
- case "json":
25
- headers["Content-Type"] = "application/json";
26
- break;
27
- case "text":
28
- headers["Content-Type"] = "text/plain";
29
- break;
30
- }
31
- }
32
- const body = payload.body ? JSON.stringify(payload.body) : undefined;
33
- let base;
34
- if (payload.base) {
35
- switch (payload.base) {
36
- case "notifications":
37
- if (payload.endpoints?.notifications) {
38
- base = payload.endpoints.notifications;
39
- }
40
- else if (payload.stage) {
41
- base = getEndpoint(payload.stage, NOTIFICATIONS);
42
- }
43
- break;
44
- }
45
- }
46
- const url = base ? `${base}/${payload.url}` : payload.url;
47
- const response = await fetch(url, {
48
- method: payload.method.toUpperCase(),
49
- headers,
50
- body,
51
- });
52
- let success = true;
53
- if (response.status >= 400 && response.status < 500) {
54
- success = false;
55
- }
56
- if (response.status >= 500) {
57
- success = false;
58
- }
59
- if (!success) {
60
- throw new HttpError(response.statusText, response.status);
61
- }
62
- const responseType = payload.responseType ?? type;
63
- switch (responseType) {
64
- case "json":
65
- return response.json();
66
- case "text":
67
- return response.text();
68
- default:
69
- return response;
70
- }
11
+ const headers = {}
12
+ if (payload.camundaAuth) {
13
+ if (JWTUtils.isExpired(payload.camundaAuth.token)) {
14
+ const newToken = await payload.camundaAuth.refreshTokenMethod()
15
+ headers.Authorization = `Bearer ${newToken}`
16
+ } else {
17
+ headers.Authorization = `Bearer ${payload.camundaAuth.token}`
18
+ }
19
+ }
20
+ const type = payload.type ?? "json"
21
+ if (type) {
22
+ switch (type) {
23
+ case "json":
24
+ headers["Content-Type"] = "application/json"
25
+ break
26
+ case "text":
27
+ headers["Content-Type"] = "text/plain"
28
+ break
29
+ }
30
+ }
31
+ const body = payload.body ? JSON.stringify(payload.body) : undefined
32
+ let base
33
+ if (payload.base) {
34
+ switch (payload.base) {
35
+ case "notifications":
36
+ if (payload.endpoints?.notifications) {
37
+ base = payload.endpoints.notifications
38
+ } else if (payload.stage) {
39
+ base = getEndpoint(payload.stage, NOTIFICATIONS)
40
+ }
41
+ break
42
+ }
43
+ }
44
+ const url = base ? `${base}/${payload.url}` : payload.url
45
+ const response = await fetch(url, {
46
+ method: payload.method.toUpperCase(),
47
+ headers,
48
+ body,
49
+ })
50
+ let success = true
51
+ if (response.status >= 400 && response.status < 500) {
52
+ success = false
53
+ }
54
+ if (response.status >= 500) {
55
+ success = false
56
+ }
57
+ if (!success) {
58
+ throw new HttpError(response.statusText, response.status)
59
+ }
60
+ const responseType = payload.responseType ?? type
61
+ switch (responseType) {
62
+ case "json":
63
+ return response.json()
64
+ case "text":
65
+ return response.text()
66
+ default:
67
+ return response
68
+ }
71
69
  }
@@ -1,17 +1,17 @@
1
1
  export interface Endpoint {
2
- id: string;
3
- dev: string;
4
- int: string;
5
- prod: string;
2
+ id: string
3
+ dev: string
4
+ int: string
5
+ prod: string
6
6
  }
7
7
  export interface Endpoints {
8
- notifications?: string;
8
+ notifications?: string
9
9
  }
10
- export declare const NOTIFICATIONS: Endpoint;
11
- export declare type Stage = "dev" | "int" | "prod";
12
- export declare function getEndpoint(stage: Stage, endpoint: Endpoint): string;
10
+ export declare const NOTIFICATIONS: Endpoint
11
+ export declare type Stage = "dev" | "int" | "prod"
12
+ export declare function getEndpoint(stage: Stage, endpoint: Endpoint): string
13
13
  export declare function getEndpointByOptions(options: {
14
- stage?: Stage;
15
- endpoints?: Endpoints;
16
- endpoint: Endpoint;
17
- }): string;
14
+ stage?: Stage
15
+ endpoints?: Endpoints
16
+ endpoint: Endpoint
17
+ }): string
@@ -1,30 +1,29 @@
1
1
  export const NOTIFICATIONS = {
2
- id: "notifications",
3
- dev: "https://notifications.cloud.dev.ultrawombat.com",
4
- int: "https://notifications.cloud.ultrawombat.com",
5
- prod: "https://notifications.cloud.camunda.io",
6
- };
2
+ id: "notifications",
3
+ dev: "https://notifications.cloud.dev.ultrawombat.com",
4
+ int: "https://notifications.cloud.ultrawombat.com",
5
+ prod: "https://notifications.cloud.camunda.io",
6
+ }
7
7
  export function getEndpoint(stage, endpoint) {
8
- switch (stage) {
9
- case "dev":
10
- return endpoint.dev;
11
- case "int":
12
- return endpoint.int;
13
- case "prod":
14
- return endpoint.prod;
15
- default:
16
- throw new Error(`Unknown stage: ${stage}`);
17
- }
8
+ switch (stage) {
9
+ case "dev":
10
+ return endpoint.dev
11
+ case "int":
12
+ return endpoint.int
13
+ case "prod":
14
+ return endpoint.prod
15
+ default:
16
+ throw new Error(`Unknown stage: ${stage}`)
17
+ }
18
18
  }
19
19
  export function getEndpointByOptions(options) {
20
- switch (options.endpoint.id) {
21
- case "notifications":
22
- if (options.endpoints?.notifications) {
23
- return options.endpoints.notifications;
24
- }
25
- else if (options.stage) {
26
- return getEndpoint(options.stage, options.endpoint);
27
- }
28
- }
29
- throw new Error(`Missing stage or notifications endpoint`);
20
+ switch (options.endpoint.id) {
21
+ case "notifications":
22
+ if (options.endpoints?.notifications) {
23
+ return options.endpoints.notifications
24
+ } else if (options.stage) {
25
+ return getEndpoint(options.stage, options.endpoint)
26
+ }
27
+ }
28
+ throw new Error(`Missing stage or notifications endpoint`)
30
29
  }
@@ -1,5 +1,5 @@
1
1
  export declare class JWTUtils {
2
- static decode(token: string): any;
3
- static getExpiration(token: string): number;
4
- static isExpired(token: string): boolean;
2
+ static decode(token: string): any
3
+ static getExpiration(token: string): number
4
+ static isExpired(token: string): boolean
5
5
  }
@@ -1,23 +1,25 @@
1
1
  export class JWTUtils {
2
- static decode(token) {
3
- const base64Url = token.split(".")[1];
4
- const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
5
- const jsonPayload = decodeURIComponent(window
6
- .atob(base64)
7
- .split("")
8
- .map(function (c) {
9
- return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
10
- })
11
- .join(""));
12
- return JSON.parse(jsonPayload);
13
- }
14
- static getExpiration(token) {
15
- const decoded = JWTUtils.decode(token);
16
- return decoded.exp;
17
- }
18
- static isExpired(token) {
19
- const expiration = JWTUtils.getExpiration(token);
20
- const now = new Date().getTime() / 1000;
21
- return expiration < now;
22
- }
2
+ static decode(token) {
3
+ const base64Url = token.split(".")[1]
4
+ const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/")
5
+ const jsonPayload = decodeURIComponent(
6
+ window
7
+ .atob(base64)
8
+ .split("")
9
+ .map(function (c) {
10
+ return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2)
11
+ })
12
+ .join(""),
13
+ )
14
+ return JSON.parse(jsonPayload)
15
+ }
16
+ static getExpiration(token) {
17
+ const decoded = JWTUtils.decode(token)
18
+ return decoded.exp
19
+ }
20
+ static isExpired(token) {
21
+ const expiration = JWTUtils.getExpiration(token)
22
+ const now = new Date().getTime() / 1000
23
+ return expiration < now
24
+ }
23
25
  }
@@ -1,39 +1,68 @@
1
- import { C3NotificationsProps } from "../components/c3-navigation/c3-navigation.types";
1
+ import { C3NotificationsProps } from "../components/c3-navigation/c3-navigation.types"
2
2
  export interface Notification {
3
- uuid: string;
4
- userId?: string;
5
- orgId?: string;
6
- timestamp: number;
7
- source: string;
8
- type: string;
9
- title: string;
10
- description: string;
11
- state: string;
12
- meta?: {
13
- identifier?: string;
14
- href?: string;
15
- label?: string;
16
- entity?: {
17
- id: string;
18
- type: string;
19
- };
20
- parentEntity?: {
21
- id: string;
22
- type: string;
23
- };
24
- };
3
+ uuid: string
4
+ userId?: string
5
+ orgId?: string
6
+ timestamp: number
7
+ source: string
8
+ type: string
9
+ title: string
10
+ description: string
11
+ state: string
12
+ meta?: {
13
+ identifier?: string
14
+ href?: string
15
+ label?: string
16
+ entity?: {
17
+ id: string
18
+ type: string
19
+ }
20
+ parentEntity?: {
21
+ id: string
22
+ type: string
23
+ }
24
+ }
25
25
  }
26
- export declare type AnalyticsEvent = "notification-panel-opened" | "notification-clicked-cta";
26
+ export declare type AnalyticsEvent =
27
+ | "notification-panel-opened"
28
+ | "notification-clicked-cta"
27
29
  export declare class NotificationService {
28
- static getNotifications(options: C3NotificationsProps): Promise<Notification[]>;
29
- static sendAnalyticsEvent(options: C3NotificationsProps, eventOptions: {
30
- event: AnalyticsEvent;
31
- id?: string;
32
- }): void;
33
- static changeState(options: C3NotificationsProps, notificationId: string, operation: "read" | "dismiss"): void;
34
- static changeManyStates(options: C3NotificationsProps, notificationIds: string[], operation: "read" | "dismiss"): void;
35
- static notificationsStream(options: C3NotificationsProps, handler: (notification: Notification) => void): void;
36
- static updateNotifications(allNotifications: Notification[], newNotification: Notification): Notification[];
37
- static updateNotificationState(allNotifications: Notification[], notificationId: string, newState: "read" | "dismiss"): Notification[];
38
- static updateNotificationStates(allNotifications: Notification[], notificationIds: string[], newState: "read" | "dismiss"): Notification[];
30
+ static getNotifications(
31
+ options: C3NotificationsProps,
32
+ ): Promise<Notification[]>
33
+ static sendAnalyticsEvent(
34
+ options: C3NotificationsProps,
35
+ eventOptions: {
36
+ event: AnalyticsEvent
37
+ id?: string
38
+ },
39
+ ): void
40
+ static changeState(
41
+ options: C3NotificationsProps,
42
+ notificationId: string,
43
+ operation: "read" | "dismiss",
44
+ ): void
45
+ static changeManyStates(
46
+ options: C3NotificationsProps,
47
+ notificationIds: string[],
48
+ operation: "read" | "dismiss",
49
+ ): void
50
+ static notificationsStream(
51
+ options: C3NotificationsProps,
52
+ handler: (notification: Notification) => void,
53
+ ): void
54
+ static updateNotifications(
55
+ allNotifications: Notification[],
56
+ newNotification: Notification,
57
+ ): Notification[]
58
+ static updateNotificationState(
59
+ allNotifications: Notification[],
60
+ notificationId: string,
61
+ newState: "read" | "dismiss",
62
+ ): Notification[]
63
+ static updateNotificationStates(
64
+ allNotifications: Notification[],
65
+ notificationIds: string[],
66
+ newState: "read" | "dismiss",
67
+ ): Notification[]
39
68
  }