@aquera/nile-elements 0.1.35-beta-2.0 → 0.1.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -66
- package/demo/index.css +4 -7
- package/demo/index.html +36 -20
- package/demo/variables.css +0 -13
- package/demo/variables_v2.css +0 -13
- package/dist/{fixture-df8b52d7.esm.js → fixture-2b5b3aba.esm.js} +1 -1
- package/dist/{fixture-d5b55278.cjs.js → fixture-7bfb866e.cjs.js} +3 -3
- package/dist/fixture-7bfb866e.cjs.js.map +1 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/internal/animate.cjs.js +1 -1
- package/dist/internal/animate.cjs.js.map +1 -1
- package/dist/internal/animate.esm.js +1 -1
- package/dist/nile-accordion/nile-accordian.test.cjs.js +1 -1
- package/dist/nile-accordion/nile-accordian.test.esm.js +1 -1
- package/dist/nile-auto-complete/nile-auto-complete.test.cjs.js +1 -1
- package/dist/nile-auto-complete/nile-auto-complete.test.esm.js +1 -1
- package/dist/nile-avatar/nile-avatar.test.cjs.js +1 -1
- package/dist/nile-avatar/nile-avatar.test.esm.js +1 -1
- package/dist/nile-badge/nile-badge.test.cjs.js +1 -1
- package/dist/nile-badge/nile-badge.test.esm.js +1 -1
- package/dist/nile-button/nile-button.test.cjs.js +1 -1
- package/dist/nile-button/nile-button.test.esm.js +1 -1
- package/dist/nile-button-toggle-group/nile-button-toggle-group.test.cjs.js +1 -1
- package/dist/nile-button-toggle-group/nile-button-toggle-group.test.esm.js +1 -1
- package/dist/nile-calendar/nile-calendar.test.cjs.js +1 -1
- package/dist/nile-calendar/nile-calendar.test.esm.js +1 -1
- package/dist/nile-card/nile-card.test.cjs.js +1 -1
- package/dist/nile-card/nile-card.test.esm.js +1 -1
- package/dist/nile-checkbox/nile-checkbox.test.cjs.js +1 -1
- package/dist/nile-checkbox/nile-checkbox.test.esm.js +1 -1
- package/dist/nile-chip/nile-chip.test.cjs.js +1 -1
- package/dist/nile-chip/nile-chip.test.esm.js +1 -1
- package/dist/nile-dialog/nile-dialog.test.cjs.js +1 -1
- package/dist/nile-dialog/nile-dialog.test.esm.js +1 -1
- package/dist/nile-drawer/nile-drawer.test.cjs.js +1 -1
- package/dist/nile-drawer/nile-drawer.test.esm.js +1 -1
- package/dist/nile-dropdown/nile-dropdown.test.cjs.js +1 -1
- package/dist/nile-dropdown/nile-dropdown.test.esm.js +1 -1
- package/dist/nile-empty-state/nile-empty-state.test.cjs.js +1 -1
- package/dist/nile-empty-state/nile-empty-state.test.esm.js +1 -1
- package/dist/nile-error-message/nile-error-message.cjs.js +1 -1
- package/dist/nile-error-message/nile-error-message.cjs.js.map +1 -1
- package/dist/nile-error-message/nile-error-message.css.cjs.js +1 -1
- package/dist/nile-error-message/nile-error-message.css.cjs.js.map +1 -1
- package/dist/nile-error-message/nile-error-message.css.esm.js +4 -6
- package/dist/nile-error-message/nile-error-message.esm.js +4 -4
- package/dist/nile-error-message/nile-error-message.test.cjs.js +1 -1
- package/dist/nile-error-message/nile-error-message.test.esm.js +1 -1
- package/dist/nile-error-notification/nile-error-notification.css.cjs.js +1 -1
- package/dist/nile-error-notification/nile-error-notification.css.cjs.js.map +1 -1
- package/dist/nile-error-notification/nile-error-notification.css.esm.js +1 -1
- package/dist/nile-form-group/nile-form-group.test.cjs.js +1 -1
- package/dist/nile-form-group/nile-form-group.test.esm.js +1 -1
- package/dist/nile-form-help-text/nile-form-help-text.test.cjs.js +1 -1
- package/dist/nile-form-help-text/nile-form-help-text.test.esm.js +1 -1
- package/dist/nile-hero/nile-hero.test.cjs.js +1 -1
- package/dist/nile-hero/nile-hero.test.esm.js +1 -1
- package/dist/nile-icon/nile-icon.test.cjs.js +1 -1
- package/dist/nile-icon/nile-icon.test.esm.js +1 -1
- package/dist/nile-input/nile-input.test.cjs.js +1 -1
- package/dist/nile-input/nile-input.test.esm.js +1 -1
- package/dist/nile-link/nile-link.test.cjs.js +1 -1
- package/dist/nile-link/nile-link.test.esm.js +1 -1
- package/dist/nile-loader/nile-loader.test.cjs.js +1 -1
- package/dist/nile-loader/nile-loader.test.esm.js +1 -1
- package/dist/nile-popover/nile-popover.test.cjs.js +1 -1
- package/dist/nile-popover/nile-popover.test.esm.js +1 -1
- package/dist/nile-popup/nile-popup.test.cjs.js +1 -1
- package/dist/nile-popup/nile-popup.test.esm.js +1 -1
- package/dist/nile-progress-bar/nile-progress-bar.css.cjs.js +1 -1
- package/dist/nile-progress-bar/nile-progress-bar.css.cjs.js.map +1 -1
- package/dist/nile-progress-bar/nile-progress-bar.css.esm.js +0 -1
- package/dist/nile-progress-bar/nile-progress-bar.test.cjs.js +1 -1
- package/dist/nile-progress-bar/nile-progress-bar.test.esm.js +1 -1
- package/dist/nile-radio/nile-radio.test.cjs.js +1 -1
- package/dist/nile-radio/nile-radio.test.esm.js +1 -1
- package/dist/nile-radio-group/nile-radio-group.test.cjs.js +1 -1
- package/dist/nile-radio-group/nile-radio-group.test.esm.js +1 -1
- package/dist/nile-select/nile-select.cjs.js +1 -1
- package/dist/nile-select/nile-select.cjs.js.map +1 -1
- package/dist/nile-select/nile-select.esm.js +1 -1
- package/dist/nile-select/nile-select.test.cjs.js +1 -1
- package/dist/nile-select/nile-select.test.esm.js +1 -1
- package/dist/nile-slide-toggle/nile-slide-toggle.test.cjs.js +1 -1
- package/dist/nile-slide-toggle/nile-slide-toggle.test.esm.js +1 -1
- package/dist/nile-tab-group/nile-tab-group.test.cjs.js +1 -1
- package/dist/nile-tab-group/nile-tab-group.test.esm.js +1 -1
- package/dist/nile-table/nile-table.cjs.js.map +1 -1
- package/dist/nile-textarea/nile-textarea.test.cjs.js +1 -1
- package/dist/nile-textarea/nile-textarea.test.esm.js +1 -1
- package/dist/nile-tooltip/index.cjs.js +1 -1
- package/dist/nile-tooltip/index.esm.js +1 -1
- package/dist/nile-tooltip/nile-tooltip.cjs.js +1 -1
- package/dist/nile-tooltip/nile-tooltip.cjs.js.map +1 -1
- package/dist/nile-tooltip/nile-tooltip.css.cjs.js +1 -1
- package/dist/nile-tooltip/nile-tooltip.css.cjs.js.map +1 -1
- package/dist/nile-tooltip/nile-tooltip.css.esm.js +45 -78
- package/dist/nile-tooltip/nile-tooltip.esm.js +28 -23
- package/dist/src/index.d.ts +0 -1
- package/dist/src/index.js +0 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/nile-error-message/nile-error-message.css.js +4 -6
- package/dist/src/nile-error-message/nile-error-message.css.js.map +1 -1
- package/dist/src/nile-error-message/nile-error-message.d.ts +0 -4
- package/dist/src/nile-error-message/nile-error-message.js +0 -20
- package/dist/src/nile-error-message/nile-error-message.js.map +1 -1
- package/dist/src/nile-error-notification/nile-error-notification.css.js +1 -1
- package/dist/src/nile-error-notification/nile-error-notification.css.js.map +1 -1
- package/dist/src/nile-file-preview/index.d.ts +1 -0
- package/dist/src/nile-file-preview/index.js +2 -0
- package/dist/src/nile-file-preview/index.js.map +1 -0
- package/dist/src/{nile-filter-chip/nile-filter-chip.css.d.ts → nile-file-preview/nile-file-preview.css.d.ts} +1 -1
- package/dist/src/nile-file-preview/nile-file-preview.css.js +533 -0
- package/dist/src/nile-file-preview/nile-file-preview.css.js.map +1 -0
- package/dist/src/nile-file-preview/nile-file-preview.d.ts +48 -0
- package/dist/src/nile-file-preview/nile-file-preview.js +149 -0
- package/dist/src/nile-file-preview/nile-file-preview.js.map +1 -0
- package/dist/src/nile-file-preview/nile-file-preview.template.d.ts +11 -0
- package/dist/src/nile-file-preview/nile-file-preview.template.js +144 -0
- package/dist/src/nile-file-preview/nile-file-preview.template.js.map +1 -0
- package/dist/src/nile-file-preview/nile-file-preview.test.d.ts +7 -0
- package/dist/src/nile-file-preview/nile-file-preview.test.js +30 -0
- package/dist/src/nile-file-preview/nile-file-preview.test.js.map +1 -0
- package/dist/src/nile-file-preview/types/file-preview.enums.d.ts +23 -0
- package/dist/src/nile-file-preview/types/file-preview.enums.js +28 -0
- package/dist/src/nile-file-preview/types/file-preview.enums.js.map +1 -0
- package/dist/src/nile-file-preview/types/file-preview.interface.d.ts +4 -0
- package/dist/src/nile-file-preview/types/file-preview.interface.js +2 -0
- package/dist/src/nile-file-preview/types/file-preview.interface.js.map +1 -0
- package/dist/src/nile-file-preview/types/index.d.ts +2 -0
- package/dist/src/nile-file-preview/types/index.js +3 -0
- package/dist/src/nile-file-preview/types/index.js.map +1 -0
- package/dist/src/nile-file-preview/utils/file-preview.util.d.ts +3 -0
- package/dist/src/nile-file-preview/utils/file-preview.util.js +29 -0
- package/dist/src/nile-file-preview/utils/file-preview.util.js.map +1 -0
- package/dist/src/nile-file-preview/utils/index.d.ts +1 -0
- package/dist/src/nile-file-preview/utils/index.js +2 -0
- package/dist/src/nile-file-preview/utils/index.js.map +1 -0
- package/dist/src/nile-file-upload/index.d.ts +1 -0
- package/dist/src/nile-file-upload/index.js +2 -0
- package/dist/src/{nile-filter-chip → nile-file-upload}/index.js.map +1 -1
- package/dist/src/nile-file-upload/nile-file-upload.css.d.ts +12 -0
- package/dist/src/nile-file-upload/nile-file-upload.css.js +547 -0
- package/dist/src/nile-file-upload/nile-file-upload.css.js.map +1 -0
- package/dist/src/nile-file-upload/nile-file-upload.d.ts +45 -0
- package/dist/src/nile-file-upload/nile-file-upload.js +148 -0
- package/dist/src/nile-file-upload/nile-file-upload.js.map +1 -0
- package/dist/src/nile-file-upload/nile-file-upload.template.d.ts +11 -0
- package/dist/src/nile-file-upload/nile-file-upload.template.js +163 -0
- package/dist/src/nile-file-upload/nile-file-upload.template.js.map +1 -0
- package/dist/src/nile-file-upload/nile-file-upload.test.d.ts +7 -0
- package/dist/src/nile-file-upload/nile-file-upload.test.js +30 -0
- package/dist/src/nile-file-upload/nile-file-upload.test.js.map +1 -0
- package/dist/src/nile-file-upload/types/file-upload.enums.d.ts +28 -0
- package/dist/src/nile-file-upload/types/file-upload.enums.js +35 -0
- package/dist/src/nile-file-upload/types/file-upload.enums.js.map +1 -0
- package/dist/src/nile-file-upload/types/file-upload.type.d.ts +4 -0
- package/dist/src/nile-file-upload/types/file-upload.type.js +2 -0
- package/dist/src/nile-file-upload/types/file-upload.type.js.map +1 -0
- package/dist/src/nile-file-upload/types/index.d.ts +2 -0
- package/dist/src/nile-file-upload/types/index.js +3 -0
- package/dist/src/nile-file-upload/types/index.js.map +1 -0
- package/dist/src/nile-file-upload/utils/drag-drop.util.d.ts +19 -0
- package/dist/src/nile-file-upload/utils/drag-drop.util.js +77 -0
- package/dist/src/nile-file-upload/utils/drag-drop.util.js.map +1 -0
- package/dist/src/nile-file-upload/utils/file-validation.util.d.ts +9 -0
- package/dist/src/nile-file-upload/utils/file-validation.util.js +58 -0
- package/dist/src/nile-file-upload/utils/file-validation.util.js.map +1 -0
- package/dist/src/nile-progress-bar/nile-progress-bar.css.js +0 -1
- package/dist/src/nile-progress-bar/nile-progress-bar.css.js.map +1 -1
- package/dist/src/nile-select/nile-select.js +1 -1
- package/dist/src/nile-select/nile-select.js.map +1 -1
- package/dist/src/nile-table/nile-table.js.map +1 -1
- package/dist/src/nile-tooltip/nile-tooltip.css.js +43 -76
- package/dist/src/nile-tooltip/nile-tooltip.css.js.map +1 -1
- package/dist/src/nile-tooltip/nile-tooltip.d.ts +46 -24
- package/dist/src/nile-tooltip/nile-tooltip.js +232 -235
- package/dist/src/nile-tooltip/nile-tooltip.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/plop-templates/lit/index.ts.hbs +1 -1
- package/plop-templates/lit/lit.css.ts.hbs +1 -1
- package/plop-templates/lit/lit.ts.hbs +3 -7
- package/plopfile.js +1 -32
- package/src/index.ts +1 -2
- package/src/nile-error-message/nile-error-message.css.ts +4 -6
- package/src/nile-error-message/nile-error-message.ts +0 -18
- package/src/nile-error-notification/nile-error-notification.css.ts +1 -1
- package/src/nile-progress-bar/nile-progress-bar.css.ts +0 -1
- package/src/nile-select/nile-select.ts +1 -1
- package/src/nile-table/nile-table.ts +2 -2
- package/src/nile-tooltip/nile-tooltip.css.ts +44 -77
- package/src/nile-tooltip/nile-tooltip.ts +230 -268
- package/vscode-html-custom-data.json +95 -144
- package/dist/fixture-d5b55278.cjs.js.map +0 -1
- package/dist/nile-filter-chip/index.cjs.js +0 -2
- package/dist/nile-filter-chip/index.cjs.js.map +0 -1
- package/dist/nile-filter-chip/index.esm.js +0 -1
- package/dist/nile-filter-chip/nile-filter-chip.cjs.js +0 -2
- package/dist/nile-filter-chip/nile-filter-chip.cjs.js.map +0 -1
- package/dist/nile-filter-chip/nile-filter-chip.css.cjs.js +0 -2
- package/dist/nile-filter-chip/nile-filter-chip.css.cjs.js.map +0 -1
- package/dist/nile-filter-chip/nile-filter-chip.css.esm.js +0 -121
- package/dist/nile-filter-chip/nile-filter-chip.esm.js +0 -43
- package/dist/nile-filter-chip/nile-filter-chip.test.cjs.js +0 -2
- package/dist/nile-filter-chip/nile-filter-chip.test.cjs.js.map +0 -1
- package/dist/nile-filter-chip/nile-filter-chip.test.esm.js +0 -20
- package/dist/nile-tooltip/nile-tooltip-utils.cjs.js +0 -2
- package/dist/nile-tooltip/nile-tooltip-utils.cjs.js.map +0 -1
- package/dist/nile-tooltip/nile-tooltip-utils.esm.js +0 -1
- package/dist/nile-tooltip/nile-tooltip.test.cjs.js +0 -2
- package/dist/nile-tooltip/nile-tooltip.test.cjs.js.map +0 -1
- package/dist/nile-tooltip/nile-tooltip.test.esm.js +0 -47
- package/dist/src/nile-filter-chip/index.d.ts +0 -1
- package/dist/src/nile-filter-chip/index.js +0 -2
- package/dist/src/nile-filter-chip/nile-filter-chip.css.js +0 -133
- package/dist/src/nile-filter-chip/nile-filter-chip.css.js.map +0 -1
- package/dist/src/nile-filter-chip/nile-filter-chip.d.ts +0 -36
- package/dist/src/nile-filter-chip/nile-filter-chip.js +0 -141
- package/dist/src/nile-filter-chip/nile-filter-chip.js.map +0 -1
- package/dist/src/nile-filter-chip/nile-filter-chip.test.d.ts +0 -1
- package/dist/src/nile-filter-chip/nile-filter-chip.test.js +0 -80
- package/dist/src/nile-filter-chip/nile-filter-chip.test.js.map +0 -1
- package/dist/src/nile-tooltip/nile-tooltip-utils.d.ts +0 -18
- package/dist/src/nile-tooltip/nile-tooltip-utils.js +0 -216
- package/dist/src/nile-tooltip/nile-tooltip-utils.js.map +0 -1
- package/dist/src/nile-tooltip/nile-tooltip.test.d.ts +0 -1
- package/dist/src/nile-tooltip/nile-tooltip.test.js +0 -148
- package/dist/src/nile-tooltip/nile-tooltip.test.js.map +0 -1
- package/plop-templates/lit/lit.template.ts.hbs +0 -3
- package/plop-templates/lit/lit.test.ts.hbs +0 -38
- package/plop-templates/lit/sub-components/index.ts.hbs +0 -4
- package/plop-templates/lit/types/index.ts.hbs +0 -0
- package/plop-templates/lit/types/type.ts.hbs +0 -3
- package/plop-templates/lit/utils/lit.utils.ts.hbs +0 -4
- package/src/nile-filter-chip/index.ts +0 -1
- package/src/nile-filter-chip/nile-filter-chip.css.ts +0 -138
- package/src/nile-filter-chip/nile-filter-chip.test.ts +0 -92
- package/src/nile-filter-chip/nile-filter-chip.ts +0 -136
- package/src/nile-tooltip/nile-tooltip-utils.ts +0 -271
- package/src/nile-tooltip/nile-tooltip.test.ts +0 -168
@@ -0,0 +1,149 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright Aquera Inc 2025
|
3
|
+
*
|
4
|
+
* This source code is licensed under the BSD-3-Clause license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*/
|
7
|
+
import { __decorate } from "tslib";
|
8
|
+
import { styles } from './nile-file-preview.css';
|
9
|
+
import NileElement from '../internal/nile-element';
|
10
|
+
import { customElement, property } from 'lit/decorators.js';
|
11
|
+
import { generatePreviewUrl } from './utils';
|
12
|
+
import { FilePreviewState, FilePreviewVariant, FilePreviewErrorMessages, FilePreviewEvent } from './types';
|
13
|
+
import { html } from 'lit';
|
14
|
+
import { getHorizontalErrorState, getHorizontalNoPreviewState, getHorizontalPreviewState, getVerticalErrorState, getVerticalNoPreviewState, getVerticalPreviewState } from './nile-file-preview.template';
|
15
|
+
/**
|
16
|
+
* Nile preview component.
|
17
|
+
*
|
18
|
+
* @tag nile-preview
|
19
|
+
*
|
20
|
+
*/
|
21
|
+
let NileFilePreview = class NileFilePreview extends NileElement {
|
22
|
+
constructor() {
|
23
|
+
super(...arguments);
|
24
|
+
this.errorMessage = "";
|
25
|
+
this.fileUrl = "";
|
26
|
+
this.uploadStatus = 0;
|
27
|
+
this.allowedTypes = [];
|
28
|
+
this.state = FilePreviewState.DEFAULT;
|
29
|
+
this.variant = FilePreviewVariant.HORIZONTAL;
|
30
|
+
this.inputFileName = "";
|
31
|
+
this.inputFileHtml = null;
|
32
|
+
this.originalUrl = "";
|
33
|
+
/* #endregion */
|
34
|
+
}
|
35
|
+
/**
|
36
|
+
* The styles for nile-preview
|
37
|
+
* @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`
|
38
|
+
*/
|
39
|
+
static get styles() {
|
40
|
+
return [styles];
|
41
|
+
}
|
42
|
+
/**
|
43
|
+
* Render method
|
44
|
+
* @slot This is a slot test
|
45
|
+
*/
|
46
|
+
connectedCallback() {
|
47
|
+
super.connectedCallback();
|
48
|
+
this.emit(FilePreviewEvent.NILE_INIT);
|
49
|
+
}
|
50
|
+
updated(changedProperties) {
|
51
|
+
if (changedProperties.has('inputFile') && this.inputFile) {
|
52
|
+
this.createState(this.inputFile);
|
53
|
+
this.emit(FilePreviewEvent.NILE_RECEIVE);
|
54
|
+
}
|
55
|
+
else if (changedProperties.has('fileUrl') && this.fileUrl) {
|
56
|
+
this.handleFileUrl(this.fileUrl);
|
57
|
+
this.emit(FilePreviewEvent.NILE_RECEIVE);
|
58
|
+
}
|
59
|
+
}
|
60
|
+
async handleFileUrl(url) {
|
61
|
+
this.originalUrl = url;
|
62
|
+
try {
|
63
|
+
const response = await fetch(url);
|
64
|
+
const blob = await response.blob();
|
65
|
+
const fileName = this.inputFileName || url.split('/').pop() || FilePreviewErrorMessages.UNKNOWN_FILE_NAME;
|
66
|
+
const file = new File([blob], fileName, { type: blob.type });
|
67
|
+
this.createState(file);
|
68
|
+
}
|
69
|
+
catch (error) {
|
70
|
+
const dummyFile = new File([], this.inputFileName || FilePreviewErrorMessages.UNKNOWN_FILE_NAME, { type: 'application/octet-stream' });
|
71
|
+
this.errorMessage = FilePreviewErrorMessages.FAILED_TO_LOAD;
|
72
|
+
this.inputFileHtml = this.variant === FilePreviewVariant.HORIZONTAL
|
73
|
+
? getHorizontalErrorState(dummyFile, this.errorMessage, this.originalUrl)
|
74
|
+
: getVerticalErrorState(dummyFile, this.errorMessage, this.originalUrl);
|
75
|
+
this.requestUpdate();
|
76
|
+
}
|
77
|
+
}
|
78
|
+
async createState(file) {
|
79
|
+
const isHorizontal = this.variant === FilePreviewVariant.HORIZONTAL;
|
80
|
+
if (this.allowedTypes.includes(file.type)) {
|
81
|
+
if (file.type.startsWith('image/')) {
|
82
|
+
try {
|
83
|
+
const url = await generatePreviewUrl(file);
|
84
|
+
this.inputFileHtml = isHorizontal
|
85
|
+
? getHorizontalPreviewState(url, file, this.originalUrl)
|
86
|
+
: getVerticalPreviewState(url, file, this.originalUrl);
|
87
|
+
}
|
88
|
+
catch (error) {
|
89
|
+
this.inputFileHtml = isHorizontal
|
90
|
+
? getHorizontalNoPreviewState(file, this.originalUrl)
|
91
|
+
: getVerticalNoPreviewState(file, this.originalUrl);
|
92
|
+
}
|
93
|
+
}
|
94
|
+
else {
|
95
|
+
this.inputFileHtml = isHorizontal
|
96
|
+
? getHorizontalNoPreviewState(file, this.originalUrl)
|
97
|
+
: getVerticalNoPreviewState(file, this.originalUrl);
|
98
|
+
}
|
99
|
+
}
|
100
|
+
else {
|
101
|
+
this.errorMessage = FilePreviewErrorMessages.INVALID_FORMAT;
|
102
|
+
this.inputFileHtml = isHorizontal
|
103
|
+
? getHorizontalErrorState(file, this.errorMessage, this.originalUrl)
|
104
|
+
: getVerticalErrorState(file, this.errorMessage, this.originalUrl);
|
105
|
+
}
|
106
|
+
this.requestUpdate();
|
107
|
+
}
|
108
|
+
render() {
|
109
|
+
return html `
|
110
|
+
${this.inputFileHtml ?
|
111
|
+
this.inputFileHtml :
|
112
|
+
html ``}
|
113
|
+
`;
|
114
|
+
}
|
115
|
+
disconnectedCallback() {
|
116
|
+
super.disconnectedCallback();
|
117
|
+
this.emit(FilePreviewEvent.NILE_DESTROY);
|
118
|
+
}
|
119
|
+
};
|
120
|
+
__decorate([
|
121
|
+
property({ type: String })
|
122
|
+
], NileFilePreview.prototype, "errorMessage", void 0);
|
123
|
+
__decorate([
|
124
|
+
property({ type: Object })
|
125
|
+
], NileFilePreview.prototype, "inputFile", void 0);
|
126
|
+
__decorate([
|
127
|
+
property({ type: String })
|
128
|
+
], NileFilePreview.prototype, "fileUrl", void 0);
|
129
|
+
__decorate([
|
130
|
+
property({ type: Number })
|
131
|
+
], NileFilePreview.prototype, "uploadStatus", void 0);
|
132
|
+
__decorate([
|
133
|
+
property({ type: Array })
|
134
|
+
], NileFilePreview.prototype, "allowedTypes", void 0);
|
135
|
+
__decorate([
|
136
|
+
property({ type: String })
|
137
|
+
], NileFilePreview.prototype, "state", void 0);
|
138
|
+
__decorate([
|
139
|
+
property({ type: String })
|
140
|
+
], NileFilePreview.prototype, "variant", void 0);
|
141
|
+
__decorate([
|
142
|
+
property({ type: String })
|
143
|
+
], NileFilePreview.prototype, "inputFileName", void 0);
|
144
|
+
NileFilePreview = __decorate([
|
145
|
+
customElement('nile-preview')
|
146
|
+
], NileFilePreview);
|
147
|
+
export { NileFilePreview };
|
148
|
+
export default NileFilePreview;
|
149
|
+
//# sourceMappingURL=nile-file-preview.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"nile-file-preview.js","sourceRoot":"","sources":["../../../src/nile-file-preview/nile-file-preview.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAEH,OAAO,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AAC/C,OAAO,WAAW,MAAM,0BAA0B,CAA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CAAC,cAAc,CAAC;GACjB,eAAe,CA2G3B;;AAED,eAAe,eAAe,CAAC","sourcesContent":["/**\n * Copyright Aquera Inc 2025\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport {styles} from './nile-file-preview.css';\nimport NileElement from '../internal/nile-element';\nimport { customElement, property } from 'lit/decorators.js';\nimport { generatePreviewUrl } from './utils';\nimport { FilePreviewState, FilePreviewVariant, FilePreviewErrorMessages, FilePreviewEvent } from './types';\nimport { LitElement, html, CSSResultArray, TemplateResult, PropertyValues } from 'lit';\nimport {\n getHorizontalErrorState,\n getHorizontalNoPreviewState,\n getHorizontalPreviewState,\n getVerticalErrorState,\n getVerticalNoPreviewState,\n getVerticalPreviewState\n} from './nile-file-preview.template';\n\n\n/**\n * Nile preview component.\n *\n * @tag nile-preview\n *\n */\n@customElement('nile-preview')\nexport class NileFilePreview extends NileElement {\n /**\n * The styles for nile-preview\n * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`\n */\n public static get styles(): CSSResultArray {\n return [styles];\n }\n\n @property({ type: String }) errorMessage: string = \"\";\n\t@property({ type: Object }) inputFile: File; \n\t@property({ type: String }) fileUrl: string = \"\";\n\t@property({ type: Number }) uploadStatus: number = 0;\n @property({ type: Array }) allowedTypes: string[] = [];\n\t@property({ type: String }) state: FilePreviewState = FilePreviewState.DEFAULT;\n\t@property({ type: String }) variant: FilePreviewVariant = FilePreviewVariant.HORIZONTAL;\n @property({ type: String }) inputFileName: string = \"\";\n\tprivate inputFileHtml: TemplateResult | null = null;\n private originalUrl: string = \"\";\n\n /**\n * Render method\n * @slot This is a slot test\n */\n\n connectedCallback(): void {\n super.connectedCallback();\n this.emit(FilePreviewEvent.NILE_INIT);\n }\n\n protected updated(changedProperties: PropertyValues): void {\n\n if (changedProperties.has('inputFile') && this.inputFile) {\n this.createState(this.inputFile);\n this.emit(FilePreviewEvent.NILE_RECEIVE);\n\n } else if (changedProperties.has('fileUrl') && this.fileUrl) {\n this.handleFileUrl(this.fileUrl);\n this.emit(FilePreviewEvent.NILE_RECEIVE);\n }\n }\n\n private async handleFileUrl(url: string): Promise<void> {\n this.originalUrl = url;\n try {\n const response = await fetch(url);\n const blob = await response.blob();\n const fileName = this.inputFileName || url.split('/').pop() || FilePreviewErrorMessages.UNKNOWN_FILE_NAME;\n const file = new File([blob], fileName, { type: blob.type });\n\n this.createState(file);\n } catch (error) {\n const dummyFile = new File([], this.inputFileName || FilePreviewErrorMessages.UNKNOWN_FILE_NAME, { type: 'application/octet-stream' });\n this.errorMessage = FilePreviewErrorMessages.FAILED_TO_LOAD;\n\n this.inputFileHtml = this.variant === FilePreviewVariant.HORIZONTAL\n ? getHorizontalErrorState(dummyFile, this.errorMessage, this.originalUrl)\n : getVerticalErrorState(dummyFile, this.errorMessage, this.originalUrl);\n this.requestUpdate();\n }\n }\n\n\tpublic async createState(file: File): Promise<void> {\n const isHorizontal = this.variant === FilePreviewVariant.HORIZONTAL;\n\n if (this.allowedTypes.includes(file.type)) { \n if (file.type.startsWith('image/')) {\n try {\n const url = await generatePreviewUrl(file);\n this.inputFileHtml = isHorizontal\n ? getHorizontalPreviewState(url, file, this.originalUrl)\n : getVerticalPreviewState(url, file, this.originalUrl);\n } catch (error) {\n this.inputFileHtml = isHorizontal\n ? getHorizontalNoPreviewState(file, this.originalUrl)\n : getVerticalNoPreviewState(file, this.originalUrl); \n }\n } else {\n this.inputFileHtml = isHorizontal\n ? getHorizontalNoPreviewState(file, this.originalUrl)\n : getVerticalNoPreviewState(file, this.originalUrl);\n }\n } else {\n this.errorMessage = FilePreviewErrorMessages.INVALID_FORMAT;\n\n this.inputFileHtml = isHorizontal\n ? getHorizontalErrorState(file, this.errorMessage, this.originalUrl)\n : getVerticalErrorState(file, this.errorMessage, this.originalUrl);\n }\n this.requestUpdate();\n }\n\n public render(): TemplateResult {\n return html`\n\t\t\t${this.inputFileHtml ?\n\t\t\t\tthis.inputFileHtml :\n\t\t\t\thtml``\n\t\t\t}\n `;\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n this.emit(FilePreviewEvent.NILE_DESTROY);\n }\n\n /* #endregion */\n}\n\nexport default NileFilePreview;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-preview': NileFilePreview;\n }\n}"]}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
/**
|
2
|
+
* Template File for nile-preview component
|
3
|
+
*/
|
4
|
+
import './nile-file-preview.css';
|
5
|
+
import { TemplateResult } from 'lit';
|
6
|
+
export declare function getHorizontalPreviewState(url: string, file: File, originalUrl: string): TemplateResult;
|
7
|
+
export declare function getHorizontalNoPreviewState(file: File, originalUrl: string): TemplateResult;
|
8
|
+
export declare function getHorizontalErrorState(file: File, errorMessage: string, originalUrl: string): TemplateResult;
|
9
|
+
export declare function getVerticalPreviewState(url: string, file: File, originalUrl: string): TemplateResult;
|
10
|
+
export declare function getVerticalNoPreviewState(file: File, originalUrl: string): TemplateResult;
|
11
|
+
export declare function getVerticalErrorState(file: File, errorMessage: string, originalUrl: string): TemplateResult;
|
@@ -0,0 +1,144 @@
|
|
1
|
+
/**
|
2
|
+
* Template File for nile-preview component
|
3
|
+
*/
|
4
|
+
import './nile-file-preview.css';
|
5
|
+
import { html } from 'lit';
|
6
|
+
import { removeFile } from './utils';
|
7
|
+
export function getHorizontalPreviewState(url, file, originalUrl) {
|
8
|
+
return html `
|
9
|
+
<div class="preview horizontal-div">
|
10
|
+
<div class="preview-inner">
|
11
|
+
<div class="preview-image-container">
|
12
|
+
${file.type.startsWith('image/')
|
13
|
+
? html `<img src="${url}" alt="Image Preview" />`
|
14
|
+
: html `<iframe src="${url}" type="${file.type}" width="40px" height="40px" />`}
|
15
|
+
</div>
|
16
|
+
<div class="preview-file-info">
|
17
|
+
<p>${file.name}</p>
|
18
|
+
<p>${(file.type.split('/')[1]).toUpperCase()} • ${(Number(file.size) / 1000).toFixed(0)}KB</p>
|
19
|
+
</div>
|
20
|
+
</div>
|
21
|
+
<nile-icon
|
22
|
+
@click=${(e) => removeFile(file, e, originalUrl)}
|
23
|
+
name="trash"
|
24
|
+
size="14"
|
25
|
+
class="icon"
|
26
|
+
></nile-icon>
|
27
|
+
</div>
|
28
|
+
`;
|
29
|
+
}
|
30
|
+
export function getHorizontalNoPreviewState(file, originalUrl) {
|
31
|
+
return html `
|
32
|
+
<div class="no-preview horizontal-div">
|
33
|
+
<div class="no-preview-container">
|
34
|
+
<div class="document-icon">
|
35
|
+
<nile-icon name="general" size="20" color="var(--nile-colors-blue-500)"></nile-icon>
|
36
|
+
</div>
|
37
|
+
<div class="preview-file-info">
|
38
|
+
<p>${file.name}</p>
|
39
|
+
<p>${(file.type.split('/')[1]).toUpperCase()} • ${(Number(file.size) / 1000).toFixed(0)}KB</p>
|
40
|
+
</div>
|
41
|
+
</div>
|
42
|
+
<div>
|
43
|
+
<nile-icon
|
44
|
+
@click=${(e) => removeFile(file, e, originalUrl)}
|
45
|
+
name="trash"
|
46
|
+
size="14"
|
47
|
+
class="icon"
|
48
|
+
></nile-icon>
|
49
|
+
</div>
|
50
|
+
</div>
|
51
|
+
`;
|
52
|
+
}
|
53
|
+
export function getHorizontalErrorState(file, errorMessage, originalUrl) {
|
54
|
+
return html `
|
55
|
+
<div class="error horizontal-div">
|
56
|
+
<div class="error-container">
|
57
|
+
<div class="error-icon">
|
58
|
+
<nile-icon name="info-icon" size="20" color="var(--nile-colors-red-700)"></nile-icon>
|
59
|
+
</div>
|
60
|
+
<div class="file-info">
|
61
|
+
<p>${file.name}</p>
|
62
|
+
<p>${errorMessage}</p>
|
63
|
+
</div>
|
64
|
+
</div>
|
65
|
+
<nile-icon
|
66
|
+
@click=${(e) => removeFile(file, e, originalUrl)}
|
67
|
+
name="close"
|
68
|
+
size="14"
|
69
|
+
class="icon"
|
70
|
+
></nile-icon>
|
71
|
+
</div>
|
72
|
+
`;
|
73
|
+
}
|
74
|
+
// vertical states
|
75
|
+
export function getVerticalPreviewState(url, file, originalUrl) {
|
76
|
+
return html `
|
77
|
+
<div class="vertical-div vertical-preview">
|
78
|
+
<div>
|
79
|
+
<img
|
80
|
+
class="image-preview"
|
81
|
+
src=${url}
|
82
|
+
alt=${file.name}
|
83
|
+
/>
|
84
|
+
</div>
|
85
|
+
|
86
|
+
<div class="content-container">
|
87
|
+
<p>${file.name}</p>
|
88
|
+
<p>${(file.type.split('/')[1]).toUpperCase()} • ${(Number(file.size) / 1000).toFixed(0)}KB</p>
|
89
|
+
</div>
|
90
|
+
|
91
|
+
<nile-icon
|
92
|
+
@click=${(e) => removeFile(file, e, originalUrl)}
|
93
|
+
name="trash"
|
94
|
+
size="14"
|
95
|
+
class="corner-icon icon"
|
96
|
+
></nile-icon>
|
97
|
+
</div>
|
98
|
+
`;
|
99
|
+
}
|
100
|
+
export function getVerticalNoPreviewState(file, originalUrl) {
|
101
|
+
return html `
|
102
|
+
<div class="vertical-div vertical-no-preview">
|
103
|
+
<div class="vertical-document-icon">
|
104
|
+
<nile-icon name="general" size="20" color="var(--nile-colors-blue-500)"></nile-icon>
|
105
|
+
</div>
|
106
|
+
|
107
|
+
<div class="content-container">
|
108
|
+
<p>${file.name}</p>
|
109
|
+
<p>${file.type} • ${(Number(file.size) / 1000).toFixed(0)}KB</p>
|
110
|
+
</div>
|
111
|
+
|
112
|
+
<nile-icon
|
113
|
+
@click=${(e) => removeFile(file, e, originalUrl)}
|
114
|
+
name="trash"
|
115
|
+
size="14"
|
116
|
+
class="corner-icon icon"
|
117
|
+
></nile-icon>
|
118
|
+
</div>
|
119
|
+
`;
|
120
|
+
}
|
121
|
+
export function getVerticalErrorState(file, errorMessage, originalUrl) {
|
122
|
+
return html `
|
123
|
+
<div class="vertical-div vertical-error">
|
124
|
+
<div class="vertical-document-icon error-bg">
|
125
|
+
<nile-icon name="info-icon" size="20" color="var(--nile-colors-red-700)"></nile-icon>
|
126
|
+
</div>
|
127
|
+
|
128
|
+
<div class="error-message">
|
129
|
+
<p>${file.name}</p>
|
130
|
+
<div class="error-p">
|
131
|
+
<p>${errorMessage}</p>
|
132
|
+
</div>
|
133
|
+
</div>
|
134
|
+
|
135
|
+
<nile-icon
|
136
|
+
@click=${(e) => removeFile(file, e, originalUrl)}
|
137
|
+
name="close"
|
138
|
+
size="14"
|
139
|
+
class="corner-icon icon"
|
140
|
+
></nile-icon>
|
141
|
+
</div>
|
142
|
+
`;
|
143
|
+
}
|
144
|
+
//# sourceMappingURL=nile-file-preview.template.js.map
|
@@ -0,0 +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,MAAM,SAAS,CAAC;AAErC,MAAM,UAAU,yBAAyB,CACvC,GAAW,EACX,IAAU,EACV,WAAmB;IAEnB,OAAO,IAAI,CAAA;;;;YAID,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;QAC9B,CAAC,CAAC,IAAI,CAAA,aAAa,GAAG,0BAA0B;QAChD,CAAC,CAAC,IAAI,CAAA,gBAAgB,GAAG,WAAW,IAAI,CAAC,IAAI,iCAC/C;;;eAGK,IAAI,CAAC,IAAI;eACT,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;;;;iBAItF,CAAC,CAAgC,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,EAAE,WAAW,CAAC;;;;;;GAMpF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,2BAA2B,CACzC,IAAU,EACV,WAAmB;IAEnB,OAAO,IAAI,CA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AY,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;;;;iBAItD,CAAC,CAAgC,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,EAAE,WAAW,CAAC;;;;;;GAMpF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,IAAU,EACV,YAAoB,EACpB,WAAmB;IAEnB,OAAO,IAAI,CAAA;;;;;;;aAOA,IAAI,CAAC,IAAI;;eAEP,YAAY;;;;;iBAKV,CAAC,CAAgC,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,EAAE,WAAW,CAAC;;;;;;GAMpF,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Template File for nile-preview component\n */\n\nimport './nile-file-preview.css';\nimport { html, TemplateResult } from 'lit';\nimport { RemoveFileDetail } from './types';\nimport { removeFile } from './utils';\n\nexport function getHorizontalPreviewState(\n url: string,\n file: File,\n originalUrl: string\n): TemplateResult {\n return html`\n <div class=\"preview horizontal-div\">\n <div class=\"preview-inner\">\n <div class=\"preview-image-container\">\n ${file.type.startsWith('image/')\n ? html`<img src=\"${url}\" alt=\"Image Preview\" />`\n : html`<iframe src=\"${url}\" type=\"${file.type}\" width=\"40px\" height=\"40px\" />`\n }\n </div>\n <div class=\"preview-file-info\">\n <p>${file.name}</p>\n <p>${(file.type.split('/')[1]).toUpperCase()} • ${(Number(file.size) / 1000).toFixed(0)}KB</p>\n </div>\n </div>\n <nile-icon \n @click=${(e: CustomEvent<RemoveFileDetail>) => removeFile(file, e, originalUrl)}\n name=\"trash\" \n size=\"14\" \n class=\"icon\"\n ></nile-icon>\n </div>\n `;\n}\n\nexport function getHorizontalNoPreviewState(\n file: File,\n originalUrl: string\n): TemplateResult {\n return html`\n <div class=\"no-preview horizontal-div\">\n <div class=\"no-preview-container\">\n <div class=\"document-icon\">\n <nile-icon name=\"general\" size=\"20\" color=\"var(--nile-colors-blue-500)\"></nile-icon>\n </div>\n <div class=\"preview-file-info\">\n <p>${file.name}</p>\n <p>${(file.type.split('/')[1]).toUpperCase()} • ${(Number(file.size) / 1000).toFixed(0)}KB</p>\n </div>\n </div>\n <div>\n <nile-icon\n @click=${(e: CustomEvent<RemoveFileDetail>) => removeFile(file, e, originalUrl)}\n name=\"trash\"\n size=\"14\"\n class=\"icon\"\n ></nile-icon>\n </div>\n </div>\n `;\n}\n\nexport function getHorizontalErrorState(\n file: File,\n errorMessage: string,\n originalUrl: string\n): TemplateResult {\n return html`\n <div class=\"error horizontal-div\">\n <div class=\"error-container\">\n <div class=\"error-icon\">\n <nile-icon name=\"info-icon\" size=\"20\" color=\"var(--nile-colors-red-700)\"></nile-icon>\n </div>\n <div class=\"file-info\">\n <p>${file.name}</p>\n <p>${errorMessage}</p>\n </div>\n </div>\n <nile-icon \n @click=${(e: CustomEvent<RemoveFileDetail>) => removeFile(file, e, originalUrl)} \n name=\"close\" \n size=\"14\" \n class=\"icon\"\n ></nile-icon>\n </div>\n `;\n}\n\n// vertical states\nexport function getVerticalPreviewState(\n url: string,\n file: File,\n originalUrl: string\n): TemplateResult {\n return html`\n <div class=\"vertical-div vertical-preview\">\n <div>\n <img\n class=\"image-preview\"\n src=${url}\n alt=${file.name}\n />\n </div>\n\n <div class=\"content-container\">\n <p>${file.name}</p>\n <p>${(file.type.split('/')[1]).toUpperCase()} • ${(Number(file.size) / 1000).toFixed(0)}KB</p>\n </div>\n\n <nile-icon \n @click=${(e: CustomEvent<RemoveFileDetail>) => removeFile(file, e, originalUrl)}\n name=\"trash\" \n size=\"14\" \n class=\"corner-icon icon\"\n ></nile-icon>\n </div>\n `;\n}\n\nexport function getVerticalNoPreviewState(\n file: File,\n originalUrl: string\n): TemplateResult {\n return html`\n <div class=\"vertical-div vertical-no-preview\">\n <div class=\"vertical-document-icon\">\n <nile-icon name=\"general\" size=\"20\" color=\"var(--nile-colors-blue-500)\"></nile-icon>\n </div>\n\n <div class=\"content-container\">\n <p>${file.name}</p>\n <p>${file.type} • ${(Number(file.size) / 1000).toFixed(0)}KB</p>\n </div>\n\n <nile-icon\n @click=${(e: CustomEvent<RemoveFileDetail>) => removeFile(file, e, originalUrl)}\n name=\"trash\"\n size=\"14\"\n class=\"corner-icon icon\"\n ></nile-icon>\n </div>\n `;\n}\n\nexport function getVerticalErrorState(\n file: File,\n errorMessage: string,\n originalUrl: string\n): TemplateResult {\n return html`\n <div class=\"vertical-div vertical-error\">\n <div class=\"vertical-document-icon error-bg\">\n <nile-icon name=\"info-icon\" size=\"20\" color=\"var(--nile-colors-red-700)\"></nile-icon>\n </div>\n\n <div class=\"error-message\">\n <p>${file.name}</p>\n <div class=\"error-p\">\n <p>${errorMessage}</p>\n </div>\n </div>\n\n <nile-icon \n @click=${(e: CustomEvent<RemoveFileDetail>) => removeFile(file, e, originalUrl)}\n name=\"close\" \n size=\"14\" \n class=\"corner-icon icon\"\n ></nile-icon>\n </div>\n `;\n}"]}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright Aquera Inc 2025
|
3
|
+
*
|
4
|
+
* This source code is licensed under the BSD-3-Clause license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*/
|
7
|
+
import { fixture, assert, expect, html } from '@open-wc/testing';
|
8
|
+
import './nile-file-preview'; // Just import to register the element
|
9
|
+
describe('<nile-preview>', () => {
|
10
|
+
let element;
|
11
|
+
beforeEach(async () => {
|
12
|
+
element = await fixture(html `<nile-file-preview></nile-file-preview>`);
|
13
|
+
});
|
14
|
+
it('passes accessibility test', async () => {
|
15
|
+
await expect(element).to.be.accessible();
|
16
|
+
});
|
17
|
+
it('renders with the correct tag name', () => {
|
18
|
+
expect(element.tagName.toLowerCase()).to.equal('nile-preview');
|
19
|
+
});
|
20
|
+
it('renders with slot content when provided', async () => {
|
21
|
+
const testContent = 'Test Content';
|
22
|
+
element = await fixture(html `<nile-file-preview>${testContent}</nile-file-preview>`);
|
23
|
+
const slot = element.shadowRoot.querySelector('slot');
|
24
|
+
assert.exists(slot, 'Slot should exist');
|
25
|
+
const assignedNodes = slot.assignedNodes({ flatten: true });
|
26
|
+
expect(assignedNodes.length).to.be.greaterThan(0);
|
27
|
+
expect(assignedNodes[0].textContent?.trim()).to.equal(testContent);
|
28
|
+
});
|
29
|
+
});
|
30
|
+
//# sourceMappingURL=nile-file-preview.test.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"nile-file-preview.test.js","sourceRoot":"","sources":["../../../src/nile-file-preview/nile-file-preview.test.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,qBAAqB,CAAC,CAAC,sCAAsC;AAEpE,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,IAAI,OAAoB,CAAC;IAEzB,UAAU,CAAC,KAAK,IAAI,EAAE;QACpB,OAAO,GAAG,MAAM,OAAO,CAAC,IAAI,CAAA,yCAAyC,CAAC,CAAC;IACzE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2BAA2B,EAAE,KAAK,IAAI,EAAE;QACzC,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC;IAC3C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;QAC3C,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IACjE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yCAAyC,EAAE,KAAK,IAAI,EAAE;QACvD,MAAM,WAAW,GAAG,cAAc,CAAC;QACnC,OAAO,GAAG,MAAM,OAAO,CAAC,IAAI,CAAA,sBAAsB,WAAW,sBAAsB,CAAC,CAAC;QAErF,MAAM,IAAI,GAAI,OAAO,CAAC,UAAW,CAAC,aAAa,CAAC,MAAM,CAAqB,CAAC;QAC5E,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC;QAEzC,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5D,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;QAClD,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["/**\n * Copyright Aquera Inc 2025\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n \nimport { fixture, assert, expect, html } from '@open-wc/testing';\nimport './nile-file-preview'; // Just import to register the element\n\ndescribe('<nile-preview>', () => {\n let element: HTMLElement;\n\n beforeEach(async () => {\n element = await fixture(html`<nile-file-preview></nile-file-preview>`);\n });\n\n it('passes accessibility test', async () => {\n await expect(element).to.be.accessible();\n });\n\n it('renders with the correct tag name', () => {\n expect(element.tagName.toLowerCase()).to.equal('nile-preview');\n });\n\n it('renders with slot content when provided', async () => {\n const testContent = 'Test Content';\n element = await fixture(html`<nile-file-preview>${testContent}</nile-file-preview>`);\n \n const slot = (element.shadowRoot!.querySelector('slot') as HTMLSlotElement);\n assert.exists(slot, 'Slot should exist');\n\n const assignedNodes = slot.assignedNodes({ flatten: true });\n expect(assignedNodes.length).to.be.greaterThan(0);\n expect(assignedNodes[0].textContent?.trim()).to.equal(testContent);\n });\n});"]}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
export declare enum FilePreviewState {
|
2
|
+
DEFAULT = "default",
|
3
|
+
UPLOADING = "uploading",
|
4
|
+
PREVIEW = "preview",
|
5
|
+
NO_PREVIEW = "no-preview",
|
6
|
+
ERROR = "error"
|
7
|
+
}
|
8
|
+
export declare enum FilePreviewVariant {
|
9
|
+
HORIZONTAL = "horizontal",
|
10
|
+
VERTICAL = "vertical"
|
11
|
+
}
|
12
|
+
export declare enum FilePreviewErrorMessages {
|
13
|
+
INVALID_FORMAT = "Invalid File Format. Please try again.",
|
14
|
+
SIZE_LIMIT = "Size limit exceeded",
|
15
|
+
FAILED_TO_LOAD = "Failed to load file from URL",
|
16
|
+
UNKNOWN_FILE_NAME = "unknown-file"
|
17
|
+
}
|
18
|
+
export declare enum FilePreviewEvent {
|
19
|
+
NILE_INIT = "nile-init",
|
20
|
+
NILE_RECEIVE = "nile-receive",
|
21
|
+
NILE_REMOVE = "nile-remove",
|
22
|
+
NILE_DESTROY = "nile-destroy"
|
23
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
export var FilePreviewState;
|
2
|
+
(function (FilePreviewState) {
|
3
|
+
FilePreviewState["DEFAULT"] = "default";
|
4
|
+
FilePreviewState["UPLOADING"] = "uploading";
|
5
|
+
FilePreviewState["PREVIEW"] = "preview";
|
6
|
+
FilePreviewState["NO_PREVIEW"] = "no-preview";
|
7
|
+
FilePreviewState["ERROR"] = "error";
|
8
|
+
})(FilePreviewState || (FilePreviewState = {}));
|
9
|
+
export var FilePreviewVariant;
|
10
|
+
(function (FilePreviewVariant) {
|
11
|
+
FilePreviewVariant["HORIZONTAL"] = "horizontal";
|
12
|
+
FilePreviewVariant["VERTICAL"] = "vertical";
|
13
|
+
})(FilePreviewVariant || (FilePreviewVariant = {}));
|
14
|
+
export var FilePreviewErrorMessages;
|
15
|
+
(function (FilePreviewErrorMessages) {
|
16
|
+
FilePreviewErrorMessages["INVALID_FORMAT"] = "Invalid File Format. Please try again.";
|
17
|
+
FilePreviewErrorMessages["SIZE_LIMIT"] = "Size limit exceeded";
|
18
|
+
FilePreviewErrorMessages["FAILED_TO_LOAD"] = "Failed to load file from URL";
|
19
|
+
FilePreviewErrorMessages["UNKNOWN_FILE_NAME"] = "unknown-file";
|
20
|
+
})(FilePreviewErrorMessages || (FilePreviewErrorMessages = {}));
|
21
|
+
export var FilePreviewEvent;
|
22
|
+
(function (FilePreviewEvent) {
|
23
|
+
FilePreviewEvent["NILE_INIT"] = "nile-init";
|
24
|
+
FilePreviewEvent["NILE_RECEIVE"] = "nile-receive";
|
25
|
+
FilePreviewEvent["NILE_REMOVE"] = "nile-remove";
|
26
|
+
FilePreviewEvent["NILE_DESTROY"] = "nile-destroy";
|
27
|
+
})(FilePreviewEvent || (FilePreviewEvent = {}));
|
28
|
+
//# sourceMappingURL=file-preview.enums.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"file-preview.enums.js","sourceRoot":"","sources":["../../../../src/nile-file-preview/types/file-preview.enums.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,gBAMX;AAND,WAAY,gBAAgB;IAC1B,uCAAmB,CAAA;IACnB,2CAAuB,CAAA;IACvB,uCAAmB,CAAA;IACnB,6CAAyB,CAAA;IACzB,mCAAe,CAAA;AACjB,CAAC,EANW,gBAAgB,KAAhB,gBAAgB,QAM3B;AAED,MAAM,CAAN,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC5B,+CAAyB,CAAA;IACzB,2CAAqB,CAAA;AACvB,CAAC,EAHW,kBAAkB,KAAlB,kBAAkB,QAG7B;AAED,MAAM,CAAN,IAAY,wBAKX;AALD,WAAY,wBAAwB;IAClC,qFAAyD,CAAA;IACzD,8DAAkC,CAAA;IAClC,2EAA+C,CAAA;IAC/C,8DAAkC,CAAA;AACpC,CAAC,EALW,wBAAwB,KAAxB,wBAAwB,QAKnC;AAED,MAAM,CAAN,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC1B,2CAAuB,CAAA;IACvB,iDAA6B,CAAA;IAC7B,+CAA2B,CAAA;IAC3B,iDAA6B,CAAA;AAC/B,CAAC,EALW,gBAAgB,KAAhB,gBAAgB,QAK3B","sourcesContent":["export enum FilePreviewState {\n DEFAULT = 'default',\n UPLOADING = 'uploading',\n PREVIEW = 'preview',\n NO_PREVIEW = 'no-preview',\n ERROR = 'error'\n}\n\nexport enum FilePreviewVariant {\n HORIZONTAL = 'horizontal',\n VERTICAL = 'vertical'\n}\n\nexport enum FilePreviewErrorMessages {\n INVALID_FORMAT = \"Invalid File Format. Please try again.\",\n SIZE_LIMIT = \"Size limit exceeded\",\n FAILED_TO_LOAD = \"Failed to load file from URL\",\n UNKNOWN_FILE_NAME = 'unknown-file'\n}\n\nexport enum FilePreviewEvent {\n NILE_INIT = \"nile-init\",\n NILE_RECEIVE = \"nile-receive\",\n NILE_REMOVE = \"nile-remove\",\n NILE_DESTROY = \"nile-destroy\"\n}"]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"file-preview.interface.js","sourceRoot":"","sources":["../../../../src/nile-file-preview/types/file-preview.interface.ts"],"names":[],"mappings":"","sourcesContent":["export type RemoveFileDetail = {\n value: File;\n url: string;\n};\n"]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/nile-file-preview/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC","sourcesContent":["export * from './file-preview.enums';\nexport * from './file-preview.interface';"]}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { FilePreviewEvent } from "../types";
|
2
|
+
export const generatePreviewUrl = (file) => {
|
3
|
+
return new Promise((resolve, reject) => {
|
4
|
+
const reader = new FileReader();
|
5
|
+
if (file) {
|
6
|
+
reader.readAsDataURL(file);
|
7
|
+
}
|
8
|
+
else {
|
9
|
+
reject('No file selected');
|
10
|
+
}
|
11
|
+
reader.onload = () => {
|
12
|
+
const previewUrl = reader.result;
|
13
|
+
resolve(previewUrl);
|
14
|
+
};
|
15
|
+
reader.onerror = (error) => {
|
16
|
+
reject("Unable to generate the url");
|
17
|
+
};
|
18
|
+
});
|
19
|
+
};
|
20
|
+
export const removeFile = (removeFile, e, originalUrl) => {
|
21
|
+
if (e.target) {
|
22
|
+
e.target.dispatchEvent(new CustomEvent(FilePreviewEvent.NILE_REMOVE, {
|
23
|
+
detail: { value: removeFile, url: originalUrl },
|
24
|
+
bubbles: true,
|
25
|
+
composed: true,
|
26
|
+
}));
|
27
|
+
}
|
28
|
+
};
|
29
|
+
//# sourceMappingURL=file-preview.util.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"file-preview.util.js","sourceRoot":"","sources":["../../../../src/nile-file-preview/utils/file-preview.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE9D,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,kBAAkB,CAAC,CAAC;QAC7B,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,4BAA4B,CAAC,CAAC;QACvC,CAAC,CAAA;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,UAAgB,EAAE,CAAgC,EAAE,WAAmB,EAAQ,EAAE;IAC1G,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;QACb,CAAC,CAAC,MAAM,CAAC,aAAa,CACpB,IAAI,WAAW,CAAC,gBAAgB,CAAC,WAAW,EAAE;YAC5C,MAAM,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,WAAW,EAAE;YAC/C,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;SACf,CAAC,CACH,CAAC;IACJ,CAAC;AACH,CAAC,CAAC","sourcesContent":["import { RemoveFileDetail, FilePreviewEvent } 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('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(\"Unable to generate the 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};"]}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './file-preview.util';
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/nile-file-preview/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA","sourcesContent":["export * from './file-preview.util'"]}
|
@@ -0,0 +1 @@
|
|
1
|
+
export { NileFileUpload } from './nile-file-upload';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/nile-
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/nile-file-upload/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC","sourcesContent":["export { NileFileUpload } from './nile-file-upload';\n"]}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright Aquera Inc 2023
|
3
|
+
*
|
4
|
+
* This source code is licensed under the BSD-3-Clause license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*/
|
7
|
+
/**
|
8
|
+
* FileUpload CSS
|
9
|
+
*/
|
10
|
+
export declare const styles: import("lit").CSSResult;
|
11
|
+
declare const _default: import("lit").CSSResult[];
|
12
|
+
export default _default;
|