@servicetitan/table 22.1.2 → 22.3.0
Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,27 @@
|
|
1
|
+
# v22.2.0 (Fri Jul 01 2022)
|
2
|
+
|
3
|
+
#### 🚀 Enhancement
|
4
|
+
|
5
|
+
- Table: prevent onRowClick when user misses row selection [#122](https://github.com/servicetitan/anvil-uikit-contrib/pull/122) ([@AntonMaksimenko](https://github.com/AntonMaksimenko))
|
6
|
+
|
7
|
+
#### Authors: 1
|
8
|
+
|
9
|
+
- Anton Maksimenko ([@AntonMaksimenko](https://github.com/AntonMaksimenko))
|
10
|
+
|
11
|
+
---
|
12
|
+
|
13
|
+
# v22.1.3 (Wed Jun 29 2022)
|
14
|
+
|
15
|
+
#### 🐛 Bug Fix
|
16
|
+
|
17
|
+
- Revert "Table: allow user to select table row by clicking on any spot within cell with selection" [#120](https://github.com/servicetitan/anvil-uikit-contrib/pull/120) ([@kanoshin](https://github.com/kanoshin))
|
18
|
+
|
19
|
+
#### Authors: 1
|
20
|
+
|
21
|
+
- Kirill Anoshin ([@kanoshin](https://github.com/kanoshin))
|
22
|
+
|
23
|
+
---
|
24
|
+
|
1
25
|
# v22.1.2 (Wed Jun 29 2022)
|
2
26
|
|
3
27
|
#### 🐛 Bug Fix
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"select-cell.d.ts","sourceRoot":"","sources":["../../src/select-cell/select-cell.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,EAAE,
|
1
|
+
{"version":3,"file":"select-cell.d.ts","sourceRoot":"","sources":["../../src/select-cell/select-cell.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,EAAE,EAAc,MAAM,OAAO,CAAC;AACtE,OAAO,EACH,cAAc,EACd,oBAAoB,EAEpB,aAAa,EAChB,MAAM,6BAA6B,CAAC;AAIrC,oBAAY,oBAAoB,GAAG,aAAa,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;AAEvE,UAAU,qBAAsB,SAAQ,cAAc;IAClD,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,OAAO,CAAC,EAAE,oBAAoB,CAAC;CAClC;AAED,UAAU,qBAAsB,SAAQ,oBAAoB;IACxD,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,OAAO,CAAC,EAAE,oBAAoB,CAAC;CAClC;AAED,UAAU,eAAe;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,cAAc,EAAE,cAAc,CAAC,GAAG,CAAC,CAAA;KAAE,KAAK,IAAI,CAAC;IAC3E,OAAO,CAAC,EAAE,oBAAoB,CAAC;CAClC;AAED,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CAa1C,CAAC;AAGF,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAyBtD,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAOtD,CAAC"}
|
@@ -10,33 +10,30 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
10
10
|
return t;
|
11
11
|
};
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
13
|
-
import { useCallback } from 'react';
|
14
13
|
import { Checkbox, } from '@servicetitan/design-system';
|
15
14
|
import classNames from 'classnames';
|
16
15
|
import * as Styles from './select-cell.module.css';
|
17
16
|
export const SelectCell = (_a) => {
|
18
17
|
var { selectionChange, control: Control = Checkbox } = _a, props = __rest(_a, ["selectionChange", "control"]);
|
19
|
-
const onChange =
|
18
|
+
const onChange = (_0, _1, event) => {
|
20
19
|
if (!selectionChange) {
|
21
20
|
return;
|
22
21
|
}
|
23
22
|
selectionChange({ syntheticEvent: event });
|
24
|
-
}
|
23
|
+
};
|
25
24
|
return _jsx(Control, Object.assign({ className: Styles.checkbox, onChange: onChange }, props));
|
26
25
|
};
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
selectionChange({ syntheticEvent: event });
|
31
|
-
}
|
32
|
-
}, [selectionChange, isRowSelectable]);
|
33
|
-
if (rowType === 'groupHeader') {
|
26
|
+
const stopPropagation = (e) => e.stopPropagation();
|
27
|
+
export const SelectColumnCell = (props) => {
|
28
|
+
if (props.rowType === 'groupHeader') {
|
34
29
|
return null;
|
35
30
|
}
|
36
|
-
if (rowType === 'groupFooter') {
|
31
|
+
if (props.rowType === 'groupFooter') {
|
37
32
|
return _jsx("td", {});
|
38
33
|
}
|
39
|
-
return (_jsx("td", Object.assign({ style: style,
|
34
|
+
return (_jsx("td", Object.assign({ style: props.style,
|
35
|
+
// prevent onRowClick when user misses row selection
|
36
|
+
onClick: stopPropagation, className: classNames(props.className, 'cursor-default-i') }, { children: _jsx(SelectCell, { checked: props.dataItem.selected, disabled: !props.isRowSelectable, selectionChange: props.selectionChange, indeterminate: props.dataItem.indeterminate, control: props.control }) })));
|
40
37
|
};
|
41
38
|
export const SelectHeaderCell = (props) => (_jsx(SelectCell, { checked: props.selectionValue, indeterminate: props.isSomeRowsSelected, selectionChange: props.selectionChange, control: props.control }));
|
42
39
|
//# sourceMappingURL=select-cell.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"select-cell.js","sourceRoot":"","sources":["../../src/select-cell/select-cell.tsx"],"names":[],"mappings":";;;;;;;;;;;;
|
1
|
+
{"version":3,"file":"select-cell.js","sourceRoot":"","sources":["../../src/select-cell/select-cell.tsx"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,EAGH,QAAQ,GAEX,MAAM,6BAA6B,CAAC;AACrC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,MAAM,MAAM,0BAA0B,CAAC;AAsBnD,MAAM,CAAC,MAAM,UAAU,GAAwB,CAAC,EAI9B,EAAE,EAAE;QAJ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F,KAAC,UAAU,IACP,OAAO,EAAE,KAAK,CAAC,cAAc,EAC7B,aAAa,EAAE,KAAK,CAAC,kBAAkB,EACvC,eAAe,EAAE,KAAK,CAAC,eAAe,EACtC,OAAO,EAAE,KAAK,CAAC,OAAO,GACxB,CACL,CAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@servicetitan/table",
|
3
|
-
"version": "22.
|
3
|
+
"version": "22.3.0",
|
4
4
|
"description": "",
|
5
5
|
"homepage": "https://docs.st.dev/docs/frontend/table",
|
6
6
|
"repository": {
|
@@ -36,9 +36,9 @@
|
|
36
36
|
"memoize-one": "~6.0.0"
|
37
37
|
},
|
38
38
|
"devDependencies": {
|
39
|
-
"@servicetitan/data-query": "^22.
|
39
|
+
"@servicetitan/data-query": "^22.3.0",
|
40
40
|
"@servicetitan/design-system": "~11.8.0",
|
41
|
-
"@servicetitan/form": "^22.
|
41
|
+
"@servicetitan/form": "^22.3.0",
|
42
42
|
"@servicetitan/react-ioc": "^21.6.0",
|
43
43
|
"@servicetitan/suppress-warnings": "^21.6.0",
|
44
44
|
"@types/accounting": "~0.4.2",
|
@@ -52,9 +52,9 @@
|
|
52
52
|
"react": "~17.0.2"
|
53
53
|
},
|
54
54
|
"peerDependencies": {
|
55
|
-
"@servicetitan/data-query": "^22.
|
55
|
+
"@servicetitan/data-query": "^22.3.0",
|
56
56
|
"@servicetitan/design-system": "~11.8.0",
|
57
|
-
"@servicetitan/form": "^22.
|
57
|
+
"@servicetitan/form": "^22.3.0",
|
58
58
|
"@servicetitan/react-ioc": "^20.0.0",
|
59
59
|
"@servicetitan/suppress-warnings": "^20.0.0",
|
60
60
|
"accounting": "~0.4.1",
|
@@ -71,5 +71,5 @@
|
|
71
71
|
"cli": {
|
72
72
|
"webpack": false
|
73
73
|
},
|
74
|
-
"gitHead": "
|
74
|
+
"gitHead": "9ff86a1eef1078b7a38b5fee09b7e96715617da7"
|
75
75
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { ComponentType, SyntheticEvent, FC,
|
1
|
+
import { ComponentType, SyntheticEvent, FC, MouseEvent } from 'react';
|
2
2
|
import {
|
3
3
|
TableCellProps,
|
4
4
|
TableHeaderCellProps,
|
@@ -33,59 +33,39 @@ export const SelectCell: FC<SelectCellProps> = ({
|
|
33
33
|
control: Control = Checkbox,
|
34
34
|
...props
|
35
35
|
}: SelectCellProps) => {
|
36
|
-
const onChange =
|
37
|
-
(
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
},
|
43
|
-
[selectionChange]
|
44
|
-
);
|
36
|
+
const onChange = (_0: never, _1: boolean, event: SyntheticEvent<HTMLInputElement>) => {
|
37
|
+
if (!selectionChange) {
|
38
|
+
return;
|
39
|
+
}
|
40
|
+
selectionChange({ syntheticEvent: event });
|
41
|
+
};
|
45
42
|
|
46
43
|
return <Control className={Styles.checkbox} onChange={onChange} {...props} />;
|
47
44
|
};
|
48
45
|
|
49
|
-
|
50
|
-
|
51
|
-
rowType
|
52
|
-
dataItem,
|
53
|
-
control,
|
54
|
-
isRowSelectable,
|
55
|
-
selectionChange,
|
56
|
-
className,
|
57
|
-
}: SelectColumnCellProps) => {
|
58
|
-
const onSelectionChange = useCallback(
|
59
|
-
(event: SyntheticEvent<HTMLTableCellElement>) => {
|
60
|
-
if (isRowSelectable && selectionChange) {
|
61
|
-
selectionChange({ syntheticEvent: event });
|
62
|
-
}
|
63
|
-
},
|
64
|
-
[selectionChange, isRowSelectable]
|
65
|
-
);
|
66
|
-
|
67
|
-
if (rowType === 'groupHeader') {
|
46
|
+
const stopPropagation = (e: MouseEvent<HTMLTableCellElement>) => e.stopPropagation();
|
47
|
+
export const SelectColumnCell: FC<SelectColumnCellProps> = (props: SelectColumnCellProps) => {
|
48
|
+
if (props.rowType === 'groupHeader') {
|
68
49
|
return null;
|
69
50
|
}
|
70
51
|
|
71
|
-
if (rowType === 'groupFooter') {
|
52
|
+
if (props.rowType === 'groupFooter') {
|
72
53
|
return <td />;
|
73
54
|
}
|
74
55
|
|
75
56
|
return (
|
76
57
|
<td
|
77
|
-
style={style}
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
)}
|
82
|
-
onClick={onSelectionChange}
|
58
|
+
style={props.style}
|
59
|
+
// prevent onRowClick when user misses row selection
|
60
|
+
onClick={stopPropagation}
|
61
|
+
className={classNames(props.className, 'cursor-default-i')}
|
83
62
|
>
|
84
63
|
<SelectCell
|
85
|
-
checked={dataItem.selected}
|
86
|
-
disabled={!isRowSelectable}
|
87
|
-
|
88
|
-
|
64
|
+
checked={props.dataItem.selected}
|
65
|
+
disabled={!props.isRowSelectable}
|
66
|
+
selectionChange={props.selectionChange}
|
67
|
+
indeterminate={props.dataItem.indeterminate}
|
68
|
+
control={props.control}
|
89
69
|
/>
|
90
70
|
</td>
|
91
71
|
);
|