@asymmetric-effort/specifyjs 0.2.145 → 0.2.151

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;
@@ -1,33 +1,14 @@
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
- }
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 computeFitAll(cards: ProjectCard[], containerWidth: number, containerHeight: number, padding?: number): {
1
+ /**
2
+ * Board.ts -- Thin wrapper around the reusable Board component.
3
+ * Re-exports the Board and its helpers from the library.
4
+ * Keeps demo-specific helpers (computeFitAll) locally.
5
+ */
6
+ import type { BoardItem } from './types';
7
+ export { Board } from '../../../components/data/board/src/Board';
8
+ export { snapToGrid, screenToCanvas } from '../../../components/data/board/src/Board';
9
+ export type { BoardProps } from '../../../components/data/board/src/Board';
10
+ export declare function computeFitAll(collection: BoardItem[], containerWidth: number, containerHeight: number, padding?: number): {
29
11
  panX: number;
30
12
  panY: number;
31
13
  zoom: number;
32
14
  };
33
- export declare function Board(props: BoardProps): import("specifyjs").SpecElement<import("specifyjs").Props>;
@@ -1,76 +1,5 @@
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 {};
1
+ import type { BoardStorage } from './types';
2
+ export type { BoardAction, HistoryState, UseBoardReducerResult } from '../../../components/data/board/src/BoardReducer';
3
+ export { boardReducer, historyReducer, useBoardReducer, DEFAULT_BOARD_STATE } from '../../../components/data/board/src/BoardReducer';
4
+ export type UseBoardStateResult = import('../../../components/data/board/src/BoardReducer').UseBoardReducerResult;
5
+ export declare function useBoardState(storage?: BoardStorage, boardId?: string): import('../../../components/data/board/src/BoardReducer').UseBoardReducerResult;
@@ -1,22 +1,11 @@
1
- import type { ProjectCard } from './types';
2
- export interface CardProps {
3
- card: ProjectCard;
4
- selected: boolean;
5
- onSelect: (cardId: string) => void;
6
- onMove: (cardId: string, position: {
7
- x: number;
8
- y: number;
9
- }) => void;
10
- onResize: (cardId: string, size: {
11
- width: number;
12
- height: number;
13
- }) => void;
14
- onDelete: (cardId: string) => void;
15
- onDoubleClick: (cardId: string) => void;
16
- onDragStart?: (cardId: string, e: Event) => void;
17
- onDuplicate?: (cardId: string) => void;
18
- onChangeColor?: (cardId: string, color: string) => void;
19
- onChangePriority?: (cardId: string, priority: 'low' | 'medium' | 'high' | 'critical') => void;
20
- onAnchorDragStart?: (cardId: string, anchor: string, x: number, y: number) => void;
21
- }
22
- export declare function Card(props: CardProps): import("specifyjs").SpecElement<import("specifyjs").Props>;
1
+ /**
2
+ * Card.ts -- Re-exports the CardComponent from the reusable Board library.
3
+ * Keeps demo-specific constants (context menu colors, priority options).
4
+ */
5
+ export { CardComponent as Card, PRIORITY_COLORS, CARD_TYPE_OPTIONS } from '../../../components/data/board/src/Card';
6
+ export type { CardComponentProps as CardProps } from '../../../components/data/board/src/Card';
7
+ export declare const CONTEXT_MENU_COLORS: string[];
8
+ export declare const PRIORITY_OPTIONS: Array<{
9
+ label: string;
10
+ value: 'low' | 'medium' | 'high' | 'critical';
11
+ }>;
@@ -1,6 +1,6 @@
1
- import type { ProjectCard } from './types';
1
+ import type { Card } from './types';
2
2
  export interface CardEditorProps {
3
- card: ProjectCard;
3
+ card: Card;
4
4
  onSave: (cardId: string, updates: {
5
5
  title: string;
6
6
  description: string;
@@ -1,11 +1,6 @@
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>;
1
+ /**
2
+ * Connection.ts -- Re-exports the CardLinkOverlay from the reusable Board library.
3
+ * The old ConnectionsOverlay is replaced by CardLinkOverlay.
4
+ */
5
+ export { CardLinkOverlay as ConnectionsOverlay } from '../../../components/data/board/src/CardLink';
6
+ export type { CardLinkOverlayProps as ConnectionsOverlayProps } from '../../../components/data/board/src/CardLink';
@@ -1,6 +1,6 @@
1
- import type { ProjectCard } from './types';
1
+ import type { BoardItem } from './types';
2
2
  export interface InterAppWrapperProps {
3
- cards: ProjectCard[];
3
+ collection: BoardItem[];
4
4
  onCardDropped: (title: string, description: string) => void;
5
5
  children: unknown;
6
6
  }
@@ -1,8 +1,9 @@
1
- export type { ProjectCard, CardConnection, BoardState, BoardStorage } from './types';
1
+ export type { Card, CardLink, BoardState, BoardItem } from './types';
2
+ export type { BoardStorage } from './types';
2
3
  export { useBoardState, boardReducer, historyReducer, DEFAULT_BOARD_STATE } from './BoardState';
3
4
  export type { BoardAction, HistoryState, UseBoardStateResult } from './BoardState';
4
5
  export { LocalBoardStorage } from './LocalStorage';
5
- export { Card } from './Card';
6
+ export { Card as CardComponent } from './Card';
6
7
  export { CardEditor } from './CardEditor';
7
8
  export { ConnectionsOverlay } from './Connection';
8
9
  export { BoardToolbar, CARD_COLORS } from './Toolbar';
@@ -1,42 +1,10 @@
1
1
  /**
2
- * types.ts -- Interfaces for the Whiteboard Project Manager.
2
+ * types.ts -- Re-exports types from the reusable Board component library.
3
+ * Keeps demo-specific interfaces (BoardStorage) locally.
3
4
  */
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
- cards: ProjectCard[];
32
- connections: CardConnection[];
33
- viewport: {
34
- panX: number;
35
- panY: number;
36
- zoom: number;
37
- };
38
- }
5
+ export type { BoardState, BoardItem, Card, Container, CardLink, CardType, TextContent, JsonContent, TaskContent, ProjectContent, } from '../../../components/data/board/src/types';
6
+ export { isCard, isContainer, generateUUID, getItemId, getItemName, } from '../../../components/data/board/src/types';
39
7
  export interface BoardStorage {
40
- load(boardId: string): Promise<BoardState>;
41
- save(boardId: string, state: BoardState): Promise<void>;
8
+ load(boardId: string): Promise<import('../../../components/data/board/src/types').BoardState>;
9
+ save(boardId: string, state: import('../../../components/data/board/src/types').BoardState): Promise<void>;
42
10
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asymmetric-effort/specifyjs",
3
- "version": "0.2.145",
3
+ "version": "0.2.151",
4
4
  "description": "A declarative TypeScript UI framework built for performance and simplicity",
5
5
  "publishConfig": {
6
6
  "access": "public"