@aiready/components 0.13.1 → 0.13.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiready/components",
3
- "version": "0.13.1",
3
+ "version": "0.13.3",
4
4
  "description": "Unified shared components library (UI, charts, hooks, utilities) for AIReady",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -65,7 +65,7 @@
65
65
  "framer-motion": "^12.35.0",
66
66
  "lucide-react": "^0.577.0",
67
67
  "tailwind-merge": "^3.0.0",
68
- "@aiready/core": "0.23.1"
68
+ "@aiready/core": "0.23.3"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@testing-library/jest-dom": "^6.6.5",
@@ -11,30 +11,8 @@ import { cn } from '../utils/cn';
11
11
  import NodeItem from './NodeItem';
12
12
  import LinkItem from './LinkItem';
13
13
 
14
- export interface GraphNode {
15
- id: string;
16
- label?: string;
17
- color?: string;
18
- size?: number;
19
- group?: string;
20
- kind?: 'file' | 'package';
21
- packageGroup?: string;
22
- x?: number;
23
- y?: number;
24
- fx?: number | null;
25
- fy?: number | null;
26
- }
27
-
28
- export interface GraphLink {
29
- source: string | GraphNode;
30
- target: string | GraphNode;
31
- color?: string;
32
- width?: number;
33
- label?: string;
34
- type?: string;
35
- }
36
-
37
- export type LayoutType = 'force' | 'hierarchical' | 'circular';
14
+ import { GraphNode, GraphLink, LayoutType } from './types';
15
+ export type { GraphNode, GraphLink, LayoutType };
38
16
 
39
17
  export interface ForceDirectedGraphHandle {
40
18
  pinAll: () => void;
@@ -42,6 +20,10 @@ export interface ForceDirectedGraphHandle {
42
20
  resetLayout: () => void;
43
21
  fitView: () => void;
44
22
  getPinnedNodes: () => string[];
23
+ /**
24
+ * Enable or disable drag mode for nodes.
25
+ * @param enabled - When true, nodes can be dragged; when false, dragging is disabled
26
+ */
45
27
  setDragMode: (enabled: boolean) => void;
46
28
  setLayout: (layout: LayoutType) => void;
47
29
  getLayout: () => LayoutType;
@@ -67,6 +49,10 @@ export interface ForceDirectedGraphProps {
67
49
  showLinkLabels?: boolean;
68
50
  className?: string;
69
51
  manualLayout?: boolean;
52
+ /**
53
+ * Callback fired when manual layout mode changes.
54
+ * @param enabled - True when manual layout mode is enabled, false when disabled
55
+ */
70
56
  onManualLayoutChange?: (enabled: boolean) => void;
71
57
  packageBounds?: Record<string, { x: number; y: number; r: number }>;
72
58
  layout?: LayoutType;
@@ -9,6 +9,7 @@ export interface GraphControlsProps {
9
9
 
10
10
  /**
11
11
  * Callback to toggle drag mode
12
+ * @param enabled - True when drag mode should be enabled, false when disabled
12
13
  */
13
14
  onDragToggle?: (enabled: boolean) => void;
14
15
 
@@ -19,6 +20,7 @@ export interface GraphControlsProps {
19
20
 
20
21
  /**
21
22
  * Callback to toggle manual layout mode
23
+ * @param enabled - True when manual layout should be enabled, false when disabled
22
24
  */
23
25
  onManualLayoutToggle?: (enabled: boolean) => void;
24
26
 
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import type { GraphLink, GraphNode } from './ForceDirectedGraph';
2
+ import type { GraphLink, GraphNode } from './types';
3
3
 
4
4
  export interface LinkItemProps {
5
5
  link: GraphLink;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import type { GraphNode } from './ForceDirectedGraph';
2
+ import type { GraphNode } from './types';
3
3
 
4
4
  export interface NodeItemProps {
5
5
  node: GraphNode;
@@ -0,0 +1,24 @@
1
+ export interface GraphNode {
2
+ id: string;
3
+ label?: string;
4
+ color?: string;
5
+ size?: number;
6
+ group?: string;
7
+ kind?: 'file' | 'package';
8
+ packageGroup?: string;
9
+ x?: number;
10
+ y?: number;
11
+ fx?: number | null;
12
+ fy?: number | null;
13
+ }
14
+
15
+ export interface GraphLink {
16
+ source: string | GraphNode;
17
+ target: string | GraphNode;
18
+ color?: string;
19
+ width?: number;
20
+ label?: string;
21
+ type?: string;
22
+ }
23
+
24
+ export type LayoutType = 'force' | 'hierarchical' | 'circular';
@@ -1,11 +1,8 @@
1
1
  import * as React from 'react';
2
2
  import { cn } from '../utils/cn';
3
+ import { ComponentOption } from '../types';
3
4
 
4
- export interface RadioOption {
5
- value: string;
6
- label: string;
7
- disabled?: boolean;
8
- }
5
+ export type RadioOption = ComponentOption;
9
6
 
10
7
  export interface RadioGroupProps extends Omit<
11
8
  React.HTMLAttributes<HTMLDivElement>,
@@ -1,11 +1,8 @@
1
1
  import * as React from 'react';
2
2
  import { cn } from '../utils/cn';
3
+ import { ComponentOption } from '../types';
3
4
 
4
- export interface SelectOption {
5
- value: string;
6
- label: string;
7
- disabled?: boolean;
8
- }
5
+ export type SelectOption = ComponentOption;
9
6
 
10
7
  export interface SelectProps extends Omit<
11
8
  React.SelectHTMLAttributes<HTMLSelectElement>,
@@ -223,6 +223,11 @@ export function useForceSimulation(
223
223
  initialLinks: SimulationLink[],
224
224
  options: ForceSimulationOptions
225
225
  ): UseForceSimulationReturn & { setForcesEnabled: (enabled: boolean) => void } {
226
+ /**
227
+ * Enable or disable the simulation forces (charge and link forces).
228
+ * When disabled, nodes can still be dragged but won't be affected by forces.
229
+ * @param enabled - When true, simulation forces are active; when false, forces are disabled
230
+ */
226
231
  const {
227
232
  chargeStrength = -300,
228
233
  linkDistance = 100,
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Shared types for UI components
3
+ */
4
+
5
+ export interface ComponentOption {
6
+ value: string;
7
+ label: string;
8
+ disabled?: boolean;
9
+ }
@@ -1,11 +1,5 @@
1
1
  import { describe, it, expect } from 'vitest';
2
- import {
3
- scoreColor,
4
- scoreBg,
5
- scoreLabel,
6
- scoreGlow,
7
- getScoreRating,
8
- } from '../score';
2
+ import { scoreColor, scoreBg, scoreLabel, getScoreRating } from '../score';
9
3
 
10
4
  describe('Score Utilities', () => {
11
5
  it('should return correct color for scores', () => {
@@ -43,6 +43,8 @@ export function scoreGlow(score: number | null | undefined): string {
43
43
  return 'shadow-red-500/20';
44
44
  }
45
45
 
46
+ import { getRatingSlug } from '@aiready/core/client';
47
+
46
48
  /**
47
49
  * Get rating from score (for use with ScoreBar component)
48
50
  */
@@ -50,9 +52,6 @@ export function getScoreRating(
50
52
  score: number | null | undefined
51
53
  ): 'excellent' | 'good' | 'fair' | 'needs-work' | 'critical' {
52
54
  if (score == null) return 'critical';
53
- if (score >= 90) return 'excellent';
54
- if (score >= 75) return 'good';
55
- if (score >= 60) return 'fair';
56
- if (score >= 40) return 'needs-work';
57
- return 'critical';
55
+ // Use core implementation to resolve duplication
56
+ return getRatingSlug(score) as any;
58
57
  }