@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.
Files changed (52) hide show
  1. package/dist/App.d.ts +0 -2
  2. package/dist/components/callout.d.ts +7 -0
  3. package/dist/components/sizeSetting.d.ts +1 -0
  4. package/dist/components/toolbar/components.d.ts +11 -0
  5. package/dist/components/toolbar/index.d.ts +15 -0
  6. package/dist/components/toolbar/toolbar-button.d.ts +7 -0
  7. package/dist/components/toolbar/toolbar-item.d.ts +40 -0
  8. package/dist/components/toolbar/toolbar-select-button.d.ts +18 -0
  9. package/dist/components/toolbar/toolbar-toggle-button.d.ts +8 -0
  10. package/dist/components/tooltip.d.ts +13 -0
  11. package/dist/fields/datasetFields/dimFields.d.ts +1 -1
  12. package/dist/fields/datasetFields/meaFields.d.ts +1 -1
  13. package/dist/fields/filterField/filterPill.d.ts +1 -1
  14. package/dist/fields/obComponents/obFContainer.d.ts +1 -1
  15. package/dist/fields/obComponents/obPill.d.ts +1 -1
  16. package/dist/graphic-walker.es.js +56487 -55304
  17. package/dist/graphic-walker.es.js.map +1 -1
  18. package/dist/graphic-walker.umd.js +501 -288
  19. package/dist/graphic-walker.umd.js.map +1 -1
  20. package/dist/index.d.ts +4 -0
  21. package/dist/style.css +0 -1
  22. package/dist/utils/throttle.d.ts +5 -0
  23. package/dist/visualSettings/menubar.d.ts +8 -0
  24. package/package.json +4 -2
  25. package/src/App.tsx +0 -4
  26. package/src/components/callout.tsx +58 -0
  27. package/src/components/sizeSetting.tsx +61 -49
  28. package/src/components/tabs/pureTab.tsx +7 -1
  29. package/src/components/toolbar/components.tsx +110 -0
  30. package/src/components/toolbar/index.tsx +57 -0
  31. package/src/components/toolbar/toolbar-button.tsx +28 -0
  32. package/src/components/toolbar/toolbar-item.tsx +218 -0
  33. package/src/components/toolbar/toolbar-select-button.tsx +196 -0
  34. package/src/components/toolbar/toolbar-toggle-button.tsx +70 -0
  35. package/src/components/tooltip.tsx +135 -0
  36. package/src/empty_sheet.css +9 -0
  37. package/src/fields/aestheticFields.tsx +1 -1
  38. package/src/fields/datasetFields/dimFields.tsx +3 -3
  39. package/src/fields/datasetFields/index.tsx +2 -2
  40. package/src/fields/datasetFields/meaFields.tsx +3 -3
  41. package/src/fields/fieldsContext.tsx +1 -1
  42. package/src/fields/filterField/filterPill.tsx +1 -1
  43. package/src/fields/filterField/index.tsx +1 -1
  44. package/src/fields/obComponents/obFContainer.tsx +1 -1
  45. package/src/fields/obComponents/obPill.tsx +1 -1
  46. package/src/fields/posFields/index.tsx +1 -1
  47. package/src/global.d.ts +7 -0
  48. package/src/index.tsx +47 -8
  49. package/src/store/visualSpecStore.ts +1 -1
  50. package/src/utils/throttle.ts +28 -0
  51. package/src/visualSettings/index.tsx +316 -321
  52. 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}&nbsp;
@@ -5,7 +5,7 @@ import {
5
5
  DropResult,
6
6
  ResponderProvided,
7
7
  DraggableLocation,
8
- } from "react-beautiful-dnd";
8
+ } from "@kanaries/react-beautiful-dnd";
9
9
  import { useGlobalStore } from '../store';
10
10
  window['__react-beautiful-dnd-disable-dev-warnings'] = true;
11
11
 
@@ -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';
@@ -5,7 +5,7 @@ import { useGlobalStore } from '../../store';
5
5
  import {
6
6
  Draggable,
7
7
  DroppableProvided
8
- } from "react-beautiful-dnd";
8
+ } from "@kanaries/react-beautiful-dnd";
9
9
  import { IDraggableStateKey } from '../../interfaces';
10
10
  import OBPill from './obPill';
11
11
 
@@ -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';
@@ -0,0 +1,7 @@
1
+ declare module '@kanaries/react-beautiful-dnd' {
2
+ export const DOM: {
3
+ setHead: (head: HTMLElement | ShadowRoot) => void;
4
+ setBody: (body: HTMLElement | ShadowRoot) => void;
5
+ };
6
+ export * from 'react-beautiful-dnd';
7
+ }
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
- export const GraphicWalker: React.FC<EditorProps> = props => {
7
- return <StoreWrapper keepAlive={props.keepAlive}>
8
- <FieldsContextWrapper>
9
- <App {...props} />
10
- </FieldsContextWrapper>
11
- </StoreWrapper>
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
+ });
@@ -71,7 +71,7 @@ function initVisualConfig (): IVisualConfig {
71
71
  height: 200
72
72
  },
73
73
  exploration: {
74
- mode: 'brush',
74
+ mode: 'none',
75
75
  brushDirection: 'default',
76
76
  },
77
77
  }
@@ -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;