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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pixel-react",
3
3
  "description": "Great for pixel-perfect, design-focused components in React",
4
- "version": "1.1.5",
4
+ "version": "1.1.6",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.esm.js",
7
7
  "types": "lib/index.d.ts",
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
- withCheckBox: false,
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
- withCheckBox: boolean;
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
- withCheckBox,
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
- {withCheckBox && <Checkbox />}
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,5 +0,0 @@
1
- import React from 'react';
2
- import './AddButton.scss';
3
- import { AddButtonProps } from './types';
4
- declare const AddButton: React.FC<AddButtonProps>;
5
- export default AddButton;
@@ -1,6 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/react';
2
- import AddButton from './AddButton';
3
- declare const meta: Meta<typeof AddButton>;
4
- type Story = StoryObj<typeof AddButton>;
5
- export declare const PrimaryAddButton: Story;
6
- export default meta;
@@ -1 +0,0 @@
1
- export { default } from './AddButton';
@@ -1,4 +0,0 @@
1
- export interface AddButtonProps {
2
- name: string;
3
- onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
4
- }
@@ -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;
@@ -1,7 +0,0 @@
1
- import { findAndInsert } from './findAndInsert';
2
- declare const _default: {
3
- title: string;
4
- component: typeof findAndInsert;
5
- };
6
- export default _default;
7
- export declare const InteractivePlayground: () => import("react/jsx-runtime").JSX.Element;