Skip to content

Commit

Permalink
Add exports and additional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mortendevold committed Feb 2, 2024
1 parent 5563dae commit 3f675aa
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 10 deletions.
59 changes: 58 additions & 1 deletion src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChartDesignerConfigOptions, ChartRendererConfigOptions, EventManagerConfigOptions } from './index'
import { ChartDesignerConfigOptions, ChartRendererConfigOptions, EventManagerConfigOptions, EventManagerFilterSectionsModeConfigOptions, EventManagerManageCategoriesModeConfigOptions, EventManagerManageChannelsModeConfigOptions, EventManagerManageObjectStatusesModeConfigOptions, EventManagerSelectModeConfigOptions, EventManagerStaticModeConfigOptions } from './index'

// Set up a fully popuplated Chart Renderer config
const fullChartRendererConfig: Required<ChartRendererConfigOptions> = {
Expand Down Expand Up @@ -218,6 +218,63 @@ const fullEventManagerConfig: Required<EventManagerConfigOptions> = {
themePreset: 'someTheme'
}

// Static Mode
const eventManagerStaticModeConfig: Required<EventManagerStaticModeConfigOptions> = {
...fullEventManagerConfig,
mode: 'static',
onObjectMouseOver: object => {},
onObjectMouseOut: object => {},
tooltipContents: object => 'tooltipContents',
events: ['eventA', 'eventB']
}

// Manage object statuses
const eventManagerManageObjectStatusesConfig: Required<EventManagerManageObjectStatusesModeConfigOptions> = {
...fullEventManagerConfig,
mode: 'manageObjectStatuses',
events: ['eventA', 'eventB'],
session: 'continue'
}

// Manage channels
const eventManagerManageChannelsConfig: Required<EventManagerManageChannelsModeConfigOptions> = {
...fullEventManagerConfig,
mode: 'manageChannels',
event: 'eventA',
manageChannelsList: true,
unavailableObjectsSelectable: false
}

// Manage categories
const eventManagerManageCategoriessConfig: Required<EventManagerManageCategoriesModeConfigOptions> = {
...fullEventManagerConfig,
mode: 'manageCategories',
unavailableObjectsSelectable: false
}

// Filter sections
const eventManagerFilterSectionsConfig: Required<EventManagerFilterSectionsModeConfigOptions> = {
...fullEventManagerConfig,
mode: 'filterSections',
onFilteredSectionChange: (sectionsLabels) => ({})
}

// Select mode
const eventManagerSelectModeConfig: Required<EventManagerSelectModeConfigOptions> = {
...fullEventManagerConfig,
mode: 'select',
maxSelectedObjects: 1,
numberOfPlacesToSelect: 1,
selectedObjects: [],
selectionBy: 'places',
ticketTypes: [],
tooltipContents: (object: object) => '',
unavailableObjectsSelectable: false,
selectableObjects: ['A'],
events: ['eventA', 'eventB']
}


// Set up a fully popuplated Chart Designer config
const chartDesignerConfig: Required<ChartDesignerConfigOptions> = {
secretKey: 'mySecretKey',
Expand Down
18 changes: 9 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ export interface CommonConfigOptions {
divId?: string
}

interface WithEvents {
export interface WithEvents {
event?: string
events?: string[]
}

interface WithEvent {
export interface WithEvent {
event: string
}

Expand Down Expand Up @@ -304,7 +304,7 @@ export type ExtractedEventManagerProps = Pick<ChartRendererConfigOptions,
>


interface BaseEventManagerConfigOptions extends CommonConfigOptions, ExtractedEventManagerProps, EventManagerCallbacks {
export interface BaseEventManagerConfigOptions extends CommonConfigOptions, ExtractedEventManagerProps, EventManagerCallbacks {
mode: EventManagerMode
/**
* The secret key of a workspace.
Expand Down Expand Up @@ -356,29 +356,29 @@ interface BaseEventManagerConfigOptions extends CommonConfigOptions, ExtractedEv
}
}

interface EventManagerManageObjectStatusesModeConfigOptions extends BaseEventManagerConfigOptions, WithEvents {
export interface EventManagerManageObjectStatusesModeConfigOptions extends BaseEventManagerConfigOptions, WithEvents {
mode: 'manageObjectStatuses'
session?: Session
}

interface EventManagerManageChannelsModeConfigOptions extends BaseEventManagerConfigOptions, WithEvent {
export interface EventManagerManageChannelsModeConfigOptions extends BaseEventManagerConfigOptions, WithEvent {
mode: 'manageChannels'
manageChannelsList?: boolean
unavailableObjectsSelectable?: boolean
}

interface EventManagerManageCategoriesModeConfigOptions extends BaseEventManagerConfigOptions, WithEvent {
export interface EventManagerManageCategoriesModeConfigOptions extends BaseEventManagerConfigOptions, WithEvent {
mode: 'manageCategories'
unavailableObjectsSelectable?: boolean
}

interface EventManagerFilterSectionsModeConfigOptions extends BaseEventManagerConfigOptions, WithEvent {
export interface EventManagerFilterSectionsModeConfigOptions extends BaseEventManagerConfigOptions, WithEvent {
mode: 'filterSections'
onFilteredSectionChange: (sectionLabels: string[]) => {}
}


interface EventManagerSelectModeConfigOptions extends BaseEventManagerConfigOptions, WithEvents {
export interface EventManagerSelectModeConfigOptions extends BaseEventManagerConfigOptions, WithEvents {
mode: 'select'
maxSelectedObjects?: SelectionLimiter
numberOfPlacesToSelect?: number
Expand All @@ -390,7 +390,7 @@ interface EventManagerSelectModeConfigOptions extends BaseEventManagerConfigOpti
selectableObjects?: string[]
}

interface EventManagerStaticModeConfigOptions extends BaseEventManagerConfigOptions, WithEvents {
export interface EventManagerStaticModeConfigOptions extends BaseEventManagerConfigOptions, WithEvents {
mode: 'static'
onObjectMouseOver?: (object: SelectableObjectProps) => void
onObjectMouseOut?: (object: SelectableObjectProps) => void
Expand Down

0 comments on commit 3f675aa

Please sign in to comment.