mock: バリアントの既定の印・バッジ・作成先を直す(T-30 単位3)
ポップオーバーの既定の印を「既定」の札にする。バッジには名前を書かず、 表示中のバリアント名はツールチップで示す(はみ出しをなくす。T-30の着手前の決定を反映)。 バリアントグループは選択の入れ物(クラスター・バリアント)の中に作る。 そのため domain に createVariantGroupInParent を足し、variant のIDを渡すと 例外になっていた parentNodes を直した。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NznQtmVPoQAnietqwr1auL
This commit is contained in:
@@ -114,9 +114,12 @@ export function insertNodes(f: PhyFile, parentId: string | null, nodes: Node[],
|
||||
|
||||
function parentNodes(f: PhyFile, parentId: string | null): Node[] {
|
||||
if (!parentId) return f.root;
|
||||
const n = find(f, parentId);
|
||||
if (n.type === "cluster") return n.children;
|
||||
if (n.type === "variantGroup") throw new Error("Choose a variant as the parent");
|
||||
// variantのIDは containers に子の入れ物として載るので、find ではノードとして引けない
|
||||
const n = containers(f)
|
||||
.get(parentId)
|
||||
?.nodes.find((x) => x.id === parentId);
|
||||
if (n?.type === "cluster") return n.children;
|
||||
if (n?.type === "variantGroup") throw new Error("Choose a variant as the parent");
|
||||
return findVariant(f, parentId).children;
|
||||
}
|
||||
/** ローカル座標の差分でノードを移動する。 */
|
||||
@@ -397,6 +400,17 @@ export function createVariantGroup(
|
||||
at: Transform,
|
||||
variants: [{ name: string; children?: Node[] }, { name: string; children?: Node[] }],
|
||||
gen?: () => string,
|
||||
): PhyFile {
|
||||
return createVariantGroupInParent(f, null, name, at, variants, gen);
|
||||
}
|
||||
/** 指定コンテナへVariantGroupを作成する。T-11。 */
|
||||
export function createVariantGroupInParent(
|
||||
f: PhyFile,
|
||||
parentId: string | null,
|
||||
name: string,
|
||||
at: Transform,
|
||||
variants: [{ name: string; children?: Node[] }, { name: string; children?: Node[] }],
|
||||
gen?: () => string,
|
||||
): PhyFile {
|
||||
const o = mutable(f),
|
||||
children = variants.map((x) => ({
|
||||
@@ -405,7 +419,7 @@ export function createVariantGroup(
|
||||
name: x.name,
|
||||
children: structuredClone(x.children ?? []),
|
||||
}));
|
||||
o.root.push({
|
||||
parentNodes(o, parentId).push({
|
||||
type: "variantGroup",
|
||||
id: nodeId("variantGroup", gen),
|
||||
name,
|
||||
|
||||
Reference in New Issue
Block a user