@amazon/vinyl-tsx 1.0.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 (73) hide show
  1. package/dist/index.cjs +354 -0
  2. package/dist/index.cjs.map +7 -0
  3. package/dist/index.js +340 -0
  4. package/dist/index.js.map +7 -0
  5. package/dist/types/current/ActiveText.d.ts +8 -0
  6. package/dist/types/current/ActiveText.d.ts.map +1 -0
  7. package/dist/types/current/ActiveText.js +19 -0
  8. package/dist/types/current/domUtil.d.ts +33 -0
  9. package/dist/types/current/domUtil.d.ts.map +1 -0
  10. package/dist/types/current/domUtil.js +73 -0
  11. package/dist/types/current/extensions/HookExtension.d.ts +2 -0
  12. package/dist/types/current/extensions/HookExtension.d.ts.map +1 -0
  13. package/dist/types/current/extensions/HookExtension.js +5 -0
  14. package/dist/types/current/extensions/applyClassList.d.ts +4 -0
  15. package/dist/types/current/extensions/applyClassList.d.ts.map +1 -0
  16. package/dist/types/current/extensions/applyClassList.js +40 -0
  17. package/dist/types/current/extensions/applyPassiveHandler.d.ts +7 -0
  18. package/dist/types/current/extensions/applyPassiveHandler.d.ts.map +1 -0
  19. package/dist/types/current/extensions/applyPassiveHandler.js +15 -0
  20. package/dist/types/current/extensions/applyStyles.d.ts +12 -0
  21. package/dist/types/current/extensions/applyStyles.d.ts.map +1 -0
  22. package/dist/types/current/extensions/applyStyles.js +31 -0
  23. package/dist/types/current/extensions/applyVisibility.d.ts +3 -0
  24. package/dist/types/current/extensions/applyVisibility.d.ts.map +1 -0
  25. package/dist/types/current/extensions/applyVisibility.js +21 -0
  26. package/dist/types/current/extensions/connectedObserver.d.ts +15 -0
  27. package/dist/types/current/extensions/connectedObserver.d.ts.map +1 -0
  28. package/dist/types/current/extensions/connectedObserver.js +72 -0
  29. package/dist/types/current/index.d.ts +12 -0
  30. package/dist/types/current/index.d.ts.map +1 -0
  31. package/dist/types/current/index.js +11 -0
  32. package/dist/types/current/jsx.d.ts +55 -0
  33. package/dist/types/current/jsx.d.ts.map +1 -0
  34. package/dist/types/current/jsx.js +106 -0
  35. package/dist/types/current/tsconfig.tsbuildinfo +1 -0
  36. package/dist/types/current/type.d.ts +10 -0
  37. package/dist/types/current/type.d.ts.map +1 -0
  38. package/dist/types/current/type.js +5 -0
  39. package/dist/types/ts3.7/ActiveText.d.ts +8 -0
  40. package/dist/types/ts3.7/domUtil.d.ts +33 -0
  41. package/dist/types/ts3.7/extensions/HookExtension.d.ts +2 -0
  42. package/dist/types/ts3.7/extensions/applyClassList.d.ts +4 -0
  43. package/dist/types/ts3.7/extensions/applyPassiveHandler.d.ts +7 -0
  44. package/dist/types/ts3.7/extensions/applyStyles.d.ts +12 -0
  45. package/dist/types/ts3.7/extensions/applyVisibility.d.ts +3 -0
  46. package/dist/types/ts3.7/extensions/connectedObserver.d.ts +15 -0
  47. package/dist/types/ts3.7/index.d.ts +12 -0
  48. package/dist/types/ts3.7/jsx.d.ts +55 -0
  49. package/dist/types/ts3.7/type.d.ts +10 -0
  50. package/dist/types/ts4.1/ActiveText.d.ts +8 -0
  51. package/dist/types/ts4.1/domUtil.d.ts +33 -0
  52. package/dist/types/ts4.1/extensions/HookExtension.d.ts +2 -0
  53. package/dist/types/ts4.1/extensions/applyClassList.d.ts +4 -0
  54. package/dist/types/ts4.1/extensions/applyPassiveHandler.d.ts +7 -0
  55. package/dist/types/ts4.1/extensions/applyStyles.d.ts +12 -0
  56. package/dist/types/ts4.1/extensions/applyVisibility.d.ts +3 -0
  57. package/dist/types/ts4.1/extensions/connectedObserver.d.ts +15 -0
  58. package/dist/types/ts4.1/index.d.ts +12 -0
  59. package/dist/types/ts4.1/jsx.d.ts +55 -0
  60. package/dist/types/ts4.1/type.d.ts +10 -0
  61. package/dist/types/ts4.7/ActiveText.d.ts +8 -0
  62. package/dist/types/ts4.7/domUtil.d.ts +33 -0
  63. package/dist/types/ts4.7/extensions/HookExtension.d.ts +2 -0
  64. package/dist/types/ts4.7/extensions/applyClassList.d.ts +4 -0
  65. package/dist/types/ts4.7/extensions/applyPassiveHandler.d.ts +7 -0
  66. package/dist/types/ts4.7/extensions/applyStyles.d.ts +12 -0
  67. package/dist/types/ts4.7/extensions/applyVisibility.d.ts +3 -0
  68. package/dist/types/ts4.7/extensions/connectedObserver.d.ts +15 -0
  69. package/dist/types/ts4.7/index.d.ts +12 -0
  70. package/dist/types/ts4.7/jsx.d.ts +55 -0
  71. package/dist/types/ts4.7/type.d.ts +10 -0
  72. package/docs/TSX.md +316 -0
  73. package/package.json +82 -0
@@ -0,0 +1,15 @@
1
+ import { Maybe, Unsubscribe } from '@amazon/vinyl-util';
2
+ /**
3
+ * Dispatches a 'connected' event on nodes attached to the dom, dispatches 'disconnected' when removed.
4
+ * Allows nodes to observe connected changes without creating a memory leak.
5
+ */
6
+ export declare function initializeConnectedObserver(): Unsubscribe;
7
+ /**
8
+ * Invokes a callback when the given target is connected to the DOM.
9
+ * If the callback returns a function, that function will be invoked when disconnected.
10
+ *
11
+ * @param target
12
+ * @param callback
13
+ */
14
+ export declare function onConnect<T extends Node>(target: T, callback: (node: T) => Maybe<Unsubscribe> | void): Unsubscribe;
15
+ //# sourceMappingURL=connectedObserver.d.ts.map
@@ -0,0 +1,12 @@
1
+ /** Auto-generated from build scripts */
2
+ export * from './type';
3
+ export * from './jsx';
4
+ export * from './domUtil';
5
+ export * from './ActiveText';
6
+ export * from './extensions/connectedObserver';
7
+ export * from './extensions/applyVisibility';
8
+ export * from './extensions/applyStyles';
9
+ export * from './extensions/applyPassiveHandler';
10
+ export * from './extensions/applyClassList';
11
+ export * from './extensions/HookExtension';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,55 @@
1
+ import { Writable } from './type';
2
+ import { applyStyles } from './extensions/applyStyles';
3
+ import { MaybeObservableValue, ObservableValue } from '@amazon/vinyl-observable';
4
+ import { applyVisibility } from './extensions/applyVisibility';
5
+ import { applyClassList } from './extensions/applyClassList';
6
+ import { HookExtension } from './extensions/HookExtension';
7
+ import { AnyRecord, Maybe } from '@amazon/vinyl-util';
8
+ /**
9
+ * Maps JS property names to their corresponding HTML attribute names where they differ.
10
+ * Extensible — add entries for custom elements or non-standard properties.
11
+ */
12
+ export declare const propToAttr: Record<string, string>;
13
+ export type JsxFactory = (props: any, children: any[]) => any;
14
+ /**
15
+ * A map of custom jsx properties to be used in hook extensions.
16
+ */
17
+ export declare const hookExtensions: {
18
+ readonly ontouchstart: HookExtension<((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined>;
19
+ readonly ontouchmove: HookExtension<((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined>;
20
+ readonly onwheel: HookExtension<((this: GlobalEventHandlers, ev: WheelEvent) => any) | null>;
21
+ readonly onConnect: (target: HTMLElement, callback: (node: HTMLElement) => Maybe<import("@amazon/vinyl-util").Unsubscribe> | void) => import("@amazon/vinyl-util").Unsubscribe;
22
+ readonly style: typeof applyStyles;
23
+ readonly visible: typeof applyVisibility;
24
+ readonly classList: typeof applyClassList;
25
+ };
26
+ export type AllowBindable<T> = {
27
+ [K in keyof T]: MaybeObservableValue<Maybe<T[K]>>;
28
+ };
29
+ /**
30
+ * A type map of the jsx extended properties to the type provided to the hook.
31
+ */
32
+ export type HookExtensions = {
33
+ [p in keyof typeof hookExtensions]?: Parameters<(typeof hookExtensions)[p]>[1];
34
+ };
35
+ export type ElementProps<K extends keyof HTMLElementTagNameMap> = Omit<Partial<Writable<HTMLElementTagNameMap[K]>>, keyof HookExtensions>;
36
+ export type BindableElementProps<K extends keyof HTMLElementTagNameMap> = AllowBindable<ElementProps<K>>;
37
+ /**
38
+ * Allowed properties for intrinsic elements when writing jsx declarative markup.
39
+ */
40
+ export type JsxElementProps<K extends keyof HTMLElementTagNameMap> = BindableElementProps<K> & HookExtensions;
41
+ export type DomIntrinsicElements = {
42
+ [K in keyof HTMLElementTagNameMap]: JsxElementProps<K>;
43
+ };
44
+ export type JsxChild = Node | string | ObservableValue<Node | string>;
45
+ export declare function jsx<K extends keyof HTMLElementTagNameMap>(type: K, props: JsxElementProps<K>, ...children: JsxChild[]): HTMLElementTagNameMap[K];
46
+ export declare function jsx<Factory extends JsxFactory>(type: Factory, props: Parameters<Factory>[0], ...children: Parameters<Factory>[1]): ReturnType<Factory>;
47
+ export declare function Fragment(_props: AnyRecord, children: (Node | string)[]): HTMLDivElement;
48
+ declare global {
49
+ namespace JSX {
50
+ type IntrinsicElements = DomIntrinsicElements;
51
+ type Element = HTMLElement;
52
+ type Fragment = HTMLElement;
53
+ }
54
+ }
55
+ //# sourceMappingURL=jsx.d.ts.map
@@ -0,0 +1,10 @@
1
+ export type WritableKeys<T> = {
2
+ [K in keyof T]-?: IfEquals<{
3
+ [P in K]: T[K];
4
+ }, {
5
+ -readonly [P in K]: T[K];
6
+ }, K>;
7
+ }[keyof T];
8
+ export type Writable<T> = Pick<T, WritableKeys<T>>;
9
+ export type IfEquals<X, Y, A = X, B = never> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? A : B;
10
+ //# sourceMappingURL=type.d.ts.map
@@ -0,0 +1,8 @@
1
+ import type { ObservableValue } from '@amazon/vinyl-observable';
2
+ /**
3
+ * A Text node bound to a data provider.
4
+ * Created automatically when a child is a ObservableValue.
5
+ * textContent will only be updated when the node is on the DOM.
6
+ */
7
+ export declare function ActiveText<T>(data: ObservableValue<T>): Text;
8
+ //# sourceMappingURL=ActiveText.d.ts.map
@@ -0,0 +1,33 @@
1
+ export declare function el<K extends keyof HTMLElementTagNameMap>(selectors: K, parentNode?: ParentNode): HTMLElementTagNameMap[K];
2
+ export declare function el(selectors: string, parentNode?: ParentNode): HTMLElement;
3
+ export interface QuerySelector {
4
+ <K extends keyof HTMLElementTagNameMap>(selectors: K, parentNode?: ParentNode): HTMLElementTagNameMap[K];
5
+ (selectors: string): HTMLElement;
6
+ }
7
+ export declare function bindQuerySelector(parentNode: ParentNode): QuerySelector;
8
+ export declare function hide(element: HTMLElement): void;
9
+ export declare function show(element: HTMLElement): void;
10
+ export declare function getVisible(element: HTMLElement): boolean;
11
+ export declare function setVisible(element: HTMLElement, value: boolean): void;
12
+ export declare function isHidden(element: HTMLElement): boolean;
13
+ export declare function isInputElement(value: Element | null): value is HTMLInputElement;
14
+ /**
15
+ * Adds or removes a class token to an element.
16
+ *
17
+ * @param value The element whose classList to modify.
18
+ * @param token The class token.
19
+ * @param toggled If true, the token is added, if false, removed.
20
+ */
21
+ export declare function setClassToken(value: HTMLElement, token: string, toggled: boolean): void;
22
+ export type ElementInitOptions = {
23
+ readonly parent?: HTMLElement;
24
+ readonly className?: string;
25
+ };
26
+ /**
27
+ * Recursively walks a node hierarchy, invoking a callback for every node, depth first.
28
+ *
29
+ * @param node
30
+ * @param callback
31
+ */
32
+ export declare function walkDomDepthFirst(node: Node | undefined | null, callback: (node: Node) => void): void;
33
+ //# sourceMappingURL=domUtil.d.ts.map
@@ -0,0 +1,2 @@
1
+ export type HookExtension<T> = (element: HTMLElement, prop: T) => any;
2
+ //# sourceMappingURL=HookExtension.d.ts.map
@@ -0,0 +1,4 @@
1
+ import type { ObservableValue } from '@amazon/vinyl-observable';
2
+ import type { Maybe } from '@amazon/vinyl-util';
3
+ export declare function applyClassList(element: HTMLElement, classList: readonly (Maybe<string> | ObservableValue<Maybe<string>>)[]): void;
4
+ //# sourceMappingURL=applyClassList.d.ts.map
@@ -0,0 +1,7 @@
1
+ import type { HookExtension } from './HookExtension';
2
+ export declare const passiveEventHandlers: {
3
+ readonly ontouchstart: HookExtension<((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined>;
4
+ readonly ontouchmove: HookExtension<((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined>;
5
+ readonly onwheel: HookExtension<((this: GlobalEventHandlers, ev: WheelEvent) => any) | null>;
6
+ };
7
+ //# sourceMappingURL=applyPassiveHandler.d.ts.map
@@ -0,0 +1,12 @@
1
+ import type { AllowBindable } from '../jsx';
2
+ import type { MaybeObservableValue } from '@amazon/vinyl-observable';
3
+ import type { Maybe } from '@amazon/vinyl-util';
4
+ /**
5
+ * The shape accepted by the `style` jsx prop. Allows the typed CSSStyleDeclaration
6
+ * fields plus any CSS custom property key (must start with `--`).
7
+ */
8
+ export type StyleProp = AllowBindable<Partial<CSSStyleDeclaration>> & {
9
+ readonly [customProperty: `--${string}`]: MaybeObservableValue<Maybe<string>>;
10
+ };
11
+ export declare function applyStyles(element: HTMLElement, style: StyleProp): void;
12
+ //# sourceMappingURL=applyStyles.d.ts.map
@@ -0,0 +1,3 @@
1
+ import type { ObservableValue } from '@amazon/vinyl-observable';
2
+ export declare function applyVisibility(element: HTMLElement, visible: boolean | ObservableValue<boolean>): void;
3
+ //# sourceMappingURL=applyVisibility.d.ts.map
@@ -0,0 +1,15 @@
1
+ import type { Maybe, Unsubscribe } from '@amazon/vinyl-util';
2
+ /**
3
+ * Dispatches a 'connected' event on nodes attached to the dom, dispatches 'disconnected' when removed.
4
+ * Allows nodes to observe connected changes without creating a memory leak.
5
+ */
6
+ export declare function initializeConnectedObserver(): Unsubscribe;
7
+ /**
8
+ * Invokes a callback when the given target is connected to the DOM.
9
+ * If the callback returns a function, that function will be invoked when disconnected.
10
+ *
11
+ * @param target
12
+ * @param callback
13
+ */
14
+ export declare function onConnect<T extends Node>(target: T, callback: (node: T) => Maybe<Unsubscribe> | void): Unsubscribe;
15
+ //# sourceMappingURL=connectedObserver.d.ts.map
@@ -0,0 +1,12 @@
1
+ /** Auto-generated from build scripts */
2
+ export * from './type';
3
+ export * from './jsx';
4
+ export * from './domUtil';
5
+ export * from './ActiveText';
6
+ export * from './extensions/connectedObserver';
7
+ export * from './extensions/applyVisibility';
8
+ export * from './extensions/applyStyles';
9
+ export * from './extensions/applyPassiveHandler';
10
+ export * from './extensions/applyClassList';
11
+ export * from './extensions/HookExtension';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,55 @@
1
+ import type { Writable } from './type';
2
+ import { applyStyles } from './extensions/applyStyles';
3
+ import type { MaybeObservableValue, ObservableValue } from '@amazon/vinyl-observable';
4
+ import { applyVisibility } from './extensions/applyVisibility';
5
+ import { applyClassList } from './extensions/applyClassList';
6
+ import type { HookExtension } from './extensions/HookExtension';
7
+ import type { AnyRecord, Maybe } from '@amazon/vinyl-util';
8
+ /**
9
+ * Maps JS property names to their corresponding HTML attribute names where they differ.
10
+ * Extensible — add entries for custom elements or non-standard properties.
11
+ */
12
+ export declare const propToAttr: Record<string, string>;
13
+ export type JsxFactory = (props: any, children: any[]) => any;
14
+ /**
15
+ * A map of custom jsx properties to be used in hook extensions.
16
+ */
17
+ export declare const hookExtensions: {
18
+ readonly ontouchstart: HookExtension<((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined>;
19
+ readonly ontouchmove: HookExtension<((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined>;
20
+ readonly onwheel: HookExtension<((this: GlobalEventHandlers, ev: WheelEvent) => any) | null>;
21
+ readonly onConnect: (target: HTMLElement, callback: (node: HTMLElement) => Maybe<import("@amazon/vinyl-util").Unsubscribe> | void) => import("@amazon/vinyl-util").Unsubscribe;
22
+ readonly style: typeof applyStyles;
23
+ readonly visible: typeof applyVisibility;
24
+ readonly classList: typeof applyClassList;
25
+ };
26
+ export type AllowBindable<T> = {
27
+ [K in keyof T]: MaybeObservableValue<Maybe<T[K]>>;
28
+ };
29
+ /**
30
+ * A type map of the jsx extended properties to the type provided to the hook.
31
+ */
32
+ export type HookExtensions = {
33
+ [p in keyof typeof hookExtensions]?: Parameters<(typeof hookExtensions)[p]>[1];
34
+ };
35
+ export type ElementProps<K extends keyof HTMLElementTagNameMap> = Omit<Partial<Writable<HTMLElementTagNameMap[K]>>, keyof HookExtensions>;
36
+ export type BindableElementProps<K extends keyof HTMLElementTagNameMap> = AllowBindable<ElementProps<K>>;
37
+ /**
38
+ * Allowed properties for intrinsic elements when writing jsx declarative markup.
39
+ */
40
+ export type JsxElementProps<K extends keyof HTMLElementTagNameMap> = BindableElementProps<K> & HookExtensions;
41
+ export type DomIntrinsicElements = {
42
+ [K in keyof HTMLElementTagNameMap]: JsxElementProps<K>;
43
+ };
44
+ export type JsxChild = Node | string | ObservableValue<Node | string>;
45
+ export declare function jsx<K extends keyof HTMLElementTagNameMap>(type: K, props: JsxElementProps<K>, ...children: JsxChild[]): HTMLElementTagNameMap[K];
46
+ export declare function jsx<Factory extends JsxFactory>(type: Factory, props: Parameters<Factory>[0], ...children: Parameters<Factory>[1]): ReturnType<Factory>;
47
+ export declare function Fragment(_props: AnyRecord, children: (Node | string)[]): HTMLDivElement;
48
+ declare global {
49
+ namespace JSX {
50
+ type IntrinsicElements = DomIntrinsicElements;
51
+ type Element = HTMLElement;
52
+ type Fragment = HTMLElement;
53
+ }
54
+ }
55
+ //# sourceMappingURL=jsx.d.ts.map
@@ -0,0 +1,10 @@
1
+ export type WritableKeys<T> = {
2
+ [K in keyof T]-?: IfEquals<{
3
+ [P in K]: T[K];
4
+ }, {
5
+ -readonly [P in K]: T[K];
6
+ }, K>;
7
+ }[keyof T];
8
+ export type Writable<T> = Pick<T, WritableKeys<T>>;
9
+ export type IfEquals<X, Y, A = X, B = never> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? A : B;
10
+ //# sourceMappingURL=type.d.ts.map
@@ -0,0 +1,8 @@
1
+ import type { ObservableValue } from '@amazon/vinyl-observable';
2
+ /**
3
+ * A Text node bound to a data provider.
4
+ * Created automatically when a child is a ObservableValue.
5
+ * textContent will only be updated when the node is on the DOM.
6
+ */
7
+ export declare function ActiveText<T>(data: ObservableValue<T>): Text;
8
+ //# sourceMappingURL=ActiveText.d.ts.map
@@ -0,0 +1,33 @@
1
+ export declare function el<K extends keyof HTMLElementTagNameMap>(selectors: K, parentNode?: ParentNode): HTMLElementTagNameMap[K];
2
+ export declare function el(selectors: string, parentNode?: ParentNode): HTMLElement;
3
+ export interface QuerySelector {
4
+ <K extends keyof HTMLElementTagNameMap>(selectors: K, parentNode?: ParentNode): HTMLElementTagNameMap[K];
5
+ (selectors: string): HTMLElement;
6
+ }
7
+ export declare function bindQuerySelector(parentNode: ParentNode): QuerySelector;
8
+ export declare function hide(element: HTMLElement): void;
9
+ export declare function show(element: HTMLElement): void;
10
+ export declare function getVisible(element: HTMLElement): boolean;
11
+ export declare function setVisible(element: HTMLElement, value: boolean): void;
12
+ export declare function isHidden(element: HTMLElement): boolean;
13
+ export declare function isInputElement(value: Element | null): value is HTMLInputElement;
14
+ /**
15
+ * Adds or removes a class token to an element.
16
+ *
17
+ * @param value The element whose classList to modify.
18
+ * @param token The class token.
19
+ * @param toggled If true, the token is added, if false, removed.
20
+ */
21
+ export declare function setClassToken(value: HTMLElement, token: string, toggled: boolean): void;
22
+ export type ElementInitOptions = {
23
+ readonly parent?: HTMLElement;
24
+ readonly className?: string;
25
+ };
26
+ /**
27
+ * Recursively walks a node hierarchy, invoking a callback for every node, depth first.
28
+ *
29
+ * @param node
30
+ * @param callback
31
+ */
32
+ export declare function walkDomDepthFirst(node: Node | undefined | null, callback: (node: Node) => void): void;
33
+ //# sourceMappingURL=domUtil.d.ts.map
@@ -0,0 +1,2 @@
1
+ export type HookExtension<T> = (element: HTMLElement, prop: T) => any;
2
+ //# sourceMappingURL=HookExtension.d.ts.map
@@ -0,0 +1,4 @@
1
+ import { type ObservableValue } from '@amazon/vinyl-observable';
2
+ import type { Maybe } from '@amazon/vinyl-util';
3
+ export declare function applyClassList(element: HTMLElement, classList: readonly (Maybe<string> | ObservableValue<Maybe<string>>)[]): void;
4
+ //# sourceMappingURL=applyClassList.d.ts.map
@@ -0,0 +1,7 @@
1
+ import type { HookExtension } from './HookExtension';
2
+ export declare const passiveEventHandlers: {
3
+ readonly ontouchstart: HookExtension<((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined>;
4
+ readonly ontouchmove: HookExtension<((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined>;
5
+ readonly onwheel: HookExtension<((this: GlobalEventHandlers, ev: WheelEvent) => any) | null>;
6
+ };
7
+ //# sourceMappingURL=applyPassiveHandler.d.ts.map
@@ -0,0 +1,12 @@
1
+ import type { AllowBindable } from '../jsx';
2
+ import { type MaybeObservableValue } from '@amazon/vinyl-observable';
3
+ import type { Maybe } from '@amazon/vinyl-util';
4
+ /**
5
+ * The shape accepted by the `style` jsx prop. Allows the typed CSSStyleDeclaration
6
+ * fields plus any CSS custom property key (must start with `--`).
7
+ */
8
+ export type StyleProp = AllowBindable<Partial<CSSStyleDeclaration>> & {
9
+ readonly [customProperty: `--${string}`]: MaybeObservableValue<Maybe<string>>;
10
+ };
11
+ export declare function applyStyles(element: HTMLElement, style: StyleProp): void;
12
+ //# sourceMappingURL=applyStyles.d.ts.map
@@ -0,0 +1,3 @@
1
+ import type { ObservableValue } from '@amazon/vinyl-observable';
2
+ export declare function applyVisibility(element: HTMLElement, visible: boolean | ObservableValue<boolean>): void;
3
+ //# sourceMappingURL=applyVisibility.d.ts.map
@@ -0,0 +1,15 @@
1
+ import type { Maybe, Unsubscribe } from '@amazon/vinyl-util';
2
+ /**
3
+ * Dispatches a 'connected' event on nodes attached to the dom, dispatches 'disconnected' when removed.
4
+ * Allows nodes to observe connected changes without creating a memory leak.
5
+ */
6
+ export declare function initializeConnectedObserver(): Unsubscribe;
7
+ /**
8
+ * Invokes a callback when the given target is connected to the DOM.
9
+ * If the callback returns a function, that function will be invoked when disconnected.
10
+ *
11
+ * @param target
12
+ * @param callback
13
+ */
14
+ export declare function onConnect<T extends Node>(target: T, callback: (node: T) => Maybe<Unsubscribe> | void): Unsubscribe;
15
+ //# sourceMappingURL=connectedObserver.d.ts.map
@@ -0,0 +1,12 @@
1
+ /** Auto-generated from build scripts */
2
+ export * from './type';
3
+ export * from './jsx';
4
+ export * from './domUtil';
5
+ export * from './ActiveText';
6
+ export * from './extensions/connectedObserver';
7
+ export * from './extensions/applyVisibility';
8
+ export * from './extensions/applyStyles';
9
+ export * from './extensions/applyPassiveHandler';
10
+ export * from './extensions/applyClassList';
11
+ export * from './extensions/HookExtension';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,55 @@
1
+ import type { Writable } from './type';
2
+ import { applyStyles } from './extensions/applyStyles';
3
+ import { type MaybeObservableValue, type ObservableValue } from '@amazon/vinyl-observable';
4
+ import { applyVisibility } from './extensions/applyVisibility';
5
+ import { applyClassList } from './extensions/applyClassList';
6
+ import type { HookExtension } from './extensions/HookExtension';
7
+ import type { AnyRecord, Maybe } from '@amazon/vinyl-util';
8
+ /**
9
+ * Maps JS property names to their corresponding HTML attribute names where they differ.
10
+ * Extensible — add entries for custom elements or non-standard properties.
11
+ */
12
+ export declare const propToAttr: Record<string, string>;
13
+ export type JsxFactory = (props: any, children: any[]) => any;
14
+ /**
15
+ * A map of custom jsx properties to be used in hook extensions.
16
+ */
17
+ export declare const hookExtensions: {
18
+ readonly ontouchstart: HookExtension<((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined>;
19
+ readonly ontouchmove: HookExtension<((this: GlobalEventHandlers, ev: TouchEvent) => any) | null | undefined>;
20
+ readonly onwheel: HookExtension<((this: GlobalEventHandlers, ev: WheelEvent) => any) | null>;
21
+ readonly onConnect: (target: HTMLElement, callback: (node: HTMLElement) => Maybe<import("@amazon/vinyl-util").Unsubscribe> | void) => import("@amazon/vinyl-util").Unsubscribe;
22
+ readonly style: typeof applyStyles;
23
+ readonly visible: typeof applyVisibility;
24
+ readonly classList: typeof applyClassList;
25
+ };
26
+ export type AllowBindable<T> = {
27
+ [K in keyof T]: MaybeObservableValue<Maybe<T[K]>>;
28
+ };
29
+ /**
30
+ * A type map of the jsx extended properties to the type provided to the hook.
31
+ */
32
+ export type HookExtensions = {
33
+ [p in keyof typeof hookExtensions]?: Parameters<(typeof hookExtensions)[p]>[1];
34
+ };
35
+ export type ElementProps<K extends keyof HTMLElementTagNameMap> = Omit<Partial<Writable<HTMLElementTagNameMap[K]>>, keyof HookExtensions>;
36
+ export type BindableElementProps<K extends keyof HTMLElementTagNameMap> = AllowBindable<ElementProps<K>>;
37
+ /**
38
+ * Allowed properties for intrinsic elements when writing jsx declarative markup.
39
+ */
40
+ export type JsxElementProps<K extends keyof HTMLElementTagNameMap> = BindableElementProps<K> & HookExtensions;
41
+ export type DomIntrinsicElements = {
42
+ [K in keyof HTMLElementTagNameMap]: JsxElementProps<K>;
43
+ };
44
+ export type JsxChild = Node | string | ObservableValue<Node | string>;
45
+ export declare function jsx<K extends keyof HTMLElementTagNameMap>(type: K, props: JsxElementProps<K>, ...children: JsxChild[]): HTMLElementTagNameMap[K];
46
+ export declare function jsx<Factory extends JsxFactory>(type: Factory, props: Parameters<Factory>[0], ...children: Parameters<Factory>[1]): ReturnType<Factory>;
47
+ export declare function Fragment(_props: AnyRecord, children: (Node | string)[]): HTMLDivElement;
48
+ declare global {
49
+ namespace JSX {
50
+ type IntrinsicElements = DomIntrinsicElements;
51
+ type Element = HTMLElement;
52
+ type Fragment = HTMLElement;
53
+ }
54
+ }
55
+ //# sourceMappingURL=jsx.d.ts.map
@@ -0,0 +1,10 @@
1
+ export type WritableKeys<T> = {
2
+ [K in keyof T]-?: IfEquals<{
3
+ [P in K]: T[K];
4
+ }, {
5
+ -readonly [P in K]: T[K];
6
+ }, K>;
7
+ }[keyof T];
8
+ export type Writable<T> = Pick<T, WritableKeys<T>>;
9
+ export type IfEquals<X, Y, A = X, B = never> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? A : B;
10
+ //# sourceMappingURL=type.d.ts.map