An open source alternative to Tableau. Embeddable visual analytic
TypeScript bidatadata-analysisdata-miningdata-visualizationedak6skanarieslow-codepivot-tablereacttableautableau-alternativetypescriptvegavega-litevisualization
feat: redesign dropdown, button
ObservedObservera257ba81978a
diff --git a/packages/graphic-walker/package.json b/packages/graphic-walker/package.jsonindex 52a2e6ed..a14c6f1b 100644--- a/packages/graphic-walker/package.json+++ b/packages/graphic-walker/package.json@@ -32,6 +32,7 @@},"types": "./dist/index.d.ts","dependencies": {+ "@headlessui/react": "^1.7.12","@heroicons/react": "^2.0.8","@kanaries/react-beautiful-dnd": "0.0.1","@kanaries/web-data-loader": "0.1.5",diff --git a/packages/graphic-walker/src/components/button/base.ts b/packages/graphic-walker/src/components/button/base.tsindex 1a2cd693..aca515b8 100644--- a/packages/graphic-walker/src/components/button/base.ts+++ b/packages/graphic-walker/src/components/button/base.ts@@ -4,4 +4,5 @@ export interface ButtonBaseProps {onClick: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;text: string;disabled?: boolean;+ className?: string;}\ No newline at end of filediff --git a/packages/graphic-walker/src/components/button/default.tsx b/packages/graphic-walker/src/components/button/default.tsxindex d007e259..c3d07781 100644--- a/packages/graphic-walker/src/components/button/default.tsx+++ b/packages/graphic-walker/src/components/button/default.tsx@@ -2,10 +2,14 @@ import React from "react";import { ButtonBaseProps } from "./base";const DefaultButton: React.FC<ButtonBaseProps> = (props) => {- const { text, onClick, disabled } = props;+ const { text, onClick, disabled, className } = props;+ let btnClassName = "inline-flex items-center rounded border border-gray-300 bg-white px-2.5 py-1.5 text-xs font-medium text-gray-700 shadow-sm hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 disabled:opacity-50"+ if (className) {+ btnClassName = btnClassName + " " + className;+ }return (<button- className="inline-block min-w-96 text-xs ml-2 pt-1 pb-1 pl-6 pr-6 border border-gray-500 rounded-sm hover:bg-gray-800 hover:border-gray-800 hover:text-white disabled:bg-gray-400 disabled:border-gray-400 disabled:text-white disabled:cursor-not-allowed disabled:text-white"+ className={btnClassName}onClick={onClick}disabled={disabled}>diff --git a/packages/graphic-walker/src/components/button/defaultMini.tsx b/packages/graphic-walker/src/components/button/defaultMini.tsxnew file mode 100644index 00000000..adcf9dab--- /dev/null+++ b/packages/graphic-walker/src/components/button/defaultMini.tsx@@ -0,0 +1,17 @@+import React from "react";+import { ButtonBaseProps } from "./base";++const DefaultMiniButton: React.FC<ButtonBaseProps> = (props) => {+ const { text, onClick, disabled } = props;+ return (+ <button+ className="inline-block min-w-96 text-xs ml-2 pt-1 pb-1 pl-6 pr-6 border border-gray-500 rounded-sm hover:bg-gray-800 hover:border-gray-800 hover:text-white disabled:bg-gray-400 disabled:border-gray-400 disabled:text-white disabled:cursor-not-allowed disabled:text-white"+ onClick={onClick}+ disabled={disabled}+ >+ {text}+ </button>+ );+};++export default DefaultMiniButton;diff --git a/packages/graphic-walker/src/components/button/primary.tsx b/packages/graphic-walker/src/components/button/primary.tsxindex 8b92deed..b7628e50 100644--- a/packages/graphic-walker/src/components/button/primary.tsx+++ b/packages/graphic-walker/src/components/button/primary.tsx@@ -2,10 +2,14 @@ import React from "react";import { ButtonBaseProps } from "./base";const PrimaryButton: React.FC<ButtonBaseProps> = (props) => {- const { text, onClick, disabled } = props;+ const { text, onClick, disabled, className } = props;+ let btnClassName = "inline-flex items-center rounded border border-transparent bg-indigo-600 px-2.5 py-1.5 text-xs font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"+ if (className) {+ btnClassName = btnClassName + " " + className;+ }return (<button- className="inline-block min-w-96 text-xs ml-2 pt-1 pb-1 pl-6 pr-6 border border-gray-800 bg-gray-800 text-white rounded-sm hover:bg-white border-gray-800 hover:text-gray-800 cursor-pointer disabled:bg-gray-400 disabled:border-gray-400 disabled:text-white disabled:cursor-not-allowed disabled:text-white"+ className={btnClassName}onClick={onClick}disabled={disabled}>diff --git a/packages/graphic-walker/src/components/button/primaryMini.tsx b/packages/graphic-walker/src/components/button/primaryMini.tsxnew file mode 100644index 00000000..9ada0b29--- /dev/null+++ b/packages/graphic-walker/src/components/button/primaryMini.tsx@@ -0,0 +1,21 @@+import React from "react";+import { ButtonBaseProps } from "./base";++const PrimaryMiniButton: React.FC<ButtonBaseProps> = (props) => {+ const { text, onClick, disabled, className } = props;+ let btnClassName = "inline-block min-w-96 text-xs ml-2 pt-1 pb-1 pl-6 pr-6 border border-gray-800 bg-gray-800 text-white rounded-sm hover:bg-white border-gray-800 hover:text-gray-800 cursor-pointer disabled:bg-gray-400 disabled:border-gray-400 disabled:text-white disabled:cursor-not-allowed disabled:text-white"+ if (className) {+ btnClassName = btnClassName + " " + className;+ }+ return (+ <button+ className={btnClassName}+ onClick={onClick}+ disabled={disabled}+ >+ {text}+ </button>+ );+};++export default PrimaryMiniButton;diff --git a/packages/graphic-walker/src/components/dataTable/index.tsx b/packages/graphic-walker/src/components/dataTable/index.tsxindex 2233751d..7adc7596 100644--- a/packages/graphic-walker/src/components/dataTable/index.tsx+++ b/packages/graphic-walker/src/components/dataTable/index.tsx@@ -3,6 +3,8 @@ import styled from "styled-components";import { IMutField, IRow } from "../../interfaces";import { useTranslation } from "react-i18next";import Pagination from "./pagination";+import { ChevronUpDownIcon } from "@heroicons/react/24/outline";+import DropdownContext from "../dropdownContext";interface DataTableProps {size?: number;@@ -116,53 +118,51 @@ const DataTable: React.FC<DataTableProps> = (props) => {><b>{field.name || field.fid}</b><div>- <select- className={- "px-2 py font-normal mt-2 rounded-full text-xs text-white " +- (field.analyticType === "dimension" ? "bg-blue-500" : "bg-teal-500")- }- // className="border-b border-gray-200 bg-gray-50 pl-0 mt-2 font-light"- value={field.analyticType}- onChange={(e) => {+ <DropdownContext+ options={analyticTypeList}+ onSelect={(value) => {onMetaChange(field.fid, fIndex, {- analyticType: e.target.value as IMutField["analyticType"],+ analyticType: value as IMutField["analyticType"],});}}>- {analyticTypeList.map((type) => (- <option key={type.value} value={type.value}>- {type.label}- </option>- ))}- </select>+ <span+ className={+ "cursor-pointer inline-flex px-2.5 py-0.5 text-xs font-medium mt-1 rounded-full text-xs text-white " ++ (field.analyticType === "dimension" ? "bg-blue-500" : "bg-teal-500")+ }+ >+ {field.analyticType}+ <ChevronUpDownIcon className="ml-2 w-3" />+ </span>+ </DropdownContext></div><div>- <select- className={- "inline-block px-2.5 py-0.5 text-xs font-medium mt-1 rounded-full text-xs text-white " +- getSemanticColors(field)- }- // className="border-b border-gray-200 bg-gray-50 pl-0 mt-2 font-light"- value={field.semanticType}- onChange={(e) => {+ <DropdownContext+ options={semanticTypeList}+ onSelect={(value) => {onMetaChange(field.fid, fIndex, {- semanticType: e.target.value as IMutField["semanticType"],+ semanticType: value as IMutField["semanticType"],});}}>- {semanticTypeList.map((type) => (- <option key={type.value} value={type.value}>- {type.label}- </option>- ))}- </select>+ <span+ className={+ "cursor-pointer inline-flex px-2.5 py-0.5 text-xs font-medium mt-1 rounded-full text-xs text-white " ++ getSemanticColors(field)+ }+ >+ {field.semanticType}+ <ChevronUpDownIcon className="ml-2 w-3" />+ </span>+ </DropdownContext></div></div></th>))}</tr></thead>- <tbody className="divide-y divide-gray-200 bg-white">+ <tbody className="divide-y divide-gray-100 bg-white">{data.slice(from, to).map((row, index) => (<tr className={"divide-x divide-gray-200 " + (index % 2 ? "bg-gray-50" : "")} key={index}>{metas.map((field) => (diff --git a/packages/graphic-walker/src/components/dataTable/pagination.tsx b/packages/graphic-walker/src/components/dataTable/pagination.tsxindex b2f106d6..892e3507 100644--- a/packages/graphic-walker/src/components/dataTable/pagination.tsx+++ b/packages/graphic-walker/src/components/dataTable/pagination.tsx@@ -26,7 +26,7 @@ export default function Pagination(props: PaginationProps) {onClick={() => {onPrev();}}- className="relative inline-flex items-center rounded-md border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50"+ className="relative inline-flex items-center rounded-md border border-gray-300 bg-white px-2.5 py-1.5 text-xs font-medium text-gray-700 hover:bg-gray-50">{t('actions.prev')}</button>@@ -34,7 +34,7 @@ export default function Pagination(props: PaginationProps) {onClick={() => {onNext()}}- className="relative ml-3 inline-flex items-center rounded-md border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50"+ className="relative ml-3 inline-flex items-center rounded-md border border-gray-300 bg-white px-2.5 py-1.5 text-xs font-medium text-gray-700 hover:bg-gray-50">{t('actions.next')}</button>diff --git a/packages/graphic-walker/src/components/dropdownContext/index.tsx b/packages/graphic-walker/src/components/dropdownContext/index.tsxnew file mode 100644index 00000000..6c5eaf72--- /dev/null+++ b/packages/graphic-walker/src/components/dropdownContext/index.tsx@@ -0,0 +1,64 @@+import React, { Fragment } from "react";+import { Menu, Transition } from "@headlessui/react";++function classNames(...classes: string[]) {+ return classes.filter(Boolean).join(" ");+}++export interface IDropdownContextOption {+ label: string;+ value: string;+ disabled?: boolean;+}+interface IDropdownContextProps {+ options?: IDropdownContextOption[];+ disable?: boolean;+ onSelect?: (value: string, index: number) => void;+}+const DropdownContext: React.FC<IDropdownContextProps> = (props) => {+ const { options = [], disable } = props;++ if (disable) {+ return <Fragment>{props.children}</Fragment>;+ }++ return (+ <Menu as="span" className="relative block text-left">+ <Menu.Button className="block w-full text-left">{props.children}</Menu.Button>++ <Transition+ as={Fragment}+ enter="transition ease-out duration-100"+ enterFrom="transform opacity-0 scale-95"+ enterTo="transform opacity-100 scale-100"+ leave="transition ease-in duration-75"+ leaveFrom="transform opacity-100 scale-100"+ leaveTo="transform opacity-0 scale-95"+ >+ <Menu.Items className="absolute left-0 z-50 mt-2 w-56 origin-top-right rounded-md bg-white shadow-lg border border-gray-50 ring-1 ring-black ring-opacity-5 focus:outline-none">+ <div className="py-1">+ {options.map((option, index) => (+ <Menu.Item>+ {(p) => (+ <span+ className={classNames(+ p.active ? "bg-gray-100 text-gray-900" : "text-gray-700",+ "block px-4 py-2 text-sm"+ )}+ onClick={() => {+ props.onSelect && !props.disable && props.onSelect(option.value, index);+ }}+ >+ {option.label}+ </span>+ )}+ </Menu.Item>+ ))}+ </div>+ </Menu.Items>+ </Transition>+ </Menu>+ );+};++export default DropdownContext;diff --git a/packages/graphic-walker/src/components/dropdownSelect/index.tsx b/packages/graphic-walker/src/components/dropdownSelect/index.tsxnew file mode 100644index 00000000..d2c8bee5--- /dev/null+++ b/packages/graphic-walker/src/components/dropdownSelect/index.tsx@@ -0,0 +1,92 @@+import React, { Fragment } from "react";+import { Listbox, Menu, Transition } from "@headlessui/react";+import { CheckIcon, ChevronDownIcon, ChevronUpDownIcon } from "@heroicons/react/24/outline";++function classNames(...classes: string[]) {+ return classes.filter(Boolean).join(" ");+}++export interface IDropdownSelectOption {+ label: string;+ value: string;+ disabled?: boolean;+}+interface IDropdownSelectProps {+ options?: IDropdownSelectOption[];+ disable?: boolean;+ selectedKey: string;+ onSelect?: (value: string) => void;+ placeholder?: string;+ className?: string;+ buttonClassName?: string;+}+const DropdownSelect: React.FC<IDropdownSelectProps> = (props) => {+ const { options = [], disable, selectedKey, onSelect, placeholder = "Select an option", className, buttonClassName } = props;++ const selectedItem = options.find((op) => op.value === selectedKey);++ if (disable) {+ return <Fragment>{props.children}</Fragment>;+ }+ let rootClassName = "flex truncate relative";+ let btnComputedClassName = "grow shrink relative cursor-default text-xs rounded-lg bg-white 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"+ if (buttonClassName) {+ btnComputedClassName = btnComputedClassName + " " + buttonClassName;+ }+ if (className) {+ rootClassName = rootClassName + " " + className;+ }+ return (+ <Listbox+ value={selectedKey}+ onChange={(newKey) => {+ onSelect && onSelect(newKey);+ }}+ >+ <div className={rootClassName}>+ <Listbox.Button className={btnComputedClassName}>+ <span className="block truncate">{selectedItem?.label || ""}</span>+ { selectedItem === undefined && <span className="block truncate text-gray-400">{placeholder}</span>}+ <span className="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2">+ <ChevronUpDownIcon className="h-5 w-5 text-gray-400" aria-hidden="true" />+ </span>+ </Listbox.Button>+ <Transition+ as={Fragment}+ leave="transition ease-in duration-100"+ leaveFrom="opacity-100"+ leaveTo="opacity-0"+ >+ <Listbox.Options className="absolute z-50 mt-1 max-h-60 w-full overflow-auto rounded-md bg-white py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm">+ {options.map((op, opIndex) => (+ <Listbox.Option+ key={op.value}+ className={({ active }) =>+ `relative cursor-default select-none py-2 pl-10 pr-4 ${+ active ? "bg-amber-100 text-amber-900" : "text-gray-900"+ }`+ }+ value={op.value}+ >+ {({ selected }) => (+ <>+ <span className={`block truncate ${selected ? "font-medium" : "font-normal"}`}>+ {op.label}+ </span>+ {selected && (+ <span className="absolute inset-y-0 left-0 flex items-center pl-3 text-amber-600">+ <CheckIcon className="h-5 w-5" aria-hidden="true" />+ </span>+ )}+ </>+ )}+ </Listbox.Option>+ ))}+ </Listbox.Options>+ </Transition>+ </div>+ </Listbox>+ );+};++export default DropdownSelect;diff --git a/packages/graphic-walker/src/components/modal.tsx b/packages/graphic-walker/src/components/modal.tsxindex 334d9c10..a628ad17 100644--- a/packages/graphic-walker/src/components/modal.tsx+++ b/packages/graphic-walker/src/components/modal.tsx@@ -1,6 +1,9 @@import React, { useRef } from "react";import styled from "styled-components";import { XCircleIcon } from "@heroicons/react/24/outline";+import { Fragment, useState } from "react";+import { Dialog, Transition } from "@headlessui/react";+import { ExclamationTriangleIcon, XMarkIcon } from "@heroicons/react/24/outline";const Background = styled.div({position: "fixed",@@ -30,7 +33,7 @@ const Container = styled.div`align-items: center;}> div.container {- padding: 1em;+ padding: 0.5em 1em 1em 1em;}position: fixed;left: 50%;@@ -43,12 +46,12 @@ const Container = styled.div``;interface ModalProps {onClose?: () => void;+ show?: boolean;title?: string;}const Modal: React.FC<ModalProps> = (props) => {- const { onClose, title } = props;+ const { onClose, title, show } = props;const prevMouseDownTimeRef = useRef(0);-return (<Background// This is a safer replacement of onClick handler.@@ -56,7 +59,7 @@ const Modal: React.FC<ModalProps> = (props) => {// at a different element and then released when the mouse is moved on the target element.// This case is required to be prevented, especially disturbing when interacting// with a Slider component.- className="border border-gray-300"+ className={"border border-gray-300 " + (show ? "block" : "hidden")}onMouseDown={() => (prevMouseDownTimeRef.current = Date.now())}onMouseOut={() => (prevMouseDownTimeRef.current = 0)}onMouseUp={() => {@@ -65,17 +68,20 @@ const Modal: React.FC<ModalProps> = (props) => {}}}>- <Container role="dialog" className="shadow-lg" onMouseDown={(e) => e.stopPropagation()}>- <div className="header relative h-9">- <header className="font-bold">{title}</header>- <XCircleIcon- className="text-red-600 absolute right-2 w-6 cursor-pointer"- role="button"- tabIndex={0}- aria-label="close dialog"- onClick={onClose}- />+ <Container role="dialog" className="shadow-lg rounded-md border border-gray-100" onMouseDown={(e) => e.stopPropagation()}>+ <div className="absolute top-0 right-0 hidden pt-4 pr-4 sm:block">+ <button+ type="button"+ className="rounded-md bg-white text-gray-400 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2"+ onClick={() => {+ onClose?.();+ }}+ >+ <span className="sr-only">Close</span>+ <XMarkIcon className="h-6 w-6" aria-hidden="true" />+ </button></div>+ <div className="px-6 pt-4 text-base font-semibold leading-6 text-gray-900">{title}</div><div className="container">{props.children}</div></Container></Background>diff --git a/packages/graphic-walker/src/components/tabs/defaultTab.tsx b/packages/graphic-walker/src/components/tabs/defaultTab.tsxindex c15b4bbe..18f06bce 100644--- a/packages/graphic-walker/src/components/tabs/defaultTab.tsx+++ b/packages/graphic-walker/src/components/tabs/defaultTab.tsx@@ -33,7 +33,7 @@ export default function Default(props: DefaultProps) {tab.key === selectedKey? 'border-indigo-500 text-indigo-600': 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300',- 'whitespace-nowrap py-2 px-1 border-b-2 font-medium text-sm'+ 'whitespace-nowrap py-2 px-1 border-b-2 font-medium text-sm cursor-pointer')}>{tab.label}</span>))}diff --git a/packages/graphic-walker/src/components/tabs/editableTab.tsx b/packages/graphic-walker/src/components/tabs/editableTab.tsxindex 452f85c7..d6aee3cc 100644--- a/packages/graphic-walker/src/components/tabs/editableTab.tsx+++ b/packages/graphic-walker/src/components/tabs/editableTab.tsx@@ -33,7 +33,7 @@ export default function EditableTabs(props: EditableTabsProps) {return (<div className="border-b border-gray-200 overflow-x-auto overflow-y-hidden" onMouseLeave={clearEditStatus}>- <nav className="-mb-px flex h-8 border-gray-200 border-l" role="tablist" aria-label="Tabs">+ <nav className="-mb-px flex h-8 border-gray-200" role="tablist" aria-label="Tabs">{tabs.map((tab, tabIndex) => (<spanrole="tab"@@ -64,9 +64,9 @@ export default function EditableTabs(props: EditableTabsProps) {key={tab.key}className={classNames(tab.key === selectedKey- ? "text-black bg-gray-100"- : "text-gray-500 hover:text-gray-700",- "whitespace-nowrap border-gray-200 py-1 px-2 border-r border-t border-b pr-6 text-sm cursor-pointer"+ ? "border rounded-t"+ : "text-gray-500 hover:text-gray-700 hover:bg-gray-50",+ "whitespace-nowrap border-gray-200 py-1 px-2 pr-6 text-sm cursor-pointer")}/>))}diff --git a/packages/graphic-walker/src/dataSource/dataSelection/csvData.tsx b/packages/graphic-walker/src/dataSource/dataSelection/csvData.tsxindex a85914d4..4f3cc7d8 100644--- a/packages/graphic-walker/src/dataSource/dataSelection/csvData.tsx+++ b/packages/graphic-walker/src/dataSource/dataSelection/csvData.tsx@@ -45,8 +45,9 @@ const CSVData: React.FC<ICSVData> = (props) => {}}}/>- <div className="mt-1 mb-1">+ <div className="my-1"><DefaultButton+ className="mr-2"onClick={() => {if (fileRef.current) {fileRef.current.click();@@ -55,6 +56,7 @@ const CSVData: React.FC<ICSVData> = (props) => {text={t("open")}/><PrimaryButton+ className="mr-2"text={t("submit")}disabled={tmpDataSource.length === 0}onClick={() => {diff --git a/packages/graphic-walker/src/dataSource/dataSelection/index.tsx b/packages/graphic-walker/src/dataSource/dataSelection/index.tsxindex 847722a2..f13a52ed 100644--- a/packages/graphic-walker/src/dataSource/dataSelection/index.tsx+++ b/packages/graphic-walker/src/dataSource/dataSelection/index.tsx@@ -3,7 +3,7 @@ import { useState } from "react";import CSVData from "./csvData";import PublicData from "./publicData";import { useTranslation } from "react-i18next";-import PureTabs from "../../components/tabs/editableTab";+import PureTabs from "../../components/tabs/defaultTab";const DataSelection: React.FC = (props) => {const [sourceType, setSourceType] = useState<"file" | "public">("file");@@ -26,7 +26,6 @@ const DataSelection: React.FC = (props) => {setSourceType(sk as "public" | "file");}}/>- <hr className="mt-1 mb-1" />{sourceType === "file" && <CSVData />}{sourceType === "public" && <PublicData />}</div>diff --git a/packages/graphic-walker/src/dataSource/dataSelection/publicData.tsx b/packages/graphic-walker/src/dataSource/dataSelection/publicData.tsxindex 0477d5d0..78890393 100644--- a/packages/graphic-walker/src/dataSource/dataSelection/publicData.tsx+++ b/packages/graphic-walker/src/dataSource/dataSelection/publicData.tsx@@ -43,13 +43,12 @@ const PublicData: React.FC<IPublicDataProps> = props => {</div>)}</div>- <hr className="m-1" /><PrimaryButton+ className='my-1'disabled={tmpDataSource.length === 0}onClick={() => { commonStore.commitTempDS() }}text={t('submit')}/>- <hr className="m-1" /><Table /></div>}diff --git a/packages/graphic-walker/src/dataSource/index.tsx b/packages/graphic-walker/src/dataSource/index.tsxindex 0eb14a19..54a14170 100644--- a/packages/graphic-walker/src/dataSource/index.tsx+++ b/packages/graphic-walker/src/dataSource/index.tsx@@ -1,20 +1,22 @@-import React, { useRef } from 'react';-import { observer } from 'mobx-react-lite';-import { CheckCircleIcon, ArrowPathIcon } from '@heroicons/react/24/outline';-import { useTranslation } from 'react-i18next';-import { Container } from '../components/container';-import Modal from '../components/modal';-import { useGlobalStore } from '../store';-import { download } from '../utils/save';-import GwFile from './dataSelection/gwFile';-import DataSelection from './dataSelection';-import DefaultButton from '../components/button/default';+import React, { useRef } from "react";+import { observer } from "mobx-react-lite";+import { CheckCircleIcon, ArrowPathIcon } from "@heroicons/react/24/outline";+import { useTranslation } from "react-i18next";+import { Container } from "../components/container";+import Modal from "../components/modal";+import { useGlobalStore } from "../store";+import { download } from "../utils/save";+import GwFile from "./dataSelection/gwFile";+import DataSelection from "./dataSelection";+import DefaultButton from "../components/button/default";+import DropdownSelect from "../components/dropdownSelect";+import PrimaryButton from "../components/button/primary";interface DSSegmentProps {preWorkDone: boolean;}-const DataSourceSegment: React.FC<DSSegmentProps> = props => {+const DataSourceSegment: React.FC<DSSegmentProps> = (props) => {const { preWorkDone } = props;const { commonStore, vizStore } = useGlobalStore();const gwFileRef = useRef<HTMLInputElement>(null);@@ -22,55 +24,73 @@ const DataSourceSegment: React.FC<DSSegmentProps> = props => {const { currentDataset, datasets, showDSPanel } = commonStore;- return <Container className="flex flex-row items-stretch">- <GwFile fileRef={gwFileRef} />- {!preWorkDone && <div className="animate-spin inline-block mr-2 ml-2 w-4 h-4 rounded-full border-t-2 border-l-2 border-blue-500"></div>}- <label className="text-xs mr-1 whitespace-nowrap self-center h-4">- {t('DataSource.labels.cur_dataset')}- </label>- <select- className="border border-gray-500 rounded-sm text-xs pt-0.5 pb-0.5 pl-2 pr-2"- value={currentDataset.id}- onChange={(e) => { commonStore.useDS(e.target.value); }}- >- {datasets.map((ds) => (- <option value={ds.id} key={ds.id}>- {ds.name}- </option>- ))}- </select>+ return (+ <Container className="flex items-center">+ <GwFile fileRef={gwFileRef} />+ {!preWorkDone && (+ <div className="animate-spin inline-block mr-2 ml-2 w-4 h-4 rounded-full border-t-2 border-l-2 border-blue-500"></div>+ )}+ {/* <label className="text-xs mr-1 whitespace-nowrap self-center h-4">+ {t("DataSource.labels.cur_dataset")}+ </label> */}+ <div className="mr-2">+ <DropdownSelect+ options={datasets.map((d) => ({ label: d.name, value: d.id }))}+ selectedKey={currentDataset.id}+ onSelect={(dsKey) => {+ commonStore.useDS(dsKey);+ }}+ placeholder={t("DataSource.labels.cur_dataset")}+ />+ </div>- <DefaultButton- text={t('DataSource.buttons.create_dataset')}- onClick={() => { commonStore.startDSBuildingTask() }}- />- <DefaultButton- text={t('DataSource.buttons.export_as_file')}- onClick={() => {- const res = vizStore.exportAsRaw();- download(res, 'graphic-walker-notebook.json', 'text/plain')- }}- />- <DefaultButton- text={t('DataSource.buttons.import_file')}- onClick={() => {- if (gwFileRef.current) {- gwFileRef.current.click();- }- }}- />- {showDSPanel && (+ <PrimaryButton+ className="mr-2"+ text={t("DataSource.buttons.create_dataset")}+ onClick={() => {+ commonStore.startDSBuildingTask();+ }}+ />+ <DefaultButton+ className="mr-2"+ text={t("DataSource.buttons.export_as_file")}+ onClick={() => {+ const res = vizStore.exportAsRaw();+ download(res, "graphic-walker-notebook.json", "text/plain");+ }}+ />+ <DefaultButton+ className="mr-2"+ text={t("DataSource.buttons.import_file")}+ onClick={() => {+ if (gwFileRef.current) {+ gwFileRef.current.click();+ }+ }}+ /><Modal- title={t('DataSource.dialog.create_data_source')}- onClose={() => { commonStore.setShowDSPanel(false) }}- >- <DataSelection />- {/* <DataSourcePanel /> */}- </Modal>- )}- { preWorkDone && <CheckCircleIcon className="text-green-500 w-5 inline-block ml-2" /> }- { !preWorkDone && <ArrowPathIcon className="text-yellow-500 w-5 inline-block ml-2" />}- </Container>-}+ title={t("DataSource.dialog.create_data_source")}+ onClose={() => {+ commonStore.setShowDSPanel(false);+ }}+ show={showDSPanel}+ >+ <DataSelection />+ </Modal>+ {/* {showDSPanel && (+ <Modal+ title={t("DataSource.dialog.create_data_source")}+ onClose={() => {+ commonStore.setShowDSPanel(false);+ }}+ >+ <DataSelection />+ </Modal>+ )} */}+ {preWorkDone && <CheckCircleIcon className="text-green-500 w-5 inline-block ml-2" />}+ {!preWorkDone && <ArrowPathIcon className="text-yellow-500 w-5 inline-block ml-2" />}+ </Container>+ );+};-export default observer(DataSourceSegment);\ No newline at end of file+export default observer(DataSourceSegment);diff --git a/packages/graphic-walker/src/fields/aestheticFields.tsx b/packages/graphic-walker/src/fields/aestheticFields.tsxindex e9dd2141..5ea31284 100644--- a/packages/graphic-walker/src/fields/aestheticFields.tsx+++ b/packages/graphic-walker/src/fields/aestheticFields.tsx@@ -3,6 +3,7 @@ import { Droppable } from "@kanaries/react-beautiful-dnd";import { DRAGGABLE_STATE_KEYS } from './fieldsContext';import { AestheticFieldContainer } from './components'import OBFieldContainer from './obComponents/obFContainer';+import SingleEncodeEditor from './encodeFields/singleEncodeEditor';const aestheticFields = DRAGGABLE_STATE_KEYS.filter(f => ['color', 'opacity', 'size', 'shape'].includes(f.id));@@ -12,7 +13,8 @@ const AestheticFields: React.FC = props => {aestheticFields.map(dkey => <AestheticFieldContainer name={dkey.id} key={dkey.id}><Droppable droppableId={dkey.id} direction="horizontal">{(provided, snapshot) => (- <OBFieldContainer dkey={dkey} provided={provided} />+ // <OBFieldContainer dkey={dkey} provided={provided} />+ <SingleEncodeEditor dkey={dkey} provided={provided} />)}</Droppable></AestheticFieldContainer>)diff --git a/packages/graphic-walker/src/fields/components.tsx b/packages/graphic-walker/src/fields/components.tsxindex d8011471..cd58a611 100644--- a/packages/graphic-walker/src/fields/components.tsx+++ b/packages/graphic-walker/src/fields/components.tsx@@ -16,7 +16,7 @@ export const AestheticSegment = styled.div`}}.aes-container{- overflow-x: auto;+ /* overflow-x: auto; */}`@@ -144,7 +144,7 @@ export const Pill = styled.div<{colType: 'discrete' | 'continuous'}>`font-size: 12px;height: 20px;min-width: 150px;- overflow-y: hidden;+ /* overflow-y: hidden; */padding: 0 10px;user-select: none;text-overflow: ellipsis;diff --git a/packages/graphic-walker/src/fields/datasetFields/meaFields.tsx b/packages/graphic-walker/src/fields/datasetFields/meaFields.tsxindex 09514860..99c2cd47 100644--- a/packages/graphic-walker/src/fields/datasetFields/meaFields.tsx+++ b/packages/graphic-walker/src/fields/datasetFields/meaFields.tsx@@ -1,58 +1,78 @@-import React from 'react';-import { Draggable, DroppableProvided } from '@kanaries/react-beautiful-dnd';-import { observer } from 'mobx-react-lite';-import { useGlobalStore } from '../../store';-import DataTypeIcon from '../../components/dataTypeIcon';-import { FieldPill } from './fieldPill';+import React, { useCallback, useMemo } from "react";+import { Draggable, DroppableProvided } from "@kanaries/react-beautiful-dnd";+import { observer } from "mobx-react-lite";+import { useGlobalStore } from "../../store";+import DataTypeIcon from "../../components/dataTypeIcon";+import { FieldPill } from "./fieldPill";+import DropdownContext, { IDropdownContextOption } from "../../components/dropdownContext";++interface Props {provided: DroppableProvided;}-const MeaFields: React.FC<Props> = props => {+const MeaFields: React.FC<Props> = (props) => {const { provided } = props;const { vizStore } = useGlobalStore();const measures = vizStore.draggableFieldState.measures;- return <div {...provided.droppableProps} ref={provided.innerRef}>- {measures.map((f, index) => (- <Draggable key={f.dragId} draggableId={f.dragId} index={index}>- {(provided, snapshot) => {- return (- <>- <FieldPill- 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"- isDragging={snapshot.isDragging}- ref={provided.innerRef}- {...provided.draggableProps}- {...provided.dragHandleProps}- >- <DataTypeIcon dataType={f.semanticType} analyticType={f.analyticType} /> {f.name} ++ const MEA_ACTION_OPTIONS = useMemo<IDropdownContextOption[]>(() => {+ return [+ {+ value: 'bin',+ label: 'Bin',+ },+ {+ value: 'log10',+ label: 'Log10',+ }+ ]+ }, [])++ const fieldActionHandler = useCallback((selectedValue: any, index: number) => {+ if (selectedValue === 'bin') {+ vizStore.createBinField("measures", index);+ } else if (selectedValue === 'log10') {+ vizStore.createLogField("measures", index);+ }+ }, [])+ return (+ <div {...provided.droppableProps} ref={provided.innerRef}>+ {measures.map((f, index) => (+ <Draggable key={f.dragId} draggableId={f.dragId} index={index}>+ {(provided, snapshot) => {+ return (+ <div className="block">+ <DropdownContext disable={snapshot.isDragging} options={MEA_ACTION_OPTIONS} onSelect={fieldActionHandler}>+ <FieldPill+ 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 ${snapshot.isDragging ? 'bg-blue-100' : ''}`}+ isDragging={snapshot.isDragging}+ ref={provided.innerRef}+ {...provided.draggableProps}+ {...provided.dragHandleProps}+ >+ <DataTypeIcon dataType={f.semanticType} analyticType={f.analyticType} />{" "}+ {f.name} + </FieldPill>+ </DropdownContext>{- f.fid && !snapshot.isDragging && <select className="bg-transparent text-gray-700 float-right focus:outline-none focus:border-gray-500" value="" onChange={e => {- if (e.target.value === 'bin') {- vizStore.createBinField('measures', index)- } else if (e.target.value === 'log10') {- vizStore.createLogField('measures', index)- }- }}>- <option value=""></option>- <option value="bin">bin</option>- <option value="log10">log10</option>- </select>+ <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 ? "bg-blue-100" : "hidden"+ }`}+ isDragging={snapshot.isDragging}+ >+ <DataTypeIcon dataType={f.semanticType} analyticType={f.analyticType} />{" "}+ {f.name} + </FieldPill>}- </FieldPill>- {- <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'}`}- isDragging={snapshot.isDragging}- >- <DataTypeIcon dataType={f.semanticType} analyticType={f.analyticType} /> {f.name} - </FieldPill>- }- </>- );- }}- </Draggable>- ))}- </div>-}+ </div>+ );+ }}+ </Draggable>+ ))}+ </div>+ );+};export default observer(MeaFields);diff --git a/packages/graphic-walker/src/fields/encodeFields/singleEncodeDropDown.tsx b/packages/graphic-walker/src/fields/encodeFields/singleEncodeDropDown.tsxnew file mode 100644index 00000000..e14712c9--- /dev/null+++ b/packages/graphic-walker/src/fields/encodeFields/singleEncodeDropDown.tsx@@ -0,0 +1,92 @@+import React, { Fragment } from "react";+import { Listbox, Menu, Transition } from "@headlessui/react";+import { CheckIcon, ChevronDownIcon, ChevronUpDownIcon } from "@heroicons/react/24/outline";++function classNames(...classes: string[]) {+ return classes.filter(Boolean).join(" ");+}++export interface IDropdownSelectOption {+ label: string;+ value: string;+ disabled?: boolean;+}+interface IDropdownSelectProps {+ options?: IDropdownSelectOption[];+ disable?: boolean;+ selectedKey: string;+ onSelect?: (value: string) => void;+ placeholder?: string;+ className?: string;+ buttonClassName?: string;+}+const DropdownSelect: React.FC<IDropdownSelectProps> = (props) => {+ const { options = [], disable, selectedKey, onSelect, placeholder = "Select an option", className, buttonClassName } = props;++ const selectedItem = options.find((op) => op.value === selectedKey);++ if (disable) {+ return <Fragment>{props.children}</Fragment>;+ }+ let rootClassName = "flex truncate";+ let btnComputedClassName = "grow shrink relative cursor-default text-xs rounded-lg bg-white 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"+ if (buttonClassName) {+ btnComputedClassName = btnComputedClassName + " " + buttonClassName;+ }+ if (className) {+ rootClassName = rootClassName + " " + className;+ }+ return (+ <Listbox+ value={selectedKey}+ onChange={(newKey) => {+ onSelect && onSelect(newKey);+ }}+ >+ <div className={rootClassName}>+ <Listbox.Button className={btnComputedClassName}>+ <span className="block truncate">{selectedItem?.label || ""}</span>+ { selectedItem === undefined && <span className="block truncate text-gray-400">{placeholder}</span>}+ <span className="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2">+ <ChevronUpDownIcon className="h-5 w-5 text-gray-400" aria-hidden="true" />+ </span>+ </Listbox.Button>+ <Transition+ as={Fragment}+ leave="transition ease-in duration-100"+ leaveFrom="opacity-100"+ leaveTo="opacity-0"+ >+ <Listbox.Options className="absolute z-50 mt-8 max-h-60 w-full overflow-auto rounded-md bg-white py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm">+ {options.map((op, opIndex) => (+ <Listbox.Option+ key={op.value}+ className={({ active }) =>+ `relative cursor-default select-none py-2 pl-10 pr-4 ${+ active ? "bg-amber-100 text-amber-900" : "text-gray-900"+ }`+ }+ value={op.value}+ >+ {({ selected }) => (+ <>+ <span className={`block truncate ${selected ? "font-medium" : "font-normal"}`}>+ {op.label}+ </span>+ {selected && (+ <span className="absolute inset-y-0 left-0 flex items-center pl-3 text-amber-600">+ <CheckIcon className="h-5 w-5" aria-hidden="true" />+ </span>+ )}+ </>+ )}+ </Listbox.Option>+ ))}+ </Listbox.Options>+ </Transition>+ </div>+ </Listbox>+ );+};++export default DropdownSelect;diff --git a/packages/graphic-walker/src/fields/encodeFields/singleEncodeEditor.tsx b/packages/graphic-walker/src/fields/encodeFields/singleEncodeEditor.tsxnew file mode 100644index 00000000..8fb3b810--- /dev/null+++ b/packages/graphic-walker/src/fields/encodeFields/singleEncodeEditor.tsx@@ -0,0 +1,45 @@+import React from "react";+import { IDraggableStateKey } from "../../interfaces";+import { observer } from "mobx-react-lite";+import { useGlobalStore } from "../../store";+import DropdownSelect from "./singleEncodeDropDown";+import { DroppableProvided } from "react-beautiful-dnd";+import { PlusSmallIcon, TrashIcon } from "@heroicons/react/24/outline";+import { useTranslation } from "react-i18next";++interface SingleEncodeEditorProps {+ dkey: IDraggableStateKey;+ provided: DroppableProvided;+}+const SingleEncodeEditor: React.FC<SingleEncodeEditorProps> = (props) => {+ const { dkey, provided } = props;+ const { vizStore } = useGlobalStore();+ const { draggableFieldState } = vizStore;+ const channelItem = draggableFieldState[dkey.id][0];+ const allFieldOptions = draggableFieldState.dimensions.concat(draggableFieldState.measures).map((f) => ({+ value: f.fid,+ label: f.name,+ }));+ const { t } = useTranslation();+ return (+ <div className="p-1 flex items-center relative" {...provided.droppableProps} ref={provided.innerRef}>+ {channelItem && (+ <div+ onClick={() => {+ vizStore.removeField(dkey.id, 0);+ }}+ className="p-1.5 bg-red-50 shrink-0 grow-0 border border-red-200 cursor-pointer"+ >+ <TrashIcon className="w-4" />+ </div>+ )}+ {channelItem && (+ <DropdownSelect className="shrink grow static" buttonClassName="rounded-none" options={allFieldOptions} selectedKey={channelItem.fid} onSelect={(value) => {}} />+ )}+ {!channelItem && <div className="p-1.5 bg-gray-50 shrink-0 grow-0 border border-gray-200 flex item-center justify-center grow text-gray-500">+ <PlusSmallIcon className="w-4" />{t('actions.drop_field')}</div>}+ </div>+ );+};++export default observer(SingleEncodeEditor);diff --git a/packages/graphic-walker/src/fields/filterField/filterEditDialog.tsx b/packages/graphic-walker/src/fields/filterField/filterEditDialog.tsxindex 02fdaa78..bcd39035 100644--- a/packages/graphic-walker/src/fields/filterField/filterEditDialog.tsx+++ b/packages/graphic-walker/src/fields/filterField/filterEditDialog.tsx@@ -109,6 +109,7 @@ const FilterEditDialog: React.FC = observer(() => {return uncontrolledField ? (<Modal+ show={Boolean(uncontrolledField)}title={t('editing')}onClose={() => vizStore.closeFilterEditing()}>diff --git a/packages/graphic-walker/src/fields/obComponents/obPill.tsx b/packages/graphic-walker/src/fields/obComponents/obPill.tsxindex 50ae342a..363bf550 100644--- a/packages/graphic-walker/src/fields/obComponents/obPill.tsx+++ b/packages/graphic-walker/src/fields/obComponents/obPill.tsx@@ -1,48 +1,78 @@-import { BarsArrowDownIcon, BarsArrowUpIcon } from '@heroicons/react/24/outline';-import { observer } from 'mobx-react-lite';-import React from 'react';-import { useTranslation } from 'react-i18next';-import { DraggableProvided } from '@kanaries/react-beautiful-dnd';-import { COUNT_FIELD_ID } from '../../constants';-import { IDraggableStateKey } from '../../interfaces';-import { useGlobalStore } from '../../store';-import { Pill } from '../components';-import { AGGREGATOR_LIST } from '../fieldsContext';-+import { BarsArrowDownIcon, BarsArrowUpIcon, ChevronUpDownIcon } from "@heroicons/react/24/outline";+import { observer } from "mobx-react-lite";+import React, { useMemo } from "react";+import { useTranslation } from "react-i18next";+import { DraggableProvided } from "@kanaries/react-beautiful-dnd";+import { COUNT_FIELD_ID } from "../../constants";+import { IDraggableStateKey } from "../../interfaces";+import { useGlobalStore } from "../../store";+import { Pill } from "../components";+import { AGGREGATOR_LIST } from "../fieldsContext";+import DropdownContext from "../../components/dropdownContext";interface PillProps {provided: DraggableProvided;fIndex: number;dkey: IDraggableStateKey;}-const OBPill: React.FC<PillProps> = props => {+const OBPill: React.FC<PillProps> = (props) => {const { provided, dkey, fIndex } = props;const { vizStore } = useGlobalStore();const { visualConfig } = vizStore;const field = vizStore.draggableFieldState[dkey.id][fIndex];- const { t } = useTranslation('translation', { keyPrefix: 'constant.aggregator' });+ const { t } = useTranslation("translation", { keyPrefix: "constant.aggregator" });- return <Pill- ref={provided.innerRef}- colType={field.analyticType === 'dimension' ? 'discrete' : 'continuous'}- {...provided.draggableProps}- {...provided.dragHandleProps}- >- {field.name} - {field.analyticType === 'measure' && field.fid !== COUNT_FIELD_ID && visualConfig.defaultAggregated && (- <select- className="bg-transparent text-gray-700 float-right focus:outline-none focus:border-gray-500"- value={field.aggName || ''}- onChange={(e) => { vizStore.setFieldAggregator(dkey.id, fIndex, e.target.value) }}- >- {- AGGREGATOR_LIST.map(op => <option value={op} key={op}>{t(op)}</option>)- }- </select>- )}- {field.analyticType === 'dimension' && field.sort === 'ascending' && <BarsArrowUpIcon className='float-right w-3' role="status" aria-label="Sorted in ascending order" />}- {field.analyticType === 'dimension' && field.sort === 'descending' && <BarsArrowDownIcon className='float-right w-3' role="status" aria-label="Sorted in descending order" />}- </Pill>-}+ const aggregationOptions = useMemo(() => {+ return AGGREGATOR_LIST.map((op) => ({+ value: op,+ label: t(op),+ }));+ }, []);++ return (+ <Pill+ ref={provided.innerRef}+ colType={field.analyticType === "dimension" ? "discrete" : "continuous"}+ {...provided.draggableProps}+ {...provided.dragHandleProps}+ >+ <span>{field.name}</span> + {field.analyticType === "measure" && field.fid !== COUNT_FIELD_ID && visualConfig.defaultAggregated && (+ <DropdownContext+ options={aggregationOptions}+ onSelect={(value) => {+ vizStore.setFieldAggregator(dkey.id, fIndex, value);+ }}+ >+ <span className="bg-transparent text-gray-700 float-right focus:outline-none focus:border-gray-500 flex items-center ml-2">+ {field.aggName || ""}+ <ChevronUpDownIcon className="w-3" />+ </span>+ </DropdownContext>+ )}+ {/* {field.analyticType === "measure" && field.fid !== COUNT_FIELD_ID && visualConfig.defaultAggregated && (+ <select+ className="bg-transparent text-gray-700 float-right focus:outline-none focus:border-gray-500"+ value={field.aggName || ""}+ onChange={(e) => {+ vizStore.setFieldAggregator(dkey.id, fIndex, e.target.value);+ }}+ >+ {AGGREGATOR_LIST.map((op) => (+ <option className="inline" value={op} key={op}>+ {t(op)}+ </option>+ ))}+ </select>+ )} */}+ {field.analyticType === "dimension" && field.sort === "ascending" && (+ <BarsArrowUpIcon className="float-right w-3" role="status" aria-label="Sorted in ascending order" />+ )}+ {field.analyticType === "dimension" && field.sort === "descending" && (+ <BarsArrowDownIcon className="float-right w-3" role="status" aria-label="Sorted in descending order" />+ )}+ </Pill>+ );+};export default observer(OBPill);diff --git a/packages/graphic-walker/src/insightBoard/index.tsx b/packages/graphic-walker/src/insightBoard/index.tsxindex d173bca2..56b9cdfa 100644--- a/packages/graphic-walker/src/insightBoard/index.tsx+++ b/packages/graphic-walker/src/insightBoard/index.tsx@@ -1,30 +1,28 @@-import { toJS } from 'mobx';-import { observer } from 'mobx-react-lite';-import React, { useCallback } from 'react';-import Modal from '../components/modal';-import { useGlobalStore } from '../store';-import InsightMainBoard from './mainBoard';+import { toJS } from "mobx";+import { observer } from "mobx-react-lite";+import React, { useCallback } from "react";+import Modal from "../components/modal";+import { useGlobalStore } from "../store";+import InsightMainBoard from "./mainBoard";-const InsightBoard: React.FC = props => {+const InsightBoard: React.FC = (props) => {const { commonStore, vizStore } = useGlobalStore();const { showInsightBoard, currentDataset, filters } = commonStore;const { viewDimensions, viewMeasures, draggableFieldState } = vizStore;const onCloseModal = useCallback(() => {commonStore.setShowInsightBoard(false);- }, [])- return <div>- {- showInsightBoard && <Modal onClose={onCloseModal}>- <InsightMainBoard- dataSource={currentDataset.dataSource}- fields={toJS(draggableFieldState.fields)}- viewDs={viewDimensions}- viewMs={viewMeasures}- filters={toJS(filters)}- />- </Modal>- }- </div>-}+ }, []);+ return (+ <Modal onClose={onCloseModal} show={showInsightBoard}>+ <InsightMainBoard+ dataSource={currentDataset.dataSource}+ fields={toJS(draggableFieldState.fields)}+ viewDs={viewDimensions}+ viewMs={viewMeasures}+ filters={toJS(filters)}+ />+ </Modal>+ );+};-export default observer(InsightBoard);\ No newline at end of file+export default observer(InsightBoard);diff --git a/packages/graphic-walker/src/locales/en-US.json b/packages/graphic-walker/src/locales/en-US.jsonindex 0f96cf80..eb80f205 100644--- a/packages/graphic-walker/src/locales/en-US.json+++ b/packages/graphic-walker/src/locales/en-US.json@@ -50,8 +50,8 @@},"draggable_key": {"fields": "Fields",- "columns": "Columns",- "rows": "Rows",+ "columns": "X-Axis",+ "rows": "Y-Axis","color": "Color","opacity": "Opacity","size": "Size",@@ -184,6 +184,7 @@},"actions": {"prev": "Previous",- "next": "Next"+ "next": "Next",+ "drop_field": "Drop Field Here"}}\ No newline at end of filediff --git a/packages/graphic-walker/src/locales/zh-CN.json b/packages/graphic-walker/src/locales/zh-CN.jsonindex 5a178a54..4ba122dd 100644--- a/packages/graphic-walker/src/locales/zh-CN.json+++ b/packages/graphic-walker/src/locales/zh-CN.json@@ -184,6 +184,7 @@},"actions": {"prev": "向前",- "next": "向后"+ "next": "向后",+ "drop_field": "拖拽字段至此"}}\ No newline at end of filediff --git a/packages/graphic-walker/src/vis/react-vega.tsx b/packages/graphic-walker/src/vis/react-vega.tsxindex 273aa206..c80cac5d 100644--- a/packages/graphic-walker/src/vis/react-vega.tsx+++ b/packages/graphic-walker/src/vis/react-vega.tsx@@ -11,6 +11,7 @@ import { COUNT_FIELD_ID } from '../constants';import { IViewField, IRow, IStackMode } from '../interfaces';import { useTranslation } from 'react-i18next';import { getVegaTimeFormatRules } from './temporalFormat';+import { DEFAULT_THEME } from './theme';const CanvaContainer = styled.div<{rowSize: number; colSize: number;}>`display: grid;@@ -502,7 +503,7 @@ const ReactVega = forwardRef<IReactVegaHandler, ReactVegaProps>(function ReactVespec.params.push(...singleView.params!);}if (viewPlaceholders.length > 0 && viewPlaceholders[0].current) {- embed(viewPlaceholders[0].current, spec, { mode: 'vega-lite', actions: showActions, timeFormatLocale: getVegaTimeFormatRules(i18n.language) }).then(res => {+ embed(viewPlaceholders[0].current, spec, { mode: 'vega-lite', actions: showActions, timeFormatLocale: getVegaTimeFormatRules(i18n.language), config: DEFAULT_THEME }).then(res => {vegaRefs.current = [res.view];try {res.view.addEventListener('click', (e) => {diff --git a/packages/graphic-walker/src/vis/theme.ts b/packages/graphic-walker/src/vis/theme.tsnew file mode 100644index 00000000..ddc7a5ee--- /dev/null+++ b/packages/graphic-walker/src/vis/theme.ts@@ -0,0 +1,30 @@+const DEFAULT_COLOR = "#5B8FF9";+export const DEFAULT_THEME = {+ area: { fill: DEFAULT_COLOR },+ bar: { fill: DEFAULT_COLOR },+ circle: { fill: DEFAULT_COLOR },+ line: { stroke: DEFAULT_COLOR },+ point: { stroke: DEFAULT_COLOR },+ rect: { fill: DEFAULT_COLOR },+ tick: { stroke: DEFAULT_COLOR },+ boxplot: { fill: DEFAULT_COLOR },+ errorbar: { stroke: DEFAULT_COLOR },+ errorband: { fill: DEFAULT_COLOR },+ arc: { fill: DEFAULT_COLOR },+ range: {+ category: [+ "#5B8FF9",+ "#61DDAA",+ "#65789B",+ "#F6BD16",+ "#7262FD",+ "#78D3F8",+ "#9661BC",+ "#F6903D",+ "#008685",+ "#F08BB4",+ ],+ diverging: ["#7b3294", "#c2a5cf", "#f7f7f7", "#a6dba0", "#008837"],+ heatmap: ["#000000", "#7b3294", "#c2a5cf", "#f7f7f7", "#a6dba0", "#008837"],+ },+};diff --git a/packages/graphic-walker/src/visualSettings/index.tsx b/packages/graphic-walker/src/visualSettings/index.tsxindex 2da24a2e..e2672961 100644--- a/packages/graphic-walker/src/visualSettings/index.tsx+++ b/packages/graphic-walker/src/visualSettings/index.tsx@@ -152,7 +152,7 @@ const VisualSettings: React.FC<IVisualSettings> = ({ rendererHandler }) => {{key: 'mark_type',label: tGlobal('constant.mark_type.__enum__'),- icon: StopIcon,+ icon: () => <StopIcon className="text-orange-500" />,options: GEMO_TYPES.map(g => ({key: g,label: tGlobal(`constant.mark_type.${g}`),diff --git a/yarn.lock b/yarn.lockindex 26645ad1..ca275f59 100644--- a/yarn.lock+++ b/yarn.lock@@ -504,6 +504,13 @@resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.16.17.tgz#c5a1a4bfe1b57f0c3e61b29883525c6da3e5c091"integrity sha512-y+EHuSchhL7FjHgvQL/0fnnFmO4T1bhvWANX6gcnqTjtnKWbTvUMCpGnv2+t+31d7RzyEAYAd4u2fnIhHL6N/Q==+"@headlessui/react@^1.7.12":+ version "1.7.12"+ resolved "https://registry.npmmirror.com/@headlessui/react/-/react-1.7.12.tgz#9ab2baa3c4f632782631e00937f9531a34033619"+ integrity sha512-FhSx5V+Qp0GvbTpaxyS+ymGDDNntCacClWsk/d8Upbr19g3AsPbjfPk4+m2CgJGcuCB5Dz7LpUIOAbvQTyjL2g==+ dependencies:+ client-only "^0.0.1"+"@heroicons/react@^2.0.8":version "2.0.13"resolved "https://registry.npmmirror.com/@heroicons/react/-/react-2.0.13.tgz#9b1cc54ff77d6625c9565efdce0054a4bcd9074c"@@ -984,6 +991,11 @@ chokidar@^3.5.3:optionalDependencies:fsevents "~2.3.2"+client-only@^0.0.1:+ version "0.0.1"+ resolved "https://registry.npmmirror.com/client-only/-/client-only-0.0.1.tgz#38bba5d403c41ab150bff64a95c85013cf73bca1"+ integrity sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==+cliui@^8.0.1:version "8.0.1"resolved "https://registry.npmmirror.com/cliui/-/cliui-8.0.1.tgz#0c04b075db02cbfe60dc8e6cf2f5486b1a3608aa"