/** * @import { Param, Selection } from '@uwdata/mosaic-core' * @import { TableRefNode } from '@uwdata/mosaic-sql' */ import { isParam, isSelection, clausePoint, clauseList } from '@uwdata/mosaic-core'; import { Query, unnest } from '@uwdata/mosaic-sql'; import { Input, input } from './input.js'; const isObject = v => { return v && typeof v === 'object' && !Array.isArray(v); }; /** * Create a new menu input instance. * @param {object} [options] Options object * @param {HTMLElement} [options.element] The parent DOM element in which to * place the menu elements. If undefined, a new `div` element is created. * @param {Selection} [options.filterBy] A selection to filter the database * table indicated by the *from* option. * @param {Param} [options.as] The output param or selection. A selection * clause is added for the currently selected menu option. * @param {string} [options.field] The database column name to use within * generated selection clause predicates. Defaults to the *column* option. * @param {(any | { value: any, label?: string })[]} [options.options] An * array of menu options, as literal values or option objects. Option * objects have a `value` property and an optional `label` property. If no * label or *format* function is provided, the string-coerced value is used. * @param {(value: any) => string} [options.format] A format function that * takes an option value as input and generates a string label. The format * function is not applied when an explicit label is provided in an option * object. * @param {*} [options.value] The initial selected menu value. * @param {string | TableRefNode} [options.from] The backing table name or `tableRef()` node to use as a data * source for this widget. Used in conjunction with the *column* option. * @param {string} [options.column] The name of a database column from which * to pull menu options. The unique column values are used as menu options. * Used in conjunction with the *from* option. * @param {string} [options.label] A text label for this input. * @param {'any' | 'all'} [options.listMatch] The list match mode. * @returns {HTMLElement} The container element for a menu input. */ export const menu = options => input(Menu, options); /** * A HTML