@adobe/data-lit 0.9.11
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/LICENSE +21 -0
- package/dist/decorators/apply-decorator.d.ts +1 -0
- package/dist/decorators/apply-decorator.js +19 -0
- package/dist/decorators/apply-decorator.js.map +1 -0
- package/dist/decorators/apply-service-decorators.d.ts +1 -0
- package/dist/decorators/apply-service-decorators.js +13 -0
- package/dist/decorators/apply-service-decorators.js.map +1 -0
- package/dist/decorators/index.d.ts +3 -0
- package/dist/decorators/index.js +5 -0
- package/dist/decorators/index.js.map +1 -0
- package/dist/decorators/require-service.d.ts +1 -0
- package/dist/decorators/require-service.js +14 -0
- package/dist/decorators/require-service.js.map +1 -0
- package/dist/elements/application-element.d.ts +9 -0
- package/dist/elements/application-element.js +42 -0
- package/dist/elements/application-element.js.map +1 -0
- package/dist/elements/application-host.d.ts +16 -0
- package/dist/elements/application-host.js +39 -0
- package/dist/elements/application-host.js.map +1 -0
- package/dist/elements/database-element.d.ts +10 -0
- package/dist/elements/database-element.js +40 -0
- package/dist/elements/database-element.js.map +1 -0
- package/dist/elements/index.d.ts +3 -0
- package/dist/elements/index.js +5 -0
- package/dist/elements/index.js.map +1 -0
- package/dist/functions/index.d.ts +1 -0
- package/dist/functions/index.js +3 -0
- package/dist/functions/index.js.map +1 -0
- package/dist/functions/iterate-self-and-ancestors.d.ts +1 -0
- package/dist/functions/iterate-self-and-ancestors.js +24 -0
- package/dist/functions/iterate-self-and-ancestors.js.map +1 -0
- package/dist/hooks/attach-decorator.d.ts +4 -0
- package/dist/hooks/attach-decorator.js +26 -0
- package/dist/hooks/attach-decorator.js.map +1 -0
- package/dist/hooks/component/component.d.ts +10 -0
- package/dist/hooks/component/component.js +3 -0
- package/dist/hooks/component/component.js.map +1 -0
- package/dist/hooks/component/stack.d.ts +6 -0
- package/dist/hooks/component/stack.js +16 -0
- package/dist/hooks/component/stack.js.map +1 -0
- package/dist/hooks/index.d.ts +19 -0
- package/dist/hooks/index.js +21 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/use-connected.d.ts +2 -0
- package/dist/hooks/use-connected.js +32 -0
- package/dist/hooks/use-connected.js.map +1 -0
- package/dist/hooks/use-debounce.d.ts +8 -0
- package/dist/hooks/use-debounce.js +21 -0
- package/dist/hooks/use-debounce.js.map +1 -0
- package/dist/hooks/use-drag-observe.d.ts +25 -0
- package/dist/hooks/use-drag-observe.js +35 -0
- package/dist/hooks/use-drag-observe.js.map +1 -0
- package/dist/hooks/use-drag-transaction.d.ts +7 -0
- package/dist/hooks/use-drag-transaction.js +35 -0
- package/dist/hooks/use-drag-transaction.js.map +1 -0
- package/dist/hooks/use-draggable.d.ts +15 -0
- package/dist/hooks/use-draggable.js +96 -0
- package/dist/hooks/use-draggable.js.map +1 -0
- package/dist/hooks/use-effect.d.ts +3 -0
- package/dist/hooks/use-effect.js +14 -0
- package/dist/hooks/use-effect.js.map +1 -0
- package/dist/hooks/use-element.d.ts +7 -0
- package/dist/hooks/use-element.js +67 -0
- package/dist/hooks/use-element.js.map +1 -0
- package/dist/hooks/use-memo.d.ts +1 -0
- package/dist/hooks/use-memo.js +13 -0
- package/dist/hooks/use-memo.js.map +1 -0
- package/dist/hooks/use-observable-values.d.ts +4 -0
- package/dist/hooks/use-observable-values.js +9 -0
- package/dist/hooks/use-observable-values.js.map +1 -0
- package/dist/hooks/use-observable.d.ts +2 -0
- package/dist/hooks/use-observable.js +13 -0
- package/dist/hooks/use-observable.js.map +1 -0
- package/dist/hooks/use-ref.d.ts +3 -0
- package/dist/hooks/use-ref.js +7 -0
- package/dist/hooks/use-ref.js.map +1 -0
- package/dist/hooks/use-resize-observer.d.ts +12 -0
- package/dist/hooks/use-resize-observer.js +23 -0
- package/dist/hooks/use-resize-observer.js.map +1 -0
- package/dist/hooks/use-state.d.ts +2 -0
- package/dist/hooks/use-state.js +15 -0
- package/dist/hooks/use-state.js.map +1 -0
- package/dist/hooks/use-updated.d.ts +4 -0
- package/dist/hooks/use-updated.js +40 -0
- package/dist/hooks/use-updated.js.map +1 -0
- package/dist/hooks/use-window-event.d.ts +1 -0
- package/dist/hooks/use-window-event.js +11 -0
- package/dist/hooks/use-window-event.js.map +1 -0
- package/dist/hooks/with-hooks.d.ts +2 -0
- package/dist/hooks/with-hooks.js +16 -0
- package/dist/hooks/with-hooks.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/package.json +30 -0
- package/src/decorators/apply-decorator.ts +26 -0
- package/src/decorators/apply-service-decorators.ts +15 -0
- package/src/decorators/index.ts +4 -0
- package/src/decorators/require-service.ts +20 -0
- package/src/elements/application-element.ts +42 -0
- package/src/elements/application-host.ts +43 -0
- package/src/elements/database-element.ts +42 -0
- package/src/elements/index.ts +5 -0
- package/src/functions/index.ts +3 -0
- package/src/functions/iterate-self-and-ancestors.ts +23 -0
- package/src/hooks/attach-decorator.ts +32 -0
- package/src/hooks/component/component.ts +12 -0
- package/src/hooks/component/stack.ts +19 -0
- package/src/hooks/index.ts +21 -0
- package/src/hooks/use-connected.ts +41 -0
- package/src/hooks/use-debounce.ts +26 -0
- package/src/hooks/use-drag-observe.ts +59 -0
- package/src/hooks/use-drag-transaction.ts +46 -0
- package/src/hooks/use-draggable.ts +112 -0
- package/src/hooks/use-effect.ts +19 -0
- package/src/hooks/use-element.ts +83 -0
- package/src/hooks/use-memo.ts +16 -0
- package/src/hooks/use-observable-values.ts +10 -0
- package/src/hooks/use-observable.ts +15 -0
- package/src/hooks/use-ref.ts +8 -0
- package/src/hooks/use-resize-observer.ts +31 -0
- package/src/hooks/use-state.ts +19 -0
- package/src/hooks/use-updated.ts +56 -0
- package/src/hooks/use-window-event.ts +16 -0
- package/src/hooks/with-hooks.ts +22 -0
- package/src/index.ts +6 -0
- package/tsconfig.json +11 -0
- package/tsconfig.tsbuildinfo +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 Adobe, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function applyDecorator(target: any, propertyKey: string, decorator: (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// © 2026 Adobe. MIT License. See /LICENSE for details.
|
|
2
|
+
export function applyDecorator(target, propertyKey, decorator) {
|
|
3
|
+
// Get the prototype chain
|
|
4
|
+
let currentPrototype = target;
|
|
5
|
+
let descriptor;
|
|
6
|
+
// Walk up the prototype chain until we find the property
|
|
7
|
+
while (currentPrototype && !descriptor) {
|
|
8
|
+
descriptor = Object.getOwnPropertyDescriptor(currentPrototype, propertyKey);
|
|
9
|
+
if (!descriptor) {
|
|
10
|
+
currentPrototype = Object.getPrototypeOf(currentPrototype);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
if (!descriptor) {
|
|
14
|
+
throw new Error(`Property ${propertyKey} not found in prototype chain`);
|
|
15
|
+
}
|
|
16
|
+
const newDescriptor = decorator(target, propertyKey, descriptor);
|
|
17
|
+
Object.defineProperty(target, propertyKey, newDescriptor);
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=apply-decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply-decorator.js","sourceRoot":"","sources":["../../src/decorators/apply-decorator.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,MAAM,UAAU,cAAc,CAC1B,MAAW,EACX,WAAmB,EACnB,SAAmG;IAEnG,0BAA0B;IAC1B,IAAI,gBAAgB,GAAG,MAAM,CAAC;IAC9B,IAAI,UAA0C,CAAC;IAE/C,yDAAyD;IACzD,OAAO,gBAAgB,IAAI,CAAC,UAAU,EAAE,CAAC;QACrC,UAAU,GAAG,MAAM,CAAC,wBAAwB,CAAC,gBAAgB,EAAE,WAAW,CAAC,CAAC;QAC5E,IAAI,CAAC,UAAU,EAAE,CAAC;YACd,gBAAgB,GAAG,MAAM,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC;QAC/D,CAAC;IACL,CAAC;IAED,IAAI,CAAC,UAAU,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,YAAY,WAAW,+BAA+B,CAAC,CAAC;IAC5E,CAAC;IAED,MAAM,aAAa,GAAG,SAAS,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;IACjE,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function applyServiceDecorators(target: any): void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// © 2026 Adobe. MIT License. See /LICENSE for details.
|
|
2
|
+
import { withHooks } from "../hooks/with-hooks.js";
|
|
3
|
+
import { requireService } from "./require-service.js";
|
|
4
|
+
export function applyServiceDecorators(target) {
|
|
5
|
+
const prototype = Object.getPrototypeOf(target);
|
|
6
|
+
const originalRender = target.render ?? prototype.render;
|
|
7
|
+
const withService = requireService()(target, 'render', {
|
|
8
|
+
value: originalRender
|
|
9
|
+
});
|
|
10
|
+
const withHooksAndService = withHooks(target, 'render', withService);
|
|
11
|
+
target.render = withHooksAndService.value;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=apply-service-decorators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply-service-decorators.js","sourceRoot":"","sources":["../../src/decorators/apply-service-decorators.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,MAAM,UAAU,sBAAsB,CAAC,MAAW;IAC9C,MAAM,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IAChD,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,IAAI,SAAS,CAAC,MAAM,CAAC;IACzD,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE;QACnD,KAAK,EAAE,cAAc;KACxB,CAAC,CAAC;IACH,MAAM,mBAAmB,GAAG,SAAS,CAAC,MAAM,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;IACrE,MAAM,CAAC,MAAM,GAAG,mBAAmB,CAAC,KAAoC,CAAC;AAC7E,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function requireService(): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// © 2026 Adobe. MIT License. See /LICENSE for details.
|
|
2
|
+
export function requireService() {
|
|
3
|
+
return function (target, propertyKey, descriptor) {
|
|
4
|
+
const originalRender = descriptor.value;
|
|
5
|
+
descriptor.value = function () {
|
|
6
|
+
if (!this.service) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
return originalRender.call(this);
|
|
10
|
+
};
|
|
11
|
+
return descriptor;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=require-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"require-service.js","sourceRoot":"","sources":["../../src/decorators/require-service.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,MAAM,UAAU,cAAc;IAC1B,OAAO,UACH,MAAW,EACX,WAAmB,EACnB,UAA8B;QAE9B,MAAM,cAAc,GAAG,UAAU,CAAC,KAAK,CAAC;QAExC,UAAU,CAAC,KAAK,GAAG;YACf,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;gBAChB,OAAO,IAAI,CAAC;YAChB,CAAC;YACD,OAAO,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrC,CAAC,CAAC;QAEF,OAAO,UAAU,CAAC;IACtB,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import { Service } from '@adobe/data/service';
|
|
3
|
+
export declare class ApplicationElement<MainService extends Service> extends LitElement {
|
|
4
|
+
service: MainService;
|
|
5
|
+
constructor();
|
|
6
|
+
connectedCallback(): void;
|
|
7
|
+
protected findAncestorService(): MainService | void;
|
|
8
|
+
render(): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// © 2026 Adobe. MIT License. See /LICENSE for details.
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
import { LitElement } from 'lit';
|
|
9
|
+
import { property } from 'lit/decorators.js';
|
|
10
|
+
import { attachDecorator, withHooks } from '../hooks/index.js';
|
|
11
|
+
import { iterateSelfAndAncestors } from '../functions/index.js';
|
|
12
|
+
import { isService } from '@adobe/data/service';
|
|
13
|
+
export class ApplicationElement extends LitElement {
|
|
14
|
+
constructor() {
|
|
15
|
+
super();
|
|
16
|
+
attachDecorator(this, 'render', withHooks);
|
|
17
|
+
}
|
|
18
|
+
connectedCallback() {
|
|
19
|
+
super.connectedCallback();
|
|
20
|
+
if (!this.service) {
|
|
21
|
+
const service = this.findAncestorService();
|
|
22
|
+
if (service) {
|
|
23
|
+
this.service = service;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
findAncestorService() {
|
|
28
|
+
for (const element of iterateSelfAndAncestors(this)) {
|
|
29
|
+
const { service } = element;
|
|
30
|
+
if (isService(service)) {
|
|
31
|
+
return service;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
render() {
|
|
36
|
+
throw new Error('render function must be overridden');
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
__decorate([
|
|
40
|
+
property({ type: Object, reflect: false })
|
|
41
|
+
], ApplicationElement.prototype, "service", void 0);
|
|
42
|
+
//# sourceMappingURL=application-element.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"application-element.js","sourceRoot":"","sources":["../../src/elements/application-element.ts"],"names":[],"mappings":"AAAA,uDAAuD;;;;;;;AAEvD,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAW,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEzD,MAAM,OAAO,kBAAgD,SAAQ,UAAU;IAI7E;QACE,KAAK,EAAE,CAAC;QACR,eAAe,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;IAC7C,CAAC;IAED,iBAAiB;QACf,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAE1B,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,OAAO,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;YAC3C,IAAI,OAAO,EAAE,CAAC;gBACZ,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;YACzB,CAAC;QACH,CAAC;IACH,CAAC;IAES,mBAAmB;QAC3B,KAAK,MAAM,OAAO,IAAI,uBAAuB,CAAC,IAAI,CAAC,EAAE,CAAC;YACpD,MAAM,EAAE,OAAO,EAAE,GAAG,OAAmD,CAAC;YACxE,IAAI,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;gBACvB,OAAO,OAAO,CAAC;YACjB,CAAC;QACH,CAAC;IACH,CAAC;IAEe,MAAM;QACpB,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;IACxD,CAAC;CAEF;AA/BC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;mDACrB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { LitElement, nothing, TemplateResult } from 'lit';
|
|
2
|
+
import { Service } from '@adobe/data/service';
|
|
3
|
+
import { ApplicationElement } from './application-element.js';
|
|
4
|
+
declare global {
|
|
5
|
+
interface HTMLElementTagNameMap {
|
|
6
|
+
'application-element': ApplicationElement<Service>;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export declare class ApplicationHost<MainService extends Service = Service> extends LitElement {
|
|
10
|
+
static styles: import("lit").CSSResult;
|
|
11
|
+
createService: () => Promise<MainService>;
|
|
12
|
+
renderElement: () => TemplateResult;
|
|
13
|
+
service: MainService;
|
|
14
|
+
connectedCallback(): Promise<void>;
|
|
15
|
+
render(): TemplateResult | typeof nothing;
|
|
16
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// © 2026 Adobe. MIT License. See /LICENSE for details.
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
import { LitElement, nothing, css } from 'lit';
|
|
9
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
10
|
+
const tagName = "application-host";
|
|
11
|
+
let ApplicationHost = class ApplicationHost extends LitElement {
|
|
12
|
+
static { this.styles = css `
|
|
13
|
+
:host {
|
|
14
|
+
display: flex;
|
|
15
|
+
flex: 1 1 auto;
|
|
16
|
+
}
|
|
17
|
+
`; }
|
|
18
|
+
async connectedCallback() {
|
|
19
|
+
super.connectedCallback();
|
|
20
|
+
this.service = await this.createService();
|
|
21
|
+
}
|
|
22
|
+
render() {
|
|
23
|
+
return this.service ? this.renderElement() : nothing;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
__decorate([
|
|
27
|
+
property()
|
|
28
|
+
], ApplicationHost.prototype, "createService", void 0);
|
|
29
|
+
__decorate([
|
|
30
|
+
property({})
|
|
31
|
+
], ApplicationHost.prototype, "renderElement", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
property({ attribute: false })
|
|
34
|
+
], ApplicationHost.prototype, "service", void 0);
|
|
35
|
+
ApplicationHost = __decorate([
|
|
36
|
+
customElement(tagName)
|
|
37
|
+
], ApplicationHost);
|
|
38
|
+
export { ApplicationHost };
|
|
39
|
+
//# sourceMappingURL=application-host.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"application-host.js","sourceRoot":"","sources":["../../src/elements/application-host.ts"],"names":[],"mappings":"AAAA,uDAAuD;;;;;;;AAEvD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAkB,GAAG,EAAE,MAAM,KAAK,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAI5D,MAAM,OAAO,GAAG,kBAAkB,CAAC;AAS5B,IAAM,eAAe,GAArB,MAAM,eAAuD,SAAQ,UAAU;aAC5E,WAAM,GAAG,GAAG,CAAA;;;;;KAKjB,AALW,CAKV;IAWM,KAAK,CAAC,iBAAiB;QAC7B,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC1B,IAAI,CAAC,OAAO,GAAG,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;IAC7C,CAAC;IAEQ,MAAM;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;IACxD,CAAC;;AAfD;IADC,QAAQ,EAAE;sDACgC;AAG3C;IADC,QAAQ,CAAC,EAAE,CAAC;sDACwB;AAG9B;IADN,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;gDACF;AAfnB,eAAe;IAD3B,aAAa,CAAC,OAAO,CAAC;GACV,eAAe,CA0B3B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import { Database } from '@adobe/data/ecs';
|
|
3
|
+
export declare abstract class DatabaseElement<P extends Database.Plugin> extends LitElement {
|
|
4
|
+
service: Database.Plugin.ToDatabase<P>;
|
|
5
|
+
constructor();
|
|
6
|
+
abstract get plugin(): P;
|
|
7
|
+
connectedCallback(): void;
|
|
8
|
+
protected findAncestorDatabase(): Database | void;
|
|
9
|
+
render(): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// © 2026 Adobe. MIT License. See /LICENSE for details.
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
import { LitElement } from 'lit';
|
|
9
|
+
import { property } from 'lit/decorators.js';
|
|
10
|
+
import { iterateSelfAndAncestors } from '../functions/index.js';
|
|
11
|
+
import { Database } from '@adobe/data/ecs';
|
|
12
|
+
import { attachDecorator, withHooks } from '../index.js';
|
|
13
|
+
export class DatabaseElement extends LitElement {
|
|
14
|
+
constructor() {
|
|
15
|
+
super();
|
|
16
|
+
attachDecorator(this, 'render', withHooks);
|
|
17
|
+
}
|
|
18
|
+
connectedCallback() {
|
|
19
|
+
if (!this.service) {
|
|
20
|
+
const service = this.findAncestorDatabase();
|
|
21
|
+
this.service = (service?.extend(this.plugin) ?? Database.create(this.plugin));
|
|
22
|
+
}
|
|
23
|
+
super.connectedCallback();
|
|
24
|
+
}
|
|
25
|
+
findAncestorDatabase() {
|
|
26
|
+
for (const element of iterateSelfAndAncestors(this)) {
|
|
27
|
+
const { service } = element;
|
|
28
|
+
if (Database.is(service)) {
|
|
29
|
+
return service;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
render() {
|
|
34
|
+
throw new Error('render function must be overridden');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
__decorate([
|
|
38
|
+
property({ type: Object, reflect: false })
|
|
39
|
+
], DatabaseElement.prototype, "service", void 0);
|
|
40
|
+
//# sourceMappingURL=database-element.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database-element.js","sourceRoot":"","sources":["../../src/elements/database-element.ts"],"names":[],"mappings":"AAAA,uDAAuD;;;;;;;AAEvD,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEzD,MAAM,OAAgB,eAA2C,SAAQ,UAAU;IAKjF;QACE,KAAK,EAAE,CAAC;QACR,eAAe,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;IAC7C,CAAC;IAID,iBAAiB;QACf,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,OAAO,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC5C,IAAI,CAAC,OAAO,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAA6C,CAAC;QAC5H,CAAC;QACD,KAAK,CAAC,iBAAiB,EAAE,CAAC;IAC5B,CAAC;IAES,oBAAoB;QAC5B,KAAK,MAAM,OAAO,IAAI,uBAAuB,CAAC,IAAI,CAAC,EAAE,CAAC;YACpD,MAAM,EAAE,OAAO,EAAE,GAAG,OAAwC,CAAC;YAC7D,IAAI,QAAQ,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;gBACzB,OAAO,OAAO,CAAC;YACjB,CAAC;QACH,CAAC;IACH,CAAC;IAEe,MAAM;QACpB,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;IACxD,CAAC;CAEF;AA9BC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;gDACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/elements/index.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./iterate-self-and-ancestors.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/functions/index.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,cAAc,iCAAiC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function iterateSelfAndAncestors(element: Element): IterableIterator<Element>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// © 2026 Adobe. MIT License. See /LICENSE for details.
|
|
2
|
+
export function* iterateSelfAndAncestors(element) {
|
|
3
|
+
let current = element;
|
|
4
|
+
while (current) {
|
|
5
|
+
yield current;
|
|
6
|
+
if (current instanceof HTMLSlotElement && current.assignedSlot) {
|
|
7
|
+
// Move to the slot's parent if the current element is assigned to a slot
|
|
8
|
+
current = current.assignedSlot;
|
|
9
|
+
}
|
|
10
|
+
else if (current.parentNode instanceof Element) {
|
|
11
|
+
// Move up to the parent node if it is an element
|
|
12
|
+
current = current.parentNode;
|
|
13
|
+
}
|
|
14
|
+
else if (current.getRootNode().host) {
|
|
15
|
+
// Move to the host element if we're at a shadow root
|
|
16
|
+
current = current.getRootNode().host;
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
// If no more ancestors, stop the iteration
|
|
20
|
+
current = null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=iterate-self-and-ancestors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iterate-self-and-ancestors.js","sourceRoot":"","sources":["../../src/functions/iterate-self-and-ancestors.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,MAAM,SAAS,CAAC,CAAC,uBAAuB,CAAC,OAAgB;IACrD,IAAI,OAAO,GAAmB,OAAO,CAAC;IAEtC,OAAO,OAAO,EAAE,CAAC;QACb,MAAM,OAAO,CAAC;QAEd,IAAI,OAAO,YAAY,eAAe,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;YAC7D,yEAAyE;YACzE,OAAO,GAAG,OAAO,CAAC,YAAY,CAAC;QACnC,CAAC;aAAM,IAAI,OAAO,CAAC,UAAU,YAAY,OAAO,EAAE,CAAC;YAC/C,iDAAiD;YACjD,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC;QACjC,CAAC;aAAM,IAAK,OAAO,CAAC,WAAW,EAAiB,CAAC,IAAI,EAAE,CAAC;YACpD,qDAAqD;YACrD,OAAO,GAAI,OAAO,CAAC,WAAW,EAAiB,CAAC,IAAI,CAAC;QACzD,CAAC;aAAM,CAAC;YACJ,2CAA2C;YAC3C,OAAO,GAAG,IAAI,CAAC;QACnB,CAAC;IACL,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Attacheds a decorator to a method on an object and reassigns the resulting value back to the object.
|
|
3
|
+
*/
|
|
4
|
+
export declare function attachDecorator<T, K extends keyof T>(obj: T, property: K, decorator: (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T[K]>) => PropertyDescriptor): void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// © 2026 Adobe. MIT License. See /LICENSE for details.
|
|
2
|
+
/**
|
|
3
|
+
* Attacheds a decorator to a method on an object and reassigns the resulting value back to the object.
|
|
4
|
+
*/
|
|
5
|
+
export function attachDecorator(obj, property,
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- This is a generic type
|
|
7
|
+
decorator) {
|
|
8
|
+
// Get the descriptor of the property
|
|
9
|
+
let descriptor = Object.getOwnPropertyDescriptor(obj, property);
|
|
10
|
+
if (!descriptor) {
|
|
11
|
+
if (!obj[property]) {
|
|
12
|
+
throw new Error(`Property ${property.toString()} does not exist on object`);
|
|
13
|
+
}
|
|
14
|
+
descriptor = {
|
|
15
|
+
value: obj[property],
|
|
16
|
+
writable: true,
|
|
17
|
+
enumerable: true,
|
|
18
|
+
configurable: true,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
// Apply the decorator to the descriptor
|
|
22
|
+
const decoratedDescriptor = decorator(obj, String(property), descriptor);
|
|
23
|
+
// Reassign the decorated method back to the object
|
|
24
|
+
obj[property] = decoratedDescriptor.value;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=attach-decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attach-decorator.js","sourceRoot":"","sources":["../../src/hooks/attach-decorator.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD;;GAEG;AACH,MAAM,UAAU,eAAe,CAC3B,GAAM,EACN,QAAW;AACX,wFAAwF;AACxF,SAA8G;IAE9G,qCAAqC;IACrC,IAAI,UAAU,GAAG,MAAM,CAAC,wBAAwB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAEhE,IAAI,CAAC,UAAU,EAAE,CAAC;QACd,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,YAAY,QAAQ,CAAC,QAAQ,EAAE,2BAA2B,CAAC,CAAC;QAChF,CAAC;QACD,UAAU,GAAG;YACT,KAAK,EAAE,GAAG,CAAC,QAAQ,CAAC;YACpB,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,IAAI;YAChB,YAAY,EAAE,IAAI;SACrB,CAAC;IACN,CAAC;IAED,wCAAwC;IACxC,MAAM,mBAAmB,GAAG,SAAS,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC,CAAC;IAEzE,mDAAmD;IACnD,GAAG,CAAC,QAAQ,CAAC,GAAG,mBAAmB,CAAC,KAAK,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface Component extends EventTarget {
|
|
2
|
+
/**
|
|
3
|
+
* Is this component active and connected to the containing dom?
|
|
4
|
+
*/
|
|
5
|
+
readonly isConnected: boolean;
|
|
6
|
+
hookIndex: number;
|
|
7
|
+
hooks: any[];
|
|
8
|
+
updatedListeners: Set<() => void>;
|
|
9
|
+
requestUpdate(): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../../src/hooks/component/component.ts"],"names":[],"mappings":"AAAA,uDAAuD"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// © 2026 Adobe. MIT License. See /LICENSE for details.
|
|
2
|
+
const activeComponentStack = [];
|
|
3
|
+
export const Component_stack = {
|
|
4
|
+
active() {
|
|
5
|
+
return activeComponentStack[activeComponentStack.length - 1];
|
|
6
|
+
},
|
|
7
|
+
push(component) {
|
|
8
|
+
component.hookIndex = 0;
|
|
9
|
+
component.hooks ??= [];
|
|
10
|
+
activeComponentStack.push(component);
|
|
11
|
+
},
|
|
12
|
+
pop() {
|
|
13
|
+
activeComponentStack.pop();
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=stack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stack.js","sourceRoot":"","sources":["../../../src/hooks/component/stack.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAIvD,MAAM,oBAAoB,GAAgB,EAAE,CAAC;AAC7C,MAAM,CAAC,MAAM,eAAe,GAAG;IAC3B,MAAM;QACF,OAAO,oBAAoB,CAAC,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAE,CAAC;IAClE,CAAC;IACD,IAAI,CAAC,SAAoB;QACrB,SAAS,CAAC,SAAS,GAAG,CAAC,CAAC;QACxB,SAAS,CAAC,KAAK,KAAK,EAAE,CAAC;QACvB,oBAAoB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IACxC,CAAC;IACD,GAAG;QACC,oBAAoB,CAAC,GAAG,EAAE,CAAA;IAC9B,CAAC;CACK,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export * from "./component/component.js";
|
|
2
|
+
export * from "./component/stack.js";
|
|
3
|
+
export * from "./use-state.js";
|
|
4
|
+
export * from "./use-effect.js";
|
|
5
|
+
export * from "./use-connected.js";
|
|
6
|
+
export * from "./use-memo.js";
|
|
7
|
+
export * from "./use-ref.js";
|
|
8
|
+
export * from "./use-observable-values.js";
|
|
9
|
+
export * from "./use-observable.js";
|
|
10
|
+
export * from "./use-window-event.js";
|
|
11
|
+
export * from "./use-resize-observer.js";
|
|
12
|
+
export * from "./use-debounce.js";
|
|
13
|
+
export * from "./use-element.js";
|
|
14
|
+
export * from "./with-hooks.js";
|
|
15
|
+
export * from "./attach-decorator.js";
|
|
16
|
+
export * from "./use-drag-transaction.js";
|
|
17
|
+
export * from "./use-drag-observe.js";
|
|
18
|
+
export * from "./use-draggable.js";
|
|
19
|
+
export * from "./use-updated.js";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// © 2026 Adobe. MIT License. See /LICENSE for details.
|
|
2
|
+
export * from "./component/component.js";
|
|
3
|
+
export * from "./component/stack.js";
|
|
4
|
+
export * from "./use-state.js";
|
|
5
|
+
export * from "./use-effect.js";
|
|
6
|
+
export * from "./use-connected.js";
|
|
7
|
+
export * from "./use-memo.js";
|
|
8
|
+
export * from "./use-ref.js";
|
|
9
|
+
export * from "./use-observable-values.js";
|
|
10
|
+
export * from "./use-observable.js";
|
|
11
|
+
export * from "./use-window-event.js";
|
|
12
|
+
export * from "./use-resize-observer.js";
|
|
13
|
+
export * from "./use-debounce.js";
|
|
14
|
+
export * from "./use-element.js";
|
|
15
|
+
export * from "./with-hooks.js";
|
|
16
|
+
export * from "./attach-decorator.js";
|
|
17
|
+
export * from "./use-drag-transaction.js";
|
|
18
|
+
export * from "./use-drag-observe.js";
|
|
19
|
+
export * from "./use-draggable.js";
|
|
20
|
+
export * from "./use-updated.js";
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// © 2026 Adobe. MIT License. See /LICENSE for details.
|
|
2
|
+
import { useEffect } from "./use-effect.js";
|
|
3
|
+
import { Component_stack } from "./component/stack.js";
|
|
4
|
+
export function useConnected(callback, dependencies) {
|
|
5
|
+
const component = Component_stack.active();
|
|
6
|
+
let disconnect;
|
|
7
|
+
function onConnect() {
|
|
8
|
+
if (!disconnect) {
|
|
9
|
+
disconnect = callback();
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function onDisconnect() {
|
|
13
|
+
if (disconnect) {
|
|
14
|
+
disconnect?.();
|
|
15
|
+
disconnect = undefined;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
// TODO
|
|
19
|
+
if (component.isConnected) {
|
|
20
|
+
onConnect();
|
|
21
|
+
}
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
component.addEventListener("connected", onConnect);
|
|
24
|
+
component.addEventListener("disconnected", onDisconnect);
|
|
25
|
+
return () => {
|
|
26
|
+
component.removeEventListener("connected", onConnect);
|
|
27
|
+
component.removeEventListener("disconnected", onDisconnect);
|
|
28
|
+
onDisconnect();
|
|
29
|
+
};
|
|
30
|
+
}, dependencies);
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=use-connected.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-connected.js","sourceRoot":"","sources":["../../src/hooks/use-connected.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAGvD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,UAAU,YAAY,CAAC,QAAwB,EAAE,YAAwB;IAC3E,MAAM,SAAS,GAAG,eAAe,CAAC,MAAM,EAAE,CAAC;IAE3C,IAAI,UAA+B,CAAC;IACpC,SAAS,SAAS;QACd,IAAI,CAAC,UAAU,EAAE,CAAC;YACd,UAAU,GAAG,QAAQ,EAAE,CAAC;QAC5B,CAAC;IACL,CAAC;IAED,SAAS,YAAY;QACjB,IAAI,UAAU,EAAE,CAAC;YACb,UAAU,EAAE,EAAE,CAAC;YACf,UAAU,GAAG,SAAS,CAAC;QAC3B,CAAC;IACL,CAAC;IAED,QAAQ;IACR,IAAI,SAAS,CAAC,WAAW,EAAE,CAAC;QACxB,SAAS,EAAE,CAAC;IAChB,CAAC;IAED,SAAS,CAAC,GAAG,EAAE;QACX,SAAS,CAAC,gBAAgB,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QACnD,SAAS,CAAC,gBAAgB,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;QAEzD,OAAO,GAAG,EAAE;YACR,SAAS,CAAC,mBAAmB,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;YACtD,SAAS,CAAC,mBAAmB,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;YAE5D,YAAY,EAAE,CAAC;QACnB,CAAC,CAAA;IAEL,CAAC,EAAE,YAAY,CAAC,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook to debounce a value. Returns the debounced value after the specified delay.
|
|
3
|
+
*
|
|
4
|
+
* @param value - The value to debounce
|
|
5
|
+
* @param delay - Delay in milliseconds before updating the debounced value
|
|
6
|
+
* @returns The debounced value
|
|
7
|
+
*/
|
|
8
|
+
export declare function useDebounce<T>(value: T, delay: number): T;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// © 2026 Adobe. MIT License. See /LICENSE for details.
|
|
2
|
+
import { useEffect } from "./use-effect.js";
|
|
3
|
+
import { useState } from "./use-state.js";
|
|
4
|
+
/**
|
|
5
|
+
* Hook to debounce a value. Returns the debounced value after the specified delay.
|
|
6
|
+
*
|
|
7
|
+
* @param value - The value to debounce
|
|
8
|
+
* @param delay - Delay in milliseconds before updating the debounced value
|
|
9
|
+
* @returns The debounced value
|
|
10
|
+
*/
|
|
11
|
+
export function useDebounce(value, delay) {
|
|
12
|
+
const [debouncedValue, setDebouncedValue] = useState(value);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
const timeoutId = window.setTimeout(() => {
|
|
15
|
+
setDebouncedValue(value);
|
|
16
|
+
}, delay);
|
|
17
|
+
return () => clearTimeout(timeoutId);
|
|
18
|
+
}, [value, delay]);
|
|
19
|
+
return debouncedValue;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=use-debounce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-debounce.js","sourceRoot":"","sources":["../../src/hooks/use-debounce.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAI,KAAQ,EAAE,KAAa;IAClD,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE5D,SAAS,CAAC,GAAG,EAAE;QACX,MAAM,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE;YACrC,iBAAiB,CAAC,KAAK,CAAC,CAAC;QAC7B,CAAC,EAAE,KAAK,CAAC,CAAC;QAEV,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IACzC,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;IAEnB,OAAO,cAAc,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { DraggableProps } from './use-draggable.js';
|
|
2
|
+
import { Observe } from '@adobe/data/observe';
|
|
3
|
+
import { Vec2 } from '@adobe/data/math';
|
|
4
|
+
export type DragObserveProps = Pick<DraggableProps, 'minDragDistance' | 'dragCursor' | 'addPlaceholder' | 'stopPropagation'>;
|
|
5
|
+
export type DragStart = {
|
|
6
|
+
readonly type: 'start' | 'cancel';
|
|
7
|
+
};
|
|
8
|
+
export type DragMove = {
|
|
9
|
+
readonly type: 'move';
|
|
10
|
+
readonly delta: Vec2;
|
|
11
|
+
readonly position: Vec2;
|
|
12
|
+
};
|
|
13
|
+
export type DragEnd = {
|
|
14
|
+
readonly type: 'end';
|
|
15
|
+
readonly delta: Vec2;
|
|
16
|
+
readonly position: Vec2;
|
|
17
|
+
};
|
|
18
|
+
export type DragState = DragStart | DragMove | DragEnd;
|
|
19
|
+
/**
|
|
20
|
+
* This hook creates a drag observe function that can be used to observe the drag state of an element.
|
|
21
|
+
* This is normally not used directly, but rather through the `useDragTransaction` hook.
|
|
22
|
+
* @param props
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
export declare function useDragObserve(props: DragObserveProps, dependencies: unknown[]): Observe<DragState>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// © 2026 Adobe. MIT License. See /LICENSE for details.
|
|
2
|
+
import { useDraggable } from './use-draggable.js';
|
|
3
|
+
import { useElement } from './use-element.js';
|
|
4
|
+
import { Observe } from '@adobe/data/observe';
|
|
5
|
+
/**
|
|
6
|
+
* This hook creates a drag observe function that can be used to observe the drag state of an element.
|
|
7
|
+
* This is normally not used directly, but rather through the `useDragTransaction` hook.
|
|
8
|
+
* @param props
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
export function useDragObserve(props, dependencies) {
|
|
12
|
+
const [dragState, setDragState] = Observe.createEvent();
|
|
13
|
+
const element = useElement();
|
|
14
|
+
useDraggable(element, {
|
|
15
|
+
...props,
|
|
16
|
+
onDragStart: _e => {
|
|
17
|
+
setDragState({ type: 'start' });
|
|
18
|
+
},
|
|
19
|
+
onDrag: (_e, position, delta) => {
|
|
20
|
+
setDragState({
|
|
21
|
+
type: 'move',
|
|
22
|
+
position,
|
|
23
|
+
delta,
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
onDragEnd: (_e, position, delta) => {
|
|
27
|
+
setDragState({ type: 'end', position, delta });
|
|
28
|
+
},
|
|
29
|
+
onDragCancel: () => {
|
|
30
|
+
setDragState({ type: 'cancel' });
|
|
31
|
+
},
|
|
32
|
+
}, dependencies);
|
|
33
|
+
return dragState;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=use-drag-observe.js.map
|