@react-fabric/data 1.0.0-beta.4 → 1.0.0-beta.40
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.
- package/{src/histogram/Histogram.module.css → css/_histogram.css} +16 -13
- package/css/styles.css +24 -0
- package/dist/cjs/checklist/CheckList.js +25 -16
- package/dist/cjs/histogram/Histogram.js +20 -10
- package/dist/cjs/hooks/usePagination.js +7 -4
- package/dist/cjs/json/JsonViewer.js +40 -27
- package/dist/cjs/table/BodyCell.js +38 -5
- package/dist/cjs/table/BodyRow.js +107 -0
- package/dist/cjs/table/CheckboxCell.js +1 -1
- package/dist/cjs/table/HeaderCell.js +29 -36
- package/dist/cjs/table/Table.js +105 -67
- package/dist/cjs/table/useResizer.js +4 -4
- package/dist/cjs/table/useVirtualTable.js +118 -17
- package/dist/cjs/tree/TreeNode.js +44 -24
- package/dist/cjs/tree/TreePanel.js +28 -10
- package/dist/cjs/tree/useTree.js +96 -14
- package/dist/cjs/tree/utils.js +20 -5
- package/dist/cjs/virtual/Gallery.js +43 -29
- package/dist/cjs/virtual/List.js +43 -31
- package/dist/esm/checklist/CheckList.js +27 -18
- package/dist/esm/histogram/Histogram.js +21 -11
- package/dist/esm/hooks/usePagination.js +7 -4
- package/dist/esm/json/JsonViewer.js +41 -28
- package/dist/esm/table/BodyCell.js +38 -5
- package/dist/esm/table/BodyRow.js +107 -0
- package/dist/esm/table/CheckboxCell.js +1 -1
- package/dist/esm/table/HeaderCell.js +30 -37
- package/dist/esm/table/Table.js +107 -69
- package/dist/esm/table/useResizer.js +4 -4
- package/dist/esm/table/useVirtualTable.js +120 -19
- package/dist/esm/tree/TreeNode.js +46 -26
- package/dist/esm/tree/TreePanel.js +28 -10
- package/dist/esm/tree/useTree.js +98 -16
- package/dist/esm/tree/utils.js +20 -5
- package/dist/esm/virtual/Gallery.js +43 -29
- package/dist/esm/virtual/List.js +43 -31
- package/dist/types/checklist/CheckList.d.ts +2 -2
- package/dist/types/histogram/Histogram.d.ts +3 -3
- package/dist/types/index.d.ts +1 -1
- package/dist/types/table/AddColumn.d.ts +2 -2
- package/dist/types/table/BodyCell.d.ts +4 -3
- package/dist/types/table/BodyRow.d.ts +20 -0
- package/dist/types/table/EmptyCell.d.ts +2 -2
- package/dist/types/table/HeaderCell.d.ts +2 -2
- package/dist/types/table/Table.d.ts +1 -1
- package/dist/types/table/types.d.ts +17 -6
- package/dist/types/table/useTableColumns.d.ts +6 -6
- package/dist/types/table/useVirtualTable.d.ts +20 -5
- package/dist/types/tree/TreeNode.d.ts +1 -1
- package/dist/types/tree/TreePanel.d.ts +1 -1
- package/dist/types/tree/types.d.ts +25 -5
- package/dist/types/tree/useTree.d.ts +2 -9
- package/dist/types/tree/utils.d.ts +4 -1
- package/dist/types/virtual/Gallery.d.ts +12 -4
- package/dist/types/virtual/List.d.ts +7 -3
- package/package.json +10 -7
- package/src/checklist/CheckList.tsx +81 -77
- package/src/histogram/Histogram.tsx +17 -11
- package/src/hooks/usePagination.tsx +13 -7
- package/src/index.ts +1 -1
- package/src/json/JsonViewer.tsx +45 -35
- package/src/table/AddColumn.tsx +2 -2
- package/src/table/BodyCell.tsx +34 -5
- package/src/table/BodyRow.tsx +143 -0
- package/src/table/CheckboxCell.tsx +1 -1
- package/src/table/EmptyCell.tsx +2 -2
- package/src/table/HeaderCell.tsx +27 -13
- package/src/table/Table.tsx +141 -73
- package/src/table/types.ts +20 -5
- package/src/table/useResizer.ts +5 -3
- package/src/table/useTableColumns.ts +7 -7
- package/src/table/useVirtualTable.ts +143 -28
- package/src/tree/TreeNode.tsx +90 -56
- package/src/tree/TreePanel.tsx +23 -3
- package/src/tree/types.ts +32 -4
- package/src/tree/useTree.ts +102 -23
- package/src/tree/utils.ts +23 -8
- package/src/virtual/Gallery.tsx +46 -35
- package/src/virtual/List.tsx +40 -27
- package/dist/cjs/histogram/Histogram.module.css +0 -1
- package/dist/esm/histogram/Histogram.module.css +0 -1
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import { type InternalNode, type
|
|
2
|
-
export declare const useTree: <T extends KeyValue<any>>({ items, checked, selected, matcher, onSelect, onChecked, }: {
|
|
3
|
-
items?: Array<TreeNodeType<T>>;
|
|
4
|
-
selected?: string;
|
|
5
|
-
checked?: string[];
|
|
6
|
-
onSelect?: (id: string) => void;
|
|
7
|
-
onChecked?: (leafs: string[], nodes: string[]) => void;
|
|
8
|
-
matcher?: (data: T, query: string) => boolean;
|
|
9
|
-
}) => {
|
|
1
|
+
import { type InternalNode, type TreePanelProps } from "./types";
|
|
2
|
+
export declare const useTree: <T extends KeyValue<any>>({ items, checked, selected, sorter, matcher, onLoad, onQuery, onSelect, onChecked, defaultExpanded, onExpandToggle, }: Partial<TreePanelProps<T>>) => {
|
|
10
3
|
tree: InternalNode[];
|
|
11
4
|
toggleExpand: (id: string) => void;
|
|
12
5
|
expandAll: () => void;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { type InternalNode, type TreeNodeType } from "./types";
|
|
2
|
-
export declare const refactorTree: (nodes: TreeNodeType[],
|
|
2
|
+
export declare const refactorTree: (nodes: TreeNodeType[], { sorter, defaultExpanded, }: {
|
|
3
|
+
sorter?: any;
|
|
4
|
+
defaultExpanded?: string[];
|
|
5
|
+
}, options?: {
|
|
3
6
|
level: number;
|
|
4
7
|
parent?: string;
|
|
5
8
|
}) => InternalNode[];
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { type TestProps } from "@react-fabric/core/dist/types/types";
|
|
1
2
|
import { type ReactElement, type Ref } from "react";
|
|
2
3
|
export interface VirtualGalleryRef {
|
|
3
4
|
scrollToItem: (index: number) => void;
|
|
4
5
|
hilight: (index: number) => void;
|
|
5
6
|
unhilight: () => void;
|
|
6
7
|
}
|
|
7
|
-
export interface VirtualGalleryProps<T> {
|
|
8
|
+
export interface VirtualGalleryProps<T> extends TestProps {
|
|
8
9
|
children: (props: {
|
|
9
|
-
|
|
10
|
+
item: T;
|
|
10
11
|
index: number;
|
|
11
12
|
isLast: boolean;
|
|
12
13
|
}) => ReactElement;
|
|
@@ -23,6 +24,12 @@ export interface VirtualGalleryProps<T> {
|
|
|
23
24
|
* default item width
|
|
24
25
|
*/
|
|
25
26
|
defaultWidth?: number;
|
|
27
|
+
/**
|
|
28
|
+
* full width list
|
|
29
|
+
*/
|
|
30
|
+
fullWidth?: boolean;
|
|
31
|
+
maxWidth?: string | number;
|
|
32
|
+
minWidth?: string | number;
|
|
26
33
|
/**
|
|
27
34
|
* padding
|
|
28
35
|
*/
|
|
@@ -31,6 +38,7 @@ export interface VirtualGalleryProps<T> {
|
|
|
31
38
|
* data list
|
|
32
39
|
*/
|
|
33
40
|
items: T[];
|
|
41
|
+
total?: number;
|
|
34
42
|
/**
|
|
35
43
|
* loading state
|
|
36
44
|
*/
|
|
@@ -43,13 +51,13 @@ export interface VirtualGalleryProps<T> {
|
|
|
43
51
|
/**
|
|
44
52
|
* load more callback
|
|
45
53
|
*/
|
|
46
|
-
onLoadMore?: () => void;
|
|
54
|
+
onLoadMore?: (page?: number) => void;
|
|
47
55
|
/**
|
|
48
56
|
* scroll handler
|
|
49
57
|
*/
|
|
50
58
|
onScroll?: (top: number) => void;
|
|
51
59
|
}
|
|
52
60
|
export declare const VirtualGallery: {
|
|
53
|
-
<T extends KeyValue<any>>({ items, children, columns, padding, defaultHeight: height, defaultWidth: width, hideScroller, initialScroll, loading, onLoadMore, onScroll, galleryRef, }: VirtualGalleryProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
61
|
+
<T extends KeyValue<any>>({ items, children, columns, fullWidth, maxWidth, minWidth, total, padding, defaultHeight: height, defaultWidth: width, hideScroller, initialScroll, loading, onLoadMore, onScroll, galleryRef, ...aria }: VirtualGalleryProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
54
62
|
displayName: string;
|
|
55
63
|
};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { type TestProps } from "@react-fabric/core/dist/types/types";
|
|
1
2
|
import { type ReactElement, type Ref } from "react";
|
|
2
3
|
export interface VirtualListRef {
|
|
3
4
|
scrollToItem: (index: number) => void;
|
|
4
5
|
hilight: (index: number) => void;
|
|
5
6
|
unhilight: () => void;
|
|
6
7
|
}
|
|
7
|
-
export interface VirtualListProps<T> {
|
|
8
|
+
export interface VirtualListProps<T> extends TestProps {
|
|
8
9
|
children: (props: {
|
|
9
|
-
|
|
10
|
+
item: T;
|
|
10
11
|
index: number;
|
|
11
12
|
isLast: boolean;
|
|
12
13
|
}) => ReactElement;
|
|
@@ -23,6 +24,8 @@ export interface VirtualListProps<T> {
|
|
|
23
24
|
* full width list
|
|
24
25
|
*/
|
|
25
26
|
fullWidth?: boolean;
|
|
27
|
+
maxWidth?: string | number;
|
|
28
|
+
minWidth?: string | number;
|
|
26
29
|
/**
|
|
27
30
|
* padding
|
|
28
31
|
*/
|
|
@@ -35,6 +38,7 @@ export interface VirtualListProps<T> {
|
|
|
35
38
|
* data list
|
|
36
39
|
*/
|
|
37
40
|
items: T[];
|
|
41
|
+
total?: number;
|
|
38
42
|
initialScroll?: number;
|
|
39
43
|
/**
|
|
40
44
|
* loading state
|
|
@@ -54,6 +58,6 @@ export interface VirtualListProps<T> {
|
|
|
54
58
|
onScroll?: (top: number) => void;
|
|
55
59
|
}
|
|
56
60
|
export declare const VirtualList: {
|
|
57
|
-
<T extends KeyValue<any>>({ items, children, fullWidth, padding, orientation, defaultHeight: height, defaultWidth: width, hideScroller, initialScroll, loading, onLoadMore, onScroll, listRef, }: VirtualListProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
61
|
+
<T extends KeyValue<any>>({ items, total, children, fullWidth, maxWidth, minWidth, padding, orientation, defaultHeight: height, defaultWidth: width, hideScroller, initialScroll, loading, onLoadMore, onScroll, listRef, ...aria }: VirtualListProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
58
62
|
displayName: string;
|
|
59
63
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-fabric/data",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.40",
|
|
4
4
|
"description": "RUF: Data package",
|
|
5
5
|
"author": "Adarsh Pastakia <adarshpastakia@outlook.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -11,9 +11,11 @@
|
|
|
11
11
|
"types": "dist/types/index.d.ts",
|
|
12
12
|
"directories": {
|
|
13
13
|
"src": "src",
|
|
14
|
+
"styles": "css",
|
|
14
15
|
"test": "tests"
|
|
15
16
|
},
|
|
16
17
|
"files": [
|
|
18
|
+
"css",
|
|
17
19
|
"src",
|
|
18
20
|
"dist"
|
|
19
21
|
],
|
|
@@ -33,9 +35,10 @@
|
|
|
33
35
|
"watch": "npm-run-all -p watch:rollup watch:dts"
|
|
34
36
|
},
|
|
35
37
|
"dependencies": {
|
|
36
|
-
"@react-fabric/core": "^1.0.0-beta.
|
|
37
|
-
"@react-fabric/
|
|
38
|
-
"@react-fabric/
|
|
38
|
+
"@react-fabric/core": "^1.0.0-beta.40",
|
|
39
|
+
"@react-fabric/date": "^1.0.0-beta.40",
|
|
40
|
+
"@react-fabric/form": "^1.0.0-beta.40",
|
|
41
|
+
"@react-fabric/utilities": "^1.0.0-beta.40",
|
|
39
42
|
"@tanstack/react-virtual": "^3.8.6",
|
|
40
43
|
"classnames": "^2.5.1",
|
|
41
44
|
"color": "^4.2.3",
|
|
@@ -43,13 +46,13 @@
|
|
|
43
46
|
},
|
|
44
47
|
"peerDependencies": {
|
|
45
48
|
"i18next": "^23.15.1",
|
|
46
|
-
"react": "
|
|
47
|
-
"react-dom": "
|
|
49
|
+
"react": "^19.0.0",
|
|
50
|
+
"react-dom": "^19.0.0",
|
|
48
51
|
"react-i18next": "^15.0.2"
|
|
49
52
|
},
|
|
50
53
|
"engines": {
|
|
51
54
|
"node": ">=18.12.0",
|
|
52
55
|
"npm": ">=8.19.0"
|
|
53
56
|
},
|
|
54
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "ede05c84683697d85e28a0ae380cb9b74d693f51"
|
|
55
58
|
}
|
|
@@ -22,12 +22,14 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
import { Badge, CoreIcons, EmptyContent, Icon } from "@react-fabric/core";
|
|
25
|
-
import {
|
|
25
|
+
import {
|
|
26
|
+
type BadgeType,
|
|
27
|
+
type TestProps,
|
|
28
|
+
} from "@react-fabric/core/dist/types/types";
|
|
26
29
|
import { isString } from "@react-fabric/utilities";
|
|
27
30
|
import {
|
|
28
31
|
Fragment,
|
|
29
32
|
isValidElement,
|
|
30
|
-
memo,
|
|
31
33
|
useEffect,
|
|
32
34
|
useMemo,
|
|
33
35
|
useState,
|
|
@@ -47,7 +49,7 @@ export interface CheckListItem extends KeyValue {
|
|
|
47
49
|
isDisabled?: boolean;
|
|
48
50
|
}
|
|
49
51
|
|
|
50
|
-
export interface CheckListProps extends SelectableProps {
|
|
52
|
+
export interface CheckListProps extends SelectableProps, TestProps {
|
|
51
53
|
/**
|
|
52
54
|
* list items
|
|
53
55
|
*/
|
|
@@ -73,84 +75,79 @@ const CheckItem: FC<
|
|
|
73
75
|
selected?: number;
|
|
74
76
|
allowNegative?: boolean;
|
|
75
77
|
}
|
|
76
|
-
> =
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
78
|
+
> = ({
|
|
79
|
+
id,
|
|
80
|
+
allowNegative,
|
|
81
|
+
selected,
|
|
82
|
+
icon,
|
|
83
|
+
label,
|
|
84
|
+
isDisabled,
|
|
85
|
+
onClick,
|
|
86
|
+
badge,
|
|
87
|
+
...aria
|
|
88
|
+
}: Omit<CheckListItem, "selected"> & {
|
|
89
|
+
selected?: number;
|
|
90
|
+
allowNegative?: boolean;
|
|
91
|
+
}) => {
|
|
92
|
+
return (
|
|
93
|
+
<div
|
|
94
|
+
role="none"
|
|
95
|
+
className="ax-checkList__item"
|
|
96
|
+
data-disabled={isDisabled}
|
|
97
|
+
onClick={() => onClick(id, false)}
|
|
98
|
+
onContextMenu={(e) => [
|
|
99
|
+
allowNegative && onClick(id, true),
|
|
100
|
+
e.preventDefault(),
|
|
101
|
+
]}
|
|
102
|
+
{...aria}
|
|
103
|
+
>
|
|
104
|
+
{!allowNegative && (
|
|
105
|
+
<Icon
|
|
106
|
+
data-type="checkbox"
|
|
107
|
+
className="ax-checkList__checkbox"
|
|
108
|
+
data-selected={selected === 1}
|
|
109
|
+
icon={selected ? CoreIcons.checkboxInt : CoreIcons.checkboxOff}
|
|
110
|
+
/>
|
|
111
|
+
)}
|
|
112
|
+
{allowNegative && (
|
|
113
|
+
<Fragment>
|
|
102
114
|
<Icon
|
|
103
|
-
data-type="
|
|
115
|
+
data-type="multiple"
|
|
104
116
|
className="ax-checkList__checkbox"
|
|
105
|
-
|
|
106
|
-
|
|
117
|
+
icon={
|
|
118
|
+
selected === 1
|
|
119
|
+
? CoreIcons.expand
|
|
120
|
+
: selected === -1
|
|
121
|
+
? CoreIcons.collapse
|
|
122
|
+
: CoreIcons.checkboxOff
|
|
123
|
+
}
|
|
124
|
+
data-selected={selected}
|
|
107
125
|
/>
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
126
|
+
<div className="ax-checkList__checkbox">
|
|
127
|
+
<Icon
|
|
128
|
+
data-type="positive"
|
|
129
|
+
onClick={(e) => [(onClick(id, false), e.stopPropagation())]}
|
|
130
|
+
icon={selected === 1 ? CoreIcons.expandActive : CoreIcons.expand}
|
|
131
|
+
data-selected={selected === 1}
|
|
132
|
+
/>
|
|
111
133
|
<Icon
|
|
112
|
-
data-type="
|
|
113
|
-
|
|
134
|
+
data-type="negative"
|
|
135
|
+
onClick={(e) => [(onClick(id, true), e.stopPropagation())]}
|
|
114
136
|
icon={
|
|
115
|
-
selected === 1
|
|
116
|
-
? CoreIcons.expand
|
|
117
|
-
: selected === -1
|
|
118
|
-
? CoreIcons.collapse
|
|
119
|
-
: CoreIcons.checkboxOff
|
|
137
|
+
selected === -1 ? CoreIcons.collapseActive : CoreIcons.collapse
|
|
120
138
|
}
|
|
121
|
-
data-selected={selected}
|
|
139
|
+
data-selected={selected === -1}
|
|
122
140
|
/>
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
data-type="negative"
|
|
134
|
-
onClick={(e) => [(onClick(id, true), e.stopPropagation())]}
|
|
135
|
-
icon={
|
|
136
|
-
selected === -1
|
|
137
|
-
? CoreIcons.collapseActive
|
|
138
|
-
: CoreIcons.collapse
|
|
139
|
-
}
|
|
140
|
-
data-selected={selected === -1}
|
|
141
|
-
/>
|
|
142
|
-
</div>
|
|
143
|
-
</Fragment>
|
|
144
|
-
)}
|
|
145
|
-
{isValidElement(icon) && icon}
|
|
146
|
-
{isString(icon) && <Icon icon={icon} />}
|
|
147
|
-
<label>{label}</label>
|
|
148
|
-
<Badge {...badge} />
|
|
149
|
-
</div>
|
|
150
|
-
);
|
|
151
|
-
},
|
|
152
|
-
);
|
|
153
|
-
CheckItem.displayName = "CheckItem";
|
|
141
|
+
</div>
|
|
142
|
+
</Fragment>
|
|
143
|
+
)}
|
|
144
|
+
{isValidElement(icon) && icon}
|
|
145
|
+
{isString(icon) && <Icon icon={icon} />}
|
|
146
|
+
<label>{label}</label>
|
|
147
|
+
<Badge {...badge} />
|
|
148
|
+
</div>
|
|
149
|
+
);
|
|
150
|
+
};
|
|
154
151
|
|
|
155
152
|
export const CheckList: FC<CheckListProps> = ({
|
|
156
153
|
items = [],
|
|
@@ -158,12 +155,19 @@ export const CheckList: FC<CheckListProps> = ({
|
|
|
158
155
|
allowNegative,
|
|
159
156
|
emptyMessage,
|
|
160
157
|
sortItems = true,
|
|
161
|
-
|
|
158
|
+
selected,
|
|
159
|
+
nonselected,
|
|
160
|
+
onChange,
|
|
161
|
+
onClick,
|
|
162
|
+
...aria
|
|
162
163
|
}: CheckListProps) => {
|
|
163
164
|
const { t } = useTranslation("data");
|
|
164
165
|
const { selection, toggleSelection } = useSelectableList({
|
|
165
166
|
items,
|
|
166
|
-
|
|
167
|
+
selected,
|
|
168
|
+
nonselected,
|
|
169
|
+
onChange,
|
|
170
|
+
onClick,
|
|
167
171
|
});
|
|
168
172
|
const [showMore, setShowMore] = useState(false);
|
|
169
173
|
|
|
@@ -186,7 +190,7 @@ export const CheckList: FC<CheckListProps> = ({
|
|
|
186
190
|
}, [items, selection, maxCount, showMore, sortItems]);
|
|
187
191
|
|
|
188
192
|
return (
|
|
189
|
-
<div
|
|
193
|
+
<div {...aria}>
|
|
190
194
|
{listItems.map((item, index) => (
|
|
191
195
|
<CheckItem
|
|
192
196
|
{...item}
|
|
@@ -31,12 +31,12 @@ import {
|
|
|
31
31
|
import {
|
|
32
32
|
type ColorType,
|
|
33
33
|
type PaletteType,
|
|
34
|
+
type TestProps,
|
|
34
35
|
} from "@react-fabric/core/dist/types/types";
|
|
35
|
-
import { compareValues, Format } from "@react-fabric/utilities";
|
|
36
|
+
import { compareValues, Format, isColor } from "@react-fabric/utilities";
|
|
36
37
|
import classNames from "classnames";
|
|
37
38
|
import { useMemo } from "react";
|
|
38
39
|
import { useTranslation } from "react-i18next";
|
|
39
|
-
import classes from "./Histogram.module.css";
|
|
40
40
|
|
|
41
41
|
const emptyIcon =
|
|
42
42
|
"M20.84 22.73L11.11 13H3V11H9.11L6.11 8H3V6H4.11L1.11 3L2.39 1.73L22.11 21.46L20.84 22.73M15 11H14.2L15 11.8V11M21 8V6H9.2L11.2 8H21M3 18H9V16H3V18Z";
|
|
@@ -49,7 +49,7 @@ interface HistogramItem {
|
|
|
49
49
|
disabled?: boolean;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
export interface HistogramProps {
|
|
52
|
+
export interface HistogramProps extends TestProps {
|
|
53
53
|
/**
|
|
54
54
|
* histogram items list
|
|
55
55
|
*/
|
|
@@ -83,11 +83,12 @@ export interface HistogramProps {
|
|
|
83
83
|
export const Histogram = ({
|
|
84
84
|
items = [],
|
|
85
85
|
total,
|
|
86
|
-
color = "primary",
|
|
86
|
+
color = "primary-500",
|
|
87
87
|
sortBy = "count",
|
|
88
88
|
emptyTitle,
|
|
89
89
|
emptyMessage,
|
|
90
90
|
onClick,
|
|
91
|
+
...aria
|
|
91
92
|
}: HistogramProps) => {
|
|
92
93
|
const { t } = useTranslation("data");
|
|
93
94
|
const maxTotal = useMemo(() => {
|
|
@@ -103,10 +104,11 @@ export const Histogram = ({
|
|
|
103
104
|
|
|
104
105
|
return (
|
|
105
106
|
<div
|
|
106
|
-
className={
|
|
107
|
+
className={"fabric-histogram from-0% to-100%"}
|
|
108
|
+
{...aria}
|
|
107
109
|
style={
|
|
108
110
|
{
|
|
109
|
-
"--color": `var(
|
|
111
|
+
"--color": isColor(color) ? color : `var(--color-${color})`,
|
|
110
112
|
} as AnyObject
|
|
111
113
|
}
|
|
112
114
|
>
|
|
@@ -124,15 +126,17 @@ export const Histogram = ({
|
|
|
124
126
|
data-disabled={item.count === 0 || item.disabled}
|
|
125
127
|
className={classNames(
|
|
126
128
|
"relative cursor-pointer flex flex-nowrap items-center select-none overflow-hidden min-h-6 my-px",
|
|
127
|
-
|
|
128
|
-
(item.count === 0 || item.disabled) &&
|
|
129
|
+
"fabric-histoLabel",
|
|
130
|
+
((item.total ?? item.count) === 0 || item.disabled) &&
|
|
131
|
+
"pointer-events-none",
|
|
129
132
|
)}
|
|
133
|
+
data-testid={item.id}
|
|
130
134
|
onClick={(e) => [onClick?.(item.id), e.stopPropagation()]}
|
|
131
135
|
>
|
|
132
136
|
<div
|
|
133
137
|
className={classNames(
|
|
134
|
-
"absolute z-0 inset-0 opacity-50 min-w-2 ltr:bg-gradient-to-r rtl:bg-gradient-to-l
|
|
135
|
-
|
|
138
|
+
"absolute z-0 inset-0 opacity-50 min-w-2 ltr:bg-gradient-to-r rtl:bg-gradient-to-l",
|
|
139
|
+
"fabric-histoBar",
|
|
136
140
|
)}
|
|
137
141
|
style={{
|
|
138
142
|
width: `${Math.min(item.count / maxTotal, 1) * 100}%`,
|
|
@@ -145,6 +149,7 @@ export const Histogram = ({
|
|
|
145
149
|
key="negative"
|
|
146
150
|
color="danger"
|
|
147
151
|
size="sm"
|
|
152
|
+
stopPropagation
|
|
148
153
|
icon={CoreIcons.funnelMinus}
|
|
149
154
|
aria-label="Filter Negative"
|
|
150
155
|
onClick={() => onClick?.(item.id, true)}
|
|
@@ -153,6 +158,7 @@ export const Histogram = ({
|
|
|
153
158
|
key="positive"
|
|
154
159
|
color="primary"
|
|
155
160
|
size="sm"
|
|
161
|
+
stopPropagation
|
|
156
162
|
icon={CoreIcons.funnelPlus}
|
|
157
163
|
aria-label="Filter"
|
|
158
164
|
onClick={() => onClick?.(item.id)}
|
|
@@ -164,7 +170,7 @@ export const Histogram = ({
|
|
|
164
170
|
<span
|
|
165
171
|
className={classNames(
|
|
166
172
|
"z-1 rounded-full text-xs font-medium px-2 py-1 leading-none",
|
|
167
|
-
|
|
173
|
+
"fabric-histoBadge",
|
|
168
174
|
)}
|
|
169
175
|
>
|
|
170
176
|
{Format.number(item.count)}
|
|
@@ -111,9 +111,12 @@ export const usePagination = ({
|
|
|
111
111
|
|
|
112
112
|
/** ***************** set page *******************/
|
|
113
113
|
useEffect(() => {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
if (totalRecords > -1) {
|
|
115
|
+
const actual = Math.min(currentPage, totalPages - 1);
|
|
116
|
+
setPage(actual);
|
|
117
|
+
actual !== currentPage && onChange?.(actual);
|
|
118
|
+
}
|
|
119
|
+
}, [currentPage, totalRecords, totalPages]);
|
|
117
120
|
|
|
118
121
|
const headLabel = useMemo(
|
|
119
122
|
() => (
|
|
@@ -126,10 +129,13 @@ export const usePagination = ({
|
|
|
126
129
|
[page, perPage, totalRecords],
|
|
127
130
|
);
|
|
128
131
|
|
|
129
|
-
const onPageChange = useCallback(
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
132
|
+
const onPageChange = useCallback(
|
|
133
|
+
(page: number) => {
|
|
134
|
+
setPage(page);
|
|
135
|
+
startTransition(() => onChange?.(page));
|
|
136
|
+
},
|
|
137
|
+
[onChange],
|
|
138
|
+
);
|
|
133
139
|
|
|
134
140
|
return { page, totalPages, headLabel, ranges, onPageChange };
|
|
135
141
|
};
|
package/src/index.ts
CHANGED
|
@@ -28,7 +28,7 @@ export { Histogram } from "./histogram/Histogram";
|
|
|
28
28
|
export { JsonViewer } from "./json/JsonViewer";
|
|
29
29
|
export { Pagination } from "./pagination/Pagination";
|
|
30
30
|
export { Table } from "./table/Table";
|
|
31
|
-
export { type TableRef } from "./table/types";
|
|
31
|
+
export { type TableColumn, type TableRef } from "./table/types";
|
|
32
32
|
export { TreePanel } from "./tree/TreePanel";
|
|
33
33
|
export { type TreeNodeType as TreeNode } from "./tree/types";
|
|
34
34
|
export { VirtualGallery, type VirtualGalleryRef } from "./virtual/Gallery";
|
package/src/json/JsonViewer.tsx
CHANGED
|
@@ -22,7 +22,6 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
import {
|
|
25
|
-
ActionLabel,
|
|
26
25
|
Button,
|
|
27
26
|
Copy,
|
|
28
27
|
CoreIcons,
|
|
@@ -181,6 +180,8 @@ const JsonEntry = ({
|
|
|
181
180
|
ret = actualValue ? t("json.true") : t("json.false");
|
|
182
181
|
if (ret?.length > 128) {
|
|
183
182
|
ret = <Text clamp={3}>{ret}</Text>;
|
|
183
|
+
} else {
|
|
184
|
+
ret = <div className="break-words">{ret}</div>;
|
|
184
185
|
}
|
|
185
186
|
|
|
186
187
|
return (
|
|
@@ -216,37 +217,36 @@ const JsonEntry = ({
|
|
|
216
217
|
|
|
217
218
|
const labelDisplay = useMemo(
|
|
218
219
|
() => (
|
|
219
|
-
<
|
|
220
|
-
className=
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
<Button
|
|
225
|
-
key="negative"
|
|
226
|
-
color="danger"
|
|
227
|
-
size="sm"
|
|
228
|
-
variant="link"
|
|
229
|
-
icon={CoreIcons.funnelMinus}
|
|
230
|
-
aria-label="Filter Negative"
|
|
231
|
-
onClick={() =>
|
|
232
|
-
onFilter?.(pathWithoutOrdinal, actualValue, true)
|
|
233
|
-
}
|
|
234
|
-
/>,
|
|
235
|
-
<Button
|
|
236
|
-
key="positive"
|
|
237
|
-
color="primary"
|
|
238
|
-
size="sm"
|
|
239
|
-
variant="link"
|
|
240
|
-
icon={CoreIcons.funnelPlus}
|
|
241
|
-
aria-label="Filter"
|
|
242
|
-
onClick={() => onFilter?.(pathWithoutOrdinal, actualValue)}
|
|
243
|
-
/>,
|
|
244
|
-
]
|
|
245
|
-
: []
|
|
246
|
-
}
|
|
220
|
+
<div
|
|
221
|
+
className={classNames(
|
|
222
|
+
"text-dimmed text-sm px-2 flex-1 group",
|
|
223
|
+
inline ? "truncate" : "break-words",
|
|
224
|
+
)}
|
|
247
225
|
>
|
|
226
|
+
{!canExpand && canFilter && (
|
|
227
|
+
<div className="hidden pe-1 group-hover:inline-block">
|
|
228
|
+
<Button
|
|
229
|
+
key="negative"
|
|
230
|
+
color="danger"
|
|
231
|
+
size="xs"
|
|
232
|
+
variant="link"
|
|
233
|
+
icon={CoreIcons.funnelMinus}
|
|
234
|
+
aria-label="Filter Negative"
|
|
235
|
+
onClick={() => onFilter?.(pathWithoutOrdinal, actualValue, true)}
|
|
236
|
+
/>
|
|
237
|
+
<Button
|
|
238
|
+
key="positive"
|
|
239
|
+
color="primary"
|
|
240
|
+
size="xs"
|
|
241
|
+
variant="link"
|
|
242
|
+
icon={CoreIcons.funnelPlus}
|
|
243
|
+
aria-label="Filter"
|
|
244
|
+
onClick={() => onFilter?.(pathWithoutOrdinal, actualValue)}
|
|
245
|
+
/>
|
|
246
|
+
</div>
|
|
247
|
+
)}
|
|
248
248
|
{labeler?.(path) ?? field}
|
|
249
|
-
</
|
|
249
|
+
</div>
|
|
250
250
|
),
|
|
251
251
|
[field, labeler, pathWithoutOrdinal, actualValue, canExpand, canFilter],
|
|
252
252
|
);
|
|
@@ -283,9 +283,14 @@ const JsonEntry = ({
|
|
|
283
283
|
{labelDisplay}
|
|
284
284
|
</div>
|
|
285
285
|
{display && (
|
|
286
|
-
<div
|
|
286
|
+
<div
|
|
287
|
+
className={classNames(
|
|
288
|
+
"px-2 flex flex-nowrap overflow-hidden",
|
|
289
|
+
inline && "flex-1",
|
|
290
|
+
)}
|
|
291
|
+
>
|
|
287
292
|
{canCopy && <Copy size="xs" text={actualValue} />}
|
|
288
|
-
{display}
|
|
293
|
+
<div className="flex-1">{display}</div>
|
|
289
294
|
</div>
|
|
290
295
|
)}
|
|
291
296
|
</div>
|
|
@@ -309,9 +314,14 @@ const JsonEntry = ({
|
|
|
309
314
|
>
|
|
310
315
|
{labelDisplay}
|
|
311
316
|
</div>
|
|
312
|
-
<div
|
|
317
|
+
<div
|
|
318
|
+
className={classNames(
|
|
319
|
+
"px-2 flex flex-nowrap overflow-hidden",
|
|
320
|
+
inline && "flex-1",
|
|
321
|
+
)}
|
|
322
|
+
>
|
|
313
323
|
{canCopy && <Copy size="xs" text={value} />}
|
|
314
|
-
{display}
|
|
324
|
+
<div className="flex-1">{display}</div>
|
|
315
325
|
</div>
|
|
316
326
|
</div>
|
|
317
327
|
)}
|
|
@@ -356,7 +366,7 @@ export const JsonViewer = <T extends KeyValue = KeyValue>({
|
|
|
356
366
|
const list = useMemo(() => reduceObject(json), [json]);
|
|
357
367
|
|
|
358
368
|
return (
|
|
359
|
-
<div {...rest} className={classNames(className, "
|
|
369
|
+
<div {...rest} className={classNames(className, "bg-alternate")}>
|
|
360
370
|
{!isEmpty(json) ? (
|
|
361
371
|
list.map((item) => (
|
|
362
372
|
<JsonEntry
|
package/src/table/AddColumn.tsx
CHANGED
|
@@ -22,13 +22,13 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
import { CoreIcons, Dropdown, Icon, Menu, MenuItem } from "@react-fabric/core";
|
|
25
|
-
import { type
|
|
25
|
+
import { type TableColumn } from "./types";
|
|
26
26
|
|
|
27
27
|
export const AddColumn = ({
|
|
28
28
|
columns,
|
|
29
29
|
onClick,
|
|
30
30
|
}: {
|
|
31
|
-
columns:
|
|
31
|
+
columns: TableColumn[];
|
|
32
32
|
onClick: (id: string) => void;
|
|
33
33
|
}) => {
|
|
34
34
|
return (
|