@celljs/widget 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/cell.yml +3 -0
- package/lib/browser/annotation/index.d.ts +2 -0
- package/lib/browser/annotation/index.d.ts.map +1 -0
- package/lib/browser/annotation/index.js +18 -0
- package/lib/browser/annotation/index.js.map +1 -0
- package/lib/browser/annotation/widget.d.ts +10 -0
- package/lib/browser/annotation/widget.d.ts.map +1 -0
- package/lib/browser/annotation/widget.js +30 -0
- package/lib/browser/annotation/widget.js.map +1 -0
- package/lib/browser/index.d.ts +6 -0
- package/lib/browser/index.d.ts.map +1 -0
- package/lib/browser/index.js +22 -0
- package/lib/browser/index.js.map +1 -0
- package/lib/browser/keyboard/index.d.ts +2 -0
- package/lib/browser/keyboard/index.d.ts.map +1 -0
- package/lib/browser/keyboard/index.js +18 -0
- package/lib/browser/keyboard/index.js.map +1 -0
- package/lib/browser/keyboard/keys.d.ts +254 -0
- package/lib/browser/keyboard/keys.d.ts.map +1 -0
- package/lib/browser/keyboard/keys.js +620 -0
- package/lib/browser/keyboard/keys.js.map +1 -0
- package/lib/browser/locale/index.d.ts +3 -0
- package/lib/browser/locale/index.d.ts.map +1 -0
- package/lib/browser/locale/index.js +19 -0
- package/lib/browser/locale/index.js.map +1 -0
- package/lib/browser/locale/locale-manager.d.ts +14 -0
- package/lib/browser/locale/locale-manager.d.ts.map +1 -0
- package/lib/browser/locale/locale-manager.js +71 -0
- package/lib/browser/locale/locale-manager.js.map +1 -0
- package/lib/browser/locale/locale-protocol.d.ts +16 -0
- package/lib/browser/locale/locale-protocol.d.ts.map +1 -0
- package/lib/browser/locale/locale-protocol.js +6 -0
- package/lib/browser/locale/locale-protocol.js.map +1 -0
- package/lib/browser/module.d.ts +3 -0
- package/lib/browser/module.d.ts.map +1 -0
- package/lib/browser/module.js +5 -0
- package/lib/browser/module.js.map +1 -0
- package/lib/browser/theme/index.d.ts +3 -0
- package/lib/browser/theme/index.d.ts.map +1 -0
- package/lib/browser/theme/index.js +19 -0
- package/lib/browser/theme/index.js.map +1 -0
- package/lib/browser/theme/theme-manager.d.ts +14 -0
- package/lib/browser/theme/theme-manager.d.ts.map +1 -0
- package/lib/browser/theme/theme-manager.js +72 -0
- package/lib/browser/theme/theme-manager.js.map +1 -0
- package/lib/browser/theme/theme-protocol.d.ts +19 -0
- package/lib/browser/theme/theme-protocol.d.ts.map +1 -0
- package/lib/browser/theme/theme-protocol.js +7 -0
- package/lib/browser/theme/theme-protocol.js.map +1 -0
- package/lib/browser/widget/index.d.ts +5 -0
- package/lib/browser/widget/index.d.ts.map +1 -0
- package/lib/browser/widget/index.js +26 -0
- package/lib/browser/widget/index.js.map +1 -0
- package/lib/browser/widget/widget-factory.d.ts +10 -0
- package/lib/browser/widget/widget-factory.d.ts.map +1 -0
- package/lib/browser/widget/widget-factory.js +46 -0
- package/lib/browser/widget/widget-factory.js.map +1 -0
- package/lib/browser/widget/widget-manager.d.ts +15 -0
- package/lib/browser/widget/widget-manager.d.ts.map +1 -0
- package/lib/browser/widget/widget-manager.js +80 -0
- package/lib/browser/widget/widget-manager.js.map +1 -0
- package/lib/browser/widget/widget-protocol.d.ts +38 -0
- package/lib/browser/widget/widget-protocol.d.ts.map +1 -0
- package/lib/browser/widget/widget-protocol.js +12 -0
- package/lib/browser/widget/widget-protocol.js.map +1 -0
- package/lib/browser/widget/widget-util.d.ts +6 -0
- package/lib/browser/widget/widget-util.d.ts.map +1 -0
- package/lib/browser/widget/widget-util.js +28 -0
- package/lib/browser/widget/widget-util.js.map +1 -0
- package/lib/package.spec.d.ts +1 -0
- package/lib/package.spec.d.ts.map +1 -0
- package/lib/package.spec.js +4 -0
- package/lib/package.spec.js.map +1 -0
- package/package.json +42 -0
- package/src/browser/annotation/index.ts +1 -0
- package/src/browser/annotation/widget.ts +34 -0
- package/src/browser/index.ts +5 -0
- package/src/browser/keyboard/index.ts +1 -0
- package/src/browser/keyboard/keys.ts +678 -0
- package/src/browser/locale/index.ts +2 -0
- package/src/browser/locale/locale-manager.ts +54 -0
- package/src/browser/locale/locale-protocol.ts +18 -0
- package/src/browser/module.ts +3 -0
- package/src/browser/theme/index.ts +2 -0
- package/src/browser/theme/theme-manager.ts +53 -0
- package/src/browser/theme/theme-protocol.ts +22 -0
- package/src/browser/widget/index.ts +4 -0
- package/src/browser/widget/widget-factory.ts +36 -0
- package/src/browser/widget/widget-manager.ts +64 -0
- package/src/browser/widget/widget-protocol.ts +38 -0
- package/src/browser/widget/widget-util.ts +26 -0
- package/src/package.spec.ts +4 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/browser/locale/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./locale-protocol"), exports);
|
|
18
|
+
__exportStar(require("./locale-manager"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/browser/locale/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,mDAAiC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { LocaleManager, Locale } from './locale-protocol';
|
|
2
|
+
import { BehaviorSubject } from 'rxjs';
|
|
3
|
+
export declare class LocaleManagerImpl implements LocaleManager {
|
|
4
|
+
protected readonly langStorageKey = "cell:lang";
|
|
5
|
+
protected readonly localesForConfig: {
|
|
6
|
+
[lang: string]: Locale;
|
|
7
|
+
};
|
|
8
|
+
protected readonly locales: Locale[];
|
|
9
|
+
protected prioritized: Locale[];
|
|
10
|
+
currentSubject: BehaviorSubject<Locale | undefined>;
|
|
11
|
+
init(): void;
|
|
12
|
+
get(): Promise<Locale[]>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=locale-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale-manager.d.ts","sourceRoot":"","sources":["../../../src/browser/locale/locale-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAEvC,qBACa,iBAAkB,YAAW,aAAa;IAEnD,SAAS,CAAC,QAAQ,CAAC,cAAc,eAAe;IAGhD,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAGhE,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAErC,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,CAAC;IAEhC,cAAc,sCAAsD;IAGpE,IAAI;IAkBE,GAAG,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CAejC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.LocaleManagerImpl = void 0;
|
|
13
|
+
const locale_protocol_1 = require("./locale-protocol");
|
|
14
|
+
const core_1 = require("@celljs/core");
|
|
15
|
+
const rxjs_1 = require("rxjs");
|
|
16
|
+
let LocaleManagerImpl = class LocaleManagerImpl {
|
|
17
|
+
constructor() {
|
|
18
|
+
this.langStorageKey = 'cell:lang';
|
|
19
|
+
this.currentSubject = new rxjs_1.BehaviorSubject(undefined);
|
|
20
|
+
}
|
|
21
|
+
init() {
|
|
22
|
+
(async () => {
|
|
23
|
+
const locales = await this.get();
|
|
24
|
+
const lang = localStorage.getItem(this.langStorageKey) || navigator.language;
|
|
25
|
+
if (locales.length) {
|
|
26
|
+
this.currentSubject.next(locales.find(l => l.lang === lang) || locales[0]);
|
|
27
|
+
}
|
|
28
|
+
this.currentSubject.subscribe(locale => {
|
|
29
|
+
if (locale) {
|
|
30
|
+
localStorage.setItem(this.langStorageKey, locale.lang);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
localStorage.removeItem(this.langStorageKey);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
})();
|
|
37
|
+
}
|
|
38
|
+
async get() {
|
|
39
|
+
if (!this.prioritized) {
|
|
40
|
+
const config = this.localesForConfig || {};
|
|
41
|
+
const parsedLacalesForConfig = Object.keys(config).map(lang => {
|
|
42
|
+
const locale = Object.assign({}, config[lang]);
|
|
43
|
+
locale.lang = lang;
|
|
44
|
+
locale.priority = locale.priority || 500;
|
|
45
|
+
return locale;
|
|
46
|
+
});
|
|
47
|
+
this.prioritized = core_1.Prioritizeable.prioritizeAllSync([...parsedLacalesForConfig, ...this.locales]).map(p => p.value);
|
|
48
|
+
}
|
|
49
|
+
return this.prioritized;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
__decorate([
|
|
53
|
+
(0, core_1.Value)('cell.locales'),
|
|
54
|
+
__metadata("design:type", Object)
|
|
55
|
+
], LocaleManagerImpl.prototype, "localesForConfig", void 0);
|
|
56
|
+
__decorate([
|
|
57
|
+
(0, core_1.Autowired)(locale_protocol_1.Locale),
|
|
58
|
+
(0, core_1.Optional)(),
|
|
59
|
+
__metadata("design:type", Array)
|
|
60
|
+
], LocaleManagerImpl.prototype, "locales", void 0);
|
|
61
|
+
__decorate([
|
|
62
|
+
(0, core_1.PostConstruct)(),
|
|
63
|
+
__metadata("design:type", Function),
|
|
64
|
+
__metadata("design:paramtypes", []),
|
|
65
|
+
__metadata("design:returntype", void 0)
|
|
66
|
+
], LocaleManagerImpl.prototype, "init", null);
|
|
67
|
+
LocaleManagerImpl = __decorate([
|
|
68
|
+
(0, core_1.Component)(locale_protocol_1.LocaleManager)
|
|
69
|
+
], LocaleManagerImpl);
|
|
70
|
+
exports.LocaleManagerImpl = LocaleManagerImpl;
|
|
71
|
+
//# sourceMappingURL=locale-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale-manager.js","sourceRoot":"","sources":["../../../src/browser/locale/locale-manager.ts"],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,CAAC,CAAE,CAAC;gBACnC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;gBACnB,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,GAAG,CAAC;gBACzC,OAAO,MAAM,CAAC;YAClB,CAAC,CAAC,CAAC;YAEH,IAAI,CAAC,WAAW,GAAG,qBAAc,CAAC,iBAAiB,CAAC,CAAE,GAAG,sBAAsB,EAAE,GAAG,IAAI,CAAC,OAAO,CAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;SACzH;QACD,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;CAEJ,CAAA;AA5CG;IAAC,IAAA,YAAK,EAAC,cAAc,CAAC;;2DAC0C;AAEhE;IAAC,IAAA,gBAAS,EAAC,wBAAM,CAAC;IAAE,IAAA,eAAQ,GAAE;;kDACO;AAMrC;IAAC,IAAA,oBAAa,GAAE;;;;6CAiBf;AA/BQ,iBAAiB;IAD7B,IAAA,gBAAS,EAAC,+BAAa,CAAC;GACZ,iBAAiB,CAgD7B;AAhDY,8CAAiB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BehaviorSubject } from 'rxjs';
|
|
2
|
+
export declare const Locale: unique symbol;
|
|
3
|
+
export declare const LocaleManager: unique symbol;
|
|
4
|
+
export interface Locale {
|
|
5
|
+
lang: string;
|
|
6
|
+
priority: number;
|
|
7
|
+
label?: string;
|
|
8
|
+
messages: {
|
|
9
|
+
[key: string]: string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export interface LocaleManager {
|
|
13
|
+
currentSubject: BehaviorSubject<Locale | undefined>;
|
|
14
|
+
get(): Promise<Locale[]>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=locale-protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale-protocol.d.ts","sourceRoot":"","sources":["../../../src/browser/locale/locale-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAEvC,eAAO,MAAM,MAAM,eAAmB,CAAC;AACvC,eAAO,MAAM,aAAa,eAA0B,CAAC;AAErD,MAAM,WAAW,MAAM;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CACvC;AAED,MAAM,WAAW,aAAa;IAE1B,cAAc,EAAE,eAAe,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAEpD,GAAG,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;CAC5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale-protocol.js","sourceRoot":"","sources":["../../../src/browser/locale/locale-protocol.ts"],"names":[],"mappings":";;;AAEa,QAAA,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;AAC1B,QAAA,aAAa,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/browser/module.ts"],"names":[],"mappings":";AAEA,wBAA0B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/browser/module.ts"],"names":[],"mappings":";;AAAA,uCAAwC;AAExC,kBAAe,IAAA,eAAQ,GAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/browser/theme/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./theme-protocol"), exports);
|
|
18
|
+
__exportStar(require("./theme-manager"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/browser/theme/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,kDAAgC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Theme, ThemeManager } from './theme-protocol';
|
|
2
|
+
import { BehaviorSubject } from 'rxjs';
|
|
3
|
+
export declare class ThemeManagerImpl<T> implements ThemeManager<T> {
|
|
4
|
+
protected readonly themeStorageKey = "cell:theme";
|
|
5
|
+
protected readonly themesForConfig: {
|
|
6
|
+
[id: string]: Theme<T>;
|
|
7
|
+
};
|
|
8
|
+
protected readonly themes: Theme<T>[];
|
|
9
|
+
protected prioritized: Theme<T>[];
|
|
10
|
+
currentSubject: BehaviorSubject<Theme<T> | undefined>;
|
|
11
|
+
init(): void;
|
|
12
|
+
get(): Promise<Theme<T>[]>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=theme-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-manager.d.ts","sourceRoot":"","sources":["../../../src/browser/theme/theme-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,YAAY,EAAiB,MAAM,kBAAkB,CAAC;AAEtE,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAEvC,qBACa,gBAAgB,CAAC,CAAC,CAAE,YAAW,YAAY,CAAC,CAAC,CAAC;IAEvD,SAAS,CAAC,QAAQ,CAAC,eAAe,gBAAgB;IAGlD,SAAS,CAAC,QAAQ,CAAC,eAAe,EAAE;QAAE,CAAC,EAAE,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;KAAE,CAAC;IAG/D,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IAEtC,SAAS,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IAElC,cAAc,wCAAwD;IAGtE,IAAI;IAkBE,GAAG,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;CAcnC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ThemeManagerImpl = void 0;
|
|
13
|
+
const theme_protocol_1 = require("./theme-protocol");
|
|
14
|
+
const core_1 = require("@celljs/core");
|
|
15
|
+
const rxjs_1 = require("rxjs");
|
|
16
|
+
let ThemeManagerImpl = class ThemeManagerImpl {
|
|
17
|
+
constructor() {
|
|
18
|
+
this.themeStorageKey = 'cell:theme';
|
|
19
|
+
this.currentSubject = new rxjs_1.BehaviorSubject(undefined);
|
|
20
|
+
}
|
|
21
|
+
init() {
|
|
22
|
+
const themeStr = localStorage.getItem(this.themeStorageKey);
|
|
23
|
+
if (themeStr) {
|
|
24
|
+
this.currentSubject.next(JSON.parse(themeStr));
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
if (this.themesForConfig) {
|
|
28
|
+
this.currentSubject.next(this.themesForConfig[theme_protocol_1.DEFAULT_THEME]);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
this.currentSubject.subscribe(theme => {
|
|
32
|
+
if (theme) {
|
|
33
|
+
localStorage.setItem(this.themeStorageKey, JSON.stringify(theme));
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
localStorage.removeItem(this.themeStorageKey);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
async get() {
|
|
41
|
+
if (!this.prioritized) {
|
|
42
|
+
const parsedThemesForConfig = Object.keys(this.themesForConfig || {}).map(id => {
|
|
43
|
+
const theme = Object.assign({}, this.themesForConfig[id]);
|
|
44
|
+
theme.id = id;
|
|
45
|
+
theme.priority = theme.priority || 500;
|
|
46
|
+
return theme;
|
|
47
|
+
});
|
|
48
|
+
this.prioritized = core_1.Prioritizeable.prioritizeAllSync([...parsedThemesForConfig, ...this.themes]).map(p => p.value);
|
|
49
|
+
}
|
|
50
|
+
return this.prioritized;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
__decorate([
|
|
54
|
+
(0, core_1.Value)('cell.themes'),
|
|
55
|
+
__metadata("design:type", Object)
|
|
56
|
+
], ThemeManagerImpl.prototype, "themesForConfig", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
(0, core_1.Autowired)(theme_protocol_1.Theme),
|
|
59
|
+
(0, core_1.Optional)(),
|
|
60
|
+
__metadata("design:type", Array)
|
|
61
|
+
], ThemeManagerImpl.prototype, "themes", void 0);
|
|
62
|
+
__decorate([
|
|
63
|
+
(0, core_1.PostConstruct)(),
|
|
64
|
+
__metadata("design:type", Function),
|
|
65
|
+
__metadata("design:paramtypes", []),
|
|
66
|
+
__metadata("design:returntype", void 0)
|
|
67
|
+
], ThemeManagerImpl.prototype, "init", null);
|
|
68
|
+
ThemeManagerImpl = __decorate([
|
|
69
|
+
(0, core_1.Component)(theme_protocol_1.ThemeManager)
|
|
70
|
+
], ThemeManagerImpl);
|
|
71
|
+
exports.ThemeManagerImpl = ThemeManagerImpl;
|
|
72
|
+
//# sourceMappingURL=theme-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-manager.js","sourceRoot":"","sources":["../../../src/browser/theme/theme-manager.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAsE;AACtE,uCAAoG;AACpG,+BAAuC;AAGhC,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAAtB;QAEgB,oBAAe,GAAG,YAAY,CAAC;QAUlD,mBAAc,GAAG,IAAI,sBAAe,CAAuB,SAAS,CAAC,CAAC;IAmC1E,CAAC;IAhCG,IAAI;QACA,MAAM,QAAQ,GAAG,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QAC5D,IAAI,QAAQ,EAAE;YACV,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC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C,sBAAK,CAAC;IAAE,IAAA,eAAQ,GAAE;;gDACS;AAMtC;IAAC,IAAA,oBAAa,GAAE;;;;4CAiBf;AA/BQ,gBAAgB;IAD5B,IAAA,gBAAS,EAAC,6BAAY,CAAC;GACX,gBAAgB,CA+C5B;AA/CY,4CAAgB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BehaviorSubject } from 'rxjs';
|
|
2
|
+
export declare const Theme: unique symbol;
|
|
3
|
+
export declare const ThemeManager: unique symbol;
|
|
4
|
+
export declare const DEFAULT_THEME = "default";
|
|
5
|
+
export interface Theme<T> {
|
|
6
|
+
id: string;
|
|
7
|
+
label: string;
|
|
8
|
+
color: string;
|
|
9
|
+
priority: number;
|
|
10
|
+
props: T;
|
|
11
|
+
metadata: {
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export interface ThemeManager<T> {
|
|
16
|
+
currentSubject: BehaviorSubject<Theme<T> | undefined>;
|
|
17
|
+
get(): Promise<Theme<T>[]>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=theme-protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-protocol.d.ts","sourceRoot":"","sources":["../../../src/browser/theme/theme-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAEvC,eAAO,MAAM,KAAK,eAAkB,CAAC;AACrC,eAAO,MAAM,YAAY,eAAyB,CAAC;AAEnD,eAAO,MAAM,aAAa,YAAY,CAAC;AAEvC,MAAM,WAAW,KAAK,CAAC,CAAC;IACpB,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,CAAC,CAAC;IACT,QAAQ,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAA;CACnC;AAED,MAAM,WAAW,YAAY,CAAC,CAAC;IAE3B,cAAc,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;IAEtD,GAAG,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;CAC9B"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_THEME = exports.ThemeManager = exports.Theme = void 0;
|
|
4
|
+
exports.Theme = Symbol('Theme');
|
|
5
|
+
exports.ThemeManager = Symbol('ThemeManager');
|
|
6
|
+
exports.DEFAULT_THEME = 'default';
|
|
7
|
+
//# sourceMappingURL=theme-protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-protocol.js","sourceRoot":"","sources":["../../../src/browser/theme/theme-protocol.ts"],"names":[],"mappings":";;;AAEa,QAAA,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;AACxB,QAAA,YAAY,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;AAEtC,QAAA,aAAa,GAAG,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/browser/widget/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC1F,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.WidgetType = exports.WidgetManager = exports.WidgetModel = exports.WidgetFactory = void 0;
|
|
18
|
+
var widget_protocol_1 = require("./widget-protocol");
|
|
19
|
+
Object.defineProperty(exports, "WidgetFactory", { enumerable: true, get: function () { return widget_protocol_1.WidgetFactory; } });
|
|
20
|
+
Object.defineProperty(exports, "WidgetModel", { enumerable: true, get: function () { return widget_protocol_1.WidgetModel; } });
|
|
21
|
+
Object.defineProperty(exports, "WidgetManager", { enumerable: true, get: function () { return widget_protocol_1.WidgetManager; } });
|
|
22
|
+
Object.defineProperty(exports, "WidgetType", { enumerable: true, get: function () { return widget_protocol_1.WidgetType; } });
|
|
23
|
+
__exportStar(require("./widget-manager"), exports);
|
|
24
|
+
__exportStar(require("./widget-factory"), exports);
|
|
25
|
+
__exportStar(require("./widget-util"), exports);
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/browser/widget/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qDAA0F;AAAjF,gHAAA,aAAa,OAAA;AAAE,8GAAA,WAAW,OAAA;AAAE,gHAAA,aAAa,OAAA;AAAE,6GAAA,UAAU,OAAA;AAC9D,mDAAiC;AACjC,mDAAiC;AACjC,gDAA8B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { WidgetModel, WidgetFactory, Widget } from './widget-protocol';
|
|
2
|
+
import { ExpressionHandler } from '@celljs/core';
|
|
3
|
+
export declare abstract class AbstractWidgetFactory<T> implements WidgetFactory<T> {
|
|
4
|
+
protected readonly expressionHandler: ExpressionHandler;
|
|
5
|
+
priority: number;
|
|
6
|
+
create(widgetModel: WidgetModel): Promise<Widget<T>>;
|
|
7
|
+
support(widgetModel: WidgetModel): Promise<boolean>;
|
|
8
|
+
protected abstract doRender(widgetModel: WidgetModel, children: Widget<T>[]): Promise<T>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=widget-factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widget-factory.d.ts","sourceRoot":"","sources":["../../../src/browser/widget/widget-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEvE,OAAO,EAAa,iBAAiB,EAAc,MAAM,cAAc,CAAC;AAExE,8BACsB,qBAAqB,CAAC,CAAC,CAAE,YAAW,aAAa,CAAC,CAAC,CAAC;IAGtE,SAAS,CAAC,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAExD,QAAQ,EAAE,MAAM,CAAO;IAEjB,MAAM,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAiBpD,OAAO,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;IAIzD,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC;CAE3F"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AbstractWidgetFactory = void 0;
|
|
13
|
+
const widget_util_1 = require("./widget-util");
|
|
14
|
+
const core_1 = require("@celljs/core");
|
|
15
|
+
let AbstractWidgetFactory = class AbstractWidgetFactory {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.priority = 500;
|
|
18
|
+
}
|
|
19
|
+
async create(widgetModel) {
|
|
20
|
+
const { children = [] } = widgetModel;
|
|
21
|
+
return {
|
|
22
|
+
id: widgetModel.id,
|
|
23
|
+
visible: widgetModel.visible,
|
|
24
|
+
area: widgetModel.area,
|
|
25
|
+
priority: widgetModel.priority,
|
|
26
|
+
render: async () => {
|
|
27
|
+
if (widgetModel.props) {
|
|
28
|
+
this.expressionHandler.handle(widgetModel.props);
|
|
29
|
+
}
|
|
30
|
+
return this.doRender(widgetModel, await Promise.all(children.map(c => widget_util_1.WidgetUtil.create(c))));
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
async support(widgetModel) {
|
|
35
|
+
return this.constructor.name.startsWith(widgetModel.type);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, core_1.Autowired)(core_1.ExpressionHandler),
|
|
40
|
+
__metadata("design:type", Object)
|
|
41
|
+
], AbstractWidgetFactory.prototype, "expressionHandler", void 0);
|
|
42
|
+
AbstractWidgetFactory = __decorate([
|
|
43
|
+
(0, core_1.Injectable)()
|
|
44
|
+
], AbstractWidgetFactory);
|
|
45
|
+
exports.AbstractWidgetFactory = AbstractWidgetFactory;
|
|
46
|
+
//# sourceMappingURL=widget-factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widget-factory.js","sourceRoot":"","sources":["../../../src/browser/widget/widget-factory.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,+CAA2C;AAC3C,uCAAwE;AAGjE,IAAe,qBAAqB,GAApC,MAAe,qBAAqB;IAApC;QAKH,aAAQ,GAAW,GAAG,CAAC;IAyB3B,CAAC;IAvBG,KAAK,CAAC,MAAM,CAAC,WAAwB;QACjC,MAAM,EAAE,QAAQ,GAAG,EAAE,EAAE,GAAG,WAAW,CAAC;QAEtC,OAAO;YACH,EAAE,EAAE,WAAW,CAAC,EAAE;YAClB,OAAO,EAAE,WAAW,CAAC,OAAO;YAC5B,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,QAAQ,EAAE,WAAW,CAAC,QAAQ;YAC9B,MAAM,EAAE,KAAK,IAAI,EAAE;gBACf,IAAI,WAAW,CAAC,KAAK,EAAE;oBACnB,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;iBACpD;gBACD,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,wBAAU,CAAC,MAAM,CAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACrG,CAAC;SACJ,CAAC;IACN,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,WAAwB;QAClC,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAC9D,CAAC;CAIJ,CAAA;AA5BG;IAAC,IAAA,gBAAS,EAAC,wBAAiB,CAAC;;gEAC2B;AAHtC,qBAAqB;IAD1C,IAAA,iBAAU,GAAE;GACS,qBAAqB,CA8B1C;AA9BqB,sDAAqB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { WidgetManager, WidgetModel, Widget } from './widget-protocol';
|
|
2
|
+
export declare class WidgetManagerImpl<T> implements WidgetManager<T> {
|
|
3
|
+
protected readonly widgets: Widget<T>[];
|
|
4
|
+
protected readonly widgetModels: WidgetModel[];
|
|
5
|
+
protected readonly widgetModelsForConfig: {
|
|
6
|
+
[id: string]: WidgetModel;
|
|
7
|
+
};
|
|
8
|
+
protected prioritized: Map<string, Widget<T>[]>;
|
|
9
|
+
constructor(widgets: Widget<T>[], widgetModels: WidgetModel[], widgetModelsForConfig: {
|
|
10
|
+
[id: string]: WidgetModel;
|
|
11
|
+
});
|
|
12
|
+
render(area: string): Promise<T[]>;
|
|
13
|
+
get(area: string): Promise<Widget<T>[]>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=widget-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widget-manager.d.ts","sourceRoot":"","sources":["../../../src/browser/widget/widget-manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAGvE,qBACa,iBAAiB,CAAC,CAAC,CAAE,YAAW,aAAa,CAAC,CAAC,CAAC;IAKtB,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE;IAClC,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,WAAW,EAAE;IACpD,SAAS,CAAC,QAAQ,CAAC,qBAAqB,EAAE;QAAE,CAAC,EAAE,EAAE,MAAM,GAAG,WAAW,CAAA;KAAE;IALzG,SAAS,CAAC,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;gBAGM,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,EACf,YAAY,EAAE,WAAW,EAAE,EACjC,qBAAqB,EAAE;QAAE,CAAC,EAAE,EAAE,MAAM,GAAG,WAAW,CAAA;KAAE;IAGnG,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC;IAKlC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;CA2ChD"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.WidgetManagerImpl = void 0;
|
|
16
|
+
const core_1 = require("@celljs/core");
|
|
17
|
+
const widget_protocol_1 = require("./widget-protocol");
|
|
18
|
+
const widget_util_1 = require("./widget-util");
|
|
19
|
+
let WidgetManagerImpl = class WidgetManagerImpl {
|
|
20
|
+
constructor(widgets, widgetModels, widgetModelsForConfig) {
|
|
21
|
+
this.widgets = widgets;
|
|
22
|
+
this.widgetModels = widgetModels;
|
|
23
|
+
this.widgetModelsForConfig = widgetModelsForConfig;
|
|
24
|
+
}
|
|
25
|
+
async render(area) {
|
|
26
|
+
const widgets = await this.get(area);
|
|
27
|
+
return Promise.all(widgets.map(w => w.render()));
|
|
28
|
+
}
|
|
29
|
+
async get(area) {
|
|
30
|
+
if (!this.prioritized) {
|
|
31
|
+
const result = new Map();
|
|
32
|
+
const config = Object.assign({}, this.widgetModelsForConfig);
|
|
33
|
+
this.widgets.forEach(w => {
|
|
34
|
+
const c = config[w.id];
|
|
35
|
+
if (config) {
|
|
36
|
+
w.area = c.area;
|
|
37
|
+
w.priority = c.priority === undefined ? w.priority : c.priority;
|
|
38
|
+
w.visible = c.visible === undefined ? w.visible : c.visible;
|
|
39
|
+
delete config[w.id];
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
const parsedWdigets = await Promise.all(this.widgetModels.map(w => {
|
|
43
|
+
const c = config[w.id];
|
|
44
|
+
delete config[w.id];
|
|
45
|
+
return widget_util_1.WidgetUtil.create(Object.assign(Object.assign({}, w), c));
|
|
46
|
+
}));
|
|
47
|
+
const parsedWidgetsForConfig = await Promise.all((Object.keys(config).map(id => {
|
|
48
|
+
const widgetModel = Object.assign({}, config[id]);
|
|
49
|
+
widgetModel.id = id;
|
|
50
|
+
widgetModel.priority = widgetModel.priority || 500;
|
|
51
|
+
widgetModel.visible = widgetModel.visible === false ? false : true;
|
|
52
|
+
return widget_util_1.WidgetUtil.create(widgetModel);
|
|
53
|
+
})));
|
|
54
|
+
for (const widget of [...this.widgets, ...parsedWdigets, ...parsedWidgetsForConfig]) {
|
|
55
|
+
if (!result.has(widget.area)) {
|
|
56
|
+
result.set(widget.area, []);
|
|
57
|
+
}
|
|
58
|
+
if (widget.visible) {
|
|
59
|
+
result.get(widget.area).push(widget);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
for (const [a, ws] of result.entries()) {
|
|
63
|
+
result.set(a, core_1.Prioritizeable.prioritizeAllSync(ws).map(c => c.value));
|
|
64
|
+
}
|
|
65
|
+
this.prioritized = result;
|
|
66
|
+
}
|
|
67
|
+
return this.prioritized.get(area) || [];
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
WidgetManagerImpl = __decorate([
|
|
71
|
+
(0, core_1.Component)(widget_protocol_1.WidgetManager),
|
|
72
|
+
__param(0, (0, core_1.Autowired)(widget_protocol_1.Widget)),
|
|
73
|
+
__param(0, (0, core_1.Optional)()),
|
|
74
|
+
__param(1, (0, core_1.Autowired)(widget_protocol_1.WidgetModel)),
|
|
75
|
+
__param(1, (0, core_1.Optional)()),
|
|
76
|
+
__param(2, (0, core_1.Value)('cell.widget.widgets')),
|
|
77
|
+
__metadata("design:paramtypes", [Array, Array, Object])
|
|
78
|
+
], WidgetManagerImpl);
|
|
79
|
+
exports.WidgetManagerImpl = WidgetManagerImpl;
|
|
80
|
+
//# sourceMappingURL=widget-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widget-manager.js","sourceRoot":"","sources":["../../../src/browser/widget/widget-manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uCAAqF;AACrF,uDAAuE;AACvE,+CAA2C;AAGpC,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAI1B,YACsD,OAAoB,EACf,YAA2B,EACjC,qBAAoD;QAFnD,YAAO,GAAP,OAAO,CAAa;QACf,iBAAY,GAAZ,YAAY,CAAe;QACjC,0BAAqB,GAArB,qBAAqB,CAA+B;IACtG,CAAC;IAEJ,KAAK,CAAC,MAAM,CAAC,IAAY;QACrB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACrC,OAA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IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IAC5C,CAAC;CAEJ,CAAA;AA1DY,iBAAiB;IAD7B,IAAA,gBAAS,EAAC,+BAAa,CAAC;IAMhB,WAAA,IAAA,gBAAS,EAAC,wBAAM,CAAC,CAAA;IAAE,WAAA,IAAA,eAAQ,GAAE,CAAA;IAC7B,WAAA,IAAA,gBAAS,EAAC,6BAAW,CAAC,CAAA;IAAE,WAAA,IAAA,eAAQ,GAAE,CAAA;IAClC,WAAA,IAAA,YAAK,EAAC,qBAAqB,CAAC,CAAA;;GAPxB,iBAAiB,CA0D7B;AA1DY,8CAAiB"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export declare const Widget: unique symbol;
|
|
2
|
+
export declare const WidgetModel: unique symbol;
|
|
3
|
+
export declare const WidgetFactory: unique symbol;
|
|
4
|
+
export declare const WidgetManager: unique symbol;
|
|
5
|
+
export declare enum WidgetType {
|
|
6
|
+
Decorator = "Decorator"
|
|
7
|
+
}
|
|
8
|
+
export interface Widget<T> {
|
|
9
|
+
id: string;
|
|
10
|
+
priority: number;
|
|
11
|
+
area?: string;
|
|
12
|
+
visible: boolean;
|
|
13
|
+
render(): Promise<T>;
|
|
14
|
+
}
|
|
15
|
+
export interface WidgetModel {
|
|
16
|
+
id: string;
|
|
17
|
+
type: string;
|
|
18
|
+
priority: number;
|
|
19
|
+
visible: boolean;
|
|
20
|
+
area?: string;
|
|
21
|
+
props?: {
|
|
22
|
+
[key: string]: any;
|
|
23
|
+
};
|
|
24
|
+
matedata?: {
|
|
25
|
+
[key: string]: any;
|
|
26
|
+
};
|
|
27
|
+
children?: WidgetModel[];
|
|
28
|
+
}
|
|
29
|
+
export interface WidgetFactory<T> {
|
|
30
|
+
priority: number;
|
|
31
|
+
create(widgetModel: WidgetModel): Promise<Widget<T>>;
|
|
32
|
+
support(widgetModel: WidgetModel): Promise<boolean>;
|
|
33
|
+
}
|
|
34
|
+
export interface WidgetManager<T> {
|
|
35
|
+
get(area: string): Promise<Widget<T>[]>;
|
|
36
|
+
render(area: string): Promise<T[]>;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=widget-protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widget-protocol.d.ts","sourceRoot":"","sources":["../../../src/browser/widget/widget-protocol.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM,eAAmB,CAAC;AACvC,eAAO,MAAM,WAAW,eAAwB,CAAC;AACjD,eAAO,MAAM,aAAa,eAA0B,CAAC;AACrD,eAAO,MAAM,aAAa,eAA0B,CAAC;AAErD,oBAAY,UAAU;IAClB,SAAS,cAAc;CAC1B;AAED,MAAM,WAAW,MAAM,CAAC,CAAC;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;CACxB;AAED,MAAM,WAAW,WAAW;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;IAC/B,QAAQ,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;IAClC,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAA;CAC3B;AAED,MAAM,WAAW,aAAa,CAAC,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IACrD,OAAO,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACvD;AAED,MAAM,WAAW,aAAa,CAAC,CAAC;IAC5B,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACxC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;CACtC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WidgetType = exports.WidgetManager = exports.WidgetFactory = exports.WidgetModel = exports.Widget = void 0;
|
|
4
|
+
exports.Widget = Symbol('Widget');
|
|
5
|
+
exports.WidgetModel = Symbol('WidgetModel');
|
|
6
|
+
exports.WidgetFactory = Symbol('WidgetFactory');
|
|
7
|
+
exports.WidgetManager = Symbol('WidgetManager');
|
|
8
|
+
var WidgetType;
|
|
9
|
+
(function (WidgetType) {
|
|
10
|
+
WidgetType["Decorator"] = "Decorator";
|
|
11
|
+
})(WidgetType = exports.WidgetType || (exports.WidgetType = {}));
|
|
12
|
+
//# sourceMappingURL=widget-protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widget-protocol.js","sourceRoot":"","sources":["../../../src/browser/widget/widget-protocol.ts"],"names":[],"mappings":";;;AAAa,QAAA,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;AAC1B,QAAA,WAAW,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;AACpC,QAAA,aAAa,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC;AACxC,QAAA,aAAa,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC;AAErD,IAAY,UAEX;AAFD,WAAY,UAAU;IAClB,qCAAuB,CAAA;AAC3B,CAAC,EAFW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAErB"}
|