@asymmetric-effort/specifyjs 0.2.145 → 0.2.150
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/dist/esm/components-barrel.js +914 -304
- package/dist/specifyjs-components.cjs.js +3 -3
- package/dist/specifyjs-components.esm.js +914 -304
- package/dist/types/components/data/board/src/Board.d.ts +28 -0
- package/dist/types/components/data/board/src/BoardReducer.d.ts +90 -0
- package/dist/types/components/data/board/src/Card.d.ts +24 -0
- package/dist/types/components/data/board/src/CardLink.d.ts +13 -0
- package/dist/types/components/data/board/src/Container.d.ts +17 -0
- package/dist/types/components/data/board/src/NamespaceValidator.d.ts +34 -0
- package/dist/types/components/data/board/src/index.d.ts +13 -0
- package/dist/types/components/data/board/src/types.d.ts +76 -0
- package/dist/types/demos/project-manager/src/Board.d.ts +1 -0
- package/dist/types/demos/project-manager/src/Card.d.ts +14 -0
- package/dist/types/demos/project-manager/src/types.d.ts +7 -0
- package/package.json +1 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { BoardState } from './types';
|
|
2
|
+
import type { BoardAction } from './BoardReducer';
|
|
3
|
+
export interface BoardProps {
|
|
4
|
+
state: BoardState;
|
|
5
|
+
dispatch: (action: BoardAction) => void;
|
|
6
|
+
selectedId?: string | null;
|
|
7
|
+
onSelectItem?: (itemId: string | null) => void;
|
|
8
|
+
gridEnabled?: boolean;
|
|
9
|
+
searchQuery?: string;
|
|
10
|
+
colorFilter?: string | null;
|
|
11
|
+
onOpenProject?: (projectId: string) => void;
|
|
12
|
+
}
|
|
13
|
+
export declare function snapToGrid(pos: {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
}, gridSize: number): {
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
};
|
|
20
|
+
export declare function screenToCanvas(screenX: number, screenY: number, viewport: {
|
|
21
|
+
panX: number;
|
|
22
|
+
panY: number;
|
|
23
|
+
zoom: number;
|
|
24
|
+
}): {
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
};
|
|
28
|
+
export declare function Board(props: BoardProps): import("specifyjs/shared/types").SpecElement<import("specifyjs/shared/types").Props>;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { BoardState, BoardItem, Card, Container, CardLink, CardType } from './types';
|
|
2
|
+
export type BoardAction = {
|
|
3
|
+
type: 'ADD_ITEM';
|
|
4
|
+
item: BoardItem;
|
|
5
|
+
containerId?: string;
|
|
6
|
+
} | {
|
|
7
|
+
type: 'REMOVE_ITEM';
|
|
8
|
+
itemId: string;
|
|
9
|
+
} | {
|
|
10
|
+
type: 'MOVE_ITEM';
|
|
11
|
+
itemId: string;
|
|
12
|
+
position: {
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
};
|
|
16
|
+
} | {
|
|
17
|
+
type: 'RESIZE_ITEM';
|
|
18
|
+
itemId: string;
|
|
19
|
+
size: {
|
|
20
|
+
width: number;
|
|
21
|
+
height: number;
|
|
22
|
+
};
|
|
23
|
+
} | {
|
|
24
|
+
type: 'UPDATE_CARD';
|
|
25
|
+
cardId: string;
|
|
26
|
+
updates: Partial<Card>;
|
|
27
|
+
} | {
|
|
28
|
+
type: 'CHANGE_CARD_TYPE';
|
|
29
|
+
cardId: string;
|
|
30
|
+
newType: CardType;
|
|
31
|
+
} | {
|
|
32
|
+
type: 'ADD_CONTAINER';
|
|
33
|
+
container: Container;
|
|
34
|
+
parentContainerId?: string;
|
|
35
|
+
} | {
|
|
36
|
+
type: 'NEST_ITEM';
|
|
37
|
+
itemId: string;
|
|
38
|
+
containerId: string;
|
|
39
|
+
} | {
|
|
40
|
+
type: 'UNNEST_ITEM';
|
|
41
|
+
itemId: string;
|
|
42
|
+
containerId: string;
|
|
43
|
+
} | {
|
|
44
|
+
type: 'ADD_LINK';
|
|
45
|
+
cardId: string;
|
|
46
|
+
link: CardLink;
|
|
47
|
+
} | {
|
|
48
|
+
type: 'REMOVE_LINK';
|
|
49
|
+
cardId: string;
|
|
50
|
+
linkId: string;
|
|
51
|
+
} | {
|
|
52
|
+
type: 'PAN';
|
|
53
|
+
panX: number;
|
|
54
|
+
panY: number;
|
|
55
|
+
} | {
|
|
56
|
+
type: 'ZOOM';
|
|
57
|
+
zoom: number;
|
|
58
|
+
} | {
|
|
59
|
+
type: 'SET_BOARD';
|
|
60
|
+
state: BoardState;
|
|
61
|
+
} | {
|
|
62
|
+
type: 'RENAME_BOARD';
|
|
63
|
+
name: string;
|
|
64
|
+
};
|
|
65
|
+
export interface HistoryState {
|
|
66
|
+
past: BoardState[];
|
|
67
|
+
present: BoardState;
|
|
68
|
+
future: BoardState[];
|
|
69
|
+
}
|
|
70
|
+
export declare const DEFAULT_BOARD_STATE: BoardState;
|
|
71
|
+
export declare function boardReducer(state: BoardState, action: BoardAction): BoardState;
|
|
72
|
+
type HistoryAction = {
|
|
73
|
+
type: 'UNDO';
|
|
74
|
+
} | {
|
|
75
|
+
type: 'REDO';
|
|
76
|
+
} | {
|
|
77
|
+
type: 'BOARD_ACTION';
|
|
78
|
+
action: BoardAction;
|
|
79
|
+
};
|
|
80
|
+
export declare function historyReducer(state: HistoryState, action: HistoryAction): HistoryState;
|
|
81
|
+
export interface UseBoardReducerResult {
|
|
82
|
+
state: BoardState;
|
|
83
|
+
dispatch: (action: BoardAction) => void;
|
|
84
|
+
undo: () => void;
|
|
85
|
+
redo: () => void;
|
|
86
|
+
canUndo: boolean;
|
|
87
|
+
canRedo: boolean;
|
|
88
|
+
}
|
|
89
|
+
export declare function useBoardReducer(initialState?: BoardState): UseBoardReducerResult;
|
|
90
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Card, CardType } from './types';
|
|
2
|
+
import type { BoardAction } from './BoardReducer';
|
|
3
|
+
export declare const PRIORITY_COLORS: Record<string, string>;
|
|
4
|
+
export declare const CARD_TYPE_OPTIONS: Array<{
|
|
5
|
+
label: string;
|
|
6
|
+
value: CardType;
|
|
7
|
+
}>;
|
|
8
|
+
export interface CardComponentProps {
|
|
9
|
+
card: Card;
|
|
10
|
+
selected?: boolean;
|
|
11
|
+
onSelect?: (cardId: string) => void;
|
|
12
|
+
onMove?: (cardId: string, position: {
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
}) => void;
|
|
16
|
+
onResize?: (cardId: string, size: {
|
|
17
|
+
width: number;
|
|
18
|
+
height: number;
|
|
19
|
+
}) => void;
|
|
20
|
+
onDelete?: (cardId: string) => void;
|
|
21
|
+
dispatch?: (action: BoardAction) => void;
|
|
22
|
+
onOpenProject?: (projectId: string) => void;
|
|
23
|
+
}
|
|
24
|
+
export declare function CardComponent(props: CardComponentProps): import("specifyjs/shared/types").SpecElement<import("specifyjs/shared/types").Props>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Card, CardLink } from './types';
|
|
2
|
+
export interface CardLinkOverlayProps {
|
|
3
|
+
links: Array<{
|
|
4
|
+
source: Card;
|
|
5
|
+
link: CardLink;
|
|
6
|
+
}>;
|
|
7
|
+
cards: Card[];
|
|
8
|
+
selectedLinkId: string | null;
|
|
9
|
+
onSelectLink: (linkId: string | null) => void;
|
|
10
|
+
canvasWidth: number;
|
|
11
|
+
canvasHeight: number;
|
|
12
|
+
}
|
|
13
|
+
export declare function CardLinkOverlay(props: CardLinkOverlayProps): import("specifyjs/shared/types").SpecElement<import("specifyjs/shared/types").Props>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Container } from './types';
|
|
2
|
+
export interface ContainerComponentProps {
|
|
3
|
+
container: Container;
|
|
4
|
+
selected?: boolean;
|
|
5
|
+
onSelect?: (containerId: string) => void;
|
|
6
|
+
onMove?: (containerId: string, position: {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
}) => void;
|
|
10
|
+
onResize?: (containerId: string, size: {
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
}) => void;
|
|
14
|
+
onDrop?: (itemId: string, containerId: string) => void;
|
|
15
|
+
children?: unknown;
|
|
16
|
+
}
|
|
17
|
+
export declare function ContainerComponent(props: ContainerComponentProps): import("specifyjs/shared/types").SpecElement<import("specifyjs/shared/types").Props>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NamespaceValidator.ts -- Scope-aware name uniqueness enforcement.
|
|
3
|
+
*
|
|
4
|
+
* Names must be unique within a container and all its descendants.
|
|
5
|
+
* Sibling containers are independent scopes.
|
|
6
|
+
* A parent and descendant cannot share names.
|
|
7
|
+
*/
|
|
8
|
+
import type { BoardItem, Container } from './types';
|
|
9
|
+
/**
|
|
10
|
+
* Check if a name is unique within a container's scope (the container
|
|
11
|
+
* itself and ALL its descendants).
|
|
12
|
+
*
|
|
13
|
+
* @param name - The name to validate
|
|
14
|
+
* @param container - The container scope to check within
|
|
15
|
+
* @param excludeId - Optional ID to exclude from the check (for renames)
|
|
16
|
+
* @returns true if the name is unique (valid), false if duplicate found
|
|
17
|
+
*/
|
|
18
|
+
export declare function validateNameInScope(name: string, container: Container, excludeId?: string): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Check if a name is unique at the board's top level collection.
|
|
21
|
+
* Only checks the top-level items — sibling containers are independent scopes.
|
|
22
|
+
*
|
|
23
|
+
* @param name - The name to validate
|
|
24
|
+
* @param collection - The board's top-level collection
|
|
25
|
+
* @param excludeId - Optional ID to exclude from the check (for renames)
|
|
26
|
+
* @returns true if the name is unique (valid), false if duplicate found
|
|
27
|
+
*/
|
|
28
|
+
export declare function validateNameInBoard(name: string, collection: BoardItem[], excludeId?: string): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Check if a name would be valid when adding/renaming an item inside a container,
|
|
31
|
+
* considering the full ancestor chain. The name must not conflict with the
|
|
32
|
+
* container's name or any of its descendants' names.
|
|
33
|
+
*/
|
|
34
|
+
export declare function validateNameForNesting(name: string, targetContainer: Container, excludeId?: string): boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type { BoardState, BoardItem, Card, Container, CardLink, CardType, TextContent, JsonContent, TaskContent, ProjectContent, } from './types';
|
|
2
|
+
export { isCard, isContainer, generateUUID, getItemId, getItemName } from './types';
|
|
3
|
+
export { validateNameInScope, validateNameInBoard, validateNameForNesting } from './NamespaceValidator';
|
|
4
|
+
export type { BoardAction, HistoryState, UseBoardReducerResult } from './BoardReducer';
|
|
5
|
+
export { boardReducer, historyReducer, useBoardReducer, DEFAULT_BOARD_STATE } from './BoardReducer';
|
|
6
|
+
export { Board } from './Board';
|
|
7
|
+
export type { BoardProps } from './Board';
|
|
8
|
+
export { ContainerComponent } from './Container';
|
|
9
|
+
export type { ContainerComponentProps } from './Container';
|
|
10
|
+
export { CardComponent, PRIORITY_COLORS, CARD_TYPE_OPTIONS } from './Card';
|
|
11
|
+
export type { CardComponentProps } from './Card';
|
|
12
|
+
export { CardLinkOverlay } from './CardLink';
|
|
13
|
+
export type { CardLinkOverlayProps } from './CardLink';
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* types.ts -- All data model interfaces for the Board component family.
|
|
3
|
+
*/
|
|
4
|
+
export interface TextContent {
|
|
5
|
+
text: string;
|
|
6
|
+
}
|
|
7
|
+
export interface JsonContent {
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
}
|
|
10
|
+
export interface TaskContent {
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
}
|
|
13
|
+
export interface ProjectContent {
|
|
14
|
+
project_id: string;
|
|
15
|
+
project_name: string;
|
|
16
|
+
}
|
|
17
|
+
export type CardType = 'text' | 'json' | 'task' | 'project';
|
|
18
|
+
export interface CardLink {
|
|
19
|
+
link_id: string;
|
|
20
|
+
link_name: string;
|
|
21
|
+
target_card_id: string;
|
|
22
|
+
color: string;
|
|
23
|
+
attributes: Record<number, string>;
|
|
24
|
+
}
|
|
25
|
+
export interface Card {
|
|
26
|
+
type: 'card';
|
|
27
|
+
card_id: string;
|
|
28
|
+
card_type: CardType;
|
|
29
|
+
card_title: string;
|
|
30
|
+
card_link: CardLink[];
|
|
31
|
+
content: TextContent | JsonContent | TaskContent | ProjectContent;
|
|
32
|
+
position: {
|
|
33
|
+
x: number;
|
|
34
|
+
y: number;
|
|
35
|
+
};
|
|
36
|
+
size: {
|
|
37
|
+
width: number;
|
|
38
|
+
height: number;
|
|
39
|
+
};
|
|
40
|
+
color: string;
|
|
41
|
+
priority?: 'low' | 'medium' | 'high' | 'critical';
|
|
42
|
+
assignee?: string;
|
|
43
|
+
tags?: string[];
|
|
44
|
+
createdAt: number;
|
|
45
|
+
updatedAt: number;
|
|
46
|
+
}
|
|
47
|
+
export interface Container {
|
|
48
|
+
type: 'container';
|
|
49
|
+
container_id: string;
|
|
50
|
+
name: string;
|
|
51
|
+
position: {
|
|
52
|
+
x: number;
|
|
53
|
+
y: number;
|
|
54
|
+
};
|
|
55
|
+
size: {
|
|
56
|
+
width: number;
|
|
57
|
+
height: number;
|
|
58
|
+
};
|
|
59
|
+
contents: BoardItem[];
|
|
60
|
+
}
|
|
61
|
+
export type BoardItem = Container | Card;
|
|
62
|
+
export interface BoardState {
|
|
63
|
+
id: string;
|
|
64
|
+
name: string;
|
|
65
|
+
collection: BoardItem[];
|
|
66
|
+
viewport: {
|
|
67
|
+
panX: number;
|
|
68
|
+
panY: number;
|
|
69
|
+
zoom: number;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export declare function isCard(item: BoardItem): item is Card;
|
|
73
|
+
export declare function isContainer(item: BoardItem): item is Container;
|
|
74
|
+
export declare function generateUUID(): string;
|
|
75
|
+
export declare function getItemId(item: BoardItem): string;
|
|
76
|
+
export declare function getItemName(item: BoardItem): string;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { ProjectCard } from './types';
|
|
2
|
+
export declare const PRIORITY_COLORS: Record<string, string>;
|
|
3
|
+
export declare const CONTEXT_MENU_COLORS: string[];
|
|
4
|
+
export declare const PRIORITY_OPTIONS: Array<{
|
|
5
|
+
label: string;
|
|
6
|
+
value: 'low' | 'medium' | 'high' | 'critical';
|
|
7
|
+
}>;
|
|
2
8
|
export interface CardProps {
|
|
3
9
|
card: ProjectCard;
|
|
4
10
|
selected: boolean;
|
|
@@ -13,10 +19,18 @@ export interface CardProps {
|
|
|
13
19
|
}) => void;
|
|
14
20
|
onDelete: (cardId: string) => void;
|
|
15
21
|
onDoubleClick: (cardId: string) => void;
|
|
22
|
+
onUpdate?: (cardId: string, updates: {
|
|
23
|
+
title?: string;
|
|
24
|
+
description?: string;
|
|
25
|
+
}) => void;
|
|
16
26
|
onDragStart?: (cardId: string, e: Event) => void;
|
|
17
27
|
onDuplicate?: (cardId: string) => void;
|
|
18
28
|
onChangeColor?: (cardId: string, color: string) => void;
|
|
19
29
|
onChangePriority?: (cardId: string, priority: 'low' | 'medium' | 'high' | 'critical') => void;
|
|
20
30
|
onAnchorDragStart?: (cardId: string, anchor: string, x: number, y: number) => void;
|
|
31
|
+
onCardContextMenu?: (cardId: string, pos: {
|
|
32
|
+
x: number;
|
|
33
|
+
y: number;
|
|
34
|
+
}) => void;
|
|
21
35
|
}
|
|
22
36
|
export declare function Card(props: CardProps): import("specifyjs").SpecElement<import("specifyjs").Props>;
|
|
@@ -28,8 +28,15 @@ export interface CardConnection {
|
|
|
28
28
|
style?: 'solid' | 'dashed' | 'dotted';
|
|
29
29
|
}
|
|
30
30
|
export interface BoardState {
|
|
31
|
+
/** Board UUID (v4) — unique identifier for this board instance */
|
|
32
|
+
id: string;
|
|
33
|
+
/** User-assigned board name (default: "Untitled") */
|
|
34
|
+
name: string;
|
|
35
|
+
/** Board contents — cards placed on the whiteboard */
|
|
31
36
|
cards: ProjectCard[];
|
|
37
|
+
/** Connections between cards */
|
|
32
38
|
connections: CardConnection[];
|
|
39
|
+
/** Viewport configuration */
|
|
33
40
|
viewport: {
|
|
34
41
|
panX: number;
|
|
35
42
|
panY: number;
|