@yahoo/uds-create-config 2.45.0 → 3.0.1

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 (376) hide show
  1. package/README.md +129 -0
  2. package/dist/ai-lanes.d.ts +23 -0
  3. package/dist/ai-lanes.js +34 -0
  4. package/dist/authoring/define-component.d.ts +85 -0
  5. package/dist/configs/CanvasConfig.d.ts +3237 -0
  6. package/dist/configs/CanvasConfig.js +332 -0
  7. package/dist/configs/build-options.d.ts +10 -0
  8. package/dist/configs/build-options.js +68 -0
  9. package/dist/configs/platform.d.ts +15 -0
  10. package/dist/configs/platform.js +17 -0
  11. package/dist/configs/react-native-system.d.ts +3026 -0
  12. package/dist/configs/react-native-system.js +64 -0
  13. package/dist/configs/system.d.ts +2771 -0
  14. package/dist/configs/system.js +74 -0
  15. package/dist/css/properties.generated.d.ts +14 -0
  16. package/dist/css/properties.generated.js +6260 -0
  17. package/dist/css/value-type.d.ts +48 -0
  18. package/dist/css/value-type.js +131 -0
  19. package/dist/css/values.d.ts +33 -0
  20. package/dist/css/values.js +116 -0
  21. package/dist/entities/native/NativeModifier.d.ts +25 -0
  22. package/dist/entities/native/NativeModifier.js +41 -0
  23. package/dist/entities/native/NativeSettings.d.ts +44 -0
  24. package/dist/entities/native/NativeSettings.js +39 -0
  25. package/dist/entities/native/NativeStyleProperty.d.ts +355 -0
  26. package/dist/entities/native/NativeStyleProperty.js +28 -0
  27. package/dist/entities/native/NativeToken.d.ts +31 -0
  28. package/dist/entities/native/NativeToken.js +49 -0
  29. package/dist/entities/system/CanvasRole.d.ts +34 -0
  30. package/dist/entities/system/CanvasRole.js +45 -0
  31. package/dist/entities/system/Component.d.ts +1287 -0
  32. package/dist/entities/system/Component.js +1840 -0
  33. package/dist/entities/system/Composite.d.ts +12 -0
  34. package/dist/entities/system/Composite.js +26 -0
  35. package/dist/entities/system/Device.d.ts +11 -0
  36. package/dist/entities/system/Device.js +18 -0
  37. package/dist/entities/system/File.d.ts +72 -0
  38. package/dist/entities/system/File.js +136 -0
  39. package/dist/entities/system/Font.d.ts +48 -0
  40. package/dist/entities/system/Font.js +56 -0
  41. package/dist/entities/system/GlobalStyle.d.ts +26 -0
  42. package/dist/entities/system/GlobalStyle.js +54 -0
  43. package/dist/entities/system/Guidance.d.ts +85 -0
  44. package/dist/entities/system/Guidance.js +59 -0
  45. package/dist/entities/system/GuidanceStyle.d.ts +14 -0
  46. package/dist/entities/system/GuidanceStyle.js +8 -0
  47. package/dist/entities/system/Icon.d.ts +46 -0
  48. package/dist/entities/system/Icon.js +46 -0
  49. package/dist/entities/system/LinkedSystem.d.ts +504 -0
  50. package/dist/entities/system/LinkedSystem.js +814 -0
  51. package/dist/entities/system/Modifier.d.ts +92 -0
  52. package/dist/entities/system/Modifier.js +120 -0
  53. package/dist/entities/system/Motion.d.ts +28 -0
  54. package/dist/entities/system/Motion.js +48 -0
  55. package/dist/entities/system/Operation.d.ts +100 -0
  56. package/dist/entities/system/Operation.js +236 -0
  57. package/dist/entities/system/Package.d.ts +42 -0
  58. package/dist/entities/system/Package.js +75 -0
  59. package/dist/entities/system/Settings.d.ts +94 -0
  60. package/dist/entities/system/Settings.js +166 -0
  61. package/dist/entities/system/StyleProperty.d.ts +135 -0
  62. package/dist/entities/system/StyleProperty.js +438 -0
  63. package/dist/entities/system/Token.d.ts +67 -0
  64. package/dist/entities/system/Token.js +129 -0
  65. package/dist/entities/system/Tool.d.ts +134 -0
  66. package/dist/entities/system/Tool.js +124 -0
  67. package/dist/entities/system/color.d.ts +64 -0
  68. package/dist/entities/system/color.js +123 -0
  69. package/dist/entities/system/component-module.d.ts +63 -0
  70. package/dist/entities/system/component-module.js +258 -0
  71. package/dist/entities/system/copy-plan.d.ts +98 -0
  72. package/dist/entities/system/copy-plan.js +451 -0
  73. package/dist/entities/system/defineComponent.d.ts +428 -0
  74. package/dist/entities/system/defineComponent.js +337 -0
  75. package/dist/entities/system/element.d.ts +101 -0
  76. package/dist/entities/system/element.js +171 -0
  77. package/dist/entities/system/icon-library.d.ts +64 -0
  78. package/dist/entities/system/icon-library.js +112 -0
  79. package/dist/entities/system/icon-metadata.d.ts +72 -0
  80. package/dist/entities/system/icon-metadata.js +111 -0
  81. package/dist/entities/system/link-declaration.d.ts +27 -0
  82. package/dist/entities/system/link-declaration.js +64 -0
  83. package/dist/entities/system/link-plan.d.ts +160 -0
  84. package/dist/entities/system/link-plan.js +770 -0
  85. package/dist/entities/system/runtime-modules.d.ts +25 -0
  86. package/dist/entities/system/runtime-modules.js +38 -0
  87. package/dist/entities/system/style-bag.d.ts +20 -0
  88. package/dist/entities/system/style-bag.js +246 -0
  89. package/dist/entities/system/token-index.d.ts +89 -0
  90. package/dist/entities/system/token-index.js +112 -0
  91. package/dist/framework/Config.d.ts +2472 -0
  92. package/dist/framework/Config.js +5023 -0
  93. package/dist/framework/Entity.d.ts +127 -0
  94. package/dist/framework/Entity.js +125 -0
  95. package/dist/framework/authoring.d.ts +24 -0
  96. package/dist/framework/authoring.js +7 -0
  97. package/dist/framework/change-hooks.d.ts +119 -0
  98. package/dist/framework/change-hooks.js +131 -0
  99. package/dist/framework/changes.d.ts +88 -0
  100. package/dist/framework/changes.js +246 -0
  101. package/dist/framework/class-names.d.ts +260 -0
  102. package/dist/framework/class-names.js +630 -0
  103. package/dist/framework/coalesce.d.ts +25 -0
  104. package/dist/framework/coalesce.js +60 -0
  105. package/dist/framework/config-op.d.ts +76 -0
  106. package/dist/framework/config-op.js +43 -0
  107. package/dist/framework/config-operation-kind.d.ts +14 -0
  108. package/dist/framework/config-operation-kind.js +14 -0
  109. package/dist/framework/config-ops.d.ts +34 -0
  110. package/dist/framework/config-ops.js +187 -0
  111. package/dist/framework/defineConfig.d.ts +196 -0
  112. package/dist/framework/defineConfig.js +100 -0
  113. package/dist/framework/defineDerivedEntity.d.ts +74 -0
  114. package/dist/framework/defineDerivedEntity.js +83 -0
  115. package/dist/framework/defineEntity.d.ts +318 -0
  116. package/dist/framework/defineEntity.js +183 -0
  117. package/dist/framework/defineSubEntity.d.ts +148 -0
  118. package/dist/framework/defineSubEntity.js +121 -0
  119. package/dist/framework/derived-mutations.d.ts +20 -0
  120. package/dist/framework/derived-mutations.js +38 -0
  121. package/dist/framework/entity-search.d.ts +29 -0
  122. package/dist/framework/entity-search.js +117 -0
  123. package/dist/framework/inline-sources.d.ts +49 -0
  124. package/dist/framework/inline-sources.js +388 -0
  125. package/dist/framework/layer-styles.d.ts +25 -0
  126. package/dist/framework/layer-styles.js +49 -0
  127. package/dist/framework/memo.d.ts +48 -0
  128. package/dist/framework/memo.js +84 -0
  129. package/dist/framework/overlay.d.ts +49 -0
  130. package/dist/framework/overlay.js +17 -0
  131. package/dist/framework/plan.d.ts +49 -0
  132. package/dist/framework/plan.js +73 -0
  133. package/dist/framework/projections.d.ts +480 -0
  134. package/dist/framework/projections.js +974 -0
  135. package/dist/framework/prop-surface.d.ts +132 -0
  136. package/dist/framework/prop-surface.js +278 -0
  137. package/dist/framework/ref-graph.d.ts +71 -0
  138. package/dist/framework/ref-graph.js +158 -0
  139. package/dist/framework/ref-integrity.d.ts +55 -0
  140. package/dist/framework/ref-integrity.js +171 -0
  141. package/dist/framework/registered.d.ts +95 -0
  142. package/dist/framework/registry-dir.d.ts +42 -0
  143. package/dist/framework/registry-dir.js +48 -0
  144. package/dist/framework/registry.d.ts +300 -0
  145. package/dist/framework/registry.js +104 -0
  146. package/dist/framework/rejection.d.ts +58 -0
  147. package/dist/framework/rejection.js +111 -0
  148. package/dist/framework/rename-inference.d.ts +26 -0
  149. package/dist/framework/rename-inference.js +50 -0
  150. package/dist/framework/render-spec.d.ts +296 -0
  151. package/dist/framework/render-spec.js +809 -0
  152. package/dist/framework/schema-version.d.ts +140 -0
  153. package/dist/framework/schema-version.js +214 -0
  154. package/dist/framework/schemas.d.ts +109 -0
  155. package/dist/framework/schemas.js +615 -0
  156. package/dist/framework/session.d.ts +196 -0
  157. package/dist/framework/session.js +367 -0
  158. package/dist/framework/signature.d.ts +15 -0
  159. package/dist/framework/signature.js +83 -0
  160. package/dist/framework/snapshot.d.ts +115 -0
  161. package/dist/framework/snapshot.js +277 -0
  162. package/dist/framework/source-integrity.d.ts +226 -0
  163. package/dist/framework/source-integrity.js +478 -0
  164. package/dist/framework/sources.d.ts +211 -0
  165. package/dist/framework/sources.js +89 -0
  166. package/dist/framework/utils/compiled-schema.d.ts +23 -0
  167. package/dist/framework/utils/compiled-schema.js +46 -0
  168. package/dist/framework/utils/content-key.d.ts +15 -0
  169. package/dist/framework/utils/content-key.js +33 -0
  170. package/dist/framework/utils/enumerated.d.ts +13 -0
  171. package/dist/framework/utils/enumerated.js +19 -0
  172. package/dist/framework/utils/field-path.d.ts +95 -0
  173. package/dist/framework/utils/field-path.js +136 -0
  174. package/dist/framework/utils/field-schema.d.ts +55 -0
  175. package/dist/framework/utils/field-schema.js +183 -0
  176. package/dist/framework/utils/group.d.ts +37 -0
  177. package/dist/framework/utils/group.js +13 -0
  178. package/dist/framework/utils/package-path.d.ts +37 -0
  179. package/dist/framework/utils/package-path.js +61 -0
  180. package/dist/framework/utils/refs.d.ts +194 -0
  181. package/dist/framework/utils/refs.js +403 -0
  182. package/dist/framework/validate-spec.d.ts +27 -0
  183. package/dist/framework/validate-spec.js +45 -0
  184. package/dist/framework/value-domain.d.ts +26 -0
  185. package/dist/framework/value-domain.js +202 -0
  186. package/dist/framework/views-facade.d.ts +15 -0
  187. package/dist/framework/views-facade.js +19 -0
  188. package/dist/index.d.ts +90 -42
  189. package/dist/index.js +86 -37
  190. package/dist/migrations/2.0.0/raw-css.d.ts +11 -0
  191. package/dist/migrations/2.0.0/raw-css.js +72 -0
  192. package/dist/migrations/2.0.0/v1-artifact.d.ts +1559 -0
  193. package/dist/migrations/2.0.0/v1-artifact.js +1018 -0
  194. package/dist/migrations/20260908171448_settings_as_kind.d.ts +22 -0
  195. package/dist/migrations/20260908171448_settings_as_kind.js +89 -0
  196. package/dist/migrations/20260908194245_visible_state_pointer.d.ts +19 -0
  197. package/dist/migrations/20260908194245_visible_state_pointer.js +115 -0
  198. package/dist/migrations/20260909183001_icon_knockout_variants.d.ts +18 -0
  199. package/dist/migrations/20260909183001_icon_knockout_variants.js +8 -0
  200. package/dist/migrations/20260910212453_linked_system_link_ops.d.ts +13 -0
  201. package/dist/migrations/20260910212453_linked_system_link_ops.js +8 -0
  202. package/dist/migrations/index.d.ts +2 -0
  203. package/dist/migrations/index.js +2 -0
  204. package/dist/react-native/style-keys.generated.d.ts +10 -0
  205. package/dist/react-native/style-keys.generated.js +167 -0
  206. package/dist/renderer/RendererErrorBoundary.d.ts +32 -5
  207. package/dist/renderer/RendererErrorBoundary.js +59 -10
  208. package/dist/renderer/UdsRenderer.d.ts +11 -10
  209. package/dist/renderer/UdsRenderer.js +1 -1
  210. package/dist/renderer/assetEntries.d.ts +37 -0
  211. package/dist/renderer/assetEntries.js +39 -0
  212. package/dist/renderer/assetRenderable.d.ts +14 -6
  213. package/dist/renderer/assetRenderable.js +8 -2
  214. package/dist/renderer/componentEntry.d.ts +58 -0
  215. package/dist/renderer/componentEntry.js +71 -0
  216. package/dist/renderer/icon-library.d.ts +20 -0
  217. package/dist/renderer/index.d.ts +7 -7
  218. package/dist/renderer/index.js +5 -5
  219. package/dist/renderer/primitives/SlotRenderer.d.ts +1 -1
  220. package/dist/renderer/primitives/SlotRenderer.js +1 -1
  221. package/dist/renderer/runtimeComponent.d.ts +33 -0
  222. package/dist/renderer/runtimeComponent.js +113 -0
  223. package/dist/renderer/spec-content.d.ts +43 -0
  224. package/dist/renderer/spec-content.js +95 -0
  225. package/dist/renderer/wrapRegistry.d.ts +22 -37
  226. package/dist/renderer/wrapRegistry.js +10 -20
  227. package/dist/renderer/wrappers/event-bridge.js +6 -5
  228. package/dist/renderer/wrappers/hex-normalize.js +6 -5
  229. package/dist/renderer/wrappers/html-aliases.d.ts +7 -2
  230. package/dist/renderer/wrappers/html-aliases.js +36 -19
  231. package/dist/renderer/wrappers/inline-styles.js +7 -6
  232. package/dist/spec/asset-jsx.d.ts +18 -5
  233. package/dist/spec/asset-jsx.js +27 -16
  234. package/dist/spec/collapse-text-labels.d.ts +5 -15
  235. package/dist/spec/collapse-text-labels.js +26 -19
  236. package/dist/spec/empty-node-slots.d.ts +56 -34
  237. package/dist/spec/empty-node-slots.js +87 -47
  238. package/dist/spec/index.d.ts +21 -10
  239. package/dist/spec/index.js +21 -10
  240. package/dist/spec/jsxToSpec.d.ts +14 -9
  241. package/dist/spec/jsxToSpec.js +20 -3
  242. package/dist/spec/preview-elements.d.ts +63 -0
  243. package/dist/spec/preview-elements.js +89 -0
  244. package/dist/spec/rewrite-refs.d.ts +58 -0
  245. package/dist/spec/rewrite-refs.js +250 -0
  246. package/dist/spec/specToJsx.js +18 -29
  247. package/dist/tsconfig.tsbuildinfo +1 -1
  248. package/package.json +39 -52
  249. package/dist/AssetGroup.d.ts +0 -77
  250. package/dist/AssetGroup.js +0 -125
  251. package/dist/Component.d.ts +0 -333
  252. package/dist/Component.js +0 -1061
  253. package/dist/ComponentGroup.d.ts +0 -22
  254. package/dist/ComponentGroup.js +0 -51
  255. package/dist/CompositeStyle.d.ts +0 -30
  256. package/dist/CompositeStyle.js +0 -59
  257. package/dist/Config.d.ts +0 -528
  258. package/dist/Config.js +0 -1712
  259. package/dist/Mode.d.ts +0 -41
  260. package/dist/Mode.js +0 -81
  261. package/dist/Modifier.d.ts +0 -51
  262. package/dist/Modifier.js +0 -97
  263. package/dist/MotionDef.d.ts +0 -81
  264. package/dist/MotionDef.js +0 -212
  265. package/dist/Props.d.ts +0 -332
  266. package/dist/Props.js +0 -35
  267. package/dist/Provider.d.ts +0 -20
  268. package/dist/Provider.js +0 -14
  269. package/dist/StyleProp.d.ts +0 -145
  270. package/dist/StyleProp.js +0 -239
  271. package/dist/Token.d.ts +0 -76
  272. package/dist/Token.js +0 -133
  273. package/dist/TokenGroup.d.ts +0 -33
  274. package/dist/TokenGroup.js +0 -69
  275. package/dist/asset-kind.d.ts +0 -55
  276. package/dist/asset-kind.js +0 -29
  277. package/dist/asset-value.d.ts +0 -23
  278. package/dist/asset-value.js +0 -40
  279. package/dist/brands.d.ts +0 -30
  280. package/dist/brands.js +0 -20
  281. package/dist/captureCallerPath.d.ts +0 -48
  282. package/dist/captureCallerPath.js +0 -95
  283. package/dist/colorExpressions.d.ts +0 -131
  284. package/dist/colorExpressions.js +0 -148
  285. package/dist/component-referrers.d.ts +0 -30
  286. package/dist/component-referrers.js +0 -40
  287. package/dist/config-diagnostics.d.ts +0 -21
  288. package/dist/config-diagnostics.js +0 -12
  289. package/dist/defineAssetGroup.d.ts +0 -200
  290. package/dist/defineAssetGroup.js +0 -323
  291. package/dist/defineProvider.d.ts +0 -29
  292. package/dist/defineProvider.js +0 -60
  293. package/dist/element-marker.d.ts +0 -63
  294. package/dist/element-marker.js +0 -113
  295. package/dist/entity-utils.d.ts +0 -56
  296. package/dist/entity-utils.js +0 -105
  297. package/dist/extension.d.ts +0 -55
  298. package/dist/extension.js +0 -214
  299. package/dist/factories.d.ts +0 -863
  300. package/dist/factories.js +0 -475
  301. package/dist/font-face.d.ts +0 -25
  302. package/dist/font-face.js +0 -72
  303. package/dist/foreign-component-name.d.ts +0 -21
  304. package/dist/foreign-component-name.js +0 -42
  305. package/dist/interpolate.d.ts +0 -20
  306. package/dist/interpolate.js +0 -10
  307. package/dist/jsx/__fixtures__/cross-component-preview.d.ts +0 -3
  308. package/dist/jsx/__fixtures__/cross-component-preview.js +0 -15
  309. package/dist/jsx/jsx-dev-runtime.d.ts +0 -15
  310. package/dist/jsx/jsx-dev-runtime.js +0 -11
  311. package/dist/jsx/jsx-runtime.d.ts +0 -48
  312. package/dist/jsx/jsx-runtime.js +0 -305
  313. package/dist/linked-system-pins.d.ts +0 -30
  314. package/dist/linked-system-pins.js +0 -45
  315. package/dist/linkedNodePrefixes.d.ts +0 -73
  316. package/dist/linkedNodePrefixes.js +0 -99
  317. package/dist/markers.d.ts +0 -235
  318. package/dist/markers.js +0 -70
  319. package/dist/motion-constants.d.ts +0 -37
  320. package/dist/motion-constants.js +0 -61
  321. package/dist/native/NativeConfig.d.ts +0 -56
  322. package/dist/native/NativeConfig.js +0 -162
  323. package/dist/native/assets.d.ts +0 -20
  324. package/dist/native/assets.js +0 -17
  325. package/dist/native/components.d.ts +0 -139
  326. package/dist/native/components.js +0 -67
  327. package/dist/native/index.d.ts +0 -18
  328. package/dist/native/index.js +0 -17
  329. package/dist/native/modes.d.ts +0 -10
  330. package/dist/native/modes.js +0 -11
  331. package/dist/native/types.d.ts +0 -95
  332. package/dist/native/types.js +0 -0
  333. package/dist/native/validation.d.ts +0 -8
  334. package/dist/native/validation.js +0 -885
  335. package/dist/native/values.d.ts +0 -7
  336. package/dist/native/values.js +0 -15
  337. package/dist/native.d.ts +0 -12
  338. package/dist/native.js +0 -10
  339. package/dist/refs.d.ts +0 -204
  340. package/dist/refs.js +0 -129
  341. package/dist/registry-aliases.d.ts +0 -33
  342. package/dist/registry-aliases.js +0 -35
  343. package/dist/registry-dir.d.ts +0 -22
  344. package/dist/registry-dir.js +0 -10
  345. package/dist/renderer/makeRegistry.d.ts +0 -34
  346. package/dist/renderer/makeRegistry.js +0 -52
  347. package/dist/renderer/makeUdsRenderer.d.ts +0 -13
  348. package/dist/renderer/makeUdsRenderer.js +0 -51
  349. package/dist/renderer/wrappers/component-slots.d.ts +0 -41
  350. package/dist/renderer/wrappers/component-slots.js +0 -66
  351. package/dist/renderer/wrappers/slot-resolution.d.ts +0 -25
  352. package/dist/renderer/wrappers/slot-resolution.js +0 -68
  353. package/dist/renderer/wrappers/void-elements.d.ts +0 -37
  354. package/dist/renderer/wrappers/void-elements.js +0 -40
  355. package/dist/spec/layer-props.d.ts +0 -52
  356. package/dist/spec/layer-props.js +0 -149
  357. package/dist/spec/preview-controls.d.ts +0 -44
  358. package/dist/spec/preview-controls.js +0 -139
  359. package/dist/spec/slot-refs.d.ts +0 -39
  360. package/dist/spec/slot-refs.js +0 -56
  361. package/dist/token-override-rows.d.ts +0 -68
  362. package/dist/token-override-rows.js +0 -233
  363. package/dist/tokenValueType.d.ts +0 -34
  364. package/dist/tokenValueType.js +0 -138
  365. package/dist/types/css-properties.d.ts +0 -233
  366. package/dist/types/css-properties.js +0 -14
  367. package/dist/types/css-property-keywords.d.ts +0 -156
  368. package/dist/types/css-property-keywords.js +0 -616
  369. package/dist/types/css-values.d.ts +0 -63
  370. package/dist/types/css-values.js +0 -16
  371. package/dist/types.d.ts +0 -1138
  372. package/dist/types.js +0 -12
  373. package/dist/units.d.ts +0 -14
  374. package/dist/units.js +0 -16
  375. package/dist/utils/index.d.ts +0 -4
  376. package/dist/utils/index.js +0 -4
@@ -1,863 +0,0 @@
1
- import { MotionName, RegisteredModifiers, TagRef, TokenGroupRef, TokenRawNameRegistry, composite, styleProp, token } from "./refs.js";
2
- import { darken, lighten } from "./colorExpressions.js";
3
- import { ComponentDefinition, ComponentGroupDefinition, ComponentMetadata, CompositeStyleDefinition, LayerInput, ModeDefinition, ModifierDefinition, MotionDefinitionInput, MotionMetadata, PreviewDefinition, RefElement, SlotMotion, StylePropDefinition, StylePropMetadata, StylePropProperty, TokenDefinition } from "./types.js";
4
- import { BooleanMarker, ComponentSlotMarker, LayerMarker, MotionMarker, NumberMarker, PreviewAxisMarker, PreviewPropsRule, RequiredBrand, SlotMarker, SlotRef, SlotValueType, StringMarker, VariantMarker, VariantMarkerArray, VariantMarkerObject } from "./markers.js";
5
- import { BaseLayerStyles, LayerPropsMap, LayerTag, Props, PropsFromBindings, SlotPropValue } from "./Props.js";
6
- import { defineProvider } from "./defineProvider.js";
7
- import { ComponentPropsWithRef, ComponentRef, ComponentType, ElementType, FC, HTMLAttributes, JSX, ReactElement, ReactNode, Ref } from "react";
8
-
9
- //#region src/factories.d.ts
10
- /**
11
- * Author-side metadata for a token group — `label` and `description`
12
- * land on Studio's UI when the group is registered. Kept open
13
- * (`Readonly<Record<string, unknown>>` superset) so consumers can
14
- * thread arbitrary fields through to codegen without a schema change.
15
- */
16
- interface TokenGroupMetadata {
17
- readonly label?: string;
18
- readonly description?: string;
19
- }
20
- /**
21
- * `defineTokenGroup` return shape — the authored tokens record plus a
22
- * non-enumerable `.metadata({...})` chain that stashes the supplied
23
- * `{ label?, description? }` under a hidden `__metadata` slot.
24
- * `Config.registerTokenGroups` reads the slot to back-fill the
25
- * `TokenGroup` instance's `label` / `description` fields.
26
- *
27
- * The data is non-enumerable so `JSON.stringify(group)` still produces
28
- * the bare tokens record — same wire format that lands in
29
- * `.uds/config.json`.
30
- */
31
- /**
32
- * Authored token-group value returned by `defineTokenGroup({...})`.
33
- * Wraps the input tokens record under `tokens` and exposes a
34
- * `.metadata({...})` chain that sets `label` / `description` on the
35
- * same object. Shape-compatible with `TokenGroupDefinition` so the
36
- * authored value round-trips through `Config.toJSON` /
37
- * `Config.fromJSON` without reshape.
38
- */
39
- type DefinedTokenGroup<T extends Record<string, TokenDefinition>> = {
40
- tokens: T;
41
- label?: string;
42
- description?: string;
43
- metadata(meta: TokenGroupMetadata): DefinedTokenGroup<T>;
44
- };
45
- /** Shared implementation shape used by platform-specific token definitions. */
46
- type DefinedTokenGroupValue<T extends Record<string, {
47
- value: unknown;
48
- }>> = {
49
- tokens: T;
50
- label?: string;
51
- description?: string;
52
- metadata(meta: TokenGroupMetadata): DefinedTokenGroupValue<T>;
53
- };
54
- declare function defineTokenGroup<const T extends Record<string, TokenDefinition>>(t: T): DefinedTokenGroup<T>;
55
- declare function defineModifier<const T extends ModifierDefinition>(t: T): T;
56
- declare function defineMode<const T extends ModeDefinition>(t: T): T;
57
- declare function defineCompositeStyle<const T extends CompositeStyleDefinition>(t: T): T;
58
- /**
59
- * `defineMotion` return shape — the authored motion definition plus a
60
- * non-enumerable, chainable `.metadata({...})` that lands `label` /
61
- * `description` as top-level fields on the definition. Mirrors
62
- * {@link DefinedTokenGroup}: the method name never collides with the data keys,
63
- * so calls accumulate. `Config.registerMotion` reads `label` / `description`
64
- * into the `MotionDef`, round-tripping through `Config.toJSON` / `fromJSON`.
65
- */
66
- type DefinedMotion<T extends MotionDefinitionInput> = T & {
67
- label?: string;
68
- description?: string;
69
- metadata(meta: MotionMetadata): DefinedMotion<T>;
70
- };
71
- /**
72
- * Author a motion preset. Accepts the same `{ runtime, ... }` shape passed to
73
- * `.registerMotion({...})`. Author-side `label` / `description` attach via the
74
- * chained `.metadata({...})`, mirroring `defineTokenGroup`.
75
- */
76
- declare function defineMotion<const T extends MotionDefinitionInput>(t: T): DefinedMotion<T>;
77
- declare function defineComponentGroup<const T extends ComponentGroupDefinition>(t: T): T;
78
- /**
79
- * Style-prop spec with chainable `.metadata({...})` (label/description/
80
- * arbitrary author-side metadata) and `.withOpacity({...})` (declares
81
- * a paired opacity sibling). Both chains mutate the underlying spec
82
- * in place and return it so chains can be appended or saved as a value.
83
- */
84
- type DefinedStyleProp<P extends StylePropProperty> = StylePropDefinition<P> & {
85
- metadata(meta: StylePropMetadata): DefinedStyleProp<P>;
86
- withOpacity(spec: {
87
- as: string;
88
- values: TokenGroupRef;
89
- separator?: string;
90
- }): DefinedStyleProp<P>;
91
- };
92
- /**
93
- * Author a style-prop spec. `P` is inferred from `cssProperty` so the
94
- * `values` array narrows against the chosen CSS property's accepted
95
- * keyword union (`'transparent'` is OK for `border-color`, errors for
96
- * `padding`). For custom properties (`--foo`), `values` accepts open
97
- * strings — `cssType` constrains the runtime value space instead.
98
- *
99
- * Returns the spec with a non-enumerable `.metadata({...})` chain;
100
- * the chain merges the supplied bag into `spec.metadata` so multiple
101
- * `.metadata({...})` calls accumulate.
102
- */
103
- declare function defineStyleProp<const P extends StylePropProperty>(spec: StylePropDefinition<P>): DefinedStyleProp<P>;
104
- /**
105
- * Slot binding. `slot()` is an open slot — codegen treats it as
106
- * `ReactNode` accepted at the component's own children. `slot('layer/prop')`
107
- * routes a JSX prop into the named layer's `layerProp` (defaults to
108
- * `'children'` when only a layer name is provided).
109
- *
110
- * Open form returns `SlotMarker` (no cross-reference). The
111
- * layer-targeting forms return `SlotRef` (the `layer` field is the
112
- * cross-reference — points at a layer's prop).
113
- *
114
- * `.required()` makes the prop mandatory in the codegen-emitted types.
115
- * `.accepts(...)` constrains the accepted children to one or more
116
- * registered components.
117
- */
118
- declare function slot(): SlotMarker;
119
- declare function slot(options: {
120
- type: 'component';
121
- }): ComponentSlotMarker;
122
- declare function slot(options: {
123
- type: SlotValueType;
124
- }): SlotMarker;
125
- declare function slot<TPath extends string>(path: TPath): TPath extends `${infer L}/${infer A}` ? SlotRef<L, A> : SlotRef<TPath, 'children'>;
126
- declare function slot<L extends string, A extends string>(layer: L, options: {
127
- prop: A;
128
- type?: SlotValueType;
129
- }): SlotRef<L, A>;
130
- declare function slot<TPath extends string>(path: TPath, options: {
131
- type: SlotValueType;
132
- }): TPath extends `${infer L}/${infer A}` ? SlotRef<L, A> : SlotRef<TPath, 'children'>;
133
- /**
134
- * The factory return type — same marker plus a guaranteed `required()`
135
- * method that returns the same chainable shape. The marker interface
136
- * declares `required?()` as optional so raw `{ __kind: ... }` object
137
- * literals (test fixtures, JSON-hydrated configs) still satisfy the
138
- * interface; factories override that with a definite version so authoring
139
- * sites can call `string().required()` without a `?.` guard.
140
- *
141
- * `.required()` does two things:
142
- * - Consumer MUST pass the prop at the JSX site (runtime + emitted
143
- * `Props<T>` shape carry the constraint).
144
- * - Render-fn destructure sees the value as non-optional (`T` rather
145
- * than `T | undefined`). The default render-arg type *is* optional
146
- * because consumers may omit the prop and `defaultProps` is just a
147
- * runtime convenience — `.required()` is the explicit "I promise
148
- * this is always defined" knob.
149
- */
150
- type Chainable<T extends {
151
- __required?: boolean;
152
- }> = T & {
153
- required(): T & RequiredBrand;
154
- };
155
- /**
156
- * Boolean-prop binding. Codegen emits the prop as `<name>?: boolean`
157
- * and routes presence/absence into a per-layer `data-${name}` attribute
158
- * the runtime selects on. Mirrors the old `@yahoo/uds-create-config` `helpers.boolean()`.
159
- *
160
- * The optional `values` argument carries per-state per-layer styles
161
- * (`{ true: { root: {...} }, false: { root: {...} } }`) — codegen emits
162
- * one variant CSS class per layer per state, same as `variant({...})`.
163
- *
164
- * `.required()` flips the prop to mandatory at JSX call sites.
165
- */
166
- declare function boolean(values?: {
167
- true?: Record<string, Record<string, unknown>>;
168
- false?: Record<string, Record<string, unknown>>;
169
- }): Chainable<BooleanMarker>;
170
- /**
171
- * `asChild()` — opt a **single-layer** component into the polymorphic-child
172
- * Slot pattern. Declare it as a prop (`props: { asChild: asChild() }`); when a
173
- * consumer passes `asChild`, the component merges its computed props (className,
174
- * style props, handlers) onto its single child element instead of rendering its
175
- * own tag — codegen wires the `_renderAsChild` Slot. Typed as a boolean prop
176
- * (`asChild?: boolean`), so no extra type plumbing.
177
- *
178
- * Opt-in only and single-layer only: multi-layer composites render multiple
179
- * children and can't slot a single child, so the codegen Slot branch is emitted
180
- * solely for inline single-layer FCs.
181
- */
182
- declare function asChild(): BooleanMarker;
183
- /**
184
- * Cross-layer style override — `_hover: layer('close', { opacity: 1 })`
185
- * declares "when this layer is hovered, apply these styles to the
186
- * named layer". Codegen emits a descendant-combinator rule pointing
187
- * from the source layer's selector to the target layer's selector.
188
- * Mirrors the old `@yahoo/uds-create-config` `helpers.layer()`.
189
- */
190
- declare function layer(layerName: string, styles: Record<string, unknown>): LayerMarker;
191
- /**
192
- * Variant-prop binding — two authoring shapes, one normalized marker.
193
- *
194
- * 1. **Object form** — `variant({ a: { root: {...} }, b: {} })`. Keys
195
- * are accepted values, values are per-layer style maps. Empty `{}`
196
- * leaves a value styleless, so mixed-styling is supported in a
197
- * single call.
198
- * 2. **Array form** — `variant(['a','b','c'] as const)`. Typed list with
199
- * no styles. Required for numeric variant (`variant([12, 16, 24] as
200
- * const)`) since JS object keys can't preserve numeric literal
201
- * types; also a nicer shorthand for "typed list, no styles."
202
- *
203
- * Both forms share the runtime tag `__kind: 'variant'`; `Array.isArray(values)`
204
- * is the single discriminator. The `defaultValue` second argument seeds
205
- * `defaultProps[<prop>]`.
206
- *
207
- * `.required()` flips the prop to mandatory at JSX call sites.
208
- */
209
- declare function variant<const V extends readonly (string | number)[]>(values: V, defaultValue?: V[number]): Chainable<VariantMarkerArray<V>>;
210
- declare function variant<const V extends Record<string, Record<string, unknown>>>(values: V, defaultValue?: keyof V & string): Chainable<VariantMarkerObject<V>>;
211
- /** `string()`'s chain surface — `.required()` and `.toggle()`, chainable in
212
- * either order. */
213
- type StringChainable = StringMarker & {
214
- required(): StringChainable & RequiredBrand;
215
- toggle(): StringChainable;
216
- };
217
- /**
218
- * Wide-string prop binding. Codegen emits the prop as `<name>?: string`
219
- * (or required when chained with `.required()`). No CSS effect — use
220
- * this for free-form text props (URLs, labels). When you want a
221
- * constrained list of accepted strings, reach for the array form of
222
- * `variant(...)` instead. Chain `.toggle()` when the prop reads as an on/off
223
- * feature (e.g. `tooltip`) — editors show a switch that reveals the field.
224
- */
225
- declare function string(): StringChainable;
226
- /**
227
- * Wide-number prop binding. Codegen emits the prop as `<name>?: number`
228
- * (or required when chained with `.required()`). No CSS effect — use
229
- * this for free-form numeric props (tabIndex, count). When you want a
230
- * constrained list of accepted numbers, reach for the array form of
231
- * `variant(...)` instead.
232
- */
233
- declare function number(): Chainable<NumberMarker>;
234
- /**
235
- * JS-motion prop binding. Emits `<name>?: SlotMotion | MotionName` — either an
236
- * inline framer-motion config object (`{ initial, animate, whileHover,
237
- * transition, … }`) or the name of a `registerMotion({...})` preset
238
- * (`motion="fadeIn"`; `MotionName` narrows to the registered names in an
239
- * augmented config, else `string`). The loader routes both through
240
- * `_renderWithMotion` at runtime (preset name → registered JS/CSS motion;
241
- * object → inline config), so
242
- * it produces no CSS of its own — this is the JS-animation counterpart to the
243
- * CSS `animation`/`transition` style props, not a `styleProp`. Chain
244
- * `.required()` to force callers to pass it.
245
- */
246
- declare function motion(): Chainable<MotionMarker>;
247
- /**
248
- * Helpers passed to `defineComponent(...).config(cb)` callbacks. Same
249
- * shape regardless of single-layer (`defineComponent('div')`) or
250
- * multi-layer (`defineComponent.layers({...})`) entry — destructure
251
- * whichever subset the prop bindings need.
252
- *
253
- * Wide form (no layer narrowing) — kept for the runtime helper bundle
254
- * and back-compat with consumers that imported the type by name.
255
- * `.config(cb)` callbacks see the narrower `TypedConfigHelpers<T>` so
256
- * authoring sites get layer-aware autocomplete.
257
- */
258
- interface ConfigCallbackHelpers {
259
- readonly slot: typeof slot;
260
- readonly variant: typeof variant;
261
- readonly boolean: typeof boolean;
262
- readonly asChild: typeof asChild;
263
- readonly string: typeof string;
264
- readonly number: typeof number;
265
- readonly motion: typeof motion;
266
- readonly layer: typeof layer;
267
- readonly composite: typeof composite;
268
- readonly styleProp: typeof styleProp;
269
- readonly token: typeof token;
270
- readonly darken: typeof darken;
271
- readonly lighten: typeof lighten;
272
- }
273
- /**
274
- * Per-layer styles map, keyed by layer name. Each value narrows to
275
- * the layer target's own prop surface via `BaseLayerStyles<TLayers[K]>`
276
- * — same mapping used by `base: { <layer>: {...} }`. Reused by
277
- * `variant({...})` variant bodies, `boolean({...})` true/false bodies,
278
- * and the cross-layer `layer(target, styles)` helper.
279
- */
280
- type LayerStylesFor<TLayers> = { [K in keyof TLayers]?: BaseLayerStyles<TLayers[K]> };
281
- /**
282
- * Layer-aware overload of `variant(...)` exposed to `.config(cb)`
283
- * callbacks. Array form is unchanged (no styles); object form narrows
284
- * each variant's body to a layer-keyed style map. The layer name and
285
- * its declared style props autocomplete; non-layer keys land in the
286
- * `unknown`-typed fallback (no autocomplete) since the inner record
287
- * permits arbitrary keys for back-compat with raw author bags.
288
- */
289
- interface TypedVariantHelper<TLayers> {
290
- <const V extends Record<string, LayerStylesFor<TLayers>>>(values: V, defaultValue?: keyof V & string): Chainable<VariantMarkerObject<V>>;
291
- <const V extends readonly (string | number)[]>(values: V, defaultValue?: V[number]): Chainable<VariantMarkerArray<V>>;
292
- }
293
- /**
294
- * Layer-aware overload of `boolean(...)` exposed to `.config(cb)`
295
- * callbacks. The optional `true` / `false` per-state bodies narrow to
296
- * a layer-keyed style map — same shape as `variant({...})` variant
297
- * bodies.
298
- */
299
- interface TypedBooleanHelper<TLayers> {
300
- (): Chainable<BooleanMarker>;
301
- (values: {
302
- true?: LayerStylesFor<TLayers>;
303
- false?: LayerStylesFor<TLayers>;
304
- }): Chainable<BooleanMarker>;
305
- }
306
- /**
307
- * Layer-aware `layer(target, styles)` cross-layer style helper. The
308
- * `target` arg narrows to declared layer names; `styles` narrows to
309
- * the target layer's own prop surface (modifiers included, same as
310
- * the `base[<layer>]` shape).
311
- */
312
- type TypedLayerHelper<TLayers> = <L extends keyof TLayers & string>(layerName: L, styles: BaseLayerStyles<TLayers[L]>) => LayerMarker;
313
- /**
314
- * Per-layer JSX prop keys — the names a `slot('layer/prop')` ref can
315
- * point at. Composed-component layers expose their `Props<...>` keys
316
- * (the same surface the rendered child accepts at JSX call sites);
317
- * tag layers expose the React `HTMLAttributes` key set (children,
318
- * onClick, aria-*, ...). Used to compute the `slot()` path union.
319
- */
320
- type LayerPropNames<TLayer> = TLayer extends ((props: infer P) => unknown) ? keyof P & string : TLayer extends ComponentDefinition<infer InnerLayers, infer InnerProps, infer InnerTag> ? keyof Props<ComponentDefinition<InnerLayers, InnerProps, InnerTag>> & string : LayerTag<TLayer> extends infer TT extends keyof JSX.IntrinsicElements ? keyof ComponentPropsWithRef<TT> & string : keyof HTMLAttributes<HTMLElement> & string;
321
- /**
322
- * Per-layer prop union, lazily computed at the slot call site.
323
- * Wrapped in a single-key conditional so TS only materializes the
324
- * inner `Props<...>` once, when the layer literal is known —
325
- * precomputing all layers eagerly via a mapped type blew the
326
- * instantiation-depth budget on multi-layer components whose
327
- * inner layers are themselves composed (Modal, Sheet, EmptyState).
328
- */
329
- type LayerPropNamesAt<TLayers, L extends keyof TLayers & string> = LayerPropNames<TLayers[L]>;
330
- /**
331
- * `true` when `TLayers` declares exactly one layer (single-layer
332
- * primitives like Box / Text). The empty `slot()` form returns an
333
- * open `SlotMarker` that routes to the component's own children —
334
- * unambiguous only when there's a single layer to route to.
335
- * Multi-layer components must use the explicit `slot('layer/prop')`
336
- * path form so the render fn knows where the slot lands.
337
- *
338
- * Implementation: standard "is-union" probe. `K extends K` distributes
339
- * over the union; `[U] extends [K]` checks whether the original
340
- * union still equals the now-distributed single member — only true
341
- * for a single-element union.
342
- */
343
- type SingleLayer<TLayers, K extends keyof TLayers = keyof TLayers> = [keyof TLayers] extends [never] ? false : K extends K ? [keyof TLayers] extends [K] ? true : false : never;
344
- /**
345
- * Layer-aware `slot(...)` helper. Two forms with *different* runtime
346
- * semantics — pick based on intent, not layer count:
347
- *
348
- * - `slot()` — open slot (returns `SlotMarker`). Codegen surfaces
349
- * the prop as a free render-fn arg (`({ children, ... }) => ...`)
350
- * so the render fn places it explicitly between siblings. Right
351
- * for sequenced positioning (`{startIcon}{children}{endIcon}`).
352
- * - `slot('layer/prop')` — typed slot ref (returns `SlotRef<L, A>`).
353
- * Codegen bundles the value into `props.<layer>.<prop>` so it
354
- * spreads onto the named layer's JSX (`<X {...props.<layer>} />`).
355
- * Right for forwarding into a wrapped component's own prop.
356
- *
357
- * The single-arg `slot('layer')` and the object-options form
358
- * `slot('layer', { prop })` were removed — always write the explicit
359
- * `'layer/prop'` path so codegen / Studio / readers see one syntax
360
- * for the routed form.
361
- */
362
- /** First parameter of a function-typed layer prop (the value a callback
363
- * hands back — e.g. the change event for an input's `onChange`). Falls
364
- * back to `any` when the prop doesn't resolve to a function type (some
365
- * composed-component props don't surface their handler signature), so
366
- * the transform is precisely typed where possible and unconstrained
367
- * otherwise — never stricter than the old untyped form.
368
- *
369
- * `NonNullable<V>` strips the `| undefined` an optional layer prop
370
- * carries (`onChange?: ChangeEventHandler`). Without it the bare
371
- * conditional distributes over the `Handler | undefined` union: the
372
- * `undefined` arm takes the `any` fallback and `any` absorbs the whole
373
- * union, collapsing the transform arg to `any` for every optional prop. */
374
- type UnresolvedArg = any;
375
- type ArgOf<V> = NonNullable<V> extends ((arg: infer A, ...rest: never[]) => unknown) ? A : UnresolvedArg;
376
- /**
377
- * Layer-aware `SlotRef` whose `.transform(fn)` types `fn`'s argument as
378
- * the targeted layer prop's value (e.g. `slot('field/onChange')`'s
379
- * transform receives the input's change event). The consumer-facing
380
- * prop then resolves to `(value: ReturnType<fn>) => void`.
381
- */
382
- interface TypedSlotRef<TLayer extends string, TAs extends string, TArg> extends Omit<SlotRef<TLayer, TAs>, 'transform'> {
383
- transform<Out>(fn: (arg: TArg) => Out): SlotRef<TLayer, TAs> & {
384
- readonly __transformOut: Out;
385
- };
386
- }
387
- interface TypedSlotHelper<TLayers> {
388
- (): SlotMarker;
389
- <L extends keyof TLayers & string, A extends LayerPropNamesAt<TLayers, L>>(path: `${L}/${A}`): TypedSlotRef<L, A, ArgOf<SlotPropValue<SlotRef<L, A>, TLayers>>>;
390
- <L extends keyof TLayers & string, A extends LayerPropNamesAt<TLayers, L>>(path: `${L}/${A}`, options: {
391
- type: SlotValueType;
392
- }): TypedSlotRef<L, A, ArgOf<SlotPropValue<SlotRef<L, A>, TLayers>>>;
393
- (options: {
394
- type: 'component';
395
- }): ComponentSlotMarker;
396
- (options: {
397
- type: SlotValueType;
398
- }): SlotMarker;
399
- }
400
- /**
401
- * `.config(cb)` callback helpers narrowed against the chain seed `T`.
402
- * `slot` / `variant` / `boolean` / `layer` know the declared layer names
403
- * and per-layer prop surfaces so authoring sites get layer-aware
404
- * autocomplete without changing the runtime helper bundle. The
405
- * remaining helpers (`string`, `number`, `composite`, `styleProp`,
406
- * `token`) don't depend on `T`, so they pass through as the wide
407
- * module-level fns.
408
- */
409
- type TypedConfigHelpers<T extends ComponentDefinition> = T extends ComponentDefinition<infer TLayers, infer _P, infer _Tag> ? {
410
- readonly slot: TypedSlotHelper<TLayers>;
411
- readonly variant: TypedVariantHelper<TLayers>;
412
- readonly boolean: TypedBooleanHelper<TLayers>;
413
- readonly asChild: typeof asChild;
414
- readonly layer: TypedLayerHelper<TLayers>;
415
- readonly string: typeof string;
416
- readonly number: typeof number;
417
- readonly motion: typeof motion;
418
- readonly composite: typeof composite;
419
- readonly styleProp: typeof styleProp;
420
- readonly token: typeof token;
421
- readonly darken: typeof darken;
422
- readonly lighten: typeof lighten;
423
- } : ConfigCallbackHelpers;
424
- /**
425
- * Helpers passed to `defineComponent(...).preview(cb)` callbacks.
426
- * `prop(name)` produces a row/column axis spec for the `matrix` field
427
- * — Studio + codegen consume the marker to expand the prop's variant
428
- * values into the preview grid.
429
- *
430
- * Wide form (no narrowing) — kept for the runtime bundle and external
431
- * consumers. `.preview(cb)` callbacks see the narrower
432
- * `TypedPreviewHelpers<T>` so axis names autocomplete to declared
433
- * props / registered modifiers.
434
- */
435
- interface PreviewCallbackHelpers {
436
- readonly prop: (name: string) => PreviewAxisMarker;
437
- readonly modifier: (name: string) => PreviewAxisMarker;
438
- /**
439
- * Per-cell prop-override axis. Pass a flat bag (applied to every cell)
440
- * or a list of `{ when?, props }` rules guarded against other axes —
441
- * the way to vary render-extra data per cell without a config prop.
442
- */
443
- readonly props: (arg: Record<string, unknown> | readonly PreviewPropsRule[]) => PreviewAxisMarker;
444
- /**
445
- * Whole interaction-state dimension at one chain level, in display order:
446
- * `'rest'` (no modifier forced) plus registered `_${name}` modifiers.
447
- * Values pass through verbatim — the author decides whether `'rest'` leads.
448
- *
449
- * Not to be confused with the matrix's `pinnedModifiers` field: `states()`
450
- * is a *positional* axis level (part of the displayed arrangement, `'rest'`
451
- * included); `pinnedModifiers` is the arrangement-independent registry of
452
- * modifiers the preview keeps even while the state dimension is hidden
453
- * (`'rest'` excluded — it's implicit).
454
- */
455
- readonly states: (values: readonly string[]) => PreviewAxisMarker;
456
- }
457
- /**
458
- * `.preview(cb)` callback helpers narrowed against the resolved
459
- * component definition `T`. `prop(name)` narrows `name` to declared
460
- * prop keys; `modifier(name)` narrows to the codegen-augmented
461
- * `RegisteredModifiers` registry. Falls back to the wide
462
- * `PreviewCallbackHelpers` when `T` isn't a concrete definition.
463
- */
464
- type TypedPreviewHelpers<T extends ComponentDefinition> = T extends ComponentDefinition<infer _L, infer TProps, infer _Tag> ? {
465
- readonly prop: <K extends keyof TProps & string>(name: K) => PreviewAxisMarker;
466
- readonly modifier: <K extends keyof RegisteredModifiers<unknown> & string>(name: K) => PreviewAxisMarker;
467
- readonly props: (arg: Record<string, unknown> | readonly PreviewPropsRule[]) => PreviewAxisMarker;
468
- readonly states: (values: readonly string[]) => PreviewAxisMarker;
469
- } : PreviewCallbackHelpers;
470
- type ConfigCallbackResult = Partial<ComponentDefinition>;
471
- /**
472
- * Per-layer `base` shape derived from the chain seed `T`. Each declared
473
- * layer key narrows to the layer target's own prop surface (style props
474
- * + HTML attrs for tag layers, `Partial<Props<...>>` for composed
475
- * component layers) — same `LayerPropsValue<TLayer>` mapping the JSX
476
- * `layerProps` prop already exposes. Lets the `.config(cb)` callback
477
- * catch typos like `base: { root: { invalidProp: '...' } }` at the
478
- * authoring site.
479
- */
480
- type BaseStylesFor<T extends ComponentDefinition> = T extends ComponentDefinition<infer TLayers, infer _P, infer _Tag> ? { [K in keyof TLayers]?: BaseLayerStyles<TLayers[K]> } : never;
481
- /**
482
- * Per-T `defaultProps` shape. Splits on layer count:
483
- *
484
- * - **Multi-layer** components (`{root, text, ...}`) — narrow to
485
- * the component's *own declared props* (`PropsFromBindings`).
486
- * Without the narrowing, `Partial<Props<T>>` bleeds the root
487
- * layer's whole prop surface through `ComposedRootProps<TLayers>`
488
- * so multi-layer authoring sites see hundreds of irrelevant Box
489
- * style props in autocomplete.
490
- * - **Single-layer** components (`defineComponent('div')`,
491
- * `defineComponent(Box)`) — keep `Partial<Props<T>>` so value-
492
- * extend chains can still default inherited style props
493
- * (`bg: 'tertiary'`, `as: 'button'`, `cursor: 'pointer'`).
494
- *
495
- * Props declared in the same `.config()` call don't appear here —
496
- * the seed `T` reflects the chain state *before* the current call.
497
- * Default a freshly-declared prop in a follow-up `.config()` step
498
- * (or in a future `.defaultProps({...})` chain method).
499
- */
500
- type DefaultPropsFor<T extends ComponentDefinition> = T extends ComponentDefinition<infer TLayers, infer TProps, infer _Tag> ? SingleLayer<TLayers> extends true ? Partial<Props<T>> : Partial<PropsFromBindings<TProps, TLayers> & RegisteredModifiers<PropsFromBindings<TProps, TLayers>> & {
501
- layerProps?: LayerPropsMap<TLayers>;
502
- }> : never;
503
- /**
504
- * `.config(cb)` callback result narrowed against the chain seed `T`.
505
- * Overrides `base` with `BaseStylesFor<T>` and `defaultProps` with
506
- * `DefaultPropsFor<T>` so authoring sites get autocomplete on
507
- * per-layer style blocks and on the right prop surface (own declared
508
- * props for multi-layer, inherited Props<T> for single-layer
509
- * value-extends). Other fields stay on the wide `ComponentDefinition`
510
- * shape.
511
- */
512
- type ConfigCallbackResultFor<T extends ComponentDefinition> = Omit<ConfigCallbackResult, 'base' | 'defaultProps'> & {
513
- base?: BaseStylesFor<T>;
514
- defaultProps?: DefaultPropsFor<T>;
515
- };
516
- /**
517
- * Per-nested-field override: when `C` carries `K`, the merged shape's
518
- * `K` is `Omit<T[K], keyof C[K]> & C[K]` so newly-bound keys *replace*
519
- * the parent's binding rather than intersect with it. When only one
520
- * side carries `K`, that side's shape wins; when neither does, the
521
- * key is omitted.
522
- */
523
- type MergeNested<T, C, K extends string> = C extends Record<K, infer CV> ? T extends Record<K, infer TV> ? Record<K, Omit<TV, keyof CV> & CV> : Record<K, CV> : T extends Record<K, infer TV> ? Record<K, TV> : {};
524
- /**
525
- * `ref` is a scalar tag, so a value-extend that re-declares it must *override*
526
- * the inherited tag (Pressable's `'button'` over Box's `'div'`). A plain
527
- * intersection would collapse `'div' & 'button'` to `never` — poisoning the
528
- * whole merged definition. C wins; falls back to T's tag when C omits `ref`.
529
- */
530
- type MergeRef<T, C> = C extends {
531
- ref: infer CR;
532
- } ? {
533
- ref: CR;
534
- } : T extends {
535
- ref: infer TR;
536
- } ? {
537
- ref: TR;
538
- } : Record<never, never>;
539
- /**
540
- * Merge a `.config(cb)` callback result `C` over the chain seed `T`.
541
- * Nested fields (`props`, `defaultProps`, `base`) merge per-key (C
542
- * overrides T at the leaf level); `ref` overrides as a scalar; other fields
543
- * fall back to the historic `T & C` intersection.
544
- */
545
- type MergeChainConfig<T, C> = Omit<T, 'props' | 'defaultProps' | 'base' | 'ref'> & Omit<C, 'props' | 'defaultProps' | 'base' | 'ref'> & MergeRef<T, C> & MergeNested<T, C, 'props'> & MergeNested<T, C, 'defaultProps'> & MergeNested<T, C, 'base'>;
546
- /**
547
- * Per-config slot-prop map: walk a `props` block, pick out every
548
- * `slot()`-marked entry, and surface it as `ReactNode | undefined` on
549
- * the render-fn args. Each entry resolves to one JSX-callable name
550
- * (`title?`, `icon?`, `actions?`) the render fn can read directly.
551
- *
552
- * Mirrors main's `SlotPropsFromConfig`. Slot markers carry
553
- * `__kind: 'slot'`; non-slot entries (style props, variant, booleans)
554
- * map to `never` and drop out of the key set.
555
- */
556
- /**
557
- * Resolve a marker to the value type the consumer passes via JSX
558
- * and the render fn destructures. Mirrors the runtime contract:
559
- * `slot` → `ReactNode`, primitive markers → their primitive,
560
- * `variant` → the literal union of values/keys, `composite` → key
561
- * union of the registered composite's styles, `styleProp` →
562
- * `string` (token name OR bracketed arbitrary — the styler picks).
563
- */
564
- type ResolveMarker<M> = M extends {
565
- readonly __kind: 'slot';
566
- readonly __valueType: 'component';
567
- } ? ComponentType : M extends {
568
- readonly __kind: 'slot';
569
- } ? ReactNode : M extends {
570
- readonly __kind: 'string';
571
- } ? string : M extends {
572
- readonly __kind: 'number';
573
- } ? number : M extends {
574
- readonly __kind: 'motion';
575
- } ? SlotMotion | MotionName : M extends {
576
- readonly __kind: 'boolean';
577
- } ? boolean : M extends {
578
- readonly __kind: 'variant';
579
- readonly values: infer V;
580
- } ? V extends readonly (infer E)[] ? E : V extends Record<string, unknown> ? keyof V & string : string : M extends {
581
- readonly __kind: 'composite';
582
- } ? string : M extends {
583
- readonly __kind: 'styleProp';
584
- } ? string : unknown;
585
- /**
586
- * Render-fn arg map: every entry in `.config({ props })` surfaces on
587
- * the render callback. Slots resolve to `ReactNode`; other markers
588
- * resolve to their value type. Optionality is driven by `.required()`:
589
- *
590
- * - default → optional (`T | undefined`). The author has to guard.
591
- * - `.required()` → non-optional (`T`). Consumer must pass at the JSX
592
- * site (or `defaultProps` covers it), so render destructure is safe
593
- * to use the value directly without an `as T` cast.
594
- *
595
- * This is what wires `.config({ props: { checked: boolean() } })` →
596
- * `.render(({ checked }) => …)` without forcing authors to repeat the
597
- * type declaration on `.render<T>`.
598
- */
599
- type RenderPropsFromConfig<TProps, TDefaultKeys extends PropertyKey = never> = { [K in keyof TProps as TProps[K] extends RequiredBrand ? K : K extends TDefaultKeys ? K : never]-?: ResolveMarker<TProps[K]> } & { [K in keyof TProps as TProps[K] extends RequiredBrand ? never : K extends TDefaultKeys ? never : K]?: ResolveMarker<TProps[K]> };
600
- /**
601
- * Per-layer prop bundle the codegen-emitted FC hands to the render
602
- * function. One key per layer declared on `.layers({...})`, each
603
- * carrying the spread-into-JSX bag (`className`, `data-uds-*`,
604
- * forwarded native attrs). Typed as `Record<string, unknown>` per
605
- * entry — the runtime contents vary by layer base component and the
606
- * render fn just spreads them with `{...props.<layer>}`.
607
- */
608
- type LayerPropsBundle<TLayers> = { [K in keyof TLayers]: Record<string, unknown> };
609
- /**
610
- * Resolved value object for a single token. `value` is the
611
- * light-mode (or single-mode) CSS value string. Any `_${string}` key
612
- * (e.g. `_dark`) holds the override for that mode. `type` is an
613
- * optional token-category hint (e.g. `'color'`, `'dimension'`).
614
- *
615
- * The precise qualified-name union for `tokenRaw`'s `name` parameter
616
- * is layered on at the call site via codegen's `uds-env.d.ts`
617
- * augmentation — keep this type config-agnostic.
618
- */
619
- type RawToken = {
620
- value: string;
621
- type?: string;
622
- } & { [K in `_${string}`]?: string };
623
- /** The accepted `name` argument for `tokenRaw`. Narrows to the
624
- * config's registered `'<group>/<token>'` union when codegen has
625
- * augmented `TokenRawNameRegistry`; falls back to `string` in
626
- * un-augmented contexts (this package's own tests, fresh consumers
627
- * before the first build). */
628
- type TokenRawName = [keyof TokenRawNameRegistry] extends [never] ? string : keyof TokenRawNameRegistry;
629
- /**
630
- * Resolved return shape of `tokenRaw(name)` for a specific `name`. Once codegen
631
- * has augmented `TokenRawNameRegistry`, each registered name maps to its own
632
- * per-token shape — `{ value: string; _dark: string }` for a themed token,
633
- * `{ value: string }` for one with no mode overrides. A finite template/union
634
- * name (e.g. `` `spectrum/blue/${step}` `` with `step` a finite union) resolves
635
- * to the union of the matching tokens' shapes, which collapses to a single type
636
- * when they share one. Falls back to the open `RawToken` in un-augmented
637
- * contexts (this package's own tests, fresh consumers before the first build).
638
- *
639
- * Values are `string`, not literals: token values are indirection by design and
640
- * change with theming, so a baked-in literal would go stale — the stable,
641
- * useful information a name carries is which keys it has.
642
- */
643
- type TokenRawValue<N extends TokenRawName> = N extends keyof TokenRawNameRegistry ? TokenRawNameRegistry[N] : RawToken;
644
- /**
645
- * Shape of the render fn passed to `.render<TExtra>(fn)`. `props` is
646
- * the per-layer bundle injected by the codegen-emitted wrapper FC,
647
- * keyed by the layers declared on `.layers({...})`. `TConfigProps`
648
- * adds every config-declared prop (slots, variant, booleans, etc.) at
649
- * the call site — required when `defaultProps` covers them, optional
650
- * otherwise. `TExtra` is the consumer-declared extra JSX-prop shape
651
- * (function-typed handlers, complex object pass-throughs) that the
652
- * marker system doesn't express yet.
653
- */
654
- /**
655
- * The render fn's `ref` arg, present only when the component declares
656
- * `.config({ ref: 'tag' })`. The author attaches it to the real root element
657
- * (`<svg ref={ref} {...props.root} />`), so TS checks the attachment against
658
- * the declared element. No declaration → no `ref` arg (empty intersection).
659
- */
660
- type RefArgFor<TDef> = TDef extends {
661
- ref: infer Tag extends string;
662
- } ? {
663
- ref?: Ref<RefElement<Tag>>;
664
- } : Record<never, never>;
665
- type ComponentRenderFn<TExtra = unknown, TConfigProps = unknown, TLayers = Record<string, unknown>, TRefArg = Record<never, never>> = (args: {
666
- props: LayerPropsBundle<TLayers>;
667
- children?: ReactNode;
668
- tokenRaw: <N extends TokenRawName>(name: N) => TokenRawValue<N>;
669
- } & TConfigProps & TExtra & TRefArg) => ReactNode;
670
- /**
671
- * Chain methods attached to every `defineComponent` result. The
672
- * builder type intersects with the underlying `ComponentDefinition`
673
- * (`T`) so the value is directly assignable to
674
- * `Config.registerComponents({...})`. All chain methods are
675
- * non-enumerable, so `JSON.stringify` over a builder still produces
676
- * the plain authored shape.
677
- */
678
- interface ComponentBuilderMethods<T extends ComponentDefinition> {
679
- /**
680
- * Resolve prop bindings, base styles, defaults, and motion from a
681
- * callback. Helpers (`slot`, `variant`, `composite`, `styleProp`,
682
- * `token`) emit the marker shapes codegen consumes.
683
- *
684
- * The result `C` *overrides* matching `T` fields rather than
685
- * intersecting — bare `T & C` would intersect literal-typed marker
686
- * fields (`gap: StylePropRef<'gap'> & StylePropRef<'gapX'>`) into
687
- * `never`, and `Props<T>`'s walker can't recover from that.
688
- */
689
- config<const C extends ConfigCallbackResultFor<T>>(cb: (helpers: TypedConfigHelpers<T>) => C): ComponentBuilder<MergeChainConfig<T, C>>;
690
- /**
691
- * Attach the React render fn. Stored on non-enumerable `__renderFn`
692
- * + `__hasRenderFn: true` so codegen's `transformAuthoringSource`
693
- * downleveler picks it up while the JSON-safe builder shape stays
694
- * clean. `TExtra` is the consumer-declared extra JSX-prop shape;
695
- * slot-bound JSX props (declared via `slot()` in `.config()`)
696
- * appear automatically alongside `props`/`children`.
697
- */
698
- render<TExtra extends Record<string, unknown> = {}>(fn: ComponentRenderFn<TExtra, T extends {
699
- props: infer P;
700
- } ? RenderPropsFromConfig<P, T extends {
701
- defaultProps: infer D;
702
- } ? keyof D : never> : unknown, T extends {
703
- layers: infer L;
704
- } ? L : Record<string, unknown>, RefArgFor<T>>): BoundComponent<T, TExtra>;
705
- /**
706
- * Attach a declarative preview spec — stored under non-enumerable
707
- * `__preview` so the authored builder stays JSON-clean. Callback
708
- * form receives `{ prop }` for axis markers and is invoked
709
- * immediately; the resolved spec is the value used downstream.
710
- *
711
- * `defaultProps` is narrowed against the component's resolved
712
- * `Props<T>` so callback parameters (`onSubmit: (event) => ...`)
713
- * infer their event type from the component's declared JSX surface.
714
- */
715
- preview(spec: PreviewDefinition<DefaultPropsFor<T>> | ((helpers: TypedPreviewHelpers<T>) => PreviewDefinition<DefaultPropsFor<T>>)): ComponentBuilder<T>;
716
- /**
717
- * Declare child components owned by this one. Children flatten into
718
- * `Config.components` at registration time and carry
719
- * `derived.subcomponentOf`.
720
- */
721
- subcomponents(children: Record<string, ComponentDefinition>): ComponentBuilder<T>;
722
- /**
723
- * Attach author-side metadata for codegen's AI prompt artifact +
724
- * Studio's UI. Merged into `definition.metadata` (multiple
725
- * `.metadata({...})` calls accumulate). Returns the builder so the
726
- * chain continues.
727
- */
728
- metadata(meta: ComponentMetadata): ComponentBuilder<T>;
729
- }
730
- /**
731
- * Authored builder value returned by `defineComponent(...).config(...)`.
732
- *
733
- * Three roles in one shape:
734
- *
735
- * 1. **Data** — the underlying `ComponentDefinition` fields (`layers`,
736
- * `props`, `base`, `defaultProps`, `motion`, `compoundProps`) live
737
- * on enumerable properties so `Config.registerComponents({Text})`
738
- * and `JSON.stringify(Text)` both see the authored shape.
739
- * 2. **Chain methods** — `.config`, `.render`, `.preview`, and
740
- * `.subcomponents` are non-enumerable methods on the same value
741
- * (see `ComponentBuilderMethods<T>`).
742
- * 3. **JSX callable** — `& FC<any>` lets consumers reference the
743
- * builder directly in JSX (`<Text variant="body">`). The builder
744
- * isn't *actually* a React FC at runtime — the UDS loader rewrites
745
- * `@/uds/components/<seg>` to the codegen-emitted
746
- * `.uds/components/<seg>` artifact (a real FC) before the runtime
747
- * ever sees it. The FC intersection here is the type-only
748
- * concession that keeps source files typechecking against this
749
- * value as if it were the rewritten artifact.
750
- */
751
- interface UdsComponent<P> {
752
- <C extends ElementType, TExtra = {}>(props: Omit<P, 'ref'> & {
753
- as: C;
754
- ref?: Ref<ComponentRef<C>>;
755
- } & NoInfer<TExtra>): ReactElement | null;
756
- <TExtra = {}>(props: P & NoInfer<TExtra>): ReactElement | null;
757
- readonly displayName?: string;
758
- }
759
- type ComponentBuilder<T extends ComponentDefinition> = T & ComponentBuilderMethods<T> & UdsComponent<Props<T>>;
760
- /**
761
- * Bound component returned by `.render<TExtra>(fn)`. Mirrors main's
762
- * `BoundComponent`: an `FC` whose JSX props are
763
- * `TExtra & Record<string, unknown>` so the consumer-declared extras
764
- * (`open`, `onOpenChange`, etc.) typecheck precisely at JSX call sites
765
- * while the rest of the prop surface (slot/style/HTML attrs) stays
766
- * permissively-typed — matching how the codegen-emitted wrapper FC
767
- * actually accepts props at runtime.
768
- *
769
- * The builder-chain methods stay attached so `.preview()` /
770
- * `.metadata()` / `.subcomponents()` can follow `.render(...)`.
771
- */
772
- /**
773
- * Chain methods exposed on a `BoundComponent` (post-`.render<TExtra>()`).
774
- * Mirrors the pre-render `ComponentBuilderMethods` minus `render` (you
775
- * only render once), with `.preview` / `.metadata` / `.subcomponents`
776
- * preserving the `TExtra` narrowing so chained authors keep their
777
- * TExtra-typed JSX surface at consumer call sites.
778
- */
779
- interface BoundComponentMethods<T extends ComponentDefinition, TExtra extends Record<string, unknown>> {
780
- config(cb: (helpers: TypedConfigHelpers<T>) => ConfigCallbackResultFor<T>): BoundComponent<T, TExtra>;
781
- preview(spec: PreviewDefinition<Omit<DefaultPropsFor<T>, keyof TExtra> & TExtra> | ((helpers: TypedPreviewHelpers<T>) => PreviewDefinition<Omit<DefaultPropsFor<T>, keyof TExtra> & TExtra>)): BoundComponent<T, TExtra>;
782
- subcomponents(children: Record<string, ComponentDefinition>): BoundComponent<T, TExtra>;
783
- metadata(meta: ComponentMetadata): BoundComponent<T, TExtra>;
784
- renderCanvas<TCanvasExtra extends Record<string, unknown> = TExtra>(fn: ComponentRenderFn<TCanvasExtra, T extends {
785
- props: infer P;
786
- } ? RenderPropsFromConfig<P, T extends {
787
- defaultProps: infer D;
788
- } ? keyof D : never> : unknown, T extends {
789
- layers: infer L;
790
- } ? L : Record<string, unknown>, RefArgFor<T>>): BoundComponent<T, TExtra>;
791
- }
792
- type BoundComponent<T extends ComponentDefinition, TExtra extends Record<string, unknown> = {}> = T & FC<Omit<Props<T>, keyof TExtra> & TExtra> & BoundComponentMethods<T, TExtra> & {
793
- readonly __config: T;
794
- };
795
- /** Doc-alignment alias kept for callers that imported the older name. */
796
- type DefinedComponent<T extends ComponentDefinition> = ComponentBuilder<T>;
797
- /**
798
- * Overloaded `defineComponent`:
799
- *
800
- * - `defineComponent(tag)` — single-layer seed `{ layers: { root: tag(tag) } }`.
801
- * - `defineComponent(source)` — value-extend an existing component
802
- * builder. The new seed is a fresh object spread from the source so
803
- * the source's identity stays intact; non-enumerable
804
- * `__extendsFrom` carries the source reference for codegen's
805
- * identity-keyed reverse-lookup (consumed by `Component.extendsFrom`
806
- * via the `__componentName` stamped at register time).
807
- * - `defineComponent({...})` — direct static `ComponentDefinition`
808
- * (literal authored shape). Mutated in place — same surface as the
809
- * earlier identity factory.
810
- * - `defineComponent.layers({...})` — multi-layer authoring entry.
811
- * Returns a builder seeded with the named layers; chain `.config`,
812
- * `.render`, and `.preview` from there.
813
- */
814
- interface DefineComponentFn {
815
- <const TTag extends string>(htmlTag: TTag): ComponentBuilder<{
816
- layers: {
817
- root: TagRef<TTag>;
818
- };
819
- }>;
820
- <const T extends ComponentDefinition>(definitionOrParent: T): ComponentBuilder<T>;
821
- layers<const L extends Record<string, LayerInput>>(layers: L): ComponentBuilder<{
822
- layers: L;
823
- }>;
824
- }
825
- declare const defineComponent: DefineComponentFn;
826
- /**
827
- * Mutable marker the Provider FC carries on `__udsProvider`. `name`
828
- * starts unset; `.registerProviders({ ToastProvider })` writes it to
829
- * the registration key so the Provider's `displayName` and the hook's
830
- * error message both pick up a meaningful label.
831
- */
832
- interface ProviderMarker {
833
- name?: string;
834
- }
835
- /**
836
- * Render-callback shape `defineProvider` accepts. Returns the context
837
- * value and the JSX to render inside the auto-built `Context.Provider`.
838
- */
839
- type ProviderRenderFn<TContext, TProps = Record<never, never>> = (props: {
840
- children: ReactNode;
841
- } & TProps) => {
842
- context: TContext;
843
- render: ReactNode;
844
- };
845
- /**
846
- * The Provider FC returned by `defineProvider`. Carries a
847
- * non-enumerable `__udsProvider` slot so `.registerProviders({...})`
848
- * consumers can identify provider values and back-fill the
849
- * registration name.
850
- */
851
- type ProviderComponent<TProps = Record<never, never>> = FC<{
852
- children: ReactNode;
853
- } & TProps> & {
854
- readonly __udsProvider: ProviderMarker;
855
- };
856
- /**
857
- * Legacy alias for the tuple shape `defineProvider` returns. Kept so
858
- * existing consumers reaching for `DefinedProvider<TContext, TProps>`
859
- * keep compiling.
860
- */
861
- type DefinedProvider<TContext = unknown, TProps = Record<never, never>> = readonly [ProviderComponent<TProps>, () => TContext];
862
- //#endregion
863
- export { BoundComponent, ComponentBuilder, ComponentBuilderMethods, ComponentRenderFn, ConfigCallbackHelpers, DefineComponentFn, DefinedComponent, DefinedMotion, DefinedProvider, DefinedStyleProp, DefinedTokenGroup, DefinedTokenGroupValue, PreviewCallbackHelpers, ProviderComponent, ProviderRenderFn, RawToken, TokenGroupMetadata, TokenRawValue, TypedSlotRef, asChild, boolean, defineComponent, defineComponentGroup, defineCompositeStyle, defineMode, defineModifier, defineMotion, defineStyleProp, defineTokenGroup, motion, number, slot, string, variant };