RC-90 | Add support for bar-input controls in item sheets
This commit is contained in:
parent
8d92040230
commit
5c78523791
12 changed files with 140 additions and 13 deletions
|
|
@ -1,15 +1,20 @@
|
|||
import { barInput } from "./barInput.mjs";
|
||||
import { dropdownInput } from "./dropdownInput.mjs";
|
||||
import { numberInput } from "./numberInput.mjs";
|
||||
import { stringSet } from "./stringSet.mjs";
|
||||
|
||||
const { getType } = foundry.utils;
|
||||
|
||||
const inputTypes = {
|
||||
"string-set": stringSet,
|
||||
integer: numberInput,
|
||||
bar: displayOnly,
|
||||
bar: barInput,
|
||||
dropdown: dropdownInput,
|
||||
boolean: displayOnly,
|
||||
};
|
||||
|
||||
const typesToSanitize = new Set([ `string`, `number` ]);
|
||||
|
||||
function displayOnly(input) {
|
||||
return `<div data-input-type="${input.type}">${input.label}</div>`;
|
||||
};
|
||||
|
|
@ -18,8 +23,15 @@ export function formFields(inputs, opts) {
|
|||
const fields = [];
|
||||
for (const input of inputs) {
|
||||
if (inputTypes[input.type] == null) { continue };
|
||||
input.value = Handlebars.escapeExpression(input.value);
|
||||
|
||||
input.limited ??= true;
|
||||
|
||||
if (typesToSanitize.has(getType(input.value))) {
|
||||
input.value = Handlebars.escapeExpression(input.value);
|
||||
};
|
||||
fields.push(inputTypes[input.type](input, opts.data.root));
|
||||
};
|
||||
return fields.join(opts.hash?.joiner ?? `<hr />`);
|
||||
return fields
|
||||
.filter(i => i.length > 0)
|
||||
.join(opts.hash?.joiner ?? `<hr />`);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue