@context-action/core 1.3.0 → 1.3.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/CHANGELOG.md +11 -0
- package/README.md +13 -0
- package/dist/element-BRlY61kW.cjs +631 -0
- package/dist/element-BTaXgo7n.js +597 -0
- package/dist/element-BTaXgo7n.js.map +1 -0
- package/dist/element-DPioFL7C.d.cts +163 -0
- package/dist/element-DPioFL7C.d.cts.map +1 -0
- package/dist/element-DPioFL7C.d.ts +163 -0
- package/dist/element-DPioFL7C.d.ts.map +1 -0
- package/dist/element-react.cjs +13 -3
- package/dist/element-react.d.cts +2 -2
- package/dist/element-react.d.ts +2 -2
- package/dist/element-react.js +9 -3
- package/dist/element-react.js.map +1 -1
- package/dist/element.cjs +6 -2
- package/dist/element.d.cts +2 -2
- package/dist/element.d.ts +2 -2
- package/dist/element.js +2 -2
- package/docs/element-interop.md +20 -8
- package/package.json +1 -1
- package/dist/element-BJpk34By.d.cts +0 -35
- package/dist/element-BJpk34By.d.cts.map +0 -1
- package/dist/element-BJpk34By.d.ts +0 -35
- package/dist/element-BJpk34By.d.ts.map +0 -1
- package/dist/element-BcfeiQgA.cjs +0 -190
- package/dist/element-DSSLaFmw.js +0 -180
- package/dist/element-DSSLaFmw.js.map +0 -1
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
//#region src/facade/types.d.ts
|
|
2
|
+
type PublicHandleFactory<Target extends object, Handle> = (getTarget: () => Target | null) => Handle;
|
|
3
|
+
//#endregion
|
|
4
|
+
//#region src/element/contracts.d.ts
|
|
5
|
+
type ImperativeHandleFactory<Element extends HTMLElement, Handle> = PublicHandleFactory<Element, Handle>;
|
|
6
|
+
interface ElementBindingConfig<Props extends object> {
|
|
7
|
+
properties?: readonly (keyof Props)[];
|
|
8
|
+
attributes?: Partial<Record<keyof Props & string, string>>;
|
|
9
|
+
styles?: Partial<Record<keyof Props & string, string>>;
|
|
10
|
+
events?: Record<string, string>;
|
|
11
|
+
}
|
|
12
|
+
interface ElementBridgeConfig<Props extends object, Element extends HTMLElement = HTMLElement, Handle = Element> extends ElementBindingConfig<Props> {
|
|
13
|
+
createHandle?: ImperativeHandleFactory<Element, Handle>;
|
|
14
|
+
}
|
|
15
|
+
interface ElementBridgeContract<Props extends object, Element extends HTMLElement = HTMLElement, Handle = Element> extends ElementBridgeConfig<Props, Element, Handle> {
|
|
16
|
+
tagName: string;
|
|
17
|
+
}
|
|
18
|
+
interface ElementBindingOptions {
|
|
19
|
+
assignmentErrors?: 'ignore' | 'throw';
|
|
20
|
+
}
|
|
21
|
+
interface ElementBinding<Props extends object> {
|
|
22
|
+
readonly disposed: boolean;
|
|
23
|
+
update(input: Props): void;
|
|
24
|
+
updateProperties(input: Props): void;
|
|
25
|
+
updateAttributes(input: Props): void;
|
|
26
|
+
updateStyles(input: Props): void;
|
|
27
|
+
updateEvents(input: Props): void;
|
|
28
|
+
disconnectEvents(): void;
|
|
29
|
+
dispose(): void;
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/element/create-element-facade.d.ts
|
|
33
|
+
declare function createElementFacade<Element extends HTMLElement, const Keys extends readonly (keyof Element)[]>(keys: Keys): ImperativeHandleFactory<Element, Pick<Element, Keys[number]>>;
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/element/create-element-binding.d.ts
|
|
36
|
+
declare function createElementBinding<Props extends object>(element: HTMLElement, config: ElementBindingConfig<Props>, options?: ElementBindingOptions): ElementBinding<Props>;
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/element/pointer-gesture-session.d.ts
|
|
39
|
+
interface PointerGestureModifiers {
|
|
40
|
+
readonly shiftKey: boolean;
|
|
41
|
+
readonly altKey: boolean;
|
|
42
|
+
readonly ctrlKey: boolean;
|
|
43
|
+
readonly metaKey: boolean;
|
|
44
|
+
}
|
|
45
|
+
interface PointerGestureSnapshot {
|
|
46
|
+
readonly active: boolean;
|
|
47
|
+
readonly pointerId: number | null;
|
|
48
|
+
readonly startX: number;
|
|
49
|
+
readonly startY: number;
|
|
50
|
+
readonly currentX: number;
|
|
51
|
+
readonly currentY: number;
|
|
52
|
+
readonly deltaX: number;
|
|
53
|
+
readonly deltaY: number;
|
|
54
|
+
readonly modifiers: PointerGestureModifiers;
|
|
55
|
+
}
|
|
56
|
+
interface PointerCaptureTargetLike {
|
|
57
|
+
setPointerCapture?(pointerId: number): void;
|
|
58
|
+
releasePointerCapture?(pointerId: number): void;
|
|
59
|
+
}
|
|
60
|
+
interface PointerGestureEventLike {
|
|
61
|
+
readonly pointerId?: number | undefined;
|
|
62
|
+
readonly button?: number | undefined;
|
|
63
|
+
readonly clientX: number;
|
|
64
|
+
readonly clientY: number;
|
|
65
|
+
readonly shiftKey?: boolean | undefined;
|
|
66
|
+
readonly altKey?: boolean | undefined;
|
|
67
|
+
readonly ctrlKey?: boolean | undefined;
|
|
68
|
+
readonly metaKey?: boolean | undefined;
|
|
69
|
+
readonly currentTarget?: PointerCaptureTargetLike | null | undefined;
|
|
70
|
+
}
|
|
71
|
+
interface PointerGestureKeyEventLike {
|
|
72
|
+
readonly key: string;
|
|
73
|
+
preventDefault?(): void;
|
|
74
|
+
}
|
|
75
|
+
interface PointerGestureOptions {
|
|
76
|
+
onStart?: ((snapshot: PointerGestureSnapshot) => boolean | void) | undefined;
|
|
77
|
+
onMove?: ((snapshot: PointerGestureSnapshot) => void) | undefined;
|
|
78
|
+
onCommit?: ((snapshot: PointerGestureSnapshot) => void) | undefined;
|
|
79
|
+
onCancel?: ((snapshot: PointerGestureSnapshot, reason?: string) => void) | undefined;
|
|
80
|
+
}
|
|
81
|
+
interface PointerGestureSession {
|
|
82
|
+
start(event: PointerGestureEventLike): boolean;
|
|
83
|
+
move(event: PointerGestureEventLike): boolean;
|
|
84
|
+
commit(event?: PointerGestureEventLike): boolean;
|
|
85
|
+
cancel(reason?: string): boolean;
|
|
86
|
+
handleKeyDown(event: PointerGestureKeyEventLike): boolean;
|
|
87
|
+
isActive(): boolean;
|
|
88
|
+
getSnapshot(): PointerGestureSnapshot;
|
|
89
|
+
dispose(): void;
|
|
90
|
+
}
|
|
91
|
+
declare function createPointerGestureSession(options?: PointerGestureOptions): PointerGestureSession;
|
|
92
|
+
//#endregion
|
|
93
|
+
//#region src/element/roving-focus.d.ts
|
|
94
|
+
type RovingFocusOrientation = 'horizontal' | 'vertical' | 'both';
|
|
95
|
+
interface RovingFocusItem {
|
|
96
|
+
readonly id: string;
|
|
97
|
+
readonly disabled?: boolean | undefined;
|
|
98
|
+
}
|
|
99
|
+
interface RovingFocusKeyEventLike {
|
|
100
|
+
readonly key: string;
|
|
101
|
+
preventDefault?(): void;
|
|
102
|
+
}
|
|
103
|
+
interface RovingFocusOptions {
|
|
104
|
+
readonly orientation?: RovingFocusOrientation | undefined;
|
|
105
|
+
readonly loop?: boolean | undefined;
|
|
106
|
+
getItems(): readonly RovingFocusItem[];
|
|
107
|
+
getActiveId(): string | null | undefined;
|
|
108
|
+
onFocusChange?: ((nextId: string) => void) | undefined;
|
|
109
|
+
}
|
|
110
|
+
interface RovingFocusController {
|
|
111
|
+
getTabIndex(itemId: string): 0 | -1;
|
|
112
|
+
handleKeyDown(currentId: string, event: RovingFocusKeyEventLike): string | null;
|
|
113
|
+
}
|
|
114
|
+
declare function createRovingFocusController(options: RovingFocusOptions): RovingFocusController;
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region src/element/sync-action-pipeline.d.ts
|
|
117
|
+
interface SyncGuardController<TPayload = unknown> {
|
|
118
|
+
abort(reason?: string): void;
|
|
119
|
+
modifyPayload(updater: TPayload | ((prev: TPayload) => TPayload)): void;
|
|
120
|
+
getPayload(): TPayload;
|
|
121
|
+
}
|
|
122
|
+
interface SyncResultController<TPayload = unknown, TResult = unknown> extends SyncGuardController<TPayload> {
|
|
123
|
+
setResult(value: TResult): void;
|
|
124
|
+
getResult(): TResult | undefined;
|
|
125
|
+
}
|
|
126
|
+
interface SyncObserverMeta<TResult = unknown> {
|
|
127
|
+
readonly success: boolean;
|
|
128
|
+
readonly aborted: boolean;
|
|
129
|
+
readonly abortReason?: string | undefined;
|
|
130
|
+
readonly result: TResult | undefined;
|
|
131
|
+
readonly errors: readonly unknown[];
|
|
132
|
+
}
|
|
133
|
+
interface SyncDispatchOutcome<TPayload = unknown, TResult = unknown> {
|
|
134
|
+
readonly success: boolean;
|
|
135
|
+
readonly aborted: boolean;
|
|
136
|
+
readonly abortReason?: string | undefined;
|
|
137
|
+
readonly payload: TPayload;
|
|
138
|
+
readonly result: TResult | undefined;
|
|
139
|
+
readonly errors: readonly unknown[];
|
|
140
|
+
}
|
|
141
|
+
interface SyncHandlerConfig {
|
|
142
|
+
readonly priority?: number;
|
|
143
|
+
readonly id?: string;
|
|
144
|
+
readonly once?: boolean;
|
|
145
|
+
}
|
|
146
|
+
interface SyncObserverConfig extends SyncHandlerConfig {
|
|
147
|
+
readonly when?: 'success' | 'failure' | 'always';
|
|
148
|
+
}
|
|
149
|
+
interface SyncActionPipeline<TActions extends Record<string, unknown> = Record<string, unknown>> {
|
|
150
|
+
readonly name: string;
|
|
151
|
+
registerGuard<K extends keyof TActions & string>(action: K, handler: (payload: TActions[K], controller: SyncGuardController<TActions[K]>) => void, config?: SyncHandlerConfig): () => void;
|
|
152
|
+
register<K extends keyof TActions & string, TResult = unknown>(action: K, handler: (payload: TActions[K], controller: SyncResultController<TActions[K], TResult>) => TResult | undefined, config?: SyncHandlerConfig): () => void;
|
|
153
|
+
registerObserver<K extends keyof TActions & string, TResult = unknown>(action: K, handler: (payload: TActions[K], meta: SyncObserverMeta<TResult>) => void, config?: SyncObserverConfig): () => void;
|
|
154
|
+
dispatch<K extends keyof TActions & string, TResult = unknown>(action: K, payload?: TActions[K]): SyncDispatchOutcome<TActions[K], TResult>;
|
|
155
|
+
destroy(): void;
|
|
156
|
+
}
|
|
157
|
+
declare function createSyncActionPipeline<TActions extends Record<string, unknown> = Record<string, unknown>>(name: string): SyncActionPipeline<TActions>;
|
|
158
|
+
//#endregion
|
|
159
|
+
//#region src/element/to-react-part-props.d.ts
|
|
160
|
+
declare function toReactPartProps<Props extends object>(snapshot: Props, config?: ElementBindingConfig<Props>): Record<string, unknown>;
|
|
161
|
+
//#endregion
|
|
162
|
+
export { ElementBridgeContract as A, createPointerGestureSession as C, ElementBindingConfig as D, ElementBinding as E, ElementBindingOptions as O, PointerGestureSnapshot as S, createElementFacade as T, PointerGestureEventLike as _, SyncHandlerConfig as a, PointerGestureOptions as b, SyncResultController as c, RovingFocusItem as d, RovingFocusKeyEventLike as f, PointerCaptureTargetLike as g, createRovingFocusController as h, SyncGuardController as i, ImperativeHandleFactory as j, ElementBridgeConfig as k, createSyncActionPipeline as l, RovingFocusOrientation as m, SyncActionPipeline as n, SyncObserverConfig as o, RovingFocusOptions as p, SyncDispatchOutcome as r, SyncObserverMeta as s, toReactPartProps as t, RovingFocusController as u, PointerGestureKeyEventLike as v, createElementBinding as w, PointerGestureSession as x, PointerGestureModifiers as y };
|
|
163
|
+
//# sourceMappingURL=element-DPioFL7C.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element-DPioFL7C.d.cts","names":[],"sources":["../src/facade/types.ts","../src/element/contracts.ts","../src/element/create-element-facade.ts","../src/element/create-element-binding.ts","../src/element/pointer-gesture-session.ts","../src/element/roving-focus.ts","../src/element/sync-action-pipeline.ts","../src/element/to-react-part-props.ts"],"mappings":";KACY,oBAAoB,uBAAuB,WACpD,iBAAiB,kBAAkB;;;KCA1B,wBAAwB,gBAAgB,aAAa,UAAU,oBAAoB,SAAS;UAGvF,qBAAqB;EACpC,6BAA6B;EAC7B,aAAa,QAAQ,aAAa;EAClC,SAAS,QAAQ,aAAa;EAC9B,SAAS;;UAGM,oBAAoB,sBAAsB,gBAAgB,cAAc,aAAa,SAAS,iBACrG,qBAAqB;EAC7B,eAAe,wBAAwB,SAAS;;UAGjC,sBAAsB,sBAAsB,gBAAgB,cAAc,aAAa,SAAS,iBACvG,oBAAoB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M,mBACf,iBAAiB,0BAA0B;WAElC;EACT,cAAc,gBAAgB,mBAC5B,QAAQ,GACR,UAAU,SAAS,SAAS,IAAI,YAAY,oBAAoB,SAAS,cACzE,SAAS;EAEX,SAAS,gBAAgB,mBAAmB,mBAC1C,QAAQ,GACR,UACE,SAAS,SAAS,IAClB,YAAY,qBAAqB,SAAS,IAAI,aAC3C,qBACL,SAAS;EAEX,iBAAiB,gBAAgB,mBAAmB,mBAClD,QAAQ,GACR,UAAU,SAAS,SAAS,IAAI,MAAM,iBAAiB,mBACvD,SAAS;EAEX,SAAS,gBAAgB,mBAAmB,mBAC1C,QAAQ,GACR,UAAU,SAAS,KAClB,oBAAoB,SAAS,IAAI;EACpC;;iBAac,yBACd,iBAAiB,0BAA0B,yBAC3C,eAAe,mBAAmB;;;iBChEpB,iBAAiB,sBAC/B,UAAU,OACV,SAAQ,qBAAqB,SAC5B"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
//#region src/facade/types.d.ts
|
|
2
|
+
type PublicHandleFactory<Target extends object, Handle> = (getTarget: () => Target | null) => Handle;
|
|
3
|
+
//#endregion
|
|
4
|
+
//#region src/element/contracts.d.ts
|
|
5
|
+
type ImperativeHandleFactory<Element extends HTMLElement, Handle> = PublicHandleFactory<Element, Handle>;
|
|
6
|
+
interface ElementBindingConfig<Props extends object> {
|
|
7
|
+
properties?: readonly (keyof Props)[];
|
|
8
|
+
attributes?: Partial<Record<keyof Props & string, string>>;
|
|
9
|
+
styles?: Partial<Record<keyof Props & string, string>>;
|
|
10
|
+
events?: Record<string, string>;
|
|
11
|
+
}
|
|
12
|
+
interface ElementBridgeConfig<Props extends object, Element extends HTMLElement = HTMLElement, Handle = Element> extends ElementBindingConfig<Props> {
|
|
13
|
+
createHandle?: ImperativeHandleFactory<Element, Handle>;
|
|
14
|
+
}
|
|
15
|
+
interface ElementBridgeContract<Props extends object, Element extends HTMLElement = HTMLElement, Handle = Element> extends ElementBridgeConfig<Props, Element, Handle> {
|
|
16
|
+
tagName: string;
|
|
17
|
+
}
|
|
18
|
+
interface ElementBindingOptions {
|
|
19
|
+
assignmentErrors?: 'ignore' | 'throw';
|
|
20
|
+
}
|
|
21
|
+
interface ElementBinding<Props extends object> {
|
|
22
|
+
readonly disposed: boolean;
|
|
23
|
+
update(input: Props): void;
|
|
24
|
+
updateProperties(input: Props): void;
|
|
25
|
+
updateAttributes(input: Props): void;
|
|
26
|
+
updateStyles(input: Props): void;
|
|
27
|
+
updateEvents(input: Props): void;
|
|
28
|
+
disconnectEvents(): void;
|
|
29
|
+
dispose(): void;
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/element/create-element-facade.d.ts
|
|
33
|
+
declare function createElementFacade<Element extends HTMLElement, const Keys extends readonly (keyof Element)[]>(keys: Keys): ImperativeHandleFactory<Element, Pick<Element, Keys[number]>>;
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/element/create-element-binding.d.ts
|
|
36
|
+
declare function createElementBinding<Props extends object>(element: HTMLElement, config: ElementBindingConfig<Props>, options?: ElementBindingOptions): ElementBinding<Props>;
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/element/pointer-gesture-session.d.ts
|
|
39
|
+
interface PointerGestureModifiers {
|
|
40
|
+
readonly shiftKey: boolean;
|
|
41
|
+
readonly altKey: boolean;
|
|
42
|
+
readonly ctrlKey: boolean;
|
|
43
|
+
readonly metaKey: boolean;
|
|
44
|
+
}
|
|
45
|
+
interface PointerGestureSnapshot {
|
|
46
|
+
readonly active: boolean;
|
|
47
|
+
readonly pointerId: number | null;
|
|
48
|
+
readonly startX: number;
|
|
49
|
+
readonly startY: number;
|
|
50
|
+
readonly currentX: number;
|
|
51
|
+
readonly currentY: number;
|
|
52
|
+
readonly deltaX: number;
|
|
53
|
+
readonly deltaY: number;
|
|
54
|
+
readonly modifiers: PointerGestureModifiers;
|
|
55
|
+
}
|
|
56
|
+
interface PointerCaptureTargetLike {
|
|
57
|
+
setPointerCapture?(pointerId: number): void;
|
|
58
|
+
releasePointerCapture?(pointerId: number): void;
|
|
59
|
+
}
|
|
60
|
+
interface PointerGestureEventLike {
|
|
61
|
+
readonly pointerId?: number | undefined;
|
|
62
|
+
readonly button?: number | undefined;
|
|
63
|
+
readonly clientX: number;
|
|
64
|
+
readonly clientY: number;
|
|
65
|
+
readonly shiftKey?: boolean | undefined;
|
|
66
|
+
readonly altKey?: boolean | undefined;
|
|
67
|
+
readonly ctrlKey?: boolean | undefined;
|
|
68
|
+
readonly metaKey?: boolean | undefined;
|
|
69
|
+
readonly currentTarget?: PointerCaptureTargetLike | null | undefined;
|
|
70
|
+
}
|
|
71
|
+
interface PointerGestureKeyEventLike {
|
|
72
|
+
readonly key: string;
|
|
73
|
+
preventDefault?(): void;
|
|
74
|
+
}
|
|
75
|
+
interface PointerGestureOptions {
|
|
76
|
+
onStart?: ((snapshot: PointerGestureSnapshot) => boolean | void) | undefined;
|
|
77
|
+
onMove?: ((snapshot: PointerGestureSnapshot) => void) | undefined;
|
|
78
|
+
onCommit?: ((snapshot: PointerGestureSnapshot) => void) | undefined;
|
|
79
|
+
onCancel?: ((snapshot: PointerGestureSnapshot, reason?: string) => void) | undefined;
|
|
80
|
+
}
|
|
81
|
+
interface PointerGestureSession {
|
|
82
|
+
start(event: PointerGestureEventLike): boolean;
|
|
83
|
+
move(event: PointerGestureEventLike): boolean;
|
|
84
|
+
commit(event?: PointerGestureEventLike): boolean;
|
|
85
|
+
cancel(reason?: string): boolean;
|
|
86
|
+
handleKeyDown(event: PointerGestureKeyEventLike): boolean;
|
|
87
|
+
isActive(): boolean;
|
|
88
|
+
getSnapshot(): PointerGestureSnapshot;
|
|
89
|
+
dispose(): void;
|
|
90
|
+
}
|
|
91
|
+
declare function createPointerGestureSession(options?: PointerGestureOptions): PointerGestureSession;
|
|
92
|
+
//#endregion
|
|
93
|
+
//#region src/element/roving-focus.d.ts
|
|
94
|
+
type RovingFocusOrientation = 'horizontal' | 'vertical' | 'both';
|
|
95
|
+
interface RovingFocusItem {
|
|
96
|
+
readonly id: string;
|
|
97
|
+
readonly disabled?: boolean | undefined;
|
|
98
|
+
}
|
|
99
|
+
interface RovingFocusKeyEventLike {
|
|
100
|
+
readonly key: string;
|
|
101
|
+
preventDefault?(): void;
|
|
102
|
+
}
|
|
103
|
+
interface RovingFocusOptions {
|
|
104
|
+
readonly orientation?: RovingFocusOrientation | undefined;
|
|
105
|
+
readonly loop?: boolean | undefined;
|
|
106
|
+
getItems(): readonly RovingFocusItem[];
|
|
107
|
+
getActiveId(): string | null | undefined;
|
|
108
|
+
onFocusChange?: ((nextId: string) => void) | undefined;
|
|
109
|
+
}
|
|
110
|
+
interface RovingFocusController {
|
|
111
|
+
getTabIndex(itemId: string): 0 | -1;
|
|
112
|
+
handleKeyDown(currentId: string, event: RovingFocusKeyEventLike): string | null;
|
|
113
|
+
}
|
|
114
|
+
declare function createRovingFocusController(options: RovingFocusOptions): RovingFocusController;
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region src/element/sync-action-pipeline.d.ts
|
|
117
|
+
interface SyncGuardController<TPayload = unknown> {
|
|
118
|
+
abort(reason?: string): void;
|
|
119
|
+
modifyPayload(updater: TPayload | ((prev: TPayload) => TPayload)): void;
|
|
120
|
+
getPayload(): TPayload;
|
|
121
|
+
}
|
|
122
|
+
interface SyncResultController<TPayload = unknown, TResult = unknown> extends SyncGuardController<TPayload> {
|
|
123
|
+
setResult(value: TResult): void;
|
|
124
|
+
getResult(): TResult | undefined;
|
|
125
|
+
}
|
|
126
|
+
interface SyncObserverMeta<TResult = unknown> {
|
|
127
|
+
readonly success: boolean;
|
|
128
|
+
readonly aborted: boolean;
|
|
129
|
+
readonly abortReason?: string | undefined;
|
|
130
|
+
readonly result: TResult | undefined;
|
|
131
|
+
readonly errors: readonly unknown[];
|
|
132
|
+
}
|
|
133
|
+
interface SyncDispatchOutcome<TPayload = unknown, TResult = unknown> {
|
|
134
|
+
readonly success: boolean;
|
|
135
|
+
readonly aborted: boolean;
|
|
136
|
+
readonly abortReason?: string | undefined;
|
|
137
|
+
readonly payload: TPayload;
|
|
138
|
+
readonly result: TResult | undefined;
|
|
139
|
+
readonly errors: readonly unknown[];
|
|
140
|
+
}
|
|
141
|
+
interface SyncHandlerConfig {
|
|
142
|
+
readonly priority?: number;
|
|
143
|
+
readonly id?: string;
|
|
144
|
+
readonly once?: boolean;
|
|
145
|
+
}
|
|
146
|
+
interface SyncObserverConfig extends SyncHandlerConfig {
|
|
147
|
+
readonly when?: 'success' | 'failure' | 'always';
|
|
148
|
+
}
|
|
149
|
+
interface SyncActionPipeline<TActions extends Record<string, unknown> = Record<string, unknown>> {
|
|
150
|
+
readonly name: string;
|
|
151
|
+
registerGuard<K extends keyof TActions & string>(action: K, handler: (payload: TActions[K], controller: SyncGuardController<TActions[K]>) => void, config?: SyncHandlerConfig): () => void;
|
|
152
|
+
register<K extends keyof TActions & string, TResult = unknown>(action: K, handler: (payload: TActions[K], controller: SyncResultController<TActions[K], TResult>) => TResult | undefined, config?: SyncHandlerConfig): () => void;
|
|
153
|
+
registerObserver<K extends keyof TActions & string, TResult = unknown>(action: K, handler: (payload: TActions[K], meta: SyncObserverMeta<TResult>) => void, config?: SyncObserverConfig): () => void;
|
|
154
|
+
dispatch<K extends keyof TActions & string, TResult = unknown>(action: K, payload?: TActions[K]): SyncDispatchOutcome<TActions[K], TResult>;
|
|
155
|
+
destroy(): void;
|
|
156
|
+
}
|
|
157
|
+
declare function createSyncActionPipeline<TActions extends Record<string, unknown> = Record<string, unknown>>(name: string): SyncActionPipeline<TActions>;
|
|
158
|
+
//#endregion
|
|
159
|
+
//#region src/element/to-react-part-props.d.ts
|
|
160
|
+
declare function toReactPartProps<Props extends object>(snapshot: Props, config?: ElementBindingConfig<Props>): Record<string, unknown>;
|
|
161
|
+
//#endregion
|
|
162
|
+
export { ElementBridgeContract as A, createPointerGestureSession as C, ElementBindingConfig as D, ElementBinding as E, ElementBindingOptions as O, PointerGestureSnapshot as S, createElementFacade as T, PointerGestureEventLike as _, SyncHandlerConfig as a, PointerGestureOptions as b, SyncResultController as c, RovingFocusItem as d, RovingFocusKeyEventLike as f, PointerCaptureTargetLike as g, createRovingFocusController as h, SyncGuardController as i, ImperativeHandleFactory as j, ElementBridgeConfig as k, createSyncActionPipeline as l, RovingFocusOrientation as m, SyncActionPipeline as n, SyncObserverConfig as o, RovingFocusOptions as p, SyncDispatchOutcome as r, SyncObserverMeta as s, toReactPartProps as t, RovingFocusController as u, PointerGestureKeyEventLike as v, createElementBinding as w, PointerGestureSession as x, PointerGestureModifiers as y };
|
|
163
|
+
//# sourceMappingURL=element-DPioFL7C.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element-DPioFL7C.d.ts","names":[],"sources":["../src/facade/types.ts","../src/element/contracts.ts","../src/element/create-element-facade.ts","../src/element/create-element-binding.ts","../src/element/pointer-gesture-session.ts","../src/element/roving-focus.ts","../src/element/sync-action-pipeline.ts","../src/element/to-react-part-props.ts"],"mappings":";KACY,oBAAoB,uBAAuB,WACpD,iBAAiB,kBAAkB;;;KCA1B,wBAAwB,gBAAgB,aAAa,UAAU,oBAAoB,SAAS;UAGvF,qBAAqB;EACpC,6BAA6B;EAC7B,aAAa,QAAQ,aAAa;EAClC,SAAS,QAAQ,aAAa;EAC9B,SAAS;;UAGM,oBAAoB,sBAAsB,gBAAgB,cAAc,aAAa,SAAS,iBACrG,qBAAqB;EAC7B,eAAe,wBAAwB,SAAS;;UAGjC,sBAAsB,sBAAsB,gBAAgB,cAAc,aAAa,SAAS,iBACvG,oBAAoB,OAAO,SAAS;EAC5C;;UAGe;EACf;;UAIe,eAAe;WACrB;EAET,OAAO,OAAO;EACd,iBAAiB,OAAO;EACxB,iBAAiB,OAAO;EACxB,aAAa,OAAO;EACpB,aAAa,OAAO;EAEpB;EAEA;;;;iBClCc,oBAAoB,gBAAgB,mBAAmB,6BAA6B,YAClG,MAAM,OACL,wBAAwB,SAAS,KAAK,SAAS;;;iBCCl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BAAiB,gBAAgB,mBAAmB,mBAClD,QAAQ,GACR,UAAU,SAAS,SAAS,IAAI,MAAM,iBAAiB,mBACvD,SAAS;EAEX,SAAS,gBAAgB,mBAAmB,mBAC1C,QAAQ,GACR,UAAU,SAAS,KAClB,oBAAoB,SAAS,IAAI;EACpC;;iBAac,yBACd,iBAAiB,0BAA0B,yBAC3C,eAAe,mBAAmB;;;iBChEpB,iBAAiB,sBAC/B,UAAU,OACV,SAAQ,qBAAqB,SAC5B"}
|
package/dist/element-react.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_element = require('./element-
|
|
2
|
+
const require_element = require('./element-BRlY61kW.cjs');
|
|
3
3
|
|
|
4
4
|
//#region src/bridges/react-element/create-react-element-bridge.ts
|
|
5
5
|
function assignRef(ref, value) {
|
|
@@ -12,10 +12,16 @@ function createReactElementBridge(React, options, assignmentErrors = "ignore") {
|
|
|
12
12
|
const { tagName, createHandle } = options;
|
|
13
13
|
const properties = Array.from(new Set(options.properties ?? []));
|
|
14
14
|
const propertySet = new Set(properties);
|
|
15
|
+
const attributes = { ...options.attributes };
|
|
16
|
+
const attributeProps = new Set(Object.keys(attributes));
|
|
17
|
+
const styles = { ...options.styles };
|
|
18
|
+
const styleProps = new Set(Object.keys(styles));
|
|
15
19
|
const events = { ...options.events };
|
|
16
20
|
const eventProps = new Set(Object.keys(events));
|
|
17
21
|
const config = {
|
|
18
22
|
properties,
|
|
23
|
+
attributes,
|
|
24
|
+
styles,
|
|
19
25
|
events
|
|
20
26
|
};
|
|
21
27
|
const Bridge = React.forwardRef(function ElementBridge(props, forwardedRef) {
|
|
@@ -66,7 +72,7 @@ function createReactElementBridge(React, options, assignmentErrors = "ignore") {
|
|
|
66
72
|
}, []);
|
|
67
73
|
const domProps = { ref };
|
|
68
74
|
for (const [key, value] of Object.entries(props)) {
|
|
69
|
-
if (propertySet.has(key) || eventProps.has(key)) continue;
|
|
75
|
+
if (propertySet.has(key) || attributeProps.has(key) || styleProps.has(key) || eventProps.has(key)) continue;
|
|
70
76
|
domProps[key === "className" ? "class" : key === "htmlFor" ? "for" : key] = value;
|
|
71
77
|
}
|
|
72
78
|
return React.createElement(tagName, domProps);
|
|
@@ -78,4 +84,8 @@ function createReactElementBridge(React, options, assignmentErrors = "ignore") {
|
|
|
78
84
|
//#endregion
|
|
79
85
|
exports.createElementBinding = require_element.createElementBinding;
|
|
80
86
|
exports.createElementFacade = require_element.createElementFacade;
|
|
81
|
-
exports.
|
|
87
|
+
exports.createPointerGestureSession = require_element.createPointerGestureSession;
|
|
88
|
+
exports.createReactElementBridge = createReactElementBridge;
|
|
89
|
+
exports.createRovingFocusController = require_element.createRovingFocusController;
|
|
90
|
+
exports.createSyncActionPipeline = require_element.createSyncActionPipeline;
|
|
91
|
+
exports.toReactPartProps = require_element.toReactPartProps;
|
package/dist/element-react.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as ElementBridgeContract, C as createPointerGestureSession, D as ElementBindingConfig, E as ElementBinding, O as ElementBindingOptions, S as PointerGestureSnapshot, T as createElementFacade, _ as PointerGestureEventLike, a as SyncHandlerConfig, b as PointerGestureOptions, c as SyncResultController, d as RovingFocusItem, f as RovingFocusKeyEventLike, g as PointerCaptureTargetLike, h as createRovingFocusController, i as SyncGuardController, j as ImperativeHandleFactory, k as ElementBridgeConfig, l as createSyncActionPipeline, m as RovingFocusOrientation, n as SyncActionPipeline, o as SyncObserverConfig, p as RovingFocusOptions, r as SyncDispatchOutcome, s as SyncObserverMeta, t as toReactPartProps, u as RovingFocusController, v as PointerGestureKeyEventLike, w as createElementBinding, x as PointerGestureSession, y as PointerGestureModifiers } from "./element-DPioFL7C.cjs";
|
|
2
2
|
import { t as PublicActionMethods } from "./public-action-methods-C_ppItRr.cjs";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
//#region src/bridges/react-element/types.d.ts
|
|
@@ -7,5 +7,5 @@ type ReactElementComponent<Props, Element extends HTMLElement, Handle = Element>
|
|
|
7
7
|
//#region src/bridges/react-element/create-react-element-bridge.d.ts
|
|
8
8
|
export declare function createReactElementBridge<Props extends object = Record<string, unknown>, Element extends HTMLElement = HTMLElement, Handle = Element>(React: typeof import('react'), options: ElementBridgeContract<Props, Element, Handle>, assignmentErrors?: 'ignore' | 'throw'): ReactElementComponent<Props, Element, Handle>;
|
|
9
9
|
//#endregion
|
|
10
|
-
export { type ElementBinding, type ElementBindingConfig, type ElementBindingOptions, type ElementBridgeConfig, type ElementBridgeContract, type ImperativeHandleFactory, type PublicActionMethods, type ReactElementComponent, createElementBinding, createElementFacade };
|
|
10
|
+
export { type ElementBinding, type ElementBindingConfig, type ElementBindingOptions, type ElementBridgeConfig, type ElementBridgeContract, type ImperativeHandleFactory, type PointerCaptureTargetLike, type PointerGestureEventLike, type PointerGestureKeyEventLike, type PointerGestureModifiers, type PointerGestureOptions, type PointerGestureSession, type PointerGestureSnapshot, type PublicActionMethods, type ReactElementComponent, type RovingFocusController, type RovingFocusItem, type RovingFocusKeyEventLike, type RovingFocusOptions, type RovingFocusOrientation, type SyncActionPipeline, type SyncDispatchOutcome, type SyncGuardController, type SyncHandlerConfig, type SyncObserverConfig, type SyncObserverMeta, type SyncResultController, createElementBinding, createElementFacade, createPointerGestureSession, createRovingFocusController, createSyncActionPipeline, toReactPartProps };
|
|
11
11
|
//# sourceMappingURL=element-react.d.cts.map
|
package/dist/element-react.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as ElementBridgeContract, C as createPointerGestureSession, D as ElementBindingConfig, E as ElementBinding, O as ElementBindingOptions, S as PointerGestureSnapshot, T as createElementFacade, _ as PointerGestureEventLike, a as SyncHandlerConfig, b as PointerGestureOptions, c as SyncResultController, d as RovingFocusItem, f as RovingFocusKeyEventLike, g as PointerCaptureTargetLike, h as createRovingFocusController, i as SyncGuardController, j as ImperativeHandleFactory, k as ElementBridgeConfig, l as createSyncActionPipeline, m as RovingFocusOrientation, n as SyncActionPipeline, o as SyncObserverConfig, p as RovingFocusOptions, r as SyncDispatchOutcome, s as SyncObserverMeta, t as toReactPartProps, u as RovingFocusController, v as PointerGestureKeyEventLike, w as createElementBinding, x as PointerGestureSession, y as PointerGestureModifiers } from "./element-DPioFL7C.js";
|
|
2
2
|
import { t as PublicActionMethods } from "./public-action-methods-C_ppItRr.js";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
//#region src/bridges/react-element/types.d.ts
|
|
@@ -7,5 +7,5 @@ type ReactElementComponent<Props, Element extends HTMLElement, Handle = Element>
|
|
|
7
7
|
//#region src/bridges/react-element/create-react-element-bridge.d.ts
|
|
8
8
|
export declare function createReactElementBridge<Props extends object = Record<string, unknown>, Element extends HTMLElement = HTMLElement, Handle = Element>(React: typeof import('react'), options: ElementBridgeContract<Props, Element, Handle>, assignmentErrors?: 'ignore' | 'throw'): ReactElementComponent<Props, Element, Handle>;
|
|
9
9
|
//#endregion
|
|
10
|
-
export { type ElementBinding, type ElementBindingConfig, type ElementBindingOptions, type ElementBridgeConfig, type ElementBridgeContract, type ImperativeHandleFactory, type PublicActionMethods, type ReactElementComponent, createElementBinding, createElementFacade };
|
|
10
|
+
export { type ElementBinding, type ElementBindingConfig, type ElementBindingOptions, type ElementBridgeConfig, type ElementBridgeContract, type ImperativeHandleFactory, type PointerCaptureTargetLike, type PointerGestureEventLike, type PointerGestureKeyEventLike, type PointerGestureModifiers, type PointerGestureOptions, type PointerGestureSession, type PointerGestureSnapshot, type PublicActionMethods, type ReactElementComponent, type RovingFocusController, type RovingFocusItem, type RovingFocusKeyEventLike, type RovingFocusOptions, type RovingFocusOrientation, type SyncActionPipeline, type SyncDispatchOutcome, type SyncGuardController, type SyncHandlerConfig, type SyncObserverConfig, type SyncObserverMeta, type SyncResultController, createElementBinding, createElementFacade, createPointerGestureSession, createRovingFocusController, createSyncActionPipeline, toReactPartProps };
|
|
11
11
|
//# sourceMappingURL=element-react.d.ts.map
|
package/dist/element-react.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as createElementFacade, t as
|
|
1
|
+
import { a as createElementBinding, i as createPointerGestureSession, n as createSyncActionPipeline, o as createElementFacade, r as createRovingFocusController, t as toReactPartProps } from "./element-BTaXgo7n.js";
|
|
2
2
|
|
|
3
3
|
//#region src/bridges/react-element/create-react-element-bridge.ts
|
|
4
4
|
function assignRef(ref, value) {
|
|
@@ -11,10 +11,16 @@ function createReactElementBridge(React, options, assignmentErrors = "ignore") {
|
|
|
11
11
|
const { tagName, createHandle } = options;
|
|
12
12
|
const properties = Array.from(new Set(options.properties ?? []));
|
|
13
13
|
const propertySet = new Set(properties);
|
|
14
|
+
const attributes = { ...options.attributes };
|
|
15
|
+
const attributeProps = new Set(Object.keys(attributes));
|
|
16
|
+
const styles = { ...options.styles };
|
|
17
|
+
const styleProps = new Set(Object.keys(styles));
|
|
14
18
|
const events = { ...options.events };
|
|
15
19
|
const eventProps = new Set(Object.keys(events));
|
|
16
20
|
const config = {
|
|
17
21
|
properties,
|
|
22
|
+
attributes,
|
|
23
|
+
styles,
|
|
18
24
|
events
|
|
19
25
|
};
|
|
20
26
|
const Bridge = React.forwardRef(function ElementBridge(props, forwardedRef) {
|
|
@@ -65,7 +71,7 @@ function createReactElementBridge(React, options, assignmentErrors = "ignore") {
|
|
|
65
71
|
}, []);
|
|
66
72
|
const domProps = { ref };
|
|
67
73
|
for (const [key, value] of Object.entries(props)) {
|
|
68
|
-
if (propertySet.has(key) || eventProps.has(key)) continue;
|
|
74
|
+
if (propertySet.has(key) || attributeProps.has(key) || styleProps.has(key) || eventProps.has(key)) continue;
|
|
69
75
|
domProps[key === "className" ? "class" : key === "htmlFor" ? "for" : key] = value;
|
|
70
76
|
}
|
|
71
77
|
return React.createElement(tagName, domProps);
|
|
@@ -75,5 +81,5 @@ function createReactElementBridge(React, options, assignmentErrors = "ignore") {
|
|
|
75
81
|
}
|
|
76
82
|
|
|
77
83
|
//#endregion
|
|
78
|
-
export { createElementBinding, createElementFacade, createReactElementBridge };
|
|
84
|
+
export { createElementBinding, createElementFacade, createPointerGestureSession, createReactElementBridge, createRovingFocusController, createSyncActionPipeline, toReactPartProps };
|
|
79
85
|
//# sourceMappingURL=element-react.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element-react.js","names":[],"sources":["../src/bridges/react-element/create-react-element-bridge.ts"],"sourcesContent":["import type * as React from 'react';\nimport type { ElementBinding, ElementBridgeContract } from '../../element/contracts.js';\nimport { createElementBinding } from '../../element/create-element-binding.js';\nimport type { ReactElementComponent } from './types.js';\n\nfunction assignRef<T>(ref: React.ForwardedRef<T>, value: T | null): void {\n if (typeof ref === 'function') ref(value);\n else if (ref) (ref as React.MutableRefObject<T | null>).current = value;\n}\n\n/** Opt-in host adapter; inject the consuming runtime rather than importing another hook dispatcher. */\nexport function createReactElementBridge<Props extends object = Record<string, unknown>, Element extends HTMLElement = HTMLElement, Handle = Element>(\n React: typeof import('react'),\n options: ElementBridgeContract<Props, Element, Handle>,\n assignmentErrors: 'ignore' | 'throw' = 'ignore',\n): ReactElementComponent<Props, Element, Handle> {\n const useLayout = typeof window === 'undefined' ? React.useEffect : React.useLayoutEffect;\n const { tagName, createHandle } = options;\n const properties = Array.from(new Set(options.properties ?? []));\n const propertySet = new Set<PropertyKey>(properties);\n const events = { ...options.events };\n const eventProps = new Set(Object.keys(events));\n const config = { properties, events };\n\n const Bridge = React.forwardRef<Handle, Props & Omit<React.HTMLAttributes<Element>, keyof Props>>(\n function ElementBridge(props, forwardedRef) {\n const elementRef = React.useRef<Element | null>(null);\n const [element, setElement] = React.useState<Element | null>(null);\n const bindingRef = React.useRef<{ element: Element; binding: ElementBinding<Props> } | null>(null);\n const rawForwardedRef = React.useRef<React.ForwardedRef<Handle>>(forwardedRef);\n const ref = React.useCallback((node: Element | null) => {\n if (bindingRef.current && bindingRef.current.element !== node) {\n bindingRef.current.binding.dispose();\n bindingRef.current = null;\n }\n elementRef.current = node;\n if (!createHandle) assignRef(rawForwardedRef.current, node as unknown as Handle | null);\n setElement(node);\n }, []);\n React.useImperativeHandle(\n createHandle ? forwardedRef : null,\n () => (createHandle ? createHandle(() => elementRef.current) : null) as unknown as Handle,\n [createHandle],\n );\n\n useLayout(() => {\n if (createHandle || rawForwardedRef.current === forwardedRef) return;\n const previousRef = rawForwardedRef.current;\n rawForwardedRef.current = forwardedRef;\n assignRef(previousRef, null);\n assignRef(forwardedRef, elementRef.current as unknown as Handle | null);\n }, [createHandle, element, forwardedRef]);\n\n useLayout(() => {\n const currentElement = elementRef.current;\n // Callback refs update state during commit. Wait for that state to\n // settle before binding so the initial mount and host replacement do\n // not reconcile the same snapshot against a stale element twice.\n if (!element || !currentElement || element !== currentElement) return;\n if (bindingRef.current?.element !== currentElement) {\n bindingRef.current?.binding.dispose();\n bindingRef.current = {\n element: currentElement,\n binding: createElementBinding<Props>(currentElement, config, { assignmentErrors }),\n };\n }\n bindingRef.current.binding.update(props as Props);\n }, [element, props]);\n\n React.useEffect(() => {\n const current = bindingRef.current;\n const currentElement = elementRef.current;\n if (currentElement && current?.element === currentElement) current.binding.updateEvents(props as Props);\n });\n\n // Effect replay only disconnects listeners. Terminal disposal here would\n // break StrictMode and lose the property-omission ledger on reconnect.\n React.useEffect(() => () => { bindingRef.current?.binding.disconnectEvents(); }, []);\n\n const domProps: Record<string, unknown> = { ref };\n for (const [key, value] of Object.entries(props)) {\n if (propertySet.has(key) || eventProps.has(key)) continue;\n domProps[key === 'className' ? 'class' : key === 'htmlFor' ? 'for' : key] = value;\n }\n return React.createElement(tagName, domProps);\n },\n );\n Bridge.displayName = `ElementBridge(${tagName})`;\n return Bridge;\n}\n"],"mappings":";;;AAKA,SAAS,UAAa,KAA4B,OAAuB;CACvE,IAAI,OAAO,QAAQ,YAAY,IAAI,KAAK;MACnC,IAAI,KAAK,AAAC,IAAyC,UAAU;AACpE;;AAGA,SAAgB,yBACd,OACA,SACA,mBAAuC,UACQ;CAC/C,MAAM,YAAY,OAAO,WAAW,cAAc,MAAM,YAAY,MAAM;CAC1E,MAAM,EAAE,SAAS,iBAAiB;CAClC,MAAM,aAAa,MAAM,KAAK,IAAI,IAAI,QAAQ,cAAc,CAAC,CAAC,CAAC;CAC/D,MAAM,cAAc,IAAI,IAAiB,UAAU;CACnD,MAAM,SAAS,EAAE,GAAG,QAAQ,OAAO;CACnC,MAAM,aAAa,IAAI,IAAI,OAAO,KAAK,MAAM,CAAC;CAC9C,MAAM,SAAS;EAAE;EAAY;CAAO;
|
|
1
|
+
{"version":3,"file":"element-react.js","names":[],"sources":["../src/bridges/react-element/create-react-element-bridge.ts"],"sourcesContent":["import type * as React from 'react';\nimport type { ElementBinding, ElementBridgeContract } from '../../element/contracts.js';\nimport { createElementBinding } from '../../element/create-element-binding.js';\nimport type { ReactElementComponent } from './types.js';\n\nfunction assignRef<T>(ref: React.ForwardedRef<T>, value: T | null): void {\n if (typeof ref === 'function') ref(value);\n else if (ref) (ref as React.MutableRefObject<T | null>).current = value;\n}\n\n/** Opt-in host adapter; inject the consuming runtime rather than importing another hook dispatcher. */\nexport function createReactElementBridge<Props extends object = Record<string, unknown>, Element extends HTMLElement = HTMLElement, Handle = Element>(\n React: typeof import('react'),\n options: ElementBridgeContract<Props, Element, Handle>,\n assignmentErrors: 'ignore' | 'throw' = 'ignore',\n): ReactElementComponent<Props, Element, Handle> {\n const useLayout = typeof window === 'undefined' ? React.useEffect : React.useLayoutEffect;\n const { tagName, createHandle } = options;\n const properties = Array.from(new Set(options.properties ?? []));\n const propertySet = new Set<PropertyKey>(properties);\n const attributes = { ...options.attributes };\n const attributeProps = new Set(Object.keys(attributes));\n const styles = { ...options.styles };\n const styleProps = new Set(Object.keys(styles));\n const events = { ...options.events };\n const eventProps = new Set(Object.keys(events));\n const config = { properties, attributes, styles, events };\n\n const Bridge = React.forwardRef<Handle, Props & Omit<React.HTMLAttributes<Element>, keyof Props>>(\n function ElementBridge(props, forwardedRef) {\n const elementRef = React.useRef<Element | null>(null);\n const [element, setElement] = React.useState<Element | null>(null);\n const bindingRef = React.useRef<{ element: Element; binding: ElementBinding<Props> } | null>(null);\n const rawForwardedRef = React.useRef<React.ForwardedRef<Handle>>(forwardedRef);\n const ref = React.useCallback((node: Element | null) => {\n if (bindingRef.current && bindingRef.current.element !== node) {\n bindingRef.current.binding.dispose();\n bindingRef.current = null;\n }\n elementRef.current = node;\n if (!createHandle) assignRef(rawForwardedRef.current, node as unknown as Handle | null);\n setElement(node);\n }, []);\n React.useImperativeHandle(\n createHandle ? forwardedRef : null,\n () => (createHandle ? createHandle(() => elementRef.current) : null) as unknown as Handle,\n [createHandle],\n );\n\n useLayout(() => {\n if (createHandle || rawForwardedRef.current === forwardedRef) return;\n const previousRef = rawForwardedRef.current;\n rawForwardedRef.current = forwardedRef;\n assignRef(previousRef, null);\n assignRef(forwardedRef, elementRef.current as unknown as Handle | null);\n }, [createHandle, element, forwardedRef]);\n\n useLayout(() => {\n const currentElement = elementRef.current;\n // Callback refs update state during commit. Wait for that state to\n // settle before binding so the initial mount and host replacement do\n // not reconcile the same snapshot against a stale element twice.\n if (!element || !currentElement || element !== currentElement) return;\n if (bindingRef.current?.element !== currentElement) {\n bindingRef.current?.binding.dispose();\n bindingRef.current = {\n element: currentElement,\n binding: createElementBinding<Props>(currentElement, config, { assignmentErrors }),\n };\n }\n bindingRef.current.binding.update(props as Props);\n }, [element, props]);\n\n React.useEffect(() => {\n const current = bindingRef.current;\n const currentElement = elementRef.current;\n if (currentElement && current?.element === currentElement) current.binding.updateEvents(props as Props);\n });\n\n // Effect replay only disconnects listeners. Terminal disposal here would\n // break StrictMode and lose the property-omission ledger on reconnect.\n React.useEffect(() => () => { bindingRef.current?.binding.disconnectEvents(); }, []);\n\n const domProps: Record<string, unknown> = { ref };\n for (const [key, value] of Object.entries(props)) {\n if (propertySet.has(key) || attributeProps.has(key) || styleProps.has(key) || eventProps.has(key)) continue;\n domProps[key === 'className' ? 'class' : key === 'htmlFor' ? 'for' : key] = value;\n }\n return React.createElement(tagName, domProps);\n },\n );\n Bridge.displayName = `ElementBridge(${tagName})`;\n return Bridge;\n}\n"],"mappings":";;;AAKA,SAAS,UAAa,KAA4B,OAAuB;CACvE,IAAI,OAAO,QAAQ,YAAY,IAAI,KAAK;MACnC,IAAI,KAAK,AAAC,IAAyC,UAAU;AACpE;;AAGA,SAAgB,yBACd,OACA,SACA,mBAAuC,UACQ;CAC/C,MAAM,YAAY,OAAO,WAAW,cAAc,MAAM,YAAY,MAAM;CAC1E,MAAM,EAAE,SAAS,iBAAiB;CAClC,MAAM,aAAa,MAAM,KAAK,IAAI,IAAI,QAAQ,cAAc,CAAC,CAAC,CAAC;CAC/D,MAAM,cAAc,IAAI,IAAiB,UAAU;CACnD,MAAM,aAAa,EAAE,GAAG,QAAQ,WAAW;CAC3C,MAAM,iBAAiB,IAAI,IAAI,OAAO,KAAK,UAAU,CAAC;CACtD,MAAM,SAAS,EAAE,GAAG,QAAQ,OAAO;CACnC,MAAM,aAAa,IAAI,IAAI,OAAO,KAAK,MAAM,CAAC;CAC9C,MAAM,SAAS,EAAE,GAAG,QAAQ,OAAO;CACnC,MAAM,aAAa,IAAI,IAAI,OAAO,KAAK,MAAM,CAAC;CAC9C,MAAM,SAAS;EAAE;EAAY;EAAY;EAAQ;CAAO;CAExD,MAAM,SAAS,MAAM,WACnB,SAAS,cAAc,OAAO,cAAc;EAC1C,MAAM,aAAa,MAAM,OAAuB,IAAI;EACpD,MAAM,CAAC,SAAS,cAAc,MAAM,SAAyB,IAAI;EACjE,MAAM,aAAa,MAAM,OAAoE,IAAI;EACjG,MAAM,kBAAkB,MAAM,OAAmC,YAAY;EAC7E,MAAM,MAAM,MAAM,aAAa,SAAyB;GACtD,IAAI,WAAW,WAAW,WAAW,QAAQ,YAAY,MAAM;IAC7D,WAAW,QAAQ,QAAQ,QAAQ;IACnC,WAAW,UAAU;GACvB;GACA,WAA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A,OAAO,MAAM,cAAc,SAAS,QAAQ;CAC9C,CACF;CACA,OAAO,cAAc,iBAAiB,QAAQ;CAC9C,OAAO;AACT"}
|
package/dist/element.cjs
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_element = require('./element-
|
|
2
|
+
const require_element = require('./element-BRlY61kW.cjs');
|
|
3
3
|
|
|
4
4
|
exports.createElementBinding = require_element.createElementBinding;
|
|
5
|
-
exports.createElementFacade = require_element.createElementFacade;
|
|
5
|
+
exports.createElementFacade = require_element.createElementFacade;
|
|
6
|
+
exports.createPointerGestureSession = require_element.createPointerGestureSession;
|
|
7
|
+
exports.createRovingFocusController = require_element.createRovingFocusController;
|
|
8
|
+
exports.createSyncActionPipeline = require_element.createSyncActionPipeline;
|
|
9
|
+
exports.toReactPartProps = require_element.toReactPartProps;
|
package/dist/element.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as ElementBridgeContract, C as createPointerGestureSession, D as ElementBindingConfig, E as ElementBinding, O as ElementBindingOptions, S as PointerGestureSnapshot, T as createElementFacade, _ as PointerGestureEventLike, a as SyncHandlerConfig, b as PointerGestureOptions, c as SyncResultController, d as RovingFocusItem, f as RovingFocusKeyEventLike, g as PointerCaptureTargetLike, h as createRovingFocusController, i as SyncGuardController, j as ImperativeHandleFactory, k as ElementBridgeConfig, l as createSyncActionPipeline, m as RovingFocusOrientation, n as SyncActionPipeline, o as SyncObserverConfig, p as RovingFocusOptions, r as SyncDispatchOutcome, s as SyncObserverMeta, t as toReactPartProps, u as RovingFocusController, v as PointerGestureKeyEventLike, w as createElementBinding, x as PointerGestureSession, y as PointerGestureModifiers } from "./element-DPioFL7C.cjs";
|
|
2
2
|
import { t as PublicActionMethods } from "./public-action-methods-C_ppItRr.cjs";
|
|
3
|
-
export { type ElementBinding, type ElementBindingConfig, type ElementBindingOptions, type ElementBridgeConfig, type ElementBridgeContract, type ImperativeHandleFactory, type PublicActionMethods, createElementBinding, createElementFacade };
|
|
3
|
+
export { type ElementBinding, type ElementBindingConfig, type ElementBindingOptions, type ElementBridgeConfig, type ElementBridgeContract, type ImperativeHandleFactory, type PointerCaptureTargetLike, type PointerGestureEventLike, type PointerGestureKeyEventLike, type PointerGestureModifiers, type PointerGestureOptions, type PointerGestureSession, type PointerGestureSnapshot, type PublicActionMethods, type RovingFocusController, type RovingFocusItem, type RovingFocusKeyEventLike, type RovingFocusOptions, type RovingFocusOrientation, type SyncActionPipeline, type SyncDispatchOutcome, type SyncGuardController, type SyncHandlerConfig, type SyncObserverConfig, type SyncObserverMeta, type SyncResultController, createElementBinding, createElementFacade, createPointerGestureSession, createRovingFocusController, createSyncActionPipeline, toReactPartProps };
|
package/dist/element.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as ElementBridgeContract, C as createPointerGestureSession, D as ElementBindingConfig, E as ElementBinding, O as ElementBindingOptions, S as PointerGestureSnapshot, T as createElementFacade, _ as PointerGestureEventLike, a as SyncHandlerConfig, b as PointerGestureOptions, c as SyncResultController, d as RovingFocusItem, f as RovingFocusKeyEventLike, g as PointerCaptureTargetLike, h as createRovingFocusController, i as SyncGuardController, j as ImperativeHandleFactory, k as ElementBridgeConfig, l as createSyncActionPipeline, m as RovingFocusOrientation, n as SyncActionPipeline, o as SyncObserverConfig, p as RovingFocusOptions, r as SyncDispatchOutcome, s as SyncObserverMeta, t as toReactPartProps, u as RovingFocusController, v as PointerGestureKeyEventLike, w as createElementBinding, x as PointerGestureSession, y as PointerGestureModifiers } from "./element-DPioFL7C.js";
|
|
2
2
|
import { t as PublicActionMethods } from "./public-action-methods-C_ppItRr.js";
|
|
3
|
-
export { type ElementBinding, type ElementBindingConfig, type ElementBindingOptions, type ElementBridgeConfig, type ElementBridgeContract, type ImperativeHandleFactory, type PublicActionMethods, createElementBinding, createElementFacade };
|
|
3
|
+
export { type ElementBinding, type ElementBindingConfig, type ElementBindingOptions, type ElementBridgeConfig, type ElementBridgeContract, type ImperativeHandleFactory, type PointerCaptureTargetLike, type PointerGestureEventLike, type PointerGestureKeyEventLike, type PointerGestureModifiers, type PointerGestureOptions, type PointerGestureSession, type PointerGestureSnapshot, type PublicActionMethods, type RovingFocusController, type RovingFocusItem, type RovingFocusKeyEventLike, type RovingFocusOptions, type RovingFocusOrientation, type SyncActionPipeline, type SyncDispatchOutcome, type SyncGuardController, type SyncHandlerConfig, type SyncObserverConfig, type SyncObserverMeta, type SyncResultController, createElementBinding, createElementFacade, createPointerGestureSession, createRovingFocusController, createSyncActionPipeline, toReactPartProps };
|
package/dist/element.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as createElementFacade, t as
|
|
1
|
+
import { a as createElementBinding, i as createPointerGestureSession, n as createSyncActionPipeline, o as createElementFacade, r as createRovingFocusController, t as toReactPartProps } from "./element-BTaXgo7n.js";
|
|
2
2
|
|
|
3
|
-
export { createElementBinding, createElementFacade };
|
|
3
|
+
export { createElementBinding, createElementFacade, createPointerGestureSession, createRovingFocusController, createSyncActionPipeline, toReactPartProps };
|
package/docs/element-interop.md
CHANGED
|
@@ -10,7 +10,7 @@ local wiring, not an approved release dependency floor.
|
|
|
10
10
|
| Entry | Owns | Does not reach |
|
|
11
11
|
| --- | --- | --- |
|
|
12
12
|
| `@context-action/core` | Existing Action runtime, pure `PublicActionMethods` type | Element/DOM types, React runtime/types |
|
|
13
|
-
| `@context-action/core/element` | `createElementBinding`, `createElementFacade`, DOM transport contracts | React, Vue, Svelte, Angular, Lit, Preact |
|
|
13
|
+
| `@context-action/core/element` | `createElementBinding`, `createElementFacade`, `toReactPartProps`, `createSyncActionPipeline`, `createRovingFocusController`, `createPointerGestureSession`, DOM transport contracts | React, Vue, Svelte, Angular, Lit, Preact |
|
|
14
14
|
| `@context-action/core/element/react` | Injected-runtime `createReactElementBridge` and React component types | Store/Mutative or a statically imported React runtime |
|
|
15
15
|
|
|
16
16
|
Core declares no framework runtime dependency or peer constraint: the React
|
|
@@ -37,21 +37,33 @@ interface Input {
|
|
|
37
37
|
onRequest?: ((event: CustomEvent<string>) => void) | undefined;
|
|
38
38
|
}
|
|
39
39
|
const binding = createElementBinding<Input>(element, {
|
|
40
|
-
|
|
40
|
+
attributes: { role: 'role', disabled: 'aria-disabled' },
|
|
41
|
+
styles: { hitSize: '--handle-hit-size', left: 'left' },
|
|
42
|
+
properties: ['items'],
|
|
43
|
+
events: { onRequest: 'item-request' },
|
|
41
44
|
}, { assignmentErrors: 'throw' });
|
|
42
45
|
binding.update({ items, onRequest });
|
|
43
|
-
binding.update({ onRequest }); // releases previously assigned items
|
|
46
|
+
binding.update({ onRequest }); // releases previously assigned items/attributes/styles once
|
|
44
47
|
binding.dispose();
|
|
45
48
|
```
|
|
46
49
|
|
|
47
50
|
- Config is captured at construction. Inputs are **complete snapshots**, not patches.
|
|
48
|
-
- `update`
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
- `updateProperties` and `updateEvents` let a host choose its own lifecycle timing.
|
|
51
|
+
- `update` reconciles in deterministic order: **events → attributes → styles → properties**, so synchronous setter events see the current handler, attribute, and style state. Attach after native creation; constructor and initial `connectedCallback` events are not captured retroactively.
|
|
52
|
+
- `updateEvents`, `updateAttributes`, `updateStyles`, and `updateProperties` let a host choose its own lifecycle timing.
|
|
53
|
+
- `attributes` and `styles` bindings track an ownership ledger per binding instance: omitted keys are removed (`removeAttribute` / `removeProperty`) only for keys previously written by that binding, leaving host-owned attributes, CSS custom properties (`--*`), and inline styles untouched. Boolean attributes (`true` writes `""`; `false`, `null`, and `undefined` remove the attribute) and style strings (`""`, `null`, or `undefined` removes the property) normalize consistently.
|
|
52
54
|
- Omission clears only previously attempted writes, once. Untouched defaults survive.
|
|
53
|
-
Explicit undefined remains an assignment. Objects keep identity; no serialization,
|
|
55
|
+
Explicit undefined remains an assignment (for properties) or removal (for attributes/styles). Objects keep identity; no serialization,
|
|
54
56
|
validation, diff/equality filtering, rollback or clone is added.
|
|
57
|
+
|
|
58
|
+
## Headless UI interaction and framework projection primitives
|
|
59
|
+
|
|
60
|
+
`@context-action/core/element` also exports framework-neutral headless primitives for Vanilla DOM, custom elements, and React/framework consumers without adding a UI framework dependency:
|
|
61
|
+
|
|
62
|
+
- `createSyncActionPipeline`: Three-phase synchronous pipeline (`registerGuard` with `abort`/`modifyPayload`, `register` with `setResult`, and `registerObserver` with `when: 'success' | 'failure' | 'always'`, `priority`, and `once`) tailored for synchronous pointer/keyboard interactions where DOM events cannot await microtasks.
|
|
63
|
+
- `createRovingFocusController`: ARIA composite navigation helper supporting `'horizontal'`, `'vertical'`, and `'both'` orientations, `Arrow*` / `Home` / `End` keys, disabled item skipping, looping, and roving `getTabIndex(id)` (`0` vs `-1`).
|
|
64
|
+
- `createPointerGestureSession`: Pointer gesture lifecycle manager handling primary-button gating, `onStart` guard rejection, automatic `setPointerCapture`/`releasePointerCapture`, `deltaX`/`deltaY` & modifier tracking (`shiftKey`, `altKey`, `ctrlKey`, `metaKey`), and `Escape` cancellation.
|
|
65
|
+
- `toReactPartProps(partProps, config)`: Projects any headless part snapshot plus its `ElementBindingConfig` into a React-compatible props bag (mapping `attributes`, CSS custom/inline `styles` into `style`, and event names into `on<Event>` handlers).
|
|
66
|
+
- **Statechart & Effect Bridges**: Dedicated integration adapters for XState v5/v6 (`@context-action/xstate`) and Effect v4 / `@xstate/effect` (`@context-action/xstate/effect`) live in the separate `@context-action/xstate` package ([architecture specification](../../xstate/docs/xstate-effect-integration.md)), keeping `@context-action/core` strictly zero-dependency.
|
|
55
67
|
- Stable function/object handlers reuse listeners. Changed/invalid/omitted handlers
|
|
56
68
|
remove prior listeners; object receivers remain intact. Multiple prop names may
|
|
57
69
|
map to one event and remain independent subscriptions.
|