@asymmetric-effort/specifyjs 0.2.143 → 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.
@@ -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;
@@ -0,0 +1,34 @@
1
+ import type { ProjectCard } from './types';
2
+ import type { BoardState } from './types';
3
+ import type { BoardAction } from './BoardState';
4
+ export interface BoardProps {
5
+ state: BoardState;
6
+ dispatch: (action: BoardAction) => void;
7
+ searchQuery: string;
8
+ gridEnabled: boolean;
9
+ selectedCardId: string | null;
10
+ onSelectCard: (cardId: string | null) => void;
11
+ colorFilter?: string | null;
12
+ showConnections?: boolean;
13
+ }
14
+ export declare function snapToGrid(pos: {
15
+ x: number;
16
+ y: number;
17
+ }, gridSize: number): {
18
+ x: number;
19
+ y: number;
20
+ };
21
+ export declare function screenToCanvas(screenX: number, screenY: number, viewport: {
22
+ panX: number;
23
+ panY: number;
24
+ zoom: number;
25
+ }): {
26
+ x: number;
27
+ y: number;
28
+ };
29
+ export declare function computeFitAll(cards: ProjectCard[], containerWidth: number, containerHeight: number, padding?: number): {
30
+ panX: number;
31
+ panY: number;
32
+ zoom: number;
33
+ };
34
+ export declare function Board(props: BoardProps): import("specifyjs").SpecElement<import("specifyjs").Props>;
@@ -0,0 +1,76 @@
1
+ import type { BoardState, BoardStorage, ProjectCard, CardConnection } from './types';
2
+ export type BoardAction = {
3
+ type: 'ADD_CARD';
4
+ card: ProjectCard;
5
+ } | {
6
+ type: 'REMOVE_CARD';
7
+ cardId: string;
8
+ } | {
9
+ type: 'MOVE_CARD';
10
+ cardId: string;
11
+ position: {
12
+ x: number;
13
+ y: number;
14
+ };
15
+ } | {
16
+ type: 'RESIZE_CARD';
17
+ cardId: string;
18
+ size: {
19
+ width: number;
20
+ height: number;
21
+ };
22
+ } | {
23
+ type: 'UPDATE_CARD';
24
+ cardId: string;
25
+ updates: Partial<ProjectCard>;
26
+ } | {
27
+ type: 'DUPLICATE_CARD';
28
+ cardId: string;
29
+ newId: string;
30
+ offset?: {
31
+ x: number;
32
+ y: number;
33
+ };
34
+ } | {
35
+ type: 'ADD_CONNECTION';
36
+ connection: CardConnection;
37
+ } | {
38
+ type: 'REMOVE_CONNECTION';
39
+ connectionId: string;
40
+ } | {
41
+ type: 'PAN';
42
+ panX: number;
43
+ panY: number;
44
+ } | {
45
+ type: 'ZOOM';
46
+ zoom: number;
47
+ } | {
48
+ type: 'SET_BOARD';
49
+ state: BoardState;
50
+ };
51
+ export interface HistoryState {
52
+ past: BoardState[];
53
+ present: BoardState;
54
+ future: BoardState[];
55
+ }
56
+ export declare const DEFAULT_BOARD_STATE: BoardState;
57
+ export declare function boardReducer(state: BoardState, action: BoardAction): BoardState;
58
+ type HistoryAction = {
59
+ type: 'UNDO';
60
+ } | {
61
+ type: 'REDO';
62
+ } | {
63
+ type: 'BOARD_ACTION';
64
+ action: BoardAction;
65
+ };
66
+ export declare function historyReducer(state: HistoryState, action: HistoryAction): HistoryState;
67
+ export interface UseBoardStateResult {
68
+ state: BoardState;
69
+ dispatch: (action: BoardAction) => void;
70
+ undo: () => void;
71
+ redo: () => void;
72
+ canUndo: boolean;
73
+ canRedo: boolean;
74
+ }
75
+ export declare function useBoardState(storage?: BoardStorage, boardId?: string): UseBoardStateResult;
76
+ export {};
@@ -0,0 +1,36 @@
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
+ }>;
8
+ export interface CardProps {
9
+ card: ProjectCard;
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
+ onDoubleClick: (cardId: string) => void;
22
+ onUpdate?: (cardId: string, updates: {
23
+ title?: string;
24
+ description?: string;
25
+ }) => void;
26
+ onDragStart?: (cardId: string, e: Event) => void;
27
+ onDuplicate?: (cardId: string) => void;
28
+ onChangeColor?: (cardId: string, color: string) => void;
29
+ onChangePriority?: (cardId: string, priority: 'low' | 'medium' | 'high' | 'critical') => void;
30
+ onAnchorDragStart?: (cardId: string, anchor: string, x: number, y: number) => void;
31
+ onCardContextMenu?: (cardId: string, pos: {
32
+ x: number;
33
+ y: number;
34
+ }) => void;
35
+ }
36
+ export declare function Card(props: CardProps): import("specifyjs").SpecElement<import("specifyjs").Props>;
@@ -0,0 +1,10 @@
1
+ import type { ProjectCard } from './types';
2
+ export interface CardEditorProps {
3
+ card: ProjectCard;
4
+ onSave: (cardId: string, updates: {
5
+ title: string;
6
+ description: string;
7
+ }) => void;
8
+ onClose: () => void;
9
+ }
10
+ export declare function CardEditor(props: CardEditorProps): import("specifyjs").SpecElement<import("specifyjs").Props>;
@@ -0,0 +1,11 @@
1
+ import type { ProjectCard, CardConnection } from './types';
2
+ export interface ConnectionsOverlayProps {
3
+ connections: CardConnection[];
4
+ cards: ProjectCard[];
5
+ selectedConnectionId: string | null;
6
+ onSelectConnection: (connectionId: string | null) => void;
7
+ onDeleteConnection: (connectionId: string) => void;
8
+ canvasWidth: number;
9
+ canvasHeight: number;
10
+ }
11
+ export declare function ConnectionsOverlay(props: ConnectionsOverlayProps): import("specifyjs").SpecElement<import("specifyjs").Props>;
@@ -0,0 +1,7 @@
1
+ import type { ProjectCard } from './types';
2
+ export interface InterAppWrapperProps {
3
+ cards: ProjectCard[];
4
+ onCardDropped: (title: string, description: string) => void;
5
+ children: unknown;
6
+ }
7
+ export declare function InterAppWrapper(props: InterAppWrapperProps): import("specifyjs").SpecElement<import("specifyjs").Props>;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * LocalStorage.ts -- localStorage persistence implementation for BoardStorage.
3
+ */
4
+ import type { BoardState, BoardStorage } from './types';
5
+ export declare class LocalBoardStorage implements BoardStorage {
6
+ load(boardId: string): Promise<BoardState>;
7
+ save(boardId: string, state: BoardState): Promise<void>;
8
+ }
@@ -0,0 +1,16 @@
1
+ export declare const CARD_COLORS: string[];
2
+ export interface ToolbarProps {
3
+ zoom: number;
4
+ gridEnabled: boolean;
5
+ selectedColor: string;
6
+ colorFilter?: string | null;
7
+ onNewCard: () => void;
8
+ onZoomIn: () => void;
9
+ onZoomOut: () => void;
10
+ onZoomReset: () => void;
11
+ onColorSelect: (color: string) => void;
12
+ onColorFilter?: (color: string | null) => void;
13
+ onGridToggle: () => void;
14
+ onSearch: (query: string) => void;
15
+ }
16
+ export declare function BoardToolbar(props: ToolbarProps): import("specifyjs").SpecElement<import("specifyjs").Props>;
@@ -0,0 +1,14 @@
1
+ export type { ProjectCard, CardConnection, BoardState, BoardStorage } from './types';
2
+ export { useBoardState, boardReducer, historyReducer, DEFAULT_BOARD_STATE } from './BoardState';
3
+ export type { BoardAction, HistoryState, UseBoardStateResult } from './BoardState';
4
+ export { LocalBoardStorage } from './LocalStorage';
5
+ export { Card } from './Card';
6
+ export { CardEditor } from './CardEditor';
7
+ export { ConnectionsOverlay } from './Connection';
8
+ export { BoardToolbar, CARD_COLORS } from './Toolbar';
9
+ export { Board, snapToGrid, screenToCanvas, computeFitAll } from './Board';
10
+ export { InterAppWrapper } from './InterApp';
11
+ export interface ProjectManagerAppProps {
12
+ boardId?: string;
13
+ }
14
+ export declare function ProjectManagerApp(props: ProjectManagerAppProps): import("specifyjs").SpecElement<import("specifyjs").Props>;
@@ -0,0 +1,49 @@
1
+ /**
2
+ * types.ts -- Interfaces for the Whiteboard Project Manager.
3
+ */
4
+ export interface ProjectCard {
5
+ id: string;
6
+ title: string;
7
+ description: string;
8
+ color: string;
9
+ position: {
10
+ x: number;
11
+ y: number;
12
+ };
13
+ size: {
14
+ width: number;
15
+ height: number;
16
+ };
17
+ tags?: string[];
18
+ priority?: 'low' | 'medium' | 'high' | 'critical';
19
+ assignee?: string;
20
+ createdAt: number;
21
+ updatedAt: number;
22
+ }
23
+ export interface CardConnection {
24
+ id: string;
25
+ fromCardId: string;
26
+ toCardId: string;
27
+ label?: string;
28
+ style?: 'solid' | 'dashed' | 'dotted';
29
+ }
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 */
36
+ cards: ProjectCard[];
37
+ /** Connections between cards */
38
+ connections: CardConnection[];
39
+ /** Viewport configuration */
40
+ viewport: {
41
+ panX: number;
42
+ panY: number;
43
+ zoom: number;
44
+ };
45
+ }
46
+ export interface BoardStorage {
47
+ load(boardId: string): Promise<BoardState>;
48
+ save(boardId: string, state: BoardState): Promise<void>;
49
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asymmetric-effort/specifyjs",
3
- "version": "0.2.143",
3
+ "version": "0.2.150",
4
4
  "description": "A declarative TypeScript UI framework built for performance and simplicity",
5
5
  "publishConfig": {
6
6
  "access": "public"