@umituz/web-dashboard 10.3.0 → 11.0.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.
- package/package.json +3 -8
- package/src/domains/layouts/components/index.ts +0 -20
- package/src/domains/notifications/components/NotificationsPage.tsx +1 -1
- package/src/domains/settings/components/index.ts +0 -1
- package/src/styles/chrome.css +0 -343
- package/src/styles/dashboard.contract.test.ts +9 -7
- package/src/styles/dashboard.css +0 -1
- package/src/domains/charts/charts.css +0 -455
- package/src/domains/charts/components/ActivityHeatmap.test.tsx +0 -48
- package/src/domains/charts/components/ActivityHeatmap.tsx +0 -5
- package/src/domains/charts/components/BarChart.test.tsx +0 -91
- package/src/domains/charts/components/BarChart.tsx +0 -6
- package/src/domains/charts/components/ChartCard.tsx +0 -1
- package/src/domains/charts/components/ChartPrimitives.test.tsx +0 -90
- package/src/domains/charts/components/ChartTip.tsx +0 -1
- package/src/domains/charts/components/Donut.test.tsx +0 -51
- package/src/domains/charts/components/Donut.tsx +0 -5
- package/src/domains/charts/components/HBars.tsx +0 -1
- package/src/domains/charts/components/Legend.tsx +0 -1
- package/src/domains/charts/components/LineChart.test.tsx +0 -81
- package/src/domains/charts/components/LineChart.tsx +0 -6
- package/src/domains/charts/components/Sparkline.tsx +0 -1
- package/src/domains/charts/components/index.ts +0 -9
- package/src/domains/charts/index.ts +0 -28
- package/src/domains/charts/ssr.test.tsx +0 -35
- package/src/domains/charts/types/index.ts +0 -8
- package/src/domains/charts/utils.ts +0 -10
- package/src/domains/layouts/components/FilterBar.test.tsx +0 -33
- package/src/domains/layouts/components/FilterBar.tsx +0 -38
- package/src/domains/layouts/components/FilterPanel.test.tsx +0 -97
- package/src/domains/layouts/components/FilterPanel.tsx +0 -129
- package/src/domains/layouts/components/FilterSelect.test.tsx +0 -28
- package/src/domains/layouts/components/FilterSelect.tsx +0 -47
- package/src/domains/layouts/components/NextSteps.test.tsx +0 -25
- package/src/domains/layouts/components/NextSteps.tsx +0 -36
- package/src/domains/layouts/components/PageHeader.test.tsx +0 -63
- package/src/domains/layouts/components/PageHeader.tsx +0 -67
- package/src/domains/layouts/components/SectionHeader.test.tsx +0 -29
- package/src/domains/layouts/components/SectionHeader.tsx +0 -36
- package/src/domains/layouts/components/TabNav.test.tsx +0 -33
- package/src/domains/layouts/components/TabNav.tsx +0 -31
- package/src/domains/settings/components/AuditLogList.tsx +0 -6
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { fireEvent, render } from "@testing-library/react";
|
|
3
|
-
import { Donut } from "./Donut";
|
|
4
|
-
|
|
5
|
-
describe("Donut", () => {
|
|
6
|
-
it("renders one segment per entry with computed percentages", () => {
|
|
7
|
-
const { container } = render(
|
|
8
|
-
<Donut
|
|
9
|
-
segments={[
|
|
10
|
-
{ label: "A", value: 3 },
|
|
11
|
-
{ label: "B", value: 1 },
|
|
12
|
-
]}
|
|
13
|
-
centerValue="4"
|
|
14
|
-
centerLabel="total"
|
|
15
|
-
/>,
|
|
16
|
-
);
|
|
17
|
-
expect(container.querySelectorAll(".udb-donut__seg")).toHaveLength(2);
|
|
18
|
-
expect(container.querySelectorAll(".udb-donut__item")).toHaveLength(2);
|
|
19
|
-
expect(container.querySelector(".udb-donut__pct")!.textContent).toBe("75%");
|
|
20
|
-
expect(container.querySelector(".udb-donut__value")!.textContent).toBe("4");
|
|
21
|
-
expect(container.querySelector(".udb-donut__label")!.textContent).toBe("total");
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it("swaps the center readout to the hovered segment", () => {
|
|
25
|
-
const { container } = render(
|
|
26
|
-
<Donut
|
|
27
|
-
segments={[
|
|
28
|
-
{ label: "A", value: 3 },
|
|
29
|
-
{ label: "B", value: 1 },
|
|
30
|
-
]}
|
|
31
|
-
centerValue="4"
|
|
32
|
-
/>,
|
|
33
|
-
);
|
|
34
|
-
fireEvent.mouseEnter(container.querySelectorAll(".udb-donut__seg")[1]!);
|
|
35
|
-
expect(container.querySelector(".udb-donut__value")!.textContent).toBe("1");
|
|
36
|
-
expect(container.querySelector(".udb-donut__label")!.textContent).toBe("B");
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it("colors segments through the --udb-chart tokens by default", () => {
|
|
40
|
-
const { container } = render(<Donut segments={[{ label: "A", value: 1 }]} />);
|
|
41
|
-
const seg = container.querySelector(".udb-donut__seg")!;
|
|
42
|
-
expect(seg.getAttribute("stroke")).toContain("var(--udb-chart-1");
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it("lets an explicit tone win over the series tokens", () => {
|
|
46
|
-
const { container } = render(
|
|
47
|
-
<Donut segments={[{ label: "A", value: 1, tone: "#ff0000" }]} />,
|
|
48
|
-
);
|
|
49
|
-
expect(container.querySelector(".udb-donut__seg")!.getAttribute("stroke")).toBe("#ff0000");
|
|
50
|
-
});
|
|
51
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { HBars, type HBarRow } from '@umituz/web-design-system/charts';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Legend, type LegendItem } from '@umituz/web-design-system/charts';
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { fireEvent, render } from "@testing-library/react";
|
|
3
|
-
import { LineChart } from "./LineChart";
|
|
4
|
-
|
|
5
|
-
const labels = ["1", "2", "3", "4"];
|
|
6
|
-
|
|
7
|
-
describe("LineChart", () => {
|
|
8
|
-
it("renders nothing without points", () => {
|
|
9
|
-
const { container } = render(<LineChart labels={[]} series={[]} />);
|
|
10
|
-
expect(container.firstChild).toBeNull();
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it("renders a flat area by default", () => {
|
|
14
|
-
const { container } = render(
|
|
15
|
-
<LineChart labels={labels} series={[{ label: "A", values: [1, 2, 3, 4] }]} />,
|
|
16
|
-
);
|
|
17
|
-
const paths = container.querySelectorAll("path");
|
|
18
|
-
expect(paths).toHaveLength(2);
|
|
19
|
-
expect(paths[0]!.getAttribute("opacity")).toBe("0.07");
|
|
20
|
-
expect(container.querySelector("linearGradient")).toBeNull();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it("paints the area with a per-series gradient when requested", () => {
|
|
24
|
-
const { container } = render(
|
|
25
|
-
<LineChart
|
|
26
|
-
labels={labels}
|
|
27
|
-
series={[{ label: "A", values: [1, 2, 3, 4], areaFill: "gradient" }]}
|
|
28
|
-
/>,
|
|
29
|
-
);
|
|
30
|
-
const gradient = container.querySelector("linearGradient");
|
|
31
|
-
expect(gradient).not.toBeNull();
|
|
32
|
-
expect(gradient!.querySelectorAll("stop")).toHaveLength(2);
|
|
33
|
-
const areaPath = [...container.querySelectorAll("path")].find((p) =>
|
|
34
|
-
p.getAttribute("fill")?.startsWith("url(#"),
|
|
35
|
-
);
|
|
36
|
-
expect(areaPath).toBeDefined();
|
|
37
|
-
expect(areaPath!.getAttribute("opacity")).toBeNull();
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it("drops the area for dashed series", () => {
|
|
41
|
-
const { container } = render(
|
|
42
|
-
<LineChart labels={labels} series={[{ label: "A", values: [1, 2, 3, 4], dashed: true }]} />,
|
|
43
|
-
);
|
|
44
|
-
expect(container.querySelectorAll("path")).toHaveLength(1);
|
|
45
|
-
expect(container.querySelector("linearGradient")).toBeNull();
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it("renders the band and a crosshair with tooltip on hover", () => {
|
|
49
|
-
const { container } = render(
|
|
50
|
-
<LineChart
|
|
51
|
-
labels={labels}
|
|
52
|
-
band={{ from: 1, to: 2 }}
|
|
53
|
-
series={[{ label: "A", values: [1, 2, 3, 4] }]}
|
|
54
|
-
/>,
|
|
55
|
-
);
|
|
56
|
-
expect(container.querySelector(".udb-linechart__band")).not.toBeNull();
|
|
57
|
-
|
|
58
|
-
const svg = container.querySelector("svg")!;
|
|
59
|
-
fireEvent.mouseMove(svg, { clientX: 700, clientY: 50 });
|
|
60
|
-
expect(container.querySelector(".udb-linechart__crosshair")).not.toBeNull();
|
|
61
|
-
const tip = container.querySelector(".udb-linechart__tip");
|
|
62
|
-
expect(tip).not.toBeNull();
|
|
63
|
-
expect(tip!.textContent).toContain("A");
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it("renders the built-in legend from the series", () => {
|
|
67
|
-
const { container } = render(
|
|
68
|
-
<LineChart
|
|
69
|
-
labels={labels}
|
|
70
|
-
series={[
|
|
71
|
-
{ label: "A", values: [1, 2, 3, 4] },
|
|
72
|
-
{ label: "B", values: [4, 3, 2, 1], axis: "right" },
|
|
73
|
-
]}
|
|
74
|
-
/>,
|
|
75
|
-
);
|
|
76
|
-
const items = container.querySelectorAll(".udb-chartlegend__item");
|
|
77
|
-
expect(items).toHaveLength(2);
|
|
78
|
-
expect(items[0]!.textContent).toContain("A");
|
|
79
|
-
expect(items[1]!.textContent).toContain("B");
|
|
80
|
-
});
|
|
81
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Sparkline } from '@umituz/web-design-system/charts';
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export { ChartTip } from './ChartTip';
|
|
2
|
-
export { ChartCard, type ChartCardProps } from './ChartCard';
|
|
3
|
-
export { Legend, type LegendItem } from './Legend';
|
|
4
|
-
export { Sparkline } from './Sparkline';
|
|
5
|
-
export { HBars, type HBarRow } from './HBars';
|
|
6
|
-
export { BarChart, type BarSeries, type BarChartGoalLine, type BarChartProps } from './BarChart';
|
|
7
|
-
export { Donut, type DonutSegment, type DonutProps } from './Donut';
|
|
8
|
-
export { LineChart, type LineSeries, type LineChartPoint, type LineChartProps } from './LineChart';
|
|
9
|
-
export { ActivityHeatmap, type HeatmapCell, type ActivityHeatmapProps } from './ActivityHeatmap';
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export { PALETTE, SERIES_COLORS, seriesColor, useTip, niceMax, gridTicks } from './utils';
|
|
2
|
-
export type { TipRow, TipState } from './utils';
|
|
3
|
-
export {
|
|
4
|
-
ChartTip,
|
|
5
|
-
ChartCard,
|
|
6
|
-
Legend,
|
|
7
|
-
Sparkline,
|
|
8
|
-
HBars,
|
|
9
|
-
BarChart,
|
|
10
|
-
Donut,
|
|
11
|
-
LineChart,
|
|
12
|
-
ActivityHeatmap,
|
|
13
|
-
} from './components';
|
|
14
|
-
export type {
|
|
15
|
-
ChartCardProps,
|
|
16
|
-
LegendItem,
|
|
17
|
-
HBarRow,
|
|
18
|
-
BarSeries,
|
|
19
|
-
BarChartGoalLine,
|
|
20
|
-
BarChartProps,
|
|
21
|
-
DonutSegment,
|
|
22
|
-
DonutProps,
|
|
23
|
-
LineSeries,
|
|
24
|
-
LineChartPoint,
|
|
25
|
-
LineChartProps,
|
|
26
|
-
HeatmapCell,
|
|
27
|
-
ActivityHeatmapProps,
|
|
28
|
-
} from './components';
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { renderToString } from "react-dom/server";
|
|
3
|
-
import { BarChart } from "./components/BarChart";
|
|
4
|
-
import { Donut } from "./components/Donut";
|
|
5
|
-
import { LineChart } from "./components/LineChart";
|
|
6
|
-
import { ActivityHeatmap } from "./components/ActivityHeatmap";
|
|
7
|
-
import { ChartCard } from "./components/ChartCard";
|
|
8
|
-
import { HBars } from "./components/HBars";
|
|
9
|
-
import { Sparkline } from "./components/Sparkline";
|
|
10
|
-
|
|
11
|
-
describe("charts server rendering", () => {
|
|
12
|
-
it("renders every chart primitive to static markup", () => {
|
|
13
|
-
const html = [
|
|
14
|
-
renderToString(
|
|
15
|
-
<ChartCard title="T" tip={null}>
|
|
16
|
-
<span>body</span>
|
|
17
|
-
</ChartCard>,
|
|
18
|
-
),
|
|
19
|
-
renderToString(<BarChart labels={["a", "b"]} series={[{ label: "A", values: [1, 2] }]} />),
|
|
20
|
-
renderToString(<BarChart labels={["a"]} stacking="stacked" series={[{ label: "A", values: [2] }, { label: "B", values: [2] }]} />),
|
|
21
|
-
renderToString(<Donut segments={[{ label: "A", value: 1 }]} centerValue="1" />),
|
|
22
|
-
renderToString(<LineChart labels={["a", "b"]} series={[{ label: "A", values: [1, 2], areaFill: "gradient" }]} />),
|
|
23
|
-
renderToString(<ActivityHeatmap cells={[{ day: "2026-01-01", value: 3 }]} />),
|
|
24
|
-
renderToString(<Sparkline data={[1, 2]} />),
|
|
25
|
-
renderToString(<HBars rows={[{ label: "A", value: 1 }]} />),
|
|
26
|
-
].join("");
|
|
27
|
-
expect(html).toContain("udb-chartcard");
|
|
28
|
-
expect(html).toContain("udb-barchart__bars--stacked");
|
|
29
|
-
expect(html).toContain("udb-donut");
|
|
30
|
-
expect(html).toContain("udb-linechart");
|
|
31
|
-
expect(html).toContain("linearGradient");
|
|
32
|
-
expect(html).toContain("udb-heatmap__cell--l");
|
|
33
|
-
expect(html).toContain("udb-hbars");
|
|
34
|
-
});
|
|
35
|
-
});
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export type { TipRow, TipState } from '../utils';
|
|
2
|
-
export type { ChartCardProps } from '../components/ChartCard';
|
|
3
|
-
export type { LegendItem } from '../components/Legend';
|
|
4
|
-
export type { HBarRow } from '../components/HBars';
|
|
5
|
-
export type { BarSeries, BarChartGoalLine, BarChartProps } from '../components/BarChart';
|
|
6
|
-
export type { DonutSegment, DonutProps } from '../components/Donut';
|
|
7
|
-
export type { LineSeries, LineChartPoint, LineChartProps } from '../components/LineChart';
|
|
8
|
-
export type { HeatmapCell, ActivityHeatmapProps } from '../components/ActivityHeatmap';
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { renderToString } from "react-dom/server";
|
|
3
|
-
import { FilterBar } from "./FilterBar";
|
|
4
|
-
|
|
5
|
-
describe("FilterBar", () => {
|
|
6
|
-
it("renders search, children and actions in their slots", () => {
|
|
7
|
-
const html = renderToString(
|
|
8
|
-
<FilterBar
|
|
9
|
-
search={{ value: "", onChange: () => {}, placeholder: "Find…" }}
|
|
10
|
-
actions={<button type="button">Sort</button>}
|
|
11
|
-
|
|
12
|
-
>
|
|
13
|
-
<span>a chip</span>
|
|
14
|
-
|
|
15
|
-
</FilterBar>
|
|
16
|
-
|
|
17
|
-
);
|
|
18
|
-
expect(html).toContain("udb-filter-bar");
|
|
19
|
-
expect(html).toContain("udb-filter-bar__search");
|
|
20
|
-
expect(html).toContain("udb-filter-bar__fields");
|
|
21
|
-
expect(html).toContain("a chip");
|
|
22
|
-
expect(html).toContain("udb-filter-bar__actions");
|
|
23
|
-
expect(html).toContain("Sort");
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it("omits absent slots entirely", () => {
|
|
27
|
-
const html = renderToString(<FilterBar />);
|
|
28
|
-
expect(html).toContain("udb-filter-bar");
|
|
29
|
-
expect(html).not.toContain("udb-filter-bar__search");
|
|
30
|
-
expect(html).not.toContain("udb-filter-bar__fields");
|
|
31
|
-
expect(html).not.toContain("udb-filter-bar__actions");
|
|
32
|
-
});
|
|
33
|
-
});
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from "react";
|
|
2
|
-
import { SearchBox } from "@umituz/web-design-system/molecules";
|
|
3
|
-
import { cn } from "@umituz/web-design-system/utils/cn";
|
|
4
|
-
import type { BaseProps } from "@umituz/web-design-system/types";
|
|
5
|
-
|
|
6
|
-
export interface FilterBarSearch {
|
|
7
|
-
value: string;
|
|
8
|
-
onChange: (value: string) => void;
|
|
9
|
-
placeholder?: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface FilterBarProps extends BaseProps {
|
|
13
|
-
search?: FilterBarSearch;
|
|
14
|
-
children?: ReactNode;
|
|
15
|
-
actions?: ReactNode;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const FilterBar = ({ search, children, actions, className, ...props }: FilterBarProps) => {
|
|
19
|
-
return (
|
|
20
|
-
<div className={cn("udb-filter-bar", className)} {...props}>
|
|
21
|
-
{search && (
|
|
22
|
-
<SearchBox
|
|
23
|
-
value={search.value}
|
|
24
|
-
onChange={search.onChange}
|
|
25
|
-
placeholder={search.placeholder}
|
|
26
|
-
className="udb-filter-bar__search"
|
|
27
|
-
/>
|
|
28
|
-
)}
|
|
29
|
-
{children && <div className="udb-filter-bar__fields">{children}</div>}
|
|
30
|
-
|
|
31
|
-
{actions && <div className="udb-filter-bar__actions">{actions}</div>}
|
|
32
|
-
|
|
33
|
-
</div>
|
|
34
|
-
|
|
35
|
-
);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
FilterBar.displayName = "FilterBar";
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { renderToString } from "react-dom/server";
|
|
3
|
-
import {
|
|
4
|
-
FilterPanel,
|
|
5
|
-
FilterSection,
|
|
6
|
-
CheckFilterList,
|
|
7
|
-
SingleSelectFilterList,
|
|
8
|
-
} from "./FilterPanel";
|
|
9
|
-
|
|
10
|
-
describe("FilterPanel", () => {
|
|
11
|
-
it("renders the header, clear action and sections", () => {
|
|
12
|
-
const html = renderToString(
|
|
13
|
-
<FilterPanel title="Program filters" onClear={() => undefined}>
|
|
14
|
-
<FilterSection title="Status">
|
|
15
|
-
<span>body</span>
|
|
16
|
-
</FilterSection>
|
|
17
|
-
</FilterPanel>,
|
|
18
|
-
);
|
|
19
|
-
expect(html).toContain('aria-label="Program filters"');
|
|
20
|
-
expect(html).toContain("Program filters");
|
|
21
|
-
expect(html).toContain("Clear all");
|
|
22
|
-
expect(html).toContain("Status");
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("can disable and label the clear action", () => {
|
|
26
|
-
const html = renderToString(
|
|
27
|
-
<FilterPanel onClear={() => undefined} clearDisabled clearLabel="Temizle">
|
|
28
|
-
<span>body</span>
|
|
29
|
-
</FilterPanel>,
|
|
30
|
-
);
|
|
31
|
-
expect(html).toContain("Temizle");
|
|
32
|
-
expect(html).toContain("disabled");
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
describe("CheckFilterList", () => {
|
|
37
|
-
const options = Array.from({ length: 10 }, (_, i) => ({
|
|
38
|
-
value: `v${i}`,
|
|
39
|
-
label: `Option ${i}`,
|
|
40
|
-
}));
|
|
41
|
-
|
|
42
|
-
it("marks selected options checked", () => {
|
|
43
|
-
const html = renderToString(
|
|
44
|
-
<CheckFilterList options={options.slice(0, 3)} selected={["v1"]} onToggle={() => undefined} />,
|
|
45
|
-
);
|
|
46
|
-
expect(html).toContain('aria-checked="true"');
|
|
47
|
-
expect(html).toContain("Option 1");
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it("caps visible options, keeps hidden selected ones and notes the rest", () => {
|
|
51
|
-
const html = renderToString(
|
|
52
|
-
<CheckFilterList options={options} selected={["v9"]} onToggle={() => undefined} maxVisible={4} />,
|
|
53
|
-
);
|
|
54
|
-
expect(html).toContain("Option 3");
|
|
55
|
-
expect(html).toContain("Option 9");
|
|
56
|
-
expect(html).not.toContain("Option 5<");
|
|
57
|
-
expect(html).toContain("+5 more");
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
describe("SingleSelectFilterList", () => {
|
|
62
|
-
const options = [
|
|
63
|
-
{ value: "all", label: "All", count: 42 },
|
|
64
|
-
{ value: "open", label: "Open", count: 7 },
|
|
65
|
-
];
|
|
66
|
-
|
|
67
|
-
it("marks the active option as the checked radio", () => {
|
|
68
|
-
const html = renderToString(
|
|
69
|
-
<SingleSelectFilterList options={options} value="open" onChange={() => undefined} />,
|
|
70
|
-
);
|
|
71
|
-
expect(html).toContain('role="radio"');
|
|
72
|
-
expect(html).toContain('aria-checked="true"');
|
|
73
|
-
expect(html).toContain(">7</span>");
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
import { BarChart } from "../../charts/components";
|
|
78
|
-
|
|
79
|
-
describe("BarChart per-bar accents", () => {
|
|
80
|
-
it("paints bars with accent overrides falling back to the series tone", () => {
|
|
81
|
-
const html = renderToString(
|
|
82
|
-
<BarChart
|
|
83
|
-
labels={["Mon", "Tue"]}
|
|
84
|
-
series={[
|
|
85
|
-
{
|
|
86
|
-
label: "load",
|
|
87
|
-
values: [3, 5],
|
|
88
|
-
tone: "#111111",
|
|
89
|
-
accents: ["#ff0000", undefined],
|
|
90
|
-
},
|
|
91
|
-
]}
|
|
92
|
-
/>,
|
|
93
|
-
);
|
|
94
|
-
expect(html).toContain("#ff0000");
|
|
95
|
-
expect(html).toContain("#111111");
|
|
96
|
-
});
|
|
97
|
-
});
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
import { Check } from 'lucide-react';
|
|
3
|
-
|
|
4
|
-
export interface FilterPanelProps {
|
|
5
|
-
title?: string;
|
|
6
|
-
onClear?: () => void;
|
|
7
|
-
clearDisabled?: boolean;
|
|
8
|
-
clearLabel?: string;
|
|
9
|
-
children: ReactNode;
|
|
10
|
-
className?: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function FilterPanel({
|
|
14
|
-
title = 'Filters',
|
|
15
|
-
onClear,
|
|
16
|
-
clearDisabled,
|
|
17
|
-
clearLabel = 'Clear all',
|
|
18
|
-
children,
|
|
19
|
-
className,
|
|
20
|
-
}: FilterPanelProps) {
|
|
21
|
-
return (
|
|
22
|
-
<aside className={className !== undefined ? `udb-filter-panel ${className}` : 'udb-filter-panel'} aria-label={title}>
|
|
23
|
-
<div className="udb-filter-panel__header">
|
|
24
|
-
<span className="udb-filter-panel__title">{title}</span>
|
|
25
|
-
{onClear !== undefined && (
|
|
26
|
-
<button type="button" className="udb-filter-panel__clear" onClick={onClear} disabled={clearDisabled}>
|
|
27
|
-
{clearLabel}
|
|
28
|
-
</button>
|
|
29
|
-
)}
|
|
30
|
-
</div>
|
|
31
|
-
<div className="udb-filter-panel__sections">{children}</div>
|
|
32
|
-
</aside>
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface FilterSectionProps {
|
|
37
|
-
title: string;
|
|
38
|
-
children: ReactNode;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function FilterSection({ title, children }: FilterSectionProps) {
|
|
42
|
-
return (
|
|
43
|
-
<section className="udb-filter-section">
|
|
44
|
-
<h4 className="udb-filter-section__title">{title}</h4>
|
|
45
|
-
<div className="udb-filter-section__body">{children}</div>
|
|
46
|
-
</section>
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export interface FilterListOption {
|
|
51
|
-
value: string;
|
|
52
|
-
label: string;
|
|
53
|
-
count?: number;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export interface CheckFilterListProps {
|
|
57
|
-
options: readonly FilterListOption[];
|
|
58
|
-
selected: readonly string[];
|
|
59
|
-
onToggle: (value: string) => void;
|
|
60
|
-
maxVisible?: number;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export function CheckFilterList({ options, selected, onToggle, maxVisible = 8 }: CheckFilterListProps) {
|
|
64
|
-
const visible = options.slice(0, maxVisible);
|
|
65
|
-
const hasMore = options.length > maxVisible;
|
|
66
|
-
const hiddenSelected = options.slice(maxVisible).filter((option) => selected.includes(option.value));
|
|
67
|
-
const shown = hasMore ? [...visible, ...hiddenSelected] : visible;
|
|
68
|
-
|
|
69
|
-
return (
|
|
70
|
-
<ul className="udb-check-filter" role="group">
|
|
71
|
-
{shown.map((option) => {
|
|
72
|
-
const isSelected = selected.includes(option.value);
|
|
73
|
-
return (
|
|
74
|
-
<li key={option.value}>
|
|
75
|
-
<button
|
|
76
|
-
type="button"
|
|
77
|
-
role="checkbox"
|
|
78
|
-
aria-checked={isSelected}
|
|
79
|
-
className={isSelected ? 'udb-check-filter__item udb-check-filter__item--checked' : 'udb-check-filter__item'}
|
|
80
|
-
onClick={() => onToggle(option.value)}
|
|
81
|
-
>
|
|
82
|
-
<span className="udb-check-filter__box" aria-hidden="true">
|
|
83
|
-
{isSelected && <Check size={12} strokeWidth={3} />}
|
|
84
|
-
</span>
|
|
85
|
-
<span className="udb-check-filter__label">{option.label}</span>
|
|
86
|
-
{option.count !== undefined && <span className="udb-check-filter__count">{option.count}</span>}
|
|
87
|
-
</button>
|
|
88
|
-
</li>
|
|
89
|
-
);
|
|
90
|
-
})}
|
|
91
|
-
{hasMore && (
|
|
92
|
-
<li className="udb-check-filter__more">{`+${options.length - shown.length} more`}</li>
|
|
93
|
-
)}
|
|
94
|
-
</ul>
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export interface SingleSelectFilterListProps {
|
|
99
|
-
options: readonly FilterListOption[];
|
|
100
|
-
value: string | null;
|
|
101
|
-
onChange: (value: string | null) => void;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export function SingleSelectFilterList({ options, value, onChange }: SingleSelectFilterListProps) {
|
|
105
|
-
return (
|
|
106
|
-
<ul className="udb-check-filter" role="group">
|
|
107
|
-
{options.map((option) => {
|
|
108
|
-
const isActive = value === option.value;
|
|
109
|
-
return (
|
|
110
|
-
<li key={option.value}>
|
|
111
|
-
<button
|
|
112
|
-
type="button"
|
|
113
|
-
role="radio"
|
|
114
|
-
aria-checked={isActive}
|
|
115
|
-
className={isActive ? 'udb-check-filter__item udb-check-filter__item--checked' : 'udb-check-filter__item'}
|
|
116
|
-
onClick={() => onChange(isActive ? null : option.value)}
|
|
117
|
-
>
|
|
118
|
-
<span className="udb-check-filter__box udb-check-filter__box--radio" aria-hidden="true">
|
|
119
|
-
{isActive && <span className="udb-check-filter__radio-dot" />}
|
|
120
|
-
</span>
|
|
121
|
-
<span className="udb-check-filter__label">{option.label}</span>
|
|
122
|
-
{option.count !== undefined && <span className="udb-check-filter__count">{option.count}</span>}
|
|
123
|
-
</button>
|
|
124
|
-
</li>
|
|
125
|
-
);
|
|
126
|
-
})}
|
|
127
|
-
</ul>
|
|
128
|
-
);
|
|
129
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { renderToString } from "react-dom/server";
|
|
3
|
-
import { FilterSelect } from "./FilterSelect";
|
|
4
|
-
|
|
5
|
-
describe("FilterSelect", () => {
|
|
6
|
-
const options = [
|
|
7
|
-
{ value: "open", label: "Open" },
|
|
8
|
-
{ value: "closed", label: "Closed" },
|
|
9
|
-
];
|
|
10
|
-
|
|
11
|
-
it("renders the all-entry plus options and reports the chosen value", () => {
|
|
12
|
-
const chosen: string[] = [];
|
|
13
|
-
const html = renderToString(
|
|
14
|
-
<FilterSelect
|
|
15
|
-
value="open"
|
|
16
|
-
options={options}
|
|
17
|
-
ariaLabel="Filter by status"
|
|
18
|
-
allLabel="Any status"
|
|
19
|
-
onChange={(v) => chosen.push(v)}
|
|
20
|
-
/>,
|
|
21
|
-
);
|
|
22
|
-
expect(html).toContain('aria-label="Filter by status"');
|
|
23
|
-
expect(html).toContain("Any status");
|
|
24
|
-
expect(html).toContain("Open");
|
|
25
|
-
expect(html).toContain("Closed");
|
|
26
|
-
expect(chosen).toEqual([]);
|
|
27
|
-
});
|
|
28
|
-
});
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import type { SelectHTMLAttributes } from "react";
|
|
2
|
-
|
|
3
|
-
export interface FilterSelectOption {
|
|
4
|
-
value: string;
|
|
5
|
-
label: string;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface FilterSelectProps
|
|
9
|
-
extends Omit<SelectHTMLAttributes<HTMLSelectElement>, "onChange" | "value" | "size"> {
|
|
10
|
-
value: string;
|
|
11
|
-
onChange: (value: string) => void;
|
|
12
|
-
options: readonly FilterSelectOption[];
|
|
13
|
-
ariaLabel: string;
|
|
14
|
-
allLabel: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const FilterSelect = ({
|
|
18
|
-
value,
|
|
19
|
-
onChange,
|
|
20
|
-
options,
|
|
21
|
-
ariaLabel,
|
|
22
|
-
allLabel,
|
|
23
|
-
className,
|
|
24
|
-
...props
|
|
25
|
-
}: FilterSelectProps) => {
|
|
26
|
-
return (
|
|
27
|
-
<select
|
|
28
|
-
aria-label={ariaLabel}
|
|
29
|
-
className={className ? `udb-filter-select ${className}` : "udb-filter-select"}
|
|
30
|
-
value={value}
|
|
31
|
-
onChange={(event) => onChange(event.target.value)}
|
|
32
|
-
{...props}
|
|
33
|
-
>
|
|
34
|
-
<option value="">{allLabel}</option>
|
|
35
|
-
|
|
36
|
-
{options.map((option) => (
|
|
37
|
-
<option key={option.value} value={option.value}>
|
|
38
|
-
{option.label}
|
|
39
|
-
</option>
|
|
40
|
-
|
|
41
|
-
))}
|
|
42
|
-
</select>
|
|
43
|
-
|
|
44
|
-
);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
FilterSelect.displayName = "FilterSelect";
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { renderToString } from 'react-dom/server';
|
|
3
|
-
import { MemoryRouter } from 'react-router';
|
|
4
|
-
import { NextSteps } from './NextSteps';
|
|
5
|
-
|
|
6
|
-
describe('NextSteps component', () => {
|
|
7
|
-
it('renders lead text and action links', () => {
|
|
8
|
-
const html = renderToString(
|
|
9
|
-
<MemoryRouter>
|
|
10
|
-
<NextSteps
|
|
11
|
-
lead="Önerilen Adımlar"
|
|
12
|
-
links={[
|
|
13
|
-
{ to: '/app/practice', label: 'Alıştırma Yap' },
|
|
14
|
-
{ to: '/app/exams', label: 'Sınavları Gör' },
|
|
15
|
-
]}
|
|
16
|
-
/>
|
|
17
|
-
</MemoryRouter>
|
|
18
|
-
);
|
|
19
|
-
expect(html).toContain('Önerilen Adımlar');
|
|
20
|
-
expect(html).toContain('Alıştırma Yap');
|
|
21
|
-
expect(html).toContain('href="/app/practice"');
|
|
22
|
-
expect(html).toContain('Sınavları Gör');
|
|
23
|
-
expect(html).toContain('href="/app/exams"');
|
|
24
|
-
});
|
|
25
|
-
});
|