mis-crystal-design-system 2.1.3 → 2.2.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.
Files changed (78) hide show
  1. package/async-search-dropdown/async-dropdown.component.d.ts +60 -0
  2. package/async-search-dropdown/async-dropdown.module.d.ts +2 -0
  3. package/async-search-dropdown/index.d.ts +1 -0
  4. package/async-search-dropdown/mis-crystal-design-system-async-search-dropdown.d.ts +4 -0
  5. package/async-search-dropdown/mis-crystal-design-system-async-search-dropdown.metadata.json +1 -0
  6. package/async-search-dropdown/package.json +11 -0
  7. package/async-search-dropdown/public_api.d.ts +2 -0
  8. package/bundles/mis-crystal-design-system-async-search-dropdown.umd.js +211 -0
  9. package/bundles/mis-crystal-design-system-async-search-dropdown.umd.js.map +1 -0
  10. package/bundles/mis-crystal-design-system-async-search-dropdown.umd.min.js +2 -0
  11. package/bundles/mis-crystal-design-system-async-search-dropdown.umd.min.js.map +1 -0
  12. package/bundles/mis-crystal-design-system-button.umd.js +60 -2
  13. package/bundles/mis-crystal-design-system-button.umd.js.map +1 -1
  14. package/bundles/mis-crystal-design-system-button.umd.min.js +1 -1
  15. package/bundles/mis-crystal-design-system-button.umd.min.js.map +1 -1
  16. package/bundles/mis-crystal-design-system-input.umd.js +111 -0
  17. package/bundles/mis-crystal-design-system-input.umd.js.map +1 -0
  18. package/bundles/mis-crystal-design-system-input.umd.min.js +2 -0
  19. package/bundles/mis-crystal-design-system-input.umd.min.js.map +1 -0
  20. package/bundles/mis-crystal-design-system-modal.umd.js +165 -0
  21. package/bundles/mis-crystal-design-system-modal.umd.js.map +1 -0
  22. package/bundles/mis-crystal-design-system-modal.umd.min.js +2 -0
  23. package/bundles/mis-crystal-design-system-modal.umd.min.js.map +1 -0
  24. package/button/button.directive.d.ts +12 -0
  25. package/button/mis-crystal-design-system-button.d.ts +1 -0
  26. package/button/mis-crystal-design-system-button.metadata.json +1 -1
  27. package/esm2015/async-search-dropdown/async-dropdown.component.js +176 -0
  28. package/esm2015/async-search-dropdown/async-dropdown.module.js +15 -0
  29. package/esm2015/async-search-dropdown/index.js +2 -0
  30. package/esm2015/async-search-dropdown/mis-crystal-design-system-async-search-dropdown.js +5 -0
  31. package/esm2015/async-search-dropdown/public_api.js +3 -0
  32. package/esm2015/button/button.directive.js +57 -0
  33. package/esm2015/button/button.module.js +4 -3
  34. package/esm2015/button/mis-crystal-design-system-button.js +2 -1
  35. package/esm2015/input/directives/input/input.directive.js +38 -0
  36. package/esm2015/input/index.js +2 -0
  37. package/esm2015/input/mis-crystal-design-system-input.js +5 -0
  38. package/esm2015/input/mis-input.component.js +40 -0
  39. package/esm2015/input/mis-input.module.js +15 -0
  40. package/esm2015/input/public_api.js +4 -0
  41. package/esm2015/modal/index.js +2 -0
  42. package/esm2015/modal/mis-crystal-design-system-modal.js +6 -0
  43. package/esm2015/modal/modal-constants.js +4 -0
  44. package/esm2015/modal/modal-ref.js +16 -0
  45. package/esm2015/modal/modal.module.js +32 -0
  46. package/esm2015/modal/modal.service.js +72 -0
  47. package/esm2015/modal/module-wrapper/module-wrapper.component.js +33 -0
  48. package/esm2015/modal/public_api.js +5 -0
  49. package/fesm2015/mis-crystal-design-system-async-search-dropdown.js +194 -0
  50. package/fesm2015/mis-crystal-design-system-async-search-dropdown.js.map +1 -0
  51. package/fesm2015/mis-crystal-design-system-button.js +60 -4
  52. package/fesm2015/mis-crystal-design-system-button.js.map +1 -1
  53. package/fesm2015/mis-crystal-design-system-input.js +94 -0
  54. package/fesm2015/mis-crystal-design-system-input.js.map +1 -0
  55. package/fesm2015/mis-crystal-design-system-modal.js +151 -0
  56. package/fesm2015/mis-crystal-design-system-modal.js.map +1 -0
  57. package/input/directives/input/input.directive.d.ts +15 -0
  58. package/input/index.d.ts +1 -0
  59. package/input/mis-crystal-design-system-input.d.ts +4 -0
  60. package/input/mis-crystal-design-system-input.metadata.json +1 -0
  61. package/input/mis-input.component.d.ts +15 -0
  62. package/input/mis-input.module.d.ts +2 -0
  63. package/input/package.json +11 -0
  64. package/input/public_api.d.ts +3 -0
  65. package/modal/index.d.ts +1 -0
  66. package/modal/mis-crystal-design-system-modal.d.ts +5 -0
  67. package/modal/mis-crystal-design-system-modal.metadata.json +1 -0
  68. package/modal/modal-constants.d.ts +3 -0
  69. package/modal/modal-ref.d.ts +9 -0
  70. package/modal/modal.module.d.ts +5 -0
  71. package/modal/modal.service.d.ts +22 -0
  72. package/modal/module-wrapper/module-wrapper.component.d.ts +9 -0
  73. package/modal/package.json +11 -0
  74. package/modal/public_api.d.ts +4 -0
  75. package/package.json +1 -1
  76. package/projects/mis-components/button/button.directive.scss +69 -0
  77. package/{drawer → projects/mis-components/drawer}/drawer.scss +0 -0
  78. package/projects/mis-components/modal/modal.scss +9 -0
@@ -0,0 +1,72 @@
1
+ import { Overlay, OverlayConfig } from "@angular/cdk/overlay";
2
+ import { ComponentPortal, PortalInjector } from "@angular/cdk/portal";
3
+ import { Injectable, Injector } from "@angular/core";
4
+ import { MODAL_DATA_VAR } from "./modal-constants";
5
+ import { ModalRef } from "./modal-ref";
6
+ import { ModuleWrapperComponent } from "./module-wrapper/module-wrapper.component";
7
+ import * as i0 from "@angular/core";
8
+ import * as i1 from "@angular/cdk/overlay";
9
+ export class ModalService {
10
+ constructor(overlay, injector) {
11
+ this.overlay = overlay;
12
+ this.injector = injector;
13
+ }
14
+ show(component, data, options) {
15
+ const positionStrategy = this.calculatePosition(options);
16
+ const { width, height } = options || {};
17
+ const config = new OverlayConfig({
18
+ hasBackdrop: true,
19
+ positionStrategy,
20
+ scrollStrategy: this.overlay.scrollStrategies.noop(),
21
+ width: width,
22
+ height,
23
+ panelClass: "mis-modal",
24
+ backdropClass: "mis-modal-overlay",
25
+ });
26
+ const overlayRef = this.overlay.create(config);
27
+ const modalRef = new ModalRef(overlayRef);
28
+ const injector = this.createInjector(modalRef, this.injector, data);
29
+ const portal = new ComponentPortal(ModuleWrapperComponent, null);
30
+ this.componentInstance = overlayRef.attach(portal);
31
+ if (options === null || options === void 0 ? void 0 : options.closeOnBackdropClick) {
32
+ overlayRef.backdropClick().subscribe(() => modalRef.close());
33
+ }
34
+ this.componentInstance.instance.bindComponent(component, injector);
35
+ return modalRef;
36
+ }
37
+ createInjector(ref, inj, data) {
38
+ const injectorTokens = new WeakMap();
39
+ injectorTokens.set(ModalRef, ref);
40
+ injectorTokens.set(MODAL_DATA_VAR, data);
41
+ return new PortalInjector(inj, injectorTokens);
42
+ }
43
+ calculatePosition(options) {
44
+ const position = this.overlay.position().global().centerHorizontally().centerVertically();
45
+ if (options && screen.width > 600) {
46
+ if (options.top) {
47
+ position.top(options.top);
48
+ }
49
+ if (options.left) {
50
+ position.left(options.left);
51
+ }
52
+ if (options.right) {
53
+ position.right(options.right);
54
+ }
55
+ if (options.bottom) {
56
+ position.bottom(options.bottom);
57
+ }
58
+ }
59
+ return position;
60
+ }
61
+ }
62
+ ModalService.ɵprov = i0.ɵɵdefineInjectable({ factory: function ModalService_Factory() { return new ModalService(i0.ɵɵinject(i1.Overlay), i0.ɵɵinject(i0.INJECTOR)); }, token: ModalService, providedIn: "root" });
63
+ ModalService.decorators = [
64
+ { type: Injectable, args: [{
65
+ providedIn: "root",
66
+ },] }
67
+ ];
68
+ ModalService.ctorParameters = () => [
69
+ { type: Overlay },
70
+ { type: Injector }
71
+ ];
72
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibW9kYWwuc2VydmljZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3Byb2plY3RzL21pcy1jb21wb25lbnRzL21vZGFsL21vZGFsLnNlcnZpY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFpQixPQUFPLEVBQUUsYUFBYSxFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFDN0UsT0FBTyxFQUFFLGVBQWUsRUFBRSxjQUFjLEVBQUUsTUFBTSxxQk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Y3JlYXRlSW5qZWN0b3I8RD4ocmVmOiBNb2RhbFJlZiwgaW5qOiBJbmplY3RvciwgZGF0YT86IEQpOiBQb3J0YWxJbmplY3RvciB7XG4gICAgY29uc3QgaW5qZWN0b3JUb2tlbnMgPSBuZXcgV2Vha01hcCgpO1xuICAgIGluamVjdG9yVG9rZW5zLnNldChNb2RhbFJlZiwgcmVmKTtcbiAgICBpbmplY3RvclRva2Vucy5zZXQoTU9EQUxfREFUQV9WQVIsIGRhdGEpO1xuICAgIHJldHVybiBuZXcgUG9ydGFsSW5qZWN0b3IoaW5qLCBpbmplY3RvclRva2Vucyk7XG4gIH1cblxuICBwcml2YXRlIGNhbGN1bGF0ZVBvc2l0aW9uKG9wdGlvbnM6IElNb2RhbE9wdGlvbnMpIHtcbiAgICBjb25zdCBwb3NpdGlvbiA9IHRoaXMub3ZlcmxheS5wb3NpdGlvbigpLmdsb2JhbCgpLmNlbnRlckhvcml6b250YWxseSgpLmNlbnRlclZlcnRpY2FsbHkoKTtcbiAgICBpZiAob3B0aW9ucyAmJiBzY3JlZW4ud2lkdGggPiA2MDApIHtcbiAgICAgIGlmIChvcHRpb25zLnRvcCkge1xuICAgICAgICBwb3NpdGlvbi50b3Aob3B0aW9ucy50b3ApO1xuICAgICAgfVxuICAgICAgaWYgKG9wdGlvbnMubGVmdCkge1xuICAgICAgICBwb3NpdGlvbi5sZWZ0KG9wdGlvbnMubGVmdCk7XG4gICAgICB9XG4gICAgICBpZiAob3B0aW9ucy5yaWdodCkge1xuICAgICAgICBwb3NpdGlvbi5yaWdodChvcHRpb25zLnJpZ2h0KTtcbiAgICAgIH1cbiAgICAgIGlmIChvcHRpb25zLmJvdHRvbSkge1xuICAgICAgICBwb3NpdGlvbi5ib3R0b20ob3B0aW9ucy5ib3R0b20pO1xuICAgICAgfVxuICAgIH1cbiAgICByZXR1cm4gcG9zaXRpb247XG4gIH1cbn1cbiJdfQ==
@@ -0,0 +1,33 @@
1
+ import { trigger, transition, style, animate } from "@angular/animations";
2
+ import { ComponentPortal } from "@angular/cdk/portal";
3
+ import { Component, ViewChild, ViewContainerRef } from "@angular/core";
4
+ export class ModuleWrapperComponent {
5
+ constructor() { }
6
+ bindComponent(type, injector) {
7
+ this.initComponent(type, injector);
8
+ }
9
+ initComponent(type, injector) {
10
+ this.modalPortal = new ComponentPortal(type, this.place, injector);
11
+ }
12
+ }
13
+ ModuleWrapperComponent.decorators = [
14
+ { type: Component, args: [{
15
+ selector: "mis-module-wrapper",
16
+ template: "<div class=\"mis-modal-body\" #place @slideInOut>\n <ng-template [cdkPortalOutlet]=\"modalPortal\"></ng-template>\n</div>\n",
17
+ animations: [
18
+ trigger("slideInOut", [
19
+ transition(":enter", [
20
+ style({ transform: "translateY(-30%)", opacity: 0 }),
21
+ animate("200ms ease-out", style({ transform: "translatey(0%)", opacity: 1 })),
22
+ ]),
23
+ transition(":leave", [animate("200ms ease-out", style({ transform: "translatey(-30%)", opacity: 0 }))]),
24
+ ]),
25
+ ],
26
+ styles: [".mis-modal-body{display:block;width:100%;height:100%;background-color:transparent;border-radius:12px;box-shadow:0 12px 24px rgba(0,0,0,.12),0 4px 8px rgba(0,0,0,.12);overflow:hidden}"]
27
+ },] }
28
+ ];
29
+ ModuleWrapperComponent.ctorParameters = () => [];
30
+ ModuleWrapperComponent.propDecorators = {
31
+ place: [{ type: ViewChild, args: ["place", { static: false, read: ViewContainerRef },] }]
32
+ };
33
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibW9kdWxlLXdyYXBwZXIuY29tcG9uZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vcHJvamVjdHMvbWlzLWNvbXBvbmVudHMvbW9kYWwvbW9kdWxlLXdyYXBwZXIvbW9kdWxlLXdyYXBwZXIuY29tcG9uZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxPQUFPLEV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uICAgICAgICBhbmltYXRlKFwiMjAwbXMgZWFzZS1vdXRcIiwgc3R5bGUoeyB0cmFuc2Zvcm06IFwidHJhbnNsYXRleSgwJSlcIiwgb3BhY2l0eTogMSB9KSksXG4gICAgICBdKSxcbiAgICAgIHRyYW5zaXRpb24oXCI6bGVhdmVcIiwgW2FuaW1hdGUoXCIyMDBtcyBlYXNlLW91dFwiLCBzdHlsZSh7IHRyYW5zZm9ybTogXCJ0cmFuc2xhdGV5KC0zMCUpXCIsIG9wYWNpdHk6IDAgfSkpXSksXG4gICAgXSksXG4gIF0sXG59KVxuZXhwb3J0IGNsYXNzIE1vZHVsZVdyYXBwZXJDb21wb25lbnQge1xuICBtb2RhbFBvcnRhbDogQ29tcG9uZW50UG9ydGFsPGFueT47XG4gIGNvbnN0cnVjdG9yKCkge31cblxuICBAVmlld0NoaWxkKFwicGxhY2VcIiwgeyBzdGF0aWM6IGZhbHNlLCByZWFkOiBWaWV3Q29udGFpbmVyUmVmIH0pIHBsYWNlOiBWaWV3Q29udGFpbmVyUmVmO1xuXG4gIGJpbmRDb21wb25lbnQodHlwZTogYW55LCBpbmplY3RvcjogUG9ydGFsSW5qZWN0b3IpIHtcbiAgICB0aGlzLmluaXRDb21wb25lbnQodHlwZSwgaW5qZWN0b3IpO1xuICB9XG5cbiAgcHJpdmF0ZSBpbml0Q29tcG9uZW50KHR5cGU6IGFueSwgaW5qZWN0b3I6IFBvcnRhbEluamVjdG9yKSB7XG4gICAgdGhpcy5tb2RhbFBvcnRhbCA9IG5ldyBDb21wb25lbnRQb3J0YWwodHlwZSwgdGhpcy5wbGFjZSwgaW5qZWN0b3IpO1xuICB9XG59XG4iXX0=
@@ -0,0 +1,5 @@
1
+ export * from './modal.service';
2
+ export * from './modal-ref';
3
+ export * from './modal-constants';
4
+ export * from './modal.module';
5
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX2FwaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3Byb2plY3RzL21pcy1jb21wb25lbnRzL21vZGFsL3B1YmxpY19hcGkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYyxpQkFBaUIsQ0FBQztBQUNoQyxjQUFjLGFBQWEsQ0FBQztBQUM1QixjQUFjLG1CQUFtQixDQUFDO0FBQ2xDLGNBQWMsZ0JBQWdCLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgKiBmcm9tICcuL21vZGFsLnNlcnZpY2UnO1xuZXhwb3J0ICogZnJvbSAnLi9tb2RhbC1yZWYnO1xuZXhwb3J0ICogZnJvbSAnLi9tb2RhbC1jb25zdGFudHMnO1xuZXhwb3J0ICogZnJvbSAnLi9tb2RhbC5tb2R1bGUnOyJdfQ==
@@ -0,0 +1,194 @@
1
+ import { ConnectionPositionPair, OverlayConfig, Overlay, OverlayModule } from '@angular/cdk/overlay';
2
+ import { TemplatePortal } from '@angular/cdk/portal';
3
+ import { EventEmitter, Component, ViewContainerRef, Input, ViewChild, ContentChild, Output, NgModule } from '@angular/core';
4
+ import { FormControl, ReactiveFormsModule, FormsModule } from '@angular/forms';
5
+ import { filter, debounceTime, distinctUntilChanged } from 'rxjs/operators';
6
+ import { CommonModule } from '@angular/common';
7
+
8
+ class AsyncDropdownComponent {
9
+ constructor(overlay, viewContainerRef) {
10
+ this.overlay = overlay;
11
+ this.viewContainerRef = viewContainerRef;
12
+ this.placeholder = 'Select'; // placeholder for input
13
+ this.debounceTime = 400; // wait time till which API call is paused
14
+ this.minInputLength = 2; // min length after which API call is made
15
+ this.multi = false; // maintain a list or emit value
16
+ // tslint:disable-next-line
17
+ this.onSelect = new EventEmitter(true); // emit selected values
18
+ this.searchInput = new FormControl();
19
+ this.data = [];
20
+ this.opened = false;
21
+ // tslint:disable-next-line
22
+ this.selections = new Map();
23
+ this.handleControlChanges = (values) => {
24
+ values.forEach((el) => {
25
+ this.selectData(el, true);
26
+ });
27
+ // tslint:disable-next-line
28
+ };
29
+ }
30
+ ngOnInit() {
31
+ var _a, _b;
32
+ if (this.multi && !this.uniqueKey) {
33
+ throw new Error('[uniqueKey] required in multi mode.');
34
+ }
35
+ if (this.disabled) {
36
+ this.searchInput.disable();
37
+ }
38
+ this.searchSubscription = this.searchInput.valueChanges
39
+ .pipe(filter((val) => val && val.length >= this.minInputLength), debounceTime(this.debounceTime), distinctUntilChanged())
40
+ .subscribe((res) => {
41
+ this.httpStream(res).subscribe((list) => {
42
+ var _a;
43
+ this.data = list;
44
+ if (!((_a = this.overlayRef) === null || _a === void 0 ? void 0 : _a.hasAttached()) && list.length > 0) {
45
+ this.openDropdown(this.dd, this.origin.nativeElement);
46
+ }
47
+ });
48
+ });
49
+ if ((_a = this.control) === null || _a === void 0 ? void 0 : _a.value) {
50
+ this.handleControlChanges(this.control.value);
51
+ }
52
+ this.controlSubscription = (_b = this.control) === null || _b === void 0 ? void 0 : _b.valueChanges.subscribe(this.handleControlChanges);
53
+ }
54
+ ngOnChanges(changes) {
55
+ if (changes && changes.disabled) {
56
+ this.searchInput.enable();
57
+ if (this.disabled) {
58
+ this.searchInput.disable();
59
+ }
60
+ }
61
+ }
62
+ ngOnDestroy() {
63
+ var _a;
64
+ (_a = this.searchSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
65
+ }
66
+ openDropdown(template, origin) {
67
+ const positionStrategy = this.overlay
68
+ .position()
69
+ .flexibleConnectedTo(origin)
70
+ .withPositions([
71
+ new ConnectionPositionPair({ originX: 'start', originY: 'bottom' }, { overlayX: 'start', overlayY: 'top' }),
72
+ new ConnectionPositionPair({ originX: 'start', originY: 'top' }, { overlayX: 'start', overlayY: 'bottom' }),
73
+ ])
74
+ .withPush(true);
75
+ const configs = new OverlayConfig({
76
+ hasBackdrop: true,
77
+ backdropClass: 'cdk-overlay-transparent-backdrop',
78
+ scrollStrategy: this.overlay.scrollStrategies.reposition(),
79
+ positionStrategy,
80
+ width: origin.clientWidth,
81
+ });
82
+ this.overlayRef = this.overlay.create(configs);
83
+ this.overlayRef.attach(new TemplatePortal(template, this.viewContainerRef));
84
+ this.overlayRef.backdropClick().subscribe((res) => {
85
+ this.closeDropdown();
86
+ });
87
+ }
88
+ /**
89
+ * closes the dropdown
90
+ */
91
+ closeDropdown() {
92
+ var _a;
93
+ this.opened = false;
94
+ (_a = this.overlayRef) === null || _a === void 0 ? void 0 : _a.detach();
95
+ this.data = [];
96
+ }
97
+ /**
98
+ *
99
+ * @param item item to select
100
+ * if item property disabled is set to true, selection will be disabled
101
+ * @param effectedFromOutside set to true if calling from parent component, if true will focus on search input
102
+ */
103
+ selectData(item, effectedFromOutside = true) {
104
+ if (item.disabled) {
105
+ return;
106
+ }
107
+ if (!this.multi) {
108
+ this.searchInput.patchValue(item[this.displayKey], { emitEvent: false });
109
+ this.setControlValue(item);
110
+ }
111
+ else {
112
+ if (!this.selections.has(item[this.uniqueKey])) {
113
+ this.selections.set(item[this.uniqueKey], item);
114
+ }
115
+ this.setControlValue(this.selectedItems);
116
+ if (!effectedFromOutside) {
117
+ setTimeout(() => {
118
+ this.input.nativeElement.focus();
119
+ this.input.nativeElement.scrollIntoView();
120
+ }, 10);
121
+ }
122
+ this.searchInput.patchValue('');
123
+ this.data = [];
124
+ }
125
+ this.closeDropdown();
126
+ }
127
+ /**
128
+ *
129
+ * @param item remove item from selected list
130
+ */
131
+ removeItem(item) {
132
+ this.selections.delete(item[this.uniqueKey]);
133
+ this.setControlValue(this.selectedItems);
134
+ // tslint:disable-next-line
135
+ this.input['nativeElement'].focus();
136
+ }
137
+ setControlValue(value) {
138
+ var _a;
139
+ this.onSelect.emit(value);
140
+ (_a = this.control) === null || _a === void 0 ? void 0 : _a.patchValue(value, { emitEvent: false });
141
+ }
142
+ /**
143
+ * @returns list of selected items
144
+ */
145
+ get selectedItems() {
146
+ return Array.from(this.selections.values());
147
+ }
148
+ }
149
+ AsyncDropdownComponent.decorators = [
150
+ { type: Component, args: [{
151
+ selector: 'mis-async-search-dropdown',
152
+ template: "<div\n class=\"dd-wrapper\"\n [ngClass]=\"{ opened: opened, disabled: disabled, readonly: readonly }\"\n #ddBtn\n>\n <div class=\"selected-list\" *ngIf=\"multi && selections.size > 0\">\n <span *ngFor=\"let item of selectedItems\" (click)=\"removeItem(item)\">{{item[displayKey]}} <span class=\"ic-navigation-cancel-24\"></span> </span>\n </div>\n <div class=\"search-input\">\n <span class=\"ic-action-search-24\"></span>\n <input\n tabindex=\"0\"\n type=\"text\"\n class=\"black-text\"\n #input\n [placeholder]=\"placeholder\"\n [formControl]=\"searchInput\"\n />\n </div>\n</div>\n\n<ng-template #dd>\n <div class=\"dd-list\" *ngIf=\"data.length\">\n <ng-container *ngFor=\"let item of data\">\n <div (click)=\"selectData(item, false)\">\n <ng-container *ngIf=\"customItem; else standardItem\" [ngTemplateOutlet]=\"customItem\" [ngTemplateOutletContext]=\"{$implicit:item}\"></ng-container>\n <ng-template #standardItem>\n <div class=\"item\">\n <div class=\"value\">\n <div class=\"primary\">\n {{ item[displayKey] }}\n </div>\n <div class=\"secondary\">\n {{item[secondaryDisplayKey]}}\n </div>\n </div>\n </div>\n </ng-template>\n </div>\n </ng-container>\n </div>\n</ng-template>\n",
153
+ styles: [".dd-wrapper{background:#fff;border:1px solid #e0e0e0;box-sizing:border-box;border-radius:4px;display:block;cursor:pointer;outline:none}.dd-wrapper.opened,.dd-wrapper:hover{background:#f5f5f5}.dd-wrapper .selected-list{display:flex;justify-content:flex-start;flex-wrap:wrap;gap:4px;padding:8px 16px}.dd-wrapper .selected-list>span{display:inline-block;background:#e0e0e0;border-radius:16px;padding:6px 12px;cursor:pointer;vertical-align:middle}.dd-wrapper:focus-within{border-color:#0937b2;background:#f5f5f5}.dd-wrapper.disabled,.dd-wrapper.readonly{pointer-events:none}.search-input{position:relative;border-radius:8px}.search-input input{outline:none;padding:10px 12px 10px 48px;background-color:transparent;font-size:15px;line-height:20px;color:#181f33;border-radius:inherit;border:1px solid transparent;width:100%}.search-input span{position:absolute;top:50%;transform:translateY(-50%);font-size:24px;width:24;line-height:24px;height:24px;left:10px}.dd-list{padding:8px 0;max-height:200px;background:#fff;box-shadow:0 12px 24px rgba(0,0,0,.12),0 4px 8px rgba(0,0,0,.12);border-radius:8px;min-width:100%;overflow-y:auto}.dd-list::-webkit-scrollbar{width:8px;border-radius:4px}.dd-list::-webkit-scrollbar-track{background:#fff;border-radius:4px}.dd-list::-webkit-scrollbar-thumb{background:#929dab;border-radius:4px}.dd-list::-webkit-scrollbar-thumb:hover{background:#929dab}.dd-list .item{padding:8px 16px;cursor:pointer}.dd-list .item .disabled{color:#6a737d!important;pointer-events:none}.dd-list .item .value{display:flex;justify-content:space-between;align-items:center}.dd-list .item .value .primary,.dd-list .item .value .secondary{font-style:normal;font-weight:400;font-size:14px;line-height:20px;letter-spacing:.2px;color:#181f33}.dd-list .item .reason{font-weight:400;font-size:14px;line-height:20px;letter-spacing:.2px;color:#6a737d}.dd-list .item:hover:not(.disabled){background:#f5f7fc}"]
154
+ },] }
155
+ ];
156
+ AsyncDropdownComponent.ctorParameters = () => [
157
+ { type: Overlay },
158
+ { type: ViewContainerRef }
159
+ ];
160
+ AsyncDropdownComponent.propDecorators = {
161
+ httpStream: [{ type: Input }],
162
+ displayKey: [{ type: Input }],
163
+ secondaryDisplayKey: [{ type: Input }],
164
+ placeholder: [{ type: Input }],
165
+ debounceTime: [{ type: Input }],
166
+ minInputLength: [{ type: Input }],
167
+ multi: [{ type: Input }],
168
+ uniqueKey: [{ type: Input }],
169
+ control: [{ type: Input }],
170
+ disabled: [{ type: Input }],
171
+ readonly: [{ type: Input }],
172
+ origin: [{ type: ViewChild, args: ['ddBtn', { static: false },] }],
173
+ input: [{ type: ViewChild, args: ['input', { static: false },] }],
174
+ dd: [{ type: ViewChild, args: ['dd', { static: false },] }],
175
+ customItem: [{ type: ContentChild, args: ['misCustomItem', { static: false },] }],
176
+ onSelect: [{ type: Output }]
177
+ };
178
+
179
+ class AsyncDropdownModule {
180
+ }
181
+ AsyncDropdownModule.decorators = [
182
+ { type: NgModule, args: [{
183
+ declarations: [AsyncDropdownComponent],
184
+ imports: [CommonModule, OverlayModule, ReactiveFormsModule, FormsModule],
185
+ exports: [AsyncDropdownComponent],
186
+ },] }
187
+ ];
188
+
189
+ /**
190
+ * Generated bundle index. Do not edit.
191
+ */
192
+
193
+ export { AsyncDropdownComponent, AsyncDropdownModule };
194
+ //# sourceMappingURL=mis-crystal-design-system-async-search-dropdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mis-crystal-design-system-async-search-dropdown.js","sources":["../../../projects/mis-components/async-search-dropdown/async-dropdown.component.ts","../../../projects/mis-components/async-search-dropdown/async-dropdown.module.ts","../../../projects/mis-components/async-search-dropdown/mis-crystal-design-system-async-search-dropdown.ts"],"sourcesContent":["import {\n ConnectionPositionPair,\n Overlay,\n OverlayConfig,\n OverlayRef,\n} from '@angular/cdk/overlay';\nimport { TemplatePortal } from '@angular/cdk/portal';\nimport {\n Component,\n ContentChild,\n ElementRef,\n EventEmitter,\n Input,\n OnChanges,\n OnDestroy,\n OnInit,\n Output,\n SimpleChanges,\n TemplateRef,\n ViewChild,\n ViewContainerRef,\n} from '@angular/core';\nimport { AbstractControl, FormControl } from '@angular/forms';\nimport { Observable, Subscription } from 'rxjs';\nimport { debounceTime, distinctUntilChanged, filter } from 'rxjs/operators';\n\n// tslint:disable-next-line\ntype IListData = any;\n\n@Component({\n selector: 'mis-async-search-dropdown',\n templateUrl: './async-dropdown.component.html',\n styleUrls: ['./async-dropdown.component.scss'],\n})\nexport class AsyncDropdownComponent implements OnInit, OnChanges, OnDestroy {\n constructor(\n private overlay: Overlay,\n private viewContainerRef: ViewContainerRef\n ) {}\n\n @Input() httpStream!: (searchKey: string) => Observable<IListData>; // function that returns an httpobservable\n @Input() displayKey!: string; // string to show value in list\n @Input() secondaryDisplayKey!: string; // string to display secondary value\n @Input() placeholder = 'Select'; // placeholder for input\n @Input() debounceTime = 400; // wait time till which API call is paused\n @Input() minInputLength = 2; // min length after which API call is made\n @Input() multi = false; // maintain a list or emit value\n @Input() uniqueKey: string; // for identifying unique values\n @Input() control: AbstractControl | null; // form control for reactive forms\n @Input() disabled: boolean; // disable actions on component\n @Input() readonly: boolean; // make component readonly\n @ViewChild('ddBtn', { static: false }) origin: ElementRef;\n @ViewChild('input', { static: false }) input: ElementRef;\n @ViewChild('dd', { static: false }) dd: TemplateRef<Element>;\n @ContentChild('misCustomItem', { static: false })\n customItem: TemplateRef<Element>;\n // tslint:disable-next-line\n @Output() onSelect: EventEmitter<IListData | IListData[]> = new EventEmitter(\n true\n ); // emit selected values\n searchInput: FormControl = new FormControl();\n data: IListData[] = [];\n opened = false;\n // tslint:disable-next-line\n selections: Map<string, any> = new Map();\n private searchSubscription: Subscription;\n private overlayRef: OverlayRef;\n controlSubscription: Subscription | undefined;\n\n ngOnInit(): void {\n if (this.multi && !this.uniqueKey) {\n throw new Error('[uniqueKey] required in multi mode.');\n }\n if (this.disabled) {\n this.searchInput.disable();\n }\n this.searchSubscription = this.searchInput.valueChanges\n .pipe(\n filter((val) => val && val.length >= this.minInputLength),\n debounceTime(this.debounceTime),\n distinctUntilChanged()\n )\n .subscribe((res) => {\n this.httpStream(res).subscribe((list) => {\n this.data = list;\n if (!this.overlayRef?.hasAttached() && list.length > 0) {\n this.openDropdown(this.dd, this.origin.nativeElement);\n }\n });\n });\n if (this.control?.value) {\n this.handleControlChanges(this.control.value);\n }\n this.controlSubscription = this.control?.valueChanges.subscribe(\n this.handleControlChanges\n );\n }\n\n ngOnChanges(changes: SimpleChanges): void {\n if (changes && changes.disabled) {\n this.searchInput.enable();\n if (this.disabled) {\n this.searchInput.disable();\n }\n }\n }\n\n ngOnDestroy(): void {\n this.searchSubscription?.unsubscribe();\n }\n\n private handleControlChanges = (values: IListData[]) => {\n values.forEach((el) => {\n this.selectData(el, true);\n });\n // tslint:disable-next-line\n };\n\n private openDropdown(\n template: TemplateRef<Element>,\n origin: HTMLElement\n ): void {\n const positionStrategy = this.overlay\n .position()\n .flexibleConnectedTo(origin)\n .withPositions([\n new ConnectionPositionPair(\n { originX: 'start', originY: 'bottom' },\n { overlayX: 'start', overlayY: 'top' }\n ),\n new ConnectionPositionPair(\n { originX: 'start', originY: 'top' },\n { overlayX: 'start', overlayY: 'bottom' }\n ),\n ])\n .withPush(true);\n\n const configs = new OverlayConfig({\n hasBackdrop: true,\n backdropClass: 'cdk-overlay-transparent-backdrop',\n scrollStrategy: this.overlay.scrollStrategies.reposition(),\n positionStrategy,\n width: origin.clientWidth,\n });\n this.overlayRef = this.overlay.create(configs);\n this.overlayRef.attach(new TemplatePortal(template, this.viewContainerRef));\n this.overlayRef.backdropClick().subscribe((res) => {\n this.closeDropdown();\n });\n }\n\n /**\n * closes the dropdown\n */\n closeDropdown(): void {\n this.opened = false;\n this.overlayRef?.detach();\n this.data = [];\n }\n\n /**\n *\n * @param item item to select\n * if item property disabled is set to true, selection will be disabled\n * @param effectedFromOutside set to true if calling from parent component, if true will focus on search input\n */\n selectData(item: IListData, effectedFromOutside = true): void {\n if (item.disabled) {\n return;\n }\n if (!this.multi) {\n this.searchInput.patchValue(item[this.displayKey], { emitEvent: false });\n this.setControlValue(item);\n } else {\n if (!this.selections.has(item[this.uniqueKey])) {\n this.selections.set(item[this.uniqueKey], item);\n }\n this.setControlValue(this.selectedItems);\n if (!effectedFromOutside) {\n setTimeout(() => {\n this.input.nativeElement.focus();\n this.input.nativeElement.scrollIntoView();\n }, 10);\n }\n this.searchInput.patchValue('');\n this.data = [];\n }\n this.closeDropdown();\n }\n\n /**\n *\n * @param item remove item from selected list\n */\n removeItem(item: IListData): void {\n this.selections.delete(item[this.uniqueKey]);\n this.setControlValue(this.selectedItems);\n // tslint:disable-next-line\n this.input['nativeElement'].focus();\n }\n\n private setControlValue(value: IListData): void {\n this.onSelect.emit(value);\n this.control?.patchValue(value, { emitEvent: false });\n }\n\n /**\n * @returns list of selected items\n */\n get selectedItems(): Array<IListData> {\n return Array.from(this.selections.values());\n }\n}\n","import { OverlayModule } from '@angular/cdk/overlay';\nimport { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { FormsModule, ReactiveFormsModule } from '@angular/forms';\nimport { AsyncDropdownComponent } from './async-dropdown.component';\n\n@NgModule({\n declarations: [AsyncDropdownComponent],\n imports: [CommonModule, OverlayModule, ReactiveFormsModule, FormsModule],\n exports: [AsyncDropdownComponent],\n})\nexport class AsyncDropdownModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;MAkCa,sBAAsB;IACjC,YACU,OAAgB,EAChB,gBAAkC;QADlC,YAAO,GAAP,OAAO,CAAS;QAChB,qBAAgB,GAAhB,gBAAgB,CAAkB;QAMnC,gBAAW,GAAG,QAAQ,CAAC;QACvB,iBAAY,GAAG,GAAG,CAAC;QACnB,mBAAc,GAAG,CAAC,CAAC;QACnB,UAAK,GAAG,KAAK,CAAC;;QAWb,aAAQ,GAA0C,IAAI,YAAY,CAC1E,IAAI,CACL,CAAC;QACF,gBAAW,GAAgB,IAAI,WAAW,EAAE,CAAC;QAC7C,SAAI,GAAgB,EAAE,CAAC;QACvB,WAAM,GAAG,KAAK,CAAC;;QAEf,eAAU,GAAqB,IAAI,GAAG,EAAE,CAAC;QA+CjC,yBAAoB,GAAG,CAAC,MAAmB;YACjD,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE;gBAChB,IAAI,CAAC,UAAU,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;aAC3B,CAAC,CAAC;;SAEJ,CAAC;KA9EE;IA+BJ,QAAQ;;QACN,IAAI,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACjC,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;SACxD;QACD,IAAI,IAAI,CAAC,QAAQ,EAAE;YACjB,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;SAC5B;QACD,I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1B,MAAA,IAAI,CAAC,OAAO,0CAAE,UAAU,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE;KACvD;;;;IAKD,IAAI,aAAa;QACf,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;KAC7C;;;YAtLF,SAAS,SAAC;gBACT,QAAQ,EAAE,2BAA2B;gBACrC,w2CAA8C;;aAE/C;;;YA/BC,OAAO;YAkBP,gBAAgB;;;yBAoBf,KAAK;yBACL,KAAK;kCACL,KAAK;0BACL,KAAK;2BACL,KAAK;6BACL,KAAK;oBACL,KAAK;wBACL,KAAK;sBACL,KAAK;uBACL,KAAK;uBACL,KAAK;qBACL,SAAS,SAAC,OAAO,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE;oBACpC,SAAS,SAAC,OAAO,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE;iBACpC,SAAS,SAAC,IAAI,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE;yBACjC,YAAY,SAAC,eAAe,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE;uBAG/C,MAAM;;;MC9CI,mBAAmB;;;YAL/B,QAAQ,SAAC;gBACR,YAAY,EAAE,CAAC,sBAAsB,CAAC;gBACtC,OAAO,EAAE,CAAC,YAAY,EAAE,aAAa,EAAE,mBAAmB,EAAE,WAAW,CAAC;gBACxE,OAAO,EAAE,CAAC,sBAAsB,CAAC;aAClC;;;ACVD;;;;;;"}
@@ -1,4 +1,4 @@
1
- import { EventEmitter, Component, Input, Output, NgModule } from '@angular/core';
1
+ import { EventEmitter, Component, Input, Output, Directive, ElementRef, Renderer2, HostBinding, NgModule } from '@angular/core';
2
2
  import { CommonModule } from '@angular/common';
3
3
 
4
4
  class ButtonComponent {
@@ -43,6 +43,62 @@ ButtonComponent.propDecorators = {
43
43
  click: [{ type: Output }]
44
44
  };
45
45
 
46
+ class ButtonDirective {
47
+ constructor(el, renderer) {
48
+ this.el = el;
49
+ this.renderer = renderer;
50
+ this.type = 'none';
51
+ this.size = 'md';
52
+ this.elementClass = 'mis-btn';
53
+ }
54
+ ngAfterViewInit() {
55
+ this.bindTypeClass();
56
+ this.bindSizeClass();
57
+ }
58
+ bindTypeClass() {
59
+ let className = '';
60
+ switch (this.type) {
61
+ case 'primary':
62
+ className = 'mis-primary';
63
+ break;
64
+ case 'outline':
65
+ className = 'mis-outline';
66
+ break;
67
+ default:
68
+ className = 'mis-none';
69
+ }
70
+ this.renderer.addClass(this.el.nativeElement, className);
71
+ }
72
+ bindSizeClass() {
73
+ let className = '';
74
+ switch (this.size) {
75
+ case 'lg':
76
+ className = 'mis-btn-lg';
77
+ break;
78
+ case 'sm':
79
+ className = 'mis-btn-sm';
80
+ break;
81
+ default:
82
+ className = 'mis-btn-md';
83
+ }
84
+ this.renderer.addClass(this.el.nativeElement, className);
85
+ }
86
+ }
87
+ ButtonDirective.decorators = [
88
+ { type: Directive, args: [{
89
+ selector: '[mis-button]',
90
+ },] }
91
+ ];
92
+ ButtonDirective.ctorParameters = () => [
93
+ { type: ElementRef },
94
+ { type: Renderer2 }
95
+ ];
96
+ ButtonDirective.propDecorators = {
97
+ type: [{ type: Input }],
98
+ size: [{ type: Input }],
99
+ elementClass: [{ type: HostBinding, args: ['class',] }]
100
+ };
101
+
46
102
  class ButtonModule {
47
103
  static forRoot() {
48
104
  return { ngModule: ButtonModule, providers: [] };
@@ -50,9 +106,9 @@ class ButtonModule {
50
106
  }
51
107
  ButtonModule.decorators = [
52
108
  { type: NgModule, args: [{
53
- declarations: [ButtonComponent],
109
+ declarations: [ButtonComponent, ButtonDirective],
54
110
  imports: [CommonModule],
55
- exports: [ButtonComponent]
111
+ exports: [ButtonComponent, ButtonDirective]
56
112
  },] }
57
113
  ];
58
114
 
@@ -60,5 +116,5 @@ ButtonModule.decorators = [
60
116
  * Generated bundle index. Do not edit.
61
117
  */
62
118
 
63
- export { ButtonComponent, ButtonModule };
119
+ export { ButtonComponent, ButtonModule, ButtonDirective as ɵa };
64
120
  //# sourceMappingURL=mis-crystal-design-system-button.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mis-crystal-design-system-button.js","sources":["../../../projects/mis-components/button/button.component.ts","../../../projects/mis-components/button/button.module.ts","../../../projects/mis-components/button/mis-crystal-design-system-button.ts"],"sourcesContent":["import {Component, Input, OnInit, Output, EventEmitter, ContentChild, TemplateRef} from '@angular/core';\n\n@Component({\n selector: 'mis-button',\n templateUrl: './button.component.html',\n styleUrls: ['./button.component.scss']\n})\nexport class ButtonComponent implements OnInit{\n\n @Input() name: string = 'Enabled'\n @Input() type: 'Solid' | 'Outline' | 'Text' = 'Solid'\n @Input() size: 'Small' | 'Medium' | 'Large' | 'Small-M' | 'Large-M' = 'Medium'\n @Input() width: string = ''\n\n @Input() showIcon: boolean = false\n @Input() iconUrl: string = ''\n @Input() iconPosition: 'Left' | 'Right' = 'Left'\n\n @Input() disabled: boolean = false\n @Input() disableLeftBorderRadius: boolean = false\n @Input() disableRightBorderRadius: boolean = false\n\n /** Emits event when button is clicked */\n @Output() click = new EventEmitter<any>()\n\n constructor(){}\n\n ngOnInit(){}\n\n onClick(event){\n this.click.emit(event)\n }\n}\n","import { NgModule, ModuleWithProviders } from '@angular/core';\nimport { CommonModule } from '@angular/common';\n\nimport { ButtonComponent } from './button.component';\n\n@NgModule({\n declarations: [ButtonComponent],\n imports: [CommonModule],\n exports: [ButtonComponent]\n})\nexport class ButtonModule {\n static forRoot(): ModuleWithProviders<ButtonModule> {\n return { ngModule: ButtonModule, providers: [] };\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;MAOa,eAAe;IAkB1B;QAhBS,SAAI,GAAW,SAAS,CAAA;QACxB,SAAI,GAAiC,OAAO,CAAA;QAC5C,SAAI,GAAyD,QAAQ,CAAA;QACrE,UAAK,GAAW,EAAE,CAAA;QAElB,aAAQ,GAAY,KAAK,CAAA;QACzB,YAAO,GAAW,EAAE,CAAA;QACpB,iBAAY,GAAqB,MAAM,CAAA;QAEvC,aAAQ,GAAY,KAAK,CAAA;QACzB,4BAAuB,GAAY,KAAK,CAAA;QACxC,6BAAwB,GAAY,KAAK,CAAA;;QAGxC,UAAK,GAAG,IAAI,YAAY,EAAO,CAAA;KAE1B;IAEf,QAAQ,MAAI;IAEZ,OAAO,CAAC,KAAK;QACX,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;KACvB;;;YA7BF,SAAS,SAAC;gBACT,QAAQ,EAAE,YAAY;gBACtB,m9BAAsC;;aAEvC;;;;mBAGE,KAAK;mBACL,KAAK;mBACL,KAAK;oBACL,KAAK;uBAEL,KAAK;sBACL,KAAK;2BACL,KAAK;uBAEL,KAAK;sCACL,KAAK;uCACL,KAAK;oBAGL,MAAM;;;MCbI,YAAY;IACvB,OAAO,OAAO;QACZ,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;KAClD;;;YARF,QAAQ,SAAC;gBACR,YAAY,EAAE,CAAC,eAAe,CAAC;gBAC/B,OAAO,EAAE,CAAC,YAAY,CAAC;gBACvB,OAAO,EAAE,CAAC,eAAe,CAAC;aAC3B;;;ACTD;;;;;;"}
1
+ {"version":3,"file":"mis-crystal-design-system-button.js","sources":["../../../projects/mis-components/button/button.component.ts","../../../projects/mis-components/button/button.directive.ts","../../../projects/mis-components/button/button.module.ts","../../../projects/mis-components/button/mis-crystal-design-system-button.ts"],"sourcesContent":["import {Component, Input, OnInit, Output, EventEmitter, ContentChild, TemplateRef} from '@angular/core';\n\n@Component({\n selector: 'mis-button',\n templateUrl: './button.component.html',\n styleUrls: ['./button.component.scss']\n})\nexport class ButtonComponent implements OnInit{\n\n @Input() name: string = 'Enabled'\n @Input() type: 'Solid' | 'Outline' | 'Text' = 'Solid'\n @Input() size: 'Small' | 'Medium' | 'Large' | 'Small-M' | 'Large-M' = 'Medium'\n @Input() width: string = ''\n\n @Input() showIcon: boolean = false\n @Input() iconUrl: string = ''\n @Input() iconPosition: 'Left' | 'Right' = 'Left'\n\n @Input() disabled: boolean = false\n @Input() disableLeftBorderRadius: boolean = false\n @Input() disableRightBorderRadius: boolean = false\n\n /** Emits event when button is clicked */\n @Output() click = new EventEmitter<any>()\n\n constructor(){}\n\n ngOnInit(){}\n\n onClick(event){\n this.click.emit(event)\n }\n}\n","import {\n AfterViewInit,\n Directive,\n ElementRef,\n HostBinding,\n Input,\n Renderer2,\n} from '@angular/core';\n\n@Directive({\n selector: '[mis-button]',\n})\nexport class ButtonDirective implements AfterViewInit {\n @Input() type: 'primary' | 'outline' | 'none' = 'none';\n @Input() size: 'sm' | 'md' | 'lg' = 'md';\n @HostBinding('class') elementClass = 'mis-btn';\n\n constructor(private el: ElementRef, private renderer: Renderer2) { }\n\n ngAfterViewInit(): void {\n this.bindTypeClass();\n this.bindSizeClass();\n }\n\n private bindTypeClass(): void {\n let className = '';\n switch (this.type) {\n case 'primary':\n className = 'mis-primary';\n break;\n case 'outline':\n className = 'mis-outline';\n break;\n default:\n className = 'mis-none';\n }\n this.renderer.addClass(this.el.nativeElement, className);\n }\n\n private bindSizeClass(): void {\n let className = '';\n switch (this.size) {\n case 'lg':\n className = 'mis-btn-lg';\n break;\n case 'sm':\n className = 'mis-btn-sm';\n break;\n default:\n className = 'mis-btn-md';\n }\n this.renderer.addClass(this.el.nativeElement, className);\n }\n}\n","import { NgModule, ModuleWithProviders } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { ButtonDirective } from './button.directive';\nimport { ButtonComponent } from './button.component';\n\n@NgModule({\n declarations: [ButtonComponent, ButtonDirective],\n imports: [CommonModule],\n exports: [ButtonComponent, ButtonDirective]\n})\nexport class ButtonModule {\n static forRoot(): ModuleWithProviders<ButtonModule> {\n return { ngModule: ButtonModule, providers: [] };\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n\nexport {ButtonDirective as ɵa} from './button.directive';"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,MAAM;YACR;gBACE,SAAS,GAAG,UAAU,CAAC;SAC1B;QACD,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;KAC1D;IAEO,aAAa;QACnB,IAAI,SAAS,GAAG,EAAE,CAAC;QACnB,QAAQ,IAAI,CAAC,IAAI;YACf,KAAK,IAAI;gBACP,SAAS,GAAG,YAAY,CAAC;gBACzB,MAAM;YACR,KAAK,IAAI;gBACP,SAAS,GAAG,YAAY,CAAC;gBACzB,MAAM;YACR;gBACE,SAAS,GAAG,YAAY,CAAC;SAC5B;QACD,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;KAC1D;;;YA3CF,SAAS,SAAC;gBACT,QAAQ,EAAE,cAAc;aACzB;;;YARC,UAAU;YAGV,SAAS;;;mBAOR,KAAK;mBACL,KAAK;2BACL,WAAW,SAAC,OAAO;;;MCLT,YAAY;IACvB,OAAO,OAAO;QACZ,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;KAClD;;;YARF,QAAQ,SAAC;gBACR,YAAY,EAAE,CAAC,eAAe,EAAE,eAAe,CAAC;gBAChD,OAAO,EAAE,CAAC,YAAY,CAAC;gBACvB,OAAO,EAAE,CAAC,eAAe,EAAE,eAAe,CAAC;aAC5C;;;ACTD;;;;;;"}
@@ -0,0 +1,94 @@
1
+ import { Directive, ElementRef, Self, Optional, Component, Input, ContentChild, NgModule } from '@angular/core';
2
+ import { NgControl, FormsModule } from '@angular/forms';
3
+ import { ReplaySubject, Subject } from 'rxjs';
4
+ import { takeUntil } from 'rxjs/operators';
5
+ import { CommonModule } from '@angular/common';
6
+
7
+ class MisInputDirective {
8
+ constructor(el, control) {
9
+ this.el = el;
10
+ this.control = control;
11
+ this.validityChange = new ReplaySubject(1);
12
+ this.validity = this.validityChange.asObservable();
13
+ this.endObs = new Subject();
14
+ this.focus = false;
15
+ this.hasValue = false;
16
+ }
17
+ ngOnInit() {
18
+ var _a, _b;
19
+ (_b = (_a = this.control) === null || _a === void 0 ? void 0 : _a.control) === null || _b === void 0 ? void 0 : _b.statusChanges.pipe(takeUntil(this.endObs)).subscribe(() => {
20
+ var _a;
21
+ this.validityChange.next((_a = this.control.control) === null || _a === void 0 ? void 0 : _a.valid);
22
+ });
23
+ this.el.nativeElement.placeholder += ' ';
24
+ }
25
+ ngOnDestroy() {
26
+ this.endObs.next();
27
+ this.endObs.complete();
28
+ }
29
+ }
30
+ MisInputDirective.decorators = [
31
+ { type: Directive, args: [{
32
+ // tslint:disable-next-line
33
+ selector: 'input[misInput]',
34
+ },] }
35
+ ];
36
+ MisInputDirective.ctorParameters = () => [
37
+ { type: ElementRef },
38
+ { type: NgControl, decorators: [{ type: Self }, { type: Optional }] }
39
+ ];
40
+
41
+ class MisInputComponent {
42
+ constructor() {
43
+ this.type = 'floating';
44
+ this.noHints = false;
45
+ this.hasError = false; // show input in error state
46
+ this.inputValidity = true;
47
+ }
48
+ set formInput(input) {
49
+ var _a;
50
+ if (!this.placeholder) {
51
+ this.placeholder = input.el.nativeElement.placeholder;
52
+ }
53
+ (_a = this.inputSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
54
+ this.inputSubscription = input === null || input === void 0 ? void 0 : input.validity.subscribe((res) => (this.inputValidity = res));
55
+ this.placeholder += ' ';
56
+ }
57
+ ngOnInit() { }
58
+ ngOnDestroy() {
59
+ var _a;
60
+ (_a = this.inputSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
61
+ }
62
+ }
63
+ MisInputComponent.decorators = [
64
+ { type: Component, args: [{
65
+ selector: 'mis-input',
66
+ template: "<div class=\"input-container\" [ngClass]=\"{'rounded': type === 'rounded', 'floating': type === 'floating', 'has-error': !inputValidity || hasError, 'no-hint': noHints}\">\n <div class=\"input-wrapper\">\n <ng-content select=\"[mis-input-icon]\"></ng-content>\n <div class=\"mis-input\">\n <ng-content select=\"input\"></ng-content>\n <span class=\"mis-placeholder\">{{placeholder}}</span>\n </div>\n <ng-content select=\"[mis-input-act]\"></ng-content>\n </div>\n <ng-content select=\"[mis-input-hint]\"></ng-content>\n <ng-content select=\"[mis-input-error]\"></ng-content>\n</div>",
67
+ styles: [".input-container{position:relative;padding-bottom:24px}.input-container .input-wrapper{box-sizing:border-box;display:flex;align-items:center;flex-direction:row;flex-wrap:nowrap;transition:all 60ms ease-in;background-color:#fff;padding:3px 16px}.input-container .input-wrapper>:not(:last-child){margin-right:16px}.input-container .input-wrapper .mis-input{flex:1 1 auto;z-index:0;position:relative;display:flex;align-items:center}.input-container .input-wrapper input{flex:1 1 auto;border:none;outline:none;height:100%;padding:0;font-family:Lato;font-style:normal;font-weight:400;font-size:16px;height:24px;color:#181f33;background-color:transparent;width:100%;vertical-align:middle}.input-container .input-wrapper input::-moz-placeholder{-moz-transition:all .1s ease-in;transition:all .1s ease-in;opacity:0;transform-origin:left center;color:transparent}.input-container .input-wrapper input:-ms-input-placeholder{-ms-transition:all .1s ease-in;transition:all .1s ease-in;opacity:0;transform-origin:left center;color:transparent}.input-container .input-wrapper input::placeholder{transition:all .1s ease-in;opacity:0;transform-origin:left center;color:transparent}.input-container .input-wrapper .mis-placeholder{position:absolute;font-family:Lato;font-style:normal;font-weight:400;font-size:16px;line-height:24px;color:#6a737d;z-index:-1;transition:all .15s ease-in}.input-container .input-wrapper:focus-within{background-color:#f5f5f5}.input-container .input-wrapper:focus-within{border:1px solid #0937b2}.input-container .input-wrapper [mis-input-act],.input-container .input-wrapper [mis-input-icon]{width:18px;height:18px;color:#6a737d;font-size:24px;line-height:18px}.input-container .input-wrapper [mis-input-act]{cursor:pointer}.input-container.no-hint{padding-bottom:0}.input-container.rounded .input-wrapper{border-radius:4px;border:1px solid #e0e0e0}.input-container.rounded .input-wrapper:focus-within,.input-container.rounded .input-wrapper:hover{background-color:#f5f5f5}.input-container.rounded .input-wrapper input:not(:-moz-placeholder-shown)+.mis-placeholder{color:transparent!important}.input-container.rounded .input-wrapper input:not(:-ms-input-placeholder)+.mis-placeholder{color:transparent!important}.input-container.rounded .input-wrapper input:not(:placeholder-shown)+.mis-placeholder{color:transparent!important}.input-container.rounded .input-wrapper .mis-placeholder{transition-duration:50ms}.input-container.rounded.has-error .input-wrapper{border:1px solid #b00020!important}.input-container.floating .input-wrapper{padding-top:24px;padding-bottom:7px;border-bottom:1px solid #e0e0e0}.input-container.floating .input-wrapper input:focus+.mis-placeholder{color:#0937b2!important}.input-container.floating .input-wrapper input:not(:-moz-placeholder-shown)+.mis-placeholder{transform:translateY(calc(-100% + 6px))!important;font-size:12px!important;letter-spacing:.2px!important}.input-container.floating .input-wrapper input:not(:-ms-input-placeholder)+.mis-placeholder{transform:translateY(calc(-100% + 6px))!important;font-size:12px!important;letter-spacing:.2px!important}.input-container.floating .input-wrapper input:focus+.mis-placeholder,.input-container.floating .input-wrapper input:not(:placeholder-shown)+.mis-placeholder{transform:translateY(calc(-100% + 6px))!important;font-size:12px!important;letter-spacing:.2px!important}.input-container.floating .input-wrapper:focus-within{border:none;border-bottom:1px solid #0937b2}.input-container.floating .input-wrapper:focus-within input::-moz-placeholder{color:#6a737d;opacity:1;font-size:16px}.input-container.floating .input-wrapper:focus-within input:-ms-input-placeholder{color:#6a737d;opacity:1;font-size:16px}.input-container.floating .input-wrapper:focus-within input::placeholder{color:#6a737d;opacity:1;font-size:16px}.input-container.floating.has-error .input-wrapper{border-bottom:1px solid #b00020!important}.input-container.floating.has-error .input-wrapper .mis-placeholder{color:#b00020!important}.input-container [mis-input-error],.input-container [mis-input-hint]{position:absolute;left:0;right:0;bottom:0;line-height:24px;height:24px;font-size:12px;color:#6a737d;letter-spacing:.2px}.input-container [mis-input-error]{color:#b00020}"]
68
+ },] }
69
+ ];
70
+ MisInputComponent.ctorParameters = () => [];
71
+ MisInputComponent.propDecorators = {
72
+ type: [{ type: Input }],
73
+ placeholder: [{ type: Input }],
74
+ noHints: [{ type: Input }],
75
+ hasError: [{ type: Input }],
76
+ formInput: [{ type: ContentChild, args: [MisInputDirective,] }]
77
+ };
78
+
79
+ class MisInputModule {
80
+ }
81
+ MisInputModule.decorators = [
82
+ { type: NgModule, args: [{
83
+ declarations: [MisInputComponent, MisInputDirective],
84
+ imports: [CommonModule, FormsModule],
85
+ exports: [MisInputComponent, MisInputDirective],
86
+ },] }
87
+ ];
88
+
89
+ /**
90
+ * Generated bundle index. Do not edit.
91
+ */
92
+
93
+ export { MisInputComponent, MisInputDirective, MisInputModule };
94
+ //# sourceMappingURL=mis-crystal-design-system-input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mis-crystal-design-system-input.js","sources":["../../../projects/mis-components/input/directives/input/input.directive.ts","../../../projects/mis-components/input/mis-input.component.ts","../../../projects/mis-components/input/mis-input.module.ts","../../../projects/mis-components/input/mis-crystal-design-system-input.ts"],"sourcesContent":["import {\n Directive,\n ElementRef,\n OnDestroy,\n OnInit,\n Optional,\n Self,\n} from '@angular/core';\nimport { NgControl } from '@angular/forms';\nimport { ReplaySubject, Subject, Subscription } from 'rxjs';\nimport { takeUntil } from 'rxjs/operators';\n\n@Directive({\n // tslint:disable-next-line\n selector: 'input[misInput]',\n})\nexport class MisInputDirective implements OnInit, OnDestroy {\n constructor(\n public el: ElementRef,\n @Self() @Optional() private control: NgControl\n ) {}\n private validityChange: ReplaySubject<boolean> = new ReplaySubject(1);\n validity = this.validityChange.asObservable();\n endObs: Subject<void> = new Subject();\n focus = false;\n hasValue = false;\n\n ngOnInit(): void {\n this.control?.control?.statusChanges\n .pipe(takeUntil(this.endObs))\n .subscribe(() => {\n this.validityChange.next(this.control.control?.valid);\n });\n this.el.nativeElement.placeholder += ' ';\n }\n ngOnDestroy(): void {\n this.endObs.next();\n this.endObs.complete();\n }\n}\n","import {\n Component,\n ContentChild,\n Input,\n OnDestroy,\n OnInit,\n ViewEncapsulation,\n} from '@angular/core';\nimport { Subscription } from 'rxjs';\nimport { MisInputDirective } from './directives/input/input.directive';\n\n@Component({\n selector: 'mis-input',\n templateUrl: './mis-input.component.html',\n styleUrls: ['./mis-input.component.scss'],\n})\nexport class MisInputComponent implements OnInit, OnDestroy {\n @Input() type: 'rounded' | 'floating' = 'floating';\n @Input() placeholder: string; // floating placeholder text\n @Input() noHints = false;\n @Input() hasError = false; // show input in error state\n @ContentChild(MisInputDirective) set formInput(input: MisInputDirective) {\n if (!this.placeholder) {\n this.placeholder = input.el.nativeElement.placeholder;\n }\n this.inputSubscription?.unsubscribe();\n this.inputSubscription = input?.validity.subscribe(\n (res) => (this.inputValidity = res)\n );\n this.placeholder += ' ';\n }\n inputSubscription: Subscription | undefined;\n inputValidity: boolean = true;\n constructor() {}\n\n ngOnInit(): void {}\n ngOnDestroy(): void {\n this.inputSubscription?.unsubscribe();\n }\n}\n","import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { FormsModule } from '@angular/forms';\nimport { MisInputDirective } from './directives/input/input.directive';\nimport { MisInputComponent } from './mis-input.component';\n\n@NgModule({\n declarations: [MisInputComponent, MisInputDirective],\n imports: [CommonModule, FormsModule],\n exports: [MisInputComponent, MisInputDirective],\n})\nexport class MisInputModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;MAgBa,iBAAiB;IAC5B,YACS,EAAc,EACO,OAAkB;QADvC,OAAE,GAAF,EAAE,CAAY;QACO,YAAO,GAAP,OAAO,CAAW;QAExC,mBAAc,GAA2B,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC;QACtE,aAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,YAAY,EAAE,CAAC;QAC9C,WAAM,GAAkB,IAAI,OAAO,EAAE,CAAC;QACtC,UAAK,GAAG,KAAK,CAAC;QACd,aAAQ,GAAG,KAAK,CAAC;KALb;IAOJ,QAAQ;;QACN,YAAA,IAAI,CAAC,OAAO,0CAAE,OAAO,0CAAE,aAAa,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