@shohojdhara/atomix 0.4.8 → 0.4.9

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.
Files changed (165) hide show
  1. package/atomix.config.ts +58 -1
  2. package/dist/atomix.css +148 -120
  3. package/dist/atomix.css.map +1 -1
  4. package/dist/atomix.min.css +1 -1
  5. package/dist/atomix.min.css.map +1 -1
  6. package/dist/charts.d.ts +33 -0
  7. package/dist/charts.js +1227 -122
  8. package/dist/charts.js.map +1 -1
  9. package/dist/core.d.ts +33 -10
  10. package/dist/core.js +1052 -41
  11. package/dist/core.js.map +1 -1
  12. package/dist/forms.d.ts +33 -0
  13. package/dist/forms.js +2086 -1035
  14. package/dist/forms.js.map +1 -1
  15. package/dist/heavy.d.ts +42 -1
  16. package/dist/heavy.js +1620 -600
  17. package/dist/heavy.js.map +1 -1
  18. package/dist/index.d.ts +441 -270
  19. package/dist/index.esm.js +1900 -638
  20. package/dist/index.esm.js.map +1 -1
  21. package/dist/index.js +1935 -670
  22. package/dist/index.js.map +1 -1
  23. package/dist/index.min.js +1 -1
  24. package/dist/index.min.js.map +1 -1
  25. package/package.json +6 -3
  26. package/scripts/atomix-cli.js +148 -4
  27. package/scripts/cli/__tests__/basic.test.js +3 -2
  28. package/scripts/cli/__tests__/clean.test.js +278 -0
  29. package/scripts/cli/__tests__/component-validator.test.js +433 -0
  30. package/scripts/cli/__tests__/generator.test.js +613 -0
  31. package/scripts/cli/__tests__/glass-motion.test.js +256 -0
  32. package/scripts/cli/__tests__/integration.test.js +719 -108
  33. package/scripts/cli/__tests__/migrate.test.js +74 -0
  34. package/scripts/cli/__tests__/security.test.js +206 -0
  35. package/scripts/cli/__tests__/test-setup.js +3 -1
  36. package/scripts/cli/__tests__/theme-bridge.test.js +507 -0
  37. package/scripts/cli/__tests__/token-provider.test.js +361 -0
  38. package/scripts/cli/__tests__/utils.test.js +5 -5
  39. package/scripts/cli/commands/benchmark.js +105 -0
  40. package/scripts/cli/commands/build-theme.js +4 -1
  41. package/scripts/cli/commands/clean.js +109 -0
  42. package/scripts/cli/commands/doctor.js +88 -0
  43. package/scripts/cli/commands/generate.js +135 -14
  44. package/scripts/cli/commands/init.js +45 -18
  45. package/scripts/cli/commands/migrate.js +106 -0
  46. package/scripts/cli/commands/sync-tokens.js +206 -0
  47. package/scripts/cli/commands/theme-bridge.js +248 -0
  48. package/scripts/cli/commands/tokens.js +157 -0
  49. package/scripts/cli/commands/validate.js +194 -0
  50. package/scripts/cli/internal/ai-engine.js +156 -0
  51. package/scripts/cli/internal/component-validator.js +443 -0
  52. package/scripts/cli/internal/config-loader.js +162 -0
  53. package/scripts/cli/internal/filesystem.js +102 -2
  54. package/scripts/cli/internal/generator.js +359 -39
  55. package/scripts/cli/internal/glass-generator.js +398 -0
  56. package/scripts/cli/internal/hook-generator.js +369 -0
  57. package/scripts/cli/internal/hooks.js +61 -0
  58. package/scripts/cli/internal/itcss-generator.js +565 -0
  59. package/scripts/cli/internal/motion-generator.js +679 -0
  60. package/scripts/cli/internal/template-engine.js +301 -0
  61. package/scripts/cli/internal/theme-bridge.js +664 -0
  62. package/scripts/cli/internal/tokens/engine.js +122 -0
  63. package/scripts/cli/internal/tokens/provider.js +34 -0
  64. package/scripts/cli/internal/tokens/providers/figma.js +50 -0
  65. package/scripts/cli/internal/tokens/providers/style-dictionary.js +48 -0
  66. package/scripts/cli/internal/tokens/providers/w3c.js +48 -0
  67. package/scripts/cli/internal/tokens/token-provider.js +443 -0
  68. package/scripts/cli/internal/tokens/token-validator.js +513 -0
  69. package/scripts/cli/internal/validator.js +276 -0
  70. package/scripts/cli/internal/wizard.js +60 -6
  71. package/scripts/cli/mappings.js +23 -0
  72. package/scripts/cli/migration-tools.js +164 -94
  73. package/scripts/cli/plugins/style-dictionary.js +46 -0
  74. package/scripts/cli/templates/README.md +525 -95
  75. package/scripts/cli/templates/common-templates.js +40 -14
  76. package/scripts/cli/templates/components/react-component.ts +282 -0
  77. package/scripts/cli/templates/config/project-config.ts +112 -0
  78. package/scripts/cli/templates/hooks/use-component.ts +477 -0
  79. package/scripts/cli/templates/index.js +19 -4
  80. package/scripts/cli/templates/index.ts +171 -0
  81. package/scripts/cli/templates/next-templates.js +72 -0
  82. package/scripts/cli/templates/react-templates.js +70 -126
  83. package/scripts/cli/templates/scss-templates.js +35 -35
  84. package/scripts/cli/templates/stories/storybook-story.ts +241 -0
  85. package/scripts/cli/templates/styles/scss-component.ts +255 -0
  86. package/scripts/cli/templates/tests/vitest-test.ts +229 -0
  87. package/scripts/cli/templates/token-templates.js +337 -1
  88. package/scripts/cli/templates/tokens/token-generators.ts +1088 -0
  89. package/scripts/cli/templates/types/component-types.ts +145 -0
  90. package/scripts/cli/templates/utils/testing-utils.ts +144 -0
  91. package/scripts/cli/templates/vanilla-templates.js +39 -0
  92. package/scripts/cli/token-manager.js +8 -2
  93. package/scripts/cli/utils/cache-manager.js +240 -0
  94. package/scripts/cli/utils/detector.js +46 -0
  95. package/scripts/cli/utils/diagnostics.js +289 -0
  96. package/scripts/cli/utils/error.js +45 -3
  97. package/scripts/cli/utils/helpers.js +24 -0
  98. package/scripts/cli/utils/logger.js +1 -1
  99. package/scripts/cli/utils/security.js +302 -0
  100. package/scripts/cli/utils/telemetry.js +115 -0
  101. package/scripts/cli/utils/validation.js +4 -38
  102. package/scripts/cli/utils.js +46 -0
  103. package/src/components/Accordion/Accordion.stories.tsx +0 -18
  104. package/src/components/Accordion/Accordion.test.tsx +0 -17
  105. package/src/components/Accordion/Accordion.tsx +0 -4
  106. package/src/components/AtomixGlass/AtomixGlass.tsx +102 -2
  107. package/src/components/AtomixGlass/AtomixGlassContainer.tsx +125 -12
  108. package/src/components/AtomixGlass/PerformanceDashboard.tsx +219 -0
  109. package/src/components/AtomixGlass/README.md +25 -10
  110. package/src/components/AtomixGlass/animation-system.ts +578 -0
  111. package/src/components/AtomixGlass/shader-utils.ts +4 -1
  112. package/src/components/AtomixGlass/stories/Overview.stories.tsx +157 -6
  113. package/src/components/AtomixGlass/stories/Phase1-Animation.stories.tsx +653 -0
  114. package/src/components/AtomixGlass/stories/Phase1-Test.stories.tsx +95 -0
  115. package/src/components/AtomixGlass/stories/Playground.stories.tsx +51 -51
  116. package/src/components/AtomixGlass/stories/shared-components.tsx +6 -0
  117. package/src/components/Avatar/Avatar.tsx +1 -1
  118. package/src/components/Button/Button.stories.disabled-link.tsx +10 -0
  119. package/src/components/Button/Button.stories.tsx +10 -0
  120. package/src/components/Button/Button.test.tsx +16 -11
  121. package/src/components/Button/Button.tsx +4 -4
  122. package/src/components/Card/Card.tsx +1 -1
  123. package/src/components/Dropdown/Dropdown.tsx +12 -12
  124. package/src/components/Form/Select.tsx +62 -3
  125. package/src/components/Modal/Modal.tsx +14 -3
  126. package/src/components/Navigation/Navbar/Navbar.tsx +44 -0
  127. package/src/components/Slider/Slider.stories.tsx +3 -3
  128. package/src/components/Slider/Slider.tsx +38 -0
  129. package/src/components/Steps/Steps.tsx +3 -3
  130. package/src/components/Tabs/Tabs.tsx +77 -8
  131. package/src/components/Testimonial/Testimonial.tsx +1 -1
  132. package/src/components/TypedButton/TypedButton.stories.tsx +59 -0
  133. package/src/components/TypedButton/TypedButton.tsx +39 -0
  134. package/src/components/TypedButton/index.ts +2 -0
  135. package/src/components/VideoPlayer/VideoPlayer.tsx +11 -4
  136. package/src/lib/composables/index.ts +4 -7
  137. package/src/lib/composables/types.ts +45 -0
  138. package/src/lib/composables/useAccordion.ts +0 -7
  139. package/src/lib/composables/useAtomixGlass.ts +144 -5
  140. package/src/lib/composables/useChartExport.ts +3 -13
  141. package/src/lib/composables/useDropdown.ts +66 -0
  142. package/src/lib/composables/useFocusTrap.ts +80 -0
  143. package/src/lib/composables/usePerformanceMonitor.ts +448 -0
  144. package/src/lib/composables/useResponsiveGlass.presets.ts +192 -0
  145. package/src/lib/composables/useResponsiveGlass.ts +441 -0
  146. package/src/lib/composables/useTooltip.ts +16 -0
  147. package/src/lib/composables/useTypedButton.ts +66 -0
  148. package/src/lib/config/index.ts +62 -5
  149. package/src/lib/constants/components.ts +55 -0
  150. package/src/lib/theme/devtools/__tests__/useHistory.test.tsx +150 -0
  151. package/src/lib/theme/tokens/centralized-tokens.ts +120 -0
  152. package/src/lib/theme/utils/__tests__/domUtils.test.ts +101 -0
  153. package/src/lib/types/components.ts +37 -11
  154. package/src/lib/types/glass.ts +35 -0
  155. package/src/lib/types/index.ts +1 -0
  156. package/src/lib/utils/displacement-generator.ts +1 -1
  157. package/src/styles/01-settings/_settings.testtypecheck.scss +53 -0
  158. package/src/styles/01-settings/_settings.typedbutton.scss +53 -0
  159. package/src/styles/06-components/_components.testbutton.scss +212 -0
  160. package/src/styles/06-components/_components.testtypecheck.scss +212 -0
  161. package/src/styles/06-components/_components.typedbutton.scss +212 -0
  162. package/src/styles/99-utilities/_index.scss +1 -0
  163. package/src/styles/99-utilities/_utilities.text.scss +1 -1
  164. package/src/styles/99-utilities/_utilities.touch-target.scss +36 -0
  165. package/src/styles/06-components/old.chart.styles.scss +0 -2788
@@ -0,0 +1,433 @@
1
+ /**
2
+ * Component Validator Tests
3
+ * Tests for Phase 2: Design System Architecture Enforcement
4
+ */
5
+
6
+ import { describe, it, expect, beforeEach } from 'vitest';
7
+ import {
8
+ ComponentValidator,
9
+ COMPONENT_RULES,
10
+ COMPONENT_SEVERITY,
11
+ componentValidator
12
+ } from '../internal/component-validator.js';
13
+
14
+ describe('ComponentValidator', () => {
15
+ let validator;
16
+
17
+ beforeEach(() => {
18
+ validator = new ComponentValidator();
19
+ });
20
+
21
+ describe('Initialization', () => {
22
+ it('should create a new ComponentValidator instance', () => {
23
+ expect(validator).toBeInstanceOf(ComponentValidator);
24
+ });
25
+
26
+ it('should register all built-in rules', () => {
27
+ expect(validator.rules.size).toBeGreaterThan(0);
28
+ expect(validator.rules.has('FORWARD_REF_REQUIRED')).toBe(true);
29
+ expect(validator.rules.has('DISPLAY_NAME_REQUIRED')).toBe(true);
30
+ expect(validator.rules.has('TYPESCRIPT_TYPES_REQUIRED')).toBe(true);
31
+ });
32
+
33
+ it('should have all rules enabled by default', () => {
34
+ expect(validator.enabledRules.length).toBeGreaterThan(0);
35
+ });
36
+ });
37
+
38
+ describe('ForwardRef Validation', () => {
39
+ it('should detect missing forwardRef', () => {
40
+ const content = `
41
+ export const Button = (props) => {
42
+ return <div {...props} />;
43
+ };
44
+ `;
45
+
46
+ const result = validator.validate(content, 'Button');
47
+
48
+ const forwardRefIssue = result.issues.find(i => i.rule === 'forward-ref-required');
49
+ expect(forwardRefIssue).toBeDefined();
50
+ expect(forwardRefIssue.severity).toBe(COMPONENT_SEVERITY.ERROR);
51
+ });
52
+
53
+ it('should pass when forwardRef is used', () => {
54
+ const content = `
55
+ import React, { forwardRef } from 'react';
56
+
57
+ export const Button = forwardRef<HTMLDivElement, ButtonProps>(
58
+ (props, ref) => {
59
+ return <div ref={ref} {...props} />;
60
+ }
61
+ );
62
+ `;
63
+
64
+ const result = validator.validate(content, 'Button');
65
+
66
+ const forwardRefIssue = result.issues.find(i => i.rule === 'forward-ref-required');
67
+ expect(forwardRefIssue).toBeUndefined();
68
+ });
69
+ });
70
+
71
+ describe('DisplayName Validation', () => {
72
+ it('should detect missing displayName', () => {
73
+ const content = `
74
+ export const Button = forwardRef((props, ref) => {
75
+ return <div ref={ref} {...props} />;
76
+ });
77
+ `;
78
+
79
+ const result = validator.validate(content, 'Button');
80
+
81
+ const displayNameIssue = result.issues.find(i => i.rule === 'display-name-required');
82
+ expect(displayNameIssue).toBeDefined();
83
+ });
84
+
85
+ it('should pass when displayName is correctly assigned', () => {
86
+ const content = `
87
+ export const Button = forwardRef((props, ref) => {
88
+ return <div ref={ref} {...props} />;
89
+ });
90
+
91
+ Button.displayName = 'Button';
92
+ `;
93
+
94
+ const result = validator.validate(content, 'Button');
95
+
96
+ const displayNameIssue = result.issues.find(i => i.rule === 'display-name-required');
97
+ expect(displayNameIssue).toBeUndefined();
98
+ });
99
+ });
100
+
101
+ describe('JSDoc Validation', () => {
102
+ it('should detect missing JSDoc', () => {
103
+ const content = `
104
+ export const Button = forwardRef((props, ref) => {
105
+ return <div ref={ref} {...props} />;
106
+ });
107
+
108
+ Button.displayName = 'Button';
109
+ `;
110
+
111
+ const result = validator.validate(content, 'Button');
112
+
113
+ const jsdocIssue = result.issues.find(i => i.rule === 'jsdoc-required');
114
+ expect(jsdocIssue).toBeDefined();
115
+ expect(jsdocIssue.severity).toBe(COMPONENT_SEVERITY.WARNING);
116
+ });
117
+
118
+ it('should pass when JSDoc is present', () => {
119
+ const content = `
120
+ /**
121
+ * Button Component
122
+ * @param {ButtonProps} props - Component properties
123
+ * @returns {JSX.Element} The rendered button
124
+ */
125
+ export const Button = forwardRef((props, ref) => {
126
+ return <div ref={ref} {...props} />;
127
+ });
128
+
129
+ Button.displayName = 'Button';
130
+ `;
131
+
132
+ const result = validator.validate(content, 'Button');
133
+
134
+ const jsdocIssue = result.issues.find(i => i.rule === 'jsdoc-required');
135
+ expect(jsdocIssue).toBeUndefined();
136
+ });
137
+ });
138
+
139
+ describe('TypeScript Types Validation', () => {
140
+ it('should detect missing Props type', () => {
141
+ const content = `
142
+ export const Button = forwardRef((props, ref) => {
143
+ return <div ref={ref} {...props} />;
144
+ });
145
+
146
+ Button.displayName = 'Button';
147
+ `;
148
+
149
+ const result = validator.validate(content, 'Button');
150
+
151
+ const typesIssue = result.issues.find(i => i.rule === 'typescript-types-required');
152
+ expect(typesIssue).toBeDefined();
153
+ });
154
+
155
+ it('should pass with local Props interface', () => {
156
+ const content = `
157
+ interface ButtonProps {
158
+ variant?: string;
159
+ size?: string;
160
+ }
161
+
162
+ export const Button = forwardRef<HTMLDivElement, ButtonProps>(
163
+ (props, ref) => {
164
+ return <div ref={ref} {...props} />;
165
+ }
166
+ );
167
+
168
+ Button.displayName = 'Button';
169
+ `;
170
+
171
+ const result = validator.validate(content, 'Button');
172
+
173
+ const typesIssue = result.issues.find(i => i.rule === 'typescript-types-required');
174
+ expect(typesIssue).toBeUndefined();
175
+ });
176
+
177
+ it('should pass with imported Props type', () => {
178
+ const content = `
179
+ import type { ButtonProps } from '../../types/components';
180
+
181
+ export const Button = forwardRef<HTMLDivElement, ButtonProps>(
182
+ (props, ref) => {
183
+ return <div ref={ref} {...props} />;
184
+ }
185
+ );
186
+
187
+ Button.displayName = 'Button';
188
+ `;
189
+
190
+ const result = validator.validate(content, 'Button');
191
+
192
+ const typesIssue = result.issues.find(i => i.rule === 'typescript-types-required');
193
+ expect(typesIssue).toBeUndefined();
194
+ });
195
+ });
196
+
197
+ describe('Accessibility Validation', () => {
198
+ it('should detect missing accessibility attributes', () => {
199
+ const content = `
200
+ export const Button = forwardRef((props, ref) => {
201
+ return <div ref={ref} {...props} />;
202
+ });
203
+
204
+ Button.displayName = 'Button';
205
+ `;
206
+
207
+ const result = validator.validate(content, 'Button');
208
+
209
+ const a11yIssue = result.issues.find(i => i.rule === 'accessibility-attributes');
210
+ expect(a11yIssue).toBeDefined();
211
+ });
212
+
213
+ it('should pass with aria-label', () => {
214
+ const content = `
215
+ export const Button = forwardRef((props, ref) => {
216
+ return <div ref={ref} aria-label="Click me" {...props} />;
217
+ });
218
+
219
+ Button.displayName = 'Button';
220
+ `;
221
+
222
+ const result = validator.validate(content, 'Button');
223
+
224
+ const a11yIssue = result.issues.find(i => i.rule === 'accessibility-attributes');
225
+ expect(a11yIssue).toBeUndefined();
226
+ });
227
+ });
228
+
229
+ describe('Hardcoded Colors Validation', () => {
230
+ it('should detect hardcoded hex colors', () => {
231
+ const content = `
232
+ export const Button = forwardRef((props, ref) => {
233
+ return <div ref={ref} style={{ color: '#ff0000' }} {...props} />;
234
+ });
235
+
236
+ Button.displayName = 'Button';
237
+ `;
238
+
239
+ const result = validator.validate(content, 'Button');
240
+
241
+ const colorIssue = result.issues.find(i => i.rule === 'no-hardcoded-colors');
242
+ expect(colorIssue).toBeDefined();
243
+ expect(colorIssue.matches).toContain('#ff0000');
244
+ });
245
+
246
+ it('should detect hardcoded RGB colors', () => {
247
+ const content = `
248
+ export const Button = forwardRef((props, ref) => {
249
+ return <div ref={ref} style={{ backgroundColor: 'rgb(255, 0, 0)' }} {...props} />;
250
+ });
251
+
252
+ Button.displayName = 'Button';
253
+ `;
254
+
255
+ const result = validator.validate(content, 'Button');
256
+
257
+ const colorIssue = result.issues.find(i => i.rule === 'no-hardcoded-colors');
258
+ expect(colorIssue).toBeDefined();
259
+ });
260
+
261
+ it('should pass without hardcoded colors', () => {
262
+ const content = `
263
+ export const Button = forwardRef((props, ref) => {
264
+ return <div ref={ref} style={{ color: 'var(--color-primary)' }} {...props} />;
265
+ });
266
+
267
+ Button.displayName = 'Button';
268
+ `;
269
+
270
+ const result = validator.validate(content, 'Button');
271
+
272
+ const colorIssue = result.issues.find(i => i.rule === 'no-hardcoded-colors');
273
+ expect(colorIssue).toBeUndefined();
274
+ });
275
+ });
276
+
277
+ describe('Memo Usage Validation', () => {
278
+ it('should suggest using memo', () => {
279
+ const content = `
280
+ export const Button = forwardRef((props, ref) => {
281
+ return <div ref={ref} {...props} />;
282
+ });
283
+
284
+ Button.displayName = 'Button';
285
+ `;
286
+
287
+ const result = validator.validate(content, 'Button');
288
+
289
+ const memoIssue = result.issues.find(i => i.rule === 'memo-usage');
290
+ expect(memoIssue).toBeDefined();
291
+ expect(memoIssue.severity).toBe(COMPONENT_SEVERITY.INFO);
292
+ });
293
+
294
+ it('should pass when memo is used', () => {
295
+ const content = `
296
+ import React, { memo, forwardRef } from 'react';
297
+
298
+ export const Button = memo(
299
+ forwardRef((props, ref) => {
300
+ return <div ref={ref} {...props} />;
301
+ })
302
+ );
303
+
304
+ Button.displayName = 'Button';
305
+ `;
306
+
307
+ const result = validator.validate(content, 'Button');
308
+
309
+ const memoIssue = result.issues.find(i => i.rule === 'memo-usage');
310
+ expect(memoIssue).toBeUndefined();
311
+ });
312
+ });
313
+
314
+ describe('Rule Management', () => {
315
+ it('should toggle rules on/off', () => {
316
+ const initialCount = validator.enabledRules.length;
317
+
318
+ validator.toggleRule('FORWARD_REF_REQUIRED', false);
319
+ expect(validator.enabledRules).not.toContain('FORWARD_REF_REQUIRED');
320
+
321
+ validator.toggleRule('FORWARD_REF_REQUIRED', true);
322
+ expect(validator.enabledRules).toContain('FORWARD_REF_REQUIRED');
323
+ });
324
+
325
+ it('should allow registering custom rules', () => {
326
+ const customRule = {
327
+ name: 'custom-rule',
328
+ description: 'Custom validation rule',
329
+ severity: COMPONENT_SEVERITY.INFO,
330
+ validate: (content) => []
331
+ };
332
+
333
+ validator.registerRule('CUSTOM_RULE', customRule);
334
+
335
+ expect(validator.rules.has('CUSTOM_RULE')).toBe(true);
336
+ });
337
+
338
+ it('should reject invalid rules', () => {
339
+ expect(() => {
340
+ validator.registerRule('INVALID', { name: 'test' });
341
+ }).toThrow('must have name, validate, and severity');
342
+ });
343
+ });
344
+
345
+ describe('Validation Report', () => {
346
+ it('should generate formatted report', () => {
347
+ const content = `
348
+ export const Button = (props) => {
349
+ return <div style={{ color: '#ff0000' }} {...props} />;
350
+ };
351
+ `;
352
+
353
+ const result = validator.validate(content, 'Button');
354
+ const report = validator.getReport(result, 'Button');
355
+
356
+ expect(report).toContain('Component Validation Report: Button');
357
+ expect(report).toContain('Status:');
358
+ expect(report).toContain('Summary:');
359
+ expect(report).toContain('Errors:');
360
+ });
361
+
362
+ it('should sort issues by severity', () => {
363
+ const content = `
364
+ export const Button = (props) => {
365
+ return <div style={{ color: '#ff0000' }} {...props} />;
366
+ };
367
+ `;
368
+
369
+ const result = validator.validate(content, 'Button');
370
+ const report = validator.getReport(result, 'Button');
371
+
372
+ // Errors should appear before warnings and info
373
+ const errorIndex = report.indexOf('❌');
374
+ const warningIndex = report.indexOf('⚠️');
375
+ const infoIndex = report.indexOf('ℹ️');
376
+
377
+ if (errorIndex !== -1 && warningIndex !== -1) {
378
+ expect(errorIndex).toBeLessThan(warningIndex);
379
+ }
380
+ });
381
+ });
382
+
383
+ describe('Integration Tests', () => {
384
+ it('should validate complete component correctly', () => {
385
+ const content = `
386
+ import React, { memo, forwardRef } from 'react';
387
+ import type { ButtonProps } from '../../types/components';
388
+
389
+ /**
390
+ * Button Component
391
+ * @param {ButtonProps} props - Component properties
392
+ * @returns {JSX.Element} Rendered button
393
+ */
394
+ export const Button = memo(
395
+ forwardRef<HTMLDivElement, ButtonProps>(
396
+ ({ children, variant = 'primary', 'aria-label': ariaLabel, ...props }, ref) => {
397
+ return (
398
+ <div
399
+ ref={ref}
400
+ className={\`c-button c-button--variant-\${variant}\`}
401
+ aria-label={ariaLabel}
402
+ {...props}
403
+ >
404
+ {children}
405
+ </div>
406
+ );
407
+ }
408
+ )
409
+ );
410
+
411
+ Button.displayName = 'Button';
412
+ `;
413
+
414
+ const result = validator.validate(content, 'Button');
415
+
416
+ // Should have no errors (warnings and info are OK)
417
+ expect(result.summary.errors).toBe(0);
418
+ });
419
+
420
+ it('should fail validation with multiple errors', () => {
421
+ const content = `
422
+ export const Button = (props) => {
423
+ return <div style={{ color: '#ff0000' }} {...props} />;
424
+ };
425
+ `;
426
+
427
+ const result = validator.validate(content, 'Button');
428
+
429
+ expect(result.valid).toBe(false);
430
+ expect(result.summary.errors).toBeGreaterThan(0);
431
+ });
432
+ });
433
+ });