[APPS-2108] break direct dependency on moment.js (#9032)

* break direct dependency on moment.js

* [ci:force] preserve moment for cli tools

* remove MatMomentDatetimeModule from content

* share dialog fixes

* revert testing module changes

* remove incorrect date modules

* fix html
This commit is contained in:
Denys Vuika
2023-10-26 14:33:26 +01:00
committed by GitHub
parent abf369bc37
commit 7ebdce7875
25 changed files with 82 additions and 160 deletions

View File

@@ -17,7 +17,6 @@ module.exports = function (config) {
included: true,
watched: false
},
{pattern: 'node_modules/moment/min/moment.min.js', included: true, watched: false},
{pattern: 'lib/core/src/lib/i18n/**/en.json', included: false, served: true, watched: false},
{pattern: 'lib/core/**/*.ts', included: false, served: true, watched: false},
{pattern: 'lib/core/src/lib/assets/**/*.svg', included: false, served: true, watched: false},

View File

@@ -31,15 +31,12 @@
"@angular/core": ">=14.1.3",
"@angular/forms": ">=14.1.3",
"@angular/material": ">=14.1.2",
"@angular/material-moment-adapter": ">=14.1.2",
"@angular/router": ">=14.1.3",
"@mat-datetimepicker/core": "^10.1.1",
"@mat-datetimepicker/moment": "^10.1.1",
"@alfresco/js-api": ">=7.1.0-1437",
"@alfresco/adf-extensions": ">=6.3.0",
"@ngx-translate/core": ">=14.0.0",
"minimatch-browser": ">=1.0.0",
"moment": ">=2.22.2",
"pdfjs-dist": ">=3.3.122"
},
"keywords": [

View File

@@ -17,9 +17,13 @@
import { Injectable } from '@angular/core';
import { DateAdapter } from '@angular/material/core';
import moment, { isMoment, Moment } from 'moment';
import { UserPreferencesService, UserPreferenceValues } from '../services/user-preferences.service';
// Stub for the moment.js integration.
// While this dependency is no longer used by the libraries, the moment adapter can still discover the moment.js linked to the application
declare let moment: any;
type Moment = any;
/**
* @deprecated this class is deprecated and should not be used.
* Consider using `AdfDateFnsAdapter` or `AdfDateTimeFnsAdapter` instead
@@ -183,7 +187,7 @@ export class MomentDateAdapter extends DateAdapter<Moment> {
if (first == null) {
// same if both null
return second == null;
} else if (isMoment(first)) {
} else if (moment.isMoment(first)) {
return first.isSame(second);
} else {
const isSame = super.sameDate(first, second);

View File

@@ -16,14 +16,15 @@
*/
import { Pipe, PipeTransform } from '@angular/core';
import moment, { Moment } from 'moment';
declare let moment: any;
/**
* @deprecated this pipe is deprecated and should no longer be used
*/
@Pipe({ name: 'adfMomentDate' })
export class MomentDatePipe implements PipeTransform {
transform(value: moment.MomentInput, dateFormat: string): Moment {
transform(value: any, dateFormat: string): any {
return moment(value, dateFormat);
}
}

View File

@@ -16,17 +16,14 @@
*/
import { Pipe, PipeTransform } from '@angular/core';
import moment, { Moment } from 'moment';
declare let moment: any;
/**
* @deprecated this pipe is deprecated and should no longer be used
*/
@Pipe({ name: 'adfMomentDateTime' })
export class MomentDateTimePipe implements PipeTransform {
transform(value: moment.MomentInput, dateFormat: string): Moment {
return moment(value, dateFormat)
.add(
moment(value, dateFormat).utcOffset(),
'minutes');
transform(value: any, dateFormat: string): any {
return moment(value, dateFormat).add(moment(value, dateFormat).utcOffset(), 'minutes');
}
}