@activecollab/components 2.0.469 → 2.0.470

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 (29) hide show
  1. package/dist/cjs/components/StackedCard/StackedCard.js.map +1 -1
  2. package/dist/cjs/components/StackedCard/Styles.js.map +1 -1
  3. package/dist/cjs/components/StackedCard/resizePolicy.js +141 -60
  4. package/dist/cjs/components/StackedCard/resizePolicy.js.map +1 -1
  5. package/dist/cjs/components/StackedCard/resizePolicy.test.js +362 -15
  6. package/dist/cjs/components/StackedCard/resizePolicy.test.js.map +1 -1
  7. package/dist/cjs/components/StackedCard/useStackedCardResize.js +35 -14
  8. package/dist/cjs/components/StackedCard/useStackedCardResize.js.map +1 -1
  9. package/dist/esm/components/StackedCard/StackedCard.d.ts +5 -5
  10. package/dist/esm/components/StackedCard/StackedCard.d.ts.map +1 -1
  11. package/dist/esm/components/StackedCard/StackedCard.js.map +1 -1
  12. package/dist/esm/components/StackedCard/Styles.d.ts +2 -2
  13. package/dist/esm/components/StackedCard/Styles.d.ts.map +1 -1
  14. package/dist/esm/components/StackedCard/Styles.js.map +1 -1
  15. package/dist/esm/components/StackedCard/resizePolicy.d.ts +85 -40
  16. package/dist/esm/components/StackedCard/resizePolicy.d.ts.map +1 -1
  17. package/dist/esm/components/StackedCard/resizePolicy.js +139 -60
  18. package/dist/esm/components/StackedCard/resizePolicy.js.map +1 -1
  19. package/dist/esm/components/StackedCard/resizePolicy.test.js +359 -16
  20. package/dist/esm/components/StackedCard/resizePolicy.test.js.map +1 -1
  21. package/dist/esm/components/StackedCard/useStackedCardResize.d.ts +25 -13
  22. package/dist/esm/components/StackedCard/useStackedCardResize.d.ts.map +1 -1
  23. package/dist/esm/components/StackedCard/useStackedCardResize.js +35 -14
  24. package/dist/esm/components/StackedCard/useStackedCardResize.js.map +1 -1
  25. package/dist/index.js +179 -74
  26. package/dist/index.js.map +1 -1
  27. package/dist/index.min.js +1 -1
  28. package/dist/index.min.js.map +1 -1
  29. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"resizePolicy.js","names":["DEFAULT_KEYBOARD_STEP","exports","SHIFT_STEP_MULTIPLIER","RESIZE_KEYS","isResizeKey","key","includes","clamp","v","lo","hi","Math","min","Number","POSITIVE_INFINITY","max","snap","step","round","makeStart","size","contentMin","w","h","effectiveBounds","policy","_policy$minW","_policy$minH","_policy$maxW","_policy$maxH","wMin","minW","hMin","minH","wMax","maxW","hMax","maxH","hasFloor","policyMin","undefined","applyResize","start","delta","opts","arguments","length","_effectiveBounds","widthOnly","axis","dx","dy","proportional","constrain","sW","sH","scale","abs","scaleMin","scaleMax","keyboardResize","base","shiftKey","b","apply","jump","_objectSpread","isFinite","measurePercent","_effectiveBounds2"],"sources":["../../../../src/components/StackedCard/resizePolicy.ts"],"sourcesContent":["/**\n * StackedCard resize policy — pure math.\n *\n * The card reports intent; the HOST applies a resize policy (spec §7). This\n * module is that policy, packaged as pure functions so the SAME code path\n * serves the pointer drag and the keyboard resize. Nothing here touches the\n * DOM, React or the card's content: it takes a start size, a delta and a\n * policy, and returns a clamped size. `useStackedCardResize` wires events to\n * it; the card's intrinsic content minimum is measured by the host and passed\n * in as `contentMin`, so this module knows nothing about heroes or footers.\n *\n * The policy has four parts:\n * - bounds — optional min/max per axis; unset means unbounded.\n * - proportional — lock the aspect ratio captured at the start of the gesture;\n * the scale is clamped by the BINDING axis so the ratio never\n * distorts at a bound.\n * - step — optional grid snap; proportion wins over the grid.\n * - content min — the effective min is max(policyMin, contentMin) per axis,\n * so a card can never be crushed below what its content needs.\n */\n\nexport interface StackedCardSize {\n w: number;\n h: number;\n}\n\n/** The card's intrinsic minimum, measured from its real content. */\nexport interface StackedCardContentMin {\n w: number;\n h: number;\n}\n\nexport interface StackedCardResizePolicy {\n minW?: number;\n maxW?: number;\n minH?: number;\n maxH?: number;\n /** Lock the aspect ratio for the whole gesture. */\n proportional: boolean;\n /** Grid snap increment in px; omitted / 0 means continuous. */\n step?: number;\n}\n\n/** The size captured at the start of a gesture (pointer down or a key press). */\nexport interface StackedCardResizeStart {\n w: number;\n h: number;\n contentMin: StackedCardContentMin;\n}\n\nexport interface StackedCardResizeDelta {\n dx: number;\n dy: number;\n}\n\nexport interface StackedCardResizeBounds {\n wMin: number;\n wMax: number;\n hMin: number;\n hMax: number;\n}\n\n/**\n * `width` locks the vertical axis: an auto-height card takes a width and lets\n * its rows set the height, so the gesture's vertical component is ignored.\n */\nexport type StackedCardResizeAxis = \"both\" | \"width\";\n\n/** Which input drove a resize event. Hosts log undo entries per source. */\nexport type StackedCardResizeSource = \"pointer\" | \"keyboard\";\n\n/** Keyboard resize nudges by the policy step, or this when no step is set. */\nexport const DEFAULT_KEYBOARD_STEP = 8;\n\n/** Shift + arrow resizes by a larger increment (the familiar coarse nudge). */\nexport const SHIFT_STEP_MULTIPLIER = 4;\n\n/** Keys the separator handles; everything else falls through to the browser. */\nexport const RESIZE_KEYS: ReadonlyArray<string> = [\n \"ArrowLeft\",\n \"ArrowRight\",\n \"ArrowUp\",\n \"ArrowDown\",\n \"Home\",\n \"End\",\n];\n\nexport const isResizeKey = (key: string): boolean => RESIZE_KEYS.includes(key);\n\nexport const clamp = (v: number, lo: number, hi?: number): number =>\n Math.min(hi ?? Number.POSITIVE_INFINITY, Math.max(lo, v));\n\nexport const snap = (v: number, step?: number): number =>\n step && step > 0 ? Math.round(v / step) * step : v;\n\nexport const makeStart = (\n size: StackedCardSize,\n contentMin: StackedCardContentMin\n): StackedCardResizeStart => ({\n w: size.w,\n h: size.h,\n contentMin,\n});\n\n/**\n * The effective bounds a size is clamped to: the policy min floored by the\n * content min, and the policy max (unbounded when unset). Independent of any\n * live gesture, so a host can also use it for the aria value and Home/End.\n */\nexport const effectiveBounds = (\n policy: StackedCardResizePolicy,\n contentMin: StackedCardContentMin\n): StackedCardResizeBounds => ({\n wMin: Math.max(policy.minW ?? 0, contentMin.w),\n hMin: Math.max(policy.minH ?? 0, contentMin.h),\n wMax: policy.maxW ?? Number.POSITIVE_INFINITY,\n hMax: policy.maxH ?? Number.POSITIVE_INFINITY,\n});\n\n/**\n * Whether an axis has a floor anyone asked for. `effectiveBounds` reports 0 for\n * an unset minimum — correct as a clamp, but not something Home should jump to:\n * an axis nobody gave a minimum must not collapse to nothing.\n */\nconst hasFloor = (policyMin: number | undefined, contentMin: number): boolean =>\n policyMin !== undefined || contentMin > 0;\n\n/**\n * Apply a delta to the start size under the policy — the single path for both\n * inputs.\n *\n * `constrain` is the transient Shift-to-constrain lock: a free-form policy\n * behaves proportionally for that one gesture; a proportional policy is already\n * locked and ignores it. `axis: \"width\"` drops the gesture's vertical component;\n * the height then holds still in free-form mode, and still follows the ratio in\n * proportional mode (that is what proportional means).\n */\nexport const applyResize = (\n start: StackedCardResizeStart,\n delta: StackedCardResizeDelta,\n policy: StackedCardResizePolicy,\n opts: { constrain?: boolean; axis?: StackedCardResizeAxis } = {}\n): StackedCardSize => {\n const { wMin, hMin, wMax, hMax } = effectiveBounds(policy, start.contentMin);\n const widthOnly = opts.axis === \"width\";\n const dx = delta.dx;\n const dy = widthOnly ? 0 : delta.dy;\n\n // A ratio needs two non-zero sides to be a ratio at all; a width-only card\n // parks a placeholder height, so fall back to free-form rather than dividing\n // by zero.\n const proportional =\n (policy.proportional || opts.constrain === true) &&\n start.w > 0 &&\n start.h > 0;\n\n let w: number;\n let h: number;\n\n if (proportional) {\n // one scale drives both axes; the corner's dominant direction wins, so a\n // vertical drag is as effective as a horizontal one\n const sW = (start.w + dx) / start.w;\n const sH = (start.h + dy) / start.h;\n let scale = Math.abs(sW - 1) >= Math.abs(sH - 1) ? sW : sH;\n\n // step: proportion wins over the grid. Snap through the SCALE (driven off\n // the width edge) so both axes move together and the ratio survives; the\n // grid yields whenever honouring it would cost the ratio.\n if (policy.step) {\n scale = snap(start.w * scale, policy.step) / start.w;\n }\n\n // Then clamp the scale so both axes stay in bounds (the binding constraint):\n // the ratio can never break at a bound — whichever edge is limiting stops\n // both. The clamp comes last on purpose: a bound is a hard stop, so the card\n // sits exactly on it rather than at the nearest grid line inside it.\n const scaleMin = Math.max(wMin / start.w, hMin / start.h);\n const scaleMax = Math.min(wMax / start.w, hMax / start.h);\n scale = clamp(scale, scaleMin, Math.max(scaleMin, scaleMax));\n\n w = start.w * scale;\n h = start.h * scale;\n } else {\n w = clamp(snap(start.w + dx, policy.step), wMin, wMax);\n h = widthOnly\n ? start.h\n : clamp(snap(start.h + dy, policy.step), hMin, hMax);\n }\n\n return { w: Math.round(w), h: Math.round(h) };\n};\n\n/**\n * Translate a resize key into the next size, reusing `applyResize` so the\n * keyboard clamps exactly like the pointer. Arrows nudge by the step (Shift ×4);\n * Home/End jump to the min/max of the allowed range, leaving any axis without\n * that bound where it is. Returns null for a key the handle does not own, and\n * for a vertical key on a width-only card.\n */\nexport const keyboardResize = (\n key: string,\n size: StackedCardSize,\n policy: StackedCardResizePolicy,\n contentMin: StackedCardContentMin,\n opts: { shiftKey?: boolean; axis?: StackedCardResizeAxis } = {}\n): StackedCardSize | null => {\n const widthOnly = opts.axis === \"width\";\n if (widthOnly && (key === \"ArrowUp\" || key === \"ArrowDown\")) return null;\n\n const base =\n policy.step && policy.step > 0 ? policy.step : DEFAULT_KEYBOARD_STEP;\n const step = base * (opts.shiftKey ? SHIFT_STEP_MULTIPLIER : 1);\n const start = makeStart(size, contentMin);\n const b = effectiveBounds(policy, contentMin);\n const apply = (delta: StackedCardResizeDelta): StackedCardSize =>\n applyResize(start, delta, policy, { axis: opts.axis });\n\n /**\n * Home and End are absolute jumps to a bound, not nudges, so they ignore the\n * grid: landing 4px off the minimum because that is where the nearest grid\n * line fell would mean the keyboard could never reach the bound the pointer\n * stops at.\n */\n const jump = (delta: StackedCardResizeDelta): StackedCardSize =>\n applyResize(start, delta, { ...policy, step: 0 }, { axis: opts.axis });\n\n switch (key) {\n case \"ArrowRight\":\n return apply({ dx: step, dy: 0 });\n case \"ArrowLeft\":\n return apply({ dx: -step, dy: 0 });\n case \"ArrowDown\":\n return apply({ dx: 0, dy: step });\n case \"ArrowUp\":\n return apply({ dx: 0, dy: -step });\n case \"Home\":\n // jump to the min corner; an axis with no floor of its own stays put\n return jump({\n dx: hasFloor(policy.minW, contentMin.w) ? b.wMin - size.w : 0,\n dy:\n !widthOnly && hasFloor(policy.minH, contentMin.h)\n ? b.hMin - size.h\n : 0,\n });\n case \"End\":\n // jump to the max corner; an unbounded axis simply doesn't move\n return jump({\n dx: Number.isFinite(b.wMax) ? b.wMax - size.w : 0,\n dy: !widthOnly && Number.isFinite(b.hMax) ? b.hMax - size.h : 0,\n });\n default:\n return null;\n }\n};\n\n/**\n * The handle's `aria-valuenow`: the current size as a percent (0–100) of its\n * allowed range. The corner resizes both axes, but the value must be a single\n * number, so it reports the WIDTH axis — the one axis the fixed-box and the\n * width-only cards share. Returns 0 when the range isn't finite (no max bound).\n */\nexport const measurePercent = (\n size: StackedCardSize,\n policy: StackedCardResizePolicy,\n contentMin: StackedCardContentMin\n): number => {\n const { wMin, wMax } = effectiveBounds(policy, contentMin);\n if (!Number.isFinite(wMax) || wMax <= wMin) return 0;\n return Math.round(clamp(((size.w - wMin) / (wMax - wMin)) * 100, 0, 100));\n};\n"],"mappings":";;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA;;AAiBA;;AAmBA;AACA;AACA;AACA;;AAGA;;AAGA;AACO,IAAMA,qBAAqB,GAAAC,OAAA,CAAAD,qBAAA,GAAG,CAAC;;AAEtC;AACO,IAAME,qBAAqB,GAAAD,OAAA,CAAAC,qBAAA,GAAG,CAAC;;AAEtC;AACO,IAAMC,WAAkC,GAAAF,OAAA,CAAAE,WAAA,GAAG,CAChD,WAAW,EACX,YAAY,EACZ,SAAS,EACT,WAAW,EACX,MAAM,EACN,KAAK,CACN;AAEM,IAAMC,WAAW,GAAAH,OAAA,CAAAG,WAAA,GAAG,SAAdA,WA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EP_MULTIPLIER","RESIZE_KEYS","isResizeKey","key","includes","clamp","v","lo","hi","Math","min","Number","POSITIVE_INFINITY","max","snap","step","round","makeStart","box","contentMin","_box$x","_box$y","w","h","x","y","effectiveBounds","policy","_policy$minW","_policy$minH","_policy$maxW","_policy$maxH","wMin","minW","hMin","minH","wMax","maxW","hMax","maxH","hasFloor","policyMin","undefined","anchorSigns","anchor","sx","sy","snapMovingEdge","origin","startLength","length","sign","anchoredOrigin","applyResize","start","delta","_opts$anchor","opts","arguments","_effectiveBounds","widthOnly","axis","_anchorSigns","anchorSy","dx","dy","proportional","constrain","sW","sH","drivenByWidth","abs","scale","scaleMin","scaleMax","keyboardResize","_opts$anchor2","_anchorSigns2","horizontalKey","verticalKey","base","shiftKey","b","resizeOpts","apply","jump","growW","growH","_objectSpread","isFinite","measurePercent","size","_effectiveBounds2"],"sources":["../../../../src/components/StackedCard/resizePolicy.ts"],"sourcesContent":["/**\n * Resize policy — pure math, shared by every resizable element.\n *\n * The element reports intent; the HOST applies a resize policy (StackedCard\n * spec §7). This module is that policy, packaged as pure functions so the SAME\n * code path serves the pointer drag and the keyboard resize, a card's single\n * bottom-right grip and a shape's eight handles. Nothing here touches the DOM,\n * React or the element's content: it takes a start box, a delta, a policy and\n * the handle being dragged, and returns a clamped box — size AND position.\n * `useStackedCardResize` wires events to it; an element's intrinsic content\n * minimum is measured by the host and passed in as `contentMin`, so this module\n * knows nothing about heroes or footers.\n *\n * The policy has four parts:\n * - bounds — optional min/max per axis; unset means unbounded.\n * - proportional — lock the aspect ratio captured at the start of the gesture;\n * the scale is clamped by the BINDING axis so the ratio never\n * distorts at a bound.\n * - step — optional grid snap; proportion wins over the grid.\n * - content min — the effective min is max(policyMin, contentMin) per axis,\n * so an element can never be crushed below what its content\n * needs.\n *\n * The anchor is the handle being dragged. The edge or corner OPPOSITE to it\n * never moves — not while the pointer travels, and not when a bound stops the\n * resize — which is what makes a resize feel like a resize rather than a nudge.\n * A `left` handle moves the position by exactly the amount the width grew; a\n * `right` handle leaves it alone. An edge handle touches one axis only.\n */\n\nexport interface ResizeSize {\n w: number;\n h: number;\n}\n\nexport interface ResizePosition {\n x: number;\n y: number;\n}\n\n/** A resized element: its size and where its top-left corner now sits. */\nexport interface ResizeBox extends ResizeSize, ResizePosition {}\n\n/** The element's intrinsic minimum, measured from its real content. */\nexport interface ResizeContentMin {\n w: number;\n h: number;\n}\n\nexport interface ResizePolicy {\n minW?: number;\n maxW?: number;\n minH?: number;\n maxH?: number;\n /** Lock the aspect ratio for the whole gesture. */\n proportional: boolean;\n /** Grid snap increment in px; omitted / 0 means continuous. */\n step?: number;\n}\n\n/**\n * The handle being dragged, named after the edge or corner it sits on. The\n * opposite edge or corner is held in place.\n */\nexport type ResizeAnchor =\n | \"top-left\"\n | \"top\"\n | \"top-right\"\n | \"right\"\n | \"bottom-right\"\n | \"bottom\"\n | \"bottom-left\"\n | \"left\";\n\nexport const RESIZE_ANCHORS: ReadonlyArray<ResizeAnchor> = [\n \"top-left\",\n \"top\",\n \"top-right\",\n \"right\",\n \"bottom-right\",\n \"bottom\",\n \"bottom-left\",\n \"left\",\n];\n\n/** A card's single grip: the top-left corner stays put. */\nexport const DEFAULT_RESIZE_ANCHOR: ResizeAnchor = \"bottom-right\";\n\n/**\n * The box captured at the start of a gesture (pointer down or a key press).\n * A host that only tracks a size leaves the position at the origin.\n */\nexport interface ResizeStart extends ResizeBox {\n contentMin: ResizeContentMin;\n}\n\nexport interface ResizeDelta {\n dx: number;\n dy: number;\n}\n\nexport interface ResizeBounds {\n wMin: number;\n wMax: number;\n hMin: number;\n hMax: number;\n}\n\n/**\n * `width` locks the vertical axis: an auto-height card takes a width and lets\n * its rows set the height, so the gesture's vertical component is ignored.\n */\nexport type ResizeAxis = \"both\" | \"width\";\n\n/** Which input drove a resize event. Hosts log undo entries per source. */\nexport type ResizeSource = \"pointer\" | \"keyboard\";\n\nexport interface ResizeOptions {\n /** Shift-to-constrain: one gesture behaves proportionally. */\n constrain?: boolean;\n axis?: ResizeAxis;\n /** The handle being dragged. Defaults to a card's bottom-right grip. */\n anchor?: ResizeAnchor;\n}\n\n/** Keyboard resize nudges by the policy step, or this when no step is set. */\nexport const DEFAULT_KEYBOARD_STEP = 8;\n\n/** Shift + arrow resizes by a larger increment (the familiar coarse nudge). */\nexport const SHIFT_STEP_MULTIPLIER = 4;\n\n/** Keys the separator handles; everything else falls through to the browser. */\nexport const RESIZE_KEYS: ReadonlyArray<string> = [\n \"ArrowLeft\",\n \"ArrowRight\",\n \"ArrowUp\",\n \"ArrowDown\",\n \"Home\",\n \"End\",\n];\n\nexport const isResizeKey = (key: string): boolean => RESIZE_KEYS.includes(key);\n\nexport const clamp = (v: number, lo: number, hi?: number): number =>\n Math.min(hi ?? Number.POSITIVE_INFINITY, Math.max(lo, v));\n\nexport const snap = (v: number, step?: number): number =>\n step && step > 0 ? Math.round(v / step) * step : v;\n\nexport const makeStart = (\n box: ResizeSize & Partial<ResizePosition>,\n contentMin: ResizeContentMin\n): ResizeStart => ({\n w: box.w,\n h: box.h,\n x: box.x ?? 0,\n y: box.y ?? 0,\n contentMin,\n});\n\n/**\n * The effective bounds a size is clamped to: the policy min floored by the\n * content min, and the policy max (unbounded when unset). Independent of any\n * live gesture, so a host can also use it for the aria value and Home/End.\n */\nexport const effectiveBounds = (\n policy: ResizePolicy,\n contentMin: ResizeContentMin\n): ResizeBounds => ({\n wMin: Math.max(policy.minW ?? 0, contentMin.w),\n hMin: Math.max(policy.minH ?? 0, contentMin.h),\n wMax: policy.maxW ?? Number.POSITIVE_INFINITY,\n hMax: policy.maxH ?? Number.POSITIVE_INFINITY,\n});\n\n/**\n * Whether an axis has a floor anyone asked for. `effectiveBounds` reports 0 for\n * an unset minimum — correct as a clamp, but not something Home should jump to:\n * an axis nobody gave a minimum must not collapse to nothing.\n */\nconst hasFloor = (policyMin: number | undefined, contentMin: number): boolean =>\n policyMin !== undefined || contentMin > 0;\n\ntype AxisSign = -1 | 0 | 1;\n\n/**\n * Which way each axis grows for a handle: +1 when the handle is on the far\n * edge (right/bottom), −1 when it is on the near edge (left/top), 0 when the\n * handle does not touch that axis at all.\n */\nexport const anchorSigns = (\n anchor: ResizeAnchor\n): { sx: AxisSign; sy: AxisSign } => ({\n sx: anchor.includes(\"left\") ? -1 : anchor.includes(\"right\") ? 1 : 0,\n sy: anchor.includes(\"top\") ? -1 : anchor.includes(\"bottom\") ? 1 : 0,\n});\n\n/**\n * Snap the MOVING edge of one axis to the grid and return the length that\n * leaves the anchored edge exactly where it was. A far-edge handle snaps\n * `origin + length`; a near-edge handle snaps `origin + startLength − length`.\n * With no step this is the identity.\n */\nconst snapMovingEdge = (\n origin: number,\n startLength: number,\n length: number,\n sign: AxisSign,\n step?: number\n): number => {\n if (!step || sign === 0) return length;\n return sign > 0\n ? snap(origin + length, step) - origin\n : origin + startLength - snap(origin + startLength - length, step);\n};\n\n/** The position that keeps the anchored edge of one axis in place. */\nconst anchoredOrigin = (\n origin: number,\n startLength: number,\n length: number,\n sign: AxisSign\n): number => (sign < 0 ? origin + startLength - length : origin);\n\n/**\n * Apply a delta to the start box under the policy — the single path for both\n * inputs and for every handle.\n *\n * `constrain` is the transient Shift-to-constrain lock: a free-form policy\n * behaves proportionally for that one gesture; a proportional policy is already\n * locked and ignores it. `axis: \"width\"` drops the gesture's vertical component;\n * the height then holds still in free-form mode, and still follows the ratio in\n * proportional mode (that is what proportional means). `anchor` is the handle\n * being dragged: the opposite edge or corner is held, so the returned position\n * moves only when a near-edge handle (left/top) grew or shrank the box.\n */\nexport const applyResize = (\n start: ResizeStart,\n delta: ResizeDelta,\n policy: ResizePolicy,\n opts: ResizeOptions = {}\n): ResizeBox => {\n const { wMin, hMin, wMax, hMax } = effectiveBounds(policy, start.contentMin);\n const widthOnly = opts.axis === \"width\";\n const { sx, sy: anchorSy } = anchorSigns(\n opts.anchor ?? DEFAULT_RESIZE_ANCHOR\n );\n const sy: AxisSign = widthOnly ? 0 : anchorSy;\n const dx = sx * delta.dx;\n const dy = sy * delta.dy;\n\n // A ratio needs two non-zero sides to be a ratio at all; a width-only card\n // parks a placeholder height, so fall back to free-form rather than dividing\n // by zero.\n const proportional =\n (policy.proportional || opts.constrain === true) &&\n start.w > 0 &&\n start.h > 0;\n\n let w: number;\n let h: number;\n\n if (proportional) {\n // one scale drives both axes; the corner's dominant direction wins, so a\n // vertical drag is as effective as a horizontal one. An edge handle has\n // only its own axis to drive with.\n const sW = sx === 0 ? 1 : (start.w + dx) / start.w;\n const sH = sy === 0 ? 1 : (start.h + dy) / start.h;\n const drivenByWidth =\n sx !== 0 && (sy === 0 || Math.abs(sW - 1) >= Math.abs(sH - 1));\n let scale = drivenByWidth ? sW : sH;\n\n // step: proportion wins over the grid. Snap through the SCALE, driven off\n // the moving edge of the driving axis, so both axes move together and the\n // ratio survives; the grid yields whenever honouring it would cost the\n // ratio.\n if (policy.step) {\n scale = drivenByWidth\n ? snapMovingEdge(start.x, start.w, start.w * scale, sx, policy.step) /\n start.w\n : snapMovingEdge(start.y, start.h, start.h * scale, sy, policy.step) /\n start.h;\n }\n\n // Then clamp the scale so both axes stay in bounds (the binding constraint):\n // the ratio can never break at a bound — whichever edge is limiting stops\n // both. The clamp comes last on purpose: a bound is a hard stop, so the\n // element sits exactly on it rather than at the nearest grid line inside it.\n const scaleMin = Math.max(wMin / start.w, hMin / start.h);\n const scaleMax = Math.min(wMax / start.w, hMax / start.h);\n scale = clamp(scale, scaleMin, Math.max(scaleMin, scaleMax));\n\n w = start.w * scale;\n h = start.h * scale;\n } else {\n // An axis the handle does not touch holds its start value exactly — it is\n // neither snapped nor clamped, because nothing about it changed.\n w =\n sx === 0\n ? start.w\n : clamp(\n snapMovingEdge(start.x, start.w, start.w + dx, sx, policy.step),\n wMin,\n wMax\n );\n h =\n sy === 0\n ? start.h\n : clamp(\n snapMovingEdge(start.y, start.h, start.h + dy, sy, policy.step),\n hMin,\n hMax\n );\n }\n\n // Round the size first and derive the position from the rounded size, so\n // the anchored edge lands on exactly the coordinate it started at.\n w = Math.round(w);\n h = Math.round(h);\n\n return {\n w,\n h,\n x: anchoredOrigin(start.x, start.w, w, sx),\n y: anchoredOrigin(start.y, start.h, h, sy),\n };\n};\n\n/**\n * Translate a resize key into the next box, reusing `applyResize` so the\n * keyboard clamps exactly like the pointer. Arrows move the HANDLE by the step\n * (Shift ×4) — so on a left handle ArrowLeft grows the element and ArrowRight\n * shrinks it — and Home/End jump the handle to the min/max of the allowed\n * range, leaving any axis without that bound where it is. Returns null for a\n * key the handle does not own: a key on an axis the handle does not touch, or a\n * vertical key on a width-only card.\n */\nexport const keyboardResize = (\n key: string,\n box: ResizeSize & Partial<ResizePosition>,\n policy: ResizePolicy,\n contentMin: ResizeContentMin,\n opts: { shiftKey?: boolean; axis?: ResizeAxis; anchor?: ResizeAnchor } = {}\n): ResizeBox | null => {\n const widthOnly = opts.axis === \"width\";\n const anchor = opts.anchor ?? DEFAULT_RESIZE_ANCHOR;\n const { sx, sy: anchorSy } = anchorSigns(anchor);\n const sy: AxisSign = widthOnly ? 0 : anchorSy;\n const horizontalKey = key === \"ArrowLeft\" || key === \"ArrowRight\";\n const verticalKey = key === \"ArrowUp\" || key === \"ArrowDown\";\n if ((horizontalKey && sx === 0) || (verticalKey && sy === 0)) return null;\n\n const base =\n policy.step && policy.step > 0 ? policy.step : DEFAULT_KEYBOARD_STEP;\n const step = base * (opts.shiftKey ? SHIFT_STEP_MULTIPLIER : 1);\n const start = makeStart(box, contentMin);\n const b = effectiveBounds(policy, contentMin);\n const resizeOpts: ResizeOptions = { axis: opts.axis, anchor };\n const apply = (delta: ResizeDelta): ResizeBox =>\n applyResize(start, delta, policy, resizeOpts);\n\n /**\n * Home and End are absolute jumps to a bound, not nudges, so they ignore the\n * grid: landing 4px off the minimum because that is where the nearest grid\n * line fell would mean the keyboard could never reach the bound the pointer\n * stops at. The jump is expressed as handle travel, so a near-edge handle\n * moves the opposite way to reach the same size.\n */\n const jump = (growW: number, growH: number): ResizeBox =>\n applyResize(\n start,\n { dx: sx * growW, dy: sy * growH },\n { ...policy, step: 0 },\n resizeOpts\n );\n\n switch (key) {\n case \"ArrowRight\":\n return apply({ dx: step, dy: 0 });\n case \"ArrowLeft\":\n return apply({ dx: -step, dy: 0 });\n case \"ArrowDown\":\n return apply({ dx: 0, dy: step });\n case \"ArrowUp\":\n return apply({ dx: 0, dy: -step });\n case \"Home\":\n // jump to the min corner; an axis with no floor of its own stays put\n return jump(\n sx !== 0 && hasFloor(policy.minW, contentMin.w) ? b.wMin - box.w : 0,\n sy !== 0 && hasFloor(policy.minH, contentMin.h) ? b.hMin - box.h : 0\n );\n case \"End\":\n // jump to the max corner; an unbounded axis simply doesn't move\n return jump(\n sx !== 0 && Number.isFinite(b.wMax) ? b.wMax - box.w : 0,\n sy !== 0 && Number.isFinite(b.hMax) ? b.hMax - box.h : 0\n );\n default:\n return null;\n }\n};\n\n/**\n * The handle's `aria-valuenow`: the current size as a percent (0–100) of its\n * allowed range. The corner resizes both axes, but the value must be a single\n * number, so it reports the WIDTH axis — the one axis the fixed-box and the\n * width-only cards share. Returns 0 when the range isn't finite (no max bound).\n */\nexport const measurePercent = (\n size: ResizeSize,\n policy: ResizePolicy,\n contentMin: ResizeContentMin\n): number => {\n const { wMin, wMax } = effectiveBounds(policy, contentMin);\n if (!Number.isFinite(wMax) || wMax <= wMin) return 0;\n return Math.round(clamp(((size.w - wMin) / (wMax - wMin)) * 100, 0, 100));\n};\n"],"mappings":";;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA;;AAGA;;AAiBA;AACA;AACA;AACA;;AAWO,IAAMA,cAA2C,GAAAC,OAAA,CAAAD,cAAA,GAAG,CACzD,UAAU,EACV,KAAK,EACL,WAAW,EACX,OAAO,EACP,cAAc,EACd,QAAQ,EACR,aAAa,EACb,MAAM,CACP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AAC;IACH,KAAK,KAAK;MACR;MACA,OAAO8D,IAAI,CACTxC,EAAE,KAAK,CAAC,IAAIlC,MAAM,CAAC8E,QAAQ,CAACP,CAAC,CAAC9C,IAAI,CAAC,GAAG8C,CAAC,CAAC9C,IAAI,GAAGlB,GAAG,CAACI,CAAC,GAAG,CAAC,EACxDwB,EAAE,KAAK,CAAC,IAAInC,MAAM,CAAC8E,QAAQ,CAACP,CAAC,CAAC5C,IAAI,CAAC,GAAG4C,CAAC,CAAC5C,IAAI,GAAGpB,GAAG,CAACK,CAAC,GAAG,CACzD,CAAC;IACH;MACE,OAAO,IAAI;EACf;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACO,IAAMmE,cAAc,GAAA7F,OAAA,CAAA6F,cAAA,GAAG,SAAjBA,cAAcA,CACzBC,IAAgB,EAChBhE,MAAoB,EACpBR,UAA4B,EACjB;EACX,IAAAyE,iBAAA,GAAuBlE,eAAe,CAACC,MAAM,EAAER,UAAU,CAAC;IAAlDa,IAAI,GAAA4D,iBAAA,CAAJ5D,IAAI;IAAEI,IAAI,GAAAwD,iBAAA,CAAJxD,IAAI;EAClB,IAAI,CAACzB,MAAM,CAAC8E,QAAQ,CAACrD,IAAI,CAAC,IAAIA,IAAI,IAAIJ,IAAI,EAAE,OAAO,CAAC;EACpD,OAAOvB,IAAI,CAACO,KAAK,CAACX,KAAK,CAAE,CAACsF,IAAI,CAACrE,CAAC,GAAGU,IAAI,KAAKI,IAAI,GAAGJ,IAAI,CAAC,GAAI,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC;AAC3E,CAAC","ignoreList":[]}
@@ -166,7 +166,7 @@ describe("applyResize — proportional", function () {
166
166
  expect((0, _resizePolicy.applyResize)(proportionalStart, {
167
167
  dx: +400,
168
168
  dy: 0
169
- }, policy)).toEqual({
169
+ }, policy)).toMatchObject({
170
170
  w: 620,
171
171
  h: 413
172
172
  });
@@ -176,7 +176,7 @@ describe("applyResize — proportional", function () {
176
176
  expect((0, _resizePolicy.applyResize)(proportionalStart, {
177
177
  dx: -400,
178
178
  dy: 0
179
- }, policy)).toEqual({
179
+ }, policy)).toMatchObject({
180
180
  w: 108,
181
181
  h: 72
182
182
  });
@@ -191,7 +191,7 @@ describe("applyResize — proportional", function () {
191
191
  expect((0, _resizePolicy.applyResize)(start(300, 200), {
192
192
  dx: 0,
193
193
  dy: +100
194
- }, free)).toEqual({
194
+ }, free)).toMatchObject({
195
195
  w: 450,
196
196
  h: 300
197
197
  });
@@ -213,7 +213,7 @@ describe("applyResize — proportional", function () {
213
213
  }, policy);
214
214
 
215
215
  // 337 snaps to 336, and the height follows the same scale.
216
- expect(result).toEqual({
216
+ expect(result).toMatchObject({
217
217
  w: 336,
218
218
  h: 224
219
219
  });
@@ -247,7 +247,7 @@ describe("applyResize — shift to constrain", function () {
247
247
  });
248
248
 
249
249
  // 1.5× on both axes, from a purely horizontal drag.
250
- expect(result).toEqual({
250
+ expect(result).toMatchObject({
251
251
  w: 450,
252
252
  h: 300
253
253
  });
@@ -256,7 +256,7 @@ describe("applyResize — shift to constrain", function () {
256
256
  expect((0, _resizePolicy.applyResize)(start(300, 200), {
257
257
  dx: +150,
258
258
  dy: 0
259
- }, FREE)).toEqual({
259
+ }, FREE)).toMatchObject({
260
260
  w: 450,
261
261
  h: 200
262
262
  });
@@ -271,7 +271,7 @@ describe("applyResize — shift to constrain", function () {
271
271
  };
272
272
  expect((0, _resizePolicy.applyResize)(start(300, 200), delta, policy, {
273
273
  constrain: true
274
- })).toEqual((0, _resizePolicy.applyResize)(start(300, 200), delta, policy));
274
+ })).toMatchObject((0, _resizePolicy.applyResize)(start(300, 200), delta, policy));
275
275
  });
276
276
  });
277
277
  describe("applyResize — width-only axis", function () {
@@ -296,7 +296,7 @@ describe("applyResize — width-only axis", function () {
296
296
  }, policy, {
297
297
  axis: "width"
298
298
  });
299
- expect(result).toEqual({
299
+ expect(result).toMatchObject({
300
300
  w: 216,
301
301
  h: 240
302
302
  });
@@ -312,7 +312,7 @@ describe("applyResize — width-only axis", function () {
312
312
  }, {
313
313
  axis: "width"
314
314
  });
315
- expect(result).toEqual({
315
+ expect(result).toMatchObject({
316
316
  w: 450,
317
317
  h: 300
318
318
  });
@@ -363,11 +363,11 @@ describe("keyboardResize", function () {
363
363
  })) === null || _keyboardResize7 === void 0 ? void 0 : _keyboardResize7.w).toBe(180);
364
364
  });
365
365
  it("jumps to the minimum on Home and the maximum on End", function () {
366
- expect((0, _resizePolicy.keyboardResize)("Home", size, policy, contentMin)).toEqual({
366
+ expect((0, _resizePolicy.keyboardResize)("Home", size, policy, contentMin)).toMatchObject({
367
367
  w: 180,
368
368
  h: 120
369
369
  });
370
- expect((0, _resizePolicy.keyboardResize)("End", size, policy, contentMin)).toEqual({
370
+ expect((0, _resizePolicy.keyboardResize)("End", size, policy, contentMin)).toMatchObject({
371
371
  w: 420,
372
372
  h: 400
373
373
  });
@@ -381,7 +381,7 @@ describe("keyboardResize", function () {
381
381
  expect((0, _resizePolicy.keyboardResize)("End", size, unbounded, {
382
382
  w: 180,
383
383
  h: 0
384
- })).toEqual({
384
+ })).toMatchObject({
385
385
  w: 420,
386
386
  h: 200
387
387
  });
@@ -392,7 +392,7 @@ describe("keyboardResize", function () {
392
392
  expect((0, _resizePolicy.keyboardResize)("Home", size, FREE, {
393
393
  w: 0,
394
394
  h: 0
395
- })).toEqual(size);
395
+ })).toMatchObject(size);
396
396
  });
397
397
  it("ignores the vertical keys on a width-only card", function () {
398
398
  expect((0, _resizePolicy.keyboardResize)("ArrowUp", size, policy, contentMin, {
@@ -405,13 +405,13 @@ describe("keyboardResize", function () {
405
405
  it("holds the height on a width-only Home and End", function () {
406
406
  expect((0, _resizePolicy.keyboardResize)("Home", size, policy, contentMin, {
407
407
  axis: "width"
408
- })).toEqual({
408
+ })).toMatchObject({
409
409
  w: 180,
410
410
  h: 200
411
411
  });
412
412
  expect((0, _resizePolicy.keyboardResize)("End", size, policy, contentMin, {
413
413
  axis: "width"
414
- })).toEqual({
414
+ })).toMatchObject({
415
415
  w: 420,
416
416
  h: 200
417
417
  });
@@ -471,4 +471,351 @@ describe("measurePercent", function () {
471
471
  }, FREE, contentMin)).toBe(0);
472
472
  });
473
473
  });
474
+ describe("applyResize — anchors", function () {
475
+ /* The worked examples from the task: the edge or corner OPPOSITE to the
476
+ dragged handle never moves, including when a bound stops the resize. */
477
+ var box = (0, _resizePolicy.makeStart)({
478
+ x: 100,
479
+ y: 100,
480
+ w: 300,
481
+ h: 200
482
+ }, {
483
+ w: 0,
484
+ h: 0
485
+ });
486
+ var right = function right(b) {
487
+ return b.x + b.w;
488
+ };
489
+ var bottom = function bottom(b) {
490
+ return b.y + b.h;
491
+ };
492
+ it("defaults to the bottom-right grip and leaves the position where it was", function () {
493
+ expect((0, _resizePolicy.applyResize)(box, {
494
+ dx: 40,
495
+ dy: 30
496
+ }, FREE)).toEqual({
497
+ w: 340,
498
+ h: 230,
499
+ x: 100,
500
+ y: 100
501
+ });
502
+ });
503
+ it("grows up and left from the top-left handle and moves x and y by the growth", function () {
504
+ expect((0, _resizePolicy.applyResize)(box, {
505
+ dx: -40,
506
+ dy: -30
507
+ }, FREE, {
508
+ anchor: "top-left"
509
+ })).toEqual({
510
+ w: 340,
511
+ h: 230,
512
+ x: 60,
513
+ y: 70
514
+ });
515
+ });
516
+ it.each(_resizePolicy.RESIZE_ANCHORS)("holds the edge opposite to the %s handle while it grows", function (anchor) {
517
+ var _anchorSigns = (0, _resizePolicy.anchorSigns)(anchor),
518
+ sx = _anchorSigns.sx,
519
+ sy = _anchorSigns.sy;
520
+ var result = (0, _resizePolicy.applyResize)(box, {
521
+ dx: 50 * sx,
522
+ dy: 40 * sy
523
+ }, FREE, {
524
+ anchor
525
+ });
526
+ if (sx < 0) expect(right(result)).toBe(right(box));
527
+ if (sx > 0) expect(result.x).toBe(box.x);
528
+ if (sy < 0) expect(bottom(result)).toBe(bottom(box));
529
+ if (sy > 0) expect(result.y).toBe(box.y);
530
+ expect(result.w).toBe(sx === 0 ? 300 : 350);
531
+ expect(result.h).toBe(sy === 0 ? 200 : 240);
532
+ });
533
+ it("keeps the anchored edge in place when a bound stops the resize", function () {
534
+ var result = (0, _resizePolicy.applyResize)(box, {
535
+ dx: 150,
536
+ dy: 0
537
+ }, {
538
+ minW: 200,
539
+ proportional: false
540
+ }, {
541
+ anchor: "top-left"
542
+ });
543
+
544
+ // width wants 150, clamped up to 200; the right edge stays at 400, not 350
545
+ expect(result).toEqual({
546
+ w: 200,
547
+ h: 200,
548
+ x: 200,
549
+ y: 100
550
+ });
551
+ });
552
+ it("follows the ratio and the position when a proportional element hits its ceiling", function () {
553
+ var circle = (0, _resizePolicy.makeStart)({
554
+ x: 100,
555
+ y: 100,
556
+ w: 200,
557
+ h: 200
558
+ }, {
559
+ w: 0,
560
+ h: 0
561
+ });
562
+ var result = (0, _resizePolicy.applyResize)(circle, {
563
+ dx: -400,
564
+ dy: 0
565
+ }, {
566
+ maxW: 300,
567
+ maxH: 300,
568
+ proportional: true
569
+ }, {
570
+ anchor: "top-left"
571
+ });
572
+
573
+ // scale wants 3.0; scaleMax = 1.5 → 300×300 with the bottom-right corner held at (300, 300)
574
+ expect(result).toEqual({
575
+ w: 300,
576
+ h: 300,
577
+ x: 0,
578
+ y: 0
579
+ });
580
+ });
581
+ it("touches only the width from a right or left edge handle", function () {
582
+ expect((0, _resizePolicy.applyResize)(box, {
583
+ dx: 40,
584
+ dy: 999
585
+ }, FREE, {
586
+ anchor: "right"
587
+ })).toEqual({
588
+ w: 340,
589
+ h: 200,
590
+ x: 100,
591
+ y: 100
592
+ });
593
+ expect((0, _resizePolicy.applyResize)(box, {
594
+ dx: -40,
595
+ dy: 999
596
+ }, FREE, {
597
+ anchor: "left"
598
+ })).toEqual({
599
+ w: 340,
600
+ h: 200,
601
+ x: 60,
602
+ y: 100
603
+ });
604
+ });
605
+ it("touches only the height from a top or bottom edge handle", function () {
606
+ expect((0, _resizePolicy.applyResize)(box, {
607
+ dx: 999,
608
+ dy: 30
609
+ }, FREE, {
610
+ anchor: "bottom"
611
+ })).toEqual({
612
+ w: 300,
613
+ h: 230,
614
+ x: 100,
615
+ y: 100
616
+ });
617
+ expect((0, _resizePolicy.applyResize)(box, {
618
+ dx: 999,
619
+ dy: -30
620
+ }, FREE, {
621
+ anchor: "top"
622
+ })).toEqual({
623
+ w: 300,
624
+ h: 230,
625
+ x: 100,
626
+ y: 70
627
+ });
628
+ });
629
+ it("leaves an untouched axis alone even when it sits off the grid or outside the bounds", function () {
630
+ var odd = (0, _resizePolicy.makeStart)({
631
+ x: 100,
632
+ y: 100,
633
+ w: 303,
634
+ h: 10
635
+ }, {
636
+ w: 0,
637
+ h: 0
638
+ });
639
+ var result = (0, _resizePolicy.applyResize)(odd, {
640
+ dx: 0,
641
+ dy: 40
642
+ }, {
643
+ minH: 20,
644
+ proportional: false,
645
+ step: 8
646
+ }, {
647
+ anchor: "bottom"
648
+ });
649
+ expect(result.w).toBe(303);
650
+ // the bottom edge 110 + 40 = 150 snaps to 152
651
+ expect(result.h).toBe(52);
652
+ });
653
+ it("snaps the moving edge to the grid and leaves the anchored edge off it", function () {
654
+ var offGrid = (0, _resizePolicy.makeStart)({
655
+ x: 103,
656
+ y: 101,
657
+ w: 300,
658
+ h: 200
659
+ }, {
660
+ w: 0,
661
+ h: 0
662
+ });
663
+ var step = {
664
+ proportional: false,
665
+ step: 8
666
+ };
667
+
668
+ // right handle: the right edge 403 + 37 = 440 is on the grid already; 403 + 35 = 438 → 440
669
+ expect((0, _resizePolicy.applyResize)(offGrid, {
670
+ dx: 35,
671
+ dy: 0
672
+ }, step, {
673
+ anchor: "right"
674
+ })).toEqual({
675
+ w: 337,
676
+ h: 200,
677
+ x: 103,
678
+ y: 101
679
+ });
680
+ // left handle: the left edge 103 − 35 = 68 → 72; the right edge stays at 403
681
+ expect((0, _resizePolicy.applyResize)(offGrid, {
682
+ dx: -35,
683
+ dy: 0
684
+ }, step, {
685
+ anchor: "left"
686
+ })).toEqual({
687
+ w: 331,
688
+ h: 200,
689
+ x: 72,
690
+ y: 101
691
+ });
692
+ });
693
+ it("snaps a proportional resize through the moving edge of the driving axis", function () {
694
+ var offGrid = (0, _resizePolicy.makeStart)({
695
+ x: 103,
696
+ y: 100,
697
+ w: 300,
698
+ h: 200
699
+ }, {
700
+ w: 0,
701
+ h: 0
702
+ });
703
+ var result = (0, _resizePolicy.applyResize)(offGrid, {
704
+ dx: -35,
705
+ dy: 0
706
+ }, {
707
+ proportional: true,
708
+ step: 8
709
+ }, {
710
+ anchor: "left"
711
+ });
712
+
713
+ // the left edge lands on 72, so the width is 331 and the height follows the ratio
714
+ expect(result.x).toBe(72);
715
+ expect(result.w).toBe(331);
716
+ expect(result.h).toBe(Math.round(200 * 331 / 300));
717
+ expect(right(result)).toBe(403);
718
+ });
719
+ it("holds the ratio from an edge handle by driving the scale off that handle's axis", function () {
720
+ var result = (0, _resizePolicy.applyResize)(box, {
721
+ dx: 999,
722
+ dy: 100
723
+ }, {
724
+ proportional: true
725
+ }, {
726
+ anchor: "bottom"
727
+ });
728
+
729
+ // +100 on a 200-tall element is 1.5×; the horizontal travel is ignored
730
+ expect(result).toEqual({
731
+ w: 450,
732
+ h: 300,
733
+ x: 100,
734
+ y: 100
735
+ });
736
+ });
737
+ });
738
+ describe("keyboardResize — anchors", function () {
739
+ var policy = {
740
+ minW: 180,
741
+ maxW: 420,
742
+ minH: 120,
743
+ maxH: 400,
744
+ proportional: false
745
+ };
746
+ var none = {
747
+ w: 0,
748
+ h: 0
749
+ };
750
+ var box = {
751
+ w: 300,
752
+ h: 200,
753
+ x: 100,
754
+ y: 100
755
+ };
756
+ it("moves the handle: ArrowLeft grows a left handle and shrinks a right one", function () {
757
+ expect((0, _resizePolicy.keyboardResize)("ArrowLeft", box, policy, none, {
758
+ anchor: "left"
759
+ })).toEqual({
760
+ w: 308,
761
+ h: 200,
762
+ x: 92,
763
+ y: 100
764
+ });
765
+ expect((0, _resizePolicy.keyboardResize)("ArrowLeft", box, policy, none, {
766
+ anchor: "right"
767
+ })).toEqual({
768
+ w: 292,
769
+ h: 200,
770
+ x: 100,
771
+ y: 100
772
+ });
773
+ });
774
+ it("moves the position with an arrow press on the top-left handle", function () {
775
+ expect((0, _resizePolicy.keyboardResize)("ArrowUp", box, policy, none, {
776
+ anchor: "top-left"
777
+ })).toEqual({
778
+ w: 300,
779
+ h: 208,
780
+ x: 100,
781
+ y: 92
782
+ });
783
+ });
784
+ it("returns null for a key on an axis the handle does not touch", function () {
785
+ expect((0, _resizePolicy.keyboardResize)("ArrowUp", box, policy, none, {
786
+ anchor: "right"
787
+ })).toBeNull();
788
+ expect((0, _resizePolicy.keyboardResize)("ArrowLeft", box, policy, none, {
789
+ anchor: "bottom"
790
+ })).toBeNull();
791
+ });
792
+ it("jumps a near-edge handle to the bounds while holding the far edge", function () {
793
+ expect((0, _resizePolicy.keyboardResize)("Home", box, policy, none, {
794
+ anchor: "top-left"
795
+ })).toEqual({
796
+ w: 180,
797
+ h: 120,
798
+ x: 220,
799
+ y: 180
800
+ });
801
+ expect((0, _resizePolicy.keyboardResize)("End", box, policy, none, {
802
+ anchor: "top-left"
803
+ })).toEqual({
804
+ w: 420,
805
+ h: 400,
806
+ x: -20,
807
+ y: -100
808
+ });
809
+ });
810
+ it("jumps only the handle's own axis on an edge handle", function () {
811
+ expect((0, _resizePolicy.keyboardResize)("End", box, policy, none, {
812
+ anchor: "left"
813
+ })).toEqual({
814
+ w: 420,
815
+ h: 200,
816
+ x: -20,
817
+ y: 100
818
+ });
819
+ });
820
+ });
474
821
  //# sourceMappingURL=resizePolicy.test.js.map