|
| 1 | +/** |
| 2 | + * @typedef {import('./index.js').Element} Element |
| 3 | + * @typedef {import('./index.js').Root} Root |
| 4 | + * @typedef {import('./index.js').XResult} XResult |
| 5 | + * @typedef {import('./index.js').XChild} XChild |
| 6 | + * @typedef {import('./index.js').XAttributes} XAttributes |
| 7 | + * @typedef {import('./index.js').XValue} XValue |
| 8 | + * |
| 9 | + * @typedef {{[x: string]: XValue|XChild}} JSXProps |
| 10 | + */ |
| 11 | + |
| 12 | +import {x} from './index.js' |
| 13 | + |
| 14 | +// Export `JSX` as a global for TypeScript. |
| 15 | +export * from './jsx-automatic.js' |
| 16 | + |
| 17 | +/** |
| 18 | + * Create XML trees in xast through JSX. |
| 19 | + * |
| 20 | + * @param name Qualified name. Case sensitive and can contain a namespace prefix (such as `rdf:RDF`). Pass `null|undefined` to build a root. |
| 21 | + * @param props Map of attributes. Nullish (null or undefined) or NaN values are ignored, other values (strings, booleans) are cast to strings. `children` can contain one child or a list of children. When strings are encountered, they are mapped to text nodes. |
| 22 | + */ |
| 23 | +export const jsx = |
| 24 | + /** |
| 25 | + * @type {{ |
| 26 | + * (name: null|undefined, props: {children?: XChild}, key?: string): Root |
| 27 | + * (name: string, props: JSXProps, key?: string): Element |
| 28 | + * }} |
| 29 | + */ |
| 30 | + ( |
| 31 | + /** |
| 32 | + * @param {string|null} name |
| 33 | + * @param {XAttributes & {children?: XChild}} props |
| 34 | + * @returns {XResult} |
| 35 | + */ |
| 36 | + function (name, props) { |
| 37 | + var {children, ...properties} = props |
| 38 | + return name === null ? x(name, children) : x(name, properties, children) |
| 39 | + } |
| 40 | + ) |
| 41 | + |
| 42 | +export const jsxs = jsx |
| 43 | + |
| 44 | +/** @type {null} */ |
| 45 | +export const Fragment = null |
0 commit comments