@mrktg-common/internal-ui 0.0.0-stage → 1.2.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.
Files changed (85) hide show
  1. package/README.md +107 -2
  2. package/dist/Alert.d.ts +18 -0
  3. package/dist/Alert.js +12 -0
  4. package/dist/Badge.d.ts +28 -0
  5. package/dist/Badge.js +23 -0
  6. package/dist/Banner.d.ts +16 -0
  7. package/dist/Banner.js +6 -0
  8. package/dist/BrandName.d.ts +9 -0
  9. package/dist/BrandName.js +10 -0
  10. package/dist/Breadcrumbs.d.ts +20 -0
  11. package/dist/Breadcrumbs.js +9 -0
  12. package/dist/Button.d.ts +25 -0
  13. package/dist/Button.js +25 -0
  14. package/dist/Card.d.ts +22 -0
  15. package/dist/Card.js +10 -0
  16. package/dist/CenteredCard.d.ts +12 -0
  17. package/dist/CenteredCard.js +6 -0
  18. package/dist/ChangeBlock.d.ts +16 -0
  19. package/dist/ChangeBlock.js +8 -0
  20. package/dist/CopyField.d.ts +16 -0
  21. package/dist/CopyField.js +20 -0
  22. package/dist/Dropzone.d.ts +31 -0
  23. package/dist/Dropzone.js +66 -0
  24. package/dist/EmptyState.d.ts +13 -0
  25. package/dist/EmptyState.js +5 -0
  26. package/dist/EnvTag.d.ts +18 -0
  27. package/dist/EnvTag.js +11 -0
  28. package/dist/Field.d.ts +52 -0
  29. package/dist/Field.js +47 -0
  30. package/dist/FileRow.d.ts +29 -0
  31. package/dist/FileRow.js +9 -0
  32. package/dist/Header.d.ts +46 -0
  33. package/dist/Header.js +11 -0
  34. package/dist/Menu.d.ts +36 -0
  35. package/dist/Menu.js +47 -0
  36. package/dist/Modal.d.ts +26 -0
  37. package/dist/Modal.js +66 -0
  38. package/dist/MultiSelectMenu.d.ts +32 -0
  39. package/dist/MultiSelectMenu.js +17 -0
  40. package/dist/Popover.d.ts +26 -0
  41. package/dist/Popover.js +42 -0
  42. package/dist/Progress.d.ts +26 -0
  43. package/dist/Progress.js +39 -0
  44. package/dist/ResultReport.d.ts +30 -0
  45. package/dist/ResultReport.js +13 -0
  46. package/dist/Search.d.ts +12 -0
  47. package/dist/Search.js +21 -0
  48. package/dist/Segmented.d.ts +27 -0
  49. package/dist/Segmented.js +17 -0
  50. package/dist/SelectMenu.d.ts +52 -0
  51. package/dist/SelectMenu.js +154 -0
  52. package/dist/Skeleton.d.ts +12 -0
  53. package/dist/Skeleton.js +6 -0
  54. package/dist/Spinner.d.ts +12 -0
  55. package/dist/Spinner.js +10 -0
  56. package/dist/Steps.d.ts +21 -0
  57. package/dist/Steps.js +11 -0
  58. package/dist/Switch.d.ts +11 -0
  59. package/dist/Switch.js +14 -0
  60. package/dist/Table.d.ts +59 -0
  61. package/dist/Table.js +39 -0
  62. package/dist/Tabs.d.ts +20 -0
  63. package/dist/Tabs.js +25 -0
  64. package/dist/Toast.d.ts +38 -0
  65. package/dist/Toast.js +79 -0
  66. package/dist/Tooltip.d.ts +18 -0
  67. package/dist/Tooltip.js +58 -0
  68. package/dist/UserMenu.d.ts +27 -0
  69. package/dist/UserMenu.js +28 -0
  70. package/dist/components.css +526 -0
  71. package/dist/cx.d.ts +2 -0
  72. package/dist/cx.js +4 -0
  73. package/dist/files.d.ts +4 -0
  74. package/dist/files.js +28 -0
  75. package/dist/index.d.ts +74 -0
  76. package/dist/index.js +39 -0
  77. package/dist/portal.d.ts +8 -0
  78. package/dist/portal.js +12 -0
  79. package/dist/theme.d.ts +25 -0
  80. package/dist/theme.js +68 -0
  81. package/dist/themeScript.d.ts +9 -0
  82. package/dist/themeScript.js +13 -0
  83. package/dist/tokens.css +118 -0
  84. package/package.json +66 -4
  85. package/tokens/tokens.json +589 -0
package/README.md CHANGED
@@ -1,3 +1,108 @@
1
- # Temporary Holding Version
1
+ # @mrktg-common/internal-ui
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Общий интерфейс внутренних инструментов маркетинга: Landings Admin и LP Constructor. Здесь живут и пакет,
4
+ и дизайн-система Internal ui: токены, классы компонентов, карточки с правилами и превью. Артефакт системы
5
+ в claude.ai собирается из этого репозитория, версия у пакета и системы одна.
6
+
7
+ ## Что внутри
8
+
9
+ - `tokens.css` — переменные обеих тем, генерируется из `tokens/tokens.json`.
10
+ - `components.css` — `styles/components.css`: глобальные классы компонентов (в системе это `bundle.css`).
11
+ - React-компоненты — тонкие обёртки над этими классами: разметка как в карточках системы, поведение
12
+ по их README (таймеры тостов, фокус в модалке, клавиатура в списках, выключенное с причиной).
13
+
14
+ `design/canvas.css` (вспомогательные классы холстов дизайна, `.is-still`) в пакет не входит.
15
+
16
+ ## Дизайн-система
17
+
18
+ - `design/README.md` — бренд-бук, `design/sections/*.md` — разделы (контраст, паттерны, переход продуктов);
19
+ - `design/components/<Comp>/` — карточка компонента: `README.md` с правилами и `preview.html` с превью в обеих темах;
20
+ - `design/cover.html` — обложка, `design/canvas.css` — классы для холстов;
21
+ - `CHANGELOG.md` — общий changelog пакета и системы.
22
+
23
+ `npm run design` собирает артефакт в `design-dist/project/` (в гит не попадает): токены с версией из
24
+ `package.json` и ссылкой на коммит, `tokens.css` тем же генератором, что и пакет, классы, карточки, разделы
25
+ и `CHANGELOG.md` разделом. Тест проверяет, что пакет и артефакт получают одинаковые `tokens.css` и классы.
26
+
27
+ ## Подключение
28
+
29
+ ```bash
30
+ npm i @mrktg-common/internal-ui
31
+ ```
32
+
33
+ Пакет ставится из публичного npm собранным (`dist/`). Peer-зависимости: `react` и `react-dom` 19,
34
+ `lucide-react` 1.
35
+
36
+ Стили импортируются один раз в корне приложения, до стилей продукта:
37
+
38
+ ```ts
39
+ import '@mrktg-common/internal-ui/tokens.css';
40
+ import '@mrktg-common/internal-ui/components.css';
41
+ ```
42
+
43
+ Базовые правила системы (box-sizing, цвет ссылок, шрифт) заданы внутри `.app`, поэтому корневой
44
+ элемент приложения получает класс `app`. Шрифт Inter 400–700 подключается продуктом (Google Fonts).
45
+
46
+ Тема — атрибут `data-theme` на `<html>`. `ThemeProvider` в корне ставит его, помнит выбор
47
+ (по умолчанию в localStorage, можно передать своё хранилище) и в режиме System следит за системной
48
+ темой. Чтобы не мигало при загрузке, в `<head>` вставляется `themeScript()`.
49
+
50
+ ```tsx
51
+ import { ThemeProvider, ToastProvider, Header, HeaderNav, UserMenu } from '@mrktg-common/internal-ui';
52
+ import { Blocks } from 'lucide-react';
53
+
54
+ <ThemeProvider>
55
+ <ToastProvider>
56
+ <div className="app">
57
+ <Header productName="LP Constructor" productIcon={Blocks} homeHref="/" link={RouterLink} end={<UserMenu email={user.email} />}>
58
+ <HeaderNav link={RouterLink} items={[{ href: '/', label: 'Projects', current: true }]} />
59
+ </Header>
60
+ </div>
61
+ </ToastProvider>
62
+ </ThemeProvider>
63
+ ```
64
+
65
+ `link` — компонент ссылки роутера продукта (`react-router`, `next/link`), по умолчанию обычный `<a>`.
66
+
67
+ ## Компоненты
68
+
69
+ Header, HeaderNav, Breadcrumbs, UserMenu, Button, Field, TextField, Input, Textarea, Checkbox, Search, Switch,
70
+ Segmented, Popover, Menu, SelectMenu, MultiSelectMenu, Badge, StatusBadge, EnvPill, EnvChip,
71
+ BrandName, Alert, Banner, ToastProvider и useToast, Tooltip, Skeleton, EmptyState, Spinner, Loading,
72
+ CenteredCard, Card, Facts, Tabs, CopyField, Modal, ChangeBlock, Table, TableCell; для файлов и долгих
73
+ операций — Dropzone, FileRow, Progress, ProgressLabel, Countdown, ResultReport, ReportRow, Steps, Step.
74
+
75
+ Правила, которые компоненты держат сами:
76
+
77
+ - выключенное с причиной — `aria-disabled` плюс причина (подсказка, `menu-hint`, `aria-describedby`):
78
+ фокус остаётся, нажатие не проходит; нативный `disabled` — только где причина очевидна;
79
+ - оверлеи и стопка тостов рендерятся в портал в `body` с классом `.is-fixed`;
80
+ - тосты: 6 с с паузой при наведении и фокусе, с Undo 10 с, ошибки висят до закрытия, не больше трёх;
81
+ - зелёный только для «живёт на продакшене»: `StatusBadge status="live" production={false}` нейтральный,
82
+ пройденная проверка в отчёте и готовый шаг — тоже нейтральные;
83
+ - Dropzone проверяет тип и размер файла до отправки, ошибка — строкой под зоной.
84
+
85
+ Продуктовые экраны держат свои CSS-модули и не переопределяют классы системы. То, чего в системе нет
86
+ (например, экран результата в окне публикации конструктора), остаётся в продукте, пока не появится здесь.
87
+
88
+ ## Разработка
89
+
90
+ ```bash
91
+ npm run lint
92
+ npm run typecheck
93
+ npm test
94
+ npm run build # dist/: index.js, *.d.ts, tokens.css, components.css
95
+ ```
96
+
97
+ ## Изменения
98
+
99
+ Одно изменение — один MR: CSS в `styles/components.css` (или токен в `tokens/tokens.json`), компонент в
100
+ `src/` с тестом, карточка в `design/components/` и запись в `CHANGELOG.md`. Версия — в `package.json`,
101
+ `meta.release` в `tokens.json` и верхнем разделе `CHANGELOG.md` одновременно (тест сверяет): patch — правка
102
+ без изменения разметки, minor — добавление, major — изменение класса, токена или разметки.
103
+
104
+ ## Публикация
105
+
106
+ Тег `vX.Y.Z` на коммит с этой версией, затем `npm publish` (`prepublishOnly` прогоняет lint, typecheck,
107
+ тесты и сборку) и публикация `design-dist/project/` в артефакт системы в claude.ai — это делает сессия Claude
108
+ (`npm run design`, затем публикация файлов в артефакт с сохранением `createdOnFiles` из его текущего индекса).
@@ -0,0 +1,18 @@
1
+ import type { ReactNode } from 'react';
2
+ import { type LucideIcon } from 'lucide-react';
3
+ export type TAlertTone = 'info' | 'success' | 'warning' | 'danger';
4
+ export interface IAlertProps {
5
+ tone?: TAlertTone;
6
+ title?: ReactNode;
7
+ /** null — без иконки. */
8
+ icon?: LucideIcon | null;
9
+ /** Кнопки под текстом: Retry, Copy request ID. */
10
+ actions?: ReactNode;
11
+ className?: string;
12
+ children?: ReactNode;
13
+ }
14
+ /**
15
+ * Сообщение, привязанное к месту: форма, окно, пустая таблица. Ошибка — role="alert", остальное — status.
16
+ * Зелёный только для «живёт на продакшене».
17
+ */
18
+ export declare function Alert({ tone, title, icon, actions, className, children }: IAlertProps): import("react").JSX.Element;
package/dist/Alert.js ADDED
@@ -0,0 +1,12 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { CircleCheck, CircleX, Info, TriangleAlert } from 'lucide-react';
3
+ import { cx } from './cx.js';
4
+ const ALERT_ICON = { info: Info, success: CircleCheck, warning: TriangleAlert, danger: CircleX };
5
+ /**
6
+ * Сообщение, привязанное к месту: форма, окно, пустая таблица. Ошибка — role="alert", остальное — status.
7
+ * Зелёный только для «живёт на продакшене».
8
+ */
9
+ export function Alert({ tone = 'info', title, icon, actions, className, children }) {
10
+ const Icon = icon === null ? null : (icon ?? ALERT_ICON[tone]);
11
+ return (_jsxs("div", { className: cx('alert', `alert-${tone}`, className), role: tone === 'danger' ? 'alert' : 'status', children: [Icon && _jsx(Icon, { className: "ic", "aria-hidden": true }), _jsxs("div", { className: "alert-body", children: [title !== undefined && _jsx("div", { className: "alert-title", children: title }), children, actions !== undefined && _jsx("div", { className: "alert-actions", children: actions })] })] }));
12
+ }
@@ -0,0 +1,28 @@
1
+ import type { ReactNode } from 'react';
2
+ import { type LucideIcon } from 'lucide-react';
3
+ export type TBadgeTone = 'neutral' | 'outline' | 'accent' | 'success' | 'warning' | 'danger' | 'solid';
4
+ export type TBadgeMark = 'dot' | 'hollow' | 'spinner';
5
+ export interface IBadgeProps {
6
+ tone?: TBadgeTone;
7
+ /** Знак перед словом, чтобы статус читался без цвета. */
8
+ mark?: TBadgeMark;
9
+ icon?: LucideIcon;
10
+ title?: string;
11
+ className?: string;
12
+ children: ReactNode;
13
+ }
14
+ export declare function Badge({ tone, mark, icon: Icon, title, className, children }: IBadgeProps): import("react").JSX.Element;
15
+ export type TStatus = 'live' | 'draft' | 'publishing' | 'error' | 'unpublished' | 'archived' | 'previous' | 'never-published' | 'publishing-failed';
16
+ export interface IStatusBadgeProps {
17
+ status: TStatus;
18
+ /**
19
+ * Live вне продакшена (Test, dev-админка) нейтральный с точкой: зелёный только у того,
20
+ * что видят снаружи. Для остальных статусов не влияет.
21
+ */
22
+ production?: boolean;
23
+ /** Подпись вместо стандартной: «Live · v3», «Live on test». */
24
+ label?: ReactNode;
25
+ title?: string;
26
+ }
27
+ /** Статус из согласованного набора: у каждого свой знак, набор читается и в оттенках серого. */
28
+ export declare function StatusBadge({ status, production, label, title }: IStatusBadgeProps): import("react").JSX.Element;
package/dist/Badge.js ADDED
@@ -0,0 +1,23 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Archive, CircleX, EyeOff } from 'lucide-react';
3
+ import { cx } from './cx.js';
4
+ export function Badge({ tone = 'neutral', mark, icon: Icon, title, className, children }) {
5
+ return (_jsxs("span", { className: cx('badge', `b-${tone}`, className), title: title, children: [mark === 'dot' && _jsx("span", { className: "dot", "aria-hidden": true }), mark === 'hollow' && _jsx("span", { className: "dot dot-hollow", "aria-hidden": true }), mark === 'spinner' && _jsx("span", { className: "mini-spin", "aria-hidden": true }), Icon && _jsx(Icon, { className: "ic ic-xs", "aria-hidden": true }), children] }));
6
+ }
7
+ const STATUS = {
8
+ live: { tone: 'success', mark: 'dot', label: 'Live' },
9
+ draft: { tone: 'neutral', mark: 'hollow', label: 'Draft' },
10
+ publishing: { tone: 'accent', mark: 'spinner', label: 'Publishing' },
11
+ error: { tone: 'danger', icon: CircleX, label: 'Error' },
12
+ 'publishing-failed': { tone: 'danger', icon: CircleX, label: 'Publishing failed' },
13
+ unpublished: { tone: 'warning', icon: EyeOff, label: 'Unpublished' },
14
+ archived: { tone: 'outline', icon: Archive, label: 'Archived' },
15
+ previous: { tone: 'neutral', label: 'Previous' },
16
+ 'never-published': { tone: 'outline', label: 'Never published' },
17
+ };
18
+ /** Статус из согласованного набора: у каждого свой знак, набор читается и в оттенках серого. */
19
+ export function StatusBadge({ status, production = true, label, title }) {
20
+ const look = STATUS[status];
21
+ const tone = status === 'live' && !production ? 'neutral' : look.tone;
22
+ return (_jsx(Badge, { tone: tone, mark: look.mark, icon: look.icon, title: title, children: label ?? look.label }));
23
+ }
@@ -0,0 +1,16 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { LucideIcon } from 'lucide-react';
3
+ export type TBannerTone = 'neutral' | 'accent' | 'warning' | 'danger';
4
+ export interface IBannerProps {
5
+ tone?: TBannerTone;
6
+ /** Иконка слева; для идущего процесса — busy со спиннером. */
7
+ icon?: LucideIcon;
8
+ busy?: boolean;
9
+ actions?: ReactNode;
10
+ /** Под тулбаром редактора: отступ 16 вместо 32. */
11
+ tight?: boolean;
12
+ className?: string;
13
+ children: ReactNode;
14
+ }
15
+ /** Состояние всей страницы или редактора, во всю ширину; висит, пока состояние не изменится. */
16
+ export declare function Banner({ tone, icon: Icon, busy, actions, tight, className, children }: IBannerProps): import("react").JSX.Element;
package/dist/Banner.js ADDED
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cx } from './cx.js';
3
+ /** Состояние всей страницы или редактора, во всю ширину; висит, пока состояние не изменится. */
4
+ export function Banner({ tone = 'neutral', icon: Icon, busy = false, actions, tight = false, className, children }) {
5
+ return (_jsxs("div", { className: cx('banner', `banner-${tone}`, tight && 'banner-tight', className), role: tone === 'danger' ? 'alert' : 'status', children: [busy ? _jsx("span", { className: "spin16", "aria-hidden": true }) : Icon && _jsx(Icon, { className: "ic", "aria-hidden": true }), _jsx("span", { className: "banner-text", children: children }), actions !== undefined && _jsx("div", { className: "banner-actions", children: actions })] }));
6
+ }
@@ -0,0 +1,9 @@
1
+ export interface IBrandNameProps {
2
+ name: string;
3
+ /** Фавиконка из пакета брендов; пока грузится или не загрузилась — плитка с буквой. */
4
+ favicon?: string;
5
+ large?: boolean;
6
+ className?: string;
7
+ }
8
+ /** Бренд: фавиконка 16 px и название; в узкой ячейке обрезается с подсказкой. */
9
+ export declare function BrandName({ name, favicon, large, className }: IBrandNameProps): import("react").JSX.Element;
@@ -0,0 +1,10 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useState } from 'react';
4
+ import { cx } from './cx.js';
5
+ /** Бренд: фавиконка 16 px и название; в узкой ячейке обрезается с подсказкой. */
6
+ export function BrandName({ name, favicon, large = false, className }) {
7
+ const [failed, setFailed] = useState(false);
8
+ const favClass = cx('fav', large && 'fav-lg');
9
+ return (_jsxs("span", { className: cx('brand', className), title: name, children: [favicon !== undefined && !failed ? (_jsx("img", { className: favClass, src: favicon, alt: "", onError: () => setFailed(true) })) : (_jsx("span", { className: favClass, "aria-hidden": true, children: name.charAt(0).toUpperCase() })), _jsx("span", { className: "name", children: name })] }));
10
+ }
@@ -0,0 +1,20 @@
1
+ import { type MouseEvent } from 'react';
2
+ import { type TLinkComponent } from './Header.tsx';
3
+ export type TCrumb = {
4
+ label: string;
5
+ href: string;
6
+ /** Перехват перехода: например, редактор спрашивает про несохранённые изменения. */
7
+ onClick?: (event: MouseEvent<HTMLAnchorElement>) => void;
8
+ };
9
+ export interface IBreadcrumbsProps {
10
+ /** Путь до текущей страницы, ссылками. */
11
+ items: TCrumb[];
12
+ /** Где вы сейчас: не ссылка, обрезается с полным текстом в title. */
13
+ current: string;
14
+ /** lg — в шапке: 14 px, текущий пункт — название документа. */
15
+ size?: 'md' | 'lg';
16
+ link?: TLinkComponent;
17
+ className?: string;
18
+ }
19
+ /** Где вы и путь назад. Разделитель — chevron-right, декоративный. */
20
+ export declare function Breadcrumbs({ items, current, size, link: Link, className }: IBreadcrumbsProps): import("react").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Fragment } from 'react';
3
+ import { ChevronRight } from 'lucide-react';
4
+ import { cx } from './cx.js';
5
+ import { PlainLink } from './Header.js';
6
+ /** Где вы и путь назад. Разделитель — chevron-right, декоративный. */
7
+ export function Breadcrumbs({ items, current, size = 'md', link: Link = PlainLink, className }) {
8
+ return (_jsxs("nav", { className: cx('crumbs', size === 'lg' && 'crumbs-lg', className), "aria-label": "Breadcrumbs", children: [items.map((item) => (_jsxs(Fragment, { children: [_jsx(Link, { href: item.href, onClick: item.onClick, children: item.label }), _jsx(ChevronRight, { className: "ic", "aria-hidden": true })] }, item.href))), _jsx("span", { className: "here", "aria-current": "page", title: current, children: current })] }));
9
+ }
@@ -0,0 +1,25 @@
1
+ import type { ComponentProps } from 'react';
2
+ export type TButtonVariant = 'primary' | 'secondary' | 'ghost' | 'danger';
3
+ export type TButtonSize = 'sm' | 'md';
4
+ export interface IButtonStyle {
5
+ variant?: TButtonVariant;
6
+ size?: TButtonSize;
7
+ /** Квадратная кнопка с одной иконкой: подпись в aria-label и подсказке. */
8
+ iconOnly?: boolean;
9
+ /** Фильтр со значением (secondary) или включённый переключатель (ghost). */
10
+ active?: boolean;
11
+ block?: boolean;
12
+ /** Ghost-кнопка опасного действия краснеет при наведении. */
13
+ dangerHover?: boolean;
14
+ }
15
+ /** Классы кнопки для ссылок роутера, которые выглядят как кнопка. */
16
+ export declare function buttonClass({ variant, size, iconOnly, active, block, dangerHover }?: IButtonStyle, className?: string): string;
17
+ export interface IButtonProps extends ComponentProps<'button'>, IButtonStyle {
18
+ /** Идёт действие: спиннер перед подписью, нажатия не проходят. */
19
+ busy?: boolean;
20
+ }
21
+ /**
22
+ * Кнопка системы. Выключенная с причиной — aria-disabled (фокус и подсказка работают, нажатие нет);
23
+ * нативный disabled — только когда причина очевидна.
24
+ */
25
+ export declare function Button({ variant, size, iconOnly, active, block, dangerHover, busy, className, type, onClick, children, ...rest }: IButtonProps): import("react").JSX.Element;
package/dist/Button.js ADDED
@@ -0,0 +1,25 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { cx } from './cx.js';
4
+ /** Классы кнопки для ссылок роутера, которые выглядят как кнопка. */
5
+ export function buttonClass({ variant = 'secondary', size = 'md', iconOnly, active, block, dangerHover } = {}, className) {
6
+ return cx('btn', `btn-${variant}`, size === 'sm' && 'btn-sm', iconOnly && 'btn-icon', active && (variant === 'ghost' ? 'is-on' : 'is-active'), block && 'btn-block', dangerHover && 'danger-hover', className);
7
+ }
8
+ function isAriaDisabled(value) {
9
+ return value === true || value === 'true';
10
+ }
11
+ /**
12
+ * Кнопка системы. Выключенная с причиной — aria-disabled (фокус и подсказка работают, нажатие нет);
13
+ * нативный disabled — только когда причина очевидна.
14
+ */
15
+ export function Button({ variant, size, iconOnly, active, block, dangerHover, busy = false, className, type = 'button', onClick, children, ...rest }) {
16
+ const blocked = busy || isAriaDisabled(rest['aria-disabled']);
17
+ const handleClick = (event) => {
18
+ if (blocked) {
19
+ event.preventDefault();
20
+ return;
21
+ }
22
+ onClick?.(event);
23
+ };
24
+ return (_jsxs("button", { type: type, className: buttonClass({ variant, size, iconOnly, active, block, dangerHover }, className), ...rest, "aria-disabled": blocked ? true : rest['aria-disabled'], "aria-busy": busy || undefined, onClick: handleClick, children: [busy && _jsx("span", { className: cx('spinner', 'spinner-sm', variant === 'primary' && 'spinner-inverse'), "aria-hidden": true }), children] }));
25
+ }
package/dist/Card.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ import type { ReactNode } from 'react';
2
+ export interface ICardProps {
3
+ title?: ReactNode;
4
+ /** Одно ghost-действие справа в шапке. */
5
+ action?: ReactNode;
6
+ className?: string;
7
+ bodyClassName?: string;
8
+ children: ReactNode;
9
+ }
10
+ /** Поверхность для группы фактов или одного блока содержимого. Карточки не вкладываются. */
11
+ export declare function Card({ title, action, className, bodyClassName, children }: ICardProps): import("react").JSX.Element;
12
+ export type TFact = {
13
+ term: ReactNode;
14
+ value: ReactNode;
15
+ mono?: boolean;
16
+ title?: string;
17
+ };
18
+ /** Список фактов: серый термин в колонке 96 px и значение. facts — под блоком изменения в окнах подтверждения. */
19
+ export declare function Facts({ items, variant }: {
20
+ items: TFact[];
21
+ variant?: 'kv' | 'facts';
22
+ }): import("react").JSX.Element;
package/dist/Card.js ADDED
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cx } from './cx.js';
3
+ /** Поверхность для группы фактов или одного блока содержимого. Карточки не вкладываются. */
4
+ export function Card({ title, action, className, bodyClassName, children }) {
5
+ return (_jsxs("section", { className: cx('card', className), children: [(title !== undefined || action !== undefined) && (_jsxs("div", { className: "card-head", children: [_jsx("span", { className: "card-title", children: title }), action] })), _jsx("div", { className: cx('card-body', bodyClassName), children: children })] }));
6
+ }
7
+ /** Список фактов: серый термин в колонке 96 px и значение. facts — под блоком изменения в окнах подтверждения. */
8
+ export function Facts({ items, variant = 'kv' }) {
9
+ return (_jsx("dl", { className: variant, children: items.map((item, index) => (_jsxs("div", { style: { display: 'contents' }, children: [_jsx("dt", { children: item.term }), _jsx("dd", { className: cx(item.mono && 'mono trunc'), title: item.title, children: item.value })] }, index))) }));
10
+ }
@@ -0,0 +1,12 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { LucideIcon } from 'lucide-react';
3
+ export interface ICenteredCardProps {
4
+ icon: LucideIcon;
5
+ /** Красный круг под иконкой: фатальная ошибка. */
6
+ danger?: boolean;
7
+ title: ReactNode;
8
+ subtitle?: ReactNode;
9
+ children?: ReactNode;
10
+ }
11
+ /** Одна карточка посреди экрана: вход, нет доступа, фатальная ошибка. */
12
+ export declare function CenteredCard({ icon: Icon, danger, title, subtitle, children }: ICenteredCardProps): import("react").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cx } from './cx.js';
3
+ /** Одна карточка посреди экрана: вход, нет доступа, фатальная ошибка. */
4
+ export function CenteredCard({ icon: Icon, danger = false, title, subtitle, children }) {
5
+ return (_jsx("div", { className: "screen", children: _jsxs("div", { className: "cc", children: [_jsx("div", { className: cx('cc-icon', danger && 'cc-icon-danger'), children: _jsx(Icon, { className: "ic ic-lg", "aria-hidden": true }) }), _jsx("h1", { className: "cc-title", children: title }), subtitle !== undefined && _jsx("p", { className: "cc-sub", children: subtitle }), children] }) }));
6
+ }
@@ -0,0 +1,16 @@
1
+ import type { ReactNode } from 'react';
2
+ export type TChangeSide = {
3
+ label: ReactNode;
4
+ /** null — после действия на сайте ничего: «Not on the site» красным. */
5
+ value: ReactNode | null;
6
+ meta?: ReactNode;
7
+ };
8
+ export interface IChangeBlockProps {
9
+ from: TChangeSide;
10
+ to: TChangeSide;
11
+ /** Даты и имена мельче, чем номера версий. */
12
+ small?: boolean;
13
+ offLabel?: string;
14
+ }
15
+ /** «Было → станет» в окне подтверждения: что изменит действие, до нажатия. */
16
+ export declare function ChangeBlock({ from, to, small, offLabel }: IChangeBlockProps): import("react").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ArrowRight } from 'lucide-react';
3
+ import { cx } from './cx.js';
4
+ /** «Было → станет» в окне подтверждения: что изменит действие, до нажатия. */
5
+ export function ChangeBlock({ from, to, small = false, offLabel = 'Not on the site' }) {
6
+ const side = (item, target) => (_jsxs("div", { className: "change-side", children: [_jsx("span", { className: "change-label", children: item.label }), item.value === null ? (_jsx("span", { className: "change-off", children: offLabel })) : (_jsx("span", { className: cx('change-v', small && 'change-v-sm', target && 'is-target'), children: item.value })), item.meta !== undefined && _jsx("span", { className: "change-meta", children: item.meta })] }));
7
+ return (_jsxs("div", { className: "change", "aria-label": "What changes", children: [side(from, false), _jsx(ArrowRight, { className: "ic", "aria-hidden": true }), side(to, true)] }));
8
+ }
@@ -0,0 +1,16 @@
1
+ import { type CSSProperties } from 'react';
2
+ export declare const COPIED_MS = 2000;
3
+ export interface ICopyFieldProps {
4
+ value: string;
5
+ /** Что копируется, для скринридера: «Copy address» → «Address copied». */
6
+ what?: string;
7
+ size?: 'sm' | 'md';
8
+ /** Ссылка «Open» в новой вкладке; только для адресов. */
9
+ openHref?: string;
10
+ /** Адреса нет на сайте: зачёркнут, Open выключен с этой причиной, копировать можно. */
11
+ offReason?: string;
12
+ className?: string;
13
+ style?: CSSProperties;
14
+ }
15
+ /** Значение, которое копируют: адрес лендинга, id запроса. «Copied» с галочкой 2 с, нейтрально. */
16
+ export declare function CopyField({ value, what, size, openHref, offReason, className, style }: ICopyFieldProps): import("react").JSX.Element;
@@ -0,0 +1,20 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useRef, useState } from 'react';
4
+ import { Check, Copy, ExternalLink } from 'lucide-react';
5
+ import { cx } from './cx.js';
6
+ export const COPIED_MS = 2000;
7
+ /** Значение, которое копируют: адрес лендинга, id запроса. «Copied» с галочкой 2 с, нейтрально. */
8
+ export function CopyField({ value, what = 'Address', size = 'md', openHref, offReason, className, style }) {
9
+ const [copied, setCopied] = useState(false);
10
+ const timer = useRef(undefined);
11
+ useEffect(() => () => window.clearTimeout(timer.current), []);
12
+ const copy = async () => {
13
+ await navigator.clipboard.writeText(value);
14
+ setCopied(true);
15
+ window.clearTimeout(timer.current);
16
+ timer.current = window.setTimeout(() => setCopied(false), COPIED_MS);
17
+ };
18
+ const off = offReason !== undefined;
19
+ return (_jsxs("div", { className: cx('copy', size === 'sm' && 'copy-sm', className), style: style, children: [_jsx("span", { className: cx('copy-url', off && 'is-off'), title: value, children: value }), openHref !== undefined && (off ? (_jsx("span", { className: "copy-act", role: "link", "aria-disabled": "true", "aria-label": offReason, title: offReason, children: _jsx(ExternalLink, { className: "ic ic-sm", "aria-hidden": true }) })) : (_jsx("a", { className: "copy-act", href: openHref, target: "_blank", rel: "noopener noreferrer", "aria-label": "Open in a new tab", title: "Open in a new tab", children: _jsx(ExternalLink, { className: "ic ic-sm", "aria-hidden": true }) }))), _jsxs("button", { type: "button", className: cx('copy-act', copied && 'is-done'), "aria-label": copied ? `${what} copied` : `Copy ${what.toLowerCase()}`, onClick: () => void copy(), children: [copied ? _jsx(Check, { className: "ic ic-sm", "aria-hidden": true }) : _jsx(Copy, { className: "ic ic-sm", "aria-hidden": true }), copied ? 'Copied' : 'Copy'] })] }));
20
+ }
@@ -0,0 +1,31 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type LucideIcon } from 'lucide-react';
3
+ export interface IDropzoneProps {
4
+ /** Что бросать: «Drop a zip here or choose a file». */
5
+ title: ReactNode;
6
+ /** Одна строка: тип и лимит. */
7
+ hint?: ReactNode;
8
+ /** Расширения и MIME: ['.zip'], ['.tsv', '.csv'], ['image/*']. Проверяются до отправки. */
9
+ accept?: readonly string[];
10
+ /** Лимит размера в байтах. */
11
+ maxBytes?: number;
12
+ /** Подходящий файл выбран или брошен. */
13
+ onFile: (file: File) => void;
14
+ /** Текст ошибки типа; по умолчанию — имя файла и допустимые типы. */
15
+ typeError?: (file: File) => string;
16
+ /** Внешняя ошибка (например, сервер не принял файл): строкой под зоной. */
17
+ error?: ReactNode;
18
+ /** Компактная зона в одну строку: панели и окна. */
19
+ compact?: boolean;
20
+ /** Зона выключена: причина встаёт вместо подсказки. */
21
+ disabledReason?: string;
22
+ icon?: LucideIcon;
23
+ /** Подпись кнопки выбора; в компактной зоне кнопки нет, выбор по клику на зону. */
24
+ chooseLabel?: string;
25
+ className?: string;
26
+ }
27
+ /**
28
+ * Куда бросить или выбрать файл. Тип и размер проверяются в браузере до отправки: ошибка — строкой
29
+ * под зоной, а зона остаётся готовой к другому файлу. Зона фокусируется, Enter и Space открывают выбор.
30
+ */
31
+ export declare function Dropzone({ title, hint, accept, maxBytes, onFile, typeError, error, compact, disabledReason, icon: Icon, chooseLabel, className, }: IDropzoneProps): import("react").JSX.Element;
@@ -0,0 +1,66 @@
1
+ 'use client';
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useId, useRef, useState } from 'react';
4
+ import { CircleX, Upload } from 'lucide-react';
5
+ import { cx } from './cx.js';
6
+ import { formatBytes, matchesAccept } from './files.js';
7
+ /**
8
+ * Куда бросить или выбрать файл. Тип и размер проверяются в браузере до отправки: ошибка — строкой
9
+ * под зоной, а зона остаётся готовой к другому файлу. Зона фокусируется, Enter и Space открывают выбор.
10
+ */
11
+ export function Dropzone({ title, hint, accept = [], maxBytes, onFile, typeError, error, compact = false, disabledReason, icon: Icon = Upload, chooseLabel = 'Choose file', className, }) {
12
+ const inputRef = useRef(null);
13
+ const hintId = useId();
14
+ const [over, setOver] = useState(false);
15
+ const [rejection, setRejection] = useState(null);
16
+ const off = disabledReason !== undefined;
17
+ const take = (file) => {
18
+ if (file === undefined)
19
+ return;
20
+ if (!matchesAccept(file, accept)) {
21
+ setRejection(typeError?.(file) ?? `${file.name} isn’t a supported file. Use ${accept.join(', ')}.`);
22
+ return;
23
+ }
24
+ if (maxBytes !== undefined && file.size > maxBytes) {
25
+ setRejection(`${file.name} is ${formatBytes(file.size)}. The limit is ${formatBytes(maxBytes)}.`);
26
+ return;
27
+ }
28
+ setRejection(null);
29
+ onFile(file);
30
+ };
31
+ const choose = () => {
32
+ if (!off)
33
+ inputRef.current?.click();
34
+ };
35
+ const handleKeyDown = (event) => {
36
+ if (event.target !== event.currentTarget || (event.key !== 'Enter' && event.key !== ' '))
37
+ return;
38
+ event.preventDefault();
39
+ choose();
40
+ };
41
+ const handleDragOver = (event) => {
42
+ if (off)
43
+ return;
44
+ event.preventDefault();
45
+ setOver(true);
46
+ };
47
+ const handleDrop = (event) => {
48
+ event.preventDefault();
49
+ setOver(false);
50
+ if (!off)
51
+ take(event.dataTransfer.files[0]);
52
+ };
53
+ const message = rejection ?? error;
54
+ const titleNode = _jsx("span", { className: "drop-title", children: over ? 'Drop to upload' : title });
55
+ const hintNode = (disabledReason ?? hint) !== undefined && _jsx("span", { className: "drop-hint", id: hintId, children: disabledReason ?? hint });
56
+ return (_jsxs("div", { className: "col", style: { gap: 'var(--space-2)' }, children: [_jsxs("div", { className: cx('drop', compact && 'drop-sm', over && 'is-over', message !== undefined && message !== null && 'is-error', className), role: "button", tabIndex: off ? -1 : 0, "aria-disabled": off || undefined, "aria-describedby": hintNode ? hintId : undefined, onClick: (event) => {
57
+ // Кнопка «Choose file» сама открывает выбор
58
+ if (event.target instanceof Element && event.target.closest('button'))
59
+ return;
60
+ choose();
61
+ }, onKeyDown: handleKeyDown, onDragOver: handleDragOver, onDragLeave: () => setOver(false), onDrop: handleDrop, children: [_jsx(Icon, { className: compact ? 'ic' : 'ic ic-lg', "aria-hidden": true }), compact ? (_jsxs("div", { className: "col", children: [titleNode, hintNode] })) : (_jsxs(_Fragment, { children: [titleNode, hintNode, !off && (_jsx("div", { className: "drop-actions", children: _jsx("button", { type: "button", className: "btn btn-secondary btn-sm", onClick: choose, children: chooseLabel }) }))] })), _jsx("input", { ref: inputRef, type: "file", hidden: true, accept: accept.length > 0 ? accept.join(',') : undefined, onChange: (event) => {
62
+ take(event.target.files?.[0]);
63
+ // Тот же файл можно выбрать снова после ошибки
64
+ event.target.value = '';
65
+ } })] }), message !== undefined && message !== null && (_jsxs("span", { className: "err", role: "alert", children: [_jsx(CircleX, { className: "ic ic-sm", "aria-hidden": true }), message] }))] }));
66
+ }
@@ -0,0 +1,13 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { LucideIcon } from 'lucide-react';
3
+ export interface IEmptyStateProps {
4
+ icon?: LucideIcon;
5
+ title: ReactNode;
6
+ text?: ReactNode;
7
+ /** Одно действие, два максимум. */
8
+ actions?: ReactNode;
9
+ /** Между текстом и действиями: например, id запроса с копированием. */
10
+ children?: ReactNode;
11
+ }
12
+ /** Что показывает пустой список: иконка, заголовок, одно предложение, действие. */
13
+ export declare function EmptyState({ icon: Icon, title, text, actions, children }: IEmptyStateProps): import("react").JSX.Element;
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /** Что показывает пустой список: иконка, заголовок, одно предложение, действие. */
3
+ export function EmptyState({ icon: Icon, title, text, actions, children }) {
4
+ return (_jsxs("div", { className: "empty", children: [Icon && _jsx(Icon, { className: "ic ic-xl", "aria-hidden": true }), _jsx("span", { className: "empty-title", children: title }), text !== undefined && _jsx("p", { className: "empty-text", children: text }), children, actions !== undefined && _jsx("div", { className: "empty-action", children: actions })] }));
5
+ }
@@ -0,0 +1,18 @@
1
+ export interface IEnvPillProps {
2
+ /** Контур: INT, RU. */
3
+ contour: string;
4
+ /** Окружение словом: Prod, Dev. */
5
+ environment: string;
6
+ dev: boolean;
7
+ /** Хост: на экране входа строкой, в шапке — в title. */
8
+ host?: string;
9
+ showHost?: boolean;
10
+ className?: string;
11
+ }
12
+ /** Где живёт админка: контур и окружение. Жёлтый значит «не продакшен» и всегда со словом. */
13
+ export declare function EnvPill({ contour, environment, dev, host, showHost, className }: IEnvPillProps): import("react").JSX.Element;
14
+ /** Короткий чип окружения перед опубликованным лендингом: PROD нейтральный, TEST жёлтый. */
15
+ export declare function EnvChip({ environment, className }: {
16
+ environment: 'prod' | 'test';
17
+ className?: string;
18
+ }): import("react").JSX.Element;
package/dist/EnvTag.js ADDED
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { TriangleAlert } from 'lucide-react';
3
+ import { cx } from './cx.js';
4
+ /** Где живёт админка: контур и окружение. Жёлтый значит «не продакшен» и всегда со словом. */
5
+ export function EnvPill({ contour, environment, dev, host, showHost = false, className }) {
6
+ return (_jsxs("span", { className: cx('env', dev ? 'env-dev' : 'env-prod', className), title: host === undefined ? `${contour} contour, ${environment}` : host, children: [_jsx("span", { className: "env-contour", children: contour }), showHost && host !== undefined && _jsx("span", { className: "env-host", children: host }), _jsxs("span", { className: "env-tag", children: [dev && _jsx(TriangleAlert, { className: "ic ic-xs", "aria-hidden": true }), environment] })] }));
7
+ }
8
+ /** Короткий чип окружения перед опубликованным лендингом: PROD нейтральный, TEST жёлтый. */
9
+ export function EnvChip({ environment, className }) {
10
+ return _jsx("span", { className: cx('env-chip', environment === 'prod' ? 'tag-prod' : 'tag-test', className), children: environment === 'prod' ? 'Prod' : 'Test' });
11
+ }