@likable-hair/svelte 4.2.5 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/composed/buttons/ActivableButton.svelte +25 -7
- package/dist/components/composed/common/HeadersDrawer.svelte +66 -28
- package/dist/components/composed/common/HeadersDrawer.svelte.d.ts +22 -12
- package/dist/components/composed/common/MenuOrDrawer.svelte +40 -12
- package/dist/components/composed/common/MenuOrDrawerOptions.svelte +51 -27
- package/dist/components/composed/common/MenuOrDrawerOptions.svelte.d.ts +15 -10
- package/dist/components/composed/common/QuickActions.svelte +59 -23
- package/dist/components/composed/common/ToolTip.svelte +51 -32
- package/dist/components/composed/dashboard/DashboardShaper.svelte +280 -147
- package/dist/components/composed/dashboard/DashboardShaper.svelte.d.ts +54 -45
- package/dist/components/composed/forms/AsyncAutocomplete.svelte +81 -30
- package/dist/components/composed/forms/AsyncAutocomplete.svelte.d.ts +12 -5
- package/dist/components/composed/forms/AvatarDropdown.svelte +146 -70
- package/dist/components/composed/forms/AvatarDropdown.svelte.d.ts +27 -22
- package/dist/components/composed/forms/ConfirmOrCancelButtons.svelte +65 -19
- package/dist/components/composed/forms/CountriesAutocomplete.svelte +33 -4
- package/dist/components/composed/forms/DatePickerTextField.svelte +266 -161
- package/dist/components/composed/forms/Dropdown.svelte +88 -21
- package/dist/components/composed/forms/Dropdown.svelte.d.ts +18 -13
- package/dist/components/composed/forms/IconsDropdown.svelte +85 -40
- package/dist/components/composed/forms/IconsDropdown.svelte.d.ts +15 -8
- package/dist/components/composed/forms/LabelAndSelect.svelte +46 -5
- package/dist/components/composed/forms/LabelAndTextField.svelte +56 -3
- package/dist/components/composed/forms/PeriodPicker.svelte +38 -18
- package/dist/components/composed/forms/PeriodPicker.svelte.d.ts +32 -7
- package/dist/components/composed/forms/PeriodSelector.svelte +427 -312
- package/dist/components/composed/forms/PeriodSelector.svelte.d.ts +20 -13
- package/dist/components/composed/forms/ToggleList.svelte +71 -37
- package/dist/components/composed/forms/ToggleList.svelte.d.ts +14 -7
- package/dist/components/composed/forms/YearPickerTextField.svelte +154 -82
- package/dist/components/composed/list/DynamicTable.svelte +1372 -809
- package/dist/components/composed/list/DynamicTable.svelte.d.ts +85 -70
- package/dist/components/composed/list/EnhancedPaginatedTable.svelte +75 -32
- package/dist/components/composed/list/EnhancedPaginatedTable.svelte.d.ts +16 -6
- package/dist/components/composed/list/PaginatedTable.svelte +324 -116
- package/dist/components/composed/list/PaginatedTable.svelte.d.ts +26 -22
- package/dist/components/composed/progress/HorizontalStackedProgress.svelte +67 -29
- package/dist/components/composed/search/DynamicFilters.svelte +126 -91
- package/dist/components/composed/search/FilterEditor.svelte +169 -109
- package/dist/components/composed/search/Filters.svelte +385 -275
- package/dist/components/composed/search/GlobalSearchTextField.svelte +102 -42
- package/dist/components/composed/search/GlobalSearchTextField.svelte.d.ts +23 -20
- package/dist/components/composed/search/MobileFilterEditor.svelte +174 -120
- package/dist/components/composed/search/QuickFilters.svelte +124 -75
- package/dist/components/composed/search/SearchBar.svelte +42 -3
- package/dist/components/composed/search/SearchResults.svelte +48 -5
- package/dist/components/composed/search/SearchResults.svelte.d.ts +17 -17
- package/dist/components/layouts/CollapsibleSideBarLayout.svelte +100 -24
- package/dist/components/layouts/StableDividedSideBarLayout.svelte +74 -24
- package/dist/components/layouts/UnstableDividedSideBarLayout.svelte +140 -57
- package/dist/components/simple/buttons/Button.svelte +86 -36
- package/dist/components/simple/buttons/LinkButton.svelte +81 -25
- package/dist/components/simple/charts/BarChart.svelte +137 -105
- package/dist/components/simple/charts/LineChart.svelte +124 -92
- package/dist/components/simple/charts/PieChart.svelte +51 -23
- package/dist/components/simple/common/CollapsibleDivider.svelte +58 -26
- package/dist/components/simple/common/Divider.svelte +2 -1
- package/dist/components/simple/common/InfiniteScroll.svelte +60 -34
- package/dist/components/simple/common/MediaQuery.svelte +28 -3
- package/dist/components/simple/common/Menu.svelte +516 -371
- package/dist/components/simple/common/NoData.svelte +18 -4
- package/dist/components/simple/common/VerticalDraggableList.svelte +52 -26
- package/dist/components/simple/common/VerticalDraggableList.svelte.d.ts +20 -9
- package/dist/components/simple/dashboards/DashboardGridShaper.svelte +28 -22
- package/dist/components/simple/dates/Calendar.svelte +142 -72
- package/dist/components/simple/dates/DatePicker.svelte +138 -71
- package/dist/components/simple/dates/MonthSelector.svelte +49 -13
- package/dist/components/simple/dates/YearSelector.svelte +73 -30
- package/dist/components/simple/dialogs/Dialog.svelte +109 -59
- package/dist/components/simple/forms/Autocomplete.svelte +341 -164
- package/dist/components/simple/forms/Autocomplete.svelte.d.ts +27 -20
- package/dist/components/simple/forms/Checkbox.svelte +57 -29
- package/dist/components/simple/forms/FileInput.svelte +103 -58
- package/dist/components/simple/forms/FileInputList.svelte +115 -51
- package/dist/components/simple/forms/RadioButton.svelte +36 -3
- package/dist/components/simple/forms/Select.svelte +30 -3
- package/dist/components/simple/forms/SimpleTextField.svelte +94 -4
- package/dist/components/simple/forms/Switch.svelte +33 -11
- package/dist/components/simple/forms/Textarea.svelte +22 -5
- package/dist/components/simple/forms/VerticalSwitch.svelte +19 -2
- package/dist/components/simple/forms/VerticalTextSwitch.svelte +35 -3
- package/dist/components/simple/lists/BoxList.svelte +42 -11
- package/dist/components/simple/lists/ColorInvertedSelector.svelte +83 -25
- package/dist/components/simple/lists/HierarchyMenu.svelte +55 -20
- package/dist/components/simple/lists/Paginator.svelte +53 -34
- package/dist/components/simple/lists/SelectableMenuList.svelte +52 -16
- package/dist/components/simple/lists/SelectableVerticalList.svelte +169 -85
- package/dist/components/simple/lists/SelectableVerticalList.svelte.d.ts +21 -14
- package/dist/components/simple/lists/SidebarMenuList.svelte +127 -79
- package/dist/components/simple/lists/SimpleTable.svelte +442 -245
- package/dist/components/simple/lists/SimpleTable.svelte.d.ts +31 -22
- package/dist/components/simple/loaders/CircularLoader.css +1 -1
- package/dist/components/simple/loaders/CircularLoader.svelte +11 -3
- package/dist/components/simple/loaders/Skeleton.svelte +3 -2
- package/dist/components/simple/media/Avatar.svelte +35 -15
- package/dist/components/simple/media/DescriptiveAvatar.svelte +30 -4
- package/dist/components/simple/media/FlagIcon.svelte +13 -3
- package/dist/components/simple/media/Icon.svelte +21 -6
- package/dist/components/simple/navigation/Breadcrumb.svelte +41 -9
- package/dist/components/simple/navigation/Chip.svelte +65 -29
- package/dist/components/simple/navigation/Drawer.svelte +132 -71
- package/dist/components/simple/navigation/HeaderMenu.svelte +69 -25
- package/dist/components/simple/navigation/Navigator.svelte +45 -11
- package/dist/components/simple/navigation/TabSwitcher.svelte +60 -19
- package/dist/components/simple/notifiers/AlertBanner.svelte +59 -11
- package/dist/components/simple/progress/ProgressBar.svelte +26 -10
- package/dist/components/simple/timeline/SimpleTimeLine.svelte +52 -5
- package/dist/components/simple/timeline/SimpleTimeLine.svelte.d.ts +16 -9
- package/dist/components/simple/typography/Code.svelte +41 -12
- package/dist/stores/layouts/unstableSidebarOpened.d.ts +1 -1
- package/dist/stores/layouts/unstableSidebarOpened.js +1 -1
- package/dist/stores/theme.js +2 -2
- package/dist/utils/filters/builder.d.ts +2 -2
- package/dist/utils/filters/builder.js +7 -7
- package/dist/utils/filters/modifiers/where.d.ts +1 -1
- package/dist/utils/teleporter.js +4 -4
- package/package.json +39 -33
|
@@ -1,287 +1,484 @@
|
|
|
1
|
-
<script module lang="ts">
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
export type HeaderType = ColumnBoolean |
|
|
3
|
+
ColumnString |
|
|
4
|
+
ColumnNumber |
|
|
5
|
+
ColumnDate |
|
|
6
|
+
ColumnIcon |
|
|
7
|
+
ColumnCheckBox |
|
|
8
|
+
ColumnCustom
|
|
9
|
+
|
|
10
|
+
export type Header<Data = any> = {
|
|
11
|
+
value: string
|
|
12
|
+
label: string
|
|
13
|
+
type: HeaderType
|
|
14
|
+
width?: string
|
|
15
|
+
minWidth?: string
|
|
16
|
+
maxWidth?: string
|
|
17
|
+
sortable?: boolean
|
|
18
|
+
icon?: string
|
|
19
|
+
pinned?: boolean
|
|
20
|
+
locked?: boolean
|
|
21
|
+
sortModify?: (params: { builder: FilterBuilder, sortDirection: 'asc' | 'desc' }) => FilterBuilder
|
|
22
|
+
data?: Data
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type CalculateRowStyles<T> = (item: T) => {
|
|
26
|
+
backgroundColor?: string;
|
|
27
|
+
color?: string;
|
|
28
|
+
fontWeight?: string;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type CalculateRowClasses<T> = (item: T) => string | undefined;
|
|
2
32
|
</script>
|
|
3
33
|
|
|
4
|
-
<script lang="ts" generics="Item extends {[key: string]: any}, Data">
|
|
5
|
-
import '
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
34
|
+
<script lang="ts" generics="Item extends {[key: string]: any}, Data">
|
|
35
|
+
import '../../../css/main.css'
|
|
36
|
+
import './SimpleTable.css'
|
|
37
|
+
import Icon from '../media/Icon.svelte';
|
|
38
|
+
import { onMount, tick, type Snippet } from 'svelte';
|
|
39
|
+
import type { DateTime } from 'luxon';
|
|
40
|
+
import type { ColumnBoolean, ColumnCheckBox, ColumnCustom, ColumnDate, ColumnIcon, ColumnNumber, ColumnString } from './columnTypes';
|
|
41
|
+
import NoData from '../common/NoData.svelte';
|
|
42
|
+
import type { FilterBuilder } from '../../..';
|
|
43
|
+
|
|
44
|
+
type TableHeader = Header<Data>
|
|
45
|
+
|
|
46
|
+
interface Props {
|
|
47
|
+
headers: TableHeader[];
|
|
48
|
+
items: Item[];
|
|
49
|
+
sortedBy?: string;
|
|
50
|
+
sortDirection?: "asc" | "desc";
|
|
51
|
+
resizableColumns?: boolean;
|
|
52
|
+
resizedColumnSizeWithPadding?: { [value: string]: number };
|
|
53
|
+
pointerOnRowHover?: boolean;
|
|
54
|
+
lang?: 'it' | 'en'
|
|
55
|
+
noItemsText?: string
|
|
56
|
+
loading?: boolean
|
|
57
|
+
doubleClickActive?: boolean,
|
|
58
|
+
doubleClickDelay?: number;
|
|
59
|
+
calculateRowStyles?: CalculateRowStyles<Item> | undefined
|
|
60
|
+
calculateRowClasses?: CalculateRowClasses<Item> | undefined
|
|
61
|
+
stickyMinContainerWidth?: number;
|
|
62
|
+
onsort?: (event: {
|
|
63
|
+
detail: {
|
|
64
|
+
sortedBy: string | undefined,
|
|
65
|
+
sortDirection: string,
|
|
66
|
+
sortModify: Header['sortModify']
|
|
67
|
+
}
|
|
68
|
+
}) => void
|
|
69
|
+
onrowClick?: (event: {
|
|
70
|
+
detail: {
|
|
71
|
+
item: Item
|
|
72
|
+
}
|
|
73
|
+
}) => void
|
|
74
|
+
onrowDoubleClick?: (event: {
|
|
75
|
+
detail: {
|
|
76
|
+
item: Item
|
|
77
|
+
}
|
|
78
|
+
}) => void
|
|
79
|
+
oncolumnResize?: (event: {
|
|
80
|
+
detail: {
|
|
81
|
+
id: string,
|
|
82
|
+
newWidthPx: number
|
|
83
|
+
}
|
|
84
|
+
}) => void
|
|
85
|
+
headerSnippet?: Snippet<[{
|
|
86
|
+
head: TableHeader
|
|
87
|
+
}]>
|
|
88
|
+
headerLabelSnippet?: Snippet<[{
|
|
89
|
+
head: TableHeader
|
|
90
|
+
}]>
|
|
91
|
+
appendSnippet?: Snippet<[{
|
|
92
|
+
index: number
|
|
93
|
+
item?: Item
|
|
94
|
+
}]>
|
|
95
|
+
prependSnippet?: Snippet<[{
|
|
96
|
+
index: number
|
|
97
|
+
item?: Item
|
|
98
|
+
}]>
|
|
99
|
+
stickyAppendSnippet?: Snippet<[]>
|
|
100
|
+
customSnippet?: Snippet<[{
|
|
101
|
+
index: number
|
|
102
|
+
columnIndex: number
|
|
103
|
+
header: TableHeader
|
|
104
|
+
item: Item
|
|
105
|
+
}]>
|
|
106
|
+
noDataSnippet?: Snippet<[]>
|
|
107
|
+
class?:{
|
|
108
|
+
container?: string;
|
|
109
|
+
header?: string;
|
|
110
|
+
row?: string;
|
|
111
|
+
cell?: string;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
let {
|
|
116
|
+
headers = [],
|
|
117
|
+
items = [],
|
|
118
|
+
sortedBy = $bindable(undefined),
|
|
119
|
+
sortDirection = $bindable("asc"),
|
|
120
|
+
resizableColumns = false,
|
|
121
|
+
resizedColumnSizeWithPadding = $bindable({}),
|
|
122
|
+
pointerOnRowHover = false,
|
|
123
|
+
lang = 'en',
|
|
124
|
+
doubleClickActive = false,
|
|
125
|
+
doubleClickDelay = 250,
|
|
126
|
+
noItemsText,
|
|
127
|
+
loading,
|
|
128
|
+
calculateRowStyles = undefined,
|
|
129
|
+
calculateRowClasses = undefined,
|
|
130
|
+
stickyMinContainerWidth = 1024,
|
|
131
|
+
oncolumnResize,
|
|
132
|
+
onrowClick,
|
|
133
|
+
onrowDoubleClick,
|
|
134
|
+
onsort,
|
|
135
|
+
headerSnippet,
|
|
136
|
+
headerLabelSnippet,
|
|
137
|
+
appendSnippet,
|
|
138
|
+
prependSnippet,
|
|
139
|
+
stickyAppendSnippet,
|
|
140
|
+
customSnippet,
|
|
141
|
+
noDataSnippet,
|
|
142
|
+
class: clazz = {},
|
|
143
|
+
}: Props = $props();
|
|
144
|
+
|
|
145
|
+
if(!onrowClick && !!onrowDoubleClick) {
|
|
146
|
+
throw new Error('cannot define an onrowDoubleClick event without defining an onrowClick event')
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
let clickTimeout: NodeJS.Timeout | undefined = undefined,
|
|
150
|
+
sortModify: Header['sortModify'],
|
|
151
|
+
tableContainer: HTMLElement | undefined = $state(),
|
|
152
|
+
mainHeader: HTMLElement | undefined = $state(),
|
|
153
|
+
remainingWidth: number = $state(0),
|
|
154
|
+
containerWidth: number = $state(0),
|
|
155
|
+
totalStickyWidth: number = $state(0),
|
|
156
|
+
resizeObserver: ResizeObserver,
|
|
157
|
+
headersHTML: { [value: string]: HTMLElement } = $state({}),
|
|
158
|
+
tableHTML: HTMLElement | undefined = $state(),
|
|
159
|
+
resizing = false,
|
|
160
|
+
colspan = $derived.by(() => {
|
|
161
|
+
return headers.length +
|
|
162
|
+
(appendSnippet || stickyAppendSnippet ? 1 : 0) +
|
|
16
163
|
(prependSnippet ? 1 : 0) +
|
|
17
164
|
(remainingWidth ? 1 : 0);
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (totalStickyWidth >= containerWidth)
|
|
23
|
-
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
let stickyEnabled = $derived.by(() => {
|
|
168
|
+
if (containerWidth <= stickyMinContainerWidth) return false;
|
|
169
|
+
if (totalStickyWidth >= containerWidth) return false;
|
|
170
|
+
|
|
24
171
|
return true;
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
const DEFAULT_MIN_WIDTH_PX = 60,
|
|
175
|
+
DEFAULT_MAX_WIDTH_PX = 400
|
|
176
|
+
|
|
177
|
+
onMount(() => {
|
|
28
178
|
(async () => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const rect = tableContainer.getBoundingClientRect();
|
|
33
|
-
containerWidth = rect.width;
|
|
34
|
-
}
|
|
35
|
-
calculateStickyMetrics();
|
|
36
|
-
updateRemainingWidth();
|
|
37
|
-
});
|
|
179
|
+
await tick()
|
|
180
|
+
|
|
181
|
+
resizeObserver = new ResizeObserver(() => {
|
|
38
182
|
if (tableContainer) {
|
|
39
|
-
|
|
183
|
+
const rect = tableContainer.getBoundingClientRect();
|
|
184
|
+
containerWidth = rect.width;
|
|
40
185
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
186
|
+
|
|
187
|
+
calculateStickyMetrics();
|
|
188
|
+
updateRemainingWidth();
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
if(tableContainer){
|
|
192
|
+
resizeObserver.observe(tableContainer);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
resizeRowAppendHeader()
|
|
196
|
+
|
|
197
|
+
for(const head of headers) {
|
|
198
|
+
let th = headersHTML[head.value]
|
|
199
|
+
if(!!th) {
|
|
200
|
+
resizeHeader(th, head)
|
|
47
201
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
return () => {
|
|
206
|
+
resizeObserver?.disconnect();
|
|
207
|
+
};
|
|
208
|
+
})()
|
|
209
|
+
})
|
|
210
|
+
|
|
211
|
+
function calculateStickyMetrics() {
|
|
54
212
|
let width = 0;
|
|
213
|
+
|
|
55
214
|
if (prependSnippet && headersHTML['prepend']) {
|
|
56
|
-
|
|
215
|
+
width += headersHTML['prepend'].getBoundingClientRect().width;
|
|
57
216
|
}
|
|
217
|
+
|
|
58
218
|
headers.forEach(head => {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
width += headersHTML[head.value].getBoundingClientRect().width;
|
|
66
|
-
}
|
|
219
|
+
if (head.pinned) {
|
|
220
|
+
const stored = resizedColumnSizeWithPadding[head.value];
|
|
221
|
+
if (stored) {
|
|
222
|
+
width += stored;
|
|
223
|
+
} else if (headersHTML[head.value]) {
|
|
224
|
+
width += headersHTML[head.value].getBoundingClientRect().width;
|
|
67
225
|
}
|
|
226
|
+
}
|
|
68
227
|
});
|
|
228
|
+
|
|
69
229
|
if (stickyAppendSnippet && headersHTML['row-append-header']) {
|
|
70
|
-
|
|
230
|
+
width += headersHTML['row-append-header'].getBoundingClientRect().width;
|
|
71
231
|
}
|
|
232
|
+
|
|
72
233
|
totalStickyWidth = width;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
sortedBy = header.value;
|
|
86
|
-
sortDirection = 'asc';
|
|
87
|
-
sortModify = header.sortModify;
|
|
88
|
-
}
|
|
89
|
-
if (onsort) {
|
|
90
|
-
onsort({
|
|
91
|
-
detail: {
|
|
92
|
-
sortedBy,
|
|
93
|
-
sortDirection,
|
|
94
|
-
sortModify
|
|
95
|
-
}
|
|
96
|
-
});
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function handleHeaderClick(header: TableHeader) {
|
|
237
|
+
if(header.sortable && !resizing) {
|
|
238
|
+
if(!!sortedBy && header.value == sortedBy) {
|
|
239
|
+
if(sortDirection == 'asc') sortDirection = 'desc'
|
|
240
|
+
else if(sortDirection == 'desc') {
|
|
241
|
+
sortedBy = undefined
|
|
242
|
+
sortModify = undefined
|
|
97
243
|
}
|
|
244
|
+
} else {
|
|
245
|
+
sortedBy = header.value
|
|
246
|
+
sortDirection = 'asc'
|
|
247
|
+
sortModify = header.sortModify
|
|
248
|
+
}
|
|
249
|
+
if(onsort) {
|
|
250
|
+
onsort({
|
|
251
|
+
detail: {
|
|
252
|
+
sortedBy,
|
|
253
|
+
sortDirection,
|
|
254
|
+
sortModify
|
|
255
|
+
}
|
|
256
|
+
})
|
|
257
|
+
}
|
|
98
258
|
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function handleRowClick(item: Item) {
|
|
262
|
+
if(doubleClickActive) {
|
|
263
|
+
if (clickTimeout) {
|
|
264
|
+
clearTimeout(clickTimeout);
|
|
265
|
+
clickTimeout = undefined;
|
|
266
|
+
|
|
267
|
+
if(onrowDoubleClick) {
|
|
268
|
+
onrowDoubleClick({
|
|
269
|
+
detail: {
|
|
270
|
+
item
|
|
111
271
|
}
|
|
272
|
+
})
|
|
112
273
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
onrowClick({
|
|
117
|
-
detail: {
|
|
118
|
-
item
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
clickTimeout = undefined;
|
|
123
|
-
}, doubleClickDelay);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
if (onrowClick) {
|
|
274
|
+
} else {
|
|
275
|
+
clickTimeout = setTimeout(() => {
|
|
276
|
+
if(onrowClick) {
|
|
128
277
|
onrowClick({
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
})
|
|
133
|
-
|
|
278
|
+
detail: {
|
|
279
|
+
item
|
|
280
|
+
}
|
|
281
|
+
})
|
|
282
|
+
}
|
|
283
|
+
clickTimeout = undefined;
|
|
284
|
+
}, doubleClickDelay);
|
|
285
|
+
}
|
|
286
|
+
} else {
|
|
287
|
+
if(onrowClick) {
|
|
288
|
+
onrowClick({
|
|
289
|
+
detail: {
|
|
290
|
+
item
|
|
291
|
+
}
|
|
292
|
+
})
|
|
293
|
+
}
|
|
134
294
|
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function formatDate(dateTime: DateTime, dateFormat: ColumnDate['params']): string {
|
|
298
|
+
return dateTime.setLocale(dateFormat.locale).toFormat(dateFormat.format)
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
function resize(node: HTMLElement) {
|
|
303
|
+
let th: HTMLElement | null = node.parentElement
|
|
304
|
+
let resizingInner = false
|
|
305
|
+
|
|
306
|
+
if(!!th) {
|
|
307
|
+
let { width } = th.getBoundingClientRect()
|
|
308
|
+
|
|
309
|
+
function mouseMoveHandler(e: MouseEvent) {
|
|
310
|
+
if (resizingInner && !!th && !!tableContainer) {
|
|
311
|
+
width += e.movementX;
|
|
312
|
+
const { paddingLeft, paddingRight } = getComputedStyle(th);
|
|
313
|
+
|
|
314
|
+
const minWidth: string | undefined = headers.find(h => h.value === th.id)?.minWidth;
|
|
315
|
+
let minWidthPx: number | undefined;
|
|
316
|
+
if (!!minWidth && minWidth.endsWith('px')) {
|
|
317
|
+
minWidthPx = parseInt(minWidth, 10);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
const maxWidth: string | undefined = headers.find(h => h.value === th.id)?.maxWidth;
|
|
321
|
+
let maxWidthPx: number | undefined;
|
|
322
|
+
if (!!maxWidth && maxWidth.endsWith('px')) {
|
|
323
|
+
maxWidthPx = parseInt(maxWidth, 10);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
const actualMinWidth = (minWidthPx || DEFAULT_MIN_WIDTH_PX) - parseFloat(paddingLeft) - parseFloat(paddingRight);
|
|
327
|
+
const actualMaxWidth = (maxWidthPx || DEFAULT_MAX_WIDTH_PX) - parseFloat(paddingLeft) - parseFloat(paddingRight);
|
|
328
|
+
|
|
329
|
+
if (width > actualMinWidth && width < actualMaxWidth) {
|
|
330
|
+
th.style.width = width + 'px';
|
|
331
|
+
resizedColumnSizeWithPadding[th.id] = th.getBoundingClientRect().width;
|
|
332
|
+
resizedColumnSizeWithPadding = {
|
|
333
|
+
...resizedColumnSizeWithPadding,
|
|
168
334
|
}
|
|
335
|
+
calculateStickyMetrics();
|
|
336
|
+
}
|
|
169
337
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
function mouseUpHandler(e: MouseEvent, setResize: boolean = true) {
|
|
342
|
+
if(!!th) {
|
|
343
|
+
resizingInner = false
|
|
344
|
+
let { paddingLeft, paddingRight } = getComputedStyle(th)
|
|
345
|
+
width = th.getBoundingClientRect().width - parseFloat(paddingLeft) - parseFloat(paddingRight)
|
|
346
|
+
if(setResize){
|
|
347
|
+
setTimeout(() => resizing = false, 20)
|
|
348
|
+
}
|
|
349
|
+
if(oncolumnResize){
|
|
350
|
+
oncolumnResize({
|
|
351
|
+
detail: {
|
|
352
|
+
id: th.id,
|
|
353
|
+
newWidthPx: width
|
|
354
|
+
}
|
|
355
|
+
})
|
|
356
|
+
}
|
|
357
|
+
calculateStickyMetrics();
|
|
188
358
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
function mouseDownHandler(e: MouseEvent) {
|
|
362
|
+
if(!!th) {
|
|
363
|
+
resizing = true
|
|
364
|
+
resizingInner = true
|
|
365
|
+
let { paddingLeft, paddingRight } = getComputedStyle(th)
|
|
366
|
+
width = th.getBoundingClientRect().width - parseFloat(paddingLeft) - parseFloat(paddingRight)
|
|
196
367
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
node.addEventListener('mousedown', mouseDownHandler)
|
|
371
|
+
document.addEventListener('mouseup', mouseUpHandler)
|
|
372
|
+
document.addEventListener('mousemove', mouseMoveHandler)
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
return {
|
|
376
|
+
destroy() {
|
|
377
|
+
node.removeEventListener('mousedown', mouseDownHandler)
|
|
378
|
+
document.removeEventListener('mouseup', mouseUpHandler)
|
|
379
|
+
document.removeEventListener('mousemove', mouseMoveHandler)
|
|
380
|
+
}
|
|
381
|
+
}
|
|
207
382
|
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
$effect(() => {
|
|
386
|
+
headers;
|
|
211
387
|
resizedColumnSizeWithPadding;
|
|
388
|
+
|
|
212
389
|
tick().then(() => {
|
|
213
|
-
|
|
214
|
-
|
|
390
|
+
calculateStickyMetrics();
|
|
391
|
+
updateRemainingWidth();
|
|
215
392
|
});
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
async function updateRemainingWidth() {
|
|
396
|
+
if(tableContainer != null && !!tableContainer && mainHeader) {
|
|
397
|
+
const containerWidth = tableContainer?.getBoundingClientRect().width;
|
|
398
|
+
const scrollbarWidth = tableContainer.offsetWidth - tableContainer.clientWidth
|
|
399
|
+
|
|
400
|
+
if(containerWidth){
|
|
401
|
+
const totalResizableWidth = headers.reduce((sum, head) => {
|
|
402
|
+
let th = headersHTML[head.value]
|
|
403
|
+
if(!!th) {
|
|
404
|
+
resizeHeader(th, head)
|
|
405
|
+
}
|
|
406
|
+
const width = th?.getBoundingClientRect().width || 0
|
|
407
|
+
return sum + width;
|
|
408
|
+
}, 0);
|
|
409
|
+
|
|
410
|
+
resizeRowAppendHeader()
|
|
411
|
+
|
|
412
|
+
const extraStaticWidth = Array.from(mainHeader.querySelectorAll('th.non-resizable, th.row-append-header'))
|
|
413
|
+
.reduce((sum, th) => sum + th.getBoundingClientRect().width, 0);
|
|
414
|
+
|
|
415
|
+
remainingWidth = Math.max(0, containerWidth - scrollbarWidth - totalResizableWidth - extraStaticWidth);
|
|
416
|
+
}
|
|
235
417
|
}
|
|
236
|
-
}
|
|
237
|
-
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
function resizeRowAppendHeader() {
|
|
238
421
|
if ((appendSnippet || stickyAppendSnippet) && headersHTML['row-append-header']) {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
422
|
+
if(!!headersHTML['row-append-header'].style.width && headersHTML['row-append-header'].style.width != "0px") {
|
|
423
|
+
return
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
if (tableHTML) {
|
|
427
|
+
tableHTML.style.tableLayout = 'auto'
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
let widthWithPadding = headersHTML['row-append-header'].scrollWidth
|
|
431
|
+
|
|
432
|
+
if (tableHTML) {
|
|
433
|
+
tableHTML.style.tableLayout = 'fixed'
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
headersHTML['row-append-header'].style.width = `${widthWithPadding}px`;
|
|
437
|
+
headersHTML['row-append-header'].style.minWidth = `${widthWithPadding}px`;
|
|
251
438
|
}
|
|
252
|
-
}
|
|
253
|
-
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
function resizeHeader(th: HTMLElement, header: { value: string, minWidth?: string, maxWidth?: string }){
|
|
254
442
|
if (!resizedColumnSizeWithPadding[header.value]) {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
443
|
+
if (tableHTML) {
|
|
444
|
+
tableHTML.style.tableLayout = 'auto'
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
let widthWithPadding = th.scrollWidth
|
|
448
|
+
|
|
449
|
+
if (widthWithPadding == 0) {
|
|
450
|
+
return
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
if (tableHTML) {
|
|
454
|
+
tableHTML.style.tableLayout = 'fixed'
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
let minWidth = header.minWidth,
|
|
458
|
+
minWidthPx = DEFAULT_MIN_WIDTH_PX
|
|
459
|
+
if (!!minWidth && minWidth.endsWith('px')) {
|
|
460
|
+
minWidthPx = parseInt(minWidth, 10);
|
|
461
|
+
}
|
|
462
|
+
if(widthWithPadding < minWidthPx) {
|
|
463
|
+
widthWithPadding = minWidthPx
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
let maxWidth = header.maxWidth,
|
|
467
|
+
maxWidthPx = DEFAULT_MAX_WIDTH_PX
|
|
468
|
+
if (!!maxWidth && maxWidth.endsWith('px')) {
|
|
469
|
+
maxWidthPx = parseInt(maxWidth, 10);
|
|
470
|
+
}
|
|
471
|
+
if(widthWithPadding > maxWidthPx) {
|
|
472
|
+
widthWithPadding = maxWidthPx
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
resizedColumnSizeWithPadding[header.value] = widthWithPadding;
|
|
280
476
|
}
|
|
281
477
|
let { paddingLeft, paddingRight } = getComputedStyle(th);
|
|
282
478
|
let width = resizedColumnSizeWithPadding[header.value] - parseFloat(paddingLeft) - parseFloat(paddingRight);
|
|
283
|
-
th.style.width = `${width}px
|
|
284
|
-
}
|
|
479
|
+
th.style.width = `${width}px`
|
|
480
|
+
}
|
|
481
|
+
|
|
285
482
|
</script>
|
|
286
483
|
|
|
287
484
|
{#if !!items && Array.isArray(items)}
|