|
14 | 14 | <!-- Basic params — always visible --> |
15 | 15 | <div class="form-grid"> |
16 | 16 | <template v-for="p in basicParams" :key="p.key"> |
17 | | - <div class="form-field" :class="{ 'full-width': p.inputType === 'text' }"> |
| 17 | + <div class="form-field" :class="{ 'full-width': p.inputType === 'text' || p.inputType === 'checkboxGroup' }"> |
18 | 18 | <label class="field-label"> |
19 | 19 | <span class="label-text">{{ p.label }}</span> |
20 | 20 | <span v-if="p.unit" class="field-unit">({{ p.unit }})</span> |
|
26 | 26 | <span class="check-label">{{ form[p.key] ? 'Enabled' : 'Disabled' }}</span> |
27 | 27 | </label> |
28 | 28 | </template> |
| 29 | + <template v-else-if="p.inputType === 'checkboxGroup'"> |
| 30 | + <div class="checkbox-group"> |
| 31 | + <label |
| 32 | + v-for="opt in p.options" |
| 33 | + :key="opt.value" |
| 34 | + class="checkbox-group-item" |
| 35 | + :class="{ active: isGroupChecked(form, p.key, opt.value) }" |
| 36 | + > |
| 37 | + <input |
| 38 | + type="checkbox" |
| 39 | + :checked="isGroupChecked(form, p.key, opt.value)" |
| 40 | + @change="toggleGroupValue(form, p.key, opt.value)" |
| 41 | + /> |
| 42 | + <span>{{ opt.label }}</span> |
| 43 | + </label> |
| 44 | + </div> |
| 45 | + </template> |
29 | 46 | <template v-else-if="p.inputType === 'select'"> |
30 | 47 | <select v-model="form[p.key]"> |
31 | 48 | <option v-for="opt in p.options" :key="opt.value" :value="opt.value">{{ opt.label }}</option> |
|
52 | 69 | <summary>Advanced ({{ advancedParams.length }})</summary> |
53 | 70 | <div class="form-grid"> |
54 | 71 | <template v-for="p in advancedParams" :key="p.key"> |
55 | | - <div class="form-field" :class="{ 'full-width': p.inputType === 'text' }"> |
| 72 | + <div class="form-field" :class="{ 'full-width': p.inputType === 'text' || p.inputType === 'checkboxGroup' }"> |
56 | 73 | <label class="field-label"> |
57 | 74 | <span class="label-text">{{ p.label }}</span> |
58 | 75 | <span v-if="p.unit" class="field-unit">({{ p.unit }})</span> |
|
64 | 81 | <span class="check-label">{{ form[p.key] ? 'Enabled' : 'Disabled' }}</span> |
65 | 82 | </label> |
66 | 83 | </template> |
| 84 | + <template v-else-if="p.inputType === 'checkboxGroup'"> |
| 85 | + <div class="checkbox-group"> |
| 86 | + <label |
| 87 | + v-for="opt in p.options" |
| 88 | + :key="opt.value" |
| 89 | + class="checkbox-group-item" |
| 90 | + :class="{ active: isGroupChecked(form, p.key, opt.value) }" |
| 91 | + > |
| 92 | + <input |
| 93 | + type="checkbox" |
| 94 | + :checked="isGroupChecked(form, p.key, opt.value)" |
| 95 | + @change="toggleGroupValue(form, p.key, opt.value)" |
| 96 | + /> |
| 97 | + <span>{{ opt.label }}</span> |
| 98 | + </label> |
| 99 | + </div> |
| 100 | + </template> |
67 | 101 | <template v-else-if="p.inputType === 'select'"> |
68 | 102 | <select v-model="form[p.key]"> |
69 | 103 | <option v-for="opt in p.options" :key="opt.value" :value="opt.value">{{ opt.label }}</option> |
@@ -99,6 +133,23 @@ const props = defineProps({ |
99 | 133 |
|
100 | 134 | const basicParams = computed(() => props.params.filter(p => p.level === 'basic')) |
101 | 135 | const advancedParams = computed(() => props.params.filter(p => p.level === 'advanced')) |
| 136 | +
|
| 137 | +// checkboxGroup helpers — form value is a comma-separated string like "bin,ter,ratio" |
| 138 | +function isGroupChecked(form, key, value) { |
| 139 | + const current = (form[key] || '').split(',').map(v => v.trim()).filter(Boolean) |
| 140 | + return current.includes(value) |
| 141 | +} |
| 142 | +
|
| 143 | +function toggleGroupValue(form, key, value) { |
| 144 | + const current = (form[key] || '').split(',').map(v => v.trim()).filter(Boolean) |
| 145 | + const idx = current.indexOf(value) |
| 146 | + if (idx >= 0) { |
| 147 | + current.splice(idx, 1) |
| 148 | + } else { |
| 149 | + current.push(value) |
| 150 | + } |
| 151 | + form[key] = current.join(',') |
| 152 | +} |
102 | 153 | </script> |
103 | 154 |
|
104 | 155 | <style scoped> |
@@ -234,6 +285,44 @@ input[type="checkbox"] { |
234 | 285 | color: var(--text-secondary); |
235 | 286 | } |
236 | 287 |
|
| 288 | +/* Checkbox group (multi-select as toggle pills) */ |
| 289 | +.checkbox-group { |
| 290 | + display: flex; |
| 291 | + flex-wrap: wrap; |
| 292 | + gap: 0.35rem; |
| 293 | +} |
| 294 | +
|
| 295 | +.checkbox-group-item { |
| 296 | + display: flex; |
| 297 | + align-items: center; |
| 298 | + gap: 0.3rem; |
| 299 | + padding: 0.25rem 0.6rem; |
| 300 | + border: 1px solid var(--border); |
| 301 | + border-radius: 6px; |
| 302 | + font-size: 0.8rem; |
| 303 | + color: var(--text-secondary); |
| 304 | + cursor: pointer; |
| 305 | + transition: all 0.15s; |
| 306 | + user-select: none; |
| 307 | +} |
| 308 | +
|
| 309 | +.checkbox-group-item input[type="checkbox"] { |
| 310 | + width: 14px; |
| 311 | + height: 14px; |
| 312 | + margin: 0; |
| 313 | + cursor: pointer; |
| 314 | +} |
| 315 | +
|
| 316 | +.checkbox-group-item.active { |
| 317 | + border-color: var(--accent); |
| 318 | + background: color-mix(in srgb, var(--accent) 10%, transparent); |
| 319 | + color: var(--text-primary); |
| 320 | +} |
| 321 | +
|
| 322 | +.checkbox-group-item:hover { |
| 323 | + border-color: var(--accent); |
| 324 | +} |
| 325 | +
|
237 | 326 | /* Advanced toggle */ |
238 | 327 | .advanced-toggle { |
239 | 328 | margin-top: 0.6rem; |
|
0 commit comments