@aquera/nile-elements 0.1.35-beta-2.0 → 0.1.36

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 (242) hide show
  1. package/README.md +12 -66
  2. package/demo/index.css +4 -7
  3. package/demo/index.html +36 -20
  4. package/demo/variables.css +0 -13
  5. package/demo/variables_v2.css +0 -13
  6. package/dist/{fixture-df8b52d7.esm.js → fixture-2b5b3aba.esm.js} +1 -1
  7. package/dist/{fixture-d5b55278.cjs.js → fixture-7bfb866e.cjs.js} +3 -3
  8. package/dist/fixture-7bfb866e.cjs.js.map +1 -0
  9. package/dist/index.cjs.js +1 -1
  10. package/dist/index.esm.js +1 -1
  11. package/dist/internal/animate.cjs.js +1 -1
  12. package/dist/internal/animate.cjs.js.map +1 -1
  13. package/dist/internal/animate.esm.js +1 -1
  14. package/dist/nile-accordion/nile-accordian.test.cjs.js +1 -1
  15. package/dist/nile-accordion/nile-accordian.test.esm.js +1 -1
  16. package/dist/nile-auto-complete/nile-auto-complete.test.cjs.js +1 -1
  17. package/dist/nile-auto-complete/nile-auto-complete.test.esm.js +1 -1
  18. package/dist/nile-avatar/nile-avatar.test.cjs.js +1 -1
  19. package/dist/nile-avatar/nile-avatar.test.esm.js +1 -1
  20. package/dist/nile-badge/nile-badge.test.cjs.js +1 -1
  21. package/dist/nile-badge/nile-badge.test.esm.js +1 -1
  22. package/dist/nile-button/nile-button.test.cjs.js +1 -1
  23. package/dist/nile-button/nile-button.test.esm.js +1 -1
  24. package/dist/nile-button-toggle-group/nile-button-toggle-group.test.cjs.js +1 -1
  25. package/dist/nile-button-toggle-group/nile-button-toggle-group.test.esm.js +1 -1
  26. package/dist/nile-calendar/nile-calendar.test.cjs.js +1 -1
  27. package/dist/nile-calendar/nile-calendar.test.esm.js +1 -1
  28. package/dist/nile-card/nile-card.test.cjs.js +1 -1
  29. package/dist/nile-card/nile-card.test.esm.js +1 -1
  30. package/dist/nile-checkbox/nile-checkbox.test.cjs.js +1 -1
  31. package/dist/nile-checkbox/nile-checkbox.test.esm.js +1 -1
  32. package/dist/nile-chip/nile-chip.test.cjs.js +1 -1
  33. package/dist/nile-chip/nile-chip.test.esm.js +1 -1
  34. package/dist/nile-dialog/nile-dialog.test.cjs.js +1 -1
  35. package/dist/nile-dialog/nile-dialog.test.esm.js +1 -1
  36. package/dist/nile-drawer/nile-drawer.test.cjs.js +1 -1
  37. package/dist/nile-drawer/nile-drawer.test.esm.js +1 -1
  38. package/dist/nile-dropdown/nile-dropdown.test.cjs.js +1 -1
  39. package/dist/nile-dropdown/nile-dropdown.test.esm.js +1 -1
  40. package/dist/nile-empty-state/nile-empty-state.test.cjs.js +1 -1
  41. package/dist/nile-empty-state/nile-empty-state.test.esm.js +1 -1
  42. package/dist/nile-error-message/nile-error-message.cjs.js +1 -1
  43. package/dist/nile-error-message/nile-error-message.cjs.js.map +1 -1
  44. package/dist/nile-error-message/nile-error-message.css.cjs.js +1 -1
  45. package/dist/nile-error-message/nile-error-message.css.cjs.js.map +1 -1
  46. package/dist/nile-error-message/nile-error-message.css.esm.js +4 -6
  47. package/dist/nile-error-message/nile-error-message.esm.js +4 -4
  48. package/dist/nile-error-message/nile-error-message.test.cjs.js +1 -1
  49. package/dist/nile-error-message/nile-error-message.test.esm.js +1 -1
  50. package/dist/nile-error-notification/nile-error-notification.css.cjs.js +1 -1
  51. package/dist/nile-error-notification/nile-error-notification.css.cjs.js.map +1 -1
  52. package/dist/nile-error-notification/nile-error-notification.css.esm.js +1 -1
  53. package/dist/nile-form-group/nile-form-group.test.cjs.js +1 -1
  54. package/dist/nile-form-group/nile-form-group.test.esm.js +1 -1
  55. package/dist/nile-form-help-text/nile-form-help-text.test.cjs.js +1 -1
  56. package/dist/nile-form-help-text/nile-form-help-text.test.esm.js +1 -1
  57. package/dist/nile-hero/nile-hero.test.cjs.js +1 -1
  58. package/dist/nile-hero/nile-hero.test.esm.js +1 -1
  59. package/dist/nile-icon/nile-icon.test.cjs.js +1 -1
  60. package/dist/nile-icon/nile-icon.test.esm.js +1 -1
  61. package/dist/nile-input/nile-input.test.cjs.js +1 -1
  62. package/dist/nile-input/nile-input.test.esm.js +1 -1
  63. package/dist/nile-link/nile-link.test.cjs.js +1 -1
  64. package/dist/nile-link/nile-link.test.esm.js +1 -1
  65. package/dist/nile-loader/nile-loader.test.cjs.js +1 -1
  66. package/dist/nile-loader/nile-loader.test.esm.js +1 -1
  67. package/dist/nile-popover/nile-popover.test.cjs.js +1 -1
  68. package/dist/nile-popover/nile-popover.test.esm.js +1 -1
  69. package/dist/nile-popup/nile-popup.test.cjs.js +1 -1
  70. package/dist/nile-popup/nile-popup.test.esm.js +1 -1
  71. package/dist/nile-progress-bar/nile-progress-bar.css.cjs.js +1 -1
  72. package/dist/nile-progress-bar/nile-progress-bar.css.cjs.js.map +1 -1
  73. package/dist/nile-progress-bar/nile-progress-bar.css.esm.js +0 -1
  74. package/dist/nile-progress-bar/nile-progress-bar.test.cjs.js +1 -1
  75. package/dist/nile-progress-bar/nile-progress-bar.test.esm.js +1 -1
  76. package/dist/nile-radio/nile-radio.test.cjs.js +1 -1
  77. package/dist/nile-radio/nile-radio.test.esm.js +1 -1
  78. package/dist/nile-radio-group/nile-radio-group.test.cjs.js +1 -1
  79. package/dist/nile-radio-group/nile-radio-group.test.esm.js +1 -1
  80. package/dist/nile-select/nile-select.cjs.js +1 -1
  81. package/dist/nile-select/nile-select.cjs.js.map +1 -1
  82. package/dist/nile-select/nile-select.esm.js +1 -1
  83. package/dist/nile-select/nile-select.test.cjs.js +1 -1
  84. package/dist/nile-select/nile-select.test.esm.js +1 -1
  85. package/dist/nile-slide-toggle/nile-slide-toggle.test.cjs.js +1 -1
  86. package/dist/nile-slide-toggle/nile-slide-toggle.test.esm.js +1 -1
  87. package/dist/nile-tab-group/nile-tab-group.test.cjs.js +1 -1
  88. package/dist/nile-tab-group/nile-tab-group.test.esm.js +1 -1
  89. package/dist/nile-table/nile-table.cjs.js.map +1 -1
  90. package/dist/nile-textarea/nile-textarea.test.cjs.js +1 -1
  91. package/dist/nile-textarea/nile-textarea.test.esm.js +1 -1
  92. package/dist/nile-tooltip/index.cjs.js +1 -1
  93. package/dist/nile-tooltip/index.esm.js +1 -1
  94. package/dist/nile-tooltip/nile-tooltip.cjs.js +1 -1
  95. package/dist/nile-tooltip/nile-tooltip.cjs.js.map +1 -1
  96. package/dist/nile-tooltip/nile-tooltip.css.cjs.js +1 -1
  97. package/dist/nile-tooltip/nile-tooltip.css.cjs.js.map +1 -1
  98. package/dist/nile-tooltip/nile-tooltip.css.esm.js +45 -78
  99. package/dist/nile-tooltip/nile-tooltip.esm.js +28 -23
  100. package/dist/src/index.d.ts +0 -1
  101. package/dist/src/index.js +0 -1
  102. package/dist/src/index.js.map +1 -1
  103. package/dist/src/nile-error-message/nile-error-message.css.js +4 -6
  104. package/dist/src/nile-error-message/nile-error-message.css.js.map +1 -1
  105. package/dist/src/nile-error-message/nile-error-message.d.ts +0 -4
  106. package/dist/src/nile-error-message/nile-error-message.js +0 -20
  107. package/dist/src/nile-error-message/nile-error-message.js.map +1 -1
  108. package/dist/src/nile-error-notification/nile-error-notification.css.js +1 -1
  109. package/dist/src/nile-error-notification/nile-error-notification.css.js.map +1 -1
  110. package/dist/src/nile-file-preview/index.d.ts +1 -0
  111. package/dist/src/nile-file-preview/index.js +2 -0
  112. package/dist/src/nile-file-preview/index.js.map +1 -0
  113. package/dist/src/{nile-filter-chip/nile-filter-chip.css.d.ts → nile-file-preview/nile-file-preview.css.d.ts} +1 -1
  114. package/dist/src/nile-file-preview/nile-file-preview.css.js +533 -0
  115. package/dist/src/nile-file-preview/nile-file-preview.css.js.map +1 -0
  116. package/dist/src/nile-file-preview/nile-file-preview.d.ts +48 -0
  117. package/dist/src/nile-file-preview/nile-file-preview.js +149 -0
  118. package/dist/src/nile-file-preview/nile-file-preview.js.map +1 -0
  119. package/dist/src/nile-file-preview/nile-file-preview.template.d.ts +11 -0
  120. package/dist/src/nile-file-preview/nile-file-preview.template.js +144 -0
  121. package/dist/src/nile-file-preview/nile-file-preview.template.js.map +1 -0
  122. package/dist/src/nile-file-preview/nile-file-preview.test.d.ts +7 -0
  123. package/dist/src/nile-file-preview/nile-file-preview.test.js +30 -0
  124. package/dist/src/nile-file-preview/nile-file-preview.test.js.map +1 -0
  125. package/dist/src/nile-file-preview/types/file-preview.enums.d.ts +23 -0
  126. package/dist/src/nile-file-preview/types/file-preview.enums.js +28 -0
  127. package/dist/src/nile-file-preview/types/file-preview.enums.js.map +1 -0
  128. package/dist/src/nile-file-preview/types/file-preview.interface.d.ts +4 -0
  129. package/dist/src/nile-file-preview/types/file-preview.interface.js +2 -0
  130. package/dist/src/nile-file-preview/types/file-preview.interface.js.map +1 -0
  131. package/dist/src/nile-file-preview/types/index.d.ts +2 -0
  132. package/dist/src/nile-file-preview/types/index.js +3 -0
  133. package/dist/src/nile-file-preview/types/index.js.map +1 -0
  134. package/dist/src/nile-file-preview/utils/file-preview.util.d.ts +3 -0
  135. package/dist/src/nile-file-preview/utils/file-preview.util.js +29 -0
  136. package/dist/src/nile-file-preview/utils/file-preview.util.js.map +1 -0
  137. package/dist/src/nile-file-preview/utils/index.d.ts +1 -0
  138. package/dist/src/nile-file-preview/utils/index.js +2 -0
  139. package/dist/src/nile-file-preview/utils/index.js.map +1 -0
  140. package/dist/src/nile-file-upload/index.d.ts +1 -0
  141. package/dist/src/nile-file-upload/index.js +2 -0
  142. package/dist/src/{nile-filter-chip → nile-file-upload}/index.js.map +1 -1
  143. package/dist/src/nile-file-upload/nile-file-upload.css.d.ts +12 -0
  144. package/dist/src/nile-file-upload/nile-file-upload.css.js +547 -0
  145. package/dist/src/nile-file-upload/nile-file-upload.css.js.map +1 -0
  146. package/dist/src/nile-file-upload/nile-file-upload.d.ts +45 -0
  147. package/dist/src/nile-file-upload/nile-file-upload.js +148 -0
  148. package/dist/src/nile-file-upload/nile-file-upload.js.map +1 -0
  149. package/dist/src/nile-file-upload/nile-file-upload.template.d.ts +11 -0
  150. package/dist/src/nile-file-upload/nile-file-upload.template.js +163 -0
  151. package/dist/src/nile-file-upload/nile-file-upload.template.js.map +1 -0
  152. package/dist/src/nile-file-upload/nile-file-upload.test.d.ts +7 -0
  153. package/dist/src/nile-file-upload/nile-file-upload.test.js +30 -0
  154. package/dist/src/nile-file-upload/nile-file-upload.test.js.map +1 -0
  155. package/dist/src/nile-file-upload/types/file-upload.enums.d.ts +28 -0
  156. package/dist/src/nile-file-upload/types/file-upload.enums.js +35 -0
  157. package/dist/src/nile-file-upload/types/file-upload.enums.js.map +1 -0
  158. package/dist/src/nile-file-upload/types/file-upload.type.d.ts +4 -0
  159. package/dist/src/nile-file-upload/types/file-upload.type.js +2 -0
  160. package/dist/src/nile-file-upload/types/file-upload.type.js.map +1 -0
  161. package/dist/src/nile-file-upload/types/index.d.ts +2 -0
  162. package/dist/src/nile-file-upload/types/index.js +3 -0
  163. package/dist/src/nile-file-upload/types/index.js.map +1 -0
  164. package/dist/src/nile-file-upload/utils/drag-drop.util.d.ts +19 -0
  165. package/dist/src/nile-file-upload/utils/drag-drop.util.js +77 -0
  166. package/dist/src/nile-file-upload/utils/drag-drop.util.js.map +1 -0
  167. package/dist/src/nile-file-upload/utils/file-validation.util.d.ts +9 -0
  168. package/dist/src/nile-file-upload/utils/file-validation.util.js +58 -0
  169. package/dist/src/nile-file-upload/utils/file-validation.util.js.map +1 -0
  170. package/dist/src/nile-progress-bar/nile-progress-bar.css.js +0 -1
  171. package/dist/src/nile-progress-bar/nile-progress-bar.css.js.map +1 -1
  172. package/dist/src/nile-select/nile-select.js +1 -1
  173. package/dist/src/nile-select/nile-select.js.map +1 -1
  174. package/dist/src/nile-table/nile-table.js.map +1 -1
  175. package/dist/src/nile-tooltip/nile-tooltip.css.js +43 -76
  176. package/dist/src/nile-tooltip/nile-tooltip.css.js.map +1 -1
  177. package/dist/src/nile-tooltip/nile-tooltip.d.ts +46 -24
  178. package/dist/src/nile-tooltip/nile-tooltip.js +232 -235
  179. package/dist/src/nile-tooltip/nile-tooltip.js.map +1 -1
  180. package/dist/tsconfig.tsbuildinfo +1 -1
  181. package/package.json +2 -2
  182. package/plop-templates/lit/index.ts.hbs +1 -1
  183. package/plop-templates/lit/lit.css.ts.hbs +1 -1
  184. package/plop-templates/lit/lit.ts.hbs +3 -7
  185. package/plopfile.js +1 -32
  186. package/src/index.ts +1 -2
  187. package/src/nile-error-message/nile-error-message.css.ts +4 -6
  188. package/src/nile-error-message/nile-error-message.ts +0 -18
  189. package/src/nile-error-notification/nile-error-notification.css.ts +1 -1
  190. package/src/nile-progress-bar/nile-progress-bar.css.ts +0 -1
  191. package/src/nile-select/nile-select.ts +1 -1
  192. package/src/nile-table/nile-table.ts +2 -2
  193. package/src/nile-tooltip/nile-tooltip.css.ts +44 -77
  194. package/src/nile-tooltip/nile-tooltip.ts +230 -268
  195. package/vscode-html-custom-data.json +95 -144
  196. package/dist/fixture-d5b55278.cjs.js.map +0 -1
  197. package/dist/nile-filter-chip/index.cjs.js +0 -2
  198. package/dist/nile-filter-chip/index.cjs.js.map +0 -1
  199. package/dist/nile-filter-chip/index.esm.js +0 -1
  200. package/dist/nile-filter-chip/nile-filter-chip.cjs.js +0 -2
  201. package/dist/nile-filter-chip/nile-filter-chip.cjs.js.map +0 -1
  202. package/dist/nile-filter-chip/nile-filter-chip.css.cjs.js +0 -2
  203. package/dist/nile-filter-chip/nile-filter-chip.css.cjs.js.map +0 -1
  204. package/dist/nile-filter-chip/nile-filter-chip.css.esm.js +0 -121
  205. package/dist/nile-filter-chip/nile-filter-chip.esm.js +0 -43
  206. package/dist/nile-filter-chip/nile-filter-chip.test.cjs.js +0 -2
  207. package/dist/nile-filter-chip/nile-filter-chip.test.cjs.js.map +0 -1
  208. package/dist/nile-filter-chip/nile-filter-chip.test.esm.js +0 -20
  209. package/dist/nile-tooltip/nile-tooltip-utils.cjs.js +0 -2
  210. package/dist/nile-tooltip/nile-tooltip-utils.cjs.js.map +0 -1
  211. package/dist/nile-tooltip/nile-tooltip-utils.esm.js +0 -1
  212. package/dist/nile-tooltip/nile-tooltip.test.cjs.js +0 -2
  213. package/dist/nile-tooltip/nile-tooltip.test.cjs.js.map +0 -1
  214. package/dist/nile-tooltip/nile-tooltip.test.esm.js +0 -47
  215. package/dist/src/nile-filter-chip/index.d.ts +0 -1
  216. package/dist/src/nile-filter-chip/index.js +0 -2
  217. package/dist/src/nile-filter-chip/nile-filter-chip.css.js +0 -133
  218. package/dist/src/nile-filter-chip/nile-filter-chip.css.js.map +0 -1
  219. package/dist/src/nile-filter-chip/nile-filter-chip.d.ts +0 -36
  220. package/dist/src/nile-filter-chip/nile-filter-chip.js +0 -141
  221. package/dist/src/nile-filter-chip/nile-filter-chip.js.map +0 -1
  222. package/dist/src/nile-filter-chip/nile-filter-chip.test.d.ts +0 -1
  223. package/dist/src/nile-filter-chip/nile-filter-chip.test.js +0 -80
  224. package/dist/src/nile-filter-chip/nile-filter-chip.test.js.map +0 -1
  225. package/dist/src/nile-tooltip/nile-tooltip-utils.d.ts +0 -18
  226. package/dist/src/nile-tooltip/nile-tooltip-utils.js +0 -216
  227. package/dist/src/nile-tooltip/nile-tooltip-utils.js.map +0 -1
  228. package/dist/src/nile-tooltip/nile-tooltip.test.d.ts +0 -1
  229. package/dist/src/nile-tooltip/nile-tooltip.test.js +0 -148
  230. package/dist/src/nile-tooltip/nile-tooltip.test.js.map +0 -1
  231. package/plop-templates/lit/lit.template.ts.hbs +0 -3
  232. package/plop-templates/lit/lit.test.ts.hbs +0 -38
  233. package/plop-templates/lit/sub-components/index.ts.hbs +0 -4
  234. package/plop-templates/lit/types/index.ts.hbs +0 -0
  235. package/plop-templates/lit/types/type.ts.hbs +0 -3
  236. package/plop-templates/lit/utils/lit.utils.ts.hbs +0 -4
  237. package/src/nile-filter-chip/index.ts +0 -1
  238. package/src/nile-filter-chip/nile-filter-chip.css.ts +0 -138
  239. package/src/nile-filter-chip/nile-filter-chip.test.ts +0 -92
  240. package/src/nile-filter-chip/nile-filter-chip.ts +0 -136
  241. package/src/nile-tooltip/nile-tooltip-utils.ts +0 -271
  242. package/src/nile-tooltip/nile-tooltip.test.ts +0 -168
@@ -0,0 +1,148 @@
1
+ /**
2
+ * Copyright Aquera Inc 2025
3
+ *
4
+ * This source code is licensed under the BSD-3-Clause license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { __decorate } from "tslib";
8
+ import { styles } from './nile-file-upload.css';
9
+ import NileElement from '../internal/nile-element';
10
+ import { DragHandler } from './utils/drag-drop.util';
11
+ import { getDragHandler } from './nile-file-upload.template';
12
+ import { FileUploadDefaults } from './types/file-upload.enums';
13
+ import { html } from 'lit';
14
+ import { customElement, property, query } from 'lit/decorators.js';
15
+ import { FileUploadState, FileUploadVariant, FileUploadEvent } from './types/file-upload.enums';
16
+ import { setUpDragHandler, addGlobalListeners, addInternalListeners } from './utils/file-validation.util';
17
+ import { getHorizontalDefaultState, getHorizontalDisabledtState, getHorizontalDragState, getVerticalDefaultState, getVerticalDisabledState, getVerticalDragState, } from './nile-file-upload.template';
18
+ /**
19
+ * Nile file-upload component.
20
+ *
21
+ * @tag nile-file-upload
22
+ *
23
+ */
24
+ let NileFileUpload = class NileFileUpload extends NileElement {
25
+ constructor() {
26
+ super(...arguments);
27
+ this.size = 0;
28
+ this.error = false;
29
+ this.errorMessage = "";
30
+ this.allowMultiple = true;
31
+ this.allowDuplicates = true;
32
+ this.uploadedFiles = [];
33
+ this.title = FileUploadDefaults.TITLE;
34
+ this.subtitle = FileUploadDefaults.SUBTITLE;
35
+ this.state = FileUploadState.DEFAULT;
36
+ this.variant = FileUploadVariant.HORIZONTAL;
37
+ this.setState = (newState) => {
38
+ this.state = newState;
39
+ };
40
+ }
41
+ /**
42
+ * The styles for nile-file-upload
43
+ * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`
44
+ */
45
+ static get styles() {
46
+ return [styles];
47
+ }
48
+ connectedCallback() {
49
+ super.connectedCallback();
50
+ this.emit(FileUploadEvent.NILE_INIT);
51
+ }
52
+ firstUpdated(changedProps) {
53
+ super.firstUpdated(changedProps);
54
+ this.dragHandler = new DragHandler();
55
+ getDragHandler(this.dragHandler);
56
+ setUpDragHandler(this, this.dragHandler);
57
+ addInternalListeners(this, this.dragHandler);
58
+ addGlobalListeners(this.dragHandler);
59
+ }
60
+ updated(changedProps) {
61
+ super.updated(changedProps);
62
+ if (changedProps.has('uploadedFiles')) {
63
+ this.emit(FileUploadEvent.NILE_CHANGE, { files: this.uploadedFiles });
64
+ }
65
+ else if (changedProps.has('state')) {
66
+ this.dragHandler.updateState(this.state);
67
+ }
68
+ }
69
+ browseFiles() {
70
+ this.emit(FileUploadEvent.NILE_BROWSE);
71
+ this.input.click();
72
+ }
73
+ render() {
74
+ return html `
75
+ ${this.getState()}
76
+ `;
77
+ }
78
+ getState() {
79
+ return this.variant === FileUploadVariant.HORIZONTAL
80
+ ? this.getHorizontalState()
81
+ : this.getVerticalState();
82
+ }
83
+ getHorizontalState() {
84
+ switch (this.state) {
85
+ case FileUploadState.DEFAULT:
86
+ return getHorizontalDefaultState(this.browseFiles, this.title, this.subtitle, this.errorMessage, this.state);
87
+ case FileUploadState.DISABLED:
88
+ return getHorizontalDisabledtState(this.browseFiles, this.title, this.subtitle);
89
+ case FileUploadState.DRAG:
90
+ return getHorizontalDragState();
91
+ default:
92
+ return getHorizontalDefaultState(this.browseFiles, this.title, this.subtitle, this.errorMessage, this.state);
93
+ }
94
+ }
95
+ getVerticalState() {
96
+ switch (this.state) {
97
+ case FileUploadState.DEFAULT:
98
+ return getVerticalDefaultState(this.browseFiles, this.title, this.subtitle, this.errorMessage, this.state);
99
+ case FileUploadState.DISABLED:
100
+ return getVerticalDisabledState(this.browseFiles, this.title, this.subtitle);
101
+ case FileUploadState.DRAG:
102
+ return getVerticalDragState();
103
+ default:
104
+ return getVerticalDefaultState(this.browseFiles, this.title, this.subtitle, this.errorMessage, this.state);
105
+ }
106
+ }
107
+ disconnectedCallback() {
108
+ this.emit(FileUploadEvent.NILE_DESTROY);
109
+ }
110
+ };
111
+ __decorate([
112
+ property({ type: Number })
113
+ ], NileFileUpload.prototype, "size", void 0);
114
+ __decorate([
115
+ property({ type: Boolean })
116
+ ], NileFileUpload.prototype, "error", void 0);
117
+ __decorate([
118
+ property({ type: String })
119
+ ], NileFileUpload.prototype, "errorMessage", void 0);
120
+ __decorate([
121
+ property({ type: Boolean })
122
+ ], NileFileUpload.prototype, "allowMultiple", void 0);
123
+ __decorate([
124
+ property({ type: Boolean })
125
+ ], NileFileUpload.prototype, "allowDuplicates", void 0);
126
+ __decorate([
127
+ property({ type: Array })
128
+ ], NileFileUpload.prototype, "uploadedFiles", void 0);
129
+ __decorate([
130
+ property({ type: String })
131
+ ], NileFileUpload.prototype, "title", void 0);
132
+ __decorate([
133
+ property({ type: String })
134
+ ], NileFileUpload.prototype, "subtitle", void 0);
135
+ __decorate([
136
+ property({ type: String })
137
+ ], NileFileUpload.prototype, "state", void 0);
138
+ __decorate([
139
+ property({ type: String })
140
+ ], NileFileUpload.prototype, "variant", void 0);
141
+ __decorate([
142
+ query('input')
143
+ ], NileFileUpload.prototype, "input", void 0);
144
+ NileFileUpload = __decorate([
145
+ customElement('nile-file-upload')
146
+ ], NileFileUpload);
147
+ export { NileFileUpload };
148
+ //# sourceMappingURL=nile-file-upload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nile-file-upload.js","sourceRoot":"","sources":["../../../src/nile-file-upload/nile-file-upload.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAEhD,OAAO,WAAW,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAc,IAAI,EAA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F,CAAA;AA/F6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAAkB;AACjB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAC,CAAC;6CAAwB;AACvB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oDAA2B;AAC1B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAC,CAAC;qDAA+B;AAC9B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAC,CAAC;uDAAiC;AAChC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAG,CAAC;qDAA4B;AAC3B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAA0C;AACzC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDAAgD;AAC/C;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAAkD;AACjD;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CAA2D;AACtE;IAAf,KAAK,CAAC,OAAO,CAAC;6CAA0B;AAnB9B,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CAwG1B","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-upload.css';\nimport { ChangedPropsInterface } from './types/file-upload.type'\nimport NileElement from '../internal/nile-element';\nimport { DragHandler } from './utils/drag-drop.util';\nimport { getDragHandler } from './nile-file-upload.template'\nimport { FileUploadDefaults } from './types/file-upload.enums';\nimport { LitElement, html, CSSResultArray, TemplateResult } from 'lit';\nimport { customElement, property, query, state } from 'lit/decorators.js';\nimport { FileUploadState, FileUploadVariant, FileUploadError, FileUploadEvent } from './types/file-upload.enums';\nimport { setUpDragHandler, addGlobalListeners, addInternalListeners } from './utils/file-validation.util';\nimport {\n getHorizontalDefaultState,\n getHorizontalDisabledtState,\n getHorizontalDragState,\n getVerticalDefaultState,\n getVerticalDisabledState,\n getVerticalDragState,\n} from './nile-file-upload.template';\n\n/**\n * Nile file-upload component.\n *\n * @tag nile-file-upload\n *\n */\n@customElement('nile-file-upload')\nexport class NileFileUpload extends NileElement {\n /**\n * The styles for nile-file-upload\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: Number }) size: number = 0;\n @property({ type: Boolean}) error: boolean = false;\n @property({ type: String }) errorMessage: string = \"\";\n @property({ type: Boolean}) allowMultiple: boolean = true;\n @property({ type: Boolean}) allowDuplicates: boolean = true;\n @property({ type: Array }) uploadedFiles: File[] = [];\n @property({ type: String }) title: string = FileUploadDefaults.TITLE;\n @property({ type: String }) subtitle: string = FileUploadDefaults.SUBTITLE;\n @property({ type: String }) state: FileUploadState = FileUploadState.DEFAULT; \n @property({ type: String }) variant: FileUploadVariant = FileUploadVariant.HORIZONTAL;\n @query('input') input!: HTMLInputElement;\n \n private dragHandler!: DragHandler;\n\n connectedCallback(): void {\n super.connectedCallback();\n this.emit(FileUploadEvent.NILE_INIT);\n }\n\n firstUpdated(changedProps: ChangedPropsInterface): void {\n super.firstUpdated(changedProps);\n\n this.dragHandler = new DragHandler();\n getDragHandler(this.dragHandler);\n setUpDragHandler(this, this.dragHandler);\n addInternalListeners(this, this.dragHandler);\n addGlobalListeners(this.dragHandler);\n }\n\n updated(changedProps: ChangedPropsInterface): void {\n super.updated(changedProps);\n\n if (changedProps.has('uploadedFiles')) {\n this.emit(FileUploadEvent.NILE_CHANGE, { files: this.uploadedFiles });\n } else if (changedProps.has('state')) {\n this.dragHandler.updateState(this.state);\n }\n }\n\n private browseFiles(): void {\n this.emit(FileUploadEvent.NILE_BROWSE);\n this.input.click();\n }\n\n public setState = (newState: FileUploadState): void => {\n this.state = newState;\n }\n\n render(): TemplateResult {\n return html`\n ${this.getState()}\n `;\n }\n\n private getState(): TemplateResult {\n return this.variant === FileUploadVariant.HORIZONTAL\n ? this.getHorizontalState()\n : this.getVerticalState();\n }\n\n private getHorizontalState(): TemplateResult {\n switch(this.state) {\n case FileUploadState.DEFAULT:\n return getHorizontalDefaultState(this.browseFiles, this.title, this.subtitle, this.errorMessage, this.state);\n\n case FileUploadState.DISABLED:\n return getHorizontalDisabledtState(this.browseFiles, this.title, this.subtitle);\n\n case FileUploadState.DRAG:\n return getHorizontalDragState();\n\n default:\n return getHorizontalDefaultState(this.browseFiles, this.title, this.subtitle, this.errorMessage, this.state);\n }\n }\n\n private getVerticalState(): TemplateResult {\n switch(this.state) {\n case FileUploadState.DEFAULT:\n return getVerticalDefaultState(this.browseFiles, this.title, this.subtitle, this.errorMessage, this.state);\n\n case FileUploadState.DISABLED:\n return getVerticalDisabledState(this.browseFiles, this.title, this.subtitle);\n\n case FileUploadState.DRAG:\n return getVerticalDragState();\n\n default:\n return getVerticalDefaultState(this.browseFiles, this.title, this.subtitle, this.errorMessage, this.state);\n }\n }\n\n disconnectedCallback(): void {\n this.emit(FileUploadEvent.NILE_DESTROY);\n }\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import { TemplateResult } from 'lit';
2
+ import './nile-file-upload.css';
3
+ import { DragHandler } from './utils/drag-drop.util';
4
+ import { FileUploadState } from './types/file-upload.enums';
5
+ export declare const getDragHandler: (dragHandler: DragHandler) => void;
6
+ export declare const getHorizontalDefaultState: (browseFiles: Function, title: string, subtitle: string, errorMessage: string, state: FileUploadState) => TemplateResult;
7
+ export declare const getHorizontalDisabledtState: (browseFiles: Function, title: string, subtitle: string) => TemplateResult;
8
+ export declare const getHorizontalDragState: () => TemplateResult;
9
+ export declare const getVerticalDefaultState: (browseFiles: Function, title: string, subtitle: string, errorMessage: string, state: FileUploadState) => TemplateResult;
10
+ export declare const getVerticalDisabledState: (browseFiles: Function, title: string, subtitle: string) => TemplateResult;
11
+ export declare const getVerticalDragState: () => TemplateResult;
@@ -0,0 +1,163 @@
1
+ import { html } from 'lit';
2
+ import './nile-file-upload.css';
3
+ import { classMap } from 'lit-html/directives/class-map.js';
4
+ let dragHandlerInstance;
5
+ export const getDragHandler = (dragHandler) => {
6
+ dragHandlerInstance = dragHandler;
7
+ };
8
+ export const getHorizontalDefaultState = (browseFiles, title, subtitle, errorMessage, state) => html `
9
+ <div>
10
+ <div class=${classMap({ 'hover-border': state === "hover", 'horizontal-div': true })}>
11
+ <div class="inner-div">
12
+ <slot name="icon">
13
+ <nile-icon name="upload" size="24"></nile-icon>
14
+ </slot>
15
+ <div class="content">
16
+ <slot name="title">
17
+ <h4>${title}</h4>
18
+ </slot>
19
+ <slot name="subtitle">
20
+ <p>${subtitle}</p>
21
+ </slot>
22
+ </div>
23
+ </div>
24
+ <input
25
+ type="file"
26
+ @change=${(e) => dragHandlerInstance.handleFiles(e)}
27
+ multiple
28
+ />
29
+ <nile-button @click=${browseFiles} variant="tertiary">
30
+ Browse File
31
+ </nile-button>
32
+ </div>
33
+ ${errorMessage ?
34
+ html `<div class="upload-error">
35
+ <nile-icon name="warning" size="12" color="red"></nile-icon>
36
+ <span>${errorMessage}</span>
37
+ </div>` :
38
+ html ``}
39
+ </div>
40
+ `;
41
+ export const getHorizontalDisabledtState = (browseFiles, title, subtitle) => html `
42
+ <div
43
+ class="horizontal-div disabled"
44
+ >
45
+ <div class="inner-div">
46
+ <slot name="icon">
47
+ <nile-icon name="upload" size="24"></nile-icon>
48
+ </slot>
49
+ <div class="content">
50
+ <slot name="title">
51
+ <h4>${title}</h4>
52
+ </slot>
53
+ <slot name="subtitle">
54
+ <p>${subtitle}</p>
55
+ </slot>
56
+ </div>
57
+ </div>
58
+ <input
59
+ type="file"
60
+ @change=${(e) => dragHandlerInstance.handleFiles(e)}
61
+ multiple
62
+ />
63
+ <nile-button @click=${browseFiles} variant="tertiary">
64
+ Browse File
65
+ </nile-button>
66
+ </div>
67
+ `;
68
+ export const getHorizontalDragState = () => html `
69
+ <div class="horizontal-div dragging">
70
+ <div class="icons-container">
71
+ <nile-icon
72
+ color="var(--nile-colors-blue-500)"
73
+ name="general"
74
+ size="20"
75
+ class="general-icon"
76
+ ></nile-icon>
77
+ <nile-icon
78
+ color="var(--nile-colors-blue-500)"
79
+ name="image"
80
+ size="24"
81
+ class="image-icon"
82
+ ></nile-icon>
83
+ </div>
84
+ <p>Drop files here to upload</p>
85
+ </div>
86
+ `;
87
+ // Vertical States
88
+ export const getVerticalDefaultState = (browseFiles, title, subtitle, errorMessage, state) => html `
89
+ <div>
90
+ <div class=${classMap({ 'hover-border': state === "hover", 'vertical-div': true })}>
91
+ <slot name="icon">
92
+ <nile-icon name="upload" size="24"></nile-icon>
93
+ </slot>
94
+ <div class="content-container">
95
+ <slot name="title">
96
+ <h4>${title}</h4>
97
+ </slot>
98
+ <slot name="title">
99
+ <p>${subtitle}</p>
100
+ </slot>
101
+ </div>
102
+ <input
103
+ type="file"
104
+ @change=${(e) => dragHandlerInstance.handleFiles(e)}
105
+ multiple
106
+ />
107
+ <nile-button @click=${browseFiles} variant="tertiary">
108
+ Browse File
109
+ </nile-button>
110
+ </div>
111
+ ${errorMessage ?
112
+ html `<div class="upload-error">
113
+ <nile-icon name="warning" size="12" color="red"></nile-icon>
114
+ <span>${errorMessage}</span>
115
+ </div>` :
116
+ html ``}
117
+ </div>
118
+ `;
119
+ export const getVerticalDisabledState = (browseFiles, title, subtitle) => html `
120
+ <div
121
+ class="vertical-deafult vertical-div disable"
122
+ >
123
+ <slot name="icon">
124
+ <nile-icon name="upload" size="24"></nile-icon>
125
+ </slot>
126
+ <div class="content-container">
127
+ <slot name="title">
128
+ <h4>${title}</h4>
129
+ </slot>
130
+ <slot name="title">
131
+ <p>${subtitle}o</p>
132
+ </slot>
133
+ </div>
134
+ <input
135
+ type="file"
136
+ @change=${(e) => dragHandlerInstance.handleFiles(e)}
137
+ multiple
138
+ />
139
+ <nile-button @click=${browseFiles} variant="tertiary">
140
+ Browse File
141
+ </nile-button>
142
+ </div>
143
+ `;
144
+ export const getVerticalDragState = () => html `
145
+ <div class="vertical-div vertical-drag">
146
+ <div class="icons-container">
147
+ <nile-icon
148
+ color="var(--nile-colors-blue-500)"
149
+ name="general"
150
+ size="20"
151
+ class="general-icon"
152
+ ></nile-icon>
153
+ <nile-icon
154
+ color="var(--nile-colors-blue-500)"
155
+ name="image"
156
+ size="24"
157
+ class="image-icon"
158
+ ></nile-icon>
159
+ </div>
160
+ <p>Drop files here to upload</p>
161
+ </div>
162
+ `;
163
+ //# sourceMappingURL=nile-file-upload.template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nile-file-upload.template.js","sourceRoot":"","sources":["../../../src/nile-file-upload/nile-file-upload.template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAC;AAC3C,OAAO,wBAAwB,CAAC;AAEhC,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAG5D,IAAI,mBAAgC,CAAC;AAErC,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,WAAwB,EAAQ,EAAE;IAC/D,mBAAmB,GAAG,WAAW,CAAC;AACpC,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,yBAAyB,GAAG,CACvC,WAAqB,EACrB,KAAa,EACb,QAAgB,EAChB,YAAoB,EACpB,KAAsB,EACN,EAAE,CAAC,IAAI,CAAA;;iBAER,QAAQ,CAAC,EAAE,cAAc,EAAE,KAAK,KAAK,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC;;;;;;;kBAOtE,KAAK;;;iBAGN,QAAQ;;;;;;kBAMP,CAAC,CAAoB,EAAE,EAAE,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC,CAAC;;;4BAGlD,WAAW;;;;MAIjC,YAAY,CAAC,CAAC;IACd,IAAI,CAAA;;gBAEM,YAAY;aACf,CAAC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;;;;;;CAkB7D,CAAC","sourcesContent":["import { html, TemplateResult } from 'lit';\nimport './nile-file-upload.css';\nimport { DragHandler } from './utils/drag-drop.util';\nimport { classMap } from 'lit-html/directives/class-map.js';\nimport { FileUploadState } from './types/file-upload.enums';\n\nlet dragHandlerInstance: DragHandler;\n\nexport const getDragHandler = (dragHandler: DragHandler): void => {\n dragHandlerInstance = dragHandler;\n}\n\nexport const getHorizontalDefaultState = (\n browseFiles: Function,\n title: string,\n subtitle: string,\n errorMessage: string,\n state: FileUploadState\n): TemplateResult => html`\n <div>\n <div class=${classMap({ 'hover-border': state === \"hover\", 'horizontal-div': true })}>\n <div class=\"inner-div\">\n <slot name=\"icon\">\n <nile-icon name=\"upload\" size=\"24\"></nile-icon>\n </slot>\n <div class=\"content\">\n <slot name=\"title\">\n <h4>${title}</h4>\n </slot>\n <slot name=\"subtitle\">\n <p>${subtitle}</p>\n </slot>\n </div>\n </div>\n <input\n type=\"file\"\n @change=${(e: Event | DragEvent) => dragHandlerInstance.handleFiles(e)}\n multiple\n />\n <nile-button @click=${browseFiles} variant=\"tertiary\">\n Browse File\n </nile-button>\n </div>\n ${errorMessage ?\n html`<div class=\"upload-error\">\n <nile-icon name=\"warning\" size=\"12\" color=\"red\"></nile-icon>\n <span>${errorMessage}</span>\n </div>` :\n html``\n }\n </div>\n`;\n\nexport const getHorizontalDisabledtState = (\n browseFiles: Function,\n title: string,\n subtitle: string\n): TemplateResult => html`\n <div\n class=\"horizontal-div disabled\"\n >\n <div class=\"inner-div\">\n <slot name=\"icon\">\n <nile-icon name=\"upload\" size=\"24\"></nile-icon>\n </slot>\n <div class=\"content\">\n <slot name=\"title\">\n <h4>${title}</h4>\n </slot>\n <slot name=\"subtitle\">\n <p>${subtitle}</p>\n </slot>\n </div>\n </div>\n <input\n type=\"file\"\n @change=${(e: Event | DragEvent) => dragHandlerInstance.handleFiles(e)}\n multiple\n />\n <nile-button @click=${browseFiles} variant=\"tertiary\">\n Browse File\n </nile-button>\n </div>\n`;\n\nexport const getHorizontalDragState = (): TemplateResult => html`\n <div class=\"horizontal-div dragging\">\n <div class=\"icons-container\">\n <nile-icon\n color=\"var(--nile-colors-blue-500)\"\n name=\"general\"\n size=\"20\"\n class=\"general-icon\"\n ></nile-icon>\n <nile-icon\n color=\"var(--nile-colors-blue-500)\"\n name=\"image\"\n size=\"24\"\n class=\"image-icon\"\n ></nile-icon>\n </div>\n <p>Drop files here to upload</p>\n </div>\n`;\n\n// Vertical States\nexport const getVerticalDefaultState = (\n browseFiles: Function,\n title: string,\n subtitle: string,\n errorMessage: string,\n state: FileUploadState\n): TemplateResult => html`\n <div>\n <div class=${classMap({ 'hover-border': state === \"hover\", 'vertical-div': true })}>\n <slot name=\"icon\">\n <nile-icon name=\"upload\" size=\"24\"></nile-icon>\n </slot>\n <div class=\"content-container\">\n <slot name=\"title\">\n <h4>${title}</h4>\n </slot>\n <slot name=\"title\">\n <p>${subtitle}</p>\n </slot>\n </div>\n <input\n type=\"file\"\n @change=${(e: Event | DragEvent) => dragHandlerInstance.handleFiles(e)}\n multiple\n />\n <nile-button @click=${browseFiles} variant=\"tertiary\">\n Browse File\n </nile-button>\n </div>\n ${errorMessage ?\n html`<div class=\"upload-error\">\n <nile-icon name=\"warning\" size=\"12\" color=\"red\"></nile-icon>\n <span>${errorMessage}</span>\n </div>` :\n html``\n }\n </div>\n`;\n\nexport const getVerticalDisabledState = (\n browseFiles: Function,\n title: string,\n subtitle: string\n): TemplateResult => html`\n <div\n class=\"vertical-deafult vertical-div disable\"\n >\n <slot name=\"icon\">\n <nile-icon name=\"upload\" size=\"24\"></nile-icon>\n </slot>\n <div class=\"content-container\">\n <slot name=\"title\">\n <h4>${title}</h4>\n </slot>\n <slot name=\"title\">\n <p>${subtitle}o</p>\n </slot>\n </div>\n <input\n type=\"file\"\n @change=${(e: Event | DragEvent) => dragHandlerInstance.handleFiles(e)}\n multiple\n />\n <nile-button @click=${browseFiles} variant=\"tertiary\">\n Browse File\n </nile-button>\n </div>\n`;\n\nexport const getVerticalDragState = (): TemplateResult => html`\n <div class=\"vertical-div vertical-drag\">\n <div class=\"icons-container\">\n <nile-icon\n color=\"var(--nile-colors-blue-500)\"\n name=\"general\"\n size=\"20\"\n class=\"general-icon\"\n ></nile-icon>\n <nile-icon\n color=\"var(--nile-colors-blue-500)\"\n name=\"image\"\n size=\"24\"\n class=\"image-icon\"\n ></nile-icon>\n </div>\n <p>Drop files here to upload</p>\n </div>\n`;"]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Copyright Aquera Inc 2025
3
+ *
4
+ * This source code is licensed under the BSD-3-Clause license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import './nile-file-upload';
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Copyright Aquera Inc 2025
3
+ *
4
+ * This source code is licensed under the BSD-3-Clause license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { fixture, assert, expect, html } from '@open-wc/testing';
8
+ import './nile-file-upload'; // Just import to register the element
9
+ describe('<nile-file-upload>', () => {
10
+ let element;
11
+ beforeEach(async () => {
12
+ element = await fixture(html `<nile-file-upload></nile-file-upload>`);
13
+ });
14
+ it('passes accessibility test', async () => {
15
+ await expect(element).to.be.accessible();
16
+ });
17
+ it('renders with the correct tag name', () => {
18
+ expect(element.tagName.toLowerCase()).to.equal('nile-file-upload');
19
+ });
20
+ it('renders with slot content when provided', async () => {
21
+ const testContent = 'Test Content';
22
+ element = await fixture(html `<nile-file-upload>${testContent}</nile-file-upload>`);
23
+ const slot = element.shadowRoot.querySelector('slot');
24
+ assert.exists(slot, 'Slot should exist');
25
+ const assignedNodes = slot.assignedNodes({ flatten: true });
26
+ expect(assignedNodes.length).to.be.greaterThan(0);
27
+ expect(assignedNodes[0].textContent?.trim()).to.equal(testContent);
28
+ });
29
+ });
30
+ //# sourceMappingURL=nile-file-upload.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nile-file-upload.test.js","sourceRoot":"","sources":["../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C,CAAC;QAClD,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,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\n \nimport { fixture, assert, expect, html } from '@open-wc/testing';\nimport './nile-file-upload'; // Just import to register the element\n\ndescribe('<nile-file-upload>', () => {\n let element: HTMLElement;\n\n beforeEach(async () => {\n element = await fixture(html`<nile-file-upload></nile-file-upload>`);\n });\n\n it('passes accessibility test', async () => {\n await expect(element).to.be.accessible();\n });\n\n it('renders with the correct tag name', () => {\n expect(element.tagName.toLowerCase()).to.equal('nile-file-upload');\n });\n\n it('renders with slot content when provided', async () => {\n const testContent = 'Test Content';\n element = await fixture(html`<nile-file-upload>${testContent}</nile-file-upload>`);\n \n const slot = (element.shadowRoot!.querySelector('slot') as HTMLSlotElement);\n assert.exists(slot, 'Slot should exist');\n\n const assignedNodes = slot.assignedNodes({ flatten: true });\n expect(assignedNodes.length).to.be.greaterThan(0);\n expect(assignedNodes[0].textContent?.trim()).to.equal(testContent);\n });\n});"]}
@@ -0,0 +1,28 @@
1
+ export declare enum FileUploadState {
2
+ DEFAULT = "default",
3
+ DISABLED = "disabled",
4
+ HOVER = "hover",
5
+ DRAG = "drag"
6
+ }
7
+ export declare enum FileUploadVariant {
8
+ HORIZONTAL = "horizontal",
9
+ VERTICAL = "vertical"
10
+ }
11
+ export declare enum FileUploadError {
12
+ INVALID_FORMAT = "Invalid file format! Upload valid file.",
13
+ SIZE_LIMIT = "File exceeds size limit! Upload smaller size.",
14
+ MULTIPLE_NOT_ALLOWED = "Please Upload Single File!",
15
+ DUPLICATES_NOT_ALLOWED = "Duplicate Files Are Not Allowed!"
16
+ }
17
+ export declare enum FileUploadEvent {
18
+ NILE_INIT = "nile-init",
19
+ NILE_BROWSE = "nile-browse",
20
+ NILE_DRAG = "nile-drag",
21
+ NILE_CHANGE = "nile-change",
22
+ NILE_DESTROY = "nile-destroy"
23
+ }
24
+ export declare enum FileUploadDefaults {
25
+ TITLE = "Drag and drop to upload",
26
+ SUBTITLE = "PNG, JPG or SVG (upto 1MB) | 1:1 ratio",
27
+ ERROR_MESSAGE = "Invalid File Format."
28
+ }
@@ -0,0 +1,35 @@
1
+ export var FileUploadState;
2
+ (function (FileUploadState) {
3
+ FileUploadState["DEFAULT"] = "default";
4
+ FileUploadState["DISABLED"] = "disabled";
5
+ FileUploadState["HOVER"] = "hover";
6
+ FileUploadState["DRAG"] = "drag";
7
+ })(FileUploadState || (FileUploadState = {}));
8
+ export var FileUploadVariant;
9
+ (function (FileUploadVariant) {
10
+ FileUploadVariant["HORIZONTAL"] = "horizontal";
11
+ FileUploadVariant["VERTICAL"] = "vertical";
12
+ })(FileUploadVariant || (FileUploadVariant = {}));
13
+ export var FileUploadError;
14
+ (function (FileUploadError) {
15
+ FileUploadError["INVALID_FORMAT"] = "Invalid file format! Upload valid file.";
16
+ FileUploadError["SIZE_LIMIT"] = "File exceeds size limit! Upload smaller size.";
17
+ FileUploadError["MULTIPLE_NOT_ALLOWED"] = "Please Upload Single File!";
18
+ FileUploadError["DUPLICATES_NOT_ALLOWED"] = "Duplicate Files Are Not Allowed!";
19
+ })(FileUploadError || (FileUploadError = {}));
20
+ export var FileUploadEvent;
21
+ (function (FileUploadEvent) {
22
+ FileUploadEvent["NILE_INIT"] = "nile-init";
23
+ FileUploadEvent["NILE_BROWSE"] = "nile-browse";
24
+ FileUploadEvent["NILE_DRAG"] = "nile-drag";
25
+ FileUploadEvent["NILE_CHANGE"] = "nile-change";
26
+ FileUploadEvent["NILE_DESTROY"] = "nile-destroy";
27
+ })(FileUploadEvent || (FileUploadEvent = {}));
28
+ export var FileUploadDefaults;
29
+ (function (FileUploadDefaults) {
30
+ FileUploadDefaults["TITLE"] = "Drag and drop to upload";
31
+ FileUploadDefaults["SUBTITLE"] = "PNG, JPG or SVG (upto 1MB) | 1:1 ratio";
32
+ FileUploadDefaults["ERROR_MESSAGE"] = "Invalid File Format.";
33
+ })(FileUploadDefaults || (FileUploadDefaults = {}));
34
+ ;
35
+ //# sourceMappingURL=file-upload.enums.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-upload.enums.js","sourceRoot":"","sources":["../../../../src/nile-file-upload/types/file-upload.enums.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,eAKX;AALD,WAAY,eAAe;IACzB,sCAAmB,CAAA;IACnB,wCAAqB,CAAA;IACrB,kCAAe,CAAA;IACf,gCAAa,CAAA;AACf,CAAC,EALW,eAAe,KAAf,eAAe,QAK1B;AAED,MAAM,CAAN,IAAY,iBAGX;AAHD,WAAY,iBAAiB;IAC3B,8CAAyB,CAAA;IACzB,0CAAqB,CAAA;AACvB,CAAC,EAHW,iBAAiB,KAAjB,iBAAiB,QAG5B;AAED,MAAM,CAAN,IAAY,eAKX;AALD,WAAY,eAAe;IACzB,6EAA0D,CAAA;IAC1D,+EAA4D,CAAA;IAC5D,sEAAmD,CAAA;IACnD,8EAA2D,CAAA;AAC7D,CAAC,EALW,eAAe,KAAf,eAAe,QAK1B;AAED,MAAM,CAAN,IAAY,eAMX;AAND,WAAY,eAAe;IACzB,0CAAuB,CAAA;IACvB,8CAA2B,CAAA;IAC3B,0CAAuB,CAAA;IACvB,8CAA2B,CAAA;IAC3B,gDAA6B,CAAA;AAC/B,CAAC,EANW,eAAe,KAAf,eAAe,QAM1B;AAED,MAAM,CAAN,IAAY,kBAIX;AAJD,WAAY,kBAAkB;IAC5B,uDAAiC,CAAA;IACjC,yEAAmD,CAAA;IACnD,4DAAsC,CAAA;AACxC,CAAC,EAJW,kBAAkB,KAAlB,kBAAkB,QAI7B;AAAA,CAAC","sourcesContent":["export enum FileUploadState {\n DEFAULT = 'default',\n DISABLED = 'disabled',\n HOVER = 'hover',\n DRAG = 'drag'\n}\n\nexport enum FileUploadVariant {\n HORIZONTAL = 'horizontal',\n VERTICAL = 'vertical'\n}\n\nexport enum FileUploadError {\n INVALID_FORMAT = \"Invalid file format! Upload valid file.\",\n SIZE_LIMIT = \"File exceeds size limit! Upload smaller size.\",\n MULTIPLE_NOT_ALLOWED = \"Please Upload Single File!\",\n DUPLICATES_NOT_ALLOWED = \"Duplicate Files Are Not Allowed!\"\n}\n\nexport enum FileUploadEvent {\n NILE_INIT = \"nile-init\",\n NILE_BROWSE = \"nile-browse\",\n NILE_DRAG = \"nile-drag\",\n NILE_CHANGE = \"nile-change\",\n NILE_DESTROY = \"nile-destroy\"\n}\n\nexport enum FileUploadDefaults {\n TITLE = 'Drag and drop to upload',\n SUBTITLE = 'PNG, JPG or SVG (upto 1MB) | 1:1 ratio',\n ERROR_MESSAGE = 'Invalid File Format.',\n};"]}
@@ -0,0 +1,4 @@
1
+ import { PropertyValueMap } from 'lit';
2
+ export interface ChangedPropsInterface extends PropertyValueMap<any> {
3
+ [key: string]: unknown;
4
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=file-upload.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-upload.type.js","sourceRoot":"","sources":["../../../../src/nile-file-upload/types/file-upload.type.ts"],"names":[],"mappings":"","sourcesContent":["import { PropertyValueMap } from 'lit';\n\nexport interface ChangedPropsInterface extends PropertyValueMap<any> {\n [key: string]: unknown;\n}"]}
@@ -0,0 +1,2 @@
1
+ export * from './file-upload.enums';
2
+ export * from './file-upload.type';
@@ -0,0 +1,3 @@
1
+ export * from './file-upload.enums';
2
+ export * from './file-upload.type';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/nile-file-upload/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAA","sourcesContent":["export * from './file-upload.enums';\nexport * from './file-upload.type'"]}
@@ -0,0 +1,19 @@
1
+ import { FileUploadState } from "../types";
2
+ export declare class DragHandler {
3
+ private currentState;
4
+ private stateChangeCallback?;
5
+ private fileDropCallback?;
6
+ constructor();
7
+ updateState(state: FileUploadState): void;
8
+ onFileDrop(callback: (files: File[]) => void): void;
9
+ onStateChange(callback: (state: FileUploadState) => void): void;
10
+ private setState;
11
+ dragEnter(e: DragEvent): void;
12
+ dragLeave(e: DragEvent): void;
13
+ dragOver(e: DragEvent): void;
14
+ drop(e: DragEvent): void;
15
+ handleDocumentDrop(e: DragEvent): void;
16
+ preventDragOver(e: DragEvent): void;
17
+ preventDrop(e: DragEvent): void;
18
+ handleFiles(event: Event | DragEvent): void;
19
+ }
@@ -0,0 +1,77 @@
1
+ import { FileUploadState } from "../types";
2
+ export class DragHandler {
3
+ constructor() {
4
+ this.currentState = FileUploadState.DEFAULT;
5
+ }
6
+ updateState(state) {
7
+ this.currentState = state;
8
+ }
9
+ onFileDrop(callback) {
10
+ this.fileDropCallback = callback;
11
+ }
12
+ onStateChange(callback) {
13
+ this.stateChangeCallback = callback;
14
+ }
15
+ setState(state) {
16
+ if (this.currentState === FileUploadState.DISABLED)
17
+ return;
18
+ this.currentState = state;
19
+ this.stateChangeCallback?.(state);
20
+ }
21
+ dragEnter(e) {
22
+ if (this.currentState === FileUploadState.DISABLED)
23
+ return;
24
+ e.preventDefault();
25
+ this.setState(FileUploadState.DRAG);
26
+ }
27
+ dragLeave(e) {
28
+ if (this.currentState === FileUploadState.DISABLED)
29
+ return;
30
+ e.preventDefault();
31
+ this.setState(FileUploadState.DEFAULT);
32
+ }
33
+ dragOver(e) {
34
+ if (this.currentState === FileUploadState.DISABLED)
35
+ return;
36
+ e.preventDefault();
37
+ }
38
+ drop(e) {
39
+ if (this.currentState === FileUploadState.DISABLED)
40
+ return;
41
+ e.preventDefault();
42
+ e.stopPropagation();
43
+ this.setState(FileUploadState.DEFAULT);
44
+ this.handleFiles(e);
45
+ }
46
+ handleDocumentDrop(e) {
47
+ if (this.currentState === FileUploadState.DISABLED)
48
+ return;
49
+ e.preventDefault();
50
+ e.stopPropagation();
51
+ this.setState(FileUploadState.DEFAULT);
52
+ }
53
+ preventDragOver(e) {
54
+ e.preventDefault();
55
+ }
56
+ preventDrop(e) {
57
+ e.preventDefault();
58
+ e.stopPropagation();
59
+ }
60
+ handleFiles(event) {
61
+ if (this.currentState === FileUploadState.DISABLED)
62
+ return;
63
+ event.preventDefault?.();
64
+ let files = null;
65
+ if ('dataTransfer' in event && event.dataTransfer) {
66
+ files = event.dataTransfer.files;
67
+ }
68
+ if (!files && event.target instanceof HTMLInputElement) {
69
+ files = event.target.files;
70
+ }
71
+ if (files && files.length > 0) {
72
+ const newFiles = Array.from(files);
73
+ this.fileDropCallback?.(newFiles);
74
+ }
75
+ }
76
+ }
77
+ //# sourceMappingURL=drag-drop.util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drag-drop.util.js","sourceRoot":"","sources":["../../../../src/nile-file-upload/utils/drag-drop.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,MAAM,OAAO,WAAW;IAMtB;QALQ,iBAAY,GAAoB,eAAe,CAAC,OAAO,CAAC;IAKjD,CAAC;IAET,WAAW,CAAC,KAAsB;QACvC,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;IAC5B,CAAC;IAEM,UAAU,CAAC,QAAiC;QACjD,IAAI,CAAC,gBAAgB,GAAG,QAAQ,CAAC;IACnC,CAAC;IAEM,aAAa,CAAC,QAA0C;QAC7D,IAAI,CAAC,mBAAmB,GAAG,QAAQ,CAAC;IACtC,CAAC;IAEO,QAAQ,CAAC,KAAsB;QACrC,IAAI,IAAI,CAAC,YAAY,KAAK,eAAe,CAAC,QAAQ;YAAE,OAAO;QAE3D,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;QAC1B,IAAI,CAAC,mBAAmB,EAAE,C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,EAAE,CAAC;QACnB,CAAC,CAAC,eAAe,EAAE,CAAC;IACtB,CAAC;IAEM,WAAW,CAAC,KAAwB;QACzC,IAAI,IAAI,CAAC,YAAY,KAAK,eAAe,CAAC,QAAQ;YAAE,OAAO;QAE3D,KAAK,CAAC,cAAc,EAAE,EAAE,CAAC;QACzB,IAAI,KAAK,GAAoB,IAAI,CAAC;QAElC,IAAI,cAAc,IAAI,KAAK,IAAI,KAAK,CAAC,YAAY,EAAE,CAAC;YAClD,KAAK,GAAG,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC;QACnC,CAAC;QAED,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,YAAY,gBAAgB,EAAE,CAAC;YACvD,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;QAC7B,CAAC;QAED,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC9B,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACnC,IAAI,CAAC,gBAAgB,EAAE,CAAC,QAAQ,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;CACF","sourcesContent":["import { FileUploadState } from \"../types\";\n\nexport class DragHandler {\n private currentState: FileUploadState = FileUploadState.DEFAULT;\n\n private stateChangeCallback?: (state: FileUploadState) => void;\n private fileDropCallback?: (files: File[]) => void;\n\n constructor() {}\n\n public updateState(state: FileUploadState): void {\n this.currentState = state;\n }\n\n public onFileDrop(callback: (files: File[]) => void): void {\n this.fileDropCallback = callback;\n }\n\n public onStateChange(callback: (state: FileUploadState) => void): void {\n this.stateChangeCallback = callback;\n }\n\n private setState(state: FileUploadState): void {\n if (this.currentState === FileUploadState.DISABLED) return;\n\n this.currentState = state;\n this.stateChangeCallback?.(state);\n }\n\n public dragEnter(e: DragEvent): void {\n if (this.currentState === FileUploadState.DISABLED) return;\n\n e.preventDefault();\n this.setState(FileUploadState.DRAG);\n }\n\n public dragLeave(e: DragEvent): void {\n if (this.currentState === FileUploadState.DISABLED) return;\n\n e.preventDefault();\n this.setState(FileUploadState.DEFAULT);\n }\n\n public dragOver(e: DragEvent): void {\n if (this.currentState === FileUploadState.DISABLED) return;\n\n e.preventDefault();\n }\n\n public drop(e: DragEvent): void {\n if (this.currentState === FileUploadState.DISABLED) return;\n\n e.preventDefault();\n e.stopPropagation();\n this.setState(FileUploadState.DEFAULT);\n this.handleFiles(e);\n }\n\n public handleDocumentDrop(e: DragEvent): void {\n if (this.currentState === FileUploadState.DISABLED) return;\n\n e.preventDefault();\n e.stopPropagation();\n this.setState(FileUploadState.DEFAULT);\n }\n\n public preventDragOver(e: DragEvent): void {\n e.preventDefault();\n }\n\n public preventDrop(e: DragEvent): void {\n e.preventDefault();\n e.stopPropagation();\n }\n\n public handleFiles(event: Event | DragEvent): void {\n if (this.currentState === FileUploadState.DISABLED) return;\n\n event.preventDefault?.();\n let files: FileList | null = null;\n\n if ('dataTransfer' in event && event.dataTransfer) {\n files = event.dataTransfer.files;\n }\n\n if (!files && event.target instanceof HTMLInputElement) {\n files = event.target.files;\n }\n\n if (files && files.length > 0) {\n const newFiles = Array.from(files);\n this.fileDropCallback?.(newFiles);\n }\n }\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import { DragHandler } from "./drag-drop.util";
2
+ import { FileUploadState } from "../types";
3
+ import { NileFileUpload } from "../nile-file-upload";
4
+ export declare const areDuplicates: (files: File[], uploadedFiles: File[]) => boolean;
5
+ export declare const setUpDragHandler: (nileFileUpload: NileFileUpload, dragHandler: DragHandler) => void;
6
+ export declare const addGlobalListeners: (dragHandler: DragHandler) => void;
7
+ export declare const addInternalListeners: (nileFileUpload: NileFileUpload, dragHandler: DragHandler) => void;
8
+ export declare function handleHoverIn(setState: (state: FileUploadState) => void, currentState: FileUploadState): void;
9
+ export declare function handleHoverOut(setState: (state: FileUploadState) => void, currentState: FileUploadState): void;