@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,301 @@
1
+ /**
2
+ * Atomix CLI Template Engine
3
+ * Centralizes all template-related logic, separating it from file I/O operations
4
+ */
5
+
6
+ import { componentTemplates } from '../templates.js';
7
+ import { AtomixCLIError } from '../utils/error.js';
8
+
9
+ export const COMPLEXITY_LEVELS = {
10
+ SIMPLE: { name: 'simple', template: 'simple' },
11
+ MEDIUM: { name: 'medium', template: 'medium' },
12
+ COMPLEX: { name: 'complex', template: 'complex' }
13
+ };
14
+
15
+ export const TEMPLATE_TYPES = {
16
+ COMPONENT: 'component',
17
+ INDEX: 'index',
18
+ STORY: 'story',
19
+ TEST: 'test',
20
+ SCSS: 'scss',
21
+ SETTINGS: 'settings',
22
+ HOOK: 'hook',
23
+ TYPES: 'types',
24
+ CONSTANTS: 'constants'
25
+ };
26
+
27
+ /**
28
+ * Template registry - maps framework + complexity to template functions
29
+ */
30
+ const templateRegistry = {
31
+ react: {
32
+ component: ['simple', 'medium', 'complex'],
33
+ index: ['index'],
34
+ story: ['story'],
35
+ test: ['test'],
36
+ scss: ['scss'], // SCSS templates don't use complexity
37
+ settings: ['settings'], // Settings templates don't use complexity
38
+ hook: ['useHook'],
39
+ types: ['types', 'constants']
40
+ },
41
+ next: {
42
+ component: ['simple', 'client', 'complex'],
43
+ index: ['index'],
44
+ story: ['story'],
45
+ test: ['test'],
46
+ scss: ['scss'],
47
+ settings: ['settings'],
48
+ hook: ['useHook'],
49
+ types: ['types', 'constants']
50
+ },
51
+ vanilla: {
52
+ component: ['component'],
53
+ scss: ['scss'],
54
+ settings: ['settings']
55
+ }
56
+ };
57
+
58
+ export const templateEngine = {
59
+ /**
60
+ * Select appropriate template based on framework and complexity
61
+ * @param {string} framework - Framework type (react, next, vanilla)
62
+ * @param {string} complexity - Complexity level (simple, medium, complex)
63
+ * @param {string} templateType - Template type (component, index, story, etc.)
64
+ * @returns {Function} Template function
65
+ * @throws {AtomixCLIError} If template not found
66
+ */
67
+ selectTemplate(framework, complexity, templateType) {
68
+ const normalizedFramework = framework.toLowerCase();
69
+ const normalizedComplexity = complexity.toLowerCase();
70
+ const normalizedType = templateType.toLowerCase();
71
+
72
+ // Validate framework exists
73
+ if (!templateRegistry[normalizedFramework]) {
74
+ throw new AtomixCLIError(
75
+ `Unsupported framework: ${framework}`,
76
+ 'FRAMEWORK_NOT_SUPPORTED',
77
+ [
78
+ `Use one of the supported frameworks: ${Object.keys(templateRegistry).join(', ')}`,
79
+ 'Check framework detection logic in detector.js',
80
+ 'Verify package.json has correct dependencies'
81
+ ]
82
+ );
83
+ }
84
+
85
+ // Get available templates for this framework
86
+ const availableTypes = templateRegistry[normalizedFramework];
87
+
88
+ // Validate template type exists for framework
89
+ if (!availableTypes[normalizedType]) {
90
+ throw new AtomixCLIError(
91
+ `Template type '${templateType}' not available for ${framework}`,
92
+ 'TEMPLATE_TYPE_NOT_AVAILABLE',
93
+ [
94
+ `Available template types for ${framework}: ${Object.keys(availableTypes).join(', ')}`,
95
+ 'Choose a different template type or framework'
96
+ ]
97
+ );
98
+ }
99
+
100
+ // For component templates, validate complexity level
101
+ if (normalizedType === 'component') {
102
+ const validComplexities = availableTypes[normalizedType];
103
+
104
+ // Handle vanilla framework which only has 'component' template
105
+ if (normalizedFramework === 'vanilla') {
106
+ return componentTemplates.vanilla.component;
107
+ }
108
+
109
+ // For Next.js, check if complexity is valid
110
+ if (normalizedFramework === 'next') {
111
+ if (!validComplexities.includes(normalizedComplexity)) {
112
+ throw new AtomixCLIError(
113
+ `Complexity level '${complexity}' not available for ${framework} component templates`,
114
+ 'INVALID_COMPLEXITY',
115
+ [
116
+ `Use one of: ${validComplexities.join(', ')}`,
117
+ 'Default complexity is "simple" for Next.js',
118
+ 'Specify complexity with --complexity flag'
119
+ ]
120
+ );
121
+ }
122
+
123
+ const templateFn = componentTemplates.next[normalizedComplexity];
124
+
125
+ if (!templateFn) {
126
+ throw new AtomixCLIError(
127
+ `Template function not found for ${framework} ${complexity} component`,
128
+ 'TEMPLATE_NOT_FOUND',
129
+ [
130
+ 'Check template files in scripts/cli/templates/',
131
+ 'Verify template export names match expected patterns',
132
+ 'Run `atomix doctor` to check template availability'
133
+ ]
134
+ );
135
+ }
136
+
137
+ return templateFn;
138
+ }
139
+
140
+ // React framework
141
+ if (!validComplexities.includes(normalizedComplexity)) {
142
+ throw new AtomixCLIError(
143
+ `Complexity level '${complexity}' not available for ${framework} component templates`,
144
+ 'INVALID_COMPLEXITY',
145
+ [
146
+ `Use one of: ${validComplexities.join(', ')}`,
147
+ 'Default complexity is "medium"',
148
+ 'Specify complexity with --complexity flag'
149
+ ]
150
+ );
151
+ }
152
+
153
+ // Return React component template based on complexity
154
+ const templateFn = componentTemplates.react[normalizedComplexity] || componentTemplates.react.component;
155
+
156
+ if (!templateFn) {
157
+ throw new AtomixCLIError(
158
+ `Template function not found for ${framework} ${complexity} component`,
159
+ 'TEMPLATE_NOT_FOUND',
160
+ [
161
+ 'Check template files in scripts/cli/templates/',
162
+ 'Verify template export names match expected patterns',
163
+ 'Run `atomix doctor` to check template availability'
164
+ ]
165
+ );
166
+ }
167
+
168
+ return templateFn;
169
+ }
170
+
171
+ // For non-component templates (scss, hook, story, etc.), don't validate complexity
172
+ // Just return the template directly
173
+ return this.getTemplateByType(normalizedFramework, normalizedType);
174
+ },
175
+
176
+ /**
177
+ * Get template function by type
178
+ * @private
179
+ */
180
+ getTemplateByType(framework, type) {
181
+ const templateMap = {
182
+ index: () => componentTemplates.react.index,
183
+ story: () => componentTemplates.storybook.story,
184
+ test: () => componentTemplates.testing.test,
185
+ scss: () => componentTemplates.scss.component,
186
+ settings: () => componentTemplates.scss.settings,
187
+ hook: () => componentTemplates.composable.useHook,
188
+ types: () => componentTemplates.types.types,
189
+ constants: () => componentTemplates.types.constants
190
+ };
191
+
192
+ const getTemplate = templateMap[type];
193
+
194
+ if (!getTemplate) {
195
+ throw new AtomixCLIError(
196
+ `Unknown template type: ${type}`,
197
+ 'TEMPLATE_NOT_FOUND',
198
+ [
199
+ `Available template types: ${Object.keys(templateMap).join(', ')}`,
200
+ 'Check template registration in template-engine.js'
201
+ ]
202
+ );
203
+ }
204
+
205
+ return getTemplate();
206
+ },
207
+
208
+ /**
209
+ * Render template with provided data
210
+ * @param {Function} templateFn - Template function
211
+ * @param {string} componentName - Component name
212
+ * @param {Object} options - Additional options
213
+ * @returns {string} Rendered template string
214
+ * @throws {AtomixCLIError} If template rendering fails
215
+ */
216
+ render(templateFn, componentName, options = {}) {
217
+ if (typeof templateFn !== 'function') {
218
+ throw new AtomixCLIError(
219
+ 'Template must be a function',
220
+ 'INVALID_TEMPLATE',
221
+ [
222
+ 'Ensure template is imported correctly',
223
+ 'Check template function signature',
224
+ 'Verify template exports in template files'
225
+ ]
226
+ );
227
+ }
228
+
229
+ try {
230
+ return templateFn(componentName, options);
231
+ } catch (error) {
232
+ throw new AtomixCLIError(
233
+ `Template rendering failed: ${error.message}`,
234
+ 'TEMPLATE_RENDER_ERROR',
235
+ [
236
+ 'Check component name format (must be PascalCase)',
237
+ 'Verify template function accepts provided parameters',
238
+ 'Review template syntax for errors'
239
+ ]
240
+ );
241
+ }
242
+ },
243
+
244
+ /**
245
+ * Get available templates for a framework
246
+ * @param {string} framework - Framework type
247
+ * @returns {Object} Object with available template types and complexities
248
+ */
249
+ getAvailableTemplates(framework) {
250
+ const normalizedFramework = framework.toLowerCase();
251
+
252
+ if (!templateRegistry[normalizedFramework]) {
253
+ return {};
254
+ }
255
+
256
+ return templateRegistry[normalizedFramework];
257
+ },
258
+
259
+ /**
260
+ * Validate template exists and is callable
261
+ * @param {string} templateName - Template name
262
+ * @param {string} framework - Framework type
263
+ * @param {string} complexity - Complexity level (for component templates)
264
+ * @returns {Object} { isValid: boolean, error?: string }
265
+ */
266
+ validateTemplate(templateName, framework, complexity = 'medium') {
267
+ try {
268
+ const templateFn = this.selectTemplate(framework, complexity, templateName);
269
+
270
+ if (typeof templateFn !== 'function') {
271
+ return {
272
+ isValid: false,
273
+ error: `Template '${templateName}' is not a function`
274
+ };
275
+ }
276
+
277
+ return { isValid: true };
278
+ } catch (error) {
279
+ return {
280
+ isValid: false,
281
+ error: error.message
282
+ };
283
+ }
284
+ },
285
+
286
+ /**
287
+ * Get all available framework names
288
+ * @returns {string[]} Array of framework names
289
+ */
290
+ getSupportedFrameworks() {
291
+ return Object.keys(templateRegistry);
292
+ },
293
+
294
+ /**
295
+ * Get all available complexity levels
296
+ * @returns {string[]} Array of complexity levels
297
+ */
298
+ getComplexityLevels() {
299
+ return Object.keys(COMPLEXITY_LEVELS).map(k => k.toLowerCase());
300
+ }
301
+ };