@3mo/data-grid 0.5.4 → 0.5.6
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.d.ts.map +1 -1
- package/dist/DataGridHeaderSeparator.js +47 -49
- package/dist/DataGridPrimaryContextMenuItem.js +5 -5
- package/dist/DataGridSelectionController.js +1 -2
- package/dist/DataGridSidePanel.js +128 -129
- 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 +56 -56
|
@@ -17,56 +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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
`}
|
|
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
|
+
}
|
|
59
57
|
`;
|
|
60
58
|
}
|
|
61
59
|
get template() {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
+
`}
|
|
70
69
|
`;
|
|
71
70
|
}
|
|
72
71
|
handleMouseUp() {
|
|
@@ -94,11 +93,10 @@ let DataGridHeaderSeparator = DataGridHeaderSeparator_1 = class DataGridHeaderSe
|
|
|
94
93
|
}
|
|
95
94
|
}
|
|
96
95
|
getColumnWidth(column) {
|
|
97
|
-
var _a;
|
|
98
96
|
if (column.hidden === true) {
|
|
99
97
|
return 0;
|
|
100
98
|
}
|
|
101
|
-
column.width =
|
|
99
|
+
column.width = column.width ?? '1fr';
|
|
102
100
|
const columnIndex = this.dataGrid.visibleColumns.findIndex(c => c === this.column);
|
|
103
101
|
const targetColumnIndex = this.dataGrid.visibleColumns.findIndex(c => c === column);
|
|
104
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) {
|
|
@@ -25,152 +25,151 @@ let DataGridSidePanel = class DataGridSidePanel extends Component {
|
|
|
25
25
|
super(...arguments);
|
|
26
26
|
this.getColumnTemplate = (column) => {
|
|
27
27
|
const change = async (e) => {
|
|
28
|
-
|
|
29
|
-
column.hidden = ((_a = e.target) === null || _a === void 0 ? void 0 : _a.selected) === false;
|
|
28
|
+
column.hidden = e.target?.selected === false;
|
|
30
29
|
this.dataGrid.setColumns(this.dataGrid.columns);
|
|
31
30
|
this.dataGrid.requestUpdate();
|
|
32
31
|
await this.dataGrid.updateComplete;
|
|
33
32
|
};
|
|
34
|
-
return html `
|
|
35
|
-
<mo-checkbox ${style({ height: '30px' })}
|
|
36
|
-
label=${column.heading}
|
|
37
|
-
?selected=${column.hidden === false}
|
|
38
|
-
@change=${change}
|
|
39
|
-
></mo-checkbox>
|
|
33
|
+
return html `
|
|
34
|
+
<mo-checkbox ${style({ height: '30px' })}
|
|
35
|
+
label=${column.heading}
|
|
36
|
+
?selected=${column.hidden === false}
|
|
37
|
+
@change=${change}
|
|
38
|
+
></mo-checkbox>
|
|
40
39
|
`;
|
|
41
40
|
};
|
|
42
41
|
}
|
|
43
42
|
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
|
-
width: calc(100% - calc(2 * 14px));
|
|
74
|
-
padding: 0 14px;
|
|
75
|
-
margin-top: 14px;
|
|
76
|
-
overflow-x: hidden;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
mo-scroller::part(container) {
|
|
80
|
-
width: calc(100% - calc(2 * 14px));
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
mo-flex[slot=heading] {
|
|
84
|
-
align-items: center;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
mo-flex[slot=heading] div {
|
|
88
|
-
color: var(--mo-color-gray);
|
|
89
|
-
margin-inline-start: 8px;
|
|
90
|
-
font-size: small;
|
|
91
|
-
}
|
|
43
|
+
return css `
|
|
44
|
+
:host {
|
|
45
|
+
display: inline-block !important;
|
|
46
|
+
transition: 250ms;
|
|
47
|
+
width: 100%;
|
|
48
|
+
height: 100%;
|
|
49
|
+
transform-origin: right center;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
:host(:not([hidden])) {
|
|
53
|
+
border-inline-start: var(--mo-data-grid-border);
|
|
54
|
+
background: var(--mo-color-transparent-gray-1);
|
|
55
|
+
opacity: 1;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
:host([hidden]) {
|
|
59
|
+
opacity: 0;
|
|
60
|
+
transform: scale(0, 1);
|
|
61
|
+
width: 0;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
#flexHeading {
|
|
65
|
+
border-top: var(--mo-data-grid-border);
|
|
66
|
+
border-bottom: var(--mo-data-grid-border);
|
|
67
|
+
height: var(--mo-data-grid-header-height);
|
|
68
|
+
padding-inline-start: 14px;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
mo-scroller {
|
|
72
|
+
width: calc(100% - calc(2 * 14px));
|
|
73
|
+
padding: 0 14px;
|
|
74
|
+
margin-top: 14px;
|
|
75
|
+
overflow-x: hidden;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
mo-scroller::part(container) {
|
|
79
|
+
width: calc(100% - calc(2 * 14px));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
mo-flex[slot=heading] {
|
|
83
|
+
align-items: center;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
mo-flex[slot=heading] div {
|
|
87
|
+
color: var(--mo-color-gray);
|
|
88
|
+
margin-inline-start: 8px;
|
|
89
|
+
font-size: small;
|
|
90
|
+
}
|
|
92
91
|
`;
|
|
93
92
|
}
|
|
94
93
|
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>
|
|
94
|
+
return html `
|
|
95
|
+
<mo-flex ${style({ height: '100%' })}>
|
|
96
|
+
${this.dataGrid.hasToolbar || this.dataGrid.hasFilters === false ? html.nothing : html `
|
|
97
|
+
<mo-tab-bar ${style({ height: '60px' })}
|
|
98
|
+
value=${ifDefined(this.dataGrid.sidePanelTab)}
|
|
99
|
+
@change=${(e) => this.dataGrid.navigateToSidePanelTab(e.detail ?? DataGridSidePanelTab.Settings)}
|
|
100
|
+
>
|
|
101
|
+
<mo-tab value=${DataGridSidePanelTab.Filters}>
|
|
102
|
+
<mo-icon icon='filter_list'></mo-icon>
|
|
103
|
+
${t('Extended Filters')}
|
|
104
|
+
</mo-tab>
|
|
105
|
+
<mo-tab value=${DataGridSidePanelTab.Settings}>
|
|
106
|
+
<mo-icon icon='settings'></mo-icon>
|
|
107
|
+
${t('Settings')}
|
|
108
|
+
</mo-tab>
|
|
109
|
+
</mo-tab-bar>
|
|
110
|
+
`}
|
|
111
|
+
|
|
112
|
+
${this.dataGrid.hasToolbar === false && this.dataGrid.hasFilters === true ? html.nothing : html `
|
|
113
|
+
<mo-flex id='flexHeading' direction='horizontal' alignItems='center'>
|
|
114
|
+
<mo-heading typography='heading6' ${style({ flex: '1', color: 'var(--mo-color-on-surface)' })}>${t(this.dataGrid.sidePanelTab === DataGridSidePanelTab.Filters ? 'Extended Filters' : 'Settings')}</mo-heading>
|
|
115
|
+
<mo-icon-button icon='close' dense
|
|
116
|
+
${tooltip(t('Close'))}
|
|
117
|
+
${style({ cursor: 'pointer', color: 'var(--mo-color-gray)' })}
|
|
118
|
+
@click=${() => this.dataGrid.navigateToSidePanelTab(undefined)}
|
|
119
|
+
></mo-icon-button>
|
|
120
|
+
</mo-flex>
|
|
121
|
+
`}
|
|
122
|
+
|
|
123
|
+
<mo-scroller ${style({ flex: '1' })}>
|
|
124
|
+
${this.dataGrid.sidePanelTab === DataGridSidePanelTab.Filters ? this.filtersTemplate : this.settingsTemplate}
|
|
125
|
+
</mo-scroller>
|
|
126
|
+
</mo-flex>
|
|
128
127
|
`;
|
|
129
128
|
}
|
|
130
129
|
get filtersTemplate() {
|
|
131
|
-
return html `
|
|
132
|
-
<mo-flex gap='14px'>
|
|
133
|
-
<slot name='filter'></slot>
|
|
134
|
-
</mo-flex>
|
|
130
|
+
return html `
|
|
131
|
+
<mo-flex gap='14px'>
|
|
132
|
+
<slot name='filter'></slot>
|
|
133
|
+
</mo-flex>
|
|
135
134
|
`;
|
|
136
135
|
}
|
|
137
136
|
get settingsTemplate() {
|
|
138
|
-
return html `
|
|
139
|
-
<mo-flex gap='14px'>
|
|
140
|
-
<slot name='settings'></slot>
|
|
141
|
-
|
|
142
|
-
<mo-section>
|
|
143
|
-
<mo-flex slot='heading' direction='horizontal'>
|
|
144
|
-
<mo-heading typography='heading4'>${t('Columns')}</mo-heading>
|
|
145
|
-
<div>${this.dataGrid.visibleColumns.length.format()} / ${this.dataGrid.columns.length.format()}</div>
|
|
146
|
-
</mo-flex>
|
|
147
|
-
${this.dataGrid.columns.map(this.getColumnTemplate)}
|
|
148
|
-
</mo-section>
|
|
149
|
-
|
|
150
|
-
<mo-section>
|
|
151
|
-
<mo-flex slot='heading' direction='horizontal'>
|
|
152
|
-
<mo-heading typography='heading4'>${t('Font Size')}</mo-heading>
|
|
153
|
-
<div>${(this.dataGrid.cellFontSize * 100).formatAsPercent()}</div>
|
|
154
|
-
</mo-flex>
|
|
155
|
-
|
|
156
|
-
<mo-slider min='0.8' max='1.2' step='0.1'
|
|
157
|
-
value=${this.dataGrid.cellFontSize}
|
|
158
|
-
@input=${(e) => this.dataGrid.cellFontSize = e.detail}
|
|
159
|
-
></mo-slider>
|
|
160
|
-
</mo-section>
|
|
161
|
-
|
|
162
|
-
<mo-section>
|
|
163
|
-
<mo-flex slot='heading' direction='horizontal'>
|
|
164
|
-
<mo-heading typography='heading4'>${t('Row Height')}</mo-heading>
|
|
165
|
-
<div>${this.dataGrid.rowHeight.format()} px</div>
|
|
166
|
-
</mo-flex>
|
|
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>
|
|
137
|
+
return html `
|
|
138
|
+
<mo-flex gap='14px'>
|
|
139
|
+
<slot name='settings'></slot>
|
|
140
|
+
|
|
141
|
+
<mo-section>
|
|
142
|
+
<mo-flex slot='heading' direction='horizontal'>
|
|
143
|
+
<mo-heading typography='heading4'>${t('Columns')}</mo-heading>
|
|
144
|
+
<div>${this.dataGrid.visibleColumns.length.format()} / ${this.dataGrid.columns.length.format()}</div>
|
|
145
|
+
</mo-flex>
|
|
146
|
+
${this.dataGrid.columns.map(this.getColumnTemplate)}
|
|
147
|
+
</mo-section>
|
|
148
|
+
|
|
149
|
+
<mo-section>
|
|
150
|
+
<mo-flex slot='heading' direction='horizontal'>
|
|
151
|
+
<mo-heading typography='heading4'>${t('Font Size')}</mo-heading>
|
|
152
|
+
<div>${(this.dataGrid.cellFontSize * 100).formatAsPercent()}</div>
|
|
153
|
+
</mo-flex>
|
|
154
|
+
|
|
155
|
+
<mo-slider min='0.8' max='1.2' step='0.1'
|
|
156
|
+
value=${this.dataGrid.cellFontSize}
|
|
157
|
+
@input=${(e) => this.dataGrid.cellFontSize = e.detail}
|
|
158
|
+
></mo-slider>
|
|
159
|
+
</mo-section>
|
|
160
|
+
|
|
161
|
+
<mo-section>
|
|
162
|
+
<mo-flex slot='heading' direction='horizontal'>
|
|
163
|
+
<mo-heading typography='heading4'>${t('Row Height')}</mo-heading>
|
|
164
|
+
<div>${this.dataGrid.rowHeight.format()} px</div>
|
|
165
|
+
</mo-flex>
|
|
166
|
+
|
|
167
|
+
<mo-slider min='30' max='60' step='5'
|
|
168
|
+
value=${this.dataGrid.rowHeight}
|
|
169
|
+
@input=${(e) => this.dataGrid.rowHeight = e.detail}
|
|
170
|
+
></mo-slider>
|
|
171
|
+
</mo-section>
|
|
172
|
+
</mo-flex>
|
|
174
173
|
`;
|
|
175
174
|
}
|
|
176
175
|
};
|
|
@@ -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([
|