sinho 0.3.5 → 0.3.7
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/bundle.d.ts +9 -7
- package/dist/component.d.ts +6 -6
- package/dist/component.js.map +1 -1
- package/dist/mod.d.ts +1 -1
- package/dist/mod.js.map +1 -1
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/component.ts +22 -10
- package/src/mod.ts +10 -7
- package/src/utils.ts +8 -0
package/dist/bundle.d.ts
CHANGED
|
@@ -727,7 +727,9 @@ interface SvgProps<in E> extends HtmlProps<E> {
|
|
|
727
727
|
|
|
728
728
|
type RemoveOn<S extends string> = S extends `on${infer R}` ? Uncapitalize<R> : never;
|
|
729
729
|
type CamelCaseToKebabCase<S extends string> = S extends `${infer F}${infer R}` ? F extends Lowercase<F> ? `${F}${CamelCaseToKebabCase<R>}` : `-${Lowercase<F>}${CamelCaseToKebabCase<R>}` : Lowercase<S>;
|
|
730
|
+
type KebabCaseToCamelCase<S extends string> = S extends `${infer F}-${infer R}` ? `${F}${Capitalize<KebabCaseToCamelCase<R>>}` : Capitalize<S>;
|
|
730
731
|
type JsxPropNameToEventName<S extends string> = CamelCaseToKebabCase<RemoveOn<S>>;
|
|
732
|
+
type EventNameToJsxProp<S extends string> = `on${Capitalize<KebabCaseToCamelCase<S>>}`;
|
|
731
733
|
|
|
732
734
|
declare const contextSym: unique symbol;
|
|
733
735
|
/**
|
|
@@ -905,7 +907,7 @@ type _CustomEventContructor<T> = undefined extends T ? typeof CustomEvent<T> : E
|
|
|
905
907
|
*/
|
|
906
908
|
declare const event: (() => EventMeta<_CustomEventContructor<undefined>>) & (<T>() => EventMeta<_CustomEventContructor<T>>) & (<E extends EventConstructor>(eventConstructor: E) => EventMeta<E>);
|
|
907
909
|
type Metadata = {
|
|
908
|
-
[K in keyof
|
|
910
|
+
[K in keyof _ComponentInner<any> | "props" | "events"]?: never;
|
|
909
911
|
} & {
|
|
910
912
|
[K in keyof DomProps<any>]?: never;
|
|
911
913
|
} & {
|
|
@@ -915,7 +917,7 @@ type Metadata = {
|
|
|
915
917
|
};
|
|
916
918
|
declare const componentSym: unique symbol;
|
|
917
919
|
declare const jsxPropsSym: unique symbol;
|
|
918
|
-
declare abstract class
|
|
920
|
+
declare abstract class _ComponentInner<M extends Metadata> {
|
|
919
921
|
protected props: Props<M>;
|
|
920
922
|
protected events: EventEmitters<M>;
|
|
921
923
|
readonly [jsxPropsSym]?: ComponentJsxProps<M>;
|
|
@@ -926,8 +928,8 @@ declare abstract class ComponentInner<M extends Metadata> {
|
|
|
926
928
|
connectedCallback(): void;
|
|
927
929
|
disconnectedCallback(): void;
|
|
928
930
|
attributeChangedCallback(name: string, oldValue: string | null, value: string | null): void;
|
|
929
|
-
addEventListener<K extends keyof Events<M> & string
|
|
930
|
-
removeEventListener<K extends keyof Events<M> & string
|
|
931
|
+
addEventListener<K extends JsxPropNameToEventName<keyof Events<M> & string>>(type: K, listener: (event: InstanceType<Events<M>[Extract<EventNameToJsxProp<K>, keyof Events<M>>]>) => void, options?: boolean | AddEventListenerOptions): void;
|
|
932
|
+
removeEventListener<K extends JsxPropNameToEventName<keyof Events<M> & string>>(type: K, listener: (event: InstanceType<Events<M>[Extract<EventNameToJsxProp<K>, keyof Events<M>>]>) => void, options?: boolean | EventListenerOptions): void;
|
|
931
933
|
abstract render(): Template;
|
|
932
934
|
}
|
|
933
935
|
interface ComponentConstructor<M extends Metadata = {}> {
|
|
@@ -958,7 +960,7 @@ interface ComponentOptions {
|
|
|
958
960
|
declare const useMountEffect: (fn: () => Cleanup, deps?: SignalLike<unknown>[]) => void;
|
|
959
961
|
type Component<M extends Metadata = {}> = {
|
|
960
962
|
-readonly [K in keyof Props<M>]: Props<M>[K] extends Signal<infer T> ? T | undefined : never;
|
|
961
|
-
} &
|
|
963
|
+
} & _ComponentInner<M> & HTMLElement;
|
|
962
964
|
/**
|
|
963
965
|
* Creates a new web component class.
|
|
964
966
|
*
|
|
@@ -1131,5 +1133,5 @@ declare namespace JSX {
|
|
|
1131
1133
|
}
|
|
1132
1134
|
}
|
|
1133
1135
|
|
|
1134
|
-
export { Component, Else, ElseIf, For, Fragment, If, JSX, MaybeSignal, Portal, Style, TemplateNodes, createContext, createElement, css, defineComponents, event, flushBatch, h, isComponent, jsx, jsx as jsxDEV, jsx as jsxs, prop, useBatch, useContext, useMountEffect as useEffect, useMemo, useRef, useSignal, useSubscope };
|
|
1135
|
-
export type { AttributeOptions, Children, Cleanup, ComponentConstructor, ComponentOptions, Context, DangerousHtml, EventConstructor, FunctionalComponent, Metadata, PropOptions, RefSignal, RefSignalSetter, SetSignalOptions, Signal, SignalLike, SignalSetter, Styles, SubscopeOptions, Template };
|
|
1136
|
+
export { Component, Else, ElseIf, For, Fragment, If, JSX, MaybeSignal, Portal, Style, TemplateNodes, _ComponentInner, createContext, createElement, css, defineComponents, event, flushBatch, h, isComponent, jsx, jsx as jsxDEV, jsx as jsxs, prop, useBatch, useContext, useMountEffect as useEffect, useMemo, useRef, useSignal, useSubscope };
|
|
1137
|
+
export type { AttributeOptions, Children, Cleanup, ComponentConstructor, ComponentOptions, Context, DangerousHtml, EventConstructor, EventMeta, FunctionalComponent, Metadata, PropMeta, PropOptions, RefSignal, RefSignalSetter, SetSignalOptions, Signal, SignalLike, SignalSetter, Styles, SubscopeOptions, Template };
|
package/dist/component.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Cleanup, MaybeSignal, Signal, SignalLike } from "./scope.js";
|
|
2
2
|
import type { DomEventProps, DomProps } from "./dom.js";
|
|
3
|
-
import { JsxPropNameToEventName } from "./utils.js";
|
|
3
|
+
import { EventNameToJsxProp, JsxPropNameToEventName } from "./utils.js";
|
|
4
4
|
import { useScope } from "./scope.js";
|
|
5
5
|
import { Context } from "./context.js";
|
|
6
6
|
import { Template } from "./template.js";
|
|
@@ -147,7 +147,7 @@ type _CustomEventContructor<T> = undefined extends T ? typeof CustomEvent<T> : E
|
|
|
147
147
|
*/
|
|
148
148
|
export declare const event: (() => EventMeta<_CustomEventContructor<undefined>>) & (<T>() => EventMeta<_CustomEventContructor<T>>) & (<E extends EventConstructor>(eventConstructor: E) => EventMeta<E>);
|
|
149
149
|
export type Metadata = {
|
|
150
|
-
[K in keyof
|
|
150
|
+
[K in keyof _ComponentInner<any> | "props" | "events"]?: never;
|
|
151
151
|
} & {
|
|
152
152
|
[K in keyof DomProps<any>]?: never;
|
|
153
153
|
} & {
|
|
@@ -157,7 +157,7 @@ export type Metadata = {
|
|
|
157
157
|
};
|
|
158
158
|
export declare const componentSym: unique symbol;
|
|
159
159
|
export declare const jsxPropsSym: unique symbol;
|
|
160
|
-
declare abstract class
|
|
160
|
+
export declare abstract class _ComponentInner<M extends Metadata> {
|
|
161
161
|
protected props: Props<M>;
|
|
162
162
|
protected events: EventEmitters<M>;
|
|
163
163
|
readonly [jsxPropsSym]?: ComponentJsxProps<M>;
|
|
@@ -168,13 +168,13 @@ declare abstract class ComponentInner<M extends Metadata> {
|
|
|
168
168
|
connectedCallback(): void;
|
|
169
169
|
disconnectedCallback(): void;
|
|
170
170
|
attributeChangedCallback(name: string, oldValue: string | null, value: string | null): void;
|
|
171
|
-
addEventListener<K extends keyof Events<M> & string
|
|
172
|
-
removeEventListener<K extends keyof Events<M> & string
|
|
171
|
+
addEventListener<K extends JsxPropNameToEventName<keyof Events<M> & string>>(type: K, listener: (event: InstanceType<Events<M>[Extract<EventNameToJsxProp<K>, keyof Events<M>>]>) => void, options?: boolean | AddEventListenerOptions): void;
|
|
172
|
+
removeEventListener<K extends JsxPropNameToEventName<keyof Events<M> & string>>(type: K, listener: (event: InstanceType<Events<M>[Extract<EventNameToJsxProp<K>, keyof Events<M>>]>) => void, options?: boolean | EventListenerOptions): void;
|
|
173
173
|
abstract render(): Template;
|
|
174
174
|
}
|
|
175
175
|
export type Component<M extends Metadata = {}> = {
|
|
176
176
|
-readonly [K in keyof Props<M>]: Props<M>[K] extends Signal<infer T> ? T | undefined : never;
|
|
177
|
-
} &
|
|
177
|
+
} & _ComponentInner<M> & HTMLElement;
|
|
178
178
|
export interface ComponentConstructor<M extends Metadata = {}> {
|
|
179
179
|
/** @ignore */
|
|
180
180
|
readonly [componentSym]: {
|
package/dist/component.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sourceRoot":"","sources":["../src/component.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,SAAS,EACT,WAAW,EACX,SAAS,GAEV,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EACL,oBAAoB,
|
|
1
|
+
{"version":3,"file":"component.js","sourceRoot":"","sources":["../src/component.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,SAAS,EACT,WAAW,EACX,SAAS,GAEV,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EACL,oBAAoB,EAGpB,sBAAsB,GACvB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAW,SAAS,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAY,aAAa,EAAE,MAAM,eAAe,CAAC;AAmKxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,CAAC,MAAM,IAAI,GAQiB,CAChC,gBAAiC,EACjC,IAAqB,EACN,EAAE,CAAC,CAAC;IACnB,IAAI,EAAE,GAAG;IACT,iBAAiB,EAAE,gBAAgB;IACnC,GAAG,IAAI;CACR,CAAC,CAAC;AAaH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,MAAM,CAAC,MAAM,KAAK,GAEsD,CAAC,CACvE,mBAAqC,WAAW,EACnB,EAAE,CAAC,CAAC;IAC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T,IAAI,CAAC,IAAI,CAAC,IAAkB,CAAC;oBAC3B,KAAK,IAAI,IAAI;wBACX,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC;wBACjD,CAAC,CAAC,SAAS,CAAC;YAClB,CAAC;QACH,CAAC;;IAKH,OAAO,UAAiB,CAAC;AAC3B,CAAC,CAAQ,CAAC;AAEV;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,KAAU,EACiC,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,YAAY,CAAC,CAAC;AAkBxE;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAGyC,CACpE,GAAG,IAAgE,EACnE,EAAE;IACF,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GACxB,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,QAAQ;QACxB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAA2B,CAAC;QACpD,CAAC,CAAC,CAAC,EAAE,EAAE,IAA8B,CAAC,CAAC;IAE3C,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,cAAc,CAAC,MAAM,CACnB,MAAM;YACJ,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,QAAQ;gBAC/B,oBAAoB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,EACzC,SAAS,CACV,CAAC;IACJ,CAAC;AACH,CAAC,CAAC"}
|
package/dist/mod.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { Component, defineComponents, event, isComponent, prop, useMountEffect as useEffect, type AttributeOptions, type Metadata, type PropOptions, type PropMeta, type EventMeta, type ComponentConstructor, type _ComponentInner, type ComponentOptions, type FunctionalComponent, type EventConstructor, } from "./component.js";
|
|
2
2
|
export { type Context, createContext, useContext } from "./context.js";
|
|
3
3
|
export { createElement, h } from "./create_element.js";
|
|
4
4
|
export { type DangerousHtml, type Styles } from "./dom.js";
|
package/dist/mod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,KAAK,EACL,WAAW,EACX,IAAI,EACJ,cAAc,IAAI,SAAS,GAW5B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAgB,aAAa,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAiB,aAAa,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAEL,WAAW,EAQX,WAAW,EACX,OAAO,EACP,SAAS,EACT,MAAM,EACN,QAAQ,EACR,UAAU,GACX,MAAM,YAAY,CAAC;AAEpB,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC"}
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
type RemoveOn<S extends string> = S extends `on${infer R}` ? Uncapitalize<R> : never;
|
|
2
2
|
export type CamelCaseToKebabCase<S extends string> = S extends `${infer F}${infer R}` ? F extends Lowercase<F> ? `${F}${CamelCaseToKebabCase<R>}` : `-${Lowercase<F>}${CamelCaseToKebabCase<R>}` : Lowercase<S>;
|
|
3
|
+
export type KebabCaseToCamelCase<S extends string> = S extends `${infer F}-${infer R}` ? `${F}${Capitalize<KebabCaseToCamelCase<R>>}` : Capitalize<S>;
|
|
3
4
|
export declare const camelCaseToKebabCase: (value: string) => string;
|
|
4
5
|
export type JsxPropNameToEventName<S extends string> = CamelCaseToKebabCase<RemoveOn<S>>;
|
|
5
6
|
export declare const jsxPropNameToEventName: (value: `on${string}`) => string;
|
|
7
|
+
export type EventNameToJsxProp<S extends string> = `on${Capitalize<KebabCaseToCamelCase<S>>}`;
|
|
6
8
|
export {};
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAgBA,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAAa,EAAU,EAAE;IAC5D,OAAO,CACL,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE;QAC9B,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAC/D,CAAC;AACJ,CAAC,CAAC;AAMF,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,KAAoB,EAAU,EAAE;IACrE,IAAI,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACxB,CAAC;SAAM,CAAC;QACN,OAAO,oBAAoB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9C,CAAC;AACH,CAAC,CAAC"}
|
package/package.json
CHANGED
package/src/component.ts
CHANGED
|
@@ -11,6 +11,7 @@ import type { DomEventProps, DomProps } from "./dom.js";
|
|
|
11
11
|
import { runWithRenderer } from "./renderer.js";
|
|
12
12
|
import {
|
|
13
13
|
camelCaseToKebabCase,
|
|
14
|
+
EventNameToJsxProp,
|
|
14
15
|
JsxPropNameToEventName,
|
|
15
16
|
jsxPropNameToEventName,
|
|
16
17
|
} from "./utils.js";
|
|
@@ -300,7 +301,7 @@ export const event: (() => EventMeta<_CustomEventContructor<undefined>>) &
|
|
|
300
301
|
|
|
301
302
|
export type Metadata = {
|
|
302
303
|
// Forbid all library properties
|
|
303
|
-
[K in keyof
|
|
304
|
+
[K in keyof _ComponentInner<any> | "props" | "events"]?: never;
|
|
304
305
|
} & {
|
|
305
306
|
// Forbid all dom props
|
|
306
307
|
[K in keyof DomProps<any>]?: never;
|
|
@@ -314,7 +315,7 @@ export type Metadata = {
|
|
|
314
315
|
export const componentSym = Symbol("Component");
|
|
315
316
|
export declare const jsxPropsSym: unique symbol;
|
|
316
317
|
|
|
317
|
-
declare abstract class
|
|
318
|
+
export declare abstract class _ComponentInner<M extends Metadata> {
|
|
318
319
|
protected props: Props<M>;
|
|
319
320
|
protected events: EventEmitters<M>;
|
|
320
321
|
|
|
@@ -332,14 +333,24 @@ declare abstract class ComponentInner<M extends Metadata> {
|
|
|
332
333
|
value: string | null,
|
|
333
334
|
): void;
|
|
334
335
|
|
|
335
|
-
addEventListener<K extends keyof Events<M> & string
|
|
336
|
-
type:
|
|
337
|
-
listener: (
|
|
336
|
+
addEventListener<K extends JsxPropNameToEventName<keyof Events<M> & string>>(
|
|
337
|
+
type: K,
|
|
338
|
+
listener: (
|
|
339
|
+
event: InstanceType<
|
|
340
|
+
Events<M>[Extract<EventNameToJsxProp<K>, keyof Events<M>>]
|
|
341
|
+
>,
|
|
342
|
+
) => void,
|
|
338
343
|
options?: boolean | AddEventListenerOptions,
|
|
339
344
|
): void;
|
|
340
|
-
removeEventListener<
|
|
341
|
-
|
|
342
|
-
|
|
345
|
+
removeEventListener<
|
|
346
|
+
K extends JsxPropNameToEventName<keyof Events<M> & string>,
|
|
347
|
+
>(
|
|
348
|
+
type: K,
|
|
349
|
+
listener: (
|
|
350
|
+
event: InstanceType<
|
|
351
|
+
Events<M>[Extract<EventNameToJsxProp<K>, keyof Events<M>>]
|
|
352
|
+
>,
|
|
353
|
+
) => void,
|
|
343
354
|
options?: boolean | EventListenerOptions,
|
|
344
355
|
): void;
|
|
345
356
|
|
|
@@ -350,7 +361,7 @@ export type Component<M extends Metadata = {}> = {
|
|
|
350
361
|
-readonly [K in keyof Props<M>]: Props<M>[K] extends Signal<infer T>
|
|
351
362
|
? T | undefined
|
|
352
363
|
: never;
|
|
353
|
-
} &
|
|
364
|
+
} & _ComponentInner<M> &
|
|
354
365
|
HTMLElement;
|
|
355
366
|
|
|
356
367
|
export interface ComponentConstructor<M extends Metadata = {}> {
|
|
@@ -494,6 +505,7 @@ export const Component: ((tagName?: string) => ComponentConstructor<{}>) &
|
|
|
494
505
|
opts.shadow
|
|
495
506
|
? (component.shadowRoot ?? component.attachShadow(opts.shadow))
|
|
496
507
|
: component;
|
|
508
|
+
|
|
497
509
|
abstract class _Component extends HTMLElement {
|
|
498
510
|
static readonly [componentSym]: ComponentConstructor[typeof componentSym] =
|
|
499
511
|
{
|
|
@@ -504,7 +516,7 @@ export const Component: ((tagName?: string) => ComponentConstructor<{}>) &
|
|
|
504
516
|
protected props: Record<string, Signal<any>> = {};
|
|
505
517
|
protected events: Record<string, (arg: unknown) => any> = {};
|
|
506
518
|
|
|
507
|
-
readonly [componentSym]:
|
|
519
|
+
readonly [componentSym]: _ComponentInner<any>[typeof componentSym] = {};
|
|
508
520
|
|
|
509
521
|
constructor() {
|
|
510
522
|
super();
|
package/src/mod.ts
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
export {
|
|
2
|
-
type AttributeOptions,
|
|
3
2
|
Component,
|
|
4
|
-
type ComponentConstructor,
|
|
5
|
-
type ComponentOptions,
|
|
6
3
|
defineComponents,
|
|
7
4
|
event,
|
|
8
|
-
type EventConstructor,
|
|
9
|
-
type FunctionalComponent,
|
|
10
5
|
isComponent,
|
|
11
|
-
type Metadata,
|
|
12
6
|
prop,
|
|
13
|
-
type PropOptions,
|
|
14
7
|
useMountEffect as useEffect,
|
|
8
|
+
type AttributeOptions,
|
|
9
|
+
type Metadata,
|
|
10
|
+
type PropOptions,
|
|
11
|
+
type PropMeta,
|
|
12
|
+
type EventMeta,
|
|
13
|
+
type ComponentConstructor,
|
|
14
|
+
type _ComponentInner,
|
|
15
|
+
type ComponentOptions,
|
|
16
|
+
type FunctionalComponent,
|
|
17
|
+
type EventConstructor,
|
|
15
18
|
} from "./component.js";
|
|
16
19
|
export { type Context, createContext, useContext } from "./context.js";
|
|
17
20
|
export { createElement, h } from "./create_element.js";
|
package/src/utils.ts
CHANGED
|
@@ -9,6 +9,11 @@ export type CamelCaseToKebabCase<S extends string> =
|
|
|
9
9
|
: `-${Lowercase<F>}${CamelCaseToKebabCase<R>}`
|
|
10
10
|
: Lowercase<S>;
|
|
11
11
|
|
|
12
|
+
export type KebabCaseToCamelCase<S extends string> =
|
|
13
|
+
S extends `${infer F}-${infer R}`
|
|
14
|
+
? `${F}${Capitalize<KebabCaseToCamelCase<R>>}`
|
|
15
|
+
: Capitalize<S>;
|
|
16
|
+
|
|
12
17
|
export const camelCaseToKebabCase = (value: string): string => {
|
|
13
18
|
return (
|
|
14
19
|
(value[0] ?? "").toLowerCase() +
|
|
@@ -27,3 +32,6 @@ export const jsxPropNameToEventName = (value: `on${string}`): string => {
|
|
|
27
32
|
return camelCaseToKebabCase(value.slice(2));
|
|
28
33
|
}
|
|
29
34
|
};
|
|
35
|
+
|
|
36
|
+
export type EventNameToJsxProp<S extends string> =
|
|
37
|
+
`on${Capitalize<KebabCaseToCamelCase<S>>}`;
|