rowvia 0.2.0 → 0.2.2

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.
@@ -157,6 +157,8 @@ export declare class Grid {
157
157
  private onColumnMoved;
158
158
  private onColumnsChanged;
159
159
  private onModelUpdated;
160
+ /** Synchronize an external horizontal scrollbar with body and header immediately. */
161
+ setHorizontalScrollLeft(left: number): void;
160
162
  onGridSizeChanged(): void;
161
163
  private onWindowResize;
162
164
  /** outside clicks (or clicks on the grid chrome) commit the edit and drop focus */
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rowvia",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "零运行时依赖的 TypeScript 数据表格、甘特图与人员排期组件库",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -13,7 +13,8 @@
13
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
14
  "test:work-items": "node test/work-items.mjs",
15
15
  "build:types": "tsc -p tsconfig.build.json && node scripts/clean-types.mjs",
16
- "prepublishOnly": "npm run typecheck && npm test && npm run build:lib"
16
+ "prepublishOnly": "npm run typecheck && npm test && npm run build:lib && npm run test:pages",
17
+ "test:pages": "node test/pages.mjs"
17
18
  },
18
19
  "devDependencies": {
19
20
  "esbuild": "^0.21.3",