@kms-ngx-ui/presentational 16.3.0 → 16.3.2

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 (223) hide show
  1. package/jest.config.js +27 -0
  2. package/ng-package.json +13 -0
  3. package/package.json +3 -17
  4. package/src/lib/directives/directives.module.ts +28 -0
  5. package/src/lib/directives/mousewheel.directive.ts +43 -0
  6. package/src/lib/directives/sum-of-height.directive.ts +73 -0
  7. package/src/lib/directives/swipe.directive.ts +193 -0
  8. package/{lib/directives/swipe.model.d.ts → src/lib/directives/swipe.model.ts} +6 -0
  9. package/src/lib/directives/tooltip.directive.spec.ts.BAK +8 -0
  10. package/src/lib/directives/tooltip.directive.ts +121 -0
  11. package/src/lib/kms-ngx-ui-presentational.component.spec.ts +25 -0
  12. package/src/lib/kms-ngx-ui-presentational.component.ts +20 -0
  13. package/src/lib/kms-ngx-ui-presentational.module.ts +124 -0
  14. package/src/lib/kms-ngx-ui-presentational.service.spec.ts +16 -0
  15. package/src/lib/kms-ngx-ui-presentational.service.ts +9 -0
  16. package/src/lib/models/address.model.ts +16 -0
  17. package/src/lib/models/iconSize.enum.ts +17 -0
  18. package/src/lib/models/image-snippet.model.ts +17 -0
  19. package/src/lib/models/is-value.function.ts +20 -0
  20. package/src/lib/models/salutation.enum.ts +6 -0
  21. package/{lib/models/types/attached-file-dto.model.d.ts → src/lib/models/types/attached-file-dto.model.ts} +1 -1
  22. package/{lib/models/types/nullable.type.d.ts → src/lib/models/types/nullable.type.ts} +1 -0
  23. package/src/lib/parent-components/actions.component.ts +43 -0
  24. package/src/lib/parent-components/form-control.component.ts +77 -0
  25. package/src/lib/parent-components/form.component.ts +79 -0
  26. package/src/lib/pipes/custom-pipes.module.ts +48 -0
  27. package/src/lib/pipes/decode-uri.pipe.ts +15 -0
  28. package/src/lib/pipes/encode-uri.pipe.ts +14 -0
  29. package/src/lib/pipes/integer-currency.pipe.ts +22 -0
  30. package/src/lib/pipes/prettyjson.pipe.ts +104 -0
  31. package/src/lib/pipes/safe-html.pipe.ts +17 -0
  32. package/src/lib/pipes/safe-resource-url.pipe.ts +17 -0
  33. package/src/lib/pipes/safe-style.pipe.ts +17 -0
  34. package/src/lib/pipes/safe-url.pipe.ts +17 -0
  35. package/src/lib/pipes/to-number.pipe.ts +19 -0
  36. package/src/lib/pipes/trim.pipe.ts +16 -0
  37. package/src/lib/pipes/typeof.pipe.ts +10 -0
  38. package/src/lib/services/viewport.service.ts +241 -0
  39. package/src/lib/ui/back-to-top/back-to-top.component.html +7 -0
  40. package/src/lib/ui/back-to-top/back-to-top.component.ts +43 -0
  41. package/src/lib/ui/back-to-top/back-to-top.stories.ts +19 -0
  42. package/src/lib/ui/button-with-confirm-dialog/button-response-types.enum.ts +4 -0
  43. package/src/lib/ui/button-with-confirm-dialog/button-with-confirm-dialog.component.html +8 -0
  44. package/src/lib/ui/button-with-confirm-dialog/button-with-confirm-dialog.component.spec.ts.BAK +25 -0
  45. package/src/lib/ui/button-with-confirm-dialog/button-with-confirm-dialog.component.ts +55 -0
  46. package/src/lib/ui/button-with-confirm-dialog/button-with-confirm-dialog.stories.ts +21 -0
  47. package/{lib/ui/button-with-confirm-dialog/dialog-data.model.d.ts → src/lib/ui/button-with-confirm-dialog/dialog-data.model.ts} +4 -3
  48. package/src/lib/ui/checkbox/checkbox.component.html +15 -0
  49. package/src/lib/ui/checkbox/checkbox.component.stories.ts +19 -0
  50. package/src/lib/ui/checkbox/checkbox.component.ts +75 -0
  51. package/src/lib/ui/color-input/color-input.component.html +11 -0
  52. package/src/lib/ui/color-input/color-input.component.spec.ts +44 -0
  53. package/src/lib/ui/color-input/color-input.component.ts +67 -0
  54. package/src/lib/ui/dropdown-from-data/dropdown-from-data.component.html +23 -0
  55. package/src/lib/ui/dropdown-from-data/dropdown-from-data.component.ts +174 -0
  56. package/src/lib/ui/enum-radiogroup/enum-radiogroup.component.html +6 -0
  57. package/src/lib/ui/enum-radiogroup/enum-radiogroup.component.spec.ts.BAK +25 -0
  58. package/src/lib/ui/enum-radiogroup/enum-radiogroup.component.ts +43 -0
  59. package/src/lib/ui/file-input/file-input.component.html +45 -0
  60. package/src/lib/ui/file-input/file-input.component.spec.ts.BAK +25 -0
  61. package/src/lib/ui/file-input/file-input.component.ts +236 -0
  62. package/src/lib/ui/flyout/flyout.component.html +35 -0
  63. package/src/lib/ui/flyout/flyout.component.spec.ts.BAK +30 -0
  64. package/src/lib/ui/flyout/flyout.component.ts +95 -0
  65. package/src/lib/ui/generic-dialog/generic-dialog.component.html +24 -0
  66. package/src/lib/ui/generic-dialog/generic-dialog.component.spec.ts.BAK +43 -0
  67. package/src/lib/ui/generic-dialog/generic-dialog.component.ts +54 -0
  68. package/src/lib/ui/icon/icon.component.html +22 -0
  69. package/src/lib/ui/icon/icon.component.spec.ts.BAK +31 -0
  70. package/src/lib/ui/icon/icon.component.ts +67 -0
  71. package/src/lib/ui/icon/iconSize.enum.ts +17 -0
  72. package/src/lib/ui/image-slider/image-slider.component.html +54 -0
  73. package/src/lib/ui/image-slider/image-slider.component.ts +205 -0
  74. package/src/lib/ui/kms-accordion-item/kms-accordion-item.component.html +22 -0
  75. package/src/lib/ui/kms-accordion-item/kms-accordion-item.component.spec.ts +61 -0
  76. package/src/lib/ui/kms-accordion-item/kms-accordion-item.component.ts +32 -0
  77. package/src/lib/ui/loader/loader.component.html +3 -0
  78. package/src/lib/ui/loader/loader.component.spec.ts.BAK +26 -0
  79. package/src/lib/ui/loader/loader.component.ts +16 -0
  80. package/src/lib/ui/map/map.component.html +18 -0
  81. package/src/lib/ui/map/map.component.spec.ts.BAK +31 -0
  82. package/src/lib/ui/map/map.component.ts +138 -0
  83. package/src/lib/ui/radiobutton/radiobutton.component.html +42 -0
  84. package/src/lib/ui/radiobutton/radiobutton.component.ts +71 -0
  85. package/src/lib/ui/salutation-dropdown/salutation-dropdown.component.html +9 -0
  86. package/src/lib/ui/salutation-dropdown/salutation-dropdown.component.spec.ts.BAK +26 -0
  87. package/src/lib/ui/salutation-dropdown/salutation-dropdown.component.ts +48 -0
  88. package/src/lib/ui/salutation-radiogroup/salutation-radiogroup.component.html +13 -0
  89. package/src/lib/ui/salutation-radiogroup/salutation-radiogroup.component.spec.ts.BAK +25 -0
  90. package/src/lib/ui/salutation-radiogroup/salutation-radiogroup.component.ts +41 -0
  91. package/src/lib/ui/time-input/time-input.component.html +5 -0
  92. package/src/lib/ui/time-input/time-input.component.spec.ts +28 -0
  93. package/src/lib/ui/time-input/time-input.component.ts +88 -0
  94. package/src/lib/ui/tooltip/tooltip.component.html +1 -0
  95. package/src/lib/ui/tooltip/tooltip.component.spec.ts.BAK +26 -0
  96. package/src/lib/ui/tooltip/tooltip.component.ts +10 -0
  97. package/src/lib/ui/tooltip-icon/tooltip-icon.component.html +11 -0
  98. package/src/lib/ui/tooltip-icon/tooltip-icon.component.spec.ts.BAK +28 -0
  99. package/src/lib/ui/tooltip-icon/tooltip-icon.component.ts +19 -0
  100. package/src/lib/ui/yes-no-radiogroup/yes-no-radiogroup.component.html +7 -0
  101. package/src/lib/ui/yes-no-radiogroup/yes-no-radiogroup.component.scss +17 -0
  102. package/src/lib/ui/yes-no-radiogroup/yes-no-radiogroup.component.spec.ts.BAK +25 -0
  103. package/src/lib/ui/yes-no-radiogroup/yes-no-radiogroup.component.ts +79 -0
  104. package/{public-api.d.ts → src/public-api.ts} +8 -0
  105. package/src/styles/styles.scss +3 -1
  106. package/src/test-setup.ts +2 -0
  107. package/tsconfig.lib.json +26 -0
  108. package/tsconfig.lib.prod.json +10 -0
  109. package/tsconfig.spec.json +17 -0
  110. package/tslint.json +17 -0
  111. package/esm2022/kms-ngx-ui-presentational.mjs +0 -5
  112. package/esm2022/lib/directives/directives.module.mjs +0 -40
  113. package/esm2022/lib/directives/mousewheel.directive.mjs +0 -56
  114. package/esm2022/lib/directives/sum-of-height.directive.mjs +0 -74
  115. package/esm2022/lib/directives/swipe.directive.mjs +0 -183
  116. package/esm2022/lib/directives/swipe.model.mjs +0 -5
  117. package/esm2022/lib/directives/tooltip.directive.mjs +0 -144
  118. package/esm2022/lib/kms-ngx-ui-presentational.component.mjs +0 -22
  119. package/esm2022/lib/kms-ngx-ui-presentational.module.mjs +0 -211
  120. package/esm2022/lib/kms-ngx-ui-presentational.service.mjs +0 -14
  121. package/esm2022/lib/models/address.model.mjs +0 -6
  122. package/esm2022/lib/models/iconSize.enum.mjs +0 -17
  123. package/esm2022/lib/models/image-snippet.model.mjs +0 -18
  124. package/esm2022/lib/models/index.mjs +0 -5
  125. package/esm2022/lib/models/is-value.function.mjs +0 -17
  126. package/esm2022/lib/models/salutation.enum.mjs +0 -8
  127. package/esm2022/lib/models/types/attached-file-dto.model.mjs +0 -6
  128. package/esm2022/lib/models/types/nullable.type.mjs +0 -5
  129. package/esm2022/lib/parent-components/actions.component.mjs +0 -56
  130. package/esm2022/lib/parent-components/form-control.component.mjs +0 -75
  131. package/esm2022/lib/parent-components/form.component.mjs +0 -78
  132. package/esm2022/lib/pipes/custom-pipes.module.mjs +0 -71
  133. package/esm2022/lib/pipes/decode-uri.pipe.mjs +0 -19
  134. package/esm2022/lib/pipes/encode-uri.pipe.mjs +0 -19
  135. package/esm2022/lib/pipes/integer-currency.pipe.mjs +0 -27
  136. package/esm2022/lib/pipes/safe-html.pipe.mjs +0 -23
  137. package/esm2022/lib/pipes/safe-resource-url.pipe.mjs +0 -23
  138. package/esm2022/lib/pipes/safe-style.pipe.mjs +0 -23
  139. package/esm2022/lib/pipes/safe-url.pipe.mjs +0 -23
  140. package/esm2022/lib/pipes/to-number.pipe.mjs +0 -23
  141. package/esm2022/lib/pipes/trim.pipe.mjs +0 -20
  142. package/esm2022/lib/pipes/typeof.pipe.mjs +0 -16
  143. package/esm2022/lib/services/viewport.service.mjs +0 -216
  144. package/esm2022/lib/ui/back-to-top/back-to-top.component.mjs +0 -49
  145. package/esm2022/lib/ui/button-with-confirm-dialog/button-response-types.enum.mjs +0 -6
  146. package/esm2022/lib/ui/button-with-confirm-dialog/button-with-confirm-dialog.component.mjs +0 -58
  147. package/esm2022/lib/ui/button-with-confirm-dialog/dialog-data.model.mjs +0 -2
  148. package/esm2022/lib/ui/checkbox/checkbox.component.mjs +0 -71
  149. package/esm2022/lib/ui/color-input/color-input.component.mjs +0 -76
  150. package/esm2022/lib/ui/dropdown-from-data/dropdown-from-data.component.mjs +0 -157
  151. package/esm2022/lib/ui/enum-radiogroup/enum-radiogroup.component.mjs +0 -53
  152. package/esm2022/lib/ui/file-input/file-input.component.mjs +0 -232
  153. package/esm2022/lib/ui/flyout/flyout.component.mjs +0 -119
  154. package/esm2022/lib/ui/generic-dialog/generic-dialog.component.mjs +0 -55
  155. package/esm2022/lib/ui/icon/icon.component.mjs +0 -48
  156. package/esm2022/lib/ui/icon/iconSize.enum.mjs +0 -17
  157. package/esm2022/lib/ui/image-slider/image-slider.component.mjs +0 -189
  158. package/esm2022/lib/ui/kms-accordion-item/kms-accordion-item.component.mjs +0 -40
  159. package/esm2022/lib/ui/loader/loader.component.mjs +0 -21
  160. package/esm2022/lib/ui/map/map.component.mjs +0 -116
  161. package/esm2022/lib/ui/radiobutton/radiobutton.component.mjs +0 -73
  162. package/esm2022/lib/ui/salutation-dropdown/salutation-dropdown.component.mjs +0 -55
  163. package/esm2022/lib/ui/salutation-radiogroup/salutation-radiogroup.component.mjs +0 -49
  164. package/esm2022/lib/ui/time-input/time-input.component.mjs +0 -83
  165. package/esm2022/lib/ui/tooltip/tooltip.component.mjs +0 -16
  166. package/esm2022/lib/ui/tooltip-icon/tooltip-icon.component.mjs +0 -35
  167. package/esm2022/lib/ui/yes-no-radiogroup/yes-no-radiogroup.component.mjs +0 -82
  168. package/esm2022/public-api.mjs +0 -49
  169. package/fesm2022/kms-ngx-ui-presentational.mjs +0 -3003
  170. package/fesm2022/kms-ngx-ui-presentational.mjs.map +0 -1
  171. package/index.d.ts +0 -5
  172. package/lib/directives/directives.module.d.ts +0 -11
  173. package/lib/directives/mousewheel.directive.d.ts +0 -15
  174. package/lib/directives/sum-of-height.directive.d.ts +0 -31
  175. package/lib/directives/swipe.directive.d.ts +0 -45
  176. package/lib/directives/tooltip.directive.d.ts +0 -29
  177. package/lib/kms-ngx-ui-presentational.component.d.ts +0 -8
  178. package/lib/kms-ngx-ui-presentational.module.d.ts +0 -47
  179. package/lib/kms-ngx-ui-presentational.service.d.ts +0 -6
  180. package/lib/models/address.model.d.ts +0 -14
  181. package/lib/models/iconSize.enum.d.ts +0 -15
  182. package/lib/models/image-snippet.model.d.ts +0 -15
  183. package/lib/models/is-value.function.d.ts +0 -9
  184. package/lib/models/salutation.enum.d.ts +0 -5
  185. package/lib/parent-components/actions.component.d.ts +0 -31
  186. package/lib/parent-components/form-control.component.d.ts +0 -27
  187. package/lib/parent-components/form.component.d.ts +0 -34
  188. package/lib/pipes/custom-pipes.module.d.ts +0 -17
  189. package/lib/pipes/decode-uri.pipe.d.ts +0 -10
  190. package/lib/pipes/encode-uri.pipe.d.ts +0 -10
  191. package/lib/pipes/integer-currency.pipe.d.ts +0 -13
  192. package/lib/pipes/safe-html.pipe.d.ts +0 -13
  193. package/lib/pipes/safe-resource-url.pipe.d.ts +0 -13
  194. package/lib/pipes/safe-style.pipe.d.ts +0 -13
  195. package/lib/pipes/safe-url.pipe.d.ts +0 -13
  196. package/lib/pipes/to-number.pipe.d.ts +0 -10
  197. package/lib/pipes/trim.pipe.d.ts +0 -10
  198. package/lib/pipes/typeof.pipe.d.ts +0 -7
  199. package/lib/services/viewport.service.d.ts +0 -74
  200. package/lib/ui/back-to-top/back-to-top.component.d.ts +0 -10
  201. package/lib/ui/button-with-confirm-dialog/button-response-types.enum.d.ts +0 -4
  202. package/lib/ui/button-with-confirm-dialog/button-with-confirm-dialog.component.d.ts +0 -19
  203. package/lib/ui/checkbox/checkbox.component.d.ts +0 -31
  204. package/lib/ui/color-input/color-input.component.d.ts +0 -19
  205. package/lib/ui/dropdown-from-data/dropdown-from-data.component.d.ts +0 -55
  206. package/lib/ui/enum-radiogroup/enum-radiogroup.component.d.ts +0 -17
  207. package/lib/ui/file-input/file-input.component.d.ts +0 -89
  208. package/lib/ui/flyout/flyout.component.d.ts +0 -32
  209. package/lib/ui/generic-dialog/generic-dialog.component.d.ts +0 -26
  210. package/lib/ui/icon/icon.component.d.ts +0 -42
  211. package/lib/ui/icon/iconSize.enum.d.ts +0 -15
  212. package/lib/ui/image-slider/image-slider.component.d.ts +0 -62
  213. package/lib/ui/kms-accordion-item/kms-accordion-item.component.d.ts +0 -22
  214. package/lib/ui/loader/loader.component.d.ts +0 -9
  215. package/lib/ui/map/map.component.d.ts +0 -71
  216. package/lib/ui/radiobutton/radiobutton.component.d.ts +0 -26
  217. package/lib/ui/salutation-dropdown/salutation-dropdown.component.d.ts +0 -17
  218. package/lib/ui/salutation-radiogroup/salutation-radiogroup.component.d.ts +0 -15
  219. package/lib/ui/time-input/time-input.component.d.ts +0 -22
  220. package/lib/ui/tooltip/tooltip.component.d.ts +0 -6
  221. package/lib/ui/tooltip-icon/tooltip-icon.component.d.ts +0 -13
  222. package/lib/ui/yes-no-radiogroup/yes-no-radiogroup.component.d.ts +0 -27
  223. /package/{lib/models/index.d.ts → src/lib/models/index.ts} +0 -0
package/jest.config.js ADDED
@@ -0,0 +1,27 @@
1
+ module.exports = {
2
+ displayName: "kms-ngx-ui-presentational",
3
+ preset: "../../jest.preset.js",
4
+ setupFilesAfterEnv: ["<rootDir>/src/test-setup.ts"],
5
+ globals: {
6
+ "ts-jest": {
7
+ tsconfig: "<rootDir>/tsconfig.spec.json",
8
+ stringifyContentPathRegex: "\\.(html|svg)$",
9
+ },
10
+ },
11
+ coverageDirectory: "../../coverage/libs/kms-ngx-ui-presentational",
12
+ transform: { "^.+.(ts|mjs|js|html)$": "jest-preset-angular" },
13
+ // transformIgnorePatterns: ["node_modules/(?!.*.mjs$)"],
14
+ // resolver: "@nrwl/jest/plugins/resolver",
15
+ testEnvironment: "jsdom",
16
+ reporters: [
17
+ "default",
18
+ ["jest-junit", { outputName: "kms-ngx-ui-presentational-test-report.xml" }],
19
+ ],
20
+ coverageReporters: ["lcovonly"],
21
+ collectCoverageFrom: ["src/**/*.{ts,html}"],
22
+ snapshotSerializers: [
23
+ "jest-preset-angular/build/serializers/no-ng-attributes",
24
+ "jest-preset-angular/build/serializers/ng-snapshot",
25
+ "jest-preset-angular/build/serializers/html-comment",
26
+ ],
27
+ };
@@ -0,0 +1,13 @@
1
+ {
2
+ "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3
+ "dest": "../../dist/@kms-ngx-ui/presentational",
4
+ "lib": {
5
+ "entryFile": "src/public-api.ts"
6
+ },
7
+ "assets": [
8
+ "./src/styles/*.*",
9
+ "./assets/**/styles.css",
10
+ "./src/lib/**/*.scss"
11
+ ],
12
+ "allowedNonPeerDependencies": ["."]
13
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kms-ngx-ui/presentational",
3
- "version": "16.3.0",
3
+ "version": "16.3.2",
4
4
  "peerDependencies": {
5
5
  "@angular/cdk": "16.2.12",
6
6
  "@angular/common": "16.2.12",
@@ -14,19 +14,5 @@
14
14
  "dependencies": {
15
15
  "ngx-translate": "0.0.1-security",
16
16
  "tslib": "^2.4.1"
17
- },
18
- "module": "fesm2022/kms-ngx-ui-presentational.mjs",
19
- "typings": "index.d.ts",
20
- "exports": {
21
- "./package.json": {
22
- "default": "./package.json"
23
- },
24
- ".": {
25
- "types": "./index.d.ts",
26
- "esm2022": "./esm2022/kms-ngx-ui-presentational.mjs",
27
- "esm": "./esm2022/kms-ngx-ui-presentational.mjs",
28
- "default": "./fesm2022/kms-ngx-ui-presentational.mjs"
29
- }
30
- },
31
- "sideEffects": false
32
- }
17
+ }
18
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @copyright KMS GmbH
3
+ */
4
+
5
+ import { CommonModule } from '@angular/common';
6
+ import { NgModule } from '@angular/core';
7
+
8
+ import { MouseWheelDirective } from './mousewheel.directive';
9
+ import { GetMaxHeightDirective } from './sum-of-height.directive';
10
+ import { SwipeDirective } from './swipe.directive';
11
+ import { TooltipDirective } from './tooltip.directive';
12
+
13
+ @NgModule({
14
+ declarations: [
15
+ SwipeDirective,
16
+ MouseWheelDirective,
17
+ GetMaxHeightDirective,
18
+ TooltipDirective,
19
+ ],
20
+ imports: [CommonModule],
21
+ exports: [
22
+ SwipeDirective,
23
+ MouseWheelDirective,
24
+ GetMaxHeightDirective,
25
+ TooltipDirective,
26
+ ],
27
+ })
28
+ export class DirectivesModule {}
@@ -0,0 +1,43 @@
1
+ /*!
2
+ * @copyright FLYACTS GmbH 2019
3
+ */
4
+
5
+ import { Directive, EventEmitter, HostListener, Output } from '@angular/core';
6
+
7
+ @Directive({ selector: '[mouseWheel]' })
8
+ export class MouseWheelDirective {
9
+ @Output() mouseWheelUp = new EventEmitter();
10
+ @Output() mouseWheelDown = new EventEmitter();
11
+
12
+
13
+ @HostListener('mousewheel', ['$event']) onMouseWheelChrome(event: any) {
14
+ this.mouseWheelFunc(event);
15
+ }
16
+
17
+
18
+ @HostListener('DOMMouseScroll', ['$event']) onMouseWheelFirefox(event: any) {
19
+ this.mouseWheelFunc(event);
20
+ }
21
+
22
+ @HostListener('onmousewheel', ['$event']) onMouseWheelIE(event: any) {
23
+ this.mouseWheelFunc(event);
24
+ }
25
+
26
+
27
+ mouseWheelFunc(event: any) {
28
+ event = window.event || event; // old IE support
29
+
30
+ const delta = Math.max(-1, Math.min(1, (event.wheelDelta || -event.detail)));
31
+ if (delta > 0) {
32
+ this.mouseWheelUp.emit(event);
33
+ } else if (delta < 0) {
34
+ this.mouseWheelDown.emit(event);
35
+ }
36
+ // for IE
37
+ event.returnValue = false;
38
+ // for Chrome and Firefox
39
+ if (event.preventDefault) {
40
+ event.preventDefault();
41
+ }
42
+ }
43
+ }
@@ -0,0 +1,73 @@
1
+ /*!
2
+ * @copyright FLYACTS GmbH 2019
3
+ */
4
+
5
+ // ng
6
+ import { AfterContentChecked, Directive, ElementRef, EventEmitter, Input, Output } from '@angular/core';
7
+
8
+ /**
9
+ * Directive to calc the height of all inner elements
10
+ */
11
+ @Directive({
12
+
13
+ selector: '[getMaxHeight]',
14
+ })
15
+ export class GetMaxHeightDirective implements AfterContentChecked {
16
+ /**
17
+ * CSS class name of the child items (markup elements) that should be checked for their height.
18
+ * This is mandatory.
19
+ */
20
+ @Input('getMaxHeight') cssClassName = '';
21
+
22
+ /**
23
+ * Event that will pass the height of the tallest child inside the container.
24
+ * Useful to calculate the target height of containers with different content (like accordion) for animations.
25
+ */
26
+ @Output() public maxHeightChanged: EventEmitter<number> = new EventEmitter();
27
+
28
+ /**
29
+ * Event that will pass the complete sum of all height values from each child.
30
+ * Useful to calculate the full target height of a container (like dropdown) for animations.
31
+ */
32
+ @Output() public sumOfHeight: EventEmitter<number> = new EventEmitter();
33
+
34
+ constructor(private el: ElementRef) {}
35
+
36
+ ngAfterContentChecked(): void {
37
+ this.checkHeightOfChildren(this.el.nativeElement, this.cssClassName);
38
+ }
39
+
40
+ private checkHeightOfChildren(parent: HTMLElement, cssClassName: string) {
41
+ if (!parent) {
42
+ return;
43
+ }
44
+
45
+ // find all the child elements with the selected class name
46
+ const children = parent.getElementsByClassName(cssClassName);
47
+
48
+ // failsafe
49
+ if (!children) {
50
+ return;
51
+ }
52
+
53
+ // get all the child elements heights
54
+ const itemHeights = Array.from(children).map((x) => x.getBoundingClientRect().height);
55
+
56
+ // failsafe
57
+ if (itemHeights.length === 0) {
58
+ return;
59
+ }
60
+
61
+ // find out the tallest element
62
+ const maxHeight = itemHeights.reduce((prev, curr) => {
63
+ return curr > prev ? curr : prev;
64
+ }, 0);
65
+
66
+ // get sum of heights
67
+ const sumOfHeight = itemHeights.reduce((pv, cv) => pv + cv, 0);
68
+
69
+ // inform
70
+ this.maxHeightChanged.emit(maxHeight);
71
+ this.sumOfHeight.emit(sumOfHeight);
72
+ }
73
+ }
@@ -0,0 +1,193 @@
1
+ /*!
2
+ * @copyright FLYACTS GmbH 2019
3
+ */
4
+
5
+ import { Directive, EventEmitter, HostListener, Input, Output } from '@angular/core';
6
+
7
+ import { SwipeMoveEvent, SwipeOptions, SwipeReleaseEvent } from './swipe.model';
8
+
9
+ @Directive({
10
+ selector: '[swipeDirective]',
11
+ })
12
+ export class SwipeDirective {
13
+ /**
14
+ * Output Event that is emitted during swipe process (mouse move or touch move event).
15
+ * Can be used for calculation purposes.
16
+ */
17
+ @Output() public moveEvent = new EventEmitter<SwipeMoveEvent>();
18
+
19
+ /**
20
+ * Output Event that is emitted when swipe process end (mouse up or touch end event).
21
+ * Can be used for calculation purposes.
22
+ */
23
+ @Output() public releaseEvent = new EventEmitter<SwipeReleaseEvent>();
24
+
25
+ private _swipeOptions: SwipeOptions | undefined;
26
+
27
+ private _moveEventData: SwipeMoveEvent | undefined;
28
+ private _startPosition = -1;
29
+
30
+ private _lastPosX = 0;
31
+
32
+ private _thresholdWasReached = false;
33
+
34
+ private _isMobile: boolean | undefined;
35
+
36
+ private _timeStart = 0;
37
+
38
+ /**
39
+ * Needed config that defines swipe behaviour.
40
+ * @param options SwipeOptions
41
+ */
42
+ @Input('swipeDirective')
43
+ set config(options: SwipeOptions) {
44
+ if (options) {
45
+ this._swipeOptions = options;
46
+ }
47
+ }
48
+
49
+ @HostListener('mousedown', ['$event'])
50
+ @HostListener('touchstart', ['$event'])
51
+ onMouseDown(event: any) {
52
+ this.calculateStartPosition(event);
53
+ }
54
+
55
+ @HostListener('mousemove', ['$event'])
56
+ @HostListener('touchmove', ['$event'])
57
+ onMove(event: any) {
58
+ this.move(event);
59
+ }
60
+
61
+ @HostListener('mouseup', ['$event'])
62
+ @HostListener('mouseleave', ['$event'])
63
+ @HostListener('touchend', ['$event'])
64
+ onRelease(event: any) {
65
+ this.release(event);
66
+ this.reset();
67
+ }
68
+
69
+ // ** PRIVATE ** //
70
+
71
+ /**
72
+ * Function checks if the current moving delta is inside the defined threshold.
73
+ * Sets the flag to true if the threshold was reached once.
74
+ */
75
+ private checkThreshold(moveEvent: SwipeMoveEvent) {
76
+ const percentage = this._swipeOptions && this._swipeOptions.swipeThresholdType === '%';
77
+
78
+ if (!percentage && this._swipeOptions && moveEvent.swipeDistanceTotal < this._swipeOptions.swipeThreshold) {
79
+ return;
80
+ } else if (
81
+ percentage &&
82
+ this._swipeOptions &&
83
+ moveEvent.swipeDistancePercentage < this._swipeOptions.swipeThreshold / 100
84
+ ) {
85
+ return;
86
+ } else {
87
+ this._thresholdWasReached = true;
88
+ }
89
+ }
90
+
91
+ private calculateStartPosition(event?: any) {
92
+ // detect if touch or click
93
+ this._isMobile = event.type === 'touchstart';
94
+
95
+ // save start position
96
+
97
+ if (this._swipeOptions && this._swipeOptions.swipeLocalPosition) {
98
+ if (this._isMobile) {
99
+ const touch: Touch = event.touches[0];
100
+ this._startPosition = this._swipeOptions.swipeLocalPosition ? touch.clientX : touch.pageX;
101
+ } else {
102
+ this._startPosition = this._swipeOptions.swipeLocalPosition ? event.offsetX : event.pageX;
103
+ }
104
+ }
105
+
106
+ this._lastPosX = this._startPosition;
107
+ this._timeStart = event.timeStamp;
108
+ this._thresholdWasReached = false;
109
+ }
110
+
111
+ private move(event: any) {
112
+ // failsafe
113
+ if (typeof event === 'undefined') {
114
+ return;
115
+ }
116
+
117
+ let posX = 0;
118
+
119
+ if (this._swipeOptions) {
120
+ if (this._isMobile && event.type === 'touchmove') {
121
+ const touch: Touch = event.touches[0];
122
+ posX = this._swipeOptions.swipeLocalPosition ? touch.clientX : touch.pageX;
123
+ } else {
124
+ posX = this._swipeOptions.swipeLocalPosition ? event.offsetX : event.pageX;
125
+ }
126
+ }
127
+
128
+ const offsetPerFrame: number = posX - this._lastPosX;
129
+ const swipeDistanceTotal: number = Math.abs(posX - this._startPosition);
130
+ const swipeDistancePercentage: number = Math.abs(swipeDistanceTotal / event.target.clientWidth);
131
+ const timeDuration: number = Math.abs(event.timeStamp - this._timeStart);
132
+
133
+ let direction: number;
134
+ let speed: number = 1 - swipeDistanceTotal / timeDuration;
135
+ speed = Math.max(0.1, speed);
136
+
137
+ if (posX - this._startPosition > 0) {
138
+ direction = 1; // a.k.a LTR
139
+ } else {
140
+ direction = -1; // a.k.a RTL
141
+ }
142
+
143
+ this._moveEventData = {
144
+ position: posX,
145
+ offsetPerFrame: offsetPerFrame,
146
+ swipeDistanceTotal: swipeDistanceTotal,
147
+ swipeDistancePercentage: swipeDistancePercentage,
148
+ direction: direction,
149
+ speed: speed,
150
+ thresholdWasReached: this._thresholdWasReached,
151
+ };
152
+
153
+ this.checkThreshold(this._moveEventData);
154
+
155
+ // update move delta
156
+ this._lastPosX = posX;
157
+
158
+ // inform
159
+ this.moveEvent.emit(this._moveEventData);
160
+ }
161
+
162
+ private release(event: any) {
163
+ // case: just a click/touch
164
+
165
+ if (!this._moveEventData) {
166
+ return;
167
+ }
168
+
169
+ const releaseEventData: SwipeReleaseEvent = {
170
+ thresholdWasReached: this._thresholdWasReached,
171
+ direction: this._moveEventData.direction,
172
+ speed: this._moveEventData.speed,
173
+ easingType: this.getEasingCurve(this._moveEventData.speed),
174
+ target: event.currentTarget,
175
+ };
176
+
177
+ // inform
178
+ this.releaseEvent.emit(releaseEventData);
179
+ }
180
+
181
+ private getEasingCurve(speed: number): string {
182
+ return speed > 0.5 ? 'ease-in' : 'ease-out';
183
+ }
184
+
185
+ private reset() {
186
+ this._startPosition = -1;
187
+ this._thresholdWasReached = false;
188
+
189
+ if (this._moveEventData) {
190
+ this._moveEventData = undefined;
191
+ }
192
+ }
193
+ }
@@ -1,6 +1,7 @@
1
1
  /*!
2
2
  * @copyright FLYACTS GmbH 2019
3
3
  */
4
+
4
5
  /**
5
6
  * Input behaviour options
6
7
  */
@@ -10,6 +11,7 @@ export interface SwipeOptions {
10
11
  * Example: 500px or 10% (depends on swipeThresholdType)
11
12
  */
12
13
  swipeThreshold: number;
14
+
13
15
  /**
14
16
  * Allowed values: '%' or 'px'
15
17
  * Defines together with the value of swipeThreshold the way how the threshold is calculated:
@@ -19,12 +21,14 @@ export interface SwipeOptions {
19
21
  * for instance skip to next slide.
20
22
  */
21
23
  swipeThresholdType: string;
24
+
22
25
  /**
23
26
  * note: Defines if the local position of the element should be used for calculation or the global.
24
27
  * For a slider the global is needed.
25
28
  */
26
29
  swipeLocalPosition: boolean;
27
30
  }
31
+
28
32
  /**
29
33
  * Swipe move event information
30
34
  */
@@ -37,6 +41,7 @@ export interface SwipeMoveEvent {
37
41
  speed: number;
38
42
  thresholdWasReached: boolean;
39
43
  }
44
+
40
45
  /**
41
46
  * Swipe release event information
42
47
  */
@@ -45,5 +50,6 @@ export interface SwipeReleaseEvent {
45
50
  direction: number;
46
51
  speed: number;
47
52
  easingType: string;
53
+
48
54
  target: any;
49
55
  }
@@ -0,0 +1,8 @@
1
+ import { describe, it } from '@jest/globals';
2
+
3
+ describe('Directive: Tooltip', () => {
4
+ it('should create an instance', () => {
5
+ // const directive = new TooltipDirective();
6
+ // expect(directive).toBeTruthy();
7
+ });
8
+ });
@@ -0,0 +1,121 @@
1
+ import { Directive, Input, ElementRef, HostListener, Renderer2 } from '@angular/core';
2
+
3
+ @Directive({
4
+ selector: '[kmsTooltip]'
5
+ })
6
+ export class TooltipDirective {
7
+ @Input('tooltipTitle') tooltipTitle = "";
8
+ @Input('tooltipText') tooltipText = "";
9
+ @Input('tooltipLinkText') tooltipLinkText = "";
10
+ @Input('tooltipLinkUrl') tooltipLinkUrl = "";
11
+ @Input('tooltipPlacement') tooltipPlacement = "bottom";
12
+ @Input('tooltipDelay') tooltipDelay = 1000;
13
+ @Input('tooltipPlaceIntoHost') tooltipPlaceIntoHost = false;
14
+ @Input('tooltipOnlyonclick') tooltipOnlyonclick = false;
15
+
16
+ tooltipElem?: HTMLElement | undefined;
17
+ tooltipLinkElem?: HTMLElement | undefined;
18
+ tooltipTitleElem?: HTMLElement | undefined;
19
+ tooltipTextElem?: HTMLElement | undefined;
20
+ offset = 0;
21
+
22
+ constructor(private el: ElementRef, private renderer: Renderer2) {
23
+
24
+ }
25
+
26
+ @HostListener('mouseenter') onMouseEnter() {
27
+ if (!this.tooltipOnlyonclick) { this.show(); }
28
+ }
29
+
30
+ @HostListener('click') onClick() {
31
+ if (this.tooltipOnlyonclick) { this.show(); }
32
+ }
33
+
34
+ @HostListener('mouseleave') onMouseLeave() {
35
+ if (this.tooltipElem) { this.hide(); }
36
+ }
37
+
38
+ show() {
39
+ if (!this.tooltipElem){
40
+ this.create();
41
+ this.setPosition();
42
+ }
43
+ this.renderer.addClass(this.tooltipElem, 'tooltip-show');
44
+ }
45
+
46
+ hide() {
47
+ this.renderer.removeClass(this.tooltipElem, 'tooltip-show');
48
+ window.setTimeout(() => {
49
+ }, this.tooltipDelay);
50
+ }
51
+
52
+ create() {
53
+ this.tooltipElem = this.renderer.createElement('kms-tooltip-element');
54
+
55
+ this.tooltipTitleElem = this.renderer.createElement('b');
56
+ this.renderer.appendChild(this.tooltipTitleElem, this.renderer.createText(this.tooltipTitle));
57
+ this.renderer.appendChild(this.tooltipElem, this.tooltipTitleElem);
58
+
59
+ this.tooltipTextElem = this.renderer.createElement('div');
60
+ this.renderer.appendChild(this.tooltipTextElem, this.renderer.createText(this.tooltipText));
61
+ this.renderer.appendChild(this.tooltipElem, this.tooltipTextElem);
62
+
63
+ this.tooltipLinkElem = this.renderer.createElement('a');
64
+ this.renderer.setAttribute(this.tooltipLinkElem, 'href', this.tooltipLinkUrl);
65
+ this.renderer.appendChild(this.tooltipLinkElem, this.renderer.createText(this.tooltipLinkText));
66
+ this.renderer.appendChild(this.tooltipElem, this.tooltipLinkElem);
67
+
68
+ if(this.tooltipPlaceIntoHost){
69
+ this.renderer.appendChild(this.el.nativeElement, this.tooltipElem);
70
+ }else{
71
+ this.renderer.appendChild(document.body, this.tooltipElem);
72
+ }
73
+
74
+ this.renderer.addClass(this.tooltipElem, 'tooltip');
75
+ this.renderer.addClass(this.tooltipElem, `tooltip-${this.tooltipPlacement}`);
76
+ this.renderer.setStyle(this.tooltipElem, '-webkit-transition', `opacity ${this.tooltipDelay}ms`);
77
+ this.renderer.setStyle(this.tooltipElem, '-moz-transition', `opacity ${this.tooltipDelay}ms`);
78
+ this.renderer.setStyle(this.tooltipElem, '-o-transition', `opacity ${this.tooltipDelay}ms`);
79
+ this.renderer.setStyle(this.tooltipElem, 'transition', `opacity ${this.tooltipDelay}ms`);
80
+ }
81
+
82
+ setPosition() {
83
+ if(this.tooltipElem){
84
+ const hostPos = this.el.nativeElement.getBoundingClientRect();
85
+ const tooltipPos = this.tooltipElem.getBoundingClientRect();
86
+
87
+ let top, left;
88
+
89
+ if(this.tooltipPlaceIntoHost){
90
+ left = 0;
91
+ top = hostPos.height;
92
+ } else {
93
+ const scrollPos = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
94
+
95
+ if (this.tooltipPlacement === 'top') {
96
+ top = hostPos.top - tooltipPos.height - this.offset;
97
+ left = hostPos.left + (hostPos.width - tooltipPos.width) / 2;
98
+ }
99
+
100
+ if (!this.tooltipPlacement || this.tooltipPlacement === 'bottom') {
101
+ top = hostPos.bottom + this.offset;
102
+ left = hostPos.left + (hostPos.width - tooltipPos.width) / 2;
103
+ }
104
+
105
+ if (this.tooltipPlacement === 'left') {
106
+ top = hostPos.top + (hostPos.height - tooltipPos.height) / 2;
107
+ left = hostPos.left - tooltipPos.width - this.offset;
108
+ }
109
+
110
+ if (this.tooltipPlacement === 'right') {
111
+ top = hostPos.top + (hostPos.height - tooltipPos.height) / 2;
112
+ left = hostPos.right + this.offset;
113
+ }
114
+ top += scrollPos;
115
+ }
116
+
117
+ this.renderer.setStyle(this.tooltipElem, 'top', `${top}px`);
118
+ this.renderer.setStyle(this.tooltipElem, 'left', `${left}px`);
119
+ }
120
+ }
121
+ }
@@ -0,0 +1,25 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { KmsUiPresentationalComponent } from './kms-ngx-ui-presentational.component';
4
+
5
+ describe('KmsUiPresentationalComponent', () => {
6
+ let component: KmsUiPresentationalComponent;
7
+ let fixture: ComponentFixture<KmsUiPresentationalComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ declarations: [ KmsUiPresentationalComponent ]
12
+ })
13
+ .compileComponents();
14
+ });
15
+
16
+ beforeEach(() => {
17
+ fixture = TestBed.createComponent(KmsUiPresentationalComponent);
18
+ component = fixture.componentInstance;
19
+ fixture.detectChanges();
20
+ });
21
+
22
+ it('should create', () => {
23
+ expect(component).toBeTruthy();
24
+ });
25
+ });
@@ -0,0 +1,20 @@
1
+ import { Component, OnInit } from '@angular/core';
2
+
3
+ @Component({
4
+ selector: 'lib-kms-ngx-ui-presentational',
5
+ template: `
6
+ <p>
7
+ kms-ngx-ui-presentational works!
8
+ </p>
9
+ `,
10
+ styles: [
11
+ ]
12
+ })
13
+ export class KmsUiPresentationalComponent implements OnInit {
14
+
15
+ constructor() { }
16
+
17
+ ngOnInit(): void {
18
+ }
19
+
20
+ }