@dile/crud 1.3.11 → 1.5.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/components/file-uploader/file-uploader-form.js +2 -0
- package/components/file-uploader/file-uploader.js +2 -0
- package/components/file-uploader/index.js +2 -0
- package/components/file-uploader/src/DileFileUploader.js +69 -0
- package/components/file-uploader/src/DileFileUploaderForm.js +39 -0
- package/components/list/src/DileCrudList.js +1 -1
- package/lib/i18n/en.js +2 -0
- package/lib/i18n/es.js +2 -0
- package/package.json +3 -3
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
|
+
import '../../ajax-form/ajax-form.js';
|
|
3
|
+
import '../file-uploader-form.js';
|
|
4
|
+
import { ResponseApiAdapter } from '../../../lib/ResponseApiAdapter.js';
|
|
5
|
+
import { DileI18nMixin } from '../../../lib/DileI18nMixin.js';
|
|
6
|
+
|
|
7
|
+
export class DileFileUploader extends DileI18nMixin(LitElement) {
|
|
8
|
+
static styles = [
|
|
9
|
+
css`
|
|
10
|
+
:host {
|
|
11
|
+
display: block;
|
|
12
|
+
}
|
|
13
|
+
`
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
static get properties() {
|
|
17
|
+
return {
|
|
18
|
+
endpoint: { type: String },
|
|
19
|
+
selectFileLabel: { type: String },
|
|
20
|
+
saveLabel: { type: String },
|
|
21
|
+
allowedExtensions: { type: Array },
|
|
22
|
+
responseAdapter: { type: Object },
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
constructor() {
|
|
27
|
+
super();
|
|
28
|
+
this.responseAdapter = new ResponseApiAdapter();
|
|
29
|
+
this.allowedExtensions = ['*'];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
render() {
|
|
33
|
+
return html`
|
|
34
|
+
<dile-ajax-form
|
|
35
|
+
id="elform"
|
|
36
|
+
operation="insert"
|
|
37
|
+
endpoint=${this.endpoint}
|
|
38
|
+
actionLabel="${this.saveLabelComputed(this.saveLabel, this.translations)}"
|
|
39
|
+
sendDataAsFormData
|
|
40
|
+
language="${this.language}"
|
|
41
|
+
@save-success=${this.fileSaveSuccess}
|
|
42
|
+
.responseAdapter=${this.responseAdapter}
|
|
43
|
+
>
|
|
44
|
+
<dile-file-uploader-form
|
|
45
|
+
id="form"
|
|
46
|
+
label="${this.selectLabelComputed(this.selectFileLabel, this.translations)}"
|
|
47
|
+
.allowedExtensions=${this.allowedExtensions}
|
|
48
|
+
.translations=${this.translations}
|
|
49
|
+
></dile-file-uploader-form>
|
|
50
|
+
</dile-ajax-form>
|
|
51
|
+
`;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
selectLabelComputed(label, translations) {
|
|
55
|
+
return label ? label : translations?.select_file_label ? translations.select_file_label : 'Select a file';
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
saveLabelComputed(label, translations) {
|
|
59
|
+
return label ? label : translations?.save_file_label ? translations.save_file_label : 'Save file';
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
fileSaveSuccess(e) {
|
|
63
|
+
this.dispatchEvent(new CustomEvent('file-uploaded', {
|
|
64
|
+
bubbles: true,
|
|
65
|
+
composed: true,
|
|
66
|
+
detail: e.detail
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
|
+
import { DileForm } from '@dile/ui/mixins/form/index.js'
|
|
3
|
+
import '@dile/ui/components/drop-file/drop-file.js';
|
|
4
|
+
|
|
5
|
+
export class DileFileUploaderForm extends DileForm(LitElement) {
|
|
6
|
+
static styles = [
|
|
7
|
+
css`
|
|
8
|
+
:host {
|
|
9
|
+
display: block;
|
|
10
|
+
}
|
|
11
|
+
dile-drop-file {
|
|
12
|
+
margin-bottom: 0;
|
|
13
|
+
}
|
|
14
|
+
`
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
static get properties() {
|
|
18
|
+
return {
|
|
19
|
+
label: { type: String },
|
|
20
|
+
allowedExtensions: { type: Array },
|
|
21
|
+
translations: { type: Object },
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
render() {
|
|
26
|
+
return html`
|
|
27
|
+
<dile-drop-file
|
|
28
|
+
name="file"
|
|
29
|
+
label="${this.label}"
|
|
30
|
+
id="dropfile"
|
|
31
|
+
.allowedExtensions=${this.allowedExtensions}
|
|
32
|
+
dropLabel="${this.translations.file_drop}"
|
|
33
|
+
buttonLabel="${this.translations.select_file}"
|
|
34
|
+
selectedFileLabel="${this.translations.selected_file}"
|
|
35
|
+
extensionErrorMessage="${this.translations.extension_allowed}"
|
|
36
|
+
></dile-drop-file>
|
|
37
|
+
`;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -39,7 +39,7 @@ export class DileCrudList extends DileI18nMixin(DileLoading(LitElement)) {
|
|
|
39
39
|
|
|
40
40
|
.empty {
|
|
41
41
|
padding: var(--dile-crud-list-empty-padding, 3rem 1rem);
|
|
42
|
-
text-align: center;
|
|
42
|
+
text-align: var(--dile-crud-list-empty-text-align, center);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
@media(min-width: 500px) {
|
package/lib/i18n/en.js
CHANGED
|
@@ -46,6 +46,8 @@ export const translations = {
|
|
|
46
46
|
element_actions: "Element actions",
|
|
47
47
|
select_image: "Select an image",
|
|
48
48
|
save_image: "Save image",
|
|
49
|
+
select_file_label: "Select a file",
|
|
50
|
+
save_file_label: "Save file",
|
|
49
51
|
file_drop: "Drop here your file",
|
|
50
52
|
select_file: "Select file",
|
|
51
53
|
selected_file: "Selected file",
|
package/lib/i18n/es.js
CHANGED
|
@@ -46,6 +46,8 @@ export const translations = {
|
|
|
46
46
|
element_actions: "Acciones en este ítem",
|
|
47
47
|
select_image: "Selecciona una imagen",
|
|
48
48
|
save_image: "Salvar la imagen",
|
|
49
|
+
select_file_label: "Selecciona un archivo",
|
|
50
|
+
save_file_label: "Guardar archivo",
|
|
49
51
|
file_drop: "Suelta aquí el archivo",
|
|
50
52
|
select_file: "Seleccionar archivo",
|
|
51
53
|
selected_file: "Archivo seleccionado",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dile/crud",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Components to create a generic crud system based on Web Components and Lit",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
},
|
|
25
25
|
"homepage": "https://dile-components.com/",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@dile/ui": "^2.
|
|
27
|
+
"@dile/ui": "^2.18.0",
|
|
28
28
|
"axios": "^1.13.0",
|
|
29
29
|
"lit": "^2.7.0 || ^3.0.0"
|
|
30
30
|
},
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "94879cea5e40ec66f9e18d617dd58334318ea35d"
|
|
35
35
|
}
|