feat(core,view): shape-option rules (plan C5) and pier selection rules (plan C6)
- C5: each member's options come from one table. Only the defaults (the 1단계 model) are selectable. The others show as disabled chips with 규칙 미정 (Q6). The member summary is built from the defaults. - C6: 전체 선택 acts only on visible, buildable piers; it reads 선택 해제 only when all of those are checked. A check survives a change of the type filter. The pier list scrolls past 300 px, for 20 piers. - Tests: defaults are the only choices; unknown options refused; the 20-pier mixed list with two failed piers; filter and check persistence. - Not verified in a browser. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
56362570ec
commit
5b162c2441
7 files changed
+228
-13
No files matched your search
@@ -0,0 +1,35 @@
|
||||
import type { PierType } from './types';
|
||||
|
||||
/** Pier list selection (spec §9 · plan C6): type filter, select-all over the visible piers, and checks that survive filtering. */
|
||||
export type TypeFilter = 'all' | PierType;
|
||||
|
||||
export interface Selectable {
|
||||
input: { type: PierType };
|
||||
/** null when the pier failed to build: such a pier cannot be checked. */
|
||||
model: unknown | null;
|
||||
checked: boolean;
|
||||
}
|
||||
|
||||
export function isVisible<T extends Selectable>(pier: T, filter: TypeFilter): boolean {
|
||||
return filter === 'all' || pier.input.type === filter;
|
||||
}
|
||||
|
||||
/** Piers the 전체 선택 button acts on: visible under the filter and buildable. */
|
||||
export function selectableVisible<T extends Selectable>(piers: T[], filter: TypeFilter): T[] {
|
||||
return piers.filter((p) => isVisible(p, filter) && p.model !== null);
|
||||
}
|
||||
|
||||
/** True when every selectable visible pier is checked (then the button reads 선택 해제). */
|
||||
export function allVisibleChecked<T extends Selectable>(piers: T[], filter: TypeFilter): boolean {
|
||||
const targets = selectableVisible(piers, filter);
|
||||
return targets.length > 0 && targets.every((p) => p.checked);
|
||||
}
|
||||
|
||||
/** Sets the check of every selectable visible pier. Hidden piers keep their check. */
|
||||
export function setVisibleChecked<T extends Selectable>(piers: T[], filter: TypeFilter, checked: boolean): T[] {
|
||||
return piers.map((p) => (isVisible(p, filter) && p.model !== null ? { ...p, checked } : p));
|
||||
}
|
||||
|
||||
export function checkedCount<T extends Selectable>(piers: T[]): number {
|
||||
return piers.filter((p) => p.checked).length;
|
||||
}
|
||||
Reference in new issue
Block a user