import type { AnyObject, InexactPartial } from "../../../utils/index.d.mts"; import type { FormInputConfig, NumberInputConfig, SelectInputConfig } from "#client/applications/forms/fields.d.mts"; /** * Get a template from the server by fetch request and caching the retrieved result * @param path - The web-accessible HTML template URL * @param id - An ID to register the partial with. * @returns A Promise which resolves to the compiled Handlebars template */ export function getTemplate(path: string, id?: string): Promise; /** * Load and cache a set of templates by providing an Array of paths * @param paths - An array of template file paths to load, or an object of Handlebars partial IDs to paths. * * @example Loading a list of templates. * ```js * await loadTemplates(["templates/apps/foo.html", "templates/apps/bar.html"]); * ``` * ```hbs * * {{> "templates/apps/foo.html" }} * ``` * * @example Loading an object of templates. * ```js * await loadTemplates({ * foo: "templates/apps/foo.html", * bar: "templates/apps/bar.html" * }); * ``` * ```hbs * * {{> foo }} * ``` */ export function loadTemplates(paths: string[] | Record): Promise; /** * Get and render a template using provided data and handle the returned HTML * Support asynchronous file template file loading with a client-side caching layer * * Allow resolution of prototype methods and properties since this all occurs within the safety of the client. * @see {@link https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access} * * @param path - The file path to the target HTML template * @param data - A data object against which to compile the template * * @returns Returns the compiled and rendered template as a string */ // TODO(LukeAbby): Create a registry for templates or some abstraction to make this type safe. export function renderTemplate(path: string, data: AnyObject): Promise; /** * Initialize Handlebars extensions and helpers. */ export function initialize(): void; /** * For checkboxes, if the value of the checkbox is true, add the "checked" property, otherwise add nothing. * @param value - A value with a truthiness indicative of whether the checkbox is checked * * @example * ```hbs * * * ``` */ export function checked(value: unknown): string; /** * For use in form inputs. If the supplied value is truthy, add the "disabled" property, otherwise add nothing. * @param value - A value with a truthiness indicative of whether the input is disabled * * @example * ```hbs * * ``` */ export function disabled(value: unknown): string; /** * Concatenate a number of string terms into a single string. * This is useful for passing arguments with variable names. * @param values - The values to concatenate * * @example Concatenate several string parts to create a dynamic variable * ```handlebars * {{filePicker target=(concat "faces." i ".img") type="image"}} * ``` */ export function concat(...values: string[]): Handlebars.SafeString; /** * Construct an editor element for rich text editing with TinyMCE or ProseMirror. * @param content - The content to display and edit * * @example * ```hbs * {{editor world.description target="description" button=false engine="prosemirror" collaborate=false}} * ``` */ export function editor(content: string, options: TextEditorOptions): Handlebars.SafeString; /** * A ternary expression that allows inserting A or B depending on the value of C. * @param criteria - The test criteria * @param ifTrue - The string to output if true * @param ifFalse - The string to output if false * @returns The ternary result * * @example Ternary if-then template usage * ```hbs * {{ifThen true "It is true" "It is false"}} * ``` */ export function ifThen(criteria: boolean, ifTrue: string, ifFalse: string): string; /** * Translate a provided string key by using the loaded dictionary of localization strings. * @param value - value The path to a localized string * * @example Translate a provided localization string, optionally including formatting parameters * ```handlebars * * * ``` */ export function localize(value: string, options: LocalizeOptions): string; /** * A string formatting helper to display a number with a certain fixed number of decimals and an explicit sign. * @param value - A numeric value to format * @param options - Additional options which customize the resulting format * @returns The formatted string to be included in a template * * @example * ```hbs * {{formatNumber 5.5}} * {{formatNumber 5.5 decimals=2}} * {{formatNumber 5.5 decimals=2 sign=true}} * {{formatNumber null decimals=2 sign=false}} * {{formatNumber undefined decimals=0 sign=true}} * ``` */ export function numberFormat(value: string | number, options: NumberFormatOptions): string; /** * Render a form input field of type number with value appropriately rounded to step size. * * @example * ```hbs * {{numberInput value name="numberField" step=1 min=0 max=10}} * ``` */ export function numberInput(value: string, options: NumberInputOptions): Handlebars.SafeString; /** * Create an object from a sequence of `key=value` pairs. */ export function object(options: Handlebars.HelperOptions): Record; /** * A helper to create a set of radio checkbox input elements in a named set. * The provided keys are the possible radio values while the provided values are human readable labels. * * @param name - The radio checkbox field name * @param choices - A mapping of radio checkbox values to human readable labels * @param options - Options which customize the radio boxes creation * * @example The provided input data * ```typescript * let groupName = "importantChoice"; * let choices = {a: "Choice A", b: "Choice B"}; * let chosen = "a"; * ``` * * @example The template HTML structure * ```handlebars *
* *
* {{radioBoxes groupName choices checked=chosen localize=true}} *
*
* ``` */ export function radioBoxes( name: string, choices: Record, options: RadioBoxesOptions, ): Handlebars.SafeString; /** * A helper to create a set of `