ngx-material-entity 16.0.1 → 16.0.3
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/components/edit-page/edit-page.component.d.ts +13 -2
- package/components/input/boolean/boolean-checkbox-input/boolean-checkbox-input.component.d.ts +1 -0
- package/components/input/boolean/boolean-toggle-input/boolean-toggle-input.component.d.ts +2 -1
- package/components/input/input.component.d.ts +28 -3
- package/components/input/input.module.d.ts +5 -2
- package/components/input/number/number-slider-input/number-slider-input.component.d.ts +2 -1
- package/components/table/create-dialog/create-entity-dialog.component.d.ts +3 -0
- package/components/table/edit-dialog/edit-entity-dialog.component.d.ts +4 -0
- package/components/tooltip/tooltip.component.d.ts +9 -0
- package/decorators/array/array-decorator-internal.data.d.ts +6 -6
- package/decorators/array/array-decorator.data.d.ts +7 -7
- package/decorators/base/property-decorator-internal.data.d.ts +11 -2
- package/decorators/base/property-decorator.data.d.ts +9 -1
- package/decorators/boolean/boolean-decorator-internal.data.d.ts +3 -3
- package/decorators/boolean/boolean-decorator.data.d.ts +1 -1
- package/decorators/custom/custom-decorator-internal.data.d.ts +2 -2
- package/decorators/custom/custom-decorator.data.d.ts +4 -4
- package/decorators/date/date-decorator-internal.data.d.ts +4 -4
- package/decorators/date/date-decorator.data.d.ts +5 -5
- package/decorators/file/file-decorator-internal.data.d.ts +3 -3
- package/decorators/file/file-decorator.data.d.ts +1 -1
- package/decorators/has-many/has-many-decorator-internal.data.d.ts +1 -1
- package/decorators/has-many/has-many-decorator.data.d.ts +1 -1
- package/decorators/number/number-decorator-internal.data.d.ts +3 -3
- package/decorators/number/number-decorator.data.d.ts +1 -1
- package/decorators/object/object-decorator-internal.data.d.ts +1 -1
- package/decorators/object/object-decorator.data.d.ts +1 -1
- package/decorators/references-many/references-many-decorator-internal.data.d.ts +1 -1
- package/decorators/references-many/references-many-decorator.data.d.ts +1 -1
- package/decorators/references-one/references-one-decorator-internal.data.d.ts +1 -1
- package/decorators/references-one/references-one-decorator.data.d.ts +1 -1
- package/decorators/string/string-decorator-internal.data.d.ts +5 -6
- package/decorators/string/string-decorator.data.d.ts +1 -7
- package/directives/number.directive.d.ts +17 -0
- package/directives/password-match.directive.d.ts +14 -0
- package/directives/tooltip.directive.d.ts +33 -0
- package/esm2022/components/edit-page/edit-page.component.mjs +57 -13
- package/esm2022/components/input/array/array-date-range-input/array-date-range-input.component.mjs +1 -1
- package/esm2022/components/input/array/array-string-chips-input/array-string-chips-input.component.mjs +2 -2
- package/esm2022/components/input/base-input.component.mjs +2 -1
- package/esm2022/components/input/boolean/boolean-checkbox-input/boolean-checkbox-input.component.mjs +6 -3
- package/esm2022/components/input/boolean/boolean-toggle-input/boolean-toggle-input.component.mjs +6 -3
- package/esm2022/components/input/date/date-range-input/date-range-input.component.mjs +3 -1
- package/esm2022/components/input/file/file-image-input/file-image-input.component.mjs +3 -3
- package/esm2022/components/input/file/file-input/file-input.component.mjs +1 -1
- package/esm2022/components/input/input.component.mjs +94 -35
- package/esm2022/components/input/input.module.mjs +15 -5
- package/esm2022/components/input/number/number-input/number-input.component.mjs +4 -3
- package/esm2022/components/input/number/number-slider-input/number-slider-input.component.mjs +6 -3
- package/esm2022/components/input/string/string-password-input/string-password-input.component.mjs +4 -3
- package/esm2022/components/table/create-dialog/create-entity-dialog.component.mjs +18 -6
- package/esm2022/components/table/edit-dialog/edit-entity-dialog.component.mjs +26 -13
- package/esm2022/components/table/table.component.mjs +14 -9
- package/esm2022/components/tooltip/tooltip.component.mjs +20 -0
- package/esm2022/decorators/array/array-decorator-internal.data.mjs +1 -1
- package/esm2022/decorators/array/array-decorator.data.mjs +1 -1
- package/esm2022/decorators/base/property-decorator-internal.data.mjs +22 -1
- package/esm2022/decorators/base/property-decorator.data.mjs +10 -1
- package/esm2022/decorators/boolean/boolean-decorator-internal.data.mjs +1 -1
- package/esm2022/decorators/boolean/boolean-decorator.data.mjs +1 -1
- package/esm2022/decorators/custom/custom-decorator-internal.data.mjs +2 -2
- package/esm2022/decorators/custom/custom-decorator.data.mjs +1 -1
- package/esm2022/decorators/date/date-decorator-internal.data.mjs +2 -1
- package/esm2022/decorators/date/date-decorator.data.mjs +1 -1
- package/esm2022/decorators/file/file-decorator-internal.data.mjs +1 -1
- package/esm2022/decorators/file/file-decorator.data.mjs +1 -1
- package/esm2022/decorators/has-many/has-many-decorator-internal.data.mjs +1 -1
- package/esm2022/decorators/has-many/has-many-decorator.data.mjs +1 -1
- package/esm2022/decorators/number/number-decorator-internal.data.mjs +1 -1
- package/esm2022/decorators/number/number-decorator.data.mjs +1 -1
- package/esm2022/decorators/object/object-decorator-internal.data.mjs +1 -1
- package/esm2022/decorators/object/object-decorator.data.mjs +1 -1
- package/esm2022/decorators/references-many/references-many-decorator-internal.data.mjs +1 -1
- package/esm2022/decorators/references-many/references-many-decorator.data.mjs +1 -1
- package/esm2022/decorators/references-one/references-one-decorator-internal.data.mjs +1 -1
- package/esm2022/decorators/references-one/references-one-decorator.data.mjs +1 -1
- package/esm2022/decorators/string/string-decorator-internal.data.mjs +1 -4
- package/esm2022/decorators/string/string-decorator.data.mjs +1 -1
- package/esm2022/directives/drag-drop.directive.mjs +62 -0
- package/esm2022/directives/number.directive.mjs +38 -0
- package/esm2022/directives/password-match.directive.mjs +30 -0
- package/esm2022/directives/tooltip.directive.mjs +112 -0
- package/esm2022/functions/get-validation-error-message.function.mjs +49 -0
- package/esm2022/functions/get-validation-errors-tooltip-content.function.ts.mjs +25 -0
- package/esm2022/public-api.mjs +6 -2
- package/esm2022/utilities/entity.utilities.mjs +83 -386
- package/esm2022/utilities/validation.utilities.mjs +455 -0
- package/fesm2022/ngx-material-entity.mjs +1713 -1183
- package/fesm2022/ngx-material-entity.mjs.map +1 -1
- package/functions/get-validation-errors-tooltip-content.function.ts.d.ts +10 -0
- package/package.json +1 -1
- package/public-api.d.ts +4 -1
- package/utilities/entity.utilities.d.ts +33 -30
- package/utilities/validation.utilities.d.ts +56 -0
- package/esm2022/components/get-validation-error-message.function.mjs +0 -42
- package/esm2022/components/input/file/file-input/dragDrop.directive.mjs +0 -62
- /package/{components/input/file/file-input/dragDrop.directive.d.ts → directives/drag-drop.directive.d.ts} +0 -0
- /package/{components → functions}/get-validation-error-message.function.d.ts +0 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
import { ValidationError } from '../utilities/validation.utilities';
|
|
3
|
+
export declare const NGX_VALIDATION_ERRORS_TOOLTIP_TITLE: InjectionToken<string>;
|
|
4
|
+
/**
|
|
5
|
+
* The default function that gets the validation errors tooltip content.
|
|
6
|
+
*
|
|
7
|
+
* @param validationErrors - All validation errors for which the tooltip content should be generated.
|
|
8
|
+
* @returns A html string, containing a list of the name of each invalid property.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getValidationErrorsTooltipContent(validationErrors: ValidationError[]): string;
|
package/package.json
CHANGED
package/public-api.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ export * from './components/confirm-dialog/confirm-dialog-data';
|
|
|
6
6
|
export * from './components/confirm-dialog/confirm-dialog.component';
|
|
7
7
|
export * from './components/edit-page/edit-data.route';
|
|
8
8
|
export * from './components/edit-page/edit-page.component';
|
|
9
|
-
export * from './components/get-validation-error-message.function';
|
|
10
9
|
export * from './components/input/base-input.component';
|
|
11
10
|
export * from './components/input/input.component';
|
|
12
11
|
export * from './components/input/input.module';
|
|
@@ -18,6 +17,7 @@ export * from './components/table/edit-dialog/edit-entity-data';
|
|
|
18
17
|
export * from './components/table/edit-dialog/edit-entity-dialog.component';
|
|
19
18
|
export * from './components/table/table-data';
|
|
20
19
|
export * from './components/table/table.component';
|
|
20
|
+
export * from './components/tooltip/tooltip.component';
|
|
21
21
|
export * from './decorators/array/array-decorator.data';
|
|
22
22
|
export * from './decorators/array/array.decorator';
|
|
23
23
|
export * from './decorators/base/decorator-types.enum';
|
|
@@ -43,8 +43,11 @@ export * from './decorators/references-one/references-one-decorator.data';
|
|
|
43
43
|
export * from './decorators/references-one/references-one.decorator';
|
|
44
44
|
export * from './decorators/string/string-decorator.data';
|
|
45
45
|
export * from './decorators/string/string.decorator';
|
|
46
|
+
export * from './functions/get-validation-error-message.function';
|
|
47
|
+
export * from './functions/get-validation-errors-tooltip-content.function.ts';
|
|
46
48
|
export * from './services/entity.service';
|
|
47
49
|
export * from './services/unsaved-changes.guard';
|
|
48
50
|
export * from './utilities/date.utilities';
|
|
49
51
|
export * from './utilities/entity.utilities';
|
|
50
52
|
export * from './utilities/file.utilities';
|
|
53
|
+
export * from './utilities/validation.utilities';
|
|
@@ -2,6 +2,23 @@ import { HttpClient } from '@angular/common/http';
|
|
|
2
2
|
import { BaseEntityType } from '../classes/entity.model';
|
|
3
3
|
import { DecoratorType, DecoratorTypes } from '../decorators/base/decorator-types.enum';
|
|
4
4
|
import { PropertyDecoratorConfigInternal } from '../decorators/base/property-decorator-internal.data';
|
|
5
|
+
/**
|
|
6
|
+
* Shows information about differences between two entities.
|
|
7
|
+
*/
|
|
8
|
+
export interface Difference<EntityType extends BaseEntityType<EntityType>> {
|
|
9
|
+
/**
|
|
10
|
+
* The key where the two entities have different values.
|
|
11
|
+
*/
|
|
12
|
+
key: keyof EntityType;
|
|
13
|
+
/**
|
|
14
|
+
* The value before any changes.
|
|
15
|
+
*/
|
|
16
|
+
before: unknown;
|
|
17
|
+
/**
|
|
18
|
+
* The current value after changes.
|
|
19
|
+
*/
|
|
20
|
+
after: unknown;
|
|
21
|
+
}
|
|
5
22
|
/**
|
|
6
23
|
* Contains HelperMethods around handling Entities and their property-metadata.
|
|
7
24
|
*/
|
|
@@ -73,6 +90,12 @@ export declare abstract class EntityUtilities {
|
|
|
73
90
|
* @returns The reduced entity object.
|
|
74
91
|
*/
|
|
75
92
|
static getWithoutOmitUpdateValues<EntityType extends BaseEntityType<EntityType>>(entity: EntityType, entityPriorChanges: EntityType, http: HttpClient): Promise<Partial<EntityType>>;
|
|
93
|
+
/**
|
|
94
|
+
* Sets all default values on the given entity.
|
|
95
|
+
*
|
|
96
|
+
* @param entity - The entity to set the default values on.
|
|
97
|
+
*/
|
|
98
|
+
static setDefaultValues<EntityType extends BaseEntityType<EntityType>>(entity: EntityType): void;
|
|
76
99
|
/**
|
|
77
100
|
* Gets all properties on the given entity which are files.
|
|
78
101
|
*
|
|
@@ -112,34 +135,6 @@ export declare abstract class EntityUtilities {
|
|
|
112
135
|
static new<EntityType extends BaseEntityType<EntityType>>(target: EntityType, entity?: EntityType): void;
|
|
113
136
|
static construct: typeof EntityUtilities.new;
|
|
114
137
|
static build: typeof EntityUtilities.new;
|
|
115
|
-
/**
|
|
116
|
-
* Checks if the values on an entity are valid.
|
|
117
|
-
* Also checks all the validators given by the metadata ("required", "maxLength" etc.).
|
|
118
|
-
*
|
|
119
|
-
* @param entity - The entity to validate.
|
|
120
|
-
* @param omit - Whether to check for creating or editing validity.
|
|
121
|
-
* @returns Whether or not the entity is valid.
|
|
122
|
-
*/
|
|
123
|
-
static isEntityValid<EntityType extends BaseEntityType<EntityType>>(entity: EntityType, omit: 'create' | 'update'): boolean;
|
|
124
|
-
/**
|
|
125
|
-
* Checks if a single property value is valid.
|
|
126
|
-
*
|
|
127
|
-
* @param entity - The entity where the property is from.
|
|
128
|
-
* @param key - The name of the property.
|
|
129
|
-
* @param omit - Whether to check if the given entity is valid for creation or updating.
|
|
130
|
-
* @returns Whether or not the property value is valid.
|
|
131
|
-
* @throws Throws when it extracts an unknown metadata type.
|
|
132
|
-
*/
|
|
133
|
-
private static isPropertyValid;
|
|
134
|
-
private static isBooleanValid;
|
|
135
|
-
private static isStringValid;
|
|
136
|
-
private static isTextboxValid;
|
|
137
|
-
private static isPasswordValid;
|
|
138
|
-
private static isNumberValid;
|
|
139
|
-
private static isDateValid;
|
|
140
|
-
private static isDateRangeValid;
|
|
141
|
-
private static isDateTimeValid;
|
|
142
|
-
private static isFileDataValid;
|
|
143
138
|
/**
|
|
144
139
|
* Checks if an entity is "dirty" (if its values have changed).
|
|
145
140
|
*
|
|
@@ -149,7 +144,15 @@ export declare abstract class EntityUtilities {
|
|
|
149
144
|
* @returns Whether or not the entity is dirty.
|
|
150
145
|
*/
|
|
151
146
|
static isDirty<EntityType extends BaseEntityType<EntityType>>(entity: EntityType, entityPriorChanges: EntityType, http: HttpClient): Promise<boolean>;
|
|
152
|
-
|
|
147
|
+
/**
|
|
148
|
+
* Gets the differences between the two given entities.
|
|
149
|
+
*
|
|
150
|
+
* @param entity - The entity as is.
|
|
151
|
+
* @param entityPriorChanges - The entity before any changes have been made.
|
|
152
|
+
* @param http - The angular http client, is needed to check if files are equal.
|
|
153
|
+
* @returns The differences as an array consisting of key, before and after.
|
|
154
|
+
*/
|
|
155
|
+
static getDifferencesBetweenEntities<EntityType extends BaseEntityType<EntityType>>(entity: EntityType, entityPriorChanges: EntityType, http: HttpClient): Promise<Difference<EntityType>[]>;
|
|
153
156
|
/**
|
|
154
157
|
* Compares two Entities and returns their difference in an object.
|
|
155
158
|
*
|
|
@@ -168,7 +171,7 @@ export declare abstract class EntityUtilities {
|
|
|
168
171
|
* @param http - The angular HttpClient. Used to fetch files.
|
|
169
172
|
* @returns Whether or not the given values are equal.
|
|
170
173
|
*/
|
|
171
|
-
static isEqual(value: unknown, valuePriorChanges: unknown, metadata: PropertyDecoratorConfigInternal
|
|
174
|
+
static isEqual(value: unknown, valuePriorChanges: unknown, metadata: PropertyDecoratorConfigInternal<unknown>, type: DecoratorTypes, http: HttpClient): Promise<boolean>;
|
|
172
175
|
private static isEqualArrayString;
|
|
173
176
|
private static isEqualArrayDate;
|
|
174
177
|
private static isEqualArrayDateRange;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { BaseEntityType } from '../classes/entity.model';
|
|
2
|
+
/**
|
|
3
|
+
* A validation error reported by the validation utilities.
|
|
4
|
+
* Consists of the property name where the error originated from and a message.
|
|
5
|
+
*/
|
|
6
|
+
export interface ValidationError {
|
|
7
|
+
/**
|
|
8
|
+
* The property name on which the error occurred. This is the displayName value.
|
|
9
|
+
*/
|
|
10
|
+
property: string;
|
|
11
|
+
/**
|
|
12
|
+
* The validation error message.
|
|
13
|
+
*/
|
|
14
|
+
message: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Contains HelperMethods around handling Validation of entities and properties.
|
|
18
|
+
*/
|
|
19
|
+
export declare abstract class ValidationUtilities {
|
|
20
|
+
/**
|
|
21
|
+
* Checks if the values on an entity are valid.
|
|
22
|
+
* Also checks all the validators given by the metadata ("required", "maxLength" etc.).
|
|
23
|
+
*
|
|
24
|
+
* @param entity - The entity to validate.
|
|
25
|
+
* @param omit - Whether to check for creating or editing validity.
|
|
26
|
+
* @returns Whether or not the entity is valid.
|
|
27
|
+
*/
|
|
28
|
+
static isEntityValid<EntityType extends BaseEntityType<EntityType>>(entity: EntityType, omit?: 'create' | 'update'): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Gets all validation errors on the given entity.
|
|
31
|
+
*
|
|
32
|
+
* @param entity - The entity to validate.
|
|
33
|
+
* @param omit - What keys not to check. An empty value means no keys are omitted.
|
|
34
|
+
* @returns An array of validation errors on the provided entity.
|
|
35
|
+
*/
|
|
36
|
+
static getEntityValidationErrors<EntityType extends BaseEntityType<EntityType>>(entity: EntityType, omit?: 'create' | 'update'): ValidationError[];
|
|
37
|
+
/**
|
|
38
|
+
* Validates the property on the given entity with the given key.
|
|
39
|
+
*
|
|
40
|
+
* @param entity - The entity on which the property to check is.
|
|
41
|
+
* @param key - The key of the property to validate.
|
|
42
|
+
* @param omit - What keys not to check. An empty value means no keys are omitted.
|
|
43
|
+
* @returns A validation error when the property is not valid, undefined otherwise.
|
|
44
|
+
* @throws When the type of the property is not known.
|
|
45
|
+
*/
|
|
46
|
+
static getPropertyValidationError<EntityType extends BaseEntityType<EntityType>>(entity: EntityType, key: keyof EntityType, omit?: 'create' | 'update'): ValidationError | undefined;
|
|
47
|
+
private static getBooleanValidationError;
|
|
48
|
+
private static getStringValidationError;
|
|
49
|
+
private static getTextboxValidationError;
|
|
50
|
+
private static getPasswordValidationError;
|
|
51
|
+
private static getNumberValidationError;
|
|
52
|
+
private static getDateValidationError;
|
|
53
|
+
private static getDateRangeValidationError;
|
|
54
|
+
private static getDateTimeValidationError;
|
|
55
|
+
private static getFileDataValidationError;
|
|
56
|
+
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { InjectionToken } from '@angular/core';
|
|
2
|
-
export const NGX_GET_VALIDATION_ERROR_MESSAGE = new InjectionToken('Provider for the default getValidationErrorMessage.', {
|
|
3
|
-
providedIn: 'root',
|
|
4
|
-
factory: () => getValidationErrorMessage
|
|
5
|
-
});
|
|
6
|
-
/**
|
|
7
|
-
* Generates a default error message for most validation errors.
|
|
8
|
-
*
|
|
9
|
-
* @param model - The ngModel to get the error from.
|
|
10
|
-
* @returns The Validation Error Message to display.
|
|
11
|
-
*/
|
|
12
|
-
function getValidationErrorMessage(model) {
|
|
13
|
-
if (model.hasError('matDatepickerParse')) {
|
|
14
|
-
return 'not a valid date';
|
|
15
|
-
}
|
|
16
|
-
else if (model.hasError('email')) {
|
|
17
|
-
return 'not a valid email';
|
|
18
|
-
}
|
|
19
|
-
else if (model.hasError('minlength')) {
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
21
|
-
return `needs to be at least ${model.getError('minlength').requiredLength} characters long`;
|
|
22
|
-
}
|
|
23
|
-
else if (model.hasError('min')) {
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
25
|
-
return `needs to be equal or bigger than ${model.getError('min').min}`;
|
|
26
|
-
}
|
|
27
|
-
else if (model.hasError('max')) {
|
|
28
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
29
|
-
return `needs to be equal or smaller than ${model.getError('max').max}`;
|
|
30
|
-
}
|
|
31
|
-
else if (model.hasError('required')) {
|
|
32
|
-
return 'required';
|
|
33
|
-
}
|
|
34
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
35
|
-
else if (model.hasError('pattern') && model.getError('pattern').requiredPattern === '^true$') {
|
|
36
|
-
return 'needs to be selected';
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
return 'invalid input';
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2V0LXZhbGlkYXRpb24tZXJyb3ItbWVzc2FnZS5mdW5jdGlvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3Byb2plY3RzL25neC1tYXRlcmlhbC1lbnRpdHkvc3JjL2NvbXBvbmVudHMvZ2V0LXZhbGlkYXRpb24tZXJyb3ItbWVzc2FnZS5mdW5jdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsY0FBYyxFQUFFLE1BQU0sZUFBZSxDQUFDO0FBRy9DLE1BQU0sQ0FBQyxNQUFNLGdDQUFnQyxHQUFpQyxJQUFJLGNBQWMsQ0FDNUYscURBQXFELEVBQ3JEO0lBQ0ksVUFBVSxFQUFFLE1BQU07SUFDbEIsT0FBTyxFQUFFLEdBQUcsRUFBRSxDQUFDLHlCQUF5QjtDQUMzQyxDQUNKLENBQUM7QUFFRjs7Ozs7R0FLRztBQUNILFNBQVMseUJBQXlCLENBQUMsS0FBYztJQUM3QyxJQUFJLEtBQUssQ0FBQyxRQUFRLENBQUMsb0JBQW9CLENBQUMsRUFBRTtRQUN0QyxPQUFPLGtCQUFrQixDQUFDO0tBQzdCO1NBQ0ksSUFBSSxLQUFLLENBQUMsUUFBUSxDQUFDLE9BQU8sQ0FBQyxFQUFFO1FBQzlCLE9BQU8sbUJBQW1CLENBQUM7S0FDOUI7U0FDSSxJQUFJLEtBQUssQ0FBQyxRQUFRLENBQUMsV0FBVyxDQUFDLEVBQUU7UUFDbEMsc0VBQXNFO1FBQ3RFLE9BQU8sd0JB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Emitter, HostListener, Output } from '@angular/core';
|
|
2
|
-
import * as i0 from "@angular/core";
|
|
3
|
-
/**
|
|
4
|
-
* Adds drag and drop functionality to an element.
|
|
5
|
-
*/
|
|
6
|
-
export class DragDropDirective {
|
|
7
|
-
/**
|
|
8
|
-
* Emits the dropped files to the parent.
|
|
9
|
-
*/
|
|
10
|
-
files = new EventEmitter();
|
|
11
|
-
constructor() { }
|
|
12
|
-
/**
|
|
13
|
-
* Prevents the event default.
|
|
14
|
-
*
|
|
15
|
-
* @param evt - The Event when dragged files hover over the parent.
|
|
16
|
-
*/
|
|
17
|
-
onDragOver(evt) {
|
|
18
|
-
evt.preventDefault();
|
|
19
|
-
evt.stopPropagation();
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Prevents the event default.
|
|
23
|
-
*
|
|
24
|
-
* @param evt - The Event when dragged files leave the parent.
|
|
25
|
-
*/
|
|
26
|
-
onDragLeave(evt) {
|
|
27
|
-
evt.preventDefault();
|
|
28
|
-
evt.stopPropagation();
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Prevents the event default and emits the dropped files with the output.
|
|
32
|
-
*
|
|
33
|
-
* @param evt - The Event when files are dropped.
|
|
34
|
-
*/
|
|
35
|
-
onDrop(evt) {
|
|
36
|
-
evt.preventDefault();
|
|
37
|
-
evt.stopPropagation();
|
|
38
|
-
if (evt.dataTransfer && evt.dataTransfer.files.length > 0) {
|
|
39
|
-
this.files.emit(Array.from(evt.dataTransfer.files));
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: DragDropDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
43
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.0", type: DragDropDirective, selector: "[dragDrop]", outputs: { files: "files" }, host: { listeners: { "dragover": "onDragOver($event)", "dragleave": "onDragLeave($event)", "drop": "onDrop($event)" } }, ngImport: i0 });
|
|
44
|
-
}
|
|
45
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: DragDropDirective, decorators: [{
|
|
46
|
-
type: Directive,
|
|
47
|
-
args: [{
|
|
48
|
-
selector: '[dragDrop]'
|
|
49
|
-
}]
|
|
50
|
-
}], ctorParameters: function () { return []; }, propDecorators: { files: [{
|
|
51
|
-
type: Output
|
|
52
|
-
}], onDragOver: [{
|
|
53
|
-
type: HostListener,
|
|
54
|
-
args: ['dragover', ['$event']]
|
|
55
|
-
}], onDragLeave: [{
|
|
56
|
-
type: HostListener,
|
|
57
|
-
args: ['dragleave', ['$event']]
|
|
58
|
-
}], onDrop: [{
|
|
59
|
-
type: HostListener,
|
|
60
|
-
args: ['drop', ['$event']]
|
|
61
|
-
}] } });
|
|
62
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZHJhZ0Ryb3AuZGlyZWN0aXZlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vcHJvamVjdHMvbmd4LW1hdGVyaWFsLWVudGl0eS9zcmMvY29tcG9uZW50cy9pbnB1dC9maWxlL2ZpbGUtaW5wdXQvZHJhZ0Ryb3AuZGlyZWN0aXZlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxTQUFTLEVBQUUsWUFBWSxFQUFFLFlBQVksRUFBRSxNQUFNLEVBQUUsTUFBTSxlQUFlLENBQUM7O0FBRTlFOztHQUVHO0FBSUgsTUFBTSxPQUFPLGlCQUFpQjtJQUMxQjs7T0FFRztJQUVILEtBQUssR0FBeUIsSUFBSSxZQUFZLEVBQVUsQ0FBQztJQUV6RCxnQkFBZ0IsQ0FBQztJQUVqQjs7OztPQUlHO0lBRUgsVUFBVSxDQUFDLEdBQWM7UUFDckIsR0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nLCBbJyRldmVudCddKVxuICAgIG9uRHJhZ0xlYXZlKGV2dDogRHJhZ0V2ZW50KTogdm9pZCB7XG4gICAgICAgIGV2dC5wcmV2ZW50RGVmYXVsdCgpO1xuICAgICAgICBldnQuc3RvcFByb3BhZ2F0aW9uKCk7XG4gICAgfVxuXG4gICAgLyoqXG4gICAgICogUHJldmVudHMgdGhlIGV2ZW50IGRlZmF1bHQgYW5kIGVtaXRzIHRoZSBkcm9wcGVkIGZpbGVzIHdpdGggdGhlIG91dHB1dC5cbiAgICAgKlxuICAgICAqIEBwYXJhbSBldnQgLSBUaGUgRXZlbnQgd2hlbiBmaWxlcyBhcmUgZHJvcHBlZC5cbiAgICAgKi9cbiAgICBASG9zdExpc3RlbmVyKCdkcm9wJywgWyckZXZlbnQnXSlcbiAgICBvbkRyb3AoZXZ0OiBEcmFnRXZlbnQpOiB2b2lkIHtcbiAgICAgICAgZXZ0LnByZXZlbnREZWZhdWx0KCk7XG4gICAgICAgIGV2dC5zdG9wUHJvcGFnYXRpb24oKTtcbiAgICAgICAgaWYgKGV2dC5kYXRhVHJhbnNmZXIgJiYgZXZ0LmRhdGFUcmFuc2Zlci5maWxlcy5sZW5ndGggPiAwKSB7XG4gICAgICAgICAgICB0aGlzLmZpbGVzLmVtaXQoQXJyYXkuZnJvbShldnQuZGF0YVRyYW5zZmVyLmZpbGVzKSk7XG4gICAgICAgIH1cbiAgICB9XG59Il19
|
|
File without changes
|
|
File without changes
|