@memberjunction/ng-timeline 6.1.4 → 6.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @module @memberjunction/ng-timeline/timeline-group
|
|
9
9
|
*/
|
|
10
|
-
import { IMetadataProvider } from '@memberjunction/core';
|
|
10
|
+
import { EntityInfo, IMetadataProvider } from '@memberjunction/core';
|
|
11
11
|
import { TimelineCardConfig, TimelineEventConfig } from './types';
|
|
12
12
|
/**
|
|
13
13
|
* Extracts a field value from a record, supporting both BaseEntity and plain objects.
|
|
@@ -118,6 +118,15 @@ export declare class TimelineGroup<T = any> {
|
|
|
118
118
|
* @example 'Tasks', 'MJ: AI Agents', 'Users'
|
|
119
119
|
*/
|
|
120
120
|
EntityName?: string;
|
|
121
|
+
/**
|
|
122
|
+
* Metadata for the entity this group's records come from, for records that do not carry their own.
|
|
123
|
+
*
|
|
124
|
+
* A BaseEntity record exposes `EntityInfo`, and the group reads field types from it. A plain object
|
|
125
|
+
* (an `'array'` group fed `simple` RunView rows, as the entity viewer's timeline does) has none, so
|
|
126
|
+
* without this a SQL `date` field is read as an instant and lands a day early west of Greenwich.
|
|
127
|
+
* A record's own `EntityInfo` wins when it has one.
|
|
128
|
+
*/
|
|
129
|
+
EntityInfo?: EntityInfo;
|
|
121
130
|
/**
|
|
122
131
|
* How data is provided to the timeline.
|
|
123
132
|
* - `'array'`: Data is provided via the `EntityObjects` array (works with any object type)
|
|
@@ -297,6 +306,13 @@ export declare class TimelineGroup<T = any> {
|
|
|
297
306
|
* @returns The date object
|
|
298
307
|
*/
|
|
299
308
|
getDate(record: T): Date;
|
|
309
|
+
/**
|
|
310
|
+
* Whether `DateFieldName` is a SQL `date` column (a calendar day), from the record's own entity
|
|
311
|
+
* metadata, else the group's {@link EntityInfo}. Entity-sourced groups load BaseEntity objects,
|
|
312
|
+
* which carry it; a plain object relies on the group's. With neither, the date is treated as an
|
|
313
|
+
* instant, as before.
|
|
314
|
+
*/
|
|
315
|
+
private isDateOnlyDateField;
|
|
300
316
|
/**
|
|
301
317
|
* Gets the subtitle from a record.
|
|
302
318
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeline-group.d.ts","sourceRoot":"","sources":["../../src/lib/timeline-group.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"timeline-group.d.ts","sourceRoot":"","sources":["../../src/lib/timeline-group.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAwC,MAAM,sBAAsB,CAAC;AAC3G,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EAEpB,MAAM,SAAS,CAAC;AAwBjB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAYrE;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,GAAG,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAwBrE;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsEG;AACH,qBAAa,aAAa,CAAC,CAAC,GAAG,GAAG;IAKhC;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;IAExB;;;;;;OAMG;IACH,cAAc,EAAE,OAAO,GAAG,QAAQ,CAAY;IAE9C;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,aAAa,EAAE,CAAC,EAAE,CAAM;IAExB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;I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
7
|
*
|
|
8
8
|
* @module @memberjunction/ng-timeline/timeline-group
|
|
9
9
|
*/
|
|
10
|
-
import { Metadata, RunView } from '@memberjunction/core';
|
|
10
|
+
import { IsDateOnlySQLType, Metadata, RunView } from '@memberjunction/core';
|
|
11
11
|
import { DEFAULT_CARD_CONFIG } from './types';
|
|
12
12
|
// ============================================================================
|
|
13
|
+
// HELPER FUNCTION - CALENDAR DAYS
|
|
14
|
+
// ============================================================================
|
|
15
|
+
/**
|
|
16
|
+
* A SQL `date` value re-anchored on LOCAL midnight of the day it stores.
|
|
17
|
+
*
|
|
18
|
+
* A calendar day arrives as UTC midnight. The timeline groups and labels every event with local
|
|
19
|
+
* getters (day, week, month, quarter, year segments and its own date formatter), which read that as
|
|
20
|
+
* the previous day west of Greenwich: an event dated Oct 1 fell into a "September 30" day segment
|
|
21
|
+
* and, on the 1st of a month, into the prior month. Carrying the day as local midnight makes every
|
|
22
|
+
* one of those local readings return the stored day.
|
|
23
|
+
*/
|
|
24
|
+
function calendarDayAsLocalDate(date) {
|
|
25
|
+
if (isNaN(date.getTime()))
|
|
26
|
+
return date;
|
|
27
|
+
return new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());
|
|
28
|
+
}
|
|
29
|
+
// ============================================================================
|
|
13
30
|
// HELPER FUNCTION - FIELD VALUE ACCESS
|
|
14
31
|
// ============================================================================
|
|
15
32
|
/**
|
|
@@ -158,6 +175,15 @@ export class TimelineGroup {
|
|
|
158
175
|
* @example 'Tasks', 'MJ: AI Agents', 'Users'
|
|
159
176
|
*/
|
|
160
177
|
EntityName;
|
|
178
|
+
/**
|
|
179
|
+
* Metadata for the entity this group's records come from, for records that do not carry their own.
|
|
180
|
+
*
|
|
181
|
+
* A BaseEntity record exposes `EntityInfo`, and the group reads field types from it. A plain object
|
|
182
|
+
* (an `'array'` group fed `simple` RunView rows, as the entity viewer's timeline does) has none, so
|
|
183
|
+
* without this a SQL `date` field is read as an instant and lands a day early west of Greenwich.
|
|
184
|
+
* A record's own `EntityInfo` wins when it has one.
|
|
185
|
+
*/
|
|
186
|
+
EntityInfo;
|
|
161
187
|
/**
|
|
162
188
|
* How data is provided to the timeline.
|
|
163
189
|
* - `'array'`: Data is provided via the `EntityObjects` array (works with any object type)
|
|
@@ -365,13 +391,31 @@ export class TimelineGroup {
|
|
|
365
391
|
*/
|
|
366
392
|
getDate(record) {
|
|
367
393
|
const value = this.getValue(record, this.DateFieldName);
|
|
394
|
+
let date;
|
|
368
395
|
if (value instanceof Date) {
|
|
369
|
-
|
|
396
|
+
date = value;
|
|
397
|
+
}
|
|
398
|
+
else if (typeof value === 'string' || typeof value === 'number') {
|
|
399
|
+
date = new Date(value);
|
|
370
400
|
}
|
|
371
|
-
|
|
372
|
-
return new Date(
|
|
401
|
+
else {
|
|
402
|
+
return new Date();
|
|
373
403
|
}
|
|
374
|
-
return
|
|
404
|
+
return this.isDateOnlyDateField(record) ? calendarDayAsLocalDate(date) : date;
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Whether `DateFieldName` is a SQL `date` column (a calendar day), from the record's own entity
|
|
408
|
+
* metadata, else the group's {@link EntityInfo}. Entity-sourced groups load BaseEntity objects,
|
|
409
|
+
* which carry it; a plain object relies on the group's. With neither, the date is treated as an
|
|
410
|
+
* instant, as before.
|
|
411
|
+
*/
|
|
412
|
+
isDateOnlyDateField(record) {
|
|
413
|
+
const fieldName = this.DateFieldName?.trim().toLowerCase();
|
|
414
|
+
if (!fieldName)
|
|
415
|
+
return false;
|
|
416
|
+
const entityInfo = record?.EntityInfo ?? this.EntityInfo;
|
|
417
|
+
const field = entityInfo?.Fields?.find(f => f.Name.trim().toLowerCase() === fieldName);
|
|
418
|
+
return IsDateOnlySQLType(field?.Type);
|
|
375
419
|
}
|
|
376
420
|
/**
|
|
377
421
|
* Gets the subtitle from a record.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeline-group.js","sourceRoot":"","sources":["../../src/lib/timeline-group.ts"],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AAwD;gBACxD,wEAAwE,EACxE,KAAK,CACN,CAAC;QACJ,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACI,MAAM,CAAC,SAAS,CACrB,IAAS,EACT,MAUC;QAED,MAAM,KAAK,GAAG,IAAI,aAAa,EAAK,CAAC;QAErC,KAAK,CAAC,cAAc,GAAG,OAAO,CAAC;QAC/B,KAAK,CAAC,aAAa,GAAG,IAAI,CAAC;QAC3B,KAAK,CAAC,cAAc,GAAG,MAAM,CAAC,UAAU,CAAC;QACzC,KAAK,CAAC,aAAa,GAAG,MAAM,CAAC,SAAS,CAAC;QACvC,KAAK,CAAC,iBAAiB,GAAG,MAAM,CAAC,aAAa,CAAC;QAC/C,KAAK,CAAC,oBAAoB,GAAG,MAAM,CAAC,gBAAgB,CAAC;QACrD,KAAK,CAAC,cAAc,GAAG,MAAM,CAAC,UAAU,CAAC;QACzC,KAAK,CAAC,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC;QACnC,KAAK,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QAErC,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;YAChB,KAAK,CAAC,eAAe,GAAG,QAAQ,CAAC;YACjC,KAAK,CAAC,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC;QAClC,CAAC;QAED,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;YACjB,KAAK,CAAC,gBAAgB,GAAG,QAAQ,CAAC;YAClC,KAAK,CAAC,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC;QACpC,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF","sourcesContent":["/**\n * @fileoverview TimelineGroup class for configuring timeline data sources.\n *\n * The TimelineGroup class defines how data is loaded and displayed in the timeline.\n * It supports both MemberJunction BaseEntity objects and plain JavaScript objects,\n * making it usable in any Angular application.\n *\n * @module @memberjunction/ng-timeline/timeline-group\n */\n\nimport { IMetadataProvider, Metadata, RunView } from '@memberjunction/core';\nimport {\n TimelineCardConfig,\n TimelineEventConfig,\n DEFAULT_CARD_CONFIG\n} from './types';\n\n// ============================================================================\n// HELPER FUNCTION - FIELD VALUE ACCESS\n// ============================================================================\n\n/**\n * Extracts a field value from a record, supporting both BaseEntity and plain objects.\n *\n * For BaseEntity objects (detected by presence of `.Get()` method), uses the `.Get()` method.\n * For plain JavaScript objects, uses standard bracket notation.\n *\n * @param record - The source record (BaseEntity or plain object)\n * @param fieldName - The name of the field to extract\n * @returns The field value, or undefined if not found\n *\n * @example\n * ```typescript\n * // Works with BaseEntity\n * const entity = await md.GetEntityObject<MJTaskEntity>('Tasks');\n * const name = getFieldValue(entity, 'Name'); // Uses entity.Get('Name')\n *\n * // Works with plain objects\n * const obj = { name: 'My Task', status: 'Open' };\n * const name = getFieldValue(obj, 'name'); // Uses obj['name']\n * ```\n */\nexport function getFieldValue(record: any, fieldName: string): unknown {\n if (record == null) {\n return undefined;\n }\n\n // Check if this is a BaseEntity (has .Get() method)\n if (typeof record.Get === 'function') {\n return record.Get(fieldName);\n }\n\n // Plain object - use bracket notation\n return record[fieldName];\n}\n\n/**\n * Extracts an ID from a record, trying common ID field names.\n *\n * @param record - The source record\n * @param idFieldName - Optional explicit ID field name\n * @returns The record ID as a string, or a generated fallback ID\n */\nexport function getRecordId(record: any, idFieldName?: string): string {\n if (record == null) {\n return `generated-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;\n }\n\n // Try explicit field name first\n if (idFieldName) {\n const id = getFieldValue(record, idFieldName);\n if (id != null) {\n return String(id);\n }\n }\n\n // Try common ID field names\n const commonIdFields = ['ID', 'id', 'Id', '_id', 'uuid', 'UUID'];\n for (const field of commonIdFields) {\n const id = getFieldValue(record, field);\n if (id != null) {\n return String(id);\n }\n }\n\n // Fallback: generate a unique ID\n return `generated-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;\n}\n\n// ============================================================================\n// TIMELINE GROUP CLASS\n// ============================================================================\n\n/**\n * Configures a data source for the timeline component.\n *\n * TimelineGroup defines how records are loaded, which fields to display,\n * and how they should be styled. Multiple groups can be used to display\n * different types of events on the same timeline.\n *\n * @typeParam T - The type of the source records. Defaults to `any` for maximum\n * flexibility. MemberJunction users can specify BaseEntity subclasses\n * for full type safety.\n *\n * @example Basic usage with plain objects\n * ```typescript\n * interface MyEvent {\n * id: string;\n * title: string;\n * eventDate: Date;\n * description: string;\n * }\n *\n * const group = new TimelineGroup<MyEvent>();\n * group.DataSourceType = 'array';\n * group.EntityObjects = myEventsArray;\n * group.TitleFieldName = 'title';\n * group.DateFieldName = 'eventDate';\n * group.DescriptionFieldName = 'description';\n * ```\n *\n * @example MemberJunction usage with BaseEntity\n * ```typescript\n * import { MJTaskEntity } from '@memberjunction/core-entities';\n *\n * const group = new TimelineGroup<MJTaskEntity>();\n * group.EntityName = 'Tasks';\n * group.DataSourceType = 'entity';\n * group.Filter = \"Status = 'Open'\";\n * group.TitleFieldName = 'Name';\n * group.DateFieldName = 'DueDate';\n * ```\n *\n * @example With full configuration\n * ```typescript\n * const group = new TimelineGroup<MJTaskEntity>();\n * group.EntityName = 'Tasks';\n * group.TitleFieldName = 'Name';\n * group.DateFieldName = 'CompletedAt';\n * group.SubtitleFieldName = 'Category';\n * group.DescriptionFieldName = 'Description';\n * group.DisplayIcon = 'fa-solid fa-check-circle';\n * group.DisplayColor = '#4caf50';\n * group.GroupLabel = 'Completed Tasks';\n *\n * group.CardConfig = {\n * collapsible: true,\n * defaultExpanded: false,\n * summaryFields: [\n * { fieldName: 'AssignedTo', label: 'Assignee', icon: 'fa-solid fa-user' },\n * { fieldName: 'Priority', icon: 'fa-solid fa-flag' }\n * ],\n * actions: [\n * { id: 'view', label: 'View', variant: 'primary' },\n * { id: 'edit', label: 'Edit', variant: 'secondary' }\n * ]\n * };\n *\n * group.EventConfigFunction = (task) => ({\n * icon: task.Priority === 'High' ? 'fa-solid fa-exclamation' : undefined,\n * color: task.Status === 'Overdue' ? '#f44336' : undefined\n * });\n * ```\n */\nexport class TimelineGroup<T = any> {\n // ============================================================================\n // DATA SOURCE CONFIGURATION\n // ============================================================================\n\n /**\n * The MemberJunction entity name for this group.\n * Required when `DataSourceType` is `'entity'`.\n *\n * @example 'Tasks', 'MJ: AI Agents', 'Users'\n */\n EntityName?: string;\n\n /**\n * How data is provided to the timeline.\n * - `'array'`: Data is provided via the `EntityObjects` array (works with any object type)\n * - `'entity'`: Data is loaded using MemberJunction's RunView (requires MJ core)\n *\n * @default 'entity'\n */\n DataSourceType: 'array' | 'entity' = 'entity';\n\n /**\n * SQL WHERE clause filter for entity queries.\n * Only used when `DataSourceType` is `'entity'`.\n *\n * @example \"Status = 'Open' AND Priority = 'High'\"\n */\n Filter?: string;\n\n /**\n * Pre-loaded data array.\n * Used when `DataSourceType` is `'array'`, or populated after loading when using `'entity'`.\n */\n EntityObjects: T[] = [];\n\n /**\n * SQL ORDER BY clause for entity queries.\n * Only used when `DataSourceType` is `'entity'`.\n *\n * @example 'CreatedAt DESC', 'Priority ASC, DueDate DESC'\n */\n OrderBy?: string;\n\n /**\n * Maximum number of records to load per batch.\n * Used for virtual scrolling.\n *\n * @default undefined (uses component's virtualScroll.batchSize)\n */\n MaxRecords?: number;\n\n // ============================================================================\n // FIELD MAPPINGS\n // ============================================================================\n\n /**\n * Field name for the event title.\n * This is the primary text displayed on each timeline card.\n *\n * @required\n */\n TitleFieldName!: string;\n\n /**\n * Field name for the event date.\n * Used for chronological ordering and date display.\n *\n * @required\n */\n DateFieldName!: string;\n\n /**\n * Field name for the subtitle.\n * Displayed below the title in smaller text.\n */\n SubtitleFieldName?: string;\n\n /**\n * Field name for the description/body text.\n * Displayed in the card body when expanded.\n */\n DescriptionFieldName?: string;\n\n /**\n * Field name containing an image URL.\n * When set, displays an image in the card.\n */\n ImageFieldName?: string;\n\n /**\n * Field name for the unique record ID.\n * Defaults to 'ID' or 'id' if not specified.\n */\n IdFieldName?: string;\n\n // ============================================================================\n // GROUP-LEVEL DISPLAY\n // ============================================================================\n\n /**\n * Icon display mode.\n * - `'standard'`: Uses a default icon based on the group index\n * - `'custom'`: Uses the icon specified in `DisplayIcon`\n *\n * @default 'standard'\n */\n DisplayIconMode: 'standard' | 'custom' = 'standard';\n\n /**\n * Custom icon class (Font Awesome).\n * Only used when `DisplayIconMode` is `'custom'`.\n *\n * @example 'fa-solid fa-check', 'fa-regular fa-calendar'\n */\n DisplayIcon?: string;\n\n /**\n * Color assignment mode.\n * - `'auto'`: System assigns colors based on group index\n * - `'manual'`: Uses the color specified in `DisplayColor`\n *\n * @default 'auto'\n */\n DisplayColorMode: 'auto' | 'manual' = 'auto';\n\n /**\n * Custom color for this group's markers and accents.\n * Only used when `DisplayColorMode` is `'manual'`.\n * Any valid CSS color value.\n *\n * @example '#4caf50', 'rgb(66, 135, 245)', 'var(--primary-color)'\n */\n DisplayColor?: string;\n\n /**\n * Human-readable label for this group.\n * Used in legends, headers, or when distinguishing multiple groups.\n *\n * @example 'Completed Tasks', 'System Events', 'User Activities'\n */\n GroupLabel?: string;\n\n // ============================================================================\n // CARD CONFIGURATION\n // ============================================================================\n\n /**\n * Card display configuration for this group.\n * Defines how event cards are rendered.\n * If not set, uses the component's `defaultCardConfig`.\n */\n CardConfig?: TimelineCardConfig;\n\n // ============================================================================\n // CUSTOM FUNCTIONS\n // ============================================================================\n\n /**\n * Custom function to generate the event summary/description.\n * Takes precedence over `DescriptionFieldName`.\n *\n * @param record - The source record\n * @returns HTML string or plain text to display\n *\n * @example\n * ```typescript\n * group.SummaryFunction = (task) => {\n * return `<strong>${task.Status}</strong>: ${task.Description}`;\n * };\n * ```\n */\n SummaryFunction?: (record: T) => string;\n\n /**\n * Custom function to configure individual events.\n * Allows per-event customization of icons, colors, and actions.\n *\n * @param record - The source record\n * @returns Configuration overrides for this event\n *\n * @example\n * ```typescript\n * group.EventConfigFunction = (task) => ({\n * icon: task.Priority === 'High' ? 'fa-solid fa-exclamation' : undefined,\n * color: task.IsOverdue ? '#f44336' : undefined,\n * actions: task.CanEdit ? [{ id: 'edit', label: 'Edit' }] : []\n * });\n * ```\n */\n EventConfigFunction?: (record: T) => TimelineEventConfig;\n\n // ============================================================================\n // METHODS\n // ============================================================================\n\n /**\n * Gets the effective card configuration, merging with defaults.\n *\n * @returns The merged card configuration\n */\n getEffectiveCardConfig(): TimelineCardConfig {\n return {\n ...DEFAULT_CARD_CONFIG,\n ...this.CardConfig\n };\n }\n\n /**\n * Extracts a field value from a record in this group.\n *\n * @param record - The source record\n * @param fieldName - The field name to extract\n * @returns The field value\n */\n getValue(record: T, fieldName: string): unknown {\n return getFieldValue(record, fieldName);\n }\n\n /**\n * Gets the ID of a record in this group.\n *\n * @param record - The source record\n * @returns The record ID\n */\n getId(record: T): string {\n return getRecordId(record, this.IdFieldName);\n }\n\n /**\n * Gets the title from a record.\n *\n * @param record - The source record\n * @returns The title string\n */\n getTitle(record: T): string {\n const value = this.getValue(record, this.TitleFieldName);\n return value != null ? String(value) : '';\n }\n\n /**\n * Gets the date from a record.\n *\n * @param record - The source record\n * @returns The date object\n */\n getDate(record: T): Date {\n const value = this.getValue(record, this.DateFieldName);\n if (value instanceof Date) {\n return value;\n }\n if (typeof value === 'string' || typeof value === 'number') {\n return new Date(value);\n }\n return new Date();\n }\n\n /**\n * Gets the subtitle from a record.\n *\n * @param record - The source record\n * @returns The subtitle string, or undefined\n */\n getSubtitle(record: T): string | undefined {\n if (!this.SubtitleFieldName) {\n return undefined;\n }\n const value = this.getValue(record, this.SubtitleFieldName);\n return value != null ? String(value) : undefined;\n }\n\n /**\n * Gets the description from a record.\n *\n * @param record - The source record\n * @returns The description string, or undefined\n */\n getDescription(record: T): string | undefined {\n // Use custom summary function if provided\n if (this.SummaryFunction) {\n return this.SummaryFunction(record);\n }\n\n // Use description field\n if (this.DescriptionFieldName) {\n const value = this.getValue(record, this.DescriptionFieldName);\n return value != null ? String(value) : undefined;\n }\n\n return undefined;\n }\n\n /**\n * Gets the image URL from a record.\n *\n * @param record - The source record\n * @returns The image URL, or undefined\n */\n getImageUrl(record: T): string | undefined {\n const fieldName = this.CardConfig?.imageField || this.ImageFieldName;\n if (!fieldName) {\n return undefined;\n }\n const value = this.getValue(record, fieldName);\n return value != null ? String(value) : undefined;\n }\n\n /**\n * Gets the event configuration for a specific record.\n *\n * @param record - The source record\n * @returns The event configuration (from EventConfigFunction or defaults)\n */\n getEventConfig(record: T): TimelineEventConfig {\n if (this.EventConfigFunction) {\n return this.EventConfigFunction(record);\n }\n return {};\n }\n\n // ============================================================================\n // STATIC FACTORY METHODS\n // ============================================================================\n\n /**\n * Creates a TimelineGroup from MemberJunction RunViewParams.\n *\n * This is a convenience method for MemberJunction applications.\n * It loads data immediately and returns a configured group.\n *\n * **Note**: This method requires `@memberjunction/core` to be available.\n * It will throw an error if used in non-MJ applications.\n *\n * @param params - RunView parameters for loading data\n * @returns A configured TimelineGroup with loaded data\n *\n * @example\n * ```typescript\n * const group = await TimelineGroup.FromView<MJTaskEntity>({\n * EntityName: 'Tasks',\n * ExtraFilter: \"Status = 'Open'\",\n * OrderBy: 'DueDate DESC'\n * });\n * group.TitleFieldName = 'Name';\n * group.DateFieldName = 'DueDate';\n * ```\n */\n public static async FromView<T = any>(params: {\n EntityName?: string;\n ExtraFilter?: string;\n OrderBy?: string;\n MaxRows?: number;\n /** The provider to read through. Omit to use the global default. */\n Provider?: IMetadataProvider;\n [key: string]: unknown;\n }): Promise<TimelineGroup<T>> {\n const group = new TimelineGroup<T>();\n\n try {\n // Provider-scoped, and a STATIC import: the dynamic form here hid the dependency from the\n // bundler and from readers while the package depends on @memberjunction/core regardless.\n const rv = RunView.FromMetadataProvider(params.Provider ?? Metadata.Provider);\n // `Provider` scopes the read; it is not a RunView parameter, so it must not be forwarded.\n const { Provider: _provider, ...viewFields } = params;\n const viewParams = {\n ...viewFields,\n ResultType: 'entity_object' as const\n };\n\n const result = await rv.RunView(viewParams);\n\n if (result?.Success) {\n group.EntityName = params.EntityName;\n group.EntityObjects = result.Results as T[];\n group.DataSourceType = 'array'; // Already loaded\n group.Filter = params.ExtraFilter;\n group.OrderBy = params.OrderBy;\n }\n } catch (error) {\n console.warn(\n 'TimelineGroup.FromView requires @memberjunction/core. ' +\n 'Use DataSourceType=\"array\" with EntityObjects for non-MJ applications.',\n error\n );\n }\n\n return group;\n }\n\n /**\n * Creates a TimelineGroup from a plain array of objects.\n *\n * This is a convenience method that sets up the group for array-based data.\n *\n * @param data - Array of objects to display\n * @param config - Configuration for field mappings\n * @returns A configured TimelineGroup\n *\n * @example\n * ```typescript\n * const group = TimelineGroup.FromArray(myEvents, {\n * titleField: 'name',\n * dateField: 'eventDate',\n * descriptionField: 'details'\n * });\n * ```\n */\n public static FromArray<T = any>(\n data: T[],\n config: {\n titleField: string;\n dateField: string;\n subtitleField?: string;\n descriptionField?: string;\n imageField?: string;\n idField?: string;\n groupLabel?: string;\n icon?: string;\n color?: string;\n }\n ): TimelineGroup<T> {\n const group = new TimelineGroup<T>();\n\n group.DataSourceType = 'array';\n group.EntityObjects = data;\n group.TitleFieldName = config.titleField;\n group.DateFieldName = config.dateField;\n group.SubtitleFieldName = config.subtitleField;\n group.DescriptionFieldName = config.descriptionField;\n group.ImageFieldName = config.imageField;\n group.IdFieldName = config.idField;\n group.GroupLabel = config.groupLabel;\n\n if (config.icon) {\n group.DisplayIconMode = 'custom';\n group.DisplayIcon = config.icon;\n }\n\n if (config.color) {\n group.DisplayColorMode = 'manual';\n group.DisplayColor = config.color;\n }\n\n return group;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"timeline-group.js","sourceRoot":"","sources":["../../src/lib/timeline-group.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAiC,iBAAiB,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC3G,OAAO,EAGL,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAEjB,+EAA+E;AAC/E,kCAAkC;AAClC,+EAA+E;AAE/E;;;;;;;;GAQG;AACH,SAAS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CAAC,aAAa,CAAC;QAC/C,KAAK,CAAC,oBAAoB,GAAG,MAAM,CAAC,gBAAgB,CAAC;QACrD,KAAK,CAAC,cAAc,GAAG,MAAM,CAAC,UAAU,CAAC;QACzC,KAAK,CAAC,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC;QACnC,KAAK,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QAErC,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;YAChB,KAAK,CAAC,eAAe,GAAG,QAAQ,CAAC;YACjC,KAAK,CAAC,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC;QAClC,CAAC;QAED,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;YACjB,KAAK,CAAC,gBAAgB,GAAG,QAAQ,CAAC;YAClC,KAAK,CAAC,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC;QACpC,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF","sourcesContent":["/**\n * @fileoverview TimelineGroup class for configuring timeline data sources.\n *\n * The TimelineGroup class defines how data is loaded and displayed in the timeline.\n * It supports both MemberJunction BaseEntity objects and plain JavaScript objects,\n * making it usable in any Angular application.\n *\n * @module @memberjunction/ng-timeline/timeline-group\n */\n\nimport { EntityInfo, IMetadataProvider, IsDateOnlySQLType, Metadata, RunView } from '@memberjunction/core';\nimport {\n TimelineCardConfig,\n TimelineEventConfig,\n DEFAULT_CARD_CONFIG\n} from './types';\n\n// ============================================================================\n// HELPER FUNCTION - CALENDAR DAYS\n// ============================================================================\n\n/**\n * A SQL `date` value re-anchored on LOCAL midnight of the day it stores.\n *\n * A calendar day arrives as UTC midnight. The timeline groups and labels every event with local\n * getters (day, week, month, quarter, year segments and its own date formatter), which read that as\n * the previous day west of Greenwich: an event dated Oct 1 fell into a \"September 30\" day segment\n * and, on the 1st of a month, into the prior month. Carrying the day as local midnight makes every\n * one of those local readings return the stored day.\n */\nfunction calendarDayAsLocalDate(date: Date): Date {\n if (isNaN(date.getTime())) return date;\n return new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());\n}\n\n// ============================================================================\n// HELPER FUNCTION - FIELD VALUE ACCESS\n// ============================================================================\n\n/**\n * Extracts a field value from a record, supporting both BaseEntity and plain objects.\n *\n * For BaseEntity objects (detected by presence of `.Get()` method), uses the `.Get()` method.\n * For plain JavaScript objects, uses standard bracket notation.\n *\n * @param record - The source record (BaseEntity or plain object)\n * @param fieldName - The name of the field to extract\n * @returns The field value, or undefined if not found\n *\n * @example\n * ```typescript\n * // Works with BaseEntity\n * const entity = await md.GetEntityObject<MJTaskEntity>('Tasks');\n * const name = getFieldValue(entity, 'Name'); // Uses entity.Get('Name')\n *\n * // Works with plain objects\n * const obj = { name: 'My Task', status: 'Open' };\n * const name = getFieldValue(obj, 'name'); // Uses obj['name']\n * ```\n */\nexport function getFieldValue(record: any, fieldName: string): unknown {\n if (record == null) {\n return undefined;\n }\n\n // Check if this is a BaseEntity (has .Get() method)\n if (typeof record.Get === 'function') {\n return record.Get(fieldName);\n }\n\n // Plain object - use bracket notation\n return record[fieldName];\n}\n\n/**\n * Extracts an ID from a record, trying common ID field names.\n *\n * @param record - The source record\n * @param idFieldName - Optional explicit ID field name\n * @returns The record ID as a string, or a generated fallback ID\n */\nexport function getRecordId(record: any, idFieldName?: string): string {\n if (record == null) {\n return `generated-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;\n }\n\n // Try explicit field name first\n if (idFieldName) {\n const id = getFieldValue(record, idFieldName);\n if (id != null) {\n return String(id);\n }\n }\n\n // Try common ID field names\n const commonIdFields = ['ID', 'id', 'Id', '_id', 'uuid', 'UUID'];\n for (const field of commonIdFields) {\n const id = getFieldValue(record, field);\n if (id != null) {\n return String(id);\n }\n }\n\n // Fallback: generate a unique ID\n return `generated-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;\n}\n\n// ============================================================================\n// TIMELINE GROUP CLASS\n// ============================================================================\n\n/**\n * Configures a data source for the timeline component.\n *\n * TimelineGroup defines how records are loaded, which fields to display,\n * and how they should be styled. Multiple groups can be used to display\n * different types of events on the same timeline.\n *\n * @typeParam T - The type of the source records. Defaults to `any` for maximum\n * flexibility. MemberJunction users can specify BaseEntity subclasses\n * for full type safety.\n *\n * @example Basic usage with plain objects\n * ```typescript\n * interface MyEvent {\n * id: string;\n * title: string;\n * eventDate: Date;\n * description: string;\n * }\n *\n * const group = new TimelineGroup<MyEvent>();\n * group.DataSourceType = 'array';\n * group.EntityObjects = myEventsArray;\n * group.TitleFieldName = 'title';\n * group.DateFieldName = 'eventDate';\n * group.DescriptionFieldName = 'description';\n * ```\n *\n * @example MemberJunction usage with BaseEntity\n * ```typescript\n * import { MJTaskEntity } from '@memberjunction/core-entities';\n *\n * const group = new TimelineGroup<MJTaskEntity>();\n * group.EntityName = 'Tasks';\n * group.DataSourceType = 'entity';\n * group.Filter = \"Status = 'Open'\";\n * group.TitleFieldName = 'Name';\n * group.DateFieldName = 'DueDate';\n * ```\n *\n * @example With full configuration\n * ```typescript\n * const group = new TimelineGroup<MJTaskEntity>();\n * group.EntityName = 'Tasks';\n * group.TitleFieldName = 'Name';\n * group.DateFieldName = 'CompletedAt';\n * group.SubtitleFieldName = 'Category';\n * group.DescriptionFieldName = 'Description';\n * group.DisplayIcon = 'fa-solid fa-check-circle';\n * group.DisplayColor = '#4caf50';\n * group.GroupLabel = 'Completed Tasks';\n *\n * group.CardConfig = {\n * collapsible: true,\n * defaultExpanded: false,\n * summaryFields: [\n * { fieldName: 'AssignedTo', label: 'Assignee', icon: 'fa-solid fa-user' },\n * { fieldName: 'Priority', icon: 'fa-solid fa-flag' }\n * ],\n * actions: [\n * { id: 'view', label: 'View', variant: 'primary' },\n * { id: 'edit', label: 'Edit', variant: 'secondary' }\n * ]\n * };\n *\n * group.EventConfigFunction = (task) => ({\n * icon: task.Priority === 'High' ? 'fa-solid fa-exclamation' : undefined,\n * color: task.Status === 'Overdue' ? '#f44336' : undefined\n * });\n * ```\n */\nexport class TimelineGroup<T = any> {\n // ============================================================================\n // DATA SOURCE CONFIGURATION\n // ============================================================================\n\n /**\n * The MemberJunction entity name for this group.\n * Required when `DataSourceType` is `'entity'`.\n *\n * @example 'Tasks', 'MJ: AI Agents', 'Users'\n */\n EntityName?: string;\n\n /**\n * Metadata for the entity this group's records come from, for records that do not carry their own.\n *\n * A BaseEntity record exposes `EntityInfo`, and the group reads field types from it. A plain object\n * (an `'array'` group fed `simple` RunView rows, as the entity viewer's timeline does) has none, so\n * without this a SQL `date` field is read as an instant and lands a day early west of Greenwich.\n * A record's own `EntityInfo` wins when it has one.\n */\n EntityInfo?: EntityInfo;\n\n /**\n * How data is provided to the timeline.\n * - `'array'`: Data is provided via the `EntityObjects` array (works with any object type)\n * - `'entity'`: Data is loaded using MemberJunction's RunView (requires MJ core)\n *\n * @default 'entity'\n */\n DataSourceType: 'array' | 'entity' = 'entity';\n\n /**\n * SQL WHERE clause filter for entity queries.\n * Only used when `DataSourceType` is `'entity'`.\n *\n * @example \"Status = 'Open' AND Priority = 'High'\"\n */\n Filter?: string;\n\n /**\n * Pre-loaded data array.\n * Used when `DataSourceType` is `'array'`, or populated after loading when using `'entity'`.\n */\n EntityObjects: T[] = [];\n\n /**\n * SQL ORDER BY clause for entity queries.\n * Only used when `DataSourceType` is `'entity'`.\n *\n * @example 'CreatedAt DESC', 'Priority ASC, DueDate DESC'\n */\n OrderBy?: string;\n\n /**\n * Maximum number of records to load per batch.\n * Used for virtual scrolling.\n *\n * @default undefined (uses component's virtualScroll.batchSize)\n */\n MaxRecords?: number;\n\n // ============================================================================\n // FIELD MAPPINGS\n // ============================================================================\n\n /**\n * Field name for the event title.\n * This is the primary text displayed on each timeline card.\n *\n * @required\n */\n TitleFieldName!: string;\n\n /**\n * Field name for the event date.\n * Used for chronological ordering and date display.\n *\n * @required\n */\n DateFieldName!: string;\n\n /**\n * Field name for the subtitle.\n * Displayed below the title in smaller text.\n */\n SubtitleFieldName?: string;\n\n /**\n * Field name for the description/body text.\n * Displayed in the card body when expanded.\n */\n DescriptionFieldName?: string;\n\n /**\n * Field name containing an image URL.\n * When set, displays an image in the card.\n */\n ImageFieldName?: string;\n\n /**\n * Field name for the unique record ID.\n * Defaults to 'ID' or 'id' if not specified.\n */\n IdFieldName?: string;\n\n // ============================================================================\n // GROUP-LEVEL DISPLAY\n // ============================================================================\n\n /**\n * Icon display mode.\n * - `'standard'`: Uses a default icon based on the group index\n * - `'custom'`: Uses the icon specified in `DisplayIcon`\n *\n * @default 'standard'\n */\n DisplayIconMode: 'standard' | 'custom' = 'standard';\n\n /**\n * Custom icon class (Font Awesome).\n * Only used when `DisplayIconMode` is `'custom'`.\n *\n * @example 'fa-solid fa-check', 'fa-regular fa-calendar'\n */\n DisplayIcon?: string;\n\n /**\n * Color assignment mode.\n * - `'auto'`: System assigns colors based on group index\n * - `'manual'`: Uses the color specified in `DisplayColor`\n *\n * @default 'auto'\n */\n DisplayColorMode: 'auto' | 'manual' = 'auto';\n\n /**\n * Custom color for this group's markers and accents.\n * Only used when `DisplayColorMode` is `'manual'`.\n * Any valid CSS color value.\n *\n * @example '#4caf50', 'rgb(66, 135, 245)', 'var(--primary-color)'\n */\n DisplayColor?: string;\n\n /**\n * Human-readable label for this group.\n * Used in legends, headers, or when distinguishing multiple groups.\n *\n * @example 'Completed Tasks', 'System Events', 'User Activities'\n */\n GroupLabel?: string;\n\n // ============================================================================\n // CARD CONFIGURATION\n // ============================================================================\n\n /**\n * Card display configuration for this group.\n * Defines how event cards are rendered.\n * If not set, uses the component's `defaultCardConfig`.\n */\n CardConfig?: TimelineCardConfig;\n\n // ============================================================================\n // CUSTOM FUNCTIONS\n // ============================================================================\n\n /**\n * Custom function to generate the event summary/description.\n * Takes precedence over `DescriptionFieldName`.\n *\n * @param record - The source record\n * @returns HTML string or plain text to display\n *\n * @example\n * ```typescript\n * group.SummaryFunction = (task) => {\n * return `<strong>${task.Status}</strong>: ${task.Description}`;\n * };\n * ```\n */\n SummaryFunction?: (record: T) => string;\n\n /**\n * Custom function to configure individual events.\n * Allows per-event customization of icons, colors, and actions.\n *\n * @param record - The source record\n * @returns Configuration overrides for this event\n *\n * @example\n * ```typescript\n * group.EventConfigFunction = (task) => ({\n * icon: task.Priority === 'High' ? 'fa-solid fa-exclamation' : undefined,\n * color: task.IsOverdue ? '#f44336' : undefined,\n * actions: task.CanEdit ? [{ id: 'edit', label: 'Edit' }] : []\n * });\n * ```\n */\n EventConfigFunction?: (record: T) => TimelineEventConfig;\n\n // ============================================================================\n // METHODS\n // ============================================================================\n\n /**\n * Gets the effective card configuration, merging with defaults.\n *\n * @returns The merged card configuration\n */\n getEffectiveCardConfig(): TimelineCardConfig {\n return {\n ...DEFAULT_CARD_CONFIG,\n ...this.CardConfig\n };\n }\n\n /**\n * Extracts a field value from a record in this group.\n *\n * @param record - The source record\n * @param fieldName - The field name to extract\n * @returns The field value\n */\n getValue(record: T, fieldName: string): unknown {\n return getFieldValue(record, fieldName);\n }\n\n /**\n * Gets the ID of a record in this group.\n *\n * @param record - The source record\n * @returns The record ID\n */\n getId(record: T): string {\n return getRecordId(record, this.IdFieldName);\n }\n\n /**\n * Gets the title from a record.\n *\n * @param record - The source record\n * @returns The title string\n */\n getTitle(record: T): string {\n const value = this.getValue(record, this.TitleFieldName);\n return value != null ? String(value) : '';\n }\n\n /**\n * Gets the date from a record.\n *\n * @param record - The source record\n * @returns The date object\n */\n getDate(record: T): Date {\n const value = this.getValue(record, this.DateFieldName);\n let date: Date;\n if (value instanceof Date) {\n date = value;\n } else if (typeof value === 'string' || typeof value === 'number') {\n date = new Date(value);\n } else {\n return new Date();\n }\n return this.isDateOnlyDateField(record) ? calendarDayAsLocalDate(date) : date;\n }\n\n /**\n * Whether `DateFieldName` is a SQL `date` column (a calendar day), from the record's own entity\n * metadata, else the group's {@link EntityInfo}. Entity-sourced groups load BaseEntity objects,\n * which carry it; a plain object relies on the group's. With neither, the date is treated as an\n * instant, as before.\n */\n private isDateOnlyDateField(record: T): boolean {\n const fieldName = this.DateFieldName?.trim().toLowerCase();\n if (!fieldName) return false;\n const entityInfo = (record as { EntityInfo?: EntityInfo } | null)?.EntityInfo ?? this.EntityInfo;\n const field = entityInfo?.Fields?.find(f => f.Name.trim().toLowerCase() === fieldName);\n return IsDateOnlySQLType(field?.Type);\n }\n\n /**\n * Gets the subtitle from a record.\n *\n * @param record - The source record\n * @returns The subtitle string, or undefined\n */\n getSubtitle(record: T): string | undefined {\n if (!this.SubtitleFieldName) {\n return undefined;\n }\n const value = this.getValue(record, this.SubtitleFieldName);\n return value != null ? String(value) : undefined;\n }\n\n /**\n * Gets the description from a record.\n *\n * @param record - The source record\n * @returns The description string, or undefined\n */\n getDescription(record: T): string | undefined {\n // Use custom summary function if provided\n if (this.SummaryFunction) {\n return this.SummaryFunction(record);\n }\n\n // Use description field\n if (this.DescriptionFieldName) {\n const value = this.getValue(record, this.DescriptionFieldName);\n return value != null ? String(value) : undefined;\n }\n\n return undefined;\n }\n\n /**\n * Gets the image URL from a record.\n *\n * @param record - The source record\n * @returns The image URL, or undefined\n */\n getImageUrl(record: T): string | undefined {\n const fieldName = this.CardConfig?.imageField || this.ImageFieldName;\n if (!fieldName) {\n return undefined;\n }\n const value = this.getValue(record, fieldName);\n return value != null ? String(value) : undefined;\n }\n\n /**\n * Gets the event configuration for a specific record.\n *\n * @param record - The source record\n * @returns The event configuration (from EventConfigFunction or defaults)\n */\n getEventConfig(record: T): TimelineEventConfig {\n if (this.EventConfigFunction) {\n return this.EventConfigFunction(record);\n }\n return {};\n }\n\n // ============================================================================\n // STATIC FACTORY METHODS\n // ============================================================================\n\n /**\n * Creates a TimelineGroup from MemberJunction RunViewParams.\n *\n * This is a convenience method for MemberJunction applications.\n * It loads data immediately and returns a configured group.\n *\n * **Note**: This method requires `@memberjunction/core` to be available.\n * It will throw an error if used in non-MJ applications.\n *\n * @param params - RunView parameters for loading data\n * @returns A configured TimelineGroup with loaded data\n *\n * @example\n * ```typescript\n * const group = await TimelineGroup.FromView<MJTaskEntity>({\n * EntityName: 'Tasks',\n * ExtraFilter: \"Status = 'Open'\",\n * OrderBy: 'DueDate DESC'\n * });\n * group.TitleFieldName = 'Name';\n * group.DateFieldName = 'DueDate';\n * ```\n */\n public static async FromView<T = any>(params: {\n EntityName?: string;\n ExtraFilter?: string;\n OrderBy?: string;\n MaxRows?: number;\n /** The provider to read through. Omit to use the global default. */\n Provider?: IMetadataProvider;\n [key: string]: unknown;\n }): Promise<TimelineGroup<T>> {\n const group = new TimelineGroup<T>();\n\n try {\n // Provider-scoped, and a STATIC import: the dynamic form here hid the dependency from the\n // bundler and from readers while the package depends on @memberjunction/core regardless.\n const rv = RunView.FromMetadataProvider(params.Provider ?? Metadata.Provider);\n // `Provider` scopes the read; it is not a RunView parameter, so it must not be forwarded.\n const { Provider: _provider, ...viewFields } = params;\n const viewParams = {\n ...viewFields,\n ResultType: 'entity_object' as const\n };\n\n const result = await rv.RunView(viewParams);\n\n if (result?.Success) {\n group.EntityName = params.EntityName;\n group.EntityObjects = result.Results as T[];\n group.DataSourceType = 'array'; // Already loaded\n group.Filter = params.ExtraFilter;\n group.OrderBy = params.OrderBy;\n }\n } catch (error) {\n console.warn(\n 'TimelineGroup.FromView requires @memberjunction/core. ' +\n 'Use DataSourceType=\"array\" with EntityObjects for non-MJ applications.',\n error\n );\n }\n\n return group;\n }\n\n /**\n * Creates a TimelineGroup from a plain array of objects.\n *\n * This is a convenience method that sets up the group for array-based data.\n *\n * @param data - Array of objects to display\n * @param config - Configuration for field mappings\n * @returns A configured TimelineGroup\n *\n * @example\n * ```typescript\n * const group = TimelineGroup.FromArray(myEvents, {\n * titleField: 'name',\n * dateField: 'eventDate',\n * descriptionField: 'details'\n * });\n * ```\n */\n public static FromArray<T = any>(\n data: T[],\n config: {\n titleField: string;\n dateField: string;\n subtitleField?: string;\n descriptionField?: string;\n imageField?: string;\n idField?: string;\n groupLabel?: string;\n icon?: string;\n color?: string;\n }\n ): TimelineGroup<T> {\n const group = new TimelineGroup<T>();\n\n group.DataSourceType = 'array';\n group.EntityObjects = data;\n group.TitleFieldName = config.titleField;\n group.DateFieldName = config.dateField;\n group.SubtitleFieldName = config.subtitleField;\n group.DescriptionFieldName = config.descriptionField;\n group.ImageFieldName = config.imageField;\n group.IdFieldName = config.idField;\n group.GroupLabel = config.groupLabel;\n\n if (config.icon) {\n group.DisplayIconMode = 'custom';\n group.DisplayIcon = config.icon;\n }\n\n if (config.color) {\n group.DisplayColorMode = 'manual';\n group.DisplayColor = config.color;\n }\n\n return group;\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/ng-timeline",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.5",
|
|
4
4
|
"description": "MemberJunction: Responsive timeline component for Angular. Works with MemberJunction entities or plain JavaScript objects. No external dependencies.",
|
|
5
5
|
"main": "./dist/public-api.js",
|
|
6
6
|
"typings": "./dist/public-api.d.ts",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@angular/compiler": "21.2.22",
|
|
22
22
|
"@angular/compiler-cli": "21.2.22",
|
|
23
|
-
"@memberjunction/ng-test-utils": "6.1.
|
|
23
|
+
"@memberjunction/ng-test-utils": "6.1.5",
|
|
24
24
|
"vitest": "^4.0.18"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@memberjunction/ng-base-types": "6.1.
|
|
37
|
-
"@memberjunction/ng-ui-components": "6.1.
|
|
38
|
-
"@memberjunction/core": "6.1.
|
|
36
|
+
"@memberjunction/ng-base-types": "6.1.5",
|
|
37
|
+
"@memberjunction/ng-ui-components": "6.1.5",
|
|
38
|
+
"@memberjunction/core": "6.1.5",
|
|
39
39
|
"rxjs": "~7.8.2",
|
|
40
40
|
"tslib": "^2.8.1"
|
|
41
41
|
},
|