@datarailsshared/datarailsshared 1.3.4 → 1.3.5

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.
@@ -1,8 +1,11 @@
1
- import { EventEmitter, Component, ViewEncapsulation, Input, Output, ChangeDetectionStrategy, forwardRef, ElementRef, Renderer2, ChangeDetectorRef, ContentChild, HostBinding, Directive, ComponentFactoryResolver, ViewContainerRef, Inject, ViewChild, NgModule } from '@angular/core';
1
+ import { EventEmitter, Component, ViewEncapsulation, Input, Output, ChangeDetectionStrategy, forwardRef, ElementRef, Renderer2, ChangeDetectorRef, ContentChild, HostBinding, TemplateRef, Directive, HostListener, ComponentFactoryResolver, ViewContainerRef, Inject, ViewChild, NgModule } from '@angular/core';
2
2
  import { FormControl, NG_VALUE_ACCESSOR, FormsModule, ReactiveFormsModule } from '@angular/forms';
3
3
  import { DateAdapter, MAT_DATE_LOCALE, MAT_DATE_FORMATS, MatNativeDateModule } from '@angular/material/core';
4
4
  import { MomentDateAdapter, MAT_MOMENT_DATE_ADAPTER_OPTIONS, MatMomentDateModule } from '@angular/material-moment-adapter';
5
5
  import * as momentImported from 'moment';
6
+ import { trigger, transition, style, animate } from '@angular/animations';
7
+ import { Overlay, OverlayPositionBuilder } from '@angular/cdk/overlay';
8
+ import { ComponentPortal } from '@angular/cdk/portal';
6
9
  import { DOCUMENT, CommonModule } from '@angular/common';
7
10
  import { MatDatepickerModule } from '@angular/material/datepicker';
8
11
  import { MatFormFieldModule } from '@angular/material/form-field';
@@ -10,6 +13,7 @@ import { MatInputModule } from '@angular/material/input';
10
13
  import { MatSelectModule } from '@angular/material/select';
11
14
  import { MatButtonToggleModule } from '@angular/material/button-toggle';
12
15
  import { NgSelectModule } from '@ng-select/ng-select';
16
+ import { MatTooltipModule } from '@angular/material/tooltip';
13
17
 
14
18
  // import {*} from ""
15
19
  class DateTagComponent {
@@ -252,7 +256,8 @@ class MonthTagComponent extends AnyTagComponent {
252
256
  }
253
257
  initDate() {
254
258
  if (this.defaultValue) {
255
- this.dateObj.date = moment$5(new Date(this.defaultValue * 1000)).utc().format("YYYY-MM");
259
+ this.dateObj.date = moment$5(this.defaultValue * 1000).utc().format("YYYY-MM");
260
+ this.date = new FormControl(moment$5(this.defaultValue * 1000));
256
261
  }
257
262
  else {
258
263
  this.dateObj.date = moment$5(new Date()).format("YYYY-MM");
@@ -1064,6 +1069,231 @@ DrSelectComponent.propDecorators = {
1064
1069
  optionTemplate: [{ type: ContentChild, args: ['optionTemplate',] }]
1065
1070
  };
1066
1071
 
1072
+ class DrAvatarComponent {
1073
+ constructor() {
1074
+ this.users = [];
1075
+ this.userClicked = new EventEmitter();
1076
+ }
1077
+ ngOnChanges(changes) {
1078
+ var _a;
1079
+ if (changes.users && ((_a = changes.users.currentValue) === null || _a === void 0 ? void 0 : _a.length)) {
1080
+ this.getFirstUsers().forEach((user, index) => user.class = `icon-${index}`);
1081
+ this.getLastUsers().forEach((user) => user.class = `icon-${this.getRandomValue(5)}`);
1082
+ }
1083
+ }
1084
+ getFirstUsers() {
1085
+ return this.users.slice(0, 2);
1086
+ }
1087
+ getLastUsers() {
1088
+ if (this.users.length > 2) {
1089
+ return this.users.slice(2, this.users.length - 1);
1090
+ }
1091
+ }
1092
+ getRandomValue(limit) {
1093
+ return ~~(limit * Math.random());
1094
+ }
1095
+ }
1096
+ DrAvatarComponent.decorators = [
1097
+ { type: Component, args: [{
1098
+ selector: 'dr-avatar',
1099
+ template: "<div class=\"users-section\">\r\n <div class=\"users-section__user\"\r\n [class]=\"user.class\"\r\n *ngFor=\"let user of getFirstUsers()\"\r\n (click)=\"userClicked.emit()\"\r\n [matTooltip]=\"user.first_name + ' ' + user.last_name\"\r\n [matTooltipPosition]=\"'below'\">\r\n {{user.first_name[0] + user.last_name[0]}}\r\n </div>\r\n\r\n <div class=\"users-section__user icon-2\" *ngIf=\"users.length > 2\"\r\n [drTooltip]=\"usersTemplate\"\r\n [drTooltipPosition]=\"'bottom'\">\r\n {{getLastUsers().length}}\r\n </div>\r\n</div>\r\n\r\n<ng-template #usersTemplate>\r\n <div *ngFor=\"let user of getLastUsers()\" class=\"users-popover-item\">\r\n <div class=\"users-section__user\"\r\n (click)=\"userClicked.emit()\"\r\n [class]=\"user.class\">\r\n {{user.first_name[0] + user.last_name[0]}}\r\n </div>\r\n <span class=\"username\">\r\n {{user.first_name + ' ' + user.last_name}}\r\n </span>\r\n </div>\r\n</ng-template>\r\n",
1100
+ changeDetection: ChangeDetectionStrategy.OnPush,
1101
+ styles: [":host{width:627px}.users-section{display:flex;position:absolute;height:28px;top:5px}.users-popover-item{display:flex;align-items:center;margin:12px}.users-popover-item .username{color:#51566f;font-size:14px}.users-popover-item .users-section__user{margin-right:8px}.users-section__user{display:flex;justify-content:center;align-items:center;height:28px;width:28px;border-radius:14px;background:red;color:#fff;font-size:12px}.users-section__user.icon-0{background-color:#7b61ff}.users-section__user.icon-1{background-color:#21b8f1}.users-section__user.icon-2{background-color:#2969b0}.users-section__user.icon-3{background-color:#51566f}.users-section__user.icon-4{background-color:#0061ff}.users-section__user:hover{cursor:pointer}.users-section__user:not(:first-child){margin-left:4px}\n"]
1102
+ },] }
1103
+ ];
1104
+ DrAvatarComponent.ctorParameters = () => [];
1105
+ DrAvatarComponent.propDecorators = {
1106
+ users: [{ type: Input }],
1107
+ userClicked: [{ type: Output }]
1108
+ };
1109
+
1110
+ class TooltipComponent {
1111
+ constructor() {
1112
+ this.isContentTemplate = false;
1113
+ }
1114
+ ngOnInit() {
1115
+ this.isContentTemplate = this.content instanceof TemplateRef;
1116
+ }
1117
+ }
1118
+ TooltipComponent.decorators = [
1119
+ { type: Component, args: [{
1120
+ selector: 'dr-tooltip',
1121
+ template: "<div [class]=\"position + ' ' + class\" [ngClass]=\"{'dr-tooltip': !options?.withoutContainerStyles}\">\r\n <div class=\"dr-tooltip-arrow\"></div>\r\n <ng-container *ngIf=\"isContentTemplate; else defaultContent\">\r\n <ng-container *ngTemplateOutlet=\"content; context: contentContext\"></ng-container>\r\n </ng-container>\r\n <ng-template #defaultContent>\r\n <div class=\"default-content\">{{ content }}</div>\r\n </ng-template>\r\n</div>\r\n",
1122
+ animations: [
1123
+ trigger('tooltip', [
1124
+ transition(':enter', [
1125
+ style({ opacity: 0 }),
1126
+ animate(300, style({ opacity: 1 })),
1127
+ ]),
1128
+ transition(':leave', [
1129
+ animate(300, style({ opacity: 0 })),
1130
+ ]),
1131
+ ]),
1132
+ ],
1133
+ styles: [":host{display:block}.dr-tooltip{background:#fff;border:1px solid #cfd7dd;box-sizing:border-box;border-radius:4px;font-size:12px;color:#545a6b;max-width:80vh!important;box-shadow:0 2px 4px #919907}.dr-tooltip .default-content{padding:.5rem;font-size:11px;line-height:16px;white-space:pre;text-overflow:ellipsis;overflow:hidden}.dr-tooltip-arrow{border-width:8px}.dr-tooltip-arrow,.dr-tooltip-arrow:after{position:absolute;display:block;width:0;height:0;border-color:transparent;border-style:solid}.dr-tooltip-arrow:after{content:\"\";border-width:8px}.top .dr-tooltip-arrow,.top-left .dr-tooltip-arrow,.top-right .dr-tooltip-arrow{bottom:-16px;border-top-color:#cfd7dd!important}.top .dr-tooltip-arrow:after,.top-left .dr-tooltip-arrow:after,.top-right .dr-tooltip-arrow:after{bottom:-6px;left:-8px;border-top-color:#fff}.bottom .dr-tooltip-arrow,.bottom-left .dr-tooltip-arrow,.bottom-right .dr-tooltip-arrow{top:-7px;border-top:none;border-bottom-color:#cfd7dd!important}.bottom .dr-tooltip-arrow:after,.bottom-left .dr-tooltip-arrow:after,.bottom-right .dr-tooltip-arrow:after{border-top:none;top:1px;left:-8px;border-bottom-color:#fff}.left .dr-tooltip-arrow,.left-top .dr-tooltip-arrow,.left-bottom .dr-tooltip-arrow{right:-16px;border-left-color:#cfd7dd!important}.left .dr-tooltip-arrow:after,.left-top .dr-tooltip-arrow:after,.left-bottom .dr-tooltip-arrow:after{bottom:-8px;left:-9px;border-left-color:#fff}.right .dr-tooltip-arrow,.right-top .dr-tooltip-arrow,.right-bottom .dr-tooltip-arrow{left:-16px;border-right-color:#cfd7dd!important}.right .dr-tooltip-arrow:after,.right-top .dr-tooltip-arrow:after,.right-bottom .dr-tooltip-arrow:after{bottom:-8px;left:-7px;border-right-color:#fff}.top .dr-tooltip-arrow,.bottom .dr-tooltip-arrow{left:calc(50% - 4px)}.bottom-left .dr-tooltip-arrow,.top-left .dr-tooltip-arrow{left:4px}.bottom-right .dr-tooltip-arrow,.top-right .dr-tooltip-arrow{right:4px}.left .dr-tooltip-arrow,.right .dr-tooltip-arrow{top:calc(50% - 4px)}.left-top .dr-tooltip-arrow,.dr-tooltip-arrow .right-top{top:4px}.right-bottom .dr-tooltip-arrow,.left-bottom .dr-tooltip-arrow{bottom:4px}\n"]
1134
+ },] }
1135
+ ];
1136
+ TooltipComponent.ctorParameters = () => [];
1137
+ TooltipComponent.propDecorators = {
1138
+ content: [{ type: Input }],
1139
+ contentContext: [{ type: Input }],
1140
+ position: [{ type: Input }],
1141
+ options: [{ type: Input }],
1142
+ class: [{ type: Input }]
1143
+ };
1144
+
1145
+ class DrTooltipDirective {
1146
+ constructor(overlay, overlayPositionBuilder, elementRef) {
1147
+ this.overlay = overlay;
1148
+ this.overlayPositionBuilder = overlayPositionBuilder;
1149
+ this.elementRef = elementRef;
1150
+ this.contentContext = {};
1151
+ this.position = 'top';
1152
+ this.class = '';
1153
+ this.tooltipPositions = {
1154
+ top: {
1155
+ originX: 'center',
1156
+ originY: 'top',
1157
+ overlayX: 'center',
1158
+ overlayY: 'bottom',
1159
+ offsetY: -8
1160
+ },
1161
+ 'top-left': {
1162
+ originX: 'start',
1163
+ originY: 'top',
1164
+ overlayX: 'start',
1165
+ overlayY: 'bottom',
1166
+ offsetY: -8
1167
+ },
1168
+ 'top-right': {
1169
+ originX: 'end',
1170
+ originY: 'top',
1171
+ overlayX: 'end',
1172
+ overlayY: 'bottom',
1173
+ offsetY: -8
1174
+ },
1175
+ bottom: {
1176
+ originX: 'center',
1177
+ originY: 'bottom',
1178
+ overlayX: 'center',
1179
+ overlayY: 'top',
1180
+ offsetY: 7
1181
+ },
1182
+ 'bottom-left': {
1183
+ originX: 'start',
1184
+ originY: 'bottom',
1185
+ overlayX: 'start',
1186
+ overlayY: 'top',
1187
+ offsetY: 7
1188
+ },
1189
+ 'bottom-right': {
1190
+ originX: 'end',
1191
+ originY: 'bottom',
1192
+ overlayX: 'end',
1193
+ overlayY: 'top',
1194
+ offsetY: 7
1195
+ },
1196
+ left: {
1197
+ originX: 'start',
1198
+ originY: 'center',
1199
+ overlayX: 'end',
1200
+ overlayY: 'center',
1201
+ offsetX: -8
1202
+ },
1203
+ 'left-top': {
1204
+ originX: 'start',
1205
+ originY: 'top',
1206
+ overlayX: 'end',
1207
+ overlayY: 'top',
1208
+ offsetX: -8
1209
+ },
1210
+ 'left-bottom': {
1211
+ originX: 'start',
1212
+ originY: 'bottom',
1213
+ overlayX: 'end',
1214
+ overlayY: 'bottom',
1215
+ offsetX: -8
1216
+ },
1217
+ right: {
1218
+ originX: 'end',
1219
+ originY: 'center',
1220
+ overlayX: 'start',
1221
+ overlayY: 'center',
1222
+ offsetX: 8
1223
+ },
1224
+ 'right-top': {
1225
+ originX: 'end',
1226
+ originY: 'top',
1227
+ overlayX: 'start',
1228
+ overlayY: 'top',
1229
+ offsetX: 8
1230
+ },
1231
+ 'right-bottom': {
1232
+ originX: 'end',
1233
+ originY: 'bottom',
1234
+ overlayX: 'start',
1235
+ overlayY: 'bottom',
1236
+ offsetX: 8
1237
+ }
1238
+ };
1239
+ }
1240
+ set drTooltipOptions(options) {
1241
+ if (options === null || options === void 0 ? void 0 : options.indent) {
1242
+ const position = this.tooltipPositions[this.position];
1243
+ if (position.offsetY) {
1244
+ position.offsetY = position.offsetY < 0 ? -options.indent : options.indent;
1245
+ }
1246
+ if (position.offsetX) {
1247
+ position.offsetX = position.offsetX < 0 ? -options.indent : options.indent;
1248
+ }
1249
+ }
1250
+ this.options = options;
1251
+ }
1252
+ ngOnInit() {
1253
+ const positionStrategy = this.overlayPositionBuilder
1254
+ .flexibleConnectedTo(this.elementRef)
1255
+ .withPositions([this.tooltipPositions[this.position]]);
1256
+ this.overlayRef = this.overlay.create({ positionStrategy });
1257
+ }
1258
+ ngOnDestroy() {
1259
+ if (this.overlayRef.hasAttached()) {
1260
+ this.hide();
1261
+ }
1262
+ this.overlayRef.dispose();
1263
+ }
1264
+ show() {
1265
+ if (!this.overlayRef.hasAttached() && this.content) {
1266
+ const tooltipRef = this.overlayRef.attach(new ComponentPortal(TooltipComponent));
1267
+ tooltipRef.instance.content = this.content;
1268
+ tooltipRef.instance.contentContext = this.contentContext;
1269
+ tooltipRef.instance.position = this.position;
1270
+ tooltipRef.instance.options = this.options;
1271
+ }
1272
+ }
1273
+ hide() {
1274
+ this.overlayRef.detach();
1275
+ }
1276
+ }
1277
+ DrTooltipDirective.decorators = [
1278
+ { type: Directive, args: [{
1279
+ selector: '[drTooltip]'
1280
+ },] }
1281
+ ];
1282
+ DrTooltipDirective.ctorParameters = () => [
1283
+ { type: Overlay },
1284
+ { type: OverlayPositionBuilder },
1285
+ { type: ElementRef }
1286
+ ];
1287
+ DrTooltipDirective.propDecorators = {
1288
+ content: [{ type: Input, args: ['drTooltip',] }],
1289
+ contentContext: [{ type: Input, args: ['drTooltipContext',] }],
1290
+ position: [{ type: Input, args: ['drTooltipPosition',] }],
1291
+ class: [{ type: Input, args: ['drTooltipClass',] }],
1292
+ drTooltipOptions: [{ type: Input }],
1293
+ show: [{ type: HostListener, args: ['mouseenter',] }],
1294
+ hide: [{ type: HostListener, args: ['mouseleave',] }]
1295
+ };
1296
+
1067
1297
  class DrToggleComponent {
1068
1298
  constructor(cdr) {
1069
1299
  this.cdr = cdr;
@@ -1282,6 +1512,43 @@ DrInputsModule.decorators = [
1282
1512
  },] }
1283
1513
  ];
1284
1514
 
1515
+ class DrTooltipModule {
1516
+ }
1517
+ DrTooltipModule.decorators = [
1518
+ { type: NgModule, args: [{
1519
+ imports: [
1520
+ CommonModule
1521
+ ],
1522
+ exports: [
1523
+ TooltipComponent,
1524
+ DrTooltipDirective,
1525
+ ],
1526
+ providers: [],
1527
+ declarations: [
1528
+ TooltipComponent,
1529
+ DrTooltipDirective,
1530
+ ],
1531
+ },] }
1532
+ ];
1533
+
1534
+ class DrAvatarModule {
1535
+ }
1536
+ DrAvatarModule.decorators = [
1537
+ { type: NgModule, args: [{
1538
+ declarations: [
1539
+ DrAvatarComponent
1540
+ ],
1541
+ exports: [
1542
+ DrAvatarComponent
1543
+ ],
1544
+ imports: [
1545
+ MatTooltipModule,
1546
+ DrTooltipModule,
1547
+ CommonModule
1548
+ ]
1549
+ },] }
1550
+ ];
1551
+
1285
1552
  const components = [DrSpinnerComponent];
1286
1553
  const directives = [DrSpinnerDirective];
1287
1554
  class DrSpinnerModule {
@@ -1302,5 +1569,5 @@ DrSpinnerModule.decorators = [
1302
1569
  * Generated bundle index. Do not edit.
1303
1570
  */
1304
1571
 
1305
- export { AnyTagComponent, CheckboxComponent, DateTagComponent, DateTagModule, DayTagComponent, DrInputComponent, DrInputsModule, DrSelectComponent, DrSpinnerComponent, DrSpinnerDirective, DrSpinnerModule, DrTagComponent, DrTagModule, DrToggleComponent, ForecastTagComponent, ISpinnerOptions, ListTagComponent, ListTagModule, MonthTagComponent, QuarterTagComponent, RadioButtonComponent, WeekTagComponent, YearTagComponent, components$2 as ɵa };
1572
+ export { AnyTagComponent, CheckboxComponent, DateTagComponent, DateTagModule, DayTagComponent, DrAvatarComponent, DrAvatarModule, DrInputComponent, DrInputsModule, DrSelectComponent, DrSpinnerComponent, DrSpinnerDirective, DrSpinnerModule, DrTagComponent, DrTagModule, DrToggleComponent, DrTooltipDirective, DrTooltipModule, ForecastTagComponent, ISpinnerOptions, ListTagComponent, ListTagModule, MonthTagComponent, QuarterTagComponent, RadioButtonComponent, TooltipComponent, WeekTagComponent, YearTagComponent, components$2 as ɵa };
1306
1573
  //# sourceMappingURL=datarailsshared-datarailsshared.js.map