@sarjallab09/figma-intelligence 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.
Files changed (286) hide show
  1. package/LICENSE +26 -0
  2. package/README.md +327 -0
  3. package/bin/cli.js +859 -0
  4. package/design-bridge/.env.example +5 -0
  5. package/design-bridge/bridge.js +196 -0
  6. package/design-bridge/lib/assets.js +367 -0
  7. package/design-bridge/lib/prompt.js +85 -0
  8. package/design-bridge/lib/server.js +66 -0
  9. package/design-bridge/lib/stitch.js +37 -0
  10. package/design-bridge/lib/tokens.js +82 -0
  11. package/design-bridge/package-lock.json +579 -0
  12. package/design-bridge/package.json +19 -0
  13. package/figma-bridge-plugin/README.md +97 -0
  14. package/figma-bridge-plugin/anthropic-chat-runner.js +192 -0
  15. package/figma-bridge-plugin/bridge-relay.js +2363 -0
  16. package/figma-bridge-plugin/chat-runner.js +459 -0
  17. package/figma-bridge-plugin/code.js +1528 -0
  18. package/figma-bridge-plugin/codex-runner.js +505 -0
  19. package/figma-bridge-plugin/component-schemas.js +110 -0
  20. package/figma-bridge-plugin/content-context.js +869 -0
  21. package/figma-bridge-plugin/create-button.js +216 -0
  22. package/figma-bridge-plugin/gemini-cli-runner.js +291 -0
  23. package/figma-bridge-plugin/gemini-runner.js +187 -0
  24. package/figma-bridge-plugin/html-to-figma.js +927 -0
  25. package/figma-bridge-plugin/knowledge-hub/.gitkeep +0 -0
  26. package/figma-bridge-plugin/knowledge-hub/uspec-references/anatomy-spec.md +159 -0
  27. package/figma-bridge-plugin/knowledge-hub/uspec-references/api-spec.md +162 -0
  28. package/figma-bridge-plugin/knowledge-hub/uspec-references/color-spec.md +148 -0
  29. package/figma-bridge-plugin/knowledge-hub/uspec-references/full-spec-template.md +314 -0
  30. package/figma-bridge-plugin/knowledge-hub/uspec-references/property-spec.md +175 -0
  31. package/figma-bridge-plugin/knowledge-hub/uspec-references/screen-reader-spec.md +180 -0
  32. package/figma-bridge-plugin/knowledge-hub/uspec-references/structure-spec.md +165 -0
  33. package/figma-bridge-plugin/manifest.json +21 -0
  34. package/figma-bridge-plugin/package-lock.json +1936 -0
  35. package/figma-bridge-plugin/package.json +20 -0
  36. package/figma-bridge-plugin/perplexity-runner.js +188 -0
  37. package/figma-bridge-plugin/references/SKILL.md +178 -0
  38. package/figma-bridge-plugin/references/anatomy-spec.md +159 -0
  39. package/figma-bridge-plugin/references/api-spec.md +162 -0
  40. package/figma-bridge-plugin/references/color-spec.md +148 -0
  41. package/figma-bridge-plugin/references/full-spec-template.md +314 -0
  42. package/figma-bridge-plugin/references/property-spec.md +175 -0
  43. package/figma-bridge-plugin/references/screen-reader-spec.md +180 -0
  44. package/figma-bridge-plugin/references/structure-spec.md +165 -0
  45. package/figma-bridge-plugin/shared-prompt-config.js +604 -0
  46. package/figma-bridge-plugin/spec-helpers/build-table.js +269 -0
  47. package/figma-bridge-plugin/spec-helpers/classify-elements.js +189 -0
  48. package/figma-bridge-plugin/spec-helpers/index.js +35 -0
  49. package/figma-bridge-plugin/spec-helpers/parse-figma-link.js +49 -0
  50. package/figma-bridge-plugin/spec-helpers/position-markers.js +158 -0
  51. package/figma-bridge-plugin/stitch-auth.js +322 -0
  52. package/figma-bridge-plugin/stitch-runner.js +1427 -0
  53. package/figma-bridge-plugin/token-resolver.js +107 -0
  54. package/figma-bridge-plugin/ui.html +4467 -0
  55. package/figma-intelligence-layer/.env.example +39 -0
  56. package/figma-intelligence-layer/docs/local-image-generation.md +60 -0
  57. package/figma-intelligence-layer/examples/comfyui-workflow-template.example.json +101 -0
  58. package/figma-intelligence-layer/jest.config.js +14 -0
  59. package/figma-intelligence-layer/mcp-config.json +19 -0
  60. package/figma-intelligence-layer/package-lock.json +5892 -0
  61. package/figma-intelligence-layer/package.json +48 -0
  62. package/figma-intelligence-layer/scripts/setup-comfyui-local.sh +67 -0
  63. package/figma-intelligence-layer/scripts/start-comfyui.sh +33 -0
  64. package/figma-intelligence-layer/src/index.ts +2233 -0
  65. package/figma-intelligence-layer/src/shared/auto-layout-validator.ts +404 -0
  66. package/figma-intelligence-layer/src/shared/cache.ts +187 -0
  67. package/figma-intelligence-layer/src/shared/color-operations.ts +533 -0
  68. package/figma-intelligence-layer/src/shared/color-utils.ts +138 -0
  69. package/figma-intelligence-layer/src/shared/component-script-builder.ts +413 -0
  70. package/figma-intelligence-layer/src/shared/component-templates.ts +2767 -0
  71. package/figma-intelligence-layer/src/shared/concept-taxonomy.ts +694 -0
  72. package/figma-intelligence-layer/src/shared/decision-log.ts +128 -0
  73. package/figma-intelligence-layer/src/shared/design-system-context.ts +568 -0
  74. package/figma-intelligence-layer/src/shared/design-system-intelligence.ts +131 -0
  75. package/figma-intelligence-layer/src/shared/design-system-matcher.ts +184 -0
  76. package/figma-intelligence-layer/src/shared/design-system-normalizers.ts +196 -0
  77. package/figma-intelligence-layer/src/shared/design-system-tokens.ts +295 -0
  78. package/figma-intelligence-layer/src/shared/dtcg-validator.ts +530 -0
  79. package/figma-intelligence-layer/src/shared/enrichment-pipeline.ts +671 -0
  80. package/figma-intelligence-layer/src/shared/figma-bridge.ts +1408 -0
  81. package/figma-intelligence-layer/src/shared/font-config.ts +126 -0
  82. package/figma-intelligence-layer/src/shared/icon-catalog.ts +360 -0
  83. package/figma-intelligence-layer/src/shared/icon-fetch.ts +80 -0
  84. package/figma-intelligence-layer/src/shared/prototype-script-builder.ts +162 -0
  85. package/figma-intelligence-layer/src/shared/response-compression.ts +440 -0
  86. package/figma-intelligence-layer/src/shared/semantic-token-catalog.ts +324 -0
  87. package/figma-intelligence-layer/src/shared/token-binder.ts +505 -0
  88. package/figma-intelligence-layer/src/shared/token-math.ts +427 -0
  89. package/figma-intelligence-layer/src/shared/token-naming.ts +468 -0
  90. package/figma-intelligence-layer/src/shared/token-utils.ts +420 -0
  91. package/figma-intelligence-layer/src/shared/types.ts +346 -0
  92. package/figma-intelligence-layer/src/shared/typography-presets.ts +94 -0
  93. package/figma-intelligence-layer/src/shared/unsplash.ts +165 -0
  94. package/figma-intelligence-layer/src/shared/vision-client.ts +607 -0
  95. package/figma-intelligence-layer/src/shared/vision-provider-anthropic.ts +334 -0
  96. package/figma-intelligence-layer/src/shared/vision-provider-openai.ts +446 -0
  97. package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/a11y-annotate-handler.ts +782 -0
  98. package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/a11y-annotate-renderer.ts +496 -0
  99. package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/a11y-annotation-kit.ts +230 -0
  100. package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/colorblind-sim.ts +66 -0
  101. package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/index.ts +810 -0
  102. package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/keyboard-sr-order-analyzer.ts +1191 -0
  103. package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/keyboard-sr-order-figma-page.ts +1346 -0
  104. package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/keyboard-sr-order-handler.ts +148 -0
  105. package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/vpat-figma-page.ts +499 -0
  106. package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/vpat-report.ts +910 -0
  107. package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/wcag-checker.ts +989 -0
  108. package/figma-intelligence-layer/src/tools/phase1-vision/a11y-audit/wcag-criteria.ts +1160 -0
  109. package/figma-intelligence-layer/src/tools/phase1-vision/design-from-ref/index.ts +424 -0
  110. package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/component-recognizer.ts +38 -0
  111. package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/ds-matcher.ts +111 -0
  112. package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/font-matcher.ts +114 -0
  113. package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/icon-resolver.ts +103 -0
  114. package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/index.ts +1060 -0
  115. package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/layout-segmenter.ts +18 -0
  116. package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/token-inferencer.ts +39 -0
  117. package/figma-intelligence-layer/src/tools/phase1-vision/screen-cloner/vision-pipeline.ts +58 -0
  118. package/figma-intelligence-layer/src/tools/phase1-vision/sketch-to-design/index.ts +298 -0
  119. package/figma-intelligence-layer/src/tools/phase1-vision/visual-audit/index.ts +197 -0
  120. package/figma-intelligence-layer/src/tools/phase2-accuracy/component-audit/index.ts +494 -0
  121. package/figma-intelligence-layer/src/tools/phase2-accuracy/intent-translator/index.ts +356 -0
  122. package/figma-intelligence-layer/src/tools/phase2-accuracy/layout-intelligence/container-patterns.ts +123 -0
  123. package/figma-intelligence-layer/src/tools/phase2-accuracy/layout-intelligence/index.ts +663 -0
  124. package/figma-intelligence-layer/src/tools/phase2-accuracy/lint-rules/built-in-rules.yaml +56 -0
  125. package/figma-intelligence-layer/src/tools/phase2-accuracy/lint-rules/index.ts +614 -0
  126. package/figma-intelligence-layer/src/tools/phase2-accuracy/lint-rules/rule-engine.ts +113 -0
  127. package/figma-intelligence-layer/src/tools/phase2-accuracy/theme-generator/color-theory.ts +178 -0
  128. package/figma-intelligence-layer/src/tools/phase2-accuracy/theme-generator/index.ts +470 -0
  129. package/figma-intelligence-layer/src/tools/phase2-accuracy/variant-expander/index.ts +429 -0
  130. package/figma-intelligence-layer/src/tools/phase2-accuracy/variant-expander/token-override-maps.ts +226 -0
  131. package/figma-intelligence-layer/src/tools/phase3-generation/ai-image-insert/index.ts +535 -0
  132. package/figma-intelligence-layer/src/tools/phase3-generation/component-archaeologist/index.ts +660 -0
  133. package/figma-intelligence-layer/src/tools/phase3-generation/component-archaeologist/pattern-fingerprints.ts +209 -0
  134. package/figma-intelligence-layer/src/tools/phase3-generation/composition-builder/index.ts +540 -0
  135. package/figma-intelligence-layer/src/tools/phase3-generation/figma-animated-build.ts +391 -0
  136. package/figma-intelligence-layer/src/tools/phase3-generation/page-architect/index.ts +2019 -0
  137. package/figma-intelligence-layer/src/tools/phase3-generation/page-architect/screen-templates.ts +131 -0
  138. package/figma-intelligence-layer/src/tools/phase3-generation/prototype-map/index.ts +381 -0
  139. package/figma-intelligence-layer/src/tools/phase3-generation/prototype-wire/index.ts +565 -0
  140. package/figma-intelligence-layer/src/tools/phase3-generation/swarm-build/index.ts +764 -0
  141. package/figma-intelligence-layer/src/tools/phase3-generation/system-drift/index.ts +535 -0
  142. package/figma-intelligence-layer/src/tools/phase3-generation/unsplash-search/index.ts +84 -0
  143. package/figma-intelligence-layer/src/tools/phase3-generation/url-to-frame/index.ts +401 -0
  144. package/figma-intelligence-layer/src/tools/phase4-sync/animation-specifier/code-generators/css-animations.ts +68 -0
  145. package/figma-intelligence-layer/src/tools/phase4-sync/animation-specifier/code-generators/framer-motion.ts +78 -0
  146. package/figma-intelligence-layer/src/tools/phase4-sync/animation-specifier/code-generators/swift-animations.ts +93 -0
  147. package/figma-intelligence-layer/src/tools/phase4-sync/animation-specifier/index.ts +596 -0
  148. package/figma-intelligence-layer/src/tools/phase4-sync/ci-check/index.ts +462 -0
  149. package/figma-intelligence-layer/src/tools/phase4-sync/export-tokens/index.ts +1470 -0
  150. package/figma-intelligence-layer/src/tools/phase4-sync/generate-component-code/index.ts +829 -0
  151. package/figma-intelligence-layer/src/tools/phase4-sync/handoff-spec/index.ts +702 -0
  152. package/figma-intelligence-layer/src/tools/phase4-sync/icon-library-sync/index.ts +483 -0
  153. package/figma-intelligence-layer/src/tools/phase4-sync/sync-from-code/index.ts +501 -0
  154. package/figma-intelligence-layer/src/tools/phase4-sync/sync-from-code/storybook-parser.ts +106 -0
  155. package/figma-intelligence-layer/src/tools/phase4-sync/watch-docs/index.ts +676 -0
  156. package/figma-intelligence-layer/src/tools/phase4-sync/webhook-listener/index.ts +560 -0
  157. package/figma-intelligence-layer/src/tools/phase5-governance/apg-doc/index.ts +1043 -0
  158. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/component-detection.ts +620 -0
  159. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/anatomy.ts +331 -0
  160. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/color-tokens.ts +77 -0
  161. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/properties.ts +54 -0
  162. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/snapshot.ts +287 -0
  163. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/spacing.ts +71 -0
  164. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/states.ts +43 -0
  165. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/extractors/typography.ts +71 -0
  166. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/index.ts +221 -0
  167. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/_default.ts +166 -0
  168. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/accordion.ts +232 -0
  169. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/alert.ts +234 -0
  170. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/avatar-group.ts +270 -0
  171. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/avatar.ts +249 -0
  172. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/badge.ts +231 -0
  173. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/banner.ts +293 -0
  174. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/breadcrumb.ts +240 -0
  175. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/button.ts +243 -0
  176. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/calendar.ts +307 -0
  177. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/card.ts +143 -0
  178. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/checkbox.ts +227 -0
  179. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/chip.ts +233 -0
  180. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/combobox.ts +282 -0
  181. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/datepicker.ts +276 -0
  182. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/divider.ts +223 -0
  183. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/drawer.ts +255 -0
  184. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/dropdown-menu.ts +289 -0
  185. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/empty-state.ts +261 -0
  186. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/file-uploader.ts +290 -0
  187. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/form.ts +265 -0
  188. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/grid.ts +238 -0
  189. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/icon.ts +255 -0
  190. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/index.ts +128 -0
  191. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/inline-edit.ts +286 -0
  192. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/inline-message.ts +255 -0
  193. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/input.ts +330 -0
  194. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/link.ts +247 -0
  195. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/list.ts +250 -0
  196. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/menu.ts +247 -0
  197. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/modal.ts +144 -0
  198. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/navbar.ts +264 -0
  199. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/navigation.ts +251 -0
  200. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/number-input.ts +261 -0
  201. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/pagination.ts +248 -0
  202. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/popover.ts +270 -0
  203. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/progress.ts +251 -0
  204. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/radio.ts +142 -0
  205. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/range-slider.ts +282 -0
  206. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/rating.ts +250 -0
  207. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/search.ts +258 -0
  208. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/segmented-control.ts +265 -0
  209. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/select.ts +319 -0
  210. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/skeleton.ts +256 -0
  211. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/slider.ts +232 -0
  212. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/spinner.ts +239 -0
  213. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/status-dot.ts +252 -0
  214. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/stepper.ts +270 -0
  215. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/table.ts +244 -0
  216. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/tabs.ts +143 -0
  217. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/tag.ts +243 -0
  218. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/textarea.ts +259 -0
  219. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/time-picker.ts +293 -0
  220. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/toast.ts +144 -0
  221. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/toggle.ts +289 -0
  222. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/toolbar.ts +267 -0
  223. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/tooltip.ts +232 -0
  224. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/treeview.ts +257 -0
  225. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/knowledge/typography.ts +319 -0
  226. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/legacy-compat.ts +121 -0
  227. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/renderers/anatomy-diagram.ts +430 -0
  228. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/renderers/figma-page.ts +312 -0
  229. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/renderers/json.ts +129 -0
  230. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/renderers/markdown.ts +78 -0
  231. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/renderers/visual-doc.ts +2333 -0
  232. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/accessibility.ts +100 -0
  233. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/anatomy.ts +32 -0
  234. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/color-tokens.ts +59 -0
  235. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/content-guidance.ts +18 -0
  236. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/design-tokens.ts +53 -0
  237. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/interaction-rules.ts +19 -0
  238. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/overview.ts +91 -0
  239. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/properties-api.ts +71 -0
  240. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/qa-criteria.ts +19 -0
  241. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/related-components.ts +110 -0
  242. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/responsive.ts +19 -0
  243. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/size-specs.ts +67 -0
  244. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/spacing-structure.ts +58 -0
  245. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/state-specs.ts +79 -0
  246. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/states.ts +50 -0
  247. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/type-hierarchy.ts +33 -0
  248. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/typography.ts +55 -0
  249. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/usage-guidelines.ts +73 -0
  250. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/sections/variants.ts +81 -0
  251. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec/types.ts +409 -0
  252. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec-sheet/index.ts +198 -0
  253. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec-sheet/renderer.ts +701 -0
  254. package/figma-intelligence-layer/src/tools/phase5-governance/component-spec-sheet/types.ts +88 -0
  255. package/figma-intelligence-layer/src/tools/phase5-governance/decision-log/index.ts +135 -0
  256. package/figma-intelligence-layer/src/tools/phase5-governance/design-decision-log/index.ts +491 -0
  257. package/figma-intelligence-layer/src/tools/phase5-governance/ds-primitives/index.ts +416 -0
  258. package/figma-intelligence-layer/src/tools/phase5-governance/ds-scaffolder/index.ts +722 -0
  259. package/figma-intelligence-layer/src/tools/phase5-governance/ds-variables/index.ts +449 -0
  260. package/figma-intelligence-layer/src/tools/phase5-governance/health-report/index.ts +393 -0
  261. package/figma-intelligence-layer/src/tools/phase5-governance/taxonomy-docs/index.ts +406 -0
  262. package/figma-intelligence-layer/src/tools/phase5-governance/taxonomy-docs/renderers/figma-page.ts +292 -0
  263. package/figma-intelligence-layer/src/tools/phase5-governance/taxonomy-docs/renderers/json.ts +24 -0
  264. package/figma-intelligence-layer/src/tools/phase5-governance/taxonomy-docs/renderers/markdown.ts +172 -0
  265. package/figma-intelligence-layer/src/tools/phase5-governance/taxonomy-docs/renderers/naming-guide.ts +409 -0
  266. package/figma-intelligence-layer/src/tools/phase5-governance/token-analytics/index.ts +594 -0
  267. package/figma-intelligence-layer/src/tools/phase5-governance/token-docs/index.ts +710 -0
  268. package/figma-intelligence-layer/src/tools/phase5-governance/token-migrate/index.ts +458 -0
  269. package/figma-intelligence-layer/src/tools/phase5-governance/token-naming/index.ts +134 -0
  270. package/figma-intelligence-layer/tests/apg-doc.test.ts +101 -0
  271. package/figma-intelligence-layer/tests/design-system-context.test.ts +152 -0
  272. package/figma-intelligence-layer/tests/design-system-matcher.test.ts +144 -0
  273. package/figma-intelligence-layer/tests/figma-bridge.test.ts +83 -0
  274. package/figma-intelligence-layer/tests/generate-image-and-insert.test.ts +56 -0
  275. package/figma-intelligence-layer/tests/screen-cloner-regression.test.ts +69 -0
  276. package/figma-intelligence-layer/tests/smoke.test.ts +174 -0
  277. package/figma-intelligence-layer/tests/spec-generator.test.ts +127 -0
  278. package/figma-intelligence-layer/tests/token-migrate.test.ts +21 -0
  279. package/figma-intelligence-layer/tests/token-naming.test.ts +30 -0
  280. package/figma-intelligence-layer/tsconfig.json +19 -0
  281. package/package.json +35 -0
  282. package/scripts/clean-existing-chunks.js +179 -0
  283. package/scripts/connect-ai-tool.js +490 -0
  284. package/scripts/convert-hub-pdfs.js +425 -0
  285. package/scripts/figma-mcp-status.js +349 -0
  286. package/scripts/register-codex-mcp.js +96 -0
@@ -0,0 +1,243 @@
1
+ /**
2
+ * button.ts — Gold-standard design knowledge for Button components
3
+ */
4
+ import type { ComponentKnowledge } from "../types.js";
5
+
6
+ export const buttonKnowledge: ComponentKnowledge = {
7
+ description:
8
+ "Core interface primitive | Triggers actions | Primary CTA element",
9
+
10
+ stateSpecifications: [
11
+ {
12
+ state: "Default",
13
+ visualChange: "Solid fill with label text in contrasting color",
14
+ opacity: "1",
15
+ cursorWeb: "pointer",
16
+ usage: "Resting state — button is interactive and ready for activation",
17
+ },
18
+ {
19
+ state: "Hover",
20
+ visualChange: "Background darkens or lightens by one step on the color scale",
21
+ opacity: "1",
22
+ cursorWeb: "pointer",
23
+ usage: "Mouse cursor enters the button's hit area",
24
+ },
25
+ {
26
+ state: "Active",
27
+ visualChange: "Background shifts an additional step; slight scale-down (0.98) gives tactile feedback",
28
+ opacity: "1",
29
+ cursorWeb: "pointer",
30
+ usage: "Mouse button is held down or touch press is in progress",
31
+ },
32
+ {
33
+ state: "Disabled",
34
+ visualChange: "Background and text switch to muted/disabled tokens; no elevation",
35
+ opacity: "0.4",
36
+ cursorWeb: "not-allowed",
37
+ usage: "Action is unavailable due to missing prerequisites or permissions",
38
+ },
39
+ {
40
+ state: "Focus",
41
+ visualChange: "2px focus ring offset by 2px from the button edge, using $focus-ring token",
42
+ opacity: "1",
43
+ cursorWeb: "pointer",
44
+ usage: "Button receives keyboard focus via Tab key or programmatic focus call",
45
+ },
46
+ {
47
+ state: "Loading",
48
+ visualChange: "Label text replaced or overlaid by a spinner; button dimensions remain fixed",
49
+ opacity: "1",
50
+ cursorWeb: "wait",
51
+ usage: "Asynchronous action is in progress — button is temporarily non-interactive",
52
+ },
53
+ ],
54
+
55
+ propertyDescriptions: {
56
+ label: "Visible text rendered inside the button; should be action-oriented (e.g. 'Save', 'Submit')",
57
+ type: "Visual hierarchy variant — Primary, Secondary, Tertiary, or Danger — controls fill and border treatment",
58
+ size: "Dimensional preset controlling height, padding, font-size, and icon-size (Small, Medium, Large)",
59
+ disabled: "When true the button is non-interactive: muted visuals, pointer-events none, aria-disabled='true'",
60
+ loading: "When true the label is replaced with a spinner and the button ignores clicks until loading completes",
61
+ iconLeft: "Optional icon slot rendered before the label; expects an icon component instance or icon name string",
62
+ iconRight: "Optional icon slot rendered after the label; typically used for directional cues (arrows, chevrons)",
63
+ },
64
+
65
+ sizeSpecifications: [
66
+ {
67
+ size: "Small",
68
+ height: "32px",
69
+ paddingLR: "12px",
70
+ fontSize: "12px",
71
+ iconSize: "16px",
72
+ borderRadius: "6px",
73
+ },
74
+ {
75
+ size: "Medium",
76
+ height: "40px",
77
+ paddingLR: "16px",
78
+ fontSize: "14px",
79
+ iconSize: "20px",
80
+ borderRadius: "8px",
81
+ },
82
+ {
83
+ size: "Large",
84
+ height: "48px",
85
+ paddingLR: "20px",
86
+ fontSize: "16px",
87
+ iconSize: "24px",
88
+ borderRadius: "10px",
89
+ },
90
+ ],
91
+
92
+ designTokenBindings: [
93
+ {
94
+ property: "Background",
95
+ tokenName: "$button-primary-bg",
96
+ role: "Primary variant fill color",
97
+ fallback: "#2563EB",
98
+ },
99
+ {
100
+ property: "Text Color",
101
+ tokenName: "$button-primary-text",
102
+ role: "Label and icon color on primary variant",
103
+ fallback: "#FFFFFF",
104
+ },
105
+ {
106
+ property: "Border",
107
+ tokenName: "$button-secondary-border",
108
+ role: "Visible border on secondary and tertiary variants",
109
+ fallback: "#D0D5DD",
110
+ },
111
+ {
112
+ property: "Radius",
113
+ tokenName: "$radius-button",
114
+ role: "Corner rounding applied to all four corners equally",
115
+ fallback: "8px",
116
+ },
117
+ {
118
+ property: "Font Family",
119
+ tokenName: "$font-family-sans",
120
+ role: "Button label typeface",
121
+ fallback: "Inter, system-ui, sans-serif",
122
+ },
123
+ {
124
+ property: "Font Weight",
125
+ tokenName: "$font-weight-medium",
126
+ role: "Label weight — medium for readability at small sizes",
127
+ fallback: "500",
128
+ },
129
+ {
130
+ property: "Line Height",
131
+ tokenName: "$line-height-tight",
132
+ role: "Tight line height to vertically center single-line label",
133
+ fallback: "1.2",
134
+ },
135
+ {
136
+ property: "Transition",
137
+ tokenName: "$transition-interactive",
138
+ role: "Smooth state transitions for background, border, and shadow",
139
+ fallback: "150ms ease-in-out",
140
+ },
141
+ {
142
+ property: "Focus Ring",
143
+ tokenName: "$focus-ring",
144
+ role: "Keyboard focus indicator ring",
145
+ fallback: "0 0 0 2px #FFFFFF, 0 0 0 4px #2E90FA",
146
+ },
147
+ ],
148
+
149
+ structureRules: [
150
+ "Container uses horizontal Auto Layout with center alignment on both axes",
151
+ "Icon and label are direct children of the container — no intermediate wrappers",
152
+ "Spacing between icon and label uses the $spacing-xs token (4px default)",
153
+ "Touch target is at least 44x44px regardless of visual size (add transparent padding if needed)",
154
+ "Full-width variant sets container to fill-container on the horizontal axis",
155
+ "Icon-only variant removes the label layer; container padding becomes equal on all sides",
156
+ "Loading spinner replaces the label but preserves the container's intrinsic width to prevent layout shift",
157
+ ],
158
+
159
+ typeHierarchyRules: [
160
+ "Font weight is Medium (500) — never Bold for standard buttons",
161
+ "Text uses sentence case ('Save changes', not 'Save Changes' or 'SAVE CHANGES')",
162
+ "No underline on label text — underline is reserved for inline links",
163
+ "Single-line only; truncate with ellipsis if text overflows the max-width",
164
+ ],
165
+
166
+ interactionRules: [
167
+ { event: "Click / Tap", trigger: "pointerup inside button bounds", action: "Fire onClick handler; optionally enter loading state" },
168
+ { event: "Hover", trigger: "pointerenter", action: "Transition to hover background token" },
169
+ { event: "Mouse Down", trigger: "pointerdown", action: "Transition to active/pressed visual state" },
170
+ { event: "Focus", trigger: "Tab key or focus()", action: "Show focus ring; do not trigger click" },
171
+ { event: "Blur", trigger: "Focus moves away", action: "Remove focus ring" },
172
+ { event: "Keydown Enter", trigger: "Enter key while focused", action: "Fire onClick handler (same as click)" },
173
+ { event: "Keydown Space", trigger: "Space key while focused", action: "Fire onClick handler on key-up (native button behavior)" },
174
+ ],
175
+
176
+ contentGuidance: [
177
+ "Labels should be action-oriented verbs or short verb phrases: 'Save', 'Add to cart', 'Continue'",
178
+ "Avoid vague labels like 'Click here', 'Submit', or 'OK' — be specific about the action",
179
+ "Keep labels under 3 words when possible; 4-5 words is the practical maximum",
180
+ "Icons should support the text meaning, not replace it (except in icon-only buttons)",
181
+ "Icon-only buttons must have an aria-label describing the action",
182
+ ],
183
+
184
+ responsiveBehaviour: [
185
+ { breakpoint: "Mobile (<768px)", behavior: "Buttons expand to full width in stacked layouts; minimum height 48px for touch" },
186
+ { breakpoint: "Tablet (768-1023px)", behavior: "Buttons may be inline or full-width depending on context" },
187
+ { breakpoint: "Desktop (1024-1439px)", behavior: "Inline buttons with standard padding; group spacing follows $spacing-md" },
188
+ { breakpoint: "Ultra-wide (>=1440px)", behavior: "Button sizes remain capped — do not scale proportionally with viewport" },
189
+ ],
190
+
191
+ accessibilitySpec: {
192
+ intro:
193
+ "Buttons are one of the most critical interactive elements. Accessibility must be flawless to meet WCAG 2.1 compliance.",
194
+ requirements: [
195
+ { requirement: "Role", level: "A", notes: "Use native <button> element or role='button' with full keyboard handling" },
196
+ { requirement: "Focusable", level: "A", notes: "Must be reachable via Tab key; disabled buttons may use aria-disabled instead of removing from tab order" },
197
+ { requirement: "Keyboard Activation", level: "A", notes: "Enter and Space keys must trigger the same action as a click" },
198
+ { requirement: "Contrast Ratio", level: "AA", notes: "Text-to-background: 4.5:1 minimum; button boundary to surrounding surface: 3:1" },
199
+ { requirement: "Touch Target", level: "AA", notes: "Minimum 44x44px touch area per WCAG 2.5.5 (AAA recommends 48x48px)" },
200
+ { requirement: "ARIA Labels", level: "A", notes: "Icon-only buttons require aria-label; loading state should announce 'Loading' via aria-live region" },
201
+ ],
202
+ outro: [
203
+ "Ensure focus management returns focus to the button after modal dismissal or async action completion",
204
+ "Never remove the focus outline without providing an equally visible alternative indicator",
205
+ ],
206
+ },
207
+
208
+ qaAcceptanceCriteria: [
209
+ { check: "Visual Regression", platform: "All", expectedResult: "Button renders pixel-perfect against baseline for each variant and size" },
210
+ { check: "Hover State", platform: "Web", expectedResult: "Background transitions smoothly on mouse enter/leave" },
211
+ { check: "Active State", platform: "Web", expectedResult: "Pressed visual appears on pointerdown and reverts on pointerup" },
212
+ { check: "Focus State", platform: "Web", expectedResult: "Focus ring visible on Tab; hidden on mouse click (focus-visible)" },
213
+ { check: "Keyboard Activation", platform: "Web", expectedResult: "Enter and Space fire click handler; no double-fire on Space" },
214
+ { check: "Screen Reader", platform: "Web", expectedResult: "Announces role 'button', accessible name, and disabled/loading state" },
215
+ { check: "Disabled State", platform: "All", expectedResult: "Muted visuals; pointer-events none; aria-disabled='true'" },
216
+ { check: "Loading State", platform: "All", expectedResult: "Spinner visible; label hidden; button width unchanged; clicks ignored" },
217
+ { check: "Truncation", platform: "Web", expectedResult: "Long labels truncate with ellipsis; no line wrapping" },
218
+ { check: "Icon Alignment", platform: "All", expectedResult: "Icons vertically centered with label; correct spacing token applied" },
219
+ { check: "Touch Target Size", platform: "Mobile", expectedResult: "Hit area is at least 44x44px even for Small size" },
220
+ { check: "Contrast", platform: "All", expectedResult: "All variants pass 4.5:1 text contrast and 3:1 non-text contrast" },
221
+ { check: "RTL Support", platform: "Web", expectedResult: "Icon positions swap; padding mirrors; text alignment correct in RTL locales" },
222
+ ],
223
+
224
+ dos: [
225
+ "Use the Primary variant for the single most important action on the page",
226
+ "Use Secondary or Tertiary variants for supporting or less critical actions",
227
+ "Keep labels short and action-oriented — prefer verbs",
228
+ "Maintain consistent padding and never override spacing tokens",
229
+ "Use standard size presets (Small, Medium, Large) — avoid custom heights",
230
+ "Ensure sufficient color contrast between button fill and label text",
231
+ "Provide visual feedback for every interactive state (hover, active, focus, loading)",
232
+ ],
233
+
234
+ donts: [
235
+ "Do not place multiple Primary buttons in the same view or action group",
236
+ "Do not use vague labels like 'Click here', 'OK', or 'Submit' without context",
237
+ "Do not allow label text to wrap to multiple lines — truncate instead",
238
+ "Do not use buttons for navigation — use links or nav components instead",
239
+ "Do not disable a button without explaining why (use a tooltip or helper text)",
240
+ "Do not override design token colors with hard-coded hex values",
241
+ "Do not make buttons smaller than the minimum touch target (44x44px)",
242
+ ],
243
+ };
@@ -0,0 +1,307 @@
1
+ /**
2
+ * calendar.ts — Gold-standard design knowledge for Calendar (date picker grid) components
3
+ */
4
+ import type { ComponentKnowledge } from "../types.js";
5
+
6
+ export const calendarKnowledge: ComponentKnowledge = {
7
+ description:
8
+ "Month-view date grid | Single or range date selection | Interactive calendar for date picking with navigation controls",
9
+
10
+ stateSpecifications: [
11
+ {
12
+ state: "Today",
13
+ visualChange: "Day cell has a subtle ring or dot indicator distinguishing it from other days; may use a distinct text color",
14
+ opacity: "1",
15
+ cursorWeb: "pointer",
16
+ usage: "Marks the current date for orientation — not necessarily the selected date",
17
+ },
18
+ {
19
+ state: "Selected",
20
+ visualChange: "Day cell has filled primary background with white text; fully rounded circle or pill shape",
21
+ opacity: "1",
22
+ cursorWeb: "pointer",
23
+ usage: "The date the user has chosen as their selection (single mode)",
24
+ },
25
+ {
26
+ state: "Range Start",
27
+ visualChange: "Day cell has filled primary background; right side has a connecting highlight leading to range-end",
28
+ opacity: "1",
29
+ cursorWeb: "pointer",
30
+ usage: "First date in a selected range — left corner rounded, right side extends highlight",
31
+ },
32
+ {
33
+ state: "Range End",
34
+ visualChange: "Day cell has filled primary background; left side has a connecting highlight from range-start",
35
+ opacity: "1",
36
+ cursorWeb: "pointer",
37
+ usage: "Last date in a selected range — right corner rounded, left side extends highlight",
38
+ },
39
+ {
40
+ state: "In Range",
41
+ visualChange: "Day cell has a light tint background connecting range-start and range-end visually",
42
+ opacity: "1",
43
+ cursorWeb: "pointer",
44
+ usage: "Dates falling between range-start and range-end; subtle highlight shows continuity",
45
+ },
46
+ {
47
+ state: "Hover",
48
+ visualChange: "Day cell gains a subtle circular background tint; text color may intensify",
49
+ opacity: "1",
50
+ cursorWeb: "pointer",
51
+ usage: "Mouse cursor enters a selectable day cell",
52
+ },
53
+ {
54
+ state: "Focus",
55
+ visualChange: "2px focus ring around the focused day cell; focus is visible via keyboard navigation",
56
+ opacity: "1",
57
+ cursorWeb: "pointer",
58
+ usage: "Day cell receives keyboard focus via arrow key navigation (roving tabindex)",
59
+ },
60
+ {
61
+ state: "Disabled",
62
+ visualChange: "Day text is muted/grayed out; no hover effect; cell is not interactive",
63
+ opacity: "0.4",
64
+ cursorWeb: "not-allowed",
65
+ usage: "Date is outside the allowed range (before minDate or after maxDate) or blocked by business logic",
66
+ },
67
+ {
68
+ state: "Outside Month",
69
+ visualChange: "Day numbers from the previous/next month are shown in a muted color to fill the grid",
70
+ opacity: "0.3",
71
+ cursorWeb: "pointer",
72
+ usage: "Dates from adjacent months visible in the grid; may or may not be selectable depending on configuration",
73
+ },
74
+ ],
75
+
76
+ propertyDescriptions: {
77
+ value: "Currently selected date (single mode) or date tuple [start, end] (range mode); controlled by parent component",
78
+ type: "Selection mode — 'single' for picking one date or 'range' for selecting a start and end date",
79
+ minDate: "Earliest selectable date — dates before this are disabled; accepts Date object or ISO string",
80
+ maxDate: "Latest selectable date — dates after this are disabled; accepts Date object or ISO string",
81
+ locale: "Locale string (e.g. 'en-US', 'de-DE') controlling day/month names, first day of week, and date formatting",
82
+ onSelect: "Callback invoked when a date is selected, receiving the selected Date or [start, end] tuple",
83
+ month: "Currently displayed month (0-indexed); controls which month's grid is rendered",
84
+ year: "Currently displayed year; paired with month to determine the visible grid",
85
+ showOutsideDays: "When true, shows dates from the previous and next months to fill the grid rows",
86
+ weekStartsOn: "Day the week starts on — 0 for Sunday (US), 1 for Monday (ISO/EU); overrides locale default",
87
+ disabledDates: "Array of specific dates or date ranges that should be non-selectable within the allowed min/max range",
88
+ },
89
+
90
+ sizeSpecifications: [
91
+ {
92
+ size: "Small",
93
+ height: "280px",
94
+ paddingLR: "8px",
95
+ fontSize: "12px",
96
+ iconSize: "16px",
97
+ borderRadius: "50% (day cell)",
98
+ },
99
+ {
100
+ size: "Medium",
101
+ height: "320px",
102
+ paddingLR: "12px",
103
+ fontSize: "14px",
104
+ iconSize: "20px",
105
+ borderRadius: "50% (day cell)",
106
+ },
107
+ {
108
+ size: "Large",
109
+ height: "380px",
110
+ paddingLR: "16px",
111
+ fontSize: "16px",
112
+ iconSize: "24px",
113
+ borderRadius: "50% (day cell)",
114
+ },
115
+ ],
116
+
117
+ designTokenBindings: [
118
+ {
119
+ property: "Background",
120
+ tokenName: "$calendar-bg",
121
+ role: "Calendar container background",
122
+ fallback: "#FFFFFF",
123
+ },
124
+ {
125
+ property: "Day Text",
126
+ tokenName: "$calendar-day-text",
127
+ role: "Default day number text color",
128
+ fallback: "#344054",
129
+ },
130
+ {
131
+ property: "Day Hover",
132
+ tokenName: "$calendar-day-hover-bg",
133
+ role: "Circular background tint on day cell hover",
134
+ fallback: "#F2F4F7",
135
+ },
136
+ {
137
+ property: "Selected Background",
138
+ tokenName: "$calendar-selected-bg",
139
+ role: "Filled background for the selected day cell",
140
+ fallback: "#2563EB",
141
+ },
142
+ {
143
+ property: "Selected Text",
144
+ tokenName: "$calendar-selected-text",
145
+ role: "Text color on the selected day cell",
146
+ fallback: "#FFFFFF",
147
+ },
148
+ {
149
+ property: "Today Indicator",
150
+ tokenName: "$calendar-today-border",
151
+ role: "Ring or border color marking today's date",
152
+ fallback: "#2563EB",
153
+ },
154
+ {
155
+ property: "Range Fill",
156
+ tokenName: "$calendar-range-bg",
157
+ role: "Light tint background for dates within a selected range",
158
+ fallback: "#EFF8FF",
159
+ },
160
+ {
161
+ property: "Outside Month Text",
162
+ tokenName: "$calendar-outside-text",
163
+ role: "Muted text color for dates from adjacent months",
164
+ fallback: "#98A2B3",
165
+ },
166
+ {
167
+ property: "Disabled Text",
168
+ tokenName: "$calendar-disabled-text",
169
+ role: "Muted text color for non-selectable dates",
170
+ fallback: "#D0D5DD",
171
+ },
172
+ {
173
+ property: "Header Text",
174
+ tokenName: "$calendar-header-text",
175
+ role: "Month and year label text color in the navigation header",
176
+ fallback: "#101828",
177
+ },
178
+ {
179
+ property: "Weekday Header",
180
+ tokenName: "$calendar-weekday-text",
181
+ role: "Day-of-week column header text color (e.g. Mon, Tue)",
182
+ fallback: "#667085",
183
+ },
184
+ {
185
+ property: "Navigation Icon",
186
+ tokenName: "$calendar-nav-icon",
187
+ role: "Previous/next month arrow icon color",
188
+ fallback: "#667085",
189
+ },
190
+ {
191
+ property: "Focus Ring",
192
+ tokenName: "$focus-ring",
193
+ role: "Keyboard focus indicator around the focused day cell",
194
+ fallback: "0 0 0 2px #FFFFFF, 0 0 0 4px #2E90FA",
195
+ },
196
+ ],
197
+
198
+ structureRules: [
199
+ "Calendar container uses vertical Auto Layout: navigation header → weekday labels → day grid",
200
+ "Navigation header has horizontal layout: previous month button → month/year label (centered) → next month button",
201
+ "Weekday labels row shows abbreviated day names (Mon, Tue, ...) in a 7-column grid",
202
+ "Day grid is a 7-column grid with 5-6 rows depending on the month; each cell is a square",
203
+ "Day cells are uniformly sized squares with the day number centered both horizontally and vertically",
204
+ "Selected day cells use a fully circular background (border-radius: 50%)",
205
+ "Range selection fills the rectangular area between start and end with a connecting background tint",
206
+ "Range start has left-rounded corners; range end has right-rounded corners; in-between cells have no rounding",
207
+ "Navigation arrows are positioned at the far left and right of the header row",
208
+ "Today's date is marked with a subtle ring or dot indicator that does not conflict with the selected state",
209
+ ],
210
+
211
+ typeHierarchyRules: [
212
+ "Month/year label in the header uses SemiBold weight (600) at the standard fontSize for the size preset",
213
+ "Weekday labels use Medium weight (500) at one size smaller (e.g. 12px when day cells use 14px)",
214
+ "Day numbers use Regular weight (400) by default; selected day may use Medium (500)",
215
+ "Month/year text uses sentence case with full month name: 'January 2026', not 'JAN 2026'",
216
+ "Weekday labels use short abbreviations: 'Mon', 'Tue' — or single letters: 'M', 'T' for compact sizes",
217
+ ],
218
+
219
+ interactionRules: [
220
+ { event: "Click Day", trigger: "Pointer up on a selectable day cell", action: "Select the date; fire onSelect; update visual to selected state" },
221
+ { event: "Click Range Start", trigger: "First click in range mode", action: "Set range start; highlight the clicked date; wait for second click to set range end" },
222
+ { event: "Click Range End", trigger: "Second click in range mode", action: "Set range end; fill in-between dates with range highlight; fire onSelect with [start, end]" },
223
+ { event: "Previous Month", trigger: "Click previous arrow button", action: "Navigate to the previous month; update grid; maintain focus position if applicable" },
224
+ { event: "Next Month", trigger: "Click next arrow button", action: "Navigate to the next month; update grid; maintain focus position if applicable" },
225
+ { event: "Arrow Keys", trigger: "Arrow keys while a day cell is focused", action: "Move focus: Left/Right by 1 day, Up/Down by 1 week; cross month boundaries automatically" },
226
+ { event: "Page Up", trigger: "Page Up key while focused", action: "Navigate to the previous month, keeping the same day-of-month focused" },
227
+ { event: "Page Down", trigger: "Page Down key while focused", action: "Navigate to the next month, keeping the same day-of-month focused" },
228
+ { event: "Home", trigger: "Home key while focused", action: "Move focus to the first day of the current month" },
229
+ { event: "End", trigger: "End key while focused", action: "Move focus to the last day of the current month" },
230
+ { event: "Enter / Space", trigger: "Enter or Space on a focused day", action: "Select the focused date (equivalent to clicking)" },
231
+ { event: "Hover (Range)", trigger: "Hover over a day while range start is set but end is not", action: "Preview the range highlight between start and hovered date" },
232
+ ],
233
+
234
+ contentGuidance: [
235
+ "Display the full month name and year in the header for clarity: 'January 2026' not '01/2026'",
236
+ "Use locale-appropriate day abbreviations and first-day-of-week settings",
237
+ "Show outside-month dates in a muted style to provide context without confusing the current month",
238
+ "Clearly distinguish today's date from the selected date — they may not be the same",
239
+ "For range selection, show a preview highlight on hover so users can see the range before confirming",
240
+ "Display the selected date(s) in a summary below or beside the calendar when used in a date picker dropdown",
241
+ "Use month/year dropdowns or year navigation for selecting dates far from the current month",
242
+ ],
243
+
244
+ responsiveBehaviour: [
245
+ { breakpoint: "Mobile (<768px)", behavior: "Calendar takes full container width; day cells expand to fill; touch targets are at least 44x44px" },
246
+ { breakpoint: "Tablet (768-1023px)", behavior: "Calendar uses medium size; may display two months side-by-side for range selection" },
247
+ { breakpoint: "Desktop (1024-1439px)", behavior: "Standard calendar size; single month view for single selection; dual month for range" },
248
+ { breakpoint: "Ultra-wide (>=1440px)", behavior: "Calendar size remains fixed; does not scale with viewport; positioned near its trigger element" },
249
+ ],
250
+
251
+ accessibilitySpec: {
252
+ intro:
253
+ "Calendars are complex interactive widgets requiring robust keyboard navigation and ARIA semantics. The WAI-ARIA grid pattern with roving tabindex ensures keyboard users can navigate dates efficiently while screen readers announce date context.",
254
+ requirements: [
255
+ { requirement: "Grid Role", level: "A", notes: "Calendar grid must use role='grid' with each row as role='row' and each day cell as role='gridcell'" },
256
+ { requirement: "Roving Tabindex", level: "A", notes: "Only one day cell has tabindex='0' at a time; arrow keys move focus; Tab exits the calendar" },
257
+ { requirement: "Arrow Key Navigation", level: "A", notes: "Left/Right moves by day; Up/Down moves by week; navigation crosses month boundaries automatically" },
258
+ { requirement: "Page Navigation", level: "A", notes: "Page Up/Down navigates months; Shift+Page Up/Down navigates years" },
259
+ { requirement: "Accessible Labels", level: "A", notes: "Each day cell must have an accessible label including the full date (e.g. 'January 15, 2026')" },
260
+ { requirement: "Selected State", level: "A", notes: "Selected dates must have aria-selected='true'; range start/end should convey range context" },
261
+ { requirement: "Disabled Dates", level: "A", notes: "Disabled dates must have aria-disabled='true' and not respond to selection" },
262
+ { requirement: "Live Region", level: "AA", notes: "When the month changes, announce the new month/year via aria-live='polite'" },
263
+ { requirement: "Contrast", level: "AA", notes: "Day numbers must meet 4.5:1 text contrast; selected/today indicators must meet 3:1 non-text contrast" },
264
+ ],
265
+ outro: [
266
+ "Test keyboard navigation across month boundaries — arrow keys on the last day of a month should advance to the next month",
267
+ "Verify screen readers announce 'selected' for chosen dates and 'disabled' for unavailable dates",
268
+ "Ensure the month/year header is announced when navigating between months via Page Up/Down",
269
+ ],
270
+ },
271
+
272
+ qaAcceptanceCriteria: [
273
+ { check: "Month Rendering", platform: "All", expectedResult: "Correct number of days for each month; proper weekday alignment" },
274
+ { check: "Today Indicator", platform: "All", expectedResult: "Today's date is visually marked with a ring or dot; distinct from selected state" },
275
+ { check: "Single Selection", platform: "All", expectedResult: "Clicking a day selects it with filled circle; previous selection clears; onSelect fires" },
276
+ { check: "Range Selection", platform: "All", expectedResult: "First click sets start; second click sets end; range highlight fills between; onSelect fires with tuple" },
277
+ { check: "Range Preview", platform: "Web", expectedResult: "Hovering after range start shows preview highlight between start and hovered date" },
278
+ { check: "Month Navigation", platform: "All", expectedResult: "Previous/Next arrows change the displayed month; header updates correctly" },
279
+ { check: "Disabled Dates", platform: "All", expectedResult: "Dates outside min/max or in disabledDates array are muted and not clickable" },
280
+ { check: "Keyboard Navigation", platform: "Web", expectedResult: "Arrow keys move focus by day/week; Page Up/Down changes month; Home/End jump to first/last day" },
281
+ { check: "Cross-Month Navigation", platform: "Web", expectedResult: "Arrow keys past month boundary navigate to the next/previous month and update grid" },
282
+ { check: "Locale Support", platform: "All", expectedResult: "Day names, month names, and first day of week respect the locale setting" },
283
+ { check: "Screen Reader", platform: "Web", expectedResult: "Grid role announced; day cells include full date label; selected/disabled states announced" },
284
+ { check: "Contrast", platform: "All", expectedResult: "All day states pass 4.5:1 text contrast; selected/today indicators pass 3:1 non-text contrast" },
285
+ { check: "RTL Support", platform: "Web", expectedResult: "Calendar grid mirrors; navigation arrows swap sides; day order respects RTL reading direction" },
286
+ ],
287
+
288
+ dos: [
289
+ "Use the WAI-ARIA grid pattern with roving tabindex for keyboard navigation",
290
+ "Mark today's date distinctly from the selected date so users can orient themselves",
291
+ "Support full keyboard navigation including arrow keys, Page Up/Down, Home, and End",
292
+ "Announce month changes to screen readers via an aria-live region",
293
+ "Show a range preview on hover when the user has selected a range start but not yet an end",
294
+ "Respect locale settings for day names, month names, and first day of week",
295
+ "Provide accessible labels on each day cell with the full date (e.g. 'January 15, 2026')",
296
+ ],
297
+
298
+ donts: [
299
+ "Do not use a calendar for selecting dates far in the past or future — add year navigation or a text input alternative",
300
+ "Do not make day cells smaller than 32x32px on desktop or 44x44px on mobile/touch devices",
301
+ "Do not hide the month/year header — users need context for the displayed dates",
302
+ "Do not allow selection of disabled dates — they must be truly non-interactive",
303
+ "Do not rely on color alone to indicate today, selected, or range states — use shapes and indicators",
304
+ "Do not skip month boundary navigation — arrow keys must flow seamlessly across months",
305
+ "Do not use a calendar component for time selection — use a time picker component instead",
306
+ ],
307
+ };