@kubb/renderer-jsx 5.0.0-beta.105 → 5.0.0-beta.106
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.
- package/dist/index.cjs +11 -5
- package/dist/index.js +11 -5
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -30,9 +30,11 @@ const CALLOUT_LABEL = {
|
|
|
30
30
|
*/
|
|
31
31
|
function Callout({ type, title, children }) {
|
|
32
32
|
const label = CALLOUT_LABEL[type];
|
|
33
|
+
const header = title ? `> [!${label}] ${title}` : `> [!${label}]`;
|
|
34
|
+
const quoted = children.trimEnd().split("\n").map((line) => line.length > 0 ? `> ${line}` : ">").join("\n");
|
|
33
35
|
return /* @__PURE__ */ require_jsx_runtime.jsx("kubb-source", {
|
|
34
36
|
name: "callout",
|
|
35
|
-
children: `${
|
|
37
|
+
children: `${header}\n${quoted}`
|
|
36
38
|
});
|
|
37
39
|
}
|
|
38
40
|
Callout.displayName = "Callout";
|
|
@@ -210,9 +212,10 @@ File.Source = FileSource;
|
|
|
210
212
|
* ```
|
|
211
213
|
*/
|
|
212
214
|
function Frontmatter({ data }) {
|
|
215
|
+
const envelope = Object.keys(data).length === 0 ? "" : `---\n${(0, yaml.stringify)(data).trimEnd()}\n---`;
|
|
213
216
|
return /* @__PURE__ */ require_jsx_runtime.jsx("kubb-source", {
|
|
214
217
|
name: "frontmatter",
|
|
215
|
-
children:
|
|
218
|
+
children: envelope
|
|
216
219
|
});
|
|
217
220
|
}
|
|
218
221
|
Frontmatter.displayName = "Frontmatter";
|
|
@@ -233,13 +236,14 @@ Frontmatter.displayName = "Frontmatter";
|
|
|
233
236
|
*/
|
|
234
237
|
function Function({ children, ...props }) {
|
|
235
238
|
const { name, default: isDefault, export: canExport, async: isAsync, generics, params, returnType, JSDoc } = props;
|
|
239
|
+
const genericsString = Array.isArray(generics) ? generics.join(", ").trim() : generics;
|
|
236
240
|
return /* @__PURE__ */ require_jsx_runtime.jsx("kubb-function", {
|
|
237
241
|
name,
|
|
238
242
|
params,
|
|
239
243
|
export: canExport,
|
|
240
244
|
default: isDefault,
|
|
241
245
|
async: isAsync,
|
|
242
|
-
generics:
|
|
246
|
+
generics: genericsString,
|
|
243
247
|
returnType,
|
|
244
248
|
JSDoc,
|
|
245
249
|
children
|
|
@@ -261,13 +265,14 @@ Function.displayName = "Function";
|
|
|
261
265
|
*/
|
|
262
266
|
function ArrowFunction({ children, ...props }) {
|
|
263
267
|
const { name, default: isDefault, export: canExport, async, generics, params, returnType, JSDoc, singleLine } = props;
|
|
268
|
+
const genericsString = Array.isArray(generics) ? generics.join(", ").trim() : generics;
|
|
264
269
|
return /* @__PURE__ */ require_jsx_runtime.jsx("kubb-arrow-function", {
|
|
265
270
|
name,
|
|
266
271
|
params,
|
|
267
272
|
export: canExport,
|
|
268
273
|
default: isDefault,
|
|
269
274
|
async,
|
|
270
|
-
generics:
|
|
275
|
+
generics: genericsString,
|
|
271
276
|
returnType,
|
|
272
277
|
singleLine,
|
|
273
278
|
JSDoc,
|
|
@@ -338,9 +343,10 @@ Jsx.displayName = "Jsx";
|
|
|
338
343
|
* ```
|
|
339
344
|
*/
|
|
340
345
|
function List({ ordered, items }) {
|
|
346
|
+
const body = items.map((item, index) => `${ordered ? `${index + 1}.` : "-"} ${item}`).join("\n");
|
|
341
347
|
return /* @__PURE__ */ require_jsx_runtime.jsx("kubb-source", {
|
|
342
348
|
name: "list",
|
|
343
|
-
children:
|
|
349
|
+
children: body
|
|
344
350
|
});
|
|
345
351
|
}
|
|
346
352
|
List.displayName = "List";
|
package/dist/index.js
CHANGED
|
@@ -29,9 +29,11 @@ const CALLOUT_LABEL = {
|
|
|
29
29
|
*/
|
|
30
30
|
function Callout({ type, title, children }) {
|
|
31
31
|
const label = CALLOUT_LABEL[type];
|
|
32
|
+
const header = title ? `> [!${label}] ${title}` : `> [!${label}]`;
|
|
33
|
+
const quoted = children.trimEnd().split("\n").map((line) => line.length > 0 ? `> ${line}` : ">").join("\n");
|
|
32
34
|
return /* @__PURE__ */ jsx("kubb-source", {
|
|
33
35
|
name: "callout",
|
|
34
|
-
children: `${
|
|
36
|
+
children: `${header}\n${quoted}`
|
|
35
37
|
});
|
|
36
38
|
}
|
|
37
39
|
Callout.displayName = "Callout";
|
|
@@ -209,9 +211,10 @@ File.Source = FileSource;
|
|
|
209
211
|
* ```
|
|
210
212
|
*/
|
|
211
213
|
function Frontmatter({ data }) {
|
|
214
|
+
const envelope = Object.keys(data).length === 0 ? "" : `---\n${stringify(data).trimEnd()}\n---`;
|
|
212
215
|
return /* @__PURE__ */ jsx("kubb-source", {
|
|
213
216
|
name: "frontmatter",
|
|
214
|
-
children:
|
|
217
|
+
children: envelope
|
|
215
218
|
});
|
|
216
219
|
}
|
|
217
220
|
Frontmatter.displayName = "Frontmatter";
|
|
@@ -232,13 +235,14 @@ Frontmatter.displayName = "Frontmatter";
|
|
|
232
235
|
*/
|
|
233
236
|
function Function({ children, ...props }) {
|
|
234
237
|
const { name, default: isDefault, export: canExport, async: isAsync, generics, params, returnType, JSDoc } = props;
|
|
238
|
+
const genericsString = Array.isArray(generics) ? generics.join(", ").trim() : generics;
|
|
235
239
|
return /* @__PURE__ */ jsx("kubb-function", {
|
|
236
240
|
name,
|
|
237
241
|
params,
|
|
238
242
|
export: canExport,
|
|
239
243
|
default: isDefault,
|
|
240
244
|
async: isAsync,
|
|
241
|
-
generics:
|
|
245
|
+
generics: genericsString,
|
|
242
246
|
returnType,
|
|
243
247
|
JSDoc,
|
|
244
248
|
children
|
|
@@ -260,13 +264,14 @@ Function.displayName = "Function";
|
|
|
260
264
|
*/
|
|
261
265
|
function ArrowFunction({ children, ...props }) {
|
|
262
266
|
const { name, default: isDefault, export: canExport, async, generics, params, returnType, JSDoc, singleLine } = props;
|
|
267
|
+
const genericsString = Array.isArray(generics) ? generics.join(", ").trim() : generics;
|
|
263
268
|
return /* @__PURE__ */ jsx("kubb-arrow-function", {
|
|
264
269
|
name,
|
|
265
270
|
params,
|
|
266
271
|
export: canExport,
|
|
267
272
|
default: isDefault,
|
|
268
273
|
async,
|
|
269
|
-
generics:
|
|
274
|
+
generics: genericsString,
|
|
270
275
|
returnType,
|
|
271
276
|
singleLine,
|
|
272
277
|
JSDoc,
|
|
@@ -337,9 +342,10 @@ Jsx.displayName = "Jsx";
|
|
|
337
342
|
* ```
|
|
338
343
|
*/
|
|
339
344
|
function List({ ordered, items }) {
|
|
345
|
+
const body = items.map((item, index) => `${ordered ? `${index + 1}.` : "-"} ${item}`).join("\n");
|
|
340
346
|
return /* @__PURE__ */ jsx("kubb-source", {
|
|
341
347
|
name: "list",
|
|
342
|
-
children:
|
|
348
|
+
children: body
|
|
343
349
|
});
|
|
344
350
|
}
|
|
345
351
|
List.displayName = "List";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/renderer-jsx",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.106",
|
|
4
4
|
"description": "Self-contained synchronous JSX renderer for Kubb. Turns JSX into FileNodes with built-in components (File, Function, Type, Const). An alternative for the ast.factory syntax.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codegen",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
71
|
"yaml": "^2.9.0",
|
|
72
|
-
"@kubb/kit": "5.0.0-beta.
|
|
72
|
+
"@kubb/kit": "5.0.0-beta.106"
|
|
73
73
|
},
|
|
74
74
|
"engines": {
|
|
75
75
|
"node": ">=22"
|