@aquera/nile-elements 0.1.63-beta-1.2 → 0.1.64-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 (61) hide show
  1. package/demo/index.html +8 -8
  2. package/dist/index.js +84 -84
  3. package/dist/nile-file-preview/nile-file-preview.cjs.js +1 -1
  4. package/dist/nile-file-preview/nile-file-preview.cjs.js.map +1 -1
  5. package/dist/nile-file-preview/nile-file-preview.css.cjs.js +1 -1
  6. package/dist/nile-file-preview/nile-file-preview.css.cjs.js.map +1 -1
  7. package/dist/nile-file-preview/nile-file-preview.css.esm.js +19 -2
  8. package/dist/nile-file-preview/nile-file-preview.esm.js +3 -3
  9. package/dist/nile-file-preview/nile-file-preview.template.cjs.js +1 -1
  10. package/dist/nile-file-preview/nile-file-preview.template.cjs.js.map +1 -1
  11. package/dist/nile-file-preview/nile-file-preview.template.esm.js +22 -22
  12. package/dist/nile-file-preview/utils/index.cjs.js +1 -1
  13. package/dist/nile-file-preview/utils/index.esm.js +1 -1
  14. package/dist/nile-file-preview/utils/nile-file-preview.util.cjs.js +1 -1
  15. package/dist/nile-file-preview/utils/nile-file-preview.util.cjs.js.map +1 -1
  16. package/dist/nile-file-preview/utils/nile-file-preview.util.esm.js +1 -1
  17. package/dist/nile-file-upload/nile-file-upload.cjs.js +1 -1
  18. package/dist/nile-file-upload/nile-file-upload.cjs.js.map +1 -1
  19. package/dist/nile-file-upload/nile-file-upload.css.cjs.js +1 -1
  20. package/dist/nile-file-upload/nile-file-upload.css.cjs.js.map +1 -1
  21. package/dist/nile-file-upload/nile-file-upload.css.esm.js +1 -1
  22. package/dist/nile-file-upload/nile-file-upload.esm.js +2 -2
  23. package/dist/nile-file-upload/nile-file-upload.template.cjs.js +3 -3
  24. package/dist/nile-file-upload/nile-file-upload.template.cjs.js.map +1 -1
  25. package/dist/nile-file-upload/nile-file-upload.template.esm.js +22 -22
  26. package/dist/nile-file-upload/utils/file-validation.util.cjs.js +2 -2
  27. package/dist/nile-file-upload/utils/file-validation.util.cjs.js.map +1 -1
  28. package/dist/nile-file-upload/utils/file-validation.util.esm.js +1 -1
  29. package/dist/src/nile-file-preview/nile-file-preview.css.js +19 -2
  30. package/dist/src/nile-file-preview/nile-file-preview.css.js.map +1 -1
  31. package/dist/src/nile-file-preview/nile-file-preview.d.ts +1 -0
  32. package/dist/src/nile-file-preview/nile-file-preview.js +7 -6
  33. package/dist/src/nile-file-preview/nile-file-preview.js.map +1 -1
  34. package/dist/src/nile-file-preview/nile-file-preview.template.d.ts +3 -2
  35. package/dist/src/nile-file-preview/nile-file-preview.template.js +16 -10
  36. package/dist/src/nile-file-preview/nile-file-preview.template.js.map +1 -1
  37. package/dist/src/nile-file-preview/utils/nile-file-preview.util.d.ts +1 -2
  38. package/dist/src/nile-file-preview/utils/nile-file-preview.util.js +8 -8
  39. package/dist/src/nile-file-preview/utils/nile-file-preview.util.js.map +1 -1
  40. package/dist/src/nile-file-upload/nile-file-upload.css.js +1 -1
  41. package/dist/src/nile-file-upload/nile-file-upload.css.js.map +1 -1
  42. package/dist/src/nile-file-upload/nile-file-upload.d.ts +1 -0
  43. package/dist/src/nile-file-upload/nile-file-upload.js +7 -6
  44. package/dist/src/nile-file-upload/nile-file-upload.js.map +1 -1
  45. package/dist/src/nile-file-upload/nile-file-upload.template.d.ts +5 -4
  46. package/dist/src/nile-file-upload/nile-file-upload.template.js +24 -15
  47. package/dist/src/nile-file-upload/nile-file-upload.template.js.map +1 -1
  48. package/dist/src/nile-file-upload/utils/file-validation.util.d.ts +1 -0
  49. package/dist/src/nile-file-upload/utils/file-validation.util.js +11 -0
  50. package/dist/src/nile-file-upload/utils/file-validation.util.js.map +1 -1
  51. package/dist/tsconfig.tsbuildinfo +1 -1
  52. package/package.json +1 -1
  53. package/src/nile-file-preview/nile-file-preview.css.ts +19 -2
  54. package/src/nile-file-preview/nile-file-preview.template.ts +23 -10
  55. package/src/nile-file-preview/nile-file-preview.ts +7 -6
  56. package/src/nile-file-preview/utils/nile-file-preview.util.ts +7 -10
  57. package/src/nile-file-upload/nile-file-upload.css.ts +1 -1
  58. package/src/nile-file-upload/nile-file-upload.template.ts +35 -17
  59. package/src/nile-file-upload/nile-file-upload.ts +7 -6
  60. package/src/nile-file-upload/utils/file-validation.util.ts +12 -0
  61. package/vscode-html-custom-data.json +2 -2
@@ -66,7 +66,7 @@ export function getHorizontalNoPreviewState(file, originalUrl) {
66
66
  <nile-icon name="general" size="20" color="var(--nile-colors-blue-500)"></nile-icon>
67
67
  </div>
68
68
  <div class="preview-file-info">
69
- <p>${truncateString(file.name, file?.type)}</p>
69
+ <p>${file.name}</p>
70
70
  <p>${getFileType(file.type)} &#8226; ${formatFileSize(Number(file.size))}</p>
71
71
  </div>
72
72
  </div>
@@ -82,7 +82,8 @@ export function getHorizontalNoPreviewState(file, originalUrl) {
82
82
  </div>
83
83
  `;
84
84
  }
85
- export function getHorizontalErrorState(file, errorMessage, originalUrl) {
85
+ export function getHorizontalErrorState(file, errorMessage, originalUrl, nileFilePreview) {
86
+ truncateString(nileFilePreview);
86
87
  return html `
87
88
  <div class="error horizontal-div" part="horizontal-error-state">
88
89
  <div class="error-container">
@@ -91,9 +92,11 @@ export function getHorizontalErrorState(file, errorMessage, originalUrl) {
91
92
  </div>
92
93
  <div class="file-info">
93
94
  <p class="horizontal-file-name">${file.name}</p>
94
- <nile-tooltip content=${errorMessage}>
95
- <span>${errorMessage}</span>
96
- </nile-tooltip>
95
+ ${nileFilePreview.isStringTruncated
96
+ ? html `<nile-tooltip content=${errorMessage}>
97
+ <span>${errorMessage}</span>
98
+ </nile-tooltip>`
99
+ : html `<span>${errorMessage}</span>`}
97
100
  </div>
98
101
  </div>
99
102
  <slot @click=${(e) => removeFile(file, e, originalUrl)} name="cancelIcon">
@@ -167,7 +170,7 @@ export function getVerticalNoPreviewState(file, originalUrl) {
167
170
  </div>
168
171
 
169
172
  <div class="content-container">
170
- <p>${truncateString(file.name, file?.type)}</p>
173
+ <p>${file.name}</p>
171
174
  <p>${getFileType(file.type)} &#8226; ${formatFileSize(Number(file.size))}</p>
172
175
  </div>
173
176
 
@@ -181,7 +184,8 @@ export function getVerticalNoPreviewState(file, originalUrl) {
181
184
  </div>
182
185
  `;
183
186
  }
184
- export function getVerticalErrorState(file, errorMessage, originalUrl) {
187
+ export function getVerticalErrorState(file, errorMessage, originalUrl, nileFilePreview) {
188
+ truncateString(nileFilePreview);
185
189
  return html `
186
190
  <div class="vertical-div vertical-error" part="vertical-error-state">
187
191
  <div class="vertical-document-icon error-bg">
@@ -190,9 +194,11 @@ export function getVerticalErrorState(file, errorMessage, originalUrl) {
190
194
 
191
195
  <div class="file-info-vertical-state">
192
196
  <p class="vertical-file-name">${file.name}</p>
193
- <nile-tooltip content=${errorMessage}>
194
- <span>${errorMessage}</span>
195
- </nile-tooltip>
197
+ ${nileFilePreview.isStringTruncated
198
+ ? html `<nile-tooltip content=${errorMessage}>
199
+ <span>${errorMessage}</span>
200
+ </nile-tooltip>`
201
+ : html `<span>${errorMessage}</span>`}
196
202
  </div>
197
203
 
198
204
  <slot @click=${(e) => removeFile(file, e, originalUrl)} name="cancelIcon">
@@ -1 +1 @@
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;AACvD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAE5F,MAAM,UAAU,2BAA2B,CAC1C,IAAU,EACV,YAAoB;IAElB,OAAO,IAAI,CAAA;;;;;;iBAME,YAAY;;;;qBAIR,YAAY;;4CAEW,IAAI,CAAC,IAAI;;uBAE9B,CAAC,CAAgC,EAAE,EAAE,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html, TemplateResult } from 'lit';\nimport { FilePreviewErrorMessages, RemoveFileDetail } from './types';\nimport { removeFile, cancelFileUpload } from './utils';\nimport { formatFileSize, truncateString, getFileType } from './utils/nile-file-preview.util';\n\n export function getHorizontalUploadingState(\n file: File,\n uploadStatus: number\n ): TemplateResult {\n return html`\n <div class=\"uploading\" part=\"horizontal-uploading-state\">\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 part=\"horizontal-progress-bar\"\n value=\"${uploadStatus}\"\n ></nile-progress-bar>\n <p class=\"horizontal-file-name\">${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\" part=\"horizontal-preview-state\">\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>${getFileType(file.type)} &#8226; ${formatFileSize(Number(file.size))}</p>\n </div>\n </div>\n <div class=\"preview-actions\">\n <slot @click=${(e: CustomEvent<RemoveFileDetail>) => removeFile(file, e, originalUrl)} name=\"cancelIcon\">\n <nile-icon\n name=\"trash\"\n size=\"14\"\n class=\"icon\"\n ></nile-icon>\n </slot>\n </div>\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\" part=\"horizontal-no-preview-state\">\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>${truncateString(file.name, file?.type)}</p>\n <p>${getFileType(file.type)} &#8226; ${formatFileSize(Number(file.size))}</p>\n </div>\n </div>\n <div>\n <slot @click=${(e: CustomEvent<RemoveFileDetail>) => removeFile(file, e, originalUrl)} name=\"cancelIcon\">\n <nile-icon\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\" part=\"horizontal-error-state\">\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 class=\"horizontal-file-name\">${file.name}</p>\n <nile-tooltip content=${errorMessage}>\n <span>${errorMessage}</span>\n </nile-tooltip>\n </div>\n </div>\n <slot @click=${(e: CustomEvent<RemoveFileDetail>) => removeFile(file, e, originalUrl)} name=\"cancelIcon\">\n <nile-icon\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\" part=\"vertical-uploading-state\">\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 class=\"vertical-file-name\">${file.name}</p>\n </div>\n\n <slot @click=${(e: CustomEvent<RemoveFileDetail>) => cancelFileUpload(file, e)} name=\"cancelIcon\">\n <nile-icon\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\" part=\"vertical-preview-state\">\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>${getFileType(file.type)} &#8226; ${formatFileSize(Number(file.size))}</p>\n </div>\n\n <slot @click=${(e: CustomEvent<RemoveFileDetail>) => removeFile(file, e, originalUrl)} name=\"cancelIcon\">\n <nile-icon\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\" part=\"vertical-no-preview-state\">\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>${truncateString(file.name, file?.type)}</p>\n <p>${getFileType(file.type)} &#8226; ${formatFileSize(Number(file.size))}</p>\n </div>\n\n <slot @click=${(e: CustomEvent<RemoveFileDetail>) => removeFile(file, e, originalUrl)} name=\"cancelIcon\">\n <nile-icon\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\" part=\"vertical-error-state\">\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 class=\"vertical-file-name\">${file.name}</p>\n <nile-tooltip content=${errorMessage}>\n <span>${errorMessage}</span>\n </nile-tooltip>\n </div>\n\n <slot @click=${(e: CustomEvent<RemoveFileDetail>) => removeFile(file, e, originalUrl)} name=\"cancelIcon\">\n <nile-icon\n name=\"close\"\n size=\"14\"\n class=\"icon corner-icon\"\n ></nile-icon>\n </slot>\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;AACvD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAG5F,MAAM,UAAU,2BAA2B,CAC1C,IAAU,EACV,YAAoB;IAElB,OAAO,IAAI,CAAA;;;;;;iBAME,YAAY;;;;qBAIR,YAAY;;4CAEW,IAAI,CAAC,IAAI;;uBAE9B,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,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;;;;uBAI3D,CAAC,CAAgC,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,EAAE,WAAW,CAAC;;;;;;;;;GAS1F,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,2BAA2B,CACzC,IAAU,EACV,WAAmB;IAEnB,OAAO,IAAI,CAAA;;;;;;;eAOE,IAAI,CAAC,IAAI;eACT,WAAW,CAAC,IAAI,CAAC,IAAI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WAAW,CAAC;;;;;;;;GAQxF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,yBAAyB,CACvC,IAAU,EACV,WAAmB;IAEnB,OAAO,IAAI,CAAA;;;;;;;aAOA,IAAI,CAAC,IAAI;aACT,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;;;qBAG3D,CAAC,CAAgC,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,EAAE,WAAW,CAAC;;;;;;;;GAQxF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,IAAU,EACV,YAAoB,EACpB,WAAmB,EACnB,eAAgC;IAEhC,cAAc,CAAC,eAAe,CAAC,CAAC;IAChC,OAAO,IAAI,CAAA;;;;;;;wCAO2B,IAAI,CAAC,IAAI;UAEvC,eAAe,CAAC,iBAAiB;QAC/B,CAAC,CAAC,IAAI,CAAA,yBAAyB,YAAY;wBAC/B,YAAY;8BACN;QAClB,CAAC,CAAC,IAAI,CAAA,SAAS,YAAY,SAC/B;;;qBAGa,CAAC,CAAgC,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,EAAE,WAAW,CAAC;;;;;;;;GAQxF,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';\nimport { formatFileSize, truncateString, getFileType } from './utils/nile-file-preview.util';\nimport { NileFilePreview } from './nile-file-preview';\n\n export function getHorizontalUploadingState(\n file: File,\n uploadStatus: number\n ): TemplateResult {\n return html`\n <div class=\"uploading\" part=\"horizontal-uploading-state\">\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 part=\"horizontal-progress-bar\"\n value=\"${uploadStatus}\"\n ></nile-progress-bar>\n <p class=\"horizontal-file-name\">${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\" part=\"horizontal-preview-state\">\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>${getFileType(file.type)} &#8226; ${formatFileSize(Number(file.size))}</p>\n </div>\n </div>\n <div class=\"preview-actions\">\n <slot @click=${(e: CustomEvent<RemoveFileDetail>) => removeFile(file, e, originalUrl)} name=\"cancelIcon\">\n <nile-icon\n name=\"trash\"\n size=\"14\"\n class=\"icon\"\n ></nile-icon>\n </slot>\n </div>\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\" part=\"horizontal-no-preview-state\">\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>${getFileType(file.type)} &#8226; ${formatFileSize(Number(file.size))}</p>\n </div>\n </div>\n <div>\n <slot @click=${(e: CustomEvent<RemoveFileDetail>) => removeFile(file, e, originalUrl)} name=\"cancelIcon\">\n <nile-icon\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 nileFilePreview: NileFilePreview\n): TemplateResult {\n truncateString(nileFilePreview);\n return html`\n <div class=\"error horizontal-div\" part=\"horizontal-error-state\">\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 class=\"horizontal-file-name\">${file.name}</p>\n ${\n nileFilePreview.isStringTruncated\n ? html`<nile-tooltip content=${errorMessage}>\n <span>${errorMessage}</span>\n </nile-tooltip>`\n : html`<span>${errorMessage}</span>`\n }\n </div>\n </div>\n <slot @click=${(e: CustomEvent<RemoveFileDetail>) => removeFile(file, e, originalUrl)} name=\"cancelIcon\">\n <nile-icon\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\" part=\"vertical-uploading-state\">\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 class=\"vertical-file-name\">${file.name}</p>\n </div>\n\n <slot @click=${(e: CustomEvent<RemoveFileDetail>) => cancelFileUpload(file, e)} name=\"cancelIcon\">\n <nile-icon\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\" part=\"vertical-preview-state\">\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>${getFileType(file.type)} &#8226; ${formatFileSize(Number(file.size))}</p>\n </div>\n\n <slot @click=${(e: CustomEvent<RemoveFileDetail>) => removeFile(file, e, originalUrl)} name=\"cancelIcon\">\n <nile-icon\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\" part=\"vertical-no-preview-state\">\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>${getFileType(file.type)} &#8226; ${formatFileSize(Number(file.size))}</p>\n </div>\n\n <slot @click=${(e: CustomEvent<RemoveFileDetail>) => removeFile(file, e, originalUrl)} name=\"cancelIcon\">\n <nile-icon\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 nileFilePreview: NileFilePreview\n): TemplateResult {\n truncateString(nileFilePreview);\n return html`\n <div class=\"vertical-div vertical-error\" part=\"vertical-error-state\">\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 class=\"vertical-file-name\">${file.name}</p>\n ${\n nileFilePreview.isStringTruncated\n ? html`<nile-tooltip content=${errorMessage}>\n <span>${errorMessage}</span>\n </nile-tooltip>`\n : html`<span>${errorMessage}</span>`\n }\n </div>\n\n <slot @click=${(e: CustomEvent<RemoveFileDetail>) => removeFile(file, e, originalUrl)} name=\"cancelIcon\">\n <nile-icon\n name=\"close\"\n size=\"14\"\n class=\"icon corner-icon\"\n ></nile-icon>\n </slot>\n </div>\n `;\n}"]}
@@ -5,5 +5,4 @@ export declare const removeFile: (removeFile: File, e: CustomEvent<RemoveFileDet
5
5
  export declare const cancelFileUpload: (file: File, e: CustomEvent<RemoveFileDetail>) => void;
6
6
  export declare const formatFileSize: (bytes: number) => string;
7
7
  export declare const getFileType: (type: string) => string;
8
- export declare const truncateString: (str: string, type: string) => string;
9
- export declare const fileUploadServerError: (nileFilePreview: NileFilePreview) => void;
8
+ export declare const truncateString: (nileFilePreview: NileFilePreview) => void;
@@ -50,14 +50,14 @@ export const formatFileSize = (bytes) => {
50
50
  export const getFileType = (type) => {
51
51
  return type.split('/')[1].toUpperCase();
52
52
  };
53
- export const truncateString = (str, type) => {
54
- return str.length > 20 ? (str.slice(0, 10) + '...' + str.slice(str.length - 5, str.length - 1) + '.' + type.split('/')[1]) : str;
55
- };
56
- export const fileUploadServerError = (nileFilePreview) => {
57
- document.addEventListener('nile-network-error', (e) => {
58
- console.log('working file preview');
59
- nileFilePreview.errorMessage = FilePreviewErrorMessages.NETWORK_ERROR;
53
+ export const truncateString = (nileFilePreview) => {
54
+ if (nileFilePreview.variant === 'vertical' && nileFilePreview.errorMessage.length > 34) {
55
+ nileFilePreview.isStringTruncated = true;
60
56
  nileFilePreview.requestUpdate();
61
- });
57
+ }
58
+ else if (nileFilePreview.variant === 'horizontal' && nileFilePreview.errorMessage.length > 96) {
59
+ nileFilePreview.isStringTruncated = true;
60
+ nileFilePreview.requestUpdate();
61
+ }
62
62
  };
63
63
  //# sourceMappingURL=nile-file-preview.util.js.map
@@ -1 +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,GA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QAAQ,CAAC,gBAAgB,CAAC,oBAAoB,EAAE,CAAC,CAAM,EAAE,EAAE;QACzD,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;QAEpC,eAAe,CAAC,YAAY,GAAG,wBAAwB,CAAC,aAAa,CAAC;QACtE,eAAe,CAAC,aAAa,EAAE,CAAC;IAClC,CAAC,CAAC,CAAC;AACL,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}\n\nexport const formatFileSize = (bytes: number): string => {\n const kb = bytes / 1024;\n const mb = kb / 1024;\n const gb = mb / 1024;\n\n if (gb >= 1) return gb.toFixed(2) + ' GB';\n if (mb >= 1) return mb.toFixed(2) + ' MB';\n if (kb >= 1) return kb.toFixed(2) + ' KB';\n return bytes + ' B';\n}\n\nexport const getFileType = (type: string): string => {\n return type.split('/')[1].toUpperCase();\n}\n\nexport const truncateString = (str: string, type: string): string => {\n return str.length > 20 ? (str.slice(0, 10) + '...' + str.slice(str.length - 5, str.length - 1) + '.' + type.split('/')[1]) : str;\n}\n\nexport const fileUploadServerError = (nileFilePreview: NileFilePreview) => {\n document.addEventListener('nile-network-error', (e: any) => {\n console.log('working file preview');\n \n nileFilePreview.errorMessage = FilePreviewErrorMessages.NETWORK_ERROR;\n nileFilePreview.requestUpdate();\n });\n}"]}
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,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AK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;AAC1C,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,eAAgC,EAAQ,EAAE;IACvE,IAAG,eAAe,CAAC,OAAO,KAAK,UAAU,IAAI,eAAe,CAAC,YAAY,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;QACtF,eAAe,CAAC,iBAAiB,GAAG,IAAI,CAAC;QACzC,eAAe,CAAC,aAAa,EAAE,CAAC;IAClC,CAAC;SAAM,IAAG,eAAe,CAAC,OAAO,KAAK,YAAY,IAAI,eAAe,CAAC,YAAY,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;QAC/F,eAAe,CAAC,iBAAiB,GAAG,IAAI,CAAC;QACzC,eAAe,CAAC,aAAa,EAAE,CAAC;IAClC,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}\n\nexport const formatFileSize = (bytes: number): string => {\n const kb = bytes / 1024;\n const mb = kb / 1024;\n const gb = mb / 1024;\n\n if (gb >= 1) return gb.toFixed(2) + ' GB';\n if (mb >= 1) return mb.toFixed(2) + ' MB';\n if (kb >= 1) return kb.toFixed(2) + ' KB';\n return bytes + ' B';\n}\n\nexport const getFileType = (type: string): string => {\n return type.split('/')[1].toUpperCase();\n}\n\nexport const truncateString = (nileFilePreview: NileFilePreview): void => {\n if(nileFilePreview.variant === 'vertical' && nileFilePreview.errorMessage.length > 34) {\n nileFilePreview.isStringTruncated = true;\n nileFilePreview.requestUpdate();\n } else if(nileFilePreview.variant === 'horizontal' && nileFilePreview.errorMessage.length > 96) {\n nileFilePreview.isStringTruncated = true;\n nileFilePreview.requestUpdate();\n }\n}"]}
@@ -597,7 +597,7 @@ export const styles = css `
597
597
  color: var(--nile-colors-red-700);
598
598
  white-space: nowrap;
599
599
  text-align: left;
600
- max-width: 538px;
600
+ max-width: 560px;
601
601
  overflow: hidden;
602
602
  text-overflow: ellipsis;
603
603
  }
@@ -1 +1 @@
1
- {"version":3,"file":"nile-file-upload.css.js","sourceRoot":"","sources":["../../../src/nile-file-upload/nile-file-upload.css.ts"],"names":[],"mappings":"AAAA;;;;;EAKE;AAEF,OAAO,EAAC,GAAG,EAAC,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAimBxB,CAAC;AAEF,eAAe,CAAC,MAAM,CAAC,CAAC","sourcesContent":["/**\n* Copyright Aquera Inc 2023\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 {css} from 'lit';\n\n/**\n * FileUpload CSS\n */\nexport const styles = css`\n :host {\n display: inline-block;\n }\n\n * {\n padding: 0px;\n margin: 0px;\n box-sizing: border-box;\n }\n\n .wrapper {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: flex-start;\n width: min-content;\n }\n\n input {\n display: none;\n }\n\n .horizontal-div {\n margin-bottom: 10px;\n height: 62px;\n max-width: 648px;\n width: 648px;\n min-width: 230px;\n padding: 12px;\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 18px;\n border-radius: var(--nile-radius-radius-xs);\n border: 1px dashed var(--nile-colors-neutral-500);\n color: var(--nile-colors-dark-900);\n background-color: var(--nile-colors-white-base);\n }\n\n .hover-border {\n border-color: var(--nile-colors-primary-600);\n }\n\n .title {\n font-size: var(--nile-type-scale-3);\n font-weight: var(--nile-font-weight-regular);\n color: var(--nile-colors-dark-900);\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n max-width: 454px;\n width: 100%;\n }\n\n .subtitle {\n font-size: var(--nile-type-scale-2);\n font-weight: var(--nile-font-weight-regular);\n color: var(--nile-colors-dark-500);\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n max-width: 454px;\n }\n\n .vertical-div {\n min-height: 156px;\n height: auto;\n min-width: 240px;\n width: 240px;\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n align-items: center;\n padding: 12px;\n border-radius: var(--nile-radius-radius-xs);\n color: var(--nile-colors-dark-900);\n border: 1px dashed var(--nile-colors-neutral-500);\n background-color: var(--nile-colors-white-base);\n position: relative; \n }\n\n .vertical-div:hover {\n border-color: var(--nile-colors-blue-500);\n }\n\n .outer-div-border {\n border: 1px solid var(--nile-colors-neutral-400);\n }\n\n .inner-div {\n display: flex;\n align-items: center;\n justify-content: flex-start;\n gap: 18px;\n box-sizing: border-box;\n }\n\n .content {\n display: flex; \n flex-direction: column;\n justify-content: center;\n gap: 8px;\n }\n\n .content h4 {\n margin: 0px;\n font-size: var(--nile-type-scale-3);\n font-weight: var(--nile-font-weight-regular);\n color: var(--nile-colors-dark-900);\n text-align: center;\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n width: 454px;\n }\n \n .content p {\n margin: 0px;\n font-size: var(--nile-type-scale-2);\n color: var(--nile-colors-neutral-700);\n text-align: center;\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n width: 454px;\n }\n\n ::slotted(img), ::slotted(nile-icon), ::slotted(video) {\n --nile-svg-height: 24px !important ;\n --nile-svg-width: 24px !important ;\n height:42px;\n width: 42px;\n object-fit: cover;\n }\n\n .browse-file-button {\n cursor: pointer;\n }\n\n /* DISABLED STATE */\n .disable {\n background-color: var(--nile-colors-dark-200);\n opacity: 0.8;\n cursor: not-allowed;\n color: var(--nile-colors-neutral-500);\n pointer-events: none;\n }\n\n /* DRAGGING */\n .dragging {\n background-color: var(--nile-colors-blue-100);\n border-color: var(--nile-colors-primary-600);\n display: flex;\n align-items: center;\n justify-content: flex-start;\n gap: 18px;\n color: var(--nile-colors-blue-700);\n font-size: var(--nile-type-scale-3);\n font-weight: var(--nile-font-weight-regular);\n }\n\n .icons-container {\n display: flex;\n gap: 4px;\n }\n\n .general-icon {\n transform: rotate(-18.11deg);\n position: relative;\n bottom: 3px;\n }\n\n .image-icon {\n transform: rotate(15deg);\n }\n\n .icon:hover {\n cursor: pointer;\n }\n\n /* Uploading State */\n .uploading {\n width: 648px;\n min-width: 230px;\n display: flex;\n justify-content: space-between;\n align-items: center;\n gap: 18px;\n box-sizing: border-box;\n border: 1px solid var(--nile-colors-neutral-400)\n }\n \n .uploading:hover {\n border-color: var(--nile-colors-neutral-400);\n }\n\n .progress-bar-container {\n width: 100%;\n display: flex;\n flex-direction: column;\n gap: 0px;\n }\n\n .progress-bar-percent {\n width: 100%;\n display: flex;\n justify-content: space-between;\n font-size: var(--nile-type-scale-2);\n font-weight: var(--nile-font-weight-regular);\n }\n\n .progress-bar-container p {\n margin: 0px;\n }\n\n .progress-bar-container > p {\n font-size: var(--nile-type-scale-1);\n color: var(--nile-colors-dark-500);\n }\n\n /* PREVIEW STATE */\n .preview {\n border: 1px solid var(--nile-colors-neutral-400);\n }\n\n .preview:hover {\n border-color: var(--nile-colors-neutral-400);\n }\n\n .preview-inner {\n display: flex;\n gap: 18px;\n }\n\n .preview-image-container {\n height: 42px;\n width: 42px;\n }\n\n .preview-image-container img {\n height: 42px;\n width: 42px;\n object-fit: contain;\n border-radius: var(--nile-radius-radius-xs);\n border: 1px solid var(--nile-colors-neutral-400);\n }\n \n .preview-file-info {\n width: 100%;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: flex-start;\n gap: 8px;\n }\n\n .preview-file-info p {\n margin: 0px;\n font-size: var(--nile-type-scale-3);\n font-weight: var(--nile-font-weight-regular);\n }\n\n .preview-file-info p:last-of-type{\n color: var(--nile-colors-neutral-700);\n font-size: var(--nile-type-scale-2);\n font-weight: var(--nile-font-weight-regular);\n }\n\n .preview nile-icon:hover {\n cursor: pointer;\n }\n\n\n /* NO PREVIEW STATE */\n .no-preview {\n border: 1px solid var(--nile-colors-neutral-400);\n }\n\n .no-preview:hover {\n border-color: var(--nile-colors-neutral-400);\n }\n\n .no-preview-container {\n display: flex;\n gap: 18px;\n }\n\n .document-icon {\n height: 40px;\n width: 40px;\n border-radius: var(--nile-radius-radius-xs);\n padding: 2px 3px 2px 3px;\n display: flex;\n justify-content: center;\n align-items: center;\n border: 1px solid var(--nile-colors-blue-400);\n background-color: var(--nile-colors-blue-100);\n }\n\n .document-icon nile-icon {\n height: 40px;\n width: 40px;\n }\n \n .preview-file-info {\n width: 100%;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: flex-start;\n gap: 8px;\n }\n\n .preview-file-info p {\n margin: 0px;\n font-size: var(--nile-type-scale-3);\n font-weight: var(--nile-font-weight-regular);\n }\n\n .preview-file-info p:last-of-type{\n color: var(--nile-colors-neutral-700);\n font-size: var(--nile-type-scale-2);\n font-weight: var(--nile-font-weight-regular);\n }\n\n .no-preview > nile-icon:hover {\n cursor: pointer;\n }\n\n /* ERROR STATE */\n \n .error {\n border: 1px solid var(--nile-colors-neutral-400);\n }\n\n .error:hover {\n border-color: var(--nile-colors-neutral-400);\n }\n\n .error-container {\n width: 100%;\n display: flex;\n gap: 18px;\n }\n\n .error-icon {\n height: 40px;\n width: 40px;\n border-radius: var(--nile-radius-radius-xs);\n padding: 2px 3px 2px 3px;\n display: flex;\n justify-content: center;\n align-items: center;\n border: 1px solid var(--nile-colors-red-400);\n background-color: var(--nile-colors-red-100);\n }\n\n .error-icon nile-icon {\n height: 40px;\n width: 40px;\n }\n \n .file-info {\n width: 100%;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: flex-start;\n gap: 8px;\n }\n\n .file-info p {\n margin: 0px;\n font-size: var(--nile-type-scale-3);\n font-weight: var(--nile-font-weight-regular);\n }\n\n .file-info p:last-of-type{\n color: var(--nile-colors-red-700);\n font-size: var(--nile-type-scale-2);\n font-weight: var(--nile-font-weight-regular);\n }\n\n .error > nile-icon:hover {\n cursor: pointer;\n }\n\n /* VARTICAL STATE START */\n /* Default State */\n\n .vertical-default {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 18px\n }\n\n .content-container {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n gap: 8px;\n }\n\n .content-container div.title {\n font-size: var(--nile-type-scale-3);\n font-weight: var(--nile-font-weight-regular);\n color: var(--nile-colors-dark-900);\n text-align: center;\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n width: 222px;\n }\n\n .content-container div.subtitle {\n font-size: var(--nile-type-scale-2);\n font-weight: var(--nile-font-weight-regular);\n color: var(--nile-colors-dark-500);\n text-align: center;\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n width: 222px;\n }\n\n /* Drag State */\n .vertical-drag {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n gap:18px;\n font-size: var(--nile-type-scale-3);\n color: var(--nile-colors-blue-700);\n background-color: var(--nile-colors-blue-100);\n border-color: var(--nile-colors-blue-500);\n }\n\n /* Uploading State */\n .vertical-uploading {\n display: flex;\n flex-direction: column;\n justify-content: flex-end;\n align-items: center;\n border: 1px solid var(--nile-colors-neutral-400);\n }\n\n .vertical-uploading:hover {\n border-color: var(--nile-colors-neutral-400);\n }\n\n .loading {\n display: flex;\n justify-content: center;\n align-items: center;\n }\n\n .corner-icon {\n position: absolute;\n top: 10px;\n right: 10px;\n }\n\n /* Preview State */\n .vertical-preview {\n border: 1px solid var(--nile-colors-neutral-400);\n }\n\n .vertical-preview:hover {\n border-color: var(--nile-colors-neutral-400);\n }\n\n .image-preview {\n border: 1px solid var(--nile-colors-neutral-400);\n object-fit: cover;\n width: 80px;\n height: 80px;\n border-radius: var(--nile-radius-radius-xs);\n }\n\n /* Vertical No Preview State */\n .vertical-no-preview {\n border: 1px solid var(--nile-colors-neutral-400);\n }\n\n .vertical-no-preview:hover {\n border-color: var(--nile-colors-neutral-400);\n }\n\n .vertical-document-icon {\n height: 80px;\n width: 80px;\n padding: 2px 3px 2px 3px;\n display: flex;\n justify-content: center;\n align-items: center;\n border-radius: var(--nile-radius-radius-xs);\n border: 1px solid var(--nile-colors-blue-400);\n background-color: var(--nile-colors-blue-100);\n }\n\n /* Veritcal Error State */\n .vertical-error {\n border: 1px solid var(--nile-colors-neutral-400);\n }\n\n .vertical-error:hover {\n border-color: var(--nile-colors-neutral-400);\n }\n\n .error-bg {\n background-color: var(--nile-colors-red-100);\n border: 1px solid var(--nile-colors-red-400);\n }\n\n .error-message {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n gap: 8px;\n margin: 0px;\n font-size: var(--nile-type-scale-3);\n font-weight: var(--nile-font-weight-regular);\n text-align: start;\n }\n\n .error-p {\n color: var(--nile-colors-red-700);\n font-size: var(--nile-type-scale-2);\n width: 216px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n text-align: center;\n }\n\n .error-p p {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n margin: 0;\n }\n\n\n /* Displaing uploaded files CSS */\n .display-files {\n display: flex;\n flex-direction: column;\n justify-content: flex-start;\n align-items: center;\n gap: 8px;\n width: 648px;\n min-width: 230px;\n max-height: 200px;\n overflow-y: auto;\n border: 1px solid var(--nile-colors-neutral-700);\n border-radius: var(--nile-radius-radius-xs);\n scrollbar-width: none;\n padding: 12px;\n }\n\n ul, li {\n width: 100%;\n }\n\n li {\n list-style-type: none;\n }\n\n /* for the upload error messages */\n .upload-error {\n font-size: var(--nile-type-scale-2);\n font-weight: var(--nile-font-weight-regular);\n color: var(--nile-colors-red-700);\n display: flex;\n justify-content: flex-start;\n align-items: center;\n gap: var(--nile-spacing-one-half-x);\n }\n\n .upload-error > nile-tooltip > span {\n color: var(--nile-colors-red-700);\n white-space: nowrap;\n text-align: left;\n max-width: 538px;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n\n .vertical-upload-error {\n display: flex;\n gap: 4px;\n }\n\n .vertical-upload-error > nile-tooltip > span {\n color: var(--nile-colors-red-700);\n white-space: nowrap;\n text-align: left;\n width: 222px;\n overflow: hidden;\n text-overflow: ellipsis;\n font-size: var(--nile-type-scale-2);\n display: inline-block;\n }\n`;\n\nexport default [styles];"]}
1
+ {"version":3,"file":"nile-file-upload.css.js","sourceRoot":"","sources":["../../../src/nile-file-upload/nile-file-upload.css.ts"],"names":[],"mappings":"AAAA;;;;;EAKE;AAEF,OAAO,EAAC,GAAG,EAAC,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAimBxB,CAAC;AAEF,eAAe,CAAC,MAAM,CAAC,CAAC","sourcesContent":["/**\n* Copyright Aquera Inc 2023\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 {css} from 'lit';\n\n/**\n * FileUpload CSS\n */\nexport const styles = css`\n :host {\n display: inline-block;\n }\n\n * {\n padding: 0px;\n margin: 0px;\n box-sizing: border-box;\n }\n\n .wrapper {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: flex-start;\n width: min-content;\n }\n\n input {\n display: none;\n }\n\n .horizontal-div {\n margin-bottom: 10px;\n height: 62px;\n max-width: 648px;\n width: 648px;\n min-width: 230px;\n padding: 12px;\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 18px;\n border-radius: var(--nile-radius-radius-xs);\n border: 1px dashed var(--nile-colors-neutral-500);\n color: var(--nile-colors-dark-900);\n background-color: var(--nile-colors-white-base);\n }\n\n .hover-border {\n border-color: var(--nile-colors-primary-600);\n }\n\n .title {\n font-size: var(--nile-type-scale-3);\n font-weight: var(--nile-font-weight-regular);\n color: var(--nile-colors-dark-900);\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n max-width: 454px;\n width: 100%;\n }\n\n .subtitle {\n font-size: var(--nile-type-scale-2);\n font-weight: var(--nile-font-weight-regular);\n color: var(--nile-colors-dark-500);\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n max-width: 454px;\n }\n\n .vertical-div {\n min-height: 156px;\n height: auto;\n min-width: 240px;\n width: 240px;\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n align-items: center;\n padding: 12px;\n border-radius: var(--nile-radius-radius-xs);\n color: var(--nile-colors-dark-900);\n border: 1px dashed var(--nile-colors-neutral-500);\n background-color: var(--nile-colors-white-base);\n position: relative; \n }\n\n .vertical-div:hover {\n border-color: var(--nile-colors-blue-500);\n }\n\n .outer-div-border {\n border: 1px solid var(--nile-colors-neutral-400);\n }\n\n .inner-div {\n display: flex;\n align-items: center;\n justify-content: flex-start;\n gap: 18px;\n box-sizing: border-box;\n }\n\n .content {\n display: flex; \n flex-direction: column;\n justify-content: center;\n gap: 8px;\n }\n\n .content h4 {\n margin: 0px;\n font-size: var(--nile-type-scale-3);\n font-weight: var(--nile-font-weight-regular);\n color: var(--nile-colors-dark-900);\n text-align: center;\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n width: 454px;\n }\n \n .content p {\n margin: 0px;\n font-size: var(--nile-type-scale-2);\n color: var(--nile-colors-neutral-700);\n text-align: center;\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n width: 454px;\n }\n\n ::slotted(img), ::slotted(nile-icon), ::slotted(video) {\n --nile-svg-height: 24px !important ;\n --nile-svg-width: 24px !important ;\n height:42px;\n width: 42px;\n object-fit: cover;\n }\n\n .browse-file-button {\n cursor: pointer;\n }\n\n /* DISABLED STATE */\n .disable {\n background-color: var(--nile-colors-dark-200);\n opacity: 0.8;\n cursor: not-allowed;\n color: var(--nile-colors-neutral-500);\n pointer-events: none;\n }\n\n /* DRAGGING */\n .dragging {\n background-color: var(--nile-colors-blue-100);\n border-color: var(--nile-colors-primary-600);\n display: flex;\n align-items: center;\n justify-content: flex-start;\n gap: 18px;\n color: var(--nile-colors-blue-700);\n font-size: var(--nile-type-scale-3);\n font-weight: var(--nile-font-weight-regular);\n }\n\n .icons-container {\n display: flex;\n gap: 4px;\n }\n\n .general-icon {\n transform: rotate(-18.11deg);\n position: relative;\n bottom: 3px;\n }\n\n .image-icon {\n transform: rotate(15deg);\n }\n\n .icon:hover {\n cursor: pointer;\n }\n\n /* Uploading State */\n .uploading {\n width: 648px;\n min-width: 230px;\n display: flex;\n justify-content: space-between;\n align-items: center;\n gap: 18px;\n box-sizing: border-box;\n border: 1px solid var(--nile-colors-neutral-400)\n }\n \n .uploading:hover {\n border-color: var(--nile-colors-neutral-400);\n }\n\n .progress-bar-container {\n width: 100%;\n display: flex;\n flex-direction: column;\n gap: 0px;\n }\n\n .progress-bar-percent {\n width: 100%;\n display: flex;\n justify-content: space-between;\n font-size: var(--nile-type-scale-2);\n font-weight: var(--nile-font-weight-regular);\n }\n\n .progress-bar-container p {\n margin: 0px;\n }\n\n .progress-bar-container > p {\n font-size: var(--nile-type-scale-1);\n color: var(--nile-colors-dark-500);\n }\n\n /* PREVIEW STATE */\n .preview {\n border: 1px solid var(--nile-colors-neutral-400);\n }\n\n .preview:hover {\n border-color: var(--nile-colors-neutral-400);\n }\n\n .preview-inner {\n display: flex;\n gap: 18px;\n }\n\n .preview-image-container {\n height: 42px;\n width: 42px;\n }\n\n .preview-image-container img {\n height: 42px;\n width: 42px;\n object-fit: contain;\n border-radius: var(--nile-radius-radius-xs);\n border: 1px solid var(--nile-colors-neutral-400);\n }\n \n .preview-file-info {\n width: 100%;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: flex-start;\n gap: 8px;\n }\n\n .preview-file-info p {\n margin: 0px;\n font-size: var(--nile-type-scale-3);\n font-weight: var(--nile-font-weight-regular);\n }\n\n .preview-file-info p:last-of-type{\n color: var(--nile-colors-neutral-700);\n font-size: var(--nile-type-scale-2);\n font-weight: var(--nile-font-weight-regular);\n }\n\n .preview nile-icon:hover {\n cursor: pointer;\n }\n\n\n /* NO PREVIEW STATE */\n .no-preview {\n border: 1px solid var(--nile-colors-neutral-400);\n }\n\n .no-preview:hover {\n border-color: var(--nile-colors-neutral-400);\n }\n\n .no-preview-container {\n display: flex;\n gap: 18px;\n }\n\n .document-icon {\n height: 40px;\n width: 40px;\n border-radius: var(--nile-radius-radius-xs);\n padding: 2px 3px 2px 3px;\n display: flex;\n justify-content: center;\n align-items: center;\n border: 1px solid var(--nile-colors-blue-400);\n background-color: var(--nile-colors-blue-100);\n }\n\n .document-icon nile-icon {\n height: 40px;\n width: 40px;\n }\n \n .preview-file-info {\n width: 100%;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: flex-start;\n gap: 8px;\n }\n\n .preview-file-info p {\n margin: 0px;\n font-size: var(--nile-type-scale-3);\n font-weight: var(--nile-font-weight-regular);\n }\n\n .preview-file-info p:last-of-type{\n color: var(--nile-colors-neutral-700);\n font-size: var(--nile-type-scale-2);\n font-weight: var(--nile-font-weight-regular);\n }\n\n .no-preview > nile-icon:hover {\n cursor: pointer;\n }\n\n /* ERROR STATE */\n \n .error {\n border: 1px solid var(--nile-colors-neutral-400);\n }\n\n .error:hover {\n border-color: var(--nile-colors-neutral-400);\n }\n\n .error-container {\n width: 100%;\n display: flex;\n gap: 18px;\n }\n\n .error-icon {\n height: 40px;\n width: 40px;\n border-radius: var(--nile-radius-radius-xs);\n padding: 2px 3px 2px 3px;\n display: flex;\n justify-content: center;\n align-items: center;\n border: 1px solid var(--nile-colors-red-400);\n background-color: var(--nile-colors-red-100);\n }\n\n .error-icon nile-icon {\n height: 40px;\n width: 40px;\n }\n \n .file-info {\n width: 100%;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: flex-start;\n gap: 8px;\n }\n\n .file-info p {\n margin: 0px;\n font-size: var(--nile-type-scale-3);\n font-weight: var(--nile-font-weight-regular);\n }\n\n .file-info p:last-of-type{\n color: var(--nile-colors-red-700);\n font-size: var(--nile-type-scale-2);\n font-weight: var(--nile-font-weight-regular);\n }\n\n .error > nile-icon:hover {\n cursor: pointer;\n }\n\n /* VARTICAL STATE START */\n /* Default State */\n\n .vertical-default {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 18px\n }\n\n .content-container {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n gap: 8px;\n }\n\n .content-container div.title {\n font-size: var(--nile-type-scale-3);\n font-weight: var(--nile-font-weight-regular);\n color: var(--nile-colors-dark-900);\n text-align: center;\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n width: 222px;\n }\n\n .content-container div.subtitle {\n font-size: var(--nile-type-scale-2);\n font-weight: var(--nile-font-weight-regular);\n color: var(--nile-colors-dark-500);\n text-align: center;\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n width: 222px;\n }\n\n /* Drag State */\n .vertical-drag {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n gap:18px;\n font-size: var(--nile-type-scale-3);\n color: var(--nile-colors-blue-700);\n background-color: var(--nile-colors-blue-100);\n border-color: var(--nile-colors-blue-500);\n }\n\n /* Uploading State */\n .vertical-uploading {\n display: flex;\n flex-direction: column;\n justify-content: flex-end;\n align-items: center;\n border: 1px solid var(--nile-colors-neutral-400);\n }\n\n .vertical-uploading:hover {\n border-color: var(--nile-colors-neutral-400);\n }\n\n .loading {\n display: flex;\n justify-content: center;\n align-items: center;\n }\n\n .corner-icon {\n position: absolute;\n top: 10px;\n right: 10px;\n }\n\n /* Preview State */\n .vertical-preview {\n border: 1px solid var(--nile-colors-neutral-400);\n }\n\n .vertical-preview:hover {\n border-color: var(--nile-colors-neutral-400);\n }\n\n .image-preview {\n border: 1px solid var(--nile-colors-neutral-400);\n object-fit: cover;\n width: 80px;\n height: 80px;\n border-radius: var(--nile-radius-radius-xs);\n }\n\n /* Vertical No Preview State */\n .vertical-no-preview {\n border: 1px solid var(--nile-colors-neutral-400);\n }\n\n .vertical-no-preview:hover {\n border-color: var(--nile-colors-neutral-400);\n }\n\n .vertical-document-icon {\n height: 80px;\n width: 80px;\n padding: 2px 3px 2px 3px;\n display: flex;\n justify-content: center;\n align-items: center;\n border-radius: var(--nile-radius-radius-xs);\n border: 1px solid var(--nile-colors-blue-400);\n background-color: var(--nile-colors-blue-100);\n }\n\n /* Veritcal Error State */\n .vertical-error {\n border: 1px solid var(--nile-colors-neutral-400);\n }\n\n .vertical-error:hover {\n border-color: var(--nile-colors-neutral-400);\n }\n\n .error-bg {\n background-color: var(--nile-colors-red-100);\n border: 1px solid var(--nile-colors-red-400);\n }\n\n .error-message {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n gap: 8px;\n margin: 0px;\n font-size: var(--nile-type-scale-3);\n font-weight: var(--nile-font-weight-regular);\n text-align: start;\n }\n\n .error-p {\n color: var(--nile-colors-red-700);\n font-size: var(--nile-type-scale-2);\n width: 216px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n text-align: center;\n }\n\n .error-p p {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n margin: 0;\n }\n\n\n /* Displaing uploaded files CSS */\n .display-files {\n display: flex;\n flex-direction: column;\n justify-content: flex-start;\n align-items: center;\n gap: 8px;\n width: 648px;\n min-width: 230px;\n max-height: 200px;\n overflow-y: auto;\n border: 1px solid var(--nile-colors-neutral-700);\n border-radius: var(--nile-radius-radius-xs);\n scrollbar-width: none;\n padding: 12px;\n }\n\n ul, li {\n width: 100%;\n }\n\n li {\n list-style-type: none;\n }\n\n /* for the upload error messages */\n .upload-error {\n font-size: var(--nile-type-scale-2);\n font-weight: var(--nile-font-weight-regular);\n color: var(--nile-colors-red-700);\n display: flex;\n justify-content: flex-start;\n align-items: center;\n gap: var(--nile-spacing-one-half-x);\n }\n\n .upload-error > nile-tooltip > span {\n color: var(--nile-colors-red-700);\n white-space: nowrap;\n text-align: left;\n max-width: 560px;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n\n .vertical-upload-error {\n display: flex;\n gap: 4px;\n }\n\n .vertical-upload-error > nile-tooltip > span {\n color: var(--nile-colors-red-700);\n white-space: nowrap;\n text-align: left;\n width: 222px;\n overflow: hidden;\n text-overflow: ellipsis;\n font-size: var(--nile-type-scale-2);\n display: inline-block;\n }\n`;\n\nexport default [styles];"]}
@@ -36,6 +36,7 @@ export declare class NileFileUpload extends NileElement {
36
36
  input: HTMLInputElement;
37
37
  uploadRequests: Map<File, XMLHttpRequest>;
38
38
  fileSizeExceededFilesNumber: number;
39
+ isStringTruncated: boolean;
39
40
  private dragHandler;
40
41
  connectedCallback(): void;
41
42
  firstUpdated(changedProps: ChangedPropsInterface): void;
@@ -39,6 +39,7 @@ let NileFileUpload = class NileFileUpload extends NileElement {
39
39
  this.autoUpload = true;
40
40
  this.uploadRequests = new Map();
41
41
  this.fileSizeExceededFilesNumber = 0;
42
+ this.isStringTruncated = false;
42
43
  this.setState = (newState) => {
43
44
  this.state = newState;
44
45
  };
@@ -100,25 +101,25 @@ let NileFileUpload = class NileFileUpload extends NileElement {
100
101
  getHorizontalState() {
101
102
  switch (this.state) {
102
103
  case FileUploadState.DEFAULT:
103
- return getHorizontalDefaultState(this.browseFiles, this.title, this.subtitle, this.dragHandler, this.state, this.errorMessage, this.allowedTypes);
104
+ return getHorizontalDefaultState(this.browseFiles, this.title, this.subtitle, this.dragHandler, this.state, this.errorMessage, this.allowedTypes, this);
104
105
  case FileUploadState.DISABLED:
105
- return getHorizontalDisabledState(this.browseFiles, this.title, this.subtitle, this.dragHandler, this.state, this.errorMessage, this.allowedTypes);
106
+ return getHorizontalDisabledState(this.browseFiles, this.title, this.subtitle, this.dragHandler, this.state, this.errorMessage, this.allowedTypes, this);
106
107
  case FileUploadState.DRAG:
107
108
  return getHorizontalDragState();
108
109
  default:
109
- return getHorizontalDefaultState(this.browseFiles, this.title, this.subtitle, this.dragHandler, this.state, this.errorMessage, this.allowedTypes);
110
+ return getHorizontalDefaultState(this.browseFiles, this.title, this.subtitle, this.dragHandler, this.state, this.errorMessage, this.allowedTypes, this);
110
111
  }
111
112
  }
112
113
  getVerticalState() {
113
114
  switch (this.state) {
114
115
  case FileUploadState.DEFAULT:
115
- return getVerticalDefaultState(this.browseFiles, this.title, this.subtitle, this.dragHandler, this.errorMessage, this.allowedTypes);
116
+ return getVerticalDefaultState(this.browseFiles, this.title, this.subtitle, this.dragHandler, this.errorMessage, this.allowedTypes, this);
116
117
  case FileUploadState.DISABLED:
117
- return getVerticalDisabledState(this.browseFiles, this.title, this.subtitle, this.dragHandler, this.errorMessage, this.allowedTypes);
118
+ return getVerticalDisabledState(this.browseFiles, this.title, this.subtitle, this.dragHandler, this.errorMessage, this.allowedTypes, this);
118
119
  case FileUploadState.DRAG:
119
120
  return getVerticalDragState();
120
121
  default:
121
- return getVerticalDefaultState(this.browseFiles, this.title, this.subtitle, this.dragHandler, this.errorMessage, this.allowedTypes);
122
+ return getVerticalDefaultState(this.browseFiles, this.title, this.subtitle, this.dragHandler, this.errorMessage, this.allowedTypes, this);
122
123
  }
123
124
  }
124
125
  disconnectedCallback() {
@@ -1 +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,0BAA0B,EAAE,MAAM,6BAA6B,CAAA;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAc,IAAI,EAAkC,MAAM,KAAK,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAS,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAmB,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjH,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,WAAW,EAAoB,MAAM,8BAA8B,CAAC;AACzI,OAAO,EACL,yBAAyB,EACzB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AAErC;;;;;GAKG;AAEI,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,WAAW;IAAxC;;QASuB,SAAI,GAAW,MAAM,CAAC;QACtB,UAAK,GAAY,KAAK,CAAC;QACvB,iBAAY,GAAW,EAAE,CAAC;QAC1B,kBAAa,GAAY,KAAK,CAAC;QAC/B,oBAAe,GAAY,KAAK,CAAC;QACjC,iBAAY,GAAa,EAAE,CAAC;QAC5B,kBAAa,GAAW,EAAE,CAAC;QAC3B,UAAK,GAAW,kBAAkB,CAAC,KAAK,CAAC;QACzC,aAAQ,GAAW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B,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CA2H1B","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 { getHorizontalDisabledState } 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, uploadFiles, cancelFileUpload } from './utils/file-validation.util';\nimport {\n getHorizontalDefaultState,\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: String }) size: string = \"10MB\";\n @property({ type: Boolean}) error: boolean = false;\n @property({ type: String }) errorMessage: string = \"\";\n @property({ type: Boolean}) allowMultiple: boolean = false;\n @property({ type: Boolean}) allowDuplicates: boolean = false;\n @property({ type: Array }) allowedTypes: string[] = [];\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 @property({ type: String }) fileUploadUrl: string = \"\";\n @property({ type: Boolean}) autoUpload: boolean = true;\n @query('input') input!: HTMLInputElement;\n public uploadRequests = new Map<File, XMLHttpRequest>();\n public fileSizeExceededFilesNumber: number = 0;\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 setUpDragHandler(this, this.dragHandler);\n addInternalListeners(this, this.dragHandler, this.uploadRequests);\n addGlobalListeners(this.dragHandler);\n }\n\n updated(changedProps: ChangedPropsInterface): void {\n super.updated(changedProps);\n\n if (changedProps.has('uploadedFiles')) {\n // if(this.uploadedFiles.length === 0) {\n // this.errorMessage = \"\";\n // }\n\n if(this.fileUploadUrl && this.autoUpload) {\n uploadFiles(this);\n }\n this.emit(FileUploadEvent.NILE_CHANGE, { files: this.uploadedFiles });\n } else if (changedProps.has('state')) {\n this.dragHandler.setValuesInDragHandler(this.state);\n }\n\n if(changedProps.has('autoUpload') && this.autoUpload) {\n if(this.fileUploadUrl && this.autoUpload) {\n uploadFiles(this);\n }\n this.emit(FileUploadEvent.NILE_CHANGE, { files: this.uploadedFiles });\n }\n }\n\n private browseFiles(): void {\n this.emit(FileUploadEvent.NILE_BROWSE);\n this.errorMessage = \"\";\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.dragHandler, this.state, this.errorMessage, this.allowedTypes);\n\n case FileUploadState.DISABLED:\n return getHorizontalDisabledState(this.browseFiles, this.title, this.subtitle, this.dragHandler, this.state, this.errorMessage, this.allowedTypes);\n\n case FileUploadState.DRAG:\n return getHorizontalDragState();\n\n default:\n return getHorizontalDefaultState(this.browseFiles, this.title, this.subtitle, this.dragHandler, this.state, this.errorMessage, this.allowedTypes);\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.dragHandler, this.errorMessage, this.allowedTypes);\n\n case FileUploadState.DISABLED:\n return getVerticalDisabledState(this.browseFiles, this.title, this.subtitle, this.dragHandler, this.errorMessage, this.allowedTypes);\n\n case FileUploadState.DRAG:\n return getVerticalDragState();\n\n default:\n return getVerticalDefaultState(this.browseFiles, this.title, this.subtitle, this.dragHandler, this.errorMessage, this.allowedTypes);\n }\n }\n\n disconnectedCallback(): void {\n this.emit(FileUploadEvent.NILE_DESTROY);\n }\n}\n"]}
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,0BAA0B,EAAE,MAAM,6BAA6B,CAAA;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAc,IAAI,EAAkC,MAAM,KAAK,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAS,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAmB,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjH,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,WAAW,EAAoB,MAAM,8BAA8B,CAAC;AACzI,OAAO,EACL,yBAAyB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B;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;AAC1D;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qDAA4B;AAC3B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAC,CAAC;kDAA4B;AACvC;IAAf,KAAK,CAAC,OAAO,CAAC;6CAA0B;AAtB9B,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CA4H1B","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 { getHorizontalDisabledState } 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, uploadFiles, cancelFileUpload } from './utils/file-validation.util';\nimport {\n getHorizontalDefaultState,\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: String }) size: string = \"10MB\";\n @property({ type: Boolean}) error: boolean = false;\n @property({ type: String }) errorMessage: string = \"\";\n @property({ type: Boolean}) allowMultiple: boolean = false;\n @property({ type: Boolean}) allowDuplicates: boolean = false;\n @property({ type: Array }) allowedTypes: string[] = [];\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 @property({ type: String }) fileUploadUrl: string = \"\";\n @property({ type: Boolean}) autoUpload: boolean = true;\n @query('input') input!: HTMLInputElement;\n public uploadRequests = new Map<File, XMLHttpRequest>();\n public fileSizeExceededFilesNumber: number = 0;\n public isStringTruncated: boolean = false;\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 setUpDragHandler(this, this.dragHandler);\n addInternalListeners(this, this.dragHandler, this.uploadRequests);\n addGlobalListeners(this.dragHandler);\n }\n\n updated(changedProps: ChangedPropsInterface): void {\n super.updated(changedProps);\n\n if (changedProps.has('uploadedFiles')) {\n // if(this.uploadedFiles.length === 0) {\n // this.errorMessage = \"\";\n // }\n\n if(this.fileUploadUrl && this.autoUpload) {\n uploadFiles(this);\n }\n this.emit(FileUploadEvent.NILE_CHANGE, { files: this.uploadedFiles });\n } else if (changedProps.has('state')) {\n this.dragHandler.setValuesInDragHandler(this.state);\n }\n\n if(changedProps.has('autoUpload') && this.autoUpload) {\n if(this.fileUploadUrl && this.autoUpload) {\n uploadFiles(this);\n }\n this.emit(FileUploadEvent.NILE_CHANGE, { files: this.uploadedFiles });\n }\n }\n\n private browseFiles(): void {\n this.emit(FileUploadEvent.NILE_BROWSE);\n this.errorMessage = \"\";\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.dragHandler, this.state, this.errorMessage, this.allowedTypes, this);\n\n case FileUploadState.DISABLED:\n return getHorizontalDisabledState(this.browseFiles, this.title, this.subtitle, this.dragHandler, this.state, this.errorMessage, this.allowedTypes, this);\n\n case FileUploadState.DRAG:\n return getHorizontalDragState();\n\n default:\n return getHorizontalDefaultState(this.browseFiles, this.title, this.subtitle, this.dragHandler, this.state, this.errorMessage, this.allowedTypes, this);\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.dragHandler, this.errorMessage, this.allowedTypes, this);\n\n case FileUploadState.DISABLED:\n return getVerticalDisabledState(this.browseFiles, this.title, this.subtitle, this.dragHandler, this.errorMessage, this.allowedTypes, this);\n\n case FileUploadState.DRAG:\n return getVerticalDragState();\n\n default:\n return getVerticalDefaultState(this.browseFiles, this.title, this.subtitle, this.dragHandler, this.errorMessage, this.allowedTypes, this);\n }\n }\n\n disconnectedCallback(): void {\n this.emit(FileUploadEvent.NILE_DESTROY);\n }\n}\n"]}
@@ -2,9 +2,10 @@ import { TemplateResult } from 'lit';
2
2
  import './nile-file-upload.css';
3
3
  import { DragHandler } from './utils/drag-drop.util';
4
4
  import { FileUploadState } from './types/file-upload.enums';
5
- export declare const getHorizontalDefaultState: (browseFiles: Function, title: string, subtitle: string, dragHandler: DragHandler, state: FileUploadState, errorMessage: string, allowedTypes: string[]) => TemplateResult;
6
- export declare const getHorizontalDisabledState: (browseFiles: Function, title: string, subtitle: string, dragHandler: DragHandler, state: FileUploadState, errorMessage: string, allowedTypes: string[]) => TemplateResult;
5
+ import { NileFileUpload } from './nile-file-upload';
6
+ export declare const getHorizontalDefaultState: (browseFiles: Function, title: string, subtitle: string, dragHandler: DragHandler, state: FileUploadState, errorMessage: string, allowedTypes: string[], nileFileUpload: NileFileUpload) => TemplateResult;
7
+ export declare const getHorizontalDisabledState: (browseFiles: Function, title: string, subtitle: string, dragHandler: DragHandler, state: FileUploadState, errorMessage: string, allowedTypes: string[], nileFileUpload: NileFileUpload) => TemplateResult;
7
8
  export declare const getHorizontalDragState: () => TemplateResult;
8
- export declare const getVerticalDefaultState: (browseFiles: Function, title: string, subtitle: string, dragHandler: DragHandler, errorMessage: string, allowedTypes: string[]) => TemplateResult;
9
- export declare const getVerticalDisabledState: (browseFiles: Function, title: string, subtitle: string, dragHandler: DragHandler, errorMessage: string, allowedTypes: string[]) => TemplateResult;
9
+ export declare const getVerticalDefaultState: (browseFiles: Function, title: string, subtitle: string, dragHandler: DragHandler, errorMessage: string, allowedTypes: string[], nileFileUpload: NileFileUpload) => TemplateResult;
10
+ export declare const getVerticalDisabledState: (browseFiles: Function, title: string, subtitle: string, dragHandler: DragHandler, errorMessage: string, allowedTypes: string[], nileFileUpload: NileFileUpload) => TemplateResult;
10
11
  export declare const getVerticalDragState: () => TemplateResult;
@@ -2,7 +2,10 @@ import { html } from 'lit';
2
2
  import './nile-file-upload.css';
3
3
  import { classMap } from 'lit-html/directives/class-map.js';
4
4
  import { FileUploadDefaults } from './types/file-upload.enums';
5
- const baseHorizontalState = (browseFiles, title, subtitle, disabled, dragHandler, state, errorMessage, allowedTypes) => html `
5
+ import { truncateString } from './utils/file-validation.util';
6
+ const baseHorizontalState = (browseFiles, title, subtitle, disabled, dragHandler, state, errorMessage, allowedTypes, nileFileUpload) => {
7
+ truncateString(nileFileUpload);
8
+ return html `
6
9
  <div class="wrapper" part="horizontal-wrapper">
7
10
  <div part="horizontal-div" class=${classMap({ 'hover-border': state === "hover", 'horizontal-div': true, 'disable': disabled })}>
8
11
  <div part="inner-div" class="inner-div">
@@ -28,17 +31,20 @@ const baseHorizontalState = (browseFiles, title, subtitle, disabled, dragHandler
28
31
  </slot>
29
32
  </div>
30
33
  ${errorMessage ?
31
- html `<div class="upload-error">
34
+ html `<div class="upload-error">
32
35
  <nile-icon name="warning" size="12" color="var(--nile-colors-red-700)"></nile-icon>
33
- <nile-tooltip content=${errorMessage}>
34
- <span>${errorMessage}</span>
35
- </nile-tooltip>
36
+ ${nileFileUpload.isStringTruncated
37
+ ? html `<nile-tooltip content=${errorMessage}>
38
+ <span>${errorMessage}</span>
39
+ </nile-tooltip>`
40
+ : html `<span>${errorMessage}</span>`}
36
41
  </div>` :
37
- html ``}
42
+ html ``}
38
43
  </div>
39
- `;
40
- export const getHorizontalDefaultState = (browseFiles, title, subtitle, dragHandler, state, errorMessage, allowedTypes) => baseHorizontalState(browseFiles, title, subtitle, false, dragHandler, state, errorMessage, allowedTypes);
41
- export const getHorizontalDisabledState = (browseFiles, title, subtitle, dragHandler, state, errorMessage, allowedTypes) => baseHorizontalState(browseFiles, title, subtitle, true, dragHandler, state, errorMessage, allowedTypes);
44
+ `;
45
+ };
46
+ export const getHorizontalDefaultState = (browseFiles, title, subtitle, dragHandler, state, errorMessage, allowedTypes, nileFileUpload) => baseHorizontalState(browseFiles, title, subtitle, false, dragHandler, state, errorMessage, allowedTypes, nileFileUpload);
47
+ export const getHorizontalDisabledState = (browseFiles, title, subtitle, dragHandler, state, errorMessage, allowedTypes, nileFileUpload) => baseHorizontalState(browseFiles, title, subtitle, true, dragHandler, state, errorMessage, allowedTypes, nileFileUpload);
42
48
  export const getHorizontalDragState = () => html `
43
49
  <div part="horizontal-drag-state" class="horizontal-div dragging">
44
50
  <div class="icons-container">
@@ -59,7 +65,9 @@ export const getHorizontalDragState = () => html `
59
65
  </div>
60
66
  `;
61
67
  // Vertical States
62
- const baseVerticalState = (browseFiles, title, subtitle, disabled, dragHandler, errorMessage, allowedTypes) => html `
68
+ const baseVerticalState = (browseFiles, title, subtitle, disabled, dragHandler, errorMessage, allowedTypes, nileFileUpload) => {
69
+ truncateString(nileFileUpload);
70
+ return html `
63
71
  <div part="vertical-wrapper" class="wrapper">
64
72
  <div part="vertical-default" class="vertical-default vertical-div ${disabled ? 'disable' : ''}">
65
73
  <slot name="upload-icon">
@@ -83,17 +91,18 @@ const baseVerticalState = (browseFiles, title, subtitle, disabled, dragHandler,
83
91
  </slot>
84
92
  </div>
85
93
  ${errorMessage ?
86
- html `<div class="vertical-upload-error">
94
+ html `<div class="vertical-upload-error">
87
95
  <nile-icon name="warning" size="12" color="var(--nile-colors-red-700)"></nile-icon>
88
96
  <nile-tooltip content=${errorMessage}>
89
97
  <span>${errorMessage}</span>
90
98
  </nile-tooltip>
91
99
  </div>` :
92
- html ``}
100
+ html ``}
93
101
  </div>
94
- `;
95
- export const getVerticalDefaultState = (browseFiles, title, subtitle, dragHandler, errorMessage, allowedTypes) => baseVerticalState(browseFiles, title, subtitle, false, dragHandler, errorMessage, allowedTypes);
96
- export const getVerticalDisabledState = (browseFiles, title, subtitle, dragHandler, errorMessage, allowedTypes) => baseVerticalState(browseFiles, title, subtitle, true, dragHandler, errorMessage, allowedTypes);
102
+ `;
103
+ };
104
+ export const getVerticalDefaultState = (browseFiles, title, subtitle, dragHandler, errorMessage, allowedTypes, nileFileUpload) => baseVerticalState(browseFiles, title, subtitle, false, dragHandler, errorMessage, allowedTypes, nileFileUpload);
105
+ export const getVerticalDisabledState = (browseFiles, title, subtitle, dragHandler, errorMessage, allowedTypes, nileFileUpload) => baseVerticalState(browseFiles, title, subtitle, true, dragHandler, errorMessage, allowedTypes, nileFileUpload);
97
106
  export const getVerticalDragState = () => html `
98
107
  <div part="vertical-drag-state" class="vertical-div vertical-drag">
99
108
  <div class="icons-container">
@@ -1 +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;AAC5D,OAAO,EAAE,kBAAkB,EAAmB,MAAM,2BAA2B,CAAC;AAEhF,MAAM,mBAAmB,GAAG,CAC1B,WAAqB,EACrB,KAAa,EACb,QAAgB,EAChB,QAAiB,EACjB,WAAwB,EACxB,KAAsB,EACtB,YAAoB,EACpB,YAAsB,EACN,EAAE,CAAC,IAAI,CAAA;;uCAEc,QAAQ,CAAC,EAAE,cAAc,EAAE,KAAK,KAAK,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;;;;;;+BAMpG,KAAK;kCACF,QAAQ;;;;;oBAKtB,QAAQ;kBACV,CAAC,CAAoB,EAAE,EAAE,GAAG,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC,CAAA,CAAC,CAAC;;iBAEzD,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC;;gDAES,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW;oDAC9B,QAAQ;;;;;MAKtD,YAAY,CAAC,CAAC;IACd,IAAI,CAAA;;gCAEsB,YAAY;kBAC1B,YAAY;;aAEjB,CAAC,CAAC;IACT,IAAI,CAAA,EACN;;CAEH,CAAC;AAEF,MAAM,CAAC,MAAM,yBAAyB,GAAG,CACvC,WAAqB,EACrB,KAAa,EACb,QAAgB,EAChB,WAAwB,EACxB,KAAsB,EACtB,YAAoB,EACpB,YAAsB,EACN,EAAE,CAAC,mBAAmB,CAAC,WAAW,EAA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AAiB,CAAC,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;AAErH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,WAAqB,EACrB,KAAa,EACb,QAAgB,EAChB,WAAwB,EACxB,YAAoB,EACpB,YAAsB,EACN,EAAE,CAAC,iBAAiB,CAAC,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;AAGpH,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAmB,EAAE,CAAC,IAAI,CAAA;;;;;;;;;;;;;;;;SAgBrD,kBAAkB,CAAC,kBAAkB;;CAE7C,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 { FileUploadDefaults, FileUploadState } from './types/file-upload.enums';\n\nconst baseHorizontalState = (\n browseFiles: Function,\n title: string,\n subtitle: string,\n disabled: boolean,\n dragHandler: DragHandler,\n state: FileUploadState,\n errorMessage: string,\n allowedTypes: string[]\n): TemplateResult => html`\n <div class=\"wrapper\" part=\"horizontal-wrapper\">\n <div part=\"horizontal-div\" class=${classMap({ 'hover-border': state === \"hover\", 'horizontal-div': true, 'disable': disabled })}>\n <div part=\"inner-div\" class=\"inner-div\">\n <slot class=\"upload-icon-slot\" name=\"upload-icon\">\n <nile-icon name=\"upload\" size=\"24\"></nile-icon>\n </slot>\n <div part=\"content\" class=\"content\">\n <div class=\"title\">${title}</div>\n <div class=\"subtitle\">${subtitle}</div>\n </div>\n </div>\n <input\n type=\"file\"\n ?disabled=${disabled}\n @change=${(e: Event | DragEvent) => { dragHandler.handleFiles(e) }}\n multiple\n accept=${allowedTypes.join(',')}\n />\n <slot class=\"browse-file-button\" @click=${disabled ? undefined : browseFiles} name=\"browse-file-button\">\n <nile-button variant=\"tertiary\" ?disabled=${disabled}>\n Browse File\n </nile-button>\n </slot>\n </div>\n ${errorMessage ?\n html`<div class=\"upload-error\">\n <nile-icon name=\"warning\" size=\"12\" color=\"var(--nile-colors-red-700)\"></nile-icon>\n <nile-tooltip content=${errorMessage}>\n <span>${errorMessage}</span>\n </nile-tooltip>\n </div>` :\n html``\n }\n </div>\n`;\n\nexport const getHorizontalDefaultState = (\n browseFiles: Function,\n title: string,\n subtitle: string,\n dragHandler: DragHandler,\n state: FileUploadState,\n errorMessage: string,\n allowedTypes: string[]\n): TemplateResult => baseHorizontalState(browseFiles, title, subtitle, false, dragHandler, state, errorMessage, allowedTypes);\n\nexport const getHorizontalDisabledState = (\n browseFiles: Function,\n title: string,\n subtitle: string,\n dragHandler: DragHandler,\n state: FileUploadState,\n errorMessage: string,\n allowedTypes: string[]\n): TemplateResult => baseHorizontalState(browseFiles, title, subtitle, true, dragHandler, state, errorMessage, allowedTypes);\n\nexport const getHorizontalDragState = (): TemplateResult => html`\n <div part=\"horizontal-drag-state\" 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>${FileUploadDefaults.DRAG_STATE_DEFAULT}</p>\n </div>\n`;\n\n// Vertical States\nconst baseVerticalState = (\n browseFiles: Function,\n title: string,\n subtitle: string,\n disabled: boolean,\n dragHandler: DragHandler,\n errorMessage: string,\n allowedTypes: string[]\n): TemplateResult => html`\n <div part=\"vertical-wrapper\" class=\"wrapper\">\n <div part=\"vertical-default\" class=\"vertical-default vertical-div ${disabled ? 'disable' : ''}\">\n <slot name=\"upload-icon\">\n <nile-icon name=\"upload\" size=\"24\"></nile-icon>\n </slot>\n <div part=\"vertical-content-container\" class=\"content-container\">\n <div class=\"title\">${title}</div>\n <div class=\"subtitle\">${subtitle}</div>\n </div>\n <input\n type=\"file\"\n ?disabled=${disabled}\n @change=${(e: Event | DragEvent) => dragHandler.handleFiles(e)}\n multiple\n accept=${allowedTypes.join(',')}\n />\n <slot @click=${disabled ? undefined : browseFiles} name=\"browse-file-button\">\n <nile-button variant=\"tertiary\" ?disabled=${disabled}>\n Browse File\n </nile-button>\n </slot>\n </div>\n ${errorMessage ?\n html`<div class=\"vertical-upload-error\">\n <nile-icon name=\"warning\" size=\"12\" color=\"var(--nile-colors-red-700)\"></nile-icon>\n <nile-tooltip content=${errorMessage}>\n <span>${errorMessage}</span>\n </nile-tooltip>\n </div>` :\n html``\n }\n </div>\n`;\n\nexport const getVerticalDefaultState = (\n browseFiles: Function,\n title: string,\n subtitle: string,\n dragHandler: DragHandler,\n errorMessage: string,\n allowedTypes: string[]\n): TemplateResult => baseVerticalState(browseFiles, title, subtitle, false, dragHandler, errorMessage, allowedTypes);\n\nexport const getVerticalDisabledState = (\n browseFiles: Function,\n title: string,\n subtitle: string,\n dragHandler: DragHandler,\n errorMessage: string,\n allowedTypes: string[]\n): TemplateResult => baseVerticalState(browseFiles, title, subtitle, true, dragHandler, errorMessage, allowedTypes);\n\n\nexport const getVerticalDragState = (): TemplateResult => html`\n <div part=\"vertical-drag-state\" 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>${FileUploadDefaults.DRAG_STATE_DEFAULT}</p>\n </div>\n`;"]}
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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GAAG,CACrC,WAAqB,EACrB,KAAa,EACb,QAAgB,EAChB,WAAwB,EACxB,YAAoB,EACpB,YAAsB,EACtB,cAA8B,EACd,EAAE,CAAC,iBAAiB,CAAC,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,cAAc,CAAC,CAAC;AAErI,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,WAAqB,EACrB,KAAa,EACb,QAAgB,EAChB,WAAwB,EACxB,YAAoB,EACpB,YAAsB,EACtB,cAA8B,EACd,EAAE,CAAC,iBAAiB,CAAC,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,cAAc,CAAC,CAAC;AAGpI,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAmB,EAAE,CAAC,IAAI,CAAA;;;;;;;;;;;;;;;;SAgBrD,kBAAkB,CAAC,kBAAkB;;CAE7C,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 { FileUploadDefaults, FileUploadState } from './types/file-upload.enums';\nimport { truncateString } from './utils/file-validation.util';\nimport { NileFileUpload } from './nile-file-upload';\n\nconst baseHorizontalState = (\n browseFiles: Function,\n title: string,\n subtitle: string,\n disabled: boolean,\n dragHandler: DragHandler,\n state: FileUploadState,\n errorMessage: string,\n allowedTypes: string[],\n nileFileUpload: NileFileUpload\n): TemplateResult => {\n truncateString(nileFileUpload);\n return html`\n <div class=\"wrapper\" part=\"horizontal-wrapper\">\n <div part=\"horizontal-div\" class=${classMap({ 'hover-border': state === \"hover\", 'horizontal-div': true, 'disable': disabled })}>\n <div part=\"inner-div\" class=\"inner-div\">\n <slot class=\"upload-icon-slot\" name=\"upload-icon\">\n <nile-icon name=\"upload\" size=\"24\"></nile-icon>\n </slot>\n <div part=\"content\" class=\"content\">\n <div class=\"title\">${title}</div>\n <div class=\"subtitle\">${subtitle}</div>\n </div>\n </div>\n <input\n type=\"file\"\n ?disabled=${disabled}\n @change=${(e: Event | DragEvent) => { dragHandler.handleFiles(e) }}\n multiple\n accept=${allowedTypes.join(',')}\n />\n <slot class=\"browse-file-button\" @click=${disabled ? undefined : browseFiles} name=\"browse-file-button\">\n <nile-button variant=\"tertiary\" ?disabled=${disabled}>\n Browse File\n </nile-button>\n </slot>\n </div>\n ${errorMessage ?\n html`<div class=\"upload-error\">\n <nile-icon name=\"warning\" size=\"12\" color=\"var(--nile-colors-red-700)\"></nile-icon>\n ${\n nileFileUpload.isStringTruncated\n ? html`<nile-tooltip content=${errorMessage}>\n <span>${errorMessage}</span>\n </nile-tooltip>`\n : html`<span>${errorMessage}</span>`\n }\n </div>` :\n html``\n }\n </div>\n `;\n}\n\nexport const getHorizontalDefaultState = (\n browseFiles: Function,\n title: string,\n subtitle: string,\n dragHandler: DragHandler,\n state: FileUploadState,\n errorMessage: string,\n allowedTypes: string[],\n nileFileUpload: NileFileUpload\n): TemplateResult => baseHorizontalState(browseFiles, title, subtitle, false, dragHandler, state, errorMessage, allowedTypes, nileFileUpload);\n\nexport const getHorizontalDisabledState = (\n browseFiles: Function,\n title: string,\n subtitle: string,\n dragHandler: DragHandler,\n state: FileUploadState,\n errorMessage: string,\n allowedTypes: string[],\n nileFileUpload: NileFileUpload\n): TemplateResult => baseHorizontalState(browseFiles, title, subtitle, true, dragHandler, state, errorMessage, allowedTypes, nileFileUpload);\n\nexport const getHorizontalDragState = (): TemplateResult => html`\n <div part=\"horizontal-drag-state\" 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>${FileUploadDefaults.DRAG_STATE_DEFAULT}</p>\n </div>\n`;\n\n// Vertical States\nconst baseVerticalState = (\n browseFiles: Function,\n title: string,\n subtitle: string,\n disabled: boolean,\n dragHandler: DragHandler,\n errorMessage: string,\n allowedTypes: string[],\n nileFileUpload: NileFileUpload\n): TemplateResult => {\n truncateString(nileFileUpload);\n return html`\n <div part=\"vertical-wrapper\" class=\"wrapper\">\n <div part=\"vertical-default\" class=\"vertical-default vertical-div ${disabled ? 'disable' : ''}\">\n <slot name=\"upload-icon\">\n <nile-icon name=\"upload\" size=\"24\"></nile-icon>\n </slot>\n <div part=\"vertical-content-container\" class=\"content-container\">\n <div class=\"title\">${title}</div>\n <div class=\"subtitle\">${subtitle}</div>\n </div>\n <input\n type=\"file\"\n ?disabled=${disabled}\n @change=${(e: Event | DragEvent) => dragHandler.handleFiles(e)}\n multiple\n accept=${allowedTypes.join(',')}\n />\n <slot @click=${disabled ? undefined : browseFiles} name=\"browse-file-button\">\n <nile-button variant=\"tertiary\" ?disabled=${disabled}>\n Browse File\n </nile-button>\n </slot>\n </div>\n ${errorMessage ?\n html`<div class=\"vertical-upload-error\">\n <nile-icon name=\"warning\" size=\"12\" color=\"var(--nile-colors-red-700)\"></nile-icon>\n <nile-tooltip content=${errorMessage}>\n <span>${errorMessage}</span>\n </nile-tooltip>\n </div>` :\n html``\n }\n </div>\n `;\n}\n\nexport const getVerticalDefaultState = (\n browseFiles: Function,\n title: string,\n subtitle: string,\n dragHandler: DragHandler,\n errorMessage: string,\n allowedTypes: string[],\n nileFileUpload: NileFileUpload\n): TemplateResult => baseVerticalState(browseFiles, title, subtitle, false, dragHandler, errorMessage, allowedTypes, nileFileUpload);\n\nexport const getVerticalDisabledState = (\n browseFiles: Function,\n title: string,\n subtitle: string,\n dragHandler: DragHandler,\n errorMessage: string,\n allowedTypes: string[],\n nileFileUpload: NileFileUpload\n): TemplateResult => baseVerticalState(browseFiles, title, subtitle, true, dragHandler, errorMessage, allowedTypes, nileFileUpload);\n\n\nexport const getVerticalDragState = (): TemplateResult => html`\n <div part=\"vertical-drag-state\" 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>${FileUploadDefaults.DRAG_STATE_DEFAULT}</p>\n </div>\n`;"]}
@@ -10,3 +10,4 @@ export declare function uploadFiles(nileFileUpload: NileFileUpload): void;
10
10
  export declare const cancelFileUpload: (nileFileUpload: NileFileUpload, uploadRequests: Map<File, XMLHttpRequest>) => void;
11
11
  export declare const preventDefaultAndStopPropagation: (event: Event | DragEvent) => void;
12
12
  export declare const removeFile: (uploadedFiles: File[], nileFileUpload: NileFileUpload) => void;
13
+ export declare const truncateString: (nileFileUpload: NileFileUpload) => void;
@@ -157,4 +157,15 @@ export const removeFile = (uploadedFiles, nileFileUpload) => {
157
157
  nileFileUpload.requestUpdate();
158
158
  });
159
159
  };
160
+ export const truncateString = (nileFileUpload) => {
161
+ if (nileFileUpload.variant === 'vertical' && nileFileUpload.errorMessage.length > 34) {
162
+ nileFileUpload.isStringTruncated = true;
163
+ nileFileUpload.requestUpdate();
164
+ }
165
+ else if (nileFileUpload.variant === 'horizontal' && nileFileUpload.errorMessage.length > 96) {
166
+ console.log('working');
167
+ nileFileUpload.isStringTruncated = true;
168
+ nileFileUpload.requestUpdate();
169
+ }
170
+ };
160
171
  //# sourceMappingURL=file-validation.util.js.map