diff --git a/apps/builder/app/builder/features/settings-panel/controls/tag-control.tsx b/apps/builder/app/builder/features/settings-panel/controls/tag-control.tsx index 57a7eb9b5996..9ea05316c02c 100644 --- a/apps/builder/app/builder/features/settings-panel/controls/tag-control.tsx +++ b/apps/builder/app/builder/features/settings-panel/controls/tag-control.tsx @@ -1,5 +1,6 @@ import { useStore } from "@nanostores/react"; -import { Select } from "@webstudio-is/design-system"; +import { Box, Select, theme } from "@webstudio-is/design-system"; +import { elementsByTag } from "@webstudio-is/html-data"; import { $selectedInstance } from "~/shared/awareness"; import { updateWebstudioData } from "~/shared/instance-utils"; import { type ControlProps, VerticalLayout } from "../shared"; @@ -39,6 +40,11 @@ export const TagControl = ({ meta, prop }: ControlProps<"tag">) => { } }); }} + getDescription={(item) => ( + + {elementsByTag[item].description} + + )} /> ); diff --git a/apps/builder/app/shared/content-model.ts b/apps/builder/app/shared/content-model.ts index 2e59acaa5f38..b3a5cac2d3d5 100644 --- a/apps/builder/app/shared/content-model.ts +++ b/apps/builder/app/shared/content-model.ts @@ -1,7 +1,4 @@ -import { - categoriesByTag, - childrenCategoriesByTag, -} from "@webstudio-is/html-data"; +import { elementsByTag } from "@webstudio-is/html-data"; import { parseComponentName, type ContentModel, @@ -55,7 +52,7 @@ const isIntersected = (arrayA: string[], arrayB: string[]) => { * so img can be put into links and buttons */ const isTagInteractive = (tag: string) => { - return tag !== "img" && categoriesByTag[tag].includes("interactive"); + return tag !== "img" && elementsByTag[tag].categories.includes("interactive"); }; const isTagSatisfyingContentModel = ({ @@ -87,7 +84,7 @@ const isTagSatisfyingContentModel = ({ // valid way to nest interactive elements if ( allowedCategories.includes("labelable") && - categoriesByTag[tag].includes("labelable") + elementsByTag[tag].categories.includes("labelable") ) { return true; } @@ -102,22 +99,22 @@ const isTagSatisfyingContentModel = ({ return false; } // instance matches parent constraints - return isIntersected(allowedCategories, categoriesByTag[tag]); + return isIntersected(allowedCategories, elementsByTag[tag].categories); }; /** * compute possible categories for tag children */ -const getTagChildrenCategories = ( +const getElementChildren = ( tag: undefined | string, allowedCategories: undefined | string[] ) => { // components without tag behave like transparent category // and pass through parent constraints - let childrenCategories: string[] = - tag === undefined ? ["transparent"] : childrenCategoriesByTag[tag]; - if (childrenCategories.includes("transparent") && allowedCategories) { - childrenCategories = allowedCategories; + let elementChildren: string[] = + tag === undefined ? ["transparent"] : elementsByTag[tag].children; + if (elementChildren.includes("transparent") && allowedCategories) { + elementChildren = allowedCategories; } // introduce custom non-interactive category to restrict nesting interactive elements // like button > button or a > input @@ -125,7 +122,7 @@ const getTagChildrenCategories = ( tag && (isTagInteractive(tag) || allowedCategories?.includes("non-interactive")) ) { - childrenCategories = [...childrenCategories, "non-interactive"]; + elementChildren = [...elementChildren, "non-interactive"]; } // interactive exception, label > input or label > button are considered // valid way to nest interactive elements @@ -133,16 +130,16 @@ const getTagChildrenCategories = ( if (tag === "label" || allowedCategories?.includes("labelable")) { // stop passing through labelable to control children // to prevent label > button > input - if (tag && categoriesByTag[tag].includes("labelable") === false) { - childrenCategories = [...childrenCategories, "labelable"]; + if (tag && elementsByTag[tag].categories.includes("labelable") === false) { + elementChildren = [...elementChildren, "labelable"]; } } // introduce custom non-form category to restrict nesting form elements // like form > div > form if (tag === "form" || allowedCategories?.includes("non-form")) { - childrenCategories = [...childrenCategories, "non-form"]; + elementChildren = [...elementChildren, "non-form"]; } - return childrenCategories; + return elementChildren; }; /** @@ -171,7 +168,7 @@ const computeAllowedCategories = ({ continue; } const tag = getTag({ instance, metas, props }); - allowedCategories = getTagChildrenCategories(tag, allowedCategories); + allowedCategories = getElementChildren(tag, allowedCategories); } return allowedCategories; }; @@ -375,7 +372,7 @@ export const isTreeSatisfyingContentModel = ({ } let isSatisfying = isTagSatisfying && isComponentSatisfying; const contentModel = getComponentContentModel(metas.get(instance.component)); - allowedCategories = getTagChildrenCategories(tag, allowedCategories); + allowedCategories = getElementChildren(tag, allowedCategories); allowedParentCategories = contentModel.children; if (contentModel.descendants) { allowedAncestorCategories ??= []; @@ -584,11 +581,11 @@ export const findClosestContainer = ({ } const tag = getTag({ instance, props, metas }); const meta = metas.get(instance.component); - const childrenCategories = tag ? childrenCategoriesByTag[tag] : undefined; - const childrenComponentCategories = getComponentContentModel(meta).children; + const elementChildren = tag ? elementsByTag[tag].children : undefined; + const componentChildren = getComponentContentModel(meta).children; if ( - childrenComponentCategories.length === 0 || - (childrenCategories && childrenCategories.length === 0) + componentChildren.length === 0 || + (elementChildren && elementChildren.length === 0) ) { continue; } @@ -621,11 +618,11 @@ export const findClosestNonTextualContainer = ({ } const tag = getTag({ instance, props, metas }); const meta = metas.get(instance.component); - const childrenCategories = tag ? childrenCategoriesByTag[tag] : undefined; - const childrenComponentCategories = getComponentContentModel(meta).children; + const elementChildren = tag ? elementsByTag[tag].children : undefined; + const componentChildren = getComponentContentModel(meta).children; if ( - childrenComponentCategories.length === 0 || - (childrenCategories && childrenCategories.length === 0) + componentChildren.length === 0 || + (elementChildren && elementChildren.length === 0) ) { continue; } diff --git a/packages/html-data/bin/elements.ts b/packages/html-data/bin/elements.ts index 98def52c909b..1b6d498ac8f6 100644 --- a/packages/html-data/bin/elements.ts +++ b/packages/html-data/bin/elements.ts @@ -12,8 +12,13 @@ import { const html = await loadHtmlIndices(); const document = parseHtml(html); -const categoriesByTag: Record = {}; -const childrenCategoriesByTag: Record = {}; +type Element = { + description: string; + categories: string[]; + children: string[]; +}; + +const elementsByTag: Record = {}; /** * scrape elements table with content model @@ -39,18 +44,27 @@ const childrenCategoriesByTag: Record = {}; // skip "SVG svg" amd "MathML math" return !tag.includes(" "); }); + const description = getTextContent(row.childNodes[1]); const categories = parseList(getTextContent(row.childNodes[2])); const children = parseList(getTextContent(row.childNodes[4])); for (const tag of elements) { - categoriesByTag[tag] = categories; - childrenCategoriesByTag[tag] = children.includes("empty") ? [] : children; + elementsByTag[tag] = { + description, + categories, + children: children.includes("empty") ? [] : children, + }; } } } -let contentModel = ``; -contentModel += `export const categoriesByTag: Record = ${JSON.stringify(categoriesByTag, null, 2)};\n`; -contentModel += `export const childrenCategoriesByTag: Record = ${JSON.stringify(childrenCategoriesByTag, null, 2)};\n`; -const contentModelFile = "./src/__generated__/content-model.ts"; +const contentModel = `type Element = { + description: string; + categories: string[]; + children: string[]; +}; + +export const elementsByTag: Record = ${JSON.stringify(elementsByTag, null, 2)}; +`; +const contentModelFile = "./src/__generated__/elements.ts"; await mkdir(dirname(contentModelFile), { recursive: true }); await writeFile(contentModelFile, contentModel); diff --git a/packages/html-data/src/__generated__/content-model.ts b/packages/html-data/src/__generated__/content-model.ts deleted file mode 100644 index 8124b376b26a..000000000000 --- a/packages/html-data/src/__generated__/content-model.ts +++ /dev/null @@ -1,298 +0,0 @@ -export const categoriesByTag: Record = { - a: ["flow", "phrasing", "interactive", "palpable"], - abbr: ["flow", "phrasing", "palpable"], - address: ["flow", "palpable"], - area: ["flow", "phrasing"], - article: ["flow", "sectioning", "palpable"], - aside: ["flow", "sectioning", "palpable"], - audio: ["flow", "phrasing", "embedded", "interactive", "palpable"], - b: ["flow", "phrasing", "palpable"], - base: ["metadata"], - bdi: ["flow", "phrasing", "palpable"], - bdo: ["flow", "phrasing", "palpable"], - blockquote: ["flow", "palpable"], - body: ["none"], - br: ["flow", "phrasing"], - button: [ - "flow", - "phrasing", - "interactive", - "listed", - "labelable", - "submittable", - "form-associated", - "palpable", - ], - canvas: ["flow", "phrasing", "embedded", "palpable"], - caption: ["none"], - cite: ["flow", "phrasing", "palpable"], - code: ["flow", "phrasing", "palpable"], - col: ["none"], - colgroup: ["none"], - data: ["flow", "phrasing", "palpable"], - datalist: ["flow", "phrasing"], - dd: ["none"], - del: ["flow", "phrasing", "palpable"], - details: ["flow", "interactive", "palpable"], - dfn: ["flow", "phrasing", "palpable"], - dialog: ["flow"], - div: ["flow", "palpable"], - dl: ["flow", "palpable"], - dt: ["none"], - em: ["flow", "phrasing", "palpable"], - embed: ["flow", "phrasing", "embedded", "interactive", "palpable"], - fieldset: ["flow", "listed", "form-associated", "palpable"], - figcaption: ["none"], - figure: ["flow", "palpable"], - footer: ["flow", "palpable"], - form: ["flow", "palpable"], - h1: ["flow", "heading", "palpable"], - h2: ["flow", "heading", "palpable"], - h3: ["flow", "heading", "palpable"], - h4: ["flow", "heading", "palpable"], - h5: ["flow", "heading", "palpable"], - h6: ["flow", "heading", "palpable"], - head: ["none"], - header: ["flow", "palpable"], - hgroup: ["flow", "palpable"], - hr: ["flow"], - html: ["none"], - i: ["flow", "phrasing", "palpable"], - iframe: ["flow", "phrasing", "embedded", "interactive", "palpable"], - img: [ - "flow", - "phrasing", - "embedded", - "interactive", - "form-associated", - "palpable", - ], - input: [ - "flow", - "phrasing", - "interactive", - "listed", - "labelable", - "submittable", - "resettable", - "form-associated", - "palpable", - ], - ins: ["flow", "phrasing", "palpable"], - kbd: ["flow", "phrasing", "palpable"], - label: ["flow", "phrasing", "interactive", "palpable"], - legend: ["none"], - li: ["none"], - link: ["metadata", "flow", "phrasing"], - main: ["flow", "palpable"], - map: ["flow", "phrasing", "palpable"], - mark: ["flow", "phrasing", "palpable"], - menu: ["flow", "palpable"], - meta: ["metadata", "flow", "phrasing"], - meter: ["flow", "phrasing", "labelable", "palpable"], - nav: ["flow", "sectioning", "palpable"], - noscript: ["metadata", "flow", "phrasing"], - object: [ - "flow", - "phrasing", - "embedded", - "interactive", - "listed", - "form-associated", - "palpable", - ], - ol: ["flow", "palpable"], - optgroup: ["none"], - option: ["none"], - output: [ - "flow", - "phrasing", - "listed", - "labelable", - "resettable", - "form-associated", - "palpable", - ], - p: ["flow", "palpable"], - picture: ["flow", "phrasing", "embedded", "palpable"], - pre: ["flow", "palpable"], - progress: ["flow", "phrasing", "labelable", "palpable"], - q: ["flow", "phrasing", "palpable"], - rp: ["none"], - rt: ["none"], - ruby: ["flow", "phrasing", "palpable"], - s: ["flow", "phrasing", "palpable"], - samp: ["flow", "phrasing", "palpable"], - script: ["metadata", "flow", "phrasing", "script-supporting"], - search: ["flow", "palpable"], - section: ["flow", "sectioning", "palpable"], - select: [ - "flow", - "phrasing", - "interactive", - "listed", - "labelable", - "submittable", - "resettable", - "form-associated", - "palpable", - ], - slot: ["flow", "phrasing"], - small: ["flow", "phrasing", "palpable"], - source: ["none"], - span: ["flow", "phrasing", "palpable"], - strong: ["flow", "phrasing", "palpable"], - style: ["metadata"], - sub: ["flow", "phrasing", "palpable"], - summary: ["none"], - sup: ["flow", "phrasing", "palpable"], - table: ["flow", "palpable"], - tbody: ["none"], - td: ["none"], - template: ["metadata", "flow", "phrasing", "script-supporting"], - textarea: [ - "flow", - "phrasing", - "interactive", - "listed", - "labelable", - "submittable", - "resettable", - "form-associated", - "palpable", - ], - tfoot: ["none"], - th: ["interactive"], - thead: ["none"], - time: ["flow", "phrasing", "palpable"], - title: ["metadata"], - tr: ["none"], - track: ["none"], - u: ["flow", "phrasing", "palpable"], - ul: ["flow", "palpable"], - var: ["flow", "phrasing", "palpable"], - video: ["flow", "phrasing", "embedded", "interactive", "palpable"], - wbr: ["flow", "phrasing"], -}; -export const childrenCategoriesByTag: Record = { - a: ["transparent"], - abbr: ["phrasing"], - address: ["flow"], - area: [], - article: ["flow"], - aside: ["flow"], - audio: ["source", "track", "transparent"], - b: ["phrasing"], - base: [], - bdi: ["phrasing"], - bdo: ["phrasing"], - blockquote: ["flow"], - body: ["flow"], - br: [], - button: ["phrasing"], - canvas: ["transparent"], - caption: ["flow"], - cite: ["phrasing"], - code: ["phrasing"], - col: [], - colgroup: ["col", "template"], - data: ["phrasing"], - datalist: ["phrasing", "option", "script-supporting elements"], - dd: ["flow"], - del: ["transparent"], - details: ["summary", "flow"], - dfn: ["phrasing"], - dialog: ["flow"], - div: ["flow"], - dl: ["dt", "dd", "div", "script-supporting elements"], - dt: ["flow"], - em: ["phrasing"], - embed: [], - fieldset: ["legend", "flow"], - figcaption: ["flow"], - figure: ["figcaption", "flow"], - footer: ["flow"], - form: ["flow"], - h1: ["phrasing"], - h2: ["phrasing"], - h3: ["phrasing"], - h4: ["phrasing"], - h5: ["phrasing"], - h6: ["phrasing"], - head: ["metadata content"], - header: ["flow"], - hgroup: ["h1", "h2", "h3", "h4", "h5", "h6", "script-supporting elements"], - hr: [], - html: ["head", "body"], - i: ["phrasing"], - iframe: [], - img: [], - input: [], - ins: ["transparent"], - kbd: ["phrasing"], - label: ["phrasing"], - legend: ["phrasing", "heading content"], - li: ["flow"], - link: [], - main: ["flow"], - map: ["transparent", "area"], - mark: ["phrasing"], - menu: ["li", "script-supporting elements"], - meta: [], - meter: ["phrasing"], - nav: ["flow"], - noscript: ["varies"], - object: ["transparent"], - ol: ["li", "script-supporting elements"], - optgroup: ["option", "script-supporting elements"], - option: ["text"], - output: ["phrasing"], - p: ["phrasing"], - picture: ["source", "one img", "script-supporting elements"], - pre: ["phrasing"], - progress: ["phrasing"], - q: ["phrasing"], - rp: ["text"], - rt: ["phrasing"], - ruby: ["phrasing", "rt", "rp"], - s: ["phrasing"], - samp: ["phrasing"], - script: ["script, data, or script documentation"], - search: ["flow"], - section: ["flow"], - select: ["option", "optgroup", "script-supporting elements"], - slot: ["transparent"], - small: ["phrasing"], - source: [], - span: ["phrasing"], - strong: ["phrasing"], - style: ["text"], - sub: ["phrasing"], - summary: ["phrasing", "heading content"], - sup: ["phrasing"], - table: [ - "caption", - "colgroup", - "thead", - "tbody", - "tfoot", - "tr", - "script-supporting elements", - ], - tbody: ["tr", "script-supporting elements"], - td: ["flow"], - template: [], - textarea: ["text"], - tfoot: ["tr", "script-supporting elements"], - th: ["flow"], - thead: ["tr", "script-supporting elements"], - time: ["phrasing"], - title: ["text"], - tr: ["th", "td", "script-supporting elements"], - track: [], - u: ["phrasing"], - ul: ["li", "script-supporting elements"], - var: ["phrasing"], - video: ["source", "track", "transparent"], - wbr: [], -}; diff --git a/packages/html-data/src/__generated__/elements.ts b/packages/html-data/src/__generated__/elements.ts new file mode 100644 index 000000000000..e9b661dce5f6 --- /dev/null +++ b/packages/html-data/src/__generated__/elements.ts @@ -0,0 +1,649 @@ +type Element = { + description: string; + categories: string[]; + children: string[]; +}; + +export const elementsByTag: Record = { + a: { + description: "Hyperlink", + categories: ["flow", "phrasing", "interactive", "palpable"], + children: ["transparent"], + }, + abbr: { + description: "Abbreviation", + categories: ["flow", "phrasing", "palpable"], + children: ["phrasing"], + }, + address: { + description: "Contact information for a page or article element", + categories: ["flow", "palpable"], + children: ["flow"], + }, + area: { + description: "Hyperlink or dead area on an image map", + categories: ["flow", "phrasing"], + children: [], + }, + article: { + description: "Self-contained syndicatable or reusable composition", + categories: ["flow", "sectioning", "palpable"], + children: ["flow"], + }, + aside: { + description: "Sidebar for tangentially related content", + categories: ["flow", "sectioning", "palpable"], + children: ["flow"], + }, + audio: { + description: "Audio player", + categories: ["flow", "phrasing", "embedded", "interactive", "palpable"], + children: ["source", "track", "transparent"], + }, + b: { + description: "Keywords", + categories: ["flow", "phrasing", "palpable"], + children: ["phrasing"], + }, + base: { + description: + "Base URL and default target navigable for hyperlinks and forms", + categories: ["metadata"], + children: [], + }, + bdi: { + description: "Text directionality isolation", + categories: ["flow", "phrasing", "palpable"], + children: ["phrasing"], + }, + bdo: { + description: "Text directionality formatting", + categories: ["flow", "phrasing", "palpable"], + children: ["phrasing"], + }, + blockquote: { + description: "A section quoted from another source", + categories: ["flow", "palpable"], + children: ["flow"], + }, + body: { + description: "Document body", + categories: ["none"], + children: ["flow"], + }, + br: { + description: "Line break, e.g. in poem or postal address", + categories: ["flow", "phrasing"], + children: [], + }, + button: { + description: "Button control", + categories: [ + "flow", + "phrasing", + "interactive", + "listed", + "labelable", + "submittable", + "form-associated", + "palpable", + ], + children: ["phrasing"], + }, + canvas: { + description: "Scriptable bitmap canvas", + categories: ["flow", "phrasing", "embedded", "palpable"], + children: ["transparent"], + }, + caption: { + description: "Table caption", + categories: ["none"], + children: ["flow"], + }, + cite: { + description: "Title of a work", + categories: ["flow", "phrasing", "palpable"], + children: ["phrasing"], + }, + code: { + description: "Computer code", + categories: ["flow", "phrasing", "palpable"], + children: ["phrasing"], + }, + col: { + description: "Table column", + categories: ["none"], + children: [], + }, + colgroup: { + description: "Group of columns in a table", + categories: ["none"], + children: ["col", "template"], + }, + data: { + description: "Machine-readable equivalent", + categories: ["flow", "phrasing", "palpable"], + children: ["phrasing"], + }, + datalist: { + description: "Container for options for combo box control", + categories: ["flow", "phrasing"], + children: ["phrasing", "option", "script-supporting elements"], + }, + dd: { + description: "Content for corresponding dt element(s)", + categories: ["none"], + children: ["flow"], + }, + del: { + description: "A removal from the document", + categories: ["flow", "phrasing", "palpable"], + children: ["transparent"], + }, + details: { + description: "Disclosure control for hiding details", + categories: ["flow", "interactive", "palpable"], + children: ["summary", "flow"], + }, + dfn: { + description: "Defining instance", + categories: ["flow", "phrasing", "palpable"], + children: ["phrasing"], + }, + dialog: { + description: "Dialog box or window", + categories: ["flow"], + children: ["flow"], + }, + div: { + description: + "Generic flow container, or container for name-value groups in dl elements", + categories: ["flow", "palpable"], + children: ["flow"], + }, + dl: { + description: + "Association list consisting of zero or more name-value groups", + categories: ["flow", "palpable"], + children: ["dt", "dd", "div", "script-supporting elements"], + }, + dt: { + description: "Legend for corresponding dd element(s)", + categories: ["none"], + children: ["flow"], + }, + em: { + description: "Stress emphasis", + categories: ["flow", "phrasing", "palpable"], + children: ["phrasing"], + }, + embed: { + description: "Plugin", + categories: ["flow", "phrasing", "embedded", "interactive", "palpable"], + children: [], + }, + fieldset: { + description: "Group of form controls", + categories: ["flow", "listed", "form-associated", "palpable"], + children: ["legend", "flow"], + }, + figcaption: { + description: "Caption for figure", + categories: ["none"], + children: ["flow"], + }, + figure: { + description: "Figure with optional caption", + categories: ["flow", "palpable"], + children: ["figcaption", "flow"], + }, + footer: { + description: "Footer for a page or section", + categories: ["flow", "palpable"], + children: ["flow"], + }, + form: { + description: "User-submittable form", + categories: ["flow", "palpable"], + children: ["flow"], + }, + h1: { + description: "Heading", + categories: ["flow", "heading", "palpable"], + children: ["phrasing"], + }, + h2: { + description: "Heading", + categories: ["flow", "heading", "palpable"], + children: ["phrasing"], + }, + h3: { + description: "Heading", + categories: ["flow", "heading", "palpable"], + children: ["phrasing"], + }, + h4: { + description: "Heading", + categories: ["flow", "heading", "palpable"], + children: ["phrasing"], + }, + h5: { + description: "Heading", + categories: ["flow", "heading", "palpable"], + children: ["phrasing"], + }, + h6: { + description: "Heading", + categories: ["flow", "heading", "palpable"], + children: ["phrasing"], + }, + head: { + description: "Container for document metadata", + categories: ["none"], + children: ["metadata content"], + }, + header: { + description: "Introductory or navigational aids for a page or section", + categories: ["flow", "palpable"], + children: ["flow"], + }, + hgroup: { + description: "Heading container", + categories: ["flow", "palpable"], + children: [ + "h1", + "h2", + "h3", + "h4", + "h5", + "h6", + "script-supporting elements", + ], + }, + hr: { + description: "Thematic break", + categories: ["flow"], + children: [], + }, + html: { + description: "Root element", + categories: ["none"], + children: ["head", "body"], + }, + i: { + description: "Alternate voice", + categories: ["flow", "phrasing", "palpable"], + children: ["phrasing"], + }, + iframe: { + description: "Child navigable", + categories: ["flow", "phrasing", "embedded", "interactive", "palpable"], + children: [], + }, + img: { + description: "Image", + categories: [ + "flow", + "phrasing", + "embedded", + "interactive", + "form-associated", + "palpable", + ], + children: [], + }, + input: { + description: "Form control", + categories: [ + "flow", + "phrasing", + "interactive", + "listed", + "labelable", + "submittable", + "resettable", + "form-associated", + "palpable", + ], + children: [], + }, + ins: { + description: "An addition to the document", + categories: ["flow", "phrasing", "palpable"], + children: ["transparent"], + }, + kbd: { + description: "User input", + categories: ["flow", "phrasing", "palpable"], + children: ["phrasing"], + }, + label: { + description: "Caption for a form control", + categories: ["flow", "phrasing", "interactive", "palpable"], + children: ["phrasing"], + }, + legend: { + description: "Caption for fieldset", + categories: ["none"], + children: ["phrasing", "heading content"], + }, + li: { + description: "List item", + categories: ["none"], + children: ["flow"], + }, + link: { + description: "Link metadata", + categories: ["metadata", "flow", "phrasing"], + children: [], + }, + main: { + description: "Container for the dominant contents of the document", + categories: ["flow", "palpable"], + children: ["flow"], + }, + map: { + description: "Image map", + categories: ["flow", "phrasing", "palpable"], + children: ["transparent", "area"], + }, + mark: { + description: "Highlight", + categories: ["flow", "phrasing", "palpable"], + children: ["phrasing"], + }, + menu: { + description: "Menu of commands", + categories: ["flow", "palpable"], + children: ["li", "script-supporting elements"], + }, + meta: { + description: "Text metadata", + categories: ["metadata", "flow", "phrasing"], + children: [], + }, + meter: { + description: "Gauge", + categories: ["flow", "phrasing", "labelable", "palpable"], + children: ["phrasing"], + }, + nav: { + description: "Section with navigational links", + categories: ["flow", "sectioning", "palpable"], + children: ["flow"], + }, + noscript: { + description: "Fallback content for script", + categories: ["metadata", "flow", "phrasing"], + children: ["varies"], + }, + object: { + description: "Image, child navigable, or plugin", + categories: [ + "flow", + "phrasing", + "embedded", + "interactive", + "listed", + "form-associated", + "palpable", + ], + children: ["transparent"], + }, + ol: { + description: "Ordered list", + categories: ["flow", "palpable"], + children: ["li", "script-supporting elements"], + }, + optgroup: { + description: "Group of options in a list box", + categories: ["none"], + children: ["option", "script-supporting elements"], + }, + option: { + description: "Option in a list box or combo box control", + categories: ["none"], + children: ["text"], + }, + output: { + description: "Calculated output value", + categories: [ + "flow", + "phrasing", + "listed", + "labelable", + "resettable", + "form-associated", + "palpable", + ], + children: ["phrasing"], + }, + p: { + description: "Paragraph", + categories: ["flow", "palpable"], + children: ["phrasing"], + }, + picture: { + description: "Image", + categories: ["flow", "phrasing", "embedded", "palpable"], + children: ["source", "one img", "script-supporting elements"], + }, + pre: { + description: "Block of preformatted text", + categories: ["flow", "palpable"], + children: ["phrasing"], + }, + progress: { + description: "Progress bar", + categories: ["flow", "phrasing", "labelable", "palpable"], + children: ["phrasing"], + }, + q: { + description: "Quotation", + categories: ["flow", "phrasing", "palpable"], + children: ["phrasing"], + }, + rp: { + description: "Parenthesis for ruby annotation text", + categories: ["none"], + children: ["text"], + }, + rt: { + description: "Ruby annotation text", + categories: ["none"], + children: ["phrasing"], + }, + ruby: { + description: "Ruby annotation(s)", + categories: ["flow", "phrasing", "palpable"], + children: ["phrasing", "rt", "rp"], + }, + s: { + description: "Inaccurate text", + categories: ["flow", "phrasing", "palpable"], + children: ["phrasing"], + }, + samp: { + description: "Computer output", + categories: ["flow", "phrasing", "palpable"], + children: ["phrasing"], + }, + script: { + description: "Embedded script", + categories: ["metadata", "flow", "phrasing", "script-supporting"], + children: ["script, data, or script documentation"], + }, + search: { + description: "Container for search controls", + categories: ["flow", "palpable"], + children: ["flow"], + }, + section: { + description: "Generic document or application section", + categories: ["flow", "sectioning", "palpable"], + children: ["flow"], + }, + select: { + description: "List box control", + categories: [ + "flow", + "phrasing", + "interactive", + "listed", + "labelable", + "submittable", + "resettable", + "form-associated", + "palpable", + ], + children: ["option", "optgroup", "script-supporting elements"], + }, + slot: { + description: "Shadow tree slot", + categories: ["flow", "phrasing"], + children: ["transparent"], + }, + small: { + description: "Side comment", + categories: ["flow", "phrasing", "palpable"], + children: ["phrasing"], + }, + source: { + description: "Image source for img or media source for video or audio", + categories: ["none"], + children: [], + }, + span: { + description: "Generic phrasing container", + categories: ["flow", "phrasing", "palpable"], + children: ["phrasing"], + }, + strong: { + description: "Importance", + categories: ["flow", "phrasing", "palpable"], + children: ["phrasing"], + }, + style: { + description: "Embedded styling information", + categories: ["metadata"], + children: ["text"], + }, + sub: { + description: "Subscript", + categories: ["flow", "phrasing", "palpable"], + children: ["phrasing"], + }, + summary: { + description: "Caption for details", + categories: ["none"], + children: ["phrasing", "heading content"], + }, + sup: { + description: "Superscript", + categories: ["flow", "phrasing", "palpable"], + children: ["phrasing"], + }, + table: { + description: "Table", + categories: ["flow", "palpable"], + children: [ + "caption", + "colgroup", + "thead", + "tbody", + "tfoot", + "tr", + "script-supporting elements", + ], + }, + tbody: { + description: "Group of rows in a table", + categories: ["none"], + children: ["tr", "script-supporting elements"], + }, + td: { + description: "Table cell", + categories: ["none"], + children: ["flow"], + }, + template: { + description: "Template", + categories: ["metadata", "flow", "phrasing", "script-supporting"], + children: [], + }, + textarea: { + description: "Multiline text controls", + categories: [ + "flow", + "phrasing", + "interactive", + "listed", + "labelable", + "submittable", + "resettable", + "form-associated", + "palpable", + ], + children: ["text"], + }, + tfoot: { + description: "Group of footer rows in a table", + categories: ["none"], + children: ["tr", "script-supporting elements"], + }, + th: { + description: "Table header cell", + categories: ["interactive"], + children: ["flow"], + }, + thead: { + description: "Group of heading rows in a table", + categories: ["none"], + children: ["tr", "script-supporting elements"], + }, + time: { + description: "Machine-readable equivalent of date- or time-related data", + categories: ["flow", "phrasing", "palpable"], + children: ["phrasing"], + }, + title: { + description: "Document title", + categories: ["metadata"], + children: ["text"], + }, + tr: { + description: "Table row", + categories: ["none"], + children: ["th", "td", "script-supporting elements"], + }, + track: { + description: "Timed text track", + categories: ["none"], + children: [], + }, + u: { + description: "Unarticulated annotation", + categories: ["flow", "phrasing", "palpable"], + children: ["phrasing"], + }, + ul: { + description: "List", + categories: ["flow", "palpable"], + children: ["li", "script-supporting elements"], + }, + var: { + description: "Variable", + categories: ["flow", "phrasing", "palpable"], + children: ["phrasing"], + }, + video: { + description: "Video player", + categories: ["flow", "phrasing", "embedded", "interactive", "palpable"], + children: ["source", "track", "transparent"], + }, + wbr: { + description: "Line breaking opportunity", + categories: ["flow", "phrasing"], + children: [], + }, +}; diff --git a/packages/html-data/src/index.ts b/packages/html-data/src/index.ts index 5b6cc9481689..017213bfefd5 100644 --- a/packages/html-data/src/index.ts +++ b/packages/html-data/src/index.ts @@ -1,5 +1,5 @@ -export * from "./__generated__/content-model"; export * from "./descriptions"; export * from "./dom-attributes-react-mappings"; +export * from "./__generated__/elements"; export * from "./__generated__/attributes"; export * from "./__generated__/aria";