@neovici/cosmoz-omnitable 12.2.1 → 12.4.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.
@@ -2,6 +2,7 @@ import { html, component } from 'haunted';
2
2
  import { repeat } from 'lit-html/directives/repeat.js';
3
3
  import './lib/cosmoz-omnitable-resize-nub';
4
4
  import { render } from './lib/settings/cosmoz-omnitable-sort-group';
5
+ import { when } from 'lit-html/directives/when.js';
5
6
 
6
7
  const /* eslint-disable-next-line max-lines-per-function */
7
8
  renderHeaderRow = ({
@@ -53,15 +54,16 @@ const /* eslint-disable-next-line max-lines-per-function */
53
54
  ></cosmoz-omnitable-resize-nub>`,
54
55
  ]
55
56
  ),
56
- HeaderRow = ({ columns, settingsConfig, ...thru }) => [
57
+ HeaderRow = ({ columns, settingsConfig, hideSelectAll, ...thru }) => [
57
58
  columns &&
58
59
  renderHeaderRow({
59
60
  columns,
60
61
  ...thru,
61
62
  }),
62
- html`<cosmoz-omnitable-settings
63
- .config=${settingsConfig}
64
- ></cosmoz-omnitable-settings>`,
63
+ html`${when(!hideSelectAll, () => html`
64
+ <cosmoz-omnitable-settings
65
+ .config=${settingsConfig}>
66
+ </cosmoz-omnitable-settings>`)}`,
65
67
  ];
66
68
 
67
69
  customElements.define(
@@ -49,7 +49,7 @@ const Omnitable = (host) => {
49
49
  customElements.define(
50
50
  'cosmoz-omnitable',
51
51
  component(Omnitable, {
52
- observedAttributes: ['hash-param', 'sort-on', 'group-on'],
52
+ observedAttributes: ['hash-param', 'sort-on', 'group-on', 'hide-select-all'],
53
53
  })
54
54
  );
55
55
 
@@ -1,4 +1,5 @@
1
1
  import { html } from 'lit-html';
2
+ import { when } from 'lit-html/directives/when.js';
2
3
 
3
4
  export const renderHeader = ({
4
5
  allSelected,
@@ -11,16 +12,29 @@ export const renderHeader = ({
11
12
  groupOnColumn,
12
13
  setFilterState,
13
14
  settingsConfig,
15
+ hideSelectAll
14
16
  }) => {
15
17
  return html` <sort-and-group-provider .value=${sortAndGroup}>
16
18
  <div class="header" id="header">
17
- <input
18
- class="checkbox all"
19
- type="checkbox"
20
- .checked=${allSelected}
21
- @input=${onAllCheckboxChange}
22
- ?disabled=${!dataIsValid}
23
- />
19
+ ${when(
20
+ !hideSelectAll,
21
+ () => html`<input
22
+ class="checkbox all"
23
+ type="checkbox"
24
+ .checked=${allSelected}
25
+ @input=${onAllCheckboxChange}
26
+ ?disabled=${!dataIsValid}
27
+ />`
28
+ )}
29
+ ${when(
30
+ hideSelectAll,
31
+ () => html`
32
+ <cosmoz-omnitable-settings
33
+ .newLayout="${true}"
34
+ .config=${settingsConfig}
35
+ ></cosmoz-omnitable-settings>`
36
+ )}
37
+
24
38
  <cosmoz-omnitable-header-row
25
39
  .data=${data}
26
40
  .columns=${columns}
@@ -28,6 +42,7 @@ export const renderHeader = ({
28
42
  .groupOnColumn=${groupOnColumn}
29
43
  .setFilterState=${setFilterState}
30
44
  .settingsConfig=${settingsConfig}
45
+ .hideSelectAll=${hideSelectAll}
31
46
  ></cosmoz-omnitable-header-row>
32
47
  </div>
33
48
  </sort-and-group-provider>`;
@@ -1,5 +1,4 @@
1
1
  import { html, component } from 'haunted';
2
- import { nothing } from 'lit-html';
3
2
  import { _ } from '@neovici/cosmoz-i18next';
4
3
  import { isEmpty } from '@neovici/cosmoz-utils/template';
5
4
  import { defaultPlacement } from '@neovici/cosmoz-dropdown';
@@ -8,6 +7,7 @@ import { sort, group } from './cosmoz-omnitable-sort-group';
8
7
  import style, { dropdown as dropdownStyle } from './style.css';
9
8
  import useSettingsUi from './use-settings-ui';
10
9
  import { close, pull, arrow } from '../icons';
10
+ import { when } from 'lit-html/directives/when.js';
11
11
 
12
12
  /* eslint-disable max-lines-per-function */
13
13
  const placement = ['bottom-right', ...defaultPlacement],
@@ -130,7 +130,7 @@ const placement = ['bottom-right', ...defaultPlacement],
130
130
  </div>`,
131
131
  ].filter(Boolean);
132
132
  },
133
- Settings = ({ config }) => html`
133
+ Settings = ({ config, newLayout }) => html`
134
134
  <style>
135
135
  ${dropdownStyle}
136
136
  </style>
@@ -138,12 +138,17 @@ const placement = ['bottom-right', ...defaultPlacement],
138
138
  .render=${() => html`<cosmoz-omnitable-settings-ui
139
139
  .config=${config}
140
140
  ></cosmoz-omnitable-settings-ui>`}
141
- .placement=${placement}
141
+ .placement=${newLayout ? ['bottom-left', ...defaultPlacement] : placement}
142
142
  >
143
- <svg viewBox="0 0 24 24" width="24" slot="button" fill="currentColor">
144
- <path d="M10 18h5V5h-5v13zm-6 0h5V5H4v13zM16 5v13h5V5h-5z"></path>
145
- </svg>
146
- ${config?.badge ? html`<div class="badge" slot="button"></div>` : nothing}
143
+ ${newLayout ?
144
+ html`<div class="headerDots" slot="button">...</div>` :
145
+ html`
146
+ <svg viewBox="0 0 24 24" width="24" slot="button" fill="currentColor">
147
+ <path d="M10 18h5V5h-5v13zm-6 0h5V5H4v13zM16 5v13h5V5h-5z"></path>
148
+ </svg>`
149
+ }
150
+
151
+ ${when(config?.badge, () => html`<div class="badge" slot="button"></div>`)}
147
152
  </cosmoz-dropdown>
148
153
  `;
149
154
  customElements.define('cosmoz-omnitable-settings', component(Settings));
@@ -196,7 +196,6 @@ export const dropdown = css`
196
196
  outline: none;
197
197
  }
198
198
  cosmoz-dropdown::part(button) {
199
- --cosmoz-dropdown-button-size: 24px;
200
199
  padding: 0;
201
200
  background: transparent;
202
201
  color: inherit;
@@ -216,4 +215,15 @@ export const dropdown = css`
216
215
  height: 8px;
217
216
  border-radius: 100%;
218
217
  }
218
+ .headerDots {
219
+ align-items: center;
220
+ color: var(--cosmoz-input-color);
221
+ display: flex;
222
+ font-size: 20px;
223
+ height: 42px;
224
+ justify-content: center;
225
+ margin-left: 12px;
226
+ min-width: 30px;
227
+ transform: rotate(90deg);
228
+ }
219
229
  `;
@@ -69,6 +69,7 @@ export const useOmnitable = (host) => {
69
69
  filterFunctions,
70
70
  settingS,
71
71
  setFilterState,
72
+ hideSelectAll: host.hideSelectAll
72
73
  }),
73
74
  list: useList({
74
75
  host,
@@ -48,6 +48,12 @@ export const usePublicInterface = ({ host, visibleData, ...api }) => {
48
48
  selectItem = (item) => {
49
49
  host.shadowRoot.querySelector('#groupedList').select(item);
50
50
  },
51
+ selectAll = () => {
52
+ host.shadowRoot.querySelector('#groupedList').selectAll();
53
+ },
54
+ deselectAll = () => {
55
+ host.shadowRoot.querySelector('#groupedList').deselectAll();
56
+ },
51
57
  deselectItem = (item) => {
52
58
  host.shadowRoot.querySelector('#groupedList').deselect(item);
53
59
  },
@@ -82,7 +88,9 @@ export const usePublicInterface = ({ host, visibleData, ...api }) => {
82
88
  replaceItem,
83
89
  replaceItemAtIndex,
84
90
  selectItem,
91
+ selectAll,
85
92
  deselectItem,
93
+ deselectAll,
86
94
  isItemSelected,
87
95
  },
88
96
  [
@@ -91,7 +99,9 @@ export const usePublicInterface = ({ host, visibleData, ...api }) => {
91
99
  replaceItem,
92
100
  replaceItemAtIndex,
93
101
  selectItem,
102
+ selectAll,
94
103
  deselectItem,
104
+ deselectAll,
95
105
  isItemSelected,
96
106
  ]
97
107
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neovici/cosmoz-omnitable",
3
- "version": "12.2.1",
3
+ "version": "12.4.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"