Start working on the Stats Viewer application

This commit is contained in:
Oliver-Akins 2025-04-21 00:50:58 -06:00
parent cb3bc7c86c
commit 91863d85a8
18 changed files with 422 additions and 1 deletions

View file

@ -0,0 +1,6 @@
import { options } from "./options.mjs";
export default {
// #region Complex
"st-options": options,
};

View file

@ -0,0 +1,33 @@
/**
* @typedef {object} Option
* @property {string} [label]
* @property {string|number} value
* @property {boolean} [disabled]
*/
/**
* @param {string | number} selected
* @param {Array<Option | string>} opts
* @param {any} meta
*/
export function options(selected, opts) {
selected = Handlebars.escapeExpression(selected);
const htmlOptions = [];
for (let opt of opts) {
if (typeof opt === `string`) {
opt = { label: opt, value: opt };
};
opt.value = Handlebars.escapeExpression(opt.value);
htmlOptions.push(
`<option
value="${opt.value}"
${selected === opt.value ? `selected` : ``}
${opt.disabled ? `disabled` : ``}
>
${ opt.label }
</option>`,
);
};
return new Handlebars.SafeString(htmlOptions.join(`\n`));
};