geonetwork-ui 2.3.0-dev.6e2b8bea → 2.3.0-dev.b46332e6

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 (199) hide show
  1. package/esm2022/libs/api/metadata-converter/src/lib/gn4/gn4.field.mapper.mjs +5 -1
  2. package/esm2022/libs/data-access/gn4/src/openapi/api/records.api.service.mjs +35 -7
  3. package/esm2022/libs/data-access/gn4/src/openapi/model/models.mjs +1 -2
  4. package/esm2022/libs/feature/dataviz/src/lib/service/data.service.mjs +2 -2
  5. package/esm2022/libs/feature/editor/src/index.mjs +2 -2
  6. package/esm2022/libs/feature/editor/src/lib/components/record-form/form-field/form-field-array/form-field-array.component.mjs +11 -0
  7. package/esm2022/libs/feature/editor/src/lib/components/record-form/form-field/form-field-file/form-field-file.component.mjs +28 -0
  8. package/esm2022/libs/feature/editor/src/lib/components/record-form/form-field/form-field-object/form-field-object.component.mjs +11 -0
  9. package/esm2022/libs/feature/editor/src/lib/components/record-form/form-field/form-field-rich/form-field-rich.component.mjs +45 -0
  10. package/esm2022/libs/feature/editor/src/lib/components/record-form/form-field/form-field-simple/form-field-simple.component.mjs +50 -0
  11. package/esm2022/libs/feature/editor/src/lib/components/record-form/form-field/form-field-spatial-extent/form-field-spatial-extent.component.mjs +11 -0
  12. package/esm2022/libs/feature/editor/src/lib/components/record-form/form-field/form-field-temporal-extent/form-field-temporal-extent.component.mjs +11 -0
  13. package/esm2022/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.mjs +93 -0
  14. package/esm2022/libs/feature/editor/src/lib/components/record-form/form-field/form-field.model.mjs +2 -0
  15. package/esm2022/libs/feature/editor/src/lib/components/record-form/form-field/index.mjs +10 -0
  16. package/esm2022/libs/feature/editor/src/lib/components/record-form/record-form.component.mjs +39 -0
  17. package/esm2022/libs/feature/editor/src/lib/feature-editor.module.mjs +10 -10
  18. package/esm2022/libs/feature/editor/src/lib/models/fields.model.mjs +1 -1
  19. package/esm2022/libs/ui/elements/src/index.mjs +14 -15
  20. package/esm2022/libs/ui/elements/src/lib/image-overlay-preview/image-overlay-preview.component.mjs +3 -3
  21. package/esm2022/libs/ui/elements/src/lib/markdown-editor/markdown-editor.component.mjs +45 -0
  22. package/esm2022/libs/ui/elements/src/lib/metadata-info/metadata-info.component.mjs +3 -3
  23. package/esm2022/libs/ui/elements/src/lib/thumbnail/thumbnail.component.mjs +4 -3
  24. package/esm2022/libs/ui/elements/src/lib/ui-elements.module.mjs +6 -5
  25. package/esm2022/libs/ui/inputs/src/index.mjs +1 -2
  26. package/esm2022/libs/ui/inputs/src/lib/button/button.component.mjs +2 -1
  27. package/esm2022/libs/ui/inputs/src/lib/files-drop/files-drop.directive.mjs +59 -0
  28. package/esm2022/libs/ui/inputs/src/lib/image-input/image-input.component.mjs +183 -0
  29. package/esm2022/libs/ui/inputs/src/lib/ui-inputs.module.mjs +10 -23
  30. package/esm2022/libs/ui/layout/src/index.mjs +6 -5
  31. package/esm2022/libs/ui/layout/src/lib/form-field-wrapper/form-field-wrapper.component.mjs +18 -0
  32. package/esm2022/libs/util/shared/src/lib/utils/bytes-convert.mjs +4 -0
  33. package/esm2022/libs/util/shared/src/lib/utils/image-resize.mjs +60 -0
  34. package/esm2022/libs/util/shared/src/lib/utils/index.mjs +8 -6
  35. package/esm2022/translations/de.json +10 -0
  36. package/esm2022/translations/en.json +10 -0
  37. package/esm2022/translations/es.json +10 -0
  38. package/esm2022/translations/fr.json +10 -0
  39. package/esm2022/translations/it.json +10 -0
  40. package/esm2022/translations/nl.json +10 -0
  41. package/esm2022/translations/pt.json +10 -0
  42. package/fesm2022/geonetwork-ui.mjs +1772 -1317
  43. package/fesm2022/geonetwork-ui.mjs.map +1 -1
  44. package/libs/api/metadata-converter/src/lib/gn4/gn4.field.mapper.d.ts.map +1 -1
  45. package/libs/data-access/gn4/src/openapi/api/records.api.service.d.ts +9 -5
  46. package/libs/data-access/gn4/src/openapi/api/records.api.service.d.ts.map +1 -1
  47. package/libs/data-access/gn4/src/openapi/model/models.d.ts +0 -1
  48. package/libs/data-access/gn4/src/openapi/model/models.d.ts.map +1 -1
  49. package/libs/feature/editor/src/index.d.ts +1 -1
  50. package/libs/feature/editor/src/index.d.ts.map +1 -1
  51. package/libs/{ui/inputs/src/lib → feature/editor/src/lib/components/record-form}/form-field/form-field-array/form-field-array.component.d.ts +1 -1
  52. package/libs/feature/editor/src/lib/components/record-form/form-field/form-field-array/form-field-array.component.d.ts.map +1 -0
  53. package/libs/{ui/inputs/src/lib → feature/editor/src/lib/components/record-form}/form-field/form-field-file/form-field-file.component.d.ts +1 -1
  54. package/libs/feature/editor/src/lib/components/record-form/form-field/form-field-file/form-field-file.component.d.ts.map +1 -0
  55. package/libs/{ui/inputs/src/lib → feature/editor/src/lib/components/record-form}/form-field/form-field-object/form-field-object.component.d.ts +1 -1
  56. package/libs/feature/editor/src/lib/components/record-form/form-field/form-field-object/form-field-object.component.d.ts.map +1 -0
  57. package/libs/feature/editor/src/lib/components/record-form/form-field/form-field-rich/form-field-rich.component.d.ts +16 -0
  58. package/libs/feature/editor/src/lib/components/record-form/form-field/form-field-rich/form-field-rich.component.d.ts.map +1 -0
  59. package/libs/{ui/inputs/src/lib → feature/editor/src/lib/components/record-form}/form-field/form-field-simple/form-field-simple.component.d.ts +2 -2
  60. package/libs/feature/editor/src/lib/components/record-form/form-field/form-field-simple/form-field-simple.component.d.ts.map +1 -0
  61. package/libs/{ui/inputs/src/lib → feature/editor/src/lib/components/record-form}/form-field/form-field-spatial-extent/form-field-spatial-extent.component.d.ts +1 -1
  62. package/libs/feature/editor/src/lib/components/record-form/form-field/form-field-spatial-extent/form-field-spatial-extent.component.d.ts.map +1 -0
  63. package/libs/{ui/inputs/src/lib → feature/editor/src/lib/components/record-form}/form-field/form-field-temporal-extent/form-field-temporal-extent.component.d.ts +1 -1
  64. package/libs/feature/editor/src/lib/components/record-form/form-field/form-field-temporal-extent/form-field-temporal-extent.component.d.ts.map +1 -0
  65. package/libs/{ui/inputs/src/lib → feature/editor/src/lib/components/record-form}/form-field/form-field.component.d.ts +4 -3
  66. package/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.d.ts.map +1 -0
  67. package/libs/feature/editor/src/lib/components/record-form/form-field/form-field.model.d.ts.map +1 -0
  68. package/libs/feature/editor/src/lib/components/record-form/form-field/index.d.ts.map +1 -0
  69. package/libs/feature/editor/src/lib/{record-form → components/record-form}/record-form.component.d.ts +3 -3
  70. package/libs/feature/editor/src/lib/components/record-form/record-form.component.d.ts.map +1 -0
  71. package/libs/feature/editor/src/lib/feature-editor.module.d.ts +1 -1
  72. package/libs/feature/editor/src/lib/feature-editor.module.d.ts.map +1 -1
  73. package/libs/feature/editor/src/lib/models/fields.model.d.ts +1 -1
  74. package/libs/ui/elements/src/index.d.ts +13 -14
  75. package/libs/ui/elements/src/index.d.ts.map +1 -1
  76. package/libs/ui/elements/src/lib/markdown-editor/markdown-editor.component.d.ts +13 -0
  77. package/libs/ui/elements/src/lib/markdown-editor/markdown-editor.component.d.ts.map +1 -0
  78. package/libs/ui/elements/src/lib/thumbnail/thumbnail.component.d.ts +1 -1
  79. package/libs/ui/elements/src/lib/thumbnail/thumbnail.component.d.ts.map +1 -1
  80. package/libs/ui/elements/src/lib/ui-elements.module.d.ts +20 -20
  81. package/libs/ui/inputs/src/index.d.ts +0 -1
  82. package/libs/ui/inputs/src/index.d.ts.map +1 -1
  83. package/libs/ui/inputs/src/lib/button/button.component.d.ts.map +1 -1
  84. package/libs/ui/inputs/src/lib/files-drop/files-drop.directive.d.ts +14 -0
  85. package/libs/ui/inputs/src/lib/files-drop/files-drop.directive.d.ts.map +1 -0
  86. package/libs/ui/inputs/src/lib/image-input/image-input.component.d.ts +44 -0
  87. package/libs/ui/inputs/src/lib/image-input/image-input.component.d.ts.map +1 -0
  88. package/libs/ui/inputs/src/lib/ui-inputs.module.d.ts +26 -33
  89. package/libs/ui/inputs/src/lib/ui-inputs.module.d.ts.map +1 -1
  90. package/libs/ui/layout/src/index.d.ts +5 -4
  91. package/libs/ui/layout/src/index.d.ts.map +1 -1
  92. package/libs/ui/layout/src/lib/form-field-wrapper/form-field-wrapper.component.d.ts +8 -0
  93. package/libs/ui/layout/src/lib/form-field-wrapper/form-field-wrapper.component.d.ts.map +1 -0
  94. package/libs/util/shared/src/lib/utils/bytes-convert.d.ts +2 -0
  95. package/libs/util/shared/src/lib/utils/bytes-convert.d.ts.map +1 -0
  96. package/libs/util/shared/src/lib/utils/image-resize.d.ts +3 -0
  97. package/libs/util/shared/src/lib/utils/image-resize.d.ts.map +1 -0
  98. package/libs/util/shared/src/lib/utils/index.d.ts +7 -5
  99. package/libs/util/shared/src/lib/utils/index.d.ts.map +1 -1
  100. package/package.json +1 -1
  101. package/src/libs/api/metadata-converter/src/lib/gn4/gn4.field.mapper.ts +6 -0
  102. package/src/libs/data-access/gn4/src/openapi/api/records.api.service.ts +43 -12
  103. package/src/libs/data-access/gn4/src/openapi/model/models.ts +0 -1
  104. package/src/libs/data-access/gn4/src/spec.yaml +1 -1
  105. package/src/libs/feature/dataviz/src/lib/service/data.service.ts +1 -1
  106. package/src/libs/feature/editor/src/index.ts +1 -1
  107. package/src/libs/feature/editor/src/lib/components/overview-upload/overview-upload.component.html +8 -0
  108. package/src/libs/feature/editor/src/lib/components/overview-upload/overview-upload.component.ts +70 -0
  109. package/src/libs/{ui/inputs/src/lib → feature/editor/src/lib/components/record-form}/form-field/form-field-array/form-field-array.component.ts +1 -0
  110. package/src/libs/{ui/inputs/src/lib → feature/editor/src/lib/components/record-form}/form-field/form-field-file/form-field-file.component.ts +4 -1
  111. package/src/libs/{ui/inputs/src/lib → feature/editor/src/lib/components/record-form}/form-field/form-field-object/form-field-object.component.ts +1 -0
  112. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-rich/form-field-rich.component.css +5 -0
  113. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-rich/form-field-rich.component.html +20 -0
  114. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-rich/form-field-rich.component.ts +44 -0
  115. package/src/libs/{ui/inputs/src/lib → feature/editor/src/lib/components/record-form}/form-field/form-field-simple/form-field-simple.component.ts +4 -1
  116. package/src/libs/{ui/inputs/src/lib → feature/editor/src/lib/components/record-form}/form-field/form-field-spatial-extent/form-field-spatial-extent.component.ts +1 -0
  117. package/src/libs/{ui/inputs/src/lib → feature/editor/src/lib/components/record-form}/form-field/form-field-temporal-extent/form-field-temporal-extent.component.ts +1 -0
  118. package/src/libs/{ui/inputs/src/lib → feature/editor/src/lib/components/record-form}/form-field/form-field.component.html +4 -4
  119. package/src/libs/{ui/inputs/src/lib → feature/editor/src/lib/components/record-form}/form-field/form-field.component.ts +31 -5
  120. package/src/libs/feature/editor/src/lib/{record-form → components/record-form}/record-form.component.html +1 -0
  121. package/src/libs/feature/editor/src/lib/{record-form → components/record-form}/record-form.component.ts +23 -4
  122. package/src/libs/feature/editor/src/lib/feature-editor.module.ts +9 -9
  123. package/src/libs/feature/editor/src/lib/models/fields.model.ts +1 -1
  124. package/src/libs/ui/elements/src/index.ts +13 -14
  125. package/src/libs/ui/elements/src/lib/markdown-editor/markdown-editor.component.css +0 -5
  126. package/src/libs/ui/elements/src/lib/markdown-editor/markdown-editor.component.html +0 -21
  127. package/src/libs/ui/elements/src/lib/markdown-editor/markdown-editor.component.ts +1 -14
  128. package/src/libs/ui/elements/src/lib/thumbnail/thumbnail.component.ts +5 -3
  129. package/src/libs/ui/elements/src/lib/ui-elements.module.ts +1 -1
  130. package/src/libs/ui/inputs/src/index.ts +0 -1
  131. package/src/libs/ui/inputs/src/lib/button/button.component.ts +1 -1
  132. package/src/libs/ui/inputs/src/lib/files-drop/files-drop.directive.ts +45 -0
  133. package/src/libs/ui/inputs/src/lib/image-input/image-input.component.css +0 -0
  134. package/src/libs/ui/inputs/src/lib/image-input/image-input.component.html +146 -0
  135. package/src/libs/ui/inputs/src/lib/image-input/image-input.component.ts +193 -0
  136. package/src/libs/ui/inputs/src/lib/ui-inputs.module.ts +3 -19
  137. package/src/libs/ui/layout/src/index.ts +5 -4
  138. package/src/libs/ui/layout/src/lib/form-field-wrapper/form-field-wrapper.component.css +5 -0
  139. package/src/libs/ui/layout/src/lib/form-field-wrapper/form-field-wrapper.component.html +18 -0
  140. package/src/libs/ui/layout/src/lib/form-field-wrapper/form-field-wrapper.component.ts +16 -0
  141. package/src/libs/util/shared/src/lib/utils/bytes-convert.ts +3 -0
  142. package/src/libs/util/shared/src/lib/utils/image-resize.ts +72 -0
  143. package/src/libs/util/shared/src/lib/utils/index.ts +7 -5
  144. package/translations/de.json +10 -0
  145. package/translations/en.json +10 -0
  146. package/translations/es.json +10 -0
  147. package/translations/fr.json +10 -0
  148. package/translations/it.json +10 -0
  149. package/translations/nl.json +10 -0
  150. package/translations/pt.json +10 -0
  151. package/translations/sk.json +10 -0
  152. package/esm2022/libs/data-access/gn4/src/openapi/model/inlineObject3.api.model.mjs +0 -13
  153. package/esm2022/libs/feature/editor/src/lib/record-form/record-form.component.mjs +0 -30
  154. package/esm2022/libs/ui/inputs/src/lib/form-field/form-field-array/form-field-array.component.mjs +0 -11
  155. package/esm2022/libs/ui/inputs/src/lib/form-field/form-field-file/form-field-file.component.mjs +0 -27
  156. package/esm2022/libs/ui/inputs/src/lib/form-field/form-field-object/form-field-object.component.mjs +0 -11
  157. package/esm2022/libs/ui/inputs/src/lib/form-field/form-field-rich/form-field-rich.component.mjs +0 -27
  158. package/esm2022/libs/ui/inputs/src/lib/form-field/form-field-simple/form-field-simple.component.mjs +0 -49
  159. package/esm2022/libs/ui/inputs/src/lib/form-field/form-field-spatial-extent/form-field-spatial-extent.component.mjs +0 -11
  160. package/esm2022/libs/ui/inputs/src/lib/form-field/form-field-temporal-extent/form-field-temporal-extent.component.mjs +0 -11
  161. package/esm2022/libs/ui/inputs/src/lib/form-field/form-field.component.mjs +0 -76
  162. package/esm2022/libs/ui/inputs/src/lib/form-field/form-field.model.mjs +0 -2
  163. package/esm2022/libs/ui/inputs/src/lib/form-field/index.mjs +0 -10
  164. package/libs/data-access/gn4/src/openapi/model/inlineObject3.api.model.d.ts +0 -18
  165. package/libs/data-access/gn4/src/openapi/model/inlineObject3.api.model.d.ts.map +0 -1
  166. package/libs/feature/editor/src/lib/record-form/record-form.component.d.ts.map +0 -1
  167. package/libs/ui/inputs/src/lib/form-field/form-field-array/form-field-array.component.d.ts.map +0 -1
  168. package/libs/ui/inputs/src/lib/form-field/form-field-file/form-field-file.component.d.ts.map +0 -1
  169. package/libs/ui/inputs/src/lib/form-field/form-field-object/form-field-object.component.d.ts.map +0 -1
  170. package/libs/ui/inputs/src/lib/form-field/form-field-rich/form-field-rich.component.d.ts +0 -11
  171. package/libs/ui/inputs/src/lib/form-field/form-field-rich/form-field-rich.component.d.ts.map +0 -1
  172. package/libs/ui/inputs/src/lib/form-field/form-field-simple/form-field-simple.component.d.ts.map +0 -1
  173. package/libs/ui/inputs/src/lib/form-field/form-field-spatial-extent/form-field-spatial-extent.component.d.ts.map +0 -1
  174. package/libs/ui/inputs/src/lib/form-field/form-field-temporal-extent/form-field-temporal-extent.component.d.ts.map +0 -1
  175. package/libs/ui/inputs/src/lib/form-field/form-field.component.d.ts.map +0 -1
  176. package/libs/ui/inputs/src/lib/form-field/form-field.model.d.ts.map +0 -1
  177. package/libs/ui/inputs/src/lib/form-field/index.d.ts.map +0 -1
  178. package/src/libs/data-access/gn4/src/openapi/model/inlineObject3.api.model.ts +0 -18
  179. package/src/libs/ui/inputs/src/lib/form-field/form-field-rich/form-field-rich.component.html +0 -11
  180. package/src/libs/ui/inputs/src/lib/form-field/form-field-rich/form-field-rich.component.ts +0 -15
  181. /package/libs/{ui/inputs/src/lib → feature/editor/src/lib/components/record-form}/form-field/form-field.model.d.ts +0 -0
  182. /package/libs/{ui/inputs/src/lib → feature/editor/src/lib/components/record-form}/form-field/index.d.ts +0 -0
  183. /package/src/libs/feature/editor/src/lib/{record-form/record-form.component.css → components/overview-upload/overview-upload.component.css} +0 -0
  184. /package/src/libs/{ui/inputs/src/lib → feature/editor/src/lib/components/record-form}/form-field/form-field-array/form-field-array.component.css +0 -0
  185. /package/src/libs/{ui/inputs/src/lib → feature/editor/src/lib/components/record-form}/form-field/form-field-array/form-field-array.component.html +0 -0
  186. /package/src/libs/{ui/inputs/src/lib → feature/editor/src/lib/components/record-form}/form-field/form-field-file/form-field-file.component.css +0 -0
  187. /package/src/libs/{ui/inputs/src/lib → feature/editor/src/lib/components/record-form}/form-field/form-field-file/form-field-file.component.html +0 -0
  188. /package/src/libs/{ui/inputs/src/lib → feature/editor/src/lib/components/record-form}/form-field/form-field-object/form-field-object.component.css +0 -0
  189. /package/src/libs/{ui/inputs/src/lib → feature/editor/src/lib/components/record-form}/form-field/form-field-object/form-field-object.component.html +0 -0
  190. /package/src/libs/{ui/inputs/src/lib → feature/editor/src/lib/components/record-form}/form-field/form-field-simple/form-field-simple.component.css +0 -0
  191. /package/src/libs/{ui/inputs/src/lib → feature/editor/src/lib/components/record-form}/form-field/form-field-simple/form-field-simple.component.html +0 -0
  192. /package/src/libs/{ui/inputs/src/lib → feature/editor/src/lib/components/record-form}/form-field/form-field-spatial-extent/form-field-spatial-extent.component.css +0 -0
  193. /package/src/libs/{ui/inputs/src/lib → feature/editor/src/lib/components/record-form}/form-field/form-field-spatial-extent/form-field-spatial-extent.component.html +0 -0
  194. /package/src/libs/{ui/inputs/src/lib → feature/editor/src/lib/components/record-form}/form-field/form-field-temporal-extent/form-field-temporal-extent.component.css +0 -0
  195. /package/src/libs/{ui/inputs/src/lib → feature/editor/src/lib/components/record-form}/form-field/form-field-temporal-extent/form-field-temporal-extent.component.html +0 -0
  196. /package/src/libs/{ui/inputs/src/lib → feature/editor/src/lib/components/record-form}/form-field/form-field.component.css +0 -0
  197. /package/src/libs/{ui/inputs/src/lib → feature/editor/src/lib/components/record-form}/form-field/form-field.model.ts +0 -0
  198. /package/src/libs/{ui/inputs/src/lib → feature/editor/src/lib/components/record-form}/form-field/index.ts +0 -0
  199. /package/src/libs/{ui/inputs/src/lib/form-field/form-field-rich/form-field-rich.component.css → feature/editor/src/lib/components/record-form/record-form.component.css} +0 -0
@@ -31,26 +31,13 @@ import { MatTooltipModule } from '@angular/material/tooltip'
31
31
  ],
32
32
  })
33
33
  export class MarkdownEditorComponent {
34
- @Input() label: string
35
- @Input() tooltip?: string
34
+ @Input() preview = false
36
35
  @Input() helperText?: string
37
36
  @Input() placeholder: string
38
37
  @Input() textContent: string
39
38
  @Output() textContentChanged: EventEmitter<string> =
40
39
  new EventEmitter<string>()
41
40
 
42
- preview = false
43
-
44
- getButtonExtraClass() {
45
- return `${
46
- this.preview ? 'text-gray-200 bg-gray-900' : 'text-gray-900 bg-gray-200'
47
- } rounded-[1.25rem] p-[0.375rem] text-xs font-medium w-24`
48
- }
49
-
50
- togglePreview() {
51
- this.preview = !this.preview
52
- }
53
-
54
41
  textContentChangedHandler(textContent: string) {
55
42
  this.textContent = textContent
56
43
  this.textContentChanged.emit(this.textContent)
@@ -1,3 +1,4 @@
1
+ import { CommonModule } from '@angular/common'
1
2
  import {
2
3
  ChangeDetectionStrategy,
3
4
  Component,
@@ -18,20 +19,21 @@ export const THUMBNAIL_PLACEHOLDER = new InjectionToken<string>(
18
19
  'thumbnail-placeholder'
19
20
  )
20
21
 
22
+ type FitOptions = 'cover' | 'contain' | 'scale-down'
21
23
  type ThumbnailImageObject = {
22
24
  url: string
23
- fit?: 'cover' | 'contain' | 'scale-down'
25
+ fit?: FitOptions
24
26
  }
25
27
 
26
28
  const DEFAULT_PLACEHOLDER =
27
29
  'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH5gkNDCUFYjA1nwAAA1pJREFUeNrtnW2TmjAURh8CLlTdrmun///3tZ22+zLuYlehH7jsMGogwRiiec4MM44K6D3x3hAwAIQQQgghhJDYSM5cPwNQAMgBpACUg22GTg2gArAD8A9AKY+9CsgALAF8YRsGALwDeAWw9yGgALCKoKWP+WU8iwxjUsudLBj83sZciIiPSwhoWz7pJ5dUZFQXlEXOZ/DNeTBt3JnhBpc9aacGsOn0BuoIUk3b+5trGnEC4B7Ak4sUlInRU+wB/JbgVxG18KrTBc01EmYmcTFJQUVPy/9zTh/4BthLDOqeenB2DdBtZBN58LsSNpcUoEtTJWM/GIvMhQDde9j6h2OhXAjo6/2Q/lgkLgSQC0IBFEABZEKyiaQv5AAv7fSlS+lPVxRwOXTnEtoTPAs04yfRHGMoz8F/HOiaJfKeggLc78dmOHsVS33y9SUXsDuLlsg6FOAw/fhYhwI0pJ7WoQASpoC9p3UoQEPpaR0K0LCB3fB1e6KfAhxRweAKgQ5PsQxJ+CzCJYC/A7+EWt4TzVCE77GgEsBPHA/G7QBswcE4b+noVRZ2QxkCCqAAQgEUQCiAAggFUAChAAogFEABhAJcfT9FAdOxQuB/ML9lAfdo/qWYy2MK8EiO5mrrliUCvdIudAEzWWzQzWuxwjRnAK9WwAzAWhZTCe3l7cryNQrQBL/txZhKGGrlwc36ogIPfvdzfhuQsDDM80EVZXUFwe+mEJ2EOwBfLfYTTFFWVxL8Qwl3nedSye1jjhEyCjAPflfCWiScU1iDKMrqyoJ/KOFxRDf1sCg/xCxgTPC7EnIHn6GYsiirKw2+ayYryorBn7YoKwb/qCgntywg1OBPdqSsGPyTRXnp07gvPgD8AAl6KIICCAVQAAlLwOg5MSNi9NyqJgKqAHpQoZNZxs5KgG7SDN7AZzgWOxcCtprn5/wVfLb+uWXsrASUPXlvHbmETGKQjBVgMitVJTuaaQS2t/GoEMeE3onEor2jlK4RvwN4G1u9T4n6zp6PMTWAXzCYdCq12OCOhdeYZzT3mIErAW1Fr+HmNOAt82KSesYIAJoRzR2aIVumo+Ms8WwT/HOOZlM0Y+Zzxv2zp/gCTzfzPOyGtdfgp7LEcDvbvSxbWXg/HUIIIYQQQogx/wHLoX7NoCMFPwAAAABJRU5ErkJggg=='
28
30
 
29
- type FitOptions = 'cover' | 'contain' | 'scale-down'
30
-
31
31
  @Component({
32
32
  selector: 'gn-ui-thumbnail',
33
33
  templateUrl: './thumbnail.component.html',
34
34
  changeDetection: ChangeDetectionStrategy.OnPush,
35
+ standalone: true,
36
+ imports: [CommonModule],
35
37
  })
36
38
  export class ThumbnailComponent implements OnInit, OnChanges {
37
39
  @Input() thumbnailUrl: string | string[]
@@ -46,6 +46,7 @@ import { ImageOverlayPreviewComponent } from './image-overlay-preview/image-over
46
46
  FormsModule,
47
47
  NgOptimizedImage,
48
48
  MarkdownParserComponent,
49
+ ThumbnailComponent,
49
50
  ],
50
51
  declarations: [
51
52
  MetadataInfoComponent,
@@ -61,7 +62,6 @@ import { ImageOverlayPreviewComponent } from './image-overlay-preview/image-over
61
62
  MetadataQualityItemComponent,
62
63
  SearchResultsErrorComponent,
63
64
  PaginationComponent,
64
- ThumbnailComponent,
65
65
  AvatarComponent,
66
66
  UserPreviewComponent,
67
67
  GnUiLinkifyDirective,
@@ -11,7 +11,6 @@ export * from './lib/button/button.component'
11
11
  export * from './lib/viewport-intersector/viewport-intersector.component'
12
12
  export * from './lib/check-toggle/check-toggle.component'
13
13
  export * from './lib/ui-inputs.module'
14
- export * from './lib/form-field'
15
14
  export * from './lib/copy-text-button/copy-text-button.component'
16
15
  export * from './lib/drag-and-drop-file-input/drag-and-drop-file-input.component'
17
16
  export * from './lib/navigation-button/navigation-button.component'
@@ -15,7 +15,7 @@ import { propagateToDocumentOnly } from '../../../../../../libs/util/shared/src'
15
15
  standalone: true,
16
16
  })
17
17
  export class ButtonComponent {
18
- private btnClass: string
18
+ private btnClass = 'gn-ui-btn-default'
19
19
 
20
20
  @Input() set type(
21
21
  value: 'primary' | 'secondary' | 'default' | 'outline' | 'light'
@@ -0,0 +1,45 @@
1
+ import { Directive, HostListener, Output, EventEmitter } from '@angular/core'
2
+
3
+ @Directive({
4
+ selector: '[gnUiFilesDrop]',
5
+ standalone: true,
6
+ })
7
+ export class FilesDropDirective {
8
+ @Output() dragFilesOver: EventEmitter<boolean> = new EventEmitter()
9
+ @Output() dropFiles: EventEmitter<File[]> = new EventEmitter()
10
+
11
+ dragEnterCounter = 0
12
+
13
+ @HostListener('dragenter', ['$event'])
14
+ _onDragEnter(event: DragEvent) {
15
+ event.preventDefault()
16
+ this.dragEnterCounter++
17
+ this.dragFilesOver.emit(true)
18
+ }
19
+
20
+ @HostListener('dragover', ['$event'])
21
+ _onDragOver(event: DragEvent) {
22
+ event.preventDefault()
23
+ }
24
+
25
+ @HostListener('dragleave', ['$event'])
26
+ _onDragLeave(event: DragEvent) {
27
+ event.preventDefault()
28
+ this.dragEnterCounter = Math.max(0, this.dragEnterCounter - 1)
29
+ if (this.dragEnterCounter === 0) {
30
+ this.dragFilesOver.emit(false)
31
+ }
32
+ }
33
+
34
+ @HostListener('drop', ['$event'])
35
+ _onDrop(event: DragEvent) {
36
+ event.preventDefault()
37
+ this.dragEnterCounter = 0
38
+ this.dragFilesOver.emit(false)
39
+
40
+ const files = Array.from(event.dataTransfer.files)
41
+ if (files.length > 0) {
42
+ this.dropFiles.emit(files)
43
+ }
44
+ }
45
+ }
@@ -0,0 +1,146 @@
1
+ <ng-container *ngIf="previewUrl; then withImage; else withoutImage">
2
+ </ng-container>
3
+
4
+ <ng-template #withImage>
5
+ <div class="w-full h-full flex flex-col gap-2">
6
+ <div class="flex-1 group relative">
7
+ <img
8
+ class="w-full h-full object-cover border-2 border-gray-300 rounded-lg"
9
+ [alt]="altText"
10
+ loading="lazy"
11
+ [src]="previewUrl"
12
+ />
13
+ <gn-ui-button
14
+ [extraClass]="
15
+ 'bg-gray-200 absolute right-2 bottom-2 invisible group-hover:visible'
16
+ "
17
+ (buttonClick)="handleDelete()"
18
+ >
19
+ <mat-icon class="material-symbols-outlined">delete</mat-icon>
20
+ </gn-ui-button>
21
+ </div>
22
+ <input
23
+ *ngIf="showAltTextInput"
24
+ type="text"
25
+ class="py-3 px-2 border-2 border-gray-300 rounded-lg text-sm font-medium"
26
+ [placeholder]="'input.image.altTextPlaceholder' | translate"
27
+ [value]="altText"
28
+ (change)="handleAltTextChange($event)"
29
+ />
30
+ <div class="flex flex-row gap-2">
31
+ <gn-ui-button
32
+ [extraClass]="'bg-gray-200 font-bold'"
33
+ (buttonClick)="handleDelete()"
34
+ >
35
+ <mat-icon class="material-symbols-outlined me-1">delete</mat-icon>
36
+ {{ 'input.image.delete' | translate }}
37
+ </gn-ui-button>
38
+ <gn-ui-button
39
+ *ngIf="!showAltTextInput"
40
+ [extraClass]="'bg-gray-200 font-bold'"
41
+ (buttonClick)="toggleAltTextInput()"
42
+ >
43
+ <mat-icon class="material-symbols-outlined me-1">add</mat-icon>
44
+ {{ 'input.image.displayAltTextInput' | translate }}
45
+ </gn-ui-button>
46
+ </div>
47
+ </div>
48
+ </ng-template>
49
+
50
+ <ng-template #withoutImage>
51
+ <div class="w-full h-full flex flex-col gap-2">
52
+ <label
53
+ gnUiFilesDrop
54
+ class="block flex-1 border-2 border-dashed border-gray-300 rounded-lg p-6 flex flex-col items-center justify-center gap-4"
55
+ (dragFilesOver)="handleDragFilesOver($event)"
56
+ (dropFiles)="handleDropFiles($event)"
57
+ >
58
+ <div class="w-14 h-14 rounded-md bg-gray-200 grid">
59
+ <mat-icon
60
+ *ngIf="!dragFilesOver && !uploadProgress && !uploadError"
61
+ class="material-symbols-outlined place-self-center text-blue-500"
62
+ >image</mat-icon
63
+ >
64
+ <mat-icon
65
+ *ngIf="dragFilesOver && !uploadProgress && !uploadError"
66
+ class="material-symbols-outlined place-self-center text-blue-500"
67
+ >add_box</mat-icon
68
+ >
69
+ <div *ngIf="uploadProgress">
70
+ <mat-progress-spinner
71
+ class="place-self-center"
72
+ [diameter]="56"
73
+ [mode]="'determinate'"
74
+ [value]="uploadProgress"
75
+ ></mat-progress-spinner>
76
+ <span
77
+ class="text-sm font-medium relative inline-block width-[30px] bottom-[40px] left-[15px]"
78
+ >
79
+ {{ uploadProgress }}%
80
+ </span>
81
+ </div>
82
+ <mat-icon
83
+ *ngIf="uploadError"
84
+ class="material-symbols-outlined place-self-center text-rose-500"
85
+ >broken_image</mat-icon
86
+ >
87
+ </div>
88
+ <div class="flex flex-col items-center gap-1">
89
+ <p class="font-medium">{{ getPrimaryText() | translate }}</p>
90
+ <p
91
+ class="text-sm"
92
+ [class]="
93
+ uploadProgress || uploadError
94
+ ? 'font-bold text-blue-500 cursor-pointer'
95
+ : 'font-medium text-gray-500'
96
+ "
97
+ (click)="handleSecondaryTextClick()"
98
+ >
99
+ {{ getSecondaryText() | translate }}
100
+ </p>
101
+ </div>
102
+ <input
103
+ type="file"
104
+ class="hidden"
105
+ (change)="handleFileInput($event)"
106
+ [disabled]="showUrlInput || uploadProgress || uploadError"
107
+ />
108
+ </label>
109
+ <div *ngIf="!showUrlInput" class="flex-none">
110
+ <gn-ui-button
111
+ [extraClass]="'bg-gray-200 font-bold'"
112
+ (buttonClick)="displayUrlInput()"
113
+ >
114
+ <mat-icon class="material-symbols-outlined me-1">link</mat-icon>
115
+ {{ 'input.image.displayUrlInput' | translate }}
116
+ </gn-ui-button>
117
+ </div>
118
+ <div *ngIf="showUrlInput" class="flex-none flex flex-col gap-2">
119
+ <div class="h-2"></div>
120
+ <div class="flex gap-2 items-center">
121
+ <div class="flex-1 flex rounded-lg">
122
+ <span
123
+ class="material-symbols-outlined px-4 inline-flex items-center min-w-fit rounded-s-lg border-2 border-e-0 border-gray-300"
124
+ >link</span
125
+ >
126
+ <input
127
+ type="text"
128
+ class="py-3 ps-1 block w-full border-2 border-s-0 border-e-0 border-gray-300 text-sm font-medium"
129
+ placeholder="https://exemple.com/image.jpg"
130
+ (change)="handleUrlChange($event)"
131
+ />
132
+ <gn-ui-button
133
+ class="px-1 inline-flex items-center min-w-fit rounded-e-lg border-2 border-s-0 border-gray-300 text-white"
134
+ [extraClass]="
135
+ urlInputValue && !downloadError ? 'bg-blue-500' : 'bg-gray-500'
136
+ "
137
+ [disabled]="!urlInputValue || downloadError"
138
+ (buttonClick)="downloadUrl()"
139
+ >
140
+ <mat-icon class="material-symbols-outlined">arrow_upward</mat-icon>
141
+ </gn-ui-button>
142
+ </div>
143
+ </div>
144
+ </div>
145
+ </div>
146
+ </ng-template>
@@ -0,0 +1,193 @@
1
+ import { CommonModule } from '@angular/common'
2
+ import { HttpClient } from '@angular/common/http'
3
+ import {
4
+ ChangeDetectionStrategy,
5
+ ChangeDetectorRef,
6
+ Component,
7
+ EventEmitter,
8
+ Input,
9
+ Output,
10
+ } from '@angular/core'
11
+ import { MatIconModule } from '@angular/material/icon'
12
+ import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'
13
+ import { downgradeImage, megabytesToBytes } from '../../../../../../libs/util/shared/src'
14
+ import { firstValueFrom } from 'rxjs'
15
+ import { ButtonComponent } from '../button/button.component'
16
+ import { FilesDropDirective } from '../files-drop/files-drop.directive'
17
+ import { TranslateModule } from '@ngx-translate/core'
18
+ import { marker } from '@biesbjerg/ngx-translate-extract-marker'
19
+
20
+ @Component({
21
+ selector: 'gn-ui-image-input',
22
+ templateUrl: './image-input.component.html',
23
+ styleUrls: ['./image-input.component.css'],
24
+ changeDetection: ChangeDetectionStrategy.OnPush,
25
+ standalone: true,
26
+ imports: [
27
+ CommonModule,
28
+ ButtonComponent,
29
+ MatIconModule,
30
+ FilesDropDirective,
31
+ MatProgressSpinnerModule,
32
+ TranslateModule,
33
+ ],
34
+ })
35
+ export class ImageInputComponent {
36
+ @Input() maxSizeMB: number
37
+ @Input() previewUrl?: string
38
+ @Input() altText?: string
39
+ @Input() uploadProgress?: number
40
+ @Input() uploadError?: boolean
41
+ @Output() fileChange: EventEmitter<File> = new EventEmitter()
42
+ @Output() urlChange: EventEmitter<string> = new EventEmitter()
43
+ @Output() uploadCancel: EventEmitter<void> = new EventEmitter()
44
+ @Output() delete: EventEmitter<void> = new EventEmitter()
45
+ @Output() altTextChange: EventEmitter<string> = new EventEmitter()
46
+
47
+ dragFilesOver = false
48
+ showUrlInput = false
49
+ downloadError = false
50
+ showAltTextInput = false
51
+
52
+ urlInputValue?: string
53
+ lastUploadType?: 'file' | 'url'
54
+ lastUploadContent?: string | File
55
+
56
+ constructor(private http: HttpClient, private cd: ChangeDetectorRef) {}
57
+
58
+ getPrimaryText() {
59
+ if (this.uploadError) {
60
+ return marker('input.image.uploadErrorLabel')
61
+ }
62
+ if (this.uploadProgress) {
63
+ return marker('input.image.uploadProgressLabel')
64
+ }
65
+ return marker('input.image.selectFileLabel')
66
+ }
67
+
68
+ getSecondaryText() {
69
+ if (this.uploadError) {
70
+ return marker('input.image.uploadErrorRetry')
71
+ }
72
+ if (this.uploadProgress) {
73
+ return marker('input.image.uploadProgressCancel')
74
+ }
75
+ return marker('input.image.dropFileLabel')
76
+ }
77
+
78
+ handleDragFilesOver(dragFilesOver: boolean) {
79
+ if (!this.showUrlInput) {
80
+ this.dragFilesOver = dragFilesOver
81
+ this.cd.markForCheck()
82
+ }
83
+ }
84
+
85
+ handleDropFiles(files: File[]) {
86
+ if (!this.showUrlInput) {
87
+ const validFiles = this.filterTypeImage(files)
88
+ if (validFiles.length > 0) {
89
+ this.resizeAndEmit(validFiles[0])
90
+ }
91
+ }
92
+ }
93
+
94
+ handleFileInput(event: Event) {
95
+ const inputFiles = Array.from((event.target as HTMLInputElement).files)
96
+ const validFiles = this.filterTypeImage(inputFiles)
97
+ if (validFiles.length > 0) {
98
+ this.resizeAndEmit(validFiles[0])
99
+ }
100
+ }
101
+
102
+ displayUrlInput() {
103
+ this.uploadCancel.emit()
104
+ this.showUrlInput = true
105
+ }
106
+
107
+ handleUrlChange(event: Event) {
108
+ this.downloadError = false
109
+ this.urlInputValue = (event.target as HTMLInputElement).value
110
+ }
111
+
112
+ async downloadUrl() {
113
+ const name = this.urlInputValue.split('/').pop()
114
+
115
+ try {
116
+ const response = await firstValueFrom(
117
+ this.http.head(this.urlInputValue, { observe: 'response' })
118
+ )
119
+ if (
120
+ response.headers.get('content-type')?.startsWith('image/') &&
121
+ parseInt(response.headers.get('content-length')) <
122
+ megabytesToBytes(this.maxSizeMB)
123
+ ) {
124
+ this.http.get(this.urlInputValue, { responseType: 'blob' }).subscribe({
125
+ next: (blob) => {
126
+ this.cd.markForCheck()
127
+ const file = new File([blob], name)
128
+ this.fileChange.emit(file)
129
+ },
130
+ error: () => {
131
+ this.downloadError = true
132
+ this.cd.markForCheck()
133
+ this.urlChange.emit(this.urlInputValue)
134
+ },
135
+ })
136
+ }
137
+ } catch {
138
+ this.downloadError = true
139
+ this.cd.markForCheck()
140
+ return
141
+ }
142
+ }
143
+
144
+ handleSecondaryTextClick() {
145
+ if (this.uploadError) {
146
+ this.handleRetry()
147
+ } else if (this.uploadProgress) {
148
+ this.handleCancel()
149
+ }
150
+ }
151
+
152
+ handleCancel() {
153
+ this.uploadCancel.emit()
154
+ }
155
+
156
+ handleRetry() {
157
+ switch (this.lastUploadType) {
158
+ case 'file':
159
+ this.fileChange.emit(this.lastUploadContent as File)
160
+ break
161
+ case 'url':
162
+ this.urlChange.emit(this.lastUploadContent as string)
163
+ break
164
+ }
165
+ }
166
+
167
+ handleDelete() {
168
+ this.delete.emit()
169
+ }
170
+
171
+ toggleAltTextInput() {
172
+ this.showAltTextInput = !this.showAltTextInput
173
+ }
174
+
175
+ handleAltTextChange(event: Event) {
176
+ const input = event.target as HTMLInputElement
177
+ this.altTextChange.emit(input.value)
178
+ }
179
+
180
+ private filterTypeImage(files: File[]) {
181
+ return files.filter((file) => {
182
+ return file.type.startsWith('image/')
183
+ })
184
+ }
185
+
186
+ private resizeAndEmit(imageToResize: File) {
187
+ const maxSizeBytes = megabytesToBytes(this.maxSizeMB)
188
+ downgradeImage(imageToResize, maxSizeBytes).then((resizedImage) => {
189
+ const fileToEmit = new File([resizedImage], imageToResize.name)
190
+ this.fileChange.emit(fileToEmit)
191
+ })
192
+ }
193
+ }
@@ -20,16 +20,6 @@ import { UiWidgetsModule } from '../../../../../libs/ui/widgets/src'
20
20
  import { OverlayModule } from '@angular/cdk/overlay'
21
21
  import { MatCheckboxModule } from '@angular/material/checkbox'
22
22
  import { ViewportIntersectorComponent } from './viewport-intersector/viewport-intersector.component'
23
- import {
24
- FormFieldArrayComponent,
25
- FormFieldComponent,
26
- FormFieldFileComponent,
27
- FormFieldObjectComponent,
28
- FormFieldRichComponent,
29
- FormFieldSimpleComponent,
30
- FormFieldSpatialExtentComponent,
31
- FormFieldTemporalExtentComponent,
32
- } from './form-field'
33
23
  import { CheckToggleComponent } from './check-toggle/check-toggle.component'
34
24
  import { CopyTextButtonComponent } from './copy-text-button/copy-text-button.component'
35
25
  import { MatTooltipModule } from '@angular/material/tooltip'
@@ -42,6 +32,7 @@ import { MatInputModule } from '@angular/material/input'
42
32
  import { MatDatepickerModule } from '@angular/material/datepicker'
43
33
  import { MatNativeDateModule } from '@angular/material/core'
44
34
  import { EditableLabelDirective } from './editable-label/editable-label.directive'
35
+ import { ImageInputComponent } from './image-input/image-input.component'
45
36
 
46
37
  @NgModule({
47
38
  declarations: [
@@ -54,14 +45,6 @@ import { EditableLabelDirective } from './editable-label/editable-label.directiv
54
45
  StarToggleComponent,
55
46
  DropdownMultiselectComponent,
56
47
  ViewportIntersectorComponent,
57
- FormFieldComponent,
58
- FormFieldSimpleComponent,
59
- FormFieldArrayComponent,
60
- FormFieldObjectComponent,
61
- FormFieldRichComponent,
62
- FormFieldFileComponent,
63
- FormFieldSpatialExtentComponent,
64
- FormFieldTemporalExtentComponent,
65
48
  CheckToggleComponent,
66
49
  CopyTextButtonComponent,
67
50
  CheckboxComponent,
@@ -89,6 +72,7 @@ import { EditableLabelDirective } from './editable-label/editable-label.directiv
89
72
  EditableLabelDirective,
90
73
  TextAreaComponent,
91
74
  ButtonComponent,
75
+ ImageInputComponent,
92
76
  ],
93
77
  exports: [
94
78
  DropdownSelectorComponent,
@@ -102,13 +86,13 @@ import { EditableLabelDirective } from './editable-label/editable-label.directiv
102
86
  StarToggleComponent,
103
87
  DropdownMultiselectComponent,
104
88
  ViewportIntersectorComponent,
105
- FormFieldComponent,
106
89
  CheckToggleComponent,
107
90
  CopyTextButtonComponent,
108
91
  CheckboxComponent,
109
92
  SearchInputComponent,
110
93
  DateRangePickerComponent,
111
94
  EditableLabelDirective,
95
+ ImageInputComponent,
112
96
  ],
113
97
  })
114
98
  export class UiInputsModule {}
@@ -1,8 +1,9 @@
1
- export * from './lib/ui-layout.module'
2
1
  export * from './lib/anchor-link/anchor-link.directive'
3
2
  export * from './lib/carousel/carousel.component'
4
- export * from './lib/expandable-panel/expandable-panel.component'
5
- export * from './lib/sticky-header/sticky-header.component'
6
3
  export * from './lib/expandable-panel-button/expandable-panel-button.component'
7
- export * from './lib/interactive-table/interactive-table.component'
4
+ export * from './lib/expandable-panel/expandable-panel.component'
5
+ export * from './lib/form-field-wrapper/form-field-wrapper.component'
8
6
  export * from './lib/interactive-table/interactive-table-column/interactive-table-column.component'
7
+ export * from './lib/interactive-table/interactive-table.component'
8
+ export * from './lib/sticky-header/sticky-header.component'
9
+ export * from './lib/ui-layout.module'
@@ -0,0 +1,5 @@
1
+ .icon-small {
2
+ font-size: 16px;
3
+ height: 16px;
4
+ width: 16px;
5
+ }
@@ -0,0 +1,18 @@
1
+ <div class="h-full flex flex-col">
2
+ <div class="flex-none w-full flex flex-row items-center">
3
+ <span class="flex-none font-bold">{{ label }}</span>
4
+ <div class="flex-1 flex justify-end items-center">
5
+ <ng-content select="[form-field-interaction]"></ng-content>
6
+ <span
7
+ class="material-symbols-outlined m-2 icon-small"
8
+ [matTooltip]="hint"
9
+ matTooltipPosition="above"
10
+ >
11
+ help
12
+ </span>
13
+ </div>
14
+ </div>
15
+ <div class="flex-1">
16
+ <ng-content></ng-content>
17
+ </div>
18
+ </div>
@@ -0,0 +1,16 @@
1
+ import { ChangeDetectionStrategy, Component, Input } from '@angular/core'
2
+ import { MatIconModule } from '@angular/material/icon'
3
+ import { MatTooltipModule } from '@angular/material/tooltip'
4
+
5
+ @Component({
6
+ selector: 'gn-ui-form-field-wrapper',
7
+ templateUrl: './form-field-wrapper.component.html',
8
+ styleUrls: ['./form-field-wrapper.component.css'],
9
+ changeDetection: ChangeDetectionStrategy.OnPush,
10
+ standalone: true,
11
+ imports: [MatIconModule, MatTooltipModule],
12
+ })
13
+ export class FormFieldWrapperComponent {
14
+ @Input() label: string
15
+ @Input() hint: string
16
+ }
@@ -0,0 +1,3 @@
1
+ export function megabytesToBytes(megabytes) {
2
+ return megabytes * 1048576
3
+ }
@@ -0,0 +1,72 @@
1
+ export function downsizeImage(
2
+ blob: Blob,
3
+ maxWidth: number,
4
+ maxHeight: number
5
+ ): Promise<Blob> {
6
+ return new Promise((resolve, reject) => {
7
+ const image = new Image()
8
+ image.src = URL.createObjectURL(blob)
9
+ image.onload = () => {
10
+ let width = image.width
11
+ let height = image.height
12
+
13
+ if (width > maxWidth || height > maxHeight) {
14
+ if (width > height) {
15
+ height = height * (maxWidth / width)
16
+ width = maxWidth
17
+ } else {
18
+ width = width * (maxHeight / height)
19
+ height = maxHeight
20
+ }
21
+ }
22
+
23
+ const canvas = document.createElement('canvas')
24
+ canvas.width = width
25
+ canvas.height = height
26
+
27
+ const context = canvas.getContext('2d')
28
+ context.drawImage(image, 0, 0, width, height)
29
+
30
+ canvas.toBlob(resolve, blob.type)
31
+ }
32
+ image.onerror = reject
33
+ })
34
+ }
35
+
36
+ export function downgradeImage(
37
+ blob: Blob,
38
+ maxSizeBytes: number
39
+ ): Promise<Blob> {
40
+ return new Promise((resolve, reject) => {
41
+ const image = new Image()
42
+ image.src = URL.createObjectURL(blob)
43
+ image.onload = () => {
44
+ const width = image.width
45
+ const height = image.height
46
+ let quality = 1.0
47
+
48
+ const canvas = document.createElement('canvas')
49
+ canvas.width = width
50
+ canvas.height = height
51
+
52
+ const context = canvas.getContext('2d')
53
+ context.drawImage(image, 0, 0, width, height)
54
+
55
+ const compressAndResolveBlob = (blobToCompress: Blob) => {
56
+ if (blobToCompress.size <= maxSizeBytes) {
57
+ resolve(blobToCompress)
58
+ } else {
59
+ quality -= 0.1
60
+ if (quality >= 0) {
61
+ canvas.toBlob(compressAndResolveBlob, blob.type, quality)
62
+ } else {
63
+ reject('Unable to compress image below max size')
64
+ }
65
+ }
66
+ }
67
+
68
+ canvas.toBlob(compressAndResolveBlob, blob.type, quality)
69
+ }
70
+ image.onerror = reject
71
+ })
72
+ }