@umituz/web-dashboard 7.4.4 → 7.5.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/web-dashboard",
3
- "version": "7.4.4",
3
+ "version": "7.5.0",
4
4
  "description": "Installable app skeleton for the fleet — layouts, analytics (dependency-free SVG charts), calendar, onboarding flow permissions/module registry; udb-* stylesheet on design-system tokens",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -174,6 +174,8 @@ export interface BarSeries {
174
174
  data?: readonly number[];
175
175
  tone?: string;
176
176
  color?: string;
177
+ /** Per-bar color override (index-aligned with labels); undefined falls back to the series tone. */
178
+ accents?: readonly (string | undefined)[];
177
179
  }
178
180
 
179
181
  export interface BarChartGoalLine {
@@ -201,6 +203,7 @@ export function BarChart({
201
203
  const vals = (s: BarSeries) => s.values ?? s.data ?? [];
202
204
  const max = Math.max(1, ...series.flatMap((s) => vals(s)), goalLine?.value ?? 0);
203
205
  const toneOf = (s: BarSeries, i: number) => s.tone ?? s.color ?? PALETTE[i % PALETTE.length]!;
206
+ const accentOf = (s: BarSeries, si: number, i: number) => s.accents?.[i] ?? toneOf(s, si);
204
207
  const goalPct = goalLine !== undefined ? Math.min(100, (goalLine.value / max) * 100) : null;
205
208
  return (
206
209
  <div className="udb-barchart" style={{ height }}>
@@ -244,7 +247,7 @@ export function BarChart({
244
247
  className="udb-barchart__bar"
245
248
  style={{
246
249
  height: `${Math.max(2, ((vals(s)[i] ?? 0) / max) * 100)}%`,
247
- background: toneOf(s, si),
250
+ background: accentOf(s, si, i),
248
251
  opacity: hover === null || hover === i ? 1 : 0.4,
249
252
  }}
250
253
  />
@@ -258,7 +261,7 @@ export function BarChart({
258
261
  {series.map((s, si) => (
259
262
  <div key={s.key ?? s.label} className="udb-barchart__tiprow">
260
263
  <span className="udb-barchart__tiplabel">
261
- <span className="udb-chartlegend__dot" style={{ background: toneOf(s, si) }} />
264
+ <span className="udb-chartlegend__dot" style={{ background: accentOf(s, si, i) }} />
262
265
  {s.label}
263
266
  </span>
264
267
 
@@ -0,0 +1,97 @@
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
+ });
@@ -0,0 +1,132 @@
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
+ /** Sidebar container for a set of filter sections. */
14
+ export function FilterPanel({
15
+ title = 'Filters',
16
+ onClear,
17
+ clearDisabled,
18
+ clearLabel = 'Clear all',
19
+ children,
20
+ className,
21
+ }: FilterPanelProps) {
22
+ return (
23
+ <aside className={className !== undefined ? `udb-filter-panel ${className}` : 'udb-filter-panel'} aria-label={title}>
24
+ <div className="udb-filter-panel__header">
25
+ <span className="udb-filter-panel__title">{title}</span>
26
+ {onClear !== undefined && (
27
+ <button type="button" className="udb-filter-panel__clear" onClick={onClear} disabled={clearDisabled}>
28
+ {clearLabel}
29
+ </button>
30
+ )}
31
+ </div>
32
+ <div className="udb-filter-panel__sections">{children}</div>
33
+ </aside>
34
+ );
35
+ }
36
+
37
+ export interface FilterSectionProps {
38
+ title: string;
39
+ children: ReactNode;
40
+ }
41
+
42
+ export function FilterSection({ title, children }: FilterSectionProps) {
43
+ return (
44
+ <section className="udb-filter-section">
45
+ <h4 className="udb-filter-section__title">{title}</h4>
46
+ <div className="udb-filter-section__body">{children}</div>
47
+ </section>
48
+ );
49
+ }
50
+
51
+ export interface FilterListOption {
52
+ value: string;
53
+ label: string;
54
+ count?: number;
55
+ }
56
+
57
+ export interface CheckFilterListProps {
58
+ options: readonly FilterListOption[];
59
+ selected: readonly string[];
60
+ onToggle: (value: string) => void;
61
+ /** Limit visible options; hidden-but-selected ones stay visible with a "+N more" note. */
62
+ maxVisible?: number;
63
+ }
64
+
65
+ export function CheckFilterList({ options, selected, onToggle, maxVisible = 8 }: CheckFilterListProps) {
66
+ const visible = options.slice(0, maxVisible);
67
+ const hasMore = options.length > maxVisible;
68
+ const hiddenSelected = options.slice(maxVisible).filter((option) => selected.includes(option.value));
69
+ const shown = hasMore ? [...visible, ...hiddenSelected] : visible;
70
+
71
+ return (
72
+ <ul className="udb-check-filter" role="group">
73
+ {shown.map((option) => {
74
+ const isSelected = selected.includes(option.value);
75
+ return (
76
+ <li key={option.value}>
77
+ <button
78
+ type="button"
79
+ role="checkbox"
80
+ aria-checked={isSelected}
81
+ className={isSelected ? 'udb-check-filter__item udb-check-filter__item--checked' : 'udb-check-filter__item'}
82
+ onClick={() => onToggle(option.value)}
83
+ >
84
+ <span className="udb-check-filter__box" aria-hidden="true">
85
+ {isSelected && <Check size={12} strokeWidth={3} />}
86
+ </span>
87
+ <span className="udb-check-filter__label">{option.label}</span>
88
+ {option.count !== undefined && <span className="udb-check-filter__count">{option.count}</span>}
89
+ </button>
90
+ </li>
91
+ );
92
+ })}
93
+ {hasMore && (
94
+ <li className="udb-check-filter__more">{`+${options.length - shown.length} more`}</li>
95
+ )}
96
+ </ul>
97
+ );
98
+ }
99
+
100
+ export interface SingleSelectFilterListProps {
101
+ options: readonly FilterListOption[];
102
+ value: string | null;
103
+ onChange: (value: string | null) => void;
104
+ }
105
+
106
+ /** Radio-style list where one option (or none) is active. */
107
+ export function SingleSelectFilterList({ options, value, onChange }: SingleSelectFilterListProps) {
108
+ return (
109
+ <ul className="udb-check-filter" role="group">
110
+ {options.map((option) => {
111
+ const isActive = value === option.value;
112
+ return (
113
+ <li key={option.value}>
114
+ <button
115
+ type="button"
116
+ role="radio"
117
+ aria-checked={isActive}
118
+ className={isActive ? 'udb-check-filter__item udb-check-filter__item--checked' : 'udb-check-filter__item'}
119
+ onClick={() => onChange(isActive ? null : option.value)}
120
+ >
121
+ <span className="udb-check-filter__box udb-check-filter__box--radio" aria-hidden="true">
122
+ {isActive && <span className="udb-check-filter__radio-dot" />}
123
+ </span>
124
+ <span className="udb-check-filter__label">{option.label}</span>
125
+ {option.count !== undefined && <span className="udb-check-filter__count">{option.count}</span>}
126
+ </button>
127
+ </li>
128
+ );
129
+ })}
130
+ </ul>
131
+ );
132
+ }
@@ -0,0 +1,33 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { renderToString } from "react-dom/server";
3
+ import { MemoryRouter } from "react-router";
4
+ import { TabNav } from "./TabNav";
5
+
6
+ describe("TabNav", () => {
7
+ const items = [
8
+ { to: "/events", label: "Events", end: true },
9
+ { to: "/events/program", label: "Program" },
10
+ ];
11
+
12
+ it("renders nav links with the accessible label", () => {
13
+ const html = renderToString(
14
+ <MemoryRouter>
15
+ <TabNav items={items} />
16
+ </MemoryRouter>,
17
+ );
18
+ expect(html).toContain('aria-label="Section tabs"');
19
+ expect(html).toContain("Events");
20
+ expect(html).toContain("Program");
21
+ expect(html).toContain('href="/events"');
22
+ expect(html).toContain('href="/events/program"');
23
+ });
24
+
25
+ it("marks the matching route active", () => {
26
+ const html = renderToString(
27
+ <MemoryRouter initialEntries={["/events/program"]}>
28
+ <TabNav items={items} />
29
+ </MemoryRouter>,
30
+ );
31
+ expect(html).toContain("udb-tabnav__tab--active");
32
+ });
33
+ });
@@ -0,0 +1,33 @@
1
+ import { NavLink } from 'react-router';
2
+
3
+ export interface TabNavItem {
4
+ to: string;
5
+ label: string;
6
+ /** Should the route match only exactly (e.g. the index tab). */
7
+ end?: boolean;
8
+ }
9
+
10
+ export interface TabNavProps {
11
+ items: readonly TabNavItem[];
12
+ className?: string;
13
+ }
14
+
15
+ /** Route-connected section tabs with an active underline. */
16
+ export function TabNav({ items, className }: TabNavProps) {
17
+ return (
18
+ <nav className={className !== undefined ? `udb-tabnav ${className}` : 'udb-tabnav'} aria-label="Section tabs">
19
+ {items.map((item) => (
20
+ <NavLink
21
+ key={item.to}
22
+ to={item.to}
23
+ end={item.end}
24
+ className={({ isActive }) =>
25
+ isActive ? 'udb-tabnav__tab udb-tabnav__tab--active' : 'udb-tabnav__tab'
26
+ }
27
+ >
28
+ {item.label}
29
+ </NavLink>
30
+ ))}
31
+ </nav>
32
+ );
33
+ }
@@ -11,3 +11,13 @@ export { PageHeader } from './PageHeader';
11
11
  export type { PageHeaderProps, PageHeaderCrumb } from './PageHeader';
12
12
  export { SectionHeader } from './SectionHeader';
13
13
  export type { SectionHeaderProps } from './SectionHeader';
14
+ export { TabNav } from './TabNav';
15
+ export type { TabNavItem, TabNavProps } from './TabNav';
16
+ export { FilterPanel, FilterSection, CheckFilterList, SingleSelectFilterList } from './FilterPanel';
17
+ export type {
18
+ FilterPanelProps,
19
+ FilterSectionProps,
20
+ FilterListOption,
21
+ CheckFilterListProps,
22
+ SingleSelectFilterListProps,
23
+ } from './FilterPanel';
@@ -2709,3 +2709,174 @@
2709
2709
  margin-top: var(--udb-space-3);
2710
2710
  font-size: var(--udb-font-size-sm);
2711
2711
  }
2712
+
2713
+ /* ------------------------------------------------------------- tab nav */
2714
+
2715
+ .udb-tabnav {
2716
+ display: flex;
2717
+ gap: var(--udb-space-1);
2718
+ border-bottom: 1px solid var(--color-border);
2719
+ overflow-x: auto;
2720
+ scrollbar-width: none;
2721
+ }
2722
+ .udb-tabnav::-webkit-scrollbar {
2723
+ display: none;
2724
+ }
2725
+ .udb-tabnav__tab {
2726
+ position: relative;
2727
+ padding: var(--udb-space-3) var(--udb-space-4);
2728
+ font-size: var(--udb-font-size-md);
2729
+ font-weight: var(--font-weight-medium);
2730
+ color: var(--color-muted-foreground);
2731
+ white-space: nowrap;
2732
+ transition: color 0.15s ease-out;
2733
+ }
2734
+ .udb-tabnav__tab:hover {
2735
+ color: var(--color-foreground);
2736
+ }
2737
+ .udb-tabnav__tab--active {
2738
+ color: var(--color-primary);
2739
+ }
2740
+ .udb-tabnav__tab--active::after {
2741
+ content: '';
2742
+ position: absolute;
2743
+ left: var(--udb-space-3);
2744
+ right: var(--udb-space-3);
2745
+ bottom: -1px;
2746
+ height: 2px;
2747
+ border-radius: var(--udb-radius-pill);
2748
+ background: var(--color-primary);
2749
+ }
2750
+
2751
+ /* --------------------------------------------------------- filter panel */
2752
+
2753
+ .udb-filter-panel {
2754
+ background: var(--color-card);
2755
+ border: 1px solid var(--color-border);
2756
+ border-radius: var(--radius-lg);
2757
+ padding: var(--udb-space-4);
2758
+ }
2759
+ .udb-filter-panel__header {
2760
+ display: flex;
2761
+ align-items: center;
2762
+ justify-content: space-between;
2763
+ margin-bottom: var(--udb-space-3);
2764
+ }
2765
+ .udb-filter-panel__title {
2766
+ font-size: var(--udb-font-size-sm);
2767
+ font-weight: var(--font-weight-bold);
2768
+ }
2769
+ .udb-filter-panel__clear {
2770
+ border: none;
2771
+ background: transparent;
2772
+ padding: 0;
2773
+ font-family: inherit;
2774
+ font-size: var(--udb-font-size-xs);
2775
+ font-weight: var(--font-weight-medium);
2776
+ color: var(--color-primary);
2777
+ cursor: pointer;
2778
+ }
2779
+ .udb-filter-panel__clear:hover:not(:disabled) {
2780
+ text-decoration: underline;
2781
+ }
2782
+ .udb-filter-panel__clear:disabled {
2783
+ opacity: 0.45;
2784
+ cursor: default;
2785
+ }
2786
+ .udb-filter-panel__sections {
2787
+ display: flex;
2788
+ flex-direction: column;
2789
+ gap: var(--udb-space-4);
2790
+ }
2791
+ .udb-filter-section__title {
2792
+ margin: 0 0 var(--udb-space-2);
2793
+ font-size: var(--udb-font-size-xs);
2794
+ font-weight: var(--font-weight-bold);
2795
+ text-transform: uppercase;
2796
+ letter-spacing: 0.08em;
2797
+ color: var(--color-muted-foreground);
2798
+ }
2799
+ .udb-filter-section__body {
2800
+ display: flex;
2801
+ flex-direction: column;
2802
+ gap: var(--udb-space-2);
2803
+ }
2804
+
2805
+ /* --------------------------------------------------------- check list */
2806
+
2807
+ .udb-check-filter {
2808
+ list-style: none;
2809
+ padding: 0;
2810
+ margin: 0;
2811
+ display: flex;
2812
+ flex-direction: column;
2813
+ gap: 2px;
2814
+ }
2815
+ .udb-check-filter__item {
2816
+ display: flex;
2817
+ align-items: center;
2818
+ gap: var(--udb-space-2);
2819
+ width: 100%;
2820
+ padding: 6px var(--udb-space-2);
2821
+ margin-left: calc(var(--udb-space-2) * -1);
2822
+ border: none;
2823
+ border-radius: var(--radius-sm);
2824
+ background: transparent;
2825
+ font-family: inherit;
2826
+ font-size: var(--udb-font-size-md);
2827
+ color: var(--color-muted-foreground);
2828
+ text-align: left;
2829
+ cursor: pointer;
2830
+ transition: background 0.15s ease-out, color 0.15s ease-out;
2831
+ }
2832
+ .udb-check-filter__item:hover {
2833
+ background: var(--color-muted);
2834
+ color: var(--color-foreground);
2835
+ }
2836
+ .udb-check-filter__item--checked {
2837
+ color: var(--color-foreground);
2838
+ font-weight: var(--font-weight-medium);
2839
+ }
2840
+ .udb-check-filter__box {
2841
+ display: inline-flex;
2842
+ align-items: center;
2843
+ justify-content: center;
2844
+ width: 16px;
2845
+ height: 16px;
2846
+ border: 1.5px solid var(--color-border);
2847
+ border-radius: 4px;
2848
+ background: var(--color-card);
2849
+ color: var(--color-primary-foreground, #fff);
2850
+ flex: none;
2851
+ transition: background 0.15s ease-out, border-color 0.15s ease-out;
2852
+ }
2853
+ .udb-check-filter__item--checked .udb-check-filter__box {
2854
+ background: var(--color-primary);
2855
+ border-color: var(--color-primary);
2856
+ }
2857
+ .udb-check-filter__box--radio {
2858
+ border-radius: 50%;
2859
+ }
2860
+ .udb-check-filter__radio-dot {
2861
+ width: 6px;
2862
+ height: 6px;
2863
+ border-radius: 50%;
2864
+ background: var(--color-primary-foreground, #fff);
2865
+ }
2866
+ .udb-check-filter__label {
2867
+ flex: 1;
2868
+ min-width: 0;
2869
+ overflow: hidden;
2870
+ text-overflow: ellipsis;
2871
+ white-space: nowrap;
2872
+ }
2873
+ .udb-check-filter__count {
2874
+ font-size: var(--udb-font-size-xs);
2875
+ color: var(--color-muted-foreground);
2876
+ font-variant-numeric: tabular-nums;
2877
+ }
2878
+ .udb-check-filter__more {
2879
+ padding: 2px var(--udb-space-2);
2880
+ font-size: var(--udb-font-size-xs);
2881
+ color: var(--color-muted-foreground);
2882
+ }