@kanaries/graphic-walker 0.2.9 → 0.2.10
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 +0 -2
- package/dist/components/callout.d.ts +7 -0
- package/dist/components/sizeSetting.d.ts +1 -0
- package/dist/components/toolbar/components.d.ts +11 -0
- package/dist/components/toolbar/index.d.ts +15 -0
- package/dist/components/toolbar/toolbar-button.d.ts +7 -0
- package/dist/components/toolbar/toolbar-item.d.ts +40 -0
- package/dist/components/toolbar/toolbar-select-button.d.ts +18 -0
- package/dist/components/toolbar/toolbar-toggle-button.d.ts +8 -0
- package/dist/components/tooltip.d.ts +13 -0
- package/dist/fields/datasetFields/dimFields.d.ts +1 -1
- package/dist/fields/datasetFields/meaFields.d.ts +1 -1
- package/dist/fields/filterField/filterPill.d.ts +1 -1
- package/dist/fields/obComponents/obFContainer.d.ts +1 -1
- package/dist/fields/obComponents/obPill.d.ts +1 -1
- package/dist/graphic-walker.es.js +56487 -55304
- package/dist/graphic-walker.es.js.map +1 -1
- package/dist/graphic-walker.umd.js +501 -288
- package/dist/graphic-walker.umd.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/style.css +0 -1
- package/dist/utils/throttle.d.ts +5 -0
- package/dist/visualSettings/menubar.d.ts +8 -0
- package/package.json +4 -2
- package/src/App.tsx +0 -4
- package/src/components/callout.tsx +58 -0
- package/src/components/sizeSetting.tsx +61 -49
- package/src/components/tabs/pureTab.tsx +7 -1
- package/src/components/toolbar/components.tsx +110 -0
- package/src/components/toolbar/index.tsx +57 -0
- package/src/components/toolbar/toolbar-button.tsx +28 -0
- package/src/components/toolbar/toolbar-item.tsx +218 -0
- package/src/components/toolbar/toolbar-select-button.tsx +196 -0
- package/src/components/toolbar/toolbar-toggle-button.tsx +70 -0
- package/src/components/tooltip.tsx +135 -0
- package/src/empty_sheet.css +9 -0
- package/src/fields/aestheticFields.tsx +1 -1
- package/src/fields/datasetFields/dimFields.tsx +3 -3
- package/src/fields/datasetFields/index.tsx +2 -2
- package/src/fields/datasetFields/meaFields.tsx +3 -3
- package/src/fields/fieldsContext.tsx +1 -1
- package/src/fields/filterField/filterPill.tsx +1 -1
- package/src/fields/filterField/index.tsx +1 -1
- package/src/fields/obComponents/obFContainer.tsx +1 -1
- package/src/fields/obComponents/obPill.tsx +1 -1
- package/src/fields/posFields/index.tsx +1 -1
- package/src/global.d.ts +7 -0
- package/src/index.tsx +47 -8
- package/src/store/visualSpecStore.ts +1 -1
- package/src/utils/throttle.ts +28 -0
- package/src/visualSettings/index.tsx +316 -321
- package/src/visualSettings/menubar.tsx +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Draggable, DroppableProvided } from 'react-beautiful-dnd';
|
|
2
|
+
import { Draggable, DroppableProvided } from '@kanaries/react-beautiful-dnd';
|
|
3
3
|
import { observer } from 'mobx-react-lite';
|
|
4
4
|
import { useGlobalStore } from '../../store';
|
|
5
5
|
import DataTypeIcon from '../../components/dataTypeIcon';
|
|
@@ -19,7 +19,7 @@ const MeaFields: React.FC<Props> = props => {
|
|
|
19
19
|
return (
|
|
20
20
|
<>
|
|
21
21
|
<FieldPill
|
|
22
|
-
className="pt-0.5 pb-0.5 pl-2 pr-2 m-1 text-xs hover:bg-blue-100 rounded-full truncate"
|
|
22
|
+
className="pt-0.5 pb-0.5 pl-2 pr-2 mx-0 m-1 text-xs hover:bg-blue-100 rounded-full truncate border border-transparent"
|
|
23
23
|
isDragging={snapshot.isDragging}
|
|
24
24
|
ref={provided.innerRef}
|
|
25
25
|
{...provided.draggableProps}
|
|
@@ -41,7 +41,7 @@ const MeaFields: React.FC<Props> = props => {
|
|
|
41
41
|
}
|
|
42
42
|
</FieldPill>
|
|
43
43
|
{
|
|
44
|
-
<FieldPill className={`pt-0.5 pb-0.5 pl-2 pr-2 m-1 text-xs hover:bg-blue-100 rounded-full border-blue-400 border truncate ${snapshot.isDragging ? '' : 'hidden'}`}
|
|
44
|
+
<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'}`}
|
|
45
45
|
isDragging={snapshot.isDragging}
|
|
46
46
|
>
|
|
47
47
|
<DataTypeIcon dataType={f.semanticType} analyticType={f.analyticType} /> {f.name}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { observer } from 'mobx-react-lite';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { DraggableProvided } from "react-beautiful-dnd";
|
|
3
|
+
import { DraggableProvided } from "@kanaries/react-beautiful-dnd";
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
5
|
import styled from 'styled-components';
|
|
6
6
|
import { PencilSquareIcon } from '@heroicons/react/24/solid';
|
|
@@ -3,7 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import {
|
|
4
4
|
Draggable,
|
|
5
5
|
Droppable, DroppableProvided,
|
|
6
|
-
} from "react-beautiful-dnd";
|
|
6
|
+
} from "@kanaries/react-beautiful-dnd";
|
|
7
7
|
|
|
8
8
|
import { useGlobalStore } from '../../store';
|
|
9
9
|
import { FilterFieldContainer, FilterFieldsContainer } from '../components';
|
|
@@ -2,7 +2,7 @@ import { BarsArrowDownIcon, BarsArrowUpIcon } from '@heroicons/react/24/outline'
|
|
|
2
2
|
import { observer } from 'mobx-react-lite';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
|
-
import { DraggableProvided } from 'react-beautiful-dnd';
|
|
5
|
+
import { DraggableProvided } from '@kanaries/react-beautiful-dnd';
|
|
6
6
|
import { COUNT_FIELD_ID } from '../../constants';
|
|
7
7
|
import { IDraggableStateKey } from '../../interfaces';
|
|
8
8
|
import { useGlobalStore } from '../../store';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
2
|
import { observer } from 'mobx-react-lite';
|
|
3
|
-
import { Droppable } from "react-beautiful-dnd";
|
|
3
|
+
import { Droppable } from "@kanaries/react-beautiful-dnd";
|
|
4
4
|
import { useGlobalStore } from '../../store';
|
|
5
5
|
import { FieldListContainer } from "../components";
|
|
6
6
|
import { DRAGGABLE_STATE_KEYS } from '../fieldsContext';
|
package/src/global.d.ts
ADDED
package/src/index.tsx
CHANGED
|
@@ -1,12 +1,51 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { createContext, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { StyleSheetManager } from 'styled-components';
|
|
3
|
+
import root from 'react-shadow';
|
|
4
|
+
import { DOM } from '@kanaries/react-beautiful-dnd';
|
|
5
|
+
import { observer } from 'mobx-react-lite';
|
|
2
6
|
import App, { EditorProps } from './App';
|
|
3
7
|
import { StoreWrapper } from './store/index';
|
|
4
8
|
import { FieldsContextWrapper } from './fields/fieldsContext';
|
|
5
9
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
import './empty_sheet.css';
|
|
11
|
+
import tailwindStyle from "tailwindcss/tailwind.css?inline";
|
|
12
|
+
import style from './index.css?inline';
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
export const ShadowDomContext = createContext<{ root: ShadowRoot | null }>({ root: null });
|
|
16
|
+
|
|
17
|
+
export const GraphicWalker: React.FC<EditorProps> = observer(props => {
|
|
18
|
+
const [shadowRoot, setShadowRoot] = useState<ShadowRoot | null>(null);
|
|
19
|
+
const rootRef = useRef<HTMLDivElement>(null);
|
|
20
|
+
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (rootRef.current) {
|
|
23
|
+
const shadowRoot = rootRef.current.shadowRoot!;
|
|
24
|
+
setShadowRoot(shadowRoot);
|
|
25
|
+
DOM.setBody(shadowRoot);
|
|
26
|
+
DOM.setHead(shadowRoot);
|
|
27
|
+
return () => {
|
|
28
|
+
DOM.setBody(document.body);
|
|
29
|
+
DOM.setHead(document.head);
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}, []);
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<root.div mode="open" ref={rootRef}>
|
|
36
|
+
<style>{tailwindStyle}</style>
|
|
37
|
+
<style>{style}</style>
|
|
38
|
+
{shadowRoot && (
|
|
39
|
+
<StyleSheetManager target={shadowRoot}>
|
|
40
|
+
<StoreWrapper keepAlive={props.keepAlive}>
|
|
41
|
+
<FieldsContextWrapper>
|
|
42
|
+
<ShadowDomContext.Provider value={{ root: shadowRoot }}>
|
|
43
|
+
<App {...props} />
|
|
44
|
+
</ShadowDomContext.Provider>
|
|
45
|
+
</FieldsContextWrapper>
|
|
46
|
+
</StoreWrapper>
|
|
47
|
+
</StyleSheetManager>
|
|
48
|
+
)}
|
|
49
|
+
</root.div>
|
|
50
|
+
);
|
|
51
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const throttle = (fn: () => void, time: number, options?: Partial<{ leading: boolean; trailing: boolean }>): () => void => {
|
|
2
|
+
const { leading = true, trailing = false } = options ?? {};
|
|
3
|
+
|
|
4
|
+
let dirty = false;
|
|
5
|
+
let hasTrailing = false;
|
|
6
|
+
|
|
7
|
+
const throttled = (): void => {
|
|
8
|
+
if (dirty) {
|
|
9
|
+
hasTrailing = true;
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
dirty = true;
|
|
13
|
+
if (leading) {
|
|
14
|
+
fn();
|
|
15
|
+
}
|
|
16
|
+
setTimeout(() => {
|
|
17
|
+
if (hasTrailing && trailing) {
|
|
18
|
+
fn();
|
|
19
|
+
}
|
|
20
|
+
dirty = false;
|
|
21
|
+
hasTrailing = false;
|
|
22
|
+
}, time);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return throttled;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default throttle;
|