@likable-hair/svelte 3.3.20 → 3.3.21
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/components/composed/buttons/ActivableButton.svelte +2 -6
- package/dist/components/composed/buttons/ActivableButton.svelte.d.ts +32 -36
- package/dist/components/composed/common/MenuOrDrawer.svelte +5 -21
- package/dist/components/composed/common/MenuOrDrawer.svelte.d.ts +36 -50
- package/dist/components/composed/common/MenuOrDrawerOptions.svelte +13 -29
- package/dist/components/composed/common/MenuOrDrawerOptions.svelte.d.ts +30 -34
- package/dist/components/composed/common/QuickActions.svelte +20 -52
- package/dist/components/composed/common/QuickActions.svelte.d.ts +20 -24
- package/dist/components/composed/common/ToolTip.svelte +22 -31
- package/dist/components/composed/common/ToolTip.svelte.d.ts +43 -32
- package/dist/components/composed/forms/AsyncAutocomplete.svelte +23 -44
- package/dist/components/composed/forms/AsyncAutocomplete.svelte.d.ts +39 -44
- package/dist/components/composed/forms/AvatarDropdown.svelte +27 -57
- package/dist/components/composed/forms/AvatarDropdown.svelte.d.ts +41 -45
- package/dist/components/composed/forms/ConfirmOrCancelButtons.svelte +17 -35
- package/dist/components/composed/forms/ConfirmOrCancelButtons.svelte.d.ts +37 -41
- package/dist/components/composed/forms/CountriesAutocomplete.svelte +7 -16
- package/dist/components/composed/forms/CountriesAutocomplete.svelte.d.ts +60 -31
- package/dist/components/composed/forms/DatePickerTextField.svelte +114 -166
- package/dist/components/composed/forms/DatePickerTextField.svelte.d.ts +63 -67
- package/dist/components/composed/forms/Dropdown.svelte +21 -51
- package/dist/components/composed/forms/Dropdown.svelte.d.ts +43 -48
- package/dist/components/composed/forms/IconsDropdown.svelte +33 -61
- package/dist/components/composed/forms/IconsDropdown.svelte.d.ts +26 -30
- package/dist/components/composed/forms/LabelAndSelect.svelte +7 -32
- package/dist/components/composed/forms/LabelAndSelect.svelte.d.ts +31 -35
- package/dist/components/composed/forms/LabelAndTextField.svelte +5 -30
- package/dist/components/composed/forms/LabelAndTextField.svelte.d.ts +42 -46
- package/dist/components/composed/forms/ToggleList.svelte +33 -59
- package/dist/components/composed/forms/ToggleList.svelte.d.ts +17 -21
- package/dist/components/composed/forms/YearPickerTextField.svelte +74 -114
- package/dist/components/composed/forms/YearPickerTextField.svelte.d.ts +49 -53
- package/dist/components/composed/list/DynamicTable.svelte +707 -1102
- package/dist/components/composed/list/DynamicTable.svelte.d.ts +365 -369
- package/dist/components/composed/list/PaginatedTable.svelte +76 -139
- package/dist/components/composed/list/PaginatedTable.svelte.d.ts +108 -108
- package/dist/components/composed/progress/HorizontalStackedProgress.svelte +30 -58
- package/dist/components/composed/progress/HorizontalStackedProgress.svelte.d.ts +21 -25
- package/dist/components/composed/search/DynamicFilters.svelte +82 -103
- package/dist/components/composed/search/DynamicFilters.svelte.d.ts +27 -31
- package/dist/components/composed/search/FilterEditor.svelte +77 -106
- package/dist/components/composed/search/FilterEditor.svelte.d.ts +33 -37
- package/dist/components/composed/search/Filters.svelte +292 -361
- package/dist/components/composed/search/Filters.svelte.d.ts +51 -55
- package/dist/components/composed/search/GlobalSearchTextField.svelte +41 -79
- package/dist/components/composed/search/GlobalSearchTextField.svelte.d.ts +39 -43
- package/dist/components/composed/search/MobileFilterEditor.svelte +93 -135
- package/dist/components/composed/search/MobileFilterEditor.svelte.d.ts +35 -39
- package/dist/components/composed/search/SearchBar.svelte +5 -28
- package/dist/components/composed/search/SearchBar.svelte.d.ts +30 -34
- package/dist/components/composed/search/SearchResults.svelte +7 -42
- package/dist/components/composed/search/SearchResults.svelte.d.ts +36 -40
- package/dist/components/composed/shop/ProductCard.svelte +4 -18
- package/dist/components/composed/shop/ProductCard.svelte.d.ts +28 -32
- package/dist/components/composed/shop/ProductsGrid.svelte +2 -22
- package/dist/components/composed/shop/ProductsGrid.svelte.d.ts +40 -44
- package/dist/components/layouts/CollapsibleSideBarLayout.svelte +38 -77
- package/dist/components/layouts/CollapsibleSideBarLayout.svelte.d.ts +69 -109
- package/dist/components/layouts/StableDividedSideBarLayout.svelte +17 -47
- package/dist/components/layouts/StableDividedSideBarLayout.svelte.d.ts +32 -50
- package/dist/components/layouts/UnstableDividedSideBarLayout.svelte +30 -53
- package/dist/components/layouts/UnstableDividedSideBarLayout.svelte.d.ts +63 -103
- package/dist/components/simple/buttons/Button.svelte +32 -78
- package/dist/components/simple/buttons/Button.svelte.d.ts +35 -47
- package/dist/components/simple/buttons/LinkButton.svelte +22 -54
- package/dist/components/simple/buttons/LinkButton.svelte.d.ts +33 -50
- package/dist/components/simple/charts/GanymedeBarChart.svelte +134 -172
- package/dist/components/simple/charts/GanymedeBarChart.svelte.d.ts +46 -50
- package/dist/components/simple/charts/GanymedeLineChart.svelte +115 -157
- package/dist/components/simple/charts/GanymedeLineChart.svelte.d.ts +47 -51
- package/dist/components/simple/charts/GanymedePieChart.svelte +39 -62
- package/dist/components/simple/charts/GanymedePieChart.svelte.d.ts +33 -37
- package/dist/components/simple/common/Card.svelte +1 -20
- package/dist/components/simple/common/Card.svelte.d.ts +38 -51
- package/dist/components/simple/common/CollapsibleDivider.svelte +11 -23
- package/dist/components/simple/common/CollapsibleDivider.svelte.d.ts +25 -29
- package/dist/components/simple/common/Divider.svelte +2 -8
- package/dist/components/simple/common/Divider.svelte.d.ts +19 -23
- package/dist/components/simple/common/Gesture.svelte +46 -64
- package/dist/components/simple/common/Gesture.svelte.d.ts +17 -21
- package/dist/components/simple/common/InfiniteScroll.svelte +29 -52
- package/dist/components/simple/common/InfiniteScroll.svelte.d.ts +20 -24
- package/dist/components/simple/common/IntersectionObserver.svelte +32 -45
- package/dist/components/simple/common/IntersectionObserver.svelte.d.ts +21 -34
- package/dist/components/simple/common/MediaQuery.svelte +21 -30
- package/dist/components/simple/common/MediaQuery.svelte.d.ts +30 -34
- package/dist/components/simple/common/Menu.svelte +201 -290
- package/dist/components/simple/common/Menu.svelte.d.ts +40 -51
- package/dist/components/simple/common/Playground.svelte +17 -18
- package/dist/components/simple/common/Playground.svelte.d.ts +15 -19
- package/dist/components/simple/common/VerticalDraggableList.svelte +16 -35
- package/dist/components/simple/common/VerticalDraggableList.svelte.d.ts +29 -33
- package/dist/components/simple/dashboards/DashboardGridShaper.svelte +26 -32
- package/dist/components/simple/dashboards/DashboardGridShaper.svelte.d.ts +12 -16
- package/dist/components/simple/dates/Calendar.svelte +28 -52
- package/dist/components/simple/dates/Calendar.svelte.d.ts +41 -45
- package/dist/components/simple/dates/DatePicker.svelte +60 -90
- package/dist/components/simple/dates/DatePicker.svelte.d.ts +40 -44
- package/dist/components/simple/dates/MonthSelector.svelte +15 -37
- package/dist/components/simple/dates/MonthSelector.svelte.d.ts +31 -35
- package/dist/components/simple/dates/TimePicker.svelte +31 -45
- package/dist/components/simple/dates/TimePicker.svelte.d.ts +20 -24
- package/dist/components/simple/dates/TimePickerTextField.svelte +35 -56
- package/dist/components/simple/dates/TimePickerTextField.svelte.d.ts +24 -28
- package/dist/components/simple/dates/YearSelector.svelte +29 -54
- package/dist/components/simple/dates/YearSelector.svelte.d.ts +31 -35
- package/dist/components/simple/dialogs/Dialog.svelte +62 -92
- package/dist/components/simple/dialogs/Dialog.svelte.d.ts +28 -42
- package/dist/components/simple/forms/Autocomplete.svelte +142 -201
- package/dist/components/simple/forms/Autocomplete.svelte.d.ts +79 -83
- package/dist/components/simple/forms/Checkbox.svelte +24 -40
- package/dist/components/simple/forms/Checkbox.svelte.d.ts +21 -25
- package/dist/components/simple/forms/FileInput.svelte +48 -88
- package/dist/components/simple/forms/FileInput.svelte.d.ts +33 -37
- package/dist/components/simple/forms/FileInputList.svelte +34 -52
- package/dist/components/simple/forms/FileInputList.svelte.d.ts +39 -43
- package/dist/components/simple/forms/RadioButton.svelte +3 -11
- package/dist/components/simple/forms/RadioButton.svelte.d.ts +27 -31
- package/dist/components/simple/forms/Select.svelte +3 -16
- package/dist/components/simple/forms/Select.svelte.d.ts +20 -24
- package/dist/components/simple/forms/SimpleTextField.svelte +6 -53
- package/dist/components/simple/forms/SimpleTextField.svelte.d.ts +60 -64
- package/dist/components/simple/forms/Switch.svelte +16 -30
- package/dist/components/simple/forms/Switch.svelte.d.ts +21 -25
- package/dist/components/simple/forms/Textarea.svelte +2 -27
- package/dist/components/simple/forms/Textarea.svelte.d.ts +37 -41
- package/dist/components/simple/forms/Textfield.svelte +18 -56
- package/dist/components/simple/forms/Textfield.svelte.d.ts +51 -55
- package/dist/components/simple/forms/TreeEditor.svelte +95 -141
- package/dist/components/simple/forms/TreeEditor.svelte.d.ts +38 -42
- package/dist/components/simple/forms/TreeEditorItem.svelte +42 -77
- package/dist/components/simple/forms/TreeEditorItem.svelte.d.ts +50 -54
- package/dist/components/simple/forms/VerticalSwitch.svelte +1 -11
- package/dist/components/simple/forms/VerticalSwitch.svelte.d.ts +28 -32
- package/dist/components/simple/forms/VerticalTextSwitch.svelte +3 -15
- package/dist/components/simple/forms/VerticalTextSwitch.svelte.d.ts +26 -30
- package/dist/components/simple/lists/ColorInvertedSelector.svelte +23 -53
- package/dist/components/simple/lists/ColorInvertedSelector.svelte.d.ts +42 -46
- package/dist/components/simple/lists/HierarchyMenu.svelte +19 -38
- package/dist/components/simple/lists/HierarchyMenu.svelte.d.ts +30 -34
- package/dist/components/simple/lists/Paginator.svelte +41 -50
- package/dist/components/simple/lists/Paginator.svelte.d.ts +19 -23
- package/dist/components/simple/lists/SelectableMenuList.svelte +15 -43
- package/dist/components/simple/lists/SelectableMenuList.svelte.d.ts +20 -24
- package/dist/components/simple/lists/SelectableVerticalList.svelte +57 -99
- package/dist/components/simple/lists/SelectableVerticalList.svelte.d.ts +47 -51
- package/dist/components/simple/lists/SidebarMenuList.svelte +70 -115
- package/dist/components/simple/lists/SidebarMenuList.svelte.d.ts +22 -26
- package/dist/components/simple/lists/SimpleTable.svelte +154 -264
- package/dist/components/simple/lists/SimpleTable.svelte.d.ts +66 -70
- package/dist/components/simple/loaders/CircularLoader.svelte +5 -16
- package/dist/components/simple/loaders/CircularLoader.svelte.d.ts +15 -19
- package/dist/components/simple/loaders/Skeleton.svelte +2 -3
- package/dist/components/simple/loaders/Skeleton.svelte.d.ts +12 -16
- package/dist/components/simple/media/AttachmentDownloader.svelte +3 -17
- package/dist/components/simple/media/AttachmentDownloader.svelte.d.ts +28 -32
- package/dist/components/simple/media/Avatar.svelte +12 -18
- package/dist/components/simple/media/Avatar.svelte.d.ts +20 -31
- package/dist/components/simple/media/Carousel.svelte +11 -29
- package/dist/components/simple/media/Carousel.svelte.d.ts +24 -28
- package/dist/components/simple/media/DescriptiveAvatar.svelte +4 -12
- package/dist/components/simple/media/DescriptiveAvatar.svelte.d.ts +28 -44
- package/dist/components/simple/media/FlagIcon.svelte +5 -8
- package/dist/components/simple/media/FlagIcon.svelte.d.ts +15 -19
- package/dist/components/simple/media/Gallery.svelte +29 -49
- package/dist/components/simple/media/Gallery.svelte.d.ts +23 -27
- package/dist/components/simple/media/Icon.svelte +4 -9
- package/dist/components/simple/media/Icon.svelte.d.ts +20 -24
- package/dist/components/simple/media/Image.svelte +20 -42
- package/dist/components/simple/media/Image.svelte.d.ts +33 -44
- package/dist/components/simple/media/ImageGrid.svelte +12 -37
- package/dist/components/simple/media/ImageGrid.svelte.d.ts +28 -32
- package/dist/components/simple/navigation/Breadcrumb.svelte +10 -28
- package/dist/components/simple/navigation/Breadcrumb.svelte.d.ts +22 -26
- package/dist/components/simple/navigation/Chip.svelte +23 -44
- package/dist/components/simple/navigation/Chip.svelte.d.ts +31 -42
- package/dist/components/simple/navigation/Drawer.svelte +65 -107
- package/dist/components/simple/navigation/Drawer.svelte.d.ts +37 -50
- package/dist/components/simple/navigation/HeaderMenu.svelte +23 -40
- package/dist/components/simple/navigation/HeaderMenu.svelte.d.ts +35 -39
- package/dist/components/simple/navigation/Navigator.svelte +8 -30
- package/dist/components/simple/navigation/Navigator.svelte.d.ts +24 -28
- package/dist/components/simple/navigation/TabSwitcher.svelte +47 -83
- package/dist/components/simple/navigation/TabSwitcher.svelte.d.ts +34 -38
- package/dist/components/simple/notifiers/AlertBanner.svelte +15 -43
- package/dist/components/simple/notifiers/AlertBanner.svelte.d.ts +37 -41
- package/dist/components/simple/progress/ProgressBar.svelte +13 -20
- package/dist/components/simple/progress/ProgressBar.svelte.d.ts +17 -21
- package/dist/components/simple/timeline/SimpleTimeLine.svelte +5 -19
- package/dist/components/simple/timeline/SimpleTimeLine.svelte.d.ts +35 -39
- package/dist/components/simple/typography/Code.svelte +12 -27
- package/dist/components/simple/typography/Code.svelte.d.ts +24 -28
- package/dist/stores/debounce.d.ts +1 -0
- package/dist/stores/layouts/unstableSidebarOpened.d.ts +1 -0
- package/dist/stores/mediaQuery.d.ts +1 -0
- package/dist/stores/theme.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,1193 +1,798 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
hideScrollbar = tableContainer.scrollHeight > tableContainer.clientHeight
|
|
46
|
-
|
|
47
|
-
for(const head of [...headers, { value: 'non-resizable', minWidth: DEFAULT_MIN_WIDTH_PX + 'px', maxWidth: DEFAULT_MAX_WIDTH_PX + 'px' }, { value: 'customize-headers', minWidth: DEFAULT_MIN_WIDTH_PX + 'px', maxWidth: DEFAULT_MAX_WIDTH_PX + 'px' }]) {
|
|
48
|
-
let th = headersHTML[head.value]
|
|
49
|
-
if(!!th) {
|
|
50
|
-
resizeHeader(th, head)
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
tableHTML.classList.add('dynamic-resizable')
|
|
55
|
-
|
|
56
|
-
resizeObserver = new ResizeObserver(() => {
|
|
57
|
-
updateRemainingWidth();
|
|
58
|
-
updateHeaderHeight();
|
|
59
|
-
});
|
|
60
|
-
resizeObserver.observe(tableContainer);
|
|
61
|
-
|
|
62
|
-
return () => {
|
|
63
|
-
window.removeEventListener('resize', updateHeaderHeight);
|
|
64
|
-
tableContainer.removeEventListener("scroll", setReachedBottomOrTop);
|
|
65
|
-
resizeObserver?.disconnect();
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
function updateHeaderHeight() {
|
|
70
|
-
if (mainHeader) {
|
|
71
|
-
const headerHeight = mainHeader.getBoundingClientRect().height;
|
|
72
|
-
document.documentElement.style.setProperty('--main-header-height', headerHeight + 'px');
|
|
1
|
+
<script>import {
|
|
2
|
+
Checkbox,
|
|
3
|
+
Chip,
|
|
4
|
+
Converter,
|
|
5
|
+
CountriesAutocomplete,
|
|
6
|
+
DatePickerTextField,
|
|
7
|
+
Drawer,
|
|
8
|
+
FilterBuilder,
|
|
9
|
+
FlagIcon,
|
|
10
|
+
Icon,
|
|
11
|
+
MediaQuery,
|
|
12
|
+
Menu,
|
|
13
|
+
ToolTip
|
|
14
|
+
} from "../../..";
|
|
15
|
+
import { DateTime } from "luxon";
|
|
16
|
+
import { createEventDispatcher, onMount, tick } from "svelte";
|
|
17
|
+
import { quintOut } from "svelte/easing";
|
|
18
|
+
import { crossfade, fade } from "svelte/transition";
|
|
19
|
+
import Filters from "../search/Filters.svelte";
|
|
20
|
+
import ConfirmOrCancelButtons from "../forms/ConfirmOrCancelButtons.svelte";
|
|
21
|
+
import { flip } from "svelte/animate";
|
|
22
|
+
import InfiniteScroll from "../../simple/common/InfiniteScroll.svelte";
|
|
23
|
+
import Divider from "../../simple/common/Divider.svelte";
|
|
24
|
+
import VerticalDraggableList from "../../simple/common/VerticalDraggableList.svelte";
|
|
25
|
+
import Button from "../../simple/buttons/Button.svelte";
|
|
26
|
+
import SimpleTextField from "../../simple/forms/SimpleTextField.svelte";
|
|
27
|
+
import Autocomplete from "../../simple/forms/Autocomplete.svelte";
|
|
28
|
+
import LabelAndSelect from "../forms/LabelAndSelect.svelte";
|
|
29
|
+
import LabelAndTextField from "../forms/LabelAndTextField.svelte";
|
|
30
|
+
import DynamicFilters from "../search/DynamicFilters.svelte";
|
|
31
|
+
import QuickActions, {} from "../common/QuickActions.svelte";
|
|
32
|
+
import "./DynamicTable.css";
|
|
33
|
+
import Switch from "../../simple/forms/Switch.svelte";
|
|
34
|
+
import CircularLoader from "../../simple/loaders/CircularLoader.svelte";
|
|
35
|
+
onMount(() => {
|
|
36
|
+
updateHeaderHeight();
|
|
37
|
+
window.addEventListener("resize", updateHeaderHeight);
|
|
38
|
+
tableContainer.addEventListener("scroll", setReachedBottomOrTop);
|
|
39
|
+
hideScrollbar = tableContainer.scrollHeight > tableContainer.clientHeight;
|
|
40
|
+
for (const head of [...headers, { value: "non-resizable", minWidth: DEFAULT_MIN_WIDTH_PX + "px", maxWidth: DEFAULT_MAX_WIDTH_PX + "px" }, { value: "customize-headers", minWidth: DEFAULT_MIN_WIDTH_PX + "px", maxWidth: DEFAULT_MAX_WIDTH_PX + "px" }]) {
|
|
41
|
+
let th = headersHTML[head.value];
|
|
42
|
+
if (!!th) {
|
|
43
|
+
resizeHeader(th, head);
|
|
73
44
|
}
|
|
74
45
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
46
|
+
tableHTML.classList.add("dynamic-resizable");
|
|
47
|
+
resizeObserver = new ResizeObserver(() => {
|
|
48
|
+
updateRemainingWidth();
|
|
49
|
+
updateHeaderHeight();
|
|
50
|
+
});
|
|
51
|
+
resizeObserver.observe(tableContainer);
|
|
52
|
+
return () => {
|
|
53
|
+
window.removeEventListener("resize", updateHeaderHeight);
|
|
54
|
+
tableContainer.removeEventListener("scroll", setReachedBottomOrTop);
|
|
55
|
+
resizeObserver?.disconnect();
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
function updateHeaderHeight() {
|
|
59
|
+
if (mainHeader) {
|
|
60
|
+
const headerHeight = mainHeader.getBoundingClientRect().height;
|
|
61
|
+
document.documentElement.style.setProperty("--main-header-height", headerHeight + "px");
|
|
80
62
|
}
|
|
81
|
-
|
|
82
|
-
|
|
63
|
+
}
|
|
64
|
+
function setReachedBottomOrTop() {
|
|
65
|
+
reachedBottom = tableContainer.scrollHeight - tableContainer.scrollTop === tableContainer.clientHeight;
|
|
66
|
+
reachedTop = tableContainer.scrollTop === 0;
|
|
67
|
+
hideScrollbar = tableContainer.scrollHeight > tableContainer.clientHeight;
|
|
68
|
+
}
|
|
69
|
+
$:
|
|
70
|
+
if (reachedBottom && rows.length < totalRows) {
|
|
83
71
|
setTimeout(() => {
|
|
84
|
-
if(reachedBottom) {
|
|
85
|
-
handleLoadForward()
|
|
72
|
+
if (reachedBottom) {
|
|
73
|
+
handleLoadForward();
|
|
86
74
|
}
|
|
87
|
-
}, 30)
|
|
75
|
+
}, 30);
|
|
88
76
|
}
|
|
89
|
-
|
|
90
|
-
|
|
77
|
+
$:
|
|
78
|
+
if (reachedTop && currentSectionNumber > 0) {
|
|
91
79
|
setTimeout(() => {
|
|
92
|
-
if(reachedTop) {
|
|
93
|
-
handleLoadBackward()
|
|
80
|
+
if (reachedTop) {
|
|
81
|
+
handleLoadBackward();
|
|
94
82
|
}
|
|
95
|
-
}, 30)
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
easing: quintOut,
|
|
107
|
-
css: (t) => `
|
|
83
|
+
}, 30);
|
|
84
|
+
}
|
|
85
|
+
const [send, receive] = crossfade({
|
|
86
|
+
duration: 500,
|
|
87
|
+
fallback(node, params) {
|
|
88
|
+
const style = getComputedStyle(node);
|
|
89
|
+
const transform = style.transform === "none" ? "" : style.transform;
|
|
90
|
+
return {
|
|
91
|
+
duration: 500,
|
|
92
|
+
easing: quintOut,
|
|
93
|
+
css: (t) => `
|
|
108
94
|
transform: ${transform} scale(${t});
|
|
109
95
|
opacity: ${t}
|
|
110
|
-
|
|
111
|
-
};
|
|
112
|
-
},
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
type Item = {
|
|
116
|
-
[key: string]: any;
|
|
117
|
-
disableEdit?: boolean,
|
|
118
|
-
rowDisableBackgroundColor?: string
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
type Row = {
|
|
122
|
-
item: Item;
|
|
123
|
-
subItems: Item[];
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
type MenuStringType = {
|
|
127
|
-
key: "string";
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
type MenuNumberType = {
|
|
131
|
-
key: "number";
|
|
132
|
-
params?: {
|
|
133
|
-
min?: number;
|
|
134
|
-
max?: number;
|
|
135
|
-
};
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
type MenuDateType = {
|
|
139
|
-
key: "date";
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
type MenuSelectType = {
|
|
143
|
-
key: "select";
|
|
144
|
-
params: {
|
|
145
|
-
options: {
|
|
146
|
-
icon?: string;
|
|
147
|
-
value: string | number | undefined;
|
|
148
|
-
id?: number | undefined;
|
|
149
|
-
text: string;
|
|
150
|
-
}[];
|
|
96
|
+
`
|
|
151
97
|
};
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
let clazz = {};
|
|
101
|
+
export { clazz as class };
|
|
102
|
+
const dispatch = createEventDispatcher();
|
|
103
|
+
export let headers = [], headersToShowInTable = headers, subHeaders = [], customizeHeaders = false, rows = [], sortedBy = void 0, sortDirection = "asc", cellEdit = false, lang = "en", dateLocale = void 0, noItemsText = lang == "en" ? "No items to show" : "Nessun elemento da visualizzare", showSelect = false, showActions = true, selectMode = "single", selectedItems = [], unselectedItems = [], selectedAll = false, showExpand = false, loading = false, disabled = false, filters = [], searchBarColumns = void 0, searchBarVisible = false, searchBarPlaceholder = lang == "en" ? "Type to search..." : "Scrivi per cercare...", filtersVisible = false, quickFiltersVisible = false, editFilterMode = "one-edit", showActiveFilters = true, quickFilters = [], actionsForSelectedItems = [], quickActionsDisabled = false, totalRows = rows.length, searchText = void 0, renderedRowsNumber = 100, sectionRowsNumber = 20, sectionThreshold = 2, backwardThresholdPixel = 100, forwardThresholdPixel = 100, uniqueKey = "id", numberOfResultsVisible = false, endLineVisible = false, resizableColumns = false, resizedColumnSizeWithPadding = {}, dynamicFilters = true, useSelectedItemsOnly = false;
|
|
104
|
+
let openCellEditor = false, cellEditorActivator, cellEditorContainer, menuElementCellEditor, menuElementQuickFilters, cellEditorInfoActive, saveEditDisabled = false, searchBarInput = void 0, openQuickFilter = false, quickFilterActivator, quickFilterActive, globalBuilder = new FilterBuilder(), calendarOpened = false, calendarOpened2 = false, selectedIndexes = [], cellEditorIndexRow, cellEditorIndexHeader, cellEditorSubItem, currentSectionNumber = 0, tableBody, tableContainer, tableHTML, headersHTML = {}, userScrolling = true, reachedBottom = false, reachedTop = false, resizing = false, remainingWidth = 0, hideScrollbar = false, sortModify, mainHeader, resizeObserver, ignoreSelectAll = rows.length == totalRows && useSelectedItemsOnly;
|
|
105
|
+
const DEFAULT_MIN_WIDTH_PX = 100, DEFAULT_MAX_WIDTH_PX = 400;
|
|
106
|
+
$:
|
|
107
|
+
totalSections = (totalRows - renderedRowsNumber) / sectionRowsNumber;
|
|
108
|
+
$:
|
|
109
|
+
hasMoreToRender = totalSections > currentSectionNumber;
|
|
110
|
+
$:
|
|
111
|
+
totalCachedSections = (rows.length - renderedRowsNumber) / sectionRowsNumber;
|
|
112
|
+
$:
|
|
113
|
+
renderedRows = rows.slice(currentSectionNumber * sectionRowsNumber, currentSectionNumber * sectionRowsNumber + renderedRowsNumber);
|
|
114
|
+
let openHeaderDrawer = false, headersToSelect = !!headers ? headers.filter((h) => {
|
|
115
|
+
return !headersToShowInTable.find((hst) => hst.value == h.value);
|
|
116
|
+
}).map((h) => {
|
|
117
|
+
return {
|
|
118
|
+
id: h.value,
|
|
119
|
+
name: h.label
|
|
152
120
|
};
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
type CellEditorInfoType =
|
|
159
|
-
| MenuStringType
|
|
160
|
-
| MenuNumberType
|
|
161
|
-
| MenuDateType
|
|
162
|
-
| MenuSelectType
|
|
163
|
-
| MenuBooleanType;
|
|
164
|
-
|
|
165
|
-
type CellEditorInfo = {
|
|
166
|
-
title: string;
|
|
167
|
-
description: string;
|
|
168
|
-
type: CellEditorInfoType;
|
|
169
|
-
column: string;
|
|
170
|
-
info?: string;
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
type Headers = NonNullable<ComponentProps<PaginatedTable>["headers"]>;
|
|
174
|
-
type Header = Headers[number] & {
|
|
175
|
-
cellEditorInfo?: CellEditorInfo;
|
|
176
|
-
info?: string;
|
|
177
|
-
maxWidth?: string
|
|
121
|
+
}) : [], headersToShow = headersToShowInTable.map((h) => {
|
|
122
|
+
return {
|
|
123
|
+
id: h.value,
|
|
124
|
+
name: h.label
|
|
178
125
|
};
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
sortDirection
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
item: Item;
|
|
196
|
-
};
|
|
197
|
-
cellClick: {
|
|
198
|
-
item: Item;
|
|
199
|
-
};
|
|
200
|
-
saveCellEdit: {
|
|
201
|
-
item: any;
|
|
202
|
-
};
|
|
203
|
-
saveHeadersToShow: {
|
|
204
|
-
headersToShow: {
|
|
205
|
-
id: string;
|
|
206
|
-
name: string;
|
|
207
|
-
}[];
|
|
208
|
-
};
|
|
209
|
-
filtersChange: {
|
|
210
|
-
builder: FilterBuilder;
|
|
211
|
-
};
|
|
212
|
-
fetchData: {};
|
|
213
|
-
removeFilter: {filter: Filter}
|
|
214
|
-
removeAllFilters: {}
|
|
215
|
-
removeCustomQuickFilter: {
|
|
216
|
-
quickFilter: QuickFilter
|
|
217
|
-
}
|
|
218
|
-
applyCustomQuickFilter: {
|
|
219
|
-
quickFilter: QuickFilter
|
|
220
|
-
setQuickFilterValue: (quickFilter: QuickFilter, value?: any) => void
|
|
221
|
-
}
|
|
222
|
-
columnResize: {
|
|
223
|
-
id: string,
|
|
224
|
-
newWidthPx: number
|
|
225
|
-
}
|
|
226
|
-
}>();
|
|
227
|
-
|
|
228
|
-
export let headers: Header[] = [],
|
|
229
|
-
headersToShowInTable: Header[] = headers,
|
|
230
|
-
subHeaders: Header[] = [],
|
|
231
|
-
customizeHeaders: boolean = false,
|
|
232
|
-
rows: Row[] = [],
|
|
233
|
-
sortedBy: string | undefined = undefined,
|
|
234
|
-
sortDirection: "asc" | "desc" = "asc",
|
|
235
|
-
cellEdit: boolean = false,
|
|
236
|
-
lang: "it" | "en" = "en",
|
|
237
|
-
dateLocale: "it" | "en" | undefined = undefined,
|
|
238
|
-
noItemsText: string = lang == 'en' ? "No items to show" : 'Nessun elemento da visualizzare',
|
|
239
|
-
showSelect: boolean = false,
|
|
240
|
-
showActions: boolean = true,
|
|
241
|
-
selectMode: "single" | "multiple" = "single",
|
|
242
|
-
selectedItems: Item[] = [],
|
|
243
|
-
unselectedItems: Item[] = [],
|
|
244
|
-
selectedAll: boolean = false,
|
|
245
|
-
showExpand: boolean = false,
|
|
246
|
-
loading: boolean = false,
|
|
247
|
-
disabled: boolean = false,
|
|
248
|
-
filters: ComponentProps<Filters>["filters"] = [],
|
|
249
|
-
searchBarColumns: string[] | undefined = undefined,
|
|
250
|
-
searchBarVisible: boolean = false,
|
|
251
|
-
searchBarPlaceholder: string = lang == 'en' ? "Type to search..." : 'Scrivi per cercare...',
|
|
252
|
-
filtersVisible: boolean = false,
|
|
253
|
-
quickFiltersVisible: boolean = false,
|
|
254
|
-
editFilterMode: "one-edit" | "multi-edit" = "one-edit",
|
|
255
|
-
showActiveFilters: boolean = true,
|
|
256
|
-
quickFilters: QuickFilter[] = [],
|
|
257
|
-
actionsForSelectedItems: Action[] = [],
|
|
258
|
-
quickActionsDisabled: boolean = false,
|
|
259
|
-
totalRows: number = rows.length,
|
|
260
|
-
searchText: string | undefined = undefined,
|
|
261
|
-
renderedRowsNumber = 100,
|
|
262
|
-
sectionRowsNumber = 20,
|
|
263
|
-
sectionThreshold = 2,
|
|
264
|
-
backwardThresholdPixel = 100,
|
|
265
|
-
forwardThresholdPixel = 100,
|
|
266
|
-
uniqueKey: keyof Item = 'id',
|
|
267
|
-
numberOfResultsVisible: boolean = false,
|
|
268
|
-
endLineVisible: boolean = false,
|
|
269
|
-
resizableColumns: boolean= false,
|
|
270
|
-
resizedColumnSizeWithPadding: { [value: string]: number } = {},
|
|
271
|
-
dynamicFilters: boolean = true,
|
|
272
|
-
useSelectedItemsOnly = false
|
|
273
|
-
|
|
274
|
-
let openCellEditor: boolean = false,
|
|
275
|
-
cellEditorActivator: HTMLElement | undefined,
|
|
276
|
-
cellEditorContainer: HTMLElement | undefined,
|
|
277
|
-
menuElementCellEditor: HTMLElement,
|
|
278
|
-
menuElementQuickFilters: HTMLElement,
|
|
279
|
-
cellEditorInfoActive: CellEditorInfo & {
|
|
280
|
-
value?: any;
|
|
281
|
-
item?: Item;
|
|
282
|
-
},
|
|
283
|
-
saveEditDisabled: boolean = false,
|
|
284
|
-
searchBarInput: HTMLElement | undefined = undefined,
|
|
285
|
-
openQuickFilter: boolean = false,
|
|
286
|
-
quickFilterActivator: HTMLElement | undefined,
|
|
287
|
-
quickFilterActive: QuickFilter,
|
|
288
|
-
globalBuilder: FilterBuilder = new FilterBuilder(),
|
|
289
|
-
calendarOpened: boolean = false,
|
|
290
|
-
calendarOpened2: boolean = false,
|
|
291
|
-
selectedIndexes: number[] = [],
|
|
292
|
-
cellEditorIndexRow: number | undefined,
|
|
293
|
-
cellEditorIndexHeader: number | undefined,
|
|
294
|
-
cellEditorSubItem: boolean | undefined,
|
|
295
|
-
currentSectionNumber = 0,
|
|
296
|
-
tableBody: HTMLElement,
|
|
297
|
-
tableContainer: HTMLElement,
|
|
298
|
-
tableHTML: HTMLElement,
|
|
299
|
-
headersHTML: { [value: string]: HTMLElement } = {},
|
|
300
|
-
userScrolling = true,
|
|
301
|
-
reachedBottom = false,
|
|
302
|
-
reachedTop = false,
|
|
303
|
-
resizing = false,
|
|
304
|
-
remainingWidth = 0,
|
|
305
|
-
hideScrollbar = false,
|
|
306
|
-
sortModify: Header['sortModify'],
|
|
307
|
-
mainHeader: Element,
|
|
308
|
-
resizeObserver: ResizeObserver,
|
|
309
|
-
ignoreSelectAll = rows.length == totalRows && useSelectedItemsOnly
|
|
310
|
-
|
|
311
|
-
const DEFAULT_MIN_WIDTH_PX = 100,
|
|
312
|
-
DEFAULT_MAX_WIDTH_PX = 400
|
|
313
|
-
|
|
314
|
-
$: totalSections = (totalRows - renderedRowsNumber) / sectionRowsNumber
|
|
315
|
-
$: hasMoreToRender = totalSections > currentSectionNumber
|
|
316
|
-
$: totalCachedSections = (rows.length - renderedRowsNumber) / sectionRowsNumber
|
|
317
|
-
$: renderedRows = rows.slice(currentSectionNumber * sectionRowsNumber, currentSectionNumber * sectionRowsNumber + renderedRowsNumber)
|
|
318
|
-
|
|
319
|
-
let openHeaderDrawer: boolean = false,
|
|
320
|
-
headersToSelect: {
|
|
321
|
-
id: string;
|
|
322
|
-
name: string;
|
|
323
|
-
}[] = !!headers
|
|
324
|
-
? headers
|
|
325
|
-
.filter((h) => {
|
|
326
|
-
return !headersToShowInTable.find((hst) => hst.value == h.value);
|
|
327
|
-
})
|
|
328
|
-
.map((h) => {
|
|
329
|
-
return {
|
|
330
|
-
id: h.value,
|
|
331
|
-
name: h.label,
|
|
332
|
-
};
|
|
333
|
-
})
|
|
334
|
-
: [],
|
|
335
|
-
headersToShow: {
|
|
336
|
-
id: string;
|
|
337
|
-
name: string;
|
|
338
|
-
}[] = headersToShowInTable.map((h) => {
|
|
339
|
-
return {
|
|
340
|
-
id: h.value,
|
|
341
|
-
name: h.label,
|
|
342
|
-
};
|
|
343
|
-
}),
|
|
344
|
-
infoActivators = Array(headersToShowInTable.length)
|
|
345
|
-
|
|
346
|
-
let totalBatchLength: number = 0,
|
|
347
|
-
expandedRows: Row[] = [];
|
|
348
|
-
|
|
349
|
-
function saveHeadersToShow() {
|
|
350
|
-
dispatch("saveHeadersToShow", {
|
|
351
|
-
headersToShow: headersToShow,
|
|
352
|
-
});
|
|
353
|
-
openHeaderDrawer = false;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
function handleHeaderClick(header: Header) {
|
|
357
|
-
if (header.sortable && !loading && !resizing) {
|
|
358
|
-
if (!!sortedBy && header.value == sortedBy) {
|
|
359
|
-
if (sortDirection == "asc") sortDirection = "desc";
|
|
360
|
-
else if (sortDirection == "desc") {
|
|
361
|
-
sortedBy = undefined;
|
|
362
|
-
sortModify = undefined
|
|
363
|
-
}
|
|
364
|
-
} else {
|
|
365
|
-
sortedBy = header.value;
|
|
366
|
-
sortDirection = "asc";
|
|
367
|
-
sortModify = header.sortModify
|
|
126
|
+
}), infoActivators = Array(headersToShowInTable.length);
|
|
127
|
+
let totalBatchLength = 0, expandedRows = [];
|
|
128
|
+
function saveHeadersToShow() {
|
|
129
|
+
dispatch("saveHeadersToShow", {
|
|
130
|
+
headersToShow
|
|
131
|
+
});
|
|
132
|
+
openHeaderDrawer = false;
|
|
133
|
+
}
|
|
134
|
+
function handleHeaderClick(header) {
|
|
135
|
+
if (header.sortable && !loading && !resizing) {
|
|
136
|
+
if (!!sortedBy && header.value == sortedBy) {
|
|
137
|
+
if (sortDirection == "asc")
|
|
138
|
+
sortDirection = "desc";
|
|
139
|
+
else if (sortDirection == "desc") {
|
|
140
|
+
sortedBy = void 0;
|
|
141
|
+
sortModify = void 0;
|
|
368
142
|
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
sortedBy,
|
|
374
|
-
sortDirection,
|
|
375
|
-
});
|
|
143
|
+
} else {
|
|
144
|
+
sortedBy = header.value;
|
|
145
|
+
sortDirection = "asc";
|
|
146
|
+
sortModify = header.sortModify;
|
|
376
147
|
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
dispatch("rowClick", {
|
|
382
|
-
item,
|
|
148
|
+
handleSearchChange(searchText);
|
|
149
|
+
dispatch("sort", {
|
|
150
|
+
sortedBy,
|
|
151
|
+
sortDirection
|
|
383
152
|
});
|
|
384
153
|
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
item
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
) {
|
|
397
|
-
if (
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
windowHeight - element.top
|
|
424
|
-
}px`;
|
|
425
|
-
} else {
|
|
426
|
-
cellEditorContainer!.style.top = `${element.bottom}px`;
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
if (windowWidth - element.right < 400) {
|
|
430
|
-
cellEditorContainer!.style.right = `${
|
|
431
|
-
windowWidth - element.left - cellEditorActivator!.clientWidth
|
|
432
|
-
}px`;
|
|
433
|
-
}
|
|
434
|
-
}, 0);
|
|
435
|
-
}
|
|
154
|
+
}
|
|
155
|
+
function handleRowClick(item) {
|
|
156
|
+
if (disabled || loading)
|
|
157
|
+
return;
|
|
158
|
+
dispatch("rowClick", {
|
|
159
|
+
item
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
function handleCellClick(mouseEvent, item, cellEditorInfo, value, indexRow, indexHeader, subItem) {
|
|
163
|
+
if (disabled || loading)
|
|
164
|
+
return;
|
|
165
|
+
if (cellEdit && cellEditorInfo && !item.disableEdit) {
|
|
166
|
+
if (!cellEditorActivator) {
|
|
167
|
+
let target = mouseEvent.target;
|
|
168
|
+
cellEditorActivator = target;
|
|
169
|
+
cellEditorIndexRow = indexRow;
|
|
170
|
+
cellEditorIndexHeader = indexHeader;
|
|
171
|
+
cellEditorSubItem = subItem;
|
|
172
|
+
cellEditorInfoActive = {
|
|
173
|
+
...cellEditorInfo,
|
|
174
|
+
value,
|
|
175
|
+
item
|
|
176
|
+
};
|
|
177
|
+
openCellEditor = !openCellEditor;
|
|
178
|
+
const element = target.getBoundingClientRect();
|
|
179
|
+
const windowHeight = window.innerHeight;
|
|
180
|
+
const windowWidth = window.innerWidth;
|
|
181
|
+
if (openCellEditor) {
|
|
182
|
+
setTimeout(() => {
|
|
183
|
+
if (windowHeight - element.bottom < 300) {
|
|
184
|
+
cellEditorContainer.style.bottom = `${windowHeight - element.top}px`;
|
|
185
|
+
} else {
|
|
186
|
+
cellEditorContainer.style.top = `${element.bottom}px`;
|
|
187
|
+
}
|
|
188
|
+
if (windowWidth - element.right < 400) {
|
|
189
|
+
cellEditorContainer.style.right = `${windowWidth - element.left - cellEditorActivator.clientWidth}px`;
|
|
190
|
+
}
|
|
191
|
+
}, 0);
|
|
436
192
|
}
|
|
437
193
|
}
|
|
438
|
-
|
|
439
|
-
dispatch("cellClick", {
|
|
440
|
-
item,
|
|
441
|
-
});
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
function handleSaveClick() {
|
|
445
|
-
cellEditorIndexHeader = undefined
|
|
446
|
-
cellEditorIndexRow = undefined
|
|
447
|
-
cellEditorSubItem = undefined
|
|
448
|
-
|
|
449
|
-
dispatch("saveCellEdit", {
|
|
450
|
-
item: cellEditorInfoActive,
|
|
451
|
-
});
|
|
452
|
-
|
|
453
|
-
cellEditorActivator = undefined;
|
|
454
|
-
openCellEditor = false;
|
|
455
194
|
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
195
|
+
dispatch("cellClick", {
|
|
196
|
+
item
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
function handleSaveClick() {
|
|
200
|
+
cellEditorIndexHeader = void 0;
|
|
201
|
+
cellEditorIndexRow = void 0;
|
|
202
|
+
cellEditorSubItem = void 0;
|
|
203
|
+
dispatch("saveCellEdit", {
|
|
204
|
+
item: cellEditorInfoActive
|
|
205
|
+
});
|
|
206
|
+
cellEditorActivator = void 0;
|
|
207
|
+
openCellEditor = false;
|
|
208
|
+
}
|
|
209
|
+
function handleCancelClick() {
|
|
210
|
+
cellEditorIndexHeader = void 0;
|
|
211
|
+
cellEditorIndexRow = void 0;
|
|
212
|
+
cellEditorSubItem = void 0;
|
|
213
|
+
cellEditorActivator = void 0;
|
|
214
|
+
openCellEditor = false;
|
|
215
|
+
quickFilterActivator = void 0;
|
|
216
|
+
openQuickFilter = false;
|
|
217
|
+
}
|
|
218
|
+
function handleSelect(item, shiftKeyPressed) {
|
|
219
|
+
let index = -1;
|
|
220
|
+
if (selectedAll && !ignoreSelectAll) {
|
|
221
|
+
index = unselectedItems.findIndex((i) => i[uniqueKey] == item[uniqueKey]);
|
|
222
|
+
} else {
|
|
223
|
+
index = selectedItems.findIndex((i) => i[uniqueKey] == item[uniqueKey]);
|
|
224
|
+
}
|
|
225
|
+
if (index == -1) {
|
|
226
|
+
if (selectMode == "single") {
|
|
227
|
+
selectedItems = [item];
|
|
228
|
+
selectedIndexes = [rows.findIndex((r) => r.item[uniqueKey] == item[uniqueKey])];
|
|
229
|
+
} else if (selectMode == "multiple") {
|
|
230
|
+
if (shiftKeyPressed && selectedIndexes.length > 0) {
|
|
231
|
+
let lastSelectedIndex = selectedIndexes[selectedIndexes.length - 1], selectedIndex = rows.findIndex((r) => r.item[uniqueKey] == item[uniqueKey]);
|
|
232
|
+
if (selectedIndex != -1) {
|
|
233
|
+
if (selectedIndex < lastSelectedIndex) {
|
|
234
|
+
let x = lastSelectedIndex;
|
|
235
|
+
lastSelectedIndex = selectedIndex - 1;
|
|
236
|
+
selectedIndex = x;
|
|
237
|
+
}
|
|
238
|
+
for (let i = lastSelectedIndex + 1; i <= selectedIndex; i++) {
|
|
239
|
+
if (selectedAll && !ignoreSelectAll) {
|
|
240
|
+
if (!unselectedItems.find((unselectedItem) => unselectedItem[uniqueKey] == rows[i].item[uniqueKey])) {
|
|
241
|
+
unselectedItems = [...unselectedItems, rows[i].item];
|
|
242
|
+
}
|
|
243
|
+
} else {
|
|
244
|
+
if (!selectedItems.find((selectedItem) => selectedItem[uniqueKey] == rows[i].item[uniqueKey])) {
|
|
245
|
+
selectedItems = [...selectedItems, rows[i].item];
|
|
500
246
|
}
|
|
501
247
|
}
|
|
502
248
|
}
|
|
503
249
|
}
|
|
504
|
-
else {
|
|
505
|
-
if(selectedAll && !ignoreSelectAll) {
|
|
506
|
-
unselectedItems = [...unselectedItems, item];
|
|
507
|
-
} else {
|
|
508
|
-
selectedItems = [...selectedItems, item];
|
|
509
|
-
}
|
|
510
|
-
selectedIndexes.push(rows.findIndex(r => r.item[uniqueKey] == item[uniqueKey]))
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
} else {
|
|
514
|
-
if(selectedAll && !ignoreSelectAll) {
|
|
515
|
-
unselectedItems = unselectedItems.filter((i) => i[uniqueKey] != item[uniqueKey]);
|
|
516
250
|
} else {
|
|
517
|
-
|
|
251
|
+
if (selectedAll && !ignoreSelectAll) {
|
|
252
|
+
unselectedItems = [...unselectedItems, item];
|
|
253
|
+
} else {
|
|
254
|
+
selectedItems = [...selectedItems, item];
|
|
255
|
+
}
|
|
256
|
+
selectedIndexes.push(rows.findIndex((r) => r.item[uniqueKey] == item[uniqueKey]));
|
|
518
257
|
}
|
|
519
|
-
selectedIndexes = selectedIndexes.filter(r => r != rows.findIndex(r => r.item[uniqueKey] == item[uniqueKey]))
|
|
520
258
|
}
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
selectedItems = rows.map(r => r.item)
|
|
527
|
-
}
|
|
528
|
-
else {
|
|
529
|
-
selectedItems = []
|
|
530
|
-
}
|
|
531
|
-
selectedIndexes = []
|
|
532
|
-
unselectedItems = []
|
|
533
|
-
selectedAll = !selectedAll
|
|
259
|
+
} else {
|
|
260
|
+
if (selectedAll && !ignoreSelectAll) {
|
|
261
|
+
unselectedItems = unselectedItems.filter((i) => i[uniqueKey] != item[uniqueKey]);
|
|
262
|
+
} else {
|
|
263
|
+
selectedItems = selectedItems.filter((i) => i[uniqueKey] != item[uniqueKey]);
|
|
534
264
|
}
|
|
265
|
+
selectedIndexes = selectedIndexes.filter((r) => r != rows.findIndex((r2) => r2.item[uniqueKey] == item[uniqueKey]));
|
|
535
266
|
}
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
if (
|
|
540
|
-
|
|
267
|
+
}
|
|
268
|
+
function handleSelectAll() {
|
|
269
|
+
if (selectMode == "multiple") {
|
|
270
|
+
if (!selectedAll && ignoreSelectAll) {
|
|
271
|
+
selectedItems = rows.map((r) => r.item);
|
|
541
272
|
} else {
|
|
542
|
-
|
|
273
|
+
selectedItems = [];
|
|
543
274
|
}
|
|
275
|
+
selectedIndexes = [];
|
|
276
|
+
unselectedItems = [];
|
|
277
|
+
selectedAll = !selectedAll;
|
|
544
278
|
}
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
279
|
+
}
|
|
280
|
+
function expandRow(row) {
|
|
281
|
+
let index = expandedRows.findIndex((r) => r.item[uniqueKey] == row.item[uniqueKey]);
|
|
282
|
+
if (index == -1) {
|
|
283
|
+
expandedRows = [...expandedRows, row];
|
|
284
|
+
} else {
|
|
285
|
+
expandedRows = expandedRows.filter((r) => r.item[uniqueKey] != row.item[uniqueKey]);
|
|
551
286
|
}
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
287
|
+
}
|
|
288
|
+
function formatDate(dateTime, dateFormat) {
|
|
289
|
+
return dateTime.setLocale(dateFormat.locale).toFormat(dateFormat.format);
|
|
290
|
+
}
|
|
291
|
+
$: {
|
|
292
|
+
if (!showExpand) {
|
|
293
|
+
totalBatchLength = rows.length;
|
|
294
|
+
} else {
|
|
295
|
+
totalBatchLength = rows.reduce(
|
|
296
|
+
(acc, row) => acc + row.subItems.length,
|
|
297
|
+
rows.length
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
if (!!cellEditorInfoActive && cellEditorInfoActive.type.key == "number" && (cellEditorInfoActive.type.params?.min != void 0 && cellEditorInfoActive.value < cellEditorInfoActive.type.params.min || cellEditorInfoActive.type.params?.max != void 0 && cellEditorInfoActive.value > cellEditorInfoActive.type.params.max)) {
|
|
301
|
+
saveEditDisabled = true;
|
|
302
|
+
} else {
|
|
303
|
+
saveEditDisabled = false;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
function searchTextBuilder(searchText2) {
|
|
307
|
+
let builder;
|
|
308
|
+
let converter = new Converter();
|
|
309
|
+
builder = converter.createBuilder({
|
|
310
|
+
filters: filters || []
|
|
311
|
+
});
|
|
312
|
+
if (!!searchText2 && !!searchBarColumns && searchBarColumns.length > 0) {
|
|
313
|
+
builder.where((b) => {
|
|
314
|
+
b.where(searchBarColumns[0], "ilike", "%" + searchText2 + "%");
|
|
315
|
+
for (let i = 1; i < searchBarColumns.length; i += 1) {
|
|
316
|
+
b.orWhere(searchBarColumns[i], "ilike", "%" + searchText2 + "%");
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
return builder;
|
|
321
|
+
}
|
|
322
|
+
let syncTimer;
|
|
323
|
+
function handleSearchChange(searchText2) {
|
|
324
|
+
clearTimeout(syncTimer);
|
|
325
|
+
syncTimer = setTimeout(async () => {
|
|
326
|
+
globalBuilder = searchTextBuilder(searchText2);
|
|
327
|
+
for (let i = 0; i < quickFilters.length; i++) {
|
|
328
|
+
globalBuilder = quickFilterBuilder(globalBuilder, quickFilters[i]);
|
|
561
329
|
}
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
330
|
+
handleFiltersChange();
|
|
331
|
+
}, 800);
|
|
332
|
+
}
|
|
333
|
+
$:
|
|
334
|
+
if (searchText != void 0)
|
|
335
|
+
handleSearchChange(searchText);
|
|
336
|
+
function handleFiltersChange() {
|
|
337
|
+
if (!!tableContainer) {
|
|
338
|
+
userScrolling = false;
|
|
339
|
+
currentSectionNumber = 0;
|
|
340
|
+
tableContainer.scrollTop = 0;
|
|
341
|
+
setTimeout(() => userScrolling = true, 20);
|
|
342
|
+
}
|
|
343
|
+
if (!!sortedBy) {
|
|
344
|
+
if (sortModify) {
|
|
345
|
+
globalBuilder = sortModify({ builder: globalBuilder, sortDirection });
|
|
572
346
|
} else {
|
|
573
|
-
|
|
347
|
+
globalBuilder.orderBy(sortedBy, sortDirection || "asc");
|
|
574
348
|
}
|
|
575
349
|
}
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
350
|
+
dispatch("filtersChange", {
|
|
351
|
+
builder: globalBuilder
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
function handleClearQuickFilter(quickFilter, dispatchFiltersChange = true) {
|
|
355
|
+
if (quickFilter.type.key == "custom") {
|
|
356
|
+
quickFilter.type.value = void 0;
|
|
357
|
+
quickFilter.type.missingValue = void 0;
|
|
358
|
+
if (dispatchFiltersChange) {
|
|
359
|
+
dispatch("removeCustomQuickFilter", { quickFilter });
|
|
360
|
+
}
|
|
361
|
+
} else if (quickFilter.type.key == "string") {
|
|
362
|
+
quickFilter.type.value = void 0;
|
|
363
|
+
quickFilter.type.missingValue = void 0;
|
|
364
|
+
} else if (quickFilter.type.key == "number") {
|
|
365
|
+
quickFilter.type.value = void 0;
|
|
366
|
+
quickFilter.type.missingValue = void 0;
|
|
367
|
+
} else if (quickFilter.type.key == "boolean") {
|
|
368
|
+
quickFilter.type.value = void 0;
|
|
369
|
+
} else if (quickFilter.type.key == "country") {
|
|
370
|
+
quickFilter.type.selected = void 0;
|
|
371
|
+
quickFilter.type.missingValue = void 0;
|
|
372
|
+
} else if (quickFilter.type.key == "date") {
|
|
373
|
+
quickFilter.type.from = void 0;
|
|
374
|
+
quickFilter.type.to = void 0;
|
|
375
|
+
} else if (quickFilter.type.key == "multi-select") {
|
|
376
|
+
quickFilter.type.values = [];
|
|
377
|
+
quickFilter.type.missingValue = false;
|
|
378
|
+
quickFilter.type.missingValue = void 0;
|
|
379
|
+
}
|
|
380
|
+
if (dispatchFiltersChange) {
|
|
381
|
+
quickFilter.active = false;
|
|
382
|
+
}
|
|
383
|
+
globalBuilder = searchTextBuilder(searchText);
|
|
384
|
+
for (let i = 0; i < quickFilters.length; i++) {
|
|
385
|
+
if (quickFilters[i].active) {
|
|
386
|
+
globalBuilder = quickFilterBuilder(
|
|
387
|
+
globalBuilder,
|
|
388
|
+
quickFilters[i],
|
|
389
|
+
false
|
|
390
|
+
);
|
|
592
391
|
}
|
|
593
|
-
|
|
594
|
-
return builder;
|
|
595
392
|
}
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
clearTimeout(syncTimer);
|
|
600
|
-
syncTimer = setTimeout(async () => {
|
|
601
|
-
globalBuilder = searchTextBuilder(searchText);
|
|
602
|
-
for (let i = 0; i < quickFilters.length; i++) {
|
|
603
|
-
globalBuilder = quickFilterBuilder(globalBuilder, quickFilters[i]);
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
handleFiltersChange();
|
|
607
|
-
}, 800);
|
|
393
|
+
if (dispatchFiltersChange) {
|
|
394
|
+
quickFilters = quickFilters;
|
|
395
|
+
handleFiltersChange();
|
|
608
396
|
}
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
globalBuilder.orderBy(sortedBy, sortDirection || "asc");
|
|
397
|
+
return globalBuilder;
|
|
398
|
+
}
|
|
399
|
+
function handleSearchBoxKeydown(e) {
|
|
400
|
+
if (e.key == "Enter") {
|
|
401
|
+
handleFiltersChange();
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
function handleQuickFilterClick(mouseEvent, quickFilter) {
|
|
405
|
+
handleCancelClick();
|
|
406
|
+
setTimeout(() => {
|
|
407
|
+
if (quickFilter) {
|
|
408
|
+
if (!quickFilterActivator) {
|
|
409
|
+
let target = mouseEvent.target;
|
|
410
|
+
quickFilterActivator = target;
|
|
411
|
+
quickFilterActive = quickFilter;
|
|
412
|
+
openQuickFilter = !openQuickFilter;
|
|
626
413
|
}
|
|
627
414
|
}
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
415
|
+
}, 300);
|
|
416
|
+
}
|
|
417
|
+
function setQuickFilterMissingValue(quickFilter) {
|
|
418
|
+
if (quickFilter.type.key == "custom") {
|
|
419
|
+
quickFilter.type.missingValue = true;
|
|
420
|
+
quickFilter.type.value = void 0;
|
|
421
|
+
} else if (quickFilter.type.key == "multi-select") {
|
|
422
|
+
quickFilter.type.missingValue = true;
|
|
423
|
+
quickFilter.type.values = [];
|
|
424
|
+
} else if (quickFilter.type.key == "string") {
|
|
425
|
+
quickFilter.type.missingValue = true;
|
|
426
|
+
quickFilter.type.value = void 0;
|
|
427
|
+
} else if (quickFilter.type.key == "country") {
|
|
428
|
+
quickFilter.type.missingValue = true;
|
|
429
|
+
quickFilter.type.selected = void 0;
|
|
430
|
+
} else if (quickFilter.type.key == "number") {
|
|
431
|
+
quickFilter.type.missingValue = true;
|
|
432
|
+
quickFilter.type.value = void 0;
|
|
433
|
+
}
|
|
434
|
+
handleApplyClick(quickFilter);
|
|
435
|
+
}
|
|
436
|
+
function setQuickFilterValue(quickFilter, value) {
|
|
437
|
+
if (quickFilter.type.key == "custom") {
|
|
438
|
+
quickFilter.type.value = value;
|
|
439
|
+
} else if (quickFilter.type.key == "boolean") {
|
|
440
|
+
quickFilter.type.value = value;
|
|
632
441
|
}
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
442
|
+
handleApplyClick(quickFilter);
|
|
443
|
+
}
|
|
444
|
+
function handleApplyClick(quickFilter, dispatchCustomFilterClick = false) {
|
|
445
|
+
if (quickFilter.type.key == "custom" && dispatchCustomFilterClick) {
|
|
446
|
+
dispatch("applyCustomQuickFilter", { quickFilter, setQuickFilterValue });
|
|
447
|
+
} else {
|
|
448
|
+
quickFilter.active = true;
|
|
449
|
+
quickFilters = quickFilters;
|
|
450
|
+
globalBuilder = quickFilterBuilder(globalBuilder, quickFilter);
|
|
451
|
+
handleFiltersChange();
|
|
452
|
+
quickFilterActivator = void 0;
|
|
453
|
+
openQuickFilter = false;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
function quickFilterBuilder(builder, quickFilter, clearPreaviousValue = true) {
|
|
457
|
+
if (quickFilter.type.key == "custom") {
|
|
458
|
+
let value = quickFilter.type.value, missingValue = quickFilter.type.missingValue;
|
|
459
|
+
if (clearPreaviousValue) {
|
|
460
|
+
builder = handleClearQuickFilter(quickFilter, false);
|
|
644
461
|
}
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
quickFilter.type.missingValue = undefined;
|
|
656
|
-
} else if (quickFilter.type.key == "date") {
|
|
657
|
-
quickFilter.type.from = undefined;
|
|
658
|
-
quickFilter.type.to = undefined;
|
|
659
|
-
} else if (quickFilter.type.key == "multi-select") {
|
|
660
|
-
quickFilter.type.values = [];
|
|
661
|
-
quickFilter.type.missingValue = false;
|
|
662
|
-
quickFilter.type.missingValue = undefined;
|
|
462
|
+
quickFilter.type.value = value;
|
|
463
|
+
quickFilter.type.missingValue = missingValue;
|
|
464
|
+
builder = quickFilter.type.modify({
|
|
465
|
+
builder,
|
|
466
|
+
value: { value, missingValue }
|
|
467
|
+
});
|
|
468
|
+
} else if (quickFilter.type.key == "string") {
|
|
469
|
+
let value = quickFilter.type.value, missingValue = quickFilter.type.missingValue;
|
|
470
|
+
if (clearPreaviousValue) {
|
|
471
|
+
builder = handleClearQuickFilter(quickFilter, false);
|
|
663
472
|
}
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
473
|
+
quickFilter.type.value = value;
|
|
474
|
+
quickFilter.type.missingValue = missingValue;
|
|
475
|
+
if (quickFilter.type.modify) {
|
|
476
|
+
builder = quickFilter.type.modify({
|
|
477
|
+
builder,
|
|
478
|
+
value: { value, missingValue }
|
|
479
|
+
});
|
|
667
480
|
}
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
false
|
|
481
|
+
if (!!quickFilter.column) {
|
|
482
|
+
if (missingValue) {
|
|
483
|
+
builder.whereNull(quickFilter.column);
|
|
484
|
+
} else if (!!value) {
|
|
485
|
+
builder.where(
|
|
486
|
+
quickFilter.column,
|
|
487
|
+
quickFilter.type.mode ?? "equal",
|
|
488
|
+
value
|
|
677
489
|
);
|
|
678
490
|
}
|
|
679
491
|
}
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
return globalBuilder;
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
function handleSearchBoxKeydown(e: KeyboardEvent) {
|
|
690
|
-
if (e.key == "Enter") {
|
|
691
|
-
handleFiltersChange();
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
function handleQuickFilterClick(
|
|
696
|
-
mouseEvent: MouseEvent & {
|
|
697
|
-
currentTarget: EventTarget & HTMLButtonElement;
|
|
698
|
-
},
|
|
699
|
-
quickFilter?: QuickFilter
|
|
700
|
-
) {
|
|
701
|
-
handleCancelClick();
|
|
702
|
-
setTimeout(() => {
|
|
703
|
-
if (quickFilter) {
|
|
704
|
-
if (!quickFilterActivator) {
|
|
705
|
-
let target = mouseEvent.target as unknown as HTMLElement;
|
|
706
|
-
quickFilterActivator = target;
|
|
707
|
-
quickFilterActive = quickFilter;
|
|
708
|
-
openQuickFilter = !openQuickFilter;
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
}, 300);
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
function setQuickFilterMissingValue(quickFilter: QuickFilter) {
|
|
715
|
-
if (quickFilter.type.key == 'custom') {
|
|
716
|
-
quickFilter.type.missingValue = true;
|
|
717
|
-
quickFilter.type.value = undefined;
|
|
492
|
+
} else if (quickFilter.type.key == "boolean") {
|
|
493
|
+
let value = quickFilter.type.value;
|
|
494
|
+
if (clearPreaviousValue) {
|
|
495
|
+
builder = handleClearQuickFilter(quickFilter, false);
|
|
718
496
|
}
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
quickFilter.type.
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
} else if (quickFilter.type.key == "country") {
|
|
726
|
-
quickFilter.type.missingValue = true;
|
|
727
|
-
quickFilter.type.selected = undefined;
|
|
728
|
-
} else if (quickFilter.type.key == "number") {
|
|
729
|
-
quickFilter.type.missingValue = true;
|
|
730
|
-
quickFilter.type.value = undefined;
|
|
497
|
+
quickFilter.type.value = value;
|
|
498
|
+
if (quickFilter.type.modify) {
|
|
499
|
+
builder = quickFilter.type.modify({
|
|
500
|
+
builder,
|
|
501
|
+
value
|
|
502
|
+
});
|
|
731
503
|
}
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
function setQuickFilterValue(quickFilter: QuickFilter, value?: any) {
|
|
737
|
-
if (quickFilter.type.key == "custom") {
|
|
738
|
-
quickFilter.type.value = value;
|
|
739
|
-
}
|
|
740
|
-
else if (quickFilter.type.key == "boolean") {
|
|
741
|
-
quickFilter.type.value = value;
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
handleApplyClick(quickFilter);
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
function handleApplyClick(quickFilter: QuickFilter, dispatchCustomFilterClick: boolean = false) {
|
|
748
|
-
if(quickFilter.type.key == 'custom' && dispatchCustomFilterClick) {
|
|
749
|
-
dispatch('applyCustomQuickFilter', { quickFilter, setQuickFilterValue})
|
|
504
|
+
if (!!quickFilter.column && value != void 0) {
|
|
505
|
+
builder.where(quickFilter.column, value);
|
|
750
506
|
}
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
handleFiltersChange();
|
|
757
|
-
|
|
758
|
-
quickFilterActivator = undefined;
|
|
759
|
-
openQuickFilter = false;
|
|
507
|
+
} else if (quickFilter.type.key == "country") {
|
|
508
|
+
let value = quickFilter.type.selected, missingValue = quickFilter.type.missingValue;
|
|
509
|
+
if (clearPreaviousValue) {
|
|
510
|
+
builder = handleClearQuickFilter(quickFilter, false);
|
|
760
511
|
}
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
quickFilter: QuickFilter,
|
|
766
|
-
clearPreaviousValue: boolean = true
|
|
767
|
-
) {
|
|
768
|
-
if (quickFilter.type.key == 'custom') {
|
|
769
|
-
let value = quickFilter.type.value,
|
|
770
|
-
missingValue = quickFilter.type.missingValue;
|
|
771
|
-
if (clearPreaviousValue) {
|
|
772
|
-
builder = handleClearQuickFilter(quickFilter, false);
|
|
773
|
-
}
|
|
774
|
-
quickFilter.type.value = value;
|
|
775
|
-
quickFilter.type.missingValue = missingValue;
|
|
776
|
-
|
|
512
|
+
quickFilter.type.selected = value;
|
|
513
|
+
quickFilter.type.missingValue = missingValue;
|
|
514
|
+
const values = value?.map((item) => item.value);
|
|
515
|
+
if (quickFilter.type.modify) {
|
|
777
516
|
builder = quickFilter.type.modify({
|
|
778
517
|
builder,
|
|
779
|
-
value: {
|
|
518
|
+
value: { values, missingValue }
|
|
780
519
|
});
|
|
781
520
|
}
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
if (
|
|
786
|
-
builder
|
|
521
|
+
if (!!quickFilter.column) {
|
|
522
|
+
if (missingValue) {
|
|
523
|
+
builder.whereNull(quickFilter.column);
|
|
524
|
+
} else if (!!values && values.length > 0) {
|
|
525
|
+
builder.whereIn(quickFilter.column, values);
|
|
787
526
|
}
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
)
|
|
807
|
-
|
|
527
|
+
}
|
|
528
|
+
} else if (quickFilter.type.key == "date") {
|
|
529
|
+
let from = quickFilter.type.from, to = quickFilter.type.to;
|
|
530
|
+
if (clearPreaviousValue) {
|
|
531
|
+
builder = handleClearQuickFilter(quickFilter, false);
|
|
532
|
+
}
|
|
533
|
+
quickFilter.type.from = from;
|
|
534
|
+
quickFilter.type.to = to;
|
|
535
|
+
if (quickFilter.type.modify) {
|
|
536
|
+
builder = quickFilter.type.modify({
|
|
537
|
+
builder,
|
|
538
|
+
value: { from, to }
|
|
539
|
+
});
|
|
540
|
+
} else if (!!quickFilter.column) {
|
|
541
|
+
if (!!from) {
|
|
542
|
+
builder.where(
|
|
543
|
+
quickFilter.column,
|
|
544
|
+
">=",
|
|
545
|
+
DateTime.fromJSDate(from).setLocale("it-IT").startOf("day").toString()
|
|
546
|
+
);
|
|
808
547
|
}
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
548
|
+
if (!!to) {
|
|
549
|
+
builder.where(
|
|
550
|
+
quickFilter.column,
|
|
551
|
+
"<=",
|
|
552
|
+
DateTime.fromJSDate(to).setLocale("it-IT").endOf("day").toString()
|
|
553
|
+
);
|
|
813
554
|
}
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
555
|
+
}
|
|
556
|
+
} else if (quickFilter.type.key == "multi-select") {
|
|
557
|
+
let value = quickFilter.type.values, missingValue = quickFilter.type.missingValue;
|
|
558
|
+
if (clearPreaviousValue) {
|
|
559
|
+
builder = handleClearQuickFilter(quickFilter, false);
|
|
560
|
+
}
|
|
561
|
+
quickFilter.type.values = value;
|
|
562
|
+
quickFilter.type.missingValue = missingValue;
|
|
563
|
+
const values = value.map((item) => item.value);
|
|
564
|
+
if (quickFilter.type.modify) {
|
|
565
|
+
builder = quickFilter.type.modify({
|
|
566
|
+
builder,
|
|
567
|
+
value: { values, missingValue }
|
|
568
|
+
});
|
|
569
|
+
} else if (quickFilter.column) {
|
|
570
|
+
if (missingValue) {
|
|
571
|
+
builder.whereNull(quickFilter.column);
|
|
572
|
+
} else if (values.length > 0) {
|
|
573
|
+
builder.whereIn(quickFilter.column, values);
|
|
821
574
|
}
|
|
822
|
-
|
|
823
|
-
|
|
575
|
+
}
|
|
576
|
+
} else if (quickFilter.type.key == "number") {
|
|
577
|
+
let value = quickFilter.type.value, missingValue = quickFilter.type.missingValue;
|
|
578
|
+
if (clearPreaviousValue) {
|
|
579
|
+
builder = handleClearQuickFilter(quickFilter, false);
|
|
580
|
+
}
|
|
581
|
+
quickFilter.type.value = value;
|
|
582
|
+
quickFilter.type.missingValue = missingValue;
|
|
583
|
+
if (quickFilter.type.modify) {
|
|
584
|
+
builder = quickFilter.type.modify({
|
|
585
|
+
builder,
|
|
586
|
+
value: { value, missingValue }
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
if (quickFilter.column) {
|
|
590
|
+
if (missingValue) {
|
|
591
|
+
builder.whereNull(quickFilter.column);
|
|
592
|
+
} else if (!!value) {
|
|
824
593
|
builder.where(quickFilter.column, value);
|
|
825
594
|
}
|
|
826
|
-
} else if (quickFilter.type.key == "country") {
|
|
827
|
-
let value = quickFilter.type.selected,
|
|
828
|
-
missingValue = quickFilter.type.missingValue;
|
|
829
|
-
if (clearPreaviousValue) {
|
|
830
|
-
builder = handleClearQuickFilter(quickFilter, false);
|
|
831
|
-
}
|
|
832
|
-
quickFilter.type.selected = value;
|
|
833
|
-
quickFilter.type.missingValue = missingValue;
|
|
834
|
-
|
|
835
|
-
const values = value?.map((item) => item.value);
|
|
836
|
-
if (quickFilter.type.modify) {
|
|
837
|
-
builder = quickFilter.type.modify({
|
|
838
|
-
builder,
|
|
839
|
-
value: { values, missingValue },
|
|
840
|
-
});
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
if (!!quickFilter.column) {
|
|
844
|
-
if (missingValue) {
|
|
845
|
-
builder.whereNull(quickFilter.column);
|
|
846
|
-
} else if (!!values && values.length > 0) {
|
|
847
|
-
builder.whereIn(quickFilter.column, values);
|
|
848
|
-
}
|
|
849
|
-
}
|
|
850
|
-
} else if (quickFilter.type.key == "date") {
|
|
851
|
-
let from = quickFilter.type.from,
|
|
852
|
-
to = quickFilter.type.to;
|
|
853
|
-
if (clearPreaviousValue) {
|
|
854
|
-
builder = handleClearQuickFilter(quickFilter, false);
|
|
855
|
-
}
|
|
856
|
-
quickFilter.type.from = from;
|
|
857
|
-
quickFilter.type.to = to;
|
|
858
|
-
|
|
859
|
-
if (quickFilter.type.modify) {
|
|
860
|
-
builder = quickFilter.type.modify({
|
|
861
|
-
builder,
|
|
862
|
-
value: { from, to },
|
|
863
|
-
});
|
|
864
|
-
} else if (!!quickFilter.column) {
|
|
865
|
-
if (!!from) {
|
|
866
|
-
builder.where(
|
|
867
|
-
quickFilter.column,
|
|
868
|
-
">=",
|
|
869
|
-
DateTime.fromJSDate(from).setLocale('it-IT').startOf('day').toString()
|
|
870
|
-
);
|
|
871
|
-
}
|
|
872
|
-
if (!!to) {
|
|
873
|
-
builder.where(
|
|
874
|
-
quickFilter.column,
|
|
875
|
-
"<=",
|
|
876
|
-
DateTime.fromJSDate(to).setLocale('it-IT').endOf('day').toString() );
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
} else if (quickFilter.type.key == "multi-select") {
|
|
880
|
-
let value = quickFilter.type.values,
|
|
881
|
-
missingValue = quickFilter.type.missingValue;
|
|
882
|
-
if (clearPreaviousValue) {
|
|
883
|
-
builder = handleClearQuickFilter(quickFilter, false);
|
|
884
|
-
}
|
|
885
|
-
quickFilter.type.values = value;
|
|
886
|
-
quickFilter.type.missingValue = missingValue;
|
|
887
|
-
|
|
888
|
-
const values = value.map(item => item.value);
|
|
889
|
-
|
|
890
|
-
if (quickFilter.type.modify) {
|
|
891
|
-
builder = quickFilter.type.modify({
|
|
892
|
-
builder,
|
|
893
|
-
value: { values: values, missingValue },
|
|
894
|
-
});
|
|
895
|
-
} else if (quickFilter.column) {
|
|
896
|
-
if (missingValue) {
|
|
897
|
-
builder.whereNull(quickFilter.column);
|
|
898
|
-
} else if (values.length > 0) {
|
|
899
|
-
builder.whereIn(quickFilter.column, values);
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
} else if (quickFilter.type.key == "number") {
|
|
903
|
-
let value = quickFilter.type.value,
|
|
904
|
-
missingValue = quickFilter.type.missingValue;
|
|
905
|
-
if (clearPreaviousValue) {
|
|
906
|
-
builder = handleClearQuickFilter(quickFilter, false);
|
|
907
|
-
}
|
|
908
|
-
quickFilter.type.value = value;
|
|
909
|
-
quickFilter.type.missingValue = missingValue;
|
|
910
|
-
|
|
911
|
-
if (quickFilter.type.modify) {
|
|
912
|
-
builder = quickFilter.type.modify({
|
|
913
|
-
builder,
|
|
914
|
-
value: { value, missingValue },
|
|
915
|
-
});
|
|
916
|
-
}
|
|
917
|
-
|
|
918
|
-
if (quickFilter.column) {
|
|
919
|
-
if (missingValue) {
|
|
920
|
-
builder.whereNull(quickFilter.column);
|
|
921
|
-
} else if (!!value) {
|
|
922
|
-
builder.where(quickFilter.column, value);
|
|
923
|
-
}
|
|
924
|
-
}
|
|
925
595
|
}
|
|
926
|
-
|
|
927
|
-
return builder;
|
|
928
596
|
}
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
filter.mode :
|
|
938
|
-
undefined
|
|
939
|
-
if(filter.type == 'select') {
|
|
940
|
-
newValue = filter.values
|
|
941
|
-
if(newValue.length > 0) {
|
|
942
|
-
newValid = true
|
|
943
|
-
}
|
|
944
|
-
} else if('mode' in filter && filter.mode == 'between') {
|
|
945
|
-
newValue.to = filter.to
|
|
946
|
-
newValue.from = filter.from
|
|
947
|
-
if(!!newValue.from || !!newValue.to) {
|
|
948
|
-
newValid = true
|
|
949
|
-
}
|
|
950
|
-
} else {
|
|
951
|
-
newValue = filter.value
|
|
952
|
-
if(!!newValue) {
|
|
953
|
-
newValid = true
|
|
954
|
-
}
|
|
597
|
+
return builder;
|
|
598
|
+
}
|
|
599
|
+
function updateFilterValues(filter, updateMultiFilterValues) {
|
|
600
|
+
let newValue = {}, newValid = false, newMode = filter.type == "date" || filter.type == "number" || filter.type == "select" || filter.type == "string" ? filter.mode : void 0;
|
|
601
|
+
if (filter.type == "select") {
|
|
602
|
+
newValue = filter.values;
|
|
603
|
+
if (newValue.length > 0) {
|
|
604
|
+
newValid = true;
|
|
955
605
|
}
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
handleSearchChange(searchText);
|
|
962
|
-
}
|
|
963
|
-
|
|
964
|
-
function handleRemoveFilter(filter: Filter) {
|
|
965
|
-
dispatch('removeFilter', { filter})
|
|
966
|
-
handleSearchChange(searchText);
|
|
967
|
-
}
|
|
968
|
-
|
|
969
|
-
async function handleLoadForward() {
|
|
970
|
-
if(renderedRows.length >= renderedRowsNumber) {
|
|
971
|
-
userScrolling = false
|
|
972
|
-
|
|
973
|
-
const anchorIndex = renderedRowsNumber - 1
|
|
974
|
-
const anchorUniqueKey = renderedRows[anchorIndex].item[uniqueKey]
|
|
975
|
-
const anchorElement = findAnchorElement(anchorUniqueKey)
|
|
976
|
-
const anchorOffsetBefore = anchorElement?.getBoundingClientRect().top || 0
|
|
977
|
-
|
|
978
|
-
let removedRowCount = 0
|
|
979
|
-
|
|
980
|
-
for (let i = 0; removedRowCount < sectionRowsNumber; i++) {
|
|
981
|
-
let row = tableBody.children.item(i)
|
|
982
|
-
removedRowCount++
|
|
983
|
-
|
|
984
|
-
const rowKey = row?.getAttribute("data-key")
|
|
985
|
-
const isExpanded = expandedRows.some(r => r.item[uniqueKey] == rowKey)
|
|
986
|
-
|
|
987
|
-
if (isExpanded) {
|
|
988
|
-
i++
|
|
989
|
-
}
|
|
990
|
-
}
|
|
991
|
-
|
|
992
|
-
currentSectionNumber = currentSectionNumber + 1
|
|
993
|
-
|
|
994
|
-
await tick()
|
|
995
|
-
const anchorElementAfter = findAnchorElement(anchorUniqueKey)
|
|
996
|
-
const anchorOffsetAfter = anchorElementAfter?.getBoundingClientRect().top || 0
|
|
997
|
-
const offsetDiff = anchorOffsetAfter - anchorOffsetBefore
|
|
998
|
-
tableContainer.scrollTop += offsetDiff
|
|
999
|
-
|
|
1000
|
-
userScrolling = true
|
|
606
|
+
} else if ("mode" in filter && filter.mode == "between") {
|
|
607
|
+
newValue.to = filter.to;
|
|
608
|
+
newValue.from = filter.from;
|
|
609
|
+
if (!!newValue.from || !!newValue.to) {
|
|
610
|
+
newValid = true;
|
|
1001
611
|
}
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
) {
|
|
1007
|
-
dispatch("fetchData", {});
|
|
612
|
+
} else {
|
|
613
|
+
newValue = filter.value;
|
|
614
|
+
if (!!newValue) {
|
|
615
|
+
newValid = true;
|
|
1008
616
|
}
|
|
1009
617
|
}
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
618
|
+
updateMultiFilterValues(filter.name, newValue, newValid, newMode);
|
|
619
|
+
}
|
|
620
|
+
function handleRemoveAllFilters() {
|
|
621
|
+
dispatch("removeAllFilters", {});
|
|
622
|
+
handleSearchChange(searchText);
|
|
623
|
+
}
|
|
624
|
+
function handleRemoveFilter(filter) {
|
|
625
|
+
dispatch("removeFilter", { filter });
|
|
626
|
+
handleSearchChange(searchText);
|
|
627
|
+
}
|
|
628
|
+
async function handleLoadForward() {
|
|
629
|
+
if (renderedRows.length >= renderedRowsNumber) {
|
|
630
|
+
userScrolling = false;
|
|
631
|
+
const anchorIndex = renderedRowsNumber - 1;
|
|
632
|
+
const anchorUniqueKey = renderedRows[anchorIndex].item[uniqueKey];
|
|
633
|
+
const anchorElement = findAnchorElement(anchorUniqueKey);
|
|
634
|
+
const anchorOffsetBefore = anchorElement?.getBoundingClientRect().top || 0;
|
|
635
|
+
let removedRowCount = 0;
|
|
636
|
+
for (let i = 0; removedRowCount < sectionRowsNumber; i++) {
|
|
637
|
+
let row = tableBody.children.item(i);
|
|
638
|
+
removedRowCount++;
|
|
639
|
+
const rowKey = row?.getAttribute("data-key");
|
|
640
|
+
const isExpanded = expandedRows.some((r) => r.item[uniqueKey] == rowKey);
|
|
641
|
+
if (isExpanded) {
|
|
642
|
+
i++;
|
|
1032
643
|
}
|
|
1033
|
-
|
|
1034
|
-
currentSectionNumber = currentSectionNumber - 1
|
|
1035
|
-
|
|
1036
|
-
await tick()
|
|
1037
|
-
const anchorElementAfter = findAnchorElement(anchorUniqueKey)
|
|
1038
|
-
const anchorOffsetAfter = anchorElementAfter?.getBoundingClientRect().top || 0
|
|
1039
|
-
const offsetDiff = anchorOffsetAfter - anchorOffsetBefore
|
|
1040
|
-
tableContainer.scrollTop += offsetDiff
|
|
1041
|
-
|
|
1042
|
-
userScrolling = true
|
|
1043
644
|
}
|
|
645
|
+
currentSectionNumber = currentSectionNumber + 1;
|
|
646
|
+
await tick();
|
|
647
|
+
const anchorElementAfter = findAnchorElement(anchorUniqueKey);
|
|
648
|
+
const anchorOffsetAfter = anchorElementAfter?.getBoundingClientRect().top || 0;
|
|
649
|
+
const offsetDiff = anchorOffsetAfter - anchorOffsetBefore;
|
|
650
|
+
tableContainer.scrollTop += offsetDiff;
|
|
651
|
+
userScrolling = true;
|
|
1044
652
|
}
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
653
|
+
if (totalCachedSections - sectionThreshold <= currentSectionNumber && !loading && totalRows > rows.length) {
|
|
654
|
+
dispatch("fetchData", {});
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
async function handleLoadBackward() {
|
|
658
|
+
if (currentSectionNumber > 0) {
|
|
659
|
+
userScrolling = false;
|
|
660
|
+
const anchorIndex = 0;
|
|
661
|
+
const anchorUniqueKey = renderedRows[anchorIndex].item[uniqueKey];
|
|
662
|
+
const anchorElement = findAnchorElement(anchorUniqueKey);
|
|
663
|
+
const anchorOffsetBefore = anchorElement?.getBoundingClientRect().top || 0;
|
|
664
|
+
let removedRowCount = 0;
|
|
665
|
+
for (let i = renderedRows.length - 1; removedRowCount < sectionRowsNumber; i--) {
|
|
666
|
+
let row = tableBody.children.item(i);
|
|
667
|
+
removedRowCount++;
|
|
668
|
+
const rowKey = row?.getAttribute("data-key");
|
|
669
|
+
const isExpanded = expandedRows.some((r) => r.item[uniqueKey] == rowKey);
|
|
670
|
+
if (isExpanded) {
|
|
671
|
+
i--;
|
|
1051
672
|
}
|
|
1052
673
|
}
|
|
1053
|
-
|
|
674
|
+
currentSectionNumber = currentSectionNumber - 1;
|
|
675
|
+
await tick();
|
|
676
|
+
const anchorElementAfter = findAnchorElement(anchorUniqueKey);
|
|
677
|
+
const anchorOffsetAfter = anchorElementAfter?.getBoundingClientRect().top || 0;
|
|
678
|
+
const offsetDiff = anchorOffsetAfter - anchorOffsetBefore;
|
|
679
|
+
tableContainer.scrollTop += offsetDiff;
|
|
680
|
+
userScrolling = true;
|
|
1054
681
|
}
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
maxWidthPx = parseInt(maxWidth, 10);
|
|
1078
|
-
}
|
|
1079
|
-
|
|
1080
|
-
const actualMinWidth = (minWidthPx || DEFAULT_MIN_WIDTH_PX) - parseFloat(paddingLeft) - parseFloat(paddingRight);
|
|
1081
|
-
const actualMaxWidth = (maxWidthPx || DEFAULT_MAX_WIDTH_PX) - parseFloat(paddingLeft) - parseFloat(paddingRight);
|
|
1082
|
-
|
|
1083
|
-
if (width > actualMinWidth && width < actualMaxWidth) {
|
|
1084
|
-
th.style.width = width + 'px';
|
|
1085
|
-
resizedColumnSizeWithPadding[th.id] = th.getBoundingClientRect().width;
|
|
1086
|
-
resizedColumnSizeWithPadding = resizedColumnSizeWithPadding
|
|
1087
|
-
}
|
|
682
|
+
}
|
|
683
|
+
function findAnchorElement(key) {
|
|
684
|
+
for (let i = 0; i < tableBody.children.length; i++) {
|
|
685
|
+
const child = tableBody.children.item(i);
|
|
686
|
+
if (child?.getAttribute("data-key") == key) {
|
|
687
|
+
return child;
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
return void 0;
|
|
691
|
+
}
|
|
692
|
+
function resize(node) {
|
|
693
|
+
let th = node.parentElement;
|
|
694
|
+
let resizingInner = false;
|
|
695
|
+
if (!!th) {
|
|
696
|
+
let mouseMoveHandler = function(e) {
|
|
697
|
+
if (resizingInner && !!th && !!tableContainer) {
|
|
698
|
+
width += e.movementX;
|
|
699
|
+
const { paddingLeft, paddingRight } = getComputedStyle(th);
|
|
700
|
+
const minWidth = headers.find((h) => h.value === th.id)?.minWidth;
|
|
701
|
+
let minWidthPx;
|
|
702
|
+
if (!!minWidth && minWidth.endsWith("px")) {
|
|
703
|
+
minWidthPx = parseInt(minWidth, 10);
|
|
1088
704
|
}
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
if(!!th) {
|
|
1094
|
-
resizingInner = false
|
|
1095
|
-
let { paddingLeft, paddingRight } = getComputedStyle(th)
|
|
1096
|
-
width = th.getBoundingClientRect().width - parseFloat(paddingLeft) - parseFloat(paddingRight)
|
|
1097
|
-
if(setResize){
|
|
1098
|
-
setTimeout(() => resizing = false, 20)
|
|
1099
|
-
}
|
|
1100
|
-
dispatch('columnResize', {
|
|
1101
|
-
id: th.id,
|
|
1102
|
-
newWidthPx: width
|
|
1103
|
-
})
|
|
705
|
+
const maxWidth = headers.find((h) => h.value === th.id)?.maxWidth;
|
|
706
|
+
let maxWidthPx;
|
|
707
|
+
if (!!maxWidth && maxWidth.endsWith("px")) {
|
|
708
|
+
maxWidthPx = parseInt(maxWidth, 10);
|
|
1104
709
|
}
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
let { paddingLeft, paddingRight } = getComputedStyle(th)
|
|
1112
|
-
width = th.getBoundingClientRect().width - parseFloat(paddingLeft) - parseFloat(paddingRight)
|
|
710
|
+
const actualMinWidth = (minWidthPx || DEFAULT_MIN_WIDTH_PX) - parseFloat(paddingLeft) - parseFloat(paddingRight);
|
|
711
|
+
const actualMaxWidth = (maxWidthPx || DEFAULT_MAX_WIDTH_PX) - parseFloat(paddingLeft) - parseFloat(paddingRight);
|
|
712
|
+
if (width > actualMinWidth && width < actualMaxWidth) {
|
|
713
|
+
th.style.width = width + "px";
|
|
714
|
+
resizedColumnSizeWithPadding[th.id] = th.getBoundingClientRect().width;
|
|
715
|
+
resizedColumnSizeWithPadding = resizedColumnSizeWithPadding;
|
|
1113
716
|
}
|
|
1114
717
|
}
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
destroy() {
|
|
1123
|
-
node.removeEventListener('mousedown', mouseDownHandler)
|
|
1124
|
-
document.removeEventListener('mouseup', mouseUpHandler)
|
|
1125
|
-
document.removeEventListener('mousemove', mouseMoveHandler)
|
|
718
|
+
}, mouseUpHandler = function(e, setResize = true) {
|
|
719
|
+
if (!!th) {
|
|
720
|
+
resizingInner = false;
|
|
721
|
+
let { paddingLeft, paddingRight } = getComputedStyle(th);
|
|
722
|
+
width = th.getBoundingClientRect().width - parseFloat(paddingLeft) - parseFloat(paddingRight);
|
|
723
|
+
if (setResize) {
|
|
724
|
+
setTimeout(() => resizing = false, 20);
|
|
1126
725
|
}
|
|
726
|
+
dispatch("columnResize", {
|
|
727
|
+
id: th.id,
|
|
728
|
+
newWidthPx: width
|
|
729
|
+
});
|
|
1127
730
|
}
|
|
1128
|
-
}
|
|
731
|
+
}, mouseDownHandler = function(e) {
|
|
732
|
+
if (!!th) {
|
|
733
|
+
resizing = true;
|
|
734
|
+
resizingInner = true;
|
|
735
|
+
let { paddingLeft, paddingRight } = getComputedStyle(th);
|
|
736
|
+
width = th.getBoundingClientRect().width - parseFloat(paddingLeft) - parseFloat(paddingRight);
|
|
737
|
+
}
|
|
738
|
+
};
|
|
739
|
+
let { width } = th.getBoundingClientRect();
|
|
740
|
+
node.addEventListener("mousedown", mouseDownHandler);
|
|
741
|
+
document.addEventListener("mouseup", mouseUpHandler);
|
|
742
|
+
document.addEventListener("mousemove", mouseMoveHandler);
|
|
743
|
+
return {
|
|
744
|
+
destroy() {
|
|
745
|
+
node.removeEventListener("mousedown", mouseDownHandler);
|
|
746
|
+
document.removeEventListener("mouseup", mouseUpHandler);
|
|
747
|
+
document.removeEventListener("mousemove", mouseMoveHandler);
|
|
748
|
+
}
|
|
749
|
+
};
|
|
1129
750
|
}
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
headersToShowInTable.length > 0 &&
|
|
1134
|
-
resizedColumnSizeWithPadding &&
|
|
1135
|
-
headersToShow.length > 0 &&
|
|
1136
|
-
mainHeader
|
|
1137
|
-
) {
|
|
751
|
+
}
|
|
752
|
+
$:
|
|
753
|
+
if (!!tableContainer && headersToShowInTable.length > 0 && resizedColumnSizeWithPadding && headersToShow.length > 0 && mainHeader) {
|
|
1138
754
|
tick().then(updateRemainingWidth);
|
|
1139
755
|
}
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
const extraStaticWidth = Array.from(mainHeader.querySelectorAll('th.non-resizable, th.customize-headers'))
|
|
1156
|
-
.reduce((sum, th) => sum + th.getBoundingClientRect().width + 1, 0);
|
|
1157
|
-
|
|
1158
|
-
remainingWidth = Math.max(0, containerWidth - totalResizableWidth - extraStaticWidth);
|
|
1159
|
-
}
|
|
756
|
+
async function updateRemainingWidth() {
|
|
757
|
+
if (tableContainer != null && !!tableContainer) {
|
|
758
|
+
const containerWidth = tableContainer?.getBoundingClientRect().width - 30;
|
|
759
|
+
if (containerWidth) {
|
|
760
|
+
const totalResizableWidth = headersToShowInTable.reduce((sum, head) => {
|
|
761
|
+
let th = headersHTML[head.value];
|
|
762
|
+
if (!!th) {
|
|
763
|
+
resizeHeader(th, head);
|
|
764
|
+
}
|
|
765
|
+
const width = th?.getBoundingClientRect().width || 0;
|
|
766
|
+
return sum + width + 1;
|
|
767
|
+
}, 0);
|
|
768
|
+
const extraStaticWidth = Array.from(mainHeader.querySelectorAll("th.non-resizable, th.customize-headers")).reduce((sum, th) => sum + th.getBoundingClientRect().width + 1, 0);
|
|
769
|
+
remainingWidth = Math.max(0, containerWidth - totalResizableWidth - extraStaticWidth);
|
|
1160
770
|
}
|
|
1161
771
|
}
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
let maxWidth = header.maxWidth,
|
|
1177
|
-
maxWidthPx = DEFAULT_MAX_WIDTH_PX
|
|
1178
|
-
if (!!maxWidth && maxWidth.endsWith('px')) {
|
|
1179
|
-
maxWidthPx = parseInt(maxWidth, 10);
|
|
1180
|
-
}
|
|
1181
|
-
if(widthWihtPadding > maxWidthPx) {
|
|
1182
|
-
widthWihtPadding = maxWidthPx
|
|
1183
|
-
}
|
|
1184
|
-
|
|
1185
|
-
resizedColumnSizeWithPadding[header.value] = widthWihtPadding;
|
|
772
|
+
}
|
|
773
|
+
function resizeHeader(th, header) {
|
|
774
|
+
if (!resizedColumnSizeWithPadding[header.value]) {
|
|
775
|
+
let widthWihtPadding = th.getBoundingClientRect().width;
|
|
776
|
+
let minWidth = header.minWidth, minWidthPx = DEFAULT_MIN_WIDTH_PX;
|
|
777
|
+
if (!!minWidth && minWidth.endsWith("px")) {
|
|
778
|
+
minWidthPx = parseInt(minWidth, 10);
|
|
779
|
+
}
|
|
780
|
+
if (widthWihtPadding < minWidthPx) {
|
|
781
|
+
widthWihtPadding = minWidthPx;
|
|
782
|
+
}
|
|
783
|
+
let maxWidth = header.maxWidth, maxWidthPx = DEFAULT_MAX_WIDTH_PX;
|
|
784
|
+
if (!!maxWidth && maxWidth.endsWith("px")) {
|
|
785
|
+
maxWidthPx = parseInt(maxWidth, 10);
|
|
1186
786
|
}
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
787
|
+
if (widthWihtPadding > maxWidthPx) {
|
|
788
|
+
widthWihtPadding = maxWidthPx;
|
|
789
|
+
}
|
|
790
|
+
resizedColumnSizeWithPadding[header.value] = widthWihtPadding;
|
|
1190
791
|
}
|
|
792
|
+
let { paddingLeft, paddingRight } = getComputedStyle(th);
|
|
793
|
+
let width = resizedColumnSizeWithPadding[header.value] - parseFloat(paddingLeft) - parseFloat(paddingRight);
|
|
794
|
+
th.style.width = `${width}px`;
|
|
795
|
+
}
|
|
1191
796
|
</script>
|
|
1192
797
|
|
|
1193
798
|
{#if !!rows && Array.isArray(rows) && !!headersToShowInTable && Array.isArray(headersToShowInTable)}
|