// Generated, do not edit. sha256:374bda270315c76a934d2540ed9d4724c841659867d96ba0c265c5a8c61bbca3 import { esc } from './escape.js'; import { cellClassAttr } from './table-markup.js'; export function editInputHtml(col, vals, { options = [], convert = null } = {}) { const e = col.edit; const cur = vals[col.key]; if (e.render) return e.render(vals); const react = e.reactive ? ' data-reactive="1"' : ''; const extra = e.attrs ? ' ' + Object.entries(e.attrs).map(([k, v]) => `${k}="${esc(v)}"`).join(' ') : ''; const phVal = typeof e.placeholder === 'function' ? e.placeholder(vals) : e.placeholder; const ph = phVal ? ` placeholder="${esc(phVal)}"` : ''; if (e.type === 'select') { const opts = options.map(o => ``).join(''); return ``; } if (e.type === 'checkbox') { return ``; } const val = cur == null ? '' : esc(cur); if (e.type === 'textarea') { return ``; } const type = e.type === 'number' ? 'number' : (e.type === 'date' ? 'date' : (e.type === 'time' ? 'time' : 'text')); const inputHtml = ``; if (!e.convert || !convert || !convert.canConvert(e.convert(vals))) return inputHtml; const cvLabel = esc(convert.label || ''); return `
${inputHtml}
`; } export function editCellHtml(col, vals, opts) { const vis = !col.edit.visible || col.edit.visible(vals); if (col.edit.expand) return ``; if (!vis) return ``; return `${editInputHtml(col, vals, opts)}`; } export function expandRowHtml({ editableCols, vals, error, colCount, optsFor, actions = '' }) { const fields = editableCols .filter(c => c.edit.expand && (!c.edit.visible || c.edit.visible(vals))) .map(c => { const full = c.edit.type === 'textarea' || c.edit.full; return `
${editInputHtml(c, vals, optsFor(c))}
`; }).join(''); const err = error ? `
${esc(error)}
` : ''; if (!fields && !err && !actions) return ''; const fieldsHtml = fields ? `
${fields}
` : ''; return ` ${fieldsHtml}${err}${actions} `; } export function captureValues(scope, editableCols, vals) { for (const c of editableCols) { if (c.edit.read) { vals[c.key] = c.edit.read(scope.querySelector(`[data-field="${c.key}"]`)); continue; } const node = scope.querySelector(`[data-field="${c.key}"]`); if (!node) continue; vals[c.key] = node.type === 'checkbox' ? node.checked : node.value; } return vals; }