@neovici/cosmoz-omnitable 13.2.4 → 13.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/cosmoz-omnitable-column-mixin.js +11 -2
- package/cosmoz-omnitable-item-expand-line.js +30 -24
- package/cosmoz-omnitable-item-expand.js +13 -33
- package/cosmoz-omnitable-item-row.js +31 -14
- package/cosmoz-omnitable-styles.js +38 -13
- package/cosmoz-omnitable.js +2 -1
- package/lib/settings/style.css.js +4 -2
- package/lib/use-canvas-width.js +4 -2
- package/lib/use-dom-columns.js +3 -0
- package/lib/use-fast-layout.js +4 -1
- package/lib/use-layout.js +27 -23
- package/lib/use-list.js +49 -29
- package/lib/use-mini.js +28 -0
- package/lib/use-omnitable.js +5 -4
- package/lib/use-resizable-columns.js +2 -2
- package/lib/use-track-size.js +4 -5
- package/package.json +1 -1
|
@@ -64,6 +64,15 @@ export const getString = ({ valuePath }, item) => get(item, valuePath),
|
|
|
64
64
|
renderCell: { type: Function },
|
|
65
65
|
renderEditCell: { type: Function },
|
|
66
66
|
renderGroup: { type: Function },
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The priority of the column in the mini mode. If missing the column is disabled in the mini mode.
|
|
70
|
+
*/
|
|
71
|
+
mini: { type: Number, value: null },
|
|
72
|
+
/**
|
|
73
|
+
* An alternative render to use in mini mode. Takes the same params as `renderCell`.
|
|
74
|
+
*/
|
|
75
|
+
renderMini: { type: Function },
|
|
67
76
|
};
|
|
68
77
|
}
|
|
69
78
|
|
|
@@ -82,7 +91,7 @@ export const getString = ({ valuePath }, item) => get(item, valuePath),
|
|
|
82
91
|
state: this.legacyFilterToState(filter),
|
|
83
92
|
},
|
|
84
93
|
bubbles: true,
|
|
85
|
-
})
|
|
94
|
+
}),
|
|
86
95
|
);
|
|
87
96
|
}
|
|
88
97
|
|
|
@@ -135,7 +144,7 @@ export const getString = ({ valuePath }, item) => get(item, valuePath),
|
|
|
135
144
|
_propertiesChanged(currentProps, changedProps, oldProps) {
|
|
136
145
|
super._propertiesChanged(currentProps, changedProps, oldProps);
|
|
137
146
|
this.dispatchEvent(
|
|
138
|
-
new CustomEvent('cosmoz-column-prop-changed', { bubbles: true })
|
|
147
|
+
new CustomEvent('cosmoz-column-prop-changed', { bubbles: true }),
|
|
139
148
|
);
|
|
140
149
|
}
|
|
141
150
|
};
|
|
@@ -1,33 +1,39 @@
|
|
|
1
1
|
import { component, html } from '@pionjs/pion';
|
|
2
|
+
import { css, sheet } from '@neovici/cosmoz-utils';
|
|
2
3
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
4
|
+
const style = css`
|
|
5
|
+
:host {
|
|
6
|
+
display: flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
flex-wrap: wrap;
|
|
9
|
+
}
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
.label {
|
|
12
|
+
overflow: hidden;
|
|
13
|
+
text-overflow: ellipsis;
|
|
14
|
+
white-space: nowrap;
|
|
15
|
+
flex: initial;
|
|
16
|
+
align-self: start;
|
|
17
|
+
}
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
.value {
|
|
20
|
+
text-align: right;
|
|
21
|
+
flex-grow: 1;
|
|
22
|
+
flex-basis: 100px;
|
|
23
|
+
white-space: nowrap;
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
<div class="
|
|
28
|
-
|
|
27
|
+
const ItemExpandLine = ({ column }) => html`
|
|
28
|
+
<div class="label" title="${column.title}" part="item-expand-label">
|
|
29
|
+
${column.title}
|
|
30
|
+
</div>
|
|
31
|
+
<div class="value" part="item-expand-value">
|
|
29
32
|
<slot></slot>
|
|
30
33
|
</div>
|
|
31
34
|
`;
|
|
32
35
|
|
|
33
|
-
customElements.define(
|
|
36
|
+
customElements.define(
|
|
37
|
+
'cosmoz-omnitable-item-expand-line',
|
|
38
|
+
component(ItemExpandLine, {styleSheets: [sheet(style)]}),
|
|
39
|
+
);
|
|
@@ -1,48 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { component } from '@pionjs/pion';
|
|
2
|
+
import { html } from 'lit-html';
|
|
3
|
+
import { map } from 'lit-html/directives/map.js';
|
|
4
4
|
import './cosmoz-omnitable-item-expand-line';
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const ItemExpand = ({ columns, item, selected, expanded, groupOnColumn }) => {
|
|
7
|
+
return map(
|
|
7
8
|
columns,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
expanded,
|
|
11
|
-
groupOnColumn,
|
|
12
|
-
}) =>
|
|
13
|
-
columns.map(
|
|
14
|
-
(column) => html`<cosmoz-omnitable-item-expand-line
|
|
9
|
+
(column) =>
|
|
10
|
+
html`<cosmoz-omnitable-item-expand-line
|
|
15
11
|
.column=${column}
|
|
16
12
|
?hidden=${column === groupOnColumn}
|
|
17
|
-
exportparts="item-expand-label,item-expand-value"
|
|
13
|
+
exportparts="item-expand-label, item-expand-value"
|
|
18
14
|
>${column.renderCell(column, {
|
|
19
15
|
item,
|
|
20
16
|
selected,
|
|
21
17
|
expanded,
|
|
22
18
|
})}</cosmoz-omnitable-item-expand-line
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const { columns } = host;
|
|
27
|
-
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
if (columns?.length > 0) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
host.setAttribute('hidden', '');
|
|
34
|
-
return () => host.removeAttribute('hidden');
|
|
35
|
-
}, [columns?.length]);
|
|
36
|
-
|
|
37
|
-
return Array.isArray(columns) && columns.length > 0 && host.expanded
|
|
38
|
-
? renderExpandList(host)
|
|
39
|
-
: nothing;
|
|
40
|
-
};
|
|
19
|
+
>`,
|
|
20
|
+
);
|
|
21
|
+
};
|
|
41
22
|
|
|
42
23
|
customElements.define(
|
|
43
24
|
'cosmoz-omnitable-item-expand',
|
|
44
|
-
component(
|
|
25
|
+
component(ItemExpand, {
|
|
45
26
|
useShadowDOM: false,
|
|
46
|
-
|
|
47
|
-
})
|
|
27
|
+
}),
|
|
48
28
|
);
|
|
@@ -1,20 +1,37 @@
|
|
|
1
1
|
import { component, html } from '@pionjs/pion';
|
|
2
2
|
import { repeat } from 'lit-html/directives/repeat.js';
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
|
|
4
|
+
const renderCell = (column, data, onItemChange) =>
|
|
5
|
+
column.editable
|
|
6
6
|
? column.renderEditCell(column, data, onItemChange(column, data.item))
|
|
7
|
-
: column.renderCell(column, data)
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
: column.renderCell(column, data);
|
|
8
|
+
|
|
9
|
+
const ItemRow = ({
|
|
10
|
+
columns,
|
|
11
|
+
groupOnColumn,
|
|
12
|
+
item,
|
|
13
|
+
index,
|
|
14
|
+
selected,
|
|
15
|
+
expanded,
|
|
16
|
+
onItemChange,
|
|
17
|
+
}) =>
|
|
18
|
+
repeat(
|
|
19
|
+
columns,
|
|
20
|
+
(column) => column.name,
|
|
21
|
+
(column) => {
|
|
10
22
|
return html`<div
|
|
11
|
-
class="cell itemRow-cell ${
|
|
12
|
-
?hidden
|
|
13
|
-
?editable
|
|
14
|
-
title
|
|
15
|
-
name
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
23
|
+
class="cell itemRow-cell ${column.cellClass ?? ''}"
|
|
24
|
+
?hidden="${column === groupOnColumn}"
|
|
25
|
+
?editable="${column.editable}"
|
|
26
|
+
title="${column.cellTitleFn(column, item)}"
|
|
27
|
+
name="${column.name}"
|
|
28
|
+
>
|
|
29
|
+
${renderCell(column, { item, index, selected, expanded }, onItemChange)}
|
|
30
|
+
</div>`;
|
|
31
|
+
},
|
|
32
|
+
);
|
|
19
33
|
|
|
20
|
-
customElements.define(
|
|
34
|
+
customElements.define(
|
|
35
|
+
'cosmoz-omnitable-item-row',
|
|
36
|
+
component(ItemRow, { useShadowDOM: false }),
|
|
37
|
+
);
|
|
@@ -159,8 +159,10 @@ export default css`
|
|
|
159
159
|
--cosmoz-omnitable-header-font-size,
|
|
160
160
|
16px
|
|
161
161
|
);
|
|
162
|
+
--cosmoz-input-padding: 0;
|
|
162
163
|
--cosmoz-input-label-text-transform: var(--cosmoz-omnitable-header-text-transform, none);
|
|
163
164
|
--cosmoz-input-label-font-weight: var(--cosmoz-omnitable-header-font-weight, normal);
|
|
165
|
+
--cosmoz-input-padding: 0;
|
|
164
166
|
}
|
|
165
167
|
|
|
166
168
|
cosmoz-omnitable-header-row {
|
|
@@ -316,11 +318,6 @@ export default css`
|
|
|
316
318
|
left: 0;
|
|
317
319
|
}
|
|
318
320
|
|
|
319
|
-
.item-row-wrapper {
|
|
320
|
-
display: block;
|
|
321
|
-
width: 100%;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
321
|
.itemRow {
|
|
325
322
|
border-bottom-color: var(--cosmoz-omnitable-border-color, #e1e2e5);
|
|
326
323
|
border-bottom-width: 1px;
|
|
@@ -329,10 +326,12 @@ export default css`
|
|
|
329
326
|
solid
|
|
330
327
|
);
|
|
331
328
|
/* set a min-height for rows so that rows with empty values are visible */
|
|
332
|
-
|
|
333
|
-
|
|
329
|
+
}
|
|
330
|
+
.itemRow-wrapper {
|
|
334
331
|
display: flex;
|
|
335
332
|
align-items: center;
|
|
333
|
+
min-height: var(--item-row-min-height, 39px);
|
|
334
|
+
padding-right: 8px;
|
|
336
335
|
}
|
|
337
336
|
|
|
338
337
|
.itemRow[selected] {
|
|
@@ -356,9 +355,8 @@ export default css`
|
|
|
356
355
|
background-color: #fafafa;
|
|
357
356
|
}
|
|
358
357
|
|
|
359
|
-
cosmoz-omnitable-item-expand[hidden],
|
|
360
358
|
cosmoz-omnitable-item-expand:not([expanded]) {
|
|
361
|
-
display: none
|
|
359
|
+
display: none;
|
|
362
360
|
}
|
|
363
361
|
|
|
364
362
|
.groupRow {
|
|
@@ -446,7 +444,7 @@ export default css`
|
|
|
446
444
|
.itemRow:hover {
|
|
447
445
|
box-shadow: inset 1px 0 0 #dadce0, inset -1px 0 0 #dadce0,
|
|
448
446
|
0 1px 2px 0 rgb(60 64 67 / 30%), 0 1px 3px 1px rgb(60 64 67 / 15%);
|
|
449
|
-
background: var(--cosmoz-omnitable-hover-color);
|
|
447
|
+
/* background: var(--cosmoz-omnitable-hover-color); */
|
|
450
448
|
}
|
|
451
449
|
.groupRow:hover .checkbox:not(:checked):not(:hover),
|
|
452
450
|
.itemRow:hover .checkbox:not(:checked):not(:hover) {
|
|
@@ -475,7 +473,6 @@ export default css`
|
|
|
475
473
|
transition: 0.15s background ease-in;
|
|
476
474
|
outline: none;
|
|
477
475
|
color: rgba(0, 0, 0, 0.16);
|
|
478
|
-
|
|
479
476
|
}
|
|
480
477
|
.expand svg {
|
|
481
478
|
fill: currentColor;
|
|
@@ -484,7 +481,7 @@ export default css`
|
|
|
484
481
|
transform: scaleY(-1);
|
|
485
482
|
}
|
|
486
483
|
.expand:active {
|
|
487
|
-
background: rgba(33,33,33,0.25)
|
|
484
|
+
background: rgba(33, 33, 33, 0.25);
|
|
488
485
|
}
|
|
489
486
|
.expand:hover {
|
|
490
487
|
color: #000;
|
|
@@ -526,8 +523,36 @@ export default css`
|
|
|
526
523
|
display: inline-flex;
|
|
527
524
|
position: relative;
|
|
528
525
|
}
|
|
529
|
-
.header-cell :not(.sg,cosmoz-clear-button) {
|
|
526
|
+
.header-cell :not(.sg, cosmoz-clear-button) {
|
|
530
527
|
min-width: 0;
|
|
531
528
|
flex: auto;
|
|
532
529
|
}
|
|
530
|
+
|
|
531
|
+
:host([mini]) .itemRow .expand,
|
|
532
|
+
:host([mini]) cosmoz-omnitable-item-expand {
|
|
533
|
+
display: none;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
.itemRow-minis {
|
|
537
|
+
display: flex;
|
|
538
|
+
justify-content: space-between;
|
|
539
|
+
margin: 0 8px 8px 8px;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
:host([mini]) .itemRow {
|
|
543
|
+
border-radius: 8px;
|
|
544
|
+
border: 1px solid var(--cosmoz-omnitable-border-color, #e1e2e5);
|
|
545
|
+
margin: 4px 8px;
|
|
546
|
+
}
|
|
547
|
+
:host([mini]) .itemRow:not([selected]) {
|
|
548
|
+
background: var(--cosmoz-omnitable-mini-item-background, #fdfdfd);
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
:host([mini]) .itemRow:hover {
|
|
552
|
+
box-shadow: none;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
:host([mini]) .header {
|
|
556
|
+
margin: 0 8px;
|
|
557
|
+
}
|
|
533
558
|
`;
|
package/cosmoz-omnitable.js
CHANGED
|
@@ -63,6 +63,7 @@ customElements.define(
|
|
|
63
63
|
'no-local-sort',
|
|
64
64
|
'no-local-filter',
|
|
65
65
|
'loading',
|
|
66
|
+
'mini-breakpoint',
|
|
66
67
|
],
|
|
67
68
|
}) {
|
|
68
69
|
connectedCallback() {
|
|
@@ -71,7 +72,7 @@ customElements.define(
|
|
|
71
72
|
notifyProperty(this, 'visibleData', []);
|
|
72
73
|
notifyProperty(this, 'sortedFilteredGroupedItems', []);
|
|
73
74
|
}
|
|
74
|
-
}
|
|
75
|
+
},
|
|
75
76
|
);
|
|
76
77
|
|
|
77
78
|
const tmplt = `
|
|
@@ -12,7 +12,8 @@ export default css`
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
.headline {
|
|
15
|
-
box-shadow:
|
|
15
|
+
box-shadow:
|
|
16
|
+
inset 0px -1px 0px rgba(0, 0, 0, 0.15),
|
|
16
17
|
inset 0px 1px 0px rgba(0, 0, 0, 0.15);
|
|
17
18
|
font-weight: 500;
|
|
18
19
|
font-size: 16px;
|
|
@@ -63,7 +64,8 @@ export default css`
|
|
|
63
64
|
transform: scaleY(-1);
|
|
64
65
|
}
|
|
65
66
|
cosmoz-collapse[opened] + .heading {
|
|
66
|
-
box-shadow:
|
|
67
|
+
box-shadow:
|
|
68
|
+
inset 0px -1px 0px rgba(0, 0, 0, 0.15),
|
|
67
69
|
inset 0px 1px 0px rgba(0, 0, 0, 0.15);
|
|
68
70
|
}
|
|
69
71
|
|
package/lib/use-canvas-width.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { useState } from '@pionjs/pion';
|
|
2
2
|
import { useTrackSize } from './use-track-size';
|
|
3
3
|
|
|
4
|
-
export const useCanvasWidth = host => {
|
|
5
|
-
const [canvasWidth, setCanvasWidth] = useState(
|
|
4
|
+
export const useCanvasWidth = (host) => {
|
|
5
|
+
const [canvasWidth, setCanvasWidth] = useState(
|
|
6
|
+
() => host.getBoundingClientRect().width,
|
|
7
|
+
);
|
|
6
8
|
|
|
7
9
|
useTrackSize(host, setCanvasWidth);
|
|
8
10
|
|
package/lib/use-dom-columns.js
CHANGED
package/lib/use-fast-layout.js
CHANGED
|
@@ -5,6 +5,7 @@ import { useCanvasWidth } from './use-canvas-width';
|
|
|
5
5
|
import { useTweenArray } from './use-tween-array';
|
|
6
6
|
import { useLayout } from './use-layout';
|
|
7
7
|
import { useStyleSheet } from '@neovici/cosmoz-utils/hooks/use-stylesheet';
|
|
8
|
+
import { useMini } from './use-mini';
|
|
8
9
|
|
|
9
10
|
export const useFastLayout = ({
|
|
10
11
|
host,
|
|
@@ -15,10 +16,12 @@ export const useFastLayout = ({
|
|
|
15
16
|
sortAndGroupOptions,
|
|
16
17
|
}) => {
|
|
17
18
|
const canvasWidth = useCanvasWidth(host),
|
|
19
|
+
{ miniColumn, miniColumns } = useMini({ host, canvasWidth, columns }),
|
|
18
20
|
{ groupOnColumn } = sortAndGroupOptions,
|
|
19
21
|
layout = useLayout({
|
|
20
22
|
canvasWidth,
|
|
21
23
|
groupOnColumn,
|
|
24
|
+
miniColumn,
|
|
22
25
|
config: settings.columns,
|
|
23
26
|
}),
|
|
24
27
|
tweenedlayout = useTweenArray(layout, resizeSpeedFactor),
|
|
@@ -49,5 +52,5 @@ export const useFastLayout = ({
|
|
|
49
52
|
|
|
50
53
|
useStyleSheet(layoutCss);
|
|
51
54
|
|
|
52
|
-
return { collapsedColumns };
|
|
55
|
+
return { collapsedColumns, miniColumns };
|
|
53
56
|
};
|
package/lib/use-layout.js
CHANGED
|
@@ -1,28 +1,32 @@
|
|
|
1
1
|
import { useMemo } from '@pionjs/pion';
|
|
2
2
|
import { computeLayout } from './compute-layout';
|
|
3
3
|
|
|
4
|
-
export const useLayout = ({ canvasWidth, groupOnColumn, config }) =>
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
export const useLayout = ({ canvasWidth, groupOnColumn, config, miniColumn }) =>
|
|
5
|
+
useMemo(() => {
|
|
6
|
+
if (!Array.isArray(config) || canvasWidth == null || canvasWidth === 0) {
|
|
7
|
+
return [];
|
|
8
|
+
}
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
10
|
+
const columnConfigs = config
|
|
11
|
+
.map((c, index) => ({
|
|
12
|
+
minWidth: c.minWidth,
|
|
13
|
+
width: c.width,
|
|
14
|
+
flex: c.flex,
|
|
15
|
+
priority: c.priority,
|
|
16
|
+
name: c.name,
|
|
17
|
+
index,
|
|
18
|
+
hidden: c.name === groupOnColumn?.name || c.disabled,
|
|
19
|
+
}))
|
|
20
|
+
.map((c) =>
|
|
21
|
+
miniColumn ? { ...c, hidden: miniColumn.name !== c.name } : c,
|
|
22
|
+
)
|
|
23
|
+
.sort(
|
|
24
|
+
(
|
|
25
|
+
{ index: aIndex, priority: aPriority },
|
|
26
|
+
{ index: bIndex, priority: bPriority },
|
|
27
|
+
) =>
|
|
28
|
+
aPriority === bPriority ? bIndex - aIndex : aPriority - bPriority,
|
|
29
|
+
);
|
|
26
30
|
|
|
27
|
-
|
|
28
|
-
}, [canvasWidth, groupOnColumn, config]);
|
|
31
|
+
return computeLayout(columnConfigs, canvasWidth, columnConfigs.length);
|
|
32
|
+
}, [canvasWidth, groupOnColumn, config]);
|
package/lib/use-list.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/* eslint-disable max-lines-per-function */
|
|
2
2
|
import { html, useCallback, useEffect, useMemo, useRef } from '@pionjs/pion';
|
|
3
|
-
import {
|
|
3
|
+
import { when } from 'lit-html/directives/when.js';
|
|
4
4
|
import { isEmpty } from '@neovici/cosmoz-utils/template';
|
|
5
|
+
import { indexSymbol } from './utils';
|
|
5
6
|
import { onItemChange as _onItemChange } from './utils-data';
|
|
6
7
|
|
|
7
8
|
const arrow = html`
|
|
@@ -19,10 +20,26 @@ const arrow = html`
|
|
|
19
20
|
const _getGroupRowClasses = (folded) =>
|
|
20
21
|
folded ? 'groupRow groupRow-folded' : 'groupRow';
|
|
21
22
|
|
|
23
|
+
const renderMinis = (item) => (columns) =>
|
|
24
|
+
when(
|
|
25
|
+
columns?.length > 0,
|
|
26
|
+
() => html`
|
|
27
|
+
<div class="itemRow-minis" part="item-minis">
|
|
28
|
+
${columns.map(
|
|
29
|
+
(column) =>
|
|
30
|
+
html`<div class="itemRow-mini" part="item-mini">
|
|
31
|
+
${(column.renderMini ?? column.renderCell)(column, { item })}
|
|
32
|
+
</div>`,
|
|
33
|
+
)}
|
|
34
|
+
</div>
|
|
35
|
+
`,
|
|
36
|
+
);
|
|
37
|
+
|
|
22
38
|
const renderItem =
|
|
23
39
|
({
|
|
24
40
|
columns,
|
|
25
41
|
collapsedColumns,
|
|
42
|
+
miniColumns,
|
|
26
43
|
onItemClick,
|
|
27
44
|
onCheckboxChange,
|
|
28
45
|
dataIsValid,
|
|
@@ -30,22 +47,22 @@ const renderItem =
|
|
|
30
47
|
onItemChange,
|
|
31
48
|
rowPartFn,
|
|
32
49
|
}) =>
|
|
33
|
-
(item, index, { selected, expanded, toggleCollapse }) =>
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
>
|
|
50
|
+
(item, index, { selected, expanded, toggleCollapse }) => html`
|
|
51
|
+
<div
|
|
52
|
+
?selected=${selected}
|
|
53
|
+
part="${[
|
|
54
|
+
'itemRow',
|
|
55
|
+
`itemRow-${item[indexSymbol]}`,
|
|
56
|
+
rowPartFn?.(item, index),
|
|
57
|
+
]
|
|
58
|
+
.filter(Boolean)
|
|
59
|
+
.join(' ')}"
|
|
60
|
+
.dataIndex=${item[indexSymbol]}
|
|
61
|
+
.dataItem=${item}
|
|
62
|
+
class="itemRow"
|
|
63
|
+
@click=${onItemClick}
|
|
64
|
+
>
|
|
65
|
+
<div class="itemRow-wrapper">
|
|
49
66
|
<input
|
|
50
67
|
class="checkbox"
|
|
51
68
|
type="checkbox"
|
|
@@ -65,7 +82,6 @@ const renderItem =
|
|
|
65
82
|
.onItemChange=${onItemChange}
|
|
66
83
|
>
|
|
67
84
|
</cosmoz-omnitable-item-row>
|
|
68
|
-
|
|
69
85
|
<button
|
|
70
86
|
class="expand"
|
|
71
87
|
?hidden="${isEmpty(collapsedColumns.length)}"
|
|
@@ -75,17 +91,19 @@ const renderItem =
|
|
|
75
91
|
${arrow}
|
|
76
92
|
</button>
|
|
77
93
|
</div>
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
94
|
+
${renderMinis(item)(miniColumns)}
|
|
95
|
+
</div>
|
|
96
|
+
<cosmoz-omnitable-item-expand
|
|
97
|
+
.columns=${collapsedColumns}
|
|
98
|
+
.item=${item}
|
|
99
|
+
.index=${index}
|
|
100
|
+
?selected=${selected}
|
|
101
|
+
?expanded=${expanded}
|
|
102
|
+
.groupOnColumn=${groupOnColumn}
|
|
103
|
+
part="item-expand"
|
|
104
|
+
>
|
|
105
|
+
</cosmoz-omnitable-item-expand>
|
|
106
|
+
`;
|
|
89
107
|
|
|
90
108
|
const renderGroup =
|
|
91
109
|
({ onCheckboxChange, dataIsValid, groupOnColumn }) =>
|
|
@@ -125,6 +143,7 @@ export const useList = ({
|
|
|
125
143
|
processedItems,
|
|
126
144
|
columns,
|
|
127
145
|
collapsedColumns,
|
|
146
|
+
miniColumns,
|
|
128
147
|
sortAndGroupOptions,
|
|
129
148
|
rowPartFn,
|
|
130
149
|
...rest
|
|
@@ -204,6 +223,7 @@ export const useList = ({
|
|
|
204
223
|
renderItem({
|
|
205
224
|
columns,
|
|
206
225
|
collapsedColumns,
|
|
226
|
+
miniColumns,
|
|
207
227
|
onItemClick,
|
|
208
228
|
onCheckboxChange,
|
|
209
229
|
dataIsValid,
|
package/lib/use-mini.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useMemo, useEffect } from '@pionjs/pion';
|
|
2
|
+
|
|
3
|
+
export const useMini = ({ host, canvasWidth, columns: _columns }) => {
|
|
4
|
+
const breakpoint = host.miniBreakpoint ?? 480;
|
|
5
|
+
const isMiniSize = useMemo(
|
|
6
|
+
() => canvasWidth <= breakpoint,
|
|
7
|
+
[canvasWidth, breakpoint],
|
|
8
|
+
);
|
|
9
|
+
const columns = useMemo(
|
|
10
|
+
() =>
|
|
11
|
+
isMiniSize
|
|
12
|
+
? _columns
|
|
13
|
+
?.filter((c) => c.mini !== null)
|
|
14
|
+
.sort((a, b) => (a.mini ?? 0) - (b.mini ?? 0))
|
|
15
|
+
: [],
|
|
16
|
+
[_columns, isMiniSize],
|
|
17
|
+
);
|
|
18
|
+
const [miniColumn, ...miniColumns] = columns ?? [];
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
host.toggleAttribute('mini', !!miniColumn);
|
|
22
|
+
}, [miniColumn]);
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
miniColumn,
|
|
26
|
+
miniColumns,
|
|
27
|
+
};
|
|
28
|
+
};
|
package/lib/use-omnitable.js
CHANGED
|
@@ -19,7 +19,7 @@ export const useOmnitable = (host) => {
|
|
|
19
19
|
noLocalSort = noLocal,
|
|
20
20
|
noLocalFilter = noLocal,
|
|
21
21
|
error,
|
|
22
|
-
rowPartFn
|
|
22
|
+
rowPartFn,
|
|
23
23
|
} = host,
|
|
24
24
|
settingS = useSettings({ settingsId, host }),
|
|
25
25
|
{ settings, setSettings, columns, resetRef } = settingS,
|
|
@@ -28,7 +28,7 @@ export const useOmnitable = (host) => {
|
|
|
28
28
|
hashParam,
|
|
29
29
|
settings,
|
|
30
30
|
setSettings,
|
|
31
|
-
resetRef
|
|
31
|
+
resetRef,
|
|
32
32
|
),
|
|
33
33
|
// TODO: drop filterFunctions
|
|
34
34
|
{ processedItems, visibleData, filters, setFilterState, filterFunctions } =
|
|
@@ -40,7 +40,7 @@ export const useOmnitable = (host) => {
|
|
|
40
40
|
noLocalSort,
|
|
41
41
|
noLocalFilter,
|
|
42
42
|
}),
|
|
43
|
-
{ collapsedColumns } = useFastLayout({
|
|
43
|
+
{ collapsedColumns, miniColumns } = useFastLayout({
|
|
44
44
|
host,
|
|
45
45
|
columns,
|
|
46
46
|
settings,
|
|
@@ -86,8 +86,9 @@ export const useOmnitable = (host) => {
|
|
|
86
86
|
setSelectedItems,
|
|
87
87
|
columns,
|
|
88
88
|
collapsedColumns,
|
|
89
|
+
miniColumns,
|
|
89
90
|
sortAndGroupOptions,
|
|
90
|
-
rowPartFn
|
|
91
|
+
rowPartFn,
|
|
91
92
|
}),
|
|
92
93
|
footer: useFooter({
|
|
93
94
|
host,
|
|
@@ -18,7 +18,7 @@ export const useResizableColumns = ({
|
|
|
18
18
|
newConfig = [],
|
|
19
19
|
maxPriority = config.reduce(
|
|
20
20
|
(p, c) => Math.max(p, c.priority),
|
|
21
|
-
-Infinity
|
|
21
|
+
-Infinity,
|
|
22
22
|
);
|
|
23
23
|
|
|
24
24
|
for (let i = 0; i < layout.length; i++) {
|
|
@@ -45,7 +45,7 @@ export const useResizableColumns = ({
|
|
|
45
45
|
|
|
46
46
|
newConfig[i].width = Math.min(
|
|
47
47
|
maxNewSize,
|
|
48
|
-
Math.max(newWidth, config[i].minWidth)
|
|
48
|
+
Math.max(newWidth, config[i].minWidth),
|
|
49
49
|
);
|
|
50
50
|
newConfig[i].flex = 0;
|
|
51
51
|
newConfig[i].priority = maxPriority;
|
package/lib/use-track-size.js
CHANGED
|
@@ -10,10 +10,10 @@ export const useTrackSize = (host, setCanvasWidth) =>
|
|
|
10
10
|
requestAnimationFrame(() =>
|
|
11
11
|
setCanvasWidth(
|
|
12
12
|
entry.contentRect?.width -
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
)
|
|
13
|
+
20 /* scrollbar width */ -
|
|
14
|
+
44 /* checkbox width */ -
|
|
15
|
+
24 /* expand button width */,
|
|
16
|
+
),
|
|
17
17
|
);
|
|
18
18
|
},
|
|
19
19
|
observer = new ResizeObserver(onResize);
|
|
@@ -21,4 +21,3 @@ export const useTrackSize = (host, setCanvasWidth) =>
|
|
|
21
21
|
observer.observe(host);
|
|
22
22
|
return () => observer.unobserve(host);
|
|
23
23
|
}, []);
|
|
24
|
-
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neovici/cosmoz-omnitable",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.3.0",
|
|
4
4
|
"description": "[](https://travis-ci.org/Neovici/cosmoz-omnitable)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"web-components"
|