Skip to content

Commit

Permalink
fix: fold types
Browse files Browse the repository at this point in the history
  • Loading branch information
islxyqwe committed Mar 27, 2024
1 parent cca4f93 commit 61cb9c1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
16 changes: 8 additions & 8 deletions packages/graphic-walker/src/components/selectContext/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ import { CheckIcon, Cog6ToothIcon } from '@heroicons/react/24/outline';
import { Float } from '@headlessui-float/react';
import { blockContext } from '../../fields/fieldsContext';

export interface ISelectContextOption {
key: string;
export interface ISelectContextOption<T extends string> {
key: T;
label: string;
disabled?: boolean;
}
interface ISelectContextProps {
options?: ISelectContextOption[];
interface ISelectContextProps<T extends string> {
options?: ISelectContextOption<T>[];
disable?: boolean;
selectedKeys?: string[];
onSelect?: (selectedKeys: string[]) => void;
selectedKeys?: T[];
onSelect?: (selectedKeys: T[]) => void;
className?: string;
required?: boolean;
children?: React.ReactNode | Iterable<React.ReactNode>;
}
const SelectContext: React.FC<ISelectContextProps> = (props) => {
function SelectContext <T extends string>(props: ISelectContextProps<T>) {
const { options = [], disable = false, selectedKeys = [], onSelect, className = '', required } = props;

const [selected, setSelected] = useState<ISelectContextOption[]>(options.filter((opt) => selectedKeys.includes(opt.key)));
const [selected, setSelected] = useState<ISelectContextOption<T>[]>(options.filter((opt) => selectedKeys.includes(opt.key)));

useEffect(() => {
setSelected(options.filter((opt) => selectedKeys.includes(opt.key)));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import React, { useMemo, useContext } from 'react';
import { DraggableFieldState, IAggregator, IDraggableStateKey } from '../../interfaces';
import { DraggableFieldState, IAggregator } from '../../interfaces';
import { observer } from 'mobx-react-lite';
import { DatasetNamesContext, useVizStore } from '../../store';
import { DroppableProvided } from 'react-beautiful-dnd';
import { ChevronUpDownIcon, PencilSquareIcon, TrashIcon } from '@heroicons/react/24/outline';
import { useTranslation } from 'react-i18next';
import { COUNT_FIELD_ID, DEFAULT_DATASET, MEA_KEY_ID, MEA_VAL_ID } from '../../constants';
import { COUNT_FIELD_ID, DEFAULT_DATASET, MEA_KEY_ID } from '../../constants';
import DropdownContext from '../../components/dropdownContext';
import { GLOBAL_CONFIG } from '../../config';
import { Draggable, DroppableStateSnapshot } from '@kanaries/react-beautiful-dnd';
import styled from 'styled-components';
import SelectContext, { type ISelectContextOption } from '../../components/selectContext';
import SelectContext from '../../components/selectContext';
import { refMapper } from '../fieldsContext';
import Tooltip from '@/components/tooltip';
import { EditNamePopover } from '../renamePanel';
import { getFieldIdentifier } from '@/utils';

Expand Down
2 changes: 1 addition & 1 deletion packages/graphic-walker/src/fields/obComponents/obPill.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React, { useMemo, useContext } from 'react';
import { useTranslation } from 'react-i18next';
import { DraggableProvided } from '@kanaries/react-beautiful-dnd';
import { COUNT_FIELD_ID, DEFAULT_DATASET, MEA_KEY_ID, MEA_VAL_ID } from '../../constants';
import { IAggregator, IDraggableViewStateKey } from '../../interfaces';
import { FieldIdentifier, IAggregator, IDraggableViewStateKey } from '../../interfaces';
import { DatasetNamesContext, useVizStore } from '../../store';
import { Pill } from '../components';
import { GLOBAL_CONFIG } from '../../config';
Expand Down
2 changes: 1 addition & 1 deletion packages/graphic-walker/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ export interface IVisualConfigNew {
/** @default "generic" */
coordSystem?: ICoordMode;
limit: number;
folds?: string[];
folds?: FieldIdentifier[];
timezoneDisplayOffset?: number;
baseDataset?: string;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/graphic-walker/src/renderer/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState, useEffect, useMemo, useRef } from 'react';
import { unstable_batchedUpdates } from 'react-dom';
import type { IFilterField, IRow, IViewField, IDataQueryWorkflowStep, IComputationFunction } from '../interfaces';
import type { IFilterField, IRow, IViewField, IDataQueryWorkflowStep, IComputationFunction, FieldIdentifier } from '../interfaces';
import { useAppRootContext } from '../components/appRoot';
import { toWorkflow } from '../utils/workflow';
import { dataQuery } from '../computation';
Expand All @@ -15,7 +15,7 @@ interface UseRendererProps {
sort: 'none' | 'ascending' | 'descending';
limit: number;
computationFunction: IComputationFunction;
folds?: string[];
folds?: FieldIdentifier[];
timezoneDisplayOffset?: number;
}

Expand Down

0 comments on commit 61cb9c1

Please sign in to comment.