@mrktg-common/internal-ui 1.5.0 → 1.6.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/dist/Header.d.ts +14 -6
- package/dist/Header.js +3 -3
- package/dist/Table.d.ts +9 -1
- package/dist/Table.js +21 -1
- package/dist/components.css +2 -0
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
- package/tokens/tokens.json +1 -1
package/dist/Header.d.ts
CHANGED
|
@@ -12,10 +12,16 @@ export type TLinkProps = {
|
|
|
12
12
|
/** Ссылка роутера продукта (react-router, next/link); по умолчанию обычный <a>. */
|
|
13
13
|
export type TLinkComponent = (props: TLinkProps) => ReactNode;
|
|
14
14
|
export declare const PlainLink: TLinkComponent;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
/** Иконка плитки: globe у админки, blocks у конструктора. */
|
|
15
|
+
/** Знак продукта: иконка lucide на акцентной плитке или собственный знак продукта (26 px, без плитки). */
|
|
16
|
+
export type TProductMark = {
|
|
18
17
|
productIcon: LucideIcon;
|
|
18
|
+
productMark?: never;
|
|
19
|
+
} | {
|
|
20
|
+
productMark: ReactNode;
|
|
21
|
+
productIcon?: never;
|
|
22
|
+
};
|
|
23
|
+
type THeaderBaseProps = {
|
|
24
|
+
productName: string;
|
|
19
25
|
homeHref: string;
|
|
20
26
|
link?: TLinkComponent;
|
|
21
27
|
/** Только плитка без названия (редактор): название уходит в aria-label ссылки. */
|
|
@@ -29,9 +35,10 @@ export interface IHeaderProps {
|
|
|
29
35
|
/** Справа: кнопка пользователя с меню. */
|
|
30
36
|
end?: ReactNode;
|
|
31
37
|
className?: string;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
38
|
+
};
|
|
39
|
+
export type IHeaderProps = THeaderBaseProps & TProductMark;
|
|
40
|
+
/** Шапка 56 px: знак и название продукта, слот продукта, справа пользователь. */
|
|
41
|
+
export declare function Header({ productName, productIcon: Icon, productMark, homeHref, link: Link, compact, homeLabel, dev, children, end, className }: IHeaderProps): import("react").JSX.Element;
|
|
35
42
|
export type TNavItem = {
|
|
36
43
|
href: string;
|
|
37
44
|
label: string;
|
|
@@ -44,3 +51,4 @@ export declare function HeaderNav({ items, link: Link, 'aria-label': label }: {
|
|
|
44
51
|
link?: TLinkComponent;
|
|
45
52
|
'aria-label'?: string;
|
|
46
53
|
}): import("react").JSX.Element;
|
|
54
|
+
export {};
|
package/dist/Header.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cx } from './cx.js';
|
|
3
3
|
export const PlainLink = ({ href, children, ...rest }) => (_jsx("a", { href: href, ...rest, children: children }));
|
|
4
|
-
/** Шапка 56 px:
|
|
5
|
-
export function Header({ productName, productIcon: Icon, homeHref, link: Link = PlainLink, compact = false, homeLabel, dev = false, children, end, className }) {
|
|
6
|
-
return (_jsxs("header", { className: cx('hdr', dev && 'hdr-dev', className), children: [_jsxs("div", { className: "hdr-left", children: [_jsxs(Link, { href: homeHref, className: "logo", "aria-label": compact ? (homeLabel ?? productName) : undefined, children: [_jsx("span", { className: "logo-mark", children: _jsx(Icon, { className: "ic ic-sm", "aria-hidden": true }) }), !compact && productName] }), children] }), end !== undefined && _jsx("div", { className: "hdr-right", children: end })] }));
|
|
4
|
+
/** Шапка 56 px: знак и название продукта, слот продукта, справа пользователь. */
|
|
5
|
+
export function Header({ productName, productIcon: Icon, productMark, homeHref, link: Link = PlainLink, compact = false, homeLabel, dev = false, children, end, className }) {
|
|
6
|
+
return (_jsxs("header", { className: cx('hdr', dev && 'hdr-dev', className), children: [_jsxs("div", { className: "hdr-left", children: [_jsxs(Link, { href: homeHref, className: "logo", "aria-label": compact ? (homeLabel ?? productName) : undefined, children: [Icon !== undefined ? (_jsx("span", { className: "logo-mark", children: _jsx(Icon, { className: "ic ic-sm", "aria-hidden": true }) })) : (_jsx("span", { className: "logo-img", "aria-hidden": true, children: productMark })), !compact && productName] }), children] }), end !== undefined && _jsx("div", { className: "hdr-right", children: end })] }));
|
|
7
7
|
}
|
|
8
8
|
/** Разделы продукта в шапке; текущий — aria-current="page". */
|
|
9
9
|
export function HeaderNav({ items, link: Link = PlainLink, 'aria-label': label = 'Sections' }) {
|
package/dist/Table.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ export type TTableColumn<T, K extends string> = {
|
|
|
15
15
|
header: ReactNode;
|
|
16
16
|
/** Ширина колонки (px или %); без неё колонка забирает остаток. */
|
|
17
17
|
width?: number | string;
|
|
18
|
+
/** Для колонки без width: уже этого таблица не сжимает остаток, а прокручивается. */
|
|
19
|
+
minWidth?: number;
|
|
18
20
|
sortable?: boolean;
|
|
19
21
|
/** Направление при первом клике: имена — A→Z, даты — новые сверху. */
|
|
20
22
|
defaultDirection?: TSortDirection;
|
|
@@ -36,7 +38,7 @@ export interface ITableProps<T, K extends string> {
|
|
|
36
38
|
rowClassName?: (row: T) => string | undefined;
|
|
37
39
|
loading?: boolean;
|
|
38
40
|
skeletonRows?: number;
|
|
39
|
-
/** Ширина, уже которой таблица прокручивается внутри рамки, а не страница. */
|
|
41
|
+
/** Ширина, уже которой таблица прокручивается внутри рамки, а не страница. Не меньше суммы колонок, см. tableMinWidth. */
|
|
40
42
|
minWidth?: number;
|
|
41
43
|
/** Вместо строк: пусто, ничего не найдено, ошибка. */
|
|
42
44
|
placeholder?: ReactNode;
|
|
@@ -48,6 +50,12 @@ export interface ITableProps<T, K extends string> {
|
|
|
48
50
|
loadingLabel?: string;
|
|
49
51
|
className?: string;
|
|
50
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Минимальная ширина таблицы: фиксированные колонки плюс минимум колонок без ширины, с поправкой на колонки в %.
|
|
55
|
+
* При table-layout: fixed колонка без ширины получает только остаток, и заданный вручную minWidth
|
|
56
|
+
* легко оставляет ей ноль: колонка пропадает.
|
|
57
|
+
*/
|
|
58
|
+
export declare function tableMinWidth<T, K extends string>(columns: TTableColumn<T, K>[], minWidth?: number): number;
|
|
51
59
|
/** Таблица списков: липкая шапка 36, строки 52, сортировка кнопками в заголовках. */
|
|
52
60
|
export declare function Table<T, K extends string>({ columns, rows, groups, rowKey, sort, onSortChange, onRowClick, rowClassName, loading, skeletonRows, minWidth, placeholder, footer, footerEnd, loadingLabel, 'aria-label': label, className, }: ITableProps<T, K>): import("react").JSX.Element;
|
|
53
61
|
/** Главный текст ячейки и строка под ним; обе обрезаются с подсказкой, таблица не переносит. */
|
package/dist/Table.js
CHANGED
|
@@ -4,6 +4,26 @@ import { ArrowDown, ArrowUp } from 'lucide-react';
|
|
|
4
4
|
import { cx } from './cx.js';
|
|
5
5
|
import { Skeleton } from './Skeleton.js';
|
|
6
6
|
const DEFAULT_SKELETON_ROWS = 7;
|
|
7
|
+
const FLEXIBLE_COLUMN_MIN_WIDTH = 120;
|
|
8
|
+
/**
|
|
9
|
+
* Минимальная ширина таблицы: фиксированные колонки плюс минимум колонок без ширины, с поправкой на колонки в %.
|
|
10
|
+
* При table-layout: fixed колонка без ширины получает только остаток, и заданный вручную minWidth
|
|
11
|
+
* легко оставляет ей ноль: колонка пропадает.
|
|
12
|
+
*/
|
|
13
|
+
export function tableMinWidth(columns, minWidth = 0) {
|
|
14
|
+
let fixed = 0;
|
|
15
|
+
let percent = 0;
|
|
16
|
+
for (const column of columns) {
|
|
17
|
+
if (typeof column.width === 'number')
|
|
18
|
+
fixed += column.width;
|
|
19
|
+
else if (typeof column.width === 'string' && column.width.endsWith('%'))
|
|
20
|
+
percent += Number.parseFloat(column.width);
|
|
21
|
+
else if (column.width === undefined)
|
|
22
|
+
fixed += column.minWidth ?? FLEXIBLE_COLUMN_MIN_WIDTH;
|
|
23
|
+
}
|
|
24
|
+
const total = percent > 0 && percent < 100 ? fixed / (1 - percent / 100) : fixed;
|
|
25
|
+
return Math.max(minWidth, Math.ceil(total));
|
|
26
|
+
}
|
|
7
27
|
const INTERACTIVE = 'a, button, input, select, textarea, label, [role="menu"], [role="listbox"]';
|
|
8
28
|
/** Таблица списков: липкая шапка 36, строки 52, сортировка кнопками в заголовках. */
|
|
9
29
|
export function Table({ columns, rows, groups, rowKey, sort, onSortChange, onRowClick, rowClassName, loading = false, skeletonRows = DEFAULT_SKELETON_ROWS, minWidth, placeholder, footer, footerEnd, loadingLabel, 'aria-label': label, className, }) {
|
|
@@ -23,7 +43,7 @@ export function Table({ columns, rows, groups, rowKey, sort, onSortChange, onRow
|
|
|
23
43
|
onRowClick?.(row);
|
|
24
44
|
};
|
|
25
45
|
const renderRow = (row) => (_jsx("tr", { className: cx(onRowClick !== undefined && 'is-link', rowClassName?.(row)), onClick: onRowClick === undefined ? undefined : handleRowClick(row), children: columns.map((column) => (_jsx("td", { className: cx(column.align === 'end' && 'end'), children: column.render(row) }, column.key))) }, rowKey(row)));
|
|
26
|
-
return (_jsxs("div", { className: cx('tbl-box', className), children: [showPlaceholder ? placeholder : (_jsxs("div", { className: "tbl-scroll", children: [_jsxs("table", { className: "tbl", style: minWidth
|
|
46
|
+
return (_jsxs("div", { className: cx('tbl-box', className), children: [showPlaceholder ? placeholder : (_jsxs("div", { className: "tbl-scroll", children: [_jsxs("table", { className: "tbl", style: { minWidth: tableMinWidth(columns, minWidth) }, "aria-label": label, "aria-busy": loading || undefined, children: [_jsx("thead", { children: _jsx("tr", { children: columns.map((column) => {
|
|
27
47
|
const sorted = sort?.key === column.key ? sort.direction : undefined;
|
|
28
48
|
return (_jsx("th", { scope: "col", className: cx(column.align === 'end' && 'end'), style: column.width === undefined ? undefined : { width: column.width }, "aria-sort": sorted === undefined ? undefined : sorted === 'asc' ? 'ascending' : 'descending', children: column.sortable && onSortChange !== undefined ? (_jsxs("button", { type: "button", className: "th-sort", onClick: () => toggleSort(column), children: [column.header, sorted === 'asc' && _jsx(ArrowUp, { className: "ic", "aria-hidden": true }), sorted === 'desc' && _jsx(ArrowDown, { className: "ic", "aria-hidden": true })] })) : column.header }, column.key));
|
|
29
49
|
}) }) }), _jsx("tbody", { children: loading
|
package/dist/components.css
CHANGED
|
@@ -46,6 +46,8 @@
|
|
|
46
46
|
.app a.logo:hover, .app a.logo.is-hover { color: var(--accent-text); text-decoration: none; }
|
|
47
47
|
.app a.logo:focus-visible, .app a.logo.is-focus { outline: none; box-shadow: var(--focus-ring); }
|
|
48
48
|
.logo-mark { display: flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: var(--radius-md); background: var(--accent); color: var(--accent-contrast); }
|
|
49
|
+
.logo-img { display: flex; width: 26px; height: 26px; flex-shrink: 0; }
|
|
50
|
+
.logo-img > img, .logo-img > svg { display: block; width: 100%; height: 100%; }
|
|
49
51
|
.nav { display: flex; align-items: center; gap: 2px; margin-left: var(--space-3); }
|
|
50
52
|
.nav a { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 var(--space-3); border-radius: var(--radius-md); font-size: var(--text-md); font-weight: 500; white-space: nowrap; }
|
|
51
53
|
.app .nav a { color: var(--text-muted); text-decoration: none; }
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { ThemeProvider, useTheme, localThemeStorage, resolveTheme } from './them
|
|
|
4
4
|
export { themeScript, isThemeChoice, THEME_STORAGE_KEY } from './themeScript.ts';
|
|
5
5
|
export type { TThemeChoice, TResolvedTheme, IThemeStorage, TThemeApi } from './theme.tsx';
|
|
6
6
|
export { Header, HeaderNav } from './Header.tsx';
|
|
7
|
-
export type { IHeaderProps, TLinkProps, TLinkComponent, TNavItem } from './Header.tsx';
|
|
7
|
+
export type { IHeaderProps, TLinkProps, TLinkComponent, TNavItem, TProductMark } from './Header.tsx';
|
|
8
8
|
export { Breadcrumbs } from './Breadcrumbs.tsx';
|
|
9
9
|
export type { IBreadcrumbsProps, TCrumb } from './Breadcrumbs.tsx';
|
|
10
10
|
export { UserMenu, initials } from './UserMenu.tsx';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrktg-common/internal-ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Общий интерфейс внутренних инструментов маркетинга (Landings Admin, LP Constructor): токены, классы компонентов и тонкие React-обёртки над ними.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|