@3mo/data-grid 0.5.13 → 0.5.15

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.
@@ -31,133 +31,133 @@ let DataGridSidePanel = class DataGridSidePanel extends Component {
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
- 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
- }
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
+ }
85
85
  `;
86
86
  }
87
87
  get template() {
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>
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>
121
121
  `;
122
122
  }
123
123
  get filtersTemplate() {
124
- return html `
125
- <mo-flex gap='14px' style='padding: 14px'>
126
- <slot name='filter'></slot>
127
- </mo-flex>
124
+ return html `
125
+ <mo-flex gap='14px' style='padding: 14px'>
126
+ <slot name='filter'></slot>
127
+ </mo-flex>
128
128
  `;
129
129
  }
130
130
  get settingsTemplate() {
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' })}>
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
138
  ${Array.from({ length: 5 }).map((_, i) => {
139
139
  const value = 0.8 + i * 0.1;
140
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' })}>
141
+ })}
142
+ </mo-field-select>
143
+ <mo-field-select label=${t('Row Height')} ${bind(this, 'dataGrid', { keyPath: 'rowHeight' })}>
144
144
  ${Array.from({ length: 7 }).map((_, i) => {
145
145
  const value = 30 + i * 5;
146
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>
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>
161
161
  `;
162
162
  }
163
163
  };
@@ -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 autofocus
31
- ?selected=${value}
32
- @change=${(e) => this.handleEdit(e.detail, data)}
33
- ></mo-checkbox>
29
+ return html `
30
+ <mo-checkbox autofocus
31
+ ?selected=${value}
32
+ @change=${(e) => this.handleEdit(e.detail, data)}
33
+ ></mo-checkbox>
34
34
  `;
35
35
  }
36
36
  };
@@ -1,9 +1,10 @@
1
1
  import { DataGridColumn } from './DataGridColumn.js';
2
2
  /** @element mo-data-grid-column-image */
3
3
  export declare class DataGridColumnImage<TData> extends DataGridColumn<TData, string> {
4
+ tooltipSelector?: KeyPathOf<TData> | ((data: TData) => string | undefined);
4
5
  nonSortable: boolean;
5
6
  nonEditable: boolean;
6
- getContentTemplate(value: string | undefined, _data: TData): import("lit-html").HTMLTemplateResult;
7
+ getContentTemplate(value: string | undefined, data: TData): import("lit-html").HTMLTemplateResult;
7
8
  getEditContentTemplate: undefined;
8
9
  }
9
10
  declare global {
@@ -1 +1 @@
1
- {"version":3,"file":"DataGridColumnImage.d.ts","sourceRoot":"","sources":["../../columns/DataGridColumnImage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEpD,yCAAyC;AACzC,qBACa,mBAAmB,CAAC,KAAK,CAAE,SAAQ,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC;IACnE,WAAW,UAAO;IAClB,WAAW,UAAO;IAG3B,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,KAAK,EAAE,KAAK;IAMjD,sBAAsB,YAAY;CAC3C;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,2BAA2B,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAA;KACzD;CACD"}
1
+ {"version":3,"file":"DataGridColumnImage.d.ts","sourceRoot":"","sources":["../../columns/DataGridColumnImage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAGpD,yCAAyC;AACzC,qBACa,mBAAmB,CAAC,KAAK,CAAE,SAAQ,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC;IAChE,eAAe,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,KAAK,MAAM,GAAG,SAAS,CAAC,CAAA;IAE7E,WAAW,UAAO;IAClB,WAAW,UAAO;IAE3B,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,KAAK;IAsBhD,sBAAsB,YAAY;CAC3C;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,2BAA2B,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAA;KACzD;CACD"}
@@ -1,6 +1,7 @@
1
1
  import { __decorate } from "tslib";
2
- import { component, html } from '@a11d/lit';
2
+ import { component, html, property, style } from '@a11d/lit';
3
3
  import { DataGridColumn } from './DataGridColumn.js';
4
+ import { tooltip } from '@3mo/tooltip';
4
5
  /** @element mo-data-grid-column-image */
5
6
  let DataGridColumnImage = class DataGridColumnImage extends DataGridColumn {
6
7
  constructor() {
@@ -9,13 +10,29 @@ let DataGridColumnImage = class DataGridColumnImage extends DataGridColumn {
9
10
  this.nonEditable = true;
10
11
  this.getEditContentTemplate = undefined;
11
12
  }
12
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
13
- getContentTemplate(value, _data) {
13
+ getContentTemplate(value, data) {
14
+ if (!value) {
15
+ return html.nothing;
16
+ }
17
+ const tooltipText = !this.tooltipSelector
18
+ ? undefined
19
+ : typeof this.tooltipSelector === 'function'
20
+ ? this.tooltipSelector(data)
21
+ : getValueByKeyPath(data, this.tooltipSelector);
14
22
  return !value ? html.nothing : html `
15
- <img style='vertical-align: middle' src=${value} onload='this.hidden = false' onerror='this.hidden = true'/>
23
+ <img
24
+ ${tooltipText ? tooltip(tooltipText) : html.nothing}
25
+ ${style({ verticalAlign: 'middle' })}
26
+ src=${value}
27
+ onload='this.hidden = false'
28
+ onerror='this.hidden = true'
29
+ />
16
30
  `;
17
31
  }
18
32
  };
33
+ __decorate([
34
+ property()
35
+ ], DataGridColumnImage.prototype, "tooltipSelector", void 0);
19
36
  DataGridColumnImage = __decorate([
20
37
  component('mo-data-grid-column-image')
21
38
  ], DataGridColumnImage);
@@ -8,11 +8,11 @@ let DataGridColumnText = class DataGridColumnText extends DataGridColumn {
8
8
  return html `${value ?? ''}`;
9
9
  }
10
10
  getEditContentTemplate(value, data) {
11
- return html `
12
- <mo-field-text dense label=${this.heading} autofocus
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} autofocus
13
+ value=${ifDefined(value)}
14
+ @change=${(e) => this.handleEdit(e.detail, data)}
15
+ ></mo-field-text>
16
16
  `;
17
17
  }
18
18
  };
@@ -14,15 +14,15 @@ export class DataGridColumnDateTimeBase extends DataGridColumn {
14
14
  return this.formatOptions ?? this.constructor.defaultFormatOptions;
15
15
  }
16
16
  getEditContentTemplate(value, data) {
17
- return html `
18
- ${staticHtml `
19
- <${this.fieldTag} dense autofocus
20
- ?pickerHidden=${this.pickerHidden}
21
- label=${this.heading}
22
- .value=${value}
23
- @change=${(e) => this.handleEdit(e.detail, data)}
24
- ></${this.fieldTag}>
25
- `}
17
+ return html `
18
+ ${staticHtml `
19
+ <${this.fieldTag} dense autofocus
20
+ ?pickerHidden=${this.pickerHidden}
21
+ label=${this.heading}
22
+ .value=${value}
23
+ @change=${(e) => this.handleEdit(e.detail, data)}
24
+ ></${this.fieldTag}>
25
+ `}
26
26
  `;
27
27
  }
28
28
  }
@@ -18,18 +18,18 @@ let DataGridColumnCurrency = DataGridColumnCurrency_1 = class DataGridColumnCurr
18
18
  return html `${this.getNumber(value)?.formatAsCurrency(this.currency) ?? html.nothing}`;
19
19
  }
20
20
  getEditContentTemplate(value, data) {
21
- return html `
22
- <mo-field-currency dense autofocus
23
- .currency=${this.currency}
24
- label=${this.heading}
25
- value=${ifDefined(value)}
26
- @change=${(e) => this.handleEdit(e.detail, data)}
27
- ></mo-field-currency>
21
+ return html `
22
+ <mo-field-currency dense autofocus
23
+ .currency=${this.currency}
24
+ label=${this.heading}
25
+ value=${ifDefined(value)}
26
+ @change=${(e) => this.handleEdit(e.detail, data)}
27
+ ></mo-field-currency>
28
28
  `;
29
29
  }
30
30
  getSumTemplate(sum) {
31
- return html `
32
- <span style='font-weight: 500'>${sum.formatAsCurrency(this.currency)}</span>
31
+ return html `
32
+ <span style='font-weight: 500'>${sum.formatAsCurrency(this.currency)}</span>
33
33
  `;
34
34
  }
35
35
  };
@@ -8,11 +8,11 @@ let DataGridColumnNumber = class DataGridColumnNumber extends DataGridColumnNumb
8
8
  return html `${this.getNumber(value)?.format() ?? html.nothing}`;
9
9
  }
10
10
  getEditContentTemplate(value, data) {
11
- return html `
12
- <mo-field-number dense label=${this.heading} autofocus
13
- value=${ifDefined(value)}
14
- @change=${(e) => this.handleEdit(e.detail, data)}
15
- ></mo-field-number>
11
+ return html `
12
+ <mo-field-number dense label=${this.heading} autofocus
13
+ value=${ifDefined(value)}
14
+ @change=${(e) => this.handleEdit(e.detail, data)}
15
+ ></mo-field-number>
16
16
  `;
17
17
  }
18
18
  getSumTemplate(sum) {
@@ -8,12 +8,12 @@ let DataGridColumnPercent = class DataGridColumnPercent extends DataGridColumnNu
8
8
  return html `${this.getNumber(value)?.formatAsPercent() ?? html.nothing}`;
9
9
  }
10
10
  getEditContentTemplate(value, data) {
11
- return html `
12
- <mo-field-percent dense autofocus
13
- label=${this.heading}
14
- value=${ifDefined(value)}
15
- @change=${(e) => this.handleEdit(e.detail, data)}
16
- ></mo-field-percent>
11
+ return html `
12
+ <mo-field-percent dense autofocus
13
+ label=${this.heading}
14
+ value=${ifDefined(value)}
15
+ @change=${(e) => this.handleEdit(e.detail, data)}
16
+ ></mo-field-percent>
17
17
  `;
18
18
  }
19
19
  getSumTemplate(sum) {
@@ -1612,6 +1612,10 @@
1612
1612
  "name": "mo-data-grid-column-image",
1613
1613
  "path": ".\\packages\\DataGrid\\columns\\DataGridColumnImage.ts",
1614
1614
  "attributes": [
1615
+ {
1616
+ "name": "tooltipSelector",
1617
+ "type": "KeyPathOf<TData>"
1618
+ },
1615
1619
  {
1616
1620
  "name": "dataGrid",
1617
1621
  "type": "DataGrid<TData, any> | undefined"
@@ -1669,6 +1673,11 @@
1669
1673
  }
1670
1674
  ],
1671
1675
  "properties": [
1676
+ {
1677
+ "name": "tooltipSelector",
1678
+ "attribute": "tooltipSelector",
1679
+ "type": "(object extends TData ? string : TData extends readonly any[] ? Extract<keyof TData, `${number}`> | SubKeyPathOf<TData, Extract<keyof TData, `${number}`>, 1> : TData extends object ? Extract<...> | SubKeyPathOf<...> : never) | ((data: TData) => string | undefined) | undefined"
1680
+ },
1672
1681
  {
1673
1682
  "name": "getEditContentTemplate",
1674
1683
  "type": "undefined",
@@ -3693,7 +3702,8 @@
3693
3702
  ],
3694
3703
  "properties": [
3695
3704
  {
3696
- "name": "dataGrid"
3705
+ "name": "dataGrid",
3706
+ "type": "DataGrid<TData, TDetailsElement>"
3697
3707
  },
3698
3708
  {
3699
3709
  "name": "data",
@@ -4564,6 +4574,10 @@
4564
4574
  }
4565
4575
  ],
4566
4576
  "properties": [
4577
+ {
4578
+ "name": "tooltipSelector",
4579
+ "type": "(object extends TData ? string : TData extends readonly any[] ? Extract<keyof TData, `${number}`> | SubKeyPathOf<TData, Extract<keyof TData, `${number}`>, 1> : TData extends object ? Extract<...> | SubKeyPathOf<...> : never) | ((data: TData) => string | undefined) | undefined"
4580
+ },
4567
4581
  {
4568
4582
  "name": "getEditContentTemplate",
4569
4583
  "type": "undefined"