@wireweave/ux-rules 1.0.0

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,187 @@
1
+ import { AnyNode, WireframeDocument } from '@wireweave/core';
2
+
3
+ /**
4
+ * UX Rules Type Definitions
5
+ *
6
+ * Types for UX validation rules engine.
7
+ */
8
+
9
+ /**
10
+ * Severity level of UX issues
11
+ */
12
+ type UXIssueSeverity = 'error' | 'warning' | 'info';
13
+ /**
14
+ * Category of UX rule
15
+ */
16
+ type UXRuleCategory = 'accessibility' | 'usability' | 'consistency' | 'touch-target' | 'contrast' | 'navigation' | 'form' | 'feedback';
17
+ /**
18
+ * UX validation issue
19
+ */
20
+ interface UXIssue {
21
+ /** Unique rule ID */
22
+ ruleId: string;
23
+ /** Rule category */
24
+ category: UXRuleCategory;
25
+ /** Issue severity */
26
+ severity: UXIssueSeverity;
27
+ /** Human-readable message */
28
+ message: string;
29
+ /** Detailed description of the issue */
30
+ description: string;
31
+ /** How to fix the issue */
32
+ suggestion: string;
33
+ /** Path to the problematic node */
34
+ path: string;
35
+ /** Node type where issue occurred */
36
+ nodeType: string;
37
+ /** Source location (if available) */
38
+ location?: {
39
+ line: number;
40
+ column: number;
41
+ };
42
+ }
43
+ /**
44
+ * UX validation result
45
+ */
46
+ interface UXValidationResult {
47
+ /** Whether all checks passed (no errors) */
48
+ valid: boolean;
49
+ /** Total score (0-100) */
50
+ score: number;
51
+ /** Issues found */
52
+ issues: UXIssue[];
53
+ /** Summary by category */
54
+ summary: {
55
+ category: UXRuleCategory;
56
+ passed: number;
57
+ failed: number;
58
+ warnings: number;
59
+ }[];
60
+ /** Summary by severity */
61
+ severityCounts: {
62
+ errors: number;
63
+ warnings: number;
64
+ info: number;
65
+ };
66
+ }
67
+ /**
68
+ * UX rule definition
69
+ */
70
+ interface UXRule {
71
+ /** Unique rule ID */
72
+ id: string;
73
+ /** Rule category */
74
+ category: UXRuleCategory;
75
+ /** Default severity */
76
+ severity: UXIssueSeverity;
77
+ /** Rule name */
78
+ name: string;
79
+ /** Rule description */
80
+ description: string;
81
+ /** Component types this rule applies to (empty = all) */
82
+ appliesTo: string[];
83
+ /** Check function */
84
+ check: (node: AnyNode, context: UXRuleContext) => UXIssue | UXIssue[] | null;
85
+ }
86
+ /**
87
+ * Context provided to rule check functions
88
+ */
89
+ interface UXRuleContext {
90
+ /** Path to current node */
91
+ path: string;
92
+ /** Parent node (if any) */
93
+ parent: AnyNode | null;
94
+ /** Root document */
95
+ root: AnyNode;
96
+ /** All siblings of current node */
97
+ siblings: AnyNode[];
98
+ /** Index in parent's children */
99
+ index: number;
100
+ /** Depth in tree */
101
+ depth: number;
102
+ }
103
+ /**
104
+ * UX validation options
105
+ */
106
+ interface UXValidationOptions {
107
+ /** Categories to check (empty = all) */
108
+ categories?: UXRuleCategory[];
109
+ /** Minimum severity to report */
110
+ minSeverity?: UXIssueSeverity;
111
+ /** Maximum issues to collect */
112
+ maxIssues?: number;
113
+ /** Custom rules to add */
114
+ customRules?: UXRule[];
115
+ /** Rules to disable by ID */
116
+ disabledRules?: string[];
117
+ }
118
+
119
+ /**
120
+ * UX Rules Index
121
+ *
122
+ * Exports all UX rules organized by category.
123
+ */
124
+
125
+ /**
126
+ * All built-in UX rules
127
+ */
128
+ declare const allRules: UXRule[];
129
+ /**
130
+ * Rules organized by category
131
+ */
132
+ declare const rulesByCategory: {
133
+ accessibility: UXRule[];
134
+ form: UXRule[];
135
+ 'touch-target': UXRule[];
136
+ consistency: UXRule[];
137
+ usability: UXRule[];
138
+ navigation: UXRule[];
139
+ };
140
+ /**
141
+ * Get rules for specific categories
142
+ */
143
+ declare function getRulesForCategories(categories: string[]): UXRule[];
144
+
145
+ /**
146
+ * UX Rules Validation Engine
147
+ *
148
+ * Validates wireframe AST against UX best practices.
149
+ * Provides actionable feedback for improving user experience.
150
+ */
151
+
152
+ /**
153
+ * Validate a wireframe document against UX rules
154
+ *
155
+ * @param ast - The parsed AST document
156
+ * @param options - Validation options
157
+ * @returns Validation result with issues and score
158
+ */
159
+ declare function validateUX(ast: WireframeDocument, options?: UXValidationOptions): UXValidationResult;
160
+ /**
161
+ * Quick UX validation - returns true if no errors
162
+ *
163
+ * @param ast - The parsed AST document
164
+ * @returns true if no UX errors found
165
+ */
166
+ declare function isUXValid(ast: WireframeDocument): boolean;
167
+ /**
168
+ * Get UX issues from an AST
169
+ *
170
+ * @param ast - The parsed AST document
171
+ * @param options - Validation options
172
+ * @returns Array of UX issues
173
+ */
174
+ declare function getUXIssues(ast: WireframeDocument, options?: UXValidationOptions): UXIssue[];
175
+ /**
176
+ * Get UX score for a wireframe (0-100)
177
+ *
178
+ * @param ast - The parsed AST document
179
+ * @returns UX score from 0 to 100
180
+ */
181
+ declare function getUXScore(ast: WireframeDocument): number;
182
+ /**
183
+ * Format UX validation result as human-readable string
184
+ */
185
+ declare function formatUXResult(result: UXValidationResult): string;
186
+
187
+ export { type UXIssue, type UXIssueSeverity, type UXRule, type UXRuleCategory, type UXRuleContext, type UXValidationOptions, type UXValidationResult, allRules, formatUXResult, getRulesForCategories, getUXIssues, getUXScore, isUXValid, rulesByCategory, validateUX };
@@ -0,0 +1,187 @@
1
+ import { AnyNode, WireframeDocument } from '@wireweave/core';
2
+
3
+ /**
4
+ * UX Rules Type Definitions
5
+ *
6
+ * Types for UX validation rules engine.
7
+ */
8
+
9
+ /**
10
+ * Severity level of UX issues
11
+ */
12
+ type UXIssueSeverity = 'error' | 'warning' | 'info';
13
+ /**
14
+ * Category of UX rule
15
+ */
16
+ type UXRuleCategory = 'accessibility' | 'usability' | 'consistency' | 'touch-target' | 'contrast' | 'navigation' | 'form' | 'feedback';
17
+ /**
18
+ * UX validation issue
19
+ */
20
+ interface UXIssue {
21
+ /** Unique rule ID */
22
+ ruleId: string;
23
+ /** Rule category */
24
+ category: UXRuleCategory;
25
+ /** Issue severity */
26
+ severity: UXIssueSeverity;
27
+ /** Human-readable message */
28
+ message: string;
29
+ /** Detailed description of the issue */
30
+ description: string;
31
+ /** How to fix the issue */
32
+ suggestion: string;
33
+ /** Path to the problematic node */
34
+ path: string;
35
+ /** Node type where issue occurred */
36
+ nodeType: string;
37
+ /** Source location (if available) */
38
+ location?: {
39
+ line: number;
40
+ column: number;
41
+ };
42
+ }
43
+ /**
44
+ * UX validation result
45
+ */
46
+ interface UXValidationResult {
47
+ /** Whether all checks passed (no errors) */
48
+ valid: boolean;
49
+ /** Total score (0-100) */
50
+ score: number;
51
+ /** Issues found */
52
+ issues: UXIssue[];
53
+ /** Summary by category */
54
+ summary: {
55
+ category: UXRuleCategory;
56
+ passed: number;
57
+ failed: number;
58
+ warnings: number;
59
+ }[];
60
+ /** Summary by severity */
61
+ severityCounts: {
62
+ errors: number;
63
+ warnings: number;
64
+ info: number;
65
+ };
66
+ }
67
+ /**
68
+ * UX rule definition
69
+ */
70
+ interface UXRule {
71
+ /** Unique rule ID */
72
+ id: string;
73
+ /** Rule category */
74
+ category: UXRuleCategory;
75
+ /** Default severity */
76
+ severity: UXIssueSeverity;
77
+ /** Rule name */
78
+ name: string;
79
+ /** Rule description */
80
+ description: string;
81
+ /** Component types this rule applies to (empty = all) */
82
+ appliesTo: string[];
83
+ /** Check function */
84
+ check: (node: AnyNode, context: UXRuleContext) => UXIssue | UXIssue[] | null;
85
+ }
86
+ /**
87
+ * Context provided to rule check functions
88
+ */
89
+ interface UXRuleContext {
90
+ /** Path to current node */
91
+ path: string;
92
+ /** Parent node (if any) */
93
+ parent: AnyNode | null;
94
+ /** Root document */
95
+ root: AnyNode;
96
+ /** All siblings of current node */
97
+ siblings: AnyNode[];
98
+ /** Index in parent's children */
99
+ index: number;
100
+ /** Depth in tree */
101
+ depth: number;
102
+ }
103
+ /**
104
+ * UX validation options
105
+ */
106
+ interface UXValidationOptions {
107
+ /** Categories to check (empty = all) */
108
+ categories?: UXRuleCategory[];
109
+ /** Minimum severity to report */
110
+ minSeverity?: UXIssueSeverity;
111
+ /** Maximum issues to collect */
112
+ maxIssues?: number;
113
+ /** Custom rules to add */
114
+ customRules?: UXRule[];
115
+ /** Rules to disable by ID */
116
+ disabledRules?: string[];
117
+ }
118
+
119
+ /**
120
+ * UX Rules Index
121
+ *
122
+ * Exports all UX rules organized by category.
123
+ */
124
+
125
+ /**
126
+ * All built-in UX rules
127
+ */
128
+ declare const allRules: UXRule[];
129
+ /**
130
+ * Rules organized by category
131
+ */
132
+ declare const rulesByCategory: {
133
+ accessibility: UXRule[];
134
+ form: UXRule[];
135
+ 'touch-target': UXRule[];
136
+ consistency: UXRule[];
137
+ usability: UXRule[];
138
+ navigation: UXRule[];
139
+ };
140
+ /**
141
+ * Get rules for specific categories
142
+ */
143
+ declare function getRulesForCategories(categories: string[]): UXRule[];
144
+
145
+ /**
146
+ * UX Rules Validation Engine
147
+ *
148
+ * Validates wireframe AST against UX best practices.
149
+ * Provides actionable feedback for improving user experience.
150
+ */
151
+
152
+ /**
153
+ * Validate a wireframe document against UX rules
154
+ *
155
+ * @param ast - The parsed AST document
156
+ * @param options - Validation options
157
+ * @returns Validation result with issues and score
158
+ */
159
+ declare function validateUX(ast: WireframeDocument, options?: UXValidationOptions): UXValidationResult;
160
+ /**
161
+ * Quick UX validation - returns true if no errors
162
+ *
163
+ * @param ast - The parsed AST document
164
+ * @returns true if no UX errors found
165
+ */
166
+ declare function isUXValid(ast: WireframeDocument): boolean;
167
+ /**
168
+ * Get UX issues from an AST
169
+ *
170
+ * @param ast - The parsed AST document
171
+ * @param options - Validation options
172
+ * @returns Array of UX issues
173
+ */
174
+ declare function getUXIssues(ast: WireframeDocument, options?: UXValidationOptions): UXIssue[];
175
+ /**
176
+ * Get UX score for a wireframe (0-100)
177
+ *
178
+ * @param ast - The parsed AST document
179
+ * @returns UX score from 0 to 100
180
+ */
181
+ declare function getUXScore(ast: WireframeDocument): number;
182
+ /**
183
+ * Format UX validation result as human-readable string
184
+ */
185
+ declare function formatUXResult(result: UXValidationResult): string;
186
+
187
+ export { type UXIssue, type UXIssueSeverity, type UXRule, type UXRuleCategory, type UXRuleContext, type UXValidationOptions, type UXValidationResult, allRules, formatUXResult, getRulesForCategories, getUXIssues, getUXScore, isUXValid, rulesByCategory, validateUX };