xv-webcomponents 0.1.44 → 0.1.48
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/dist/cjs/{index-MLh9SbX2.js → index-CjhPTfz8.js} +41 -14
- package/dist/cjs/index-CjhPTfz8.js.map +1 -0
- package/dist/cjs/loader.cjs.js +3 -4
- package/dist/cjs/loader.cjs.js.map +1 -1
- package/dist/cjs/xv-accordion-v2_38.cjs.entry.js +79072 -0
- package/dist/cjs/xv-accordion-v2_38.cjs.entry.js.map +1 -0
- package/dist/cjs/xv-breadcrumbs-v2.cjs.entry.js +2 -2
- package/dist/cjs/xv-breadcrumbs-v2.cjs.entry.js.map +1 -1
- package/dist/cjs/xv-breadcrumbs-v2.entry.cjs.js.map +1 -1
- package/dist/cjs/xv-webcomponents.cjs.js +4 -5
- package/dist/cjs/xv-webcomponents.cjs.js.map +1 -1
- package/dist/collection/collection-manifest.json +5 -1
- package/dist/collection/components/xv-accordion/xv-accordion.css +95 -0
- package/dist/collection/components/xv-accordion-item/xv-accordion-item.css +95 -0
- package/dist/collection/components/xv-breadcrumbs/xv-breadcrumbs.css +95 -0
- package/dist/collection/components/xv-button/xv-button-v2.css +95 -0
- package/dist/collection/components/xv-card/xv-card.css +95 -0
- package/dist/collection/components/xv-checkbox/xv-checkbox.css +95 -0
- package/dist/collection/components/xv-data-table/xv-data-table-cell/xv-data-table-cell.css +95 -0
- package/dist/collection/components/xv-data-table/xv-data-table-cell/xv-data-table-cell.js +29 -5
- package/dist/collection/components/xv-data-table/xv-data-table-cell/xv-data-table-cell.js.map +1 -1
- package/dist/collection/components/xv-data-table/xv-data-table-collapse/xv-data-table-collapse.css +95 -0
- package/dist/collection/components/xv-data-table/xv-data-table-collapse/xv-data-table-collapse.js +1 -1
- package/dist/collection/components/xv-data-table/xv-data-table-row/xv-data-table-row.css +104 -7
- package/dist/collection/components/xv-data-table/xv-data-table-row/xv-data-table-row.js +9 -3
- package/dist/collection/components/xv-data-table/xv-data-table-row/xv-data-table-row.js.map +1 -1
- package/dist/collection/components/xv-data-table/xv-data-table.css +112 -2
- package/dist/collection/components/xv-data-table/xv-data-table.js +20 -1
- package/dist/collection/components/xv-data-table/xv-data-table.js.map +1 -1
- package/dist/collection/components/xv-datepicker/xv-datepicker.css +401 -0
- package/dist/collection/components/xv-datepicker/xv-datepicker.js +570 -0
- package/dist/collection/components/xv-datepicker/xv-datepicker.js.map +1 -0
- package/dist/collection/components/xv-dropdown/xv-dropdown-item/xv-dropdown-item.css +95 -0
- package/dist/collection/components/xv-dropdown/xv-dropdown-item/xv-dropdown-item.js +1 -1
- package/dist/collection/components/xv-dropdown/xv-dropdown.css +95 -0
- package/dist/collection/components/xv-dropdown/xv-dropdown.js +2 -2
- package/dist/collection/components/xv-dropdown/xv-dropdown.js.map +1 -1
- package/dist/collection/components/xv-file-uploader/xv-file-uploader.css +98 -1
- package/dist/collection/components/xv-file-uploader/xv-file-uploader.js +76 -10
- package/dist/collection/components/xv-file-uploader/xv-file-uploader.js.map +1 -1
- package/dist/collection/components/xv-footer/xv-footer.css +95 -0
- package/dist/collection/components/xv-footer/xv-footer.js +1 -1
- package/dist/collection/components/xv-header/xv-header.css +95 -0
- package/dist/collection/components/xv-header/xv-header.js +1 -1
- package/dist/collection/components/xv-link/xv-link.css +95 -0
- package/dist/collection/components/xv-link/xv-link.js +1 -1
- package/dist/collection/components/xv-loader/xv-loader.css +95 -0
- package/dist/collection/components/xv-login-modal/xv-login-modal.css +95 -0
- package/dist/collection/components/xv-modal/xv-modal.css +108 -0
- package/dist/collection/components/xv-modal/xv-modal.js +20 -1
- package/dist/collection/components/xv-modal/xv-modal.js.map +1 -1
- package/dist/collection/components/xv-notification/xv-notification.css +96 -1
- package/dist/collection/components/xv-notification/xv-notification.js +1 -1
- package/dist/collection/components/xv-number-input/xv-number-input.css +95 -0
- package/dist/collection/components/xv-number-input/xv-number-input.js +2 -2
- package/dist/collection/components/xv-overflow-menu/xv-overflow-menu-item/xv-overflow-menu-item.css +95 -0
- package/dist/collection/components/xv-overflow-menu/xv-overflow-menu-item/xv-overflow-menu-item.js +1 -1
- package/dist/collection/components/xv-overflow-menu/xv-overflow-menu.css +95 -0
- package/dist/collection/components/xv-overflow-menu/xv-overflow-menu.js +1 -1
- package/dist/collection/components/xv-progress-indicator/xv-progress-indicator-item/xv-progress-indicator-item.css +96 -1
- package/dist/collection/components/xv-progress-indicator/xv-progress-indicator-item/xv-progress-indicator-item.js +1 -1
- package/dist/collection/components/xv-progress-indicator/xv-progress-indicator.css +95 -0
- package/dist/collection/components/xv-progress-indicator/xv-progress-indicator.js +1 -1
- package/dist/collection/components/xv-slider/xv-slider.css +196 -0
- package/dist/collection/components/xv-slider/xv-slider.js +259 -0
- package/dist/collection/components/xv-slider/xv-slider.js.map +1 -0
- package/dist/collection/components/xv-table/xv-table-cell/xv-table-cell.css +95 -0
- package/dist/collection/components/xv-table/xv-table-cell/xv-table-cell.js +1 -1
- package/dist/collection/components/xv-table/xv-table-expand/xv-table-expand.css +95 -0
- package/dist/collection/components/xv-table/xv-table-expand/xv-table-expand.js +1 -1
- package/dist/collection/components/xv-table/xv-table-row/xv-table-row.css +95 -0
- package/dist/collection/components/xv-table/xv-table-row/xv-table-row.js +1 -1
- package/dist/collection/components/xv-table/xv-table.css +95 -0
- package/dist/collection/components/xv-table/xv-table.js +1 -1
- package/dist/collection/components/xv-tabs/xv-tab/xv-tab.css +95 -0
- package/dist/collection/components/xv-tabs/xv-tab/xv-tab.js +1 -1
- package/dist/collection/components/xv-tabs/xv-tabs.css +100 -11
- package/dist/collection/components/xv-tag/xv-tag.css +95 -0
- package/dist/collection/components/xv-tag/xv-tag.js +1 -1
- package/dist/collection/components/xv-text-input/xv-text-input.css +98 -0
- package/dist/collection/components/xv-text-input/xv-text-input.js +21 -2
- package/dist/collection/components/xv-text-input/xv-text-input.js.map +1 -1
- package/dist/collection/components/xv-textarea/xv-textarea.css +254 -0
- package/dist/collection/components/xv-textarea/xv-textarea.js +411 -0
- package/dist/collection/components/xv-textarea/xv-textarea.js.map +1 -0
- package/dist/collection/components/xv-tile/xv-tile.css +294 -0
- package/dist/collection/components/xv-tile/xv-tile.js +264 -0
- package/dist/collection/components/xv-tile/xv-tile.js.map +1 -0
- package/dist/collection/components/xv-toggle-tip/xv-toggle-tip.css +95 -0
- package/dist/collection/components/xv-toggle-tip/xv-toggle-tip.js +1 -1
- package/dist/collection/components/xv-tooltip/xv-tooltip.css +92 -28
- package/dist/collection/components/xv-tooltip/xv-tooltip.js +66 -18
- package/dist/collection/components/xv-tooltip/xv-tooltip.js.map +1 -1
- package/dist/esm/{index-DLYJiP99.js → index-BQoQLd_U.js} +41 -15
- package/dist/esm/index-BQoQLd_U.js.map +1 -0
- package/dist/esm/loader.js +3 -4
- package/dist/esm/loader.js.map +1 -1
- package/dist/esm/xv-accordion-v2_38.entry.js +79033 -0
- package/dist/esm/xv-accordion-v2_38.entry.js.map +1 -0
- package/dist/esm/xv-breadcrumbs-v2.entry.js +2 -2
- package/dist/esm/xv-breadcrumbs-v2.entry.js.map +1 -1
- package/dist/esm/xv-webcomponents.js +4 -5
- package/dist/esm/xv-webcomponents.js.map +1 -1
- package/dist/types/components/xv-data-table/xv-data-table-cell/xv-data-table-cell.d.ts +2 -0
- package/dist/types/components/xv-data-table/xv-data-table.d.ts +1 -0
- package/dist/types/components/xv-datepicker/xv-datepicker.d.ts +69 -0
- package/dist/types/components/xv-file-uploader/xv-file-uploader.d.ts +3 -0
- package/dist/types/components/xv-modal/xv-modal.d.ts +4 -0
- package/dist/types/components/xv-slider/xv-slider.d.ts +20 -0
- package/dist/types/components/xv-text-input/xv-text-input.d.ts +1 -0
- package/dist/types/components/xv-textarea/xv-textarea.d.ts +27 -0
- package/dist/types/components/xv-tile/xv-tile.d.ts +24 -0
- package/dist/types/components/xv-tooltip/xv-tooltip.d.ts +5 -3
- package/dist/types/components.d.ts +373 -0
- package/dist/types/stencil-public-runtime.d.ts +1 -1
- package/dist/xv-webcomponents/loader.esm.js.map +1 -1
- package/dist/xv-webcomponents/p-50fb934d.entry.js +2 -0
- package/dist/xv-webcomponents/p-50fb934d.entry.js.map +1 -0
- package/dist/xv-webcomponents/p-BQoQLd_U.js +3 -0
- package/dist/xv-webcomponents/p-BQoQLd_U.js.map +1 -0
- package/dist/xv-webcomponents/p-a8d785da.entry.js +2 -0
- package/dist/xv-webcomponents/{p-5b63a259.entry.js.map → p-a8d785da.entry.js.map} +1 -1
- package/dist/xv-webcomponents/xv-breadcrumbs-v2.entry.esm.js.map +1 -1
- package/dist/xv-webcomponents/xv-webcomponents.esm.js +1 -1
- package/dist/xv-webcomponents/xv-webcomponents.esm.js.map +1 -1
- package/package.json +7 -4
- package/dist/cjs/app-globals-V2Kpy_OQ.js +0 -8
- package/dist/cjs/app-globals-V2Kpy_OQ.js.map +0 -1
- package/dist/cjs/index-MLh9SbX2.js.map +0 -1
- package/dist/cjs/xv-accordion-v2_34.cjs.entry.js +0 -3510
- package/dist/cjs/xv-accordion-v2_34.cjs.entry.js.map +0 -1
- package/dist/esm/app-globals-DQuL1Twl.js +0 -6
- package/dist/esm/app-globals-DQuL1Twl.js.map +0 -1
- package/dist/esm/index-DLYJiP99.js.map +0 -1
- package/dist/esm/xv-accordion-v2_34.entry.js +0 -3475
- package/dist/esm/xv-accordion-v2_34.entry.js.map +0 -1
- package/dist/xv-webcomponents/p-5b63a259.entry.js +0 -2
- package/dist/xv-webcomponents/p-9c06f44c.entry.js +0 -2
- package/dist/xv-webcomponents/p-9c06f44c.entry.js.map +0 -1
- package/dist/xv-webcomponents/p-DLYJiP99.js +0 -3
- package/dist/xv-webcomponents/p-DLYJiP99.js.map +0 -1
- package/dist/xv-webcomponents/p-DQuL1Twl.js +0 -2
- package/dist/xv-webcomponents/p-DQuL1Twl.js.map +0 -1
|
@@ -1,3 +1,98 @@
|
|
|
1
|
+
.xv-tooltip[role=tooltip] {
|
|
2
|
+
position: absolute;
|
|
3
|
+
background-color: var(--background-inverse, #333333);
|
|
4
|
+
color: var(--text-on-color);
|
|
5
|
+
padding: var(--spacing-03) var(--spacing-04);
|
|
6
|
+
border-radius: 3px;
|
|
7
|
+
font-size: var(--fz-sm);
|
|
8
|
+
z-index: 999;
|
|
9
|
+
min-width: min(150px, 90vw);
|
|
10
|
+
max-width: min(400px, 90vw);
|
|
11
|
+
}
|
|
12
|
+
.xv-tooltip[role=tooltip]::after {
|
|
13
|
+
content: "";
|
|
14
|
+
position: absolute;
|
|
15
|
+
width: 0;
|
|
16
|
+
height: 0;
|
|
17
|
+
border-style: solid;
|
|
18
|
+
}
|
|
19
|
+
.xv-tooltip[role=tooltip][data-popper-placement=top]::after {
|
|
20
|
+
bottom: -5px;
|
|
21
|
+
left: 50%;
|
|
22
|
+
transform: translateX(-50%);
|
|
23
|
+
border-width: 5px 5px 0 5px;
|
|
24
|
+
border-color: var(--background-inverse, black) transparent transparent transparent;
|
|
25
|
+
}
|
|
26
|
+
.xv-tooltip[role=tooltip][data-popper-placement=top-start]::after {
|
|
27
|
+
bottom: -5px;
|
|
28
|
+
left: 12px;
|
|
29
|
+
border-width: 5px 5px 0 5px;
|
|
30
|
+
border-color: var(--background-inverse, black) transparent transparent transparent;
|
|
31
|
+
}
|
|
32
|
+
.xv-tooltip[role=tooltip][data-popper-placement=top-end]::after {
|
|
33
|
+
bottom: -5px;
|
|
34
|
+
right: 12px;
|
|
35
|
+
border-width: 5px 5px 0 5px;
|
|
36
|
+
border-color: var(--background-inverse, black) transparent transparent transparent;
|
|
37
|
+
}
|
|
38
|
+
.xv-tooltip[role=tooltip][data-popper-placement=bottom]::after {
|
|
39
|
+
top: -5px;
|
|
40
|
+
left: 50%;
|
|
41
|
+
transform: translateX(-50%);
|
|
42
|
+
border-width: 0 5px 5px 5px;
|
|
43
|
+
border-color: transparent transparent var(--background-inverse, black) transparent;
|
|
44
|
+
}
|
|
45
|
+
.xv-tooltip[role=tooltip][data-popper-placement=bottom-start]::after {
|
|
46
|
+
top: -5px;
|
|
47
|
+
left: 12px;
|
|
48
|
+
border-width: 0 5px 5px 5px;
|
|
49
|
+
border-color: transparent transparent var(--background-inverse, black) transparent;
|
|
50
|
+
}
|
|
51
|
+
.xv-tooltip[role=tooltip][data-popper-placement=bottom-end]::after {
|
|
52
|
+
top: -5px;
|
|
53
|
+
right: 12px;
|
|
54
|
+
border-width: 0 5px 5px 5px;
|
|
55
|
+
border-color: transparent transparent var(--background-inverse, black) transparent;
|
|
56
|
+
}
|
|
57
|
+
.xv-tooltip[role=tooltip][data-popper-placement=left]::after {
|
|
58
|
+
top: 50%;
|
|
59
|
+
right: -5px;
|
|
60
|
+
transform: translateY(-50%);
|
|
61
|
+
border-width: 5px 0 5px 5px;
|
|
62
|
+
border-color: transparent transparent transparent var(--background-inverse, black);
|
|
63
|
+
}
|
|
64
|
+
.xv-tooltip[role=tooltip][data-popper-placement=left-start]::after {
|
|
65
|
+
top: 12px;
|
|
66
|
+
right: -5px;
|
|
67
|
+
border-width: 5px 0 5px 5px;
|
|
68
|
+
border-color: transparent transparent transparent var(--background-inverse, black);
|
|
69
|
+
}
|
|
70
|
+
.xv-tooltip[role=tooltip][data-popper-placement=left-end]::after {
|
|
71
|
+
bottom: 12px;
|
|
72
|
+
right: -5px;
|
|
73
|
+
border-width: 5px 0 5px 5px;
|
|
74
|
+
border-color: transparent transparent transparent var(--background-inverse, black);
|
|
75
|
+
}
|
|
76
|
+
.xv-tooltip[role=tooltip][data-popper-placement=right]::after {
|
|
77
|
+
top: 50%;
|
|
78
|
+
left: -5px;
|
|
79
|
+
transform: translateY(-50%);
|
|
80
|
+
border-width: 5px 5px 5px 0;
|
|
81
|
+
border-color: transparent var(--background-inverse, black) transparent transparent;
|
|
82
|
+
}
|
|
83
|
+
.xv-tooltip[role=tooltip][data-popper-placement=right-start]::after {
|
|
84
|
+
top: 12px;
|
|
85
|
+
left: -5px;
|
|
86
|
+
border-width: 5px 5px 5px 0;
|
|
87
|
+
border-color: transparent var(--background-inverse, black) transparent transparent;
|
|
88
|
+
}
|
|
89
|
+
.xv-tooltip[role=tooltip][data-popper-placement=right-end]::after {
|
|
90
|
+
bottom: 12px;
|
|
91
|
+
left: -5px;
|
|
92
|
+
border-width: 5px 5px 5px 0;
|
|
93
|
+
border-color: transparent var(--background-inverse, black) transparent transparent;
|
|
94
|
+
}
|
|
95
|
+
|
|
1
96
|
:host {
|
|
2
97
|
display: block;
|
|
3
98
|
}
|
|
@@ -21,7 +21,7 @@ export class XvDropdownItem {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
render() {
|
|
24
|
-
return (h(Host, { key: '
|
|
24
|
+
return (h(Host, { key: '8e7a822ee3c4eb8fd402d580cebcfba898223d27', class: "xv-dropdown-item", value: this.value, role: "option", tabindex: this.disabled ? -1 : false }, h("slot", { key: 'ba93c8487f3390044e841db6d5e6f1df1f7bb5c9' }), this.selected && h("span", { key: '4596986268b2974d85970f0422987fb6906040fa', class: "checkmark" })));
|
|
25
25
|
}
|
|
26
26
|
componentWillLoad() {
|
|
27
27
|
if (!this.value)
|
|
@@ -1,3 +1,98 @@
|
|
|
1
|
+
.xv-tooltip[role=tooltip] {
|
|
2
|
+
position: absolute;
|
|
3
|
+
background-color: var(--background-inverse, #333333);
|
|
4
|
+
color: var(--text-on-color);
|
|
5
|
+
padding: var(--spacing-03) var(--spacing-04);
|
|
6
|
+
border-radius: 3px;
|
|
7
|
+
font-size: var(--fz-sm);
|
|
8
|
+
z-index: 999;
|
|
9
|
+
min-width: min(150px, 90vw);
|
|
10
|
+
max-width: min(400px, 90vw);
|
|
11
|
+
}
|
|
12
|
+
.xv-tooltip[role=tooltip]::after {
|
|
13
|
+
content: "";
|
|
14
|
+
position: absolute;
|
|
15
|
+
width: 0;
|
|
16
|
+
height: 0;
|
|
17
|
+
border-style: solid;
|
|
18
|
+
}
|
|
19
|
+
.xv-tooltip[role=tooltip][data-popper-placement=top]::after {
|
|
20
|
+
bottom: -5px;
|
|
21
|
+
left: 50%;
|
|
22
|
+
transform: translateX(-50%);
|
|
23
|
+
border-width: 5px 5px 0 5px;
|
|
24
|
+
border-color: var(--background-inverse, black) transparent transparent transparent;
|
|
25
|
+
}
|
|
26
|
+
.xv-tooltip[role=tooltip][data-popper-placement=top-start]::after {
|
|
27
|
+
bottom: -5px;
|
|
28
|
+
left: 12px;
|
|
29
|
+
border-width: 5px 5px 0 5px;
|
|
30
|
+
border-color: var(--background-inverse, black) transparent transparent transparent;
|
|
31
|
+
}
|
|
32
|
+
.xv-tooltip[role=tooltip][data-popper-placement=top-end]::after {
|
|
33
|
+
bottom: -5px;
|
|
34
|
+
right: 12px;
|
|
35
|
+
border-width: 5px 5px 0 5px;
|
|
36
|
+
border-color: var(--background-inverse, black) transparent transparent transparent;
|
|
37
|
+
}
|
|
38
|
+
.xv-tooltip[role=tooltip][data-popper-placement=bottom]::after {
|
|
39
|
+
top: -5px;
|
|
40
|
+
left: 50%;
|
|
41
|
+
transform: translateX(-50%);
|
|
42
|
+
border-width: 0 5px 5px 5px;
|
|
43
|
+
border-color: transparent transparent var(--background-inverse, black) transparent;
|
|
44
|
+
}
|
|
45
|
+
.xv-tooltip[role=tooltip][data-popper-placement=bottom-start]::after {
|
|
46
|
+
top: -5px;
|
|
47
|
+
left: 12px;
|
|
48
|
+
border-width: 0 5px 5px 5px;
|
|
49
|
+
border-color: transparent transparent var(--background-inverse, black) transparent;
|
|
50
|
+
}
|
|
51
|
+
.xv-tooltip[role=tooltip][data-popper-placement=bottom-end]::after {
|
|
52
|
+
top: -5px;
|
|
53
|
+
right: 12px;
|
|
54
|
+
border-width: 0 5px 5px 5px;
|
|
55
|
+
border-color: transparent transparent var(--background-inverse, black) transparent;
|
|
56
|
+
}
|
|
57
|
+
.xv-tooltip[role=tooltip][data-popper-placement=left]::after {
|
|
58
|
+
top: 50%;
|
|
59
|
+
right: -5px;
|
|
60
|
+
transform: translateY(-50%);
|
|
61
|
+
border-width: 5px 0 5px 5px;
|
|
62
|
+
border-color: transparent transparent transparent var(--background-inverse, black);
|
|
63
|
+
}
|
|
64
|
+
.xv-tooltip[role=tooltip][data-popper-placement=left-start]::after {
|
|
65
|
+
top: 12px;
|
|
66
|
+
right: -5px;
|
|
67
|
+
border-width: 5px 0 5px 5px;
|
|
68
|
+
border-color: transparent transparent transparent var(--background-inverse, black);
|
|
69
|
+
}
|
|
70
|
+
.xv-tooltip[role=tooltip][data-popper-placement=left-end]::after {
|
|
71
|
+
bottom: 12px;
|
|
72
|
+
right: -5px;
|
|
73
|
+
border-width: 5px 0 5px 5px;
|
|
74
|
+
border-color: transparent transparent transparent var(--background-inverse, black);
|
|
75
|
+
}
|
|
76
|
+
.xv-tooltip[role=tooltip][data-popper-placement=right]::after {
|
|
77
|
+
top: 50%;
|
|
78
|
+
left: -5px;
|
|
79
|
+
transform: translateY(-50%);
|
|
80
|
+
border-width: 5px 5px 5px 0;
|
|
81
|
+
border-color: transparent var(--background-inverse, black) transparent transparent;
|
|
82
|
+
}
|
|
83
|
+
.xv-tooltip[role=tooltip][data-popper-placement=right-start]::after {
|
|
84
|
+
top: 12px;
|
|
85
|
+
left: -5px;
|
|
86
|
+
border-width: 5px 5px 5px 0;
|
|
87
|
+
border-color: transparent var(--background-inverse, black) transparent transparent;
|
|
88
|
+
}
|
|
89
|
+
.xv-tooltip[role=tooltip][data-popper-placement=right-end]::after {
|
|
90
|
+
bottom: 12px;
|
|
91
|
+
left: -5px;
|
|
92
|
+
border-width: 5px 5px 5px 0;
|
|
93
|
+
border-color: transparent var(--background-inverse, black) transparent transparent;
|
|
94
|
+
}
|
|
95
|
+
|
|
1
96
|
:host {
|
|
2
97
|
--dropdown-padding-x: 16px;
|
|
3
98
|
--dropdown-padding-y: 11px;
|
|
@@ -10,7 +10,7 @@ export class XvDropdown {
|
|
|
10
10
|
this.setSelected = (selectedMap, optionNodes) => {
|
|
11
11
|
const values = Array.from(selectedMap.values());
|
|
12
12
|
const options = optionNodes || this.el.querySelectorAll(DropdownItemSelector);
|
|
13
|
-
this.selected = values.length === options.length ?
|
|
13
|
+
this.selected = this.multiple && values.length === options.length ?
|
|
14
14
|
['Alle ausgewählt'] : values.length > 2 ?
|
|
15
15
|
[`${values.length} ausgewählt`] : values.map((v) => v.text);
|
|
16
16
|
return values;
|
|
@@ -94,7 +94,7 @@ export class XvDropdown {
|
|
|
94
94
|
this.changeSelection.emit(this.setSelected(this.selectedMap, optionElements));
|
|
95
95
|
}
|
|
96
96
|
render() {
|
|
97
|
-
return (h(Host, { key: '
|
|
97
|
+
return (h(Host, { key: '22a368d8ed8366bc14b76571d1d230b09a8796b0', class: "xv-dropdown", role: "combobox", size: this.size, open: this.open, error: this.error, disabled: this.disabled, tabindex: this.disabled ? -1 : false }, h("label", { key: '758412d82f433d5675f0f69048a76c67d7fea92c', class: "label" }, h("slot", { key: '7ea798f0ddca889db33845470d45aeeaaddce4a8', name: "label" }, this.label), this.info && h("xv-tooltip-v2", { key: '72bdd6aabf193f323cbc5ca715314568dc3aa8c8', class: "label_info", message: this.info })), h("div", { key: '91fc2cae2fe12eb171c017fcbf2e9b5a204bc955', class: "xv-dropdown-control control", onClick: this.handleOpen }, this.selected.length ? (h("p", { class: "control_value" }, this.selected.join(', '))) : (h("p", { class: "control_placeholder" }, this.placeholder || '')), this.renderIcon(), h("svg", { key: 'ab6e2eea7aa7563f9bdfa82bd980ba62bc29037a', class: "control_arrow", focusable: "false", preserveAspectRatio: "xMidYMid meet", xmlns: "http://www.w3.org/2000/svg", fill: "currentColor", "aria-hidden": "true", width: "16", height: "16", viewBox: "0 0 16 16" }, h("path", { key: '71fc59d404e95dc3de990403370bc5abf206812b', d: "M8 11L3 6 3.7 5.3 8 9.6 12.3 5.3 13 6z" }))), this.open && h("div", { key: '52f8a04ccb8364b6e9a0b1d3ad50cbff3ebf96af', class: "options" }, h("slot", { key: "xv-dropdown-options" })), (this.helper || this.error || this.warning) && (h("p", { key: 'a83ed0ce93a8886dbdff9e0d271c8d4229ffadc0', class: "helper" }, this.error || this.warning || this.helper))));
|
|
98
98
|
}
|
|
99
99
|
componentWillLoad() {
|
|
100
100
|
this.setDefaultValues();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xv-dropdown.js","sourceRoot":"","sources":["../../../src/components/xv-dropdown/xv-dropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAgB,MAAM,eAAe,CAAC;AAC7G,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAoB,oBAAoB,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAOrD,MAAM,OAAO,UAAU;IALvB;QAkBU,SAAI,GAAa,QAAQ,CAAC,EAAE,CAAC;QAG5B,aAAQ,GAA+B,EAAE,CAAC;QAC1C,gBAAW,GAAqD,IAAI,GAAG,EAAE,CAAC;QAgD3E,gBAAW,GAAG,CAAC,WAAoC,EAAE,WAAiC,EAAsB,EAAE;YACpH,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC;YAChD,MAAM,OAAO,GAAG,WAAW,IAAI,IAAI,CAAC,EAAE,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,CAAC;YAE9E,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;gBAChD,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;gBACvC,CAAC,GAAG,MAAM,CAAC,MAAM,aAAa,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YAEhE,OAAO,MAAM,CAAC;QA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AAc,KAAK,EAAC,oBAAoB,EAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,GAAI,CAAA;QACvE,CAAC;QAED,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,OAAO,CACL,WAAK,KAAK,EAAC,oBAAoB,EAAC,KAAK,EAAC,4BAA4B,EAAC,OAAO,EAAC,aAAa;gBACtF,YAAM,IAAI,EAAC,cAAc,EACnB,CAAC,EAAC,gMAAgM,GAAG,CACvM,CACP,CAAA;QACH,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAClC,OAAO,CACL,WAAK,KAAK,EAAC,sBAAsB,EAAC,KAAK,EAAC,4BAA4B,EAAC,OAAO,EAAC,aAAa;gBACxF,YAAM,IAAI,EAAC,cAAc,EAAC,CAAC,EAAC,yTAAyT,GAAG,CACpV,CACP,CAAC;QACJ,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Host, h, Prop, State, Element, Watch, Listen, Event, EventEmitter } from '@stencil/core';\nimport { SIZE_VAR } from '../../types/enum';\nimport { DropdownItemData, DropdownItemSelector } from './_vars';\nimport { forEach, setAttr } from '../../utils/utils';\n\n@Component({\n tag: 'xv-dropdown-v2',\n styleUrl: 'xv-dropdown.scss',\n shadow: true,\n})\nexport class XvDropdown {\n @Element() el: HTMLElement;\n @Prop({ reflect: true }) disabled?: boolean;\n @Prop({ reflect: true }) multiple?: boolean;\n @Prop({ reflect: true }) required?: boolean;\n @Prop({ reflect: true }) loading?: boolean;\n @Prop({ reflect: true, mutable: true }) open?: boolean;\n @Prop({ reflect: true }) error?: string;\n @Prop({ reflect: true }) label?: string;\n @Prop({ reflect: true }) helper?: string;\n @Prop({ reflect: true }) warning?: string;\n @Prop({ reflect: true }) placeholder?: string;\n @Prop({ reflect: false }) info?: string;\n @Prop() size: SIZE_VAR = SIZE_VAR.MD;\n @Prop({ attribute: 'default-value'}) defaultValue?: DropdownItemData['value'];\n\n @State() selected: DropdownItemData['text'][] = [];\n @State() selectedMap: Map<DropdownItemData['value'], DropdownItemData> = new Map();\n\n @Event() changeSelection: EventEmitter<DropdownItemData[]>;\n\n @Watch('open')\n openChangeHandle() {\n if (this.disabled) return;\n\n if (this.open) {\n this.addListeners();\n } else {\n this.removeListeners();\n }\n }\n\n @Listen('itemSelected')\n handleItemSelected({ detail }: CustomEvent<DropdownItemData>) {\n const hasItem = this.selectedMap.has(detail.value);\n\n if (this.multiple) {\n if (detail.selected) {\n if (!hasItem) this.selectedMap.set(detail.value, detail);\n } else {\n if (hasItem) {\n if (this.required && this.selectedMap.size === 1) return;\n this.selectedMap.delete(detail.value);\n }\n }\n } else {\n if (detail.selected) {\n this.selectedMap.clear();\n this.selectedMap.set(detail.value, detail);\n } else {\n if (!this.required) this.selectedMap.clear();\n }\n this.open = false;\n }\n\n const optionElements = this.el.querySelectorAll(DropdownItemSelector);\n\n forEach(\n optionElements,\n (option) => setAttr(option, 'selected', this.selectedMap.has(option.getAttribute('value')))\n );\n\n this.changeSelection.emit(this.setSelected(this.selectedMap, optionElements));\n }\n\n private setSelected = (selectedMap: typeof this.selectedMap, optionNodes?: NodeListOf<Element>): DropdownItemData[] => {\n const values = Array.from(selectedMap.values());\n const options = optionNodes || this.el.querySelectorAll(DropdownItemSelector);\n\n this.selected = values.length === options.length ?\n ['Alle ausgewählt'] : values.length > 2 ?\n [`${values.length} ausgewählt`] : values.map((v) => v.text);\n\n return values;\n };\n\n private handleOpen = () => {\n if (this.disabled || this.open || this.loading) return;\n this.open = true;\n };\n\n private handleClickOutside = (ev: MouseEvent) => {\n if (!this.open || this.el.contains(ev.target as Node)) return;\n\n if (this.open) this.open = false;\n }\n\n private addListeners = () => {\n document.body.addEventListener('click', this.handleClickOutside);\n }\n\n private removeListeners = () => {\n document.body.removeEventListener('click', this.handleClickOutside);\n }\n\n private setDefaultValues = () => {\n if (!this.defaultValue) return;\n\n // Needs to wait next Javascript tik\n setTimeout(() => {\n const options = this.el.querySelectorAll(DropdownItemSelector);\n\n forEach(\n options,\n (option) => {\n const dropdownItemData: DropdownItemData = {\n value: option.getAttribute('value'),\n text: (option as any).innerText,\n selected: `${this.defaultValue}` === option.getAttribute('value'),\n };\n\n if (dropdownItemData.selected) {\n setAttr(option, 'selected', dropdownItemData.selected);\n this.selectedMap.set(dropdownItemData.value, dropdownItemData);\n }\n }\n );\n\n this.setSelected(this.selectedMap, options);\n });\n };\n\n render() {\n return (\n <Host\n class=\"xv-dropdown\"\n role=\"combobox\"\n size={this.size}\n open={this.open}\n error={this.error}\n disabled={this.disabled}\n tabindex={this.disabled ? -1 : false}>\n <label class=\"label\">\n <slot name=\"label\">{this.label}</slot>\n {this.info && <xv-tooltip-v2 class=\"label_info\" message={this.info}></xv-tooltip-v2>}\n </label>\n\n <div class=\"xv-dropdown-control control\" onClick={this.handleOpen}>\n {this.selected.length ? (\n <p class=\"control_value\">{this.selected.join(', ')}</p>\n ) : (\n <p class=\"control_placeholder\">{this.placeholder || ''}</p>\n )}\n\n {this.renderIcon()}\n\n <svg class=\"control_arrow\" focusable=\"false\" preserveAspectRatio=\"xMidYMid meet\"\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"currentColor\" aria-hidden=\"true\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\">\n <path d=\"M8 11L3 6 3.7 5.3 8 9.6 12.3 5.3 13 6z\"></path>\n </svg>\n </div>\n\n {this.open && <div class=\"options\">\n <slot key=\"xv-dropdown-options\" />\n </div>}\n\n {(this.helper || this.error || this.warning) && (\n <p class=\"helper\">{this.error || this.warning || this.helper}</p>\n )}\n </Host>\n );\n }\n\n componentWillLoad() {\n this.setDefaultValues();\n }\n\n componentDidLoad() {\n this.openChangeHandle();\n }\n\n disconnectedCallback() {\n this.removeListeners();\n }\n\n private renderIcon(): undefined | HTMLElement {\n if (this.loading) {\n return <xv-loader-v2 class=\"control_icon error\" size={SIZE_VAR.XS} />\n }\n\n if (this.error) {\n return (\n <svg class=\"control_icon error\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path fill=\"currentColor\"\n d=\"M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zm0-384c13.3 0 24 10.7 24 24l0 112c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-112c0-13.3 10.7-24 24-24zM224 352a32 32 0 1 1 64 0 32 32 0 1 1 -64 0z\" />\n </svg>\n )\n }\n\n if (!this.error && !!this.warning) {\n return (\n <svg class=\"control_icon warning\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path fill=\"currentColor\" d=\"M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480L40 480c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24l0 112c0 13.3 10.7 24 24 24s24-10.7 24-24l0-112c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z\" />\n </svg>\n );\n }\n\n return undefined;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"xv-dropdown.js","sourceRoot":"","sources":["../../../src/components/xv-dropdown/xv-dropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,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C,KAAK,EAAC,4BAA4B,EAAC,OAAO,EAAC,aAAa;gBACtF,YAAM,IAAI,EAAC,cAAc,EACnB,CAAC,EAAC,gMAAgM,GAAG,CACvM,CACP,CAAA;QACH,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAClC,OAAO,CACL,WAAK,KAAK,EAAC,sBAAsB,EAAC,KAAK,EAAC,4BAA4B,EAAC,OAAO,EAAC,aAAa;gBACxF,YAAM,IAAI,EAAC,cAAc,EAAC,CAAC,EAAC,yTAAyT,GAAG,CACpV,CACP,CAAC;QACJ,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Host, h, Prop, State, Element, Watch, Listen, Event, EventEmitter } from '@stencil/core';\nimport { SIZE_VAR } from '../../types/enum';\nimport { DropdownItemData, DropdownItemSelector } from './_vars';\nimport { forEach, setAttr } from '../../utils/utils';\n\n@Component({\n tag: 'xv-dropdown-v2',\n styleUrl: 'xv-dropdown.scss',\n shadow: true,\n})\nexport class XvDropdown {\n @Element() el: HTMLElement;\n @Prop({ reflect: true }) disabled?: boolean;\n @Prop({ reflect: true }) multiple?: boolean;\n @Prop({ reflect: true }) required?: boolean;\n @Prop({ reflect: true }) loading?: boolean;\n @Prop({ reflect: true, mutable: true }) open?: boolean;\n @Prop({ reflect: true }) error?: string;\n @Prop({ reflect: true }) label?: string;\n @Prop({ reflect: true }) helper?: string;\n @Prop({ reflect: true }) warning?: string;\n @Prop({ reflect: true }) placeholder?: string;\n @Prop({ reflect: false }) info?: string;\n @Prop() size: SIZE_VAR = SIZE_VAR.MD;\n @Prop({ attribute: 'default-value'}) defaultValue?: DropdownItemData['value'];\n\n @State() selected: DropdownItemData['text'][] = [];\n @State() selectedMap: Map<DropdownItemData['value'], DropdownItemData> = new Map();\n\n @Event() changeSelection: EventEmitter<DropdownItemData[]>;\n\n @Watch('open')\n openChangeHandle() {\n if (this.disabled) return;\n\n if (this.open) {\n this.addListeners();\n } else {\n this.removeListeners();\n }\n }\n\n @Listen('itemSelected')\n handleItemSelected({ detail }: CustomEvent<DropdownItemData>) {\n const hasItem = this.selectedMap.has(detail.value);\n\n if (this.multiple) {\n if (detail.selected) {\n if (!hasItem) this.selectedMap.set(detail.value, detail);\n } else {\n if (hasItem) {\n if (this.required && this.selectedMap.size === 1) return;\n this.selectedMap.delete(detail.value);\n }\n }\n } else {\n if (detail.selected) {\n this.selectedMap.clear();\n this.selectedMap.set(detail.value, detail);\n } else {\n if (!this.required) this.selectedMap.clear();\n }\n this.open = false;\n }\n\n const optionElements = this.el.querySelectorAll(DropdownItemSelector);\n\n forEach(\n optionElements,\n (option) => setAttr(option, 'selected', this.selectedMap.has(option.getAttribute('value')))\n );\n\n this.changeSelection.emit(this.setSelected(this.selectedMap, optionElements));\n }\n\n private setSelected = (selectedMap: typeof this.selectedMap, optionNodes?: NodeListOf<Element>): DropdownItemData[] => {\n const values = Array.from(selectedMap.values());\n const options = optionNodes || this.el.querySelectorAll(DropdownItemSelector);\n\n this.selected = this.multiple && values.length === options.length ?\n ['Alle ausgewählt'] : values.length > 2 ?\n [`${values.length} ausgewählt`] : values.map((v) => v.text);\n\n return values;\n };\n\n private handleOpen = () => {\n if (this.disabled || this.open || this.loading) return;\n this.open = true;\n };\n\n private handleClickOutside = (ev: MouseEvent) => {\n if (!this.open || this.el.contains(ev.target as Node)) return;\n\n if (this.open) this.open = false;\n }\n\n private addListeners = () => {\n document.body.addEventListener('click', this.handleClickOutside);\n }\n\n private removeListeners = () => {\n document.body.removeEventListener('click', this.handleClickOutside);\n }\n\n private setDefaultValues = () => {\n if (!this.defaultValue) return;\n\n // Needs to wait next Javascript tik\n setTimeout(() => {\n const options = this.el.querySelectorAll(DropdownItemSelector);\n\n forEach(\n options,\n (option) => {\n const dropdownItemData: DropdownItemData = {\n value: option.getAttribute('value'),\n text: (option as any).innerText,\n selected: `${this.defaultValue}` === option.getAttribute('value'),\n };\n\n if (dropdownItemData.selected) {\n setAttr(option, 'selected', dropdownItemData.selected);\n this.selectedMap.set(dropdownItemData.value, dropdownItemData);\n }\n }\n );\n\n this.setSelected(this.selectedMap, options);\n });\n };\n\n render() {\n return (\n <Host\n class=\"xv-dropdown\"\n role=\"combobox\"\n size={this.size}\n open={this.open}\n error={this.error}\n disabled={this.disabled}\n tabindex={this.disabled ? -1 : false}>\n <label class=\"label\">\n <slot name=\"label\">{this.label}</slot>\n {this.info && <xv-tooltip-v2 class=\"label_info\" message={this.info}></xv-tooltip-v2>}\n </label>\n\n <div class=\"xv-dropdown-control control\" onClick={this.handleOpen}>\n {this.selected.length ? (\n <p class=\"control_value\">{this.selected.join(', ')}</p>\n ) : (\n <p class=\"control_placeholder\">{this.placeholder || ''}</p>\n )}\n\n {this.renderIcon()}\n\n <svg class=\"control_arrow\" focusable=\"false\" preserveAspectRatio=\"xMidYMid meet\"\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"currentColor\" aria-hidden=\"true\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\">\n <path d=\"M8 11L3 6 3.7 5.3 8 9.6 12.3 5.3 13 6z\"></path>\n </svg>\n </div>\n\n {this.open && <div class=\"options\">\n <slot key=\"xv-dropdown-options\" />\n </div>}\n\n {(this.helper || this.error || this.warning) && (\n <p class=\"helper\">{this.error || this.warning || this.helper}</p>\n )}\n </Host>\n );\n }\n\n componentWillLoad() {\n this.setDefaultValues();\n }\n\n componentDidLoad() {\n this.openChangeHandle();\n }\n\n disconnectedCallback() {\n this.removeListeners();\n }\n\n private renderIcon(): undefined | HTMLElement {\n if (this.loading) {\n return <xv-loader-v2 class=\"control_icon error\" size={SIZE_VAR.XS} />\n }\n\n if (this.error) {\n return (\n <svg class=\"control_icon error\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path fill=\"currentColor\"\n d=\"M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zm0-384c13.3 0 24 10.7 24 24l0 112c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-112c0-13.3 10.7-24 24-24zM224 352a32 32 0 1 1 64 0 32 32 0 1 1 -64 0z\" />\n </svg>\n )\n }\n\n if (!this.error && !!this.warning) {\n return (\n <svg class=\"control_icon warning\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path fill=\"currentColor\" d=\"M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480L40 480c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24l0 112c0 13.3 10.7 24 24 24s24-10.7 24-24l0-112c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z\" />\n </svg>\n );\n }\n\n return undefined;\n }\n}\n"]}
|
|
@@ -1,3 +1,98 @@
|
|
|
1
|
+
.xv-tooltip[role=tooltip] {
|
|
2
|
+
position: absolute;
|
|
3
|
+
background-color: var(--background-inverse, #333333);
|
|
4
|
+
color: var(--text-on-color);
|
|
5
|
+
padding: var(--spacing-03) var(--spacing-04);
|
|
6
|
+
border-radius: 3px;
|
|
7
|
+
font-size: var(--fz-sm);
|
|
8
|
+
z-index: 999;
|
|
9
|
+
min-width: min(150px, 90vw);
|
|
10
|
+
max-width: min(400px, 90vw);
|
|
11
|
+
}
|
|
12
|
+
.xv-tooltip[role=tooltip]::after {
|
|
13
|
+
content: "";
|
|
14
|
+
position: absolute;
|
|
15
|
+
width: 0;
|
|
16
|
+
height: 0;
|
|
17
|
+
border-style: solid;
|
|
18
|
+
}
|
|
19
|
+
.xv-tooltip[role=tooltip][data-popper-placement=top]::after {
|
|
20
|
+
bottom: -5px;
|
|
21
|
+
left: 50%;
|
|
22
|
+
transform: translateX(-50%);
|
|
23
|
+
border-width: 5px 5px 0 5px;
|
|
24
|
+
border-color: var(--background-inverse, black) transparent transparent transparent;
|
|
25
|
+
}
|
|
26
|
+
.xv-tooltip[role=tooltip][data-popper-placement=top-start]::after {
|
|
27
|
+
bottom: -5px;
|
|
28
|
+
left: 12px;
|
|
29
|
+
border-width: 5px 5px 0 5px;
|
|
30
|
+
border-color: var(--background-inverse, black) transparent transparent transparent;
|
|
31
|
+
}
|
|
32
|
+
.xv-tooltip[role=tooltip][data-popper-placement=top-end]::after {
|
|
33
|
+
bottom: -5px;
|
|
34
|
+
right: 12px;
|
|
35
|
+
border-width: 5px 5px 0 5px;
|
|
36
|
+
border-color: var(--background-inverse, black) transparent transparent transparent;
|
|
37
|
+
}
|
|
38
|
+
.xv-tooltip[role=tooltip][data-popper-placement=bottom]::after {
|
|
39
|
+
top: -5px;
|
|
40
|
+
left: 50%;
|
|
41
|
+
transform: translateX(-50%);
|
|
42
|
+
border-width: 0 5px 5px 5px;
|
|
43
|
+
border-color: transparent transparent var(--background-inverse, black) transparent;
|
|
44
|
+
}
|
|
45
|
+
.xv-tooltip[role=tooltip][data-popper-placement=bottom-start]::after {
|
|
46
|
+
top: -5px;
|
|
47
|
+
left: 12px;
|
|
48
|
+
border-width: 0 5px 5px 5px;
|
|
49
|
+
border-color: transparent transparent var(--background-inverse, black) transparent;
|
|
50
|
+
}
|
|
51
|
+
.xv-tooltip[role=tooltip][data-popper-placement=bottom-end]::after {
|
|
52
|
+
top: -5px;
|
|
53
|
+
right: 12px;
|
|
54
|
+
border-width: 0 5px 5px 5px;
|
|
55
|
+
border-color: transparent transparent var(--background-inverse, black) transparent;
|
|
56
|
+
}
|
|
57
|
+
.xv-tooltip[role=tooltip][data-popper-placement=left]::after {
|
|
58
|
+
top: 50%;
|
|
59
|
+
right: -5px;
|
|
60
|
+
transform: translateY(-50%);
|
|
61
|
+
border-width: 5px 0 5px 5px;
|
|
62
|
+
border-color: transparent transparent transparent var(--background-inverse, black);
|
|
63
|
+
}
|
|
64
|
+
.xv-tooltip[role=tooltip][data-popper-placement=left-start]::after {
|
|
65
|
+
top: 12px;
|
|
66
|
+
right: -5px;
|
|
67
|
+
border-width: 5px 0 5px 5px;
|
|
68
|
+
border-color: transparent transparent transparent var(--background-inverse, black);
|
|
69
|
+
}
|
|
70
|
+
.xv-tooltip[role=tooltip][data-popper-placement=left-end]::after {
|
|
71
|
+
bottom: 12px;
|
|
72
|
+
right: -5px;
|
|
73
|
+
border-width: 5px 0 5px 5px;
|
|
74
|
+
border-color: transparent transparent transparent var(--background-inverse, black);
|
|
75
|
+
}
|
|
76
|
+
.xv-tooltip[role=tooltip][data-popper-placement=right]::after {
|
|
77
|
+
top: 50%;
|
|
78
|
+
left: -5px;
|
|
79
|
+
transform: translateY(-50%);
|
|
80
|
+
border-width: 5px 5px 5px 0;
|
|
81
|
+
border-color: transparent var(--background-inverse, black) transparent transparent;
|
|
82
|
+
}
|
|
83
|
+
.xv-tooltip[role=tooltip][data-popper-placement=right-start]::after {
|
|
84
|
+
top: 12px;
|
|
85
|
+
left: -5px;
|
|
86
|
+
border-width: 5px 5px 5px 0;
|
|
87
|
+
border-color: transparent var(--background-inverse, black) transparent transparent;
|
|
88
|
+
}
|
|
89
|
+
.xv-tooltip[role=tooltip][data-popper-placement=right-end]::after {
|
|
90
|
+
bottom: 12px;
|
|
91
|
+
left: -5px;
|
|
92
|
+
border-width: 5px 5px 5px 0;
|
|
93
|
+
border-color: transparent var(--background-inverse, black) transparent transparent;
|
|
94
|
+
}
|
|
95
|
+
|
|
1
96
|
:host {
|
|
2
97
|
font-family: inherit;
|
|
3
98
|
display: flex;
|
|
@@ -30,6 +125,7 @@
|
|
|
30
125
|
background-color: var(--background-inverse-hover);
|
|
31
126
|
}
|
|
32
127
|
:host .drop-zone {
|
|
128
|
+
min-height: 90px;
|
|
33
129
|
border: 1px dashed var(--border-strong-01);
|
|
34
130
|
background-color: transparent;
|
|
35
131
|
padding: 1.14em;
|
|
@@ -96,8 +192,9 @@
|
|
|
96
192
|
margin: 0;
|
|
97
193
|
padding: 0;
|
|
98
194
|
}
|
|
99
|
-
:host .error-
|
|
195
|
+
:host .error-container_secondary {
|
|
100
196
|
color: var(--text-secondary, #515151);
|
|
197
|
+
white-space: pre-line;
|
|
101
198
|
}
|
|
102
199
|
|
|
103
200
|
:host(.disabled) {
|
|
@@ -6,6 +6,7 @@ export class XvFileUploader {
|
|
|
6
6
|
this.variant = XvFileUploaderVariants.BUTTON;
|
|
7
7
|
this.size = SIZE_VAR.MD;
|
|
8
8
|
this.accept = [];
|
|
9
|
+
this.buttonVariant = 'primary';
|
|
9
10
|
this.maxFileSizeMB = 5;
|
|
10
11
|
this.maxFiles = 20;
|
|
11
12
|
this.multiple = true;
|
|
@@ -38,8 +39,13 @@ export class XvFileUploader {
|
|
|
38
39
|
this.dragActive = false;
|
|
39
40
|
};
|
|
40
41
|
}
|
|
42
|
+
async clearFiles() {
|
|
43
|
+
this.files = [];
|
|
44
|
+
if (this.fileInput) {
|
|
45
|
+
this.fileInput.value = '';
|
|
46
|
+
}
|
|
47
|
+
}
|
|
41
48
|
validation(files) {
|
|
42
|
-
var _a;
|
|
43
49
|
const maxSize = this.maxFileSizeMB * 1024 * 1024;
|
|
44
50
|
const seenFileNames = new Set();
|
|
45
51
|
const errorMessages = [];
|
|
@@ -50,12 +56,9 @@ export class XvFileUploader {
|
|
|
50
56
|
seenFileNames.add(file.name);
|
|
51
57
|
uniqueFiles.push(file);
|
|
52
58
|
}
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
const normalized = type.toLowerCase().replace(/^\./, '');
|
|
57
|
-
return normalized === extension;
|
|
58
|
-
});
|
|
59
|
+
const dotIndex = file.name.lastIndexOf('.');
|
|
60
|
+
const extension = file.name.substring(dotIndex).toLowerCase();
|
|
61
|
+
const isAccepted = this.accept.length === 0 || this.accept.some(type => type.toLowerCase() === extension);
|
|
59
62
|
if (!isAccepted) {
|
|
60
63
|
error = 'Unsupported file type.';
|
|
61
64
|
}
|
|
@@ -71,6 +74,8 @@ export class XvFileUploader {
|
|
|
71
74
|
return uniqueFiles;
|
|
72
75
|
}
|
|
73
76
|
removeFile(index) {
|
|
77
|
+
if (this.files[index])
|
|
78
|
+
this.fileRemoved.emit(this.files[index]);
|
|
74
79
|
this.files = this.validation([...this.files.slice(0, index), ...this.files.slice(index + 1)]);
|
|
75
80
|
this.filesChange.emit(this.files);
|
|
76
81
|
if (this.fileInput) {
|
|
@@ -79,10 +84,10 @@ export class XvFileUploader {
|
|
|
79
84
|
}
|
|
80
85
|
render() {
|
|
81
86
|
var _a;
|
|
82
|
-
return (h(Host, { key: '
|
|
87
|
+
return (h(Host, { key: '4a33985fd3a6b9213d592ebec1b5b8abbf1d27df', class: { 'upload-wrapper': true, [`uploader-${this.size}`]: true, disabled: !!this.disabled } }, this.label && h("label", { key: '127894a635ce497df0a3a4732f5fc5a28f4d635b', class: "label" }, this.label), this.description && h("p", { key: 'dc34a999207c109b45f6e793552ff93b144fde85', class: "description" }, this.description), this.variant === 'button' ? (h("xv-button-v2", { variant: this.buttonVariant, disabled: this.disabled, onClick: () => this.fileInput.click() }, this.addText || 'Dateien auswählen')) : (h("div", { class: { 'drop-zone': true, active: this.dragActive }, onDrop: this.onDrop, onDragOver: this.onDragOver, onDragLeave: this.onDragLeave, onClick: () => this.fileInput.click() }, this.addText || 'Dateien hierher ziehen oder darauf klicken, um eine Datei auszuwählen.', ((_a = this.accept) === null || _a === void 0 ? void 0 : _a.length) > 0 && h("span", null, " (", this.accept.join(', '), ")"))), h("input", { key: 'f7d47bff9993ab16abb38d70a065c6778f141359', ref: el => (this.fileInput = el), type: "file", hidden: true, onChange: this.onFileSelect, multiple: this.multiple, accept: this.accept.join(',') }), h("ul", { key: '04f33d47b7f3389b29b880261eb7d032ffea37e4', class: "file-list" }, this.files.map((file, index) => {
|
|
83
88
|
var _a, _b;
|
|
84
89
|
return (h("li", { class: { file: true, withError: !!(((_a = this.errors) === null || _a === void 0 ? void 0 : _a[index]) || ((_b = this.errorMessages) === null || _b === void 0 ? void 0 : _b[index])) } }, h("div", { class: "file_container" }, h("span", { class: "file_container_name" }, file.name), this._renderLoaderState(index)), this._renderError(index)));
|
|
85
|
-
})), this.error && (h("div", { key: '
|
|
90
|
+
})), this.error && (h("div", { key: '21aae629c18e97fc42f478e78ed4b771975389ab', class: "error-container" }, h("p", { key: '2fefb6eae6b6a8d838f6aca2ff05c5981f1491a2', class: "error-container_primary" }, this.error)))));
|
|
86
91
|
}
|
|
87
92
|
_renderLoaderState(index) {
|
|
88
93
|
var _a, _b, _c;
|
|
@@ -92,7 +97,7 @@ export class XvFileUploader {
|
|
|
92
97
|
case 'loading':
|
|
93
98
|
return (h(Fragment, null, errorIcon, h("xv-loader-v2", { size: SIZE_VAR.XS })));
|
|
94
99
|
case 'success':
|
|
95
|
-
return (h(Fragment, null, errorIcon, h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 18 16", fill: "none" }, h("path", { d: "M9 16C6.125 16 3.5 14.5 2.0625 12C0.625 9.53125 0.625 6.5 2.0625 4C3.5 1.53125 6.125 0 9 0C11.8438 0 14.4688 1.53125 15.9062 4C17.3438 6.5 17.3438 9.53125 15.9062 12C14.4688 14.5 11.8438 16 9 16ZM12.5312 6.53125H12.5C12.8125 6.25 12.8125 5.78125 12.5 5.46875C12.2188 5.1875 11.75 5.1875 11.4688 5.46875L8 8.96875L6.53125 7.5C6.21875 7.1875 5.75 7.1875 5.46875 7.5C5.15625 7.78125 5.15625 8.25 5.46875 8.53125L7.46875 10.5312C7.75 10.8438 8.21875 10.8438 8.53125 10.5312L12.5312 6.53125Z", fill: "#97BF0D" }))));
|
|
100
|
+
return (h(Fragment, null, errorIcon, h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 18 16", fill: "none" }, h("path", { d: "M9 16C6.125 16 3.5 14.5 2.0625 12C0.625 9.53125 0.625 6.5 2.0625 4C3.5 1.53125 6.125 0 9 0C11.8438 0 14.4688 1.53125 15.9062 4C17.3438 6.5 17.3438 9.53125 15.9062 12C14.4688 14.5 11.8438 16 9 16ZM12.5312 6.53125H12.5C12.8125 6.25 12.8125 5.78125 12.5 5.46875C12.2188 5.1875 11.75 5.1875 11.4688 5.46875L8 8.96875L6.53125 7.5C6.21875 7.1875 5.75 7.1875 5.46875 7.5C5.15625 7.78125 5.15625 8.25 5.46875 8.53125L7.46875 10.5312C7.75 10.8438 8.21875 10.8438 8.53125 10.5312L12.5312 6.53125Z", fill: "#97BF0D" })), h("xv-button-v2", { variant: "ghost", size: SIZE_VAR.XS, onClick: () => this.removeFile(index) }, h("span", { slot: "icon-left" }, "\u00D7"))));
|
|
96
101
|
case 'uploaded':
|
|
97
102
|
default:
|
|
98
103
|
return (h(Fragment, null, errorIcon, h("xv-button-v2", { variant: "ghost", size: SIZE_VAR.XS, onClick: () => this.removeFile(index) }, h("span", { slot: "icon-left" }, "\u00D7"))));
|
|
@@ -253,6 +258,26 @@ export class XvFileUploader {
|
|
|
253
258
|
"setter": false,
|
|
254
259
|
"defaultValue": "[]"
|
|
255
260
|
},
|
|
261
|
+
"buttonVariant": {
|
|
262
|
+
"type": "string",
|
|
263
|
+
"attribute": "button-variant",
|
|
264
|
+
"mutable": false,
|
|
265
|
+
"complexType": {
|
|
266
|
+
"original": "'primary' | 'secondary' | 'ghost' | 'danger' | 'tertiary'",
|
|
267
|
+
"resolved": "\"danger\" | \"ghost\" | \"primary\" | \"secondary\" | \"tertiary\"",
|
|
268
|
+
"references": {}
|
|
269
|
+
},
|
|
270
|
+
"required": false,
|
|
271
|
+
"optional": false,
|
|
272
|
+
"docs": {
|
|
273
|
+
"tags": [],
|
|
274
|
+
"text": ""
|
|
275
|
+
},
|
|
276
|
+
"getter": false,
|
|
277
|
+
"setter": false,
|
|
278
|
+
"reflect": false,
|
|
279
|
+
"defaultValue": "'primary'"
|
|
280
|
+
},
|
|
256
281
|
"maxFileSizeMB": {
|
|
257
282
|
"type": "number",
|
|
258
283
|
"attribute": "max-file-size-mb",
|
|
@@ -442,7 +467,48 @@ export class XvFileUploader {
|
|
|
442
467
|
}
|
|
443
468
|
}
|
|
444
469
|
}
|
|
470
|
+
}, {
|
|
471
|
+
"method": "fileRemoved",
|
|
472
|
+
"name": "fileRemoved",
|
|
473
|
+
"bubbles": true,
|
|
474
|
+
"cancelable": true,
|
|
475
|
+
"composed": true,
|
|
476
|
+
"docs": {
|
|
477
|
+
"tags": [],
|
|
478
|
+
"text": ""
|
|
479
|
+
},
|
|
480
|
+
"complexType": {
|
|
481
|
+
"original": "File",
|
|
482
|
+
"resolved": "File",
|
|
483
|
+
"references": {
|
|
484
|
+
"File": {
|
|
485
|
+
"location": "global",
|
|
486
|
+
"id": "global::File"
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
}
|
|
445
490
|
}];
|
|
446
491
|
}
|
|
492
|
+
static get methods() {
|
|
493
|
+
return {
|
|
494
|
+
"clearFiles": {
|
|
495
|
+
"complexType": {
|
|
496
|
+
"signature": "() => Promise<void>",
|
|
497
|
+
"parameters": [],
|
|
498
|
+
"references": {
|
|
499
|
+
"Promise": {
|
|
500
|
+
"location": "global",
|
|
501
|
+
"id": "global::Promise"
|
|
502
|
+
}
|
|
503
|
+
},
|
|
504
|
+
"return": "Promise<void>"
|
|
505
|
+
},
|
|
506
|
+
"docs": {
|
|
507
|
+
"text": "",
|
|
508
|
+
"tags": []
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
};
|
|
512
|
+
}
|
|
447
513
|
}
|
|
448
514
|
//# sourceMappingURL=xv-file-uploader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xv-file-uploader.js","sourceRoot":"","sources":["../../../src/components/xv-file-uploader/xv-file-uploader.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAgB,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAOjD,MAAM,OAAO,cAAc;IAL3B;QASU,YAAO,GAA2B,sBAAsB,CAAC,MAAM,CAAC;QAChE,SAAI,GAAa,QAAQ,CAAC,EAAE,CAAC;QAC7B,WAAM,GAAa,EAAE,CAAC;QACW,kBAAa,GAAW,CAAC,CAAC;QACjC,aAAQ,GAAW,EAAE,CAAC;QAChD,aAAQ,GAAY,IAAI,CAAC;QAEO,UAAK,GAAW,EAAE,CAAC;QACU,kBAAa,GAA2C,EAAE,CAAC;QAExF,WAAM,GAAyD,EAAE,CAAC;QAEjG,eAAU,GAAG,KAAK,CAAC;QACnB,kBAAa,GAAa,EAAE,CAAC;QAM9B,iBAAY,GAAG,CAAC,KAAY,EAAE,EAAE;YACtC,MAAM,KAAK,GAAG,KAAK,CAAC,MAA0B,CAAC;YAC/C,MAAM,aAAa,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;YACpD,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;QAClC,CAAC,CAAC;QAEM,WAAM,GAAG,CAAC,KAAgB,EAAE,EAAE;;YACpC,KAAK,CAAC,cAAc,EAAE,CAAC;YACvB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;YACxB,MAAM,YAAY,GA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AO;QAEnB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,OAAO,CACL,WAAK,KAAK,EAAC,iBAAiB;gBAC1B,SAAG,KAAK,EAAC,yBAAyB,IAAE,KAAK,CAAC,OAAO,CAAK;gBACtD,SAAG,KAAK,EAAC,2BAA2B,IAAE,KAAK,CAAC,SAAS,CAAK,CACtD,CACP,CAAC;QACJ,CAAC;QAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,OAAO,CACL,WAAK,KAAK,EAAC,iBAAiB;gBAC1B,SAAG,KAAK,EAAC,yBAAyB,IAAE,KAAK,CAAK,CAC1C,CACP,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, EventEmitter, Event, h, Host, Prop, State, Fragment } from '@stencil/core';\nimport { SIZE_VAR } from '../../types/enum';\nimport { XvFileUploaderVariants } from './_vars';\n\n@Component({\n tag: 'xv-file-uploader',\n styleUrl: 'xv-file-uploader.scss',\n shadow: true,\n})\nexport class XvFileUploader {\n @Prop() label?: string;\n @Prop() description?: string;\n @Prop({ attribute: 'add-text' }) addText?: string;\n @Prop() variant: XvFileUploaderVariants = XvFileUploaderVariants.BUTTON;\n @Prop() size: SIZE_VAR = SIZE_VAR.MD;\n @Prop() accept: string[] = [];\n @Prop({ attribute: 'max-file-size-mb' }) maxFileSizeMB: number = 5;\n @Prop({ attribute: 'max-files' }) maxFiles: number = 20;\n @Prop() multiple: boolean = true;\n @Prop({ reflect: true }) disabled?: boolean;\n @Prop({ reflect: true, mutable: true }) files: File[] = [];\n @Prop({ reflect: true, mutable: true, attribute: 'loading-states' }) loadingStates: ('loading' | 'success' | 'uploaded')[] = [];\n @Prop({ reflect: true, mutable: true }) error?: string;\n @Prop({ reflect: true, mutable: true }) errors: string[] | { primary: string; secondary: string; }[] = [];\n\n @State() dragActive = false;\n @State() errorMessages: string[] = [];\n\n @Event() filesChange: EventEmitter<File[]>;\n\n private fileInput: HTMLInputElement;\n\n private onFileSelect = (event: Event) => {\n const input = event.target as HTMLInputElement;\n const selectedFiles = Array.from(input.files || []);\n this.handleFiles(selectedFiles);\n };\n\n private onDrop = (event: DragEvent) => {\n event.preventDefault();\n this.dragActive = false;\n const droppedFiles = Array.from(event.dataTransfer?.files || []);\n this.handleFiles(droppedFiles);\n };\n\n private handleFiles = (files: File[]) => {\n this.files = this.validation(this.multiple ? [...this.files, ...files] : files);\n this.filesChange.emit(this.files);\n };\n\n private validation(files: File[]): File[] {\n const maxSize = this.maxFileSizeMB * 1024 * 1024;\n const seenFileNames = new Set<string>();\n const errorMessages: (string | null)[] = [];\n const uniqueFiles: File[] = [];\n\n for (const file of files) {\n let error: string | undefined = null;\n\n if (!seenFileNames.has(file.name)) {\n seenFileNames.add(file.name);\n uniqueFiles.push(file);\n }\n\n const extension = file.name.split('.').pop()?.toLowerCase();\n const isAccepted =\n this.accept.length === 0 ||\n this.accept.some(type => {\n const normalized = type.toLowerCase().replace(/^\\./, '');\n return normalized === extension;\n });\n\n if (!isAccepted) {\n error = 'Unsupported file type.';\n } else if (file.size > maxSize) {\n error = `File ${file.name} is too large.`;\n }\n\n errorMessages.push(error);\n }\n\n this.error = uniqueFiles.length > this.maxFiles\n ? `Only ${this.maxFiles} file(s) allowed.`\n : null;\n\n this.errorMessages = errorMessages;\n\n return uniqueFiles;\n }\n\n private removeFile(index: number) {\n this.files = this.validation([...this.files.slice(0, index), ...this.files.slice(index + 1)]);\n this.filesChange.emit(this.files);\n if (this.fileInput) {\n this.fileInput.value = '';\n }\n }\n\n private onDragOver = (event: DragEvent) => {\n event.preventDefault();\n this.dragActive = true;\n };\n\n private onDragLeave = () => {\n this.dragActive = false;\n };\n\n render() {\n return (\n <Host class={{ 'upload-wrapper': true, [`uploader-${this.size}`]: true, disabled: !!this.disabled }}>\n {this.label && <label class=\"label\">{this.label}</label>}\n {this.description && <p class=\"description\">{this.description}</p>}\n {this.variant === 'button' ? (\n <button disabled={this.disabled} class=\"upload-btn\" onClick={() => this.fileInput.click()}>\n {this.addText || 'Dateien auswählen'}\n </button>\n ) : (\n <div\n class={{ 'drop-zone': true, active: this.dragActive }}\n onDrop={this.onDrop}\n onDragOver={this.onDragOver}\n onDragLeave={this.onDragLeave}\n onClick={() => this.fileInput.click()}\n >\n {this.addText || 'Dateien hierher ziehen oder darauf klicken, um eine Datei auszuwählen.'}\n {this.accept?.length > 0 && <span> ({this.accept.join(', ')})</span>}\n </div>\n )}\n\n <input\n ref={el => (this.fileInput = el)}\n type=\"file\"\n hidden\n onChange={this.onFileSelect}\n multiple={this.multiple}\n accept={this.accept.map(type => `.${type}`).join(',')}\n />\n\n <ul class=\"file-list\">\n {this.files.map((file, index) => (\n <li class={{ file: true, withError: !!(this.errors?.[index] || this.errorMessages?.[index]) }}>\n <div class=\"file_container\">\n <span class=\"file_container_name\">{file.name}</span>\n {this._renderLoaderState(index)}\n </div>\n {this._renderError(index)}\n </li>\n ))}\n </ul>\n {this.error && (\n <div class=\"error-container\">\n <p class=\"error-container_primary\">{this.error}</p>\n </div>\n )}\n </Host>\n );\n }\n\n private _renderLoaderState(index: number) {\n const state = this.loadingStates?.[index] || null;\n\n const errorIcon = this.errors?.[index] || this.errorMessages?.[index] ? (\n <svg class=\"file_container_errorIcon\" width=\"16\" height=\"16\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path fill=\"currentColor\"\n d=\"M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zm0-384c13.3 0 24 10.7 24 24l0 112c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-112c0-13.3 10.7-24 24-24zM224 352a32 32 0 1 1 64 0 32 32 0 1 1 -64 0z\" />\n </svg>\n ) : null;\n\n switch (state) {\n case 'loading':\n return (\n <Fragment>\n {errorIcon}\n <xv-loader-v2 size={SIZE_VAR.XS} />\n </Fragment>\n );\n case 'success':\n return (\n <Fragment>\n {errorIcon}\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 18 16\" fill=\"none\">\n <path\n d=\"M9 16C6.125 16 3.5 14.5 2.0625 12C0.625 9.53125 0.625 6.5 2.0625 4C3.5 1.53125 6.125 0 9 0C11.8438 0 14.4688 1.53125 15.9062 4C17.3438 6.5 17.3438 9.53125 15.9062 12C14.4688 14.5 11.8438 16 9 16ZM12.5312 6.53125H12.5C12.8125 6.25 12.8125 5.78125 12.5 5.46875C12.2188 5.1875 11.75 5.1875 11.4688 5.46875L8 8.96875L6.53125 7.5C6.21875 7.1875 5.75 7.1875 5.46875 7.5C5.15625 7.78125 5.15625 8.25 5.46875 8.53125L7.46875 10.5312C7.75 10.8438 8.21875 10.8438 8.53125 10.5312L12.5312 6.53125Z\"\n fill=\"#97BF0D\" />\n </svg>\n </Fragment>\n );\n case 'uploaded':\n default:\n return (\n <Fragment>\n {errorIcon}\n <xv-button-v2 variant=\"ghost\" size={SIZE_VAR.XS} onClick={() => this.removeFile(index)}>\n <span slot=\"icon-left\">×</span>\n </xv-button-v2>\n </Fragment>\n );\n }\n }\n\n private _renderError(index: number) {\n const error = this.errors?.[index] || this.errorMessages?.[index];\n\n if (!error) return;\n\n if (typeof error === 'object') {\n return (\n <div class=\"error-container\">\n <p class=\"error-container_primary\">{error.primary}</p>\n <p class=\"error-container_secondary\">{error.secondary}</p>\n </div>\n );\n }\n\n if (typeof error === 'string') {\n return (\n <div class=\"error-container\">\n <p class=\"error-container_primary\">{error}</p>\n </div>\n );\n }\n\n return null;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"xv-file-uploader.js","sourceRoot":"","sources":["../../../src/components/xv-file-uploader/xv-file-uploader.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAgB,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvG,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAOjD,MAAM,OAAO,cAAc;IAL3B;QASU,YAAO,GAA2B,sBAAsB,CAAC,MAAM,CAAC;QAChE,SAAI,GAAa,QAAQ,CAAC,EAAE,CAAC;QAC7B,WAAM,GAAa,EAAE,CAAC;QACtB,kBAAa,GAA8D,SAAS,CAAC;QACpD,kBAAa,GAAW,CAAC,CAAC;QACjC,aAAQ,GAAW,EAAE,CAAC;QAChD,aAAQ,GAAY,IAAI,CAAC;QAEO,UAAK,GAAW,EAAE,CAAC;QACU,kBAAa,GAA2C,EAAE,CAAC;QAExF,WAAM,GAAyD,EAAE,CAAC;QAEjG,eAAU,GAAG,KAAK,CAAC;QACnB,kBAAa,GAAa,EAAE,CAAC;QAe9B,iBAAY,GAAG,CAAC,KAAY,EAAE,EAAE;YACtC,MAAM,KAAK,GAAG,KAAK,CAAC,MAA0B,CAAC;YAC/C,MAAM,aAAa,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;YACpD,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;QAClC,CAAC,CAAC;QAEM,WAAM,GAAG,CAAC,KAAgB,EAAE,EAAE;;YACpC,KAAK,CAAC,cAAc,EAAE,CAAC;YACvB,IAAI,CAAC,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, EventEmitter, Event, h, Host, Prop, State, Fragment, Method } from '@stencil/core';\nimport { SIZE_VAR } from '../../types/enum';\nimport { XvFileUploaderVariants } from './_vars';\n\n@Component({\n tag: 'xv-file-uploader',\n styleUrl: 'xv-file-uploader.scss',\n shadow: true,\n})\nexport class XvFileUploader {\n @Prop() label?: string;\n @Prop() description?: string;\n @Prop({ attribute: 'add-text' }) addText?: string;\n @Prop() variant: XvFileUploaderVariants = XvFileUploaderVariants.BUTTON;\n @Prop() size: SIZE_VAR = SIZE_VAR.MD;\n @Prop() accept: string[] = [];\n @Prop() buttonVariant: 'primary' | 'secondary' | 'ghost' | 'danger' | 'tertiary' = 'primary';\n @Prop({ attribute: 'max-file-size-mb' }) maxFileSizeMB: number = 5;\n @Prop({ attribute: 'max-files' }) maxFiles: number = 20;\n @Prop() multiple: boolean = true;\n @Prop({ reflect: true }) disabled?: boolean;\n @Prop({ reflect: true, mutable: true }) files: File[] = [];\n @Prop({ reflect: true, mutable: true, attribute: 'loading-states' }) loadingStates: ('loading' | 'success' | 'uploaded')[] = [];\n @Prop({ reflect: true, mutable: true }) error?: string;\n @Prop({ reflect: true, mutable: true }) errors: string[] | { primary: string; secondary: string; }[] = [];\n\n @State() dragActive = false;\n @State() errorMessages: string[] = [];\n\n @Event() filesChange: EventEmitter<File[]>;\n @Event() fileRemoved: EventEmitter<File>;\n\n private fileInput: HTMLInputElement;\n\n @Method()\n async clearFiles() {\n this.files = [];\n if (this.fileInput) {\n this.fileInput.value = '';\n }\n }\n\n private onFileSelect = (event: Event) => {\n const input = event.target as HTMLInputElement;\n const selectedFiles = Array.from(input.files || []);\n this.handleFiles(selectedFiles);\n };\n\n private onDrop = (event: DragEvent) => {\n event.preventDefault();\n this.dragActive = false;\n const droppedFiles = Array.from(event.dataTransfer?.files || []);\n this.handleFiles(droppedFiles);\n };\n\n private handleFiles = (files: File[]) => {\n this.files = this.validation(this.multiple ? [...this.files, ...files] : files);\n this.filesChange.emit(this.files);\n };\n\n private validation(files: File[]): File[] {\n const maxSize = this.maxFileSizeMB * 1024 * 1024;\n const seenFileNames = new Set<string>();\n const errorMessages: (string | null)[] = [];\n const uniqueFiles: File[] = [];\n\n for (const file of files) {\n let error: string | undefined = null;\n\n if (!seenFileNames.has(file.name)) {\n seenFileNames.add(file.name);\n uniqueFiles.push(file);\n }\n\n const dotIndex = file.name.lastIndexOf('.');\n const extension = file.name.substring(dotIndex).toLowerCase();\n const isAccepted = this.accept.length === 0 || this.accept.some(type => type.toLowerCase() === extension);\n\n if (!isAccepted) {\n error = 'Unsupported file type.';\n } else if (file.size > maxSize) {\n error = `File ${file.name} is too large.`;\n }\n\n errorMessages.push(error);\n }\n\n this.error = uniqueFiles.length > this.maxFiles\n ? `Only ${this.maxFiles} file(s) allowed.`\n : null;\n\n this.errorMessages = errorMessages;\n\n return uniqueFiles;\n }\n\n private removeFile(index: number) {\n if (this.files[index]) this.fileRemoved.emit(this.files[index]);\n this.files = this.validation([...this.files.slice(0, index), ...this.files.slice(index + 1)]);\n this.filesChange.emit(this.files);\n if (this.fileInput) {\n this.fileInput.value = '';\n }\n }\n\n private onDragOver = (event: DragEvent) => {\n event.preventDefault();\n this.dragActive = true;\n };\n\n private onDragLeave = () => {\n this.dragActive = false;\n };\n\n render() {\n return (\n <Host class={{ 'upload-wrapper': true, [`uploader-${this.size}`]: true, disabled: !!this.disabled }}>\n {this.label && <label class=\"label\">{this.label}</label>}\n {this.description && <p class=\"description\">{this.description}</p>}\n {this.variant === 'button' ? (\n <xv-button-v2 variant={this.buttonVariant} disabled={this.disabled} onClick={() => this.fileInput.click()}>\n {this.addText || 'Dateien auswählen'}\n </xv-button-v2>\n ) : (\n <div\n class={{ 'drop-zone': true, active: this.dragActive }}\n onDrop={this.onDrop}\n onDragOver={this.onDragOver}\n onDragLeave={this.onDragLeave}\n onClick={() => this.fileInput.click()}\n >\n {this.addText || 'Dateien hierher ziehen oder darauf klicken, um eine Datei auszuwählen.'}\n {this.accept?.length > 0 && <span> ({this.accept.join(', ')})</span>}\n </div>\n )}\n\n <input\n ref={el => (this.fileInput = el)}\n type=\"file\"\n hidden\n onChange={this.onFileSelect}\n multiple={this.multiple}\n accept={this.accept.join(',')}\n />\n\n <ul class=\"file-list\">\n {this.files.map((file, index) => (\n <li class={{ file: true, withError: !!(this.errors?.[index] || this.errorMessages?.[index]) }}>\n <div class=\"file_container\">\n <span class=\"file_container_name\">{file.name}</span>\n {this._renderLoaderState(index)}\n </div>\n {this._renderError(index)}\n </li>\n ))}\n </ul>\n {this.error && (\n <div class=\"error-container\">\n <p class=\"error-container_primary\">{this.error}</p>\n </div>\n )}\n </Host>\n );\n }\n\n private _renderLoaderState(index: number) {\n const state = this.loadingStates?.[index] || null;\n\n const errorIcon = this.errors?.[index] || this.errorMessages?.[index] ? (\n <svg class=\"file_container_errorIcon\" width=\"16\" height=\"16\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path fill=\"currentColor\"\n d=\"M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zm0-384c13.3 0 24 10.7 24 24l0 112c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-112c0-13.3 10.7-24 24-24zM224 352a32 32 0 1 1 64 0 32 32 0 1 1 -64 0z\" />\n </svg>\n ) : null;\n\n switch (state) {\n case 'loading':\n return (\n <Fragment>\n {errorIcon}\n <xv-loader-v2 size={SIZE_VAR.XS} />\n </Fragment>\n );\n case 'success':\n return (\n <Fragment>\n {errorIcon}\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 18 16\" fill=\"none\">\n <path\n d=\"M9 16C6.125 16 3.5 14.5 2.0625 12C0.625 9.53125 0.625 6.5 2.0625 4C3.5 1.53125 6.125 0 9 0C11.8438 0 14.4688 1.53125 15.9062 4C17.3438 6.5 17.3438 9.53125 15.9062 12C14.4688 14.5 11.8438 16 9 16ZM12.5312 6.53125H12.5C12.8125 6.25 12.8125 5.78125 12.5 5.46875C12.2188 5.1875 11.75 5.1875 11.4688 5.46875L8 8.96875L6.53125 7.5C6.21875 7.1875 5.75 7.1875 5.46875 7.5C5.15625 7.78125 5.15625 8.25 5.46875 8.53125L7.46875 10.5312C7.75 10.8438 8.21875 10.8438 8.53125 10.5312L12.5312 6.53125Z\"\n fill=\"#97BF0D\" />\n </svg>\n <xv-button-v2 variant=\"ghost\" size={SIZE_VAR.XS} onClick={() => this.removeFile(index)}>\n <span slot=\"icon-left\">×</span>\n </xv-button-v2>\n </Fragment>\n );\n case 'uploaded':\n default:\n return (\n <Fragment>\n {errorIcon}\n <xv-button-v2 variant=\"ghost\" size={SIZE_VAR.XS} onClick={() => this.removeFile(index)}>\n <span slot=\"icon-left\">×</span>\n </xv-button-v2>\n </Fragment>\n );\n }\n }\n\n private _renderError(index: number) {\n const error = this.errors?.[index] || this.errorMessages?.[index];\n\n if (!error) return;\n\n if (typeof error === 'object') {\n return (\n <div class=\"error-container\">\n <p class=\"error-container_primary\">{error.primary}</p>\n <p class=\"error-container_secondary\">{error.secondary}</p>\n </div>\n );\n }\n\n if (typeof error === 'string') {\n return (\n <div class=\"error-container\">\n <p class=\"error-container_primary\">{error}</p>\n </div>\n );\n }\n\n return null;\n }\n}\n"]}
|