@neovici/cosmoz-omnitable 14.6.0 → 14.7.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.
@@ -0,0 +1,70 @@
1
+ import { html, css, component } from '@pionjs/pion';
2
+
3
+ const styles = css`
4
+ :host {
5
+ max-width: 100%;
6
+ overflow-x: hidden;
7
+ padding: 0 12px;
8
+ }
9
+ .skeleton {
10
+ width: 100%;
11
+ }
12
+ .skeleton > div {
13
+ height: 17.5px;
14
+ display: flex;
15
+ padding: 11px 12px 11px 0;
16
+ }
17
+ .skeleton > div div:not(.handle) {
18
+ background-image: linear-gradient(90deg, #e0e0e0, #f5f5f5, #e0e0e0);
19
+ background-size: 1000%;
20
+ background-position: right;
21
+ border-radius: 4px;
22
+ animation: sweep 1.5s cubic-bezier(0.3, 1, 0.3, 1) infinite;
23
+ }
24
+ .skeleton > div div:not(.checkbox):not(:last-of-type) {
25
+ margin-right: 7px;
26
+ }
27
+ .skeleton > div div.checkbox {
28
+ min-width: 18px;
29
+ margin-left: 0;
30
+ margin-right: 12px;
31
+ }
32
+ @keyframes sweep {
33
+ 0% {
34
+ background-position: right;
35
+ }
36
+ 100% {
37
+ background-position: left;
38
+ }
39
+ }
40
+ `;
41
+
42
+ const Skeleton = ({ settingsConfig }) => {
43
+ const { columns, collapsed } = settingsConfig,
44
+ showingColumns = columns.filter(
45
+ (column) => !collapsed.some((hidden) => hidden.name === column.name),
46
+ );
47
+
48
+ return html`<div class="skeleton">
49
+ ${Array.from(
50
+ { length: 5 },
51
+ () =>
52
+ html`<div>
53
+ <div class="checkbox"></div>
54
+ ${showingColumns.map(
55
+ (col) =>
56
+ html`<div
57
+ class="cell"
58
+ part=${`cell-${col.name}`}
59
+ name=${col.name}
60
+ ></div>`,
61
+ )}
62
+ </div>`,
63
+ )}
64
+ </div>`;
65
+ };
66
+
67
+ customElements.define(
68
+ 'cosmoz-omnitable-skeleton',
69
+ component(Skeleton, { styleSheets: [styles] }),
70
+ );
@@ -1,6 +1,7 @@
1
1
  /* eslint-disable max-lines */
2
2
  import { tagged as css } from '@neovici/cosmoz-utils';
3
- const checkbox = css`
3
+
4
+ export const checkbox = css`
4
5
  .checkbox {
5
6
  box-sizing: border-box;
6
7
  width: 18px;
@@ -80,8 +81,6 @@ const checkbox = css`
80
81
  }
81
82
  `;
82
83
 
83
- export { checkbox };
84
-
85
84
  export default css`
86
85
  :host {
87
86
  display: flex;
@@ -101,6 +100,7 @@ export default css`
101
100
  );
102
101
  color: var(--primary-link-color-hover, var(--primary-link-color));
103
102
  }
103
+
104
104
  /* The wrapping div that contains the header, the table content and the footer */
105
105
  .mainContainer {
106
106
  background-color: var(--cosmoz-omnitable-bg-color, rgb(255, 255, 255));
@@ -118,6 +118,10 @@ export default css`
118
118
  display: flex;
119
119
  align-items: flex-end;
120
120
  background-color: var(--cosmoz-omnitable-header-bg-color, inherit);
121
+ border-top-left-radius: var(--cosmoz-omnitable-header-border-radius-top-left, 8px);
122
+ border-top-right-radius: var(--cosmoz-omnitable-header-border-radius-top-right, 8px);
123
+ border-bottom-left-radius: var(--cosmoz-omnitable-header-border-radius-bottom-left, 2px);
124
+ border-bottom-right-radius: var(--cosmoz-omnitable-header-border-radius-bottom-right, 2px);
121
125
  }
122
126
 
123
127
  [hidden] {
@@ -147,7 +151,7 @@ export default css`
147
151
  .header-cell {
148
152
  --paper-input-container: {
149
153
  padding-top: 0;
150
- padding-bottom: 0;
154
+ padding-bottom: 1px;
151
155
  --paper-font-caption_-_line-height: 18px;
152
156
  }
153
157
  --paper-font-subhead_-_font-family: var(
@@ -237,7 +241,6 @@ export default css`
237
241
  }
238
242
 
239
243
  /* Empty data set styling */
240
-
241
244
  .tableContent-empty {
242
245
  position: absolute;
243
246
  top: 0;
@@ -249,13 +252,11 @@ export default css`
249
252
  justify-content: center;
250
253
  color: #ccc;
251
254
  }
252
-
253
255
  .tableContent-empty.overlay {
254
256
  background-color: rgba(255, 255, 255, 0.8);
255
257
  color: #333;
256
258
  z-index: 1;
257
259
  }
258
-
259
260
  .tableContent-empty iron-icon {
260
261
  height: 96px;
261
262
  min-height: 96px;
@@ -263,34 +264,23 @@ export default css`
263
264
  min-width: 96px;
264
265
  margin-right: 24px;
265
266
  }
266
-
267
- .tableContent-empty.overlay paper-spinner-lite {
268
- height: 48px;
269
- min-height: 48px;
270
- width: 48px;
271
- min-width: 48px;
272
- margin-right: 24px;
273
- --paper-spinner-color: #333;
274
- --paper-spinner-stroke-width: 6px;
275
- }
276
-
277
267
  .tableContent-empty > div {
278
268
  display: flex;
279
269
  flex-direction: column;
280
270
  justify-content: center;
281
271
  padding-bottom: 24px;
282
272
  }
283
-
284
273
  .tableContent-empty.overlay > div {
285
274
  padding-bottom: 0;
286
275
  }
287
-
276
+ .tableContent-empty.overlay:has(cosmoz-omnitable-skeleton) {
277
+ align-items: flex-start;
278
+ }
288
279
  .tableContent-empty div.tableContent-empty-message {
289
280
  @apply --layout-vertical;
290
281
  @apply --layout-center-justified;
291
282
  padding-bottom: 24px;
292
283
  }
293
-
294
284
  .tableContent-empty.overlay div.tableContent-empty-message {
295
285
  padding-bottom: 0;
296
286
  }
@@ -299,7 +289,6 @@ export default css`
299
289
  color: #ddd;
300
290
  margin: 0;
301
291
  }
302
-
303
292
  .tableContent-empty h3 {
304
293
  white-space: nowrap;
305
294
  margin: 0px 0px 8px 0px;
@@ -368,10 +357,6 @@ export default css`
368
357
  border-bottom: 1px solid var(--cosmoz-omnitable-border-color, #e1e2e5);
369
358
  }
370
359
 
371
- .groupRow.groupRow-folded {
372
- /* Add here style rules for folded group rows */
373
- }
374
-
375
360
  .groupRow-label {
376
361
  display: flex;
377
362
  flex: auto;
@@ -547,6 +532,7 @@ export default css`
547
532
  margin: 4px 8px;
548
533
  padding-top: 2px;
549
534
  }
535
+
550
536
  :host([mini]) .itemRow:not([selected]) {
551
537
  background: var(--cosmoz-omnitable-mini-item-background, #fdfdfd);
552
538
  }
@@ -562,22 +548,26 @@ export default css`
562
548
  :host([mini]) .tableContent {
563
549
  overflow: hidden;
564
550
  }
551
+
565
552
  :host([mini]) .tableContent-scroller::-webkit-scrollbar {
566
553
  width: 4px;
567
554
  }
555
+
568
556
  :host([mini]) .tableContent-scroller::-webkit-scrollbar-track {
569
557
  background: transparent;
570
558
  }
559
+
571
560
  :host([mini]) .tableContent-scroller::-webkit-scrollbar-thumb {
572
- background: transparent;
561
+ background: transparent;
573
562
  }
563
+
574
564
  :host([mini]) .tableContent-scroller:hover::-webkit-scrollbar-thumb {
575
- background: var(--cosmoz-omnitable-mini-scrollbar-thumb-bg, #aaa);
565
+ background: var(--cosmoz-omnitable-mini-scrollbar-thumb-bg, #aaa);
576
566
  }
577
567
 
578
568
  :host([mini]) .tableContent-scroller::-webkit-scrollbar-button:decrement,
579
569
  :host([mini]) .tableContent-scroller::-webkit-scrollbar-button:increment {
580
- width: 0px;
570
+ width: 0px;
581
571
  }
582
572
 
583
573
  :host([mini]) cosmoz-omnitable-settings::part(columns) {
@@ -1,29 +1,27 @@
1
- /* eslint-disable max-lines-per-function */
2
- /* eslint-disable max-lines */
3
- import '@polymer/iron-icons/iron-icons';
1
+ import '@neovici/cosmoz-bottom-bar';
4
2
  import '@polymer/iron-icon/iron-icon';
3
+ import '@polymer/iron-icons/iron-icons';
5
4
  import '@polymer/paper-spinner/paper-spinner-lite';
6
5
 
7
- import '@neovici/cosmoz-bottom-bar';
8
-
9
6
  import './cosmoz-omnitable-column';
7
+ import './cosmoz-omnitable-columns';
8
+ import './cosmoz-omnitable-group-row';
10
9
  import './cosmoz-omnitable-header-row';
11
- import './cosmoz-omnitable-item-row';
12
10
  import './cosmoz-omnitable-item-expand';
13
- import './cosmoz-omnitable-group-row';
14
- import './cosmoz-omnitable-columns';
15
- import styles from './cosmoz-omnitable-styles';
11
+ import './cosmoz-omnitable-item-row';
16
12
 
13
+ import { notifyProperty } from '@neovici/cosmoz-utils/hooks/use-notify-property';
14
+ import { component } from '@pionjs/pion';
17
15
  import { html as polymerHtml } from '@polymer/polymer/lib/utils/html-tag';
18
16
  import { html } from 'lit-html';
19
17
  import { guard } from 'lit-html/directives/guard.js';
20
- import { notifyProperty } from '@neovici/cosmoz-utils/hooks/use-notify-property';
21
18
 
22
- import { useOmnitable } from './lib/use-omnitable';
23
- import { component } from '@pionjs/pion';
24
- import { renderHeader } from './lib/render-header';
19
+ import styles from './cosmoz-omnitable-styles';
25
20
  import { renderFooter } from './lib/render-footer';
21
+ import { renderHeader } from './lib/render-header';
26
22
  import { renderList } from './lib/render-list';
23
+ import { useOmnitable } from './lib/use-omnitable';
24
+
27
25
  import './grouped-list/index.js';
28
26
 
29
27
  const shimCSS = (s) => window.ShadyCSS?.ApplyShim?.transformCssText?.(s) || s;
@@ -38,7 +36,9 @@ const Omnitable = (host) => {
38
36
 
39
37
  <div class="mainContainer">
40
38
  ${renderHeader(header)}
41
- <div class="tableContent" id="tableContent">${renderList(list)}</div>
39
+ <div class="tableContent" id="tableContent">
40
+ ${renderList(header, list)}
41
+ </div>
42
42
  ${renderFooter(footer)}
43
43
  </div>
44
44
 
@@ -2,29 +2,36 @@ import { layout } from './layout';
2
2
 
3
3
  const _toCss = (layout, config) => {
4
4
  const lastVisibleIndex = layout.findLastIndex(
5
- (width) => width != null && width > 0,
6
- );
5
+ (width) => width != null && width > 0,
6
+ ),
7
+ generateCellCSS = (itemName, width) =>
8
+ `.cell[name="${itemName}"], cosmoz-omnitable-skeleton::part(cell-${itemName}){width: ${Math.floor(
9
+ width,
10
+ )}px;padding: 0 min(3px, ${width / 2}px)}`,
11
+ hideResizeNub = (itemName) =>
12
+ `cosmoz-omnitable-resize-nub[name="${itemName}"]{display:none}`,
13
+ hideColumn = (itemName) =>
14
+ `cosmoz-omnitable-resize-nub[name="${itemName}"], .cell[name="${itemName}"]{display:none}`;
7
15
 
8
16
  return config
9
17
  .map((item, index) => {
10
18
  const width = layout[index];
19
+
11
20
  // Hidden columns
12
21
  if (width == null || width === 0) {
13
- return `cosmoz-omnitable-resize-nub[name="${item.name}"], .cell[name="${item.name}"]{display:none}`;
22
+ return hideColumn(item.name);
14
23
  }
15
24
 
16
- // Last visible column, show the cell but hide its resize nub
25
+ // All visible columns
26
+ const cellCSS = generateCellCSS(item.name, width);
27
+
28
+ // Last visible column, show cell but hide its resize nub
17
29
  if (index === lastVisibleIndex) {
18
- return `.cell[name="${item.name}"]{width: ${Math.floor(
19
- width,
20
- )}px;padding: 0 min(3px, ${width / 2}px)}
21
- cosmoz-omnitable-resize-nub[name="${item.name}"]{display:none}`;
30
+ return `${cellCSS}\n${hideResizeNub(item.name)}`;
22
31
  }
23
32
 
24
- // Other visible columns
25
- return `.cell[name="${item.name}"]{width: ${Math.floor(
26
- width,
27
- )}px;padding: 0 min(3px, ${width / 2}px)}`;
33
+ // Other visible columns just show the cell
34
+ return cellCSS;
28
35
  })
29
36
  .join('\n');
30
37
  };
@@ -2,8 +2,8 @@ import { html } from 'lit-html';
2
2
  import { when } from 'lit-html/directives/when.js';
3
3
 
4
4
  export const renderHeader = ({
5
- allSelected,
6
- onAllCheckboxChange,
5
+ allSelected,
6
+ onAllCheckboxChange,
7
7
  sortAndGroup,
8
8
  dataIsValid,
9
9
  data,
@@ -12,28 +12,29 @@ export const renderHeader = ({
12
12
  groupOnColumn,
13
13
  setFilterState,
14
14
  settingsConfig,
15
- hideSelectAll
16
- }) => {
17
- return html` <sort-and-group-provider .value=${sortAndGroup}>
15
+ hideSelectAll,
16
+ }) =>
17
+ html`<sort-and-group-provider .value=${sortAndGroup}>
18
18
  <div class="header" id="header">
19
19
  ${when(
20
20
  !hideSelectAll,
21
- () => html`<input
22
- class="checkbox all"
23
- type="checkbox"
24
- .checked=${allSelected}
25
- @input=${onAllCheckboxChange}
26
- ?disabled=${!dataIsValid}
27
- part="all"
28
- />`
21
+ () =>
22
+ html`<input
23
+ class="checkbox all"
24
+ type="checkbox"
25
+ .checked=${allSelected}
26
+ @input=${onAllCheckboxChange}
27
+ ?disabled=${!dataIsValid}
28
+ part="all"
29
+ />`,
29
30
  )}
30
31
  ${when(
31
32
  hideSelectAll,
32
- () => html`
33
- <cosmoz-omnitable-settings
33
+ () =>
34
+ html` <cosmoz-omnitable-settings
34
35
  .newLayout="${true}"
35
36
  .config=${settingsConfig}
36
- ></cosmoz-omnitable-settings>`
37
+ ></cosmoz-omnitable-settings>`,
37
38
  )}
38
39
 
39
40
  <cosmoz-omnitable-header-row
@@ -47,4 +48,3 @@ export const renderHeader = ({
47
48
  ></cosmoz-omnitable-header-row>
48
49
  </div>
49
50
  </sort-and-group-provider>`;
50
- };
@@ -1,24 +1,28 @@
1
- /* eslint-disable max-lines-per-function */
1
+ import '../cosmoz-omnitable-skeleton.js';
2
+
2
3
  import { _ } from '@neovici/cosmoz-i18next';
3
4
  import { html } from 'lit-html';
4
5
  import { when } from 'lit-html/directives/when.js';
5
6
 
6
- export const renderList = ({
7
- processedItems,
8
- dataIsValid,
9
- filterIsTooStrict,
10
- loading,
11
- displayEmptyGroups,
12
- compareItemsFn,
13
- setSelectedItems,
14
- renderItem,
15
- renderGroup,
16
- error,
17
- }) => {
18
- return html` ${when(
19
- !dataIsValid && !error,
7
+ export const renderList = (header, list) => {
8
+ const { settingsConfig } = header,
9
+ {
10
+ processedItems,
11
+ dataIsValid,
12
+ filterIsTooStrict,
13
+ loading,
14
+ displayEmptyGroups,
15
+ compareItemsFn,
16
+ setSelectedItems,
17
+ renderItem,
18
+ renderGroup,
19
+ error,
20
+ } = list;
21
+
22
+ return html`${when(
23
+ !loading && !dataIsValid && !error,
20
24
  () =>
21
- html` <div class="tableContent-empty">
25
+ html`<div class="tableContent-empty">
22
26
  <slot name="empty-set-message">
23
27
  <iron-icon icon="icons:announcement"></iron-icon>
24
28
  <div class="tableContent-empty-message">
@@ -31,7 +35,7 @@ export const renderList = ({
31
35
  ${when(
32
36
  filterIsTooStrict,
33
37
  () =>
34
- html` <div class="tableContent-empty">
38
+ html`<div class="tableContent-empty">
35
39
  <iron-icon icon="icons:announcement"></iron-icon>
36
40
  <div>
37
41
  <h3>${_('Filter too strict')}</h3>
@@ -42,17 +46,16 @@ export const renderList = ({
42
46
  ${when(
43
47
  loading,
44
48
  () =>
45
- html` <div class="tableContent-empty overlay">
46
- <paper-spinner-lite active></paper-spinner-lite>
47
- <div>
48
- <h3>${_('Data set is updating')}</h3>
49
- </div>
49
+ html`<div class="tableContent-empty overlay">
50
+ <cosmoz-omnitable-skeleton
51
+ .settingsConfig=${settingsConfig}
52
+ ></cosmoz-omnitable-skeleton>
50
53
  </div>`,
51
54
  )}
52
55
  ${when(
53
56
  error,
54
57
  () =>
55
- html` <div class="tableContent-empty overlay">
58
+ html`<div class="tableContent-empty overlay">
56
59
  <iron-icon icon="icons:error"></iron-icon>
57
60
  <div class="tableContent-empty-message">
58
61
  <h3>${_('Error loading data')}</h3>
@@ -63,15 +66,15 @@ export const renderList = ({
63
66
  <div class="tableContent-scroller" id="scroller" part="scroller">
64
67
  <cosmoz-grouped-list
65
68
  id="groupedList"
66
- .data="${processedItems}"
67
- @selected-items-changed="${(event) =>
68
- setSelectedItems(event.detail.value)}"
69
- .displayEmptyGroups="${
69
+ .data=${processedItems}
70
+ @selected-items-changed=${(event) =>
71
+ setSelectedItems(event.detail.value)}
72
+ .displayEmptyGroups=${
70
73
  displayEmptyGroups /* TODO: check if still works */
71
- }"
72
- .compareItemsFn="${compareItemsFn}"
73
- .renderItem="${renderItem}"
74
- .renderGroup="${renderGroup}"
74
+ }
75
+ .compareItemsFn=${compareItemsFn}
76
+ .renderItem=${renderItem}
77
+ .renderGroup=${renderGroup}
75
78
  ></cosmoz-grouped-list>
76
79
  <slot name="extraContent"></slot>
77
80
  </div>`;
package/lib/use-header.js CHANGED
@@ -1,4 +1,3 @@
1
- /* eslint-disable max-lines-per-function */
2
1
  import { useEffect, useMemo } from '@pionjs/pion';
3
2
 
4
3
  export const useHeader = ({
@@ -31,9 +30,9 @@ export const useHeader = ({
31
30
  ...settings.columns.filter((s) => s.disabled),
32
31
  ].some(
33
32
  (column) =>
34
- column && Object.keys(filterFunctions).includes(column.name)
33
+ column && Object.keys(filterFunctions).includes(column.name),
35
34
  ),
36
- [filterFunctions, settings, collapsedColumns]
35
+ [filterFunctions, settings, collapsedColumns],
37
36
  ),
38
37
  settingsConfig = useMemo(
39
38
  () => ({
@@ -42,7 +41,7 @@ export const useHeader = ({
42
41
  badge: hasHiddenFilter,
43
42
  filters,
44
43
  }),
45
- [settingS, collapsedColumns, hasHiddenFilter, filters]
44
+ [settingS, collapsedColumns, hasHiddenFilter, filters],
46
45
  );
47
46
 
48
47
  useEffect(() => {
@@ -51,9 +50,9 @@ export const useHeader = ({
51
50
  requestAnimationFrame(() => {
52
51
  host.style.setProperty(
53
52
  '--ot-height',
54
- entries[0]?.contentRect.height + 'px'
53
+ entries[0]?.contentRect.height + 'px',
55
54
  );
56
- })
55
+ }),
57
56
  );
58
57
  observer.observe(el);
59
58
  return () => observer.unobserve(el);
package/lib/use-list.js CHANGED
@@ -1,4 +1,3 @@
1
- /* eslint-disable max-lines-per-function */
2
1
  import { html, useCallback, useEffect, useMemo, useRef } from '@pionjs/pion';
3
2
  import { when } from 'lit-html/directives/when.js';
4
3
  import { isEmpty } from '@neovici/cosmoz-utils/template';
@@ -1,12 +1,12 @@
1
1
  import { useState } from '@pionjs/pion';
2
- import { useProcessedItems } from './use-processed-items';
3
- import { useFastLayout } from './use-fast-layout';
4
2
  import { useSettings } from './settings';
5
- import { useSortAndGroupOptions } from './use-sort-and-group-options';
6
- import { usePublicInterface } from './use-public-interface';
3
+ import { useFastLayout } from './use-fast-layout';
4
+ import { useFooter } from './use-footer';
7
5
  import { useHeader } from './use-header';
8
6
  import { useList } from './use-list';
9
- import { useFooter } from './use-footer';
7
+ import { useProcessedItems } from './use-processed-items';
8
+ import { usePublicInterface } from './use-public-interface';
9
+ import { useSortAndGroupOptions } from './use-sort-and-group-options';
10
10
 
11
11
  export const useOmnitable = (host) => {
12
12
  const {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neovici/cosmoz-omnitable",
3
- "version": "14.6.0",
3
+ "version": "14.7.0",
4
4
  "description": "[![Build Status](https://travis-ci.org/Neovici/cosmoz-omnitable.svg?branch=master)](https://travis-ci.org/Neovici/cosmoz-omnitable)",
5
5
  "keywords": [
6
6
  "web-components"