@kanaries/graphic-walker 0.2.12 → 0.2.14
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/dist/App.d.ts +4 -2
- package/dist/assets/explainer.worker-8428eb12.js.map +1 -1
- package/dist/components/button/base.d.ts +1 -0
- package/dist/components/button/defaultMini.d.ts +4 -0
- package/dist/components/button/primaryMini.d.ts +4 -0
- package/dist/components/dataTable/index.d.ts +10 -0
- package/dist/components/dataTable/pagination.d.ts +10 -0
- package/dist/components/dropdownContext/index.d.ts +13 -0
- package/dist/components/dropdownSelect/index.d.ts +17 -0
- package/dist/components/modal.d.ts +1 -0
- package/dist/components/tabs/defaultTab.d.ts +14 -0
- package/dist/components/tabs/{pureTab.d.ts → editableTab.d.ts} +2 -2
- package/dist/components/toolbar/toolbar-item.d.ts +1 -0
- package/dist/dataSource/dataSelection/config.d.ts +2 -0
- package/dist/dataSource/datasetConfig/index.d.ts +3 -0
- package/dist/dataSource/index.d.ts +1 -1
- package/dist/fields/datasetFields/dimFields.d.ts +2 -2
- package/dist/fields/datasetFields/meaFields.d.ts +2 -2
- package/dist/fields/encodeFields/singleEncodeDropDown.d.ts +17 -0
- package/dist/fields/encodeFields/singleEncodeEditor.d.ts +11 -0
- package/dist/fields/obComponents/obPill.d.ts +3 -3
- package/dist/graphic-walker.es.js +21038 -19133
- package/dist/graphic-walker.es.js.map +1 -1
- package/dist/graphic-walker.umd.js +247 -170
- package/dist/graphic-walker.umd.js.map +1 -1
- package/dist/insightBoard/index.d.ts +1 -1
- package/dist/interfaces.d.ts +5 -0
- package/dist/renderer/index.d.ts +3 -1
- package/dist/segments/segmentNav.d.ts +3 -0
- package/dist/store/commonStore.d.ts +7 -1
- package/dist/store/visualSpecStore.d.ts +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/media.d.ts +2 -0
- package/dist/vis/react-vega.d.ts +2 -0
- package/dist/vis/theme.d.ts +130 -0
- package/package.json +2 -1
- package/src/App.tsx +74 -46
- package/src/components/button/base.ts +1 -0
- package/src/components/button/default.tsx +6 -2
- package/src/components/button/defaultMini.tsx +17 -0
- package/src/components/button/primary.tsx +6 -2
- package/src/components/button/primaryMini.tsx +21 -0
- package/src/components/callout.tsx +4 -1
- package/src/components/clickMenu.tsx +4 -2
- package/src/components/container.tsx +9 -0
- package/src/components/dataTable/index.tsx +177 -0
- package/src/components/dataTable/pagination.tsx +44 -0
- package/src/components/dataTypeIcon.tsx +1 -1
- package/src/components/dropdownContext/index.tsx +64 -0
- package/src/components/dropdownSelect/index.tsx +92 -0
- package/src/components/modal.tsx +26 -14
- package/src/components/tabs/defaultTab.tsx +43 -0
- package/src/components/tabs/{pureTab.tsx → editableTab.tsx} +7 -7
- package/src/components/toolbar/components.tsx +18 -1
- package/src/components/toolbar/index.tsx +5 -0
- package/src/components/toolbar/toolbar-button.tsx +6 -1
- package/src/components/toolbar/toolbar-item.tsx +4 -0
- package/src/components/toolbar/toolbar-select-button.tsx +21 -4
- package/src/components/toolbar/toolbar-toggle-button.tsx +6 -1
- package/src/components/tooltip.tsx +4 -1
- package/src/dataSource/dataSelection/config.ts +28 -0
- package/src/dataSource/dataSelection/csvData.tsx +77 -32
- package/src/dataSource/dataSelection/gwFile.tsx +0 -8
- package/src/dataSource/dataSelection/index.tsx +1 -2
- package/src/dataSource/dataSelection/publicData.tsx +2 -3
- package/src/dataSource/datasetConfig/index.tsx +21 -0
- package/src/dataSource/index.tsx +81 -61
- package/src/dataSource/table.tsx +11 -155
- package/src/fields/aestheticFields.tsx +3 -1
- package/src/fields/components.tsx +21 -2
- package/src/fields/datasetFields/dimFields.tsx +43 -35
- package/src/fields/datasetFields/index.tsx +2 -2
- package/src/fields/datasetFields/meaFields.tsx +73 -47
- package/src/fields/encodeFields/singleEncodeDropDown.tsx +92 -0
- package/src/fields/encodeFields/singleEncodeEditor.tsx +78 -0
- package/src/fields/filterField/filterEditDialog.tsx +2 -1
- package/src/fields/filterField/filterPill.tsx +1 -1
- package/src/fields/filterField/slider.tsx +1 -1
- package/src/fields/filterField/tabs.tsx +11 -21
- package/src/fields/obComponents/obPill.tsx +65 -35
- package/src/index.css +13 -0
- package/src/insightBoard/index.tsx +24 -23
- package/src/insightBoard/radioGroupButtons.tsx +7 -0
- package/src/interfaces.ts +6 -0
- package/src/lib/inferMeta.ts +1 -1
- package/src/locales/en-US.json +14 -3
- package/src/locales/zh-CN.json +12 -1
- package/src/main.tsx +1 -1
- package/src/renderer/index.tsx +3 -1
- package/src/segments/segmentNav.tsx +58 -0
- package/src/segments/visNav.tsx +2 -2
- package/src/store/commonStore.ts +28 -2
- package/src/store/visualSpecStore.ts +16 -0
- package/src/utils/index.ts +19 -0
- package/src/utils/media.ts +26 -0
- package/src/utils/normalization.ts +2 -1
- package/src/vis/react-vega.tsx +20 -4
- package/src/vis/theme.ts +126 -0
- package/src/visualSettings/index.tsx +24 -8
package/src/dataSource/table.tsx
CHANGED
|
@@ -1,171 +1,27 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import styled from "styled-components";
|
|
1
|
+
import React from "react";
|
|
3
2
|
import { observer } from "mobx-react-lite";
|
|
4
|
-
import { IMutField } from "../interfaces";
|
|
5
3
|
import { useGlobalStore } from "../store";
|
|
6
|
-
import
|
|
4
|
+
import DataTable from "../components/dataTable";
|
|
5
|
+
import { toJS } from "mobx";
|
|
7
6
|
|
|
8
7
|
interface TableProps {
|
|
9
8
|
size?: number;
|
|
10
9
|
}
|
|
11
|
-
const Container = styled.div`
|
|
12
|
-
overflow-x: auto;
|
|
13
|
-
table {
|
|
14
|
-
box-sizing: content-box;
|
|
15
|
-
border-collapse: collapse;
|
|
16
|
-
font-size: 12px;
|
|
17
|
-
thead {
|
|
18
|
-
th {
|
|
19
|
-
}
|
|
20
|
-
th.number {
|
|
21
|
-
border-top: 3px solid #5cdbd3;
|
|
22
|
-
}
|
|
23
|
-
th.text {
|
|
24
|
-
border-top: 3px solid #69c0ff;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
tbody {
|
|
28
|
-
td {
|
|
29
|
-
}
|
|
30
|
-
td.number {
|
|
31
|
-
text-align: right;
|
|
32
|
-
}
|
|
33
|
-
td.text {
|
|
34
|
-
text-align: left;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
`;
|
|
39
|
-
const ANALYTIC_TYPE_LIST = ["dimension", "measure"];
|
|
40
|
-
const SEMANTIC_TYPE_LIST = ["nominal", "ordinal", "quantitative", "temporal"];
|
|
41
|
-
// function getCellType(field: IMutField): 'number' | 'text' {
|
|
42
|
-
// return field.dataType === 'number' || field.dataType === 'integer' ? 'number' : 'text';
|
|
43
|
-
// }
|
|
44
|
-
function getHeaderType(field: IMutField): "number" | "text" {
|
|
45
|
-
return field.analyticType === "dimension" ? "text" : "number";
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function getHeaderClassNames(field: IMutField) {
|
|
49
|
-
return field.analyticType === "dimension" ? "border-t-4 border-blue-400" : "border-t-4 border-teal-400";
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function getSemanticColors(field: IMutField): string {
|
|
53
|
-
switch (field.semanticType) {
|
|
54
|
-
case "nominal":
|
|
55
|
-
return "bg-indigo-100 text-indigo-800";
|
|
56
|
-
case "ordinal":
|
|
57
|
-
return "bg-purple-100 text-purple-800"
|
|
58
|
-
case "quantitative":
|
|
59
|
-
return "bg-green-100 text-green-800"
|
|
60
|
-
case "temporal":
|
|
61
|
-
return "bg-yellow-100 text-yellow-800"
|
|
62
|
-
default:
|
|
63
|
-
return "bg-gray-400";
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
10
|
|
|
67
11
|
const Table: React.FC<TableProps> = (props) => {
|
|
68
12
|
const { size = 10 } = props;
|
|
69
13
|
const { commonStore } = useGlobalStore();
|
|
70
14
|
const { tmpDSRawFields, tmpDataSource } = commonStore;
|
|
71
|
-
const { t } = useTranslation();
|
|
72
|
-
|
|
73
|
-
const analyticTypeList = useMemo<{ value: string; label: string }[]>(() => {
|
|
74
|
-
return ANALYTIC_TYPE_LIST.map((at) => ({
|
|
75
|
-
value: at,
|
|
76
|
-
label: t(`constant.analytic_type.${at}`),
|
|
77
|
-
}));
|
|
78
|
-
}, []);
|
|
79
|
-
|
|
80
|
-
const semanticTypeList = useMemo<{ value: string; label: string }[]>(() => {
|
|
81
|
-
return SEMANTIC_TYPE_LIST.map((st) => ({
|
|
82
|
-
value: st,
|
|
83
|
-
label: t(`constant.semantic_type.${st}`),
|
|
84
|
-
}));
|
|
85
|
-
}, []);
|
|
86
15
|
|
|
87
16
|
return (
|
|
88
|
-
<
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
getHeaderClassNames(field) +
|
|
97
|
-
" whitespace-nowrap py-3.5 px-6 text-left text-xs font-semibold text-gray-900 sm:pl-6"
|
|
98
|
-
}
|
|
99
|
-
>
|
|
100
|
-
<b>{field.name || field.fid}</b>
|
|
101
|
-
<div>
|
|
102
|
-
<select
|
|
103
|
-
className={
|
|
104
|
-
"px-2 py font-normal mt-2 rounded-full text-xs text-white " +
|
|
105
|
-
(field.analyticType === "dimension" ? "bg-blue-500" : "bg-teal-500")
|
|
106
|
-
}
|
|
107
|
-
// className="border-b border-gray-200 bg-gray-50 pl-0 mt-2 font-light"
|
|
108
|
-
value={field.analyticType}
|
|
109
|
-
onChange={(e) => {
|
|
110
|
-
commonStore.updateTempFieldAnalyticType(
|
|
111
|
-
field.fid,
|
|
112
|
-
e.target.value as IMutField["analyticType"]
|
|
113
|
-
);
|
|
114
|
-
}}
|
|
115
|
-
>
|
|
116
|
-
{analyticTypeList.map((type) => (
|
|
117
|
-
<option key={type.value} value={type.value}>
|
|
118
|
-
{type.label}
|
|
119
|
-
</option>
|
|
120
|
-
))}
|
|
121
|
-
</select>
|
|
122
|
-
</div>
|
|
123
|
-
<div>
|
|
124
|
-
<select
|
|
125
|
-
className={
|
|
126
|
-
"inline-block px-2.5 py-0.5 text-xs font-medium mt-1 rounded-full text-xs text-white " +
|
|
127
|
-
getSemanticColors(field)
|
|
128
|
-
}
|
|
129
|
-
// className="border-b border-gray-200 bg-gray-50 pl-0 mt-2 font-light"
|
|
130
|
-
value={field.semanticType}
|
|
131
|
-
onChange={(e) => {
|
|
132
|
-
commonStore.updateTempFieldSemanticType(
|
|
133
|
-
field.fid,
|
|
134
|
-
e.target.value as IMutField["semanticType"]
|
|
135
|
-
);
|
|
136
|
-
}}
|
|
137
|
-
>
|
|
138
|
-
{semanticTypeList.map((type) => (
|
|
139
|
-
<option key={type.value} value={type.value}>
|
|
140
|
-
{type.label}
|
|
141
|
-
</option>
|
|
142
|
-
))}
|
|
143
|
-
</select>
|
|
144
|
-
</div>
|
|
145
|
-
</div>
|
|
146
|
-
</th>
|
|
147
|
-
))}
|
|
148
|
-
</tr>
|
|
149
|
-
</thead>
|
|
150
|
-
<tbody className="divide-y divide-gray-200 bg-white">
|
|
151
|
-
{tmpDataSource.slice(0, size).map((record, index) => (
|
|
152
|
-
<tr className={"divide-x divide-gray-200 " + (index % 2 ? "bg-gray-50" : "")} key={index}>
|
|
153
|
-
{tmpDSRawFields.map((field) => (
|
|
154
|
-
<td
|
|
155
|
-
key={field.fid + index}
|
|
156
|
-
className={
|
|
157
|
-
getHeaderType(field) +
|
|
158
|
-
" whitespace-nowrap py-2 pl-4 pr-3 text-xs text-gray-500 sm:pl-6"
|
|
159
|
-
}
|
|
160
|
-
>
|
|
161
|
-
{record[field.fid]}
|
|
162
|
-
</td>
|
|
163
|
-
))}
|
|
164
|
-
</tr>
|
|
165
|
-
))}
|
|
166
|
-
</tbody>
|
|
167
|
-
</table>
|
|
168
|
-
</Container>
|
|
17
|
+
<DataTable
|
|
18
|
+
size={size}
|
|
19
|
+
metas={toJS(tmpDSRawFields)}
|
|
20
|
+
data={tmpDataSource}
|
|
21
|
+
onMetaChange={(fid, fIndex, diffMeta) => {
|
|
22
|
+
commonStore.updateTempDatasetMetas(fid, diffMeta);
|
|
23
|
+
}}
|
|
24
|
+
/>
|
|
169
25
|
);
|
|
170
26
|
};
|
|
171
27
|
|
|
@@ -3,6 +3,7 @@ import { Droppable } from "@kanaries/react-beautiful-dnd";
|
|
|
3
3
|
import { DRAGGABLE_STATE_KEYS } from './fieldsContext';
|
|
4
4
|
import { AestheticFieldContainer } from './components'
|
|
5
5
|
import OBFieldContainer from './obComponents/obFContainer';
|
|
6
|
+
import SingleEncodeEditor from './encodeFields/singleEncodeEditor';
|
|
6
7
|
|
|
7
8
|
const aestheticFields = DRAGGABLE_STATE_KEYS.filter(f => ['color', 'opacity', 'size', 'shape'].includes(f.id));
|
|
8
9
|
|
|
@@ -12,7 +13,8 @@ const AestheticFields: React.FC = props => {
|
|
|
12
13
|
aestheticFields.map(dkey => <AestheticFieldContainer name={dkey.id} key={dkey.id}>
|
|
13
14
|
<Droppable droppableId={dkey.id} direction="horizontal">
|
|
14
15
|
{(provided, snapshot) => (
|
|
15
|
-
<OBFieldContainer dkey={dkey} provided={provided} />
|
|
16
|
+
// <OBFieldContainer dkey={dkey} provided={provided} />
|
|
17
|
+
<SingleEncodeEditor dkey={dkey} provided={provided} snapshot={snapshot} />
|
|
16
18
|
)}
|
|
17
19
|
</Droppable>
|
|
18
20
|
</AestheticFieldContainer>)
|
|
@@ -5,18 +5,25 @@ import { COLORS } from "../config";
|
|
|
5
5
|
|
|
6
6
|
export const AestheticSegment = styled.div`
|
|
7
7
|
border: 1px solid #e5e7eb;
|
|
8
|
+
// dark mode
|
|
9
|
+
@media (prefers-color-scheme: dark) {
|
|
10
|
+
border: 1px solid #2d3748;
|
|
11
|
+
}
|
|
8
12
|
font-size: 12px;
|
|
9
13
|
margin: 0.2em;
|
|
10
14
|
|
|
11
15
|
.aes-header{
|
|
12
16
|
border-bottom: 1px solid #e5e7eb;
|
|
17
|
+
@media (prefers-color-scheme: dark) {
|
|
18
|
+
border-bottom: 1px solid #2d3748;
|
|
19
|
+
}
|
|
13
20
|
padding: 0.6em;
|
|
14
21
|
h4 {
|
|
15
22
|
font-weight: 400;
|
|
16
23
|
}
|
|
17
24
|
}
|
|
18
25
|
.aes-container{
|
|
19
|
-
overflow-x: auto;
|
|
26
|
+
/* overflow-x: auto; */
|
|
20
27
|
}
|
|
21
28
|
|
|
22
29
|
`
|
|
@@ -85,12 +92,18 @@ export const FilterFieldsContainer = styled.div({
|
|
|
85
92
|
export const FieldListSegment = styled.div`
|
|
86
93
|
display: flex;
|
|
87
94
|
border: 1px solid #e5e7eb;
|
|
95
|
+
@media (prefers-color-scheme: dark) {
|
|
96
|
+
border: 1px solid #2d3748;
|
|
97
|
+
}
|
|
88
98
|
margin: 0.2em;
|
|
89
99
|
font-size: 12px;
|
|
90
100
|
div.fl-header {
|
|
91
101
|
/* flex-basis: 100px; */
|
|
92
102
|
width: 100px;
|
|
93
103
|
border-right: 1px solid #e5e7eb;
|
|
104
|
+
@media (prefers-color-scheme: dark) {
|
|
105
|
+
border-right: 1px solid #2d3748;
|
|
106
|
+
}
|
|
94
107
|
flex-shrink: 0;
|
|
95
108
|
h4 {
|
|
96
109
|
margin: 0.6em;
|
|
@@ -108,11 +121,17 @@ export const FieldListSegment = styled.div`
|
|
|
108
121
|
|
|
109
122
|
export const FilterFieldSegment = styled.div`
|
|
110
123
|
border: 1px solid #e5e7eb;
|
|
124
|
+
@media (prefers-color-scheme: dark) {
|
|
125
|
+
border: 1px solid #2d3748;
|
|
126
|
+
}
|
|
111
127
|
font-size: 12px;
|
|
112
128
|
margin: 0.2em;
|
|
113
129
|
|
|
114
130
|
.flt-header {
|
|
115
131
|
border-bottom: 1px solid #e5e7eb;
|
|
132
|
+
@media (prefers-color-scheme: dark) {
|
|
133
|
+
border-bottom: 1px solid #2d3748;
|
|
134
|
+
}
|
|
116
135
|
padding: 0.6em;
|
|
117
136
|
|
|
118
137
|
> h4 {
|
|
@@ -144,7 +163,7 @@ export const Pill = styled.div<{colType: 'discrete' | 'continuous'}>`
|
|
|
144
163
|
font-size: 12px;
|
|
145
164
|
height: 20px;
|
|
146
165
|
min-width: 150px;
|
|
147
|
-
overflow-y: hidden;
|
|
166
|
+
/* overflow-y: hidden; */
|
|
148
167
|
padding: 0 10px;
|
|
149
168
|
user-select: none;
|
|
150
169
|
text-overflow: ellipsis;
|
|
@@ -1,46 +1,54 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { Draggable, DroppableProvided } from
|
|
3
|
-
import { observer } from
|
|
4
|
-
import { useGlobalStore } from
|
|
5
|
-
import DataTypeIcon from
|
|
6
|
-
import { FieldPill } from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Draggable, DroppableProvided } from "@kanaries/react-beautiful-dnd";
|
|
3
|
+
import { observer } from "mobx-react-lite";
|
|
4
|
+
import { useGlobalStore } from "../../store";
|
|
5
|
+
import DataTypeIcon from "../../components/dataTypeIcon";
|
|
6
|
+
import { FieldPill } from "./fieldPill";
|
|
7
7
|
|
|
8
8
|
interface Props {
|
|
9
9
|
provided: DroppableProvided;
|
|
10
10
|
}
|
|
11
|
-
const DimFields: React.FC<Props> = props => {
|
|
11
|
+
const DimFields: React.FC<Props> = (props) => {
|
|
12
12
|
const { provided } = props;
|
|
13
13
|
const { vizStore } = useGlobalStore();
|
|
14
14
|
const dimensions = vizStore.draggableFieldState.dimensions;
|
|
15
|
-
return
|
|
16
|
-
{
|
|
17
|
-
|
|
18
|
-
{
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
</FieldPill>
|
|
31
|
-
{
|
|
32
|
-
<FieldPill className={`pt-0.5 pb-0.5 pl-2 pr-2 mx-0 m-1 text-xs hover:bg-blue-100 rounded-full border-blue-400 border truncate ${snapshot.isDragging ? '' : 'hidden'}`}
|
|
33
|
-
isDragging={snapshot.isDragging}
|
|
15
|
+
return (
|
|
16
|
+
<div {...provided.droppableProps} ref={provided.innerRef}>
|
|
17
|
+
{dimensions.map((f, index) => (
|
|
18
|
+
<Draggable key={f.dragId} draggableId={f.dragId} index={index}>
|
|
19
|
+
{(provided, snapshot) => {
|
|
20
|
+
return (
|
|
21
|
+
<>
|
|
22
|
+
<FieldPill
|
|
23
|
+
className={`dark:text-white pt-0.5 pb-0.5 pl-2 pr-2 mx-0 m-1 text-xs hover:bg-blue-100 dark:hover:bg-blue-800 rounded-full truncate border border-transparent ${
|
|
24
|
+
snapshot.isDragging ? "bg-blue-100 dark:bg-blue-800" : ""
|
|
25
|
+
}`}
|
|
26
|
+
ref={provided.innerRef}
|
|
27
|
+
isDragging={snapshot.isDragging}
|
|
28
|
+
{...provided.draggableProps}
|
|
29
|
+
{...provided.dragHandleProps}
|
|
34
30
|
>
|
|
35
|
-
<DataTypeIcon dataType={f.semanticType} analyticType={f.analyticType} /> {f.name}
|
|
31
|
+
<DataTypeIcon dataType={f.semanticType} analyticType={f.analyticType} /> {f.name}
|
|
32
|
+
|
|
36
33
|
</FieldPill>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
34
|
+
{
|
|
35
|
+
<FieldPill
|
|
36
|
+
className={`dark:text-white pt-0.5 pb-0.5 pl-2 pr-2 mx-0 m-1 text-xs hover:bg-blue-100 dark:hover:bg-blue-800 rounded-full border-blue-400 border truncate ${
|
|
37
|
+
snapshot.isDragging ? "bg-blue-100 dark:bg-blue-800" : "hidden"
|
|
38
|
+
}`}
|
|
39
|
+
isDragging={snapshot.isDragging}
|
|
40
|
+
>
|
|
41
|
+
<DataTypeIcon dataType={f.semanticType} analyticType={f.analyticType} />{" "}
|
|
42
|
+
{f.name}
|
|
43
|
+
</FieldPill>
|
|
44
|
+
}
|
|
45
|
+
</>
|
|
46
|
+
);
|
|
47
|
+
}}
|
|
48
|
+
</Draggable>
|
|
49
|
+
))}
|
|
50
|
+
</div>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
45
53
|
|
|
46
54
|
export default observer(DimFields);
|
|
@@ -16,14 +16,14 @@ const DatasetFields: React.FC = (props) => {
|
|
|
16
16
|
const { t } = useTranslation("translation", { keyPrefix: "main.tabpanel.DatasetFields" });
|
|
17
17
|
|
|
18
18
|
return (
|
|
19
|
-
<DSContainer className="border-gray-200 flex md:flex-col" style={{ paddingBlock: 0, paddingInline: '0.6em' }}>
|
|
19
|
+
<DSContainer className="border-gray-200 dark:border-gray-700 flex md:flex-col" style={{ paddingBlock: 0, paddingInline: '0.6em' }}>
|
|
20
20
|
<h4 className="text-xs mb-2 flex-grow-0 cursor-default select-none mt-2">{t("field_list")}</h4>
|
|
21
21
|
<div className="pd-1 overflow-y-auto" style={{ maxHeight: "380px", minHeight: '100px' }}>
|
|
22
22
|
<Droppable droppableId="dimensions" direction="vertical">
|
|
23
23
|
{(provided, snapshot) => <DimFields provided={provided} />}
|
|
24
24
|
</Droppable>
|
|
25
25
|
</div>
|
|
26
|
-
<div className="border-t flex-grow pd-1 overflow-y-auto">
|
|
26
|
+
<div className="border-t dark:border-gray-800 flex-grow pd-1 overflow-y-auto">
|
|
27
27
|
<Droppable droppableId="measures" direction="vertical">
|
|
28
28
|
{(provided, snapshot) => <MeaFields provided={provided} />}
|
|
29
29
|
</Droppable>
|
|
@@ -1,58 +1,84 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { Draggable, DroppableProvided } from
|
|
3
|
-
import { observer } from
|
|
4
|
-
import { useGlobalStore } from
|
|
5
|
-
import DataTypeIcon from
|
|
6
|
-
import { FieldPill } from
|
|
1
|
+
import React, { useCallback, useMemo } from "react";
|
|
2
|
+
import { Draggable, DroppableProvided } from "@kanaries/react-beautiful-dnd";
|
|
3
|
+
import { observer } from "mobx-react-lite";
|
|
4
|
+
import { useGlobalStore } from "../../store";
|
|
5
|
+
import DataTypeIcon from "../../components/dataTypeIcon";
|
|
6
|
+
import { FieldPill } from "./fieldPill";
|
|
7
|
+
import DropdownContext, { IDropdownContextOption } from "../../components/dropdownContext";
|
|
7
8
|
|
|
8
9
|
interface Props {
|
|
9
10
|
provided: DroppableProvided;
|
|
10
11
|
}
|
|
11
|
-
const MeaFields: React.FC<Props> = props => {
|
|
12
|
+
const MeaFields: React.FC<Props> = (props) => {
|
|
12
13
|
const { provided } = props;
|
|
13
14
|
const { vizStore } = useGlobalStore();
|
|
14
15
|
const measures = vizStore.draggableFieldState.measures;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
16
|
+
|
|
17
|
+
const MEA_ACTION_OPTIONS = useMemo<IDropdownContextOption[]>(() => {
|
|
18
|
+
return [
|
|
19
|
+
{
|
|
20
|
+
value: "bin",
|
|
21
|
+
label: "Bin",
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
value: "log10",
|
|
25
|
+
label: "Log10",
|
|
26
|
+
},
|
|
27
|
+
];
|
|
28
|
+
}, []);
|
|
29
|
+
|
|
30
|
+
const fieldActionHandler = useCallback((selectedValue: any, opIndex: number, meaIndex: number) => {
|
|
31
|
+
if (selectedValue === "bin") {
|
|
32
|
+
vizStore.createBinField("measures", meaIndex);
|
|
33
|
+
} else if (selectedValue === "log10") {
|
|
34
|
+
vizStore.createLogField("measures", meaIndex);
|
|
35
|
+
}
|
|
36
|
+
}, []);
|
|
37
|
+
return (
|
|
38
|
+
<div {...provided.droppableProps} ref={provided.innerRef}>
|
|
39
|
+
{measures.map((f, index) => (
|
|
40
|
+
<Draggable key={f.dragId} draggableId={f.dragId} index={index}>
|
|
41
|
+
{(provided, snapshot) => {
|
|
42
|
+
return (
|
|
43
|
+
<div className="block">
|
|
44
|
+
<DropdownContext
|
|
45
|
+
disable={snapshot.isDragging}
|
|
46
|
+
options={MEA_ACTION_OPTIONS}
|
|
47
|
+
onSelect={(v, opIndex) => {
|
|
48
|
+
fieldActionHandler(v, opIndex, index);
|
|
49
|
+
}}
|
|
50
|
+
>
|
|
51
|
+
<FieldPill
|
|
52
|
+
className={`dark:text-white pt-0.5 pb-0.5 pl-2 pr-2 mx-0 m-1 text-xs hover:bg-purple-100 dark:hover:bg-purple-800 rounded-full truncate border border-transparent ${
|
|
53
|
+
snapshot.isDragging ? "bg-purple-100 dark:bg-purple-800" : ""
|
|
54
|
+
}`}
|
|
55
|
+
isDragging={snapshot.isDragging}
|
|
56
|
+
ref={provided.innerRef}
|
|
57
|
+
{...provided.draggableProps}
|
|
58
|
+
{...provided.dragHandleProps}
|
|
59
|
+
>
|
|
60
|
+
<DataTypeIcon dataType={f.semanticType} analyticType={f.analyticType} />{" "}
|
|
61
|
+
{f.name}
|
|
62
|
+
</FieldPill>
|
|
63
|
+
</DropdownContext>
|
|
29
64
|
{
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
<option value="log10">log10</option>
|
|
40
|
-
</select>
|
|
65
|
+
<FieldPill
|
|
66
|
+
className={`dark:text-white pt-0.5 pb-0.5 pl-2 pr-2 mx-0 m-1 text-xs hover:bg-purple-100 dark:hover:bg-purple-800 rounded-full border-purple-400 border truncate ${
|
|
67
|
+
snapshot.isDragging ? "bg-purple-100 dark:bg-purple-800" : "hidden"
|
|
68
|
+
}`}
|
|
69
|
+
isDragging={snapshot.isDragging}
|
|
70
|
+
>
|
|
71
|
+
<DataTypeIcon dataType={f.semanticType} analyticType={f.analyticType} />{" "}
|
|
72
|
+
{f.name}
|
|
73
|
+
</FieldPill>
|
|
41
74
|
}
|
|
42
|
-
</
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
</>
|
|
51
|
-
);
|
|
52
|
-
}}
|
|
53
|
-
</Draggable>
|
|
54
|
-
))}
|
|
55
|
-
</div>
|
|
56
|
-
}
|
|
75
|
+
</div>
|
|
76
|
+
);
|
|
77
|
+
}}
|
|
78
|
+
</Draggable>
|
|
79
|
+
))}
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
57
83
|
|
|
58
84
|
export default observer(MeaFields);
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import React, { Fragment } from "react";
|
|
2
|
+
import { Listbox, Menu, Transition } from "@headlessui/react";
|
|
3
|
+
import { CheckIcon, ChevronDownIcon, ChevronUpDownIcon } from "@heroicons/react/24/outline";
|
|
4
|
+
|
|
5
|
+
function classNames(...classes: string[]) {
|
|
6
|
+
return classes.filter(Boolean).join(" ");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface IDropdownSelectOption {
|
|
10
|
+
label: string;
|
|
11
|
+
value: string;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
}
|
|
14
|
+
interface IDropdownSelectProps {
|
|
15
|
+
options?: IDropdownSelectOption[];
|
|
16
|
+
disable?: boolean;
|
|
17
|
+
selectedKey: string;
|
|
18
|
+
onSelect?: (value: string) => void;
|
|
19
|
+
placeholder?: string;
|
|
20
|
+
className?: string;
|
|
21
|
+
buttonClassName?: string;
|
|
22
|
+
}
|
|
23
|
+
const DropdownSelect: React.FC<IDropdownSelectProps> = (props) => {
|
|
24
|
+
const { options = [], disable, selectedKey, onSelect, placeholder = "Select an option", className, buttonClassName } = props;
|
|
25
|
+
|
|
26
|
+
const selectedItem = options.find((op) => op.value === selectedKey);
|
|
27
|
+
|
|
28
|
+
if (disable) {
|
|
29
|
+
return <Fragment>{props.children}</Fragment>;
|
|
30
|
+
}
|
|
31
|
+
let rootClassName = "flex truncate";
|
|
32
|
+
let btnComputedClassName = "grow shrink relative cursor-default text-xs rounded-lg bg-white dark:bg-zinc-900 px-2.5 py-1.5 pr-10 text-left border border-gray-200 focus:outline-none focus-visible:border-indigo-500 focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75 focus-visible:ring-offset-2 focus-visible:ring-offset-orange-300 truncate"
|
|
33
|
+
if (buttonClassName) {
|
|
34
|
+
btnComputedClassName = btnComputedClassName + " " + buttonClassName;
|
|
35
|
+
}
|
|
36
|
+
if (className) {
|
|
37
|
+
rootClassName = rootClassName + " " + className;
|
|
38
|
+
}
|
|
39
|
+
return (
|
|
40
|
+
<Listbox
|
|
41
|
+
value={selectedKey}
|
|
42
|
+
onChange={(newKey) => {
|
|
43
|
+
onSelect && onSelect(newKey);
|
|
44
|
+
}}
|
|
45
|
+
>
|
|
46
|
+
<div className={rootClassName}>
|
|
47
|
+
<Listbox.Button className={btnComputedClassName}>
|
|
48
|
+
<span className="block truncate">{selectedItem?.label || ""}</span>
|
|
49
|
+
{ selectedItem === undefined && <span className="block truncate text-gray-400">{placeholder}</span>}
|
|
50
|
+
<span className="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2">
|
|
51
|
+
<ChevronUpDownIcon className="h-5 w-5 text-gray-400" aria-hidden="true" />
|
|
52
|
+
</span>
|
|
53
|
+
</Listbox.Button>
|
|
54
|
+
<Transition
|
|
55
|
+
as={Fragment}
|
|
56
|
+
leave="transition ease-in duration-100"
|
|
57
|
+
leaveFrom="opacity-100"
|
|
58
|
+
leaveTo="opacity-0"
|
|
59
|
+
>
|
|
60
|
+
<Listbox.Options className="absolute z-50 mt-8 max-h-60 w-full overflow-auto rounded-md bg-white dark:bg-zinc-900 py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm">
|
|
61
|
+
{options.map((op, opIndex) => (
|
|
62
|
+
<Listbox.Option
|
|
63
|
+
key={op.value}
|
|
64
|
+
className={({ active }) =>
|
|
65
|
+
`relative cursor-default select-none py-2 pl-10 pr-4 ${
|
|
66
|
+
active ? "bg-amber-100 text-amber-900 dark:bg-amber-800 dark:text-amber-50" : "text-gray-900 dark:text-amber-50"
|
|
67
|
+
}`
|
|
68
|
+
}
|
|
69
|
+
value={op.value}
|
|
70
|
+
>
|
|
71
|
+
{({ selected }) => (
|
|
72
|
+
<>
|
|
73
|
+
<span className={`block truncate ${selected ? "font-medium" : "font-normal"}`}>
|
|
74
|
+
{op.label}
|
|
75
|
+
</span>
|
|
76
|
+
{selected && (
|
|
77
|
+
<span className="absolute inset-y-0 left-0 flex items-center pl-3 text-amber-600">
|
|
78
|
+
<CheckIcon className="h-5 w-5" aria-hidden="true" />
|
|
79
|
+
</span>
|
|
80
|
+
)}
|
|
81
|
+
</>
|
|
82
|
+
)}
|
|
83
|
+
</Listbox.Option>
|
|
84
|
+
))}
|
|
85
|
+
</Listbox.Options>
|
|
86
|
+
</Transition>
|
|
87
|
+
</div>
|
|
88
|
+
</Listbox>
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export default DropdownSelect;
|