({
cursorFlags,
groups,
state
}: {
cursorFlags: number;
groups: RegisteredGroup[];
state: InteractionState["state"];
})
| 10 | import { supportsAdvancedCursorStyles } from "./supportsAdvancedCursorStyles"; |
| 11 | |
| 12 | export function getCursorStyle({ |
| 13 | cursorFlags, |
| 14 | groups, |
| 15 | state |
| 16 | }: { |
| 17 | cursorFlags: number; |
| 18 | groups: RegisteredGroup[]; |
| 19 | state: InteractionState["state"]; |
| 20 | }): Properties["cursor"] { |
| 21 | let horizontalCount = 0; |
| 22 | let verticalCount = 0; |
| 23 | |
| 24 | switch (state) { |
| 25 | case "active": |
| 26 | case "hover": { |
| 27 | groups.forEach((group) => { |
| 28 | if (group.mutableState.disableCursor) { |
| 29 | return; |
| 30 | } |
| 31 | |
| 32 | switch (group.orientation) { |
| 33 | case "horizontal": { |
| 34 | horizontalCount++; |
| 35 | break; |
| 36 | } |
| 37 | case "vertical": { |
| 38 | verticalCount++; |
| 39 | break; |
| 40 | } |
| 41 | } |
| 42 | }); |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | if (horizontalCount === 0 && verticalCount === 0) { |
| 47 | return undefined; |
| 48 | } |
| 49 | |
| 50 | switch (state) { |
| 51 | case "active": { |
| 52 | if (cursorFlags) { |
| 53 | if (supportsAdvancedCursorStyles()) { |
| 54 | const horizontalMin = |
| 55 | (cursorFlags & CURSOR_FLAG_HORIZONTAL_MIN) !== 0; |
| 56 | const horizontalMax = |
| 57 | (cursorFlags & CURSOR_FLAG_HORIZONTAL_MAX) !== 0; |
| 58 | const verticalMin = (cursorFlags & CURSOR_FLAG_VERTICAL_MIN) !== 0; |
| 59 | const verticalMax = (cursorFlags & CURSOR_FLAG_VERTICAL_MAX) !== 0; |
| 60 | |
| 61 | if (horizontalMin) { |
| 62 | if (verticalMin) { |
| 63 | return "se-resize"; |
| 64 | } else if (verticalMax) { |
| 65 | return "ne-resize"; |
| 66 | } else { |
| 67 | return "e-resize"; |
| 68 | } |
| 69 | } else if (horizontalMax) { |
no test coverage detected