@digital-realty/ix-grid 1.3.8 → 1.3.10

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.
@@ -1,9 +1,10 @@
1
1
  import '@digital-realty/ix-button/ix-button.js';
2
2
  import '@digital-realty/ix-date/ix-date.js';
3
+ import '@digital-realty/ix-date-next/ix-date-next.js';
3
4
  import '@digital-realty/ix-icon-button/ix-icon-button.js';
4
5
  import '@digital-realty/ix-icon/ix-icon.js';
5
6
  import '@digital-realty/ix-select/ix-select.js';
6
- import { formatDate } from 'date-fns/format.js';
7
+ import { format, formatDate } from 'date-fns/format.js';
7
8
  import { LitElement, html, nothing } from 'lit';
8
9
  import { customElement, property, state } from 'lit/decorators.js';
9
10
  import { repeat } from 'lit/directives/repeat.js';
@@ -29,6 +30,8 @@ export class IxGridRowFilter extends LitElement {
29
30
 
30
31
  @property({ type: Boolean }) readParamsFromURL = false;
31
32
 
33
+ @property({ type: Boolean }) useNewDatePicker = false;
34
+
32
35
  @property({ type: String }) maxDate: string = formatDate(
33
36
  new Date(),
34
37
  'yyyy-MM-dd'
@@ -255,12 +258,19 @@ export class IxGridRowFilter extends LitElement {
255
258
  }
256
259
  return html` <p>${this.activeFilters.length} ${copy.activeFilter}</p>
257
260
  <ul>
258
- ${this.activeFilters.map(
259
- filter => html`<li>
261
+ ${this.activeFilters.map(filter => {
262
+ let displayValue = filter.value;
263
+
264
+ if (filter.dataType === 'dateTime' && this.useNewDatePicker) {
265
+ const date = this.shadowRoot?.querySelector(`ix-date-next`) as any;
266
+ displayValue = format(displayValue, date.format);
267
+ }
268
+
269
+ return html`<li>
260
270
  ${this.formatCamelCaseToEnglish(filter.columnField)}
261
- ${filter.operatorValue} ${filter.value}
262
- </li>`
263
- )}
271
+ ${filter.operatorValue} ${displayValue}
272
+ </li>`;
273
+ })}
264
274
  </ul>`;
265
275
  }
266
276
 
@@ -278,15 +288,26 @@ export class IxGridRowFilter extends LitElement {
278
288
  }
279
289
 
280
290
  private renderDateInput(value: any, index: number) {
281
- return html` <ix-date
282
- data-testid=${`filterValueInput-${index}`}
283
- .value=${value.value}
284
- max=${this.maxDate}
285
- name="${value.columnField}-valueDate"
286
- .errorText=${this.fromDateErrorText}
287
- .onChanged=${e => this.onDatefilterValueChange(index, e)}
288
- >
289
- </ix-date>`;
291
+ return this.useNewDatePicker
292
+ ? html`<ix-date-next
293
+ data-testid=${`filterValueInput-${index}`}
294
+ .value=${value.value}
295
+ max=${this.maxDate}
296
+ name="${value.columnField}-valueDate"
297
+ showCalendarOnMouseDown="true"
298
+ .errorText=${this.fromDateErrorText}
299
+ .onChanged=${e => this.onDatefilterValueChange(index, e)}
300
+ >
301
+ </ix-date-next>`
302
+ : html`<ix-date
303
+ data-testid=${`filterValueInput-${index}`}
304
+ .value=${value.value}
305
+ max=${this.maxDate}
306
+ name="${value.columnField}-valueDate"
307
+ .errorText=${this.fromDateErrorText}
308
+ .onChanged=${e => this.onDatefilterValueChange(index, e)}
309
+ >
310
+ </ix-date>`;
290
311
  }
291
312
 
292
313
  private renderFilterInputControl(value: any, index: number) {
@@ -18,6 +18,8 @@ export class IxPagination extends LitElement {
18
18
 
19
19
  @property({ type: Array }) pageSizes: number[] = [5, 10, 25, 100];
20
20
 
21
+ @property({ type: Boolean, attribute: 'simple' }) isSimple = false;
22
+
21
23
  private changePage(offset: number) {
22
24
  this.page += offset;
23
25
  this.updatePagination();
@@ -49,8 +51,8 @@ export class IxPagination extends LitElement {
49
51
  render() {
50
52
  const back = this.page > 1;
51
53
  const next = this.recordCount > this.page * this.pageSize;
52
- return html` <div class="pagination">
53
- <div>
54
+ return html` <div class="pagination ${this.isSimple ? 'simple' : ''}">
55
+ <div ?hidden=${this.isSimple}>
54
56
  <p class="rows-per-page" data-testid="ix-pagination-rows-per-page">
55
57
  ${copy.rowsPerPage}:
56
58
  </p>
@@ -160,8 +160,14 @@ export const IxGridRowFilterStyles = css`
160
160
  flex-direction: column;
161
161
  align-items: baseline;
162
162
  height: 54px;
163
- justify-content: flex-end;
163
+ justify-content: space-between;
164
164
  font-family: var(--text-default-font, sans-serif);
165
+ white-space: wrap;
166
+
167
+ ix-date-next,
168
+ ix-date {
169
+ margin-top: 10px;
170
+ }
165
171
  }
166
172
 
167
173
  option {
@@ -8,6 +8,10 @@ export const PaginationStyles = css`
8
8
  );
9
9
  }
10
10
 
11
+ [hidden] {
12
+ display: none !important;
13
+ }
14
+
11
15
  .pagination {
12
16
  display: flex;
13
17
  align-items: center;
@@ -23,6 +27,10 @@ export const PaginationStyles = css`
23
27
  margin: 1.25rem 0.5rem 1.25rem 1rem;
24
28
  }
25
29
 
30
+ .pagination.simple {
31
+ margin: 0;
32
+ }
33
+
26
34
  .pagination > div {
27
35
  display: flex;
28
36
  align-items: center;
@@ -154,7 +154,7 @@ export const IxGridViewStyles = css`
154
154
 
155
155
  .progress-container {
156
156
  position: relative;
157
- top: 60px;
157
+ top: var(--progress-bar-top, 60px);
158
158
  z-index: 1;
159
159
  }
160
160
 
@@ -193,6 +193,17 @@ export const IxGridViewStyles = css`
193
193
 
194
194
  .row-controls {
195
195
  border-top: solid 1px var(--clr-border-outline, #0922411f);
196
+ padding: 8px;
197
+ }
198
+
199
+ .more-pagination {
200
+ align-items: center;
201
+ display: flex;
202
+ justify-content: flex-end;
203
+ }
204
+
205
+ .pagination {
206
+ flex-grow: 1;
196
207
  }
197
208
 
198
209
  .row-limit {
@@ -206,17 +217,12 @@ export const IxGridViewStyles = css`
206
217
 
207
218
  /* launchpad variant */
208
219
  .launchpad vaadin-grid {
209
- --_lumo-grid-border-width: 0;
210
220
  --lumo-size-xl: auto;
211
221
  }
212
222
 
213
- .launchpad vaadin-grid-cell-content {
214
- padding: 11px 24px;
215
- border-bottom: 0;
216
- }
217
-
218
- .launchpad vaadin-grid::part(body-row) {
219
- border-bottom: 1px solid var(--clr-border-outline, rgba(9, 34, 65, 0.12));
223
+ .launchpad {
224
+ --ix-grid-cell-height: 44px;
225
+ --ix-grid-cell-padding: 14px 24px;
220
226
  }
221
227
 
222
228
  .launchpad .grid-header {
@@ -385,5 +385,35 @@ describe('IxGridRowFilter', () => {
385
385
  const today = new Date().toISOString().split('T')[0];
386
386
  expect(dateInput?.getAttribute('max')).to.equal(today);
387
387
  });
388
+
389
+ it('should render ix-date-next if "useNewDatePicker" is true', async () => {
390
+ const columnsWithDataType = [
391
+ {
392
+ name: 'dateField',
393
+ header: 'Date Field',
394
+ filterable: true,
395
+ filterOperators: ['='],
396
+ dataType: 'dateTime',
397
+ },
398
+ ];
399
+
400
+ const el = await fixture(
401
+ html`<ix-grid-row-filter
402
+ .columns=${columnsWithDataType}
403
+ .useNewDatePicker=${true}
404
+ ></ix-grid-row-filter>`
405
+ );
406
+
407
+ const openMenu = el.shadowRoot?.querySelector(
408
+ '.filter-button'
409
+ ) as HTMLElement;
410
+ openMenu?.click();
411
+ await elementUpdated(el);
412
+
413
+ const dateInput = el.shadowRoot?.querySelector(
414
+ 'div.filterValueField ix-date-next'
415
+ );
416
+ expect(dateInput).to.exist;
417
+ });
388
418
  });
389
419
  });