@baishuyun/ui-mobile 0.3.0 → 0.5.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.
Files changed (63) hide show
  1. package/README.md +2 -11
  2. package/dist/ActionSheet/ActionSheet-Ok-UTVMn.js +133 -0
  3. package/dist/ActionSheet/index.js +5 -0
  4. package/dist/Calendar/Calendar-ipjycVqK.js +1580 -0
  5. package/dist/Calendar/index.js +4 -3
  6. package/dist/Calendar/timeUtils-CPYfw0pt.js +27 -0
  7. package/dist/ConfigProvider/ConfigProvider-CNhaKMJa.js +181 -0
  8. package/dist/ConfigProvider/index.js +3 -3
  9. package/dist/Gantt/Gantt-DDItjDkR.js +1099 -0
  10. package/dist/Gantt/index.js +7 -3
  11. package/dist/Icon/Icon-CFvcrGGg.js +23 -0
  12. package/dist/Icon/index.js +3 -0
  13. package/dist/components/ActionSheet/ActionSheet.d.ts +3 -0
  14. package/dist/components/ActionSheet/index.d.ts +2 -0
  15. package/dist/components/ActionSheet/interface.d.ts +75 -0
  16. package/dist/components/Calendar/index.d.ts +1 -1
  17. package/dist/components/Calendar/interface.d.ts +65 -7
  18. package/dist/components/ConfigProvider/context.d.ts +4 -0
  19. package/dist/components/Gantt/Gantt.d.ts +1 -1
  20. package/dist/components/Gantt/GanttBar.d.ts +10 -0
  21. package/dist/components/Gantt/GanttHeader.d.ts +2 -0
  22. package/dist/components/Gantt/GanttTimeLine.d.ts +9 -0
  23. package/dist/components/Gantt/HeaderToolbar.d.ts +6 -0
  24. package/dist/components/Gantt/OffscreenIndicatorArrow.d.ts +8 -0
  25. package/dist/components/Gantt/OffscreenIndicatorOverlay.d.ts +14 -0
  26. package/dist/components/Gantt/StickyLabel.d.ts +10 -0
  27. package/dist/components/Gantt/TodayIndicator.d.ts +14 -0
  28. package/dist/components/Gantt/calcTodayLeft.d.ts +8 -0
  29. package/dist/components/Gantt/context.d.ts +27 -0
  30. package/dist/components/Gantt/hooks/useGanttScroll.d.ts +23 -0
  31. package/dist/components/Gantt/hooks/useGanttViewport.d.ts +20 -0
  32. package/dist/components/Gantt/hooks/useTodayTracker.d.ts +7 -0
  33. package/dist/components/Gantt/index.d.ts +2 -1
  34. package/dist/components/Gantt/interface.d.ts +27 -2
  35. package/dist/components/Gantt/msUntilNextDay.d.ts +2 -0
  36. package/dist/components/Gantt/utils/color.d.ts +2 -0
  37. package/dist/components/Gantt/utils/cx.d.ts +1 -0
  38. package/dist/components/Gantt/utils/dateRangeNormalizer.d.ts +25 -0
  39. package/dist/components/Gantt/utils/dayScale.d.ts +30 -0
  40. package/dist/components/Gantt/utils/headerTimeUtils.d.ts +43 -0
  41. package/dist/components/Gantt/utils/layoutBars.d.ts +26 -0
  42. package/dist/components/Gantt/utils/time.d.ts +4 -0
  43. package/dist/components/Gantt/utils/viewportDateUtils.d.ts +11 -0
  44. package/dist/components/Gantt/utils/zoomReanchor.d.ts +18 -0
  45. package/dist/components/Icon/Icon.d.ts +6 -0
  46. package/dist/components/Icon/index.d.ts +2 -0
  47. package/dist/components/Icon/interface.d.ts +19 -0
  48. package/dist/components/Icon/loadIconfont.d.ts +1 -0
  49. package/dist/components/index.d.ts +7 -2
  50. package/dist/index.js +9 -6
  51. package/dist/locale/index.d.ts +3 -0
  52. package/dist/locale/lang/en-US.json.d.ts +41 -0
  53. package/dist/locale/lang/zh-CN.json.d.ts +41 -0
  54. package/dist/locale/lang/zh-TW.json.d.ts +41 -0
  55. package/dist/style.css +1 -1
  56. package/dist/vendors/useLocale-CMHIlzlj.js +98 -0
  57. package/dist/vendors/{version-BVySNITW.js → version-3D9AaDf3.js} +1 -1
  58. package/dist/vite-env.d.ts +1 -0
  59. package/package.json +6 -1
  60. package/dist/Calendar/Calendar-6ibIyMx0.js +0 -1606
  61. package/dist/ConfigProvider/ConfigProvider-E792q6ny.js +0 -99
  62. package/dist/Gantt/Gantt-DLmqZPAQ.js +0 -8
  63. package/dist/vendors/useLocale-BbUDQCzl.js +0 -57
@@ -1,3 +1,7 @@
1
- import "../vendors/version-BVySNITW.js";
2
- import { t as e } from "./Gantt-DLmqZPAQ.js";
3
- export { e as default };
1
+ import "../vendors/version-3D9AaDf3.js";
2
+ import "../ActionSheet/ActionSheet-Ok-UTVMn.js";
3
+ import { a as e, i as t, n, o as r, r as i, t as a } from "./Gantt-DDItjDkR.js";
4
+ import "../Icon/Icon-CFvcrGGg.js";
5
+ import "../vendors/useLocale-CMHIlzlj.js";
6
+ import "../Calendar/timeUtils-CPYfw0pt.js";
7
+ export { n as ALL_ZOOM_LEVELS, i as CALENDAR_ZOOM_LEVELS, t as SUB_DAY_ZOOM_LEVELS, e as ZOOM_LEVEL_DISPLAY_ORDER, r as ZOOM_LEVEL_LABEL_MAP, a as default };
@@ -0,0 +1,23 @@
1
+ import { jsx as e } from "react/jsx-runtime";
2
+ //#region src/components/Icon/Icon.module.scss
3
+ var t = { "bsy-icon": "_bsy-icon_gwzb9_1" }, n = /* @__PURE__ */ new Set();
4
+ //#endregion
5
+ //#region src/components/Icon/Icon.tsx
6
+ ((e) => {
7
+ if (!e || n.has(e) || (n.add(e), [...document.scripts].some((t) => t.getAttribute("src") === e))) return;
8
+ let t = document.createElement("script");
9
+ t.setAttribute("src", e), document.body.appendChild(t);
10
+ })("https://at.alicdn.com/t/c/font_4786625_7yye49rghck.js");
11
+ var r = ({ name: n, size: r = 16, color: i, className: a }) => /* @__PURE__ */ e("svg", {
12
+ className: [t["bsy-icon"], a].filter(Boolean).join(" "),
13
+ style: {
14
+ color: i,
15
+ fontSize: `${r}px`
16
+ },
17
+ "aria-hidden": !0,
18
+ focusable: "false",
19
+ children: /* @__PURE__ */ e("use", { href: `#icon-${n}` })
20
+ });
21
+ r.displayName = "BsyIcon";
22
+ //#endregion
23
+ export { r as t };
@@ -0,0 +1,3 @@
1
+ import "../vendors/version-3D9AaDf3.js";
2
+ import { t as e } from "./Icon-CFvcrGGg.js";
3
+ export { e as default };
@@ -0,0 +1,3 @@
1
+ import { ActionSheetProps } from './interface';
2
+ declare const ActionSheet: ({ open, onClose, mode, title, actions, onAction, children, zIndex, getPopupContainer, className, }: ActionSheetProps) => import('react').ReactPortal | null;
3
+ export default ActionSheet;
@@ -0,0 +1,2 @@
1
+ export { default } from './ActionSheet';
2
+ export type { ActionSheetProps, ActionSheetAction, ActionSheetMode } from './interface';
@@ -0,0 +1,75 @@
1
+ import { ReactNode } from 'react';
2
+ /**
3
+ * @description 内置列表形态:`select` 勾选当前值,`menu` 居中菜单
4
+ */
5
+ export type ActionSheetMode = 'select' | 'menu';
6
+ export interface ActionSheetAction {
7
+ /**
8
+ * @description 项标识
9
+ */
10
+ key: string;
11
+ /**
12
+ * @description 文案
13
+ */
14
+ text: ReactNode;
15
+ /**
16
+ * @description 为 `true` 时禁用:变灰、不触发 `onAction`、不关闭
17
+ */
18
+ disabled?: boolean;
19
+ /**
20
+ * @description 仅 `select`:为 `true` 时高亮并显示勾选
21
+ */
22
+ selected?: boolean;
23
+ /**
24
+ * @description 仅 `menu`:左侧图标,建议 16×16
25
+ */
26
+ icon?: ReactNode;
27
+ /**
28
+ * @description 仅 `menu`:同时作用在图标和文字,如 `#ff5631`
29
+ */
30
+ color?: string;
31
+ }
32
+ export interface ActionSheetProps {
33
+ /**
34
+ * @description 是否打开
35
+ */
36
+ open: boolean;
37
+ /**
38
+ * @description 点蒙层、关闭按钮,或点未禁用的内置动作项
39
+ */
40
+ onClose: () => void;
41
+ /**
42
+ * @description 内置列表形态
43
+ * @default 'select'
44
+ */
45
+ mode?: ActionSheetMode;
46
+ /**
47
+ * @description 标题
48
+ */
49
+ title?: ReactNode;
50
+ /**
51
+ * @description 动作列表;传入 `children` 时忽略
52
+ */
53
+ actions?: ActionSheetAction[];
54
+ /**
55
+ * @description 点击未禁用项;内置列表随后会关闭
56
+ */
57
+ onAction?: (action: ActionSheetAction) => void;
58
+ /**
59
+ * @description 自定义 body,整块替换 `actions`,且不会因点项自动关闭
60
+ */
61
+ children?: ReactNode;
62
+ /**
63
+ * @description 根节点层级
64
+ * @default 1000
65
+ */
66
+ zIndex?: number;
67
+ /**
68
+ * @description 挂载节点;未传或返回空则用 `document.body`
69
+ */
70
+ getPopupContainer?: () => HTMLElement;
71
+ /**
72
+ * @description 根节点 class
73
+ */
74
+ className?: string;
75
+ }
@@ -1,2 +1,2 @@
1
1
  export { default } from './Calendar';
2
- export type { CalendarProps, CalendarEvent, CalendarViewMode, NormalizedCalendarEvent, } from './interface';
2
+ export type { CalendarProps, CalendarEvent, CalendarViewMode } from './interface';
@@ -1,27 +1,85 @@
1
1
  import { Dayjs } from 'dayjs';
2
+ /**
3
+ * @description 日历视图:日 / 三日 / 月
4
+ */
2
5
  export type CalendarViewMode = 'day' | 'threeDay' | 'month';
3
6
  export interface CalendarEvent {
7
+ /**
8
+ * @description 唯一标识
9
+ */
4
10
  id: string;
11
+ /**
12
+ * @description 标题
13
+ */
5
14
  label: string;
15
+ /**
16
+ * @description 开始时间
17
+ */
6
18
  startTime: number | string | Date | Dayjs;
19
+ /**
20
+ * @description 结束时间
21
+ */
7
22
  endTime: number | string | Date | Dayjs;
23
+ /**
24
+ * @description 允许附带业务字段,点击时原样回传
25
+ */
8
26
  [key: string]: unknown;
9
27
  }
10
28
  export interface CalendarProps {
29
+ /**
30
+ * @description 日程数据
31
+ * @default []
32
+ */
11
33
  events?: CalendarEvent[];
34
+ /**
35
+ * @description 主题色
36
+ */
12
37
  scheduleColor: string;
38
+ /**
39
+ * @description IANA 时区;未传则用浏览器本地时区
40
+ */
13
41
  timeZone?: string;
14
- viewMode?: CalendarViewMode;
15
- initialViewMode?: CalendarViewMode;
16
- currentDate?: Date;
17
- initialDate?: Date;
42
+ /**
43
+ * @description 受控当前视图
44
+ */
45
+ mode?: CalendarViewMode;
46
+ /**
47
+ * @description 非受控初始视图
48
+ * @default 'month'
49
+ */
50
+ defaultMode?: CalendarViewMode;
51
+ /**
52
+ * @description 受控当前日期
53
+ */
54
+ value?: Date;
55
+ /**
56
+ * @description 非受控初始日期;未传则为当前时区「今天」
57
+ */
58
+ defaultValue?: Date;
59
+ /**
60
+ * @description 根节点 class
61
+ */
18
62
  className?: string;
63
+ /**
64
+ * @description 点击日程条
65
+ */
19
66
  onEventClick?: (event: CalendarEvent) => void;
67
+ /**
68
+ * @description 月视图点击日期格,并带上该日日程
69
+ */
20
70
  onDayClick?: (date: Date, dayEvents: CalendarEvent[]) => void;
21
- onViewModeChange?: (mode: CalendarViewMode) => void;
22
- onDateChange?: (date: Date) => void;
71
+ /**
72
+ * @description 视图变更
73
+ */
74
+ onModeChange?: (mode: CalendarViewMode) => void;
75
+ /**
76
+ * @description 锚定日期变更(含手势翻页、「今天」)
77
+ */
78
+ onChange?: (date: Date) => void;
23
79
  }
24
- /** 归一化后的内部事件(时间已转为 Dayjs) */
80
+ /**
81
+ * @description 归一化后的内部事件(时间已转为 Dayjs)
82
+ */
25
83
  export interface NormalizedCalendarEvent {
26
84
  id: string;
27
85
  label: string;
@@ -1,6 +1,10 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { Locale } from '../../locale';
3
3
  export type ConfigProviderProps = {
4
+ /**
5
+ * @description 文案语言;未传则沿用上层
6
+ * @default 'zh-CN'
7
+ */
4
8
  locale?: Locale;
5
9
  children?: ReactNode;
6
10
  };
@@ -1,3 +1,3 @@
1
1
  import { GanttProps } from './interface';
2
- declare const Gantt: ({ className, children }: GanttProps) => import("react").JSX.Element;
2
+ declare const Gantt: (props: GanttProps) => import("react").JSX.Element;
3
3
  export default Gantt;
@@ -0,0 +1,10 @@
1
+ import { MutableRefObject } from 'react';
2
+ import { GanttTask } from './interface';
3
+ import { LayoutGanttBar } from './utils/layoutBars';
4
+ declare const _default: import('react').MemoExoticComponent<({ bar, top, horizontalScrollRef, onClick, }: {
5
+ bar: LayoutGanttBar;
6
+ top: number;
7
+ horizontalScrollRef: MutableRefObject<HTMLDivElement | null>;
8
+ onClick?: (task: GanttTask) => void;
9
+ }) => import("react").JSX.Element>;
10
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const GanttHeader: () => import("react").JSX.Element;
2
+ export default GanttHeader;
@@ -0,0 +1,9 @@
1
+ import { MutableRefObject } from 'react';
2
+ import { LayoutGanttBar } from './utils/layoutBars';
3
+ import { GanttTask } from './interface';
4
+ declare const GanttTimeLine: ({ bars, onTaskClick, overlayHostRef, }: {
5
+ bars: LayoutGanttBar[];
6
+ onTaskClick?: (task: GanttTask) => void;
7
+ overlayHostRef?: MutableRefObject<HTMLDivElement | null>;
8
+ }) => import("react").JSX.Element;
9
+ export default GanttTimeLine;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 右侧工具栏固定在 Header 视口边缘。
3
+ * 它故意不参与时间轴横向滚动,否则缩放和导航入口会跟着内容一起跑掉。
4
+ */
5
+ declare const HeaderToolbar: () => import("react").JSX.Element;
6
+ export default HeaderToolbar;
@@ -0,0 +1,8 @@
1
+ interface OffscreenIndicatorArrowProps {
2
+ direction: 'left' | 'right';
3
+ edge: 'left' | 'right';
4
+ offset: number;
5
+ onClick: () => void;
6
+ }
7
+ declare const _default: import('react').MemoExoticComponent<({ direction, edge, offset, onClick, }: OffscreenIndicatorArrowProps) => import("react").JSX.Element>;
8
+ export default _default;
@@ -0,0 +1,14 @@
1
+ import { MutableRefObject } from 'react';
2
+ import { Dayjs } from 'dayjs';
3
+ import { VirtualItem } from '@tanstack/react-virtual';
4
+ import { LayoutGanttBar } from './utils/layoutBars';
5
+ interface OffscreenIndicatorOverlayProps {
6
+ virtualRows: VirtualItem[];
7
+ bars: LayoutGanttBar[];
8
+ horizontalScrollRef: MutableRefObject<HTMLDivElement | null>;
9
+ viewportWidth: number;
10
+ rowHeight: number;
11
+ onNavigate: (startDate: Dayjs | null) => void;
12
+ }
13
+ declare const _default: import('react').MemoExoticComponent<({ virtualRows, bars, horizontalScrollRef, viewportWidth, rowHeight, onNavigate, }: OffscreenIndicatorOverlayProps) => import("react").JSX.Element>;
14
+ export default _default;
@@ -0,0 +1,10 @@
1
+ import { Row1Cell } from './utils/headerTimeUtils';
2
+ interface StickyLabelProps {
3
+ cell: Row1Cell;
4
+ }
5
+ /**
6
+ * Row1 标签只交给浏览器原生 sticky 处理。
7
+ * 如果再让 JS 逐帧推吸附位置,移动端惯性滚动时会重新走一条更慢的更新链路。
8
+ */
9
+ declare const StickyLabel: ({ cell }: StickyLabelProps) => import("react").JSX.Element;
10
+ export default StickyLabel;
@@ -0,0 +1,14 @@
1
+ import { Dayjs } from 'dayjs';
2
+ import { ZoomLevel } from './interface';
3
+ interface TodayIndicatorProps {
4
+ today: Dayjs;
5
+ startDate: Dayjs;
6
+ pxPerDay: number;
7
+ totalDays: number;
8
+ zoomLevel: ZoomLevel;
9
+ }
10
+ /**
11
+ * 时间轴只负责“今天”竖线,Header 单独负责圆点。
12
+ */
13
+ declare const TodayIndicator: ({ today, startDate, pxPerDay, totalDays, zoomLevel, }: TodayIndicatorProps) => import("react").JSX.Element | null;
14
+ export default TodayIndicator;
@@ -0,0 +1,8 @@
1
+ import { Dayjs } from 'dayjs';
2
+ import { ZoomLevel } from './interface';
3
+ /**
4
+ * 计算今天/当前时刻在时间窗里的横向位置。
5
+ * - 日历档:今天列视觉中心
6
+ * - 亚日档:当前 bottom 格中心
7
+ */
8
+ export declare function calcTodayLeft(today: Dayjs, startDate: Dayjs, pxPerDay: number, totalDays: number, zoomLevel?: ZoomLevel): number | null;
@@ -0,0 +1,27 @@
1
+ import { MutableRefObject } from 'react';
2
+ import { Dayjs } from 'dayjs';
3
+ import { ZoomLevel } from './interface';
4
+ export type GanttStateContextType = {
5
+ zoomLevel: ZoomLevel;
6
+ pxPerDay: number;
7
+ timeZone?: string;
8
+ viewportWidth: number;
9
+ anchorDate: Dayjs;
10
+ startDate: Dayjs;
11
+ count: number;
12
+ totalDays: number;
13
+ totalWidth: number;
14
+ };
15
+ export type GanttActionContextType = {
16
+ setZoomLevel: (level: ZoomLevel) => void;
17
+ horizontalScrollRef: MutableRefObject<HTMLDivElement | null>;
18
+ scrollToX: (left: number, behavior?: ScrollBehavior) => void;
19
+ getScrollLeft: () => number;
20
+ handleTodayClick: () => void;
21
+ navigateToBar: (startDate: Dayjs | null) => void;
22
+ };
23
+ declare const GanttStateContext: import('react').Context<GanttStateContextType | null>;
24
+ declare const GanttActionContext: import('react').Context<GanttActionContextType | null>;
25
+ export declare const useGanttState: () => GanttStateContextType;
26
+ export declare const useGanttAction: () => GanttActionContextType;
27
+ export { GanttStateContext, GanttActionContext };
@@ -0,0 +1,23 @@
1
+ import { MutableRefObject } from 'react';
2
+ import { Dayjs } from 'dayjs';
3
+ import { ZoomLevel } from '../interface';
4
+ import { GanttViewportModel } from './useGanttViewport';
5
+ interface GanttScrollController {
6
+ horizontalScrollRef: MutableRefObject<HTMLDivElement | null>;
7
+ scrollToX: (left: number, behavior?: ScrollBehavior) => void;
8
+ getScrollLeft: () => number;
9
+ handleHorizontalScroll: () => void;
10
+ setZoomLevel: (level: ZoomLevel) => void;
11
+ handleTodayClick: () => void;
12
+ navigateToBar: (startDate: Dayjs | null) => void;
13
+ }
14
+ /**
15
+ * 维护甘特图横向滚动坐标系。
16
+ *
17
+ * [核心目标] 用户无论在 resize、zoom、拖拽或“回到今天”之间切换,
18
+ * 当前观察焦点都应保持稳定;否则时间轴会出现“跳屏感”。
19
+ */
20
+ export declare function useGanttScroll(viewport: GanttViewportModel, { onZoomLevelChange }: {
21
+ onZoomLevelChange: (level: ZoomLevel) => void;
22
+ }): GanttScrollController;
23
+ export {};
@@ -0,0 +1,20 @@
1
+ import { MutableRefObject } from 'react';
2
+ import { Dayjs } from 'dayjs';
3
+ import { ZoomLevel } from '../interface';
4
+ export interface GanttViewportModel {
5
+ timeZone?: string;
6
+ zoomLevel: ZoomLevel;
7
+ pxPerDay: number;
8
+ anchorDate: Dayjs;
9
+ containerRef: MutableRefObject<HTMLDivElement | null>;
10
+ viewportWidth: number;
11
+ startDate: Dayjs;
12
+ count: number;
13
+ totalDays: number;
14
+ totalWidth: number;
15
+ setAnchorDate: (date: Dayjs) => void;
16
+ }
17
+ export declare function useGanttViewport({ timeZone, initialZoomLevel, }: {
18
+ timeZone?: string;
19
+ initialZoomLevel?: ZoomLevel;
20
+ }): GanttViewportModel;
@@ -0,0 +1,7 @@
1
+ import { Dayjs } from 'dayjs';
2
+ import { ZoomLevel } from '../interface';
3
+ /**
4
+ * 低成本地追踪“今天 / 当前格”。
5
+ * 日历档只在业务时区跨天时更新;亚日档在当前 bottom 格结束时更新。
6
+ */
7
+ export declare function useTodayTracker(timeZone?: string, zoomLevel?: ZoomLevel): Dayjs;
@@ -1,2 +1,3 @@
1
1
  export { default } from './Gantt';
2
- export type { GanttProps } from './interface';
2
+ export type { GanttProps, GanttTask, ZoomLevel } from './interface';
3
+ export { CALENDAR_ZOOM_LEVELS, SUB_DAY_ZOOM_LEVELS, ALL_ZOOM_LEVELS, ZOOM_LEVEL_LABEL_MAP, ZOOM_LEVEL_DISPLAY_ORDER, } from './interface';
@@ -1,5 +1,30 @@
1
- import { ReactNode } from 'react';
1
+ import { Dayjs } from 'dayjs';
2
+ export declare const CALENDAR_ZOOM_LEVELS: readonly ["day", "week", "month", "quarter", "quarterMonth", "year"];
3
+ export declare const SUB_DAY_ZOOM_LEVELS: readonly ["halfDay", "sixHour", "hour", "halfHour", "tenMinute", "oneMinute"];
4
+ export declare const ALL_ZOOM_LEVELS: readonly ["day", "week", "month", "quarter", "quarterMonth", "year", "halfDay", "sixHour", "hour", "halfHour", "tenMinute", "oneMinute"];
5
+ export type ZoomLevel = (typeof ALL_ZOOM_LEVELS)[number];
6
+ export type SubDayZoomLevel = (typeof SUB_DAY_ZOOM_LEVELS)[number];
7
+ export declare const ZOOM_LEVEL_LABEL_MAP: Record<ZoomLevel, string>;
8
+ /** 工具栏展示顺序:亚日(细)→ 年(粗) */
9
+ export declare const ZOOM_LEVEL_DISPLAY_ORDER: readonly ZoomLevel[];
10
+ export type GanttTimeInput = number | string | Date | Dayjs;
11
+ /**
12
+ * 甘特任务的公开模型。不含业务字段;点击只回传这些字段。
13
+ */
14
+ export interface GanttTask {
15
+ id: string;
16
+ label: string;
17
+ startTime: GanttTimeInput;
18
+ endTime: GanttTimeInput;
19
+ progress?: number;
20
+ color?: string;
21
+ }
2
22
  export interface GanttProps {
23
+ tasks?: GanttTask[];
24
+ timeZone?: string;
25
+ zoomLevel?: ZoomLevel;
26
+ defaultZoomLevel?: ZoomLevel;
27
+ onZoomChange?: (level: ZoomLevel) => void;
28
+ onTaskClick?: (task: GanttTask) => void;
3
29
  className?: string;
4
- children?: ReactNode;
5
30
  }
@@ -0,0 +1,2 @@
1
+ export declare function msUntilNextDay(timeZone?: string): number;
2
+ export declare function msUntilNextCell(timeZone: string | undefined, cellMs: number): number;
@@ -0,0 +1,2 @@
1
+ export declare const hexToRgba: (hex: string, alpha: number) => string | null;
2
+ export declare const getContrastColor: (color: string, minContrastRatio?: number) => string;
@@ -0,0 +1 @@
1
+ export declare const cx: (...parts: Array<string | false | null | undefined>) => string;
@@ -0,0 +1,25 @@
1
+ import { Dayjs } from 'dayjs';
2
+ import { ZoomLevel } from '../interface';
3
+ import { MS_PER_DAY } from './dayScale';
4
+ export declare const hasTimeComponent: (date: Dayjs | null) => boolean;
5
+ export interface NormalizedTaskRange {
6
+ rawStart: Dayjs | null;
7
+ rawEnd: Dayjs | null;
8
+ baseStart: Dayjs | null;
9
+ baseEnd: Dayjs | null;
10
+ invalid: boolean;
11
+ }
12
+ /**
13
+ * 归一化任务起止:base 为日历整天闭区间包络(end 日 +1 天)。
14
+ */
15
+ export declare const normalizeTaskDateRange: (start: Dayjs | null, end: Dayjs | null) => NormalizedTaskRange;
16
+ /**
17
+ * 对齐 ui-base resolveRenderRange:
18
+ * - 亚日 + 起/止含时分 → 连续 raw
19
+ * - 其余 → 整天包络 base
20
+ */
21
+ export declare const resolveRenderRange: (range: NormalizedTaskRange, zoomLevel: ZoomLevel) => {
22
+ start: Dayjs | null;
23
+ end: Dayjs | null;
24
+ };
25
+ export { MS_PER_DAY };
@@ -0,0 +1,30 @@
1
+ import { Dayjs } from 'dayjs';
2
+ import { SubDayZoomLevel, ZoomLevel } from '../interface';
3
+ export declare const MS_PER_DAY: number;
4
+ export declare const MS_HOUR: number;
5
+ export declare const MS_MIN: number;
6
+ /** 亚日档 bottom 格时长(ms) */
7
+ export declare const BOTTOM_CELL_MS: Record<SubDayZoomLevel, number>;
8
+ /** mobile「按日」列宽锚点;tenMinute / oneMinute 单格宽与此一致 */
9
+ export declare const MOBILE_DAY_COLUMN_WIDTH_PX = 30;
10
+ /**
11
+ * 所有缩放级别都共享同一条“按天连续缩放”的比例尺。
12
+ * 日历档为 mobile 独立取值;亚日档在 ui-base 层次上按 day 锚点缩放。
13
+ */
14
+ export declare const PX_PER_DAY_MAP: Record<ZoomLevel, number>;
15
+ /**
16
+ * 亚日档初始缓冲天数(单侧)。
17
+ * 细档必须收窄窗口,避免初次构建上万列表头格。
18
+ */
19
+ export declare const SUBDAY_BUFFER_DAYS: Record<SubDayZoomLevel, number>;
20
+ export declare function isSubDayZoom(level: ZoomLevel): level is SubDayZoomLevel;
21
+ export declare function getBottomCellMs(level: ZoomLevel): number;
22
+ export declare function getBottomCellWidthPx(level: ZoomLevel, pxPerDay: number): number;
23
+ /**
24
+ * 在连续日尺度上把日期映射成像素偏移(保留时分秒,不做日截断)。
25
+ */
26
+ export declare function dateToPx(date: Dayjs, originDate: Dayjs, pxPerDay: number): number;
27
+ /**
28
+ * `dateToPx` 的逆过程,用于从当前视口位置反推日期锚点。
29
+ */
30
+ export declare function pxToDate(px: number, originDate: Dayjs, pxPerDay: number): Dayjs;
@@ -0,0 +1,43 @@
1
+ import { Dayjs } from 'dayjs';
2
+ import { LocaleKeys } from '../../../hooks/useLocale';
3
+ import { LocaleParams } from '../../../locale/formatLocaleMessage';
4
+ import { ZoomLevel } from '../interface';
5
+ export type GanttTranslate = (key: LocaleKeys, params?: LocaleParams) => string;
6
+ /**
7
+ * Row1 只是 Row2 的视觉聚合层;真正的滚动、today 和宽度都仍以 Row2 为准。
8
+ */
9
+ export interface Row1Cell {
10
+ label: string;
11
+ startIndex: number;
12
+ span: number;
13
+ widthPx: number;
14
+ }
15
+ /**
16
+ * Row2 是时间轴的最小真实网格;所有横向定位都要回到这层定义。
17
+ */
18
+ export interface Row2Cell {
19
+ label: string;
20
+ isToday: boolean;
21
+ isWeekend: boolean;
22
+ date: Dayjs;
23
+ endDate: Dayjs;
24
+ days: number;
25
+ }
26
+ /**
27
+ * Row1 宽度必须严格等于底下 Row2 宽度之和,否则 sticky 标题会和列线错位。
28
+ */
29
+ export declare function generateRow1Cells(row2Cells: Row2Cell[], zoomLevel: ZoomLevel, pxPerDay: number, t?: GanttTranslate): Row1Cell[];
30
+ /**
31
+ * 按当前 zoom 生成底层时间网格;上层标题、today 指示器和滚动定位都共用这份列定义。
32
+ */
33
+ export declare function generateRow2Cells(startDate: Dayjs, count: number, zoomLevel: ZoomLevel, todayDate: Dayjs, t?: GanttTranslate): Row2Cell[];
34
+ export declare function getTodayColumnIndex(row2Cells: Row2Cell[]): number;
35
+ /**
36
+ * 以 `anchorDate` 为中心扩出一段稳定的时间窗口。
37
+ * 日历档按“屏数”扩容;亚日档按固定 buffer 天数收窄,避免细粒度列爆炸。
38
+ */
39
+ export declare function calcTimeRange(anchorDate: Dayjs, zoomLevel: ZoomLevel, pxPerDay: number, viewportWidth: number, bufferScreens?: number): {
40
+ startDate: Dayjs;
41
+ count: number;
42
+ totalDays: number;
43
+ };
@@ -0,0 +1,26 @@
1
+ import { Dayjs } from 'dayjs';
2
+ import { GanttTask, ZoomLevel } from '../interface';
3
+ export declare const DEFAULT_BAR_COLOR = "#5170E8";
4
+ export interface LayoutGanttBar {
5
+ id: string;
6
+ label: string;
7
+ hasTimeRange: boolean;
8
+ left: number;
9
+ width: number;
10
+ color: string;
11
+ bgColor: string;
12
+ progress: number;
13
+ rowIndex: number;
14
+ startDate: Dayjs | null;
15
+ endDate: Dayjs | null;
16
+ task: GanttTask;
17
+ }
18
+ export interface GanttTimeAxis {
19
+ startDate: Dayjs;
20
+ pxPerDay: number;
21
+ zoomLevel: ZoomLevel;
22
+ }
23
+ /**
24
+ * 把 GanttTask 转成可渲染的像素条:颜色、进度、left/width。
25
+ */
26
+ export declare function layoutGanttBars(tasks: GanttTask[], timeAxis: GanttTimeAxis, timeZone?: string): LayoutGanttBar[];
@@ -0,0 +1,4 @@
1
+ import { Dayjs } from 'dayjs';
2
+ import { GanttTimeInput } from '../interface';
3
+ export declare const nowInTz: (timeZone?: string) => Dayjs;
4
+ export declare const parseGanttTime: (value: GanttTimeInput | null | undefined, timeZone?: string) => Dayjs;
@@ -0,0 +1,11 @@
1
+ import { Dayjs } from 'dayjs';
2
+ /**
3
+ * 把“当前正盯着哪一天”从滚动位置里反算出来。
4
+ * zoom 切换和 re-anchor 都依赖这个日期来保持视口焦点不跳。
5
+ */
6
+ export declare function calcViewportCenterDate(scrollLeft: number, viewportWidth: number, startDate: Dayjs, pxPerDay: number): Dayjs;
7
+ /**
8
+ * 反过来把“想盯住的日期”换成 scrollLeft。
9
+ * 这样时间窗结构变了以后,仍能把同一个日期放回视口中心。
10
+ */
11
+ export declare function calcScrollLeftForAnchor(anchorDate: Dayjs, newStartDate: Dayjs, pxPerDay: number, viewportWidth: number): number;
@@ -0,0 +1,18 @@
1
+ import { Dayjs } from 'dayjs';
2
+ import { ZoomLevel } from '../interface';
3
+ interface CalcReanchoredZoomStateParams {
4
+ currentZoomLevel: ZoomLevel;
5
+ nextZoomLevel: ZoomLevel;
6
+ currentAnchorDate: Dayjs;
7
+ currentScrollLeft: number;
8
+ viewportWidth: number;
9
+ }
10
+ interface ReanchoredZoomState {
11
+ anchorDate: Dayjs;
12
+ scrollLeft: number;
13
+ }
14
+ /**
15
+ * 用当前视口中心日期重建缩放后的时间窗,保证 zoom 切换时视觉焦点稳定。
16
+ */
17
+ export declare function calcReanchoredZoomState({ currentZoomLevel, nextZoomLevel, currentAnchorDate, currentScrollLeft, viewportWidth, }: CalcReanchoredZoomStateParams): ReanchoredZoomState;
18
+ export {};
@@ -0,0 +1,6 @@
1
+ import { IconProps } from './interface';
2
+ declare const Icon: {
3
+ ({ name, size, color, className }: IconProps): import("react").JSX.Element;
4
+ displayName: string;
5
+ };
6
+ export default Icon;
@@ -0,0 +1,2 @@
1
+ export { default } from './Icon';
2
+ export type { IconProps } from './interface';