@politiet/sheriff-web-components 2.13.1 → 2.14.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.
- package/custom-elements.json +3949 -1463
- package/dist/controllers/index.d.ts +3 -0
- package/dist/controllers/index.d.ts.map +1 -0
- package/dist/controllers/index.js +3 -0
- package/dist/controllers/index.js.map +1 -0
- package/dist/controllers/sds-drag-drop-controller.d.ts +25 -0
- package/dist/controllers/sds-drag-drop-controller.d.ts.map +1 -0
- package/dist/controllers/sds-drag-drop-controller.js +52 -0
- package/dist/controllers/sds-drag-drop-controller.js.map +1 -0
- package/dist/controllers/sds-file-preview-controller.d.ts +38 -0
- package/dist/controllers/sds-file-preview-controller.d.ts.map +1 -0
- package/dist/controllers/sds-file-preview-controller.js +90 -0
- package/dist/controllers/sds-file-preview-controller.js.map +1 -0
- package/dist/frameworks/preact.d.ts +14 -1
- package/dist/frameworks/preact.d.ts.map +1 -1
- package/dist/frameworks/react.d.ts +30 -1
- package/dist/frameworks/react.d.ts.map +1 -1
- package/dist/frameworks/solidjs.d.ts +4 -0
- package/dist/frameworks/solidjs.d.ts.map +1 -1
- package/dist/frameworks/svelte.d.ts +4 -0
- package/dist/frameworks/svelte.d.ts.map +1 -1
- package/dist/frameworks/vue.d.ts +24 -1
- package/dist/frameworks/vue.d.ts.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/react-wrappers/SDSDialogWrapper.d.ts +1 -0
- package/dist/react-wrappers/SDSDialogWrapper.d.ts.map +1 -1
- package/dist/react-wrappers/SDSDialogWrapper.js +1 -0
- package/dist/react-wrappers/SDSDialogWrapper.js.map +1 -1
- package/dist/react-wrappers/SDSFileUploadFileListWrapper.d.ts +3 -0
- package/dist/react-wrappers/SDSFileUploadFileListWrapper.d.ts.map +1 -0
- package/dist/react-wrappers/SDSFileUploadFileListWrapper.js +10 -0
- package/dist/react-wrappers/SDSFileUploadFileListWrapper.js.map +1 -0
- package/dist/react-wrappers/SDSFileUploadItemWrapper.d.ts +6 -0
- package/dist/react-wrappers/SDSFileUploadItemWrapper.d.ts.map +1 -0
- package/dist/react-wrappers/SDSFileUploadItemWrapper.js +12 -0
- package/dist/react-wrappers/SDSFileUploadItemWrapper.js.map +1 -0
- package/dist/react-wrappers/SDSFileUploadWrapper.d.ts +12 -0
- package/dist/react-wrappers/SDSFileUploadWrapper.d.ts.map +1 -0
- package/dist/react-wrappers/SDSFileUploadWrapper.js +18 -0
- package/dist/react-wrappers/SDSFileUploadWrapper.js.map +1 -0
- package/dist/react-wrappers/SDSSearchWrapper.d.ts +15 -0
- package/dist/react-wrappers/SDSSearchWrapper.d.ts.map +1 -0
- package/dist/react-wrappers/SDSSearchWrapper.js +19 -0
- package/dist/react-wrappers/SDSSearchWrapper.js.map +1 -0
- package/dist/react-wrappers/index.d.ts +4 -0
- package/dist/react-wrappers/index.d.ts.map +1 -1
- package/dist/react-wrappers/index.js +4 -0
- package/dist/react-wrappers/index.js.map +1 -1
- package/dist/sds-button/sds-button.component.d.ts +0 -1
- package/dist/sds-button/sds-button.component.d.ts.map +1 -1
- package/dist/sds-button/sds-button.component.js +10 -16
- package/dist/sds-button/sds-button.component.js.map +1 -1
- package/dist/sds-dialog/sds-dialog.component.d.ts.map +1 -1
- package/dist/sds-dialog/sds-dialog.component.js +11 -1
- package/dist/sds-dialog/sds-dialog.component.js.map +1 -1
- package/dist/sds-file-upload/sds-file-upload.d.ts +102 -0
- package/dist/sds-file-upload/sds-file-upload.d.ts.map +1 -0
- package/dist/sds-file-upload/sds-file-upload.js +384 -0
- package/dist/sds-file-upload/sds-file-upload.js.map +1 -0
- package/dist/sds-file-upload/sds-file-upload.styles.d.ts +2 -0
- package/dist/sds-file-upload/sds-file-upload.styles.d.ts.map +1 -0
- package/dist/sds-file-upload/sds-file-upload.styles.js +234 -0
- package/dist/sds-file-upload/sds-file-upload.styles.js.map +1 -0
- package/dist/sds-file-upload-file-list/sds-file-upload-file-list.d.ts +14 -0
- package/dist/sds-file-upload-file-list/sds-file-upload-file-list.d.ts.map +1 -0
- package/dist/sds-file-upload-file-list/sds-file-upload-file-list.js +26 -0
- package/dist/sds-file-upload-file-list/sds-file-upload-file-list.js.map +1 -0
- package/dist/sds-file-upload-file-list/sds-file-upload-file-list.styles.d.ts +2 -0
- package/dist/sds-file-upload-file-list/sds-file-upload-file-list.styles.d.ts.map +1 -0
- package/dist/sds-file-upload-file-list/sds-file-upload-file-list.styles.js +19 -0
- package/dist/sds-file-upload-file-list/sds-file-upload-file-list.styles.js.map +1 -0
- package/dist/sds-file-upload-item/assets/u-progress.js +2 -0
- package/dist/sds-file-upload-item/sds-file-upload-item.d.ts +62 -0
- package/dist/sds-file-upload-item/sds-file-upload-item.d.ts.map +1 -0
- package/dist/sds-file-upload-item/sds-file-upload-item.js +205 -0
- package/dist/sds-file-upload-item/sds-file-upload-item.js.map +1 -0
- package/dist/sds-file-upload-item/sds-file-upload-item.styles.d.ts +2 -0
- package/dist/sds-file-upload-item/sds-file-upload-item.styles.d.ts.map +1 -0
- package/dist/sds-file-upload-item/sds-file-upload-item.styles.js +227 -0
- package/dist/sds-file-upload-item/sds-file-upload-item.styles.js.map +1 -0
- package/dist/sds-search/sds-search.component.d.ts +128 -0
- package/dist/sds-search/sds-search.component.d.ts.map +1 -0
- package/dist/sds-search/sds-search.component.js +345 -0
- package/dist/sds-search/sds-search.component.js.map +1 -0
- package/dist/sds-search/sds-search.d.ts +13 -0
- package/dist/sds-search/sds-search.d.ts.map +1 -0
- package/dist/sds-search/sds-search.js +18 -0
- package/dist/sds-search/sds-search.js.map +1 -0
- package/dist/sds-search/sds-search.styles.d.ts +2 -0
- package/dist/sds-search/sds-search.styles.d.ts.map +1 -0
- package/dist/sds-search/sds-search.styles.js +74 -0
- package/dist/sds-search/sds-search.styles.js.map +1 -0
- package/dist/sds-textfield/sds-textfield.component.d.ts +4 -1
- package/dist/sds-textfield/sds-textfield.component.d.ts.map +1 -1
- package/dist/sds-textfield/sds-textfield.component.js +20 -5
- package/dist/sds-textfield/sds-textfield.component.js.map +1 -1
- package/dist/sds-textfield/sds-textfield.styles.d.ts.map +1 -1
- package/dist/sds-textfield/sds-textfield.styles.js +11 -0
- package/dist/sds-textfield/sds-textfield.styles.js.map +1 -1
- package/dist/sheriff-web-components.js +1015 -294
- package/dist/skill/SKILL.md +44 -36
- package/dist/skill/references/components.md +88 -3
- package/dist/skill/references/react-wrappers.md +25 -18
- package/dist/utils/file-validation.d.ts +31 -0
- package/dist/utils/file-validation.d.ts.map +1 -0
- package/dist/utils/file-validation.js +57 -0
- package/dist/utils/file-validation.js.map +1 -0
- package/dist/utils/format-bytes.d.ts +6 -0
- package/dist/utils/format-bytes.d.ts.map +1 -0
- package/dist/utils/format-bytes.js +13 -0
- package/dist/utils/format-bytes.js.map +1 -0
- package/dist/utils/video-thumbnail.d.ts +8 -0
- package/dist/utils/video-thumbnail.d.ts.map +1 -0
- package/dist/utils/video-thumbnail.js +77 -0
- package/dist/utils/video-thumbnail.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +24 -4
- package/web-types.json +3431 -1120
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { type PropertyValues } from 'lit';
|
|
2
|
+
import { SDSElement } from '../utils/sds-element';
|
|
3
|
+
import { type SDSRejectedFile } from '../utils/file-validation';
|
|
4
|
+
import { type SDSFormControlAttributes } from '../mixins/sds-form-control-mixin';
|
|
5
|
+
import { SDS_SIZES } from '../types';
|
|
6
|
+
import '../sds-button/sds-button';
|
|
7
|
+
import '../sds-icon/sds-icon';
|
|
8
|
+
import '../sds-alert/sds-alert';
|
|
9
|
+
import '../sds-file-upload-item/sds-file-upload-item';
|
|
10
|
+
import '../sds-file-upload-file-list/sds-file-upload-file-list';
|
|
11
|
+
export type { SDSRejectedFile };
|
|
12
|
+
export type SDSFileUploadVariant = 'default' | 'compact';
|
|
13
|
+
export type SDSFileUploadSize = Extract<SDS_SIZES, 'lg' | 'md' | 'sm'>;
|
|
14
|
+
export interface SDSFileUploadProps extends Omit<SDSFormControlAttributes, 'readonly'> {
|
|
15
|
+
accept?: string;
|
|
16
|
+
label?: string;
|
|
17
|
+
multiple?: boolean;
|
|
18
|
+
required?: boolean;
|
|
19
|
+
'max-size-in-bytes'?: number;
|
|
20
|
+
'help-text'?: string;
|
|
21
|
+
'error-message'?: string;
|
|
22
|
+
'file-limitation-text'?: string;
|
|
23
|
+
'hide-file-list'?: boolean;
|
|
24
|
+
variant?: SDSFileUploadVariant;
|
|
25
|
+
size?: SDSFileUploadSize;
|
|
26
|
+
}
|
|
27
|
+
declare const SDSFileUpload_base: import("../mixins/types").Constructable<import("../mixins/sds-delegate-interaction-mixin").DelegateInteractionMixinInterface> & import("../mixins/types").Constructable<import("../mixins/sds-event-dispatcher-mixin").SDSEventDispatcherMixinInterface> & import("../mixins/types").Constructable<import("../mixins/sds-form-control-mixin").SDSFormControlMixinInterface> & typeof SDSElement;
|
|
28
|
+
export declare class SDSFileUpload extends SDSFileUpload_base {
|
|
29
|
+
static styles: import("lit").CSSResult[];
|
|
30
|
+
accept?: string;
|
|
31
|
+
label?: string;
|
|
32
|
+
multiple: boolean;
|
|
33
|
+
required: boolean;
|
|
34
|
+
maxSizeInBytes?: number;
|
|
35
|
+
helpText?: string;
|
|
36
|
+
errorMessage?: string;
|
|
37
|
+
fileLimitationText?: string;
|
|
38
|
+
variant: SDSFileUploadVariant;
|
|
39
|
+
size: SDSFileUploadSize;
|
|
40
|
+
hideFileList: boolean;
|
|
41
|
+
control: HTMLInputElement;
|
|
42
|
+
private _files;
|
|
43
|
+
private _rejectedFiles;
|
|
44
|
+
private _hasSlottedLabel;
|
|
45
|
+
private readonly _previews;
|
|
46
|
+
private readonly _dragDrop;
|
|
47
|
+
get files(): File[];
|
|
48
|
+
get rejectedFiles(): SDSRejectedFile[];
|
|
49
|
+
get value(): string;
|
|
50
|
+
set value(newValue: string);
|
|
51
|
+
removeFile(file: File): void;
|
|
52
|
+
clear(): void;
|
|
53
|
+
dismissRejected(file: File): void;
|
|
54
|
+
getPreviewUrl(file: File): string | undefined;
|
|
55
|
+
focus(options?: FocusOptions): void;
|
|
56
|
+
blur(): void;
|
|
57
|
+
checkValidity(): boolean;
|
|
58
|
+
reportValidity(): boolean;
|
|
59
|
+
setCustomValidity(message: string): void;
|
|
60
|
+
connectedCallback(): void;
|
|
61
|
+
formResetCallback(): void;
|
|
62
|
+
protected updated(changed: PropertyValues): void;
|
|
63
|
+
updateValidity(): void;
|
|
64
|
+
private _reset;
|
|
65
|
+
get type(): string;
|
|
66
|
+
private readonly _handleInputChange;
|
|
67
|
+
private readonly _handleNativeInput;
|
|
68
|
+
private readonly _handleInputCancel;
|
|
69
|
+
private readonly _handleItemRemove;
|
|
70
|
+
private readonly _handleLabelSlotChange;
|
|
71
|
+
private readonly _handleFocus;
|
|
72
|
+
private readonly _handleBlur;
|
|
73
|
+
private get _showLabel();
|
|
74
|
+
private get _triggerText();
|
|
75
|
+
private _processFiles;
|
|
76
|
+
private _builtInItems;
|
|
77
|
+
private _isSameSelection;
|
|
78
|
+
private _syncSelection;
|
|
79
|
+
private _commitSelection;
|
|
80
|
+
private _syncNativeInput;
|
|
81
|
+
private _updateFormValue;
|
|
82
|
+
private readonly _renderItem;
|
|
83
|
+
private readonly _renderFileList;
|
|
84
|
+
private readonly _renderInput;
|
|
85
|
+
private readonly _renderDropzone;
|
|
86
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
87
|
+
}
|
|
88
|
+
declare global {
|
|
89
|
+
interface HTMLElementTagNameMap {
|
|
90
|
+
'sds-file-upload': SDSFileUpload;
|
|
91
|
+
}
|
|
92
|
+
interface GlobalEventHandlersEventMap {
|
|
93
|
+
'sds-reject': CustomEvent<{
|
|
94
|
+
rejected: SDSRejectedFile[];
|
|
95
|
+
}>;
|
|
96
|
+
'sds-preview-ready': CustomEvent<{
|
|
97
|
+
file: File;
|
|
98
|
+
url: string;
|
|
99
|
+
}>;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=sds-file-upload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sds-file-upload.d.ts","sourceRoot":"","sources":["../../src/sds-file-upload/sds-file-upload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAKzD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAA8B,KAAK,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC5F,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAGjF,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,OAAO,0BAA0B,CAAC;AAClC,OAAO,sBAAsB,CAAC;AAC9B,OAAO,wBAAwB,CAAC;AAChC,OAAO,8CAA8C,CAAC;AAEtD,OAAO,wDAAwD,CAAC;AAEhE,YAAY,EAAE,eAAe,EAAE,CAAC;AAEhC,MAAM,MAAM,oBAAoB,GAAG,SAAS,GAAG,SAAS,CAAC;AACzD,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,SAAS,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC;AAEvE,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,wBAAwB,EAAE,UAAU,CAAC;IACrF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IA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E,IAAI,EAAE,IAAI,CAAC;YAAC,GAAG,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KAC9D;CACD"}
|
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { html, nothing } from 'lit';
|
|
8
|
+
import { property, query, state } from 'lit/decorators.js';
|
|
9
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
10
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
11
|
+
import { guardedCustomElement } from '../utils/guarded-custom-element';
|
|
12
|
+
import { SDSElement } from '../utils/sds-element';
|
|
13
|
+
import { isSameFile, partitionFiles } from '../utils/file-validation';
|
|
14
|
+
import { SDSEventDispatcherMixin, SDSDelegateInteractionMixin, SDSFormControlMixin } from '../mixins';
|
|
15
|
+
import { SDSDragDropController, SDSFilePreviewController } from '../controllers';
|
|
16
|
+
import { styles } from './sds-file-upload.styles';
|
|
17
|
+
import '../sds-button/sds-button';
|
|
18
|
+
import '../sds-icon/sds-icon';
|
|
19
|
+
import '../sds-alert/sds-alert';
|
|
20
|
+
import '../sds-file-upload-item/sds-file-upload-item';
|
|
21
|
+
import '../sds-file-upload-file-list/sds-file-upload-file-list';
|
|
22
|
+
let SDSFileUpload = class SDSFileUpload extends SDSDelegateInteractionMixin(SDSEventDispatcherMixin(SDSFormControlMixin(SDSElement))) {
|
|
23
|
+
constructor() {
|
|
24
|
+
super(...arguments);
|
|
25
|
+
this.multiple = false;
|
|
26
|
+
this.required = false;
|
|
27
|
+
this.variant = 'default';
|
|
28
|
+
this.size = 'md';
|
|
29
|
+
this.hideFileList = false;
|
|
30
|
+
// Internal state
|
|
31
|
+
this._files = [];
|
|
32
|
+
this._rejectedFiles = [];
|
|
33
|
+
this._hasSlottedLabel = false;
|
|
34
|
+
// Controllers
|
|
35
|
+
this._previews = new SDSFilePreviewController(this, (file, url) => this.dispatchSheriffEvent('sds-preview-ready', { file, url }));
|
|
36
|
+
this._dragDrop = new SDSDragDropController(this, (files) => this._processFiles(files), () => Boolean(this.disabled));
|
|
37
|
+
// Event handlers
|
|
38
|
+
this._handleInputChange = (event) => {
|
|
39
|
+
event.stopImmediatePropagation();
|
|
40
|
+
const input = event.target;
|
|
41
|
+
this._processFiles(Array.from(input.files ?? []));
|
|
42
|
+
};
|
|
43
|
+
this._handleNativeInput = (event) => {
|
|
44
|
+
event.stopImmediatePropagation();
|
|
45
|
+
};
|
|
46
|
+
this._handleInputCancel = (event) => {
|
|
47
|
+
event.stopImmediatePropagation();
|
|
48
|
+
this.dispatchSheriffEvent('cancel', undefined, false);
|
|
49
|
+
};
|
|
50
|
+
this._handleItemRemove = async (event, file, rejection) => {
|
|
51
|
+
const index = this._builtInItems().indexOf(event.currentTarget);
|
|
52
|
+
if (rejection)
|
|
53
|
+
this.dismissRejected(file);
|
|
54
|
+
else
|
|
55
|
+
this.removeFile(file);
|
|
56
|
+
await this.updateComplete;
|
|
57
|
+
const remaining = this._builtInItems();
|
|
58
|
+
(remaining[index] ?? remaining[index - 1] ?? this).focus();
|
|
59
|
+
};
|
|
60
|
+
this._handleLabelSlotChange = (event) => {
|
|
61
|
+
this._hasSlottedLabel = event.target.assignedNodes().length > 0;
|
|
62
|
+
};
|
|
63
|
+
this._handleFocus = (event) => {
|
|
64
|
+
event.stopImmediatePropagation();
|
|
65
|
+
this.dispatchSheriffEvent('focus');
|
|
66
|
+
};
|
|
67
|
+
this._handleBlur = (event) => {
|
|
68
|
+
event.stopImmediatePropagation();
|
|
69
|
+
this.dispatchSheriffEvent('blur');
|
|
70
|
+
};
|
|
71
|
+
// Rendering
|
|
72
|
+
this._renderItem = (file, rejection) => html `
|
|
73
|
+
<sds-file-upload-item
|
|
74
|
+
file="${file.name}"
|
|
75
|
+
size-in-bytes="${file.size}"
|
|
76
|
+
preview="${ifDefined(rejection ? undefined : this._previews.get(file))}"
|
|
77
|
+
error-message="${ifDefined(rejection?.reason)}"
|
|
78
|
+
?disabled="${!rejection && this.disabled}"
|
|
79
|
+
@sds-remove="${(event) => this._handleItemRemove(event, file, rejection)}"
|
|
80
|
+
></sds-file-upload-item>
|
|
81
|
+
`;
|
|
82
|
+
this._renderFileList = () => html `
|
|
83
|
+
<sds-file-upload-file-list aria-label="Valgte filer" aria-live="polite">
|
|
84
|
+
${this._files.map((file) => this._renderItem(file))}
|
|
85
|
+
${this._rejectedFiles.map((rejected) => this._renderItem(rejected.file, rejected))}
|
|
86
|
+
</sds-file-upload-file-list>
|
|
87
|
+
`;
|
|
88
|
+
this._renderInput = () => {
|
|
89
|
+
const describedBy = [this.errorMessage ? 'error-message' : null, this.helpText ? 'help-text' : null, this.fileLimitationText ? 'file-limitation-text' : null]
|
|
90
|
+
.filter(Boolean)
|
|
91
|
+
.join(' ') || undefined;
|
|
92
|
+
return html `
|
|
93
|
+
<input
|
|
94
|
+
id="control"
|
|
95
|
+
class="sds-file-upload__input"
|
|
96
|
+
type="file"
|
|
97
|
+
accept="${ifDefined(this.accept)}"
|
|
98
|
+
name="${ifDefined(this.name)}"
|
|
99
|
+
?multiple="${this.multiple}"
|
|
100
|
+
?required="${this.required}"
|
|
101
|
+
?disabled="${this.disabled}"
|
|
102
|
+
aria-label="${ifDefined(this._showLabel ? undefined : this._triggerText)}"
|
|
103
|
+
aria-describedby="${ifDefined(describedBy)}"
|
|
104
|
+
aria-invalid="${this.errorMessage ? 'true' : 'false'}"
|
|
105
|
+
@input="${this._handleNativeInput}"
|
|
106
|
+
@change="${this._handleInputChange}"
|
|
107
|
+
@cancel="${this._handleInputCancel}"
|
|
108
|
+
@focus="${this._handleFocus}"
|
|
109
|
+
@blur="${this._handleBlur}"
|
|
110
|
+
/>
|
|
111
|
+
`;
|
|
112
|
+
};
|
|
113
|
+
this._renderDropzone = () => {
|
|
114
|
+
const dropzoneClasses = {
|
|
115
|
+
'sds-file-upload__dropzone': true,
|
|
116
|
+
'sds-file-upload__dropzone--dragging': this._dragDrop.dragging,
|
|
117
|
+
'sds-file-upload__dropzone--error': Boolean(this.errorMessage),
|
|
118
|
+
};
|
|
119
|
+
const iconSize = this.variant === 'compact' ? this.size : 'lg';
|
|
120
|
+
return html `
|
|
121
|
+
<div
|
|
122
|
+
class="${classMap(dropzoneClasses)}"
|
|
123
|
+
@dragover="${this._dragDrop.handleDragOver}"
|
|
124
|
+
@dragleave="${this._dragDrop.handleDragLeave}"
|
|
125
|
+
@drop="${this._dragDrop.handleDrop}"
|
|
126
|
+
>
|
|
127
|
+
${this._renderInput()}
|
|
128
|
+
<sds-icon name="upload-material-outlined" size="${iconSize}"></sds-icon>
|
|
129
|
+
<p class="sds-file-upload__drop-text" aria-hidden="true">${this.multiple ? 'Dra og slipp filene her eller' : 'Dra og slipp filen her eller'}</p>
|
|
130
|
+
<sds-button
|
|
131
|
+
class="sds-file-upload__trigger"
|
|
132
|
+
variant="secondary"
|
|
133
|
+
size="${this.variant === 'compact' ? 'sm' : this.size}"
|
|
134
|
+
type="button"
|
|
135
|
+
?disabled="${this.disabled}"
|
|
136
|
+
inert
|
|
137
|
+
>
|
|
138
|
+
<span class="sds-file-upload__button-label">${this._triggerText}</span>
|
|
139
|
+
</sds-button>
|
|
140
|
+
<div class="sds-file-upload__drop-hint" aria-hidden="true">
|
|
141
|
+
<sds-icon name="upload-material-outlined" size="${iconSize}"></sds-icon>
|
|
142
|
+
<span class="sds-file-upload__drop-hint-text">Slipp fil</span>
|
|
143
|
+
</div>
|
|
144
|
+
</div>
|
|
145
|
+
`;
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
// Public API
|
|
149
|
+
get files() {
|
|
150
|
+
return this._files;
|
|
151
|
+
}
|
|
152
|
+
get rejectedFiles() {
|
|
153
|
+
return this._rejectedFiles;
|
|
154
|
+
}
|
|
155
|
+
get value() {
|
|
156
|
+
return this._files[0] ? `C:\\fakepath\\${this._files[0].name}` : '';
|
|
157
|
+
}
|
|
158
|
+
set value(newValue) {
|
|
159
|
+
if (newValue !== '') {
|
|
160
|
+
throw new DOMException('Failed to set the \'value\' property on sds-file-upload: only the empty string may be assigned.', 'InvalidStateError');
|
|
161
|
+
}
|
|
162
|
+
this._reset();
|
|
163
|
+
}
|
|
164
|
+
removeFile(file) {
|
|
165
|
+
const previous = this._files;
|
|
166
|
+
this._files = previous.filter((existing) => !isSameFile(existing, file));
|
|
167
|
+
this._commitSelection(previous);
|
|
168
|
+
}
|
|
169
|
+
clear() {
|
|
170
|
+
const previous = this._files;
|
|
171
|
+
this._files = [];
|
|
172
|
+
this._rejectedFiles = [];
|
|
173
|
+
this._commitSelection(previous);
|
|
174
|
+
}
|
|
175
|
+
dismissRejected(file) {
|
|
176
|
+
this._rejectedFiles = this._rejectedFiles.filter((rejected) => !isSameFile(rejected.file, file));
|
|
177
|
+
}
|
|
178
|
+
getPreviewUrl(file) {
|
|
179
|
+
return this._previews.get(file);
|
|
180
|
+
}
|
|
181
|
+
focus(options) {
|
|
182
|
+
if (!this.disabled)
|
|
183
|
+
this.control?.focus(options);
|
|
184
|
+
}
|
|
185
|
+
blur() {
|
|
186
|
+
if (!this.disabled)
|
|
187
|
+
this.control?.blur();
|
|
188
|
+
}
|
|
189
|
+
checkValidity() {
|
|
190
|
+
return this.internals.checkValidity();
|
|
191
|
+
}
|
|
192
|
+
reportValidity() {
|
|
193
|
+
return this.internals.reportValidity();
|
|
194
|
+
}
|
|
195
|
+
setCustomValidity(message) {
|
|
196
|
+
this.errorMessage = message || undefined;
|
|
197
|
+
this.updateValidity();
|
|
198
|
+
}
|
|
199
|
+
// Lifecycle
|
|
200
|
+
connectedCallback() {
|
|
201
|
+
super.connectedCallback();
|
|
202
|
+
this._updateFormValue();
|
|
203
|
+
}
|
|
204
|
+
formResetCallback() {
|
|
205
|
+
this._reset();
|
|
206
|
+
}
|
|
207
|
+
updated(changed) {
|
|
208
|
+
super.updated(changed);
|
|
209
|
+
if (changed.has('required') || changed.has('errorMessage') || changed.has('disabled'))
|
|
210
|
+
this.updateValidity();
|
|
211
|
+
if (changed.has('name'))
|
|
212
|
+
this._updateFormValue();
|
|
213
|
+
}
|
|
214
|
+
// Validity
|
|
215
|
+
updateValidity() {
|
|
216
|
+
if (!this.control)
|
|
217
|
+
return;
|
|
218
|
+
if (this.disabled) {
|
|
219
|
+
this.internals.setValidity({});
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
if (this.errorMessage) {
|
|
223
|
+
this.internals.setValidity({ customError: true }, this.errorMessage, this.control);
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
if (this.required && this._files.length === 0) {
|
|
227
|
+
const message = this.control.validationMessage;
|
|
228
|
+
if (!message)
|
|
229
|
+
return;
|
|
230
|
+
this.internals.setValidity({ valueMissing: true }, message, this.control);
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
this.internals.setValidity({});
|
|
234
|
+
}
|
|
235
|
+
_reset() {
|
|
236
|
+
this._files = [];
|
|
237
|
+
this._rejectedFiles = [];
|
|
238
|
+
if (this.control)
|
|
239
|
+
this.control.value = '';
|
|
240
|
+
this._previews.sync(this._files);
|
|
241
|
+
this._updateFormValue();
|
|
242
|
+
this.updateValidity();
|
|
243
|
+
}
|
|
244
|
+
get type() {
|
|
245
|
+
return 'file';
|
|
246
|
+
}
|
|
247
|
+
// Internal helpers
|
|
248
|
+
get _showLabel() {
|
|
249
|
+
return this._hasSlottedLabel || Boolean(this.label);
|
|
250
|
+
}
|
|
251
|
+
get _triggerText() {
|
|
252
|
+
return this.multiple ? 'Velg filer' : 'Velg fil';
|
|
253
|
+
}
|
|
254
|
+
_processFiles(incoming) {
|
|
255
|
+
if (incoming.length === 0)
|
|
256
|
+
return;
|
|
257
|
+
const previous = this._files;
|
|
258
|
+
const { accepted, rejected } = partitionFiles(incoming, {
|
|
259
|
+
accept: this.accept,
|
|
260
|
+
maxSizeInBytes: this.maxSizeInBytes,
|
|
261
|
+
multiple: this.multiple,
|
|
262
|
+
});
|
|
263
|
+
this._files = accepted;
|
|
264
|
+
this._rejectedFiles = rejected;
|
|
265
|
+
this._commitSelection(previous);
|
|
266
|
+
if (rejected.length) {
|
|
267
|
+
this.dispatchSheriffEvent('sds-reject', { rejected });
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
_builtInItems() {
|
|
271
|
+
return Array.from(this.renderRoot.querySelectorAll('sds-file-upload-file-list > sds-file-upload-item'));
|
|
272
|
+
}
|
|
273
|
+
_isSameSelection(previous, next) {
|
|
274
|
+
if (previous.length !== next.length)
|
|
275
|
+
return false;
|
|
276
|
+
return previous.every((file, index) => {
|
|
277
|
+
const other = next[index];
|
|
278
|
+
return other !== undefined && isSameFile(file, other);
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
_syncSelection() {
|
|
282
|
+
this._previews.sync(this._files);
|
|
283
|
+
this._syncNativeInput();
|
|
284
|
+
this._updateFormValue();
|
|
285
|
+
this.updateValidity();
|
|
286
|
+
}
|
|
287
|
+
_commitSelection(previous) {
|
|
288
|
+
this._syncSelection();
|
|
289
|
+
if (this._isSameSelection(previous, this._files))
|
|
290
|
+
return;
|
|
291
|
+
this.dispatchSheriffEvent('input');
|
|
292
|
+
this.dispatchSheriffEvent('change');
|
|
293
|
+
}
|
|
294
|
+
_syncNativeInput() {
|
|
295
|
+
if (!this.control)
|
|
296
|
+
return;
|
|
297
|
+
const dataTransfer = new DataTransfer();
|
|
298
|
+
for (const file of this._files)
|
|
299
|
+
dataTransfer.items.add(file);
|
|
300
|
+
this.control.files = dataTransfer.files;
|
|
301
|
+
}
|
|
302
|
+
_updateFormValue() {
|
|
303
|
+
if (!this.name) {
|
|
304
|
+
this.internals.setFormValue(null);
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
const data = new FormData();
|
|
308
|
+
if (this._files.length === 0)
|
|
309
|
+
data.append(this.name, new File([], '', { type: 'application/octet-stream' }));
|
|
310
|
+
for (const file of this._files)
|
|
311
|
+
data.append(this.name, file, file.name);
|
|
312
|
+
this.internals.setFormValue(data);
|
|
313
|
+
}
|
|
314
|
+
render() {
|
|
315
|
+
return html `
|
|
316
|
+
<div class="sds-file-upload">
|
|
317
|
+
<label for="control" class="sds-file-upload__label" ?hidden="${!this._showLabel}">
|
|
318
|
+
<slot name="label" @slotchange="${this._handleLabelSlotChange}">${this.label}</slot>
|
|
319
|
+
</label>
|
|
320
|
+
${this.helpText ? html `<p id="help-text" class="sds-file-upload__help-text">${this.helpText}</p>` : nothing}
|
|
321
|
+
|
|
322
|
+
${this._renderDropzone()}
|
|
323
|
+
|
|
324
|
+
${this.fileLimitationText ? html `<p id="file-limitation-text" class="sds-file-upload__file-limitation-text">${this.fileLimitationText}</p>` : nothing}
|
|
325
|
+
</div>
|
|
326
|
+
${this.errorMessage
|
|
327
|
+
? html `<sds-alert class="sds-file-upload__error-message" id="error-message" variant="secondary" data-palette="danger"><p slot="message">${this.errorMessage}</p></sds-alert>`
|
|
328
|
+
: nothing}
|
|
329
|
+
${this.hideFileList ? nothing : this._renderFileList()}
|
|
330
|
+
`;
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
// Styling
|
|
334
|
+
SDSFileUpload.styles = [styles];
|
|
335
|
+
__decorate([
|
|
336
|
+
property({ type: String, reflect: true })
|
|
337
|
+
], SDSFileUpload.prototype, "accept", void 0);
|
|
338
|
+
__decorate([
|
|
339
|
+
property({ type: String, reflect: true })
|
|
340
|
+
], SDSFileUpload.prototype, "label", void 0);
|
|
341
|
+
__decorate([
|
|
342
|
+
property({ type: Boolean, reflect: true })
|
|
343
|
+
], SDSFileUpload.prototype, "multiple", void 0);
|
|
344
|
+
__decorate([
|
|
345
|
+
property({ type: Boolean, reflect: true })
|
|
346
|
+
], SDSFileUpload.prototype, "required", void 0);
|
|
347
|
+
__decorate([
|
|
348
|
+
property({ type: Number, attribute: 'max-size-in-bytes', reflect: true })
|
|
349
|
+
], SDSFileUpload.prototype, "maxSizeInBytes", void 0);
|
|
350
|
+
__decorate([
|
|
351
|
+
property({ type: String, attribute: 'help-text', reflect: true })
|
|
352
|
+
], SDSFileUpload.prototype, "helpText", void 0);
|
|
353
|
+
__decorate([
|
|
354
|
+
property({ type: String, attribute: 'error-message', reflect: true })
|
|
355
|
+
], SDSFileUpload.prototype, "errorMessage", void 0);
|
|
356
|
+
__decorate([
|
|
357
|
+
property({ type: String, attribute: 'file-limitation-text', reflect: true })
|
|
358
|
+
], SDSFileUpload.prototype, "fileLimitationText", void 0);
|
|
359
|
+
__decorate([
|
|
360
|
+
property({ type: String, reflect: true })
|
|
361
|
+
], SDSFileUpload.prototype, "variant", void 0);
|
|
362
|
+
__decorate([
|
|
363
|
+
property({ type: String, reflect: true })
|
|
364
|
+
], SDSFileUpload.prototype, "size", void 0);
|
|
365
|
+
__decorate([
|
|
366
|
+
property({ type: Boolean, attribute: 'hide-file-list', reflect: true })
|
|
367
|
+
], SDSFileUpload.prototype, "hideFileList", void 0);
|
|
368
|
+
__decorate([
|
|
369
|
+
query('#control')
|
|
370
|
+
], SDSFileUpload.prototype, "control", void 0);
|
|
371
|
+
__decorate([
|
|
372
|
+
state()
|
|
373
|
+
], SDSFileUpload.prototype, "_files", void 0);
|
|
374
|
+
__decorate([
|
|
375
|
+
state()
|
|
376
|
+
], SDSFileUpload.prototype, "_rejectedFiles", void 0);
|
|
377
|
+
__decorate([
|
|
378
|
+
state()
|
|
379
|
+
], SDSFileUpload.prototype, "_hasSlottedLabel", void 0);
|
|
380
|
+
SDSFileUpload = __decorate([
|
|
381
|
+
guardedCustomElement('sds-file-upload')
|
|
382
|
+
], SDSFileUpload);
|
|
383
|
+
export { SDSFileUpload };
|
|
384
|
+
//# sourceMappingURL=sds-file-upload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sds-file-upload.js","sourceRoot":"","sources":["../../src/sds-file-upload/sds-file-upload.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAuB,MAAM,KAAK,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,cAAc,EAAwB,MAAM,0BAA0B,CAAC;AAE5F,OAAO,EAAE,uBAAuB,EAAE,2BAA2B,EAAG,mBAAmB,EAAC,MAAM,WAAW,CAAC;AACtG,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAEjF,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,0BAA0B,CAAC;AAClC,OAAO,sBAAsB,CAAC;AAC9B,OAAO,wBAAwB,CAAC;AAChC,OAAO,8CAA8C,CAAC;AAEtD,OAAO,wDAAwD,CAAC;AAsBzD,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,2BAA2B,CAAC,uBAAuB,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC,CAAC;IAAjH;;QASsC,aAAQ,GAAG,KAAK,CAAC;QACjB,aAAQ,GAAG,KAAK,CAAC;QAKlB,YAAO,GAAyB,SAAS,CAAC;QAC1C,SAAI,GAAsB,IAAI,CAAC;QACD,iBAAY,GAAG,KAAK,CAAC;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AAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,sBAAsB,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;yDAA6B;AAC/D;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8CAA2C;AAC1C;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CAAgC;AACD;IAAxE,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;mDAAsB;AAE3E;IAAlB,KAAK,CAAC,UAAU,CAAC;8CAA4B;AAG7B;IAAhB,KAAK,EAAE;6CAA6B;AACpB;IAAhB,KAAK,EAAE;qDAAgD;AACvC;IAAhB,KAAK,EAAE;uDAAkC;AAxB9B,aAAa;IADzB,oBAAoB,CAAC,iBAAiB,CAAC;GAC3B,aAAa,CA8WzB","sourcesContent":["import { html, nothing, type PropertyValues } from 'lit';\nimport { property, query, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { guardedCustomElement } from '../utils/guarded-custom-element';\nimport { SDSElement } from '../utils/sds-element';\nimport { isSameFile, partitionFiles, type SDSRejectedFile } from '../utils/file-validation';\nimport { type SDSFormControlAttributes } from '../mixins/sds-form-control-mixin';\nimport { SDSEventDispatcherMixin, SDSDelegateInteractionMixin, SDSFormControlMixin} from '../mixins';\nimport { SDSDragDropController, SDSFilePreviewController } from '../controllers';\nimport { SDS_SIZES } from '../types';\nimport { styles } from './sds-file-upload.styles';\nimport '../sds-button/sds-button';\nimport '../sds-icon/sds-icon';\nimport '../sds-alert/sds-alert';\nimport '../sds-file-upload-item/sds-file-upload-item';\nimport type { SDSFileUploadItem } from '../sds-file-upload-item/sds-file-upload-item';\nimport '../sds-file-upload-file-list/sds-file-upload-file-list';\n\nexport type { SDSRejectedFile };\n\nexport type SDSFileUploadVariant = 'default' | 'compact';\nexport type SDSFileUploadSize = Extract<SDS_SIZES, 'lg' | 'md' | 'sm'>;\n\nexport interface SDSFileUploadProps extends Omit<SDSFormControlAttributes, 'readonly'> {\n\taccept?: string;\n\tlabel?: string;\n\tmultiple?: boolean;\n\trequired?: boolean;\n\t'max-size-in-bytes'?: number;\n\t'help-text'?: string;\n\t'error-message'?: string;\n\t'file-limitation-text'?: string;\n\t'hide-file-list'?: boolean;\n\tvariant?: SDSFileUploadVariant;\n\tsize?: SDSFileUploadSize;\n}\n\n@guardedCustomElement('sds-file-upload')\nexport class SDSFileUpload extends SDSDelegateInteractionMixin(SDSEventDispatcherMixin(SDSFormControlMixin(SDSElement))) {\n\t// Styling\n\tstatic override styles = [styles];\n\n\t// Props\n\t// `name`, `disabled`, `internals` and form association come from SDSFormControlMixin.\n\t// Note: a native file input has no `readonly`, so we neither honor nor document it here.\n\t@property({ type: String, reflect: true }) accept?: string;\n\t@property({ type: String, reflect: true }) label?: string;\n\t@property({ type: Boolean, reflect: true }) multiple = false;\n\t@property({ type: Boolean, reflect: true }) required = false;\n\t@property({ type: Number, attribute: 'max-size-in-bytes', reflect: true }) maxSizeInBytes?: number;\n\t@property({ type: String, attribute: 'help-text', reflect: true }) helpText?: string;\n\t@property({ type: String, attribute: 'error-message', reflect: true }) errorMessage?: string;\n\t@property({ type: String, attribute: 'file-limitation-text', reflect: true }) fileLimitationText?: string;\n\t@property({ type: String, reflect: true }) variant: SDSFileUploadVariant = 'default';\n\t@property({ type: String, reflect: true }) size: SDSFileUploadSize = 'md';\n\t@property({ type: Boolean, attribute: 'hide-file-list', reflect: true }) hideFileList = false;\n\n\t@query('#control') control!: HTMLInputElement;\n\n\t// Internal state\n\t@state() private _files: File[] = [];\n\t@state() private _rejectedFiles: SDSRejectedFile[] = [];\n\t@state() private _hasSlottedLabel = false;\n\n\t// Controllers\n\tprivate readonly _previews = new SDSFilePreviewController(this, (file, url) => this.dispatchSheriffEvent('sds-preview-ready', { file, url }));\n\n\tprivate readonly _dragDrop = new SDSDragDropController(\n\t\tthis,\n\t\t(files) => this._processFiles(files),\n\t\t() => Boolean(this.disabled),\n\t);\n\n\t// Public API\n\tget files(): File[] {\n\t\treturn this._files;\n\t}\n\n\tget rejectedFiles(): SDSRejectedFile[] {\n\t\treturn this._rejectedFiles;\n\t}\n\n\tget value(): string {\n\t\treturn this._files[0] ? `C:\\\\fakepath\\\\${this._files[0].name}` : '';\n\t}\n\n\tset value(newValue: string) {\n\t\tif (newValue !== '') {\n\t\t\tthrow new DOMException('Failed to set the \\'value\\' property on sds-file-upload: only the empty string may be assigned.', 'InvalidStateError');\n\t\t}\n\t\tthis._reset();\n\t}\n\n\tremoveFile(file: File): void {\n\t\tconst previous = this._files;\n\t\tthis._files = previous.filter((existing) => !isSameFile(existing, file));\n\t\tthis._commitSelection(previous);\n\t}\n\n\tclear(): void {\n\t\tconst previous = this._files;\n\t\tthis._files = [];\n\t\tthis._rejectedFiles = [];\n\t\tthis._commitSelection(previous);\n\t}\n\n\tdismissRejected(file: File): void {\n\t\tthis._rejectedFiles = this._rejectedFiles.filter((rejected) => !isSameFile(rejected.file, file));\n\t}\n\n\tgetPreviewUrl(file: File): string | undefined {\n\t\treturn this._previews.get(file);\n\t}\n\n\toverride focus(options?: FocusOptions): void {\n\t\tif (!this.disabled) this.control?.focus(options);\n\t}\n\n\toverride blur(): void {\n\t\tif (!this.disabled) this.control?.blur();\n\t}\n\n\tcheckValidity(): boolean {\n\t\treturn this.internals.checkValidity();\n\t}\n\n\treportValidity(): boolean {\n\t\treturn this.internals.reportValidity();\n\t}\n\n\tsetCustomValidity(message: string): void {\n\t\tthis.errorMessage = message || undefined;\n\t\tthis.updateValidity();\n\t}\n\n\t// Lifecycle\n\toverride connectedCallback(): void {\n\t\tsuper.connectedCallback();\n\t\tthis._updateFormValue();\n\t}\n\n\tformResetCallback(): void {\n\t\tthis._reset();\n\t}\n\n\tprotected override updated(changed: PropertyValues): void {\n\t\tsuper.updated(changed);\n\t\tif (changed.has('required') || changed.has('errorMessage') || changed.has('disabled')) this.updateValidity();\n\t\tif (changed.has('name')) this._updateFormValue();\n\t}\n\n\t// Validity\n\toverride updateValidity(): void {\n\t\tif (!this.control) return;\n\n\t\tif (this.disabled) {\n\t\t\tthis.internals.setValidity({});\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.errorMessage) {\n\t\t\tthis.internals.setValidity({ customError: true }, this.errorMessage, this.control);\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.required && this._files.length === 0) {\n\t\t\tconst message = this.control.validationMessage;\n\t\t\tif (!message) return;\n\n\t\t\tthis.internals.setValidity({ valueMissing: true }, message, this.control);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.internals.setValidity({});\n\t}\n\n\tprivate _reset(): void {\n\t\tthis._files = [];\n\t\tthis._rejectedFiles = [];\n\t\tif (this.control) this.control.value = '';\n\t\tthis._previews.sync(this._files);\n\t\tthis._updateFormValue();\n\t\tthis.updateValidity();\n\t}\n\tget type(): string {\n\t\treturn 'file';\n\t}\n\t// Event handlers\n\tprivate readonly _handleInputChange = (event: Event): void => {\n\t\tevent.stopImmediatePropagation();\n\t\tconst input = event.target as HTMLInputElement;\n\t\tthis._processFiles(Array.from(input.files ?? []));\n\t};\n\n\tprivate readonly _handleNativeInput = (event: Event): void => {\n\t\tevent.stopImmediatePropagation();\n\t};\n\n\tprivate readonly _handleInputCancel = (event: Event): void => {\n\t\tevent.stopImmediatePropagation();\n\t\tthis.dispatchSheriffEvent('cancel', undefined, false);\n\t};\n\n\tprivate readonly _handleItemRemove = async (event: Event, file: File, rejection?: SDSRejectedFile): Promise<void> => {\n\t\tconst index = this._builtInItems().indexOf(event.currentTarget as SDSFileUploadItem);\n\t\tif (rejection) this.dismissRejected(file);\n\t\telse this.removeFile(file);\n\n\t\tawait this.updateComplete;\n\t\tconst remaining = this._builtInItems();\n\t\t(remaining[index] ?? remaining[index - 1] ?? this).focus();\n\t};\n\n\tprivate readonly _handleLabelSlotChange = (event: Event): void => {\n\t\tthis._hasSlottedLabel = (event.target as HTMLSlotElement).assignedNodes().length > 0;\n\t};\n\n\tprivate readonly _handleFocus = (event: FocusEvent): void => {\n\t\tevent.stopImmediatePropagation();\n\t\tthis.dispatchSheriffEvent('focus');\n\t};\n\n\tprivate readonly _handleBlur = (event: FocusEvent): void => {\n\t\tevent.stopImmediatePropagation();\n\t\tthis.dispatchSheriffEvent('blur');\n\t};\n\n\t// Internal helpers\n\tprivate get _showLabel(): boolean {\n\t\treturn this._hasSlottedLabel || Boolean(this.label);\n\t}\n\n\tprivate get _triggerText(): string {\n\t\treturn this.multiple ? 'Velg filer' : 'Velg fil';\n\t}\n\n\tprivate _processFiles(incoming: File[]): void {\n\t\tif (incoming.length === 0) return;\n\n\t\tconst previous = this._files;\n\t\tconst { accepted, rejected } = partitionFiles(incoming, {\n\t\t\taccept: this.accept,\n\t\t\tmaxSizeInBytes: this.maxSizeInBytes,\n\t\t\tmultiple: this.multiple,\n\t\t});\n\n\t\tthis._files = accepted;\n\t\tthis._rejectedFiles = rejected;\n\n\t\tthis._commitSelection(previous);\n\n\t\tif (rejected.length) {\n\t\t\tthis.dispatchSheriffEvent('sds-reject', { rejected });\n\t\t}\n\t}\n\n\tprivate _builtInItems(): SDSFileUploadItem[] {\n\t\treturn Array.from(this.renderRoot.querySelectorAll<SDSFileUploadItem>('sds-file-upload-file-list > sds-file-upload-item'));\n\t}\n\n\tprivate _isSameSelection(previous: File[], next: File[]): boolean {\n\t\tif (previous.length !== next.length) return false;\n\n\t\treturn previous.every((file, index) => {\n\t\t\tconst other = next[index];\n\t\t\treturn other !== undefined && isSameFile(file, other);\n\t\t});\n\t}\n\n\tprivate _syncSelection(): void {\n\t\tthis._previews.sync(this._files);\n\t\tthis._syncNativeInput();\n\t\tthis._updateFormValue();\n\t\tthis.updateValidity();\n\t}\n\n\tprivate _commitSelection(previous: File[]): void {\n\t\tthis._syncSelection();\n\t\tif (this._isSameSelection(previous, this._files)) return;\n\n\t\tthis.dispatchSheriffEvent('input');\n\t\tthis.dispatchSheriffEvent('change');\n\t}\n\n\tprivate _syncNativeInput(): void {\n\t\tif (!this.control) return;\n\t\tconst dataTransfer = new DataTransfer();\n\t\tfor (const file of this._files) dataTransfer.items.add(file);\n\t\tthis.control.files = dataTransfer.files;\n\t}\n\n\tprivate _updateFormValue(): void {\n\t\tif (!this.name) {\n\t\t\tthis.internals.setFormValue(null);\n\t\t\treturn;\n\t\t}\n\t\tconst data = new FormData();\n\t\tif (this._files.length === 0) data.append(this.name, new File([], '', { type: 'application/octet-stream' }));\n\t\tfor (const file of this._files) data.append(this.name, file, file.name);\n\t\tthis.internals.setFormValue(data);\n\t}\n\n\t// Rendering\n\tprivate readonly _renderItem = (file: File, rejection?: SDSRejectedFile) => html`\n\t\t<sds-file-upload-item\n\t\t\tfile=\"${file.name}\"\n\t\t\tsize-in-bytes=\"${file.size}\"\n\t\t\tpreview=\"${ifDefined(rejection ? undefined : this._previews.get(file))}\"\n\t\t\terror-message=\"${ifDefined(rejection?.reason)}\"\n\t\t\t?disabled=\"${!rejection && this.disabled}\"\n\t\t\t@sds-remove=\"${(event: Event) => this._handleItemRemove(event, file, rejection)}\"\n\t\t></sds-file-upload-item>\n\t`;\n\n\tprivate readonly _renderFileList = () => html`\n\t\t<sds-file-upload-file-list aria-label=\"Valgte filer\" aria-live=\"polite\">\n\t\t\t${this._files.map((file) => this._renderItem(file))}\n\t\t\t${this._rejectedFiles.map((rejected) => this._renderItem(rejected.file, rejected))}\n\t\t</sds-file-upload-file-list>\n\t`;\n\n\tprivate readonly _renderInput = () => {\n\t\tconst describedBy =\n\t\t\t[this.errorMessage ? 'error-message' : null, this.helpText ? 'help-text' : null, this.fileLimitationText ? 'file-limitation-text' : null]\n\t\t\t\t.filter(Boolean)\n\t\t\t\t.join(' ') || undefined;\n\n\t\treturn html`\n\t\t\t<input\n\t\t\t\tid=\"control\"\n\t\t\t\tclass=\"sds-file-upload__input\"\n\t\t\t\ttype=\"file\"\n\t\t\t\taccept=\"${ifDefined(this.accept)}\"\n\t\t\t\tname=\"${ifDefined(this.name)}\"\n\t\t\t\t?multiple=\"${this.multiple}\"\n\t\t\t\t?required=\"${this.required}\"\n\t\t\t\t?disabled=\"${this.disabled}\"\n\t\t\t\taria-label=\"${ifDefined(this._showLabel ? undefined : this._triggerText)}\"\n\t\t\t\taria-describedby=\"${ifDefined(describedBy)}\"\n\t\t\t\taria-invalid=\"${this.errorMessage ? 'true' : 'false'}\"\n\t\t\t\t@input=\"${this._handleNativeInput}\"\n\t\t\t\t@change=\"${this._handleInputChange}\"\n\t\t\t\t@cancel=\"${this._handleInputCancel}\"\n\t\t\t\t@focus=\"${this._handleFocus}\"\n\t\t\t\t@blur=\"${this._handleBlur}\"\n\t\t\t/>\n\t\t`;\n\t};\n\n\tprivate readonly _renderDropzone = () => {\n\t\tconst dropzoneClasses = {\n\t\t\t'sds-file-upload__dropzone': true,\n\t\t\t'sds-file-upload__dropzone--dragging': this._dragDrop.dragging,\n\t\t\t'sds-file-upload__dropzone--error': Boolean(this.errorMessage),\n\t\t};\n\n\t\tconst iconSize = this.variant === 'compact' ? this.size : 'lg';\n\n\t\treturn html`\n\t\t\t<div\n\t\t\t\tclass=\"${classMap(dropzoneClasses)}\"\n\t\t\t\t@dragover=\"${this._dragDrop.handleDragOver}\"\n\t\t\t\t@dragleave=\"${this._dragDrop.handleDragLeave}\"\n\t\t\t\t@drop=\"${this._dragDrop.handleDrop}\"\n\t\t\t>\n\t\t\t\t${this._renderInput()}\n\t\t\t\t<sds-icon name=\"upload-material-outlined\" size=\"${iconSize}\"></sds-icon>\n\t\t\t\t<p class=\"sds-file-upload__drop-text\" aria-hidden=\"true\">${this.multiple ? 'Dra og slipp filene her eller' : 'Dra og slipp filen her eller'}</p>\n\t\t\t\t<sds-button\n\t\t\t\t\tclass=\"sds-file-upload__trigger\"\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tsize=\"${this.variant === 'compact' ? 'sm' : this.size}\"\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t?disabled=\"${this.disabled}\"\n\t\t\t\t\tinert\n\t\t\t\t>\n\t\t\t\t\t<span class=\"sds-file-upload__button-label\">${this._triggerText}</span>\n\t\t\t\t</sds-button>\n\t\t\t\t<div class=\"sds-file-upload__drop-hint\" aria-hidden=\"true\">\n\t\t\t\t\t<sds-icon name=\"upload-material-outlined\" size=\"${iconSize}\"></sds-icon>\n\t\t\t\t\t<span class=\"sds-file-upload__drop-hint-text\">Slipp fil</span>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t`;\n\t};\n\n\toverride render() {\n\t\treturn html`\n\t\t\t<div class=\"sds-file-upload\">\n\t\t\t\t<label for=\"control\" class=\"sds-file-upload__label\" ?hidden=\"${!this._showLabel}\">\n\t\t\t\t\t<slot name=\"label\" @slotchange=\"${this._handleLabelSlotChange}\">${this.label}</slot>\n\t\t\t\t</label>\n\t\t\t\t${this.helpText ? html`<p id=\"help-text\" class=\"sds-file-upload__help-text\">${this.helpText}</p>` : nothing}\n\n\t\t\t\t${this._renderDropzone()}\n\n\t\t\t\t${this.fileLimitationText ? html`<p id=\"file-limitation-text\" class=\"sds-file-upload__file-limitation-text\">${this.fileLimitationText}</p>` : nothing}\n\t\t\t</div>\n\t\t\t${this.errorMessage\n\t\t\t\t? html`<sds-alert class=\"sds-file-upload__error-message\" id=\"error-message\" variant=\"secondary\" data-palette=\"danger\"><p slot=\"message\">${this.errorMessage}</p></sds-alert>`\n\t\t\t\t: nothing}\n\t\t\t${this.hideFileList ? nothing : this._renderFileList()}\n\t\t`;\n\t}\n}\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t'sds-file-upload': SDSFileUpload;\n\t}\n\tinterface GlobalEventHandlersEventMap {\n\t\t'sds-reject': CustomEvent<{ rejected: SDSRejectedFile[] }>;\n\t\t'sds-preview-ready': CustomEvent<{ file: File; url: string }>;\n\t}\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sds-file-upload.styles.d.ts","sourceRoot":"","sources":["../../src/sds-file-upload/sds-file-upload.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,yBAuOlB,CAAC"}
|