@aquera/nile-elements 0.1.36 → 0.1.38-beta-1.0

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 (241) hide show
  1. package/README.md +13 -0
  2. package/demo/index.html +9 -9
  3. package/demo/variables.css +13 -0
  4. package/dist/{fixture-2b5b3aba.esm.js → fixture-add72f26.esm.js} +1 -1
  5. package/dist/{fixture-7bfb866e.cjs.js → fixture-cb376a7f.cjs.js} +3 -3
  6. package/dist/fixture-cb376a7f.cjs.js.map +1 -0
  7. package/dist/index.cjs.js +1 -1
  8. package/dist/index.esm.js +1 -1
  9. package/dist/lit-html-39a6718c.esm.js +6 -0
  10. package/dist/lit-html-9b3af046.cjs.js +6 -0
  11. package/dist/lit-html-9b3af046.cjs.js.map +1 -0
  12. package/dist/nile-accordion/nile-accordian.test.cjs.js +1 -1
  13. package/dist/nile-accordion/nile-accordian.test.esm.js +1 -1
  14. package/dist/nile-auto-complete/nile-auto-complete.test.cjs.js +1 -1
  15. package/dist/nile-auto-complete/nile-auto-complete.test.cjs.js.map +1 -1
  16. package/dist/nile-auto-complete/nile-auto-complete.test.esm.js +1 -1
  17. package/dist/nile-avatar/nile-avatar.test.cjs.js +1 -1
  18. package/dist/nile-avatar/nile-avatar.test.esm.js +1 -1
  19. package/dist/nile-badge/nile-badge.test.cjs.js +1 -1
  20. package/dist/nile-badge/nile-badge.test.esm.js +1 -1
  21. package/dist/nile-button/nile-button.test.cjs.js +1 -1
  22. package/dist/nile-button/nile-button.test.esm.js +1 -1
  23. package/dist/nile-button-toggle-group/nile-button-toggle-group.test.cjs.js +1 -1
  24. package/dist/nile-button-toggle-group/nile-button-toggle-group.test.esm.js +1 -1
  25. package/dist/nile-calendar/nile-calendar.test.cjs.js +1 -1
  26. package/dist/nile-calendar/nile-calendar.test.esm.js +1 -1
  27. package/dist/nile-card/nile-card.test.cjs.js +1 -1
  28. package/dist/nile-card/nile-card.test.esm.js +1 -1
  29. package/dist/nile-checkbox/nile-checkbox.test.cjs.js +1 -1
  30. package/dist/nile-checkbox/nile-checkbox.test.esm.js +1 -1
  31. package/dist/nile-chip/nile-chip.test.cjs.js +1 -1
  32. package/dist/nile-chip/nile-chip.test.esm.js +1 -1
  33. package/dist/nile-dialog/nile-dialog.test.cjs.js +1 -1
  34. package/dist/nile-dialog/nile-dialog.test.esm.js +1 -1
  35. package/dist/nile-drawer/nile-drawer.test.cjs.js +1 -1
  36. package/dist/nile-drawer/nile-drawer.test.esm.js +1 -1
  37. package/dist/nile-dropdown/nile-dropdown.test.cjs.js +1 -1
  38. package/dist/nile-dropdown/nile-dropdown.test.esm.js +1 -1
  39. package/dist/nile-empty-state/nile-empty-state.test.cjs.js +1 -1
  40. package/dist/nile-empty-state/nile-empty-state.test.esm.js +1 -1
  41. package/dist/nile-error-message/nile-error-message.test.cjs.js +1 -1
  42. package/dist/nile-error-message/nile-error-message.test.esm.js +1 -1
  43. package/dist/nile-file-preview/index.cjs.js +2 -0
  44. package/dist/nile-file-preview/index.cjs.js.map +1 -0
  45. package/dist/nile-file-preview/index.esm.js +1 -0
  46. package/dist/nile-file-preview/nile-file-preview.cjs.js +2 -0
  47. package/dist/nile-file-preview/nile-file-preview.cjs.js.map +1 -0
  48. package/dist/nile-file-preview/nile-file-preview.css.cjs.js +2 -0
  49. package/dist/nile-file-preview/nile-file-preview.css.cjs.js.map +1 -0
  50. package/dist/nile-file-preview/nile-file-preview.css.esm.js +510 -0
  51. package/dist/nile-file-preview/nile-file-preview.esm.js +3 -0
  52. package/dist/nile-file-preview/nile-file-preview.template.cjs.js +2 -0
  53. package/dist/nile-file-preview/nile-file-preview.template.cjs.js.map +1 -0
  54. package/dist/nile-file-preview/nile-file-preview.template.esm.js +179 -0
  55. package/dist/nile-file-preview/nile-file-preview.test.cjs.js +2 -0
  56. package/dist/nile-file-preview/nile-file-preview.test.cjs.js.map +1 -0
  57. package/dist/nile-file-preview/nile-file-preview.test.esm.js +1 -0
  58. package/dist/nile-file-preview/types/index.cjs.js +2 -0
  59. package/dist/nile-file-preview/types/index.cjs.js.map +1 -0
  60. package/dist/nile-file-preview/types/index.esm.js +1 -0
  61. package/dist/nile-file-preview/types/nile-file-preview.enums.cjs.js +2 -0
  62. package/dist/nile-file-preview/types/nile-file-preview.enums.cjs.js.map +1 -0
  63. package/dist/nile-file-preview/types/nile-file-preview.enums.esm.js +1 -0
  64. package/dist/nile-file-preview/types/nile-file-preview.interface.cjs.js +2 -0
  65. package/dist/nile-file-preview/types/nile-file-preview.interface.cjs.js.map +1 -0
  66. package/dist/nile-file-preview/types/nile-file-preview.interface.esm.js +1 -0
  67. package/dist/nile-file-preview/utils/index.cjs.js +2 -0
  68. package/dist/nile-file-preview/utils/index.cjs.js.map +1 -0
  69. package/dist/nile-file-preview/utils/index.esm.js +1 -0
  70. package/dist/nile-file-preview/utils/nile-file-preview.util.cjs.js +2 -0
  71. package/dist/nile-file-preview/utils/nile-file-preview.util.cjs.js.map +1 -0
  72. package/dist/nile-file-preview/utils/nile-file-preview.util.esm.js +1 -0
  73. package/dist/nile-file-upload/index.cjs.js +2 -0
  74. package/dist/nile-file-upload/index.cjs.js.map +1 -0
  75. package/dist/nile-file-upload/index.esm.js +1 -0
  76. package/dist/nile-file-upload/nile-file-upload.cjs.js +2 -0
  77. package/dist/nile-file-upload/nile-file-upload.cjs.js.map +1 -0
  78. package/dist/nile-file-upload/nile-file-upload.css.cjs.js +2 -0
  79. package/dist/nile-file-upload/nile-file-upload.css.cjs.js.map +1 -0
  80. package/dist/nile-file-upload/nile-file-upload.css.esm.js +536 -0
  81. package/dist/nile-file-upload/nile-file-upload.esm.js +3 -0
  82. package/dist/nile-file-upload/nile-file-upload.template.cjs.js +10 -0
  83. package/dist/nile-file-upload/nile-file-upload.template.cjs.js.map +1 -0
  84. package/dist/nile-file-upload/nile-file-upload.template.esm.js +163 -0
  85. package/dist/nile-file-upload/nile-file-upload.test.cjs.js +2 -0
  86. package/dist/nile-file-upload/nile-file-upload.test.cjs.js.map +1 -0
  87. package/dist/nile-file-upload/nile-file-upload.test.esm.js +1 -0
  88. package/dist/nile-file-upload/types/file-upload.enums.cjs.js +2 -0
  89. package/dist/nile-file-upload/types/file-upload.enums.cjs.js.map +1 -0
  90. package/dist/nile-file-upload/types/file-upload.enums.esm.js +1 -0
  91. package/dist/nile-file-upload/types/file-upload.type.cjs.js +2 -0
  92. package/dist/nile-file-upload/types/file-upload.type.cjs.js.map +1 -0
  93. package/dist/nile-file-upload/types/file-upload.type.esm.js +1 -0
  94. package/dist/nile-file-upload/types/index.cjs.js +2 -0
  95. package/dist/nile-file-upload/types/index.cjs.js.map +1 -0
  96. package/dist/nile-file-upload/types/index.esm.js +1 -0
  97. package/dist/nile-file-upload/utils/drag-drop.util.cjs.js +2 -0
  98. package/dist/nile-file-upload/utils/drag-drop.util.cjs.js.map +1 -0
  99. package/dist/nile-file-upload/utils/drag-drop.util.esm.js +1 -0
  100. package/dist/nile-file-upload/utils/file-validation.util.cjs.js +2 -0
  101. package/dist/nile-file-upload/utils/file-validation.util.cjs.js.map +1 -0
  102. package/dist/nile-file-upload/utils/file-validation.util.esm.js +1 -0
  103. package/dist/nile-filter-chip/index.cjs.js +2 -0
  104. package/dist/nile-filter-chip/index.cjs.js.map +1 -0
  105. package/dist/nile-filter-chip/index.esm.js +1 -0
  106. package/dist/nile-filter-chip/nile-filter-chip.cjs.js +2 -0
  107. package/dist/nile-filter-chip/nile-filter-chip.cjs.js.map +1 -0
  108. package/dist/nile-filter-chip/nile-filter-chip.css.cjs.js +2 -0
  109. package/dist/nile-filter-chip/nile-filter-chip.css.cjs.js.map +1 -0
  110. package/dist/nile-filter-chip/nile-filter-chip.css.esm.js +121 -0
  111. package/dist/nile-filter-chip/nile-filter-chip.esm.js +43 -0
  112. package/dist/nile-filter-chip/nile-filter-chip.test.cjs.js +2 -0
  113. package/dist/nile-filter-chip/nile-filter-chip.test.cjs.js.map +1 -0
  114. package/dist/nile-filter-chip/nile-filter-chip.test.esm.js +20 -0
  115. package/dist/nile-form-group/nile-form-group.test.cjs.js +1 -1
  116. package/dist/nile-form-group/nile-form-group.test.esm.js +1 -1
  117. package/dist/nile-form-help-text/nile-form-help-text.test.cjs.js +1 -1
  118. package/dist/nile-form-help-text/nile-form-help-text.test.esm.js +1 -1
  119. package/dist/nile-hero/nile-hero.test.cjs.js +1 -1
  120. package/dist/nile-hero/nile-hero.test.esm.js +1 -1
  121. package/dist/nile-icon/nile-icon.test.cjs.js +1 -1
  122. package/dist/nile-icon/nile-icon.test.esm.js +1 -1
  123. package/dist/nile-input/nile-input.test.cjs.js +1 -1
  124. package/dist/nile-input/nile-input.test.esm.js +1 -1
  125. package/dist/nile-link/nile-link.test.cjs.js +1 -1
  126. package/dist/nile-link/nile-link.test.esm.js +1 -1
  127. package/dist/nile-loader/nile-loader.test.cjs.js +1 -1
  128. package/dist/nile-loader/nile-loader.test.esm.js +1 -1
  129. package/dist/nile-popover/index.cjs.js +1 -1
  130. package/dist/nile-popover/index.esm.js +1 -1
  131. package/dist/nile-popover/nile-popover.cjs.js +3 -11
  132. package/dist/nile-popover/nile-popover.cjs.js.map +1 -1
  133. package/dist/nile-popover/nile-popover.esm.js +7 -13
  134. package/dist/nile-popover/nile-popover.test.cjs.js +1 -1
  135. package/dist/nile-popover/nile-popover.test.cjs.js.map +1 -1
  136. package/dist/nile-popover/nile-popover.test.esm.js +3 -3
  137. package/dist/nile-popup/nile-popup.test.cjs.js +1 -1
  138. package/dist/nile-popup/nile-popup.test.esm.js +1 -1
  139. package/dist/nile-progress-bar/nile-progress-bar.test.cjs.js +1 -1
  140. package/dist/nile-progress-bar/nile-progress-bar.test.esm.js +1 -1
  141. package/dist/nile-radio/nile-radio.test.cjs.js +1 -1
  142. package/dist/nile-radio/nile-radio.test.esm.js +1 -1
  143. package/dist/nile-radio-group/nile-radio-group.test.cjs.js +1 -1
  144. package/dist/nile-radio-group/nile-radio-group.test.esm.js +1 -1
  145. package/dist/nile-select/nile-select.test.cjs.js +1 -1
  146. package/dist/nile-select/nile-select.test.esm.js +1 -1
  147. package/dist/nile-slide-toggle/nile-slide-toggle.test.cjs.js +1 -1
  148. package/dist/nile-slide-toggle/nile-slide-toggle.test.esm.js +1 -1
  149. package/dist/nile-tab-group/nile-tab-group.test.cjs.js +1 -1
  150. package/dist/nile-tab-group/nile-tab-group.test.esm.js +1 -1
  151. package/dist/nile-textarea/nile-textarea.test.cjs.js +1 -1
  152. package/dist/nile-textarea/nile-textarea.test.esm.js +1 -1
  153. package/dist/src/index.d.ts +3 -0
  154. package/dist/src/index.js +3 -0
  155. package/dist/src/index.js.map +1 -1
  156. package/dist/src/nile-file-preview/nile-file-preview.css.js +32 -43
  157. package/dist/src/nile-file-preview/nile-file-preview.css.js.map +1 -1
  158. package/dist/src/nile-file-preview/nile-file-preview.d.ts +3 -1
  159. package/dist/src/nile-file-preview/nile-file-preview.js +27 -5
  160. package/dist/src/nile-file-preview/nile-file-preview.js.map +1 -1
  161. package/dist/src/nile-file-preview/nile-file-preview.template.d.ts +2 -0
  162. package/dist/src/nile-file-preview/nile-file-preview.template.js +114 -48
  163. package/dist/src/nile-file-preview/nile-file-preview.template.js.map +1 -1
  164. package/dist/src/nile-file-preview/types/index.d.ts +2 -2
  165. package/dist/src/nile-file-preview/types/index.js +2 -2
  166. package/dist/src/nile-file-preview/types/index.js.map +1 -1
  167. package/dist/src/nile-file-preview/types/nile-file-preview.enums.d.ts +28 -0
  168. package/dist/src/nile-file-preview/types/nile-file-preview.enums.js +33 -0
  169. package/dist/src/nile-file-preview/types/nile-file-preview.enums.js.map +1 -0
  170. package/dist/src/nile-file-preview/types/nile-file-preview.interface.d.ts +4 -0
  171. package/dist/src/nile-file-preview/types/nile-file-preview.interface.js +2 -0
  172. package/dist/src/nile-file-preview/types/nile-file-preview.interface.js.map +1 -0
  173. package/dist/src/nile-file-preview/utils/index.d.ts +1 -1
  174. package/dist/src/nile-file-preview/utils/index.js +1 -1
  175. package/dist/src/nile-file-preview/utils/index.js.map +1 -1
  176. package/dist/src/nile-file-preview/utils/nile-file-preview.util.d.ts +4 -0
  177. package/dist/src/nile-file-preview/utils/nile-file-preview.util.js +38 -0
  178. package/dist/src/nile-file-preview/utils/nile-file-preview.util.js.map +1 -0
  179. package/dist/src/nile-file-upload/nile-file-upload.css.js +2 -1
  180. package/dist/src/nile-file-upload/nile-file-upload.css.js.map +1 -1
  181. package/dist/src/nile-file-upload/nile-file-upload.d.ts +3 -0
  182. package/dist/src/nile-file-upload/nile-file-upload.js +22 -5
  183. package/dist/src/nile-file-upload/nile-file-upload.js.map +1 -1
  184. package/dist/src/nile-file-upload/nile-file-upload.template.js +27 -19
  185. package/dist/src/nile-file-upload/nile-file-upload.template.js.map +1 -1
  186. package/dist/src/nile-file-upload/types/file-upload.enums.d.ts +9 -2
  187. package/dist/src/nile-file-upload/types/file-upload.enums.js +8 -1
  188. package/dist/src/nile-file-upload/types/file-upload.enums.js.map +1 -1
  189. package/dist/src/nile-file-upload/utils/drag-drop.util.d.ts +5 -1
  190. package/dist/src/nile-file-upload/utils/drag-drop.util.js +9 -1
  191. package/dist/src/nile-file-upload/utils/drag-drop.util.js.map +1 -1
  192. package/dist/src/nile-file-upload/utils/file-validation.util.d.ts +3 -1
  193. package/dist/src/nile-file-upload/utils/file-validation.util.js +72 -10
  194. package/dist/src/nile-file-upload/utils/file-validation.util.js.map +1 -1
  195. package/dist/src/nile-filter-chip/index.d.ts +1 -0
  196. package/dist/src/nile-filter-chip/index.js +2 -0
  197. package/dist/src/nile-filter-chip/index.js.map +1 -0
  198. package/dist/src/nile-filter-chip/nile-filter-chip.css.d.ts +12 -0
  199. package/dist/src/nile-filter-chip/nile-filter-chip.css.js +133 -0
  200. package/dist/src/nile-filter-chip/nile-filter-chip.css.js.map +1 -0
  201. package/dist/src/nile-filter-chip/nile-filter-chip.d.ts +36 -0
  202. package/dist/src/nile-filter-chip/nile-filter-chip.js +141 -0
  203. package/dist/src/nile-filter-chip/nile-filter-chip.js.map +1 -0
  204. package/dist/src/nile-filter-chip/nile-filter-chip.test.d.ts +1 -0
  205. package/dist/src/nile-filter-chip/nile-filter-chip.test.js +80 -0
  206. package/dist/src/nile-filter-chip/nile-filter-chip.test.js.map +1 -0
  207. package/dist/src/nile-tooltip/nile-tooltip-utils.d.ts +18 -0
  208. package/dist/src/nile-tooltip/nile-tooltip-utils.js +216 -0
  209. package/dist/src/nile-tooltip/nile-tooltip-utils.js.map +1 -0
  210. package/dist/src/nile-tooltip/nile-tooltip.test.d.ts +1 -0
  211. package/dist/src/nile-tooltip/nile-tooltip.test.js +148 -0
  212. package/dist/src/nile-tooltip/nile-tooltip.test.js.map +1 -0
  213. package/dist/tsconfig.tsbuildinfo +1 -1
  214. package/package.json +1 -1
  215. package/src/index.ts +4 -1
  216. package/src/nile-file-preview/index.ts +1 -0
  217. package/src/nile-file-preview/nile-file-preview.css.ts +524 -0
  218. package/src/nile-file-preview/nile-file-preview.template.ts +248 -0
  219. package/src/nile-file-preview/nile-file-preview.test.ts +38 -0
  220. package/src/nile-file-preview/nile-file-preview.ts +173 -0
  221. package/src/nile-file-preview/types/index.ts +2 -0
  222. package/src/nile-file-preview/types/nile-file-preview.enums.ts +31 -0
  223. package/src/nile-file-preview/types/nile-file-preview.interface.ts +4 -0
  224. package/src/nile-file-preview/utils/index.ts +1 -0
  225. package/src/nile-file-preview/utils/nile-file-preview.util.ts +47 -0
  226. package/src/nile-file-upload/index.ts +1 -0
  227. package/src/nile-file-upload/nile-file-upload.css.ts +550 -0
  228. package/src/nile-file-upload/nile-file-upload.template.ts +201 -0
  229. package/src/nile-file-upload/nile-file-upload.test.ts +38 -0
  230. package/src/nile-file-upload/nile-file-upload.ts +149 -0
  231. package/src/nile-file-upload/types/file-upload.enums.ts +39 -0
  232. package/src/nile-file-upload/types/file-upload.type.ts +5 -0
  233. package/src/nile-file-upload/types/index.ts +2 -0
  234. package/src/nile-file-upload/utils/drag-drop.util.ts +106 -0
  235. package/src/nile-file-upload/utils/file-validation.util.ts +163 -0
  236. package/src/nile-filter-chip/index.ts +1 -0
  237. package/src/nile-filter-chip/nile-filter-chip.css.ts +138 -0
  238. package/src/nile-filter-chip/nile-filter-chip.test.ts +92 -0
  239. package/src/nile-filter-chip/nile-filter-chip.ts +136 -0
  240. package/vscode-html-custom-data.json +192 -0
  241. package/dist/fixture-7bfb866e.cjs.js.map +0 -1
@@ -11,7 +11,7 @@ import { customElement, property } from 'lit/decorators.js';
11
11
  import { generatePreviewUrl } from './utils';
12
12
  import { FilePreviewState, FilePreviewVariant, FilePreviewErrorMessages, FilePreviewEvent } from './types';
13
13
  import { html } from 'lit';
14
- import { getHorizontalErrorState, getHorizontalNoPreviewState, getHorizontalPreviewState, getVerticalErrorState, getVerticalNoPreviewState, getVerticalPreviewState } from './nile-file-preview.template';
14
+ import { getHorizontalErrorState, getHorizontalNoPreviewState, getHorizontalPreviewState, getHorizontalUploadingState, getVerticalErrorState, getVerticalNoPreviewState, getVerticalPreviewState, getVerticalUploadingState } from './nile-file-preview.template';
15
15
  /**
16
16
  * Nile preview component.
17
17
  *
@@ -30,6 +30,7 @@ let NileFilePreview = class NileFilePreview extends NileElement {
30
30
  this.inputFileName = "";
31
31
  this.inputFileHtml = null;
32
32
  this.originalUrl = "";
33
+ this.dummyFile = new File(['sdfjbs ewhf'], "dummy.txt", { type: "text/plain" });
33
34
  /* #endregion */
34
35
  }
35
36
  /**
@@ -48,7 +49,16 @@ let NileFilePreview = class NileFilePreview extends NileElement {
48
49
  this.emit(FilePreviewEvent.NILE_INIT);
49
50
  }
50
51
  updated(changedProperties) {
51
- if (changedProperties.has('inputFile') && this.inputFile) {
52
+ if (changedProperties.has('uploadStatus') && this.uploadStatus) {
53
+ if (this.uploadStatus < 100) {
54
+ this.createUploadState(this.inputFile, this.uploadStatus);
55
+ this.emit(FilePreviewEvent.NILE_UPLOADING);
56
+ }
57
+ else {
58
+ this.createState(this.inputFile);
59
+ }
60
+ }
61
+ else if (changedProperties.has('inputFile') && this.inputFile) {
52
62
  this.createState(this.inputFile);
53
63
  this.emit(FilePreviewEvent.NILE_RECEIVE);
54
64
  }
@@ -56,6 +66,16 @@ let NileFilePreview = class NileFilePreview extends NileElement {
56
66
  this.handleFileUrl(this.fileUrl);
57
67
  this.emit(FilePreviewEvent.NILE_RECEIVE);
58
68
  }
69
+ else if (changedProperties.has('errorMessage')) {
70
+ this.createState(this.inputFile);
71
+ }
72
+ }
73
+ createUploadState(file, uploadStatus) {
74
+ const isHorizontal = this.variant === FilePreviewVariant.HORIZONTAL;
75
+ this.inputFileHtml = isHorizontal
76
+ ? getHorizontalUploadingState(file, uploadStatus)
77
+ : getVerticalUploadingState(file, uploadStatus);
78
+ this.requestUpdate();
59
79
  }
60
80
  async handleFileUrl(url) {
61
81
  this.originalUrl = url;
@@ -77,7 +97,7 @@ let NileFilePreview = class NileFilePreview extends NileElement {
77
97
  }
78
98
  async createState(file) {
79
99
  const isHorizontal = this.variant === FilePreviewVariant.HORIZONTAL;
80
- if (this.allowedTypes.includes(file.type)) {
100
+ if (this.allowedTypes.includes(file.type) && !this.errorMessage) {
81
101
  if (file.type.startsWith('image/')) {
82
102
  try {
83
103
  const url = await generatePreviewUrl(file);
@@ -98,7 +118,9 @@ let NileFilePreview = class NileFilePreview extends NileElement {
98
118
  }
99
119
  }
100
120
  else {
101
- this.errorMessage = FilePreviewErrorMessages.INVALID_FORMAT;
121
+ this.errorMessage = !this.errorMessage
122
+ ? FilePreviewErrorMessages.INVALID_FORMAT
123
+ : FilePreviewErrorMessages.UPLOAD_CANCEL;
102
124
  this.inputFileHtml = isHorizontal
103
125
  ? getHorizontalErrorState(file, this.errorMessage, this.originalUrl)
104
126
  : getVerticalErrorState(file, this.errorMessage, this.originalUrl);
@@ -142,7 +164,7 @@ __decorate([
142
164
  property({ type: String })
143
165
  ], NileFilePreview.prototype, "inputFileName", void 0);
144
166
  NileFilePreview = __decorate([
145
- customElement('nile-preview')
167
+ customElement('nile-file-preview')
146
168
  ], NileFilePreview);
147
169
  export { NileFilePreview };
148
170
  export default NileFilePreview;
@@ -1 +1 @@
1
- {"version":3,"file":"nile-file-preview.js","sourceRoot":"","sources":["../../../src/nile-file-preview/nile-file-preview.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAEH,OAAO,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AAC/C,OAAO,WAAW,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3G,OAAO,EAAc,IAAI,EAAkD,MAAM,KAAK,CAAC;AACvF,OAAO,EACL,uBAAuB,EACvB,2BAA2B,EAC3B,yBAAyB,EACzB,qBAAqB,EACrB,yBAAyB,EACzB,uBAAuB,EACxB,MAAM,8BAA8B,CAAC;AAGtC;;;;;GAKG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,WAAW;IAAzC;;QASuB,iBAAY,GAAW,EAAE,CAAC;QAE3B,YAAO,GAAW,EAAE,CAAC;QACrB,iBAAY,GAAW,CAAC,CAAC;QACzB,iBAAY,GAAa,EAAE,CAAC;QAC5B,UAAK,GAAqB,gBAAgB,CAAC,OAAO,CAAC;QACnD,YAAO,GAAuB,kBAAkB,CAAC,UAAU,CAAC;QAC3D,kBAAa,GAAW,EAAE,CAAC;QAChD,kBAAa,GAA0B,IAAI,CAAC;QAC3C,gBAAW,GAAW,EAAE,CAAC;QAwFjC,gBAAgB;IAClB,CAAC;IA1GC;;;OAGG;IACI,MAAM,KAAK,MAAM;QACtB,OAAO,CAAC,MAAM,CAAC,CAAC;IAClB,CAAC;IAaD;;;OAGG;IAEH,iBAAiB;QACf,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC1B,IAAI,CAAC,IAAI,CAAC,gBAA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A3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAAoD;AACnD;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDAA6D;AAC3D;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sDAA4B;AAhB5C,eAAe;IAD3B,aAAa,CAAC,cAAc,CAAC;GACjB,eAAe,CA2G3B;;AAED,eAAe,eAAe,CAAC","sourcesContent":["/**\n * Copyright Aquera Inc 2025\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport {styles} from './nile-file-preview.css';\nimport NileElement from '../internal/nile-element';\nimport { customElement, property } from 'lit/decorators.js';\nimport { generatePreviewUrl } from './utils';\nimport { FilePreviewState, FilePreviewVariant, FilePreviewErrorMessages, FilePreviewEvent } from './types';\nimport { LitElement, html, CSSResultArray, TemplateResult, PropertyValues } from 'lit';\nimport {\n getHorizontalErrorState,\n getHorizontalNoPreviewState,\n getHorizontalPreviewState,\n getVerticalErrorState,\n getVerticalNoPreviewState,\n getVerticalPreviewState\n} from './nile-file-preview.template';\n\n\n/**\n * Nile preview component.\n *\n * @tag nile-preview\n *\n */\n@customElement('nile-preview')\nexport class NileFilePreview extends NileElement {\n /**\n * The styles for nile-preview\n * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`\n */\n public static get styles(): CSSResultArray {\n return [styles];\n }\n\n @property({ type: String }) errorMessage: string = \"\";\n\t@property({ type: Object }) inputFile: File; \n\t@property({ type: String }) fileUrl: string = \"\";\n\t@property({ type: Number }) uploadStatus: number = 0;\n @property({ type: Array }) allowedTypes: string[] = [];\n\t@property({ type: String }) state: FilePreviewState = FilePreviewState.DEFAULT;\n\t@property({ type: String }) variant: FilePreviewVariant = FilePreviewVariant.HORIZONTAL;\n @property({ type: String }) inputFileName: string = \"\";\n\tprivate inputFileHtml: TemplateResult | null = null;\n private originalUrl: string = \"\";\n\n /**\n * Render method\n * @slot This is a slot test\n */\n\n connectedCallback(): void {\n super.connectedCallback();\n this.emit(FilePreviewEvent.NILE_INIT);\n }\n\n protected updated(changedProperties: PropertyValues): void {\n\n if (changedProperties.has('inputFile') && this.inputFile) {\n this.createState(this.inputFile);\n this.emit(FilePreviewEvent.NILE_RECEIVE);\n\n } else if (changedProperties.has('fileUrl') && this.fileUrl) {\n this.handleFileUrl(this.fileUrl);\n this.emit(FilePreviewEvent.NILE_RECEIVE);\n }\n }\n\n private async handleFileUrl(url: string): Promise<void> {\n this.originalUrl = url;\n try {\n const response = await fetch(url);\n const blob = await response.blob();\n const fileName = this.inputFileName || url.split('/').pop() || FilePreviewErrorMessages.UNKNOWN_FILE_NAME;\n const file = new File([blob], fileName, { type: blob.type });\n\n this.createState(file);\n } catch (error) {\n const dummyFile = new File([], this.inputFileName || FilePreviewErrorMessages.UNKNOWN_FILE_NAME, { type: 'application/octet-stream' });\n this.errorMessage = FilePreviewErrorMessages.FAILED_TO_LOAD;\n\n this.inputFileHtml = this.variant === FilePreviewVariant.HORIZONTAL\n ? getHorizontalErrorState(dummyFile, this.errorMessage, this.originalUrl)\n : getVerticalErrorState(dummyFile, this.errorMessage, this.originalUrl);\n this.requestUpdate();\n }\n }\n\n\tpublic async createState(file: File): Promise<void> {\n const isHorizontal = this.variant === FilePreviewVariant.HORIZONTAL;\n\n if (this.allowedTypes.includes(file.type)) { \n if (file.type.startsWith('image/')) {\n try {\n const url = await generatePreviewUrl(file);\n this.inputFileHtml = isHorizontal\n ? getHorizontalPreviewState(url, file, this.originalUrl)\n : getVerticalPreviewState(url, file, this.originalUrl);\n } catch (error) {\n this.inputFileHtml = isHorizontal\n ? getHorizontalNoPreviewState(file, this.originalUrl)\n : getVerticalNoPreviewState(file, this.originalUrl); \n }\n } else {\n this.inputFileHtml = isHorizontal\n ? getHorizontalNoPreviewState(file, this.originalUrl)\n : getVerticalNoPreviewState(file, this.originalUrl);\n }\n } else {\n this.errorMessage = FilePreviewErrorMessages.INVALID_FORMAT;\n\n this.inputFileHtml = isHorizontal\n ? getHorizontalErrorState(file, this.errorMessage, this.originalUrl)\n : getVerticalErrorState(file, this.errorMessage, this.originalUrl);\n }\n this.requestUpdate();\n }\n\n public render(): TemplateResult {\n return html`\n\t\t\t${this.inputFileHtml ?\n\t\t\t\tthis.inputFileHtml :\n\t\t\t\thtml``\n\t\t\t}\n `;\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n this.emit(FilePreviewEvent.NILE_DESTROY);\n }\n\n /* #endregion */\n}\n\nexport default NileFilePreview;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-preview': NileFilePreview;\n }\n}"]}
1
+ {"version":3,"file":"nile-file-preview.js","sourceRoot":"","sources":["../../../src/nile-file-preview/nile-file-preview.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAEH,OAAO,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AAC/C,OAAO,WAAW,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3G,OAAO,EAAc,IAAI,EAAkD,MAAM,KAAK,CAAC;AACvF,OAAO,EACL,uBAAuB,EACvB,2BAA2B,EAC3B,yBAAyB,EACzB,2BAA2B,EAC3B,qBAAqB,EACrB,yBAAyB,EACzB,uBAAuB,EACvB,yBAAyB,EAC1B,MAAM,8BAA8B,CAAC;AAGtC;;;;;GAKG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,WAAW;IAAzC;;QASuB,iBAAY,GAAW,EAAE,CAAC;QAE3B,YAAO,GAAW,EAAE,CAAC;QACrB,iBAAY,GAAW,CAAC,CAAC;QACxB,iBAAY,GA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QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAAiB;AAChB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDAAsB;AACrB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qDAA0B;AACxB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAG,CAAC;qDAA6B;AAC7B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAAoD;AACnD;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDAA6D;AAC3D;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sDAA4B;AAhB5C,eAAe;IAD3B,aAAa,CAAC,mBAAmB,CAAC;GACtB,eAAe,CAoI3B;;AAED,eAAe,eAAe,CAAC","sourcesContent":["/**\n * Copyright Aquera Inc 2025\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport {styles} from './nile-file-preview.css';\nimport NileElement from '../internal/nile-element';\nimport { customElement, property } from 'lit/decorators.js';\nimport { generatePreviewUrl } from './utils';\nimport { FilePreviewState, FilePreviewVariant, FilePreviewErrorMessages, FilePreviewEvent } from './types';\nimport { LitElement, html, CSSResultArray, TemplateResult, PropertyValues } from 'lit';\nimport {\n getHorizontalErrorState,\n getHorizontalNoPreviewState,\n getHorizontalPreviewState,\n getHorizontalUploadingState,\n getVerticalErrorState,\n getVerticalNoPreviewState,\n getVerticalPreviewState,\n getVerticalUploadingState\n} from './nile-file-preview.template';\n\n\n/**\n * Nile preview component.\n *\n * @tag nile-preview\n *\n */\n@customElement('nile-file-preview')\nexport class NileFilePreview extends NileElement {\n /**\n * The styles for nile-preview\n * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`\n */\n public static get styles(): CSSResultArray {\n return [styles];\n }\n\n @property({ type: String }) errorMessage: string = \"\";\n\t@property({ type: Object }) inputFile: File; \n\t@property({ type: String }) fileUrl: string = \"\";\n\t@property({ type: Number }) uploadStatus: number = 0;\n @property({ type: Array }) allowedTypes: string[] = [];\n\t@property({ type: String }) state: FilePreviewState = FilePreviewState.DEFAULT;\n\t@property({ type: String }) variant: FilePreviewVariant = FilePreviewVariant.HORIZONTAL;\n @property({ type: String }) inputFileName: string = \"\";\n\tprivate inputFileHtml: TemplateResult | null = null;\n private originalUrl: string = \"\";\n\n /**\n * Render method\n * @slot This is a slot test\n */\n\n connectedCallback(): void {\n super.connectedCallback();\n this.emit(FilePreviewEvent.NILE_INIT);\n }\n\n protected updated(changedProperties: PropertyValues): void {\n if(changedProperties.has('uploadStatus') && this.uploadStatus) {\n if(this.uploadStatus < 100) {\n this.createUploadState(this.inputFile, this.uploadStatus);\n this.emit(FilePreviewEvent.NILE_UPLOADING);\n\n } else {\n this.createState(this.inputFile);\n }\n\n } else if (changedProperties.has('inputFile') && this.inputFile) {\n this.createState(this.inputFile);\n this.emit(FilePreviewEvent.NILE_RECEIVE);\n\n } else if (changedProperties.has('fileUrl') && this.fileUrl) {\n this.handleFileUrl(this.fileUrl);\n this.emit(FilePreviewEvent.NILE_RECEIVE);\n\n } else if (changedProperties.has('errorMessage')) {\n this.createState(this.inputFile);\n }\n }\n\n private createUploadState( file: File, uploadStatus: number): void {\n const isHorizontal = this.variant === FilePreviewVariant.HORIZONTAL;\n\n this.inputFileHtml = isHorizontal \n ? getHorizontalUploadingState(file, uploadStatus)\n : getVerticalUploadingState(file, uploadStatus);\n\n this.requestUpdate();\n }\n\n private async handleFileUrl(url: string): Promise<void> {\n this.originalUrl = url;\n try {\n const response = await fetch(url);\n const blob = await response.blob();\n const fileName = this.inputFileName || url.split('/').pop() || FilePreviewErrorMessages.UNKNOWN_FILE_NAME;\n const file = new File([blob], fileName, { type: blob.type });\n\n this.createState(file);\n } catch (error) {\n const dummyFile = new File([], this.inputFileName || FilePreviewErrorMessages.UNKNOWN_FILE_NAME, { type: 'application/octet-stream' });\n this.errorMessage = FilePreviewErrorMessages.FAILED_TO_LOAD;\n\n this.inputFileHtml = this.variant === FilePreviewVariant.HORIZONTAL\n ? getHorizontalErrorState(dummyFile, this.errorMessage, this.originalUrl)\n : getVerticalErrorState(dummyFile, this.errorMessage, this.originalUrl);\n this.requestUpdate();\n }\n }\n\n\tpublic async createState(file: File): Promise<void> {\n const isHorizontal = this.variant === FilePreviewVariant.HORIZONTAL;\n\n if (this.allowedTypes.includes(file.type) && !this.errorMessage) { \n if (file.type.startsWith('image/')) {\n try {\n const url = await generatePreviewUrl(file);\n this.inputFileHtml = isHorizontal\n ? getHorizontalPreviewState(url, file, this.originalUrl)\n : getVerticalPreviewState(url, file, this.originalUrl);\n } catch (error) {\n this.inputFileHtml = isHorizontal\n ? getHorizontalNoPreviewState(file, this.originalUrl)\n : getVerticalNoPreviewState(file, this.originalUrl); \n }\n } else {\n this.inputFileHtml = isHorizontal\n ? getHorizontalNoPreviewState(file, this.originalUrl)\n : getVerticalNoPreviewState(file, this.originalUrl);\n }\n } else {\n this.errorMessage = !this.errorMessage\n ? FilePreviewErrorMessages.INVALID_FORMAT\n : FilePreviewErrorMessages.UPLOAD_CANCEL;\n\n this.inputFileHtml = isHorizontal\n ? getHorizontalErrorState(file, this.errorMessage, this.originalUrl)\n : getVerticalErrorState(file, this.errorMessage, this.originalUrl);\n }\n this.requestUpdate();\n }\n\n private dummyFile = new File(['sdfjbs ewhf'], \"dummy.txt\", { type: \"text/plain\" });\n\n public render(): TemplateResult {\n return html`\n\t\t\t${this.inputFileHtml ?\n\t\t\t\tthis.inputFileHtml :\n\t\t\t\thtml``\n\t\t\t}\n `;\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n this.emit(FilePreviewEvent.NILE_DESTROY);\n }\n\n /* #endregion */\n}\n\nexport default NileFilePreview;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-file-preview': NileFilePreview;\n }\n}"]}
@@ -3,9 +3,11 @@
3
3
  */
4
4
  import './nile-file-preview.css';
5
5
  import { TemplateResult } from 'lit';
6
+ export declare function getHorizontalUploadingState(file: File, uploadStatus: number): TemplateResult;
6
7
  export declare function getHorizontalPreviewState(url: string, file: File, originalUrl: string): TemplateResult;
7
8
  export declare function getHorizontalNoPreviewState(file: File, originalUrl: string): TemplateResult;
8
9
  export declare function getHorizontalErrorState(file: File, errorMessage: string, originalUrl: string): TemplateResult;
10
+ export declare function getVerticalUploadingState(file: File, uploadStatus: number): TemplateResult;
9
11
  export declare function getVerticalPreviewState(url: string, file: File, originalUrl: string): TemplateResult;
10
12
  export declare function getVerticalNoPreviewState(file: File, originalUrl: string): TemplateResult;
11
13
  export declare function getVerticalErrorState(file: File, errorMessage: string, originalUrl: string): TemplateResult;
@@ -3,27 +3,55 @@
3
3
  */
4
4
  import './nile-file-preview.css';
5
5
  import { html } from 'lit';
6
- import { removeFile } from './utils';
6
+ import { removeFile, cancelFileUpload } from './utils';
7
+ export function getHorizontalUploadingState(file, uploadStatus) {
8
+ return html `
9
+ <div class="uploading">
10
+ <nile-loader width="24" height="24"></nile-loader>
11
+ <div class="progress-bar-container">
12
+ <div class="progress-bar-percent">
13
+ <p>Uploading File...</p>
14
+ <p>${uploadStatus}%</p>
15
+ </div>
16
+ <nile-progress-bar
17
+ value="${uploadStatus}"
18
+ ></nile-progress-bar>
19
+ <p>${file.name}</p>
20
+ </div>
21
+ <slot @click=${(e) => cancelFileUpload(file, e)} name="cancelIcon">
22
+ <nile-icon
23
+ name="close"
24
+ size="14"
25
+ class="icon"
26
+ ></nile-icon>
27
+ </slot>
28
+ </div>
29
+ `;
30
+ }
7
31
  export function getHorizontalPreviewState(url, file, originalUrl) {
8
32
  return html `
9
33
  <div class="preview horizontal-div">
10
34
  <div class="preview-inner">
11
35
  <div class="preview-image-container">
12
- ${file.type.startsWith('image/')
13
- ? html `<img src="${url}" alt="Image Preview" />`
14
- : html `<iframe src="${url}" type="${file.type}" width="40px" height="40px" />`}
36
+ <img
37
+ class="image-preview"
38
+ src=${url}
39
+ alt=${file.name}
40
+ />
15
41
  </div>
16
42
  <div class="preview-file-info">
17
43
  <p>${file.name}</p>
18
- <p>${(file.type.split('/')[1]).toUpperCase()} &#8226; ${(Number(file.size) / 1000).toFixed(0)}KB</p>
44
+ <p>${(file.type.split('/')[1]).toUpperCase()} &#8226; ${(Number(file.size) / 1024).toFixed(0)}KB</p>
19
45
  </div>
20
46
  </div>
21
- <nile-icon
22
- @click=${(e) => removeFile(file, e, originalUrl)}
23
- name="trash"
24
- size="14"
25
- class="icon"
26
- ></nile-icon>
47
+ <slot name="cancelIcon">
48
+ <nile-icon
49
+ @click=${(e) => removeFile(file, e, originalUrl)}
50
+ name="trash"
51
+ size="14"
52
+ class="icon"
53
+ ></nile-icon>
54
+ </slot>
27
55
  </div>
28
56
  `;
29
57
  }
@@ -36,16 +64,18 @@ export function getHorizontalNoPreviewState(file, originalUrl) {
36
64
  </div>
37
65
  <div class="preview-file-info">
38
66
  <p>${file.name}</p>
39
- <p>${(file.type.split('/')[1]).toUpperCase()} &#8226; ${(Number(file.size) / 1000).toFixed(0)}KB</p>
67
+ <p>${(file.type.split('/')[1]).toUpperCase()} &#8226; ${(Number(file.size) / 1034).toFixed(0)}KB</p>
40
68
  </div>
41
69
  </div>
42
70
  <div>
43
- <nile-icon
44
- @click=${(e) => removeFile(file, e, originalUrl)}
45
- name="trash"
46
- size="14"
47
- class="icon"
48
- ></nile-icon>
71
+ <slot name="cancelIcon">
72
+ <nile-icon
73
+ @click=${(e) => removeFile(file, e, originalUrl)}
74
+ name="trash"
75
+ size="14"
76
+ class="icon"
77
+ ></nile-icon>
78
+ </slot>
49
79
  </div>
50
80
  </div>
51
81
  `;
@@ -59,19 +89,50 @@ export function getHorizontalErrorState(file, errorMessage, originalUrl) {
59
89
  </div>
60
90
  <div class="file-info">
61
91
  <p>${file.name}</p>
62
- <p>${errorMessage}</p>
92
+ <nile-tooltip content=${errorMessage}>
93
+ <p>${errorMessage}</p>
94
+ </nile-tooltip>
63
95
  </div>
64
96
  </div>
65
- <nile-icon
66
- @click=${(e) => removeFile(file, e, originalUrl)}
67
- name="close"
68
- size="14"
69
- class="icon"
70
- ></nile-icon>
97
+ <slot name="cancelIcon">
98
+ <nile-icon
99
+ @click=${(e) => removeFile(file, e, originalUrl)}
100
+ name="close"
101
+ size="14"
102
+ class="icon"
103
+ ></nile-icon>
104
+ </slot>
71
105
  </div>
72
106
  `;
73
107
  }
74
108
  // vertical states
109
+ export function getVerticalUploadingState(file, uploadStatus) {
110
+ return html `
111
+ <div class="vertical-div vertical-uploading">
112
+ <div class="loading">
113
+ <nile-loader width="24" height="24"></nile-loader>
114
+ </div>
115
+
116
+ <div class="progress-bar-container">
117
+ <div class="progress-bar-percent">
118
+ <p>Uploading...</p>
119
+ <p>${uploadStatus}%</p>
120
+ </div>
121
+ <nile-progress-bar value=${uploadStatus}></nile-progress-bar>
122
+ <p>${file.name}</p>
123
+ </div>
124
+
125
+ <slot name="cancelIcon">
126
+ <nile-icon
127
+ @click=${(e) => cancelFileUpload(file, e)}
128
+ name="close"
129
+ size="14"
130
+ class="icon corner-icon"
131
+ ></nile-icon>
132
+ </slot>
133
+ </div>
134
+ `;
135
+ }
75
136
  export function getVerticalPreviewState(url, file, originalUrl) {
76
137
  return html `
77
138
  <div class="vertical-div vertical-preview">
@@ -85,15 +146,17 @@ export function getVerticalPreviewState(url, file, originalUrl) {
85
146
 
86
147
  <div class="content-container">
87
148
  <p>${file.name}</p>
88
- <p>${(file.type.split('/')[1]).toUpperCase()} &#8226; ${(Number(file.size) / 1000).toFixed(0)}KB</p>
149
+ <p>${(file.type.split('/')[1]).toUpperCase()} &#8226; ${(Number(file.size) / 1024).toFixed(0)}KB</p>
89
150
  </div>
90
151
 
91
- <nile-icon
92
- @click=${(e) => removeFile(file, e, originalUrl)}
93
- name="trash"
94
- size="14"
95
- class="corner-icon icon"
96
- ></nile-icon>
152
+ <slot name="cancelIcon">
153
+ <nile-icon
154
+ @click=${(e) => removeFile(file, e, originalUrl)}
155
+ name="trash"
156
+ size="14"
157
+ class="icon corner-icon"
158
+ ></nile-icon>
159
+ </slot>
97
160
  </div>
98
161
  `;
99
162
  }
@@ -106,15 +169,17 @@ export function getVerticalNoPreviewState(file, originalUrl) {
106
169
 
107
170
  <div class="content-container">
108
171
  <p>${file.name}</p>
109
- <p>${file.type} &#8226; ${(Number(file.size) / 1000).toFixed(0)}KB</p>
172
+ <p>${file.type} &#8226; ${(Number(file.size) / 1024).toFixed(0)}KB</p>
110
173
  </div>
111
174
 
112
- <nile-icon
113
- @click=${(e) => removeFile(file, e, originalUrl)}
114
- name="trash"
115
- size="14"
116
- class="corner-icon icon"
117
- ></nile-icon>
175
+ <slot name="cancelIcon">
176
+ <nile-icon
177
+ @click=${(e) => removeFile(file, e, originalUrl)}
178
+ name="trash"
179
+ size="14"
180
+ class="icon corner-icon"
181
+ ></nile-icon>
182
+ </slot>
118
183
  </div>
119
184
  `;
120
185
  }
@@ -125,19 +190,20 @@ export function getVerticalErrorState(file, errorMessage, originalUrl) {
125
190
  <nile-icon name="info-icon" size="20" color="var(--nile-colors-red-700)"></nile-icon>
126
191
  </div>
127
192
 
128
- <div class="error-message">
193
+ <div class="file-info-vertical-state">
129
194
  <p>${file.name}</p>
130
- <div class="error-p">
195
+ <nile-tooltip content=${errorMessage}>
131
196
  <p>${errorMessage}</p>
132
- </div>
197
+ </nile-tooltip>
133
198
  </div>
134
199
 
135
- <nile-icon
136
- @click=${(e) => removeFile(file, e, originalUrl)}
137
- name="close"
138
- size="14"
139
- class="corner-icon icon"
140
- ></nile-icon>
200
+ <slot name="cancelIcon" @click=${(e) => removeFile(file, e, originalUrl)}>
201
+ <nile-icon
202
+ name="close"
203
+ size="14"
204
+ class="icon corner-icon"
205
+ ></nile-icon>
206
+ </slot>
141
207
  </div>
142
208
  `;
143
209
  }
@@ -1 +1 @@
1
- {"version":3,"file":"nile-file-preview.template.js","source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;;;;;iBAKV,CAAC,CAAgC,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,EAAE,WAAW,CAAC;;;;;;GAMpF,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Template File for nile-preview component\n */\n\nimport './nile-file-preview.css';\nimport { html, TemplateResult } from 'lit';\nimport { RemoveFileDetail } from './types';\nimport { removeFile } from './utils';\n\nexport function getHorizontalPreviewState(\n url: string,\n file: File,\n originalUrl: string\n): TemplateResult {\n return html`\n <div class=\"preview horizontal-div\">\n <div class=\"preview-inner\">\n <div class=\"preview-image-container\">\n ${file.type.startsWith('image/')\n ? html`<img src=\"${url}\" alt=\"Image Preview\" />`\n : html`<iframe src=\"${url}\" type=\"${file.type}\" width=\"40px\" height=\"40px\" />`\n }\n </div>\n <div class=\"preview-file-info\">\n <p>${file.name}</p>\n <p>${(file.type.split('/')[1]).toUpperCase()} &#8226; ${(Number(file.size) / 1000).toFixed(0)}KB</p>\n </div>\n </div>\n <nile-icon \n @click=${(e: CustomEvent<RemoveFileDetail>) => removeFile(file, e, originalUrl)}\n name=\"trash\" \n size=\"14\" \n class=\"icon\"\n ></nile-icon>\n </div>\n `;\n}\n\nexport function getHorizontalNoPreviewState(\n file: File,\n originalUrl: string\n): TemplateResult {\n return html`\n <div class=\"no-preview horizontal-div\">\n <div class=\"no-preview-container\">\n <div class=\"document-icon\">\n <nile-icon name=\"general\" size=\"20\" color=\"var(--nile-colors-blue-500)\"></nile-icon>\n </div>\n <div class=\"preview-file-info\">\n <p>${file.name}</p>\n <p>${(file.type.split('/')[1]).toUpperCase()} &#8226; ${(Number(file.size) / 1000).toFixed(0)}KB</p>\n </div>\n </div>\n <div>\n <nile-icon\n @click=${(e: CustomEvent<RemoveFileDetail>) => removeFile(file, e, originalUrl)}\n name=\"trash\"\n size=\"14\"\n class=\"icon\"\n ></nile-icon>\n </div>\n </div>\n `;\n}\n\nexport function getHorizontalErrorState(\n file: File,\n errorMessage: string,\n originalUrl: string\n): TemplateResult {\n return html`\n <div class=\"error horizontal-div\">\n <div class=\"error-container\">\n <div class=\"error-icon\">\n <nile-icon name=\"info-icon\" size=\"20\" color=\"var(--nile-colors-red-700)\"></nile-icon>\n </div>\n <div class=\"file-info\">\n <p>${file.name}</p>\n <p>${errorMessage}</p>\n </div>\n </div>\n <nile-icon \n @click=${(e: CustomEvent<RemoveFileDetail>) => removeFile(file, e, originalUrl)} \n name=\"close\" \n size=\"14\" \n class=\"icon\"\n ></nile-icon>\n </div>\n `;\n}\n\n// vertical states\nexport function getVerticalPreviewState(\n url: string,\n file: File,\n originalUrl: string\n): TemplateResult {\n return html`\n <div class=\"vertical-div vertical-preview\">\n <div>\n <img\n class=\"image-preview\"\n src=${url}\n alt=${file.name}\n />\n </div>\n\n <div class=\"content-container\">\n <p>${file.name}</p>\n <p>${(file.type.split('/')[1]).toUpperCase()} &#8226; ${(Number(file.size) / 1000).toFixed(0)}KB</p>\n </div>\n\n <nile-icon \n @click=${(e: CustomEvent<RemoveFileDetail>) => removeFile(file, e, originalUrl)}\n name=\"trash\" \n size=\"14\" \n class=\"corner-icon icon\"\n ></nile-icon>\n </div>\n `;\n}\n\nexport function getVerticalNoPreviewState(\n file: File,\n originalUrl: string\n): TemplateResult {\n return html`\n <div class=\"vertical-div vertical-no-preview\">\n <div class=\"vertical-document-icon\">\n <nile-icon name=\"general\" size=\"20\" color=\"var(--nile-colors-blue-500)\"></nile-icon>\n </div>\n\n <div class=\"content-container\">\n <p>${file.name}</p>\n <p>${file.type} &#8226; ${(Number(file.size) / 1000).toFixed(0)}KB</p>\n </div>\n\n <nile-icon\n @click=${(e: CustomEvent<RemoveFileDetail>) => removeFile(file, e, originalUrl)}\n name=\"trash\"\n size=\"14\"\n class=\"corner-icon icon\"\n ></nile-icon>\n </div>\n `;\n}\n\nexport function getVerticalErrorState(\n file: File,\n errorMessage: string,\n originalUrl: string\n): TemplateResult {\n return html`\n <div class=\"vertical-div vertical-error\">\n <div class=\"vertical-document-icon error-bg\">\n <nile-icon name=\"info-icon\" size=\"20\" color=\"var(--nile-colors-red-700)\"></nile-icon>\n </div>\n\n <div class=\"error-message\">\n <p>${file.name}</p>\n <div class=\"error-p\">\n <p>${errorMessage}</p>\n </div>\n </div>\n\n <nile-icon \n @click=${(e: CustomEvent<RemoveFileDetail>) => removeFile(file, e, originalUrl)}\n name=\"close\" \n size=\"14\" \n class=\"corner-icon icon\"\n ></nile-icon>\n </div>\n `;\n}"]}
1
+ {"version":3,"file":"nile-file-preview.template.js","sourceRoot":"","sources":["../../../src/nile-file-preview/nile-file-preview.template.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,yBAAyB,CAAC;AACjC,OAAO,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEtD,MAAM,UAAU,2BAA2B,CAC1C,IAAU,EACV,YAAoB;IAElB,OAAO,IAAI,CAAA;;;;;;iBAME,YAAY;;;qBAGR,YAAY;;eAElB,IAAI,CAAC,IAAI;;uBAED,CAAC,CAAgC,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC;;;;;;;;KAQjF,CAAC;AACJ,CAAC;AAEH,MAAM,UAAU,yBAAyB,CACvC,GAAW,EACX,IAAU,EACV,WAAmB;IAEnB,OAAO,IAAI,CAAA;;;;;;oBAMO,GAAG;oBACH,IAAI,CAAC,IAAI;;;;eAId,IAAI,CAAC,IAAI;eACT,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;;;;;mBAKpF,CAAC,CAAgC,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,EAAE,WAAW,CAAC;;;;;;;GAOt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,WAAW,EAAE,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;;;;;mBAKnF,CAAC,CAAgC,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,EAAE,WAAW,CAAC;;;;;;;GAOtF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,yBAAyB,CACvC,IAAU,EACV,WAAmB;IAEnB,OAAO,IAAI,CAAA;;;;;;;aAOA,IAAI,CAAC,IAAI;aACT,IAAI,CAAC,IAAI,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;;;;;mBAKpD,CAAC,CAAgC,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,EAAE,WAAW,CAAC;;;;;;;GAOtF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,IAAU,EACV,YAAoB,EACpB,WAAmB;IAEnB,OAAO,IAAI,CAAA;;;;;;;aAOA,IAAI,CAAC,IAAI;gCACU,YAAY;eAC7B,YAAY;;;;uCAIY,CAAC,CAAgC,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,EAAE,WAAW,CAAC;;;;;;;;GAQ1G,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Template File for nile-preview component\n */\n\nimport './nile-file-preview.css';\nimport { html, TemplateResult } from 'lit';\nimport { FilePreviewErrorMessages, RemoveFileDetail } from './types';\nimport { removeFile, cancelFileUpload } from './utils';\n\n export function getHorizontalUploadingState(\n file: File,\n uploadStatus: number\n ): TemplateResult {\n return html`\n <div class=\"uploading\">\n <nile-loader width=\"24\" height=\"24\"></nile-loader>\n <div class=\"progress-bar-container\">\n <div class=\"progress-bar-percent\">\n <p>Uploading File...</p>\n <p>${uploadStatus}%</p>\n </div>\n <nile-progress-bar\n value=\"${uploadStatus}\"\n ></nile-progress-bar>\n <p>${file.name}</p>\n </div>\n <slot @click=${(e: CustomEvent<RemoveFileDetail>) => cancelFileUpload(file, e)} name=\"cancelIcon\">\n <nile-icon\n name=\"close\"\n size=\"14\"\n class=\"icon\"\n ></nile-icon>\n </slot>\n </div>\n `;\n }\n\nexport function getHorizontalPreviewState(\n url: string,\n file: File,\n originalUrl: string\n): TemplateResult {\n return html`\n <div class=\"preview horizontal-div\">\n <div class=\"preview-inner\">\n <div class=\"preview-image-container\">\n <img\n class=\"image-preview\"\n src=${url}\n alt=${file.name}\n />\n </div>\n <div class=\"preview-file-info\">\n <p>${file.name}</p>\n <p>${(file.type.split('/')[1]).toUpperCase()} &#8226; ${(Number(file.size) / 1024).toFixed(0)}KB</p>\n </div>\n </div>\n <slot name=\"cancelIcon\">\n <nile-icon\n @click=${(e: CustomEvent<RemoveFileDetail>) => removeFile(file, e, originalUrl)}\n name=\"trash\"\n size=\"14\"\n class=\"icon\"\n ></nile-icon>\n </slot>\n </div>\n `;\n}\n\nexport function getHorizontalNoPreviewState(\n file: File,\n originalUrl: string\n): TemplateResult {\n return html`\n <div class=\"no-preview horizontal-div\">\n <div class=\"no-preview-container\">\n <div class=\"document-icon\">\n <nile-icon name=\"general\" size=\"20\" color=\"var(--nile-colors-blue-500)\"></nile-icon>\n </div>\n <div class=\"preview-file-info\">\n <p>${file.name}</p>\n <p>${(file.type.split('/')[1]).toUpperCase()} &#8226; ${(Number(file.size) / 1034).toFixed(0)}KB</p>\n </div>\n </div>\n <div>\n <slot name=\"cancelIcon\">\n <nile-icon\n @click=${(e: CustomEvent<RemoveFileDetail>) => removeFile(file, e, originalUrl)}\n name=\"trash\"\n size=\"14\"\n class=\"icon\"\n ></nile-icon>\n </slot>\n </div>\n </div>\n `;\n}\n\nexport function getHorizontalErrorState(\n file: File,\n errorMessage: string,\n originalUrl: string\n): TemplateResult {\n return html`\n <div class=\"error horizontal-div\">\n <div class=\"error-container\">\n <div class=\"error-icon\">\n <nile-icon name=\"info-icon\" size=\"20\" color=\"var(--nile-colors-red-700)\"></nile-icon>\n </div>\n <div class=\"file-info\">\n <p>${file.name}</p>\n <nile-tooltip content=${errorMessage}>\n <p>${errorMessage}</p>\n </nile-tooltip>\n </div>\n </div>\n <slot name=\"cancelIcon\">\n <nile-icon\n @click=${(e: CustomEvent<RemoveFileDetail>) => removeFile(file, e, originalUrl)}\n name=\"close\"\n size=\"14\"\n class=\"icon\"\n ></nile-icon>\n </slot>\n </div>\n `;\n}\n\n// vertical states\nexport function getVerticalUploadingState(\n file: File,\n uploadStatus: number\n): TemplateResult {\n return html`\n <div class=\"vertical-div vertical-uploading\">\n <div class=\"loading\">\n <nile-loader width=\"24\" height=\"24\"></nile-loader>\n </div>\n\n <div class=\"progress-bar-container\">\n <div class=\"progress-bar-percent\">\n <p>Uploading...</p>\n <p>${uploadStatus}%</p>\n </div>\n <nile-progress-bar value=${uploadStatus}></nile-progress-bar>\n <p>${file.name}</p>\n </div>\n\n <slot name=\"cancelIcon\">\n <nile-icon\n @click=${(e: CustomEvent<RemoveFileDetail>) => cancelFileUpload(file, e)}\n name=\"close\"\n size=\"14\"\n class=\"icon corner-icon\"\n ></nile-icon>\n </slot>\n </div>\n `;\n}\n\n\nexport function getVerticalPreviewState(\n url: string,\n file: File,\n originalUrl: string\n): TemplateResult {\n return html`\n <div class=\"vertical-div vertical-preview\">\n <div>\n <img\n class=\"image-preview\"\n src=${url}\n alt=${file.name}\n />\n </div>\n\n <div class=\"content-container\">\n <p>${file.name}</p>\n <p>${(file.type.split('/')[1]).toUpperCase()} &#8226; ${(Number(file.size) / 1024).toFixed(0)}KB</p>\n </div>\n\n <slot name=\"cancelIcon\">\n <nile-icon\n @click=${(e: CustomEvent<RemoveFileDetail>) => removeFile(file, e, originalUrl)}\n name=\"trash\"\n size=\"14\"\n class=\"icon corner-icon\"\n ></nile-icon>\n </slot>\n </div>\n `;\n}\n\nexport function getVerticalNoPreviewState(\n file: File,\n originalUrl: string\n): TemplateResult {\n return html`\n <div class=\"vertical-div vertical-no-preview\">\n <div class=\"vertical-document-icon\">\n <nile-icon name=\"general\" size=\"20\" color=\"var(--nile-colors-blue-500)\"></nile-icon>\n </div>\n\n <div class=\"content-container\">\n <p>${file.name}</p>\n <p>${file.type} &#8226; ${(Number(file.size) / 1024).toFixed(0)}KB</p>\n </div>\n\n <slot name=\"cancelIcon\">\n <nile-icon\n @click=${(e: CustomEvent<RemoveFileDetail>) => removeFile(file, e, originalUrl)}\n name=\"trash\"\n size=\"14\"\n class=\"icon corner-icon\"\n ></nile-icon>\n </slot>\n </div>\n `;\n}\n\nexport function getVerticalErrorState(\n file: File,\n errorMessage: string,\n originalUrl: string\n): TemplateResult {\n return html`\n <div class=\"vertical-div vertical-error\">\n <div class=\"vertical-document-icon error-bg\">\n <nile-icon name=\"info-icon\" size=\"20\" color=\"var(--nile-colors-red-700)\"></nile-icon>\n </div>\n\n <div class=\"file-info-vertical-state\">\n <p>${file.name}</p>\n <nile-tooltip content=${errorMessage}>\n <p>${errorMessage}</p>\n </nile-tooltip>\n </div>\n\n <slot name=\"cancelIcon\" @click=${(e: CustomEvent<RemoveFileDetail>) => removeFile(file, e, originalUrl)}>\n <nile-icon\n name=\"close\"\n size=\"14\"\n class=\"icon corner-icon\"\n ></nile-icon>\n </slot>\n </div>\n `;\n}"]}
@@ -1,2 +1,2 @@
1
- export * from './file-preview.enums';
2
- export * from './file-preview.interface';
1
+ export * from './nile-file-preview.enums';
2
+ export * from './nile-file-preview.interface';
@@ -1,3 +1,3 @@
1
- export * from './file-preview.enums';
2
- export * from './file-preview.interface';
1
+ export * from './nile-file-preview.enums';
2
+ export * from './nile-file-preview.interface';
3
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/nile-file-preview/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC","sourcesContent":["export * from './file-preview.enums';\nexport * from './file-preview.interface';"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/nile-file-preview/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC","sourcesContent":["export * from './nile-file-preview.enums';\nexport * from './nile-file-preview.interface';"]}
@@ -0,0 +1,28 @@
1
+ export declare enum FilePreviewState {
2
+ DEFAULT = "default",
3
+ UPLOADING = "uploading",
4
+ PREVIEW = "preview",
5
+ NO_PREVIEW = "no-preview",
6
+ ERROR = "error"
7
+ }
8
+ export declare enum FilePreviewVariant {
9
+ HORIZONTAL = "horizontal",
10
+ VERTICAL = "vertical"
11
+ }
12
+ export declare enum FilePreviewErrorMessages {
13
+ INVALID_FORMAT = "Invalid File Format. Please try again.",
14
+ SIZE_LIMIT = "Size limit exceeded",
15
+ FAILED_TO_LOAD = "Failed to load file from URL",
16
+ UNKNOWN_FILE_NAME = "unknown-file",
17
+ UPLOAD_CANCEL = "File upload cancelled.",
18
+ NO_FILE_SELECTED = "No file selected.",
19
+ UNABLE_TO_GENEARTE_URL = "Unable to generate the url."
20
+ }
21
+ export declare enum FilePreviewEvent {
22
+ NILE_INIT = "nile-init",
23
+ NILE_RECEIVE = "nile-receive",
24
+ NILE_UPLOADING = "nile-uploding",
25
+ NILE_REMOVE = "nile-remove",
26
+ NILE_CANCEL_UPLOAD = "nile-cancel-upload",
27
+ NILE_DESTROY = "nile-destroy"
28
+ }
@@ -0,0 +1,33 @@
1
+ export var FilePreviewState;
2
+ (function (FilePreviewState) {
3
+ FilePreviewState["DEFAULT"] = "default";
4
+ FilePreviewState["UPLOADING"] = "uploading";
5
+ FilePreviewState["PREVIEW"] = "preview";
6
+ FilePreviewState["NO_PREVIEW"] = "no-preview";
7
+ FilePreviewState["ERROR"] = "error";
8
+ })(FilePreviewState || (FilePreviewState = {}));
9
+ export var FilePreviewVariant;
10
+ (function (FilePreviewVariant) {
11
+ FilePreviewVariant["HORIZONTAL"] = "horizontal";
12
+ FilePreviewVariant["VERTICAL"] = "vertical";
13
+ })(FilePreviewVariant || (FilePreviewVariant = {}));
14
+ export var FilePreviewErrorMessages;
15
+ (function (FilePreviewErrorMessages) {
16
+ FilePreviewErrorMessages["INVALID_FORMAT"] = "Invalid File Format. Please try again.";
17
+ FilePreviewErrorMessages["SIZE_LIMIT"] = "Size limit exceeded";
18
+ FilePreviewErrorMessages["FAILED_TO_LOAD"] = "Failed to load file from URL";
19
+ FilePreviewErrorMessages["UNKNOWN_FILE_NAME"] = "unknown-file";
20
+ FilePreviewErrorMessages["UPLOAD_CANCEL"] = "File upload cancelled.";
21
+ FilePreviewErrorMessages["NO_FILE_SELECTED"] = "No file selected.";
22
+ FilePreviewErrorMessages["UNABLE_TO_GENEARTE_URL"] = "Unable to generate the url.";
23
+ })(FilePreviewErrorMessages || (FilePreviewErrorMessages = {}));
24
+ export var FilePreviewEvent;
25
+ (function (FilePreviewEvent) {
26
+ FilePreviewEvent["NILE_INIT"] = "nile-init";
27
+ FilePreviewEvent["NILE_RECEIVE"] = "nile-receive";
28
+ FilePreviewEvent["NILE_UPLOADING"] = "nile-uploding";
29
+ FilePreviewEvent["NILE_REMOVE"] = "nile-remove";
30
+ FilePreviewEvent["NILE_CANCEL_UPLOAD"] = "nile-cancel-upload";
31
+ FilePreviewEvent["NILE_DESTROY"] = "nile-destroy";
32
+ })(FilePreviewEvent || (FilePreviewEvent = {}));
33
+ //# sourceMappingURL=nile-file-preview.enums.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nile-file-preview.enums.js","sourceRoot":"","sources":["../../../../src/nile-file-preview/types/nile-file-preview.enums.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,gBAMX;AAND,WAAY,gBAAgB;IAC1B,uCAAmB,CAAA;IACnB,2CAAuB,CAAA;IACvB,uCAAmB,CAAA;IACnB,6CAAyB,CAAA;IACzB,mCAAe,CAAA;AACjB,CAAC,EANW,gBAAgB,KAAhB,gBAAgB,QAM3B;AAED,MAAM,CAAN,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC5B,+CAAyB,CAAA;IACzB,2CAAqB,CAAA;AACvB,CAAC,EAHW,kBAAkB,KAAlB,kBAAkB,QAG7B;AAED,MAAM,CAAN,IAAY,wBAQX;AARD,WAAY,wBAAwB;IAClC,qFAAyD,CAAA;IACzD,8DAAkC,CAAA;IAClC,2EAA+C,CAAA;IAC/C,8DAAkC,CAAA;IAClC,oEAAwC,CAAA;IACxC,kEAAsC,CAAA;IACtC,kFAAsD,CAAA;AACxD,CAAC,EARW,wBAAwB,KAAxB,wBAAwB,QAQnC;AAED,MAAM,CAAN,IAAY,gBAOX;AAPD,WAAY,gBAAgB;IAC1B,2CAAuB,CAAA;IACvB,iDAA6B,CAAA;IAC7B,oDAAgC,CAAA;IAChC,+CAA2B,CAAA;IAC3B,6DAAyC,CAAA;IACzC,iDAA6B,CAAA;AAC/B,CAAC,EAPW,gBAAgB,KAAhB,gBAAgB,QAO3B","sourcesContent":["export enum FilePreviewState {\n DEFAULT = 'default',\n UPLOADING = 'uploading',\n PREVIEW = 'preview',\n NO_PREVIEW = 'no-preview',\n ERROR = 'error'\n}\n\nexport enum FilePreviewVariant {\n HORIZONTAL = 'horizontal',\n VERTICAL = 'vertical'\n}\n\nexport enum FilePreviewErrorMessages {\n INVALID_FORMAT = \"Invalid File Format. Please try again.\",\n SIZE_LIMIT = \"Size limit exceeded\",\n FAILED_TO_LOAD = \"Failed to load file from URL\",\n UNKNOWN_FILE_NAME = 'unknown-file',\n UPLOAD_CANCEL = \"File upload cancelled.\",\n NO_FILE_SELECTED = \"No file selected.\",\n UNABLE_TO_GENEARTE_URL = \"Unable to generate the url.\"\n}\n\nexport enum FilePreviewEvent {\n NILE_INIT = \"nile-init\",\n NILE_RECEIVE = \"nile-receive\",\n NILE_UPLOADING = \"nile-uploding\",\n NILE_REMOVE = \"nile-remove\",\n NILE_CANCEL_UPLOAD = \"nile-cancel-upload\",\n NILE_DESTROY = \"nile-destroy\"\n}"]}
@@ -0,0 +1,4 @@
1
+ export type RemoveFileDetail = {
2
+ value: File;
3
+ url: string;
4
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=nile-file-preview.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nile-file-preview.interface.js","sourceRoot":"","sources":["../../../../src/nile-file-preview/types/nile-file-preview.interface.ts"],"names":[],"mappings":"","sourcesContent":["export type RemoveFileDetail = {\n value: File;\n url: string;\n};\n"]}
@@ -1 +1 @@
1
- export * from './file-preview.util';
1
+ export * from './nile-file-preview.util';
@@ -1,2 +1,2 @@
1
- export * from './file-preview.util';
1
+ export * from './nile-file-preview.util';
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/nile-file-preview/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA","sourcesContent":["export * from './file-preview.util'"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/nile-file-preview/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA","sourcesContent":["export * from './nile-file-preview.util'"]}
@@ -0,0 +1,4 @@
1
+ import { RemoveFileDetail } from "../types";
2
+ export declare const generatePreviewUrl: (file: File) => Promise<string>;
3
+ export declare const removeFile: (removeFile: File, e: CustomEvent<RemoveFileDetail>, originalUrl: string) => void;
4
+ export declare const cancelFileUpload: (file: File, e: CustomEvent<RemoveFileDetail>) => void;
@@ -0,0 +1,38 @@
1
+ import { FilePreviewEvent, FilePreviewErrorMessages } from "../types";
2
+ export const generatePreviewUrl = (file) => {
3
+ return new Promise((resolve, reject) => {
4
+ const reader = new FileReader();
5
+ if (file) {
6
+ reader.readAsDataURL(file);
7
+ }
8
+ else {
9
+ reject(FilePreviewErrorMessages.NO_FILE_SELECTED);
10
+ }
11
+ reader.onload = () => {
12
+ const previewUrl = reader.result;
13
+ resolve(previewUrl);
14
+ };
15
+ reader.onerror = (error) => {
16
+ reject(FilePreviewErrorMessages.UNABLE_TO_GENEARTE_URL);
17
+ };
18
+ });
19
+ };
20
+ export const removeFile = (removeFile, e, originalUrl) => {
21
+ if (e.target) {
22
+ e.target.dispatchEvent(new CustomEvent(FilePreviewEvent.NILE_REMOVE, {
23
+ detail: { value: removeFile, url: originalUrl },
24
+ bubbles: true,
25
+ composed: true,
26
+ }));
27
+ }
28
+ };
29
+ export const cancelFileUpload = (file, e) => {
30
+ if (e.target) {
31
+ e.target.dispatchEvent(new CustomEvent(FilePreviewEvent.NILE_CANCEL_UPLOAD, {
32
+ detail: { file: file },
33
+ bubbles: true,
34
+ composed: true,
35
+ }));
36
+ }
37
+ };
38
+ //# sourceMappingURL=nile-file-preview.util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nile-file-preview.util.js","sourceRoot":"","sources":["../../../../src/nile-file-preview/utils/nile-file-preview.util.ts"],"names":[],"mappings":"AACA,OAAO,EAAoB,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAExF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,IAAU,EAAmB,EAAE;IAChE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAEhC,IAAI,IAAI,EAAE,CAAC;YACT,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,wBAAwB,CAAC,gBAAgB,CAAC,CAAC;QACpD,CAAC;QAED,MAAM,CAAC,MAAM,GAAG,GAAG,EAAE;YACnB,MAAM,UAAU,GAAG,MAAM,CAAC,MAAgB,CAAC;YAC3C,OAAO,CAAC,UAAU,CAAC,CAAC;QACtB,CAAC,CAAC;QAEF,MAAM,CAAC,OAAO,GAAG,CAAC,KAAK,EAAE,EAAE;YACzB,MAAM,CAAC,wBAAwB,CAAC,sBAAsB,CAAC,CAAC;QAC1D,CAAC,CAAA;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,UAAgB,EAAE,CAAgC,EAAE,WAAmB,EAAQ,EAAE;IAC1G,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;QACb,CAAC,CAAC,MAAM,CAAC,aAAa,CACpB,IAAI,WAAW,CAAC,gBAAgB,CAAC,WAAW,EAAE;YAC5C,MAAM,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,WAAW,EAAE;YAC/C,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;SACf,CAAC,CACH,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAAU,EAAE,CAAgC,EAAE,EAAE;IAC/E,IAAG,CAAC,CAAC,MAAM,EAAE,CAAC;QACZ,CAAC,CAAC,MAAM,CAAC,aAAa,CACpB,IAAI,WAAW,CAAC,gBAAgB,CAAC,kBAAkB,EAAE;YACnD,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;YACtB,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;SACf,CAAC,CACH,CAAC;IACJ,CAAC;AACH,CAAC,CAAA","sourcesContent":["import NileFilePreview from \"../nile-file-preview\";\nimport { RemoveFileDetail, FilePreviewEvent, FilePreviewErrorMessages } from \"../types\";\n\nexport const generatePreviewUrl = (file: File): Promise<string> => {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n\n if (file) {\n reader.readAsDataURL(file);\n } else {\n reject(FilePreviewErrorMessages.NO_FILE_SELECTED);\n }\n\n reader.onload = () => {\n const previewUrl = reader.result as string;\n resolve(previewUrl);\n };\n\n reader.onerror = (error) => {\n reject(FilePreviewErrorMessages.UNABLE_TO_GENEARTE_URL);\n }\n });\n}\n\nexport const removeFile = (removeFile: File, e: CustomEvent<RemoveFileDetail>, originalUrl: string): void => {\n if (e.target) {\n e.target.dispatchEvent(\n new CustomEvent(FilePreviewEvent.NILE_REMOVE, {\n detail: { value: removeFile, url: originalUrl },\n bubbles: true,\n composed: true,\n })\n );\n }\n};\n\nexport const cancelFileUpload = (file: File, e: CustomEvent<RemoveFileDetail>) => {\n if(e.target) {\n e.target.dispatchEvent(\n new CustomEvent(FilePreviewEvent.NILE_CANCEL_UPLOAD, {\n detail: { file: file },\n bubbles: true,\n composed: true,\n })\n );\n }\n}"]}
@@ -35,7 +35,8 @@ export const styles = css `
35
35
  .horizontal-div {
36
36
  margin-bottom: 10px;
37
37
  height: 62px;
38
- width: 648px;
38
+ max-width: 648px;
39
+ width: max(648px, 100%);
39
40
  min-width: 230px;
40
41
  padding: 12px;
41
42
  display: flex;