ngx-material-entity 0.1.2 → 0.1.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.
Files changed (183) hide show
  1. package/README.md +533 -326
  2. package/capsulation/lodash.utilities.d.ts +62 -0
  3. package/capsulation/reflect.utilities.d.ts +56 -0
  4. package/classes/base.builder.d.ts +36 -0
  5. package/classes/date.utilities.d.ts +70 -0
  6. package/classes/entity.model.d.ts +19 -0
  7. package/classes/entity.service.d.ts +108 -0
  8. package/classes/entity.utilities.d.ts +180 -0
  9. package/classes/file.utilities.d.ts +52 -0
  10. package/components/confirm-dialog/confirm-dialog-data.builder.d.ts +10 -11
  11. package/components/confirm-dialog/confirm-dialog-data.d.ts +4 -0
  12. package/components/confirm-dialog/confirm-dialog.component.d.ts +11 -0
  13. package/components/input/add-array-item-dialog-data.builder.d.ts +21 -0
  14. package/components/input/{array-table/add-array-item-dialog/add-array-item-dialog-data.d.ts → add-array-item-dialog-data.d.ts} +6 -3
  15. package/components/input/array/array-date-input/array-date-input.component.d.ts +22 -0
  16. package/components/input/array/array-date-range-input/array-date-range-input.component.d.ts +30 -0
  17. package/components/input/array/array-date-time-input/array-date-time-input.component.d.ts +32 -0
  18. package/components/input/array/array-string-autocomplete-chips/array-string-autocomplete-chips.component.d.ts +58 -0
  19. package/components/input/array/array-string-chips-input/array-string-chips-input.component.d.ts +51 -0
  20. package/components/input/array/array-table.class.d.ts +48 -0
  21. package/components/input/boolean/boolean-checkbox-input/boolean-checkbox-input.component.d.ts +17 -0
  22. package/components/input/boolean/boolean-dropdown-input/boolean-dropdown-input.component.d.ts +17 -0
  23. package/components/input/boolean/boolean-toggle-input/boolean-toggle-input.component.d.ts +17 -0
  24. package/components/input/date/date-input/date-input.component.d.ts +21 -0
  25. package/components/input/date/date-range-input/date-range-input.component.d.ts +27 -0
  26. package/components/input/date/date-time-input/date-time-input.component.d.ts +38 -0
  27. package/components/input/file/file-default-input/file-default-input.component.d.ts +21 -0
  28. package/components/input/file/file-image-input/file-image-input.component.d.ts +30 -0
  29. package/components/input/file/file-input/dragDrop.directive.d.ts +32 -0
  30. package/components/input/file/file-input/file-input.component.d.ts +32 -0
  31. package/components/input/input.component.d.ts +108 -39
  32. package/components/input/input.module.d.ts +37 -13
  33. package/components/input/number/number-dropdown-input/number-dropdown-input.component.d.ts +17 -0
  34. package/components/input/number/number-input/number-input.component.d.ts +17 -0
  35. package/components/input/string/string-autocomplete-input/string-autocomplete-input.component.d.ts +25 -0
  36. package/components/input/string/string-dropdown-input/string-dropdown-input.component.d.ts +17 -0
  37. package/components/input/string/string-input/string-input.component.d.ts +17 -0
  38. package/components/input/string/string-textbox-input/string-textbox-input.component.d.ts +17 -0
  39. package/components/table/create-dialog/create-dialog-data.builder.d.ts +9 -8
  40. package/components/table/create-dialog/create-entity-dialog-data.builder.d.ts +12 -6
  41. package/components/table/create-dialog/create-entity-dialog-data.d.ts +3 -3
  42. package/components/table/create-dialog/create-entity-dialog.component.d.ts +23 -7
  43. package/components/table/edit-dialog/edit-dialog-data.builder.d.ts +11 -13
  44. package/components/table/edit-dialog/edit-entity-dialog-data.d.ts +3 -3
  45. package/components/table/edit-dialog/edit-entity-dialog.builder.d.ts +12 -6
  46. package/components/table/edit-dialog/edit-entity-dialog.component.d.ts +25 -7
  47. package/components/table/table-data.builder.d.ts +25 -14
  48. package/components/table/table-data.d.ts +22 -10
  49. package/components/table/table.component.d.ts +48 -2
  50. package/components/table/table.module.d.ts +3 -1
  51. package/decorators/array/array-decorator-internal.data.d.ts +85 -9
  52. package/decorators/array/array-decorator.data.d.ts +200 -25
  53. package/decorators/array/array.decorator.d.ts +4 -4
  54. package/decorators/base/base-property.decorator.d.ts +2 -3
  55. package/decorators/base/decorator-types.enum.d.ts +13 -4
  56. package/decorators/base/dropdown-value.interface.d.ts +14 -0
  57. package/decorators/base/property-decorator-internal.data.d.ts +16 -3
  58. package/decorators/base/property-decorator.data.d.ts +26 -5
  59. package/decorators/boolean/boolean-decorator-internal.data.d.ts +9 -0
  60. package/decorators/boolean/boolean-decorator.data.d.ts +9 -0
  61. package/decorators/boolean/boolean.decorator.d.ts +1 -1
  62. package/decorators/date/date-decorator-internal.data.d.ts +44 -0
  63. package/decorators/date/date-decorator.data.d.ts +129 -0
  64. package/decorators/date/date.decorator.d.ts +8 -0
  65. package/decorators/file/file-decorator-internal.data.d.ts +92 -0
  66. package/decorators/file/file-decorator.data.d.ts +92 -0
  67. package/decorators/file/file.decorator.d.ts +9 -0
  68. package/decorators/number/number-decorator-internal.data.d.ts +8 -4
  69. package/decorators/number/number-decorator.data.d.ts +8 -4
  70. package/decorators/number/number.decorator.d.ts +2 -2
  71. package/decorators/object/object-decorator-internal.data.d.ts +6 -3
  72. package/decorators/object/object-decorator.data.d.ts +8 -5
  73. package/decorators/object/object.decorator.d.ts +3 -3
  74. package/decorators/string/string-decorator-internal.data.d.ts +14 -4
  75. package/decorators/string/string-decorator.data.d.ts +14 -4
  76. package/decorators/string/string.decorator.d.ts +1 -1
  77. package/esm2020/capsulation/lodash.utilities.mjs +75 -0
  78. package/esm2020/capsulation/reflect.utilities.mjs +69 -0
  79. package/esm2020/classes/base.builder.mjs +42 -0
  80. package/esm2020/classes/date.utilities.mjs +158 -0
  81. package/esm2020/classes/entity.model.mjs +19 -0
  82. package/esm2020/classes/entity.service.mjs +180 -0
  83. package/esm2020/classes/entity.utilities.mjs +669 -0
  84. package/esm2020/classes/file.utilities.mjs +123 -0
  85. package/esm2020/components/confirm-dialog/confirm-dialog-data.builder.mjs +17 -50
  86. package/esm2020/components/confirm-dialog/confirm-dialog-data.mjs +1 -1
  87. package/esm2020/components/confirm-dialog/confirm-dialog.component.mjs +15 -4
  88. package/esm2020/components/get-validation-error-message.function.mjs +5 -1
  89. package/esm2020/components/input/add-array-item-dialog-data.builder.mjs +30 -0
  90. package/esm2020/components/input/add-array-item-dialog-data.mjs +2 -0
  91. package/esm2020/components/input/array/array-date-input/array-date-input.component.mjs +44 -0
  92. package/esm2020/components/input/array/array-date-range-input/array-date-range-input.component.mjs +68 -0
  93. package/esm2020/components/input/array/array-date-time-input/array-date-time-input.component.mjs +65 -0
  94. package/esm2020/components/input/array/array-string-autocomplete-chips/array-string-autocomplete-chips.component.mjs +131 -0
  95. package/esm2020/components/input/array/array-string-chips-input/array-string-chips-input.component.mjs +116 -0
  96. package/esm2020/components/input/array/array-table.class.mjs +92 -0
  97. package/esm2020/components/input/boolean/boolean-checkbox-input/boolean-checkbox-input.component.mjs +38 -0
  98. package/esm2020/components/input/boolean/boolean-dropdown-input/boolean-dropdown-input.component.mjs +35 -0
  99. package/esm2020/components/input/boolean/boolean-toggle-input/boolean-toggle-input.component.mjs +38 -0
  100. package/esm2020/components/input/date/date-input/date-input.component.mjs +38 -0
  101. package/esm2020/components/input/date/date-range-input/date-range-input.component.mjs +63 -0
  102. package/esm2020/components/input/date/date-time-input/date-time-input.component.mjs +74 -0
  103. package/esm2020/components/input/file/file-default-input/file-default-input.component.mjs +39 -0
  104. package/esm2020/components/input/file/file-image-input/file-image-input.component.mjs +95 -0
  105. package/esm2020/components/input/file/file-input/dragDrop.directive.mjs +64 -0
  106. package/esm2020/components/input/file/file-input/file-input.component.mjs +152 -0
  107. package/esm2020/components/input/input.component.mjs +207 -110
  108. package/esm2020/components/input/input.module.mjs +87 -10
  109. package/esm2020/components/input/number/number-dropdown-input/number-dropdown-input.component.mjs +36 -0
  110. package/esm2020/components/input/number/number-input/number-input.component.mjs +34 -0
  111. package/esm2020/components/input/string/string-autocomplete-input/string-autocomplete-input.component.mjs +52 -0
  112. package/esm2020/components/input/string/string-dropdown-input/string-dropdown-input.component.mjs +36 -0
  113. package/esm2020/components/input/string/string-input/string-input.component.mjs +34 -0
  114. package/esm2020/components/input/string/string-textbox-input/string-textbox-input.component.mjs +35 -0
  115. package/esm2020/components/table/create-dialog/create-dialog-data.builder.mjs +18 -40
  116. package/esm2020/components/table/create-dialog/create-entity-dialog-data.builder.mjs +15 -7
  117. package/esm2020/components/table/create-dialog/create-entity-dialog-data.mjs +1 -1
  118. package/esm2020/components/table/create-dialog/create-entity-dialog.component.mjs +36 -22
  119. package/esm2020/components/table/create-dialog/create-entity-dialog.module.mjs +20 -4
  120. package/esm2020/components/table/edit-dialog/edit-dialog-data.builder.mjs +23 -63
  121. package/esm2020/components/table/edit-dialog/edit-entity-dialog-data.mjs +1 -1
  122. package/esm2020/components/table/edit-dialog/edit-entity-dialog.builder.mjs +15 -7
  123. package/esm2020/components/table/edit-dialog/edit-entity-dialog.component.mjs +50 -31
  124. package/esm2020/components/table/table-data.builder.mjs +31 -15
  125. package/esm2020/components/table/table-data.mjs +1 -1
  126. package/esm2020/components/table/table.component.mjs +77 -32
  127. package/esm2020/components/table/table.module.mjs +12 -4
  128. package/esm2020/decorators/array/array-decorator-internal.data.mjs +111 -12
  129. package/esm2020/decorators/array/array-decorator.data.mjs +2 -2
  130. package/esm2020/decorators/array/array.decorator.mjs +9 -3
  131. package/esm2020/decorators/base/base-property.decorator.mjs +4 -3
  132. package/esm2020/decorators/base/decorator-types.enum.mjs +9 -1
  133. package/esm2020/decorators/base/dropdown-value.interface.mjs +2 -0
  134. package/esm2020/decorators/base/property-decorator-internal.data.mjs +33 -10
  135. package/esm2020/decorators/base/property-decorator.data.mjs +1 -1
  136. package/esm2020/decorators/boolean/boolean-decorator-internal.data.mjs +12 -1
  137. package/esm2020/decorators/boolean/boolean-decorator.data.mjs +1 -1
  138. package/esm2020/decorators/boolean/boolean.decorator.mjs +2 -2
  139. package/esm2020/decorators/date/date-decorator-internal.data.mjs +48 -0
  140. package/esm2020/decorators/date/date-decorator.data.mjs +7 -0
  141. package/esm2020/decorators/date/date.decorator.mjs +21 -0
  142. package/esm2020/decorators/file/file-decorator-internal.data.mjs +98 -0
  143. package/esm2020/decorators/file/file-decorator.data.mjs +7 -0
  144. package/esm2020/decorators/file/file.decorator.mjs +22 -0
  145. package/esm2020/decorators/number/number-decorator-internal.data.mjs +7 -1
  146. package/esm2020/decorators/number/number-decorator.data.mjs +1 -1
  147. package/esm2020/decorators/number/number.decorator.mjs +3 -3
  148. package/esm2020/decorators/object/object-decorator-internal.data.mjs +5 -2
  149. package/esm2020/decorators/object/object-decorator.data.mjs +1 -1
  150. package/esm2020/decorators/object/object.decorator.mjs +2 -2
  151. package/esm2020/decorators/string/string-decorator-internal.data.mjs +13 -1
  152. package/esm2020/decorators/string/string-decorator.data.mjs +1 -1
  153. package/esm2020/decorators/string/string.decorator.mjs +2 -2
  154. package/esm2020/mocks/placeholder-data.png.mjs +3 -0
  155. package/esm2020/public-api.mjs +12 -5
  156. package/fesm2015/ngx-material-entity.mjs +3271 -894
  157. package/fesm2015/ngx-material-entity.mjs.map +1 -1
  158. package/fesm2020/ngx-material-entity.mjs +3140 -829
  159. package/fesm2020/ngx-material-entity.mjs.map +1 -1
  160. package/mocks/placeholder-data.png.d.ts +1 -0
  161. package/package.json +7 -1
  162. package/public-api.d.ts +12 -5
  163. package/classes/entity-model.class.d.ts +0 -9
  164. package/classes/entity-service.class.d.ts +0 -66
  165. package/classes/entity-utilities.class.d.ts +0 -112
  166. package/components/input/array-table/add-array-item-dialog/add-array-item-dialog-data.builder.d.ts +0 -17
  167. package/components/input/array-table/add-array-item-dialog/add-array-item-dialog.component.d.ts +0 -22
  168. package/components/input/array-table/add-array-item-dialog/add-array-item-dialog.module.d.ts +0 -12
  169. package/components/input/array-table/array-table.component.d.ts +0 -34
  170. package/components/input/array-table/array-table.module.d.ts +0 -19
  171. package/components/input/internal-input/internal-input.component.d.ts +0 -54
  172. package/components/input/internal-input/internal-input.module.d.ts +0 -16
  173. package/esm2020/classes/entity-model.class.mjs +0 -19
  174. package/esm2020/classes/entity-service.class.mjs +0 -76
  175. package/esm2020/classes/entity-utilities.class.mjs +0 -329
  176. package/esm2020/components/input/array-table/add-array-item-dialog/add-array-item-dialog-data.builder.mjs +0 -33
  177. package/esm2020/components/input/array-table/add-array-item-dialog/add-array-item-dialog-data.mjs +0 -2
  178. package/esm2020/components/input/array-table/add-array-item-dialog/add-array-item-dialog.component.mjs +0 -45
  179. package/esm2020/components/input/array-table/add-array-item-dialog/add-array-item-dialog.module.mjs +0 -22
  180. package/esm2020/components/input/array-table/array-table.component.mjs +0 -119
  181. package/esm2020/components/input/array-table/array-table.module.mjs +0 -66
  182. package/esm2020/components/input/internal-input/internal-input.component.mjs +0 -70
  183. package/esm2020/components/input/internal-input/internal-input.module.mjs +0 -54
@@ -0,0 +1,62 @@
1
+ import { Dictionary, Many, ValueKeyIteratee } from 'lodash';
2
+ /**
3
+ * Encapsulates all functionality of lodash.
4
+ */
5
+ export declare abstract class LodashUtilities {
6
+ /**
7
+ * Performs a deep comparison between two values to determine if they are
8
+ * equivalent.
9
+ *
10
+ * **Note:** This method supports comparing arrays, array buffers, booleans,
11
+ * date objects, error objects, maps, numbers, `Object` objects, regexps,
12
+ * sets, strings, symbols, and typed arrays. `Object` objects are compared
13
+ * by their own, not inherited, enumerable properties. Functions and DOM
14
+ * nodes are **not** supported.
15
+ *
16
+ * @param value - The value to compare.
17
+ * @param other - The other value to compare.
18
+ * @returns Returns `true` if the values are equivalent, else `false`.
19
+ */
20
+ static isEqual(value: unknown, other: unknown): boolean;
21
+ /**
22
+ * This method is like _.clone except that it recursively clones value.
23
+ *
24
+ * @param value - The value to recursively clone.
25
+ * @returns Returns the deep cloned value.
26
+ */
27
+ static cloneDeep<T>(value: T): T;
28
+ /**
29
+ * The opposite of `_.pick`; this method creates an object composed of the
30
+ * own and inherited enumerable properties of `object` that are not omitted.
31
+ *
32
+ * @param object - The source object.
33
+ * @param paths - The property names to omit, specified
34
+ * individually or in arrays.
35
+ * @returns Returns the new object.
36
+ */
37
+ static omit<T extends object, K extends keyof T>(object: T | null | undefined, ...paths: Many<K>[]): Omit<T, K>;
38
+ /**
39
+ * Checks if `value` is `null` or `undefined`.
40
+ *
41
+ * @param value - The value to check.
42
+ * @returns Returns `true` if `value` is nullish, else `false`.
43
+ */
44
+ static isNil(value: unknown): value is null | undefined;
45
+ /**
46
+ * The opposite of `_.pickBy`; this method creates an object composed of the
47
+ * own and inherited enumerable properties of `object` that `predicate`
48
+ * doesn't return truthy for.
49
+ *
50
+ * @param object - The source object.
51
+ * @param predicate - The function invoked per property.
52
+ * @returns Returns the new object.
53
+ */
54
+ static omitBy<T>(object: Dictionary<T> | null | undefined, predicate?: ValueKeyIteratee<T>): Dictionary<T>;
55
+ /**
56
+ * Checks if value is classified as an Array object.
57
+ *
58
+ * @param value - The value to check.
59
+ * @returns Returns true if value is correctly classified, else false.
60
+ */
61
+ static isArray(value?: unknown): value is unknown[];
62
+ }
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Encapsulates all functionality of Reflect.
3
+ */
4
+ export declare abstract class ReflectUtilities {
5
+ /**
6
+ * Gets the metadata value for the provided metadata key on the target object or its prototype chain.
7
+ *
8
+ * @param metadataKey - A key used to store and retrieve metadata.
9
+ * @param target - The target object on which the metadata is defined.
10
+ * @param propertyKey - The property key for the target.
11
+ * @returns The metadata value for the metadata key if found; otherwise, undefined.
12
+ */
13
+ static getMetadata<T extends object>(metadataKey: string, target: T, propertyKey: keyof T): unknown;
14
+ /**
15
+ * Returns the string and symbol keys of the own properties of an object. The own properties of an object
16
+ * are those that are defined directly on that object, and are not inherited from the object's prototype.
17
+ *
18
+ * @param target - Object that contains the own properties.
19
+ * @returns The keys of the given object.
20
+ */
21
+ static ownKeys<T extends object>(target: T): (keyof T)[];
22
+ /**
23
+ * Gets the property of target, equivalent to `target[propertyKey]`.
24
+ *
25
+ * @param target - Object that contains the property on itself or in its prototype chain.
26
+ * @param propertyKey - The property name.
27
+ * @returns The property of the target of the given key.
28
+ */
29
+ static get<T extends object>(target: T, propertyKey: keyof T): unknown;
30
+ /**
31
+ * Sets the property of target, equivalent to `target[propertyKey] = value`.
32
+ *
33
+ * @param target - Object that contains the property on itself or in its prototype chain.
34
+ * @param propertyKey - The property name.
35
+ * @param value - The value to set the property to.
36
+ * @returns If setting the value was successful.
37
+ */
38
+ static set<T extends object>(target: T, propertyKey: keyof T, value: unknown): boolean;
39
+ /**
40
+ * Equivalent to `propertyKey in target`.
41
+ *
42
+ * @param target - Object that contains the property on itself or in its prototype chain.
43
+ * @param propertyKey - Name of the property.
44
+ * @returns Whether or not the given target has the key.
45
+ */
46
+ static has<T extends object>(target: T, propertyKey: keyof T): boolean;
47
+ /**
48
+ * Define a unique metadata entry on the target.
49
+ *
50
+ * @param metadataKey - A key used to store and retrieve metadata.
51
+ * @param metadataValue - A value that contains attached metadata.
52
+ * @param target - The target object on which to define metadata.
53
+ * @param propertyKey - The property key for the target.
54
+ */
55
+ static defineMetadata<T extends object>(metadataKey: unknown, metadataValue: unknown, target: T, propertyKey: string): void;
56
+ }
@@ -0,0 +1,36 @@
1
+ import { BaseEntityType } from './entity.model';
2
+ /**
3
+ * The abstract BaseBuilder class.
4
+ */
5
+ export declare abstract class BaseBuilder<InternalType extends InputType, InputType extends BaseEntityType<InputType>> {
6
+ private readonly data;
7
+ private readonly inputData?;
8
+ protected constructor(data?: InputType);
9
+ /**
10
+ * Generates the internal data from the given user inputs.
11
+ *
12
+ * @param data - The input from the user.
13
+ * @returns The internal data.
14
+ */
15
+ protected abstract generateBaseData(data?: InputType): InternalType;
16
+ /**
17
+ * Used to validate the user input in the constructor.
18
+ *
19
+ * @param data - The user input.
20
+ */
21
+ protected validateInput(data?: InputType): void;
22
+ /**
23
+ * Sets the value for the given key if no user value was provided.
24
+ *
25
+ * @param key - The key to set the default value for.
26
+ * @param value - The value to set when nothing was provided.
27
+ * @returns The Builder.
28
+ */
29
+ withDefault(key: keyof InputType, value: Omit<InternalType[keyof InputType], 'undefined'>): BaseBuilder<InternalType, InputType>;
30
+ /**
31
+ * Method used to get the final build value after applying all chaining.
32
+ *
33
+ * @returns The build value.
34
+ */
35
+ getResult(): InternalType;
36
+ }
@@ -0,0 +1,70 @@
1
+ import { Time } from '@angular/common';
2
+ import { DateFilterFn } from '@angular/material/datepicker';
3
+ import { DropdownValue } from '../decorators/base/dropdown-value.interface';
4
+ /**
5
+ * Valid steps from one time value to the next. Needs to be able to divide 60 minutes without remainder.
6
+ */
7
+ declare type MinuteSteps = 1 | 2 | 3 | 4 | 5 | 6 | 10 | 12 | 15 | 20 | 30 | 60;
8
+ /**
9
+ * Contains Helper Functions for handling date properties.
10
+ */
11
+ export declare abstract class DateUtilities {
12
+ /**
13
+ * The default filter function to user when none was provided by the user.
14
+ */
15
+ static defaultDateFilter: DateFilterFn<Date | null | undefined>;
16
+ /**
17
+ * Gets the given value as a date value.
18
+ *
19
+ * @param value - The value to get as a date.
20
+ * @returns The given value as a date.
21
+ */
22
+ static asDate(value: unknown): Date;
23
+ /**
24
+ * Gets the default times used by the DateTime picker when nothing is specified by the user.
25
+ *
26
+ * @param format - The time format. Defaults to 24.
27
+ * @param minuteSteps - The steps from one time value to the next. Defaults to 30.
28
+ * @returns Times in the 24 hour format from 0:00 until 23:30 in 30 minute steps.
29
+ */
30
+ static getDefaultTimes(format?: 12 | 24, minuteSteps?: MinuteSteps): DropdownValue<Time>[];
31
+ private static getTimeDropdownValue;
32
+ private static getFormattedHour;
33
+ private static getFormattedMinute;
34
+ /**
35
+ * Gets the Time object from the given date.
36
+ *
37
+ * @param value - The date to get the time object from.
38
+ * @returns The Time object build from the date value.
39
+ */
40
+ static getTimeFromDate(value: Date): Time | undefined;
41
+ /**
42
+ * Gets the dates between the two given gates. Does additional filtering based on the provided DateRange metadata.
43
+ *
44
+ * @param startDate - The start date.
45
+ * @param endDate - The end date.
46
+ * @param filter - The custom filter from the metadata.
47
+ * @returns All dates between the two provided dates. Includes start and end date.
48
+ */
49
+ static getDatesBetween(startDate: Date, endDate: Date, filter?: DateFilterFn<Date>): Date[];
50
+ /**
51
+ * Get all valid times for the dropdown of a datetime property.
52
+ *
53
+ * @param date - The date of the datetime.
54
+ * @param times - All given times to filter.
55
+ * @param min - The function that defines the minimum time.
56
+ * @param max - The function that defines the maximum time.
57
+ * @param filter - A filter function to do more specific time filtering. This could be e.g. The removal of lunch breaks.
58
+ * @returns All valid dropdown values for the datetime property.
59
+ */
60
+ static getValidTimesForDropdown(date: Date, times: DropdownValue<Time>[], min?: (date?: Date) => Time, max?: (date?: Date) => Time, filter?: ((time: Time) => boolean) | (() => boolean)): DropdownValue<Time>[];
61
+ /**
62
+ * Checks if the time object has processable hours and minutes properties.
63
+ * Doesn't check custom validators like min/max from the metadata configuration.
64
+ *
65
+ * @param time - The time to check.
66
+ * @returns Whether or not the time object is unprocessable.
67
+ */
68
+ static timeIsUnprocessable(time?: Time): boolean;
69
+ }
70
+ export {};
@@ -0,0 +1,19 @@
1
+ /**
2
+ * The newable type used whenever an entity class is passed to create an entity and initialize its metadata.
3
+ */
4
+ export declare type EntityClassNewable<EntityType extends BaseEntityType<EntityType>> = new (data?: EntityType) => EntityType;
5
+ /**
6
+ * The Generic Base EntityType.
7
+ */
8
+ export declare type BaseEntityType<T> = {
9
+ [K in keyof T]: unknown;
10
+ };
11
+ /**
12
+ * A base Entity class with a builtin id.
13
+ */
14
+ export declare abstract class Entity {
15
+ /**
16
+ * A unique identifier for the Entity.
17
+ */
18
+ id: string;
19
+ }
@@ -0,0 +1,108 @@
1
+ import { HttpClient } from '@angular/common/http';
2
+ import { BehaviorSubject } from 'rxjs';
3
+ import { BaseEntityType } from './entity.model';
4
+ /**
5
+ * A generic EntityService class.
6
+ * Offers basic CRUD-functionality.
7
+ * You should create a service for every Entity you have.
8
+ * If you extend from this you need to make sure that the extended Service can be injected.
9
+ */
10
+ export declare abstract class EntityService<EntityType extends BaseEntityType<EntityType>> {
11
+ private readonly http;
12
+ /**
13
+ * The base url used for api requests. If u want to have more control over this,
14
+ * you can override the create, read, update and delete methods.
15
+ *
16
+ * Create Sends a POST-Request to baseUrl.
17
+ *
18
+ * Read Sends a GET-Request to baseUrl.
19
+ *
20
+ * Update Sends a PATCH-Request to baseUrl/{id}.
21
+ *
22
+ * Delete Sends a DEL-Request to baseUrl/{id}.
23
+ */
24
+ abstract readonly baseUrl: string;
25
+ /**
26
+ * The key which holds the id value.
27
+ *
28
+ * @default 'id'
29
+ */
30
+ readonly idKey: keyof EntityType;
31
+ /**
32
+ * A subject of all the entity values.
33
+ * Can be subscribed to when you want to do a specific thing whenever the entities change.
34
+ */
35
+ readonly entitiesSubject: BehaviorSubject<EntityType[]>;
36
+ /**
37
+ * Gets the entities in an array from the internal entitiesSubject.
38
+ *
39
+ * @returns The current entities in form of an array.
40
+ */
41
+ get entities(): EntityType[];
42
+ constructor(http: HttpClient);
43
+ /**
44
+ * Creates a new Entity and pushes it to the entities array.
45
+ *
46
+ * @param entity - The data of the entity to create.
47
+ * All values that should be omitted will be removed from it inside this method.
48
+ * @returns A Promise of the created entity.
49
+ */
50
+ create(entity: EntityType): Promise<EntityType>;
51
+ /**
52
+ * Creates the entity with form data when the entity contains files in contrast to creating it with a normal json body.
53
+ * All file values are stored inside their respective property key and their name.
54
+ * Form data is able to handle setting multiple files to the same key.
55
+ *
56
+ * @param body - The body Of the request.
57
+ * @param filePropertyKeys - All property keys that are files and need to be added to the form data.
58
+ * @param entity - The entity to create. This is needed in addition to the body because the body doesn't contain any metadata.
59
+ * @returns The created entity from the server.
60
+ */
61
+ protected createWithFormData(body: Partial<EntityType>, filePropertyKeys: (keyof EntityType)[], entity: EntityType): Promise<EntityType>;
62
+ /**
63
+ * Creates the entity with a normal json body in contrast to creating it with form data when the entity contains files.
64
+ *
65
+ * @param body - The body Of the request.
66
+ * @returns The created entity from the server.
67
+ */
68
+ protected createWithJson(body: Partial<EntityType>): Promise<EntityType>;
69
+ /**
70
+ * Gets all existing entities and pushes them to the entities array.
71
+ *
72
+ * @returns A Promise of all received Entities.
73
+ */
74
+ read(): Promise<EntityType[]>;
75
+ /**
76
+ * Updates a specific Entity.
77
+ *
78
+ * @param entity - The updated Entity
79
+ * All values that should be omitted will be removed from it inside this method.
80
+ * @param entityPriorChanges - The current Entity.
81
+ * It Is used to get changed values and only update them instead of sending the whole entity data.
82
+ */
83
+ update(entity: EntityType, entityPriorChanges: EntityType): Promise<void>;
84
+ /**
85
+ * Updates the entity with form data when the entity contains files in contrast to creating it with a normal json body.
86
+ * All file values are stored inside their respective property key and their name.
87
+ * Form data is able to handle setting multiple files to the same key.
88
+ *
89
+ * @param body - The request body. Already contains only properties that have changed.
90
+ * @param filePropertyKeys - The keys of all properties which are files and need to separately be appended to the form data.
91
+ * @param entity - The original entity. Is needed to get the metadata of all the files.
92
+ * @param id - The id of the entity to update.
93
+ */
94
+ protected updateWithFormData(body: Partial<EntityType>, filePropertyKeys: (keyof EntityType)[], entity: EntityType, id: EntityType[keyof EntityType]): Promise<void>;
95
+ /**
96
+ * Updates the entity with a normal json body in contrast to updating it with form data when the entity contains files.
97
+ *
98
+ * @param body - The body of the Request. Has already removed all unnecessary values.
99
+ * @param id - The id of the entity to update.
100
+ */
101
+ protected updateWithJson(body: Partial<EntityType>, id: EntityType[keyof EntityType]): Promise<void>;
102
+ /**
103
+ * Deletes a specific Entity.
104
+ *
105
+ * @param entity - The entity to delete.
106
+ */
107
+ delete(entity: EntityType): Promise<void>;
108
+ }
@@ -0,0 +1,180 @@
1
+ import { DecoratorType, DecoratorTypes } from '../decorators/base/decorator-types.enum';
2
+ import { PropertyDecoratorConfigInternal } from '../decorators/base/property-decorator-internal.data';
3
+ import { BaseEntityType } from './entity.model';
4
+ /**
5
+ * Contains HelperMethods around handling Entities and their property-metadata.
6
+ */
7
+ export declare abstract class EntityUtilities {
8
+ /**
9
+ * Gets the properties to omit when updating the entity.
10
+ *
11
+ * @param entity - The entity to get the properties which should be left out for updating from.
12
+ * @returns The properties which should be left out for updating an Entity.
13
+ */
14
+ static getOmitForUpdate<EntityType extends BaseEntityType<EntityType>>(entity: EntityType): (keyof EntityType)[];
15
+ /**
16
+ * Gets the properties to omit when creating new entities.
17
+ *
18
+ * @param entity - The entity to get the properties which should be left out for creating from.
19
+ * @returns The properties which should be left out for creating a new Entity.
20
+ */
21
+ static getOmitForCreate<EntityType extends BaseEntityType<EntityType>>(entity: EntityType): (keyof EntityType)[];
22
+ /**
23
+ * Gets all properties on the given entity which are files.
24
+ *
25
+ * @param entity - The entity to check for file properties.
26
+ * @param omit - Whether to leave out values that are omitted for create or delete.
27
+ * @returns The keys of all file properties on the given entity.
28
+ */
29
+ static getFileProperties<EntityType extends BaseEntityType<EntityType>>(entity: EntityType, omit?: 'create' | 'update'): (keyof EntityType)[];
30
+ /**
31
+ * Gets the metadata included in an property.
32
+ *
33
+ * @param entity - The entity with the property to get the metadata from.
34
+ * @param propertyKey - The property on the given Entity to get the metadata from.
35
+ * @param type - For secure Typing, defines the returned PropertyConfig.
36
+ * @returns The metadata of the property.
37
+ * @throws When no metadata can be found for the given property.
38
+ */
39
+ static getPropertyMetadata<EntityType extends BaseEntityType<EntityType>, T extends DecoratorTypes>(entity: EntityType, propertyKey: keyof EntityType, type?: T): DecoratorType<T>;
40
+ /**
41
+ * Gets the type of the property-metadata.
42
+ *
43
+ * @param entity - The entity with the property to get the type from.
44
+ * @param propertyKey - The property on the given Entity to get the type from.
45
+ * @returns The type of the metadata.
46
+ * @throws Will throw an error if no metadata can be found for the given property.
47
+ */
48
+ static getPropertyType<EntityType extends BaseEntityType<EntityType>>(entity: EntityType, propertyKey: keyof EntityType): DecoratorTypes;
49
+ /**
50
+ * Sets all property values based on a given entity data-object.
51
+ *
52
+ * @param target - The target object that needs to be constructed (if called inside an Entity constructor its usually this).
53
+ * @param entity - The data object to get the property values from.
54
+ * @alias new
55
+ * @alias build
56
+ * @alias construct
57
+ */
58
+ static new<EntityType extends BaseEntityType<EntityType>>(target: EntityType, entity?: EntityType): void;
59
+ static construct: typeof EntityUtilities.new;
60
+ static build: typeof EntityUtilities.new;
61
+ /**
62
+ * Checks if the values on an entity are valid.
63
+ * Also checks all the validators given by the metadata ("required", "maxLength" etc.).
64
+ *
65
+ * @param entity - The entity to validate.
66
+ * @param omit - Whether to check for creating or editing validity.
67
+ * @returns Whether or not the entity is valid.
68
+ */
69
+ static isEntityValid<EntityType extends BaseEntityType<EntityType>>(entity: EntityType, omit: 'create' | 'update'): boolean;
70
+ /**
71
+ * Checks if a single property value is valid.
72
+ *
73
+ * @param entity - The entity where the property is from.
74
+ * @param key - The name of the property.
75
+ * @param omit - Whether to check if the given entity is valid for creation or updating.
76
+ * @returns Whether or not the property value is valid.
77
+ * @throws Throws when it extracts an unknown metadata type.
78
+ */
79
+ private static isPropertyValid;
80
+ private static isBooleanValid;
81
+ private static isStringValid;
82
+ private static isTextboxValid;
83
+ private static isNumberValid;
84
+ private static isDateValid;
85
+ private static isDateRangeValid;
86
+ private static isDateTimeValid;
87
+ private static isFileDataValid;
88
+ /**
89
+ * Checks if an entity is "dirty" (if its values have changed).
90
+ *
91
+ * @param entity - The entity after all changes.
92
+ * @param entityPriorChanges - The entity before the changes.
93
+ * @returns Whether or not the entity is dirty.
94
+ */
95
+ static dirty<EntityType extends BaseEntityType<EntityType>>(entity: EntityType, entityPriorChanges: EntityType): Promise<boolean>;
96
+ private static differencesForDirty;
97
+ /**
98
+ * Compares two Entities and returns their difference in an object.
99
+ *
100
+ * @param entity - The first entity to compare.
101
+ * @param entityPriorChanges - The second entity to compare.
102
+ * @returns The difference between the two Entities in form of a Partial.
103
+ */
104
+ static difference<EntityType extends BaseEntityType<EntityType>>(entity: EntityType, entityPriorChanges: EntityType): Promise<Partial<EntityType>>;
105
+ /**
106
+ * Checks if two given values are equal.
107
+ * It uses the isEqual method from LodashUtilities and extends it with functionality regarding Dates.
108
+ *
109
+ * @param value - The updated value.
110
+ * @param valuePriorChanges - The value before any changes.
111
+ * @param metadata - The metadata of the property.
112
+ * @param type - The type of the property.
113
+ * @returns Whether or not the given values are equal.
114
+ */
115
+ static isEqual(value: unknown, valuePriorChanges: unknown, metadata: PropertyDecoratorConfigInternal, type: DecoratorTypes): Promise<boolean>;
116
+ private static isEqualArrayDate;
117
+ private static isEqualArrayDateRange;
118
+ private static isEqualDateTime;
119
+ private static isEqualDate;
120
+ private static isEqualDateRange;
121
+ private static isEqualFile;
122
+ /**
123
+ * Compare function for sorting entity keys by their order value.
124
+ *
125
+ * @param a - First key of entity.
126
+ * @param b - Second key of entity.
127
+ * @param entity - Current entity (used to get metadata of entity keys).
128
+ * @returns 0 if both values have the same order, a negative value if 'a' comes before 'b', a positive value if 'a' comes behind 'b'.
129
+ */
130
+ static compareOrder<EntityType extends BaseEntityType<EntityType>>(a: keyof EntityType, b: keyof EntityType, entity: EntityType): number;
131
+ /**
132
+ * Gets the bootstrap column values for "lg", "md", "sm".
133
+ *
134
+ * @param entity - Entity to get the bootstrap column values of the key.
135
+ * @param key - Key of the property to get bootstrap column values from.
136
+ * @param type - Defines for which screen size the column values should be returned.
137
+ * @returns Bootstrap column value.
138
+ */
139
+ static getWidth<EntityType extends BaseEntityType<EntityType>>(entity: EntityType, key: keyof EntityType, type: 'lg' | 'md' | 'sm'): number;
140
+ /**
141
+ * Resets all changes on an entity.
142
+ *
143
+ * @param entity - The entity to reset.
144
+ * @param entityPriorChanges - The entity before any changes.
145
+ */
146
+ static resetChangesOnEntity<EntityType extends BaseEntityType<EntityType>>(entity: EntityType, entityPriorChanges: EntityType): void;
147
+ /**
148
+ * Gets the rows that are used to display the given entity.
149
+ *
150
+ * @param entity - The entity to get the rows from.
151
+ * @param hideOmitForCreate - Whether or not keys with the metadata omitForCreate should be filtered out.
152
+ * @param hideOmitForEdit - Whether or not keys with the metadata omitForUpdate should be filtered out.
153
+ * @returns The sorted Rows containing the row number and the keys to display in that row.
154
+ */
155
+ static getEntityRows<EntityType extends BaseEntityType<EntityType>>(entity: EntityType, hideOmitForCreate?: boolean, hideOmitForEdit?: boolean): EntityRow<EntityType>[];
156
+ private static getKeysForRow;
157
+ private static getNumberOfRows;
158
+ /**
159
+ * Gets the keys of the provided entity correctly typed.
160
+ *
161
+ * @param entity - The entity to get the keys of.
162
+ * @param hideOmitForCreate - Whether or not keys with the metadata omitForCreate should be filtered out.
163
+ * @param hideOmitForEdit - Whether or not keys with the metadata omitForUpdate should be filtered out.
164
+ * @returns An array of keys of the entity.
165
+ */
166
+ static keysOf<EntityType extends BaseEntityType<EntityType>>(entity: EntityType, hideOmitForCreate?: boolean, hideOmitForEdit?: boolean): (keyof EntityType)[];
167
+ }
168
+ /**
169
+ * A row that contains all the information about how to display an entity.
170
+ */
171
+ export interface EntityRow<EntityType extends BaseEntityType<EntityType>> {
172
+ /**
173
+ * The row in which this should be displayed.
174
+ */
175
+ row: number;
176
+ /**
177
+ * The keys of the values that should be displayed in that row.
178
+ */
179
+ keys: (keyof EntityType)[];
180
+ }
@@ -0,0 +1,52 @@
1
+ import { FileDataWithFile } from '../decorators/file/file-decorator-internal.data';
2
+ import { FileData } from '../decorators/file/file-decorator.data';
3
+ /**
4
+ * Provides functionality regarding files.
5
+ */
6
+ export declare abstract class FileUtilities {
7
+ /**
8
+ * Gets the accept value for the html input.
9
+ *
10
+ * @param mimeTypes - The mimeTypes to get the accept string from.
11
+ * @returns A comma separated string of all the provided mime types.
12
+ */
13
+ static getAcceptString(mimeTypes?: string[]): string;
14
+ /**
15
+ * Reads a url to display the given file.
16
+ *
17
+ * @param file - The file to get the url from.
18
+ * @returns A promise of the url. Undefined if no file was provided.
19
+ */
20
+ static getDataURLFromFile(file?: Blob): Promise<string | undefined>;
21
+ /**
22
+ * Gets a file from the given url.
23
+ *
24
+ * @param url - The url to get the file from.
25
+ * @returns A promise of the File.
26
+ */
27
+ private static getFileFromUrl;
28
+ /**
29
+ * Gets the file data with the blob from the given File Data.
30
+ *
31
+ * @param data - The File Data to get the file data with blob from.
32
+ * @returns FileDataWithFile.
33
+ */
34
+ static getFileData(data: FileData): Promise<FileDataWithFile>;
35
+ /**
36
+ * Checks if the given file has a valid mime type.
37
+ *
38
+ * @param type - The type of the file to check.
39
+ * @param allowedMimeTypes - The allowed mime types.
40
+ * @returns Whether or not the given file has a valid mime type.
41
+ */
42
+ static isMimeTypeValid(type: string, allowedMimeTypes: string[]): boolean;
43
+ /**
44
+ * Transform the given value to Megabytes.
45
+ *
46
+ * @param value - The original value.
47
+ * @param unit - If the value is B, KB or GB.
48
+ * @returns The given value as bytes.
49
+ */
50
+ static transformToMegaBytes(value: number, unit: 'B' | 'KB' | 'GB'): number;
51
+ private static transformToBytes;
52
+ }
@@ -1,4 +1,8 @@
1
+ import { BaseBuilder } from '../../classes/base.builder';
1
2
  import { ConfirmDialogData, ConfirmDialogTypes } from './confirm-dialog-data';
3
+ /**
4
+ * The internal ConfirmDialogData. Requires all default values the user can leave out.
5
+ */
2
6
  export declare class ConfirmDialogDataInternal implements ConfirmDialogData {
3
7
  text: string[];
4
8
  type: ConfirmDialogTypes;
@@ -9,16 +13,11 @@ export declare class ConfirmDialogDataInternal implements ConfirmDialogData {
9
13
  confirmationText?: string;
10
14
  constructor(text: string[], type: ConfirmDialogTypes, confirmButtonLabel: string, cancelButtonLabel: string, title: string, requireConfirmation: boolean, confirmationText?: string);
11
15
  }
12
- export declare class ConfirmDialogDataBuilder {
13
- confirmDialogData: ConfirmDialogDataInternal;
14
- private readonly dataInput?;
16
+ /**
17
+ * The Builder for the ConfirmDialogData. Sets default values.
18
+ */
19
+ export declare class ConfirmDialogDataBuilder extends BaseBuilder<ConfirmDialogDataInternal, ConfirmDialogData> {
15
20
  constructor(data?: ConfirmDialogData);
16
- private validateInput;
17
- withDefaultText(text: string[]): ConfirmDialogDataBuilder;
18
- withDefaultType(type: ConfirmDialogTypes): ConfirmDialogDataBuilder;
19
- withDefaultConfirmButtonLabel(label: string): ConfirmDialogDataBuilder;
20
- withDefaultCancelButtonLabel(label: string): ConfirmDialogDataBuilder;
21
- withDefaultTitle(title: string): ConfirmDialogDataBuilder;
22
- withDefaultRequireConfirmation(requireConfirmation: boolean): ConfirmDialogDataBuilder;
23
- withDefaultConfirmationText(confirmationText: string): ConfirmDialogDataBuilder;
21
+ protected generateBaseData(data?: ConfirmDialogData): ConfirmDialogDataInternal;
22
+ protected validateInput(data?: ConfirmDialogData): void;
24
23
  }
@@ -1,3 +1,7 @@
1
+ /**
2
+ * The different types of a confirm dialog.
3
+ * Is used for displaying different buttons accordingly.
4
+ */
1
5
  export declare type ConfirmDialogTypes = 'default' | 'delete' | 'info-only';
2
6
  /**
3
7
  * The Definition of the Confirm Dialog Data.
@@ -3,6 +3,11 @@ import { MatDialogRef } from '@angular/material/dialog';
3
3
  import { ConfirmDialogData } from './confirm-dialog-data';
4
4
  import { ConfirmDialogDataInternal } from './confirm-dialog-data.builder';
5
5
  import * as i0 from "@angular/core";
6
+ /**
7
+ * The Dialog used whenever confirmation by the user is required (e.g. When the user tries to delete an entity).
8
+ *
9
+ * Can be customized with the MAT_DIALOG_DATA "inputData". Customization options are defined in "ConfirmDialogData".
10
+ */
6
11
  export declare class NgxMatEntityConfirmDialogComponent implements OnInit {
7
12
  private readonly dialogRef;
8
13
  private readonly inputData;
@@ -10,7 +15,13 @@ export declare class NgxMatEntityConfirmDialogComponent implements OnInit {
10
15
  data: ConfirmDialogDataInternal;
11
16
  constructor(dialogRef: MatDialogRef<NgxMatEntityConfirmDialogComponent>, inputData: ConfirmDialogData);
12
17
  ngOnInit(): void;
18
+ /**
19
+ * Closes the dialog with value 1 to signal that the action should be run.
20
+ */
13
21
  confirmAction(): void;
22
+ /**
23
+ * Closes the dialog.
24
+ */
14
25
  cancel(): void;
15
26
  static ɵfac: i0.ɵɵFactoryDeclaration<NgxMatEntityConfirmDialogComponent, never>;
16
27
  static ɵcmp: i0.ɵɵComponentDeclaration<NgxMatEntityConfirmDialogComponent, "ngx-mat-entity-confirm-dialog", never, {}, {}, never, never>;