@tensor_1/react 2.29.0 → 2.30.0
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.
- package/README.md +23 -0
- package/dist/components/SchedulingTimeline.d.ts +109 -0
- package/dist/components/SchedulingTimeline.js +245 -0
- package/dist/index.cjs +664 -303
- package/dist/index.d.cts +174 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +23 -0
- package/dist/labels-context.d.ts +3 -0
- package/dist/scheduling-timeline-model.d.ts +71 -0
- package/dist/scheduling-timeline-model.js +108 -0
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -466,6 +466,178 @@ interface DateRangePickerProps {
|
|
|
466
466
|
/** Controlled, two-month range picker using the UIx calendar language. */
|
|
467
467
|
declare function DateRangePicker({ value, onChange, visibleMonth: controlledMonth, onVisibleMonthChange, months, min, max, isDateDisabled, locale, label, invalid, invalidMessage, disabled, className, labels: labelOverrides, }: DateRangePickerProps): react.JSX.Element;
|
|
468
468
|
|
|
469
|
+
/**
|
|
470
|
+
* Pure model for `SchedulingTimeline` (HAR-1364; TENSOR C8): ticks on a time axis, where a
|
|
471
|
+
* bar sits on it, which bars in a lane overlap (and so stack and are flagged), and how a
|
|
472
|
+
* keyboard or pointer move snaps. Instants are ISO 8601 strings or epoch milliseconds; the
|
|
473
|
+
* axis is linear in real time, and only labels depend on the time zone.
|
|
474
|
+
*/
|
|
475
|
+
type TimelineScale = 'hour' | 'day' | 'week' | 'month';
|
|
476
|
+
interface TimelineRange {
|
|
477
|
+
start: string;
|
|
478
|
+
end: string;
|
|
479
|
+
}
|
|
480
|
+
interface TimelineTick {
|
|
481
|
+
/** Epoch ms of the tick. */
|
|
482
|
+
at: number;
|
|
483
|
+
/** Position on the axis, 0–100. */
|
|
484
|
+
offset: number;
|
|
485
|
+
/** A major tick starts a larger unit (a new day on an hour axis, a new month on a day axis). */
|
|
486
|
+
major: boolean;
|
|
487
|
+
}
|
|
488
|
+
interface TimelineSpan {
|
|
489
|
+
id: string;
|
|
490
|
+
start: string;
|
|
491
|
+
end: string;
|
|
492
|
+
}
|
|
493
|
+
interface PlacedSpan<T extends TimelineSpan = TimelineSpan> {
|
|
494
|
+
item: T;
|
|
495
|
+
/** 0–100, clamped to the visible range. */
|
|
496
|
+
left: number;
|
|
497
|
+
width: number;
|
|
498
|
+
/** Starts before / ends after the visible range (draw a cut edge). */
|
|
499
|
+
clippedStart: boolean;
|
|
500
|
+
clippedEnd: boolean;
|
|
501
|
+
/** Sub-row inside the lane, so overlapping bars stack instead of covering each other. */
|
|
502
|
+
row: number;
|
|
503
|
+
/** Overlaps at least one other bar in the same lane. */
|
|
504
|
+
conflict: boolean;
|
|
505
|
+
}
|
|
506
|
+
declare const HOUR = 3600000;
|
|
507
|
+
declare const DAY: number;
|
|
508
|
+
/** The default move/resize step for a scale: 15 min on an hour axis, 1 h on a day axis, 1 day otherwise. */
|
|
509
|
+
declare const defaultTimelineStep: (scale: TimelineScale) => number;
|
|
510
|
+
/**
|
|
511
|
+
* Ticks for the range at the scale's unit (hour, day, week starting `weekStartsOn`, month),
|
|
512
|
+
* aligned to wall-clock boundaries in `timeZone`. Bounded to 500 ticks; a month axis over a
|
|
513
|
+
* year walks ~8,800 hours, so keep ranges to what fits on screen.
|
|
514
|
+
*/
|
|
515
|
+
declare function timelineTicks(range: TimelineRange, scale: TimelineScale, timeZone: string, weekStartsOn?: number): TimelineTick[];
|
|
516
|
+
/** Position of one span on the axis, clamped to it; null when it is entirely outside. */
|
|
517
|
+
declare function placeSpan(span: {
|
|
518
|
+
start: string;
|
|
519
|
+
end: string;
|
|
520
|
+
}, range: TimelineRange): Omit<PlacedSpan, 'item' | 'row' | 'conflict'> | null;
|
|
521
|
+
/**
|
|
522
|
+
* Places a lane's spans: sorted by start, each in the first sub-row where it does not overlap
|
|
523
|
+
* the previous bar, and flagged `conflict` when it overlaps any other span in the lane.
|
|
524
|
+
*/
|
|
525
|
+
declare function layoutLane<T extends TimelineSpan>(items: readonly T[], range: TimelineRange): PlacedSpan<T>[];
|
|
526
|
+
/** Rounds a millisecond offset to the nearest step. */
|
|
527
|
+
declare const snapToStep: (ms: number, step: number) => number;
|
|
528
|
+
/** A span moved (both ends) or resized (end only) by `delta` ms, as ISO strings; never shorter than one step. */
|
|
529
|
+
declare function shiftSpan(span: {
|
|
530
|
+
start: string;
|
|
531
|
+
end: string;
|
|
532
|
+
}, delta: number, mode: 'move' | 'resize', step: number): {
|
|
533
|
+
start: string;
|
|
534
|
+
end: string;
|
|
535
|
+
};
|
|
536
|
+
/** Converts a horizontal pointer distance on a track of `trackWidth` px to snapped milliseconds. */
|
|
537
|
+
declare function pixelsToMs(px: number, trackWidth: number, range: TimelineRange, step: number): number;
|
|
538
|
+
|
|
539
|
+
interface SchedulingTimelineLane {
|
|
540
|
+
id: string;
|
|
541
|
+
label: ReactNode;
|
|
542
|
+
/** A quieter second line under the lane name (an owner, a count). */
|
|
543
|
+
meta?: ReactNode;
|
|
544
|
+
}
|
|
545
|
+
interface SchedulingTimelineItem {
|
|
546
|
+
id: string;
|
|
547
|
+
laneId: string;
|
|
548
|
+
title: string;
|
|
549
|
+
/** ISO 8601 instants. */
|
|
550
|
+
start: string;
|
|
551
|
+
end: string;
|
|
552
|
+
state?: SchedulingEntryState;
|
|
553
|
+
meta?: string;
|
|
554
|
+
/** `false` keeps this bar fixed even when `onMoveItem` is set. */
|
|
555
|
+
movable?: boolean;
|
|
556
|
+
}
|
|
557
|
+
type SchedulingTimelineOverlayKind = 'freeze' | 'maintenance' | 'blackout';
|
|
558
|
+
interface SchedulingTimelineOverlay {
|
|
559
|
+
id: string;
|
|
560
|
+
label: string;
|
|
561
|
+
start: string;
|
|
562
|
+
end: string;
|
|
563
|
+
kind: SchedulingTimelineOverlayKind;
|
|
564
|
+
/** Only this lane; every lane when unset. */
|
|
565
|
+
laneId?: string;
|
|
566
|
+
}
|
|
567
|
+
interface SchedulingTimelineMarker {
|
|
568
|
+
id: string;
|
|
569
|
+
label: string;
|
|
570
|
+
/** ISO 8601 instant. */
|
|
571
|
+
at: string;
|
|
572
|
+
laneId?: string;
|
|
573
|
+
}
|
|
574
|
+
interface SchedulingTimelineLabels {
|
|
575
|
+
region: string;
|
|
576
|
+
lanes: string;
|
|
577
|
+
/** `{title}`, `{state}`, `{start}`, `{end}`, `{conflict}`. */
|
|
578
|
+
item: string;
|
|
579
|
+
conflict: string;
|
|
580
|
+
moveHint: string;
|
|
581
|
+
/** Announced after a move. `{title}`, `{start}`, `{end}`. */
|
|
582
|
+
moved: string;
|
|
583
|
+
/** Announced after a resize. `{title}`, `{end}`. */
|
|
584
|
+
resized: string;
|
|
585
|
+
loading: string;
|
|
586
|
+
retry: string;
|
|
587
|
+
empty: string;
|
|
588
|
+
/** Heading of the screen-reader list of windows and markers. */
|
|
589
|
+
windows: string;
|
|
590
|
+
now: string;
|
|
591
|
+
states: Record<SchedulingEntryState, string>;
|
|
592
|
+
overlays: Record<SchedulingTimelineOverlayKind, string>;
|
|
593
|
+
}
|
|
594
|
+
declare const DEFAULT_SCHEDULING_TIMELINE_LABELS: SchedulingTimelineLabels;
|
|
595
|
+
interface SchedulingTimelineProps {
|
|
596
|
+
lanes: SchedulingTimelineLane[];
|
|
597
|
+
items: SchedulingTimelineItem[];
|
|
598
|
+
/** The visible window (ISO 8601 instants). */
|
|
599
|
+
range: TimelineRange;
|
|
600
|
+
/** Tick unit of the axis. Default `day`. */
|
|
601
|
+
scale?: TimelineScale;
|
|
602
|
+
/** IANA zone for tick boundaries and every printed time. */
|
|
603
|
+
timeZone: string;
|
|
604
|
+
locale?: string;
|
|
605
|
+
overlays?: SchedulingTimelineOverlay[];
|
|
606
|
+
markers?: SchedulingTimelineMarker[];
|
|
607
|
+
/** Draws a "now" line at this instant (pass the current time; the component keeps no clock). */
|
|
608
|
+
now?: string;
|
|
609
|
+
/** First day of a week tick (0 = Sunday). Default 1. */
|
|
610
|
+
weekStartsOn?: number;
|
|
611
|
+
/** Width of one tick, as a CSS length. Defaults: hour 3.5rem, day 7rem, week 6rem, month 8rem. */
|
|
612
|
+
tickWidth?: string;
|
|
613
|
+
/** Move/resize granularity in ms. Defaults: 15 min (hour), 1 h (day), 1 day (week, month). */
|
|
614
|
+
step?: number;
|
|
615
|
+
/** Tick label. Default: `Intl` in `locale` and `timeZone`. */
|
|
616
|
+
formatTick?: (at: Date, scale: TimelineScale) => string;
|
|
617
|
+
/** Start/end text in names and announcements. Default: `Intl` medium date + short time in `timeZone`. */
|
|
618
|
+
formatInstant?: (instant: string) => string;
|
|
619
|
+
/** Bar content. Default: the title. */
|
|
620
|
+
renderItem?: (item: SchedulingTimelineItem) => ReactNode;
|
|
621
|
+
onSelectItem?: (item: SchedulingTimelineItem) => void;
|
|
622
|
+
/** Makes bars draggable and keyboard-movable. Receives the snapped new start and end. */
|
|
623
|
+
onMoveItem?: (id: string, next: {
|
|
624
|
+
start: string;
|
|
625
|
+
end: string;
|
|
626
|
+
}) => void;
|
|
627
|
+
loading?: boolean;
|
|
628
|
+
error?: string;
|
|
629
|
+
onRetry?: () => void;
|
|
630
|
+
labels?: Partial<SchedulingTimelineLabels>;
|
|
631
|
+
className?: string;
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* Lanes of bars on a time axis (HAR-1364; TENSOR C8): change schedules, rollout Gantt rows,
|
|
635
|
+
* renewal markers. Overlapping bars in a lane stack and are hatched; freeze, maintenance and
|
|
636
|
+
* blackout windows are bands; with `onMoveItem`, bars move by drag or Shift+arrows and their
|
|
637
|
+
* end changes with Alt+Shift+arrows, snapped to `step`.
|
|
638
|
+
*/
|
|
639
|
+
declare function SchedulingTimeline({ lanes, items, range, scale, timeZone, locale, overlays, markers, now, weekStartsOn, tickWidth, step: stepProp, formatTick, formatInstant: formatInstantProp, renderItem, onSelectItem, onMoveItem, loading, error, onRetry, labels: labelOverrides, className, }: SchedulingTimelineProps): react.JSX.Element;
|
|
640
|
+
|
|
469
641
|
/**
|
|
470
642
|
* Kit chrome strings by component (HAR-1358; TENSOR C20, MOTUS executive summary #3).
|
|
471
643
|
* Each entry overrides that component's English defaults for every instance below the
|
|
@@ -513,6 +685,7 @@ interface UixLabels {
|
|
|
513
685
|
};
|
|
514
686
|
schedulingCalendar?: Partial<SchedulingCalendarLabels>;
|
|
515
687
|
dateRangePicker?: Partial<DateRangePickerLabels>;
|
|
688
|
+
schedulingTimeline?: Partial<SchedulingTimelineLabels>;
|
|
516
689
|
/** Read by `useUixLabels()` callers; `Pagination` itself is server-safe and takes `labels`. */
|
|
517
690
|
pagination?: Partial<PaginationLabels>;
|
|
518
691
|
/** Read by `useUixLabels()` callers; `BulkBar` itself is server-safe and takes `label`. */
|
|
@@ -3472,4 +3645,4 @@ declare function hsvToHex(value: HsvColor): string;
|
|
|
3472
3645
|
declare function contrastRatio(background: string, foreground: string): number | undefined;
|
|
3473
3646
|
declare function meetsContrast(background: string, foreground: string, minimum?: number): boolean;
|
|
3474
3647
|
|
|
3475
|
-
export { type AccessStateProps, Alert, type AlertProps, type AlertTone, AppShell, type AppShellProps, type AppliedBrandProfileSnapshot, type AsyncOperationState, AsyncOperationStatus, type AsyncOperationStatusProps, Avatar, AvatarGroup, type AvatarGroupProps, type AvatarProps, type BoundedRelationshipGraph, type BrandProfile, BrandProfileEditor, type BrandProfileEditorLabels, type BrandProfileEditorProps, type BrandProfileLogo, type BrandProfileTypography, BrandProfiles, type BreadcrumbItem, Breadcrumbs, type BreadcrumbsProps, BuilderCanvas, type BuilderCanvasItem, type BuilderCanvasLabels, type BuilderCanvasProps, type BuilderPaletteItem, BulkBar, type BulkBarProps, Button, ButtonGroup, type ButtonGroupProps, ButtonLink, type ButtonLinkProps, type ButtonProps, type ButtonSize, type ButtonVariant, type CalendarDay, type CalendarWeekday, Card, CardLink, type CardLinkProps, type CardProps, CellStrong, CellSub, Checkbox, type CheckboxProps, Chip, ChipGroup, type ChipGroupProps, type ChipProps, CollapsibleSection, type CollapsibleSectionProps, ColorPicker, type ColorPickerLabels, type ColorPickerProps, type ColumnFilter, Combobox, type ComboboxOption, type ComboboxProps, CommandGroup, type CommandGroupProps, CommandItem, type CommandItemProps, CommandPalette, type CommandPaletteProps, Comment, type CommentProps, Comments, type CommentsProps, Composer, ComposerBar, type ComposerBarProps, type ComposerProps, ConfirmDialog, type ConfirmDialogProps, ContentList, ContentListItem, type ContentListItemProps, type ContentListProps, CopyButton, type CopyButtonProps, DEFAULT_BRAND_PROFILE_EDITOR_LABELS, DEFAULT_BUILDER_CANVAS_LABELS, DEFAULT_COLOR_PICKER_LABELS, DEFAULT_DATE_RANGE_PICKER_LABELS, DEFAULT_DIFF_VIEWER_LABELS, DEFAULT_MATCH_REVIEW_LABELS, DEFAULT_PAGINATION_LABELS, DEFAULT_RELATIONSHIP_GRAPH_LABELS, DEFAULT_RULE_BUILDER_LABELS, DEFAULT_SAVE_STATUS_LABELS, DEFAULT_SCHEDULING_CALENDAR_LABELS, DEFAULT_STEP_STATE_LABELS, DateRangePicker, type DateRangePickerLabels, type DateRangePickerProps, type DateRangeValue, DescriptionItem, type DescriptionItemProps, DescriptionList, type DescriptionListItem, type DescriptionListProps, DetailLayout, type DetailLayoutProps, DetailPage, type DetailPageLinkProps, type DetailPageMetric, type DetailPageProps, type DetailPageTab, type DiffEntry, type DiffKind, type DiffResolution, type DiffSummary, DiffViewer, type DiffViewerLabels, type DiffViewerProps, Drawer, type DrawerProps, EmptyState, type EmptyStateProps, ErrorState, type ErrorStateProps, EventRow, type EventRowProps, ExpandToggle, type ExpandToggleProps, FeaturedRundown, FeaturedRundownItem, type FeaturedRundownItemProps, type FeaturedRundownProps, FeaturedStage, type FeaturedStageProps, Field, type FieldProps, type FilterKind, type FilterOp, type FilterOption, FilterPopover, type FilterPopoverProps, FilteredEmptyState, type FlatNode, Flow, FlowNode, type FlowNodeProps, type FlowNodeState, type FlowProps, type FlowVariant, type FoldedText, ForbiddenState, Highlighted, type HighlightedProps, type HsvColor, Inbox, InboxDetail, type InboxDetailProps, InboxItem, type InboxItemProps, InboxList, type InboxListProps, type InboxProps, InfoTip, type InfoTipProps, Input, InputGroup, type InputGroupProps, type InputProps, type JsonPrimitive, type JsonValue, Kanban, KanbanCard, type KanbanCardProps, KanbanColumn, type KanbanColumnProps, type KanbanMoveDirection, type KanbanProps, Kbd, KbdCombo, type KbdComboProps, type KbdPlatform, type KbdProps, Label, type LabelProps, type LayeredColumn, type LayeredEdgeClassification, type LayeredEdgeKind, type LayeredItem, type LayeredLayout, type LayeredLayoutOptions, type LayeredNavigationKey, LicensePositionBar, type LicensePositionBarProps, List, ListItem, type ListItemProps, type ListProps, LoadingState, type LoadingStateProps, Mark, type MarkProps, type MatchBulkResult, MatchReview, type MatchReviewAction, type MatchReviewCandidate, type MatchReviewField, type MatchReviewLabels, type MatchReviewProps, Menu, MenuGroup, type MenuGroupProps, MenuItem, type MenuItemProps, type MenuProps, MenuSeparator, Meter, type MeterProps, type MeterTone, MetricInput, type MetricInputProps, Modal, type ModalProps, type NavFavouriteItem, NavFavourites, type NavFavouritesLabels, type NavFavouritesProps, NavGroup, type NavGroupProps, NavItem, type NavItemProps, NewsLead, type NewsLeadProps, NotFoundState, Note, type NoteProps, type NoteTone, NoticeQueue, type NoticeQueueProps, PageHeader, type PageHeaderProps, PageIntro, type PageIntroProps, Pagination, type PaginationLabels, type PaginationProps, Peek, type PeekProps, type PillTone, type PillTreatment, Pipeline, type PipelineProps, PipelineStage, type PipelineStageProps, type PipelineStageState, Placement, Popconfirm, type PopconfirmProps, Popover, type PopoverProps, type PositionedRelationshipNode, type Primitive, Progress, type ProgressProps, PromptDialog, type PromptDialogProps, Prose, type ProseProps, Radio, RadioGroup, type RadioGroupProps, type RadioProps, type RelatedLinkItem, RelatedLinks, type RelatedLinksProps, RelationshipGraph, type RelationshipGraphArrow, type RelationshipGraphCluster, type RelationshipGraphEdge, type RelationshipGraphLabels, type RelationshipGraphLegendItem, type RelationshipGraphNode, type RelationshipGraphProps, RelativeTime, type RelativeTimeFormatContext, type RelativeTimeProps, type RelativeTimeUnit, type RelativeTimeValue, ResourceGrid, type ResourceGridProps, type RgbColor, type RoutedEdge, type Row, RowAction, type RowActionProps, RowActions, type RowActionsProps, type RuleAction, type RuleActionDefinition, RuleBuilder, type RuleBuilderLabels, type RuleBuilderProps, type RuleCondition, type RuleDefinition, type RuleFieldDefinition, type RuleGroup, type RuleOperatorDefinition, type RuleValidationIssue, type RuleValueEditorProps, SaveStatus, type SaveStatusLabels, type SaveStatusProps, type SaveStatusState, type SavedViewItem, SavedViewMenu, type SavedViewMenuProps, type SavedViewSection, SchedulingCalendar, type SchedulingCalendarEntry, type SchedulingCalendarLabels, type SchedulingCalendarOverlay, type SchedulingCalendarProps, type SchedulingCalendarView, type SchedulingDatePart, type SchedulingEntryState, type SchedulingOverlayKind, type SearchSegment, SearchSuggest, type SearchSuggestAction, type SearchSuggestOption, type SearchSuggestProps, SectionHead, type SectionHeadProps, type Segment, Segmented, SegmentedOption, type SegmentedOptionProps, type SegmentedProps, Select, type SelectAllState, type SelectProps, type ShellNav, Sidebar, type SidebarProps, SidebarSection, type SidebarSectionProps, Skeleton, type SkeletonProps, type SortDir, type SortDirection, type SortKey, Spinner, type SpinnerProps, StarButton, type StarButtonProps, Stat, StatLine, type StatLineItem, type StatLineProps, type StatProps, type StatTrend, type StateVariant, StatusPill, type StatusPillProps, StatusRow, type StatusRowProps, Step, type StepProps, type StepState, type StepStateLabels, Steps, type StepsProps, SubNavItem, type SubNavItemProps, Switch, type SwitchProps, TOAST_LEAVE_MS, Tab, TabPanel, type TabPanelProps, type TabProps, Table, type TableDensity, type TableProps, TableWrap, type TableWrapProps, Tabs, type TabsProps, Td, type TdProps, Textarea, type TextareaProps, Th, type ThProps, Timeline, TimelineItem, type TimelineItemProps, type TimelineProps, Toast, type ToastAction, type ToastApi, type ToastDismissReason, type ToastKind, type ToastOptions, type ToastPromiseMessages, type ToastProps, type ToastRecord, type ToastStore, type ToastTone, Toaster, type ToasterProps, ToggleRow, type ToggleRowProps, Tooltip, type TooltipProps, Tr, type TrProps, Tree, type TreeLike, type TreeNavAction, type TreeNodeData, type TreeNodeProps, type TreeProps, type UixLabels, UixLabelsProvider, type UixLabelsProviderProps, type UixLinkProps, type UixRenderLink, type UndoableToastOptions, type UseAnchoredPositionOptions, type UseTableOptions, type UseTableResult, type UseVirtualRowsOptions, type UseVirtualRowsResult, UserChip, type UserChipProps, ViewMenu, type ViewMenuColumn, type ViewMenuColumnLabels, type ViewMenuProps, type ViewState, type VirtualWindow, type ZonedDateSpan, addCalendarDays, addCalendarMonths, appendRuleNode, applyBrandProfile, applyFilters, boundRelationshipGraph, buildMonthGrid, buildThreeWayDiff, clampMetricValue, clampWidth, classifyLayeredEdges, clusterIdFor, contrastRatio, createToastApi, createToastStore, cx, enumerateDateSpan, filterComboboxOptions, findRuleNodeDepth, flattenTree, foldForSearch, hexToRgb, highlightSegments, hsvToHex, hsvToRgb, isDateInRange, isDateUnavailable, isRuleGroup, layeredNeighbor, layoutLayeredGraph, layoutRelationshipGraph, mapRuleGroup, matchFilter, meetsContrast, mergePinned, moveRuleNode, multiSort, nextSortDir, normalizeHex, parseDateValue, parseMetricValue, parseView, relationshipNeighbors, relativeTimeValue, removeRuleNode, renderPlainLink, reorder, restoreBrandProfile, rgbToHex, rgbToHsv, ruleDepth, searchRows, searchSegments, selectAllState, selectRangeDate, serializeView, shouldVirtualize, startOfMonth, stepMetricValue, summarizeDiff, summarizeRule, toDateKey, toast, toggleId, togglePage, toggleSort, traverseRelationshipNode, treeNav, useAnchoredPosition, useDialog, useTable, useUixLabels, useVirtualRows, validateRuleDefinition, virtualWindow, wrapEdgeLabel, zonedDateKey, zonedDateSpan };
|
|
3648
|
+
export { type AccessStateProps, Alert, type AlertProps, type AlertTone, AppShell, type AppShellProps, type AppliedBrandProfileSnapshot, type AsyncOperationState, AsyncOperationStatus, type AsyncOperationStatusProps, Avatar, AvatarGroup, type AvatarGroupProps, type AvatarProps, type BoundedRelationshipGraph, type BrandProfile, BrandProfileEditor, type BrandProfileEditorLabels, type BrandProfileEditorProps, type BrandProfileLogo, type BrandProfileTypography, BrandProfiles, type BreadcrumbItem, Breadcrumbs, type BreadcrumbsProps, BuilderCanvas, type BuilderCanvasItem, type BuilderCanvasLabels, type BuilderCanvasProps, type BuilderPaletteItem, BulkBar, type BulkBarProps, Button, ButtonGroup, type ButtonGroupProps, ButtonLink, type ButtonLinkProps, type ButtonProps, type ButtonSize, type ButtonVariant, type CalendarDay, type CalendarWeekday, Card, CardLink, type CardLinkProps, type CardProps, CellStrong, CellSub, Checkbox, type CheckboxProps, Chip, ChipGroup, type ChipGroupProps, type ChipProps, CollapsibleSection, type CollapsibleSectionProps, ColorPicker, type ColorPickerLabels, type ColorPickerProps, type ColumnFilter, Combobox, type ComboboxOption, type ComboboxProps, CommandGroup, type CommandGroupProps, CommandItem, type CommandItemProps, CommandPalette, type CommandPaletteProps, Comment, type CommentProps, Comments, type CommentsProps, Composer, ComposerBar, type ComposerBarProps, type ComposerProps, ConfirmDialog, type ConfirmDialogProps, ContentList, ContentListItem, type ContentListItemProps, type ContentListProps, CopyButton, type CopyButtonProps, DAY, DEFAULT_BRAND_PROFILE_EDITOR_LABELS, DEFAULT_BUILDER_CANVAS_LABELS, DEFAULT_COLOR_PICKER_LABELS, DEFAULT_DATE_RANGE_PICKER_LABELS, DEFAULT_DIFF_VIEWER_LABELS, DEFAULT_MATCH_REVIEW_LABELS, DEFAULT_PAGINATION_LABELS, DEFAULT_RELATIONSHIP_GRAPH_LABELS, DEFAULT_RULE_BUILDER_LABELS, DEFAULT_SAVE_STATUS_LABELS, DEFAULT_SCHEDULING_CALENDAR_LABELS, DEFAULT_SCHEDULING_TIMELINE_LABELS, DEFAULT_STEP_STATE_LABELS, DateRangePicker, type DateRangePickerLabels, type DateRangePickerProps, type DateRangeValue, DescriptionItem, type DescriptionItemProps, DescriptionList, type DescriptionListItem, type DescriptionListProps, DetailLayout, type DetailLayoutProps, DetailPage, type DetailPageLinkProps, type DetailPageMetric, type DetailPageProps, type DetailPageTab, type DiffEntry, type DiffKind, type DiffResolution, type DiffSummary, DiffViewer, type DiffViewerLabels, type DiffViewerProps, Drawer, type DrawerProps, EmptyState, type EmptyStateProps, ErrorState, type ErrorStateProps, EventRow, type EventRowProps, ExpandToggle, type ExpandToggleProps, FeaturedRundown, FeaturedRundownItem, type FeaturedRundownItemProps, type FeaturedRundownProps, FeaturedStage, type FeaturedStageProps, Field, type FieldProps, type FilterKind, type FilterOp, type FilterOption, FilterPopover, type FilterPopoverProps, FilteredEmptyState, type FlatNode, Flow, FlowNode, type FlowNodeProps, type FlowNodeState, type FlowProps, type FlowVariant, type FoldedText, ForbiddenState, HOUR, Highlighted, type HighlightedProps, type HsvColor, Inbox, InboxDetail, type InboxDetailProps, InboxItem, type InboxItemProps, InboxList, type InboxListProps, type InboxProps, InfoTip, type InfoTipProps, Input, InputGroup, type InputGroupProps, type InputProps, type JsonPrimitive, type JsonValue, Kanban, KanbanCard, type KanbanCardProps, KanbanColumn, type KanbanColumnProps, type KanbanMoveDirection, type KanbanProps, Kbd, KbdCombo, type KbdComboProps, type KbdPlatform, type KbdProps, Label, type LabelProps, type LayeredColumn, type LayeredEdgeClassification, type LayeredEdgeKind, type LayeredItem, type LayeredLayout, type LayeredLayoutOptions, type LayeredNavigationKey, LicensePositionBar, type LicensePositionBarProps, List, ListItem, type ListItemProps, type ListProps, LoadingState, type LoadingStateProps, Mark, type MarkProps, type MatchBulkResult, MatchReview, type MatchReviewAction, type MatchReviewCandidate, type MatchReviewField, type MatchReviewLabels, type MatchReviewProps, Menu, MenuGroup, type MenuGroupProps, MenuItem, type MenuItemProps, type MenuProps, MenuSeparator, Meter, type MeterProps, type MeterTone, MetricInput, type MetricInputProps, Modal, type ModalProps, type NavFavouriteItem, NavFavourites, type NavFavouritesLabels, type NavFavouritesProps, NavGroup, type NavGroupProps, NavItem, type NavItemProps, NewsLead, type NewsLeadProps, NotFoundState, Note, type NoteProps, type NoteTone, NoticeQueue, type NoticeQueueProps, PageHeader, type PageHeaderProps, PageIntro, type PageIntroProps, Pagination, type PaginationLabels, type PaginationProps, Peek, type PeekProps, type PillTone, type PillTreatment, Pipeline, type PipelineProps, PipelineStage, type PipelineStageProps, type PipelineStageState, type PlacedSpan, Placement, Popconfirm, type PopconfirmProps, Popover, type PopoverProps, type PositionedRelationshipNode, type Primitive, Progress, type ProgressProps, PromptDialog, type PromptDialogProps, Prose, type ProseProps, Radio, RadioGroup, type RadioGroupProps, type RadioProps, type RelatedLinkItem, RelatedLinks, type RelatedLinksProps, RelationshipGraph, type RelationshipGraphArrow, type RelationshipGraphCluster, type RelationshipGraphEdge, type RelationshipGraphLabels, type RelationshipGraphLegendItem, type RelationshipGraphNode, type RelationshipGraphProps, RelativeTime, type RelativeTimeFormatContext, type RelativeTimeProps, type RelativeTimeUnit, type RelativeTimeValue, ResourceGrid, type ResourceGridProps, type RgbColor, type RoutedEdge, type Row, RowAction, type RowActionProps, RowActions, type RowActionsProps, type RuleAction, type RuleActionDefinition, RuleBuilder, type RuleBuilderLabels, type RuleBuilderProps, type RuleCondition, type RuleDefinition, type RuleFieldDefinition, type RuleGroup, type RuleOperatorDefinition, type RuleValidationIssue, type RuleValueEditorProps, SaveStatus, type SaveStatusLabels, type SaveStatusProps, type SaveStatusState, type SavedViewItem, SavedViewMenu, type SavedViewMenuProps, type SavedViewSection, SchedulingCalendar, type SchedulingCalendarEntry, type SchedulingCalendarLabels, type SchedulingCalendarOverlay, type SchedulingCalendarProps, type SchedulingCalendarView, type SchedulingDatePart, type SchedulingEntryState, type SchedulingOverlayKind, SchedulingTimeline, type SchedulingTimelineItem, type SchedulingTimelineLabels, type SchedulingTimelineLane, type SchedulingTimelineMarker, type SchedulingTimelineOverlay, type SchedulingTimelineOverlayKind, type SchedulingTimelineProps, type SearchSegment, SearchSuggest, type SearchSuggestAction, type SearchSuggestOption, type SearchSuggestProps, SectionHead, type SectionHeadProps, type Segment, Segmented, SegmentedOption, type SegmentedOptionProps, type SegmentedProps, Select, type SelectAllState, type SelectProps, type ShellNav, Sidebar, type SidebarProps, SidebarSection, type SidebarSectionProps, Skeleton, type SkeletonProps, type SortDir, type SortDirection, type SortKey, Spinner, type SpinnerProps, StarButton, type StarButtonProps, Stat, StatLine, type StatLineItem, type StatLineProps, type StatProps, type StatTrend, type StateVariant, StatusPill, type StatusPillProps, StatusRow, type StatusRowProps, Step, type StepProps, type StepState, type StepStateLabels, Steps, type StepsProps, SubNavItem, type SubNavItemProps, Switch, type SwitchProps, TOAST_LEAVE_MS, Tab, TabPanel, type TabPanelProps, type TabProps, Table, type TableDensity, type TableProps, TableWrap, type TableWrapProps, Tabs, type TabsProps, Td, type TdProps, Textarea, type TextareaProps, Th, type ThProps, Timeline, TimelineItem, type TimelineItemProps, type TimelineProps, type TimelineRange, type TimelineScale, type TimelineSpan, type TimelineTick, Toast, type ToastAction, type ToastApi, type ToastDismissReason, type ToastKind, type ToastOptions, type ToastPromiseMessages, type ToastProps, type ToastRecord, type ToastStore, type ToastTone, Toaster, type ToasterProps, ToggleRow, type ToggleRowProps, Tooltip, type TooltipProps, Tr, type TrProps, Tree, type TreeLike, type TreeNavAction, type TreeNodeData, type TreeNodeProps, type TreeProps, type UixLabels, UixLabelsProvider, type UixLabelsProviderProps, type UixLinkProps, type UixRenderLink, type UndoableToastOptions, type UseAnchoredPositionOptions, type UseTableOptions, type UseTableResult, type UseVirtualRowsOptions, type UseVirtualRowsResult, UserChip, type UserChipProps, ViewMenu, type ViewMenuColumn, type ViewMenuColumnLabels, type ViewMenuProps, type ViewState, type VirtualWindow, type ZonedDateSpan, addCalendarDays, addCalendarMonths, appendRuleNode, applyBrandProfile, applyFilters, boundRelationshipGraph, buildMonthGrid, buildThreeWayDiff, clampMetricValue, clampWidth, classifyLayeredEdges, clusterIdFor, contrastRatio, createToastApi, createToastStore, cx, defaultTimelineStep, enumerateDateSpan, filterComboboxOptions, findRuleNodeDepth, flattenTree, foldForSearch, hexToRgb, highlightSegments, hsvToHex, hsvToRgb, isDateInRange, isDateUnavailable, isRuleGroup, layeredNeighbor, layoutLane, layoutLayeredGraph, layoutRelationshipGraph, mapRuleGroup, matchFilter, meetsContrast, mergePinned, moveRuleNode, multiSort, nextSortDir, normalizeHex, parseDateValue, parseMetricValue, parseView, pixelsToMs, placeSpan, relationshipNeighbors, relativeTimeValue, removeRuleNode, renderPlainLink, reorder, restoreBrandProfile, rgbToHex, rgbToHsv, ruleDepth, searchRows, searchSegments, selectAllState, selectRangeDate, serializeView, shiftSpan, shouldVirtualize, snapToStep, startOfMonth, stepMetricValue, summarizeDiff, summarizeRule, timelineTicks, toDateKey, toast, toggleId, togglePage, toggleSort, traverseRelationshipNode, treeNav, useAnchoredPosition, useDialog, useTable, useUixLabels, useVirtualRows, validateRuleDefinition, virtualWindow, wrapEdgeLabel, zonedDateKey, zonedDateSpan };
|
package/dist/index.d.ts
CHANGED
|
@@ -82,6 +82,8 @@ export { DEFAULT_RULE_BUILDER_LABELS, RuleActionDefinition, RuleBuilder, RuleBui
|
|
|
82
82
|
export { RuleAction, RuleCondition, RuleDefinition, RuleGroup, RuleValidationIssue, appendRuleNode, findRuleNodeDepth, isRuleGroup, mapRuleGroup, moveRuleNode, removeRuleNode, ruleDepth, summarizeRule, validateRuleDefinition } from './rule-builder-model.js';
|
|
83
83
|
export { BuilderCanvas, BuilderCanvasItem, BuilderCanvasLabels, BuilderCanvasProps, BuilderPaletteItem, DEFAULT_BUILDER_CANVAS_LABELS } from './components/BuilderCanvas.js';
|
|
84
84
|
export { DEFAULT_SCHEDULING_CALENDAR_LABELS, SchedulingCalendar, SchedulingCalendarEntry, SchedulingCalendarLabels, SchedulingCalendarOverlay, SchedulingCalendarProps, SchedulingCalendarView, SchedulingDatePart, SchedulingEntryState, SchedulingOverlayKind } from './components/SchedulingCalendar.js';
|
|
85
|
+
export { DEFAULT_SCHEDULING_TIMELINE_LABELS, SchedulingTimeline, SchedulingTimelineItem, SchedulingTimelineLabels, SchedulingTimelineLane, SchedulingTimelineMarker, SchedulingTimelineOverlay, SchedulingTimelineOverlayKind, SchedulingTimelineProps } from './components/SchedulingTimeline.js';
|
|
86
|
+
export { DAY, HOUR, PlacedSpan, TimelineRange, TimelineScale, TimelineSpan, TimelineTick, defaultTimelineStep, layoutLane, pixelsToMs, placeSpan, shiftSpan, snapToStep, timelineTicks } from './scheduling-timeline-model.js';
|
|
85
87
|
export { DEFAULT_DATE_RANGE_PICKER_LABELS, DateRangePicker, DateRangePickerLabels, DateRangePickerProps } from './components/DateRangePicker.js';
|
|
86
88
|
export { CalendarDay, CalendarWeekday, DateRangeValue, ZonedDateSpan, addCalendarDays, addCalendarMonths, buildMonthGrid, enumerateDateSpan, isDateInRange, isDateUnavailable, selectRangeDate, startOfMonth, toDateKey, zonedDateKey, zonedDateSpan } from './calendar-model.js';
|
|
87
89
|
export { DEFAULT_RELATIONSHIP_GRAPH_LABELS, RelationshipGraph, RelationshipGraphLabels, RelationshipGraphLegendItem, RelationshipGraphProps } from './components/RelationshipGraph.js';
|
package/dist/index.js
CHANGED
|
@@ -119,6 +119,18 @@ import {
|
|
|
119
119
|
} from "./rule-builder-model.js";
|
|
120
120
|
import { BuilderCanvas, DEFAULT_BUILDER_CANVAS_LABELS } from "./components/BuilderCanvas.js";
|
|
121
121
|
import { DEFAULT_SCHEDULING_CALENDAR_LABELS, SchedulingCalendar } from "./components/SchedulingCalendar.js";
|
|
122
|
+
import { DEFAULT_SCHEDULING_TIMELINE_LABELS, SchedulingTimeline } from "./components/SchedulingTimeline.js";
|
|
123
|
+
import {
|
|
124
|
+
DAY,
|
|
125
|
+
HOUR,
|
|
126
|
+
defaultTimelineStep,
|
|
127
|
+
layoutLane,
|
|
128
|
+
pixelsToMs,
|
|
129
|
+
placeSpan,
|
|
130
|
+
shiftSpan,
|
|
131
|
+
snapToStep,
|
|
132
|
+
timelineTicks
|
|
133
|
+
} from "./scheduling-timeline-model.js";
|
|
122
134
|
import { DateRangePicker, DEFAULT_DATE_RANGE_PICKER_LABELS } from "./components/DateRangePicker.js";
|
|
123
135
|
import {
|
|
124
136
|
addCalendarDays,
|
|
@@ -179,6 +191,7 @@ export {
|
|
|
179
191
|
ContentList,
|
|
180
192
|
ContentListItem,
|
|
181
193
|
CopyButton,
|
|
194
|
+
DAY,
|
|
182
195
|
DEFAULT_BRAND_PROFILE_EDITOR_LABELS,
|
|
183
196
|
DEFAULT_BUILDER_CANVAS_LABELS,
|
|
184
197
|
DEFAULT_COLOR_PICKER_LABELS,
|
|
@@ -190,6 +203,7 @@ export {
|
|
|
190
203
|
DEFAULT_RULE_BUILDER_LABELS,
|
|
191
204
|
DEFAULT_SAVE_STATUS_LABELS,
|
|
192
205
|
DEFAULT_SCHEDULING_CALENDAR_LABELS,
|
|
206
|
+
DEFAULT_SCHEDULING_TIMELINE_LABELS,
|
|
193
207
|
DEFAULT_STEP_STATE_LABELS,
|
|
194
208
|
DateRangePicker,
|
|
195
209
|
DescriptionItem,
|
|
@@ -211,6 +225,7 @@ export {
|
|
|
211
225
|
Flow,
|
|
212
226
|
FlowNode,
|
|
213
227
|
ForbiddenState,
|
|
228
|
+
HOUR,
|
|
214
229
|
Highlighted,
|
|
215
230
|
Inbox,
|
|
216
231
|
InboxDetail,
|
|
@@ -268,6 +283,7 @@ export {
|
|
|
268
283
|
SaveStatus,
|
|
269
284
|
SavedViewMenu,
|
|
270
285
|
SchedulingCalendar,
|
|
286
|
+
SchedulingTimeline,
|
|
271
287
|
SearchSuggest,
|
|
272
288
|
SectionHead,
|
|
273
289
|
Segmented,
|
|
@@ -321,6 +337,7 @@ export {
|
|
|
321
337
|
createToastApi,
|
|
322
338
|
createToastStore,
|
|
323
339
|
cx,
|
|
340
|
+
defaultTimelineStep,
|
|
324
341
|
enumerateDateSpan,
|
|
325
342
|
filterComboboxOptions,
|
|
326
343
|
findRuleNodeDepth,
|
|
@@ -333,6 +350,7 @@ export {
|
|
|
333
350
|
isDateUnavailable,
|
|
334
351
|
isRuleGroup,
|
|
335
352
|
layeredNeighbor,
|
|
353
|
+
layoutLane,
|
|
336
354
|
layoutLayeredGraph,
|
|
337
355
|
layoutRelationshipGraph,
|
|
338
356
|
mapRuleGroup,
|
|
@@ -341,6 +359,8 @@ export {
|
|
|
341
359
|
normalizeHex,
|
|
342
360
|
parseDateValue,
|
|
343
361
|
parseMetricValue,
|
|
362
|
+
pixelsToMs,
|
|
363
|
+
placeSpan,
|
|
344
364
|
relationshipNeighbors,
|
|
345
365
|
relativeTimeValue,
|
|
346
366
|
removeRuleNode,
|
|
@@ -351,10 +371,13 @@ export {
|
|
|
351
371
|
ruleDepth,
|
|
352
372
|
searchSegments,
|
|
353
373
|
selectRangeDate,
|
|
374
|
+
shiftSpan,
|
|
375
|
+
snapToStep,
|
|
354
376
|
startOfMonth,
|
|
355
377
|
stepMetricValue,
|
|
356
378
|
summarizeDiff,
|
|
357
379
|
summarizeRule,
|
|
380
|
+
timelineTicks,
|
|
358
381
|
toDateKey,
|
|
359
382
|
toast,
|
|
360
383
|
traverseRelationshipNode,
|
package/dist/labels-context.d.ts
CHANGED
|
@@ -3,8 +3,10 @@ import { ReactNode } from 'react';
|
|
|
3
3
|
import { PaginationLabels } from './components/Pagination.js';
|
|
4
4
|
import { SchedulingCalendarLabels } from './components/SchedulingCalendar.js';
|
|
5
5
|
import { DateRangePickerLabels } from './components/DateRangePicker.js';
|
|
6
|
+
import { SchedulingTimelineLabels } from './components/SchedulingTimeline.js';
|
|
6
7
|
import './link.js';
|
|
7
8
|
import './calendar-model.js';
|
|
9
|
+
import './scheduling-timeline-model.js';
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
* Kit chrome strings by component (HAR-1358; TENSOR C20, MOTUS executive summary #3).
|
|
@@ -53,6 +55,7 @@ interface UixLabels {
|
|
|
53
55
|
};
|
|
54
56
|
schedulingCalendar?: Partial<SchedulingCalendarLabels>;
|
|
55
57
|
dateRangePicker?: Partial<DateRangePickerLabels>;
|
|
58
|
+
schedulingTimeline?: Partial<SchedulingTimelineLabels>;
|
|
56
59
|
/** Read by `useUixLabels()` callers; `Pagination` itself is server-safe and takes `labels`. */
|
|
57
60
|
pagination?: Partial<PaginationLabels>;
|
|
58
61
|
/** Read by `useUixLabels()` callers; `BulkBar` itself is server-safe and takes `label`. */
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure model for `SchedulingTimeline` (HAR-1364; TENSOR C8): ticks on a time axis, where a
|
|
3
|
+
* bar sits on it, which bars in a lane overlap (and so stack and are flagged), and how a
|
|
4
|
+
* keyboard or pointer move snaps. Instants are ISO 8601 strings or epoch milliseconds; the
|
|
5
|
+
* axis is linear in real time, and only labels depend on the time zone.
|
|
6
|
+
*/
|
|
7
|
+
type TimelineScale = 'hour' | 'day' | 'week' | 'month';
|
|
8
|
+
interface TimelineRange {
|
|
9
|
+
start: string;
|
|
10
|
+
end: string;
|
|
11
|
+
}
|
|
12
|
+
interface TimelineTick {
|
|
13
|
+
/** Epoch ms of the tick. */
|
|
14
|
+
at: number;
|
|
15
|
+
/** Position on the axis, 0–100. */
|
|
16
|
+
offset: number;
|
|
17
|
+
/** A major tick starts a larger unit (a new day on an hour axis, a new month on a day axis). */
|
|
18
|
+
major: boolean;
|
|
19
|
+
}
|
|
20
|
+
interface TimelineSpan {
|
|
21
|
+
id: string;
|
|
22
|
+
start: string;
|
|
23
|
+
end: string;
|
|
24
|
+
}
|
|
25
|
+
interface PlacedSpan<T extends TimelineSpan = TimelineSpan> {
|
|
26
|
+
item: T;
|
|
27
|
+
/** 0–100, clamped to the visible range. */
|
|
28
|
+
left: number;
|
|
29
|
+
width: number;
|
|
30
|
+
/** Starts before / ends after the visible range (draw a cut edge). */
|
|
31
|
+
clippedStart: boolean;
|
|
32
|
+
clippedEnd: boolean;
|
|
33
|
+
/** Sub-row inside the lane, so overlapping bars stack instead of covering each other. */
|
|
34
|
+
row: number;
|
|
35
|
+
/** Overlaps at least one other bar in the same lane. */
|
|
36
|
+
conflict: boolean;
|
|
37
|
+
}
|
|
38
|
+
declare const HOUR = 3600000;
|
|
39
|
+
declare const DAY: number;
|
|
40
|
+
/** The default move/resize step for a scale: 15 min on an hour axis, 1 h on a day axis, 1 day otherwise. */
|
|
41
|
+
declare const defaultTimelineStep: (scale: TimelineScale) => number;
|
|
42
|
+
/**
|
|
43
|
+
* Ticks for the range at the scale's unit (hour, day, week starting `weekStartsOn`, month),
|
|
44
|
+
* aligned to wall-clock boundaries in `timeZone`. Bounded to 500 ticks; a month axis over a
|
|
45
|
+
* year walks ~8,800 hours, so keep ranges to what fits on screen.
|
|
46
|
+
*/
|
|
47
|
+
declare function timelineTicks(range: TimelineRange, scale: TimelineScale, timeZone: string, weekStartsOn?: number): TimelineTick[];
|
|
48
|
+
/** Position of one span on the axis, clamped to it; null when it is entirely outside. */
|
|
49
|
+
declare function placeSpan(span: {
|
|
50
|
+
start: string;
|
|
51
|
+
end: string;
|
|
52
|
+
}, range: TimelineRange): Omit<PlacedSpan, 'item' | 'row' | 'conflict'> | null;
|
|
53
|
+
/**
|
|
54
|
+
* Places a lane's spans: sorted by start, each in the first sub-row where it does not overlap
|
|
55
|
+
* the previous bar, and flagged `conflict` when it overlaps any other span in the lane.
|
|
56
|
+
*/
|
|
57
|
+
declare function layoutLane<T extends TimelineSpan>(items: readonly T[], range: TimelineRange): PlacedSpan<T>[];
|
|
58
|
+
/** Rounds a millisecond offset to the nearest step. */
|
|
59
|
+
declare const snapToStep: (ms: number, step: number) => number;
|
|
60
|
+
/** A span moved (both ends) or resized (end only) by `delta` ms, as ISO strings; never shorter than one step. */
|
|
61
|
+
declare function shiftSpan(span: {
|
|
62
|
+
start: string;
|
|
63
|
+
end: string;
|
|
64
|
+
}, delta: number, mode: 'move' | 'resize', step: number): {
|
|
65
|
+
start: string;
|
|
66
|
+
end: string;
|
|
67
|
+
};
|
|
68
|
+
/** Converts a horizontal pointer distance on a track of `trackWidth` px to snapped milliseconds. */
|
|
69
|
+
declare function pixelsToMs(px: number, trackWidth: number, range: TimelineRange, step: number): number;
|
|
70
|
+
|
|
71
|
+
export { DAY, HOUR, type PlacedSpan, type TimelineRange, type TimelineScale, type TimelineSpan, type TimelineTick, defaultTimelineStep, layoutLane, pixelsToMs, placeSpan, shiftSpan, snapToStep, timelineTicks };
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
const HOUR = 36e5;
|
|
2
|
+
const DAY = 24 * HOUR;
|
|
3
|
+
const toMs = (value) => {
|
|
4
|
+
const ms = typeof value === "number" ? value : Date.parse(value);
|
|
5
|
+
if (Number.isNaN(ms)) throw new TypeError(`Invalid instant: ${String(value)}`);
|
|
6
|
+
return ms;
|
|
7
|
+
};
|
|
8
|
+
const defaultTimelineStep = (scale) => scale === "hour" ? 15 * 6e4 : scale === "day" ? HOUR : DAY;
|
|
9
|
+
function zonedParts(ms, timeZone) {
|
|
10
|
+
const parts = new Intl.DateTimeFormat("en-US", {
|
|
11
|
+
timeZone,
|
|
12
|
+
hourCycle: "h23",
|
|
13
|
+
year: "numeric",
|
|
14
|
+
month: "numeric",
|
|
15
|
+
day: "numeric",
|
|
16
|
+
hour: "numeric",
|
|
17
|
+
minute: "numeric",
|
|
18
|
+
weekday: "short"
|
|
19
|
+
}).formatToParts(new Date(ms));
|
|
20
|
+
const get = (type) => parts.find((p) => p.type === type)?.value ?? "";
|
|
21
|
+
return { year: +get("year"), month: +get("month"), day: +get("day"), hour: +get("hour"), minute: +get("minute"), weekday: get("weekday") };
|
|
22
|
+
}
|
|
23
|
+
function timelineTicks(range, scale, timeZone, weekStartsOn = 1) {
|
|
24
|
+
const start = toMs(range.start);
|
|
25
|
+
const end = toMs(range.end);
|
|
26
|
+
if (end <= start) return [];
|
|
27
|
+
const span = end - start;
|
|
28
|
+
const ticks = [];
|
|
29
|
+
const weekdays = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
30
|
+
const step = scale === "hour" ? 15 * 6e4 : HOUR;
|
|
31
|
+
let prev = zonedParts(start - step, timeZone);
|
|
32
|
+
for (let at = Math.ceil(start / step) * step; at <= end && ticks.length < 500; at += step) {
|
|
33
|
+
const p = zonedParts(at, timeZone);
|
|
34
|
+
const newHour = p.minute === 0 && (p.hour !== prev.hour || prev.minute !== 0);
|
|
35
|
+
const newDay = p.day !== prev.day && p.minute === 0;
|
|
36
|
+
const newMonth = newDay && p.day === 1;
|
|
37
|
+
const newWeek = newDay && weekdays.indexOf(p.weekday) === weekStartsOn;
|
|
38
|
+
const isTick = scale === "hour" ? newHour : scale === "day" ? newDay : scale === "week" ? newWeek : newMonth;
|
|
39
|
+
if (isTick) {
|
|
40
|
+
const major = scale === "hour" ? newDay : scale === "day" ? newWeek : scale === "week" ? newMonth : p.month === 1;
|
|
41
|
+
ticks.push({ at, offset: (at - start) / span * 100, major });
|
|
42
|
+
}
|
|
43
|
+
prev = p;
|
|
44
|
+
}
|
|
45
|
+
return ticks;
|
|
46
|
+
}
|
|
47
|
+
function placeSpan(span, range) {
|
|
48
|
+
const start = toMs(range.start);
|
|
49
|
+
const end = toMs(range.end);
|
|
50
|
+
const s = toMs(span.start);
|
|
51
|
+
const e = Math.max(toMs(span.end), s);
|
|
52
|
+
if (e < start || s > end || end <= start) return null;
|
|
53
|
+
const total = end - start;
|
|
54
|
+
const left = (Math.max(s, start) - start) / total * 100;
|
|
55
|
+
const right = (Math.min(e, end) - start) / total * 100;
|
|
56
|
+
return { left, width: Math.max(right - left, 0), clippedStart: s < start, clippedEnd: e > end };
|
|
57
|
+
}
|
|
58
|
+
function layoutLane(items, range) {
|
|
59
|
+
const sorted = [...items].sort((a, b) => toMs(a.start) - toMs(b.start) || toMs(a.end) - toMs(b.end));
|
|
60
|
+
const rowEnds = [];
|
|
61
|
+
const placed = [];
|
|
62
|
+
for (const item of sorted) {
|
|
63
|
+
const pos = placeSpan(item, range);
|
|
64
|
+
if (!pos) continue;
|
|
65
|
+
const s = toMs(item.start);
|
|
66
|
+
let row = rowEnds.findIndex((end) => end <= s);
|
|
67
|
+
if (row === -1) {
|
|
68
|
+
row = rowEnds.length;
|
|
69
|
+
rowEnds.push(0);
|
|
70
|
+
}
|
|
71
|
+
rowEnds[row] = Math.max(toMs(item.end), s);
|
|
72
|
+
placed.push({ item, ...pos, row, conflict: false });
|
|
73
|
+
}
|
|
74
|
+
for (let i = 0; i < placed.length; i++) {
|
|
75
|
+
for (let j = i + 1; j < placed.length; j++) {
|
|
76
|
+
const a = placed[i].item;
|
|
77
|
+
const b = placed[j].item;
|
|
78
|
+
if (toMs(b.start) >= toMs(a.end)) continue;
|
|
79
|
+
if (toMs(a.start) < toMs(b.end)) {
|
|
80
|
+
placed[i].conflict = true;
|
|
81
|
+
placed[j].conflict = true;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return placed;
|
|
86
|
+
}
|
|
87
|
+
const snapToStep = (ms, step) => Math.round(ms / step) * step;
|
|
88
|
+
function shiftSpan(span, delta, mode, step) {
|
|
89
|
+
const s = toMs(span.start);
|
|
90
|
+
const e = toMs(span.end);
|
|
91
|
+
if (mode === "move") return { start: new Date(s + delta).toISOString(), end: new Date(e + delta).toISOString() };
|
|
92
|
+
return { start: new Date(s).toISOString(), end: new Date(Math.max(e + delta, s + step)).toISOString() };
|
|
93
|
+
}
|
|
94
|
+
function pixelsToMs(px, trackWidth, range, step) {
|
|
95
|
+
if (trackWidth <= 0) return 0;
|
|
96
|
+
return snapToStep(px / trackWidth * (toMs(range.end) - toMs(range.start)), step);
|
|
97
|
+
}
|
|
98
|
+
export {
|
|
99
|
+
DAY,
|
|
100
|
+
HOUR,
|
|
101
|
+
defaultTimelineStep,
|
|
102
|
+
layoutLane,
|
|
103
|
+
pixelsToMs,
|
|
104
|
+
placeSpan,
|
|
105
|
+
shiftSpan,
|
|
106
|
+
snapToStep,
|
|
107
|
+
timelineTicks
|
|
108
|
+
};
|