@camunda/ccma-saas-frontend 0.3.1 → 0.4.0

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 (50) hide show
  1. package/lib/esm/components/c4-activity-graph/c4-activity-graph.d.ts +2 -2
  2. package/lib/esm/components/c4-activity-graph/c4-activity-graph.js +90 -73
  3. package/lib/esm/components/c4-advanced-search-filters/c4-advanced-search-filters.js +13 -13
  4. package/lib/esm/components/c4-billing-page/elements/current-usage-metrics.js +7 -1
  5. package/lib/esm/components/c4-charts-dashboard/c4-charts-dashboard.d.ts +1 -1
  6. package/lib/esm/components/c4-charts-dashboard/c4-charts-dashboard.js +31 -25
  7. package/lib/esm/components/c4-cluster-details-activity/c4-cluster-details-activity.js +11 -8
  8. package/lib/esm/components/c4-cluster-details-clients/c4-cluster-details-clients.d.ts +1 -1
  9. package/lib/esm/components/c4-cluster-details-clients/c4-cluster-details-clients.js +21 -20
  10. package/lib/esm/components/c4-cluster-details-secure-connectivity/c4-cluster-details-secure-connectivity.js +10 -2
  11. package/lib/esm/components/c4-cluster-overview/applications.js +7 -1
  12. package/lib/esm/components/c4-cluster-tag-selector/c4-cluster-tag-selector.js +7 -1
  13. package/lib/esm/components/c4-data-table/c4-data-table.js +58 -4
  14. package/lib/esm/components/c4-data-table/c4-data-table.spec.js +52 -1
  15. package/lib/esm/components/c4-management-activity/c4-management-activity.d.ts +1 -1
  16. package/lib/esm/components/c4-management-activity/c4-management-activity.js +9 -4
  17. package/lib/esm/components/c4-management-settings/c4-management-settings.d.ts +1 -1
  18. package/lib/esm/components/c4-management-settings/c4-management-settings.js +9 -5
  19. package/lib/esm/components/c4-stackdriver-links/c4-stackdriver-links.js +3 -4
  20. package/lib/esm/components/c4-usage-history/c4-usage-history.d.ts +1 -1
  21. package/lib/esm/components/c4-usage-history/c4-usage-history.js +5 -2
  22. package/lib/esm/components/c4-usage-history/elements/usage-history-charts.d.ts +2 -2
  23. package/lib/esm/components/c4-usage-history/elements/usage-history-charts.js +6 -2
  24. package/lib/esm/components/c4-usage-metrics-per-cluster/c4-usage-metrics-per-cluster.d.ts +1 -1
  25. package/lib/esm/components/c4-usage-metrics-per-cluster/c4-usage-metrics-per-cluster.js +14 -8
  26. package/lib/esm/runtime/c4-console-data-context.d.ts +17 -5
  27. package/lib/esm/runtime/c4-console-data-context.js +40 -15
  28. package/lib/esm/runtime/c4-console-data-context.spec.d.ts +1 -0
  29. package/lib/esm/runtime/c4-console-data-context.spec.js +354 -0
  30. package/lib/esm/runtime/c4-console-data-context.types.d.ts +6 -0
  31. package/lib/esm/runtime/c4-console-data-store.d.ts +11 -0
  32. package/lib/esm/runtime/c4-console-data-store.js +74 -34
  33. package/lib/esm/runtime/c4-console-data-store.nav.spec.js +1 -0
  34. package/lib/esm/runtime/c4-console-data-store.spec.js +147 -1
  35. package/lib/esm/runtime/c4-user-notifications-context.spec.js +2 -0
  36. package/lib/esm/runtime/nav/use-webapp-nav-data.js +11 -3
  37. package/lib/esm/runtime/to-api-config.d.ts +1 -1
  38. package/lib/esm/runtime/to-api-config.js +6 -0
  39. package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-connector-secrets-tab.d.ts +3 -1
  40. package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-connector-secrets-tab.js +6 -1
  41. package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-hot-backups-tab.d.ts +3 -1
  42. package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-hot-backups-tab.js +5 -1
  43. package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-overview-tab.d.ts +3 -1
  44. package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-overview-tab.js +5 -1
  45. package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-secure-connectivity-tab.d.ts +3 -1
  46. package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-secure-connectivity-tab.js +5 -1
  47. package/lib/esm/widgets/clusters/c4-clusters-page.spec.js +1 -1
  48. package/lib/esm/widgets/connector-management/c4-connector-management.shared.js +12 -3
  49. package/lib/esm/widgets/dashboard/c4-dashboard-app.js +24 -6
  50. package/package.json +7 -4
@@ -1,3 +1,3 @@
1
- import type { JSX } from 'react';
1
+ import { type JSX } from 'react';
2
2
  import type { C4ActivityGraphProps } from './c4-activity-graph.types';
3
- export declare const C4ActivityGraph: ({ dataPoints, options, }: C4ActivityGraphProps) => JSX.Element;
3
+ export declare const C4ActivityGraph: import("react").MemoExoticComponent<({ dataPoints, options, }: C4ActivityGraphProps) => JSX.Element>;
@@ -1,86 +1,102 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- export const C4ActivityGraph = ({ dataPoints, options, }) => {
2
+ /*
3
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
4
+ * under one or more contributor license agreements. Licensed under a commercial license.
5
+ * You may not use this file except in compliance with the commercial license.
6
+ */
7
+ import { memo, useMemo } from 'react';
8
+ const DAY = 24 * 60 * 60 * 1000;
9
+ const getDayOfWeek = (date) => {
10
+ const dayOfWeek = date.getDay();
11
+ return dayOfWeek === 0 ? 6 : dayOfWeek - 1;
12
+ };
13
+ const colors = ['#edf5ff', '#a6c8ff', '#4589ff', '#0f62fe', '#0043ce'];
14
+ const DAYS = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
15
+ const MONTHS = [
16
+ 'Jan',
17
+ 'Feb',
18
+ 'Mar',
19
+ 'Apr',
20
+ 'May',
21
+ 'Jun',
22
+ 'Jul',
23
+ 'Aug',
24
+ 'Sep',
25
+ 'Oct',
26
+ 'Nov',
27
+ 'Dec',
28
+ ];
29
+ const C4ActivityGraphComponent = ({ dataPoints, options, }) => {
3
30
  const componentOptions = {
4
31
  lastWeeks: options?.lastWeeks ?? 25,
5
32
  width: options?.width ?? '100%',
6
33
  height: options?.height ?? '300px',
7
34
  gap: options?.gap ?? '0.5rem',
8
35
  };
9
- const getDayOfWeek = (date) => {
10
- const dayOfWeek = date.getDay();
11
- return dayOfWeek === 0 ? 6 : dayOfWeek - 1;
12
- };
13
- // calculate aggregated data points
14
- const DAY = 24 * 60 * 60 * 1000;
15
- let currentStart = new Date();
16
- currentStart.setHours(0, 0, 0, 0);
17
- const currentDayOfWeek = getDayOfWeek(currentStart);
18
- const numberOfDays = componentOptions.lastWeeks * 7 - (7 - currentDayOfWeek);
19
- const activityDataPoints = [];
20
- let currentWeek = -1;
21
- let weekIndex = componentOptions.lastWeeks;
22
- let months = [];
23
- let currentMonth = -1;
24
- let maxActivities = 0;
25
- for (let i = 0; i < numberOfDays; i++) {
26
- const range = {
27
- start: currentStart.getTime(),
28
- end: currentStart.getTime() + DAY,
29
- };
30
- const dayOfWeek = getDayOfWeek(currentStart);
31
- if (currentWeek < 0) {
32
- currentWeek = Math.ceil((currentStart.getTime() -
33
- new Date(currentStart.getFullYear(), 0, 1).getTime()) /
34
- DAY /
35
- 7);
36
+ // Aggregating ~25 weeks of activity is O(days × dataPoints); memoize it so it
37
+ // only re-runs when the inputs change, not on every parent re-render.
38
+ const { activityDataPoints, months, maxActivities } = useMemo(() => {
39
+ const lastWeeks = componentOptions.lastWeeks;
40
+ let currentStart = new Date();
41
+ currentStart.setHours(0, 0, 0, 0);
42
+ const currentDayOfWeek = getDayOfWeek(currentStart);
43
+ const numberOfDays = lastWeeks * 7 - (7 - currentDayOfWeek);
44
+ const aggregated = [];
45
+ let currentWeek = -1;
46
+ let weekIndex = lastWeeks;
47
+ let monthMarkers = [];
48
+ let currentMonth = -1;
49
+ let maxCount = 0;
50
+ for (let i = 0; i < numberOfDays; i++) {
51
+ const range = {
52
+ start: currentStart.getTime(),
53
+ end: currentStart.getTime() + DAY,
54
+ };
55
+ const dayOfWeek = getDayOfWeek(currentStart);
56
+ if (currentWeek < 0) {
57
+ currentWeek = Math.ceil((currentStart.getTime() -
58
+ new Date(currentStart.getFullYear(), 0, 1).getTime()) /
59
+ DAY /
60
+ 7);
61
+ }
62
+ if (dayOfWeek === 6) {
63
+ weekIndex--;
64
+ currentWeek--;
65
+ }
66
+ const dataPoint = {
67
+ index: numberOfDays - i,
68
+ range,
69
+ dataPoints: dataPoints.filter((dataPoint) => dataPoint.timestamp >= range.start &&
70
+ dataPoint.timestamp < range.end),
71
+ dayOfWeek,
72
+ weekOfYear: currentWeek,
73
+ grid: {
74
+ x: weekIndex,
75
+ y: dayOfWeek,
76
+ },
77
+ };
78
+ maxCount = Math.max(maxCount, dataPoint.dataPoints.length);
79
+ aggregated.push(dataPoint);
80
+ currentStart = new Date(currentStart.getTime() - DAY);
36
81
  }
37
- if (dayOfWeek === 6) {
38
- weekIndex--;
39
- currentWeek--;
82
+ aggregated.reverse();
83
+ for (const dataPoint of aggregated) {
84
+ const start = new Date(dataPoint.range.start);
85
+ if (currentMonth < 0 || currentMonth !== start.getMonth()) {
86
+ currentMonth = start.getMonth();
87
+ monthMarkers = monthMarkers.filter((month) => month.column !== dataPoint.grid.x);
88
+ monthMarkers.push({
89
+ month: currentMonth,
90
+ column: dataPoint.grid.x,
91
+ });
92
+ }
40
93
  }
41
- const dataPoint = {
42
- index: numberOfDays - i,
43
- range,
44
- dataPoints: dataPoints.filter((dataPoint) => dataPoint.timestamp >= range.start && dataPoint.timestamp < range.end),
45
- dayOfWeek,
46
- weekOfYear: currentWeek,
47
- grid: {
48
- x: weekIndex,
49
- y: dayOfWeek,
50
- },
94
+ return {
95
+ activityDataPoints: aggregated,
96
+ months: monthMarkers,
97
+ maxActivities: maxCount,
51
98
  };
52
- maxActivities = Math.max(maxActivities, dataPoint.dataPoints.length);
53
- activityDataPoints.push(dataPoint);
54
- currentStart = new Date(currentStart.getTime() - DAY);
55
- }
56
- activityDataPoints.reverse();
57
- for (const dataPoint of activityDataPoints) {
58
- const currentStart = new Date(dataPoint.range.start);
59
- if (currentMonth < 0 || currentMonth !== currentStart.getMonth()) {
60
- currentMonth = currentStart.getMonth();
61
- months = months.filter((month) => month.column !== dataPoint.grid.x);
62
- months.push({
63
- month: currentMonth,
64
- column: dataPoint.grid.x,
65
- });
66
- }
67
- }
68
- const colors = ['#edf5ff', '#a6c8ff', '#4589ff', '#0f62fe', '#0043ce'];
69
- const DAYS = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
70
- const MONTHS = [
71
- 'Jan',
72
- 'Feb',
73
- 'Mar',
74
- 'Apr',
75
- 'May',
76
- 'Jun',
77
- 'Jul',
78
- 'Aug',
79
- 'Sep',
80
- 'Oct',
81
- 'Nov',
82
- 'Dec',
83
- ];
99
+ }, [dataPoints, componentOptions.lastWeeks]);
84
100
  const component = (_jsxs("div", { style: {
85
101
  display: 'grid',
86
102
  gridTemplateRows: 'repeat(9, 1fr)',
@@ -133,3 +149,4 @@ export const C4ActivityGraph = ({ dataPoints, options, }) => {
133
149
  // TODO: Add component content
134
150
  return component;
135
151
  };
152
+ export const C4ActivityGraph = memo(C4ActivityGraphComponent);
@@ -5,7 +5,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
5
5
  * You may not use this file except in compliance with the commercial license.
6
6
  */
7
7
  import { Add } from '@carbon/react/icons/index.esm.js';
8
- import { useCallback, useEffect, useState } from 'react';
8
+ import { useCallback, useEffect, useMemo, useState } from 'react';
9
9
  import { Button, Stack } from '../../ui/index.js';
10
10
  import { useSelectFamily } from '../../ui/families.js';
11
11
  import { FieldRow } from './FieldRow.js';
@@ -342,7 +342,11 @@ export const C4AdvancedSearchFilters = ({ fields, onFilterChange, }) => {
342
342
  updateFilter([...filterFields, ...newFields]);
343
343
  }, [fields, filterFields, createInitialField, updateFilter]);
344
344
  const renderFieldRow = (field, spec) => (_jsx(FieldRow, { field: field, spec: spec, onFieldChange: handleFieldChange, onRemove: spec.optional ? removeField : undefined, onAddArrayValue: addArrayValue, onRemoveArrayValue: removeArrayValue }, field.id));
345
- const getAvailableOptionalFields = () => {
345
+ // Root-section fields and the still-available optional fields are both pure
346
+ // functions of `filterFields`/`fields` but were recomputed several times per
347
+ // render; memoize them so each render does the work at most once.
348
+ const rootFilterFields = useMemo(() => filterFields.filter((f) => f.orSectionId === 'root'), [filterFields]);
349
+ const availableOptionalFields = useMemo(() => {
346
350
  const addedFields = new Set(filterFields
347
351
  .filter((f) => f.orSectionId === 'root' && !f.parentArrayField)
348
352
  .map((f) => f.fieldName));
@@ -356,14 +360,14 @@ export const C4AdvancedSearchFilters = ({ fields, onFilterChange, }) => {
356
360
  !addedArrayFields.has(fieldName))
357
361
  .map(([fieldName, spec]) => ({ fieldName, spec }))
358
362
  .sort((a, b) => a.spec.label.localeCompare(b.spec.label));
359
- };
363
+ }, [filterFields, fields]);
360
364
  return (_jsx(Stack, { gap: 5, children: Object.keys(fields).length === 0 ? (_jsx("div", { style: {
361
365
  textAlign: 'center',
362
366
  padding: '2rem',
363
367
  color: 'var(--cds-text-secondary)',
364
368
  fontSize: '0.875rem',
365
- }, children: "No fields are configured for this filter component." })) : (_jsxs(_Fragment, { children: [filterFields.filter((f) => f.orSectionId === 'root').length === 0 &&
366
- getAvailableOptionalFields().length > 0 ? (_jsx("div", { style: {
369
+ }, children: "No fields are configured for this filter component." })) : (_jsxs(_Fragment, { children: [rootFilterFields.length === 0 &&
370
+ availableOptionalFields.length > 0 ? (_jsx("div", { style: {
367
371
  textAlign: 'center',
368
372
  padding: '1rem',
369
373
  color: 'var(--cds-text-secondary)',
@@ -384,13 +388,9 @@ export const C4AdvancedSearchFilters = ({ fields, onFilterChange, }) => {
384
388
  borderRadius: '4px',
385
389
  fontSize: '0.75rem',
386
390
  fontWeight: '500',
387
- }, children: "AND" }), "Main Filter Conditions"] }), _jsx(FiltersSection, { fields: fields, filterFields: filterFields.filter((f) => f.orSectionId === 'root'), addArrayItem: addArrayItem, updateFilter: updateFilter, renderFieldRow: renderFieldRow })] })), getAvailableOptionalFields().length > 0 && (_jsxs("div", { style: {
388
- marginTop: filterFields.filter((f) => f.orSectionId === 'root')
389
- .length === 0
390
- ? '0'
391
- : '1rem',
392
- }, children: [filterFields.filter((f) => f.orSectionId === 'root').length ===
393
- 0 && (_jsx("div", { style: {
391
+ }, children: "AND" }), "Main Filter Conditions"] }), _jsx(FiltersSection, { fields: fields, filterFields: rootFilterFields, addArrayItem: addArrayItem, updateFilter: updateFilter, renderFieldRow: renderFieldRow })] })), availableOptionalFields.length > 0 && (_jsxs("div", { style: {
392
+ marginTop: rootFilterFields.length === 0 ? '0' : '1rem',
393
+ }, children: [rootFilterFields.length === 0 && (_jsx("div", { style: {
394
394
  marginBottom: '1rem',
395
395
  color: 'var(--cds-text-primary)',
396
396
  fontSize: '0.875rem',
@@ -400,7 +400,7 @@ export const C4AdvancedSearchFilters = ({ fields, onFilterChange, }) => {
400
400
  if (fieldName) {
401
401
  addOptionalField(fieldName);
402
402
  }
403
- }, children: [_jsx(SelectItem, { value: '', text: 'Select field to add...' }), getAvailableOptionalFields().map((field) => (_jsx(SelectItem, { value: field.fieldName, text: field.spec.label }, field.fieldName)))] })] })), orSections.map((sectionId) => (_jsx(OrSection, { sectionId: sectionId, fieldsConfig: fields, filterFields: filterFields.filter((f) => f.orSectionId === sectionId), addArrayItem: addArrayItem, removeOrSection: removeOrSection, addOptionalFieldToSection: addOptionalFieldToSection, updateFilter: updateFilter, renderFieldRow: renderFieldRow }, sectionId))), _jsxs("div", { style: { marginTop: '1rem' }, children: [_jsx(Button, { kind: 'tertiary', size: 'sm', renderIcon: Add, onClick: addOrSection, children: "Add OR Condition" }), _jsx("div", { style: {
403
+ }, children: [_jsx(SelectItem, { value: '', text: 'Select field to add...' }), availableOptionalFields.map((field) => (_jsx(SelectItem, { value: field.fieldName, text: field.spec.label }, field.fieldName)))] })] })), orSections.map((sectionId) => (_jsx(OrSection, { sectionId: sectionId, fieldsConfig: fields, filterFields: filterFields.filter((f) => f.orSectionId === sectionId), addArrayItem: addArrayItem, removeOrSection: removeOrSection, addOptionalFieldToSection: addOptionalFieldToSection, updateFilter: updateFilter, renderFieldRow: renderFieldRow }, sectionId))), _jsxs("div", { style: { marginTop: '1rem' }, children: [_jsx(Button, { kind: 'tertiary', size: 'sm', renderIcon: Add, onClick: addOrSection, children: "Add OR Condition" }), _jsx("div", { style: {
404
404
  fontSize: '0.75rem',
405
405
  color: 'var(--cds-text-secondary)',
406
406
  marginTop: '0.5rem',
@@ -13,11 +13,17 @@ import { ValueMetric } from './value-metric.js';
13
13
  export const CurrentUsageMetrics = ({ title, decisionInstances, description, generalUsers, order, processInstances, taskUsers, isEnterpriseOrg = false, }) => {
14
14
  const [mediaSize, setMediaSize] = useState(mediaSizeByWidth(window.innerWidth));
15
15
  useEffect(() => {
16
+ let frame = 0;
16
17
  const handleWindowResize = () => {
17
- setMediaSize(mediaSizeByWidth(window.innerWidth));
18
+ // Coalesce bursts of resize events into one update per animation frame.
19
+ cancelAnimationFrame(frame);
20
+ frame = requestAnimationFrame(() => {
21
+ setMediaSize(mediaSizeByWidth(window.innerWidth));
22
+ });
18
23
  };
19
24
  window.addEventListener('resize', handleWindowResize);
20
25
  return () => {
26
+ cancelAnimationFrame(frame);
21
27
  window.removeEventListener('resize', handleWindowResize);
22
28
  };
23
29
  }, []);
@@ -1,3 +1,3 @@
1
- import type { JSX } from 'react';
1
+ import { type JSX } from 'react';
2
2
  import type { C4ChartsDashboardProps } from './c4-charts-dashboard.types';
3
3
  export declare const C4ChartsDashboard: ({ charts, theme, title, menuItems, isLoading, }: C4ChartsDashboardProps) => JSX.Element;
@@ -5,38 +5,44 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
5
  * You may not use this file except in compliance with the commercial license.
6
6
  */
7
7
  import { C3Page } from '@camunda/camunda-composite-components';
8
+ import { useMemo } from 'react';
8
9
  import { Stack } from '../../ui/index.js';
9
10
  import { C4AlluvialChart } from './elements/alluvial-chart.js';
10
11
  import { C4BarChart } from './elements/bar-chart.js';
11
12
  import { C4LineChart } from './elements/line-chart.js';
12
13
  export const C4ChartsDashboard = ({ charts, theme, title, menuItems, isLoading, }) => {
13
14
  const carbonTheme = theme === 'dark' ? 'g100' : 'g10';
14
- const chartsByTab = new Map();
15
- charts.forEach((chartConfig) => {
16
- const key = chartConfig.tab;
17
- const list = chartsByTab.get(key) ?? [];
18
- list.push({
19
- ...chartConfig,
20
- dataPoints: chartConfig.dataPoints.toSorted((a, b) => {
21
- if ('date' in a && 'date' in b) {
22
- return String(a.date).localeCompare(String(b.date));
23
- }
24
- if ('key' in a && 'key' in b) {
25
- return String(a.key).localeCompare(String(b.key));
26
- }
27
- return 0;
28
- }),
15
+ // Memoize the per-tab grouping + sort and the tab tree so each chart receives
16
+ // a stable `dataPoints` identity; otherwise every parent re-render hands the
17
+ // underlying chart libraries fresh arrays and forces a full re-init.
18
+ const tabs = useMemo(() => {
19
+ const chartsByTab = new Map();
20
+ charts.forEach((chartConfig) => {
21
+ const key = chartConfig.tab;
22
+ const list = chartsByTab.get(key) ?? [];
23
+ list.push({
24
+ ...chartConfig,
25
+ dataPoints: chartConfig.dataPoints.toSorted((a, b) => {
26
+ if ('date' in a && 'date' in b) {
27
+ return String(a.date).localeCompare(String(b.date));
28
+ }
29
+ if ('key' in a && 'key' in b) {
30
+ return String(a.key).localeCompare(String(b.key));
31
+ }
32
+ return 0;
33
+ }),
34
+ });
35
+ chartsByTab.set(key, list);
29
36
  });
30
- chartsByTab.set(key, list);
31
- });
32
- const tabs = Array.from(chartsByTab.entries()).map(([tab, defs]) => ({
33
- id: tab,
34
- label: tab,
35
- content: (_jsx(Stack, { gap: 4, children: defs.map((def, i) => {
36
- const key = def.id ?? `${tab}-${def.title}-${i}`;
37
- return _jsx(ChartItem, { ...def, theme: carbonTheme }, key);
38
- }) })),
39
- }));
37
+ return Array.from(chartsByTab.entries()).map(([tab, defs]) => ({
38
+ id: tab,
39
+ label: tab,
40
+ content: (_jsx(Stack, { gap: 4, children: defs.map((def, i) => {
41
+ const key = def.id ?? `${tab}-${def.title}-${i}`;
42
+ return _jsx(ChartItem, { ...def, theme: carbonTheme }, key);
43
+ }) })),
44
+ }));
45
+ }, [charts, carbonTheme]);
40
46
  return (_jsx(C3Page, { isLoading: isLoading, header: { title, menuItems }, tabs: { list: tabs } }));
41
47
  };
42
48
  const ChartItem = (props) => {
@@ -31,16 +31,19 @@ export const C4ClusterDetailsActivity = ({ activityGroups, isLoading, hasError,
31
31
  }) }) }))] }, `activity-group-${groupIndex}`));
32
32
  }) }));
33
33
  };
34
+ // Module-level singleton: constructing an Intl.DateTimeFormat is expensive, and
35
+ // this was previously rebuilt for every row on every render.
36
+ const DATE_TIME_FORMATTER = Intl.DateTimeFormat('en-GB', {
37
+ hour12: false,
38
+ day: '2-digit',
39
+ month: 'short',
40
+ year: 'numeric',
41
+ hour: '2-digit',
42
+ minute: '2-digit',
43
+ });
34
44
  const formatDateTime = (date) => {
35
45
  try {
36
- return Intl.DateTimeFormat('en-GB', {
37
- hour12: false,
38
- day: '2-digit',
39
- month: 'short',
40
- year: 'numeric',
41
- hour: '2-digit',
42
- minute: '2-digit',
43
- }).format(date);
46
+ return DATE_TIME_FORMATTER.format(date);
44
47
  }
45
48
  catch (_error) {
46
49
  return '';
@@ -1,3 +1,3 @@
1
- import type { JSX } from 'react';
1
+ import { type JSX } from 'react';
2
2
  import type { C4ClusterDetailsClientsProps } from './c4-cluster-details-clients.types';
3
3
  export declare const C4ClusterDetailsClients: ({ clients, isLoading, hasError, hasIdentityIntegration, hasIdentityAuthorization, hasZeebeUrl, text, urls, permissions, onNavigateToClient, onCreateClient, onUpdateClient, onDeleteClient, onRefresh, onOpenIdentity, onOpenDocs, }: C4ClusterDetailsClientsProps) => JSX.Element;
@@ -1,15 +1,31 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Edit, Renew } from '@carbon/react/icons/index.esm.js';
3
+ import { useMemo } from 'react';
3
4
  import { C4_ASSET_URLS } from '../../assetUrls.js';
4
5
  import { Button, CodeSnippet, Stack } from '../../ui/index.js';
5
6
  import { C4DataTable } from '../c4-data-table/c4-data-table.js';
6
7
  import { C4EmptyState } from '../c4-empty-state/c4-empty-state.js';
7
8
  import { C4LinkButton } from '../c4-link-button/c4-link-button.js';
9
+ // Module-level singletons: constructing Intl formatters is expensive, and these
10
+ // were previously rebuilt for every cell on every render. `toLocaleString(loc,
11
+ // opts)` is specified to construct an Intl.DateTimeFormat(loc, opts) internally,
12
+ // so formatting through this shared instance yields byte-identical output.
13
+ const SCOPES_LIST_FORMATTER = new Intl.ListFormat('en', {
14
+ style: 'long',
15
+ type: 'conjunction',
16
+ });
17
+ const CLIENT_DATE_TIME_FORMATTER = new Intl.DateTimeFormat('en-US', {
18
+ year: 'numeric',
19
+ month: 'short',
20
+ day: 'numeric',
21
+ hour: '2-digit',
22
+ minute: '2-digit',
23
+ });
8
24
  export const C4ClusterDetailsClients = ({ clients, isLoading, hasError, hasIdentityIntegration, hasIdentityAuthorization, hasZeebeUrl, text, urls, permissions, onNavigateToClient, onCreateClient, onUpdateClient, onDeleteClient, onRefresh, onOpenIdentity, onOpenDocs, }) => {
9
- const tableData = clients.map((client, originalIndex) => ({
25
+ const tableData = useMemo(() => clients.map((client, originalIndex) => ({
10
26
  ...client,
11
27
  originalIndex,
12
- }));
28
+ })), [clients]);
13
29
  const headerData = [
14
30
  {
15
31
  label: text.headerName,
@@ -59,10 +75,7 @@ export const C4ClusterDetailsClients = ({ clients, isLoading, hasError, hasIdent
59
75
  wrapperOptions: {
60
76
  wrapper: (row) => {
61
77
  const clientRow = row;
62
- return (_jsx(_Fragment, { children: new Intl.ListFormat('en', {
63
- style: 'long',
64
- type: 'conjunction',
65
- }).format(clientRow.scopes) }));
78
+ return _jsx(_Fragment, { children: SCOPES_LIST_FORMATTER.format(clientRow.scopes) });
66
79
  },
67
80
  },
68
81
  },
@@ -81,13 +94,7 @@ export const C4ClusterDetailsClients = ({ clients, isLoading, hasError, hasIdent
81
94
  const clientRow = row;
82
95
  if (!clientRow.created)
83
96
  return _jsx(_Fragment, { children: "-" });
84
- return (_jsx(_Fragment, { children: clientRow.created.toLocaleString('en-US', {
85
- year: 'numeric',
86
- month: 'short',
87
- day: 'numeric',
88
- hour: '2-digit',
89
- minute: '2-digit',
90
- }) }));
97
+ return _jsx(_Fragment, { children: CLIENT_DATE_TIME_FORMATTER.format(clientRow.created) });
91
98
  },
92
99
  },
93
100
  },
@@ -106,13 +113,7 @@ export const C4ClusterDetailsClients = ({ clients, isLoading, hasError, hasIdent
106
113
  const clientRow = row;
107
114
  if (!clientRow.lastUsed)
108
115
  return _jsx(_Fragment, { children: "-" });
109
- return (_jsx(_Fragment, { children: clientRow.lastUsed.toLocaleString('en-US', {
110
- year: 'numeric',
111
- month: 'short',
112
- day: 'numeric',
113
- hour: '2-digit',
114
- minute: '2-digit',
115
- }) }));
116
+ return (_jsx(_Fragment, { children: CLIENT_DATE_TIME_FORMATTER.format(clientRow.lastUsed) }));
116
117
  },
117
118
  },
118
119
  },
@@ -147,9 +147,17 @@ export const C4ClusterDetailsSecureConnectivity = ({ status, privateEndpoints, c
147
147
  // thresholds that would be needed to detect this breakpoint.
148
148
  const [isNarrowLayout, setIsNarrowLayout] = useState(() => typeof window !== 'undefined' && window.innerWidth < 1520);
149
149
  useEffect(() => {
150
- const handleResize = () => setIsNarrowLayout(window.innerWidth < 1520);
150
+ let frame = 0;
151
+ const handleResize = () => {
152
+ // Coalesce bursts of resize events into one update per animation frame.
153
+ cancelAnimationFrame(frame);
154
+ frame = requestAnimationFrame(() => setIsNarrowLayout(window.innerWidth < 1520));
155
+ };
151
156
  window.addEventListener('resize', handleResize);
152
- return () => window.removeEventListener('resize', handleResize);
157
+ return () => {
158
+ cancelAnimationFrame(frame);
159
+ window.removeEventListener('resize', handleResize);
160
+ };
153
161
  }, []);
154
162
  const deactivateLinkElement = onDeactivate ? (_jsx(Link, { href: '#', "aria-disabled": !permissions.canDeactivate || !!isDeactivating, tabIndex: !permissions.canDeactivate || isDeactivating ? -1 : undefined, onClick: (e) => {
155
163
  e.preventDefault();
@@ -194,11 +194,17 @@ const templateColumnsBySize = {
194
194
  export const Applications = (props) => {
195
195
  const [mediaSize, setMediaSize] = useState(mediaSizeByWidth(window.innerWidth));
196
196
  useEffect(() => {
197
+ let frame = 0;
197
198
  const handleWindowResize = () => {
198
- setMediaSize(mediaSizeByWidth(window.innerWidth));
199
+ // Coalesce bursts of resize events into one update per animation frame.
200
+ cancelAnimationFrame(frame);
201
+ frame = requestAnimationFrame(() => {
202
+ setMediaSize(mediaSizeByWidth(window.innerWidth));
203
+ });
199
204
  };
200
205
  window.addEventListener('resize', handleWindowResize);
201
206
  return () => {
207
+ cancelAnimationFrame(frame);
202
208
  window.removeEventListener('resize', handleWindowResize);
203
209
  };
204
210
  }, []);
@@ -18,11 +18,17 @@ export const C4ClusterTagSelector = (props) => {
18
18
  const designSystem = useC4DesignSystem();
19
19
  const [mediaSize, setMediaSize] = useState(mediaSizeByWidth(window.innerWidth));
20
20
  useEffect(() => {
21
+ let frame = 0;
21
22
  const handleWindowResize = () => {
22
- setMediaSize(mediaSizeByWidth(window.innerWidth));
23
+ // Coalesce bursts of resize events into one update per animation frame.
24
+ cancelAnimationFrame(frame);
25
+ frame = requestAnimationFrame(() => {
26
+ setMediaSize(mediaSizeByWidth(window.innerWidth));
27
+ });
23
28
  };
24
29
  window.addEventListener('resize', handleWindowResize);
25
30
  return () => {
31
+ cancelAnimationFrame(frame);
26
32
  window.removeEventListener('resize', handleWindowResize);
27
33
  };
28
34
  }, []);
@@ -6,8 +6,25 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
6
  */
7
7
  import { C3DataTable, } from '@camunda/camunda-composite-components';
8
8
  import { Button, DataTable, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, Input, MultiSelect, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '@camunda/design-system';
9
- import { useCallback, useMemo, useRef, useState, } from 'react';
9
+ import { useCallback, useEffect, useMemo, useRef, useState, } from 'react';
10
10
  import { useC4DesignSystem } from '../../runtime/c4-console-runtime-context.js';
11
+ /**
12
+ * Delay (ms) between a keystroke in a search field and the row filter running.
13
+ * Typing echoes instantly; only the (potentially O(n)) filter pass is deferred.
14
+ */
15
+ const SEARCH_DEBOUNCE_MS = 200;
16
+ /**
17
+ * Returns a copy of `value` that only updates after it has stopped changing for
18
+ * `delayMs`. Used to keep search-driven re-filtering off the per-keystroke path.
19
+ */
20
+ function useDebouncedValue(value, delayMs) {
21
+ const [debounced, setDebounced] = useState(value);
22
+ useEffect(() => {
23
+ const timer = setTimeout(() => setDebounced(value), delayMs);
24
+ return () => clearTimeout(timer);
25
+ }, [value, delayMs]);
26
+ return debounced;
27
+ }
11
28
  /**
12
29
  * Design-system-switchable data table.
13
30
  *
@@ -204,6 +221,37 @@ function C4DataTableDs(props) {
204
221
  item.type === 'multiSelect')
205
222
  .map((item) => `${item.type}:${item.id}`)
206
223
  .join('|');
224
+ // Debounced snapshot of the live filter state. Search inputs read from this so
225
+ // that typing does not re-scan the whole dataset on every keystroke; discrete
226
+ // filters (single/multi select) keep applying immediately (see below).
227
+ const debouncedFilterState = useDebouncedValue(filterState, SEARCH_DEBOUNCE_MS);
228
+ // The state that actually drives row filtering. For `search` items we take the
229
+ // debounced value; every other filter uses its live value so dropdowns still
230
+ // apply instantly. Rebuilt each render, but its *content* is identical between
231
+ // keystrokes (the search value stays at its last debounced value), so keying
232
+ // the filter memo on `effectiveFilterKey` keeps `filteredData` stable until the
233
+ // debounce settles or a non-search filter changes.
234
+ const effectiveFilterState = useMemo(() => {
235
+ const searchIds = new Set(allToolbarItems
236
+ .filter((item) => item.type === 'search')
237
+ .map((item) => item.id));
238
+ if (searchIds.size === 0) {
239
+ return filterState;
240
+ }
241
+ const merged = { ...filterState };
242
+ for (const id of searchIds) {
243
+ const debouncedValue = debouncedFilterState[id];
244
+ if (debouncedValue === undefined) {
245
+ delete merged[id];
246
+ }
247
+ else {
248
+ merged[id] = debouncedValue;
249
+ }
250
+ }
251
+ return merged;
252
+ // biome-ignore lint/correctness/useExhaustiveDependencies: allToolbarItems is rebuilt every render and its filtering shape is subsumed by filterSignature
253
+ }, [filterState, debouncedFilterState, filterSignature]);
254
+ const effectiveFilterKey = useMemo(() => JSON.stringify(effectiveFilterState), [effectiveFilterState]);
207
255
  // Keep the array reference stable across renders when neither the source
208
256
  // `data` reference, the filter state, nor the filtering toolbar shape
209
257
  // changed. The underlying DS `DataTable` is backed by TanStack Table, whose
@@ -216,10 +264,16 @@ function C4DataTableDs(props) {
216
264
  // render, so it is intentionally not a dependency — `filterSignature`
217
265
  // subsumes it; depending on the array directly would defeat the memo and
218
266
  // reintroduce the reset.
219
- // biome-ignore lint/correctness/useExhaustiveDependencies: allToolbarItems is rebuilt every render and is subsumed by filterSignature (see comment above)
267
+ // `effectiveFilterState` and `allToolbarItems` are used in the body but are
268
+ // intentionally not dependencies: `effectiveFilterKey` subsumes the effective
269
+ // filter contents (including the debounced search term) and `filterSignature`
270
+ // subsumes the toolbar shape. Depending on the objects directly would rebuild
271
+ // the array on every render — snapping TanStack back to page 1 and re-scanning
272
+ // the whole dataset on every keystroke.
273
+ // biome-ignore lint/correctness/useExhaustiveDependencies: effectiveFilterState/allToolbarItems are subsumed by effectiveFilterKey + filterSignature (see comment above)
220
274
  const filteredData = useMemo(() => allToolbarItems.length
221
- ? data.filter((row) => keepRow(row, allToolbarItems, filterState))
222
- : data, [data, filterState, filterSignature]);
275
+ ? data.filter((row) => keepRow(row, allToolbarItems, effectiveFilterState))
276
+ : data, [data, effectiveFilterKey, filterSignature]);
223
277
  const renderToolbarItem = (item) => {
224
278
  switch (item.type) {
225
279
  case 'search': {