- 앞 커밋 글 그대로(층 · 부름 common_util_m02_call · 찾아 넣기 창 StackFind 주입 · 단위 고르기 부품 상자 · 합계 상자 A00 · 기계 칸 부품) - 앞 커밋에서 git add 가 옛 경로에 걸려 고친 파일이 빠짐 — 두 커밋을 같이 올림 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
67 lines
2.9 KiB
TypeScript
67 lines
2.9 KiB
TypeScript
/* =============================================================================
|
|
* line_stack_machine_cell.ts
|
|
* 기계 제어 구역 칸 부품(PLAN 856-4) — 수 칸 · 「바뀜」 표시(출처 테두리 · 원래 값 풍선)
|
|
* 제어 구역(`line_stack_machine_ctl`) · 작업량 묶음(`line_stack_machine_work`)이 같이 씀 — 둘이 서로 부르던 고리 끊음
|
|
* ========================================================================== */
|
|
|
|
import { setUiDiff, type UiDiff } from "@ui/ui_template_button";
|
|
import { el, showToast } from "@ui/ui_template_elements";
|
|
import { createInputField } from "@ui/ui_template_input";
|
|
import { MINE, type Source } from "../common_util/common_util_formula_doc_cover";
|
|
import { lt } from "./line_stack_text";
|
|
|
|
/** 출처(848-3) — 나 · 위 층. 테두리는 나만(892) · 풍선(원래 값)은 둘 다 */
|
|
export type DiffSrc = UiDiff | "upper";
|
|
export const diffOf = (src: Source | undefined): DiffSrc | null =>
|
|
src === undefined ? null : src === MINE ? "mine" : "upper";
|
|
|
|
/** 칸 묶음 안 입력 · 고르기 · 이름 단추에 「바뀜」 상태(나만) · 풍선(원래 값) */
|
|
export function markDiff(box: HTMLElement, diff: DiffSrc | null, was?: string): void {
|
|
const own = ["ui-input", "ui-select", "ui-btn"].some((c) => box.classList.contains(c));
|
|
const nodes = own ? [box] : ["ui-input", "ui-select", "lstk-res"].flatMap((c) => [...box.querySelectorAll<HTMLElement>(`.${c}`)]); // prettier-ignore
|
|
for (const n of nodes) {
|
|
setUiDiff(n, diff === "mine" ? "mine" : null);
|
|
if (diff && was !== undefined)
|
|
n.title = `${n.title ? `${n.title} — ` : ""}${lt("Ctl_Was")} ${was}`;
|
|
}
|
|
}
|
|
|
|
const num = (t: string): number | null => {
|
|
const n = Number(t.trim().replace(/,/g, ""));
|
|
return t.trim() !== "" && Number.isFinite(n) ? n : null;
|
|
};
|
|
|
|
/** 수 칸 — 빈 글 = 원래대로(null) · 음수 · 글 = 알림 · 단위 = 칸 바로 뒤(공식 묶음 값 칸과 같은 자리 · 845-2 ㉥) */
|
|
export function numBox(
|
|
label: string,
|
|
value: unknown,
|
|
unit: string,
|
|
ro: boolean,
|
|
set: (n: number | null) => void,
|
|
hint = "",
|
|
): HTMLElement {
|
|
const f = createInputField({
|
|
value: value === undefined || value === null ? "" : String(value),
|
|
placeholder: hint,
|
|
compact: true,
|
|
size: 24,
|
|
});
|
|
f.root.classList.add("lstk-f-s");
|
|
f.input.setAttribute("aria-label", label);
|
|
f.input.title = label;
|
|
f.input.disabled = ro;
|
|
f.input.addEventListener("change", () => {
|
|
const t = f.input.value;
|
|
const n = num(t);
|
|
if (t.trim() === "") return set(null);
|
|
if (n === null || n < 0) {
|
|
f.input.value = value === undefined || value === null ? "" : String(value);
|
|
return void showToast(lt("Ctl_Bad"), "warning");
|
|
}
|
|
set(n);
|
|
});
|
|
return unit
|
|
? el("span", { className: "lstk-qty", children: [f.root, el("span", { className: "lstk-unit", text: unit })] }) // prettier-ignore
|
|
: f.root;
|
|
}
|