/* ui-appearance.js —— 外观(界面主题 / 画布 / 连线 / 节点 / 主题色)与取色器(v3.25.22) * * 设计边界(与用户确认过): * · 开放:画布底色、网格、连线(颜色/粗细/线型/高亮)、节点(底色/边框/圆角/选中描边)、主题色 * · 不开放:界面背景 / 面板底色 / 文字颜色 —— 它们被大量 color-mix 派生,开放后极易变成不可读 * · 所有颜色项**亮/暗各存一套**;尺寸类(粗细、圆角、间距)共用一套 * · 全部最终落到 CSS 变量上(改一个变量全局生效,不需要改渲染逻辑) */ ;(function (global) { 'use strict' const g = /** @type {any} */ (global || {}) const React = g.React || {} const el = (type, prop, ...children) => React.createElement(type, prop, ...children) const DEFAULTS = Object.freeze({ canvasBgLight: '#d9dbde', canvasBgDark: '#6f6f6f', gridDotLight: '#c9ccd6', gridDotDark: '#8f8f8f', gridSize: 1.4, gridGap: 22, gridOn: true, gridStyle: 'dots', // v3.25.81:自动配色(默认开)——只定 4 个种子,其余由 src/theme-tokens.js 派生 auto: true, seedNeutral: '#808080', seedAccent: '#6b7280', depth: 22, edgeColorLight: '#b9bfca', edgeColorDark: '#7a7a7a', edgeWidth: 1.8, edgeDash: 'dashed', edgeHotLight: '#6b7280', edgeHotDark: '#ffffff', nodeBgLight: '#f1f3f6', nodeBgDark: '#b3b3b3', nodeBorderLight: '#d5d9e0', nodeBorderDark: '#4f4f4f', nodeRadius: 14, nodeSelWidth: 1, accent: '#6b7280', presets: [], }) const DASH = { solid: 'none', dashed: '4 3', dotted: '1 3' } const HEX_RE = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i const isHex = (v) => HEX_RE.test(String(v || '')) const normHex = (v) => { const s = String(v || '').trim() if (!isHex(s)) return '' if (s.length === 4) return ('#' + s[1] + s[1] + s[2] + s[2] + s[3] + s[3]).toLowerCase() return s.toLowerCase() } const clamp = (v, lo, hi, def) => { const n = Number(v) if (!Number.isFinite(n)) return def return Math.min(hi, Math.max(lo, n)) } function normalize (cfg) { const c = (cfg && cfg.canvas && cfg.canvas.appearance) || {} const hex = (k) => normHex(c[k]) || DEFAULTS[k] return { canvasBgLight: hex('canvasBgLight'), canvasBgDark: hex('canvasBgDark'), gridDotLight: hex('gridDotLight'), gridDotDark: hex('gridDotDark'), gridSize: clamp(c.gridSize, 0.8, 2.6, DEFAULTS.gridSize), gridGap: clamp(c.gridGap, 16, 40, DEFAULTS.gridGap), gridOn: c.gridOn !== false, gridStyle: (function () { const st = String(c.gridStyle || '') if (st === 'dots' || st === 'lines' || st === 'blank') return st return (c.gridOn === false) ? 'blank' : 'dots' })(), edgeColorLight: hex('edgeColorLight'), edgeColorDark: hex('edgeColorDark'), edgeWidth: clamp(c.edgeWidth, 1, 4, DEFAULTS.edgeWidth), edgeDash: DASH[c.edgeDash] ? c.edgeDash : DEFAULTS.edgeDash, edgeHotLight: hex('edgeHotLight'), edgeHotDark: hex('edgeHotDark'), auto: c.auto !== false, seedNeutral: normHex(c.seedNeutral) || DEFAULTS.seedNeutral, seedAccent: normHex(c.seedAccent) || DEFAULTS.seedAccent, depth: clamp(c.depth, 0, 60, DEFAULTS.depth), nodeBgLight: hex('nodeBgLight'), nodeBgDark: hex('nodeBgDark'), nodeBorderLight: hex('nodeBorderLight'), nodeBorderDark: hex('nodeBorderDark'), nodeRadius: clamp(c.nodeRadius, 6, 20, DEFAULTS.nodeRadius), nodeSelWidth: clamp(c.nodeSelWidth, 1, 4, DEFAULTS.nodeSelWidth), accent: hex('accent'), presets: Array.isArray(c.presets) ? c.presets.slice(0, 12) : [], } } function apply (cfg, dark) { try { const a = normalize(cfg) const root = g.document && g.document.documentElement if (!root || !root.style) return const set = (k, v) => root.style.setProperty(k, v) set('--iwb-canvas-bg', dark ? a.canvasBgDark : a.canvasBgLight) set('--iwb-brand', a.accent) set('--iwb-grid-dot', dark ? a.gridDotDark : a.gridDotLight) set('--iwb-grid-size', a.gridSize + 'px') set('--iwb-grid-gap', a.gridGap + 'px') const gs = a.gridStyle || 'dots' set('--iwb-grid-on', (gs !== 'blank' && a.gridOn !== false) ? '1' : '0') try { root.setAttribute('data-iwb-grid', gs) } catch (e) { /* ignore */ } set('--iwb-edge', dark ? a.edgeColorDark : a.edgeColorLight) set('--iwb-edge-w', a.edgeWidth + 'px') set('--iwb-edge-dash', DASH[a.edgeDash] || DASH.dashed) set('--iwb-edge-hot', dark ? a.edgeHotDark : a.edgeHotLight) set('--iwb-node-bg', dark ? a.nodeBgDark : a.nodeBgLight) set('--iwb-border', dark ? a.nodeBorderDark : a.nodeBorderLight) set('--iwb-node-radius', a.nodeRadius + 'px') set('--iwb-node-sel-w', a.nodeSelWidth + 'px') // v3.25.81:自动配色 —— 由 4 个种子派生整套语义色并覆盖上面的手写值 if (a.auto) { const T = g.IWBThemeTokens if (T && typeof T.derive === 'function') { try { T.applyTo(root, T.derive(a, !!dark)) } catch (e) { /* 派生失败保留手写值 */ } } } } catch (e) { /* 样式写失败不影响功能 */ } } function hexToRgb (hex) { const h = normHex(hex) || DEFAULTS.accent return { r: parseInt(h.slice(1, 3), 16), g: parseInt(h.slice(3, 5), 16), b: parseInt(h.slice(5, 7), 16) } } function rgbToHex (r, gg, b) { const p = (n) => Math.max(0, Math.min(255, Math.round(n))).toString(16).padStart(2, '0') return '#' + p(r) + p(gg) + p(b) } function rgbToHsv (r, gg, b) { const R = r / 255, G = gg / 255, B = b / 255 const max = Math.max(R, G, B), min = Math.min(R, G, B) const d = max - min let h = 0 if (d) { if (max === R) h = ((G - B) / d) % 6 else if (max === G) h = (B - R) / d + 2 else h = (R - G) / d + 4 h *= 60 if (h < 0) h += 360 } return { h: h, s: max ? d / max : 0, v: max } } function hsvToRgb (h, s, v) { const c = v * s const x = c * (1 - Math.abs(((h / 60) % 2) - 1)) const m = v - c let R = 0, G = 0, B = 0 if (h < 60) { R = c; G = x } else if (h < 120) { R = x; G = c } else if (h < 180) { G = c; B = x } else if (h < 240) { G = x; B = c } else if (h < 300) { R = x; B = c } else { R = c; B = x } return { r: (R + m) * 255, g: (G + m) * 255, b: (B + m) * 255 } } const lum = (rgb) => { const f = (v) => { const c = v / 255; return c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4) } return 0.2126 * f(rgb.r) + 0.7152 * f(rgb.g) + 0.0722 * f(rgb.b) } function contrast (a, b) { const l1 = lum(hexToRgb(a)), l2 = lum(hexToRgb(b)) const hi = Math.max(l1, l2), lo = Math.min(l1, l2) return (hi + 0.05) / (lo + 0.05) } const readableOn = (bg) => (contrast(bg, '#1c2333') >= 3 ? '#1c2333' : '#ffffff') function ColorPicker (props) { const value = normHex(props && props.value) || DEFAULTS.accent const onChange = (props && props.onChange) || function () {} const [open, setOpen] = React.useState(false) const [hsv, setHsv] = React.useState(() => { const c = hexToRgb(value); return rgbToHsv(c.r, c.g, c.b) }) const boxRef = React.useRef(null) const popRef = React.useRef(null) React.useEffect(() => { const c = hexToRgb(value) setHsv((prev) => { const next = rgbToHsv(c.r, c.g, c.b) return { h: next.s === 0 ? prev.h : next.h, s: next.s, v: next.v } }) }, [value]) const emit = (next) => { const c = hsvToRgb(next.h, next.s, next.v); onChange(rgbToHex(c.r, c.g, c.b)) } const pick = (e) => { const box = boxRef.current if (!box || !box.getBoundingClientRect) return const r = box.getBoundingClientRect() const x = Math.max(0, Math.min(1, (e.clientX - r.left) / r.width)) const y = Math.max(0, Math.min(1, (e.clientY - r.top) / r.height)) const next = { h: hsv.h, s: x, v: 1 - y } setHsv(next); emit(next) } const hue = (e) => { const next = { h: Number(e.target.value) || 0, s: hsv.s || 0.6, v: hsv.v || 1 }; setHsv(next); emit(next) } const rgb = hexToRgb(value) const setChannel = (k) => (e) => { const n = Math.max(0, Math.min(255, Number(e.target.value) || 0)) const c = { ...rgb }; c[k] = n onChange(rgbToHex(c.r, c.g, c.b)) } const hueColor = 'hsl(' + Math.round(hsv.h) + ',100%,50%)' // v3.25.84:拖完自动确认 —— 松手 120ms 后自动收起取色板(不需要点「完成」); // 正在输入 hex/RGB 时不自动收(输入过程中松手会误关)。 const closeTimer = React.useRef(null) const armAutoClose = () => { try { if (closeTimer.current) clearTimeout(closeTimer.current) } catch (e) { /* ignore */ } closeTimer.current = setTimeout(() => { setOpen(false) }, 120) } const cancelAutoClose = () => { try { if (closeTimer.current) clearTimeout(closeTimer.current) } catch (e) { /* ignore */ } } React.useEffect(() => { if (!open) return undefined const onDocDown = (e) => { try { const host = popRef.current if (host && host.contains(e.target)) return setOpen(false) } catch (err) { /* ignore */ } } document.addEventListener('pointerdown', onDocDown, true) return () => document.removeEventListener('pointerdown', onDocDown, true) }, [open]) React.useEffect(() => () => cancelAutoClose(), []) return el('div', { className: 'iwb-cpick' }, el('button', { type: 'button', className: 'iwb-cpick-swatch', title: '点击取色', onClick: () => setOpen((v) => !v), style: { background: value, color: readableOn(value) }, }, el('span', { className: 'iwb-cpick-hex' }, value.toUpperCase())), open ? el('div', { className: 'iwb-cpick-pop', ref: popRef, onPointerDown: (e) => e.stopPropagation(), onKeyDown: cancelAutoClose }, el('div', { className: 'iwb-cpick-box', ref: boxRef, onPointerDown: (e) => { cancelAutoClose(); e.currentTarget.setPointerCapture && e.currentTarget.setPointerCapture(e.pointerId); pick(e) }, onPointerMove: (e) => { if (e.buttons === 1) pick(e) }, onPointerUp: () => armAutoClose(), style: { background: 'linear-gradient(to top, #000, rgba(0,0,0,0)), linear-gradient(to right, #fff, ' + hueColor + ')' }, }, el('div', { className: 'iwb-cpick-dot', style: { left: (hsv.s * 100) + '%', top: ((1 - hsv.v) * 100) + '%', background: value } })), el('input', { type: 'range', min: 0, max: 360, value: Math.round(hsv.h), onChange: (e) => { hue(e); armAutoClose() }, onPointerDown: cancelAutoClose, className: 'iwb-cpick-hue', style: { background: 'linear-gradient(to right,#f00,#ff0,#0f0,#0ff,#00f,#f0f,#f00)' } }), el('div', { className: 'iwb-cpick-rgb' }, ['r', 'g', 'b'].map((k) => el('label', { key: k, className: 'iwb-cpick-chan' }, el('input', { type: 'number', min: 0, max: 255, value: rgb[k], onChange: setChannel(k) }), el('span', null, k.toUpperCase())))), el('div', { className: 'iwb-cpick-foot' }, el('input', { className: 'iwb-input iwb-cpick-input', value: value, onFocus: cancelAutoClose, onChange: (e) => { cancelAutoClose(); const v = normHex(e.target.value); if (v) onChange(v) }, title: '支持 #rgb / #rrggbb' }), g.EyeDropper ? el('button', { type: 'button', className: 'iwb-btn iwb-btn-sm', title: '从屏幕取色', onClick: () => { try { new g.EyeDropper().open().then((r) => { const v = normHex(r && r.sRGBHex); if (v) onChange(v) }).catch(() => {}) } catch (e) { /* ignore */ } } }, '吸管') : null, el('button', { type: 'button', className: 'iwb-btn iwb-btn-sm', onClick: () => setOpen(false) }, '完成')), ) : null, ) } function NumberRow (props) { const { label, value, min, max, step, unit, onChange, title } = props return el('div', { className: 'iwb-row' }, el('span', { className: 'iwb-label', title: title || '' }, label), el('input', { type: 'range', min, max, step, value, className: 'iwb-appear-range', onChange: (e) => onChange(Number(e.target.value)) }), el('span', { className: 'iwb-appear-val' }, String(value) + (unit || '')), ) } const PRESETS = [ { name: '默认', values: {} }, { name: '护眼深色', values: { canvasBgLight: '#cfd6cf', canvasBgDark: '#3c4a42', gridDotLight: '#b9c4b9', gridDotDark: '#6f7f73', edgeColorLight: '#9aa79c', edgeColorDark: '#8fa694', accent: '#3f8f6b', edgeHotLight: '#3f8f6b', edgeHotDark: '#7fe0b0', nodeBgLight: '#eef2ee', nodeBgDark: '#4a574e' } }, { name: '高对比', values: { canvasBgLight: '#ffffff', canvasBgDark: '#111111', gridDotLight: '#d0d0d0', gridDotDark: '#3a3a3a', edgeColorLight: '#111111', edgeColorDark: '#ffffff', edgeWidth: 2.4, edgeDash: 'solid', accent: '#0057d8', edgeHotLight: '#0057d8', edgeHotDark: '#59a4ff', nodeBgLight: '#ffffff', nodeBgDark: '#1e1e1e', nodeBorderLight: '#8a8a8a', nodeBorderDark: '#9a9a9a', nodeSelWidth: 2 } }, { name: '纸质', values: { canvasBgLight: '#efe7d7', canvasBgDark: '#3b3227', gridDotLight: '#d8cbb4', gridDotDark: '#5a4c3d', edgeColorLight: '#b9a88c', edgeColorDark: '#a2917a', edgeDash: 'solid', accent: '#8a6f4a', edgeHotLight: '#8a6f4a', edgeHotDark: '#e0c9a0', nodeBgLight: '#faf6ee', nodeBgDark: '#4a4034', nodeBorderLight: '#ddd0b8', nodeBorderDark: '#6b5c49' } }, ] // ── 外观面板(v3.25.75 重构)─────────────────────────────────────────────── // 用户反馈:分组混乱、颜色字段看不出可点、网格三项无效、对比度警告刷屏。 // 现在:4 个分组(主题 / 画布 / 连线 / 节点),统一两栏网格(标签 120px + 控件), // 每组组头右侧「恢复本组默认」;颜色统一为「色块 + hex + ▾」;警告收进行尾。 function AppearanceTab (props) { const draft = (props && props.draft) || {} const setDraft = (props && props.setDraft) || function () {} const theme = (props && props.theme) || 'light' const setTheme = (props && props.setTheme) || function () {} const applyTheme = (props && props.applyTheme) || function () {} const value = normalize(draft) const set = (patch) => setDraft((d) => Object.assign({}, d, { canvas: Object.assign({}, d.canvas, { appearance: Object.assign({}, normalize(d), patch) }), })) const resetGroup = (keys) => { const p = {}; for (const k of keys) p[k] = DEFAULTS[k]; set(p) } const importRef = React.useRef(null) const Row = function (label, control, note) { return el('div', { className: 'iwb-appear-row' + (note ? ' iwb-appear-row-note' : '') }, el('span', { className: 'iwb-appear-label', title: label }, label), el('div', { className: 'iwb-appear-ctrl' }, control), note ? el('span', { className: 'iwb-appear-note' }, note) : null) } const Group = function (title, rows, keys) { return el('section', { className: 'iwb-appear-group' }, el('div', { className: 'iwb-appear-ghead' }, el('span', { className: 'iwb-appear-gtitle' }, title), keys ? el('button', { className: 'iwb-btn iwb-btn-sm', onClick: () => resetGroup(keys) }, '恢复本组默认') : null), rows) } const Seg = function (val, onChange, items) { return el('div', { className: 'iwb-seg' }, (items || []).map((item) => el('button', { key: item.value, type: 'button', className: 'iwb-seg-item' + (val === item.value ? ' on' : ''), onClick: () => onChange(item.value), }, item.label))) } const warnOf = function (edge, bg) { const r = contrast(edge, bg) return r < 1.5 ? ('⚠ 对比度 ' + r.toFixed(1) + ':1,可能看不清') : '' } // 主题下拉:配色模式 + 全部预设合并(用户裁定:合并) const themeOptions = [{ value: 'theme:light', label: '亮色(节点灰底 + 内容白)' }, { value: 'theme:dark', label: '暗色' }, { value: 'theme:system', label: '跟随系统' }] const presetOptions = PRESETS.map((p) => ({ value: 'preset:' + p.name, label: '预设 · ' + p.name })) .concat(value.presets.map((p, i) => ({ value: 'preset-c:' + i, label: '预设 · ' + p.name }))) const onThemePick = (raw) => { if (raw.indexOf('theme:') === 0) { const t = raw.slice(6) const v = (t === 'dark' || t === 'system') ? t : 'light' setTheme(v); applyTheme(v); return } if (raw.indexOf('preset-c:') === 0) { const p = value.presets[Number(raw.slice(9)) || 0] if (p && p.values) set(normalize({ canvas: { appearance: p.values } })) return } if (raw.indexOf('preset:') === 0) { const name = raw.slice(7) const p = PRESETS.find((x) => x.name === name) if (p) set(Object.assign({}, DEFAULTS, p.values)) } } const exportPresets = () => { try { const doc = { version: 1, appearance: Object.assign({}, value, { presets: undefined }) } const blob = new Blob([JSON.stringify(doc, null, 2)], { type: 'application/json' }) const a = g.document.createElement('a') a.href = URL.createObjectURL(blob) a.download = 'iwb-appearance.json' a.click() setTimeout(() => URL.revokeObjectURL(a.href), 3000) } catch (e) { /* ignore */ } } const importFile = (file) => { try { const rd = new g.FileReader() rd.onload = () => { try { const doc = JSON.parse(String(rd.result || '{}')) const src = doc && (doc.appearance || doc) if (!src || typeof src !== 'object') return set(normalize({ canvas: { appearance: src } })) } catch (e) { /* 忽略坏文件 */ } } rd.readAsText(file) } catch (e) { /* ignore */ } } const themeGroup = Group('主题', [ Row('主题', el('select', { className: 'iwb-input iwb-appear-select', value: 'theme:' + theme, onChange: (e) => onThemePick(e.target.value), }, themeOptions.concat(presetOptions).map((o) => el('option', { key: o.value, value: o.value }, o.label))), '切换配色模式或直接套用预设'), Row('主题色', el(ColorPicker, { value: value.accent, onChange: (v) => set({ accent: v }) }), '按钮 / 端口 / 选中框'), Row('预设', el('div', { className: 'iwb-appear-btns' }, el('button', { className: 'iwb-btn iwb-btn-sm', onClick: () => { const name = (g.prompt ? g.prompt('预设名称', '我的配色') : '') || '' if (!name) return const snap = Object.assign({}, value, { presets: undefined }) set({ presets: value.presets.concat([{ name: String(name).slice(0, 20), values: snap }]).slice(0, 12) }) }, }, '保存当前为预设'), el('button', { className: 'iwb-btn iwb-btn-sm', onClick: exportPresets }, '导出'), el('button', { className: 'iwb-btn iwb-btn-sm', onClick: () => importRef.current && importRef.current.click() }, '导入'), el('input', { ref: importRef, type: 'file', accept: 'application/json', style: { display: 'none' }, onChange: (e) => { const f = e.target.files && e.target.files[0]; if (f) importFile(f) } }))), ], null) const canvasGroup = Group('画布', [ Row('网格样式', Seg(value.gridStyle, (v) => set({ gridStyle: v, gridOn: v !== 'blank' }), [ { value: 'dots', label: '点' }, { value: 'lines', label: '线' }, { value: 'blank', label: '空白' }, ]), '空白 = 不显示背景网格'), Row('底色(亮)', el(ColorPicker, { value: value.canvasBgLight, onChange: (v) => set({ canvasBgLight: v }) })), Row('底色(暗)', el(ColorPicker, { value: value.canvasBgDark, onChange: (v) => set({ canvasBgDark: v }) })), Row(value.gridStyle === 'lines' ? '网格线色(亮)' : '网格点(亮)', el(ColorPicker, { value: value.gridDotLight, onChange: (v) => set({ gridDotLight: v }) })), Row(value.gridStyle === 'lines' ? '网格线色(暗)' : '网格点(暗)', el(ColorPicker, { value: value.gridDotDark, onChange: (v) => set({ gridDotDark: v }) })), Row(value.gridStyle === 'lines' ? '网格线粗细' : '网格点大小', el('input', { type: 'range', min: 0.8, max: 2.6, step: 0.1, value: value.gridSize, className: 'iwb-appear-range', onChange: (e) => set({ gridSize: Number(e.target.value) }) }), String(value.gridSize) + 'px'), Row('网格间距', el('input', { type: 'range', min: 16, max: 40, step: 1, value: value.gridGap, className: 'iwb-appear-range', onChange: (e) => set({ gridGap: Number(e.target.value) }) }), String(value.gridGap) + 'px'), ], ['canvasBgLight', 'canvasBgDark', 'gridDotLight', 'gridDotDark', 'gridSize', 'gridGap', 'gridOn', 'gridStyle']) const edgeGroup = Group('连线', [ Row('默认色(亮)', el(ColorPicker, { value: value.edgeColorLight, onChange: (v) => set({ edgeColorLight: v }) }), warnOf(value.edgeColorLight, value.canvasBgLight)), Row('默认色(暗)', el(ColorPicker, { value: value.edgeColorDark, onChange: (v) => set({ edgeColorDark: v }) }), warnOf(value.edgeColorDark, value.canvasBgDark)), Row('粗细', el('input', { type: 'range', min: 1, max: 4, step: 0.1, value: value.edgeWidth, className: 'iwb-appear-range', onChange: (e) => set({ edgeWidth: Number(e.target.value) }) }), String(value.edgeWidth) + 'px'), Row('线型', el('select', { className: 'iwb-input iwb-appear-select', value: value.edgeDash, onChange: (e) => set({ edgeDash: e.target.value }) }, el('option', { value: 'solid' }, '实线'), el('option', { value: 'dashed' }, '虚线'), el('option', { value: 'dotted' }, '点线'))), Row('高亮色(亮)', el(ColorPicker, { value: value.edgeHotLight, onChange: (v) => set({ edgeHotLight: v }) }), '仅选中/悬停/临时连线'), Row('高亮色(暗)', el(ColorPicker, { value: value.edgeHotDark, onChange: (v) => set({ edgeHotDark: v }) })), ], ['edgeColorLight', 'edgeColorDark', 'edgeWidth', 'edgeDash', 'edgeHotLight', 'edgeHotDark']) const nodeGroup = Group('节点', [ Row('节点底色(亮)', el(ColorPicker, { value: value.nodeBgLight, onChange: (v) => set({ nodeBgLight: v }) })), Row('节点底色(暗)', el(ColorPicker, { value: value.nodeBgDark, onChange: (v) => set({ nodeBgDark: v }) })), Row('边框色(亮)', el(ColorPicker, { value: value.nodeBorderLight, onChange: (v) => set({ nodeBorderLight: v }) })), Row('边框色(暗)', el(ColorPicker, { value: value.nodeBorderDark, onChange: (v) => set({ nodeBorderDark: v }) })), Row('节点圆角', el('input', { type: 'range', min: 6, max: 20, step: 1, value: value.nodeRadius, className: 'iwb-appear-range', onChange: (e) => set({ nodeRadius: Number(e.target.value) }) }), String(value.nodeRadius) + 'px'), Row('选中描边', el('input', { type: 'range', min: 1, max: 4, step: 0.5, value: value.nodeSelWidth, className: 'iwb-appear-range', onChange: (e) => set({ nodeSelWidth: Number(e.target.value) }) }), String(value.nodeSelWidth) + 'px'), ], ['nodeBgLight', 'nodeBgDark', 'nodeBorderLight', 'nodeBorderDark', 'nodeRadius', 'nodeSelWidth']) const autoGroup = Group('自动配色', [ Row('自动配色', el('label', { className: 'iwb-check' }, el('input', { type: 'checkbox', checked: value.auto, onChange: (e) => set({ auto: e.target.checked }) }), '按 4 个种子自动派生整套配色'), '关闭后可逐项手动调节'), Row('中性基调', el(ColorPicker, { value: value.seedNeutral, onChange: (v) => set({ seedNeutral: v, auto: true }) }), '整机灰阶的基准'), Row('画布深浅', el('input', { type: 'range', min: 0, max: 60, step: 1, value: value.depth, className: 'iwb-appear-range', onChange: (e) => set({ depth: Number(e.target.value), auto: true }) }), String(value.depth)), Row('强调色', el(ColorPicker, { value: value.seedAccent, onChange: (v) => set({ seedAccent: v, auto: true }) }), '按钮 / 端口 / 选中框'), ], ['auto', 'seedNeutral', 'seedAccent', 'depth']) return el('div', { className: 'iwb-appear' }, autoGroup, themeGroup, value.auto ? el('div', { className: 'iwb-appear-note-only' }, '自动配色已开启;关闭后可逐项微调(画布 / 连线 / 节点)。') : canvasGroup, value.auto ? null : edgeGroup, value.auto ? null : nodeGroup, el('div', { className: 'iwb-row', style: { marginTop: 12 } }, el('button', { className: 'iwb-btn iwb-btn-sm', onClick: () => set(Object.assign({}, DEFAULTS, { presets: value.presets })) }, '全部恢复默认'))) } g.IWBUIApearance = Object.freeze({ DEFAULTS, PRESETS, DASH, normalize, apply, contrast, ColorPicker, AppearanceTab }) })(typeof window !== 'undefined' ? window : globalThis)