@fldr/ui 0.0.0-stage → 0.3.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 (555) hide show
  1. package/CHANGELOG.md +2366 -0
  2. package/LICENSE +21 -0
  3. package/README.md +488 -2
  4. package/ai/USAGE.md +216 -0
  5. package/ai/component-registry.json +8694 -0
  6. package/ai/component-registry.md +11933 -0
  7. package/ai/schemas.ts +1239 -0
  8. package/bin/kumo.js +36 -0
  9. package/dist/.build-complete +1 -0
  10. package/dist/ai/schemas.d.ts +3229 -0
  11. package/dist/ai/schemas.js +5963 -0
  12. package/dist/blocks-source/delete-resource/delete-resource.test.tsx +21 -0
  13. package/dist/blocks-source/delete-resource/delete-resource.tsx +219 -0
  14. package/dist/blocks-source/page-header/page-header.tsx +99 -0
  15. package/dist/blocks-source/resource-list/resource-list.test.tsx +28 -0
  16. package/dist/blocks-source/resource-list/resource-list.tsx +66 -0
  17. package/dist/button-DzavLWXm.d.ts +227 -0
  18. package/dist/catalog.d.ts +380 -0
  19. package/dist/catalog.js +387 -0
  20. package/dist/chunks/AccordionPanelDataAttributes-mmrmkky28u1010l5.js +457 -0
  21. package/dist/chunks/AlertDialogTrigger-l1r1gbxcky1xq889.js +24 -0
  22. package/dist/chunks/AlertDialogTriggerDataAttributes-go49qon601catpgn.js +56 -0
  23. package/dist/chunks/AutocompleteItem-36ysm5nwbsd0snr6.js +70 -0
  24. package/dist/chunks/AutocompleteItemDataAttributes-n5rigpf0s9ylnwi3.js +232 -0
  25. package/dist/chunks/AutocompleteSeparator-bnqeqh7i983d92gx.js +12 -0
  26. package/dist/chunks/AvatarImageDataAttributes-jw70u384c83lhqfp.js +247 -0
  27. package/dist/chunks/ButtonDataAttributes-nceand1fi7lvnmkb.js +35 -0
  28. package/dist/chunks/CSPContext-iv67i0qqhihg8mur.js +11 -0
  29. package/dist/chunks/CSPProvider-finau3a8hnc9o2td.js +24 -0
  30. package/dist/chunks/CheckboxGroup-581mfftu99wvjb3a.js +190 -0
  31. package/dist/chunks/CheckboxGroupContext-jf1bt3znvqlhrql6.js +10 -0
  32. package/dist/chunks/CheckboxGroupDataAttributes-nskqcxts64symbvf.js +10 -0
  33. package/dist/chunks/CheckboxIndicator-i13dmhacfgqo328c.js +414 -0
  34. package/dist/chunks/CheckboxIndicatorDataAttributes-3p29ju7nkczz1l2y.js +85 -0
  35. package/dist/chunks/CollapsiblePanel-md5suzmtnsyz1kab.js +178 -0
  36. package/dist/chunks/CollapsibleRootDataAttributes-bynmgxmt4jikaoha.js +36 -0
  37. package/dist/chunks/ComboboxClear-ioejwvtnmqanph88.js +294 -0
  38. package/dist/chunks/ComboboxClearDataAttributes-lo0enstdmrqpywsy.js +402 -0
  39. package/dist/chunks/ComboboxEmpty-gkt1y5b81a4983v7.js +1950 -0
  40. package/dist/chunks/ComboboxItemIndicatorDataAttributes-iku7l9ig0ve09an4.js +259 -0
  41. package/dist/chunks/ComboboxPopup-n8cbgys9st446j1i.js +205 -0
  42. package/dist/chunks/CompositeItem-kepwg8jtvgap06o6.js +20 -0
  43. package/dist/chunks/CompositeList-gwuaf6d14s4da0j0.js +182 -0
  44. package/dist/chunks/CompositeListContext-bejvmlu39hsfjzgu.js +15 -0
  45. package/dist/chunks/CompositeRoot-dnlkb27uw4g5aocf.js +223 -0
  46. package/dist/chunks/CompositeRootContext-obm54j7y6s86qwhq.js +12 -0
  47. package/dist/chunks/ContextMenuTriggerDataAttributes-xwozccynxv6pk5s0.js +237 -0
  48. package/dist/chunks/DialogBackdropDataAttributes-jwqxd6jla03xh8ke.js +28 -0
  49. package/dist/chunks/DialogCloseDataAttributes-12m7gwh3i6fd7d05.js +76 -0
  50. package/dist/chunks/DialogPopup-n6w7b389e7bs0472.js +133 -0
  51. package/dist/chunks/DialogRoot-hkkqj7vcjpkx8qk8.js +16 -0
  52. package/dist/chunks/DialogTrigger-kpugfkbfswqrus4u.js +142 -0
  53. package/dist/chunks/DialogTriggerDataAttributes-bp9bu13cvwuddh5b.js +18 -0
  54. package/dist/chunks/DialogViewportDataAttributes-mma9emv1edsc1vuy.js +78 -0
  55. package/dist/chunks/DirectionContext-kpby968j030psajn.js +10 -0
  56. package/dist/chunks/DirectionProvider-cg0pwzgdyg6r73r6.js +21 -0
  57. package/dist/chunks/DrawerViewport-mzqpwvqtylnad8ib.js +1532 -0
  58. package/dist/chunks/DrawerViewportDataAttributes-dd9593zm9fl9vcsm.js +1072 -0
  59. package/dist/chunks/FieldControl-hjj2tcqruozadgdi.js +122 -0
  60. package/dist/chunks/FieldDescription-orix2gepowrp5ni4.js +122 -0
  61. package/dist/chunks/FieldItemContext-ohsf45im6xhpay40.js +10 -0
  62. package/dist/chunks/FieldItemDataAttributes-m52srx69pispz49i.js +283 -0
  63. package/dist/chunks/FieldLabel-fjc7tdis7rcbq8o4.js +353 -0
  64. package/dist/chunks/FieldsetLegend-gl9z9eezr0xg9zr7.js +61 -0
  65. package/dist/chunks/FieldsetLegendDataAttributes-fn20251jxjqkpkxm.js +17 -0
  66. package/dist/chunks/FieldsetRootContext-fphwizvcm55ydg94.js +12 -0
  67. package/dist/chunks/FloatingPortalLite-j7dsy7gokbxdoe1i.js +25 -0
  68. package/dist/chunks/FloatingRootStore-men6ufp3a2b296fh.js +840 -0
  69. package/dist/chunks/FloatingTree-kiyzavvaum442o1s.js +115 -0
  70. package/dist/chunks/Form-oz425k7r4abea8o4.js +113 -0
  71. package/dist/chunks/FormContext-jv19engyccpf6xcl.js +18 -0
  72. package/dist/chunks/Input-ozudotydd679ly63.js +20 -0
  73. package/dist/chunks/InputDataAttributes-oy8t6q5y5t8ik02j.js +42 -0
  74. package/dist/chunks/ItemIndicator-cvf8cw5fv5l3cd8j.js +37 -0
  75. package/dist/chunks/LabelableContext-dz4wz3lu3lgqusu7.js +135 -0
  76. package/dist/chunks/ListboxSeparator-skazx18vzzj7i9zp.js +21 -0
  77. package/dist/chunks/MenuClearDataAttributes-fo0pekd36n56mdxu.js +1645 -0
  78. package/dist/chunks/MenuSubmenuTrigger-hm5xbgik6aq95x35.js +1976 -0
  79. package/dist/chunks/MenuSubmenuTriggerDataAttributes-gdfxdjymgmnaxdds.js +372 -0
  80. package/dist/chunks/MenuTrigger-dlfvicsaggss0o9m.js +265 -0
  81. package/dist/chunks/Menubar-ja5int05ihjj0ra4.js +116 -0
  82. package/dist/chunks/MenubarContext-ooz0h08i55c8oip5.js +12 -0
  83. package/dist/chunks/MeterLabel-cykbkvqys5263z05.js +148 -0
  84. package/dist/chunks/NavigationMenuIconDataAttributes-l82pkpm61d0meqxf.js +1654 -0
  85. package/dist/chunks/NullStore-my62xo2vfcfkerri.js +110 -0
  86. package/dist/chunks/NumberFieldScrubAreaCursorDataAttributes-k2lsbk35svshnwf5.js +1493 -0
  87. package/dist/chunks/OTPFieldInputDataAttributes-gvgtu2gg85kgjzwr.js +683 -0
  88. package/dist/chunks/PopoverViewport-peh28i8q4hqfjy97.js +713 -0
  89. package/dist/chunks/PopoverViewportDataAttributes-gplhq9d7ffp9q8u3.js +329 -0
  90. package/dist/chunks/PrehydrationScript-hs2je3mndbxuts7w.js +78 -0
  91. package/dist/chunks/PreviewCardViewportDataAttributes-bgfwmyshey7fx6nr.js +914 -0
  92. package/dist/chunks/ProgressLabelDataAttributes-j8mutcz11ei0ohvj.js +287 -0
  93. package/dist/chunks/RadioGroup-kioqngmmuo7a1lfa.js +163 -0
  94. package/dist/chunks/RadioGroupContext-dr6uihsj7oky0eol.js +10 -0
  95. package/dist/chunks/RadioGroupDataAttributes-dpdr6xe4ve204qwb.js +10 -0
  96. package/dist/chunks/RadioIndicator-bhxqih8wzv7hyrec.js +299 -0
  97. package/dist/chunks/RadioIndicatorDataAttributes-n5yupp5psifu0d4f.js +80 -0
  98. package/dist/chunks/ScrollAreaThumb-hxig41yn4lrurd3o.js +928 -0
  99. package/dist/chunks/ScrollAreaThumbDataAttributes-gup5wfxvqye6jj27.js +137 -0
  100. package/dist/chunks/SelectScrollUpArrowDataAttributes-fce5i1afjkb0necr.js +473 -0
  101. package/dist/chunks/SelectSeparator-nnak70azojox8b2b.js +1632 -0
  102. package/dist/chunks/Separator-fhwve0tfny3tht3a.js +24 -0
  103. package/dist/chunks/SeparatorDataAttributes-ch6e63bas7zflw00.js +11 -0
  104. package/dist/chunks/SliderIndicator-h1o3qbrvr8x0t4t2.js +1171 -0
  105. package/dist/chunks/SliderIndicatorDataAttributes-ff2f1cjealif5nvo.js +240 -0
  106. package/dist/chunks/SwitchRoot-m4t2tq5zn5wibyxk.js +244 -0
  107. package/dist/chunks/SwitchThumbDataAttributes-f95ld864on9y6ptk.js +90 -0
  108. package/dist/chunks/TabsList-n5n93rxr4sy704u8.js +664 -0
  109. package/dist/chunks/TabsListDataAttributes-e03a7kbubuf02z1l.js +183 -0
  110. package/dist/chunks/ToastArrowDataAttributes-jbnvz3kp6a35slgj.js +136 -0
  111. package/dist/chunks/ToggleDataAttributes-jl9ojyvwgrvefke6.js +103 -0
  112. package/dist/chunks/ToggleGroupContext-hg8zbkgqpscqhz83.js +10 -0
  113. package/dist/chunks/ToggleGroupDataAttributes-n1dwona1alvabstl.js +102 -0
  114. package/dist/chunks/ToolbarGroupContext-eawva8xkxb4osbxb.js +10 -0
  115. package/dist/chunks/ToolbarInput-kyxl1be0p3cyuayp.js +174 -0
  116. package/dist/chunks/ToolbarInputDataAttributes-n4a18a4km735du04.js +150 -0
  117. package/dist/chunks/ToolbarRootContext-difqbj720teyt8lu.js +12 -0
  118. package/dist/chunks/TooltipPopup-furysmeyb68uycbz.js +839 -0
  119. package/dist/chunks/TooltipProvider-hyans0ens4axh1y8.js +61 -0
  120. package/dist/chunks/TooltipViewportDataAttributes-gkwbezdq40ssuevg.js +312 -0
  121. package/dist/chunks/adaptiveOriginMiddleware-m9tqzw58wya9sdds.js +51 -0
  122. package/dist/chunks/addEventListener-ku3x23446prmd1kz.js +13 -0
  123. package/dist/chunks/areArraysEqual-nnpg93s9g7aqcaoh.js +15 -0
  124. package/dist/chunks/autocomplete-gdd9aruremdgdvx7.js +152 -0
  125. package/dist/chunks/badge-gca8xfu79ne55d5k.js +165 -0
  126. package/dist/chunks/banner-mo1xl9ww734kgsqh.js +269 -0
  127. package/dist/chunks/breadcrumbs-z1jo40oxlw8e4eh4.js +159 -0
  128. package/dist/chunks/button-group-biv43ksvaipc3p5n.js +59 -0
  129. package/dist/chunks/button-hzvowfkbathmx8yg.js +274 -0
  130. package/dist/chunks/chart-dgh98nbzo2sux2bs.js +3985 -0
  131. package/dist/chunks/checkbox-eifiwbw34xwsikvf.js +211 -0
  132. package/dist/chunks/clamp-rcpupxvhqrn8uuyf.js +7 -0
  133. package/dist/chunks/clipboard-text-oukrnke1s3kebk3y.js +209 -0
  134. package/dist/chunks/cloudflare-logo-d8mid9xr190h78cu.js +186 -0
  135. package/dist/chunks/code-hp2x28uiufmk3elz.js +94 -0
  136. package/dist/chunks/collapsible-ic6813hc4yv5s5hv.js +185 -0
  137. package/dist/chunks/combobox-mzvobpvalz2gnpli.js +321 -0
  138. package/dist/chunks/command-palette-d45ueqbuxygu87ir.js +507 -0
  139. package/dist/chunks/composite-c11t1ok72s3cggjc.js +90 -0
  140. package/dist/chunks/constants-l10cgj6pyqg27jod.js +5 -0
  141. package/dist/chunks/createBaseUIEventDetails-nvee6bghv2reeqdb.js +50 -0
  142. package/dist/chunks/createItems-n07tfwx89cdoar18.js +323 -0
  143. package/dist/chunks/createToastManager-cxjmn4jx3ejh85fs.js +1225 -0
  144. package/dist/chunks/date-picker-ija2bz17ai6ypnao.js +6865 -0
  145. package/dist/chunks/date-range-picker-oivlshld01jbel29.js +336 -0
  146. package/dist/chunks/dialog-g7wavhkdv2gplwq9.js +173 -0
  147. package/dist/chunks/dropdown-m5a8nwer5hpvnkfk.js +384 -0
  148. package/dist/chunks/empty-e0onzpyokyl6h9bp.js +96 -0
  149. package/dist/chunks/engine-hzmefiqm63hu0c7i.js +10 -0
  150. package/dist/chunks/error-lbnic2b20qr3mukp.js +6 -0
  151. package/dist/chunks/field-fowmq5smvp17pnqe.js +75 -0
  152. package/dist/chunks/flow-fak0fyldoaozd32s.js +10290 -0
  153. package/dist/chunks/formatNumber-b4kjdsebslm2b3t0.js +21 -0
  154. package/dist/chunks/getCssDimensions-gckwdrp86f73cv51.js +21 -0
  155. package/dist/chunks/getElementTransform-cz3jyftv0x5io95f.js +38 -0
  156. package/dist/chunks/getFiniteAnimations-jwd833ybtz81j5f0.js +13 -0
  157. package/dist/chunks/getHighlightReason-fhc53kq6qakcct9s.js +15 -0
  158. package/dist/chunks/getPseudoElementBounds-csuw8kwsoeyxd5tv.js +37 -0
  159. package/dist/chunks/grid-nwiczrab3r4w0zr2.js +118 -0
  160. package/dist/chunks/highlighter-mouttug0tu8xg1i8.js +1364 -0
  161. package/dist/chunks/index.parts-db9pzsm9rrs9tp0t.js +200 -0
  162. package/dist/chunks/index.parts-ggacwr0yakuemead.js +24 -0
  163. package/dist/chunks/index.parts-pcg3pmf3yyro841t.js +13 -0
  164. package/dist/chunks/inertValue-n09gkjvwwa1kddov.js +9 -0
  165. package/dist/chunks/inline-copy-text-izxpvnrtebcqlquf.js +104 -0
  166. package/dist/chunks/input-group-h9fepskc84e1h11n.js +457 -0
  167. package/dist/chunks/input-kfi46426y22ocoo4.js +85 -0
  168. package/dist/chunks/input-m2tfec2viezoz9hh.js +146 -0
  169. package/dist/chunks/isElementDisabled-dyqutxpzdfppbohx.js +7 -0
  170. package/dist/chunks/itemEquality-ki3x4tzdhjlqjey6.js +56 -0
  171. package/dist/chunks/label-f18fnpbv85jddo4q.js +76 -0
  172. package/dist/chunks/layer-card-lsmeuqic9i1isv2b.js +74 -0
  173. package/dist/chunks/layer-dialog-ejtz9s7bbfhjk1md.js +414 -0
  174. package/dist/chunks/link-h84bkh8eem39p529.js +112 -0
  175. package/dist/chunks/link-provider-kbwllpbo24fvgioj.js +60 -0
  176. package/dist/chunks/loader-kv5nk8j8tsuesxqo.js +87 -0
  177. package/dist/chunks/locale-provider-j4ii538ntyok36r6.js +50 -0
  178. package/dist/chunks/menubar-gzlyhmmc4i24prn1.js +106 -0
  179. package/dist/chunks/mergeCleanups-nw73c6jfwl5tyhw4.js +15 -0
  180. package/dist/chunks/meter-poh8jpe0qtq6mvee.js +35 -0
  181. package/dist/chunks/pagination-lmogkvvtu19mnr7f.js +296 -0
  182. package/dist/chunks/popover-nqrt3ykqv6sic8pz.js +206 -0
  183. package/dist/chunks/popupHandle-dk3ixgc8flr7v971.js +177 -0
  184. package/dist/chunks/popupStoreUtils-czfnxn051xakask5.js +868 -0
  185. package/dist/chunks/portal-provider-eveknxf26oudn7pp.js +63 -0
  186. package/dist/chunks/radio-nf717i5ypsga9zdh.js +204 -0
  187. package/dist/chunks/reason-parts-hssx64rmlxyn6gw5.js +40 -0
  188. package/dist/chunks/resolve-variant-l6x5ksfrjtu4m66l.js +35 -0
  189. package/dist/chunks/resolveAriaLabelledBy-knaucrjrjwnk7tvs.js +10 -0
  190. package/dist/chunks/resolveValueLabel-ntacnb58mhka5gg0.js +70 -0
  191. package/dist/chunks/rolldown-runtime-hi7ti5xiuxsegr96.js +18 -0
  192. package/dist/chunks/safePolygon-ep4133qogeu5vjf3.js +661 -0
  193. package/dist/chunks/safeReact-ek77ilng4ekk7mgz.js +18 -0
  194. package/dist/chunks/scrollable-k784b35i80aolmvg.js +29 -0
  195. package/dist/chunks/select-lnekz415wm4v6d6m.js +279 -0
  196. package/dist/chunks/sensitive-input-dvwlnntm7rdudwp0.js +252 -0
  197. package/dist/chunks/serializeValue-d1otz2i7h5tygrwf.js +13 -0
  198. package/dist/chunks/sidebar-mhlgvpawixxoey2k.js +1466 -0
  199. package/dist/chunks/skeleton-line-kmhnp0lx3rxhioxa.js +74 -0
  200. package/dist/chunks/slider-e395gihi5cjd62ss.js +87 -0
  201. package/dist/chunks/stringifyLocale-gbxouqj7ol627jxh.js +9 -0
  202. package/dist/chunks/styles-eb8bvypmayf578jf.js +35 -0
  203. package/dist/chunks/surface-jr8x5hy0gucjk5ig.js +30 -0
  204. package/dist/chunks/switch-nc8thi7ogd51m3gi.js +202 -0
  205. package/dist/chunks/table-ngl1b5yc8mcur662.js +238 -0
  206. package/dist/chunks/table-of-contents-gkjv9ck8etbz64ej.js +234 -0
  207. package/dist/chunks/tabs-o59bv7348nh2gppm.js +280 -0
  208. package/dist/chunks/tag-input-lbx9yzt33d4wu07o.js +156 -0
  209. package/dist/chunks/text-nqum95flcp07ac9s.js +126 -0
  210. package/dist/chunks/toast-ljpenshot856xqq4.js +341 -0
  211. package/dist/chunks/toolbar-kh6pc12ii7b6dv1x.js +141 -0
  212. package/dist/chunks/tooltip-bcymn9bfyz29fvji.js +92 -0
  213. package/dist/chunks/unwrap-lazy-element-hzbdkmujhd7iksau.js +45 -0
  214. package/dist/chunks/use-copy-feedback-gl55ghst0csvpv4j.js +55 -0
  215. package/dist/chunks/useAnchoredPopupScrollLock-msm8tzkewysnunut.js +31 -0
  216. package/dist/chunks/useAnimationFrame-k9lqdj9quln3sd85.js +87 -0
  217. package/dist/chunks/useAriaLabelledBy-j3j9jqlr9ukyk08s.js +36 -0
  218. package/dist/chunks/useBaseUiId-nk4k7nj9h1cy76ny.js +13 -0
  219. package/dist/chunks/useButton-lklvdzuhvj22bx07.js +186 -0
  220. package/dist/chunks/useClick-pcbkcc7r620v1smu.js +87 -0
  221. package/dist/chunks/useCollapsiblePanel-lrfsgx21ds36cwlp.js +415 -0
  222. package/dist/chunks/useCompositeItem-2juex3zh9gyrs8e9.js +31 -0
  223. package/dist/chunks/useCompositeListItem-ekwo2j2rjkggg7xj.js +54 -0
  224. package/dist/chunks/useControlled-i3srnkxy598s0au9.js +52 -0
  225. package/dist/chunks/useFieldValidation-oe16jiigp971yrzr.js +224 -0
  226. package/dist/chunks/useFloatingRootContext-k676b6m7f80bdapd.js +51 -0
  227. package/dist/chunks/useFocus-mn7a9t9v6fnlb4mf.js +124 -0
  228. package/dist/chunks/useId-82z8yqlmc1hy1c5t.js +50 -0
  229. package/dist/chunks/useInitialLiveRegionTextMutation-nl2hus7zx1h7ggno.js +86 -0
  230. package/dist/chunks/useLabel-me6zzfvkypo458pi.js +58 -0
  231. package/dist/chunks/useLabelableId-bjeh6q3pgrqjb7er.js +56 -0
  232. package/dist/chunks/useListNavigation-hpddbd0cc9pvt461.js +441 -0
  233. package/dist/chunks/useOnMount-gxggz1m0n869s6r0.js +12 -0
  234. package/dist/chunks/useOpenChangeComplete-edtabjwqmechsyv6.js +129 -0
  235. package/dist/chunks/usePopupHandleStore-gawjmfjf1xdgiph3.js +27 -0
  236. package/dist/chunks/usePopupViewport-l6w01iohvzloghy8.js +367 -0
  237. package/dist/chunks/usePositioner-mzvgnazldqvy44z2.js +580 -0
  238. package/dist/chunks/usePressAndHold-k9ynk78pgf677kpx.js +179 -0
  239. package/dist/chunks/usePreviousValue-o6swt5tb7xhpdu4e.js +21 -0
  240. package/dist/chunks/useRegisterFieldControl-m1stc9l9y4cndf0k.js +40 -0
  241. package/dist/chunks/useRegisteredLabelId-b7u9ygya03448zzn.js +16 -0
  242. package/dist/chunks/useRender-h9ktka9xt4obdv6y.js +13 -0
  243. package/dist/chunks/useRenderDialogRoot-bsqrqpc1ddau7xg4.js +312 -0
  244. package/dist/chunks/useRenderElement-nkklxbq1rp7h2kw0.js +436 -0
  245. package/dist/chunks/useScrollLock-le7ajwlt7oh6fzxi.js +877 -0
  246. package/dist/chunks/useSetFieldFocused-fbvj7gcv67dqfkp0.js +35 -0
  247. package/dist/chunks/useStableCallback-le5qgj6p9l04729n.js +38 -0
  248. package/dist/chunks/useSwipeDismiss-e8tfxzlp05p86mgb.js +697 -0
  249. package/dist/chunks/useTimeout-f0ayn2l2l9aop4l8.js +43 -0
  250. package/dist/chunks/useTransitionStatus-disysoblzgk34w14.js +74 -0
  251. package/dist/chunks/useTriggerFocusGuards-dyd3hb1m8en8ct50.js +40 -0
  252. package/dist/chunks/useTriggerSwitchTransition-hk5j36hd5dq2ok6w.js +62 -0
  253. package/dist/chunks/useTypeahead-kfdsw1ksl5bgvvzl.js +111 -0
  254. package/dist/chunks/useValueAsRef-dv0tmfr1xlpzdlru.js +27 -0
  255. package/dist/chunks/useValueChanged-fjssa2v6d4w8y332.js +15 -0
  256. package/dist/chunks/utils-o44zfmzz9z7uyj1v.js +18 -0
  257. package/dist/chunks/valueToPercent-djk2mqnihth2uvf6.js +7 -0
  258. package/dist/chunks/vendor-floating-ui-fqblx3wa0r71mjoo.js +1458 -0
  259. package/dist/chunks/vendor-styling-gs32v7xt5znc8kg0.js +1167 -0
  260. package/dist/chunks/vendor-utils-io8z5lsfxq8m2dcc.js +660 -0
  261. package/dist/chunks/visuallyHidden-kzzs9hbe93is3rci.js +25 -0
  262. package/dist/code/server.d.ts +11 -0
  263. package/dist/code/server.js +18 -0
  264. package/dist/code.d.ts +65 -0
  265. package/dist/code.js +232 -0
  266. package/dist/command-line/cli.js +1705 -0
  267. package/dist/command-line/commands/add.js +282 -0
  268. package/dist/command-line/commands/ai.js +22 -0
  269. package/dist/command-line/commands/blocks.js +61 -0
  270. package/dist/command-line/commands/doc.js +167 -0
  271. package/dist/command-line/commands/init.js +95 -0
  272. package/dist/command-line/commands/ls.js +53 -0
  273. package/dist/command-line/commands/theme.js +850 -0
  274. package/dist/components/autocomplete.d.ts +2 -0
  275. package/dist/components/autocomplete.js +3 -0
  276. package/dist/components/badge.d.ts +2 -0
  277. package/dist/components/badge.js +3 -0
  278. package/dist/components/banner.d.ts +2 -0
  279. package/dist/components/banner.js +3 -0
  280. package/dist/components/breadcrumbs.d.ts +2 -0
  281. package/dist/components/breadcrumbs.js +3 -0
  282. package/dist/components/button-group.d.ts +2 -0
  283. package/dist/components/button-group.js +3 -0
  284. package/dist/components/button.d.ts +3 -0
  285. package/dist/components/button.js +3 -0
  286. package/dist/components/chart.d.ts +2 -0
  287. package/dist/components/chart.js +3 -0
  288. package/dist/components/checkbox.d.ts +2 -0
  289. package/dist/components/checkbox.js +3 -0
  290. package/dist/components/clipboard-text.d.ts +2 -0
  291. package/dist/components/clipboard-text.js +3 -0
  292. package/dist/components/cloudflare-logo.d.ts +2 -0
  293. package/dist/components/cloudflare-logo.js +3 -0
  294. package/dist/components/code.d.ts +2 -0
  295. package/dist/components/code.js +3 -0
  296. package/dist/components/collapsible.d.ts +2 -0
  297. package/dist/components/collapsible.js +3 -0
  298. package/dist/components/combobox.d.ts +2 -0
  299. package/dist/components/combobox.js +3 -0
  300. package/dist/components/command-palette.d.ts +2 -0
  301. package/dist/components/command-palette.js +3 -0
  302. package/dist/components/date-picker.d.ts +2 -0
  303. package/dist/components/date-picker.js +3 -0
  304. package/dist/components/date-range-picker.d.ts +2 -0
  305. package/dist/components/date-range-picker.js +3 -0
  306. package/dist/components/dialog.d.ts +2 -0
  307. package/dist/components/dialog.js +3 -0
  308. package/dist/components/dropdown.d.ts +2 -0
  309. package/dist/components/dropdown.js +3 -0
  310. package/dist/components/empty.d.ts +2 -0
  311. package/dist/components/empty.js +3 -0
  312. package/dist/components/field.d.ts +2 -0
  313. package/dist/components/field.js +3 -0
  314. package/dist/components/flow.d.ts +2 -0
  315. package/dist/components/flow.js +3 -0
  316. package/dist/components/grid.d.ts +2 -0
  317. package/dist/components/grid.js +3 -0
  318. package/dist/components/inline-copy-text.d.ts +2 -0
  319. package/dist/components/inline-copy-text.js +3 -0
  320. package/dist/components/input-group.d.ts +2 -0
  321. package/dist/components/input-group.js +3 -0
  322. package/dist/components/input.d.ts +4 -0
  323. package/dist/components/input.js +5 -0
  324. package/dist/components/label.d.ts +2 -0
  325. package/dist/components/label.js +3 -0
  326. package/dist/components/layer-card.d.ts +2 -0
  327. package/dist/components/layer-card.js +3 -0
  328. package/dist/components/layer-dialog.d.ts +2 -0
  329. package/dist/components/layer-dialog.js +3 -0
  330. package/dist/components/link.d.ts +67 -0
  331. package/dist/components/link.js +3 -0
  332. package/dist/components/loader.d.ts +2 -0
  333. package/dist/components/loader.js +4 -0
  334. package/dist/components/menubar.d.ts +2 -0
  335. package/dist/components/menubar.js +3 -0
  336. package/dist/components/meter.d.ts +2 -0
  337. package/dist/components/meter.js +3 -0
  338. package/dist/components/pagination.d.ts +2 -0
  339. package/dist/components/pagination.js +3 -0
  340. package/dist/components/popover.d.ts +2 -0
  341. package/dist/components/popover.js +3 -0
  342. package/dist/components/radio.d.ts +2 -0
  343. package/dist/components/radio.js +3 -0
  344. package/dist/components/select.d.ts +2 -0
  345. package/dist/components/select.js +3 -0
  346. package/dist/components/sensitive-input.d.ts +2 -0
  347. package/dist/components/sensitive-input.js +3 -0
  348. package/dist/components/sidebar.d.ts +2 -0
  349. package/dist/components/sidebar.js +3 -0
  350. package/dist/components/slider.d.ts +2 -0
  351. package/dist/components/slider.js +3 -0
  352. package/dist/components/surface.d.ts +2 -0
  353. package/dist/components/surface.js +3 -0
  354. package/dist/components/switch.d.ts +2 -0
  355. package/dist/components/switch.js +3 -0
  356. package/dist/components/table-of-contents.d.ts +2 -0
  357. package/dist/components/table-of-contents.js +3 -0
  358. package/dist/components/table.d.ts +2 -0
  359. package/dist/components/table.js +3 -0
  360. package/dist/components/tabs.d.ts +2 -0
  361. package/dist/components/tabs.js +3 -0
  362. package/dist/components/tag-input.d.ts +2 -0
  363. package/dist/components/tag-input.js +3 -0
  364. package/dist/components/text.d.ts +2 -0
  365. package/dist/components/text.js +3 -0
  366. package/dist/components/toast.d.ts +2 -0
  367. package/dist/components/toast.js +4 -0
  368. package/dist/components/toolbar.d.ts +2 -0
  369. package/dist/components/toolbar.js +3 -0
  370. package/dist/components/tooltip.d.ts +2 -0
  371. package/dist/components/tooltip.js +3 -0
  372. package/dist/config-BKj6nyHa.d.ts +620 -0
  373. package/dist/field-DIjlHM8W.d.ts +91 -0
  374. package/dist/highlighter-BT3TakhJ.d.ts +13 -0
  375. package/dist/index-2jvVmJ8P.d.ts +46 -0
  376. package/dist/index-5PpauI_2.d.ts +85 -0
  377. package/dist/index-AMEc1MEg.d.ts +180 -0
  378. package/dist/index-AUC5xRcO.d.ts +236 -0
  379. package/dist/index-B7epkoHc.d.ts +72 -0
  380. package/dist/index-B9-RdY6D.d.ts +75 -0
  381. package/dist/index-BD-gTiEv.d.ts +71 -0
  382. package/dist/index-BK1tZgmP.d.ts +426 -0
  383. package/dist/index-BVgXnR1V.d.ts +137 -0
  384. package/dist/index-BW1HVU7T.d.ts +119 -0
  385. package/dist/index-BWe6haHU.d.ts +64 -0
  386. package/dist/index-BkTAB4wj.d.ts +673 -0
  387. package/dist/index-Bwhwpw_j.d.ts +189 -0
  388. package/dist/index-BzE0aNpx.d.ts +143 -0
  389. package/dist/index-C7RoG_CH.d.ts +57 -0
  390. package/dist/index-CE09bLNb.d.ts +72 -0
  391. package/dist/index-CJRe-8P-.d.ts +174 -0
  392. package/dist/index-CNL6VDYZ.d.ts +138 -0
  393. package/dist/index-CReGk3Dc.d.ts +91 -0
  394. package/dist/index-CU_lnxg7.d.ts +287 -0
  395. package/dist/index-CYoiniZ4.d.ts +135 -0
  396. package/dist/index-ClS-eFxE.d.ts +104 -0
  397. package/dist/index-CzIWigmH.d.ts +62 -0
  398. package/dist/index-CzTgKPh-.d.ts +105 -0
  399. package/dist/index-D2Gvly0i.d.ts +96 -0
  400. package/dist/index-DIV3riUd.d.ts +148 -0
  401. package/dist/index-DL1-uSuH.d.ts +1 -0
  402. package/dist/index-DYYiDxZs.d.ts +243 -0
  403. package/dist/index-DjSGDESy.d.ts +222 -0
  404. package/dist/index-Dmbgjww7.d.ts +157 -0
  405. package/dist/index-DwNMa4LN.d.ts +166 -0
  406. package/dist/index-Dx7hOWUc.d.ts +93 -0
  407. package/dist/index-DxOyYZaJ.d.ts +251 -0
  408. package/dist/index-NnHba-T1.d.ts +136 -0
  409. package/dist/index-RP_rt8vB.d.ts +140 -0
  410. package/dist/index-T1sSoiWG.d.ts +184 -0
  411. package/dist/index-aahL-0Zw.d.ts +60 -0
  412. package/dist/index-bBPKMepR.d.ts +73 -0
  413. package/dist/index-g-eFm1Bq.d.ts +877 -0
  414. package/dist/index-gYC6cQVO.d.ts +105 -0
  415. package/dist/index-lOWfpkxK.d.ts +118 -0
  416. package/dist/index-pjdgauIH.d.ts +170 -0
  417. package/dist/index-yK3Hayg_.d.ts +40 -0
  418. package/dist/index.d.ts +108 -0
  419. package/dist/index.js +207 -0
  420. package/dist/input-BeWEb-jD.d.ts +122 -0
  421. package/dist/input-group-8gEtPiKw.d.ts +100 -0
  422. package/dist/layer-card-BNIn9pqy.d.ts +56 -0
  423. package/dist/link-provider-tz-NJp9x.d.ts +67 -0
  424. package/dist/locale-provider-CHMCQ0-J.d.ts +40 -0
  425. package/dist/panda.d.ts +25 -0
  426. package/dist/panda.js +32 -0
  427. package/dist/portal-provider-BAqPpq_a.d.ts +55 -0
  428. package/dist/primitives/accordion.d.ts +1 -0
  429. package/dist/primitives/accordion.js +3 -0
  430. package/dist/primitives/alert-dialog.d.ts +1 -0
  431. package/dist/primitives/alert-dialog.js +8 -0
  432. package/dist/primitives/autocomplete.d.ts +1 -0
  433. package/dist/primitives/autocomplete.js +6 -0
  434. package/dist/primitives/avatar.d.ts +1 -0
  435. package/dist/primitives/avatar.js +3 -0
  436. package/dist/primitives/button.d.ts +1 -0
  437. package/dist/primitives/button.js +3 -0
  438. package/dist/primitives/checkbox-group.d.ts +1 -0
  439. package/dist/primitives/checkbox-group.js +4 -0
  440. package/dist/primitives/checkbox.d.ts +1 -0
  441. package/dist/primitives/checkbox.js +4 -0
  442. package/dist/primitives/collapsible.d.ts +1 -0
  443. package/dist/primitives/collapsible.js +5 -0
  444. package/dist/primitives/combobox.d.ts +1 -0
  445. package/dist/primitives/combobox.js +6 -0
  446. package/dist/primitives/context-menu.d.ts +1 -0
  447. package/dist/primitives/context-menu.js +6 -0
  448. package/dist/primitives/csp-provider.d.ts +1 -0
  449. package/dist/primitives/csp-provider.js +3 -0
  450. package/dist/primitives/dialog.d.ts +1 -0
  451. package/dist/primitives/dialog.js +9 -0
  452. package/dist/primitives/direction-provider.d.ts +1 -0
  453. package/dist/primitives/direction-provider.js +4 -0
  454. package/dist/primitives/drawer.d.ts +1 -0
  455. package/dist/primitives/drawer.js +6 -0
  456. package/dist/primitives/field.d.ts +1 -0
  457. package/dist/primitives/field.js +4 -0
  458. package/dist/primitives/fieldset.d.ts +1 -0
  459. package/dist/primitives/fieldset.js +3 -0
  460. package/dist/primitives/form.d.ts +1 -0
  461. package/dist/primitives/form.js +3 -0
  462. package/dist/primitives/input.d.ts +1 -0
  463. package/dist/primitives/input.js +4 -0
  464. package/dist/primitives/menu.d.ts +1 -0
  465. package/dist/primitives/menu.js +6 -0
  466. package/dist/primitives/menubar.d.ts +1 -0
  467. package/dist/primitives/menubar.js +3 -0
  468. package/dist/primitives/meter.d.ts +1 -0
  469. package/dist/primitives/meter.js +3 -0
  470. package/dist/primitives/navigation-menu.d.ts +1 -0
  471. package/dist/primitives/navigation-menu.js +3 -0
  472. package/dist/primitives/number-field.d.ts +1 -0
  473. package/dist/primitives/number-field.js +3 -0
  474. package/dist/primitives/otp-field.d.ts +3 -0
  475. package/dist/primitives/otp-field.js +4 -0
  476. package/dist/primitives/popover.d.ts +1 -0
  477. package/dist/primitives/popover.js +3 -0
  478. package/dist/primitives/preview-card.d.ts +1 -0
  479. package/dist/primitives/preview-card.js +3 -0
  480. package/dist/primitives/progress.d.ts +1 -0
  481. package/dist/primitives/progress.js +3 -0
  482. package/dist/primitives/radio-group.d.ts +1 -0
  483. package/dist/primitives/radio-group.js +4 -0
  484. package/dist/primitives/radio.d.ts +1 -0
  485. package/dist/primitives/radio.js +4 -0
  486. package/dist/primitives/scroll-area.d.ts +1 -0
  487. package/dist/primitives/scroll-area.js +4 -0
  488. package/dist/primitives/select.d.ts +1 -0
  489. package/dist/primitives/select.js +5 -0
  490. package/dist/primitives/separator.d.ts +1 -0
  491. package/dist/primitives/separator.js +4 -0
  492. package/dist/primitives/slider.d.ts +1 -0
  493. package/dist/primitives/slider.js +4 -0
  494. package/dist/primitives/switch.d.ts +1 -0
  495. package/dist/primitives/switch.js +4 -0
  496. package/dist/primitives/tabs.d.ts +1 -0
  497. package/dist/primitives/tabs.js +4 -0
  498. package/dist/primitives/toast.d.ts +1 -0
  499. package/dist/primitives/toast.js +5 -0
  500. package/dist/primitives/toggle-group.d.ts +1 -0
  501. package/dist/primitives/toggle-group.js +3 -0
  502. package/dist/primitives/toggle.d.ts +1 -0
  503. package/dist/primitives/toggle.js +3 -0
  504. package/dist/primitives/toolbar.d.ts +1 -0
  505. package/dist/primitives/toolbar.js +3 -0
  506. package/dist/primitives/tooltip.d.ts +1 -0
  507. package/dist/primitives/tooltip.js +4 -0
  508. package/dist/primitives.d.ts +42 -0
  509. package/dist/primitives.js +71 -0
  510. package/dist/registry.d.ts +2 -0
  511. package/dist/registry.js +1 -0
  512. package/dist/scripts/theme-generator/config.d.ts +2 -0
  513. package/dist/scripts/theme-generator/config.js +487 -0
  514. package/dist/scripts/theme-generator/types.d.ts +2 -0
  515. package/dist/scripts/theme-generator/types.js +1 -0
  516. package/dist/styles/kumo-binding.css +491 -0
  517. package/dist/styles/kumo-standalone.css +2 -0
  518. package/dist/styles/kumo.css +135 -0
  519. package/dist/styles/theme-code.css +142 -0
  520. package/dist/styles/theme-fedramp.css +31 -0
  521. package/dist/styles/theme-fldr.css +481 -0
  522. package/dist/styles/theme-kumo.css +464 -0
  523. package/dist/text-CRRU2g-u.d.ts +183 -0
  524. package/dist/theming.d.ts +224 -0
  525. package/dist/theming.js +386 -0
  526. package/dist/tooltip-D_vhi1PN.d.ts +105 -0
  527. package/dist/types-CdzJnnIl.d.ts +193 -0
  528. package/dist/types-Cl4HuOrB.d.ts +84 -0
  529. package/dist/utils.d.ts +4 -0
  530. package/dist/utils.js +7 -0
  531. package/package.json +481 -3
  532. package/scripts/component-registry/cache.ts +123 -0
  533. package/scripts/component-registry/discovery.ts +560 -0
  534. package/scripts/component-registry/example-cleanup.ts +168 -0
  535. package/scripts/component-registry/index.test.ts +1075 -0
  536. package/scripts/component-registry/index.ts +1065 -0
  537. package/scripts/component-registry/markdown-generator.ts +222 -0
  538. package/scripts/component-registry/metadata.ts +1030 -0
  539. package/scripts/component-registry/props-filter.ts +312 -0
  540. package/scripts/component-registry/schema-generator.ts +333 -0
  541. package/scripts/component-registry/sub-components.ts +393 -0
  542. package/scripts/component-registry/types.ts +158 -0
  543. package/scripts/component-registry/utils.ts +280 -0
  544. package/scripts/component-registry/variant-parser.ts +262 -0
  545. package/scripts/css-build.ts +107 -0
  546. package/scripts/format-generated.ts +12 -0
  547. package/scripts/generate-globe-land-mask.mjs +80 -0
  548. package/scripts/generate-primitives.ts +196 -0
  549. package/scripts/publish-fldr.ts +120 -0
  550. package/scripts/theme-generator/config.ts +666 -0
  551. package/scripts/theme-generator/generate-css.test.ts +30 -0
  552. package/scripts/theme-generator/generate-css.ts +352 -0
  553. package/scripts/theme-generator/index.ts +175 -0
  554. package/scripts/theme-generator/migrate.ts +560 -0
  555. package/scripts/theme-generator/types.ts +92 -0
@@ -0,0 +1,1075 @@
1
+ /**
2
+ * Tests for component-registry utility functions.
3
+ *
4
+ * These tests cover the pure utility functions that will be extracted
5
+ * into separate modules. Writing tests first ensures we don't break
6
+ * functionality during the refactoring.
7
+ */
8
+
9
+ import { describe, it, expect } from "vite-plus/test";
10
+ import { detectComponentExportsFromIndex } from "./discovery.js";
11
+
12
+ // =============================================================================
13
+ // Tests for string transformation utilities
14
+ // =============================================================================
15
+
16
+ describe("toPascalCase", () => {
17
+ // Function: Convert kebab-case to PascalCase
18
+ // "clipboard-text" → "ClipboardText"
19
+
20
+ function toPascalCase(str: string): string {
21
+ return str
22
+ .split("-")
23
+ .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
24
+ .join("");
25
+ }
26
+
27
+ it("converts simple kebab-case to PascalCase", () => {
28
+ expect(toPascalCase("button")).toBe("Button");
29
+ });
30
+
31
+ it("converts multi-word kebab-case to PascalCase", () => {
32
+ expect(toPascalCase("clipboard-text")).toBe("ClipboardText");
33
+ });
34
+
35
+ it("converts triple-word kebab-case to PascalCase", () => {
36
+ expect(toPascalCase("date-range-picker")).toBe("DateRangePicker");
37
+ });
38
+
39
+ it("handles already-capitalized segments", () => {
40
+ expect(toPascalCase("page-header")).toBe("PageHeader");
41
+ });
42
+ });
43
+
44
+ describe("toScreamingSnakeCase", () => {
45
+ // Function: Convert PascalCase to SCREAMING_SNAKE_CASE
46
+ // "ClipboardText" → "CLIPBOARD_TEXT"
47
+
48
+ function toScreamingSnakeCase(str: string): string {
49
+ return str
50
+ .replace(/([a-z])([A-Z])/g, "$1_$2")
51
+ .replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2")
52
+ .toUpperCase();
53
+ }
54
+
55
+ it("converts simple PascalCase to SCREAMING_SNAKE_CASE", () => {
56
+ expect(toScreamingSnakeCase("Button")).toBe("BUTTON");
57
+ });
58
+
59
+ it("converts multi-word PascalCase to SCREAMING_SNAKE_CASE", () => {
60
+ expect(toScreamingSnakeCase("ClipboardText")).toBe("CLIPBOARD_TEXT");
61
+ });
62
+
63
+ it("converts triple-word PascalCase to SCREAMING_SNAKE_CASE", () => {
64
+ expect(toScreamingSnakeCase("DateRangePicker")).toBe("DATE_RANGE_PICKER");
65
+ });
66
+
67
+ it("handles consecutive uppercase letters", () => {
68
+ expect(toScreamingSnakeCase("HTMLParser")).toBe("HTML_PARSER");
69
+ });
70
+ });
71
+
72
+ // =============================================================================
73
+ // Tests for variant parsing utilities
74
+ // =============================================================================
75
+
76
+ describe("extractBalancedBraces", () => {
77
+ // Function: Extract a balanced brace block starting from a position
78
+
79
+ function extractBalancedBraces(
80
+ content: string,
81
+ startIndex: number,
82
+ ): string | null {
83
+ let depth = 0;
84
+ let start = -1;
85
+
86
+ for (let i = startIndex; i < content.length; i++) {
87
+ if (content[i] === "{") {
88
+ if (depth === 0) start = i;
89
+ depth++;
90
+ } else if (content[i] === "}") {
91
+ depth--;
92
+ if (depth === 0 && start !== -1) {
93
+ return content.substring(start, i + 1);
94
+ }
95
+ }
96
+ }
97
+ return null;
98
+ }
99
+
100
+ it("extracts simple object", () => {
101
+ const content = 'const x = { foo: "bar" };';
102
+ expect(extractBalancedBraces(content, 10)).toBe('{ foo: "bar" }');
103
+ });
104
+
105
+ it("extracts nested objects", () => {
106
+ const content = 'const x = { foo: { bar: "baz" } };';
107
+ expect(extractBalancedBraces(content, 10)).toBe('{ foo: { bar: "baz" } }');
108
+ });
109
+
110
+ it("extracts deeply nested objects", () => {
111
+ const content = "const x = { a: { b: { c: 1 } } };";
112
+ expect(extractBalancedBraces(content, 10)).toBe("{ a: { b: { c: 1 } } }");
113
+ });
114
+
115
+ it("returns null for unbalanced braces", () => {
116
+ const content = "const x = { foo:";
117
+ expect(extractBalancedBraces(content, 10)).toBeNull();
118
+ });
119
+
120
+ it("starts from correct position", () => {
121
+ const content = "a = {}; b = { inner: true };";
122
+ // Start after first object
123
+ expect(extractBalancedBraces(content, 12)).toBe("{ inner: true }");
124
+ });
125
+ });
126
+
127
+ describe("parseDefaultsObject", () => {
128
+ // Function: Parse a defaults object string into a key-value map
129
+
130
+ function parseDefaultsObject(objStr: string): Record<string, string> {
131
+ const result: Record<string, string> = {};
132
+ const propPattern = /(\w+)\s*:\s*["']([^"']*)["']/g;
133
+ let match: RegExpExecArray | null;
134
+
135
+ while ((match = propPattern.exec(objStr)) !== null) {
136
+ result[match[1]] = match[2];
137
+ }
138
+
139
+ return result;
140
+ }
141
+
142
+ it("parses simple defaults object", () => {
143
+ const objStr = '{ variant: "primary", size: "base" }';
144
+ expect(parseDefaultsObject(objStr)).toEqual({
145
+ variant: "primary",
146
+ size: "base",
147
+ });
148
+ });
149
+
150
+ it("handles single-quoted values", () => {
151
+ const objStr = "{ variant: 'secondary' }";
152
+ expect(parseDefaultsObject(objStr)).toEqual({ variant: "secondary" });
153
+ });
154
+
155
+ it("handles multi-line objects", () => {
156
+ const objStr = `{
157
+ variant: "ghost",
158
+ size: "lg",
159
+ shape: "round"
160
+ }`;
161
+ expect(parseDefaultsObject(objStr)).toEqual({
162
+ variant: "ghost",
163
+ size: "lg",
164
+ shape: "round",
165
+ });
166
+ });
167
+
168
+ it("returns empty object for empty input", () => {
169
+ expect(parseDefaultsObject("{}")).toEqual({});
170
+ });
171
+ });
172
+
173
+ // =============================================================================
174
+ // Tests for state class extraction
175
+ // =============================================================================
176
+
177
+ describe("extractStateClasses", () => {
178
+ // Function: Extract state-specific classes from a class string
179
+
180
+ function extractStateClasses(classString: string): Record<string, string> {
181
+ const states: Record<string, string> = {};
182
+ const classes = classString.split(/\s+/);
183
+
184
+ for (const cls of classes) {
185
+ if (!cls) continue;
186
+
187
+ if (cls.startsWith("hover:") || cls.match(/^\[&:hover[^\]]*\]:/)) {
188
+ states.hover = states.hover ? `${states.hover} ${cls}` : cls;
189
+ } else if (
190
+ cls.match(/^(focus|focus-visible|focus-within):/) ||
191
+ cls.match(/^\[&:focus(-visible|-within)?[^\]]*\]:/)
192
+ ) {
193
+ states.focus = states.focus ? `${states.focus} ${cls}` : cls;
194
+ } else if (cls.startsWith("active:")) {
195
+ states.active = states.active ? `${states.active} ${cls}` : cls;
196
+ } else if (cls.startsWith("disabled:")) {
197
+ states.disabled = states.disabled ? `${states.disabled} ${cls}` : cls;
198
+ } else if (cls.startsWith("not-disabled:")) {
199
+ states["not-disabled"] = states["not-disabled"]
200
+ ? `${states["not-disabled"]} ${cls}`
201
+ : cls;
202
+ } else if (cls.match(/^data-\[state=[^\]]+\]:/)) {
203
+ states["data-state"] = states["data-state"]
204
+ ? `${states["data-state"]} ${cls}`
205
+ : cls;
206
+ }
207
+ }
208
+
209
+ return states;
210
+ }
211
+
212
+ it("extracts hover state", () => {
213
+ const classes = "bg-kumo-brand hover:bg-primary-dark";
214
+ expect(extractStateClasses(classes)).toEqual({
215
+ hover: "hover:bg-primary-dark",
216
+ });
217
+ });
218
+
219
+ it("extracts focus state", () => {
220
+ const classes = "ring-kumo-line focus:ring-kumo-hairline";
221
+ expect(extractStateClasses(classes)).toEqual({
222
+ focus: "focus:ring-kumo-hairline",
223
+ });
224
+ });
225
+
226
+ it("extracts multiple states", () => {
227
+ const classes =
228
+ "bg-kumo-base hover:bg-kumo-elevated focus:ring-kumo-hairline disabled:opacity-50";
229
+ expect(extractStateClasses(classes)).toEqual({
230
+ hover: "hover:bg-kumo-elevated",
231
+ focus: "focus:ring-kumo-hairline",
232
+ disabled: "disabled:opacity-50",
233
+ });
234
+ });
235
+
236
+ it("handles focus-visible variant", () => {
237
+ const classes = "focus-visible:ring-2";
238
+ expect(extractStateClasses(classes)).toEqual({
239
+ focus: "focus-visible:ring-2",
240
+ });
241
+ });
242
+
243
+ it("handles complex selectors", () => {
244
+ const classes = "[&:hover>span]:text-white";
245
+ expect(extractStateClasses(classes)).toEqual({
246
+ hover: "[&:hover>span]:text-white",
247
+ });
248
+ });
249
+
250
+ it("returns empty object for no state classes", () => {
251
+ const classes = "bg-kumo-base text-kumo-default rounded-lg";
252
+ expect(extractStateClasses(classes)).toEqual({});
253
+ });
254
+
255
+ it("combines multiple classes of same state", () => {
256
+ const classes = "hover:bg-kumo-brand hover:text-white";
257
+ expect(extractStateClasses(classes)).toEqual({
258
+ hover: "hover:bg-kumo-brand hover:text-white",
259
+ });
260
+ });
261
+ });
262
+
263
+ // =============================================================================
264
+ // Tests for example cleanup utilities
265
+ // =============================================================================
266
+
267
+ describe("cleanupExample", () => {
268
+ // Function: Clean up extracted examples to fix common issues
269
+
270
+ function cleanupExample(example: string): string {
271
+ let cleaned = example;
272
+
273
+ // Fix stringified functions: prop="() => {}" -> prop={() => {}}
274
+ cleaned = cleaned.replace(/(\w+)="(\(\)\s*=>\s*\{[^}]*\})"/g, "$1={$2}");
275
+
276
+ // Fix stringified arrays: prop={`[...]`} -> prop={[...]}
277
+ cleaned = cleaned.replace(/(\w+)=\{`(\[[\s\S]*?\])`\}/g, "$1={$2}");
278
+
279
+ // Fix escaped template literals: \` -> `
280
+ cleaned = cleaned.replace(/\\`/g, "`");
281
+
282
+ // Fix double backticks
283
+ cleaned = cleaned.replace(/\{``/g, "{`");
284
+ cleaned = cleaned.replace(/``\}/g, "`}");
285
+
286
+ // Fix unquoted identifiers that should be strings
287
+ const identifierAsStringProps = ["label"];
288
+ for (const prop of identifierAsStringProps) {
289
+ const pattern = new RegExp(
290
+ `(${prop})=\\{([A-Z][a-z]+)\\}(?![\\w.])`,
291
+ "g",
292
+ );
293
+ cleaned = cleaned.replace(pattern, '$1="$2"');
294
+ }
295
+
296
+ return cleaned;
297
+ }
298
+
299
+ it("fixes stringified function props", () => {
300
+ const example = '<Button onClick="() => {}">Click</Button>';
301
+ expect(cleanupExample(example)).toBe(
302
+ "<Button onClick={() => {}}>Click</Button>",
303
+ );
304
+ });
305
+
306
+ it("fixes stringified array props", () => {
307
+ const example = '<Tabs tabs={`["one", "two"]`} />';
308
+ expect(cleanupExample(example)).toBe('<Tabs tabs={["one", "two"]} />');
309
+ });
310
+
311
+ it("fixes escaped template literals", () => {
312
+ const example = "<Code code={\\`const x = 1;\\`} />";
313
+ expect(cleanupExample(example)).toBe("<Code code={`const x = 1;`} />");
314
+ });
315
+
316
+ it("fixes unquoted label identifiers", () => {
317
+ const example = "<Checkbox label={Checked} />";
318
+ expect(cleanupExample(example)).toBe('<Checkbox label="Checked" />');
319
+ });
320
+
321
+ it("preserves already correct examples", () => {
322
+ const example = '<Button variant="primary">Submit</Button>';
323
+ expect(cleanupExample(example)).toBe(
324
+ '<Button variant="primary">Submit</Button>',
325
+ );
326
+ });
327
+ });
328
+
329
+ describe("shouldIncludeExample", () => {
330
+ // Function: Filter out problematic examples
331
+
332
+ function shouldIncludeExample(
333
+ example: string,
334
+ componentName: string,
335
+ ): boolean {
336
+ const undefinedComponents = [
337
+ "RefreshButton",
338
+ "LinkButton",
339
+ "DefaultMenuBar",
340
+ "ToastTriggerButton",
341
+ ];
342
+ for (const comp of undefinedComponents) {
343
+ if (example.includes(`<${comp}`)) {
344
+ return false;
345
+ }
346
+ }
347
+
348
+ if (example.trim().length < 10) {
349
+ return false;
350
+ }
351
+
352
+ const emptyPattern = new RegExp(`^<${componentName}\\s*/>$`);
353
+ if (emptyPattern.test(example.trim())) {
354
+ return false;
355
+ }
356
+
357
+ const undefinedVars = [
358
+ "args.placeholder",
359
+ "args.inputSide",
360
+ "botList",
361
+ "INITIAL_BOT_LIST",
362
+ ];
363
+ for (const varName of undefinedVars) {
364
+ if (example.includes(varName)) {
365
+ return false;
366
+ }
367
+ }
368
+
369
+ return true;
370
+ }
371
+
372
+ it("rejects examples with undefined components", () => {
373
+ expect(shouldIncludeExample("<RefreshButton />", "Button")).toBe(false);
374
+ expect(shouldIncludeExample("<DefaultMenuBar />", "MenuBar")).toBe(false);
375
+ });
376
+
377
+ it("rejects empty examples", () => {
378
+ expect(shouldIncludeExample("<Button />", "Button")).toBe(false);
379
+ expect(shouldIncludeExample("", "Button")).toBe(false);
380
+ });
381
+
382
+ it("rejects examples with undefined variables", () => {
383
+ expect(
384
+ shouldIncludeExample("<Input placeholder={args.placeholder} />", "Input"),
385
+ ).toBe(false);
386
+ });
387
+
388
+ it("accepts valid examples", () => {
389
+ expect(
390
+ shouldIncludeExample(
391
+ '<Button variant="primary">Submit</Button>',
392
+ "Button",
393
+ ),
394
+ ).toBe(true);
395
+ });
396
+ });
397
+
398
+ describe("getExampleSignature", () => {
399
+ // Function: Generate a signature for an example to detect near-duplicates
400
+
401
+ function getExampleSignature(example: string): string {
402
+ const propPattern = /(\w+)=["'{]/g;
403
+ const props: string[] = [];
404
+ let match: RegExpExecArray | null;
405
+ while ((match = propPattern.exec(example)) !== null) {
406
+ props.push(match[1]);
407
+ }
408
+ return props.sort().join(",");
409
+ }
410
+
411
+ it("extracts prop names as signature", () => {
412
+ expect(getExampleSignature('<Button variant="primary" size="lg" />')).toBe(
413
+ "size,variant",
414
+ );
415
+ });
416
+
417
+ it("handles single prop", () => {
418
+ expect(getExampleSignature('<Button variant="primary" />')).toBe("variant");
419
+ });
420
+
421
+ it("handles JSX expression props", () => {
422
+ expect(getExampleSignature("<Button onClick={() => {}} />")).toBe(
423
+ "onClick",
424
+ );
425
+ });
426
+
427
+ it("returns empty string for no props", () => {
428
+ expect(getExampleSignature("<Button>Click</Button>")).toBe("");
429
+ });
430
+ });
431
+
432
+ // =============================================================================
433
+ // Tests for props filtering utilities
434
+ // =============================================================================
435
+
436
+ describe("shouldSkipProp", () => {
437
+ // Constants used by the filter
438
+ const ALWAYS_SKIP_PROPS = new Set([
439
+ "key",
440
+ "ref",
441
+ "style",
442
+ "dangerouslySetInnerHTML",
443
+ ]);
444
+
445
+ const SKIP_PROP_PREFIXES = ["aria-", "data-", "on"];
446
+
447
+ const KEEP_PROPS = new Set([
448
+ "children",
449
+ "className",
450
+ "id",
451
+ "disabled",
452
+ "name",
453
+ "value",
454
+ "checked",
455
+ "required",
456
+ "placeholder",
457
+ "readOnly",
458
+ "type",
459
+ "size",
460
+ "title",
461
+ "label",
462
+ "href",
463
+ "lang",
464
+ "onClick",
465
+ "onChange",
466
+ "onSubmit",
467
+ ]);
468
+
469
+ const MINIMAL_SKIP_PROPS = new Set([
470
+ "accessKey",
471
+ "autoCapitalize",
472
+ "autoFocus",
473
+ "contentEditable",
474
+ "dir",
475
+ "draggable",
476
+ "hidden",
477
+ "spellCheck",
478
+ "tabIndex",
479
+ "translate",
480
+ ]);
481
+
482
+ function shouldSkipProp(propName: string): boolean {
483
+ if (KEEP_PROPS.has(propName)) {
484
+ return false;
485
+ }
486
+ if (ALWAYS_SKIP_PROPS.has(propName)) {
487
+ return true;
488
+ }
489
+ for (const prefix of SKIP_PROP_PREFIXES) {
490
+ if (propName.startsWith(prefix)) {
491
+ return true;
492
+ }
493
+ }
494
+ if (MINIMAL_SKIP_PROPS.has(propName)) {
495
+ return true;
496
+ }
497
+ return false;
498
+ }
499
+
500
+ it("keeps important props like children and className", () => {
501
+ expect(shouldSkipProp("children")).toBe(false);
502
+ expect(shouldSkipProp("className")).toBe(false);
503
+ expect(shouldSkipProp("disabled")).toBe(false);
504
+ });
505
+
506
+ it("keeps common event handlers", () => {
507
+ expect(shouldSkipProp("onClick")).toBe(false);
508
+ expect(shouldSkipProp("onChange")).toBe(false);
509
+ expect(shouldSkipProp("onSubmit")).toBe(false);
510
+ });
511
+
512
+ it("skips React internal props", () => {
513
+ expect(shouldSkipProp("key")).toBe(true);
514
+ expect(shouldSkipProp("ref")).toBe(true);
515
+ expect(shouldSkipProp("style")).toBe(true);
516
+ });
517
+
518
+ it("skips aria attributes", () => {
519
+ expect(shouldSkipProp("aria-label")).toBe(true);
520
+ expect(shouldSkipProp("aria-hidden")).toBe(true);
521
+ });
522
+
523
+ it("skips data attributes", () => {
524
+ expect(shouldSkipProp("data-testid")).toBe(true);
525
+ expect(shouldSkipProp("data-state")).toBe(true);
526
+ });
527
+
528
+ it("skips most event handlers except kept ones", () => {
529
+ expect(shouldSkipProp("onMouseDown")).toBe(true);
530
+ expect(shouldSkipProp("onKeyUp")).toBe(true);
531
+ });
532
+
533
+ it("skips common HTML attributes", () => {
534
+ expect(shouldSkipProp("accessKey")).toBe(true);
535
+ expect(shouldSkipProp("tabIndex")).toBe(true);
536
+ expect(shouldSkipProp("spellCheck")).toBe(true);
537
+ });
538
+ });
539
+
540
+ // =============================================================================
541
+ // Tests for path detection utilities
542
+ // =============================================================================
543
+
544
+ describe("getComponentNameFromPath", () => {
545
+ // Function: Extract component name from file path
546
+
547
+ function getComponentNameFromPath(filename: string): string | null {
548
+ const match = filename.match(/src\/components\/([^/]+)\/\1\.tsx$/);
549
+ if (!match) return null;
550
+ return match[1].toUpperCase().replace(/-/g, "_");
551
+ }
552
+
553
+ it("extracts component name from standard path", () => {
554
+ expect(getComponentNameFromPath("src/components/button/button.tsx")).toBe(
555
+ "BUTTON",
556
+ );
557
+ });
558
+
559
+ it("handles kebab-case component names", () => {
560
+ expect(
561
+ getComponentNameFromPath(
562
+ "src/components/clipboard-text/clipboard-text.tsx",
563
+ ),
564
+ ).toBe("CLIPBOARD_TEXT");
565
+ });
566
+
567
+ it("returns null for non-component files", () => {
568
+ expect(getComponentNameFromPath("src/utils/cn.ts")).toBeNull();
569
+ });
570
+
571
+ it("returns null for mismatched directory/file names", () => {
572
+ expect(
573
+ getComponentNameFromPath("src/components/button/types.tsx"),
574
+ ).toBeNull();
575
+ });
576
+
577
+ it("returns null for test files", () => {
578
+ expect(
579
+ getComponentNameFromPath("src/components/button/button.test.tsx"),
580
+ ).toBeNull();
581
+ });
582
+ });
583
+
584
+ describe("detectComponentExportsFromIndex", () => {
585
+ it("detects multiple components with matching props from a barrel", () => {
586
+ const dir = mkdtempSync(join(tmpdir(), "kumo-barrel-test-"));
587
+ try {
588
+ writeFileSync(
589
+ join(dir, "index.ts"),
590
+ `
591
+ export {
592
+ BubbleMap,
593
+ ChoroplethMap,
594
+ type MapGeoJson,
595
+ type BubbleMapProps,
596
+ type ChoroplethMapProps,
597
+ } from "./Maps";
598
+ export {
599
+ ServerChart,
600
+ type ServerChartProps,
601
+ } from "./ServerChart";
602
+ `,
603
+ );
604
+ writeFileSync(join(dir, "Maps.tsx"), "export const placeholder = true;");
605
+ writeFileSync(
606
+ join(dir, "ServerChart.ts"),
607
+ "export const placeholder = true;",
608
+ );
609
+
610
+ expect(detectComponentExportsFromIndex(dir)).toEqual([
611
+ {
612
+ componentName: "BubbleMap",
613
+ propsType: "BubbleMapProps",
614
+ sourceFile: "Maps.tsx",
615
+ },
616
+ {
617
+ componentName: "ChoroplethMap",
618
+ propsType: "ChoroplethMapProps",
619
+ sourceFile: "Maps.tsx",
620
+ },
621
+ {
622
+ componentName: "ServerChart",
623
+ propsType: "ServerChartProps",
624
+ sourceFile: "ServerChart.ts",
625
+ },
626
+ ]);
627
+ } finally {
628
+ rmSync(dir, { recursive: true });
629
+ }
630
+ });
631
+ });
632
+
633
+ // =============================================================================
634
+ // Tests for JSON Schema type conversion
635
+ // =============================================================================
636
+
637
+ describe("jsonSchemaTypeToString", () => {
638
+ // Function: Convert JSON Schema type to string representation
639
+
640
+ interface Definition {
641
+ $ref?: string;
642
+ enum?: unknown[];
643
+ type?: string | string[];
644
+ items?: Definition;
645
+ anyOf?: Definition[];
646
+ oneOf?: Definition[];
647
+ }
648
+
649
+ function jsonSchemaTypeToString(def: Definition): string {
650
+ if (def.$ref) {
651
+ const refName = decodeURIComponent(
652
+ def.$ref.split("/").pop() || "unknown",
653
+ );
654
+ if (refName.includes("ReactNode") || refName.includes("ReactElement")) {
655
+ return "ReactNode";
656
+ }
657
+ return refName;
658
+ }
659
+ if (def.enum) {
660
+ return "enum";
661
+ }
662
+ if (def.type === "array") {
663
+ const itemType = def.items
664
+ ? jsonSchemaTypeToString(def.items)
665
+ : "unknown";
666
+ return `${itemType}[]`;
667
+ }
668
+ if (def.anyOf || def.oneOf) {
669
+ const types = (def.anyOf || def.oneOf) as Definition[];
670
+ const typeStrings = types
671
+ .map((t) => jsonSchemaTypeToString(t))
672
+ .filter((t) => t !== "undefined" && t !== "null");
673
+ if (typeStrings.some((t) => t.includes("React"))) {
674
+ return "ReactNode";
675
+ }
676
+ return typeStrings.join(" | ");
677
+ }
678
+ if (def.type) {
679
+ return Array.isArray(def.type) ? def.type.join(" | ") : def.type;
680
+ }
681
+ return "unknown";
682
+ }
683
+
684
+ it("converts basic types", () => {
685
+ expect(jsonSchemaTypeToString({ type: "string" })).toBe("string");
686
+ expect(jsonSchemaTypeToString({ type: "number" })).toBe("number");
687
+ expect(jsonSchemaTypeToString({ type: "boolean" })).toBe("boolean");
688
+ });
689
+
690
+ it("converts array types", () => {
691
+ expect(
692
+ jsonSchemaTypeToString({ type: "array", items: { type: "string" } }),
693
+ ).toBe("string[]");
694
+ });
695
+
696
+ it("converts $ref to type name", () => {
697
+ expect(
698
+ jsonSchemaTypeToString({ $ref: "#/definitions/ButtonVariant" }),
699
+ ).toBe("ButtonVariant");
700
+ });
701
+
702
+ it("simplifies ReactNode references", () => {
703
+ expect(jsonSchemaTypeToString({ $ref: "#/definitions/ReactNode" })).toBe(
704
+ "ReactNode",
705
+ );
706
+ expect(jsonSchemaTypeToString({ $ref: "#/definitions/ReactElement" })).toBe(
707
+ "ReactNode",
708
+ );
709
+ });
710
+
711
+ it("converts enums", () => {
712
+ expect(jsonSchemaTypeToString({ enum: ["primary", "secondary"] })).toBe(
713
+ "enum",
714
+ );
715
+ });
716
+
717
+ it("converts union types", () => {
718
+ expect(
719
+ jsonSchemaTypeToString({
720
+ anyOf: [{ type: "string" }, { type: "number" }],
721
+ }),
722
+ ).toBe("string | number");
723
+ });
724
+
725
+ it("handles multiple types", () => {
726
+ expect(jsonSchemaTypeToString({ type: ["string", "null"] })).toBe(
727
+ "string | null",
728
+ );
729
+ });
730
+ });
731
+
732
+ // Tests for sub-component detection utilities
733
+
734
+ import { writeFileSync, unlinkSync, mkdtempSync, rmSync } from "node:fs";
735
+ import { join } from "node:path";
736
+ import { tmpdir } from "node:os";
737
+ import {
738
+ detectSubComponents,
739
+ extractSubComponentProps,
740
+ extractPropsFromInterface,
741
+ } from "./sub-components.js";
742
+
743
+ function writeTempFile(content: string): {
744
+ filePath: string;
745
+ cleanup: () => void;
746
+ } {
747
+ const dir = mkdtempSync(join(tmpdir(), "kumo-test-"));
748
+ const filePath = join(dir, "test.tsx");
749
+ writeFileSync(filePath, content);
750
+ return { filePath, cleanup: () => unlinkSync(filePath) };
751
+ }
752
+
753
+ const cliFlags = {
754
+ includeInheritedProps: false,
755
+ noCache: true,
756
+ verbose: false,
757
+ };
758
+
759
+ describe("detectSubComponents", () => {
760
+ it("detects sub-components from Object.assign with function declarations", () => {
761
+ const { filePath, cleanup } = writeTempFile(`
762
+ function GroupComponent({ legend, children }: GroupProps) {
763
+ return <div>{children}</div>;
764
+ }
765
+
766
+ const Root = () => <div />;
767
+
768
+ export const MyComponent = Object.assign(Root, {
769
+ Group: GroupComponent,
770
+ });
771
+ `);
772
+
773
+ try {
774
+ const result = detectSubComponents(filePath);
775
+ expect(result).toHaveLength(1);
776
+ expect(result[0].name).toBe("Group");
777
+ expect(result[0].valueName).toBe("GroupComponent");
778
+ expect(result[0].propsType).toBe("GroupProps");
779
+ } finally {
780
+ cleanup();
781
+ }
782
+ });
783
+
784
+ it("detects sub-components from Object.assign with multi-line forwardRef", () => {
785
+ const { filePath, cleanup } = writeTempFile(`
786
+ import { forwardRef } from "react";
787
+
788
+ export interface MyItemProps {
789
+ active?: boolean;
790
+ label: string;
791
+ }
792
+
793
+ const MyItem = forwardRef<
794
+ HTMLLIElement,
795
+ MyItemProps
796
+ >(({ active, label, ...props }, ref) => (
797
+ <li ref={ref} {...props}>{label}</li>
798
+ ));
799
+
800
+ const Root = forwardRef<HTMLElement, {}>(
801
+ (props, ref) => <nav ref={ref} {...props} />
802
+ );
803
+
804
+ export const MyComponent = Object.assign(Root, {
805
+ Item: MyItem,
806
+ });
807
+ `);
808
+
809
+ try {
810
+ const result = detectSubComponents(filePath);
811
+ expect(result).toHaveLength(1);
812
+ expect(result[0].name).toBe("Item");
813
+ expect(result[0].valueName).toBe("MyItem");
814
+ expect(result[0].propsType).toBe("MyItemProps");
815
+ } finally {
816
+ cleanup();
817
+ }
818
+ });
819
+
820
+ it("detects sub-components with single-line forwardRef generics", () => {
821
+ const { filePath, cleanup } = writeTempFile(`
822
+ import { forwardRef } from "react";
823
+
824
+ export interface CellProps { span?: number; }
825
+
826
+ const TableCell = forwardRef<HTMLTableCellElement, CellProps>((props, ref) => (
827
+ <td ref={ref} {...props} />
828
+ ));
829
+
830
+ const Root = forwardRef<HTMLTableElement, {}>((props, ref) => <table ref={ref} {...props} />);
831
+
832
+ export const Table = Object.assign(Root, {
833
+ Cell: TableCell,
834
+ });
835
+ `);
836
+
837
+ try {
838
+ const result = detectSubComponents(filePath);
839
+ expect(result).toHaveLength(1);
840
+ expect(result[0].name).toBe("Cell");
841
+ expect(result[0].valueName).toBe("TableCell");
842
+ expect(result[0].propsType).toBe("CellProps");
843
+ } finally {
844
+ cleanup();
845
+ }
846
+ });
847
+
848
+ it("populates valueName field for direct property assignment", () => {
849
+ const { filePath, cleanup } = writeTempFile(`
850
+ function Link({ href }: LinkProps) {
851
+ return <a href={href} />;
852
+ }
853
+
854
+ const Breadcrumbs = () => <nav />;
855
+ Breadcrumbs.Link = Link;
856
+ `);
857
+
858
+ try {
859
+ const result = detectSubComponents(filePath);
860
+ expect(result).toHaveLength(1);
861
+ expect(result[0].name).toBe("Link");
862
+ expect(result[0].valueName).toBe("Link");
863
+ } finally {
864
+ cleanup();
865
+ }
866
+ });
867
+ });
868
+
869
+ describe("extractSubComponentProps", () => {
870
+ it("extracts props from interface via propsType (forwardRef pattern)", () => {
871
+ const { filePath, cleanup } = writeTempFile(`
872
+ import { forwardRef } from "react";
873
+
874
+ export interface ItemProps {
875
+ active?: boolean;
876
+ label: string;
877
+ }
878
+
879
+ const MyItem = forwardRef<HTMLLIElement, ItemProps>(
880
+ ({ active, label, ...props }, ref) => <li ref={ref} {...props}>{label}</li>
881
+ );
882
+ `);
883
+
884
+ try {
885
+ const props = extractSubComponentProps(
886
+ filePath,
887
+ {
888
+ name: "Item",
889
+ valueName: "MyItem",
890
+ propsType: "ItemProps",
891
+ description: "Item sub-component",
892
+ isPassThrough: false,
893
+ },
894
+ cliFlags,
895
+ );
896
+
897
+ expect(props).toHaveProperty("active");
898
+ expect(props.active).toEqual({ type: "boolean", optional: true });
899
+ expect(props).toHaveProperty("label");
900
+ expect(props.label).toEqual({ type: "string", required: true });
901
+ } finally {
902
+ cleanup();
903
+ }
904
+ });
905
+
906
+ it("skips pass-through sub-components", () => {
907
+ const { filePath, cleanup } = writeTempFile("export const Foo = {};");
908
+
909
+ try {
910
+ const props = extractSubComponentProps(
911
+ filePath,
912
+ {
913
+ name: "Root",
914
+ valueName: "DialogBase.Root",
915
+ propsType: null,
916
+ description: "Root sub-component (wraps DialogBase)",
917
+ isPassThrough: true,
918
+ baseComponent: "DialogBase.Root",
919
+ },
920
+ cliFlags,
921
+ );
922
+
923
+ expect(props).toEqual({});
924
+ } finally {
925
+ cleanup();
926
+ }
927
+ });
928
+
929
+ it("uses valueName for inline props lookup when name doesn't match", () => {
930
+ const { filePath, cleanup } = writeTempFile(`
931
+ function TableOfContentsGroup({ label, href }: { label: string; href?: string }) {
932
+ return <div>{label}</div>;
933
+ }
934
+ `);
935
+
936
+ try {
937
+ const props = extractSubComponentProps(
938
+ filePath,
939
+ {
940
+ name: "Group",
941
+ valueName: "TableOfContentsGroup",
942
+ propsType: null,
943
+ description: "Group sub-component",
944
+ isPassThrough: false,
945
+ },
946
+ cliFlags,
947
+ );
948
+
949
+ expect(props).toHaveProperty("label");
950
+ expect(props.label).toEqual({ type: "string", required: true });
951
+ expect(props).toHaveProperty("href");
952
+ expect(props.href).toEqual({ type: "string", optional: true });
953
+ } finally {
954
+ cleanup();
955
+ }
956
+ });
957
+ });
958
+
959
+ describe("extractPropsFromInterface", () => {
960
+ it("extracts props from a simple interface", () => {
961
+ const content = `
962
+ interface MyProps {
963
+ label: string;
964
+ active?: boolean;
965
+ count: number;
966
+ }
967
+ `;
968
+ const props = extractPropsFromInterface(content, "MyProps", cliFlags);
969
+ expect(props).toEqual({
970
+ label: { type: "string", required: true },
971
+ active: { type: "boolean", optional: true },
972
+ count: { type: "number", required: true },
973
+ });
974
+ });
975
+
976
+ it("extracts props from interface with extends", () => {
977
+ const content = `
978
+ interface GroupProps extends BaseProps {
979
+ label: string;
980
+ href?: string;
981
+ }
982
+ `;
983
+ const props = extractPropsFromInterface(content, "GroupProps", cliFlags);
984
+ expect(props).toEqual({
985
+ label: { type: "string", required: true },
986
+ href: { type: "string", optional: true },
987
+ });
988
+ });
989
+
990
+ it("returns empty object when interface not found", () => {
991
+ const content = "interface OtherProps { foo: string; }";
992
+ const props = extractPropsFromInterface(content, "MyProps", cliFlags);
993
+ expect(props).toEqual({});
994
+ });
995
+
996
+ it("extracts documented props from a generic interface", () => {
997
+ const content = `
998
+ interface MapProps<T extends { id: string }> {
999
+ /** Raw data rows. */
1000
+ data: T[];
1001
+ /** Value accessor. */
1002
+ value: MapAccessor<T, number>;
1003
+ /** Show the tooltip. Default: true. */
1004
+ showTooltip?: boolean;
1005
+ /** Nested configuration. */
1006
+ config?: { item: { id: string }; enabled: boolean };
1007
+ }
1008
+ `;
1009
+ const props = extractPropsFromInterface(content, "MapProps", cliFlags);
1010
+ expect(props).toEqual({
1011
+ data: {
1012
+ type: "T[]",
1013
+ required: true,
1014
+ description: "Raw data rows.",
1015
+ },
1016
+ value: {
1017
+ type: "MapAccessor<T, number>",
1018
+ required: true,
1019
+ description: "Value accessor.",
1020
+ },
1021
+ showTooltip: {
1022
+ type: "boolean",
1023
+ optional: true,
1024
+ description: "Show the tooltip. Default: true.",
1025
+ },
1026
+ config: {
1027
+ type: "{ item: { id: string }; enabled: boolean }",
1028
+ optional: true,
1029
+ description: "Nested configuration.",
1030
+ },
1031
+ });
1032
+ });
1033
+ });
1034
+
1035
+ describe("SUB_COMPONENT_OVERRIDES", () => {
1036
+ it("declares a Tooltip.Provider entry that passes through to TooltipBase.Provider", async () => {
1037
+ const { SUB_COMPONENT_OVERRIDES, PASSTHROUGH_COMPONENT_DOCS } =
1038
+ await import("./metadata.js");
1039
+
1040
+ expect(SUB_COMPONENT_OVERRIDES.Tooltip).toBeDefined();
1041
+ const tooltipOverrides = SUB_COMPONENT_OVERRIDES.Tooltip;
1042
+ expect(tooltipOverrides).toHaveLength(1);
1043
+
1044
+ const provider = tooltipOverrides[0];
1045
+ expect(provider.name).toBe("Provider");
1046
+ expect(provider.valueName).toBe("TooltipProvider");
1047
+ expect(provider.isPassThrough).toBe(true);
1048
+ expect(provider.baseComponent).toBe("TooltipBase.Provider");
1049
+ expect(provider.propsType).toBeNull();
1050
+
1051
+ // The baseComponent must resolve to a documented passthrough entry so the
1052
+ // merge + lookup path in index.ts produces real docs, not an empty stub.
1053
+ expect(
1054
+ PASSTHROUGH_COMPONENT_DOCS[provider.baseComponent as string],
1055
+ ).toBeDefined();
1056
+ });
1057
+
1058
+ it("entries have the same shape as detectSubComponents() results", async () => {
1059
+ const { SUB_COMPONENT_OVERRIDES } = await import("./metadata.js");
1060
+
1061
+ for (const overrides of Object.values(SUB_COMPONENT_OVERRIDES)) {
1062
+ for (const entry of overrides) {
1063
+ // Required fields of SubComponentConfig.
1064
+ expect(typeof entry.name).toBe("string");
1065
+ expect(typeof entry.valueName).toBe("string");
1066
+ expect(typeof entry.description).toBe("string");
1067
+ expect(typeof entry.isPassThrough).toBe("boolean");
1068
+ // propsType may be a string or null.
1069
+ expect(
1070
+ entry.propsType === null || typeof entry.propsType === "string",
1071
+ ).toBe(true);
1072
+ }
1073
+ }
1074
+ });
1075
+ });