@umituz/web-dashboard 10.4.0 → 11.1.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.
@@ -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
- });
@@ -1,36 +0,0 @@
1
- import type { ReactNode } from "react";
2
- import { Link } from "react-router";
3
- import { ArrowRight } from "lucide-react";
4
-
5
- export interface NextStepLink {
6
- to: string;
7
- label: ReactNode;
8
- icon?: ReactNode;
9
- }
10
-
11
- export interface NextStepsProps {
12
- lead?: ReactNode;
13
- links: readonly NextStepLink[];
14
- className?: string;
15
- }
16
-
17
- export const NextSteps = ({ lead, links, className }: NextStepsProps) => {
18
- return (
19
- <div className={`flex flex-wrap items-center gap-x-4 gap-y-2${className ? ` ${className}` : ""}`}>
20
- {lead && (
21
- <span className="text-xs font-bold uppercase tracking-wider text-muted-foreground">
22
- {lead}
23
- </span>
24
- )}
25
- {links.map((link) => (
26
- <Link
27
- key={link.to}
28
- to={link.to}
29
- className="inline-flex items-center gap-1.5 rounded-full border border-border bg-card px-3.5 py-2 text-xs font-semibold text-foreground transition-colors hover:border-primary/50 hover:text-primary"
30
- >
31
- {link.label} {link.icon ?? <ArrowRight size={12} aria-hidden="true" />}
32
- </Link>
33
- ))}
34
- </div>
35
- );
36
- };
@@ -1,63 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { renderToString } from 'react-dom/server';
3
- import { render } from '@testing-library/react';
4
- import { MemoryRouter } from 'react-router';
5
- import { PageHeader } from './PageHeader';
6
-
7
- describe('PageHeader markup smoke', () => {
8
- it('renders kicker before title and omits it when undefined', () => {
9
- const html = renderToString(
10
- <PageHeader kicker="Customer area" title="Policies" subtitle="Your coverage at a glance" />,
11
- );
12
- const kickerAt = html.indexOf('udb-pageheader__kicker');
13
- const titleAt = html.indexOf('udb-pageheader__title');
14
- expect(kickerAt).toBeGreaterThan(-1);
15
- expect(kickerAt).toBeLessThan(titleAt);
16
- expect(html).toContain('Customer area');
17
-
18
- const bare = renderToString(<PageHeader title="Policies" />);
19
- expect(bare).not.toContain('udb-pageheader__kicker');
20
- });
21
-
22
- it('renders actions and breadcrumb nodes in their slots', () => {
23
- const html = renderToString(
24
- <PageHeader
25
- title="Claims"
26
- breadcrumbs={<a href="/policies">Policies</a>}
27
-
28
- actions={<button type="button">New claim</button>}
29
-
30
- />,
31
- );
32
- expect(html).toContain('udb-pageheader__breadcrumbs');
33
- expect(html).toContain('udb-pageheader__actions');
34
- expect(html).toContain('New claim');
35
- });
36
-
37
- it('renders crumb lists as in-app links', () => {
38
- const { container } = render(
39
- <MemoryRouter>
40
- <PageHeader
41
- title="Claim 92"
42
- breadcrumbs={[{ label: 'Policies', to: '/policies' }, { label: 'Claim 92' }]}
43
- />
44
- </MemoryRouter>,
45
-
46
- );
47
- expect(container.querySelectorAll("a[href='/policies']")).toHaveLength(1);
48
- expect(container.querySelector('.udb-pageheader__crumb a')?.textContent).toBe('Policies');
49
- });
50
-
51
- it('renders meta under the title block and omits it when undefined', () => {
52
- const html = renderToString(
53
- <PageHeader title="Policy AC-123" meta={<span>Renews 2027-01-15</span>} />,
54
- );
55
- const metaAt = html.indexOf('udb-pageheader__meta');
56
- expect(metaAt).toBeGreaterThan(-1);
57
- expect(html.indexOf('udb-pageheader__subtitle')).toBe(-1);
58
- expect(html).toContain('Renews 2027-01-15');
59
-
60
- const bare = renderToString(<PageHeader title="Policy AC-123" />);
61
- expect(bare).not.toContain('udb-pageheader__meta');
62
- });
63
- });
@@ -1,67 +0,0 @@
1
- import type { ReactNode } from "react";
2
- import { Link } from "react-router";
3
-
4
- export interface PageHeaderCrumb {
5
- label: string;
6
- to?: string;
7
- }
8
-
9
- export interface PageHeaderProps {
10
- kicker?: ReactNode;
11
- title?: ReactNode;
12
- subtitle?: ReactNode;
13
- description?: ReactNode;
14
- meta?: ReactNode;
15
- breadcrumbs?: ReactNode | readonly PageHeaderCrumb[];
16
- actions?: ReactNode;
17
- className?: string;
18
- }
19
-
20
- const isCrumbList = (value: ReactNode | readonly PageHeaderCrumb[]): value is readonly PageHeaderCrumb[] =>
21
- Array.isArray(value) && value.every((item) => typeof item === "object" && item !== null && "label" in item);
22
-
23
- export const PageHeader = ({
24
- kicker,
25
- title,
26
- subtitle,
27
- description,
28
- meta,
29
- breadcrumbs,
30
- actions,
31
- className,
32
- }: PageHeaderProps) => {
33
- const crumbNode =
34
- breadcrumbs === undefined
35
- ? undefined
36
- : isCrumbList(breadcrumbs)
37
- ? breadcrumbs.map((crumb, index) => (
38
- <span key={`${crumb.label}-${index}`} className="udb-pageheader__crumb">
39
- {crumb.to !== undefined ? <Link to={crumb.to}>{crumb.label}</Link> : crumb.label}
40
-
41
- </span>
42
-
43
- ))
44
- : breadcrumbs;
45
- return (
46
- <div className={`udb-pageheader${className ? ` ${className}` : ""}`}>
47
- {crumbNode !== undefined && <div className="udb-pageheader__breadcrumbs">{crumbNode}</div>}
48
-
49
- <div className="udb-pageheader__main">
50
- {kicker !== undefined && <p className="udb-pageheader__kicker">{kicker}</p>}
51
-
52
- {title !== undefined && <h1 className="udb-pageheader__title">{title}</h1>}
53
-
54
- {(subtitle ?? description) !== undefined && (
55
- <p className="udb-pageheader__subtitle">{subtitle ?? description}</p>
56
-
57
- )}
58
- {meta !== undefined && <div className="udb-pageheader__meta">{meta}</div>}
59
-
60
- </div>
61
-
62
- {actions !== undefined && <div className="udb-pageheader__actions">{actions}</div>}
63
-
64
- </div>
65
-
66
- );
67
- };
@@ -1,29 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { renderToString } from 'react-dom/server';
3
- import { SectionHeader } from './SectionHeader';
4
-
5
- describe('SectionHeader markup smoke', () => {
6
- it('renders an h2 title with optional kicker before it', () => {
7
- const html = renderToString(
8
- <SectionHeader kicker="This week" title="Reading" subtitle="Long-form practice" />,
9
- );
10
- const kickerAt = html.indexOf('udb-sectionheader__kicker');
11
- const titleAt = html.indexOf('<h2 class="udb-sectionheader__title"');
12
- expect(kickerAt).toBeGreaterThan(-1);
13
- expect(kickerAt).toBeLessThan(titleAt);
14
- expect(html).toContain('Long-form practice');
15
-
16
- const bare = renderToString(<SectionHeader title="Reading" />);
17
- expect(bare).not.toContain('udb-sectionheader__kicker');
18
- expect(bare).not.toContain('udb-sectionheader__subtitle');
19
- });
20
-
21
- it('renders actions in their slot and accepts description as subtitle alias', () => {
22
- const html = renderToString(
23
- <SectionHeader title="Writing" description="Timed tasks" actions={<button type="button">New</button>} />,
24
- );
25
- expect(html).toContain('udb-sectionheader__actions');
26
- expect(html).toContain('udb-sectionheader__subtitle');
27
- expect(html).toContain('New');
28
- });
29
- });
@@ -1,36 +0,0 @@
1
- import type { ReactNode } from "react";
2
-
3
- export interface SectionHeaderProps {
4
- kicker?: ReactNode;
5
- title?: ReactNode;
6
- subtitle?: ReactNode;
7
- description?: ReactNode;
8
- actions?: ReactNode;
9
- className?: string;
10
- }
11
-
12
- export const SectionHeader = ({
13
- kicker,
14
- title,
15
- subtitle,
16
- description,
17
- actions,
18
- className,
19
- }: SectionHeaderProps) => (
20
- <div className={`udb-sectionheader${className ? ` ${className}` : ""}`}>
21
- <div className="udb-sectionheader__main">
22
- {kicker !== undefined && <p className="udb-sectionheader__kicker">{kicker}</p>}
23
-
24
- {title !== undefined && <h2 className="udb-sectionheader__title">{title}</h2>}
25
-
26
- {(subtitle ?? description) !== undefined && (
27
- <p className="udb-sectionheader__subtitle">{subtitle ?? description}</p>
28
-
29
- )}
30
- </div>
31
-
32
- {actions !== undefined && <div className="udb-sectionheader__actions">{actions}</div>}
33
-
34
- </div>
35
-
36
- );
@@ -1,33 +0,0 @@
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
- });
@@ -1,31 +0,0 @@
1
- import { NavLink } from 'react-router';
2
-
3
- export interface TabNavItem {
4
- to: string;
5
- label: string;
6
- end?: boolean;
7
- }
8
-
9
- export interface TabNavProps {
10
- items: readonly TabNavItem[];
11
- className?: string;
12
- }
13
-
14
- export function TabNav({ items, className }: TabNavProps) {
15
- return (
16
- <nav className={className !== undefined ? `udb-tabnav ${className}` : 'udb-tabnav'} aria-label="Section tabs">
17
- {items.map((item) => (
18
- <NavLink
19
- key={item.to}
20
- to={item.to}
21
- end={item.end}
22
- className={({ isActive }) =>
23
- isActive ? 'udb-tabnav__tab udb-tabnav__tab--active' : 'udb-tabnav__tab'
24
- }
25
- >
26
- {item.label}
27
- </NavLink>
28
- ))}
29
- </nav>
30
- );
31
- }