@mrktg-common/internal-ui 1.5.0 → 1.5.1

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/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 === undefined ? undefined : { minWidth }, "aria-label": label, "aria-busy": loading || undefined, children: [_jsx("thead", { children: _jsx("tr", { children: columns.map((column) => {
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrktg-common/internal-ui",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "Общий интерфейс внутренних инструментов маркетинга (Landings Admin, LP Constructor): токены, классы компонентов и тонкие React-обёртки над ними.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -2,7 +2,7 @@
2
2
  "name": "Internal ui",
3
3
  "version": 1,
4
4
  "meta": {
5
- "release": "1.5.0",
5
+ "release": "1.5.1",
6
6
  "source": "lp-constructor src/styles/tokens.css + Landings Admin admin.css, merged 2026-10-12"
7
7
  },
8
8
  "color": {