rowvia 0.1.0 → 0.2.1

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.
@@ -1,12 +1,12 @@
1
1
  /**
2
2
  * UI text for menus, popups and tool panels. Mirrors ag-grid's `localeText`
3
- * option: the grid merges user-supplied keys over these English defaults and
3
+ * option: the grid merges user-supplied keys over these Chinese defaults and
4
4
  * every built-in string resolves through `t(key)` / `translate(key, fallback)`.
5
5
  */
6
6
  export declare const DEFAULT_LOCALE_TEXT: Record<string, string>;
7
7
  /** filter condition value → locale key (same names as ag-grid) */
8
8
  export declare const CONDITION_LABELS: Record<string, string>;
9
- /** resolves UI text: user overrides first, then the English defaults, then the key itself */
9
+ /** resolves UI text: user overrides first, then the Chinese defaults, then the key itself */
10
10
  export declare class LocaleText {
11
11
  private overrides;
12
12
  constructor(overrides: Record<string, string>);
@@ -26,3 +26,4 @@ export * from './gantt';
26
26
  export * from './personnel';
27
27
  export { createDetailDialog } from './components/detailDialog';
28
28
  export type { DetailDialogContent } from './components/detailDialog';
29
+ export * from './pages';
@@ -0,0 +1,2 @@
1
+ import { type GridPageOptions } from '../lifecycle';
2
+ export declare function createFinancePage(container: HTMLElement, options?: GridPageOptions): import("rowvia").GridPageHandle;
@@ -0,0 +1,14 @@
1
+ declare function logoFor(ticker: string): string;
2
+ export interface Instrument {
3
+ ticker: string;
4
+ name: string;
5
+ instrument: string;
6
+ quantity: number;
7
+ purchaseDate: string;
8
+ purchasePrice: number;
9
+ price: number;
10
+ timeline: number[];
11
+ }
12
+ export declare function getData(): Instrument[];
13
+ export declare function updateRows(rowData: Instrument[]): void;
14
+ export { logoFor };
@@ -0,0 +1,2 @@
1
+ import { type GridPageOptions } from '../lifecycle';
2
+ export declare function createHrPage(container: HTMLElement, options?: GridPageOptions): import("rowvia").GridPageHandle;
@@ -0,0 +1,21 @@
1
+ /** Deterministic pseudo random generator (LCG) so demos render identically. */
2
+ export declare function createRandom(seed?: number): () => number;
3
+ export declare const DEPARTMENTS: Record<string, string>;
4
+ interface EmployeeRecord {
5
+ orgHierarchy: string[];
6
+ contact: string;
7
+ jobTitle: string;
8
+ employmentType: string;
9
+ department: string;
10
+ employeeId: number;
11
+ location: string;
12
+ joinDate: string;
13
+ basicMonthlySalary: number;
14
+ currency: string;
15
+ paymentMethod: string;
16
+ paymentStatus: string;
17
+ image: string;
18
+ flag: string;
19
+ }
20
+ export declare function getData(): EmployeeRecord[];
21
+ export {};
@@ -0,0 +1,12 @@
1
+ export { createFinancePage } from './finance/component';
2
+ export { createHrPage } from './hr/component';
3
+ export { createInventoryPage } from './inventory/component';
4
+ export { createPerformancePage } from './performance/component';
5
+ export { createServerSidePage } from './server-side/component';
6
+ export type { GridPageOptions, GridPageHandle } from './lifecycle';
7
+ export { createWorkItemPage } from './work-items/page';
8
+ export { createControlRegistry, sanitizeRichText } from './work-items/controls';
9
+ export type { FieldControl, ControlContext, ControlEditor, ControlSurface } from './work-items/controls';
10
+ export type { WorkItemPageConfig, FieldConfig, FieldKind, FormConfig, FormFieldConfig } from './work-items/config';
11
+ export type { WorkItem, ViewState, SavedView, Rule, ColorRule } from './work-items/model';
12
+ export { topicDemoConfig, dateDemoConfig } from './work-items/config';
@@ -0,0 +1,2 @@
1
+ import { type GridPageOptions } from '../lifecycle';
2
+ export declare function createInventoryPage(container: HTMLElement, options?: GridPageOptions): import("rowvia").GridPageHandle;
@@ -0,0 +1,26 @@
1
+ /** Inventory demo data: 10 vinyl albums with variant details. */
2
+ export interface VariantDetail {
3
+ title: string;
4
+ available: number;
5
+ format: string;
6
+ label: string;
7
+ cat: string;
8
+ country: string;
9
+ year: string;
10
+ }
11
+ export interface Album {
12
+ product: string;
13
+ artist: string;
14
+ category: string;
15
+ year: string;
16
+ status: 'active' | 'paused' | 'outOfStock';
17
+ available: number;
18
+ incoming: number;
19
+ image: string;
20
+ price: number;
21
+ sold: number;
22
+ priceIncrease: number;
23
+ variants: number;
24
+ variantDetails: VariantDetail[];
25
+ }
26
+ export declare function getData(): Album[];
@@ -0,0 +1,24 @@
1
+ import type { GridOptions, GridApi, ColumnApi } from '../types';
2
+ export interface GridPageOptions {
3
+ /** Overrides the demo's columns, data, callbacks or remote datasource. */
4
+ gridOptions?: Partial<GridOptions>;
5
+ /** Finance sample stream; disable when supplying business data. */
6
+ liveUpdates?: boolean;
7
+ }
8
+ export interface GridPageHandle {
9
+ readonly api: GridApi | null;
10
+ readonly columnApi: ColumnApi | null;
11
+ destroy(): void;
12
+ }
13
+ export declare function createPageLifecycle(container: HTMLElement, name: string, markup: string, options: GridPageOptions): {
14
+ host: HTMLElement;
15
+ handle: GridPageHandle;
16
+ timeout: (callback: () => void, delay: number) => number;
17
+ cleanup(callback: () => void): void;
18
+ interval(callback: () => void, delay: number): number;
19
+ createGrid(element: HTMLElement, defaults: GridOptions): {
20
+ api: GridApi;
21
+ columnApi: ColumnApi;
22
+ grid: import("../grid").Grid;
23
+ };
24
+ };
@@ -0,0 +1,2 @@
1
+ import { type GridPageOptions } from '../lifecycle';
2
+ export declare function createPerformancePage(container: HTMLElement, options?: GridPageOptions): import("rowvia").GridPageHandle;
@@ -0,0 +1,33 @@
1
+ /** Performance demo data + column generation. */
2
+ export interface RowItem {
3
+ name: string;
4
+ language: string;
5
+ country: string;
6
+ game: {
7
+ name: string;
8
+ bought: boolean;
9
+ };
10
+ bankBalance: number;
11
+ rating: number;
12
+ totalWinnings: number;
13
+ [month: string]: any;
14
+ [key: `col${number}`]: any;
15
+ }
16
+ export declare const COUNTRY_NAMES: string[];
17
+ export declare const LANGUAGES: string[];
18
+ export declare const GAMES: string[];
19
+ export declare const MONTHS: string[];
20
+ /** deterministic LCG so every reload produces identical data */
21
+ export declare function createRandom(seed?: number): () => number;
22
+ export declare function resetRandom(): void;
23
+ export declare function createRowItem(index: number, extraColumnCount: number): RowItem;
24
+ export declare function createData(rowCount: number, extraColumnCount: number): RowItem[];
25
+ declare const DATA_TYPES: readonly ["currency", "percent", "rating", "text", "number"];
26
+ export interface ExtraColumnConfig {
27
+ field: string;
28
+ group: string;
29
+ dataType: (typeof DATA_TYPES)[number];
30
+ width: number;
31
+ }
32
+ export declare function createExtraColumns(count: number): ExtraColumnConfig[];
33
+ export {};
@@ -0,0 +1,2 @@
1
+ import { type GridPageOptions } from '../lifecycle';
2
+ export declare function createServerSidePage(container: HTMLElement, options?: GridPageOptions): import("rowvia").GridPageHandle;
@@ -0,0 +1,60 @@
1
+ import type { FieldControl } from "./controls";
2
+ import type { ColDef } from "rowvia";
3
+ import { type WorkItem } from "./model";
4
+ export type FieldKind = (string & {}) | "richText" | "number" | "dateTime" | "detail" | "title" | "text" | "longText" | "multiSelect" | "select" | "status" | "person" | "date" | "vote" | "relation";
5
+ export interface FieldConfig {
6
+ key: string;
7
+ label: string;
8
+ kind?: FieldKind;
9
+ /** Registered control ID; defaults to the field kind. */
10
+ control?: string;
11
+ width?: number;
12
+ minWidth?: number;
13
+ pinned?: "left" | "right" | null;
14
+ hidden?: boolean;
15
+ editable?: boolean;
16
+ required?: boolean;
17
+ options?: string[];
18
+ /** Maximum selected values for multiSelect; omitted means unlimited. */
19
+ maxSelections?: number;
20
+ /** Calendar features. date hides time by default; dateTime shows it. */
21
+ dateOptions?: {
22
+ showTime?: boolean;
23
+ showRange?: boolean;
24
+ };
25
+ colors?: Record<string, string>;
26
+ defaultValue?: string | number | string[] | null;
27
+ column?: Partial<ColDef>;
28
+ }
29
+ export interface FormFieldConfig {
30
+ field: string;
31
+ label?: string;
32
+ required?: boolean;
33
+ editable?: boolean;
34
+ }
35
+ export interface FormConfig {
36
+ fields: FormFieldConfig[];
37
+ showRoles?: boolean;
38
+ showMeetings?: boolean;
39
+ showApproval?: boolean;
40
+ showVotes?: boolean;
41
+ }
42
+ export interface WorkItemPageConfig {
43
+ container: HTMLElement;
44
+ title: string;
45
+ workspace: string;
46
+ storageKey: string;
47
+ currentUser: string;
48
+ fields: FieldConfig[];
49
+ createForm: FormConfig;
50
+ detailForm: FormConfig;
51
+ items: WorkItem[];
52
+ controls?: FieldControl[];
53
+ /** Opt in to browser URL hash integration. Disabled for embedded pages. */
54
+ syncLocationHash?: boolean;
55
+ onDataChange?: (items: WorkItem[]) => void;
56
+ }
57
+ /** The table, create form, and detail layout are three independent configurations. */
58
+ export declare function topicDemoConfig(container: HTMLElement): WorkItemPageConfig;
59
+ /** Deterministic 1,000-row fixture for exercising all three date controls. */
60
+ export declare function dateDemoConfig(container: HTMLElement): WorkItemPageConfig;
@@ -0,0 +1,34 @@
1
+ export { sanitizeRichText } from './rich-control';
2
+ import type { FieldConfig } from './config';
3
+ import type { WorkItem } from './model';
4
+ export type ControlSurface = 'cell' | 'detail' | 'create';
5
+ export interface ControlContext {
6
+ field: FieldConfig;
7
+ value: unknown;
8
+ item: WorkItem;
9
+ surface: ControlSurface;
10
+ readonly: boolean;
11
+ openDetail: (id: string) => void;
12
+ }
13
+ export interface ControlEditor {
14
+ element: HTMLElement;
15
+ read: () => unknown;
16
+ validate?: () => string | undefined;
17
+ focus?: () => void;
18
+ destroy?: () => void;
19
+ }
20
+ /** Definitions are scoped to a page. Return fresh DOM for each mount. */
21
+ export interface FieldControl {
22
+ id: string;
23
+ label: string;
24
+ description: string;
25
+ glyph: string;
26
+ action?: 'edit' | 'select' | 'view';
27
+ render: (context: ControlContext) => HTMLElement;
28
+ createEditor: (context: ControlContext) => ControlEditor;
29
+ }
30
+ export declare function createControlRegistry(custom?: FieldControl[]): {
31
+ register: (control: FieldControl) => void;
32
+ list: () => FieldControl[];
33
+ resolve: (field: FieldConfig) => FieldControl;
34
+ };
@@ -0,0 +1,3 @@
1
+ import type { ControlContext, ControlEditor } from './controls';
2
+ export declare function renderDate(context: ControlContext): HTMLElement;
3
+ export declare function dateEditor(context: ControlContext): ControlEditor;
@@ -0,0 +1,72 @@
1
+ import type { FieldConfig } from "./config";
2
+ export interface WorkItem {
3
+ [field: string]: any;
4
+ id: string;
5
+ name: string;
6
+ description: string;
7
+ vote: string;
8
+ showVotes: string;
9
+ status: string;
10
+ selectedTopic: string;
11
+ format: string | string[];
12
+ approved: string;
13
+ category: string;
14
+ owner: string;
15
+ space: string;
16
+ created: string;
17
+ creator: string;
18
+ source: string;
19
+ followed: boolean;
20
+ starred: boolean;
21
+ viewed: boolean;
22
+ comments: string[];
23
+ history: string[];
24
+ }
25
+ export declare const fields: readonly [readonly ["name", "选题概要"], readonly ["description", "选题描述"], readonly ["vote", "选题投票"], readonly ["showVotes", "是否展示投票结果"], readonly ["status", "状态"], readonly ["selectedTopic", "确定入选"], readonly ["format", "内容形式"], readonly ["approved", "选题是否通过"], readonly ["category", "主题分类"], readonly ["owner", "当前负责人"], readonly ["space", "所属空间"], readonly ["created", "创建时间"], readonly ["creator", "创建者"]];
26
+ export type Field = string;
27
+ export declare const statuses: string[];
28
+ export declare const categories: string[];
29
+ export declare const formats: string[];
30
+ export declare const options: Partial<Record<Field, string[]>>;
31
+ export interface Rule {
32
+ field: Field;
33
+ operator: "contains" | "equals" | "notEqual" | "blank" | "notBlank";
34
+ value: string;
35
+ }
36
+ export interface ColorRule extends Rule {
37
+ color: string;
38
+ scope?: string;
39
+ }
40
+ export interface ViewState {
41
+ filters: Rule[];
42
+ sorts: {
43
+ colId: string;
44
+ sort: "asc" | "desc";
45
+ }[];
46
+ groups: string[];
47
+ colors: ColorRule[];
48
+ showTerminated: boolean;
49
+ }
50
+ export declare const emptyView: () => ViewState;
51
+ export declare const storageKey = "rowvia:work-items:v2";
52
+ export declare const names: string[];
53
+ export declare const seed: WorkItem[];
54
+ export declare function matches(item: WorkItem, rules: Rule[]): boolean;
55
+ export interface SavedView {
56
+ name: string;
57
+ state: ViewState;
58
+ columns?: unknown;
59
+ gridState?: unknown;
60
+ tab?: string;
61
+ search?: string;
62
+ filterSearch?: boolean;
63
+ collaborators?: string;
64
+ visibility?: string;
65
+ inNavigation?: boolean;
66
+ }
67
+ export declare function loadData(key?: string, initialItems?: WorkItem[]): {
68
+ items: WorkItem[];
69
+ views: SavedView[];
70
+ drafts: WorkItem[];
71
+ customFields: FieldConfig[];
72
+ };
@@ -0,0 +1,23 @@
1
+ import { type FieldControl } from "./controls";
2
+ import { type ColumnState } from "rowvia";
3
+ import { type WorkItem, type Rule } from "./model";
4
+ import type { WorkItemPageConfig } from "./config";
5
+ export declare function createWorkItemPage(config: WorkItemPageConfig): {
6
+ registerControl: (control: FieldControl) => void;
7
+ getControls: () => FieldControl[];
8
+ api: import("rowvia").GridApi;
9
+ columnApi: import("rowvia").ColumnApi;
10
+ getViewState: () => {
11
+ columns: ColumnState[];
12
+ filters: Rule[];
13
+ sorts: {
14
+ colId: string;
15
+ sort: "asc" | "desc";
16
+ }[];
17
+ groups: string[];
18
+ colors: import("rowvia").ColorRule[];
19
+ showTerminated: boolean;
20
+ };
21
+ getItems: () => WorkItem[];
22
+ destroy: () => void;
23
+ };
@@ -0,0 +1,4 @@
1
+ import type { ControlContext, ControlEditor } from './controls';
2
+ /** Preserve editor formatting while dropping executable content and untrusted attributes. */
3
+ export declare function sanitizeRichText(value: unknown): string;
4
+ export declare function richEditor(context: ControlContext): ControlEditor;
@@ -58,7 +58,7 @@ export declare class HeaderView {
58
58
  updateIndicators(): void;
59
59
  private headerColumnIndex;
60
60
  private layoutPositions;
61
- setScrollLeft(left: number): void;
61
+ setScrollLeft(left: number, scrollbarWidth?: number): void;
62
62
  getHeaderCell(column: Column): HTMLElement | undefined;
63
63
  getHeaderRow(): HTMLElement;
64
64
  }
@@ -6,6 +6,8 @@ export interface RowRendererContext {
6
6
  options: GridOptions;
7
7
  eventService: EventService;
8
8
  rowModel: RowModel;
9
+ /** UI text lookup (localeText) */
10
+ t: (key: string) => string;
9
11
  getColumns: () => {
10
12
  left: Column[];
11
13
  center: Column[];
@@ -68,10 +70,11 @@ export declare class RowRenderer {
68
70
  private lastRange;
69
71
  private firstRendered;
70
72
  private heightVersion;
73
+ private scrollFrame;
71
74
  constructor(eRoot: HTMLElement, eHeader: HTMLElement, ctx: RowRendererContext);
72
75
  /**
73
- * Forward wheel gestures from the non-scrollable sections (pinned column
74
- * areas, sticky rows, floating rows, header) to the scrolling viewport.
76
+ * Apply wheel gestures to the shared viewport and pinned transforms in one
77
+ * handler, including gestures originating in the centre columns.
75
78
  */
76
79
  private onSectionWheel;
77
80
  private onBodyMouseOver;
@@ -112,6 +115,7 @@ export declare class RowRenderer {
112
115
  }): void;
113
116
  private rowCompKey;
114
117
  private findRowIndex;
118
+ private scheduleScrollRender;
115
119
  private onScroll;
116
120
  /** keep the pinned column sections aligned with the vertical scroll position */
117
121
  private syncPinnedScroll;
@@ -125,6 +129,7 @@ export declare class RowRenderer {
125
129
  getVerticalScrollTop(): number;
126
130
  setVerticalScrollTop(top: number): void;
127
131
  getHorizontalScrollLeft(): number;
132
+ getVerticalScrollbarWidth(): number;
128
133
  setHorizontalScrollLeft(left: number): void;
129
134
  /**
130
135
  * Re-renders the group rows that stick to the top of the viewport. A group
@@ -181,7 +186,6 @@ declare class RowComp {
181
186
  private updateCellContent;
182
187
  refreshCells(columns?: Column[], force?: boolean, flash?: boolean): void;
183
188
  appendTo(leftContainer: HTMLElement, centerContainer: HTMLElement, rightContainer: HTMLElement): void;
184
- ensureVisibleCells(): void;
185
189
  setTop(top: number): void;
186
190
  getCenterElement(): HTMLElement | null;
187
191
  getCellElements(): HTMLElement[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rowvia",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "零运行时依赖的 TypeScript 数据表格、甘特图与人员排期组件库",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -10,9 +10,11 @@
10
10
  "build:lib": "vite build --config vite.lib.config.ts && npm run build:types",
11
11
  "preview": "vite preview",
12
12
  "typecheck": "tsc --noEmit",
13
- "test": "esbuild src/index.ts --bundle --format=esm --outfile=dist-test/rowvia.mjs --loader:.ts=ts --log-level=error && node test/smoke.mjs && node test/gantt.mjs && node test/personnel.mjs",
13
+ "test": "esbuild src/index.ts --bundle --format=esm --outfile=dist-test/rowvia.mjs --loader:.ts=ts --log-level=error && node test/smoke.mjs && node test/gantt.mjs && node test/personnel.mjs && node test/work-items.mjs",
14
+ "test:work-items": "node test/work-items.mjs",
14
15
  "build:types": "tsc -p tsconfig.build.json && node scripts/clean-types.mjs",
15
- "prepublishOnly": "npm run typecheck && npm test && npm run build:lib"
16
+ "prepublishOnly": "npm run typecheck && npm test && npm run build:lib",
17
+ "test:pages": "node test/pages.mjs"
16
18
  },
17
19
  "devDependencies": {
18
20
  "esbuild": "^0.21.3",