@omegagrid/bucket 0.11.30 → 0.11.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ui/bucket.components.d.ts +2 -0
- package/dist/ui/bucket.components.d.ts.map +1 -1
- package/dist/ui/bucket.components.js +11 -5
- package/dist/ui/bucket.components.js.map +1 -1
- package/dist/ui/bucket.dialogs.d.ts +7 -0
- package/dist/ui/bucket.dialogs.d.ts.map +1 -1
- package/dist/ui/bucket.dialogs.js +15 -2
- package/dist/ui/bucket.dialogs.js.map +1 -1
- package/package.json +6 -6
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ComponentId, ComponentSlice, ComponentState } from "@omegagrid/core";
|
|
2
2
|
import { ComponentUpdateOptions, PathSegments } from "../types";
|
|
3
3
|
import { Bucket } from "./bucket";
|
|
4
|
+
/** Calls dispose() of a component that is not used again (a closed tab, modal sidebar or dialog), if it has one */
|
|
5
|
+
export declare const disposeComponent: (component: HTMLElement) => void;
|
|
4
6
|
export declare class BucketComponents extends ComponentSlice<Bucket> {
|
|
5
7
|
private _componentPromiseResolutions;
|
|
6
8
|
private _resolvingComponentIds;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bucket.components.d.ts","sourceRoot":"","sources":["../../src/ui/bucket.components.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,cAAc,EAAkB,MAAM,iBAAiB,CAAC;AAC9F,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAChE,OAAO,EAAE,MAAM,EAAe,MAAM,UAAU,CAAC;AAE/C,qBAAa,gBAAiB,SAAQ,cAAc,CAAC,MAAM,CAAC;IAE3D,OAAO,CAAC,4BAA4B,CAG7B;IAEP,OAAO,CAAC,sBAAsB,CAA0B;IAExD,QAAQ,CAAC,KAAK,iCAAwC;IACtD,QAAQ,CAAC,UAAU,gCAAuC;IAC1D,QAAQ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B,YAA6C;IAErE,IAAI,MAAM,WAA4B;IAEtC,QAAQ,CAAC,MAAM,mCAA0C;IAEzD,QAAQ,CAAC,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,cAAc;IAS/C,GAAG,CAAC,EAAE,EAAE,WAAW;IAInB,OAAO,CAAC,OAAO;IAIf,GAAG,CAAC,EAAE,EAAE,WAAW;IAyBnB,OAAO,CAAC,EAAE,EAAE,WAAW;IAUvB,wBAAwB,CAAC,EAAE,EAAE,WAAW,EAAE,SAAS,CAAC,EAAE,WAAW;IAQjE,0BAA0B,CAAC,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,SAAS,EAAE,WAAW,KAAK,IAAI,EAAE,MAAM,EAAE,MAAM,IAAI;IAKzG,MAAM,CAAC,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,sBAAsB;IAcvD,QAAQ,CAAC,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW;IAchD,UAAU,CAAC,EAAE,EAAE,WAAW;IAcpB,OAAO,CAAC,EAAE,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;CAQrD"}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { ComponentSlice } from "@omegagrid/core";
|
|
2
2
|
import { Bucket, BucketEvent } from "./bucket";
|
|
3
|
+
/** Calls dispose() of a component that is not used again (a closed tab, modal sidebar or dialog), if it has one */
|
|
4
|
+
export const disposeComponent = (component) => {
|
|
5
|
+
const disposable = component;
|
|
6
|
+
if (component && typeof disposable.dispose === 'function')
|
|
7
|
+
disposable.dispose();
|
|
8
|
+
};
|
|
3
9
|
export class BucketComponents extends ComponentSlice {
|
|
4
10
|
constructor() {
|
|
5
11
|
super(...arguments);
|
|
@@ -77,8 +83,11 @@ export class BucketComponents extends ComponentSlice {
|
|
|
77
83
|
const newId = options.id ?? id;
|
|
78
84
|
this.bucket.editorContainer.updateTab(id, { id: newId, title: options.title ?? undefined });
|
|
79
85
|
if (this.components.has(id) && newId != id) {
|
|
86
|
+
// the component lives on under the new id: moved over, not disposed like on unregister()
|
|
80
87
|
const c = this.components.get(id);
|
|
81
|
-
this.
|
|
88
|
+
this.components.delete(id);
|
|
89
|
+
this.paths.delete(id);
|
|
90
|
+
this.bucket.dispatchEvent(new BucketEvent('unregister', { componentId: id }));
|
|
82
91
|
this.register(newId, c);
|
|
83
92
|
}
|
|
84
93
|
return this.components.get(newId);
|
|
@@ -107,10 +116,7 @@ export class BucketComponents extends ComponentSlice {
|
|
|
107
116
|
}
|
|
108
117
|
this.components.delete(id);
|
|
109
118
|
this.anonymousComponents.delete(id);
|
|
110
|
-
|
|
111
|
-
if (component && typeof disposable.dispose === 'function') {
|
|
112
|
-
disposable.dispose();
|
|
113
|
-
}
|
|
119
|
+
disposeComponent(component);
|
|
114
120
|
this.paths.delete(id);
|
|
115
121
|
this.bucket.dispatchEvent(new BucketEvent('unregister', { componentId: id }));
|
|
116
122
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bucket.components.js","sourceRoot":"","sources":["../../src/ui/bucket.components.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,cAAc,EAAkC,MAAM,iBAAiB,CAAC;AAE9F,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE/C,MAAM,OAAO,gBAAiB,SAAQ,cAAsB;IAA5D;;QAES,iCAA4B,GAAG,IAAI,GAAG,EAGxC,CAAC;QAEC,2BAAsB,GAAG,IAAI,GAAG,EAAe,CAAC;QAE/C,UAAK,GAAG,IAAI,GAAG,EAA6B,CAAC;QAC7C,eAAU,GAAG,IAAI,GAAG,EAA4B,CAAC;QACjD,wBAAmB,GAAG,IAAI,GAAG,EAA4B,CAAC;QAC1D,sBAAiB,GAAG,IAAI,GAAG,EAAe,CAAC;QAK3C,WAAM,GAAG,IAAI,GAAG,EAA+B,CAAC;IAuH1D,CAAC;IA3HA,IAAI,oBAAoB,KAAK,OAAO,IAAI,CAAC,iBAAiB,C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,UAAU,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;YAC3D,UAAU,CAAC,OAAO,EAAE,CAAC;QACtB,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACtB,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,YAAY,EAAE,EAAC,WAAW,EAAE,EAAE,EAAC,CAAC,CAAC,CAAC;IAC7E,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,EAAe;QAC5B,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;YAAE,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAClD,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY;YAAE,OAAO,EAAE,CAAC;QACjD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;QACxD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QACzB,OAAO,IAAI,CAAC;IACb,CAAC;CAED","sourcesContent":["import { ComponentId, ComponentSlice, ComponentState, OmegaComponent } from \"@omegagrid/core\";\nimport { ComponentUpdateOptions, PathSegments } from \"../types\";\nimport { Bucket, BucketEvent } from \"./bucket\";\n\nexport class BucketComponents extends ComponentSlice<Bucket> {\n\n\tprivate _componentPromiseResolutions = new Map<ComponentId, {\n\t\tresolve: (component: HTMLElement) => void,\n\t\treject: () => void\n\t}[]>();\n\n\tprivate _resolvingComponentIds = new Set<ComponentId>();\n\n\treadonly paths = new Map<ComponentId, PathSegments>();\n\treadonly components = new Map<ComponentId, HTMLElement>();\n\treadonly anonymousComponents = new Map<ComponentId, HTMLElement>();\n\treadonly unsavedComponents = new Set<ComponentId>();\n\tget hasUnsavedComponents() { return this.unsavedComponents.size > 0 }\n\n\tget bucket() { return this.component }\n\n\treadonly states = new Map<ComponentId, ComponentState>();\n\n\tsetState(id: ComponentId, state: ComponentState) {\n\t\tconst component = this.components.get(id) as OmegaComponent;\n\t\tif (component && component.setState) {\n\t\t\tcomponent.setState(state);\n\t\t} else {\n\t\t\tthis.states.set(id, state);\n\t\t}\n\t}\n\n\thas(id: ComponentId) {\n\t\treturn this.components.has(id) || this.anonymousComponents.has(id) || this._resolvingComponentIds.has(id);\n\t}\n\n\tprivate _lookup(id: ComponentId) {\n\t\treturn this.components.get(id) ?? this.anonymousComponents.get(id);\n\t}\n\n\tget(id: ComponentId) {\n\t\tconst component = this._lookup(id);\n\t\tif (component) {\n\t\t\tthis.resolveComponentPromises(id, component);\n\t\t\treturn component;\n\t\t}\n\n\t\treturn new Promise<HTMLElement>((resolve, reject) => {\n\t\t\tthis.enqueueComponentResolution(id, resolve, reject);\n\t\t\tif (this._resolvingComponentIds.has(id)) return;\n\t\t\tthis._resolvingComponentIds.add(id);\n\t\t\tPromise.resolve(this.component.createComponent(id)).then(created => {\n\t\t\t\tconst component = created as OmegaComponent;\n\t\t\t\tif (component) {\n\t\t\t\t\tthis.register(id, component);\n\t\t\t\t\tconst state = this.bucket.state;\n\t\t\t\t\tif (state?.components?.[id] && component.setState) {\n\t\t\t\t\t\tcomponent.setState(state.components[id]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.resolveComponentPromises(id, component);\n\t\t\t});\n\t\t});\n\t}\n\n\twaitFor(id: ComponentId) {\n\t\treturn new Promise<HTMLElement>((resolve, reject) => {\n\t\t\tthis.enqueueComponentResolution(id, resolve, reject);\n\t\t\tconst component = this._lookup(id);\n\t\t\tif (component && !this._resolvingComponentIds.has(id)) {\n\t\t\t\tthis.resolveComponentPromises(id, component);\n\t\t\t}\n\t\t});\n\t}\n\n\tresolveComponentPromises(id: ComponentId, component?: HTMLElement) {\n\t\tif (this._componentPromiseResolutions.has(id)) {\n\t\t\tthis._componentPromiseResolutions.get(id).forEach(res => res.resolve(component));\n\t\t\tthis._componentPromiseResolutions.delete(id);\n\t\t}\n\t\tthis._resolvingComponentIds.delete(id);\n\t}\n\n\tenqueueComponentResolution(id: ComponentId, resolve: (component: HTMLElement) => void, reject: () => void) {\n\t\tif (!this._componentPromiseResolutions.has(id)) this._componentPromiseResolutions.set(id, []);\n\t\tthis._componentPromiseResolutions.get(id).push({ resolve, reject });\n\t}\n\n\tupdate(id: ComponentId, options: ComponentUpdateOptions) {\n\t\tconst newId = options.id ?? id;\n\t\tthis.bucket.editorContainer.updateTab(id, {id: newId, title: options.title ?? undefined});\n\t\tif (this.components.has(id) && newId != id) {\n\t\t\tconst c = this.components.get(id);\n\t\t\tthis.unregister(id);\n\t\t\tthis.register(newId, c);\n\t\t}\n\t\treturn this.components.get(newId);\n\t}\n\n\tregister(id: ComponentId, component: HTMLElement) {\n\t\tif (id == null) {\n\t\t\tid = `temp_${Bucket.getUniqueId()}`;\n\t\t\tthis.anonymousComponents.set(id, component);\n\t\t} else {\n\t\t\tconst alreadyRegistered = this.components.has(id);\n\t\t\tthis.components.set(id, component);\n\t\t\tif (alreadyRegistered) return id;\n\t\t}\n\n\t\tthis.bucket.dispatchEvent(new BucketEvent('register', {componentId: id}));\n\t\treturn id;\n\t}\n\n\tunregister(id: ComponentId) {\n\t\tlet component: HTMLElement;\n\t\tif (this.components.has(id)) {\n\t\t\tcomponent = this.components.get(id);\n\t\t} else if (this.anonymousComponents.has(id)) {\n\t\t\tcomponent = this.anonymousComponents.get(id);\n\t\t}\n\t\tthis.components.delete(id);\n\t\tthis.anonymousComponents.delete(id);\n\n\t\tconst disposable = component as unknown as { dispose?: () => void };\n\t\tif (component && typeof disposable.dispose === 'function') {\n\t\t\tdisposable.dispose();\n\t\t}\n\n\t\tthis.paths.delete(id);\n\t\tthis.bucket.dispatchEvent(new BucketEvent('unregister', {componentId: id}));\n\t}\n\n\tasync getPath(id: ComponentId): Promise<PathSegments> {\n\t\tif (this.paths.has(id)) return this.paths.get(id);\n\t\tif (!this.bucket.options.pathResolver) return [];\n\t\tconst path = await this.bucket.options.pathResolver(id);\n\t\tthis.paths.set(id, path);\n\t\treturn path;\n\t}\n\n}\n"]}
|
|
1
|
+
{"version":3,"file":"bucket.components.js","sourceRoot":"","sources":["../../src/ui/bucket.components.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,cAAc,EAAkC,MAAM,iBAAiB,CAAC;AAE9F,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE/C,mHAAmH;AACnH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,SAAsB,EAAE,EAAE;IAC1D,MAAM,UAAU,GAAG,SAAgD,CAAC;IACpE,IAAI,SAAS,IAAI,OAAO,UAAU,CAAC,OAAO,KAAK,UAAU;QAAE,UAAU,CAAC,OAAO,EAAE,CAAC;AACjF,CAAC,CAAA;AAED,MAAM,OAAO,gBAAiB,SAAQ,cAAsB;IAA5D;;QAES,iCAA4B,GAAG,IAAI,GAAG,EAGxC,CAAC;QAEC,2BAAsB,GAAG,IAAI,GAAG,EAAe,CAAC;QAE/C,UAAK,GAAG,IAAI,GAAG,EAA6B,CAAC;QAC7C,eAAU,GAAG,IAAI,GAAG,EAA4B,CAAC;QACjD,wBAAmB,GAAG,IAAI,GAAG,EAA4B,CAAC;QAC1D,sBAAiB,GAAG,IAAI,GAAG,EAAe,CAAC;QAK3C,WAAM,GAAG,IAAI,GAAG,EAA+B,CAAC;IAqH1D,CAAC;IAzHA,IAAI,oBAAoB,KAAK,OAAO,IAAI,CAAC,iBAAiB,CAAC,IAAI,GAAG,CAAC,CAAA,CAAC,CAAC;IAErE,IAAI,MAAM,KAAK,OAAO,IAAI,CAAC,SAAS,CAAA,CAAC,CAAC;IAItC,QAAQ,CAAC,EAAe,EAAE,KAAqB;QAC9C,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAmB,CAAC;QAC5D,IAAI,SAAS,IAAI,SAAS,CAAC,QAAQ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C,aAAa,CAAC,IAAI,WAAW,CAAC,YAAY,EAAE,EAAC,WAAW,EAAE,EAAE,EAAC,CAAC,CAAC,CAAC;IAC7E,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,EAAe;QAC5B,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;YAAE,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAClD,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY;YAAE,OAAO,EAAE,CAAC;QACjD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;QACxD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QACzB,OAAO,IAAI,CAAC;IACb,CAAC;CAED","sourcesContent":["import { ComponentId, ComponentSlice, ComponentState, OmegaComponent } from \"@omegagrid/core\";\nimport { ComponentUpdateOptions, PathSegments } from \"../types\";\nimport { Bucket, BucketEvent } from \"./bucket\";\n\n/** Calls dispose() of a component that is not used again (a closed tab, modal sidebar or dialog), if it has one */\nexport const disposeComponent = (component: HTMLElement) => {\n\tconst disposable = component as unknown as { dispose?: () => void };\n\tif (component && typeof disposable.dispose === 'function') disposable.dispose();\n}\n\nexport class BucketComponents extends ComponentSlice<Bucket> {\n\n\tprivate _componentPromiseResolutions = new Map<ComponentId, {\n\t\tresolve: (component: HTMLElement) => void,\n\t\treject: () => void\n\t}[]>();\n\n\tprivate _resolvingComponentIds = new Set<ComponentId>();\n\n\treadonly paths = new Map<ComponentId, PathSegments>();\n\treadonly components = new Map<ComponentId, HTMLElement>();\n\treadonly anonymousComponents = new Map<ComponentId, HTMLElement>();\n\treadonly unsavedComponents = new Set<ComponentId>();\n\tget hasUnsavedComponents() { return this.unsavedComponents.size > 0 }\n\n\tget bucket() { return this.component }\n\n\treadonly states = new Map<ComponentId, ComponentState>();\n\n\tsetState(id: ComponentId, state: ComponentState) {\n\t\tconst component = this.components.get(id) as OmegaComponent;\n\t\tif (component && component.setState) {\n\t\t\tcomponent.setState(state);\n\t\t} else {\n\t\t\tthis.states.set(id, state);\n\t\t}\n\t}\n\n\thas(id: ComponentId) {\n\t\treturn this.components.has(id) || this.anonymousComponents.has(id) || this._resolvingComponentIds.has(id);\n\t}\n\n\tprivate _lookup(id: ComponentId) {\n\t\treturn this.components.get(id) ?? this.anonymousComponents.get(id);\n\t}\n\n\tget(id: ComponentId) {\n\t\tconst component = this._lookup(id);\n\t\tif (component) {\n\t\t\tthis.resolveComponentPromises(id, component);\n\t\t\treturn component;\n\t\t}\n\n\t\treturn new Promise<HTMLElement>((resolve, reject) => {\n\t\t\tthis.enqueueComponentResolution(id, resolve, reject);\n\t\t\tif (this._resolvingComponentIds.has(id)) return;\n\t\t\tthis._resolvingComponentIds.add(id);\n\t\t\tPromise.resolve(this.component.createComponent(id)).then(created => {\n\t\t\t\tconst component = created as OmegaComponent;\n\t\t\t\tif (component) {\n\t\t\t\t\tthis.register(id, component);\n\t\t\t\t\tconst state = this.bucket.state;\n\t\t\t\t\tif (state?.components?.[id] && component.setState) {\n\t\t\t\t\t\tcomponent.setState(state.components[id]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.resolveComponentPromises(id, component);\n\t\t\t});\n\t\t});\n\t}\n\n\twaitFor(id: ComponentId) {\n\t\treturn new Promise<HTMLElement>((resolve, reject) => {\n\t\t\tthis.enqueueComponentResolution(id, resolve, reject);\n\t\t\tconst component = this._lookup(id);\n\t\t\tif (component && !this._resolvingComponentIds.has(id)) {\n\t\t\t\tthis.resolveComponentPromises(id, component);\n\t\t\t}\n\t\t});\n\t}\n\n\tresolveComponentPromises(id: ComponentId, component?: HTMLElement) {\n\t\tif (this._componentPromiseResolutions.has(id)) {\n\t\t\tthis._componentPromiseResolutions.get(id).forEach(res => res.resolve(component));\n\t\t\tthis._componentPromiseResolutions.delete(id);\n\t\t}\n\t\tthis._resolvingComponentIds.delete(id);\n\t}\n\n\tenqueueComponentResolution(id: ComponentId, resolve: (component: HTMLElement) => void, reject: () => void) {\n\t\tif (!this._componentPromiseResolutions.has(id)) this._componentPromiseResolutions.set(id, []);\n\t\tthis._componentPromiseResolutions.get(id).push({ resolve, reject });\n\t}\n\n\tupdate(id: ComponentId, options: ComponentUpdateOptions) {\n\t\tconst newId = options.id ?? id;\n\t\tthis.bucket.editorContainer.updateTab(id, {id: newId, title: options.title ?? undefined});\n\t\tif (this.components.has(id) && newId != id) {\n\t\t\t// the component lives on under the new id: moved over, not disposed like on unregister()\n\t\t\tconst c = this.components.get(id);\n\t\t\tthis.components.delete(id);\n\t\t\tthis.paths.delete(id);\n\t\t\tthis.bucket.dispatchEvent(new BucketEvent('unregister', {componentId: id}));\n\t\t\tthis.register(newId, c);\n\t\t}\n\t\treturn this.components.get(newId);\n\t}\n\n\tregister(id: ComponentId, component: HTMLElement) {\n\t\tif (id == null) {\n\t\t\tid = `temp_${Bucket.getUniqueId()}`;\n\t\t\tthis.anonymousComponents.set(id, component);\n\t\t} else {\n\t\t\tconst alreadyRegistered = this.components.has(id);\n\t\t\tthis.components.set(id, component);\n\t\t\tif (alreadyRegistered) return id;\n\t\t}\n\n\t\tthis.bucket.dispatchEvent(new BucketEvent('register', {componentId: id}));\n\t\treturn id;\n\t}\n\n\tunregister(id: ComponentId) {\n\t\tlet component: HTMLElement;\n\t\tif (this.components.has(id)) {\n\t\t\tcomponent = this.components.get(id);\n\t\t} else if (this.anonymousComponents.has(id)) {\n\t\t\tcomponent = this.anonymousComponents.get(id);\n\t\t}\n\t\tthis.components.delete(id);\n\t\tthis.anonymousComponents.delete(id);\n\t\tdisposeComponent(component);\n\t\tthis.paths.delete(id);\n\t\tthis.bucket.dispatchEvent(new BucketEvent('unregister', {componentId: id}));\n\t}\n\n\tasync getPath(id: ComponentId): Promise<PathSegments> {\n\t\tif (this.paths.has(id)) return this.paths.get(id);\n\t\tif (!this.bucket.options.pathResolver) return [];\n\t\tconst path = await this.bucket.options.pathResolver(id);\n\t\tthis.paths.set(id, path);\n\t\treturn path;\n\t}\n\n}\n"]}
|
|
@@ -5,7 +5,14 @@ export declare class BucketDialogs extends ComponentSlice<Bucket> {
|
|
|
5
5
|
readonly items: Map<ComponentId, BucketDialog>;
|
|
6
6
|
get bucket(): Bucket;
|
|
7
7
|
register(id: ComponentId, dialog: BucketDialog): void;
|
|
8
|
+
/** Drops the dialog from the state; its component is disposed when the dialog closes */
|
|
8
9
|
unregister(id: ComponentId): void;
|
|
10
|
+
/**
|
|
11
|
+
* The dialog closed: it leaves the state and its component is disposed like the component of a closed tab.
|
|
12
|
+
* The component belongs to the dialog alone (created for it or passed in by the caller) and is not among the
|
|
13
|
+
* registered components, so the registry is left alone - a tab open under the same id keeps its component.
|
|
14
|
+
*/
|
|
15
|
+
private _onClose;
|
|
9
16
|
open(options: OpenDialogOptions): Promise<BucketDialog>;
|
|
10
17
|
}
|
|
11
18
|
//# sourceMappingURL=bucket.dialogs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bucket.dialogs.d.ts","sourceRoot":"","sources":["../../src/ui/bucket.dialogs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAO,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"bucket.dialogs.d.ts","sourceRoot":"","sources":["../../src/ui/bucket.dialogs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAO,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAI3D,qBAAa,aAAc,SAAQ,cAAc,CAAC,MAAM,CAAC;IAExD,QAAQ,CAAC,KAAK,iCAAwC;IAEtD,IAAI,MAAM,WAA4B;IAEtC,QAAQ,CAAC,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY;IAI9C,wFAAwF;IACxF,UAAU,CAAC,EAAE,EAAE,WAAW;IAK1B;;;;OAIG;IACH,OAAO,CAAC,QAAQ;IAOV,IAAI,CAAC,OAAO,EAAE,iBAAiB;CAuCrC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ComponentSlice, dom } from "@omegagrid/core";
|
|
2
|
+
import { disposeComponent } from "./bucket.components";
|
|
2
3
|
export class BucketDialogs extends ComponentSlice {
|
|
3
4
|
constructor() {
|
|
4
5
|
super(...arguments);
|
|
@@ -8,9 +9,21 @@ export class BucketDialogs extends ComponentSlice {
|
|
|
8
9
|
register(id, dialog) {
|
|
9
10
|
this.items.set(id, dialog);
|
|
10
11
|
}
|
|
12
|
+
/** Drops the dialog from the state; its component is disposed when the dialog closes */
|
|
11
13
|
unregister(id) {
|
|
12
14
|
this.items.delete(id);
|
|
13
|
-
this.bucket.
|
|
15
|
+
this.bucket.dispatchStateEvent();
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The dialog closed: it leaves the state and its component is disposed like the component of a closed tab.
|
|
19
|
+
* The component belongs to the dialog alone (created for it or passed in by the caller) and is not among the
|
|
20
|
+
* registered components, so the registry is left alone - a tab open under the same id keeps its component.
|
|
21
|
+
*/
|
|
22
|
+
_onClose(dialog) {
|
|
23
|
+
const id = dialog.componentId;
|
|
24
|
+
if (id != null && this.items.get(id) === dialog)
|
|
25
|
+
this.items.delete(id);
|
|
26
|
+
disposeComponent(dialog.component);
|
|
14
27
|
this.bucket.dispatchStateEvent();
|
|
15
28
|
}
|
|
16
29
|
async open(options) {
|
|
@@ -20,7 +33,7 @@ export class BucketDialogs extends ComponentSlice {
|
|
|
20
33
|
listeners: [
|
|
21
34
|
['dialog.move', () => this.bucket.dispatchStateEvent()],
|
|
22
35
|
['dialog.resize', () => this.bucket.dispatchStateEvent()],
|
|
23
|
-
['dialog.close', (e) => this.
|
|
36
|
+
['dialog.close', (e) => this._onClose(e.dialog)]
|
|
24
37
|
]
|
|
25
38
|
});
|
|
26
39
|
// compact (mobile) bucket: dialogs fill the whole bucket regardless of the requested size
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bucket.dialogs.js","sourceRoot":"","sources":["../../src/ui/bucket.dialogs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,cAAc,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"bucket.dialogs.js","sourceRoot":"","sources":["../../src/ui/bucket.dialogs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,cAAc,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAInE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,MAAM,OAAO,aAAc,SAAQ,cAAsB;IAAzD;;QAEU,UAAK,GAAG,IAAI,GAAG,EAA6B,CAAC;IAiEvD,CAAC;IA/DA,IAAI,MAAM,KAAK,OAAO,IAAI,CAAC,SAAS,CAAA,CAAC,CAAC;IAEtC,QAAQ,CAAC,EAAe,EAAE,MAAoB;QAC7C,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IAC5B,CAAC;IAED,wFAAwF;IACxF,UAAU,CAAC,EAAe;QACzB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACtB,IAAI,CAAC,MAAM,CAAC,kBAAkB,EAAE,CAAC;IAClC,CAAC;IAED;;;;OAIG;IACK,QAAQ,CAAC,MAAoB;QACpC,MAAM,EAAE,GAAG,MAAM,CAAC,WAAW,CAAC;QAC9B,IAAI,EAAE,IAAI,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,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,CAAC;YAC9B,SAAS,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YAC1D,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;QACnC,CAAC;QAED,MAAM,CAAC,UAAU,EAAE,CAAC;QACpB,MAAM,CAAC,SAAS,GAAG,SAAS,CAAC;QAE7B,yEAAyE;QACzE,IAAI,OAAO,CAAC,EAAE,EAAE,CAAC;YAChB,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;YAClC,IAAI,CAAC,MAAM,CAAC,kBAAkB,EAAE,CAAC;QAClC,CAAC;QAED,8BAA8B;QAE9B,OAAO,MAAM,CAAC;IACf,CAAC;CAED","sourcesContent":["import { ComponentId, ComponentSlice, dom } from \"@omegagrid/core\";\nimport { Bucket } from \"./bucket\";\nimport { BucketDialog, OpenDialogOptions } from \"../types\";\nimport { DialogEvent } from \"@omegagrid/dialog\";\nimport { disposeComponent } from \"./bucket.components\";\n\nexport class BucketDialogs extends ComponentSlice<Bucket> {\n\n\treadonly items = new Map<ComponentId, BucketDialog>();\n\n\tget bucket() { return this.component }\n\n\tregister(id: ComponentId, dialog: BucketDialog) {\n\t\tthis.items.set(id, dialog);\n\t}\n\n\t/** Drops the dialog from the state; its component is disposed when the dialog closes */\n\tunregister(id: ComponentId) {\n\t\tthis.items.delete(id);\n\t\tthis.bucket.dispatchStateEvent();\n\t}\n\n\t/**\n\t * The dialog closed: it leaves the state and its component is disposed like the component of a closed tab.\n\t * The component belongs to the dialog alone (created for it or passed in by the caller) and is not among the\n\t * registered components, so the registry is left alone - a tab open under the same id keeps its component.\n\t */\n\tprivate _onClose(dialog: BucketDialog) {\n\t\tconst id = dialog.componentId;\n\t\tif (id != null && this.items.get(id) === dialog) this.items.delete(id);\n\t\tdisposeComponent(dialog.component);\n\t\tthis.bucket.dispatchStateEvent();\n\t}\n\n\tasync open(options: OpenDialogOptions) {\n\t\tconst dialog = dom.createElement<BucketDialog>('og-dialog', {\n\t\t\tcomponentId: options.id,\n\t\t\tmaximizable: options.maximizable ?? true,\n\t\t\tlisteners: [\n\t\t\t\t['dialog.move', () => this.bucket.dispatchStateEvent()],\n\t\t\t\t['dialog.resize', () => this.bucket.dispatchStateEvent()],\n\t\t\t\t['dialog.close', (e: DialogEvent) => this._onClose(e.dialog as BucketDialog)]\n\t\t\t]\n\t\t});\n\t\t// compact (mobile) bucket: dialogs fill the whole bucket regardless of the requested size\n\t\tdialog.setOptions(this.bucket.compact\n\t\t\t? {...options, width: '100%', height: '100%', location: {x: 0, y: 0}, resizable: false}\n\t\t\t: options\n\t\t);\n\t\tdialog.open(this.bucket);\n\t\tdialog.showLoader();\n\n\t\tlet component = options.component;\n\t\tdelete options.component;\n\t\tif (!component && options.id) {\n\t\t\tcomponent = await this.bucket.createComponent(options.id);\n\t\t\tthis.register(options.id, dialog);\n\t\t}\n\n\t\tdialog.hideLoader();\n\t\tdialog.component = component;\n\n\t\t// dialog without component id cannot be registered and included in state\n\t\tif (options.id) {\n\t\t\tthis.register(options.id, dialog);\n\t\t\tthis.bucket.dispatchStateEvent();\n\t\t}\n\n\t\t// TODO - fix dialog position;\n\n\t\treturn dialog;\n\t}\n\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omegagrid/bucket",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.32",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"description": "Application layout component",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@fortawesome/fontawesome-svg-core": "^7.0.1",
|
|
31
|
-
"@omegagrid/commands": "^0.11.
|
|
32
|
-
"@omegagrid/core": "^0.11.
|
|
33
|
-
"@omegagrid/dialog": "^0.11.
|
|
34
|
-
"@omegagrid/localize": "^0.11.
|
|
35
|
-
"@omegagrid/tabs": "^0.11.
|
|
31
|
+
"@omegagrid/commands": "^0.11.32",
|
|
32
|
+
"@omegagrid/core": "^0.11.32",
|
|
33
|
+
"@omegagrid/dialog": "^0.11.32",
|
|
34
|
+
"@omegagrid/localize": "^0.11.32",
|
|
35
|
+
"@omegagrid/tabs": "^0.11.32",
|
|
36
36
|
"lit": "^3.1.1",
|
|
37
37
|
"ts-debounce": "^4.0.0"
|
|
38
38
|
},
|