@neovici/cosmoz-omnitable 12.7.0 → 12.7.2

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.
@@ -8,7 +8,7 @@ import {
8
8
  html, nothing
9
9
  } from 'lit-html';
10
10
  import { get } from '@polymer/polymer/lib/utils/path';
11
- import { memooize } from './lib/memoize';
11
+ import { memooize } from '@neovici/cosmoz-utils/memoize';
12
12
 
13
13
  const
14
14
  computeValue = (value, source) =>
@@ -49,7 +49,6 @@ const placement = ['bottom-right', ...defaultPlacement],
49
49
  .checked=${checked}
50
50
  @click=${onToggle}
51
51
  .indeterminate=${indeterminate}
52
- .windeterminate=${indeterminate}
53
52
  />
54
53
  </div>`;
55
54
  },
@@ -9,8 +9,9 @@ const parseIndex = (str) => {
9
9
  // eslint-disable-next-line max-lines-per-function
10
10
  export default (host) => {
11
11
  const { config } = host,
12
- { settings, setSettings } = config,
12
+ { settings, setSettings, collapsed } = config,
13
13
  meta = useMeta({
14
+ collapsed,
14
15
  settings: settings.columns,
15
16
  setSettings: useCallback(
16
17
  (columns) =>
@@ -105,19 +106,21 @@ export default (host) => {
105
106
 
106
107
  onToggle: useCallback(
107
108
  (e) => {
108
- const checked = e.target.checked,
109
- idx = parseIndex(e.target.closest('[data-index]')?.dataset.index),
110
- { settings, setSettings } = meta,
111
- newSettings = settings.slice(),
112
- setting = settings[idx],
113
- priority = e.target.windeterminate
114
- ? settings.reduce((acc, s) => Math.max(acc, s.priority), 0) + 1
115
- : setting.priority;
109
+ const { settings, setSettings } = meta,
110
+ newSettings = settings.map((column) => ({
111
+ ...column,
112
+ disabled:
113
+ column.disabled ||
114
+ meta.collapsed?.some((c) => c.name === column.name),
115
+ })),
116
+ idx = parseIndex(e.target.closest('[data-index]')?.dataset.index);
116
117
 
117
118
  newSettings.splice(idx, 1, {
118
119
  ...settings[idx],
119
- disabled: !checked,
120
- priority,
120
+ disabled: !e.target.checked,
121
+ priority: e.target.checked
122
+ ? settings.reduce((acc, s) => Math.max(acc, s.priority), 0) + 1
123
+ : settings[idx].priority,
121
124
  });
122
125
  setSettings(newSettings);
123
126
  },
@@ -1,5 +1,5 @@
1
1
  import { useEffect, useLayoutEffect, useState } from 'haunted';
2
- import { memooize } from './memoize';
2
+ import { memooize } from '@neovici/cosmoz-utils/memoize';
3
3
 
4
4
  const columnSymbol = Symbol('column'),
5
5
  verifyColumnSetup = (columns) => {
@@ -1,6 +1,6 @@
1
1
 
2
2
  import { get } from '@polymer/polymer/lib/utils/path';
3
- import { memoooize } from './memoize';
3
+ import { memoooize } from '@neovici/cosmoz-utils/memoize';
4
4
 
5
5
  export const
6
6
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neovici/cosmoz-omnitable",
3
- "version": "12.7.0",
3
+ "version": "12.7.2",
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"
@@ -67,7 +67,7 @@
67
67
  "@neovici/cosmoz-grouped-list": "^6.0.0",
68
68
  "@neovici/cosmoz-i18next": "^3.1.1",
69
69
  "@neovici/cosmoz-router": "^10.0.0",
70
- "@neovici/cosmoz-utils": "^5.0.0",
70
+ "@neovici/cosmoz-utils": "^5.12.1",
71
71
  "@neovici/nullxlsx": "^3.0.0",
72
72
  "@polymer/iron-icon": "^3.0.0",
73
73
  "@polymer/iron-icons": "^3.0.0",
package/lib/memoize.js DELETED
@@ -1,54 +0,0 @@
1
- export const
2
- memoize = fn => {
3
- let
4
- lastArg,
5
- lastResult;
6
- return function (arg) {
7
- if (lastArg === arg) {
8
- return lastResult;
9
- }
10
-
11
- const result = fn(arg);
12
- lastResult = result;
13
- lastArg = arg;
14
- return result;
15
- };
16
- },
17
-
18
- memooize = fn => {
19
- let
20
- lastArg1,
21
- lastArg2,
22
- lastResult;
23
- return function (arg1, arg2) {
24
- if (lastArg1 === arg1 && lastArg2 === arg2) {
25
- return lastResult;
26
- }
27
-
28
- const result = fn(arg1, arg2);
29
- lastResult = result;
30
- lastArg1 = arg1;
31
- lastArg2 = arg2;
32
- return result;
33
- };
34
- },
35
-
36
- memoooize = fn => {
37
- let
38
- lastArg1,
39
- lastArg2,
40
- lastArg3,
41
- lastResult;
42
- return function (arg1, arg2, arg3) {
43
- if (lastArg1 === arg1 && lastArg2 === arg2 && lastArg3 === arg3) {
44
- return lastResult;
45
- }
46
-
47
- const result = fn(arg1, arg2, arg3);
48
- lastResult = result;
49
- lastArg1 = arg1;
50
- lastArg2 = arg2;
51
- lastArg3 = arg3;
52
- return result;
53
- };
54
- };