@redis-ui/components 51.27.0 → 51.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/dist/CodeBlock/CodeBlock.cjs +29 -14
  2. package/dist/CodeBlock/CodeBlock.js +29 -14
  3. package/dist/CodeBlock/CodeBlock.style.d.ts +4 -3
  4. package/dist/CodeBlock/CodeBlock.types.cjs +7 -0
  5. package/dist/CodeBlock/CodeBlock.types.d.ts +4 -0
  6. package/dist/CodeBlock/CodeBlock.types.js +7 -1
  7. package/dist/CodeBlock/components/HighlightedCode/HighlightedCode.cjs +29 -0
  8. package/dist/CodeBlock/components/HighlightedCode/HighlightedCode.constants.cjs +34 -0
  9. package/dist/CodeBlock/components/HighlightedCode/HighlightedCode.constants.d.ts +25 -0
  10. package/dist/CodeBlock/components/HighlightedCode/HighlightedCode.constants.js +32 -0
  11. package/dist/CodeBlock/components/HighlightedCode/HighlightedCode.d.ts +6 -0
  12. package/dist/CodeBlock/components/HighlightedCode/HighlightedCode.js +29 -0
  13. package/dist/CodeBlock/components/HighlightedCode/HighlightedCode.types.d.ts +10 -0
  14. package/dist/CodeBlock/components/HighlightedCode/HighlightedCode.types.js +1 -0
  15. package/dist/index.cjs +1 -0
  16. package/dist/index.js +2 -2
  17. package/dist/node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.cjs +8 -0
  18. package/dist/node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js +8 -0
  19. package/dist/node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.cjs +7 -0
  20. package/dist/node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js +7 -0
  21. package/dist/node_modules/@babel/runtime/helpers/esm/defineProperty.cjs +12 -0
  22. package/dist/node_modules/@babel/runtime/helpers/esm/defineProperty.js +12 -0
  23. package/dist/node_modules/@babel/runtime/helpers/esm/extends.cjs +17 -0
  24. package/dist/node_modules/@babel/runtime/helpers/esm/extends.js +12 -0
  25. package/dist/node_modules/@babel/runtime/helpers/esm/iterableToArray.cjs +6 -0
  26. package/dist/node_modules/@babel/runtime/helpers/esm/iterableToArray.js +6 -0
  27. package/dist/node_modules/@babel/runtime/helpers/esm/nonIterableSpread.cjs +6 -0
  28. package/dist/node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js +6 -0
  29. package/dist/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.cjs +13 -0
  30. package/dist/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js +13 -0
  31. package/dist/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.cjs +12 -0
  32. package/dist/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js +12 -0
  33. package/dist/node_modules/@babel/runtime/helpers/esm/toConsumableArray.cjs +10 -0
  34. package/dist/node_modules/@babel/runtime/helpers/esm/toConsumableArray.js +10 -0
  35. package/dist/node_modules/@babel/runtime/helpers/esm/toPrimitive.cjs +14 -0
  36. package/dist/node_modules/@babel/runtime/helpers/esm/toPrimitive.js +14 -0
  37. package/dist/node_modules/@babel/runtime/helpers/esm/toPropertyKey.cjs +9 -0
  38. package/dist/node_modules/@babel/runtime/helpers/esm/toPropertyKey.js +9 -0
  39. package/dist/node_modules/@babel/runtime/helpers/esm/typeof.cjs +16 -0
  40. package/dist/node_modules/@babel/runtime/helpers/esm/typeof.js +11 -0
  41. package/dist/node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.cjs +11 -0
  42. package/dist/node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js +11 -0
  43. package/dist/node_modules/character-entities-legacy/index.cjs +116 -0
  44. package/dist/node_modules/character-entities-legacy/index.js +116 -0
  45. package/dist/node_modules/character-reference-invalid/index.cjs +38 -0
  46. package/dist/node_modules/character-reference-invalid/index.js +38 -0
  47. package/dist/node_modules/comma-separated-tokens/index.cjs +43 -0
  48. package/dist/node_modules/comma-separated-tokens/index.js +43 -0
  49. package/dist/node_modules/decode-named-character-reference/index.dom.cjs +15 -0
  50. package/dist/node_modules/decode-named-character-reference/index.dom.js +15 -0
  51. package/dist/node_modules/hast-util-parse-selector/lib/index.cjs +76 -0
  52. package/dist/node_modules/hast-util-parse-selector/lib/index.js +76 -0
  53. package/dist/node_modules/hastscript/lib/create-h.cjs +262 -0
  54. package/dist/node_modules/hastscript/lib/create-h.js +262 -0
  55. package/dist/node_modules/hastscript/lib/index.cjs +21 -0
  56. package/dist/node_modules/hastscript/lib/index.js +21 -0
  57. package/dist/node_modules/hastscript/lib/svg-case-sensitive-tag-names.cjs +49 -0
  58. package/dist/node_modules/hastscript/lib/svg-case-sensitive-tag-names.js +49 -0
  59. package/dist/node_modules/is-alphabetical/index.cjs +14 -0
  60. package/dist/node_modules/is-alphabetical/index.js +14 -0
  61. package/dist/node_modules/is-alphanumerical/index.cjs +15 -0
  62. package/dist/node_modules/is-alphanumerical/index.js +15 -0
  63. package/dist/node_modules/is-decimal/index.cjs +14 -0
  64. package/dist/node_modules/is-decimal/index.js +14 -0
  65. package/dist/node_modules/is-hexadecimal/index.cjs +14 -0
  66. package/dist/node_modules/is-hexadecimal/index.js +14 -0
  67. package/dist/node_modules/parse-entities/lib/index.cjs +232 -0
  68. package/dist/node_modules/parse-entities/lib/index.js +232 -0
  69. package/dist/node_modules/property-information/index.cjs +27 -0
  70. package/dist/node_modules/property-information/index.js +26 -0
  71. package/dist/node_modules/property-information/lib/aria.cjs +60 -0
  72. package/dist/node_modules/property-information/lib/aria.js +61 -0
  73. package/dist/node_modules/property-information/lib/find.cjs +81 -0
  74. package/dist/node_modules/property-information/lib/find.js +81 -0
  75. package/dist/node_modules/property-information/lib/html.cjs +326 -0
  76. package/dist/node_modules/property-information/lib/html.js +326 -0
  77. package/dist/node_modules/property-information/lib/normalize.cjs +15 -0
  78. package/dist/node_modules/property-information/lib/normalize.js +15 -0
  79. package/dist/node_modules/property-information/lib/svg.cjs +564 -0
  80. package/dist/node_modules/property-information/lib/svg.js +564 -0
  81. package/dist/node_modules/property-information/lib/util/case-insensitive-transform.cjs +15 -0
  82. package/dist/node_modules/property-information/lib/util/case-insensitive-transform.js +15 -0
  83. package/dist/node_modules/property-information/lib/util/case-sensitive-transform.cjs +14 -0
  84. package/dist/node_modules/property-information/lib/util/case-sensitive-transform.js +14 -0
  85. package/dist/node_modules/property-information/lib/util/create.cjs +53 -0
  86. package/dist/node_modules/property-information/lib/util/create.js +53 -0
  87. package/dist/node_modules/property-information/lib/util/defined-info.cjs +49 -0
  88. package/dist/node_modules/property-information/lib/util/defined-info.js +49 -0
  89. package/dist/node_modules/property-information/lib/util/info.cjs +33 -0
  90. package/dist/node_modules/property-information/lib/util/info.js +33 -0
  91. package/dist/node_modules/property-information/lib/util/merge.cjs +26 -0
  92. package/dist/node_modules/property-information/lib/util/merge.js +26 -0
  93. package/dist/node_modules/property-information/lib/util/schema.cjs +27 -0
  94. package/dist/node_modules/property-information/lib/util/schema.js +27 -0
  95. package/dist/node_modules/property-information/lib/util/types.cjs +35 -0
  96. package/dist/node_modules/property-information/lib/util/types.js +24 -0
  97. package/dist/node_modules/property-information/lib/xlink.cjs +18 -0
  98. package/dist/node_modules/property-information/lib/xlink.js +19 -0
  99. package/dist/node_modules/property-information/lib/xml.cjs +14 -0
  100. package/dist/node_modules/property-information/lib/xml.js +15 -0
  101. package/dist/node_modules/property-information/lib/xmlns.cjs +14 -0
  102. package/dist/node_modules/property-information/lib/xmlns.js +14 -0
  103. package/dist/node_modules/react-syntax-highlighter/dist/esm/checkForListedLanguage.cjs +6 -0
  104. package/dist/node_modules/react-syntax-highlighter/dist/esm/checkForListedLanguage.js +6 -0
  105. package/dist/node_modules/react-syntax-highlighter/dist/esm/create-element.cjs +183 -0
  106. package/dist/node_modules/react-syntax-highlighter/dist/esm/create-element.js +181 -0
  107. package/dist/node_modules/react-syntax-highlighter/dist/esm/highlight.cjs +308 -0
  108. package/dist/node_modules/react-syntax-highlighter/dist/esm/highlight.js +306 -0
  109. package/dist/node_modules/react-syntax-highlighter/dist/esm/languages/prism/bash.cjs +4 -0
  110. package/dist/node_modules/react-syntax-highlighter/dist/esm/languages/prism/bash.js +5 -0
  111. package/dist/node_modules/react-syntax-highlighter/dist/esm/languages/prism/json.cjs +4 -0
  112. package/dist/node_modules/react-syntax-highlighter/dist/esm/languages/prism/json.js +5 -0
  113. package/dist/node_modules/react-syntax-highlighter/dist/esm/languages/prism/python.cjs +4 -0
  114. package/dist/node_modules/react-syntax-highlighter/dist/esm/languages/prism/python.js +5 -0
  115. package/dist/node_modules/react-syntax-highlighter/dist/esm/languages/prism/typescript.cjs +4 -0
  116. package/dist/node_modules/react-syntax-highlighter/dist/esm/languages/prism/typescript.js +5 -0
  117. package/dist/node_modules/react-syntax-highlighter/dist/esm/prism-light.cjs +12 -0
  118. package/dist/node_modules/react-syntax-highlighter/dist/esm/prism-light.js +12 -0
  119. package/dist/node_modules/react-syntax-highlighter/dist/esm/styles/prism/vs.cjs +121 -0
  120. package/dist/node_modules/react-syntax-highlighter/dist/esm/styles/prism/vs.js +121 -0
  121. package/dist/node_modules/react-syntax-highlighter/dist/esm/styles/prism/vsc-dark-plus.cjs +147 -0
  122. package/dist/node_modules/react-syntax-highlighter/dist/esm/styles/prism/vsc-dark-plus.js +147 -0
  123. package/dist/node_modules/refractor/lang/bash.cjs +190 -0
  124. package/dist/node_modules/refractor/lang/bash.js +190 -0
  125. package/dist/node_modules/refractor/lang/clike.cjs +37 -0
  126. package/dist/node_modules/refractor/lang/clike.js +37 -0
  127. package/dist/node_modules/refractor/lang/javascript.cjs +122 -0
  128. package/dist/node_modules/refractor/lang/javascript.js +122 -0
  129. package/dist/node_modules/refractor/lang/json.cjs +36 -0
  130. package/dist/node_modules/refractor/lang/json.js +36 -0
  131. package/dist/node_modules/refractor/lang/python.cjs +71 -0
  132. package/dist/node_modules/refractor/lang/python.js +71 -0
  133. package/dist/node_modules/refractor/lang/typescript.cjs +55 -0
  134. package/dist/node_modules/refractor/lang/typescript.js +55 -0
  135. package/dist/node_modules/refractor/lib/core.cjs +214 -0
  136. package/dist/node_modules/refractor/lib/core.js +214 -0
  137. package/dist/node_modules/refractor/lib/prism-core.cjs +595 -0
  138. package/dist/node_modules/refractor/lib/prism-core.js +595 -0
  139. package/dist/node_modules/space-separated-tokens/index.cjs +15 -0
  140. package/dist/node_modules/space-separated-tokens/index.js +15 -0
  141. package/package.json +3 -1
  142. package/skills/redis-ui-components/references/CodeBlock.md +23 -5
@@ -0,0 +1,262 @@
1
+ const require_normalize = require("../../property-information/lib/normalize.cjs");
2
+ const require_find = require("../../property-information/lib/find.cjs");
3
+ const require_index = require("../../comma-separated-tokens/index.cjs");
4
+ const require_index$1 = require("../../hast-util-parse-selector/lib/index.cjs");
5
+ const require_index$2 = require("../../space-separated-tokens/index.cjs");
6
+ //#region ../../node_modules/hastscript/lib/create-h.js
7
+ /**
8
+ * @import {Element, Nodes, RootContent, Root} from 'hast'
9
+ * @import {Info, Schema} from 'property-information'
10
+ */
11
+ /**
12
+ * @typedef {Array<Nodes | PrimitiveChild>} ArrayChildNested
13
+ * List of children (deep).
14
+ */
15
+ /**
16
+ * @typedef {Array<ArrayChildNested | Nodes | PrimitiveChild>} ArrayChild
17
+ * List of children.
18
+ */
19
+ /**
20
+ * @typedef {Array<number | string>} ArrayValue
21
+ * List of property values for space- or comma separated values (such as `className`).
22
+ */
23
+ /**
24
+ * @typedef {ArrayChild | Nodes | PrimitiveChild} Child
25
+ * Acceptable child value.
26
+ */
27
+ /**
28
+ * @typedef {number | string | null | undefined} PrimitiveChild
29
+ * Primitive children, either ignored (nullish), or turned into text nodes.
30
+ */
31
+ /**
32
+ * @typedef {boolean | number | string | null | undefined} PrimitiveValue
33
+ * Primitive property value.
34
+ */
35
+ /**
36
+ * @typedef {Record<string, PropertyValue | Style>} Properties
37
+ * Acceptable value for element properties.
38
+ */
39
+ /**
40
+ * @typedef {ArrayValue | PrimitiveValue} PropertyValue
41
+ * Primitive value or list value.
42
+ */
43
+ /**
44
+ * @typedef {Element | Root} Result
45
+ * Result from a `h` (or `s`) call.
46
+ */
47
+ /**
48
+ * @typedef {number | string} StyleValue
49
+ * Value for a CSS style field.
50
+ */
51
+ /**
52
+ * @typedef {Record<string, StyleValue>} Style
53
+ * Supported value of a `style` prop.
54
+ */
55
+ /**
56
+ * Create an `h` function.
57
+ *
58
+ * @param {Schema} schema
59
+ * Schema to use.
60
+ * @param {string} defaultTagName
61
+ * Default tag name.
62
+ * @param {ReadonlyArray<string> | undefined} [caseSensitive]
63
+ * Case-sensitive tag names (default: `undefined`).
64
+ * @returns
65
+ * `h`.
66
+ */
67
+ function createH(schema, defaultTagName, caseSensitive) {
68
+ const adjust = caseSensitive ? createAdjustMap(caseSensitive) : void 0;
69
+ /**
70
+ * Hyperscript compatible DSL for creating virtual hast trees.
71
+ *
72
+ * @overload
73
+ * @param {null | undefined} [selector]
74
+ * Nothing to get a root.
75
+ * @param {...Child} children
76
+ * Children.
77
+ * @returns {Root}
78
+ * Root.
79
+ *
80
+ * @overload
81
+ * @param {string} selector
82
+ * Selector.
83
+ * @param {Child | Properties} [properties]
84
+ * Properties (or first child) (default: `undefined`).
85
+ * @param {...Child} children
86
+ * Children.
87
+ * @returns {Element}
88
+ * Element.
89
+ *
90
+ * @param {string | null | undefined} [selector]
91
+ * Selector.
92
+ * @param {Child | Properties} [properties]
93
+ * Properties (or first child) (default: `undefined`).
94
+ * @param {...Child} children
95
+ * Children.
96
+ * @returns {Result}
97
+ * Result.
98
+ */
99
+ function h(selector, properties, ...children) {
100
+ /** @type {Result} */
101
+ let node;
102
+ if (selector === null || selector === void 0) {
103
+ node = {
104
+ type: "root",
105
+ children: []
106
+ };
107
+ const child = properties;
108
+ children.unshift(child);
109
+ } else {
110
+ node = require_index$1.parseSelector(selector, defaultTagName);
111
+ const lower = node.tagName.toLowerCase();
112
+ const adjusted = adjust ? adjust.get(lower) : void 0;
113
+ node.tagName = adjusted || lower;
114
+ if (isChild(properties)) children.unshift(properties);
115
+ else for (const [key, value] of Object.entries(properties)) addProperty(schema, node.properties, key, value);
116
+ }
117
+ for (const child of children) addChild(node.children, child);
118
+ if (node.type === "element" && node.tagName === "template" && schema.space === "html") {
119
+ node.content = {
120
+ type: "root",
121
+ children: node.children
122
+ };
123
+ node.children = [];
124
+ }
125
+ return node;
126
+ }
127
+ return h;
128
+ }
129
+ /**
130
+ * Check if something is properties or a child.
131
+ *
132
+ * @param {Child | Properties} value
133
+ * Value to check.
134
+ * @returns {value is Child}
135
+ * Whether `value` is definitely a child.
136
+ */
137
+ function isChild(value) {
138
+ if (value === null || typeof value !== "object" || Array.isArray(value)) return true;
139
+ if (typeof value.type !== "string") return false;
140
+ const record = value;
141
+ const keys = Object.keys(value);
142
+ for (const key of keys) {
143
+ const value = record[key];
144
+ if (value && typeof value === "object") {
145
+ if (!Array.isArray(value)) return true;
146
+ const list = value;
147
+ for (const item of list) if (typeof item !== "number" && typeof item !== "string") return true;
148
+ }
149
+ }
150
+ if ("children" in value && Array.isArray(value.children)) return true;
151
+ return false;
152
+ }
153
+ /**
154
+ * Add a property.
155
+ *
156
+ * @param {Schema} schema
157
+ * Schema.
158
+ * @param {Properties} properties
159
+ * Properties object.
160
+ * @param {string} key
161
+ * Property name.
162
+ * @param {PropertyValue | Style} value
163
+ * Property value.
164
+ * @returns {undefined}
165
+ * Nothing.
166
+ */
167
+ function addProperty(schema, properties, key, value) {
168
+ if (value === null || value === void 0) return;
169
+ const info = require_find.find(schema, key);
170
+ /** @type {PropertyValue} */
171
+ let result;
172
+ if (typeof value === "number") {
173
+ if (Number.isNaN(value)) return;
174
+ result = value;
175
+ } else if (typeof value === "boolean") result = value;
176
+ else if (typeof value === "string") if (info.spaceSeparated) result = require_index$2.parse(value);
177
+ else if (info.commaSeparated) result = require_index.parse(value);
178
+ else if (info.commaOrSpaceSeparated) result = require_index$2.parse(require_index.parse(value).join(" "));
179
+ else result = parsePrimitive(info, info.property, value);
180
+ else if (Array.isArray(value)) result = [...value];
181
+ else result = info.property === "style" ? style(value) : String(value);
182
+ if (Array.isArray(result)) {
183
+ /** @type {Array<number | string>} */
184
+ const finalResult = [];
185
+ for (const item of result) finalResult.push(parsePrimitive(info, info.property, item));
186
+ result = finalResult;
187
+ }
188
+ if (info.property === "className" && Array.isArray(properties.className)) {
189
+ const add = result;
190
+ result = [...properties.className, ...Array.isArray(add) ? add : [add]];
191
+ }
192
+ properties[info.property] = result;
193
+ }
194
+ /**
195
+ * Add a child.
196
+ *
197
+ * @param {Array<RootContent>} nodes
198
+ * Children.
199
+ * @param {Child} value
200
+ * Child.
201
+ * @returns {undefined}
202
+ * Nothing.
203
+ */
204
+ function addChild(nodes, value) {
205
+ if (value === null || value === void 0) {} else if (typeof value === "number" || typeof value === "string") nodes.push({
206
+ type: "text",
207
+ value: String(value)
208
+ });
209
+ else if (Array.isArray(value)) for (const child of value) addChild(nodes, child);
210
+ else if (typeof value === "object" && "type" in value) if (value.type === "root") addChild(nodes, value.children);
211
+ else nodes.push(value);
212
+ else throw new Error("Expected node, nodes, or string, got `" + value + "`");
213
+ }
214
+ /**
215
+ * Parse a single primitives.
216
+ *
217
+ * @param {Info} info
218
+ * Property information.
219
+ * @param {string} name
220
+ * Property name.
221
+ * @param {PrimitiveValue} value
222
+ * Property value.
223
+ * @returns {PrimitiveValue}
224
+ * Property value.
225
+ */
226
+ function parsePrimitive(info, name, value) {
227
+ if (typeof value === "string") {
228
+ if (info.number && value && !Number.isNaN(Number(value))) return Number(value);
229
+ if ((info.boolean || info.overloadedBoolean) && (value === "" || require_normalize.normalize(value) === require_normalize.normalize(name))) return true;
230
+ }
231
+ return value;
232
+ }
233
+ /**
234
+ * Serialize a `style` object as a string.
235
+ *
236
+ * @param {Style} styles
237
+ * Style object.
238
+ * @returns {string}
239
+ * CSS string.
240
+ */
241
+ function style(styles) {
242
+ /** @type {Array<string>} */
243
+ const result = [];
244
+ for (const [key, value] of Object.entries(styles)) result.push([key, value].join(": "));
245
+ return result.join("; ");
246
+ }
247
+ /**
248
+ * Create a map to adjust casing.
249
+ *
250
+ * @param {ReadonlyArray<string>} values
251
+ * List of properly cased keys.
252
+ * @returns {Map<string, string>}
253
+ * Map of lowercase keys to uppercase keys.
254
+ */
255
+ function createAdjustMap(values) {
256
+ /** @type {Map<string, string>} */
257
+ const result = /* @__PURE__ */ new Map();
258
+ for (const value of values) result.set(value.toLowerCase(), value);
259
+ return result;
260
+ }
261
+ //#endregion
262
+ exports.createH = createH;
@@ -0,0 +1,262 @@
1
+ import { normalize } from "../../property-information/lib/normalize.js";
2
+ import { find } from "../../property-information/lib/find.js";
3
+ import { parse } from "../../comma-separated-tokens/index.js";
4
+ import { parseSelector } from "../../hast-util-parse-selector/lib/index.js";
5
+ import { parse as parse$1 } from "../../space-separated-tokens/index.js";
6
+ //#region ../../node_modules/hastscript/lib/create-h.js
7
+ /**
8
+ * @import {Element, Nodes, RootContent, Root} from 'hast'
9
+ * @import {Info, Schema} from 'property-information'
10
+ */
11
+ /**
12
+ * @typedef {Array<Nodes | PrimitiveChild>} ArrayChildNested
13
+ * List of children (deep).
14
+ */
15
+ /**
16
+ * @typedef {Array<ArrayChildNested | Nodes | PrimitiveChild>} ArrayChild
17
+ * List of children.
18
+ */
19
+ /**
20
+ * @typedef {Array<number | string>} ArrayValue
21
+ * List of property values for space- or comma separated values (such as `className`).
22
+ */
23
+ /**
24
+ * @typedef {ArrayChild | Nodes | PrimitiveChild} Child
25
+ * Acceptable child value.
26
+ */
27
+ /**
28
+ * @typedef {number | string | null | undefined} PrimitiveChild
29
+ * Primitive children, either ignored (nullish), or turned into text nodes.
30
+ */
31
+ /**
32
+ * @typedef {boolean | number | string | null | undefined} PrimitiveValue
33
+ * Primitive property value.
34
+ */
35
+ /**
36
+ * @typedef {Record<string, PropertyValue | Style>} Properties
37
+ * Acceptable value for element properties.
38
+ */
39
+ /**
40
+ * @typedef {ArrayValue | PrimitiveValue} PropertyValue
41
+ * Primitive value or list value.
42
+ */
43
+ /**
44
+ * @typedef {Element | Root} Result
45
+ * Result from a `h` (or `s`) call.
46
+ */
47
+ /**
48
+ * @typedef {number | string} StyleValue
49
+ * Value for a CSS style field.
50
+ */
51
+ /**
52
+ * @typedef {Record<string, StyleValue>} Style
53
+ * Supported value of a `style` prop.
54
+ */
55
+ /**
56
+ * Create an `h` function.
57
+ *
58
+ * @param {Schema} schema
59
+ * Schema to use.
60
+ * @param {string} defaultTagName
61
+ * Default tag name.
62
+ * @param {ReadonlyArray<string> | undefined} [caseSensitive]
63
+ * Case-sensitive tag names (default: `undefined`).
64
+ * @returns
65
+ * `h`.
66
+ */
67
+ function createH(schema, defaultTagName, caseSensitive) {
68
+ const adjust = caseSensitive ? createAdjustMap(caseSensitive) : void 0;
69
+ /**
70
+ * Hyperscript compatible DSL for creating virtual hast trees.
71
+ *
72
+ * @overload
73
+ * @param {null | undefined} [selector]
74
+ * Nothing to get a root.
75
+ * @param {...Child} children
76
+ * Children.
77
+ * @returns {Root}
78
+ * Root.
79
+ *
80
+ * @overload
81
+ * @param {string} selector
82
+ * Selector.
83
+ * @param {Child | Properties} [properties]
84
+ * Properties (or first child) (default: `undefined`).
85
+ * @param {...Child} children
86
+ * Children.
87
+ * @returns {Element}
88
+ * Element.
89
+ *
90
+ * @param {string | null | undefined} [selector]
91
+ * Selector.
92
+ * @param {Child | Properties} [properties]
93
+ * Properties (or first child) (default: `undefined`).
94
+ * @param {...Child} children
95
+ * Children.
96
+ * @returns {Result}
97
+ * Result.
98
+ */
99
+ function h(selector, properties, ...children) {
100
+ /** @type {Result} */
101
+ let node;
102
+ if (selector === null || selector === void 0) {
103
+ node = {
104
+ type: "root",
105
+ children: []
106
+ };
107
+ const child = properties;
108
+ children.unshift(child);
109
+ } else {
110
+ node = parseSelector(selector, defaultTagName);
111
+ const lower = node.tagName.toLowerCase();
112
+ const adjusted = adjust ? adjust.get(lower) : void 0;
113
+ node.tagName = adjusted || lower;
114
+ if (isChild(properties)) children.unshift(properties);
115
+ else for (const [key, value] of Object.entries(properties)) addProperty(schema, node.properties, key, value);
116
+ }
117
+ for (const child of children) addChild(node.children, child);
118
+ if (node.type === "element" && node.tagName === "template" && schema.space === "html") {
119
+ node.content = {
120
+ type: "root",
121
+ children: node.children
122
+ };
123
+ node.children = [];
124
+ }
125
+ return node;
126
+ }
127
+ return h;
128
+ }
129
+ /**
130
+ * Check if something is properties or a child.
131
+ *
132
+ * @param {Child | Properties} value
133
+ * Value to check.
134
+ * @returns {value is Child}
135
+ * Whether `value` is definitely a child.
136
+ */
137
+ function isChild(value) {
138
+ if (value === null || typeof value !== "object" || Array.isArray(value)) return true;
139
+ if (typeof value.type !== "string") return false;
140
+ const record = value;
141
+ const keys = Object.keys(value);
142
+ for (const key of keys) {
143
+ const value = record[key];
144
+ if (value && typeof value === "object") {
145
+ if (!Array.isArray(value)) return true;
146
+ const list = value;
147
+ for (const item of list) if (typeof item !== "number" && typeof item !== "string") return true;
148
+ }
149
+ }
150
+ if ("children" in value && Array.isArray(value.children)) return true;
151
+ return false;
152
+ }
153
+ /**
154
+ * Add a property.
155
+ *
156
+ * @param {Schema} schema
157
+ * Schema.
158
+ * @param {Properties} properties
159
+ * Properties object.
160
+ * @param {string} key
161
+ * Property name.
162
+ * @param {PropertyValue | Style} value
163
+ * Property value.
164
+ * @returns {undefined}
165
+ * Nothing.
166
+ */
167
+ function addProperty(schema, properties, key, value) {
168
+ if (value === null || value === void 0) return;
169
+ const info = find(schema, key);
170
+ /** @type {PropertyValue} */
171
+ let result;
172
+ if (typeof value === "number") {
173
+ if (Number.isNaN(value)) return;
174
+ result = value;
175
+ } else if (typeof value === "boolean") result = value;
176
+ else if (typeof value === "string") if (info.spaceSeparated) result = parse$1(value);
177
+ else if (info.commaSeparated) result = parse(value);
178
+ else if (info.commaOrSpaceSeparated) result = parse$1(parse(value).join(" "));
179
+ else result = parsePrimitive(info, info.property, value);
180
+ else if (Array.isArray(value)) result = [...value];
181
+ else result = info.property === "style" ? style(value) : String(value);
182
+ if (Array.isArray(result)) {
183
+ /** @type {Array<number | string>} */
184
+ const finalResult = [];
185
+ for (const item of result) finalResult.push(parsePrimitive(info, info.property, item));
186
+ result = finalResult;
187
+ }
188
+ if (info.property === "className" && Array.isArray(properties.className)) {
189
+ const add = result;
190
+ result = [...properties.className, ...Array.isArray(add) ? add : [add]];
191
+ }
192
+ properties[info.property] = result;
193
+ }
194
+ /**
195
+ * Add a child.
196
+ *
197
+ * @param {Array<RootContent>} nodes
198
+ * Children.
199
+ * @param {Child} value
200
+ * Child.
201
+ * @returns {undefined}
202
+ * Nothing.
203
+ */
204
+ function addChild(nodes, value) {
205
+ if (value === null || value === void 0) {} else if (typeof value === "number" || typeof value === "string") nodes.push({
206
+ type: "text",
207
+ value: String(value)
208
+ });
209
+ else if (Array.isArray(value)) for (const child of value) addChild(nodes, child);
210
+ else if (typeof value === "object" && "type" in value) if (value.type === "root") addChild(nodes, value.children);
211
+ else nodes.push(value);
212
+ else throw new Error("Expected node, nodes, or string, got `" + value + "`");
213
+ }
214
+ /**
215
+ * Parse a single primitives.
216
+ *
217
+ * @param {Info} info
218
+ * Property information.
219
+ * @param {string} name
220
+ * Property name.
221
+ * @param {PrimitiveValue} value
222
+ * Property value.
223
+ * @returns {PrimitiveValue}
224
+ * Property value.
225
+ */
226
+ function parsePrimitive(info, name, value) {
227
+ if (typeof value === "string") {
228
+ if (info.number && value && !Number.isNaN(Number(value))) return Number(value);
229
+ if ((info.boolean || info.overloadedBoolean) && (value === "" || normalize(value) === normalize(name))) return true;
230
+ }
231
+ return value;
232
+ }
233
+ /**
234
+ * Serialize a `style` object as a string.
235
+ *
236
+ * @param {Style} styles
237
+ * Style object.
238
+ * @returns {string}
239
+ * CSS string.
240
+ */
241
+ function style(styles) {
242
+ /** @type {Array<string>} */
243
+ const result = [];
244
+ for (const [key, value] of Object.entries(styles)) result.push([key, value].join(": "));
245
+ return result.join("; ");
246
+ }
247
+ /**
248
+ * Create a map to adjust casing.
249
+ *
250
+ * @param {ReadonlyArray<string>} values
251
+ * List of properly cased keys.
252
+ * @returns {Map<string, string>}
253
+ * Map of lowercase keys to uppercase keys.
254
+ */
255
+ function createAdjustMap(values) {
256
+ /** @type {Map<string, string>} */
257
+ const result = /* @__PURE__ */ new Map();
258
+ for (const value of values) result.set(value.toLowerCase(), value);
259
+ return result;
260
+ }
261
+ //#endregion
262
+ export { createH };
@@ -0,0 +1,21 @@
1
+ const require_index = require("../../property-information/index.cjs");
2
+ const require_create_h = require("./create-h.cjs");
3
+ const require_svg_case_sensitive_tag_names = require("./svg-case-sensitive-tag-names.cjs");
4
+ //#region ../../node_modules/hastscript/lib/index.js
5
+ /**
6
+ * @typedef {import('./jsx-classic.js').Element} h.JSX.Element
7
+ * @typedef {import('./jsx-classic.js').ElementChildrenAttribute} h.JSX.ElementChildrenAttribute
8
+ * @typedef {import('./jsx-classic.js').IntrinsicAttributes} h.JSX.IntrinsicAttributes
9
+ * @typedef {import('./jsx-classic.js').IntrinsicElements} h.JSX.IntrinsicElements
10
+ */
11
+ /**
12
+ * @typedef {import('./jsx-classic.js').Element} s.JSX.Element
13
+ * @typedef {import('./jsx-classic.js').ElementChildrenAttribute} s.JSX.ElementChildrenAttribute
14
+ * @typedef {import('./jsx-classic.js').IntrinsicAttributes} s.JSX.IntrinsicAttributes
15
+ * @typedef {import('./jsx-classic.js').IntrinsicElements} s.JSX.IntrinsicElements
16
+ */
17
+ /** @type {ReturnType<createH>} */
18
+ var h = require_create_h.createH(require_index.html, "div");
19
+ require_create_h.createH(require_index.svg, "g", require_svg_case_sensitive_tag_names.svgCaseSensitiveTagNames);
20
+ //#endregion
21
+ exports.h = h;
@@ -0,0 +1,21 @@
1
+ import { html, svg } from "../../property-information/index.js";
2
+ import { createH } from "./create-h.js";
3
+ import { svgCaseSensitiveTagNames } from "./svg-case-sensitive-tag-names.js";
4
+ //#region ../../node_modules/hastscript/lib/index.js
5
+ /**
6
+ * @typedef {import('./jsx-classic.js').Element} h.JSX.Element
7
+ * @typedef {import('./jsx-classic.js').ElementChildrenAttribute} h.JSX.ElementChildrenAttribute
8
+ * @typedef {import('./jsx-classic.js').IntrinsicAttributes} h.JSX.IntrinsicAttributes
9
+ * @typedef {import('./jsx-classic.js').IntrinsicElements} h.JSX.IntrinsicElements
10
+ */
11
+ /**
12
+ * @typedef {import('./jsx-classic.js').Element} s.JSX.Element
13
+ * @typedef {import('./jsx-classic.js').ElementChildrenAttribute} s.JSX.ElementChildrenAttribute
14
+ * @typedef {import('./jsx-classic.js').IntrinsicAttributes} s.JSX.IntrinsicAttributes
15
+ * @typedef {import('./jsx-classic.js').IntrinsicElements} s.JSX.IntrinsicElements
16
+ */
17
+ /** @type {ReturnType<createH>} */
18
+ var h = createH(html, "div");
19
+ createH(svg, "g", svgCaseSensitiveTagNames);
20
+ //#endregion
21
+ export { h };
@@ -0,0 +1,49 @@
1
+ //#region ../../node_modules/hastscript/lib/svg-case-sensitive-tag-names.js
2
+ /**
3
+ * List of case-sensitive SVG tag names.
4
+ *
5
+ * @type {ReadonlyArray<string>}
6
+ */
7
+ var svgCaseSensitiveTagNames = [
8
+ "altGlyph",
9
+ "altGlyphDef",
10
+ "altGlyphItem",
11
+ "animateColor",
12
+ "animateMotion",
13
+ "animateTransform",
14
+ "clipPath",
15
+ "feBlend",
16
+ "feColorMatrix",
17
+ "feComponentTransfer",
18
+ "feComposite",
19
+ "feConvolveMatrix",
20
+ "feDiffuseLighting",
21
+ "feDisplacementMap",
22
+ "feDistantLight",
23
+ "feDropShadow",
24
+ "feFlood",
25
+ "feFuncA",
26
+ "feFuncB",
27
+ "feFuncG",
28
+ "feFuncR",
29
+ "feGaussianBlur",
30
+ "feImage",
31
+ "feMerge",
32
+ "feMergeNode",
33
+ "feMorphology",
34
+ "feOffset",
35
+ "fePointLight",
36
+ "feSpecularLighting",
37
+ "feSpotLight",
38
+ "feTile",
39
+ "feTurbulence",
40
+ "foreignObject",
41
+ "glyphRef",
42
+ "linearGradient",
43
+ "radialGradient",
44
+ "solidColor",
45
+ "textArea",
46
+ "textPath"
47
+ ];
48
+ //#endregion
49
+ exports.svgCaseSensitiveTagNames = svgCaseSensitiveTagNames;
@@ -0,0 +1,49 @@
1
+ //#region ../../node_modules/hastscript/lib/svg-case-sensitive-tag-names.js
2
+ /**
3
+ * List of case-sensitive SVG tag names.
4
+ *
5
+ * @type {ReadonlyArray<string>}
6
+ */
7
+ var svgCaseSensitiveTagNames = [
8
+ "altGlyph",
9
+ "altGlyphDef",
10
+ "altGlyphItem",
11
+ "animateColor",
12
+ "animateMotion",
13
+ "animateTransform",
14
+ "clipPath",
15
+ "feBlend",
16
+ "feColorMatrix",
17
+ "feComponentTransfer",
18
+ "feComposite",
19
+ "feConvolveMatrix",
20
+ "feDiffuseLighting",
21
+ "feDisplacementMap",
22
+ "feDistantLight",
23
+ "feDropShadow",
24
+ "feFlood",
25
+ "feFuncA",
26
+ "feFuncB",
27
+ "feFuncG",
28
+ "feFuncR",
29
+ "feGaussianBlur",
30
+ "feImage",
31
+ "feMerge",
32
+ "feMergeNode",
33
+ "feMorphology",
34
+ "feOffset",
35
+ "fePointLight",
36
+ "feSpecularLighting",
37
+ "feSpotLight",
38
+ "feTile",
39
+ "feTurbulence",
40
+ "foreignObject",
41
+ "glyphRef",
42
+ "linearGradient",
43
+ "radialGradient",
44
+ "solidColor",
45
+ "textArea",
46
+ "textPath"
47
+ ];
48
+ //#endregion
49
+ export { svgCaseSensitiveTagNames };
@@ -0,0 +1,14 @@
1
+ //#region ../../node_modules/is-alphabetical/index.js
2
+ /**
3
+ * Check if the given character code, or the character code at the first
4
+ * character, is alphabetical.
5
+ *
6
+ * @param {string|number} character
7
+ * @returns {boolean} Whether `character` is alphabetical.
8
+ */
9
+ function isAlphabetical(character) {
10
+ const code = typeof character === "string" ? character.charCodeAt(0) : character;
11
+ return code >= 97 && code <= 122 || code >= 65 && code <= 90;
12
+ }
13
+ //#endregion
14
+ exports.isAlphabetical = isAlphabetical;
@@ -0,0 +1,14 @@
1
+ //#region ../../node_modules/is-alphabetical/index.js
2
+ /**
3
+ * Check if the given character code, or the character code at the first
4
+ * character, is alphabetical.
5
+ *
6
+ * @param {string|number} character
7
+ * @returns {boolean} Whether `character` is alphabetical.
8
+ */
9
+ function isAlphabetical(character) {
10
+ const code = typeof character === "string" ? character.charCodeAt(0) : character;
11
+ return code >= 97 && code <= 122 || code >= 65 && code <= 90;
12
+ }
13
+ //#endregion
14
+ export { isAlphabetical };