From 5b6b299e521ff88a69b90b6e7806d02f7b20300d Mon Sep 17 00:00:00 2001 From: Brian Heston <47367562+bheston@users.noreply.github.com> Date: Tue, 14 Jul 2026 19:04:13 -0400 Subject: [PATCH 1/2] AUI: Added support for generating default cursor styles --- packages/adaptive-ui/docs/api-report.md | 9 ++++++ packages/adaptive-ui/src/bin/aui.ts | 5 ++++ .../core/modules/element-styles-renderer.ts | 29 +++++++++++++++++++ .../adaptive-ui/src/core/modules/types.ts | 27 +++++++++++++++++ packages/adaptive-ui/src/reference/modules.ts | 14 +++++++++ 5 files changed, 84 insertions(+) diff --git a/packages/adaptive-ui/docs/api-report.md b/packages/adaptive-ui/docs/api-report.md index 8aafc2e0..64957722 100644 --- a/packages/adaptive-ui/docs/api-report.md +++ b/packages/adaptive-ui/docs/api-report.md @@ -116,6 +116,7 @@ export type ColorRecipeParams = { export interface ComponentAnatomy { conditions: TConditions; context?: string; + cursor?: CursorDefinition | false; focus?: FocusDefinition; interactivity?: InteractivityDefinition; name?: string; @@ -246,6 +247,12 @@ export function createTokenSwatch(name: string, intendedFor?: StyleProperty | St // @public export const createTyped: typeof TypedCSSDesignToken.createTyped; +// @public +export interface CursorDefinition { + cursorType?: string; + part?: string; +} + // @public export function deltaSwatch(palette: Palette, reference: Paint, delta: number, direction?: PaletteDirection): Color; @@ -599,6 +606,8 @@ export interface SerializableAnatomy { // (undocumented) context: string; // (undocumented) + cursor?: CursorDefinition | false; + // (undocumented) focus?: FocusDefinition; // (undocumented) interactivity?: InteractivityDefinition; diff --git a/packages/adaptive-ui/src/bin/aui.ts b/packages/adaptive-ui/src/bin/aui.ts index ef99e7c6..6a9453a2 100644 --- a/packages/adaptive-ui/src/bin/aui.ts +++ b/packages/adaptive-ui/src/bin/aui.ts @@ -347,6 +347,7 @@ function jsonToAUIStyleSheet(obj: SerializableAnatomy): AUIStyleSheet { parts: obj.parts, interactivity: obj.interactivity, focus: obj.focus, + cursor: obj.cursor, }, rules: obj.styleRules.map(style => { const styles = style.styles?.map(name => { @@ -396,6 +397,10 @@ function jsonToAUIStyleSheet(obj: SerializableAnatomy): AUIStyleSheet { } } + if (sheet.anatomy.cursor && typeof sheet.anatomy.cursor === "object") { + sheet.anatomy.cursor.part = resolvePart(obj, sheet.anatomy.cursor.part); + } + return sheet; } diff --git a/packages/adaptive-ui/src/core/modules/element-styles-renderer.ts b/packages/adaptive-ui/src/core/modules/element-styles-renderer.ts index dd4e0aeb..19f5ce0b 100644 --- a/packages/adaptive-ui/src/core/modules/element-styles-renderer.ts +++ b/packages/adaptive-ui/src/core/modules/element-styles-renderer.ts @@ -278,6 +278,35 @@ export class ElementStylesRenderer { ); } + // Apply interactive cursor styles (skip if explicitly disabled) + if (anatomy.interactivity?.interactive !== undefined && anatomy.cursor !== false) { + // Determine which part gets the cursor (already resolved to selector by aui.ts) + let cursorPart: string | undefined; + let cursorType = "pointer"; + + if (anatomy.cursor && typeof anatomy.cursor === "object") { + // Explicit cursor definition (part already resolved to selector) + cursorPart = anatomy.cursor.part ?? anatomy.focus?.focusTarget.part; + cursorType = anatomy.cursor.cursorType ?? "pointer"; + } else if (anatomy.focus) { + // Default: use focus target part (already resolved to selector) + cursorPart = anatomy.focus.focusTarget.part; + } + + // Only apply if we determined a cursor target or want to apply to root + if (cursorPart !== undefined || anatomy.focus) { + globalStyleRules.push( + { + target: { + contextCondition: anatomy.interactivity.interactive, + part: cursorPart, + }, + styles: Styles.fromProperties({ cursor: cursorType }), + }, + ); + } + } + // If this component can get focus, apply the focus indicator styles. if (anatomy.focus) { if (ElementStylesRenderer._focusResetStylesAdjusted && anatomy.focus?.resetTarget) { diff --git a/packages/adaptive-ui/src/core/modules/types.ts b/packages/adaptive-ui/src/core/modules/types.ts index dc4dd3f5..83eae82b 100644 --- a/packages/adaptive-ui/src/core/modules/types.ts +++ b/packages/adaptive-ui/src/core/modules/types.ts @@ -72,6 +72,13 @@ export interface ComponentAnatomy; + + /** + * Description of cursor behavior for interactive elements. + * If not provided, defaults to using focus.focusTarget.part with cursor: pointer. + * Set to false to explicitly disable automatic cursor generation. + */ + cursor?: CursorDefinition | false; } /** @@ -285,6 +292,25 @@ export const Focus = { }, } as const; +/** + * Defines cursor behavior for interactive elements. + * + * @public + */ +export interface CursorDefinition { + /** + * The part that should receive the cursor style when interactive. + * If undefined, uses the same part as focus.focusTarget.part. + */ + part?: string; + + /** + * The cursor type to apply (defaults to "pointer"). + * Common values: "pointer", "text", "move", "grab", "default". + */ + cursorType?: string; +} + /** * Parameters used to evaluate style modules for a component. * @@ -525,6 +551,7 @@ export interface SerializableAnatomy { parts: Record, interactivity?: InteractivityDefinition, focus?: FocusDefinition, + cursor?: CursorDefinition | false, styleRules: SerializableStyleRule[] } diff --git a/packages/adaptive-ui/src/reference/modules.ts b/packages/adaptive-ui/src/reference/modules.ts index c0d29601..1c9839d0 100644 --- a/packages/adaptive-ui/src/reference/modules.ts +++ b/packages/adaptive-ui/src/reference/modules.ts @@ -1708,6 +1708,20 @@ export const disabledStyles: Styles = Styles.fromProperties( "styles.disabled", ); +/** + * Style module for the interactive cursor. + * + * By default, sets the cursor to "pointer". + * + * @public + */ +export const interactiveCursorStyles: Styles = Styles.fromProperties( + { + cursor: "pointer", + }, + "styles.interactiveCursor", +); + /** * @public */ From 20c15b60eb569d7b5ec11b4d654ed25e55f5849c Mon Sep 17 00:00:00 2001 From: Brian Heston <47367562+bheston@users.noreply.github.com> Date: Tue, 14 Jul 2026 19:06:31 -0400 Subject: [PATCH 2/2] Change --- .changeset/silver-crabs-flash.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/silver-crabs-flash.md diff --git a/.changeset/silver-crabs-flash.md b/.changeset/silver-crabs-flash.md new file mode 100644 index 00000000..f7c535a9 --- /dev/null +++ b/.changeset/silver-crabs-flash.md @@ -0,0 +1,6 @@ +--- +"@adaptive-web/adaptive-ui-designer-core": patch +"@adaptive-web/adaptive-ui": patch +--- + +AUI: Added support for generating default cursor styles