pixel-react 1.1.5 → 1.1.6
Sign up to get free protection for your applications and to get access to all the features.
- package/.yarn/install-state.gz +0 -0
- package/lib/components/TableTree/TableTree.d.ts +4 -2
- package/lib/index.d.ts +4 -2
- package/lib/index.esm.js +95 -392
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +95 -392
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/rollup.config.mjs +5 -1
- package/src/components/TableTree/TableTree.stories.tsx +8 -1
- package/src/components/TableTree/TableTree.tsx +25 -3
- package/src/index.ts +0 -6
- package/lib/components/AddButton/AddButton.d.ts +0 -5
- package/lib/components/AddButton/AddButton.stories.d.ts +0 -6
- package/lib/components/AddButton/index.d.ts +0 -1
- package/lib/components/AddButton/types.d.ts +0 -4
- package/lib/utils/find/findAndInsert.d.ts +0 -7
- package/lib/utils/find/findAndInsert.stories.d.ts +0 -7
package/package.json
CHANGED
package/rollup.config.mjs
CHANGED
@@ -14,6 +14,7 @@ const packageJson = requireFile('./package.json');
|
|
14
14
|
export default [
|
15
15
|
{
|
16
16
|
input: 'src/index.ts',
|
17
|
+
context: 'window',
|
17
18
|
output: [
|
18
19
|
{
|
19
20
|
file: packageJson.main, // CJS output
|
@@ -31,7 +32,9 @@ export default [
|
|
31
32
|
plugins: [
|
32
33
|
peerDepsExternal(),
|
33
34
|
resolve(),
|
34
|
-
commonjs(
|
35
|
+
commonjs({
|
36
|
+
transformMixedEsModules: true,
|
37
|
+
}),
|
35
38
|
typescript(),
|
36
39
|
postcss({
|
37
40
|
extensions: ['.scss'],
|
@@ -49,6 +52,7 @@ export default [
|
|
49
52
|
],
|
50
53
|
},
|
51
54
|
{
|
55
|
+
context: 'window',
|
52
56
|
input: 'lib/index.d.ts',
|
53
57
|
output: [
|
54
58
|
{ file: 'lib/index.d.ts', format: 'es', inlineDynamicImports: true },
|
@@ -67,7 +67,14 @@ const createTilteAndAction = (row: any): JSX.Element => {
|
|
67
67
|
|
68
68
|
export const Default: Story = {
|
69
69
|
args: {
|
70
|
-
|
70
|
+
select: 'radio',
|
71
|
+
onChange: (e: any, node: any) => {
|
72
|
+
e.preventDefault();
|
73
|
+
e.stopPropagation();
|
74
|
+
|
75
|
+
console.log(node, '------------', e);
|
76
|
+
},
|
77
|
+
selected: ['MOD1003'],
|
71
78
|
treeData,
|
72
79
|
columnsData: [
|
73
80
|
{
|
@@ -7,6 +7,7 @@ import { checkEmpty } from '../../utils/checkEmpty/checkEmpty';
|
|
7
7
|
|
8
8
|
import Checkbox from '../Checkbox';
|
9
9
|
import './TableTree.scss';
|
10
|
+
import RadioButton from '../RadioButton';
|
10
11
|
|
11
12
|
interface ColumnDataProps {
|
12
13
|
name: string;
|
@@ -22,20 +23,24 @@ interface ObjectProps {
|
|
22
23
|
}
|
23
24
|
|
24
25
|
interface TableTreeProps {
|
25
|
-
|
26
|
+
select: 'checkbox' | 'radio' | 'none';
|
26
27
|
columnsData: Array<ColumnDataProps>;
|
27
28
|
treeData: Array<ObjectProps>;
|
28
29
|
onClick?: (
|
29
30
|
event: React.MouseEvent<HTMLDivElement, MouseEvent>,
|
30
31
|
data: any
|
31
32
|
) => void;
|
33
|
+
onChange?: (e: any, node: any) => void;
|
34
|
+
selected: Array<string>;
|
32
35
|
}
|
33
36
|
|
34
37
|
const TableTree = ({
|
35
38
|
columnsData,
|
36
39
|
treeData,
|
37
|
-
|
40
|
+
select,
|
38
41
|
onClick = () => {},
|
42
|
+
onChange,
|
43
|
+
selected,
|
39
44
|
}: TableTreeProps) => {
|
40
45
|
const [expandedNodes, setExpandedNodes] = useState<Set<ObjectProps>>(
|
41
46
|
new Set()
|
@@ -89,6 +94,12 @@ const TableTree = ({
|
|
89
94
|
|
90
95
|
const isExpanded = expandedNodes.has(node);
|
91
96
|
|
97
|
+
const handleCheckBoxChange = (e, node) => {
|
98
|
+
if (onChange) {
|
99
|
+
onChange(e, node);
|
100
|
+
}
|
101
|
+
};
|
102
|
+
|
92
103
|
useLayoutEffect(() => {
|
93
104
|
if (nodeRef.current) {
|
94
105
|
const observer = new ResizeObserver(() => {
|
@@ -143,7 +154,18 @@ const TableTree = ({
|
|
143
154
|
style={{ fontWeight: node.folder ? 600 : 400 }}
|
144
155
|
onClick={(event) => onClick(event, node)}
|
145
156
|
>
|
146
|
-
{
|
157
|
+
{select === 'checkbox' && (
|
158
|
+
<Checkbox
|
159
|
+
checked={selected.includes(node.key)}
|
160
|
+
onChange={(e) => handleCheckBoxChange(e, node)}
|
161
|
+
/>
|
162
|
+
)}
|
163
|
+
{select === 'radio' && (
|
164
|
+
<RadioButton
|
165
|
+
checked={selected.includes(node.key)}
|
166
|
+
onChange={(e) => handleCheckBoxChange(e, node)}
|
167
|
+
/>
|
168
|
+
)}
|
147
169
|
{prepareData(node, column)}
|
148
170
|
</div>
|
149
171
|
</td>
|
package/src/index.ts
CHANGED
@@ -55,19 +55,13 @@ import {
|
|
55
55
|
getExtension,
|
56
56
|
getExtensionWithPeriod,
|
57
57
|
} from './utils/getExtension/getExtension';
|
58
|
-
|
59
58
|
import { findAndInsert } from './utils/findAndInsert/findAndInsert';
|
60
59
|
import { ffid } from './utils/ffID/ffid';
|
61
|
-
|
62
60
|
import { debounce } from './utils/debounce/debounce';
|
63
61
|
import { compareArrays } from './utils/compareArrays/compareArrays';
|
64
|
-
|
65
62
|
import { compareObjects } from './utils/compareObjects/compareObjects';
|
66
|
-
|
67
63
|
import { getEncryptedData } from './utils/getEncryptedData/getEncryptedData';
|
68
|
-
|
69
64
|
import { throttle } from './utils/throttle/throttle';
|
70
|
-
|
71
65
|
import { truncateText } from './utils/truncateText/truncateText';
|
72
66
|
|
73
67
|
export {
|
@@ -1 +0,0 @@
|
|
1
|
-
export { default } from './AddButton';
|
@@ -1,7 +0,0 @@
|
|
1
|
-
export type AnyObject = {
|
2
|
-
id: number;
|
3
|
-
[key: string]: any;
|
4
|
-
};
|
5
|
-
export declare function findAndInsert<T extends AnyObject>(data: T[], key: keyof T, targetId: number, newEntry: T, insertPosition: 'above' | 'below' | 'replace', childrenKey?: string): {
|
6
|
-
updatedArray: T[];
|
7
|
-
} | null;
|