@yahoo/uds-create-config 1.29.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/types.d.ts CHANGED
@@ -327,35 +327,104 @@ interface MotionTransition {
327
327
  interface MotionStateKeyframe {
328
328
  [key: string]: unknown;
329
329
  }
330
- interface CssMotionDefinition {
331
- runtime: 'css';
332
- keyframes: MotionKeyframes;
330
+ /**
331
+ * A time-ish CSS motion value: a raw string (`'300ms'`), a number (seconds), or
332
+ * a `token('...')` ref resolved to a `var(...)` at build time — so durations and
333
+ * easings stay token-aware like every other config value, not raw literals.
334
+ */
335
+ type MotionCssValue = string | number | TokenRef;
336
+ /** Per-side box a framer drag prop accepts (`dragConstraints`/`dragElastic`). */
337
+ type MotionDragBox = Partial<Record<'top' | 'right' | 'bottom' | 'left', number>>;
338
+ /**
339
+ * Named animation targets a JS motion can animate between, keyed by variant
340
+ * name (framer's `Variants`). `initial`/`animate`/`while*` may reference a
341
+ * variant by name (a `string`) instead of an inline keyframe.
342
+ */
343
+ type MotionVariants = Record<string, MotionStateKeyframe>;
344
+ /** A JS-motion state: inline keyframes or the name of a declared variant. */
345
+ type MotionState = MotionStateKeyframe | string;
346
+ /** `whileInView` viewport options (framer's `ViewportOptions`). */
347
+ interface MotionViewportOptions {
348
+ once?: boolean;
349
+ margin?: string;
350
+ amount?: number | 'some' | 'all';
351
+ }
352
+ /**
353
+ * The CSS timing/playback surface shared by a registered CSS motion
354
+ * ({@link CssMotionDefinition}) and an inline CSS slot motion
355
+ * ({@link CssSlotMotion}). No `keyframes` here — a definition requires them
356
+ * while a slot motion doesn't, so each declares its own.
357
+ */
358
+ interface CssMotionFields {
333
359
  transition?: MotionTransition;
334
360
  /**
335
- * Open index signature for `animation-*` CSS shorthand fields the
336
- * old `@yahoo/uds-create-config` placed directly on the motion def
337
- * (`animationDuration`, `animationTimingFunction`, etc.). Codegen
338
- * reads them off the toJSON'd shape and folds them into the emitted
339
- * `animation: ...` declaration alongside the keyframes/transition.
361
+ * Timing / playback knobs folded into the emitted `animation: …` declaration
362
+ * alongside the keyframes. No `animation` prefix — it's redundant inside a
363
+ * motion def, and these are motion-def config, not registered style props.
364
+ * Explicitly typed (not an open index signature) so they autocomplete, reject
365
+ * typos, and accept `token(...)` refs where a value can be tokenized
366
+ * (duration / timing-function / delay).
340
367
  */
341
- [key: string]: unknown;
368
+ duration?: MotionCssValue;
369
+ timingFunction?: string | TokenRef;
370
+ delay?: MotionCssValue;
371
+ iterationCount?: number | 'infinite';
372
+ direction?: 'normal' | 'reverse' | 'alternate' | 'alternate-reverse';
373
+ fillMode?: 'none' | 'forwards' | 'backwards' | 'both';
374
+ playState?: 'running' | 'paused';
375
+ /** `'none'` disables the animation under `prefers-reduced-motion: reduce`. */
376
+ reducedMotion?: 'none';
342
377
  }
343
- interface JsMotionDefinition {
344
- runtime: 'js';
345
- initial?: MotionStateKeyframe;
346
- animate?: MotionStateKeyframe;
378
+ interface CssMotionDefinition extends CssMotionFields {
379
+ runtime: 'css';
380
+ keyframes: MotionKeyframes;
381
+ }
382
+ /**
383
+ * The framer-motion `motion`-prop surface shared by a registered JS motion
384
+ * ({@link JsMotionDefinition}) and an inline JS slot motion
385
+ * ({@link JsSlotMotion}) — a preset and an inline motion accept the same
386
+ * fields; they differ only in whether `runtime` is required. Typed to the
387
+ * config-serializable subset of framer's API: no element `ref` constraints or
388
+ * event callbacks, which can't round-trip through JSON.
389
+ */
390
+ interface JsMotionFields {
391
+ /** Named targets `initial`/`animate`/`while*` may reference by name. */
392
+ variants?: MotionVariants;
393
+ initial?: MotionState | boolean;
394
+ animate?: MotionState;
347
395
  /**
348
396
  * Exit keyframes — applied when the host element unmounts. Requires
349
397
  * the consumer to render the slot conditionally so the JS runtime
350
398
  * (`motion/react`'s `<AnimatePresence>`) can play the exit before the
351
399
  * node detaches.
352
400
  */
353
- exit?: MotionStateKeyframe;
401
+ exit?: MotionState;
354
402
  transition?: MotionTransition;
355
403
  /** Keyframes applied while the element is hovered. */
356
- whileHover?: MotionStateKeyframe;
404
+ whileHover?: MotionState;
357
405
  /** Keyframes applied while the element is actively pressed. */
358
- whileTap?: MotionStateKeyframe;
406
+ whileTap?: MotionState;
407
+ /** Keyframes applied while the element holds keyboard focus. */
408
+ whileFocus?: MotionState;
409
+ /** Keyframes applied while the element is being dragged. */
410
+ whileDrag?: MotionState;
411
+ /** Keyframes applied while the element is in the viewport. */
412
+ whileInView?: MotionState;
413
+ viewport?: MotionViewportOptions;
414
+ drag?: boolean | 'x' | 'y';
415
+ dragConstraints?: boolean | MotionDragBox;
416
+ dragElastic?: boolean | number | MotionDragBox;
417
+ dragMomentum?: boolean;
418
+ dragSnapToOrigin?: boolean;
419
+ dragPropagation?: boolean;
420
+ dragDirectionLock?: boolean;
421
+ dragTransition?: MotionTransition;
422
+ layout?: boolean | 'position' | 'size';
423
+ layoutId?: string;
424
+ layoutDependency?: string | number;
425
+ }
426
+ interface JsMotionDefinition extends JsMotionFields {
427
+ runtime: 'js';
359
428
  }
360
429
  type MotionDefinitionInput = CssMotionDefinition | JsMotionDefinition;
361
430
  /**
@@ -400,24 +469,32 @@ interface CompoundPropsEntry {
400
469
  layers: Record<string, unknown>;
401
470
  }
402
471
  /**
403
- * Per-layer framer-motion spec a component carries inline. Mirrors
404
- * main's `SlotMotion`: every field is `unknown` because the framer-
405
- * motion API surface is wide and we don't want to lock authoring to
406
- * a particular `motion/react` version. Codegen passes the value
407
- * through to the runtime renderer.
472
+ * JS-runtime inline slot motion — a `motion/react` config the component
473
+ * carries inline and codegen spreads onto the hoisted `motion.create`
474
+ * wrapper. Shares {@link JsMotionFields} with a `registerMotion({ runtime:
475
+ * 'js' })` preset (identical field set); the only difference is that
476
+ * `runtime` is optional here (absent ⇒ JS).
408
477
  */
409
- interface SlotMotion {
410
- readonly runtime?: 'js' | 'css';
411
- readonly initial?: unknown;
412
- readonly animate?: unknown;
413
- readonly exit?: unknown;
414
- readonly transition?: unknown;
415
- readonly whileHover?: unknown;
416
- readonly whileTap?: unknown;
417
- readonly drag?: unknown;
418
- readonly dragConstraints?: unknown;
419
- readonly dragElastic?: unknown;
478
+ interface JsSlotMotion extends JsMotionFields {
479
+ readonly runtime?: 'js';
420
480
  }
481
+ /**
482
+ * CSS-runtime inline slot motion — mirrors the timing/playback knobs of a
483
+ * `registerMotion({ runtime: 'css' })` definition via the shared
484
+ * {@link CssMotionFields}, so an inline CSS motion emits an `animation: …`
485
+ * declaration from its own keyframes instead of pulling in `motion/react`.
486
+ */
487
+ interface CssSlotMotion extends CssMotionFields {
488
+ readonly runtime: 'css';
489
+ readonly keyframes?: MotionKeyframes;
490
+ }
491
+ /**
492
+ * Per-layer motion spec a component carries inline, discriminated on
493
+ * `runtime`. Absent/`'js'` → {@link JsSlotMotion} (framer-motion config);
494
+ * `'css'` → {@link CssSlotMotion} (emitted `animation` declaration). Codegen
495
+ * branches on `runtime` and passes the value through to the runtime renderer.
496
+ */
497
+ type SlotMotion = JsSlotMotion | CssSlotMotion;
421
498
  /**
422
499
  * Component-level motion field. Three shapes:
423
500
  * - `string` — alias of a `registerMotion({...})` preset.
@@ -884,4 +961,4 @@ interface SerializedConfig {
884
961
  playgroundOptions?: SerializedPlaygroundOptions;
885
962
  }
886
963
  //#endregion
887
- export { AnyStylePropDefinition, ArbitraryEntry, ArbitrarySpec, BaseStyles, BuildOptions, CanvasRole, CanvasRoleEntry, CanvasRoleEntryInput, CanvasRolesDefinition, CanvasRolesDefinitionInput, CanvasRolesInputConstraint, ComponentDefinition, ComponentGroupDefinition, ComponentMetadata, ComponentMotionValue, CompositeStyleDefinition, CompositeStyleObject, CompoundPropsEntry, CssMotionDefinition, FontAssetMember, GlobalStylesDef, JsMotionDefinition, LayerInput, LiteralFor, ModeDefinition, ModeOptionDefinition, ModifierDefinition, MotionDefinitionInput, MotionKeyframes, MotionStateKeyframe, MotionTransition, OpacityPairSpec, PlaygroundOptions, PlaygroundPage, PlaygroundSpec, PreviewDefinition, PropBinding, RefElement, RefTag, RootTag, SerializedAssetGroup, SerializedComponent, SerializedComponentGroup, SerializedConfig, SerializedFontAssetGroup, SerializedIconAssetGroup, SerializedPlaygroundOptions, SerializedTokenGroup, SlotMotion, StylePropDefinition, StylePropMetadata, StylePropProperty, TokenDefinition, TokenGroupDefinition, TokenModifierKey, TokenModifierValue, TokenType, TokenValue, ValuesEntry };
964
+ export { AnyStylePropDefinition, ArbitraryEntry, ArbitrarySpec, BaseStyles, BuildOptions, CanvasRole, CanvasRoleEntry, CanvasRoleEntryInput, CanvasRolesDefinition, CanvasRolesDefinitionInput, CanvasRolesInputConstraint, ComponentDefinition, ComponentGroupDefinition, ComponentMetadata, ComponentMotionValue, CompositeStyleDefinition, CompositeStyleObject, CompoundPropsEntry, CssMotionDefinition, CssMotionFields, CssSlotMotion, FontAssetMember, GlobalStylesDef, JsMotionDefinition, JsMotionFields, JsSlotMotion, LayerInput, LiteralFor, ModeDefinition, ModeOptionDefinition, ModifierDefinition, MotionDefinitionInput, MotionDragBox, MotionKeyframes, MotionState, MotionStateKeyframe, MotionTransition, MotionVariants, MotionViewportOptions, OpacityPairSpec, PlaygroundOptions, PlaygroundPage, PlaygroundSpec, PreviewDefinition, PropBinding, RefElement, RefTag, RootTag, SerializedAssetGroup, SerializedComponent, SerializedComponentGroup, SerializedConfig, SerializedFontAssetGroup, SerializedIconAssetGroup, SerializedPlaygroundOptions, SerializedTokenGroup, SlotMotion, StylePropDefinition, StylePropMetadata, StylePropProperty, TokenDefinition, TokenGroupDefinition, TokenModifierKey, TokenModifierValue, TokenType, TokenValue, ValuesEntry };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yahoo/uds-create-config",
3
- "version": "1.29.1",
3
+ "version": "2.0.0",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "files": [
@@ -68,7 +68,7 @@
68
68
  "dependencies": {
69
69
  "@babel/parser": "^7.29.0",
70
70
  "motion": "^12.35.0",
71
- "@yahoo/uds-create-utils": "1.29.1"
71
+ "@yahoo/uds-create-utils": "2.0.0"
72
72
  },
73
73
  "devDependencies": {
74
74
  "@babel/types": "^7.29.0",