@rws-framework/client 2.20.1 → 2.20.2
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/.bin/emerge.sh +15 -15
- package/builder/vite/index.ts +4 -4
- package/builder/vite/rws.vite.config.ts +132 -132
- package/builder/vite/rws_scss_plugin.ts +61 -61
- package/builder/webpack/index.js +10 -10
- package/builder/webpack/rws.webpack.config.js +161 -161
- package/builder/webpack/rws_scss_plugin.js +90 -90
- package/builder/webpack/rws_webpack_plugin.js +137 -137
- package/cfg/_default.cfg.js +26 -26
- package/cfg/_storage.d.ts +22 -22
- package/cfg/_storage.js +42 -42
- package/cfg/tsconfigSetup.js +146 -146
- package/docs/assets/26e93147f10415a0ed4a.svg +6 -6
- package/docs/assets/75c9471662e97ee24f29.svg +7 -7
- package/docs/assets/db90e4df2373980c497d.svg +9 -9
- package/docs/assets/highlight.css +127 -127
- package/docs/assets/main.js +59 -59
- package/docs/assets/style.css +1414 -1414
- package/docs/classes/ApiServiceInstance.html +25 -25
- package/docs/classes/ConfigServiceInstance.html +21 -21
- package/docs/classes/DOMServiceInstance.html +17 -17
- package/docs/classes/NotifyServiceInstance.html +15 -15
- package/docs/classes/RWSClientInstance.html +45 -45
- package/docs/classes/RWSPlugin.html +13 -13
- package/docs/classes/RWSService.html +10 -10
- package/docs/classes/RWSViewComponent.html +1022 -1022
- package/docs/classes/ServiceWorkerServiceInstance.html +13 -13
- package/docs/classes/UtilsServiceInstance.html +13 -13
- package/docs/functions/attr.html +5 -5
- package/docs/functions/observable.html +3 -3
- package/docs/index.html +179 -179
- package/docs/interfaces/HTMLTag.html +3 -3
- package/docs/interfaces/IRWSConfig.html +20 -20
- package/docs/interfaces/IRWSDecoratorOptions.html +5 -5
- package/docs/interfaces/IRWSHttpRoute.html +2 -2
- package/docs/interfaces/IRWSPrefixedHTTProutes.html +2 -2
- package/docs/interfaces/IRWSUser.html +5 -5
- package/docs/modules.html +45 -45
- package/foundation/index.js +1 -1
- package/foundation/rws-foundation.d.ts +7 -7
- package/foundation/rws-foundation.js +7 -7
- package/package.json +1 -1
- package/service_worker/src/_service_worker.ts +83 -83
- package/service_worker/tsconfig.json +20 -20
- package/service_worker/webpack.config.js +66 -66
- package/src/client/components.ts +67 -67
- package/src/client/config.ts +175 -175
- package/src/client/hotReload.ts +22 -22
- package/src/client/services.ts +27 -27
- package/src/client.ts +208 -208
- package/src/components/_component.ts +247 -247
- package/src/components/_container.ts +15 -15
- package/src/components/_decorator.ts +122 -122
- package/src/components/_definitions.ts +64 -64
- package/src/components/_event_handling.ts +40 -40
- package/src/components/index.ts +25 -25
- package/src/index.ts +86 -86
- package/src/plugins/_builder.js +31 -31
- package/src/plugins/_plugin.ts +60 -60
- package/src/services/ApiService.ts +105 -105
- package/src/services/ConfigService.ts +125 -125
- package/src/services/DOMService.ts +93 -93
- package/src/services/NotifyService.ts +47 -47
- package/src/services/ServiceWorkerService.ts +60 -60
- package/src/services/UtilsService.ts +60 -60
- package/src/services/_service.ts +64 -64
- package/src/styles/README.md +157 -157
- package/src/styles/_darkreader.scss +30 -30
- package/src/styles/_grid.scss +75 -75
- package/src/styles/_grid_legacy.scss +49 -49
- package/src/styles/_misc.scss +8 -8
- package/src/styles/_scrollbars.scss +40 -40
- package/src/styles/includes.scss +6 -6
- package/src/types/IBackendCore.ts +11 -11
- package/src/types/IRWSConfig.ts +29 -29
- package/src/types/IRWSPlugin.ts +23 -23
- package/src/types/IRWSResource.ts +4 -4
- package/src/types/IRWSUser.ts +6 -6
- package/src/types/IRWSViewComponent.ts +36 -36
- package/src/types/IReFormerField.ts +4 -4
- package/src/types/RWSNotify.ts +6 -6
- package/src/types/RWSWindow.ts +41 -41
- package/types/declarations.d.ts +8 -8
- package/types/docs-typings.d.ts +15 -15
|
@@ -1,123 +1,123 @@
|
|
|
1
|
-
import RWSContainer from './_container';
|
|
2
|
-
import TheRWSService from '../services/_service';
|
|
3
|
-
import ConfigService from '../services/ConfigService';
|
|
4
|
-
import { loadRWSRichWindow } from '../types/RWSWindow';
|
|
5
|
-
import RWSViewComponent, { IWithCompose } from './_component';
|
|
6
|
-
import { InterfaceSymbol } from './_container';
|
|
7
|
-
import { RWSInject } from './_decorators/RWSInject';
|
|
8
|
-
import { ElementStyles, Observable, ViewTemplate } from '@microsoft/fast-element';
|
|
9
|
-
import { handleExternalChange } from './_attrs/_external_handler';
|
|
10
|
-
|
|
11
|
-
interface RWSDecoratorOptions {
|
|
12
|
-
template?: string,
|
|
13
|
-
styles?: string,
|
|
14
|
-
fastElementOptions?: any,
|
|
15
|
-
ignorePackaging?: boolean,
|
|
16
|
-
debugPackaging?: boolean
|
|
17
|
-
oreoMode?: boolean
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
//const _PARAMTYPES_METADATA_KEY = 'design:paramtypes';
|
|
21
|
-
type HtmlBinderType = (context: RWSViewComponent) => ViewTemplate;
|
|
22
|
-
|
|
23
|
-
function RWSView<Component extends RWSViewComponent>(name: string, data?: RWSDecoratorOptions | null, override?: { styles?: ElementStyles, template?: ViewTemplate, options?: any }): (type: any, args?: any) => void {
|
|
24
|
-
return (theComponent: IWithCompose<Component>, args?: any) => {
|
|
25
|
-
theComponent.definition = { name, template: null }
|
|
26
|
-
|
|
27
|
-
if(override){
|
|
28
|
-
if(override.styles){
|
|
29
|
-
theComponent.definition.styles = override.styles;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if(override.template){
|
|
33
|
-
theComponent.definition.template = override.template;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if(override.options){
|
|
38
|
-
(theComponent.definition as any).options = override.options;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
function RWSIgnore(params: { mergeToApp?: boolean } | null = null): () => void {
|
|
46
|
-
return () => { };
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function getParentConstructor(instance: any): any {
|
|
50
|
-
const proto = Object.getPrototypeOf(instance.constructor.prototype);
|
|
51
|
-
if (proto && proto.constructor) {
|
|
52
|
-
return proto.constructor;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const applyConstructor = (component: RWSViewComponent, x: boolean = false): void => {
|
|
60
|
-
const mainConstructor: any = component.constructor;
|
|
61
|
-
const parent = getParentConstructor(component);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (parent.name !== 'RWSViewComponent' ) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const existingInjectedDependencies = (mainConstructor as IWithCompose<RWSViewComponent>)._toInject;
|
|
70
|
-
|
|
71
|
-
const regServices = loadRWSRichWindow().RWS._registered;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const depsToInject: string[] = (mainConstructor as IWithCompose<RWSViewComponent>)._depKeys[mainConstructor.name] || [];
|
|
75
|
-
const depsInInjector: string[] = Object.keys(existingInjectedDependencies);
|
|
76
|
-
|
|
77
|
-
const toInject: string[] = [...depsToInject]
|
|
78
|
-
|
|
79
|
-
type KeyType = {[key: string]: TheRWSService | string };
|
|
80
|
-
|
|
81
|
-
const _target = (component as any);
|
|
82
|
-
|
|
83
|
-
function inject(services: KeyType){
|
|
84
|
-
for (const prop in services) {
|
|
85
|
-
const service = (typeof services[prop] === 'string' ? existingInjectedDependencies[prop] : services[prop]) as TheRWSService;
|
|
86
|
-
_target[prop] = service;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
inject(toInject.reduce((acc: KeyType, cur) => {
|
|
91
|
-
acc[cur] = cur;
|
|
92
|
-
return acc;
|
|
93
|
-
}, {}));
|
|
94
|
-
|
|
95
|
-
const defaultDeps: [string, TheRWSService][] = Object.keys(existingInjectedDependencies)
|
|
96
|
-
.filter((depKey: string) => existingInjectedDependencies[depKey].isDefault()).map((depKey => [depKey, existingInjectedDependencies[depKey]]));
|
|
97
|
-
|
|
98
|
-
inject(defaultDeps.reduce((acc: KeyType, cur: [string, TheRWSService]) => {
|
|
99
|
-
acc[cur[0]] = cur[1];
|
|
100
|
-
return acc;
|
|
101
|
-
}, {}));
|
|
102
|
-
|
|
103
|
-
inject({
|
|
104
|
-
config: RWSContainer().get(ConfigService)
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
if(Object.keys(RWSViewComponent._externalAttrs).includes((_target.constructor as IWithCompose<any>).name)){
|
|
108
|
-
for(const exAttrKey in RWSViewComponent._externalAttrs[(_target.constructor as IWithCompose<any>).name]){
|
|
109
|
-
const exAttr = RWSViewComponent._externalAttrs[(_target.constructor as IWithCompose<any>).name][exAttrKey];
|
|
110
|
-
const notifier = Observable.getNotifier(_target);
|
|
111
|
-
notifier.subscribe({
|
|
112
|
-
handleChange(source, key) {
|
|
113
|
-
if (key === exAttr && !_target.__exAttrLoaded.includes(exAttr)) {
|
|
114
|
-
handleExternalChange(source, key);
|
|
115
|
-
_target.__exAttrLoaded.push(key);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}, exAttr);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
|
|
1
|
+
import RWSContainer from './_container';
|
|
2
|
+
import TheRWSService from '../services/_service';
|
|
3
|
+
import ConfigService from '../services/ConfigService';
|
|
4
|
+
import { loadRWSRichWindow } from '../types/RWSWindow';
|
|
5
|
+
import RWSViewComponent, { IWithCompose } from './_component';
|
|
6
|
+
import { InterfaceSymbol } from './_container';
|
|
7
|
+
import { RWSInject } from './_decorators/RWSInject';
|
|
8
|
+
import { ElementStyles, Observable, ViewTemplate } from '@microsoft/fast-element';
|
|
9
|
+
import { handleExternalChange } from './_attrs/_external_handler';
|
|
10
|
+
|
|
11
|
+
interface RWSDecoratorOptions {
|
|
12
|
+
template?: string,
|
|
13
|
+
styles?: string,
|
|
14
|
+
fastElementOptions?: any,
|
|
15
|
+
ignorePackaging?: boolean,
|
|
16
|
+
debugPackaging?: boolean
|
|
17
|
+
oreoMode?: boolean
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//const _PARAMTYPES_METADATA_KEY = 'design:paramtypes';
|
|
21
|
+
type HtmlBinderType = (context: RWSViewComponent) => ViewTemplate;
|
|
22
|
+
|
|
23
|
+
function RWSView<Component extends RWSViewComponent>(name: string, data?: RWSDecoratorOptions | null, override?: { styles?: ElementStyles, template?: ViewTemplate, options?: any }): (type: any, args?: any) => void {
|
|
24
|
+
return (theComponent: IWithCompose<Component>, args?: any) => {
|
|
25
|
+
theComponent.definition = { name, template: null }
|
|
26
|
+
|
|
27
|
+
if(override){
|
|
28
|
+
if(override.styles){
|
|
29
|
+
theComponent.definition.styles = override.styles;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if(override.template){
|
|
33
|
+
theComponent.definition.template = override.template;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
if(override.options){
|
|
38
|
+
(theComponent.definition as any).options = override.options;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
function RWSIgnore(params: { mergeToApp?: boolean } | null = null): () => void {
|
|
46
|
+
return () => { };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function getParentConstructor(instance: any): any {
|
|
50
|
+
const proto = Object.getPrototypeOf(instance.constructor.prototype);
|
|
51
|
+
if (proto && proto.constructor) {
|
|
52
|
+
return proto.constructor;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
const applyConstructor = (component: RWSViewComponent, x: boolean = false): void => {
|
|
60
|
+
const mainConstructor: any = component.constructor;
|
|
61
|
+
const parent = getParentConstructor(component);
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
if (parent.name !== 'RWSViewComponent' ) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
const existingInjectedDependencies = (mainConstructor as IWithCompose<RWSViewComponent>)._toInject;
|
|
70
|
+
|
|
71
|
+
const regServices = loadRWSRichWindow().RWS._registered;
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
const depsToInject: string[] = (mainConstructor as IWithCompose<RWSViewComponent>)._depKeys[mainConstructor.name] || [];
|
|
75
|
+
const depsInInjector: string[] = Object.keys(existingInjectedDependencies);
|
|
76
|
+
|
|
77
|
+
const toInject: string[] = [...depsToInject]
|
|
78
|
+
|
|
79
|
+
type KeyType = {[key: string]: TheRWSService | string };
|
|
80
|
+
|
|
81
|
+
const _target = (component as any);
|
|
82
|
+
|
|
83
|
+
function inject(services: KeyType){
|
|
84
|
+
for (const prop in services) {
|
|
85
|
+
const service = (typeof services[prop] === 'string' ? existingInjectedDependencies[prop] : services[prop]) as TheRWSService;
|
|
86
|
+
_target[prop] = service;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
inject(toInject.reduce((acc: KeyType, cur) => {
|
|
91
|
+
acc[cur] = cur;
|
|
92
|
+
return acc;
|
|
93
|
+
}, {}));
|
|
94
|
+
|
|
95
|
+
const defaultDeps: [string, TheRWSService][] = Object.keys(existingInjectedDependencies)
|
|
96
|
+
.filter((depKey: string) => existingInjectedDependencies[depKey].isDefault()).map((depKey => [depKey, existingInjectedDependencies[depKey]]));
|
|
97
|
+
|
|
98
|
+
inject(defaultDeps.reduce((acc: KeyType, cur: [string, TheRWSService]) => {
|
|
99
|
+
acc[cur[0]] = cur[1];
|
|
100
|
+
return acc;
|
|
101
|
+
}, {}));
|
|
102
|
+
|
|
103
|
+
inject({
|
|
104
|
+
config: RWSContainer().get(ConfigService)
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
if(Object.keys(RWSViewComponent._externalAttrs).includes((_target.constructor as IWithCompose<any>).name)){
|
|
108
|
+
for(const exAttrKey in RWSViewComponent._externalAttrs[(_target.constructor as IWithCompose<any>).name]){
|
|
109
|
+
const exAttr = RWSViewComponent._externalAttrs[(_target.constructor as IWithCompose<any>).name][exAttrKey];
|
|
110
|
+
const notifier = Observable.getNotifier(_target);
|
|
111
|
+
notifier.subscribe({
|
|
112
|
+
handleChange(source, key) {
|
|
113
|
+
if (key === exAttr && !_target.__exAttrLoaded.includes(exAttr)) {
|
|
114
|
+
handleExternalChange(source, key);
|
|
115
|
+
_target.__exAttrLoaded.push(key);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}, exAttr);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
123
|
export { RWSView, RWSDecoratorOptions, RWSIgnore, RWSInject, applyConstructor };
|
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
import RWSViewComponent, { IWithCompose } from './_component';
|
|
2
|
-
import RWSWindow, { RWSWindowComponentInterface, loadRWSRichWindow } from '../types/RWSWindow';
|
|
3
|
-
import { ElementStyles, ViewTemplate } from '@microsoft/fast-element';
|
|
4
|
-
|
|
5
|
-
export interface IFastDefinition {
|
|
6
|
-
name: string;
|
|
7
|
-
template: ViewTemplate;
|
|
8
|
-
styles?: ElementStyles;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function isDefined<T extends RWSViewComponent>(element: IWithCompose<T>): boolean {
|
|
12
|
-
const richWindow: RWSWindow = loadRWSRichWindow();
|
|
13
|
-
|
|
14
|
-
if (!element.definition) {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return Object.keys(richWindow.RWS.components).includes(element.definition.name);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function defineComponent<T extends RWSViewComponent>(element: IWithCompose<T>): void {
|
|
22
|
-
if (element.isDefined()) {
|
|
23
|
-
if (element._verbose) {
|
|
24
|
-
console.warn(`Component ${element.name} is already declared`);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const richWindow = loadRWSRichWindow();
|
|
31
|
-
|
|
32
|
-
if (!element.definition) {
|
|
33
|
-
throw new Error('RWS component is not named. Add `static definition = {name, template};`');
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const composedComp = element.compose({
|
|
37
|
-
baseName: element.definition.name,
|
|
38
|
-
template: element.definition.template,
|
|
39
|
-
styles: element.definition.styles
|
|
40
|
-
}) as RWSWindowComponentInterface;
|
|
41
|
-
|
|
42
|
-
if (!richWindow.RWS) {
|
|
43
|
-
throw new Error('RWS client not initialized');
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
element.sendEventToOutside<string>(element._EVENTS.component_define, element.definition.name);
|
|
47
|
-
|
|
48
|
-
richWindow.RWS.components[element.definition.name] = {
|
|
49
|
-
interface: composedComp,
|
|
50
|
-
component: element
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export function getDefinition(tagName: string, htmlTemplate: ViewTemplate, styles: ElementStyles = null) {
|
|
55
|
-
const def: IFastDefinition = {
|
|
56
|
-
name: tagName,
|
|
57
|
-
template: htmlTemplate
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
if (styles) {
|
|
61
|
-
def.styles = styles;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return def;
|
|
1
|
+
import RWSViewComponent, { IWithCompose } from './_component';
|
|
2
|
+
import RWSWindow, { RWSWindowComponentInterface, loadRWSRichWindow } from '../types/RWSWindow';
|
|
3
|
+
import { ElementStyles, ViewTemplate } from '@microsoft/fast-element';
|
|
4
|
+
|
|
5
|
+
export interface IFastDefinition {
|
|
6
|
+
name: string;
|
|
7
|
+
template: ViewTemplate;
|
|
8
|
+
styles?: ElementStyles;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function isDefined<T extends RWSViewComponent>(element: IWithCompose<T>): boolean {
|
|
12
|
+
const richWindow: RWSWindow = loadRWSRichWindow();
|
|
13
|
+
|
|
14
|
+
if (!element.definition) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return Object.keys(richWindow.RWS.components).includes(element.definition.name);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function defineComponent<T extends RWSViewComponent>(element: IWithCompose<T>): void {
|
|
22
|
+
if (element.isDefined()) {
|
|
23
|
+
if (element._verbose) {
|
|
24
|
+
console.warn(`Component ${element.name} is already declared`);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const richWindow = loadRWSRichWindow();
|
|
31
|
+
|
|
32
|
+
if (!element.definition) {
|
|
33
|
+
throw new Error('RWS component is not named. Add `static definition = {name, template};`');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const composedComp = element.compose({
|
|
37
|
+
baseName: element.definition.name,
|
|
38
|
+
template: element.definition.template,
|
|
39
|
+
styles: element.definition.styles
|
|
40
|
+
}) as RWSWindowComponentInterface;
|
|
41
|
+
|
|
42
|
+
if (!richWindow.RWS) {
|
|
43
|
+
throw new Error('RWS client not initialized');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
element.sendEventToOutside<string>(element._EVENTS.component_define, element.definition.name);
|
|
47
|
+
|
|
48
|
+
richWindow.RWS.components[element.definition.name] = {
|
|
49
|
+
interface: composedComp,
|
|
50
|
+
component: element
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function getDefinition(tagName: string, htmlTemplate: ViewTemplate, styles: ElementStyles = null) {
|
|
55
|
+
const def: IFastDefinition = {
|
|
56
|
+
name: tagName,
|
|
57
|
+
template: htmlTemplate
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
if (styles) {
|
|
61
|
+
def.styles = styles;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return def;
|
|
65
65
|
}
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import RWSViewComponent from './_component';
|
|
2
|
-
|
|
3
|
-
export function on<T>(this: RWSViewComponent, type: string, listener: (event: CustomEvent<any>) => any) {
|
|
4
|
-
this.addEventListener(type, (baseEvent: Event) => {
|
|
5
|
-
listener(baseEvent as CustomEvent<T>);
|
|
6
|
-
});
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function $emitDown<T>(this: RWSViewComponent, eventName: string, payload: T) {
|
|
10
|
-
this.$emit(eventName, payload, {
|
|
11
|
-
bubbles: true,
|
|
12
|
-
composed: true
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function observe(this: RWSViewComponent, callback: (component: RWSViewComponent, node: Node, observer: MutationObserver) => Promise<void>, condition: (component: RWSViewComponent, node: Node) => boolean = null, observeRemoved: boolean = false)
|
|
17
|
-
{
|
|
18
|
-
const observer = new MutationObserver((mutationsList, observer) => {
|
|
19
|
-
for(const mutation of mutationsList) {
|
|
20
|
-
if (mutation.type === 'childList') {
|
|
21
|
-
const mutationObserveType: NodeList = observeRemoved ? mutation.removedNodes : mutation.addedNodes;
|
|
22
|
-
mutationObserveType.forEach(node => {
|
|
23
|
-
if ((condition !== null && condition(this, node))) {
|
|
24
|
-
callback(this, node, observer);
|
|
25
|
-
}else if(condition === null){
|
|
26
|
-
callback(this, node, observer);
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
observer.observe(this.getShadowRoot(), { childList: true, subtree: true });
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function sendEventToOutside<T>(eventName: string, data: T): void
|
|
37
|
-
{
|
|
38
|
-
document.dispatchEvent(new CustomEvent<T>(eventName, {
|
|
39
|
-
detail: data,
|
|
40
|
-
}));
|
|
1
|
+
import RWSViewComponent from './_component';
|
|
2
|
+
|
|
3
|
+
export function on<T>(this: RWSViewComponent, type: string, listener: (event: CustomEvent<any>) => any) {
|
|
4
|
+
this.addEventListener(type, (baseEvent: Event) => {
|
|
5
|
+
listener(baseEvent as CustomEvent<T>);
|
|
6
|
+
});
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function $emitDown<T>(this: RWSViewComponent, eventName: string, payload: T) {
|
|
10
|
+
this.$emit(eventName, payload, {
|
|
11
|
+
bubbles: true,
|
|
12
|
+
composed: true
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function observe(this: RWSViewComponent, callback: (component: RWSViewComponent, node: Node, observer: MutationObserver) => Promise<void>, condition: (component: RWSViewComponent, node: Node) => boolean = null, observeRemoved: boolean = false)
|
|
17
|
+
{
|
|
18
|
+
const observer = new MutationObserver((mutationsList, observer) => {
|
|
19
|
+
for(const mutation of mutationsList) {
|
|
20
|
+
if (mutation.type === 'childList') {
|
|
21
|
+
const mutationObserveType: NodeList = observeRemoved ? mutation.removedNodes : mutation.addedNodes;
|
|
22
|
+
mutationObserveType.forEach(node => {
|
|
23
|
+
if ((condition !== null && condition(this, node))) {
|
|
24
|
+
callback(this, node, observer);
|
|
25
|
+
}else if(condition === null){
|
|
26
|
+
callback(this, node, observer);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
observer.observe(this.getShadowRoot(), { childList: true, subtree: true });
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function sendEventToOutside<T>(eventName: string, data: T): void
|
|
37
|
+
{
|
|
38
|
+
document.dispatchEvent(new CustomEvent<T>(eventName, {
|
|
39
|
+
detail: data,
|
|
40
|
+
}));
|
|
41
41
|
}
|
package/src/components/index.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { RWSUploader } from './rws/uploader/component';
|
|
2
|
-
import { RWSProgress } from './rws/progress/component';
|
|
3
|
-
import { RWSLoader } from './rws/loader/component';
|
|
4
|
-
import { RWSApiResource } from './rws/rws-api-resource/component';
|
|
5
|
-
import { ReFormer } from './rws/reformer/component';
|
|
6
|
-
import { RWSTable } from './rws/rws-table/component';
|
|
7
|
-
import { RWSModal } from './rws/rws-modal/component';
|
|
8
|
-
import { LineSplitter } from './rws/line-splitter/component';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
function declareRWSComponents(parted: boolean = false): void
|
|
12
|
-
{
|
|
13
|
-
if(!parted){
|
|
14
|
-
RWSUploader;
|
|
15
|
-
RWSProgress;
|
|
16
|
-
RWSLoader;
|
|
17
|
-
RWSTable;
|
|
18
|
-
RWSModal;
|
|
19
|
-
LineSplitter;
|
|
20
|
-
|
|
21
|
-
RWSApiResource;
|
|
22
|
-
ReFormer;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
1
|
+
import { RWSUploader } from './rws/uploader/component';
|
|
2
|
+
import { RWSProgress } from './rws/progress/component';
|
|
3
|
+
import { RWSLoader } from './rws/loader/component';
|
|
4
|
+
import { RWSApiResource } from './rws/rws-api-resource/component';
|
|
5
|
+
import { ReFormer } from './rws/reformer/component';
|
|
6
|
+
import { RWSTable } from './rws/rws-table/component';
|
|
7
|
+
import { RWSModal } from './rws/rws-modal/component';
|
|
8
|
+
import { LineSplitter } from './rws/line-splitter/component';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
function declareRWSComponents(parted: boolean = false): void
|
|
12
|
+
{
|
|
13
|
+
if(!parted){
|
|
14
|
+
RWSUploader;
|
|
15
|
+
RWSProgress;
|
|
16
|
+
RWSLoader;
|
|
17
|
+
RWSTable;
|
|
18
|
+
RWSModal;
|
|
19
|
+
LineSplitter;
|
|
20
|
+
|
|
21
|
+
RWSApiResource;
|
|
22
|
+
ReFormer;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
26
|
export { declareRWSComponents };
|