@siemens/ix-angular 1.0.0-beta.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/ng-package.json +9 -0
- package/package.json +27 -0
- package/src/angular-component-lib/utils.ts +63 -0
- package/src/app-initialize.ts +29 -0
- package/src/components.ts +1631 -0
- package/src/declare-components.ts +68 -0
- package/src/index.ts +16 -0
- package/src/modal/index.ts +10 -0
- package/src/modal/modal.config.ts +14 -0
- package/src/modal/modal.service.ts +64 -0
- package/src/module.ts +44 -0
- package/src/toast/index.ts +10 -0
- package/src/toast/toast.config.ts +15 -0
- package/src/toast/toast.service.ts +51 -0
- package/src/tree/index.ts +10 -0
- package/src/tree/tree.ts +124 -0
- package/tsconfig.json +43 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
|
|
2
|
+
import * as d from './components';
|
|
3
|
+
|
|
4
|
+
export const DIRECTIVES = [
|
|
5
|
+
d.IxAnimatedTab,
|
|
6
|
+
d.IxAnimatedTabs,
|
|
7
|
+
d.IxApplicationHeader,
|
|
8
|
+
d.IxBasicNavigation,
|
|
9
|
+
d.IxBlind,
|
|
10
|
+
d.IxBreadcrumb,
|
|
11
|
+
d.IxBreadcrumbItem,
|
|
12
|
+
d.IxButton,
|
|
13
|
+
d.IxCategoryFilter,
|
|
14
|
+
d.IxChip,
|
|
15
|
+
d.IxCounterPill,
|
|
16
|
+
d.IxDatePicker,
|
|
17
|
+
d.IxDateTimeCard,
|
|
18
|
+
d.IxDatetimePicker,
|
|
19
|
+
d.IxDrawer,
|
|
20
|
+
d.IxDropdown,
|
|
21
|
+
d.IxDropdownItem,
|
|
22
|
+
d.IxEventList,
|
|
23
|
+
d.IxEventListItem,
|
|
24
|
+
d.IxExpandingSearch,
|
|
25
|
+
d.IxFilterChip,
|
|
26
|
+
d.IxFlipTile,
|
|
27
|
+
d.IxFlipTileContent,
|
|
28
|
+
d.IxGroup,
|
|
29
|
+
d.IxGroupDropdownItem,
|
|
30
|
+
d.IxGroupItem,
|
|
31
|
+
d.IxIcon,
|
|
32
|
+
d.IxIconButton,
|
|
33
|
+
d.IxInputGroup,
|
|
34
|
+
d.IxKpi,
|
|
35
|
+
d.IxMapNavigation,
|
|
36
|
+
d.IxMapNavigationOverlay,
|
|
37
|
+
d.IxMenu,
|
|
38
|
+
d.IxMenuAbout,
|
|
39
|
+
d.IxMenuAboutItem,
|
|
40
|
+
d.IxMenuAboutNews,
|
|
41
|
+
d.IxMenuAvatar,
|
|
42
|
+
d.IxMenuAvatarItem,
|
|
43
|
+
d.IxMenuItem,
|
|
44
|
+
d.IxMenuSettings,
|
|
45
|
+
d.IxMenuSettingsItem,
|
|
46
|
+
d.IxMessageBar,
|
|
47
|
+
d.IxModal,
|
|
48
|
+
d.IxModalContainer,
|
|
49
|
+
d.IxModalExample,
|
|
50
|
+
d.IxPill,
|
|
51
|
+
d.IxSelect,
|
|
52
|
+
d.IxSelectItem,
|
|
53
|
+
d.IxSpinner,
|
|
54
|
+
d.IxSplitButton,
|
|
55
|
+
d.IxSplitButtonItem,
|
|
56
|
+
d.IxTabItem,
|
|
57
|
+
d.IxTabs,
|
|
58
|
+
d.IxTile,
|
|
59
|
+
d.IxTimePicker,
|
|
60
|
+
d.IxToast,
|
|
61
|
+
d.IxToastContainer,
|
|
62
|
+
d.IxToggle,
|
|
63
|
+
d.IxTreeItem,
|
|
64
|
+
d.IxUpload,
|
|
65
|
+
d.IxValidationTooltip,
|
|
66
|
+
d.IxWorkflowStep,
|
|
67
|
+
d.IxWorkflowSteps
|
|
68
|
+
];
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* SPDX-FileCopyrightText: 2022 Siemens AG
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export * from '@siemens/ix';
|
|
11
|
+
export * from './components';
|
|
12
|
+
export * from './modal';
|
|
13
|
+
export * from './module';
|
|
14
|
+
export * from './toast';
|
|
15
|
+
export * from './tree';
|
|
16
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* SPDX-FileCopyrightText: 2022 Siemens AG
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { TemplateRef } from '@angular/core';
|
|
11
|
+
|
|
12
|
+
export type ModalConfig = {
|
|
13
|
+
content: TemplateRef<any>;
|
|
14
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* SPDX-FileCopyrightText: 2022 Siemens AG
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { Injectable } from '@angular/core';
|
|
11
|
+
import {
|
|
12
|
+
closeModal,
|
|
13
|
+
dismissModal,
|
|
14
|
+
modal,
|
|
15
|
+
ModalConfig as IxModalConfig
|
|
16
|
+
} from '@siemens/ix';
|
|
17
|
+
import { ModalConfig } from './modal.config';
|
|
18
|
+
|
|
19
|
+
@Injectable({
|
|
20
|
+
providedIn: 'root',
|
|
21
|
+
})
|
|
22
|
+
export class ModalService {
|
|
23
|
+
constructor() {}
|
|
24
|
+
|
|
25
|
+
async open(config: Omit<IxModalConfig, 'content'> & ModalConfig) {
|
|
26
|
+
const context: {
|
|
27
|
+
close: ((result: any) => void) | null;
|
|
28
|
+
dismiss: ((result?: any) => void) | null;
|
|
29
|
+
} = {
|
|
30
|
+
close: null,
|
|
31
|
+
dismiss: null,
|
|
32
|
+
};
|
|
33
|
+
const embeddedView = config.content.createEmbeddedView({
|
|
34
|
+
$implicit: context,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const node = embeddedView.rootNodes[0];
|
|
38
|
+
|
|
39
|
+
context.close = (result: any) => {
|
|
40
|
+
closeModal(node, result);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
context.dismiss = (result?: any) => {
|
|
44
|
+
dismissModal(node, result);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
embeddedView.detectChanges();
|
|
48
|
+
|
|
49
|
+
const modalInstance = await modal({
|
|
50
|
+
title: '',
|
|
51
|
+
content: node,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
modalInstance.onClose.once(() => {
|
|
55
|
+
embeddedView.destroy();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
modalInstance.onDismiss.once(() => {
|
|
59
|
+
embeddedView.destroy();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
return modalInstance;
|
|
63
|
+
}
|
|
64
|
+
}
|
package/src/module.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* SPDX-FileCopyrightText: 2022 Siemens AG
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { DOCUMENT } from '@angular/common';
|
|
11
|
+
import {
|
|
12
|
+
APP_INITIALIZER,
|
|
13
|
+
ModuleWithProviders,
|
|
14
|
+
NgModule,
|
|
15
|
+
NgZone
|
|
16
|
+
} from '@angular/core';
|
|
17
|
+
import { appInitialize } from './app-initialize';
|
|
18
|
+
import { DIRECTIVES } from './declare-components';
|
|
19
|
+
import { ModalService } from './modal';
|
|
20
|
+
import { ToastService } from './toast';
|
|
21
|
+
import * as tree from './tree';
|
|
22
|
+
const DECLARATIONS = [...DIRECTIVES, tree.IxTree];
|
|
23
|
+
|
|
24
|
+
@NgModule({
|
|
25
|
+
declarations: DECLARATIONS,
|
|
26
|
+
exports: DECLARATIONS,
|
|
27
|
+
})
|
|
28
|
+
export class IxModule {
|
|
29
|
+
static forRoot(): ModuleWithProviders<IxModule> {
|
|
30
|
+
return {
|
|
31
|
+
ngModule: IxModule,
|
|
32
|
+
providers: [
|
|
33
|
+
{
|
|
34
|
+
provide: APP_INITIALIZER,
|
|
35
|
+
useFactory: appInitialize,
|
|
36
|
+
multi: true,
|
|
37
|
+
deps: [DOCUMENT, NgZone],
|
|
38
|
+
},
|
|
39
|
+
ModalService,
|
|
40
|
+
ToastService,
|
|
41
|
+
],
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* SPDX-FileCopyrightText: 2022 Siemens AG
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { TemplateRef } from '@angular/core';
|
|
11
|
+
import { ToastConfig as IxToastConfig } from '@siemens/ix';
|
|
12
|
+
|
|
13
|
+
export type ToastConfig = Omit<IxToastConfig, 'message'> & {
|
|
14
|
+
message: string | TemplateRef<any>;
|
|
15
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* SPDX-FileCopyrightText: 2022 Siemens AG
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { Injectable } from '@angular/core';
|
|
11
|
+
import { toast, ToastConfig as IxToastConfig } from '@siemens/ix';
|
|
12
|
+
import { ToastConfig } from './toast.config';
|
|
13
|
+
|
|
14
|
+
@Injectable({
|
|
15
|
+
providedIn: 'root',
|
|
16
|
+
})
|
|
17
|
+
export class ToastService {
|
|
18
|
+
public async show(config: ToastConfig) {
|
|
19
|
+
if (typeof config.message === 'string') {
|
|
20
|
+
return toast(config as IxToastConfig);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const context: {
|
|
24
|
+
close: (() => void) | null;
|
|
25
|
+
} = {
|
|
26
|
+
close: null,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const embeddedView = config.message.createEmbeddedView({
|
|
30
|
+
$implicit: context,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const node: HTMLElement = embeddedView.rootNodes[0];
|
|
34
|
+
const instance = await toast({
|
|
35
|
+
...config,
|
|
36
|
+
message: node,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
context.close = () => {
|
|
40
|
+
instance.close();
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
embeddedView.detectChanges();
|
|
44
|
+
|
|
45
|
+
instance.onClose.once(() => {
|
|
46
|
+
embeddedView.destroy();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
return instance;
|
|
50
|
+
}
|
|
51
|
+
}
|
package/src/tree/tree.ts
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* SPDX-FileCopyrightText: 2022 Siemens AG
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
ChangeDetectionStrategy,
|
|
12
|
+
ChangeDetectorRef,
|
|
13
|
+
Component,
|
|
14
|
+
ElementRef,
|
|
15
|
+
EmbeddedViewRef,
|
|
16
|
+
EventEmitter,
|
|
17
|
+
Input,
|
|
18
|
+
NgZone,
|
|
19
|
+
OnDestroy,
|
|
20
|
+
TemplateRef
|
|
21
|
+
} from '@angular/core';
|
|
22
|
+
import type {
|
|
23
|
+
Components,
|
|
24
|
+
TreeContext as ICwTreeTreeContext,
|
|
25
|
+
TreeContext,
|
|
26
|
+
UpdateCallback
|
|
27
|
+
} from '@siemens/ix';
|
|
28
|
+
import { Subscription } from 'rxjs';
|
|
29
|
+
import { ProxyCmp, proxyOutputs } from './../angular-component-lib/utils';
|
|
30
|
+
|
|
31
|
+
export declare interface IxTree extends Omit<Components.IxTree, 'renderItem'> {
|
|
32
|
+
/**
|
|
33
|
+
* Context changed
|
|
34
|
+
*/
|
|
35
|
+
contextChange: EventEmitter<CustomEvent<ICwTreeTreeContext>>;
|
|
36
|
+
/**
|
|
37
|
+
* Emits removed nodes
|
|
38
|
+
*/
|
|
39
|
+
nodeRemoved: EventEmitter<CustomEvent<any>>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@ProxyCmp({
|
|
43
|
+
defineCustomElementFn: undefined,
|
|
44
|
+
inputs: ['context', 'model', 'root'],
|
|
45
|
+
})
|
|
46
|
+
@Component({
|
|
47
|
+
selector: 'ix-tree',
|
|
48
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
49
|
+
template: '<ng-content></ng-content>',
|
|
50
|
+
inputs: ['context', 'model', 'root'],
|
|
51
|
+
})
|
|
52
|
+
export class IxTree implements OnDestroy {
|
|
53
|
+
renderCache = new Map<HTMLElement, EmbeddedViewRef<any>>();
|
|
54
|
+
|
|
55
|
+
@Input()
|
|
56
|
+
set renderItem(template: TemplateRef<any>) {
|
|
57
|
+
const itemRenderFunction = this.generateItemRenderer(template);
|
|
58
|
+
(this.el as HTMLIxTreeElement).renderItem = itemRenderFunction.bind(this);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
protected el: HTMLElement;
|
|
62
|
+
|
|
63
|
+
onRemovedSubscription!: Subscription;
|
|
64
|
+
|
|
65
|
+
constructor(c: ChangeDetectorRef, r: ElementRef, protected z: NgZone) {
|
|
66
|
+
c.detach();
|
|
67
|
+
this.el = r.nativeElement;
|
|
68
|
+
proxyOutputs(this, this.el, ['contextChange', 'nodeRemoved']);
|
|
69
|
+
|
|
70
|
+
this.onRemovedSubscription = this.nodeRemoved.subscribe(
|
|
71
|
+
(removedEvent: CustomEvent<HTMLIxTreeItemElement[]>) => {
|
|
72
|
+
const { detail } = removedEvent;
|
|
73
|
+
|
|
74
|
+
detail.forEach((removedItemElement) => {
|
|
75
|
+
if (this.renderCache.has(removedItemElement)) {
|
|
76
|
+
this.renderCache.get(removedItemElement)?.destroy();
|
|
77
|
+
this.renderCache.delete(removedItemElement);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
ngOnDestroy(): void {
|
|
85
|
+
this.onRemovedSubscription?.unsubscribe();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
generateItemRenderer(templateRef: TemplateRef<any>) {
|
|
89
|
+
return (
|
|
90
|
+
_: number,
|
|
91
|
+
itemData: any,
|
|
92
|
+
__: any[],
|
|
93
|
+
context: TreeContext,
|
|
94
|
+
update: (callback: UpdateCallback) => void
|
|
95
|
+
) => {
|
|
96
|
+
const treeItem = document.createElement('ix-tree-item');
|
|
97
|
+
treeItem.hasChildren = itemData.hasChildren;
|
|
98
|
+
treeItem.context = context as any;
|
|
99
|
+
|
|
100
|
+
const embeddedView = templateRef.createEmbeddedView({
|
|
101
|
+
$implicit: itemData.data,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
const container = embeddedView.rootNodes[0];
|
|
105
|
+
embeddedView.detectChanges();
|
|
106
|
+
|
|
107
|
+
update((itemData, context) => {
|
|
108
|
+
treeItem.context = context as any;
|
|
109
|
+
treeItem.hasChildren = itemData.hasChildren;
|
|
110
|
+
|
|
111
|
+
embeddedView.context = {
|
|
112
|
+
$implicit: itemData.data,
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
embeddedView.detectChanges();
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
treeItem.appendChild(container);
|
|
119
|
+
this.renderCache.set(treeItem, embeddedView);
|
|
120
|
+
|
|
121
|
+
return treeItem;
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"angularCompilerOptions": {
|
|
3
|
+
"annotateForClosureCompiler": true,
|
|
4
|
+
"strictMetadataEmit": true,
|
|
5
|
+
"skipTemplateCodegen": true,
|
|
6
|
+
"fullTemplateTypeCheck": false,
|
|
7
|
+
"enableResourceInlining": true,
|
|
8
|
+
"compilationMode": "partial"
|
|
9
|
+
},
|
|
10
|
+
"compilerOptions": {
|
|
11
|
+
"alwaysStrict": true,
|
|
12
|
+
"strict": true,
|
|
13
|
+
"allowSyntheticDefaultImports": true,
|
|
14
|
+
"allowUnreachableCode": false,
|
|
15
|
+
"declaration": true,
|
|
16
|
+
"declarationDir": "dist",
|
|
17
|
+
"experimentalDecorators": true,
|
|
18
|
+
"forceConsistentCasingInFileNames": true,
|
|
19
|
+
"lib": ["dom", "es2017"],
|
|
20
|
+
"module": "es2015",
|
|
21
|
+
"moduleResolution": "node",
|
|
22
|
+
"noImplicitAny": true,
|
|
23
|
+
"noImplicitReturns": true,
|
|
24
|
+
"noUnusedLocals": true,
|
|
25
|
+
"noUnusedParameters": true,
|
|
26
|
+
"outDir": "build/es2015",
|
|
27
|
+
"pretty": true,
|
|
28
|
+
"removeComments": false,
|
|
29
|
+
"importHelpers": true,
|
|
30
|
+
"rootDir": "src",
|
|
31
|
+
"strictPropertyInitialization": false,
|
|
32
|
+
"target": "es2015",
|
|
33
|
+
"baseUrl": ".",
|
|
34
|
+
"paths": {
|
|
35
|
+
"@siemens/ix": ["../core"]
|
|
36
|
+
},
|
|
37
|
+
"plugins": [
|
|
38
|
+
],
|
|
39
|
+
"skipLibCheck": true
|
|
40
|
+
},
|
|
41
|
+
"exclude": ["node_modules"],
|
|
42
|
+
"files": ["src/index.ts"]
|
|
43
|
+
}
|