feat(ui): add docking, viewport controls and composed settings

Add shared dock layouts, navigation cube, range bands, progress actions and comparison surfaces. Extend toolbar menus and loading composition, and align tokens, registry entries, documentation and the living catalog.
This commit is contained in:
Codex
2026-10-29 09:38:25 +03:00
parent a6e6c8f2d9
commit cb534dbe39
51 changed files with 2273 additions and 336 deletions
+54
View File
@@ -0,0 +1,54 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { createElement } from 'react';
import { renderToStaticMarkup } from 'react-dom/server';
import { SegmentedControl, SegmentedGroup, SegmentedButton, ProgressButton, LayerStackIndicator } from '../packages/ui-react/dist/index.js';
test('multiple segments allow all/none and never drop another active layer', () => {
let value = ['gaussian'];
const items = [{value:'gaussian',label:'Gaussian'},{value:'collision',label:'Коллизии'}];
const render = () => SegmentedControl({selectionMode:'multiple',value,items,label:'Слои',onChange:next=>{value=next;}});
render().props.children[1].props.onClick();
assert.deepEqual(value,['gaussian','collision']);
render().props.children[0].props.onClick();
assert.deepEqual(value,['collision']);
render().props.children[1].props.onClick();
assert.deepEqual(value,[]);
const html=renderToStaticMarkup(render());
assert.match(html,/role="group"/);
assert.doesNotMatch(html,/role="tab|aria-selected/);
assert.equal((html.match(/aria-pressed="false"/g)||[]).length,2);
});
test('single segment consumers retain one selected tab and scalar changes', () => {
let value='3d';
const element=SegmentedControl({value,items:[{value:'3d',label:'3D'},{value:'top',label:'Top'}],label:'View',onChange:next=>{value=next;}});
assert.match(renderToStaticMarkup(element),/role="tablist"/);
element.props.children[1].props.onClick();
assert.equal(value,'top');
});
test('pending progress preserves action name, rejects reentry and exposes a separate measured progressbar', () => {
const html=renderToStaticMarkup(createElement(ProgressButton,{label:'Проанализировать',icon:createElement(LayerStackIndicator),progress:{label:'Анализ поверхности · 29 / 96',value:29/96}}));
assert.match(html,/<button[^>]*aria-label="Проанализировать"[^>]*disabled=""/);
assert.match(html,/aria-busy="true"/);
assert.match(html,/aria-valuenow="30"/);
assert.match(html,/<\/button>[\s\S]*role="progressbar"/);
assert.match(html,/Анализ поверхности/);
const unknown=renderToStaticMarkup(createElement(ProgressButton,{label:'Анализ',progress:{label:'Подготовка'}}));
assert.doesNotMatch(unknown,/aria-valuenow/);
const idle=renderToStaticMarkup(createElement(ProgressButton,{label:'Анализ'}));
assert.doesNotMatch(idle,/disabled=""|role="progressbar"/);
});
test('mixed capsule keeps toggle and menu semantics distinct', () => {
const html=renderToStaticMarkup(createElement(SegmentedGroup,{label:'Layers'},
createElement(SegmentedButton,{active:true,'aria-pressed':true},'Gaussian'),
createElement(SegmentedButton,{'aria-expanded':false,'aria-haspopup':'dialog'},'Memory')));
assert.match(html,/role="group" aria-label="Layers"/);
assert.match(html,/aria-pressed="true"[^>]*data-active="true"/);
assert.match(html,/aria-expanded="false" aria-haspopup="dialog"/);
assert.equal((html.match(/aria-pressed/g)||[]).length,1);
assert.doesNotMatch(html,/role="tab/);
});