@equinor/workspace-garden
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -7,8 +7,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; | ||
const controller = useGardenContext(); | ||
const { clickEvents: { onClickItem }, visuals: { getCustomItemColor, getCustomDescription }, } = controller; | ||
const { clickEvents: { onClickItem }, visuals: { getDescription, getItemColor }, } = controller; | ||
const { color, description, label } = useMemo(() => { | ||
var _a; | ||
const label = controller.nodeLabelCallback(item, controller); | ||
const color = (_a = (getCustomItemColor && getCustomItemColor(item, controller))) !== null && _a !== void 0 ? _a : 'grey'; | ||
const description = getCustomDescription && getCustomDescription(item, controller); | ||
const color = (_a = (getItemColor && getItemColor(item))) !== null && _a !== void 0 ? _a : 'grey'; | ||
const description = getDescription && getDescription(item); | ||
return { | ||
@@ -19,4 +19,4 @@ label, | ||
}; | ||
}, [controller, getCustomDescription, getCustomItemColor, item]); | ||
}, [controller, getItemColor, getDescription, item]); | ||
return (_jsxs(StyledDefaultPackage, Object.assign({ bgColor: color, onClick: () => onClickItem && onClickItem(item, controller), isSelected: isSelected, depth: depth }, { children: [_jsx("div", { children: label }), columnExpanded && _jsx("div", { children: description })] }))); | ||
}); |
@@ -10,3 +10,4 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; | ||
export function FilterSelector() { | ||
const { setHorizontalGroupingAccessor, setVerticalGroupingKeys, customViews, data, fieldSettings } = useGardenContext(); | ||
const controller = useGardenContext(); | ||
const { setHorizontalGroupingAccessor, setVerticalGroupingKeys, customViews, data, fieldSettings } = controller; | ||
const { gardenKey, groupByKeys } = useGroupingKeys(); | ||
@@ -46,3 +47,3 @@ const CustomGroupByView = customViews === null || customViews === void 0 ? void 0 : customViews.customGroupByView; | ||
return null; | ||
return (_jsxs(StyledSelectRowWrapper, { children: [CustomGroupByView && _jsx(CustomGroupByView, {}), _jsx(StyledSeparator, { children: " Group by " }), _jsx(StyledSelectOneWrapper, { children: _jsx(SingleSelect, { items: groupingOptions, label: '', selectedOption: getFieldSettingsLabelFromKey(gardenKey.toString(), fieldSettings), handleSelectedItemChange: (changes) => handleGardenKeyChange(changes.selectedItem) }, gardenKey.toString()) }), _jsx(StyledSeparator, { children: "then" }), groupByKeys.sort().map((groupByKey, index) => { | ||
return (_jsxs(StyledSelectRowWrapper, { children: [CustomGroupByView && _jsx(CustomGroupByView, { controller: controller }), _jsx(StyledSeparator, { children: " Group by " }), _jsx(StyledSelectOneWrapper, { children: _jsx(SingleSelect, { items: groupingOptions, label: '', selectedOption: getFieldSettingsLabelFromKey(gardenKey.toString(), fieldSettings), handleSelectedItemChange: (changes) => handleGardenKeyChange(changes.selectedItem) }, gardenKey.toString()) }), _jsx(StyledSeparator, { children: "then" }), groupByKeys.sort().map((groupByKey, index) => { | ||
return (_jsxs(Fragment, { children: [_jsx(StyledSelectOneWrapper, { children: _jsx(SingleSelect, { items: groupingOptions || [], label: '', selectedOption: getFieldSettingsLabelFromKey(groupByKey.toString(), fieldSettings), handleSelectedItemChange: (changes) => { | ||
@@ -49,0 +50,0 @@ handleExistingSelectionChange(changes.selectedItem, index); |
@@ -28,3 +28,4 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime"; | ||
height: `${virtualRow.size}px`, | ||
} }, { children: isSubGroup(item) ? (CustomSubGroup ? (_jsx(CustomSubGroup, { columnExpanded: item.isExpanded, data: item, onClick: () => handleExpand(item), onSelect: (item) => onClickItem && onClickItem(item, controller), onGroupeSelect: (group) => onClickGroup && onClickGroup(group, controller), groupByKeys: [horizontalGroupingAccessor, ...verticalGroupingKeys] })) : (_jsxs(StyledSubGroup, Object.assign({ onClick: () => handleExpand(item), style: { width: `${width}%` } }, { children: [_jsxs(StyledSubGroupText, { children: [_jsx("div", Object.assign({ onClick: () => onClickGroup && onClickGroup(item, controller) }, { children: item.value })), item.description && ' - ' + item.description, _jsxs(StyledCount, { children: ["(", item.count, ")"] })] }), _jsx(Icon, { name: item.isExpanded ? 'chevron_up' : 'chevron_down', color: tokens.colors.interactive.primary__resting.hex })] })))) : PackageChild ? (_jsx(PackageChild, { columnExpanded: (_c = (_b = (_a = expand === null || expand === void 0 ? void 0 : expand.expandedColumns) === null || _a === void 0 ? void 0 : _a[groups[virtualColumn.index].value]) === null || _b === void 0 ? void 0 : _b.isExpanded) !== null && _c !== void 0 ? _c : false, controller: controller, data: item.item, isSelected: selectedIds.includes(getIdentifier(item.item)), onClick: () => { | ||
} }, { children: isSubGroup(item) ? (CustomSubGroup ? (_jsx(CustomSubGroup, { columnExpanded: item.isExpanded, data: item, onClick: () => handleExpand(item), onSelect: (item) => onClickItem && onClickItem(item, controller), onGroupeSelect: (group) => onClickGroup && onClickGroup(group, controller), groupByKeys: [horizontalGroupingAccessor, ...verticalGroupingKeys] })) : (_jsxs(StyledSubGroup, Object.assign({ onClick: () => handleExpand(item), style: { width: `${width}%` } }, { children: [_jsxs(StyledSubGroupText, { children: [_jsx("div", Object.assign({ onClick: () => onClickGroup && | ||
onClickGroup(item, controller) }, { children: item.value })), item.description && ' - ' + item.description, _jsxs(StyledCount, { children: ["(", item.count, ")"] })] }), _jsx(Icon, { name: item.isExpanded ? 'chevron_up' : 'chevron_down', color: tokens.colors.interactive.primary__resting.hex })] })))) : PackageChild ? (_jsx(PackageChild, { columnExpanded: (_c = (_b = (_a = expand === null || expand === void 0 ? void 0 : expand.expandedColumns) === null || _a === void 0 ? void 0 : _a[groups[virtualColumn.index].value]) === null || _b === void 0 ? void 0 : _b.isExpanded) !== null && _c !== void 0 ? _c : false, controller: controller, data: item.item, isSelected: selectedIds.includes(getIdentifier(item.item)), onClick: () => { | ||
controller.clickEvents.onClickItem && | ||
@@ -31,0 +32,0 @@ controller.clickEvents.onClickItem(item.item, controller); |
@@ -13,3 +13,3 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime"; | ||
const controller = useGardenContext(); | ||
const { visuals: { getCustomDescription = () => '' }, customViews: { customHeaderView: HeaderChild }, grouping: { value: { horizontalGroupingAccessor: groupByKey }, }, } = controller; | ||
const { visuals: { getDescription = () => '' }, customViews: { customHeaderView: HeaderChild }, grouping: { value: { horizontalGroupingAccessor: groupByKey }, }, } = controller; | ||
const expandColumn = useExpandDispatch(); | ||
@@ -23,3 +23,3 @@ const expanded = useExpand(); | ||
descriptionData: getGardenItems(column), | ||
customDescription: (item) => getCustomDescription(item, controller), | ||
customDescription: (item) => getDescription(item), | ||
}); | ||
@@ -26,0 +26,0 @@ }, [expandColumn, getGardenItems]); |
@@ -9,3 +9,3 @@ import { useState, useEffect, useMemo } from 'react'; | ||
useEffect(() => { | ||
const unsubscribe = controller.groups.onChange(setGroups); | ||
const unsubscribe = controller.groups.onChange((val) => setGroups(val)); | ||
return unsubscribe; | ||
@@ -12,0 +12,0 @@ }, []); |
@@ -1,2 +0,2 @@ | ||
import { CustomVirtualViews, FieldSettings, findNodeCallback, GardenGroups, GroupingKeys, HorizontalGroupingAccessor, GetDisplayName, OnClickEvents, Visuals, GardenConfig, BaseRecordObject } from '../types'; | ||
import { CustomVirtualViews, FieldSettings, FindNodeCallback, GardenGroups, GroupingKeys, HorizontalGroupingAccessor, GetDisplayName, OnClickEvents, Visuals, GardenConfig, BaseRecordObject } from '../types'; | ||
import { ReactiveValue } from './reactiveValue'; | ||
@@ -10,3 +10,3 @@ export declare type GetIdentifier<TData> = (item: TData) => string; | ||
*/ | ||
export declare class GardenController<TData, ExtendedFields extends string = never, TCustomGroupByKeys extends BaseRecordObject<TCustomGroupByKeys> = BaseRecordObject<unknown>, TCustomState extends BaseRecordObject<TCustomState> = BaseRecordObject<unknown>, TContext = unknown> { | ||
export declare class GardenController<TData extends Record<PropertyKey, unknown>, ExtendedFields extends string = never, TCustomGroupByKeys extends BaseRecordObject<TCustomGroupByKeys> = never, TCustomState extends BaseRecordObject<TCustomState> = BaseRecordObject<unknown>, TContext extends Record<PropertyKey, unknown> = Record<PropertyKey, unknown>> { | ||
#private; | ||
@@ -60,5 +60,5 @@ /** The nodes that is currently selected */ | ||
*/ | ||
setHighlightedNode: (nodeIdOrCallback: (string | null) | findNodeCallback<TData>) => void; | ||
setHighlightedNode: (nodeIdOrCallback: (string | null) | FindNodeCallback<TData>) => void; | ||
/** Function for sorting groups after they have been grouped */ | ||
postGroupSorting: (groups: GardenGroups<TData>, keys: (keyof TData | ExtendedFields)[]) => GardenGroups<TData>; | ||
} |
@@ -1,1 +0,9 @@ | ||
export declare const DefaultGardenItem: any; | ||
/// <reference types="react" /> | ||
interface DefaultGardenItemProps { | ||
columnExpanded: boolean; | ||
item: Record<string, string>; | ||
depth: number; | ||
isSelected: boolean; | ||
} | ||
export declare const DefaultGardenItem: import("react").MemoExoticComponent<({ columnExpanded, item, depth, isSelected }: DefaultGardenItemProps) => JSX.Element>; | ||
export {}; |
@@ -1,7 +0,26 @@ | ||
/// <reference types="react" /> | ||
import { PropsWithChildren } from 'react'; | ||
import { GardenItem } from '../../types'; | ||
declare type Expanded = { | ||
isExpanded: boolean; | ||
index: number; | ||
}; | ||
declare type ExpandedItems = Record<string, Expanded>; | ||
declare type State = { | ||
expandedColumns: ExpandedItems; | ||
widths: number[]; | ||
}; | ||
export declare enum ActionType { | ||
EXPAND_COLUMN = 0 | ||
} | ||
declare const ExpandContext: any; | ||
declare const ExpandDispatchContext: any; | ||
declare type ExpandColumn<T extends Record<PropertyKey, unknown> = Record<PropertyKey, unknown>> = { | ||
key: string; | ||
index: number; | ||
descriptionData: GardenItem<T>[] | null; | ||
type: ActionType.EXPAND_COLUMN; | ||
customDescription?: (item: T | GardenItem<T>) => string; | ||
}; | ||
declare type Action = ExpandColumn; | ||
declare type DispatchAction = (action: Action) => void; | ||
declare const ExpandContext: import("react").Context<State>; | ||
declare const ExpandDispatchContext: import("react").Context<DispatchAction | undefined>; | ||
declare type ExpandProviderProps = { | ||
@@ -8,0 +27,0 @@ initialWidths: number[]; |
/// <reference types="react" /> | ||
import { GardenController } from '../classes'; | ||
import { BaseRecordObject } from '../types'; | ||
interface GardenProps<TData, TExtendedFields extends string, TCustomGroupByKeys extends BaseRecordObject<TCustomGroupByKeys> = BaseRecordObject<unknown>, TCustomState extends BaseRecordObject<TCustomState> = BaseRecordObject<unknown>, TContext = unknown> { | ||
interface GardenProps<TData extends Record<PropertyKey, unknown>, TExtendedFields extends string, TCustomGroupByKeys extends BaseRecordObject<TCustomGroupByKeys> = never, TCustomState extends BaseRecordObject<TCustomState> = BaseRecordObject<unknown>, TContext extends Record<PropertyKey, unknown> = Record<PropertyKey, unknown>> { | ||
controller: GardenController<TData, TExtendedFields, TCustomGroupByKeys, TCustomState, TContext>; | ||
} | ||
export declare function Garden<TData, TExtendedFields extends string, TCustomGroupByKeys extends BaseRecordObject<TCustomGroupByKeys> = BaseRecordObject<unknown>, TCustomState extends BaseRecordObject<TCustomState> = BaseRecordObject<unknown>, TContext = unknown>({ controller }: GardenProps<TData, TExtendedFields, TCustomGroupByKeys, TCustomState, TContext>): JSX.Element | null; | ||
export declare const GardenContext: any; | ||
export declare function Garden<TData extends Record<PropertyKey, unknown>, TExtendedFields extends string = never, TCustomGroupByKeys extends BaseRecordObject<TCustomGroupByKeys> = never, TCustomState extends BaseRecordObject<TCustomState> = BaseRecordObject<unknown>, TContext extends Record<PropertyKey, unknown> = Record<PropertyKey, unknown>>({ controller }: GardenProps<TData, TExtendedFields, TCustomGroupByKeys, TCustomState, TContext>): JSX.Element | null; | ||
export declare const GardenContext: import("react").Context<GardenController<Record<PropertyKey, unknown>, string, BaseRecordObject<unknown>, BaseRecordObject<unknown>, Record<PropertyKey, unknown>>>; | ||
export {}; |
@@ -5,3 +5,3 @@ import { MutableRefObject } from 'react'; | ||
declare type VirtualHookReturn = Pick<ReturnType<typeof useVirtual>, 'virtualItems' | 'scrollToIndex'>; | ||
declare type PackageContainerProps<TData, TExtendedFields extends string, TCustomGroupByKeys, TCustomState, TContext> = { | ||
declare type PackageContainerProps<TData extends Record<PropertyKey, unknown>, TExtendedFields extends string, TCustomGroupByKeys extends Record<PropertyKey, unknown>, TCustomState extends Record<PropertyKey, unknown>, TContext extends Record<PropertyKey, unknown>> = { | ||
virtualColumn: VirtualItem; | ||
@@ -17,3 +17,3 @@ rowVirtualizer: VirtualHookReturn; | ||
}; | ||
export declare const GardenItemContainer: <TData, TExtendedFields extends string, TCustomGroupByKeys, TCustomState, TContext>(props: PackageContainerProps<TData, TExtendedFields, TCustomGroupByKeys, TCustomState, TContext>) => JSX.Element; | ||
export declare const GardenItemContainer: <TData extends Record<PropertyKey, unknown>, TExtendedFields extends string, TCustomGroupByKeys extends Record<PropertyKey, unknown>, TCustomState extends Record<PropertyKey, unknown>, TContext extends Record<PropertyKey, unknown>>(props: PackageContainerProps<TData, TExtendedFields, TCustomGroupByKeys, TCustomState, TContext>) => JSX.Element; | ||
export {}; |
@@ -1,2 +0,2 @@ | ||
/// <reference types="react" /> | ||
import { PropsWithChildren } from 'react'; | ||
declare type LayoutProps = { | ||
@@ -3,0 +3,0 @@ columnTotalSize: number; |
/// <reference types="react" /> | ||
declare type VirtualGardenProps<TData> = { | ||
declare type VirtualGardenProps<TData extends Record<PropertyKey, unknown>> = { | ||
width?: number; | ||
handleOnItemClick: (item: TData) => void; | ||
}; | ||
export declare const VirtualGarden: <TData, TExtendedFields extends string, TCustomGroupByKeys, TCustomState, TContext>({ width, handleOnItemClick, }: VirtualGardenProps<TData>) => JSX.Element; | ||
export declare const VirtualGarden: <TData extends Record<PropertyKey, unknown>, TExtendedFields extends string, TCustomGroupByKeys extends Record<PropertyKey, unknown>, TCustomState extends Record<PropertyKey, unknown>, TContext extends Record<PropertyKey, unknown>>({ width, handleOnItemClick, }: VirtualGardenProps<TData>) => JSX.Element; | ||
export {}; |
import { GardenController } from '../classes'; | ||
import { BaseRecordObject } from '../types'; | ||
export declare function useData<TData, TExtendedFields extends string, TCustomGroupByKeys extends BaseRecordObject<TCustomGroupByKeys>, TCustomState extends BaseRecordObject<TCustomState>, TContext>(controller: GardenController<TData, TExtendedFields, TCustomGroupByKeys, TCustomState, TContext>): any; | ||
export declare function useData<TData extends Record<PropertyKey, unknown>, TExtendedFields extends string, TCustomGroupByKeys extends BaseRecordObject<TCustomGroupByKeys>, TCustomState extends BaseRecordObject<TCustomState>, TContext extends Record<PropertyKey, unknown> = Record<PropertyKey, unknown>>(controller: GardenController<TData, TExtendedFields, TCustomGroupByKeys, TCustomState, TContext>): TData[]; |
@@ -1,2 +0,16 @@ | ||
export declare const useExpand: () => any; | ||
export declare const useExpandDispatch: () => any; | ||
export declare const useExpand: () => { | ||
expandedColumns: { | ||
[x: string]: { | ||
isExpanded: boolean; | ||
index: number; | ||
}; | ||
}; | ||
widths: number[]; | ||
}; | ||
export declare const useExpandDispatch: () => (action: { | ||
key: string; | ||
index: number; | ||
descriptionData: import("..").GardenItem<Record<PropertyKey, unknown>>[] | null; | ||
type: import("../components/ExpandProvider").ActionType; | ||
customDescription?: ((item: Record<PropertyKey, unknown> | import("..").GardenItem<Record<PropertyKey, unknown>>) => string) | undefined; | ||
}) => void; |
@@ -1,1 +0,1 @@ | ||
export declare const useGardenContext: () => any; | ||
export declare const useGardenContext: () => import("..").GardenController<Record<PropertyKey, unknown>, string, import("..").BaseRecordObject<unknown>, import("..").BaseRecordObject<unknown>, Record<PropertyKey, unknown>>; |
@@ -1,1 +0,2 @@ | ||
export declare function useGardenGroups(): any; | ||
import { GardenGroups } from '../types'; | ||
export declare function useGardenGroups(): GardenGroups<Record<PropertyKey, unknown>>; |
export declare function useGroupingKeys(): { | ||
gardenKey: any; | ||
groupByKeys: any; | ||
gardenKey: string | number | symbol; | ||
groupByKeys: string[]; | ||
}; |
@@ -1,1 +0,1 @@ | ||
export declare function useItemWidths(): any; | ||
export declare function useItemWidths(): number[]; |
import { ReactiveValue } from '../classes/reactiveValue'; | ||
export declare function useReactiveValue<TData>(reactiveValue: ReactiveValue<TData>): any; | ||
export declare function useReactiveValue<TData>(reactiveValue: ReactiveValue<TData>): TData; |
/**Returns the selected nodes */ | ||
export declare function useSelected(): any; | ||
export declare function useSelected(): string[]; |
@@ -0,1 +1,2 @@ | ||
import { MutableRefObject } from 'react'; | ||
/** | ||
@@ -8,4 +9,4 @@ * Hook for checking if the user is scrolling... | ||
export declare const useVirtualScrolling: (ref: MutableRefObject<HTMLDivElement | null>) => { | ||
isScrolling: any; | ||
scrollOffsetFn: any; | ||
isScrolling: boolean; | ||
scrollOffsetFn: (event: any) => number; | ||
}; |
@@ -6,2 +6,2 @@ import { GardenConfig } from '../types'; | ||
}; | ||
export declare const defaultGardenConfig: GardenConfig<MockInterface, any, any, any, unknown>; | ||
export declare const defaultGardenConfig: GardenConfig<MockInterface, any, any, any, Record<PropertyKey, unknown>>; |
@@ -7,6 +7,6 @@ import { GardenController } from '../classes'; | ||
*/ | ||
export declare type ItemWidthCalculation<TData, TExtendedFields extends string, TCustomGroupByKeys extends BaseRecordObject<TCustomGroupByKeys> = BaseRecordObject<unknown>> = (garden: GardenGroups<TData>, key: keyof TData | TExtendedFields, customGroupByKeys?: TCustomGroupByKeys) => number; | ||
export declare type HighlightHorizontalColumn<TData, ExtendedFields extends string, TCustomGroupByKeys extends BaseRecordObject<TCustomGroupByKeys> = BaseRecordObject<unknown>> = (groupBy: keyof TData | ExtendedFields, customGroupByKeys: TCustomGroupByKeys) => string | undefined; | ||
export declare type GetDescription<T> = (item: T | GardenItem<T>) => string; | ||
export declare type GetItemColor<T> = (item: T) => string; | ||
export declare type GetDisplayName<T> = (item: T, controller: GardenController<T>) => string; | ||
export declare type ItemWidthCalculation<TData extends Record<PropertyKey, unknown>, TExtendedFields extends string = never, TCustomGroupByKeys extends BaseRecordObject<TCustomGroupByKeys> = never> = (garden: GardenGroups<TData>, key: keyof TData | TExtendedFields, customGroupByKeys?: TCustomGroupByKeys) => number; | ||
export declare type HighlightHorizontalColumn<TData extends Record<PropertyKey, unknown>, ExtendedFields extends string = never, TCustomGroupByKeys extends BaseRecordObject<TCustomGroupByKeys> = never> = (groupBy: keyof TData | ExtendedFields, customGroupByKeys: TCustomGroupByKeys) => string | undefined; | ||
export declare type GetDescription<TData extends Record<PropertyKey, unknown>> = (item: TData | GardenItem<TData>) => string; | ||
export declare type GetItemColor<TData extends Record<PropertyKey, unknown>> = (item: TData) => string; | ||
export declare type GetDisplayName<TData extends Record<PropertyKey, unknown>> = (item: TData, controller: GardenController<TData>) => string; |
import { GetIdentifier } from '../classes'; | ||
import { GroupingKeys, FieldSettings, OnClickEvents, GetDisplayName, BaseRecordObject, CustomVirtualViews, Visuals, GardenGroups } from './'; | ||
export declare type GardenConfig<TData, TExtendedFields extends string, TCustomGroupByKeys extends BaseRecordObject<TCustomGroupByKeys> = BaseRecordObject<unknown>, TCustomState extends BaseRecordObject<TCustomState> = BaseRecordObject<unknown>, TContext = unknown> = { | ||
export declare type GardenConfig<TData extends Record<PropertyKey, unknown>, TExtendedFields extends string = never, TCustomGroupByKeys extends BaseRecordObject<TCustomGroupByKeys> = never, TCustomState extends BaseRecordObject<TCustomState> = BaseRecordObject<unknown>, TContext extends Record<PropertyKey, unknown> = Record<PropertyKey, unknown>> = { | ||
/** Data to be used for the garden */ | ||
@@ -45,5 +45,5 @@ data: TData[]; | ||
}; | ||
export declare type PostGroupBySorting<T, TExtendedFields extends string> = (data: GardenGroups<T>, keys: (keyof T | TExtendedFields)[]) => GardenGroups<T>; | ||
export declare type GardenDataIntercepters<T, TExtendedFields extends string> = { | ||
postGroupSorting?: PostGroupBySorting<T, TExtendedFields>; | ||
export declare type PostGroupBySorting<TData extends Record<PropertyKey, unknown>, TExtendedFields extends string = never> = (data: GardenGroups<TData>, keys: (keyof TData | TExtendedFields)[]) => GardenGroups<TData>; | ||
export declare type GardenDataIntercepters<TData extends Record<PropertyKey, unknown>, TExtendedFields extends string = never> = { | ||
postGroupSorting?: PostGroupBySorting<TData, TExtendedFields>; | ||
}; |
@@ -5,7 +5,7 @@ import { GardenGroup } from '.'; | ||
/** Function signature for clicking an item */ | ||
export declare type OnClickItem<TData, TExtendedFields extends string, TCustomGroupByKeys extends BaseRecordObject<TCustomGroupByKeys> = BaseRecordObject<unknown>, TCustomState extends BaseRecordObject<TCustomState> = BaseRecordObject<unknown>, TContext = unknown> = (item: TData, controller: GardenController<TData, TExtendedFields, TCustomGroupByKeys, TCustomState, TContext>) => void; | ||
export declare type OnClickItem<TData extends Record<PropertyKey, unknown>, TExtendedFields extends string = never, TCustomGroupByKeys extends BaseRecordObject<TCustomGroupByKeys> = never, TCustomState extends BaseRecordObject<TCustomState> = BaseRecordObject<unknown>, TContext extends Record<PropertyKey, unknown> = Record<PropertyKey, unknown>> = (item: TData, controller: GardenController<TData, TExtendedFields, TCustomGroupByKeys, TCustomState, TContext>) => void; | ||
/** Function signature for clicking a group containing children in the garden */ | ||
export declare type OnClickGroup<TData, TExtendedFields extends string, TCustomGroupByKeys extends BaseRecordObject<TCustomGroupByKeys> = BaseRecordObject<unknown>, TCustomState extends BaseRecordObject<TCustomState> = Record<string, unknown>, TContext = unknown> = (item: GardenGroup<TData>, controller: GardenController<TData, TExtendedFields, TCustomGroupByKeys, TCustomState, TContext>) => void; | ||
export declare type OnClickGroup<TData extends Record<PropertyKey, unknown>, TExtendedFields extends string = never, TCustomGroupByKeys extends BaseRecordObject<TCustomGroupByKeys> = never, TCustomState extends BaseRecordObject<TCustomState> = Record<string, unknown>, TContext extends Record<PropertyKey, unknown> = Record<PropertyKey, unknown>> = (item: GardenGroup<TData>, controller: GardenController<TData, TExtendedFields, TCustomGroupByKeys, TCustomState, TContext>) => void; | ||
/**Onclick events for garden */ | ||
export interface OnClickEvents<TData, TExtendedFields extends string, TCustomGroupByKeys extends BaseRecordObject<TCustomGroupByKeys> = BaseRecordObject<unknown>, TCustomState extends BaseRecordObject<TCustomState> = BaseRecordObject<unknown>, TContext = unknown> { | ||
export interface OnClickEvents<TData extends Record<PropertyKey, unknown>, TExtendedFields extends string = never, TCustomGroupByKeys extends BaseRecordObject<TCustomGroupByKeys> = never, TCustomState extends BaseRecordObject<TCustomState> = BaseRecordObject<unknown>, TContext extends Record<PropertyKey, unknown> = Record<PropertyKey, unknown>> { | ||
/** Fires when an item is clicked */ | ||
@@ -12,0 +12,0 @@ onClickItem?: OnClickItem<TData, TExtendedFields, TCustomGroupByKeys, TCustomState, TContext>; |
@@ -1,5 +0,4 @@ | ||
import { BaseRecordObject } from './customGeneric'; | ||
export declare type GetSortFunction = (a: string, b: string) => number; | ||
export declare type GetKeyFunction<TData, TExtendedFields extends string = never, TCustomGroupByKeys extends BaseRecordObject<TCustomGroupByKeys> = never> = (item: TData, itemKey: keyof TData | TExtendedFields, customGroupByKeys?: TCustomGroupByKeys) => string[] | string; | ||
export declare type FieldSetting<ItemType, TExtendedFields extends string, TCustomGroupByKeys extends BaseRecordObject<TCustomGroupByKeys>> = { | ||
export declare type GetKeyFunction<TData extends Record<PropertyKey, unknown>, TExtendedFields extends string = never, TCustomGroupByKeys extends Record<PropertyKey, unknown> = never> = (item: TData, itemKey: keyof TData | TExtendedFields, customGroupByKeys?: TCustomGroupByKeys) => string[] | string; | ||
export declare type FieldSetting<ItemType extends Record<PropertyKey, unknown>, TExtendedFields extends string = never, TCustomGroupByKeys extends Record<PropertyKey, unknown> = never> = { | ||
key?: keyof ItemType | string; | ||
@@ -19,2 +18,2 @@ label?: string; | ||
*/ | ||
export declare type FieldSettings<ItemType, ExtendedFields extends string = never, TCustomGroupByKeys extends BaseRecordObject<TCustomGroupByKeys> = never> = Partial<Record<keyof ItemType | ExtendedFields, FieldSetting<ItemType, ExtendedFields, TCustomGroupByKeys>>>; | ||
export declare type FieldSettings<ItemType extends Record<PropertyKey, unknown>, ExtendedFields extends string = never, TCustomGroupByKeys extends Record<PropertyKey, unknown> = never> = Partial<Record<keyof ItemType | ExtendedFields, FieldSetting<ItemType, ExtendedFields, TCustomGroupByKeys>>>; |
@@ -1,2 +0,2 @@ | ||
export declare type GardenGroup<TData> = { | ||
export declare type GardenGroup<TData extends Record<PropertyKey, unknown>> = { | ||
groupKey: keyof TData; | ||
@@ -12,5 +12,5 @@ value: string; | ||
}; | ||
export declare type GardenGroups<TData> = GardenGroup<TData>[]; | ||
export declare type GardenGroups<TData extends Record<PropertyKey, unknown>> = GardenGroup<TData>[]; | ||
export interface GroupDescriptionFunc<TData> { | ||
(data: TData, groupingKey: string): string; | ||
} |
import { GardenGroup } from './gardenGroup'; | ||
export declare type GardenItemWithDepth<T> = { | ||
item: T; | ||
export declare type GardenItemWithDepth<TData extends Record<PropertyKey, unknown>> = { | ||
item: TData; | ||
itemDepth: number; | ||
}; | ||
export declare type GardenItem<T> = GardenGroup<T> | GardenItemWithDepth<T>; | ||
export declare type GardenItem<TData extends Record<PropertyKey, unknown>> = GardenGroup<TData> | GardenItemWithDepth<TData>; |
import { MemoExoticComponent, MutableRefObject } from 'react'; | ||
import { GardenController } from '../classes'; | ||
import { GardenGroup, GardenGroups } from '.'; | ||
export interface CustomItemView<TData, TExtendedFields extends string, TCustomGroupByKeys, TCustomState, TContext> { | ||
export interface CustomItemView<TData extends Record<PropertyKey, unknown>, TExtendedFields extends string = never, TCustomGroupByKeys extends Record<PropertyKey, unknown> = never, TCustomState extends Record<PropertyKey, unknown> = Record<PropertyKey, unknown>, TContext extends Record<PropertyKey, unknown> = Record<PropertyKey, unknown>> { | ||
data: TData; | ||
@@ -16,3 +16,3 @@ controller: Omit<GardenController<TData, TExtendedFields, TCustomGroupByKeys, TCustomState, TContext>, 'destroy'>; | ||
} | ||
export interface CustomGroupView<TData> { | ||
export interface CustomGroupView<TData extends Record<PropertyKey, unknown>> { | ||
data: GardenGroup<TData>; | ||
@@ -25,4 +25,4 @@ onClick: () => void; | ||
} | ||
export interface CustomHeaderView<T> { | ||
garden: GardenGroups<T>; | ||
export interface CustomHeaderView<TData extends Record<PropertyKey, unknown>> { | ||
garden: GardenGroups<TData>; | ||
columnIndex: number; | ||
@@ -32,3 +32,3 @@ columnIsExpanded: boolean; | ||
} | ||
export interface CustomVirtualViews<TData, TExtendedFields extends string, TCustomGroupByKeys, TCustomState, TContext> { | ||
export interface CustomVirtualViews<TData extends Record<PropertyKey, unknown>, TExtendedFields extends string = never, TCustomGroupByKeys extends Record<PropertyKey, unknown> = never, TCustomState extends Record<PropertyKey, unknown> = Record<PropertyKey, unknown>, TContext extends Record<PropertyKey, unknown> = Record<PropertyKey, unknown>> { | ||
customItemView?: MemoExoticComponent<(args: CustomItemView<TData, TExtendedFields, TCustomGroupByKeys, TCustomState, TContext>) => JSX.Element>; | ||
@@ -39,6 +39,5 @@ customGroupView?: MemoExoticComponent<(args: CustomGroupView<TData>) => JSX.Element>; | ||
} | ||
declare type CustomGroupViewProps<TData, TExtendedFields extends string, TCustomGroupByKeys, TCustomState, TContext> = { | ||
export declare type CustomGroupViewProps<TData extends Record<PropertyKey, unknown>, TExtendedFields extends string = never, TCustomGroupByKeys extends Record<PropertyKey, unknown> = never, TCustomState extends Record<PropertyKey, unknown> = Record<PropertyKey, unknown>, TContext extends Record<PropertyKey, unknown> = Record<PropertyKey, unknown>> = { | ||
controller: GardenController<TData, TExtendedFields, TCustomGroupByKeys, TCustomState, TContext>; | ||
}; | ||
export declare type PreGroupByFiltering<T = unknown> = (arr: T[], groupByKey: string) => T[]; | ||
export {}; | ||
export declare type PreGroupByFiltering<TData extends Record<PropertyKey, unknown>> = (arr: TData[], groupByKey: string) => TData[]; |
@@ -1,1 +0,1 @@ | ||
export declare type findNodeCallback<T> = (data: T[]) => string | null; | ||
export declare type FindNodeCallback<TData extends Record<PropertyKey, unknown>> = (data: TData[]) => string | null; |
@@ -1,5 +0,5 @@ | ||
export declare type HorizontalGroupingAccessor<T> = keyof T | string; | ||
export interface GroupingKeys<T> { | ||
horizontalGroupingAccessor: HorizontalGroupingAccessor<T>; | ||
export declare type HorizontalGroupingAccessor<TData extends Record<PropertyKey, unknown>> = keyof TData | string; | ||
export interface GroupingKeys<TData extends Record<PropertyKey, unknown>> { | ||
horizontalGroupingAccessor: HorizontalGroupingAccessor<TData>; | ||
verticalGroupingKeys: string[]; | ||
} |
import { ItemWidthCalculation, HighlightHorizontalColumn, GetDescription, GetItemColor } from './'; | ||
export interface Visuals<TData, TExtendedFields extends string, TCustomGroupByKeys> { | ||
export interface Visuals<TData extends Record<PropertyKey, unknown>, TExtendedFields extends string = never, TCustomGroupByKeys extends Record<PropertyKey, unknown> = never> { | ||
/**Function for calculating the longest width of a garden column */ | ||
@@ -4,0 +4,0 @@ calculateItemWidth: ItemWidthCalculation<TData, TExtendedFields, TCustomGroupByKeys>; |
import { GardenController } from '../classes'; | ||
import { BaseRecordObject, GardenGroups } from '../types'; | ||
export declare function createGarden<TData, TExtendedFields extends string, TCustomGroupByKeys extends BaseRecordObject<TCustomGroupByKeys> = BaseRecordObject<unknown>, TContext = unknown>(props: GardenController<TData, TExtendedFields, TCustomGroupByKeys, TContext>): GardenGroups<TData>; | ||
export declare function createGarden<TData extends Record<PropertyKey, unknown>, TExtendedFields extends string = never, TCustomGroupByKeys extends BaseRecordObject<TCustomGroupByKeys> = never, TContext = unknown>(props: GardenController<TData, TExtendedFields, TCustomGroupByKeys, TContext>): GardenGroups<TData>; |
import { GardenItem, GardenItemWithDepth } from '../types'; | ||
export declare function columnDataIsWithDepth<T>(packageObj: GardenItem<T>[]): packageObj is GardenItemWithDepth<T>[]; | ||
export declare function columnDataIsWithDepth<T extends Record<PropertyKey, unknown>>(packageObj: GardenItem<T>[]): packageObj is GardenItemWithDepth<T>[]; | ||
/** | ||
@@ -7,3 +7,3 @@ * @param columnData One column from the garden | ||
*/ | ||
export declare const getLongestDescription: <T>(columnData: GardenItem<T>[], customDescription?: ((item: T | GardenItem<T>) => string) | undefined) => string; | ||
export declare const getLongestDescription: <T extends Record<PropertyKey, unknown>>(columnData: GardenItem<T>[], customDescription?: ((item: T | GardenItem<T>) => string) | undefined) => string; | ||
/** | ||
@@ -14,2 +14,2 @@ * Function for estimating the extra width it takes to display the descriptions of packages. | ||
*/ | ||
export declare const getDescriptionWidth: <T>(columnData: GardenItem<T>[] | null, customDescription?: ((item: T | GardenItem<T>) => string) | undefined) => number; | ||
export declare const getDescriptionWidth: <T extends Record<PropertyKey, unknown>>(columnData: GardenItem<T>[] | null, customDescription?: ((item: T | GardenItem<T>) => string) | undefined) => number; |
@@ -10,2 +10,2 @@ import { GardenGroup } from '../types'; | ||
*/ | ||
export declare const getGardenItems: <T = unknown>(column: GardenGroup<T> | undefined, includeSubGroupValue?: boolean) => GardenItem<T>[] | null; | ||
export declare const getGardenItems: <T extends Record<PropertyKey, unknown>>(column: GardenGroup<T> | undefined, includeSubGroupValue?: boolean) => GardenItem<T>[] | null; |
import { GardenGroups } from '../types'; | ||
export declare const getRowCount: <T>(garden: GardenGroups<T>) => number; | ||
export declare const getRowCount: <T extends Record<PropertyKey, unknown>>(garden: GardenGroups<T>) => number; |
import { BaseRecordObject, FieldSettings, GardenGroups } from '../types'; | ||
import { PreGroupByFiltering } from '../types'; | ||
declare type GroupByArgs<TData, TExtendedFields extends string, TCustomGroupByKeys extends BaseRecordObject<TCustomGroupByKeys> = BaseRecordObject<unknown>> = { | ||
declare type GroupByArgs<TData extends Record<PropertyKey, unknown>, TExtendedFields extends string = never, TCustomGroupByKeys extends BaseRecordObject<TCustomGroupByKeys> = never> = { | ||
arr: TData[]; | ||
@@ -12,3 +12,3 @@ keys: (keyof TData | TExtendedFields)[]; | ||
}; | ||
export declare function groupBy<TData, TExtendedFields extends string, TCustomGroupByKeys extends BaseRecordObject<TCustomGroupByKeys> = BaseRecordObject<unknown>>({ arr, keys, customGroupByKeys, fieldSettings, isExpanded, preGroupFiltering, depth, }: GroupByArgs<TData, TExtendedFields, TCustomGroupByKeys>): GardenGroups<TData>; | ||
export declare function groupBy<TData extends Record<PropertyKey, unknown>, TExtendedFields extends string = never, TCustomGroupByKeys extends BaseRecordObject<TCustomGroupByKeys> = never>({ arr, keys, customGroupByKeys, fieldSettings, isExpanded, preGroupFiltering, depth, }: GroupByArgs<TData, TExtendedFields, TCustomGroupByKeys>): GardenGroups<TData>; | ||
export {}; |
import { GardenGroup, GardenItem } from '../types'; | ||
export declare const isSubGroup: <T>(arg: GardenItem<T> | undefined) => arg is GardenGroup<T>; | ||
export declare const isSubGroup: <T extends Record<PropertyKey, unknown>>(arg: GardenItem<T> | undefined) => arg is GardenGroup<T>; |
{ | ||
"name": "@equinor/workspace-garden", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
163791
1655