@server/next 0.44.1 → 0.45.1
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/index.d.ts +15 -17
- package/index.js +96 -189
- package/package.json +4 -2
- package/readme.md +12 -4
- package/src/jsx/jsx-runtime.d.ts +26 -8
- package/src/jsx/jsx-runtime.js +8 -5
- package/src/jsx/jsx-runtime.test.jsx +0 -694
package/src/jsx/jsx-runtime.d.ts
CHANGED
|
@@ -1,12 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
// What a JSX tag can be: an intrinsic name, a Fragment, a function component,
|
|
2
|
+
// or an object exposing `render` (the shape forwardRef-style components take)
|
|
3
|
+
type Tag =
|
|
4
|
+
| string
|
|
5
|
+
| symbol
|
|
6
|
+
| ((props: any) => unknown)
|
|
7
|
+
| { render: (props: any, ref: unknown) => unknown };
|
|
8
|
+
|
|
9
|
+
export declare function jsx(
|
|
10
|
+
type: Tag,
|
|
11
|
+
props?: any,
|
|
12
|
+
key?: string | number,
|
|
13
|
+
): JSX.Element;
|
|
14
|
+
export declare function jsxs(
|
|
15
|
+
type: Tag,
|
|
16
|
+
props?: any,
|
|
17
|
+
key?: string | number,
|
|
18
|
+
): JSX.Element;
|
|
19
|
+
export declare function jsxDEV(
|
|
20
|
+
type: Tag,
|
|
21
|
+
props?: any,
|
|
22
|
+
key?: string | number,
|
|
23
|
+
): JSX.Element;
|
|
24
|
+
export declare const Fragment: symbol;
|
|
5
25
|
|
|
6
26
|
export declare namespace JSX {
|
|
7
27
|
interface Element {
|
|
8
|
-
|
|
9
|
-
props: any;
|
|
28
|
+
(): string;
|
|
10
29
|
}
|
|
11
30
|
interface IntrinsicElements {
|
|
12
31
|
[elem: string]: any;
|
|
@@ -16,8 +35,7 @@ export declare namespace JSX {
|
|
|
16
35
|
declare global {
|
|
17
36
|
namespace JSX {
|
|
18
37
|
interface Element {
|
|
19
|
-
|
|
20
|
-
props: any;
|
|
38
|
+
(): string;
|
|
21
39
|
}
|
|
22
40
|
interface IntrinsicElements {
|
|
23
41
|
[elem: string]: any;
|
package/src/jsx/jsx-runtime.js
CHANGED
|
@@ -21,8 +21,6 @@ const SVG_TAGS = new Set([
|
|
|
21
21
|
"defs",
|
|
22
22
|
]);
|
|
23
23
|
|
|
24
|
-
const REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
|
|
25
|
-
|
|
26
24
|
const ALT_NAMES = {
|
|
27
25
|
classname: "class",
|
|
28
26
|
htmlfor: "for",
|
|
@@ -100,8 +98,9 @@ const renderChild = (child) => {
|
|
|
100
98
|
};
|
|
101
99
|
|
|
102
100
|
const jsx = (tag, { children, ...props } = {}) => {
|
|
103
|
-
// Fragment
|
|
104
|
-
|
|
101
|
+
// Fragment. It is the registered React symbol, so a compiled React library
|
|
102
|
+
// matches whether it imports Fragment or inlines Symbol.for("react.fragment")
|
|
103
|
+
if (tag === Fragment) {
|
|
105
104
|
return () => renderChild(children);
|
|
106
105
|
}
|
|
107
106
|
|
|
@@ -158,7 +157,9 @@ const jsx = (tag, { children, ...props } = {}) => {
|
|
|
158
157
|
// `minify` drives <style>, it isn't an HTML attribute
|
|
159
158
|
.filter(([k]) => !(tag === "style" && k === "minify"))
|
|
160
159
|
.filter(([k, v]) => !/on[A-Z]/.test(k) && typeof v !== "function")
|
|
161
|
-
|
|
160
|
+
// `false`, `null` and `undefined` drop the attribute (as React does),
|
|
161
|
+
// rather than rendering it empty
|
|
162
|
+
.filter(([, v]) => v !== false && v != null)
|
|
162
163
|
.map(([k, v]) => {
|
|
163
164
|
const preserveSvg = k === "viewBox" || k === "preserveAspectRatio";
|
|
164
165
|
|
|
@@ -180,6 +181,7 @@ const jsx = (tag, { children, ...props } = {}) => {
|
|
|
180
181
|
return `${cssKey}:${val}`;
|
|
181
182
|
})
|
|
182
183
|
.join(";");
|
|
184
|
+
if (!v) return null; // an empty style object adds nothing
|
|
183
185
|
}
|
|
184
186
|
|
|
185
187
|
const value =
|
|
@@ -187,6 +189,7 @@ const jsx = (tag, { children, ...props } = {}) => {
|
|
|
187
189
|
|
|
188
190
|
return `${key}="${value}"`;
|
|
189
191
|
})
|
|
192
|
+
.filter((attr) => attr !== null)
|
|
190
193
|
.join(" ");
|
|
191
194
|
|
|
192
195
|
if (attrStr) attrStr = ` ${attrStr}`;
|