@3mo/data-grid 0.5.5 → 0.5.7
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/CsvGenerator.js +2 -3
- package/dist/DataGrid.d.ts +3 -1
- package/dist/DataGrid.d.ts.map +1 -1
- package/dist/DataGrid.js +294 -297
- package/dist/DataGridCell.js +46 -50
- package/dist/DataGridFooter.js +93 -94
- package/dist/DataGridHeader.js +92 -92
- package/dist/DataGridHeaderSeparator.js +46 -47
- package/dist/DataGridPrimaryContextMenuItem.js +5 -5
- package/dist/DataGridSelectionController.js +1 -2
- package/dist/DataGridSidePanel.d.ts.map +1 -1
- package/dist/DataGridSidePanel.js +117 -130
- package/dist/FieldSelectDataGridPageSize.js +7 -7
- package/dist/columns/DataGridColumn.js +4 -7
- package/dist/columns/DataGridColumn.test.js +6 -6
- package/dist/columns/DataGridColumnBoolean.js +9 -9
- package/dist/columns/DataGridColumnImage.js +2 -2
- package/dist/columns/DataGridColumnText.js +6 -6
- package/dist/columns/date-time/DataGridColumnDate.js +1 -2
- package/dist/columns/date-time/DataGridColumnDateRange.js +1 -2
- package/dist/columns/date-time/DataGridColumnDateTime.js +1 -2
- package/dist/columns/date-time/DataGridColumnDateTimeBase.js +10 -11
- package/dist/columns/date-time/DataGridColumnDateTimeRange.js +1 -2
- package/dist/columns/number/DataGridColumnCurrency.js +10 -11
- package/dist/columns/number/DataGridColumnNumber.js +6 -7
- package/dist/columns/number/DataGridColumnNumberBase.js +5 -1
- package/dist/columns/number/DataGridColumnPercent.js +7 -8
- package/dist/columns/number/DataGridFooterSum.js +20 -20
- package/dist/excel.svg.js +47 -47
- package/dist/rows/DataGridDefaultRow.js +47 -47
- package/dist/rows/DataGridRow.d.ts +2 -0
- package/dist/rows/DataGridRow.d.ts.map +1 -1
- package/dist/rows/DataGridRow.js +159 -147
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +55 -56
|
@@ -17,55 +17,55 @@ let DataGridHeaderSeparator = DataGridHeaderSeparator_1 = class DataGridHeaderSe
|
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
static get styles() {
|
|
20
|
-
return css `
|
|
21
|
-
div.separator {
|
|
22
|
-
display: flex;
|
|
23
|
-
align-items: center;
|
|
24
|
-
justify-content: center;
|
|
25
|
-
inset-inline-start: calc(var(--mo-data-grid-columns-gap) * -1);
|
|
26
|
-
width: var(--mo-data-grid-columns-gap);
|
|
27
|
-
height: 100%;
|
|
28
|
-
user-select: none;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.knob {
|
|
32
|
-
height: var(--mo-data-grid-header-separator-height);
|
|
33
|
-
width: var(--mo-data-grid-header-separator-width);
|
|
34
|
-
border-radius: 100px;
|
|
35
|
-
background-color: var(--mo-color-gray);
|
|
36
|
-
transition: 0.2s;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
:host(:not([disabled])) div.separator {
|
|
40
|
-
cursor: col-resize;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
:host(:not([disabled])) .separator:hover .knob {
|
|
44
|
-
--mo-data-grid-header-separator-height: 30px;
|
|
45
|
-
--mo-data-grid-header-separator-width: 8px;
|
|
46
|
-
background-color: var(--mo-color-accent);
|
|
47
|
-
cursor: col-resize;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
:host(:not([disabled])) .resizerOverlay {
|
|
51
|
-
position: fixed;
|
|
52
|
-
top: 0;
|
|
53
|
-
height: 100%;
|
|
54
|
-
background: var(--mo-color-gray);
|
|
55
|
-
width: 2px;
|
|
56
|
-
}
|
|
20
|
+
return css `
|
|
21
|
+
div.separator {
|
|
22
|
+
display: flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
justify-content: center;
|
|
25
|
+
inset-inline-start: calc(var(--mo-data-grid-columns-gap) * -1);
|
|
26
|
+
width: var(--mo-data-grid-columns-gap);
|
|
27
|
+
height: 100%;
|
|
28
|
+
user-select: none;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.knob {
|
|
32
|
+
height: var(--mo-data-grid-header-separator-height);
|
|
33
|
+
width: var(--mo-data-grid-header-separator-width);
|
|
34
|
+
border-radius: 100px;
|
|
35
|
+
background-color: var(--mo-color-gray);
|
|
36
|
+
transition: 0.2s;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
:host(:not([disabled])) div.separator {
|
|
40
|
+
cursor: col-resize;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
:host(:not([disabled])) .separator:hover .knob {
|
|
44
|
+
--mo-data-grid-header-separator-height: 30px;
|
|
45
|
+
--mo-data-grid-header-separator-width: 8px;
|
|
46
|
+
background-color: var(--mo-color-accent);
|
|
47
|
+
cursor: col-resize;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
:host(:not([disabled])) .resizerOverlay {
|
|
51
|
+
position: fixed;
|
|
52
|
+
top: 0;
|
|
53
|
+
height: 100%;
|
|
54
|
+
background: var(--mo-color-gray);
|
|
55
|
+
width: 2px;
|
|
56
|
+
}
|
|
57
57
|
`;
|
|
58
58
|
}
|
|
59
59
|
get template() {
|
|
60
60
|
this.toggleAttribute('disabled', DataGridHeaderSeparator_1.disableResizing);
|
|
61
|
-
return html `
|
|
62
|
-
<div class='separator' @mousedown=${this.handleMouseDown}>
|
|
63
|
-
<div class='knob'></div>
|
|
64
|
-
</div>
|
|
65
|
-
|
|
66
|
-
${this.isResizing === false ? html.nothing : html `
|
|
67
|
-
<div class='resizerOverlay' ${style({ marginInlineStart: `${this.delta}px` })}></div>
|
|
68
|
-
`}
|
|
61
|
+
return html `
|
|
62
|
+
<div class='separator' @mousedown=${this.handleMouseDown}>
|
|
63
|
+
<div class='knob'></div>
|
|
64
|
+
</div>
|
|
65
|
+
|
|
66
|
+
${this.isResizing === false ? html.nothing : html `
|
|
67
|
+
<div class='resizerOverlay' ${style({ marginInlineStart: `${this.delta}px` })}></div>
|
|
68
|
+
`}
|
|
69
69
|
`;
|
|
70
70
|
}
|
|
71
71
|
handleMouseUp() {
|
|
@@ -93,11 +93,10 @@ let DataGridHeaderSeparator = DataGridHeaderSeparator_1 = class DataGridHeaderSe
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
getColumnWidth(column) {
|
|
96
|
-
var _a;
|
|
97
96
|
if (column.hidden === true) {
|
|
98
97
|
return 0;
|
|
99
98
|
}
|
|
100
|
-
column.width =
|
|
99
|
+
column.width = column.width ?? '1fr';
|
|
101
100
|
const columnIndex = this.dataGrid.visibleColumns.findIndex(c => c === this.column);
|
|
102
101
|
const targetColumnIndex = this.dataGrid.visibleColumns.findIndex(c => c === column);
|
|
103
102
|
let targetColumn = this.previousElementSibling;
|
|
@@ -3,11 +3,11 @@ import { component, css } from '@a11d/lit';
|
|
|
3
3
|
import { ContextMenuItem } from '@3mo/context-menu';
|
|
4
4
|
let DataGridPrimaryContextMenuItem = class DataGridPrimaryContextMenuItem extends ContextMenuItem {
|
|
5
5
|
static get styles() {
|
|
6
|
-
return css `
|
|
7
|
-
${super.styles}
|
|
8
|
-
:host {
|
|
9
|
-
font-weight: bold;
|
|
10
|
-
}
|
|
6
|
+
return css `
|
|
7
|
+
${super.styles}
|
|
8
|
+
:host {
|
|
9
|
+
font-weight: bold;
|
|
10
|
+
}
|
|
11
11
|
`;
|
|
12
12
|
}
|
|
13
13
|
};
|
|
@@ -26,8 +26,7 @@ export class DataGridSelectionController extends Controller {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
isSelectable(data) {
|
|
29
|
-
|
|
30
|
-
return (_c = (_b = (_a = this.dataGrid).isDataSelectable) === null || _b === void 0 ? void 0 : _b.call(_a, data)) !== null && _c !== void 0 ? _c : true;
|
|
29
|
+
return this.dataGrid.isDataSelectable?.(data) ?? true;
|
|
31
30
|
}
|
|
32
31
|
selectAll() {
|
|
33
32
|
if (this.mode === DataGridSelectionMode.Multiple) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataGridSidePanel.d.ts","sourceRoot":"","sources":["../DataGridSidePanel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,SAAS,
|
|
1
|
+
{"version":3,"file":"DataGridSidePanel.d.ts","sourceRoot":"","sources":["../DataGridSidePanel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,SAAS,EAAwC,MAAM,WAAW,CAAA;AAK7F,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAYxC,oBAAY,oBAAoB;IAC/B,QAAQ,aAAa;IACrB,OAAO,YAAY;CACnB;AAED;;;;GAIG;AACH,qBACa,iBAAiB,CAAC,KAAK,CAAE,SAAQ,SAAS;IAC1B,QAAQ,EAAG,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;IAC/C,GAAG,CAAC,EAAE,oBAAoB,CAAA;IAEtC,WAAoB,MAAM,kCA2CzB;IAED,cAAuB,QAAQ,0CAmC9B;IAED,SAAS,KAAK,eAAe,0CAM5B;IAED,SAAS,KAAK,gBAAgB,0CAgC7B;IAED,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAcjC;CACD;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,yBAAyB,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAA;KACrD;CACD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { component, style, Component, css, html, ifDefined, property } from '@a11d/lit';
|
|
2
|
+
import { component, style, Component, css, html, ifDefined, property, bind } from '@a11d/lit';
|
|
3
3
|
import { Localizer } from '@3mo/localization';
|
|
4
4
|
import { tooltip } from '@3mo/tooltip';
|
|
5
5
|
Localizer.register('de', {
|
|
@@ -9,6 +9,7 @@ Localizer.register('de', {
|
|
|
9
9
|
'Font Size': 'Schriftgröße',
|
|
10
10
|
'Row Height': 'Zeilenhöhe',
|
|
11
11
|
'Tools': 'Tools',
|
|
12
|
+
'Design': 'Design',
|
|
12
13
|
});
|
|
13
14
|
export var DataGridSidePanelTab;
|
|
14
15
|
(function (DataGridSidePanelTab) {
|
|
@@ -25,152 +26,138 @@ let DataGridSidePanel = class DataGridSidePanel extends Component {
|
|
|
25
26
|
super(...arguments);
|
|
26
27
|
this.getColumnTemplate = (column) => {
|
|
27
28
|
const change = async (e) => {
|
|
28
|
-
|
|
29
|
-
column.hidden = ((_a = e.target) === null || _a === void 0 ? void 0 : _a.selected) === false;
|
|
29
|
+
column.hidden = e.target?.selected === false;
|
|
30
30
|
this.dataGrid.setColumns(this.dataGrid.columns);
|
|
31
31
|
this.dataGrid.requestUpdate();
|
|
32
32
|
await this.dataGrid.updateComplete;
|
|
33
33
|
};
|
|
34
|
-
return html `
|
|
35
|
-
<mo-checkbox ${style({ height: '30px' })}
|
|
36
|
-
label=${column.heading}
|
|
37
|
-
?selected=${column.hidden === false}
|
|
38
|
-
@change=${change}
|
|
39
|
-
></mo-checkbox>
|
|
34
|
+
return html `
|
|
35
|
+
<mo-checkbox ${style({ height: '30px' })}
|
|
36
|
+
label=${column.heading}
|
|
37
|
+
?selected=${column.hidden === false}
|
|
38
|
+
@change=${change}
|
|
39
|
+
></mo-checkbox>
|
|
40
40
|
`;
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
static get styles() {
|
|
44
|
-
return css `
|
|
45
|
-
:host {
|
|
46
|
-
display: inline-block !important;
|
|
47
|
-
transition: 250ms;
|
|
48
|
-
width: 100%;
|
|
49
|
-
height: 100%;
|
|
50
|
-
transform-origin: right center;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
:host(:not([hidden])) {
|
|
54
|
-
border-inline-start: var(--mo-data-grid-border);
|
|
55
|
-
background: var(--mo-color-transparent-gray-1);
|
|
56
|
-
opacity: 1;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
:host([hidden]) {
|
|
60
|
-
opacity: 0;
|
|
61
|
-
transform: scale(0, 1);
|
|
62
|
-
width: 0;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
#flexHeading {
|
|
66
|
-
border-top: var(--mo-data-grid-border);
|
|
67
|
-
border-bottom: var(--mo-data-grid-border);
|
|
68
|
-
height: var(--mo-data-grid-header-height);
|
|
69
|
-
padding-inline-start: 14px;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
mo-scroller {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
mo-flex[slot=heading] div {
|
|
88
|
-
color: var(--mo-color-gray);
|
|
89
|
-
margin-inline-start: 8px;
|
|
90
|
-
font-size: small;
|
|
91
|
-
}
|
|
44
|
+
return css `
|
|
45
|
+
:host {
|
|
46
|
+
display: inline-block !important;
|
|
47
|
+
transition: 250ms;
|
|
48
|
+
width: 100%;
|
|
49
|
+
height: 100%;
|
|
50
|
+
transform-origin: right center;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
:host(:not([hidden])) {
|
|
54
|
+
border-inline-start: var(--mo-data-grid-border);
|
|
55
|
+
background: var(--mo-color-transparent-gray-1);
|
|
56
|
+
opacity: 1;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
:host([hidden]) {
|
|
60
|
+
opacity: 0;
|
|
61
|
+
transform: scale(0, 1);
|
|
62
|
+
width: 0;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
#flexHeading {
|
|
66
|
+
border-top: var(--mo-data-grid-border);
|
|
67
|
+
border-bottom: var(--mo-data-grid-border);
|
|
68
|
+
height: var(--mo-data-grid-header-height);
|
|
69
|
+
padding-inline-start: 14px;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
mo-scroller {
|
|
73
|
+
overflow-x: hidden;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
mo-section {
|
|
77
|
+
padding: 10px 14px 20px;
|
|
78
|
+
border-bottom: var(--mo-data-grid-border);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
mo-section::part(heading) {
|
|
82
|
+
font-size: min(1em, 14px);
|
|
83
|
+
letter-spacing: 0.15px;
|
|
84
|
+
}
|
|
92
85
|
`;
|
|
93
86
|
}
|
|
94
87
|
get template() {
|
|
95
|
-
return html `
|
|
96
|
-
<mo-flex ${style({ height: '100%' })}>
|
|
97
|
-
${this.dataGrid.hasToolbar || this.dataGrid.hasFilters === false ? html.nothing : html `
|
|
98
|
-
<mo-tab-bar ${style({ height: '60px' })}
|
|
99
|
-
value=${ifDefined(this.dataGrid.sidePanelTab)}
|
|
100
|
-
@change=${(e) =>
|
|
101
|
-
>
|
|
102
|
-
<mo-tab value=${DataGridSidePanelTab.Filters}>
|
|
103
|
-
<mo-icon icon='filter_list'></mo-icon>
|
|
104
|
-
${t('Extended Filters')}
|
|
105
|
-
</mo-tab>
|
|
106
|
-
<mo-tab value=${DataGridSidePanelTab.Settings}>
|
|
107
|
-
<mo-icon icon='settings'></mo-icon>
|
|
108
|
-
${t('Settings')}
|
|
109
|
-
</mo-tab>
|
|
110
|
-
</mo-tab-bar>
|
|
111
|
-
`}
|
|
112
|
-
|
|
113
|
-
${this.dataGrid.hasToolbar === false && this.dataGrid.hasFilters === true ? html.nothing : html `
|
|
114
|
-
<mo-flex id='flexHeading' direction='horizontal' alignItems='center'>
|
|
115
|
-
<mo-heading typography='heading6' ${style({ flex: '1', color: 'var(--mo-color-on-surface)' })}>${t(this.dataGrid.sidePanelTab === DataGridSidePanelTab.Filters ? 'Extended Filters' : 'Settings')}</mo-heading>
|
|
116
|
-
<mo-icon-button icon='close' dense
|
|
117
|
-
${tooltip(t('Close'))}
|
|
118
|
-
${style({ cursor: 'pointer', color: 'var(--mo-color-gray)' })}
|
|
119
|
-
@click=${() => this.dataGrid.navigateToSidePanelTab(undefined)}
|
|
120
|
-
></mo-icon-button>
|
|
121
|
-
</mo-flex>
|
|
122
|
-
`}
|
|
123
|
-
|
|
124
|
-
<mo-scroller ${style({ flex: '1' })}>
|
|
125
|
-
${this.dataGrid.sidePanelTab === DataGridSidePanelTab.Filters ? this.filtersTemplate : this.settingsTemplate}
|
|
126
|
-
</mo-scroller>
|
|
127
|
-
</mo-flex>
|
|
88
|
+
return html `
|
|
89
|
+
<mo-flex ${style({ height: '100%' })}>
|
|
90
|
+
${this.dataGrid.hasToolbar || this.dataGrid.hasFilters === false ? html.nothing : html `
|
|
91
|
+
<mo-tab-bar ${style({ height: '60px' })}
|
|
92
|
+
value=${ifDefined(this.dataGrid.sidePanelTab)}
|
|
93
|
+
@change=${(e) => this.dataGrid.navigateToSidePanelTab(e.detail ?? DataGridSidePanelTab.Settings)}
|
|
94
|
+
>
|
|
95
|
+
<mo-tab value=${DataGridSidePanelTab.Filters}>
|
|
96
|
+
<mo-icon icon='filter_list'></mo-icon>
|
|
97
|
+
${t('Extended Filters')}
|
|
98
|
+
</mo-tab>
|
|
99
|
+
<mo-tab value=${DataGridSidePanelTab.Settings}>
|
|
100
|
+
<mo-icon icon='settings'></mo-icon>
|
|
101
|
+
${t('Settings')}
|
|
102
|
+
</mo-tab>
|
|
103
|
+
</mo-tab-bar>
|
|
104
|
+
`}
|
|
105
|
+
|
|
106
|
+
${this.dataGrid.hasToolbar === false && this.dataGrid.hasFilters === true ? html.nothing : html `
|
|
107
|
+
<mo-flex id='flexHeading' direction='horizontal' alignItems='center'>
|
|
108
|
+
<mo-heading typography='heading6' ${style({ flex: '1', color: 'var(--mo-color-on-surface)' })}>${t(this.dataGrid.sidePanelTab === DataGridSidePanelTab.Filters ? 'Extended Filters' : 'Settings')}</mo-heading>
|
|
109
|
+
<mo-icon-button icon='close' dense
|
|
110
|
+
${tooltip(t('Close'))}
|
|
111
|
+
${style({ cursor: 'pointer', color: 'var(--mo-color-gray)' })}
|
|
112
|
+
@click=${() => this.dataGrid.navigateToSidePanelTab(undefined)}
|
|
113
|
+
></mo-icon-button>
|
|
114
|
+
</mo-flex>
|
|
115
|
+
`}
|
|
116
|
+
|
|
117
|
+
<mo-scroller ${style({ flex: '1' })}>
|
|
118
|
+
${this.dataGrid.sidePanelTab === DataGridSidePanelTab.Filters ? this.filtersTemplate : this.settingsTemplate}
|
|
119
|
+
</mo-scroller>
|
|
120
|
+
</mo-flex>
|
|
128
121
|
`;
|
|
129
122
|
}
|
|
130
123
|
get filtersTemplate() {
|
|
131
|
-
return html `
|
|
132
|
-
<mo-flex gap='14px'>
|
|
133
|
-
<slot name='filter'></slot>
|
|
134
|
-
</mo-flex>
|
|
124
|
+
return html `
|
|
125
|
+
<mo-flex gap='14px' style='padding: 14px'>
|
|
126
|
+
<slot name='filter'></slot>
|
|
127
|
+
</mo-flex>
|
|
135
128
|
`;
|
|
136
129
|
}
|
|
137
130
|
get settingsTemplate() {
|
|
138
|
-
return html `
|
|
139
|
-
<mo-flex
|
|
140
|
-
<slot name='settings'></slot>
|
|
141
|
-
|
|
142
|
-
<mo-section>
|
|
143
|
-
<mo-flex
|
|
144
|
-
<mo-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
<mo-slider min='30' max='60' step='5'
|
|
169
|
-
value=${this.dataGrid.rowHeight}
|
|
170
|
-
@input=${(e) => this.dataGrid.rowHeight = e.detail}
|
|
171
|
-
></mo-slider>
|
|
172
|
-
</mo-section>
|
|
173
|
-
</mo-flex>
|
|
131
|
+
return html `
|
|
132
|
+
<mo-flex>
|
|
133
|
+
<slot name='settings'></slot>
|
|
134
|
+
|
|
135
|
+
<mo-section heading=${t('Design')}>
|
|
136
|
+
<mo-flex gap='16px'>
|
|
137
|
+
<mo-field-select label=${t('Font Size')} ${bind(this, 'dataGrid', { keyPath: 'cellFontSize' })}>
|
|
138
|
+
${Array.from({ length: 5 }).map((_, i) => {
|
|
139
|
+
const value = 0.8 + i * 0.1;
|
|
140
|
+
return html `<mo-option value=${value}>${(value * 100).formatAsPercent()}</mo-option>`;
|
|
141
|
+
})}
|
|
142
|
+
</mo-field-select>
|
|
143
|
+
<mo-field-select label=${t('Row Height')} ${bind(this, 'dataGrid', { keyPath: 'rowHeight' })}>
|
|
144
|
+
${Array.from({ length: 7 }).map((_, i) => {
|
|
145
|
+
const value = 30 + i * 5;
|
|
146
|
+
return html `<mo-option value=${value}>${value}px</mo-option>`;
|
|
147
|
+
})}
|
|
148
|
+
</mo-field-select>
|
|
149
|
+
</mo-flex>
|
|
150
|
+
</mo-section>
|
|
151
|
+
|
|
152
|
+
<mo-section .heading=${html `
|
|
153
|
+
${t('Columns')}
|
|
154
|
+
<span style='color: var(--mo-color-gray)'>
|
|
155
|
+
${this.dataGrid.visibleColumns.length.format()}/${this.dataGrid.columns.length.format()}
|
|
156
|
+
</span>
|
|
157
|
+
`}>
|
|
158
|
+
${this.dataGrid.columns.map(this.getColumnTemplate)}
|
|
159
|
+
</mo-section>
|
|
160
|
+
</mo-flex>
|
|
174
161
|
`;
|
|
175
162
|
}
|
|
176
163
|
};
|
|
@@ -4,13 +4,13 @@ import { component, html, property } from '@a11d/lit';
|
|
|
4
4
|
import { FieldSelect } from '@3mo/select-field';
|
|
5
5
|
let FieldSelectDataGridPageSize = FieldSelectDataGridPageSize_1 = class FieldSelectDataGridPageSize extends FieldSelect {
|
|
6
6
|
get optionsTemplate() {
|
|
7
|
-
return html `
|
|
8
|
-
${!this.dataGrid || !this.dataGrid.supportsDynamicPageSize ? html.nothing : html `
|
|
9
|
-
<mo-option value='auto'>Auto</mo-option>
|
|
10
|
-
`}
|
|
11
|
-
${FieldSelectDataGridPageSize_1.data.map(size => html `
|
|
12
|
-
<mo-option value=${size}>${size.format()}</mo-option>
|
|
13
|
-
`)}
|
|
7
|
+
return html `
|
|
8
|
+
${!this.dataGrid || !this.dataGrid.supportsDynamicPageSize ? html.nothing : html `
|
|
9
|
+
<mo-option value='auto'>Auto</mo-option>
|
|
10
|
+
`}
|
|
11
|
+
${FieldSelectDataGridPageSize_1.data.map(size => html `
|
|
12
|
+
<mo-option value=${size}>${size.format()}</mo-option>
|
|
13
|
+
`)}
|
|
14
14
|
`;
|
|
15
15
|
}
|
|
16
16
|
};
|
|
@@ -26,7 +26,6 @@ export class DataGridColumn extends Component {
|
|
|
26
26
|
return Number(value.replace(DataGridColumn.regex, '$1') || 1);
|
|
27
27
|
}
|
|
28
28
|
get definition() {
|
|
29
|
-
var _a;
|
|
30
29
|
const nonEditable = this.nonEditable;
|
|
31
30
|
return {
|
|
32
31
|
dataSelector: this.dataSelector,
|
|
@@ -39,12 +38,11 @@ export class DataGridColumn extends Component {
|
|
|
39
38
|
sortable: !this.nonSortable,
|
|
40
39
|
editable: this.getEditContentTemplate !== undefined && (typeof nonEditable !== 'function' ? !nonEditable : x => !nonEditable(x)),
|
|
41
40
|
getContentTemplate: this.getContentTemplate.bind(this),
|
|
42
|
-
getEditContentTemplate:
|
|
41
|
+
getEditContentTemplate: this.getEditContentTemplate?.bind(this),
|
|
43
42
|
};
|
|
44
43
|
}
|
|
45
44
|
handleEdit(value, data) {
|
|
46
|
-
|
|
47
|
-
(_a = this.dataGrid) === null || _a === void 0 ? void 0 : _a.handleEdit(data, this.dataSelector, value);
|
|
45
|
+
this.dataGrid?.handleEdit(data, this.dataSelector, value);
|
|
48
46
|
}
|
|
49
47
|
connectedCallback() {
|
|
50
48
|
if (this.parentElement instanceof DataGrid) {
|
|
@@ -53,9 +51,8 @@ export class DataGridColumn extends Component {
|
|
|
53
51
|
super.connectedCallback();
|
|
54
52
|
}
|
|
55
53
|
updated() {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
(_b = this.dataGrid) === null || _b === void 0 ? void 0 : _b.requestUpdate();
|
|
54
|
+
this.dataGrid?.extractColumns();
|
|
55
|
+
this.dataGrid?.requestUpdate();
|
|
59
56
|
}
|
|
60
57
|
}
|
|
61
58
|
DataGridColumn.regex = /^\s*(0|[1-9][0-9]*)?\s*\*\s*$/;
|
|
@@ -4,12 +4,12 @@ describe('DataGridColumn', () => {
|
|
|
4
4
|
describe('nonEditable', () => {
|
|
5
5
|
it('should not trigger update when a new passed predicate is equal but not identical', () => {
|
|
6
6
|
const hasChanged = DataGridColumn.getPropertyOptions('nonEditable').hasChanged;
|
|
7
|
-
expect(hasChanged
|
|
8
|
-
expect(hasChanged
|
|
9
|
-
expect(hasChanged
|
|
10
|
-
expect(hasChanged
|
|
11
|
-
expect(hasChanged
|
|
12
|
-
expect(hasChanged
|
|
7
|
+
expect(hasChanged?.(false, false)).toBe(false);
|
|
8
|
+
expect(hasChanged?.(true, true)).toBe(false);
|
|
9
|
+
expect(hasChanged?.(() => true, () => true)).toBe(false);
|
|
10
|
+
expect(hasChanged?.(false, true)).toBe(true);
|
|
11
|
+
expect(hasChanged?.(true, false)).toBe(true);
|
|
12
|
+
expect(hasChanged?.(() => false, () => true)).toBe(true);
|
|
13
13
|
});
|
|
14
14
|
});
|
|
15
15
|
});
|
|
@@ -19,18 +19,18 @@ let DataGridColumnBoolean = class DataGridColumnBoolean extends DataGridColumn {
|
|
|
19
19
|
}
|
|
20
20
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
21
21
|
getContentTemplate(value, _data) {
|
|
22
|
-
return html `
|
|
23
|
-
<mo-flex justifyContent='center' ${style({ height: '100%' })}>
|
|
24
|
-
<mo-icon icon=${value ? this.trueIcon : this.falseIcon} ${style({ color: value ? this.trueIconColor : this.falseIconColor })}></mo-icon>
|
|
25
|
-
</mo-flex>
|
|
22
|
+
return html `
|
|
23
|
+
<mo-flex justifyContent='center' ${style({ height: '100%' })}>
|
|
24
|
+
<mo-icon icon=${value ? this.trueIcon : this.falseIcon} ${style({ color: value ? this.trueIconColor : this.falseIconColor })}></mo-icon>
|
|
25
|
+
</mo-flex>
|
|
26
26
|
`;
|
|
27
27
|
}
|
|
28
28
|
getEditContentTemplate(value, data) {
|
|
29
|
-
return html `
|
|
30
|
-
<mo-checkbox data-focus
|
|
31
|
-
?selected=${value}
|
|
32
|
-
@change=${(e) => this.handleEdit(e.detail, data)}
|
|
33
|
-
></mo-checkbox>
|
|
29
|
+
return html `
|
|
30
|
+
<mo-checkbox data-focus
|
|
31
|
+
?selected=${value}
|
|
32
|
+
@change=${(e) => this.handleEdit(e.detail, data)}
|
|
33
|
+
></mo-checkbox>
|
|
34
34
|
`;
|
|
35
35
|
}
|
|
36
36
|
};
|
|
@@ -11,8 +11,8 @@ let DataGridColumnImage = class DataGridColumnImage extends DataGridColumn {
|
|
|
11
11
|
}
|
|
12
12
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
13
13
|
getContentTemplate(value, _data) {
|
|
14
|
-
return !value ? html.nothing : html `
|
|
15
|
-
<img style='vertical-align: middle' src=${value} onload='this.hidden = false' onerror='this.hidden = true'/>
|
|
14
|
+
return !value ? html.nothing : html `
|
|
15
|
+
<img style='vertical-align: middle' src=${value} onload='this.hidden = false' onerror='this.hidden = true'/>
|
|
16
16
|
`;
|
|
17
17
|
}
|
|
18
18
|
};
|
|
@@ -5,14 +5,14 @@ import { DataGridColumn } from './DataGridColumn.js';
|
|
|
5
5
|
let DataGridColumnText = class DataGridColumnText extends DataGridColumn {
|
|
6
6
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
7
7
|
getContentTemplate(value, _data) {
|
|
8
|
-
return html `${value
|
|
8
|
+
return html `${value ?? ''}`;
|
|
9
9
|
}
|
|
10
10
|
getEditContentTemplate(value, data) {
|
|
11
|
-
return html `
|
|
12
|
-
<mo-field-text dense label=${this.heading} data-focus
|
|
13
|
-
value=${ifDefined(value)}
|
|
14
|
-
@change=${(e) => this.handleEdit(e.detail, data)}
|
|
15
|
-
></mo-field-text>
|
|
11
|
+
return html `
|
|
12
|
+
<mo-field-text dense label=${this.heading} data-focus
|
|
13
|
+
value=${ifDefined(value)}
|
|
14
|
+
@change=${(e) => this.handleEdit(e.detail, data)}
|
|
15
|
+
></mo-field-text>
|
|
16
16
|
`;
|
|
17
17
|
}
|
|
18
18
|
};
|
|
@@ -8,9 +8,8 @@ let DataGridColumnDate = class DataGridColumnDate extends DataGridColumnDateTime
|
|
|
8
8
|
this.fieldTag = literal `mo-field-date`;
|
|
9
9
|
}
|
|
10
10
|
getContentTemplate(value, data) {
|
|
11
|
-
var _a;
|
|
12
11
|
data;
|
|
13
|
-
return html `${value ?
|
|
12
|
+
return html `${value ? value.formatAsDate(this.formatOptionsValue) ?? '' : ''}`;
|
|
14
13
|
}
|
|
15
14
|
};
|
|
16
15
|
DataGridColumnDate = __decorate([
|
|
@@ -8,9 +8,8 @@ let DataGridColumnDateRange = class DataGridColumnDateRange extends DataGridColu
|
|
|
8
8
|
this.fieldTag = literal `mo-field-date-range`;
|
|
9
9
|
}
|
|
10
10
|
getContentTemplate(value, data) {
|
|
11
|
-
var _a;
|
|
12
11
|
data;
|
|
13
|
-
return html `${value ?
|
|
12
|
+
return html `${value ? value.formatAsDateRange(this.formatOptionsValue) ?? '' : ''}`;
|
|
14
13
|
}
|
|
15
14
|
};
|
|
16
15
|
DataGridColumnDateRange = __decorate([
|
|
@@ -8,9 +8,8 @@ let DataGridColumnDateTime = class DataGridColumnDateTime extends DataGridColumn
|
|
|
8
8
|
this.fieldTag = literal `mo-field-date-time`;
|
|
9
9
|
}
|
|
10
10
|
getContentTemplate(value, data) {
|
|
11
|
-
var _a;
|
|
12
11
|
data;
|
|
13
|
-
return html `${value ?
|
|
12
|
+
return html `${value ? value.format(this.formatOptionsValue) ?? '' : ''}`;
|
|
14
13
|
}
|
|
15
14
|
};
|
|
16
15
|
DataGridColumnDateTime = __decorate([
|
|
@@ -11,19 +11,18 @@ export class DataGridColumnDateTimeBase extends DataGridColumn {
|
|
|
11
11
|
this.pickerHidden = false;
|
|
12
12
|
}
|
|
13
13
|
get formatOptionsValue() {
|
|
14
|
-
|
|
15
|
-
return (_a = this.formatOptions) !== null && _a !== void 0 ? _a : this.constructor.defaultFormatOptions;
|
|
14
|
+
return this.formatOptions ?? this.constructor.defaultFormatOptions;
|
|
16
15
|
}
|
|
17
16
|
getEditContentTemplate(value, data) {
|
|
18
|
-
return html `
|
|
19
|
-
${staticHtml `
|
|
20
|
-
<${this.fieldTag} dense data-focus
|
|
21
|
-
?pickerHidden=${this.pickerHidden}
|
|
22
|
-
label=${this.heading}
|
|
23
|
-
.value=${value}
|
|
24
|
-
@change=${(e) => this.handleEdit(e.detail, data)}
|
|
25
|
-
></${this.fieldTag}>
|
|
26
|
-
`}
|
|
17
|
+
return html `
|
|
18
|
+
${staticHtml `
|
|
19
|
+
<${this.fieldTag} dense data-focus
|
|
20
|
+
?pickerHidden=${this.pickerHidden}
|
|
21
|
+
label=${this.heading}
|
|
22
|
+
.value=${value}
|
|
23
|
+
@change=${(e) => this.handleEdit(e.detail, data)}
|
|
24
|
+
></${this.fieldTag}>
|
|
25
|
+
`}
|
|
27
26
|
`;
|
|
28
27
|
}
|
|
29
28
|
}
|
|
@@ -8,9 +8,8 @@ let DataGridColumnDateTimeRange = class DataGridColumnDateTimeRange extends Data
|
|
|
8
8
|
this.fieldTag = literal `mo-field-date-time-range`;
|
|
9
9
|
}
|
|
10
10
|
getContentTemplate(value, data) {
|
|
11
|
-
var _a;
|
|
12
11
|
data;
|
|
13
|
-
return html `${value ?
|
|
12
|
+
return html `${value ? value.format(this.formatOptionsValue) ?? '' : ''}`;
|
|
14
13
|
}
|
|
15
14
|
};
|
|
16
15
|
DataGridColumnDateTimeRange = __decorate([
|