@mrktg-common/internal-ui 1.3.2 → 1.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/dist/Badge.d.ts CHANGED
@@ -16,8 +16,8 @@ export type TStatus = 'live' | 'draft' | 'publishing' | 'error' | 'unpublished'
16
16
  export interface IStatusBadgeProps {
17
17
  status: TStatus;
18
18
  /**
19
- * Live вне продакшена (Test, dev-админка) нейтральный с точкой: зелёный только у того,
20
- * что видят снаружи. Для остальных статусов не влияет.
19
+ * @deprecated С 1.5.0 Live зелёный в любом окружении (где живой — говорят Dev-плашка и PROD / TEST),
20
+ * проп ни на что не влияет. Удалить из вызовов; уберётся в следующей мажорной версии.
21
21
  */
22
22
  production?: boolean;
23
23
  /** Подпись вместо стандартной: «Live · v3», «Live on test». */
@@ -25,4 +25,4 @@ export interface IStatusBadgeProps {
25
25
  title?: string;
26
26
  }
27
27
  /** Статус из согласованного набора: у каждого свой знак, набор читается и в оттенках серого. */
28
- export declare function StatusBadge({ status, production, label, title }: IStatusBadgeProps): import("react").JSX.Element;
28
+ export declare function StatusBadge({ status, label, title }: IStatusBadgeProps): import("react").JSX.Element;
package/dist/Badge.js CHANGED
@@ -16,8 +16,7 @@ const STATUS = {
16
16
  'never-published': { tone: 'outline', label: 'Never published' },
17
17
  };
18
18
  /** Статус из согласованного набора: у каждого свой знак, набор читается и в оттенках серого. */
19
- export function StatusBadge({ status, production = true, label, title }) {
19
+ export function StatusBadge({ status, label, title }) {
20
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 }));
21
+ return (_jsx(Badge, { tone: look.tone, mark: look.mark, icon: look.icon, title: title, children: label ?? look.label }));
23
22
  }
@@ -12,6 +12,14 @@ export type TMultiSelectOption<T extends string> = {
12
12
  export type TMultiSelectGroup<T extends string> = {
13
13
  /** Заголовок группы, не кликается. */
14
14
  label: string | null;
15
+ /**
16
+ * Группу выбирают целиком (бренды одного рынка): первой строкой под заголовком — «All INT brands»
17
+ * с тремя состояниями, на кнопке одна целая группа называется button («Brand: All INT»). Без label не действует.
18
+ */
19
+ wholeGroup?: {
20
+ option: string;
21
+ button: string;
22
+ };
15
23
  /** Оговорка про всю группу одной строкой под её вариантами. */
16
24
  note?: ReactNode;
17
25
  options: TMultiSelectOption<T>[];
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { Fragment, useState } from 'react';
4
- import { ChevronDown } from 'lucide-react';
3
+ import { Fragment, useEffect, useRef, useState } from 'react';
4
+ import { ChevronDown, Layers } from 'lucide-react';
5
5
  import { buttonClass } from './buttonClass.js';
6
6
  import { Popover } from './Popover.js';
7
7
  /**
@@ -12,6 +12,40 @@ export function MultiSelectMenu({ label, groups, value, onChange, size = 'md', w
12
12
  const [open, setOpen] = useState(false);
13
13
  const all = groups.flatMap((group) => group.options);
14
14
  const single = value.length === 1 ? all.find((option) => option.value === value[0]) : undefined;
15
+ const whole = wholeGroupOf(groups, value);
15
16
  const toggle = (option) => onChange(value.includes(option) ? value.filter((item) => item !== option) : [...value, option]);
16
- return (_jsxs(Popover, { open: open, onClose: () => setOpen(false), width: width, role: "listbox", "aria-label": label, "aria-multiselectable": true, scroll: true, trigger: _jsxs("button", { type: "button", className: buttonClass({ variant: 'secondary', size, active: value.length > 0 }), "aria-haspopup": "listbox", "aria-expanded": open, onClick: () => setOpen((current) => !current), children: [single === undefined ? label : `${label}: ${single.label}`, value.length > 1 && _jsx("span", { className: "count-pill", children: value.length }), _jsx(ChevronDown, { className: "ic ic-sm", "aria-hidden": true })] }), children: [groups.map((group, index) => (_jsxs(Fragment, { children: [index > 0 && _jsx("div", { className: "menu-sep" }), group.label !== null && _jsx("div", { className: "menu-label", children: group.label }), group.options.map((option) => (_jsxs(Fragment, { children: [_jsxs("label", { className: "menu-item", role: "option", "aria-selected": value.includes(option.value), children: [_jsx("input", { className: "checkbox", type: "checkbox", checked: value.includes(option.value), onChange: () => toggle(option.value) }), option.icon === undefined ? option.label : (_jsxs("span", { className: "brand", children: [option.icon, _jsx("span", { className: "name", children: option.label })] })), option.count !== undefined && _jsx("span", { className: "count", children: option.count })] }), option.hint !== undefined && _jsx("div", { className: "menu-hint", children: option.hint })] }, option.value))), group.note !== undefined && _jsx("div", { className: "menu-hint", children: group.note })] }, group.label ?? `group-${index}`))), _jsxs("div", { className: "menu-foot", style: { position: 'sticky', bottom: 'calc(-1 * var(--space-1))', background: 'var(--surface)', paddingBottom: 'var(--space-1)' }, children: [_jsx("button", { type: "button", className: "btn btn-ghost btn-sm", disabled: value.length === 0, onClick: () => onChange([]), children: "Clear" }), _jsx("span", { className: "hint", children: "Applies as you tick" })] })] }));
17
+ const toggleGroup = (group) => {
18
+ const options = group.options.map((option) => option.value);
19
+ onChange(groupState(group, value) === 'all' ? value.filter((item) => !options.includes(item)) : [...value, ...options.filter((option) => !value.includes(option))]);
20
+ };
21
+ return (_jsxs(Popover, { open: open, onClose: () => setOpen(false), width: width, role: "listbox", "aria-label": label, "aria-multiselectable": true, scroll: true, trigger: _jsxs("button", { type: "button", className: buttonClass({ variant: 'secondary', size, active: value.length > 0 }), "aria-haspopup": "listbox", "aria-expanded": open, onClick: () => setOpen((current) => !current), children: [whole !== null ? `${label}: ${whole}` : single === undefined ? label : `${label}: ${single.label}`, whole === null && value.length > 1 && _jsx("span", { className: "count-pill", children: value.length }), _jsx(ChevronDown, { className: "ic ic-sm", "aria-hidden": true })] }), children: [groups.map((group, index) => (_jsxs(Fragment, { children: [index > 0 && _jsx("div", { className: "menu-sep" }), group.label !== null && _jsx("div", { className: "menu-label", children: group.label }), group.label !== null && group.wholeGroup !== undefined && (_jsx(WholeGroupRow, { option: group.wholeGroup.option, state: groupState(group, value), options: group.options, onToggle: () => toggleGroup(group) })), group.options.map((option) => (_jsxs(Fragment, { children: [_jsxs("label", { className: "menu-item", role: "option", "aria-selected": value.includes(option.value), children: [_jsx("input", { className: "checkbox", type: "checkbox", checked: value.includes(option.value), onChange: () => toggle(option.value) }), option.icon === undefined ? option.label : (_jsxs("span", { className: "brand", children: [option.icon, _jsx("span", { className: "name", children: option.label })] })), option.count !== undefined && _jsx("span", { className: "count", children: option.count })] }), option.hint !== undefined && _jsx("div", { className: "menu-hint", children: option.hint })] }, option.value))), group.note !== undefined && _jsx("div", { className: "menu-hint", children: group.note })] }, group.label ?? `group-${index}`))), _jsxs("div", { className: "menu-foot", style: { position: 'sticky', bottom: 'calc(-1 * var(--space-1))', background: 'var(--surface)', paddingBottom: 'var(--space-1)' }, children: [_jsx("button", { type: "button", className: "btn btn-ghost btn-sm", disabled: value.length === 0, onClick: () => onChange([]), children: "Clear" }), _jsx("span", { className: "hint", children: "Applies as you tick" })] })] }));
22
+ }
23
+ function groupState(group, value) {
24
+ const picked = group.options.filter((option) => value.includes(option.value)).length;
25
+ if (picked === 0)
26
+ return 'none';
27
+ return picked === group.options.length ? 'all' : 'some';
28
+ }
29
+ /** Подпись кнопки для ровно одной целой группы и ничего больше; null — подпись как обычно. */
30
+ function wholeGroupOf(groups, value) {
31
+ const group = groups.find((candidate) => candidate.label !== null && candidate.wholeGroup !== undefined && candidate.options.length > 0 && groupState(candidate, value) === 'all');
32
+ return group?.wholeGroup !== undefined && value.length === group.options.length ? group.wholeGroup.button : null;
33
+ }
34
+ /** Сумма count вариантов группы; если хоть один — «≥ N», сумма тоже «≥». */
35
+ function groupCount(options) {
36
+ if (options.every((option) => option.count === undefined))
37
+ return undefined;
38
+ const atLeast = options.some((option) => typeof option.count === 'string');
39
+ const sum = options.reduce((total, option) => total + (typeof option.count === 'number' ? option.count : Number.parseInt(String(option.count ?? 0).replace(/\D/g, ''), 10) || 0), 0);
40
+ return atLeast ? `≥ ${sum}` : sum;
41
+ }
42
+ function WholeGroupRow({ option, state, options, onToggle }) {
43
+ const ref = useRef(null);
44
+ // indeterminate у чекбокса — только свойство DOM, атрибутом React его не ставит
45
+ useEffect(() => {
46
+ if (ref.current)
47
+ ref.current.indeterminate = state === 'some';
48
+ }, [state]);
49
+ const count = groupCount(options);
50
+ return (_jsxs("label", { className: "menu-item", role: "option", "aria-selected": state === 'all', children: [_jsx("input", { ref: ref, className: "checkbox", type: "checkbox", checked: state === 'all', "aria-checked": state === 'some' ? 'mixed' : state === 'all', onChange: onToggle }), options.some((item) => item.icon !== undefined) && _jsx(Layers, { className: "ic", "aria-hidden": true }), option, count !== undefined && _jsx("span", { className: "count", children: count })] }));
17
51
  }
package/dist/Toast.d.ts CHANGED
@@ -7,7 +7,7 @@ export type TToastAction = {
7
7
  icon?: LucideIcon;
8
8
  };
9
9
  export type TToast = {
10
- /** neutral — сохранено, удалено, скопировано; success — только «vN is live on Production». */
10
+ /** neutral — сохранено, удалено, скопировано; success — только «vN is live» (на Production или Test). */
11
11
  tone?: TToastTone;
12
12
  /** Иконка вместо стандартной для тона: корзина у удаления и т. п. */
13
13
  icon?: LucideIcon;
@@ -141,7 +141,7 @@
141
141
  .hint { font-size: var(--text-sm); line-height: var(--leading-normal); color: var(--text-muted); }
142
142
  .err { display: flex; align-items: center; gap: var(--space-1); font-size: var(--text-sm); color: var(--danger-text); }
143
143
  .err > .ic, .ok > .ic { align-self: flex-start; margin-top: 2px; }
144
- /* Positive check under a field: neutral, green is kept for “live on production”. */
144
+ /* Positive check under a field: neutral, green is kept for Live. */
145
145
  .ok { display: flex; align-items: center; gap: var(--space-1); font-size: var(--text-sm); color: var(--text-muted); }
146
146
  .control { width: 100%; min-height: var(--control-height-md); padding: 0 var(--space-3); border: 1px solid var(--border-strong);
147
147
  border-radius: var(--radius-md); background: var(--surface); color: var(--text); font: 400 var(--text-md) / 1.4 var(--font-ui);
@@ -371,7 +371,7 @@
371
371
  .app a.copy-act { color: var(--text-muted); text-decoration: none; }
372
372
  .copy-act:hover, .copy-act.is-hover, .app a.copy-act:hover { background: var(--bg-subtle); color: var(--text); text-decoration: none; }
373
373
  .copy-act:focus-visible, .copy-act.is-focus { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }
374
- /* Copied: neutral with a check; green is kept for “live on production”. */
374
+ /* Copied: neutral with a check; green is kept for Live. */
375
375
  .copy-act.is-done, .app a.copy-act.is-done { color: var(--text); background: var(--bg-subtle); }
376
376
  .copy-act:disabled, .copy-act[aria-disabled='true'] { opacity: 0.55; cursor: not-allowed; background: transparent; }
377
377
 
@@ -431,9 +431,8 @@
431
431
  .tbl tbody tr.is-link:hover td, .tbl tr.is-hover td { background: var(--surface-hover); }
432
432
  .tbl tr.is-archived td { background: var(--bg-subtle); }
433
433
  .tbl tr.is-archived .cell-main { color: var(--text-muted); }
434
- /* Live version row: green tint on production only; on Test and Dev it is neutral. */
434
+ /* Live version row: green tint in every environment; the version cell or the environment chip says where. */
435
435
  .tbl tr.is-current td { background: color-mix(in srgb, var(--success-soft) 60%, var(--surface)); }
436
- .tbl tr.is-current.is-nonprod td { background: var(--bg); }
437
436
  /* Group heading inside a table: Upcoming, Past 30 days. */
438
437
  .tbl tr.grp td { height: 32px; padding-top: 0; padding-bottom: 0; background: var(--bg); font-size: var(--text-sm); font-weight: 600; color: var(--text-muted); }
439
438
  .tbl tbody tr.grp:hover td { background: var(--bg); }
@@ -495,7 +494,7 @@
495
494
  .report-row + .report-row { border-top: 1px solid var(--border); }
496
495
  .report-row > .ic { margin-top: 2px; }
497
496
  .report-row > .report-text { flex: 1; min-width: 0; }
498
- /* A passed check is neutral: green is kept for “live on production”. */
497
+ /* A passed check is neutral: green is kept for Live. */
499
498
  .c-ok { color: var(--text-muted); }
500
499
  .c-info { color: var(--accent); }
501
500
  .c-warn { color: var(--warning); }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrktg-common/internal-ui",
3
- "version": "1.3.2",
3
+ "version": "1.5.0",
4
4
  "description": "Общий интерфейс внутренних инструментов маркетинга (Landings Admin, LP Constructor): токены, классы компонентов и тонкие React-обёртки над ними.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "repository": {
41
41
  "type": "git",
42
- "url": "git+ssh://git@gitlab.srv.team/marketing-frontend/marketing-common/internal-ui.git"
42
+ "url": "git+ssh://git@gitlab.srv.team/marketing-frontend/common/internal-ui.git"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "lucide-react": "^1",
@@ -2,7 +2,7 @@
2
2
  "name": "Internal ui",
3
3
  "version": 1,
4
4
  "meta": {
5
- "release": "1.3.2",
5
+ "release": "1.5.0",
6
6
  "source": "lp-constructor src/styles/tokens.css + Landings Admin admin.css, merged 2026-10-12"
7
7
  },
8
8
  "color": {
@@ -143,7 +143,7 @@
143
143
  "light": "#1f9d55",
144
144
  "dark": "#34c073"
145
145
  },
146
- "usage": "Icon only: toast icon for “vN is live on Production”. Green means live on production and nothing else."
146
+ "usage": "Icon only: toast icon for “vN is live”. Green means Live, in any environment, and nothing else."
147
147
  },
148
148
  {
149
149
  "name": "success-soft",
@@ -151,7 +151,7 @@
151
151
  "light": "#e6f6ec",
152
152
  "dark": "rgba(52, 192, 115, 0.16)"
153
153
  },
154
- "usage": "Fill of the Live on production badge and the live version row."
154
+ "usage": "Fill of the Live badge and the live version row, in any environment."
155
155
  },
156
156
  {
157
157
  "name": "success-text",
@@ -159,7 +159,7 @@
159
159
  "light": "#187a43",
160
160
  "dark": "#7ad9a3"
161
161
  },
162
- "usage": "Live on production badge text on success-soft (4.8:1 light, 6.9:1 dark)."
162
+ "usage": "Live badge text on success-soft (4.8:1 light, 6.9:1 dark)."
163
163
  },
164
164
  {
165
165
  "name": "warning",