@colijnit/corecomponents_v12 256.1.18 → 256.1.20

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 (29) hide show
  1. package/bundles/colijnit-corecomponents_v12.umd.js +141 -37
  2. package/bundles/colijnit-corecomponents_v12.umd.js.map +1 -1
  3. package/colijnit-corecomponents_v12.metadata.json +1 -1
  4. package/esm2015/lib/components/base/base-input.component.js +8 -1
  5. package/esm2015/lib/components/button/button.component.js +1 -1
  6. package/esm2015/lib/components/filter-item/filter-item.component.js +2 -2
  7. package/esm2015/lib/components/input-date-picker/input-date-picker.component.js +20 -2
  8. package/esm2015/lib/components/input-date-range-picker/input-date-range-picker.component.js +65 -30
  9. package/esm2015/lib/components/input-scanner/bar-code-scanner.js +16 -3
  10. package/esm2015/lib/components/input-scanner/input-scanner.component.js +28 -4
  11. package/esm2015/lib/components/input-search/input-search.component.js +6 -1
  12. package/esm2015/lib/components/list-of-values/list-of-values.module.js +1 -2
  13. package/esm2015/lib/directives/screen-configuration/screen-configuration.directive.js +2 -1
  14. package/esm2015/lib/interfaces/screen-config-adapter.component.interface.js +1 -1
  15. package/esm2015/lib/service/base-module-screen-config.service.js +2 -2
  16. package/fesm2015/colijnit-corecomponents_v12.js +139 -37
  17. package/fesm2015/colijnit-corecomponents_v12.js.map +1 -1
  18. package/lib/components/base/base-input.component.d.ts +4 -0
  19. package/lib/components/button/button.component.d.ts +2 -0
  20. package/lib/components/calendar/style/_layout.scss +14 -14
  21. package/lib/components/calendar/style/_material-definition.scss +3 -3
  22. package/lib/components/filter-item/filter-item.component.d.ts +2 -0
  23. package/lib/components/input-date-picker/input-date-picker.component.d.ts +2 -0
  24. package/lib/components/input-date-range-picker/input-date-range-picker.component.d.ts +5 -0
  25. package/lib/components/input-scanner/bar-code-scanner.d.ts +3 -0
  26. package/lib/components/input-scanner/input-scanner.component.d.ts +7 -2
  27. package/lib/components/input-search/input-search.component.d.ts +1 -0
  28. package/lib/interfaces/screen-config-adapter.component.interface.d.ts +2 -0
  29. package/package.json +1 -1
@@ -1955,6 +1955,12 @@ class BaseInputComponent {
1955
1955
  get maxLength() {
1956
1956
  return notNill(this.forcedMaxLength) ? this.forcedMaxLength : this._maxLength;
1957
1957
  }
1958
+ set defaultValue(defaultValue) {
1959
+ this._defaultValue = defaultValue;
1960
+ }
1961
+ get defaultValue() {
1962
+ return this._defaultValue;
1963
+ }
1958
1964
  set readonly(readonly) {
1959
1965
  if (this._forceReadonly !== undefined || readonly === this._readonly) {
1960
1966
  return;
@@ -2600,6 +2606,7 @@ BaseInputComponent.propDecorators = {
2600
2606
  businessObjectId: [{ type: Input }],
2601
2607
  disabled: [{ type: Input }],
2602
2608
  maxLength: [{ type: Input }],
2609
+ defaultValue: [{ type: Input }],
2603
2610
  forcedMaxLength: [{ type: Input }],
2604
2611
  readonly: [{ type: Input }],
2605
2612
  forceReadonly: [{ type: Input }],
@@ -5439,6 +5446,23 @@ class InputDatePickerComponent extends BaseInputDatePickerDirective {
5439
5446
  this.overlayService.removeComponent(this._calendarComponentRef);
5440
5447
  }
5441
5448
  }
5449
+ finalizeDate() {
5450
+ if (this.isValidDateString(this.modelAsString)) {
5451
+ const [year, month, day] = this.modelAsString.split('-').map(Number);
5452
+ const date = new Date(year, month - 1, day);
5453
+ this.setModel(date);
5454
+ }
5455
+ }
5456
+ isValidDateString(value) {
5457
+ const regex = /^\d{4}-\d{2}-\d{2}$/;
5458
+ if (!regex.test(value))
5459
+ return false;
5460
+ const [year, month, day] = value.split('-').map(Number);
5461
+ const date = new Date(year, month - 1, day);
5462
+ return (date.getFullYear() === year &&
5463
+ date.getMonth() === month - 1 &&
5464
+ date.getDate() === day);
5465
+ }
5442
5466
  handleDateChange(value) {
5443
5467
  if (value) {
5444
5468
  this.setModel(new Date(value));
@@ -5478,9 +5502,10 @@ InputDatePickerComponent.decorators = [
5478
5502
  [placeholder]="placeholder"
5479
5503
  (leftIconClick)="leftIconClick.emit($event)"
5480
5504
  (rightIconClick)="toggleCalendar(true)"
5481
- (blur)="handleDateChange(modelAsString)"
5505
+ (modelChange)="modelAsString = $event"
5482
5506
  (clearIconClick)="handleClearIconClicked()"
5483
5507
  [emptyPlace]="true"
5508
+ (keyup.enter)="finalizeDate()"
5484
5509
  ></co-input-text>
5485
5510
  `,
5486
5511
  providers: [
@@ -6907,6 +6932,11 @@ DoubleCalendarModule.decorators = [
6907
6932
  ];
6908
6933
 
6909
6934
  class InputDateRangePickerComponent extends BaseInputDatePickerDirective {
6935
+ constructor() {
6936
+ super(...arguments);
6937
+ this.EARLIEST_DATE = new Date(1900, 0, 1); // 1900-01-01
6938
+ this.LATEST_DATE = new Date(2100, 11, 31); // 2100-12-31
6939
+ }
6910
6940
  showClass() {
6911
6941
  return true;
6912
6942
  }
@@ -6947,43 +6977,71 @@ class InputDateRangePickerComponent extends BaseInputDatePickerDirective {
6947
6977
  }
6948
6978
  }
6949
6979
  handleFirstDateChanged(value) {
6950
- if (value) {
6951
- if (!this.model) {
6952
- this.setModel([]);
6980
+ setTimeout(() => {
6981
+ var _a, _b;
6982
+ if (this.isValidDateString(value)) {
6983
+ const [year, month, day] = value.split('-').map(Number);
6984
+ const date = new Date(year, month - 1, day);
6985
+ if (!this.model)
6986
+ this.setModel([]);
6987
+ this.setModel([date, (_b = (_a = this.model) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : null]);
6953
6988
  }
6954
- this.setModel([new Date(value), this.model[1] ? this.model[1] : null]);
6955
- }
6989
+ });
6956
6990
  }
6957
6991
  handleSecondDateChanged(value) {
6958
- if (value) {
6959
- if (!this.model) {
6960
- this.setModel([]);
6992
+ setTimeout(() => {
6993
+ var _a, _b;
6994
+ if (this.isValidDateString(value)) {
6995
+ const [year, month, day] = value.split('-').map(Number);
6996
+ const date = new Date(year, month - 1, day);
6997
+ if (!this.model)
6998
+ this.setModel([]);
6999
+ this.setModel([(_b = (_a = this.model) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : null, date]);
6961
7000
  }
6962
- this.setModel([this.model[0] ? this.model[0] : null, new Date(value)]);
7001
+ });
7002
+ }
7003
+ finalizeDates() {
7004
+ let startDate = this.EARLIEST_DATE;
7005
+ let endDate = this.LATEST_DATE;
7006
+ if (this.isValidDateString(this.firstDateAsString)) {
7007
+ const [y, m, d] = this.firstDateAsString.split('-').map(Number);
7008
+ startDate = new Date(y, m - 1, d);
7009
+ }
7010
+ if (this.isValidDateString(this.secondDateAsString)) {
7011
+ const [y, m, d] = this.secondDateAsString.split('-').map(Number);
7012
+ endDate = new Date(y, m - 1, d);
6963
7013
  }
7014
+ this.setModel([startDate, endDate]);
7015
+ }
7016
+ isValidDateString(value) {
7017
+ const regex = /^\d{4}-\d{2}-\d{2}$/;
7018
+ if (!regex.test(value))
7019
+ return false;
7020
+ const [yearStr, monthStr, dayStr] = value.split('-');
7021
+ const [year, month, day] = [Number(yearStr), Number(monthStr), Number(dayStr)];
7022
+ // Prevent ancient years or too-far future
7023
+ if (year < 1900 || year > 2100)
7024
+ return false;
7025
+ const date = new Date(year, month - 1, day);
7026
+ return (date.getFullYear() === year &&
7027
+ date.getMonth() === month - 1 &&
7028
+ date.getDate() === day);
6964
7029
  }
6965
7030
  modelSet() {
6966
7031
  this.setModelAsString();
6967
7032
  }
6968
7033
  setModelAsString() {
6969
- if (this.model[0]) {
6970
- const year = this.model[0].toLocaleString("default", { year: "numeric" });
6971
- const month = this.model[0].toLocaleString("default", { month: "2-digit" });
6972
- const day = this.model[0].toLocaleString("default", { day: "2-digit" });
6973
- this.firstDateAsString = `${year}-${month}-${day}`;
6974
- }
6975
- else {
6976
- this.firstDateAsString = ``;
6977
- }
6978
- if (this.model[1]) {
6979
- const year = this.model[1].toLocaleString("default", { year: "numeric" });
6980
- const month = this.model[1].toLocaleString("default", { month: "2-digit" });
6981
- const day = this.model[1].toLocaleString("default", { day: "2-digit" });
6982
- this.secondDateAsString = `${year}-${month}-${day}`;
6983
- }
6984
- else {
6985
- this.secondDateAsString = ``;
6986
- }
7034
+ var _a, _b;
7035
+ const isStartDefault = ((_a = this.model[0]) === null || _a === void 0 ? void 0 : _a.getTime()) === this.EARLIEST_DATE.getTime();
7036
+ const isEndDefault = ((_b = this.model[1]) === null || _b === void 0 ? void 0 : _b.getTime()) === this.LATEST_DATE.getTime();
7037
+ this.firstDateAsString = (!this.model[0] || isStartDefault) ? '' : this.formatDate(this.model[0]);
7038
+ this.secondDateAsString = (!this.model[1] || isEndDefault) ? '' : this.formatDate(this.model[1]);
7039
+ }
7040
+ formatDate(date) {
7041
+ const year = date.toLocaleString("default", { year: "numeric" });
7042
+ const month = date.toLocaleString("default", { month: "2-digit" });
7043
+ const day = date.toLocaleString("default", { day: "2-digit" });
7044
+ return `${year}-${month}-${day}`;
6987
7045
  }
6988
7046
  }
6989
7047
  InputDateRangePickerComponent.decorators = [
@@ -6999,10 +7057,11 @@ InputDateRangePickerComponent.decorators = [
6999
7057
  [leftIcon]="leftIcon"
7000
7058
  [leftIconData]="leftIconData"
7001
7059
  [placeholder]="placeholder"
7002
- (blur)="handleFirstDateChanged(firstDateAsString)"
7060
+ (modelChange)="handleFirstDateChanged(firstDateAsString)"
7003
7061
  (clearIconClick)="clearDate(0)"
7004
7062
  (click)="handleFirstInputClick($event)"
7005
7063
  [emptyPlace]="true"
7064
+ (keyup.enter)="finalizeDates()"
7006
7065
  ></co-input-text>
7007
7066
  <co-input-text #secondInput class="no-focus-line custom-height"
7008
7067
  [(model)]= "secondDateAsString"
@@ -7011,10 +7070,11 @@ InputDateRangePickerComponent.decorators = [
7011
7070
  [type]="'date'"
7012
7071
  [rightIcon]="rightIcon"
7013
7072
  (rightIconClick)="toggleCalendar()"
7014
- (blur)="handleSecondDateChanged(secondDateAsString)"
7073
+ (modelChange)="handleSecondDateChanged(secondDateAsString)"
7015
7074
  (clearIconClick)="clearDate(1)"
7016
7075
  (click)="handleSecondInputClick($event)"
7017
7076
  [emptyPlace]="true"
7077
+ (keyup.enter)="finalizeDates()"
7018
7078
  ></co-input-text>
7019
7079
  </div>
7020
7080
  `,
@@ -7766,6 +7826,7 @@ class InputSearchComponent extends BaseInputComponent {
7766
7826
  constructor() {
7767
7827
  super(...arguments);
7768
7828
  this.searchIcon = CoreComponentsIcon.Magnifier;
7829
+ this.handleKeydown = true;
7769
7830
  this.search = new EventEmitter();
7770
7831
  this.isFocused = new EventEmitter();
7771
7832
  this.leftIconClick = new EventEmitter();
@@ -7778,6 +7839,9 @@ class InputSearchComponent extends BaseInputComponent {
7778
7839
  return true;
7779
7840
  }
7780
7841
  handleKeyDown(event) {
7842
+ if (!this.handleKeydown) {
7843
+ return;
7844
+ }
7781
7845
  const enterKeys = ['Enter', 'NumpadEnter', 'Go'];
7782
7846
  if (enterKeys.includes(event.key)) {
7783
7847
  event.preventDefault();
@@ -7825,6 +7889,7 @@ InputSearchComponent.decorators = [
7825
7889
  ];
7826
7890
  InputSearchComponent.propDecorators = {
7827
7891
  placeholder: [{ type: Input }],
7892
+ handleKeydown: [{ type: Input }],
7828
7893
  search: [{ type: Output }],
7829
7894
  isFocused: [{ type: Output }],
7830
7895
  leftIconClick: [{ type: Output }],
@@ -11435,7 +11500,6 @@ ListOfValuesModule.decorators = [
11435
11500
  OverlayModule,
11436
11501
  ClickoutsideModule,
11437
11502
  IconModule,
11438
- InputTextModule,
11439
11503
  InputSearchModule
11440
11504
  ],
11441
11505
  declarations: [
@@ -12562,7 +12626,7 @@ FilterItemComponent.decorators = [
12562
12626
  <co-input-date-range [readonly]="readonly"
12563
12627
  [model]="[dateRangeStart, dateRangeEnd]"
12564
12628
  (modelChange)="handleModelChange($event)"
12565
- [placeholder]="'SELECT_DATE' | coreLocalize">
12629
+ [placeholder]="'Kies datum' | coreLocalize">
12566
12630
  </co-input-date-range>
12567
12631
  </div>
12568
12632
  </ng-template>
@@ -12794,11 +12858,17 @@ class BarCodeScanner {
12794
12858
  constructor() {
12795
12859
  this._buffer = [];
12796
12860
  this._keyPress = (event) => {
12861
+ this._clearScanTimeout();
12797
12862
  if (event.key === "Enter") {
12798
- document.dispatchEvent(this._createScanEvent());
12799
- this._buffer.length = 0;
12863
+ if (this._buffer.length > 0) {
12864
+ document.dispatchEvent(this._createScanEvent());
12865
+ this._clearBuffer();
12866
+ }
12800
12867
  }
12801
12868
  else {
12869
+ this._scanTimeout = setTimeout(() => {
12870
+ this._clearBuffer();
12871
+ }, 200);
12802
12872
  const str = event.key;
12803
12873
  this._buffer.push(str);
12804
12874
  }
@@ -12808,6 +12878,13 @@ class BarCodeScanner {
12808
12878
  close() {
12809
12879
  document.removeEventListener('keypress', this._keyPress);
12810
12880
  }
12881
+ _clearScanTimeout() {
12882
+ clearTimeout(this._scanTimeout);
12883
+ this._scanTimeout = undefined;
12884
+ }
12885
+ _clearBuffer() {
12886
+ this._buffer.length = 0;
12887
+ }
12811
12888
  _createScanEvent() {
12812
12889
  return new CustomEvent("barcodescanned", { detail: this._buffer.join("") });
12813
12890
  }
@@ -12851,14 +12928,37 @@ class InputScannerComponent {
12851
12928
  this.search = new EventEmitter();
12852
12929
  this.isFocused = new EventEmitter();
12853
12930
  this.barCodeScanned = new EventEmitter();
12931
+ this._blockEnterKeydown = false;
12854
12932
  this._scannerService.registerInput(this);
12855
12933
  }
12856
12934
  showClass() {
12857
12935
  return true;
12858
12936
  }
12937
+ ngOnDestroy() {
12938
+ this._clearTimeout();
12939
+ }
12940
+ handleKeyDown(event) {
12941
+ this._clearTimeout();
12942
+ this._keyDownTimeout = setTimeout(() => {
12943
+ if (this._blockEnterKeydown) {
12944
+ return;
12945
+ }
12946
+ const enterKeys = ['Enter', 'NumpadEnter', 'Go'];
12947
+ if (enterKeys.includes(event.key)) {
12948
+ this.search.next(this.model);
12949
+ }
12950
+ }, 200);
12951
+ }
12859
12952
  triggerCodeScanned(code) {
12953
+ this._clearTimeout();
12954
+ this._blockEnterKeydown = true;
12860
12955
  this.model = code;
12861
12956
  this.barCodeScanned.next(this.model);
12957
+ this._blockEnterKeydown = false;
12958
+ }
12959
+ _clearTimeout() {
12960
+ clearTimeout(this._keyDownTimeout);
12961
+ this._keyDownTimeout = undefined;
12862
12962
  }
12863
12963
  }
12864
12964
  InputScannerComponent.decorators = [
@@ -12867,6 +12967,7 @@ InputScannerComponent.decorators = [
12867
12967
  template: `
12868
12968
  <co-input-search
12869
12969
  [(model)]="model"
12970
+ [handleKeydown]="false"
12870
12971
  [customCssClass]="customCssClass"
12871
12972
  [placeholder]="placeholder"
12872
12973
  [centerLabel]="centerLabel"
@@ -12876,7 +12977,6 @@ InputScannerComponent.decorators = [
12876
12977
  [rightIconData]="rightIconData"
12877
12978
  (leftIconClick)="leftIconClick.emit($event)"
12878
12979
  (rightIconClick)="rightIconClick.emit($event)"
12879
- (search)="search.emit($event)"
12880
12980
  (isFocused)="isFocused.emit($event)"
12881
12981
  ></co-input-search>
12882
12982
  `,
@@ -12905,7 +13005,8 @@ InputScannerComponent.propDecorators = {
12905
13005
  search: [{ type: Output }],
12906
13006
  isFocused: [{ type: Output }],
12907
13007
  barCodeScanned: [{ type: Output }],
12908
- showClass: [{ type: HostBinding, args: ['class.co-input-scanner',] }]
13008
+ showClass: [{ type: HostBinding, args: ['class.co-input-scanner',] }],
13009
+ handleKeyDown: [{ type: HostListener, args: ['keydown', ['$event'],] }]
12909
13010
  };
12910
13011
 
12911
13012
  class InputScannerModule {
@@ -13447,7 +13548,7 @@ class BaseModuleScreenConfigService {
13447
13548
  }
13448
13549
  getDefaultValue(configName) {
13449
13550
  const objectConfig = this._objectConfigsMap.get(configName);
13450
- return objectConfig ? objectConfig.getDefaultValue() : undefined;
13551
+ return objectConfig ? objectConfig.defaultValue : undefined;
13451
13552
  }
13452
13553
  getDefaultStringValue(configName) {
13453
13554
  const objectConfig = this._objectConfigsMap.get(configName);
@@ -13664,6 +13765,7 @@ class ScreenConfigurationDirective {
13664
13765
  this.hostComponent.readonly = this.hostComponent.forceReadonly || this._moduleInReadonlyMode() || myCfgObj.isReadonly();
13665
13766
  this.hostComponent.decimals = myCfgObj.scale;
13666
13767
  this.hostComponent.maxLength = myCfgObj.maxLength;
13768
+ this.hostComponent.defaultValue = myCfgObj.defaultValue;
13667
13769
  if ('configObject' in this.hostComponent) {
13668
13770
  this.hostComponent.configObject = myCfgObj;
13669
13771
  }