create-h.d.ts 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /**
  2. * @param {Schema} schema
  3. * Schema to use.
  4. * @param {string} defaultTagName
  5. * Default tag name.
  6. * @param {ReadonlyArray<string> | undefined} [caseSensitive]
  7. * Case-sensitive tag names (default: `undefined`).
  8. * @returns
  9. * `h`.
  10. */
  11. export function createH(schema: Schema, defaultTagName: string, caseSensitive?: ReadonlyArray<string> | undefined): {
  12. /**
  13. * Hyperscript compatible DSL for creating virtual hast trees.
  14. *
  15. * @overload
  16. * @param {null | undefined} [selector]
  17. * @param {...Child} children
  18. * @returns {Root}
  19. *
  20. * @overload
  21. * @param {string} selector
  22. * @param {Properties} properties
  23. * @param {...Child} children
  24. * @returns {Element}
  25. *
  26. * @overload
  27. * @param {string} selector
  28. * @param {...Child} children
  29. * @returns {Element}
  30. *
  31. * @param {string | null | undefined} [selector]
  32. * Selector.
  33. * @param {Child | Properties | null | undefined} [properties]
  34. * Properties (or first child) (default: `undefined`).
  35. * @param {...Child} children
  36. * Children.
  37. * @returns {Result}
  38. * Result.
  39. */
  40. (selector?: null | undefined, ...children: Child[]): Root;
  41. /**
  42. * Hyperscript compatible DSL for creating virtual hast trees.
  43. *
  44. * @overload
  45. * @param {null | undefined} [selector]
  46. * @param {...Child} children
  47. * @returns {Root}
  48. *
  49. * @overload
  50. * @param {string} selector
  51. * @param {Properties} properties
  52. * @param {...Child} children
  53. * @returns {Element}
  54. *
  55. * @overload
  56. * @param {string} selector
  57. * @param {...Child} children
  58. * @returns {Element}
  59. *
  60. * @param {string | null | undefined} [selector]
  61. * Selector.
  62. * @param {Child | Properties | null | undefined} [properties]
  63. * Properties (or first child) (default: `undefined`).
  64. * @param {...Child} children
  65. * Children.
  66. * @returns {Result}
  67. * Result.
  68. */
  69. (selector: string, properties: Properties, ...children: Child[]): Element;
  70. /**
  71. * Hyperscript compatible DSL for creating virtual hast trees.
  72. *
  73. * @overload
  74. * @param {null | undefined} [selector]
  75. * @param {...Child} children
  76. * @returns {Root}
  77. *
  78. * @overload
  79. * @param {string} selector
  80. * @param {Properties} properties
  81. * @param {...Child} children
  82. * @returns {Element}
  83. *
  84. * @overload
  85. * @param {string} selector
  86. * @param {...Child} children
  87. * @returns {Element}
  88. *
  89. * @param {string | null | undefined} [selector]
  90. * Selector.
  91. * @param {Child | Properties | null | undefined} [properties]
  92. * Properties (or first child) (default: `undefined`).
  93. * @param {...Child} children
  94. * Children.
  95. * @returns {Result}
  96. * Result.
  97. */
  98. (selector: string, ...children: Child[]): Element;
  99. };
  100. /**
  101. * List of children (deep).
  102. */
  103. export type ArrayChildNested = Array<Nodes | PrimitiveChild>;
  104. /**
  105. * List of children.
  106. */
  107. export type ArrayChild = Array<ArrayChildNested | Nodes | PrimitiveChild>;
  108. /**
  109. * List of property values for space- or comma separated values (such as `className`).
  110. */
  111. export type ArrayValue = Array<number | string>;
  112. /**
  113. * Acceptable child value.
  114. */
  115. export type Child = ArrayChild | Nodes | PrimitiveChild;
  116. /**
  117. * Primitive children, either ignored (nullish), or turned into text nodes.
  118. */
  119. export type PrimitiveChild = number | string | null | undefined;
  120. /**
  121. * Primitive property value.
  122. */
  123. export type PrimitiveValue = boolean | number | string | null | undefined;
  124. /**
  125. * Acceptable value for element properties.
  126. */
  127. export type Properties = Record<string, PropertyValue | Style>;
  128. /**
  129. * Primitive value or list value.
  130. */
  131. export type PropertyValue = ArrayValue | PrimitiveValue;
  132. /**
  133. * Result from a `h` (or `s`) call.
  134. */
  135. export type Result = Element | Root;
  136. /**
  137. * Value for a CSS style field.
  138. */
  139. export type StyleValue = number | string;
  140. /**
  141. * Supported value of a `style` prop.
  142. */
  143. export type Style = Record<string, StyleValue>;
  144. import type { Schema } from 'property-information';
  145. import type { Root } from 'hast';
  146. import type { Element } from 'hast';
  147. import type { Nodes } from 'hast';
  148. //# sourceMappingURL=create-h.d.ts.map