AnP/Public/ecma/Utils/HTMLDSL.ecma.js

350 lines
15 KiB
JavaScript

"use strict";
/**
* @callback element_callback
* @param {!Object.<string, any|null>} [attributes = {}]
* @param {!Array.<any|null>} [children = []]
* @returns {!Array.<any>}
*/
/** @type {element_callback} */
export const Div = (attributes = {}, children = []) => ["div", attributes, children];
/** @type {element_callback} */
export const Span = (attributes = {}, children = []) => ["span", attributes, children];
/** @type {element_callback} */
export const Footer = (attributes = {}, children = []) => ["footer", attributes, children];
/** @type {element_callback} */
export const Header = (attributes = {}, children = []) => ["header", attributes, children];
/** @type {element_callback} */
export const Main = (attributes = {}, children = []) => ["main", attributes, children];
/** @type {element_callback} */
export const H1 = (attributes = {}, children = []) => ["h1", attributes, children];
/** @type {element_callback} */
export const H2 = (attributes = {}, children = []) => ["h2", attributes, children];
/** @type {element_callback} */
export const H3 = (attributes = {}, children = []) => ["h3", attributes, children];
/** @type {element_callback} */
export const H4 = (attributes = {}, children = []) => ["h4", attributes, children];
/** @type {element_callback} */
export const H5 = (attributes = {}, children = []) => ["h5", attributes, children];
/** @type {element_callback} */
export const H6 = (attributes = {}, children = []) => ["h6", attributes, children];
/** @type {element_callback} */
export const Heading1 = H1;
/** @type {element_callback} */
export const Heading2 = H2;
/** @type {element_callback} */
export const Heading3 = H3;
/** @type {element_callback} */
export const Heading4 = H4;
/** @type {element_callback} */
export const Heading5 = H5;
/** @type {element_callback} */
export const Heading6 = H6;
/** @type {element_callback} */
export const Heading = (level, attributes = {}, children = []) => {
const tag = "h" + Math.min(Math.max(1, level), 6);
return [tag, attributes, children];
};
/** @type {element_callback} */
export const H = Heading;
/** @type {element_callback} */
export const A = (attributes = {}, children = []) => ["a", attributes, children];
/** @type {element_callback} */
export const Anchor = A;
/** @type {element_callback} */
export const Img = (attributes = {}, children = []) => ["img", attributes, children];
/** @type {element_callback} */
export const Image = Img;
/** @type {element_callback} */
export const P = (attributes = {}, children = []) => ["p", attributes, children];
/** @type {element_callback} */
export const Paragraph = P;
/** @type {element_callback} */
export const Section = (attributes = {}, children = []) => ["section", attributes, children];
/** @type {element_callback} */
export const Article = (attributes = {}, children = []) => ["article", attributes, children];
/** @type {element_callback} */
export const Aside = (attributes = {}, children = []) => ["aside", attributes, children];
/** @type {element_callback} */
export const Label = (attributes = {}, children = []) => ["label", attributes, children];
/** @type {element_callback} */
export const Form = (attributes = {}, children = []) => ["form", attributes, children];
/** @type {element_callback} */
export const Fieldset = (attributes = {}, children = []) => ["fieldset", attributes, children];
/** @type {element_callback} */
export const Legend = (attributes = {}, children = []) => ["legend", attributes, children];
/** @type {element_callback} */
export const Input = (attributes = {}, children = []) => ["input", attributes, children];
/** @type {element_callback} */
export const Checkbox = (attributes = {}, children = []) => ["input", Object.assign({type : "checkbox"}, attributes), children];
/** @type {element_callback} */
export const Radio = (attributes = {}, children = []) => ["input", Object.assign({type : "radio"}, attributes), children];
/** @type {element_callback} */
export const Submit = (attributes = {}, children = []) => ["input", Object.assign({type : "submit"}, attributes), children];
/** @type {element_callback} */
export const Reset = (attributes = {}, children = []) => ["input", Object.assign({type : "reset"}, attributes), children];
/** @type {element_callback} */
export const Hidden = (attributes = {}, children = []) => ["input", Object.assign({type : "hidden"}, attributes), children];
/** @type {element_callback} */
export const Text = (attributes = {}, children = []) => ["input", Object.assign({type : "text"}, attributes), children];
/** @type {element_callback} */
export const Date = (attributes = {}, children = []) => ["input", Object.assign({type : "date"}, attributes), children];
/** @type {element_callback} */
export const File = (attributes = {}, children = []) => ["input", Object.assign({type : "file"}, attributes), children];
/** @type {element_callback} */
export const Password = (attributes = {}, children = []) => ["input", Object.assign({type : "password"}, attributes), children];
/** @type {element_callback} */
export const Email = (attributes = {}, children = []) => ["input", Object.assign({type : "email"}, attributes), children];
/** @type {element_callback} */
export const Number = (attributes = {}, children = []) => ["input", Object.assign({type : "number"}, attributes), children];
/** @type {element_callback} */
export const Integer = (attributes = {}, children = []) => ["input", Object.assign({type : "number", step : 1}, attributes), children];
/** @type {element_callback} */
export const Float = Number;
/** @type {element_callback} */
export const Range = (attributes = {}, children = []) => ["input", Object.assign({type : "range"}, attributes), children];
/** @type {element_callback} */
export const Color = (attributes = {}, children = []) => ["input", Object.assign({type : "color"}, attributes), children];
/** @type {element_callback} */
export const RadioButton = Radio;
/** @type {element_callback} */
export const Button = (attributes = {}, children = []) => ["button", attributes, children];
/** @type {element_callback} */
export const Textarea = (attributes = {}, children = []) => ["textarea", attributes, children];
/** @type {element_callback} */
export const Select = (attributes = {}, children = []) => ["select", attributes, children];
/** @type {element_callback} */
export const Option = (attributes = {}, children = []) => ["option", attributes, children];
/** @type {element_callback} */
export const Optgroup = (attributes = {}, children = []) => ["optgroup", attributes, children];
/** @type {element_callback} */
export const OptionGroup = Optgroup;
/** @type {element_callback} */
export const Table = (attributes = {}, children = []) => ["table", attributes, children];
/** @type {element_callback} */
export const TBody = (attributes = {}, children = []) => ["tbody", attributes, children];
/** @type {element_callback} */
export const THead = (attributes = {}, children = []) => ["thead", attributes, children];
/** @type {element_callback} */
export const TFoot = (attributes = {}, children = []) => ["tfoot", attributes, children];
/** @type {element_callback} */
export const TR = (attributes = {}, children = []) => ["tr", attributes, children];
/** @type {element_callback} */
export const TD = (attributes = {}, children = []) => ["td", attributes, children];
/** @type {element_callback} */
export const TH = (attributes = {}, children = []) => ["th", attributes, children];
/** @type {element_callback} */
export const TableBody = TBody;
/** @type {element_callback} */
export const TableHead = THead;
/** @type {element_callback} */
export const TableFoot = TFoot;
/** @type {element_callback} */
export const TableRow = TR;
/** @type {element_callback} */
export const TableCell = TD;
/** @type {element_callback} */
export const TableHeaderCell = TH;
/** @type {element_callback} */
export const UL = (attributes = {}, children = []) => ["ul", attributes, children];
/** @type {element_callback} */
export const OL = (attributes = {}, children = []) => ["ol", attributes, children];
/** @type {element_callback} */
export const LI = (attributes = {}, children = []) => ["li", attributes, children];
/** @type {element_callback} */
export const DL = (attributes = {}, children = []) => ["dl", attributes, children];
/** @type {element_callback} */
export const DT = (attributes = {}, children = []) => ["dt", attributes, children];
/** @type {element_callback} */
export const DD = (attributes = {}, children = []) => ["dd", attributes, children];
/** @type {element_callback} */
export const Nav = (attributes = {}, children = []) => ["nav", attributes, children];
/** @type {element_callback} */
export const UnorderedList = UL;
/** @type {element_callback} */
export const OrderedList = OL;
/** @type {element_callback} */
export const ListItem = LI;
/** @type {element_callback} */
export const DescriptionList = DL;
/** @type {element_callback} */
export const DescriptionTerm = DT;
/** @type {element_callback} */
export const DescriptionDetails = DD;
/** @type {element_callback} */
export const Navigation = Nav;
/** @type {element_callback} */
export const I = (attributes = {}, children = []) => ["i", attributes, children];
/** @type {element_callback} */
export const Italic = I;
/** @type {element_callback} */
export const B = (attributes = {}, children = []) => ["b", attributes, children];
/** @type {element_callback} */
export const Strong = B;
/** @type {element_callback} */
export const Bold = B;
/** @type {element_callback} */
export const U = (attributes = {}, children = []) => ["u", attributes, children];
/** @type {element_callback} */
export const Underline = U;
/** @type {element_callback} */
export const S = (attributes = {}, children = []) => ["s", attributes, children];
/** @type {element_callback} */
export const Strike = S;
/** @type {element_callback} */
export const StrikeThrough = S;
/** @type {element_callback} */
export const Mark = (attributes = {}, children = []) => ["mark", attributes, children];
/** @type {element_callback} */
export const Small = (attributes = {}, children = []) => ["small", attributes, children];
/** @type {element_callback} */
export const Sub = (attributes = {}, children = []) => ["sub", attributes, children];
/** @type {element_callback} */
export const Subscript = Sub;
/** @type {element_callback} */
export const Sup = (attributes = {}, children = []) => ["sup", attributes, children];
/** @type {element_callback} */
export const Superscript = Sup;
/** @type {element_callback} */
export const BR = (attributes = {}, children = []) => ["br", attributes, children];
/** @type {element_callback} */
export const Break = BR;
/** @type {element_callback} */
export const HR = (attributes = {}, children = []) => ["hr", attributes, children];
/** @type {element_callback} */
export const HorizontalRule = HR;
/** @type {element_callback} */
export const Datalist = (attributes = {}, children = []) => ["datalist", attributes, children];
/** @type {element_callback} */
export const Output = (attributes = {}, children = []) => ["output", attributes, children];
/** @type {element_callback} */
export const Progress = (attributes = {}, children = []) => ["progress", attributes, children];
/** @type {element_callback} */
export const Meter = (attributes = {}, children = []) => ["meter", attributes, children];
/** @type {element_callback} */
export const Details = (attributes = {}, children = []) => ["details", attributes, children];
/** @type {element_callback} */
export const Summary = (attributes = {}, children = []) => ["summary", attributes, children];
/** @type {element_callback} */
export const Dialog = (attributes = {}, children = []) => ["dialog", attributes, children];
/** @type {element_callback} */
export const Menu = (attributes = {}, children = []) => ["menu", attributes, children];
/** @type {element_callback} */
export const Menuitem = (attributes = {}, children = []) => ["menuitem", attributes, children];
/** @type {element_callback} */
export const Menuitemcheckbox = (attributes = {}, children = []) => ["menuitemcheckbox", attributes, children];
/** @type {element_callback} */
export const Menuitemradio = (attributes = {}, children = []) => ["menuitemradio", attributes, children];
/** @type {element_callback} */
export const Slot = (attributes = {}, children = []) => ["slot", attributes, children];
/** @type {element_callback} */
export const Template = (attributes = {}, children = []) => ["template", attributes, children];
/** @type {element_callback} */
export const Canvas = (attributes = {}, children = []) => ["canvas", attributes, children];
/** @type {element_callback} */
export const SVG = (attributes = {}, children = []) => ["svg", attributes, children];
/** @type {element_callback} */
export const MathML = (attributes = {}, children = []) => ["math", attributes, children];
/** @type {element_callback} */
export const Audio = (attributes = {}, children = []) => ["audio", attributes, children];
/** @type {element_callback} */
export const Video = (attributes = {}, children = []) => ["video", attributes, children];
/** @type {element_callback} */
export const Source = (attributes = {}, children = []) => ["source", attributes, children];
/** @type {element_callback} */
export const Track = (attributes = {}, children = []) => ["track", attributes, children];
/** @type {element_callback} */
export const Iframe = (attributes = {}, children = []) => ["iframe", attributes, children];
/** @type {element_callback} */
export const Embed = (attributes = {}, children = []) => ["embed", attributes, children];
/** @type {element_callback} */
export const Object = (attributes = {}, children = []) => ["object", attributes, children];
/** @type {element_callback} */
export const Param = (attributes = {}, children = []) => ["param", attributes, children];
/** @type {element_callback} */
export const Picture = (attributes = {}, children = []) => ["picture", attributes, children];
/** @type {element_callback} */
export const SourceElement = (attributes = {}, children = []) => ["source", attributes, children];
/** @type {element_callback} */
export const Map = (attributes = {}, children = []) => ["map", attributes, children];
/** @type {element_callback} */
export const Area = (attributes = {}, children = []) => ["area", attributes, children];
/** @type {element_callback} */
export const Meta = (attributes = {}, children = []) => ["meta", attributes, children];
/** @type {element_callback} */
export const Link = (attributes = {}, children = []) => ["link", attributes, children];
/** @type {element_callback} */
export const Base = (attributes = {}, children = []) => ["base", attributes, children];
/** @type {element_callback} */
export const Head = (attributes = {}, children = []) => ["head", attributes, children];
/** @type {element_callback} */
export const Body = (attributes = {}, children = []) => ["body", attributes, children];
/** @type {element_callback} */
export const HTML = (attributes = {}, children = []) => ["html", attributes, children];