revojs 0.0.58 → 0.0.59
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/html/index.d.ts +1 -0
- package/dist/index.js +22 -8
- package/dist/jsx/index.d.ts +4 -0
- package/dist/jsx/index.js +23 -8
- package/package.json +1 -1
package/dist/html/index.d.ts
CHANGED
|
@@ -74,6 +74,7 @@ export declare class MountedEvent extends Event {
|
|
|
74
74
|
}
|
|
75
75
|
export declare const isTemplate: <T>(value?: T) => value is Template & T;
|
|
76
76
|
export declare const isCustomElement: <T>(value?: T) => value is CustomElement<Events, Attributes> & T;
|
|
77
|
+
export declare const isComponent: <T>(value?: T) => value is ComponentConstructor<Events, Attributes> & T;
|
|
77
78
|
export declare const useHost: (scope: Scope) => HostContext;
|
|
78
79
|
export declare const createElement: <TEvents extends Events, TAttributes extends Attributes>(input: string | ComponentConstructor<TEvents, TAttributes>, attributes?: AttributeInput<TAttributes>, ...children: Array<Slot>) => Slot;
|
|
79
80
|
export declare const toString: (slot: Slot) => string;
|
package/dist/index.js
CHANGED
|
@@ -223,20 +223,34 @@ const isTemplate = (value) => {
|
|
|
223
223
|
const isCustomElement = (value) => {
|
|
224
224
|
return !!value && typeof value === "object" && "component" in value;
|
|
225
225
|
};
|
|
226
|
+
const isComponent = (value) => {
|
|
227
|
+
return !!value && typeof value === "function" && "$name" in value;
|
|
228
|
+
};
|
|
226
229
|
const useHost = (scope) => {
|
|
227
230
|
return scope.getContext(HOST_CONTEXT);
|
|
228
231
|
};
|
|
229
232
|
const createElement = (input, attributes, ...children) => {
|
|
230
|
-
|
|
231
|
-
|
|
233
|
+
if (isComponent(input)) {
|
|
234
|
+
const template = {
|
|
235
|
+
tag: input.$name,
|
|
236
|
+
attributes: attributes ?? {},
|
|
237
|
+
children
|
|
238
|
+
};
|
|
239
|
+
if (input.$styles.length) {
|
|
240
|
+
const classes = template.attributes["class"];
|
|
241
|
+
template.attributes["class"] = (classes ? [classes, ...input.$styles] : input.$styles).join(" ");
|
|
242
|
+
}
|
|
243
|
+
return template;
|
|
244
|
+
}
|
|
245
|
+
if (typeof input === "string") return {
|
|
246
|
+
tag: input,
|
|
232
247
|
attributes: attributes ?? {},
|
|
233
248
|
children
|
|
234
249
|
};
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
}
|
|
239
|
-
return template;
|
|
250
|
+
return input?.({
|
|
251
|
+
...attributes,
|
|
252
|
+
children
|
|
253
|
+
});
|
|
240
254
|
};
|
|
241
255
|
const toString = (slot) => {
|
|
242
256
|
switch (typeof slot) {
|
|
@@ -853,4 +867,4 @@ const useLocale = (scope, context) => {
|
|
|
853
867
|
};
|
|
854
868
|
|
|
855
869
|
//#endregion
|
|
856
|
-
export { $fetch, CLIENT, Compute, HOST_CONTEXT, Handler, LOCALE_CONTEXT, MountedEvent, NavigateEvent, Page, ROUTER_CONTEXT, ROUTE_CONTEXT, RUNTIME_CONTEXT, Radix, SERVER, Scope, StopEvent, activeCompute, components, createApp, createCompute, createElement, createLocale, createMemo, createRouter, createRuntime, createState, defineComponent, defineContext, defineMiddleware, defineRoute, fileName, fromValue, hydrate, isClient, isCustomElement, isRoute, isServer, isTemplate, mimeType, preventDefault, registerComponent, renderToString, sendBadRequest, sendHtml, sendJson, sendRedirect, sendText, sendUnauthorized, setCookie, stopImmediatePropagation, stopPropagation, targets, toArray, toCustomElement, toFragment, toPath, toRange, toString, useCookies, useEvent, useHost, useLocale, useRequestUrl, useRoute, useRouter, useRuntime, useSetCookies };
|
|
870
|
+
export { $fetch, CLIENT, Compute, HOST_CONTEXT, Handler, LOCALE_CONTEXT, MountedEvent, NavigateEvent, Page, ROUTER_CONTEXT, ROUTE_CONTEXT, RUNTIME_CONTEXT, Radix, SERVER, Scope, StopEvent, activeCompute, components, createApp, createCompute, createElement, createLocale, createMemo, createRouter, createRuntime, createState, defineComponent, defineContext, defineMiddleware, defineRoute, fileName, fromValue, hydrate, isClient, isComponent, isCustomElement, isRoute, isServer, isTemplate, mimeType, preventDefault, registerComponent, renderToString, sendBadRequest, sendHtml, sendJson, sendRedirect, sendText, sendUnauthorized, setCookie, stopImmediatePropagation, stopPropagation, targets, toArray, toCustomElement, toFragment, toPath, toRange, toString, useCookies, useEvent, useHost, useLocale, useRequestUrl, useRoute, useRouter, useRuntime, useSetCookies };
|
package/dist/jsx/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { type EventListener, type Slot } from "../html";
|
|
2
|
+
export type Fragment = {
|
|
3
|
+
children: Array<Slot>;
|
|
4
|
+
};
|
|
2
5
|
export type EventAttributes = {
|
|
3
6
|
onScroll?: EventListener<Event>;
|
|
4
7
|
onScrollCapture?: EventListener<Event>;
|
|
@@ -365,3 +368,4 @@ export declare namespace JSX {
|
|
|
365
368
|
export declare const svgElements: Set<string>;
|
|
366
369
|
export declare const namespace: (tag: string) => "http://www.w3.org/1999/xhtml" | "http://www.w3.org/2000/svg";
|
|
367
370
|
export declare const h: <TEvents extends import("..").Events, TAttributes extends import("..").Attributes>(input: string | import("..").ComponentConstructor<TEvents, TAttributes>, attributes?: import("..").AttributeInput<TAttributes>, ...children: Array<Slot>) => Slot;
|
|
371
|
+
export declare const fragment: ({ children }: Fragment) => unknown[];
|
package/dist/jsx/index.js
CHANGED
|
@@ -5,17 +5,31 @@ function defineContext(key) {
|
|
|
5
5
|
|
|
6
6
|
//#endregion
|
|
7
7
|
//#region src/html/index.ts
|
|
8
|
+
const isComponent = (value) => {
|
|
9
|
+
return !!value && typeof value === "function" && "$name" in value;
|
|
10
|
+
};
|
|
8
11
|
const createElement = (input, attributes, ...children) => {
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
if (isComponent(input)) {
|
|
13
|
+
const template = {
|
|
14
|
+
tag: input.$name,
|
|
15
|
+
attributes: attributes ?? {},
|
|
16
|
+
children
|
|
17
|
+
};
|
|
18
|
+
if (input.$styles.length) {
|
|
19
|
+
const classes = template.attributes["class"];
|
|
20
|
+
template.attributes["class"] = (classes ? [classes, ...input.$styles] : input.$styles).join(" ");
|
|
21
|
+
}
|
|
22
|
+
return template;
|
|
23
|
+
}
|
|
24
|
+
if (typeof input === "string") return {
|
|
25
|
+
tag: input,
|
|
11
26
|
attributes: attributes ?? {},
|
|
12
27
|
children
|
|
13
28
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
return template;
|
|
29
|
+
return input?.({
|
|
30
|
+
...attributes,
|
|
31
|
+
children
|
|
32
|
+
});
|
|
19
33
|
};
|
|
20
34
|
const HOST_CONTEXT = defineContext("HOST_CONTEXT");
|
|
21
35
|
|
|
@@ -104,6 +118,7 @@ const namespace = (tag) => {
|
|
|
104
118
|
return svgElements.has(tag) ? "http://www.w3.org/2000/svg" : "http://www.w3.org/1999/xhtml";
|
|
105
119
|
};
|
|
106
120
|
const h = createElement;
|
|
121
|
+
const fragment = ({ children }) => children;
|
|
107
122
|
|
|
108
123
|
//#endregion
|
|
109
|
-
export { h, namespace, svgElements };
|
|
124
|
+
export { fragment, h, namespace, svgElements };
|