@activecollab/components 2.0.468 → 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.
- package/dist/cjs/components/StackedCard/StackedCard.js.map +1 -1
- package/dist/cjs/components/StackedCard/Styles.js.map +1 -1
- package/dist/cjs/components/StackedCard/resizePolicy.js +141 -60
- package/dist/cjs/components/StackedCard/resizePolicy.js.map +1 -1
- package/dist/cjs/components/StackedCard/resizePolicy.test.js +362 -15
- package/dist/cjs/components/StackedCard/resizePolicy.test.js.map +1 -1
- package/dist/cjs/components/StackedCard/useStackedCardResize.js +35 -14
- package/dist/cjs/components/StackedCard/useStackedCardResize.js.map +1 -1
- package/dist/cjs/presentation/shared/SourceCodeSection.js +88 -82
- package/dist/cjs/presentation/shared/SourceCodeSection.js.map +1 -1
- package/dist/esm/components/StackedCard/StackedCard.d.ts +5 -5
- package/dist/esm/components/StackedCard/StackedCard.d.ts.map +1 -1
- package/dist/esm/components/StackedCard/StackedCard.js.map +1 -1
- package/dist/esm/components/StackedCard/Styles.d.ts +2 -2
- package/dist/esm/components/StackedCard/Styles.d.ts.map +1 -1
- package/dist/esm/components/StackedCard/Styles.js.map +1 -1
- package/dist/esm/components/StackedCard/resizePolicy.d.ts +85 -40
- package/dist/esm/components/StackedCard/resizePolicy.d.ts.map +1 -1
- package/dist/esm/components/StackedCard/resizePolicy.js +139 -60
- package/dist/esm/components/StackedCard/resizePolicy.js.map +1 -1
- package/dist/esm/components/StackedCard/resizePolicy.test.js +359 -16
- package/dist/esm/components/StackedCard/resizePolicy.test.js.map +1 -1
- package/dist/esm/components/StackedCard/useStackedCardResize.d.ts +25 -13
- package/dist/esm/components/StackedCard/useStackedCardResize.d.ts.map +1 -1
- package/dist/esm/components/StackedCard/useStackedCardResize.js +35 -14
- package/dist/esm/components/StackedCard/useStackedCardResize.js.map +1 -1
- package/dist/esm/presentation/shared/SourceCodeSection.d.ts.map +1 -1
- package/dist/esm/presentation/shared/SourceCodeSection.js +88 -82
- package/dist/esm/presentation/shared/SourceCodeSection.js.map +1 -1
- package/dist/index.js +179 -74
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -31309,15 +31309,17 @@
|
|
|
31309
31309
|
};
|
|
31310
31310
|
|
|
31311
31311
|
/**
|
|
31312
|
-
*
|
|
31313
|
-
*
|
|
31314
|
-
* The
|
|
31315
|
-
* module is that policy, packaged as pure functions so the SAME
|
|
31316
|
-
* serves the pointer drag and the keyboard resize
|
|
31317
|
-
*
|
|
31318
|
-
*
|
|
31319
|
-
*
|
|
31320
|
-
*
|
|
31312
|
+
* Resize policy — pure math, shared by every resizable element.
|
|
31313
|
+
*
|
|
31314
|
+
* The element reports intent; the HOST applies a resize policy (StackedCard
|
|
31315
|
+
* spec §7). This module is that policy, packaged as pure functions so the SAME
|
|
31316
|
+
* code path serves the pointer drag and the keyboard resize, a card's single
|
|
31317
|
+
* bottom-right grip and a shape's eight handles. Nothing here touches the DOM,
|
|
31318
|
+
* React or the element's content: it takes a start box, a delta, a policy and
|
|
31319
|
+
* the handle being dragged, and returns a clamped box — size AND position.
|
|
31320
|
+
* `useStackedCardResize` wires events to it; an element's intrinsic content
|
|
31321
|
+
* minimum is measured by the host and passed in as `contentMin`, so this module
|
|
31322
|
+
* knows nothing about heroes or footers.
|
|
31321
31323
|
*
|
|
31322
31324
|
* The policy has four parts:
|
|
31323
31325
|
* - bounds — optional min/max per axis; unset means unbounded.
|
|
@@ -31326,12 +31328,34 @@
|
|
|
31326
31328
|
* distorts at a bound.
|
|
31327
31329
|
* - step — optional grid snap; proportion wins over the grid.
|
|
31328
31330
|
* - content min — the effective min is max(policyMin, contentMin) per axis,
|
|
31329
|
-
* so
|
|
31331
|
+
* so an element can never be crushed below what its content
|
|
31332
|
+
* needs.
|
|
31333
|
+
*
|
|
31334
|
+
* The anchor is the handle being dragged. The edge or corner OPPOSITE to it
|
|
31335
|
+
* never moves — not while the pointer travels, and not when a bound stops the
|
|
31336
|
+
* resize — which is what makes a resize feel like a resize rather than a nudge.
|
|
31337
|
+
* A `left` handle moves the position by exactly the amount the width grew; a
|
|
31338
|
+
* `right` handle leaves it alone. An edge handle touches one axis only.
|
|
31330
31339
|
*/
|
|
31331
31340
|
|
|
31332
|
-
/**
|
|
31341
|
+
/** A resized element: its size and where its top-left corner now sits. */
|
|
31342
|
+
|
|
31343
|
+
/** The element's intrinsic minimum, measured from its real content. */
|
|
31333
31344
|
|
|
31334
|
-
/**
|
|
31345
|
+
/**
|
|
31346
|
+
* The handle being dragged, named after the edge or corner it sits on. The
|
|
31347
|
+
* opposite edge or corner is held in place.
|
|
31348
|
+
*/
|
|
31349
|
+
|
|
31350
|
+
var RESIZE_ANCHORS = ["top-left", "top", "top-right", "right", "bottom-right", "bottom", "bottom-left", "left"];
|
|
31351
|
+
|
|
31352
|
+
/** A card's single grip: the top-left corner stays put. */
|
|
31353
|
+
var DEFAULT_RESIZE_ANCHOR = "bottom-right";
|
|
31354
|
+
|
|
31355
|
+
/**
|
|
31356
|
+
* The box captured at the start of a gesture (pointer down or a key press).
|
|
31357
|
+
* A host that only tracks a size leaves the position at the origin.
|
|
31358
|
+
*/
|
|
31335
31359
|
|
|
31336
31360
|
/**
|
|
31337
31361
|
* `width` locks the vertical axis: an auto-height card takes a width and lets
|
|
@@ -31357,10 +31381,13 @@
|
|
|
31357
31381
|
var snap = function snap(v, step) {
|
|
31358
31382
|
return step && step > 0 ? Math.round(v / step) * step : v;
|
|
31359
31383
|
};
|
|
31360
|
-
var makeStart = function makeStart(
|
|
31384
|
+
var makeStart = function makeStart(box, contentMin) {
|
|
31385
|
+
var _box$x, _box$y;
|
|
31361
31386
|
return {
|
|
31362
|
-
w:
|
|
31363
|
-
h:
|
|
31387
|
+
w: box.w,
|
|
31388
|
+
h: box.h,
|
|
31389
|
+
x: (_box$x = box.x) !== null && _box$x !== void 0 ? _box$x : 0,
|
|
31390
|
+
y: (_box$y = box.y) !== null && _box$y !== void 0 ? _box$y : 0,
|
|
31364
31391
|
contentMin
|
|
31365
31392
|
};
|
|
31366
31393
|
};
|
|
@@ -31388,18 +31415,48 @@
|
|
|
31388
31415
|
var hasFloor = function hasFloor(policyMin, contentMin) {
|
|
31389
31416
|
return policyMin !== undefined || contentMin > 0;
|
|
31390
31417
|
};
|
|
31418
|
+
/**
|
|
31419
|
+
* Which way each axis grows for a handle: +1 when the handle is on the far
|
|
31420
|
+
* edge (right/bottom), −1 when it is on the near edge (left/top), 0 when the
|
|
31421
|
+
* handle does not touch that axis at all.
|
|
31422
|
+
*/
|
|
31423
|
+
var anchorSigns = function anchorSigns(anchor) {
|
|
31424
|
+
return {
|
|
31425
|
+
sx: anchor.includes("left") ? -1 : anchor.includes("right") ? 1 : 0,
|
|
31426
|
+
sy: anchor.includes("top") ? -1 : anchor.includes("bottom") ? 1 : 0
|
|
31427
|
+
};
|
|
31428
|
+
};
|
|
31429
|
+
|
|
31430
|
+
/**
|
|
31431
|
+
* Snap the MOVING edge of one axis to the grid and return the length that
|
|
31432
|
+
* leaves the anchored edge exactly where it was. A far-edge handle snaps
|
|
31433
|
+
* `origin + length`; a near-edge handle snaps `origin + startLength − length`.
|
|
31434
|
+
* With no step this is the identity.
|
|
31435
|
+
*/
|
|
31436
|
+
var snapMovingEdge = function snapMovingEdge(origin, startLength, length, sign, step) {
|
|
31437
|
+
if (!step || sign === 0) return length;
|
|
31438
|
+
return sign > 0 ? snap(origin + length, step) - origin : origin + startLength - snap(origin + startLength - length, step);
|
|
31439
|
+
};
|
|
31440
|
+
|
|
31441
|
+
/** The position that keeps the anchored edge of one axis in place. */
|
|
31442
|
+
var anchoredOrigin = function anchoredOrigin(origin, startLength, length, sign) {
|
|
31443
|
+
return sign < 0 ? origin + startLength - length : origin;
|
|
31444
|
+
};
|
|
31391
31445
|
|
|
31392
31446
|
/**
|
|
31393
|
-
* Apply a delta to the start
|
|
31394
|
-
* inputs.
|
|
31447
|
+
* Apply a delta to the start box under the policy — the single path for both
|
|
31448
|
+
* inputs and for every handle.
|
|
31395
31449
|
*
|
|
31396
31450
|
* `constrain` is the transient Shift-to-constrain lock: a free-form policy
|
|
31397
31451
|
* behaves proportionally for that one gesture; a proportional policy is already
|
|
31398
31452
|
* locked and ignores it. `axis: "width"` drops the gesture's vertical component;
|
|
31399
31453
|
* the height then holds still in free-form mode, and still follows the ratio in
|
|
31400
|
-
* proportional mode (that is what proportional means).
|
|
31454
|
+
* proportional mode (that is what proportional means). `anchor` is the handle
|
|
31455
|
+
* being dragged: the opposite edge or corner is held, so the returned position
|
|
31456
|
+
* moves only when a near-edge handle (left/top) grew or shrank the box.
|
|
31401
31457
|
*/
|
|
31402
31458
|
var applyResize = function applyResize(start, delta, policy) {
|
|
31459
|
+
var _opts$anchor;
|
|
31403
31460
|
var opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
31404
31461
|
var _effectiveBounds = effectiveBounds(policy, start.contentMin),
|
|
31405
31462
|
wMin = _effectiveBounds.wMin,
|
|
@@ -31407,8 +31464,12 @@
|
|
|
31407
31464
|
wMax = _effectiveBounds.wMax,
|
|
31408
31465
|
hMax = _effectiveBounds.hMax;
|
|
31409
31466
|
var widthOnly = opts.axis === "width";
|
|
31410
|
-
var
|
|
31411
|
-
|
|
31467
|
+
var _anchorSigns = anchorSigns((_opts$anchor = opts.anchor) !== null && _opts$anchor !== void 0 ? _opts$anchor : DEFAULT_RESIZE_ANCHOR),
|
|
31468
|
+
sx = _anchorSigns.sx,
|
|
31469
|
+
anchorSy = _anchorSigns.sy;
|
|
31470
|
+
var sy = widthOnly ? 0 : anchorSy;
|
|
31471
|
+
var dx = sx * delta.dx;
|
|
31472
|
+
var dy = sy * delta.dy;
|
|
31412
31473
|
|
|
31413
31474
|
// A ratio needs two non-zero sides to be a ratio at all; a width-only card
|
|
31414
31475
|
// parks a placeholder height, so fall back to free-form rather than dividing
|
|
@@ -31418,70 +31479,96 @@
|
|
|
31418
31479
|
var h;
|
|
31419
31480
|
if (proportional) {
|
|
31420
31481
|
// one scale drives both axes; the corner's dominant direction wins, so a
|
|
31421
|
-
// vertical drag is as effective as a horizontal one
|
|
31422
|
-
|
|
31423
|
-
var
|
|
31424
|
-
var
|
|
31425
|
-
|
|
31426
|
-
|
|
31427
|
-
|
|
31428
|
-
//
|
|
31482
|
+
// vertical drag is as effective as a horizontal one. An edge handle has
|
|
31483
|
+
// only its own axis to drive with.
|
|
31484
|
+
var sW = sx === 0 ? 1 : (start.w + dx) / start.w;
|
|
31485
|
+
var sH = sy === 0 ? 1 : (start.h + dy) / start.h;
|
|
31486
|
+
var drivenByWidth = sx !== 0 && (sy === 0 || Math.abs(sW - 1) >= Math.abs(sH - 1));
|
|
31487
|
+
var scale = drivenByWidth ? sW : sH;
|
|
31488
|
+
|
|
31489
|
+
// step: proportion wins over the grid. Snap through the SCALE, driven off
|
|
31490
|
+
// the moving edge of the driving axis, so both axes move together and the
|
|
31491
|
+
// ratio survives; the grid yields whenever honouring it would cost the
|
|
31492
|
+
// ratio.
|
|
31429
31493
|
if (policy.step) {
|
|
31430
|
-
scale =
|
|
31494
|
+
scale = drivenByWidth ? snapMovingEdge(start.x, start.w, start.w * scale, sx, policy.step) / start.w : snapMovingEdge(start.y, start.h, start.h * scale, sy, policy.step) / start.h;
|
|
31431
31495
|
}
|
|
31432
31496
|
|
|
31433
31497
|
// Then clamp the scale so both axes stay in bounds (the binding constraint):
|
|
31434
31498
|
// the ratio can never break at a bound — whichever edge is limiting stops
|
|
31435
|
-
// both. The clamp comes last on purpose: a bound is a hard stop, so the
|
|
31436
|
-
// sits exactly on it rather than at the nearest grid line inside it.
|
|
31499
|
+
// both. The clamp comes last on purpose: a bound is a hard stop, so the
|
|
31500
|
+
// element sits exactly on it rather than at the nearest grid line inside it.
|
|
31437
31501
|
var scaleMin = Math.max(wMin / start.w, hMin / start.h);
|
|
31438
31502
|
var scaleMax = Math.min(wMax / start.w, hMax / start.h);
|
|
31439
31503
|
scale = clamp(scale, scaleMin, Math.max(scaleMin, scaleMax));
|
|
31440
31504
|
w = start.w * scale;
|
|
31441
31505
|
h = start.h * scale;
|
|
31442
31506
|
} else {
|
|
31443
|
-
|
|
31444
|
-
|
|
31507
|
+
// An axis the handle does not touch holds its start value exactly — it is
|
|
31508
|
+
// neither snapped nor clamped, because nothing about it changed.
|
|
31509
|
+
w = sx === 0 ? start.w : clamp(snapMovingEdge(start.x, start.w, start.w + dx, sx, policy.step), wMin, wMax);
|
|
31510
|
+
h = sy === 0 ? start.h : clamp(snapMovingEdge(start.y, start.h, start.h + dy, sy, policy.step), hMin, hMax);
|
|
31445
31511
|
}
|
|
31512
|
+
|
|
31513
|
+
// Round the size first and derive the position from the rounded size, so
|
|
31514
|
+
// the anchored edge lands on exactly the coordinate it started at.
|
|
31515
|
+
w = Math.round(w);
|
|
31516
|
+
h = Math.round(h);
|
|
31446
31517
|
return {
|
|
31447
|
-
w
|
|
31448
|
-
h
|
|
31518
|
+
w,
|
|
31519
|
+
h,
|
|
31520
|
+
x: anchoredOrigin(start.x, start.w, w, sx),
|
|
31521
|
+
y: anchoredOrigin(start.y, start.h, h, sy)
|
|
31449
31522
|
};
|
|
31450
31523
|
};
|
|
31451
31524
|
|
|
31452
31525
|
/**
|
|
31453
|
-
* Translate a resize key into the next
|
|
31454
|
-
* keyboard clamps exactly like the pointer. Arrows
|
|
31455
|
-
*
|
|
31456
|
-
*
|
|
31457
|
-
*
|
|
31526
|
+
* Translate a resize key into the next box, reusing `applyResize` so the
|
|
31527
|
+
* keyboard clamps exactly like the pointer. Arrows move the HANDLE by the step
|
|
31528
|
+
* (Shift ×4) — so on a left handle ArrowLeft grows the element and ArrowRight
|
|
31529
|
+
* shrinks it — and Home/End jump the handle to the min/max of the allowed
|
|
31530
|
+
* range, leaving any axis without that bound where it is. Returns null for a
|
|
31531
|
+
* key the handle does not own: a key on an axis the handle does not touch, or a
|
|
31532
|
+
* vertical key on a width-only card.
|
|
31458
31533
|
*/
|
|
31459
|
-
var keyboardResize = function keyboardResize(key,
|
|
31534
|
+
var keyboardResize = function keyboardResize(key, box, policy, contentMin) {
|
|
31535
|
+
var _opts$anchor2;
|
|
31460
31536
|
var opts = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
31461
31537
|
var widthOnly = opts.axis === "width";
|
|
31462
|
-
|
|
31538
|
+
var anchor = (_opts$anchor2 = opts.anchor) !== null && _opts$anchor2 !== void 0 ? _opts$anchor2 : DEFAULT_RESIZE_ANCHOR;
|
|
31539
|
+
var _anchorSigns2 = anchorSigns(anchor),
|
|
31540
|
+
sx = _anchorSigns2.sx,
|
|
31541
|
+
anchorSy = _anchorSigns2.sy;
|
|
31542
|
+
var sy = widthOnly ? 0 : anchorSy;
|
|
31543
|
+
var horizontalKey = key === "ArrowLeft" || key === "ArrowRight";
|
|
31544
|
+
var verticalKey = key === "ArrowUp" || key === "ArrowDown";
|
|
31545
|
+
if (horizontalKey && sx === 0 || verticalKey && sy === 0) return null;
|
|
31463
31546
|
var base = policy.step && policy.step > 0 ? policy.step : DEFAULT_KEYBOARD_STEP;
|
|
31464
31547
|
var step = base * (opts.shiftKey ? SHIFT_STEP_MULTIPLIER : 1);
|
|
31465
|
-
var start = makeStart(
|
|
31548
|
+
var start = makeStart(box, contentMin);
|
|
31466
31549
|
var b = effectiveBounds(policy, contentMin);
|
|
31550
|
+
var resizeOpts = {
|
|
31551
|
+
axis: opts.axis,
|
|
31552
|
+
anchor
|
|
31553
|
+
};
|
|
31467
31554
|
var apply = function apply(delta) {
|
|
31468
|
-
return applyResize(start, delta, policy,
|
|
31469
|
-
axis: opts.axis
|
|
31470
|
-
});
|
|
31555
|
+
return applyResize(start, delta, policy, resizeOpts);
|
|
31471
31556
|
};
|
|
31472
31557
|
|
|
31473
31558
|
/**
|
|
31474
31559
|
* Home and End are absolute jumps to a bound, not nudges, so they ignore the
|
|
31475
31560
|
* grid: landing 4px off the minimum because that is where the nearest grid
|
|
31476
31561
|
* line fell would mean the keyboard could never reach the bound the pointer
|
|
31477
|
-
* stops at.
|
|
31562
|
+
* stops at. The jump is expressed as handle travel, so a near-edge handle
|
|
31563
|
+
* moves the opposite way to reach the same size.
|
|
31478
31564
|
*/
|
|
31479
|
-
var jump = function jump(
|
|
31480
|
-
return applyResize(start,
|
|
31565
|
+
var jump = function jump(growW, growH) {
|
|
31566
|
+
return applyResize(start, {
|
|
31567
|
+
dx: sx * growW,
|
|
31568
|
+
dy: sy * growH
|
|
31569
|
+
}, _objectSpread2(_objectSpread2({}, policy), {}, {
|
|
31481
31570
|
step: 0
|
|
31482
|
-
}),
|
|
31483
|
-
axis: opts.axis
|
|
31484
|
-
});
|
|
31571
|
+
}), resizeOpts);
|
|
31485
31572
|
};
|
|
31486
31573
|
switch (key) {
|
|
31487
31574
|
case "ArrowRight":
|
|
@@ -31506,16 +31593,10 @@
|
|
|
31506
31593
|
});
|
|
31507
31594
|
case "Home":
|
|
31508
31595
|
// jump to the min corner; an axis with no floor of its own stays put
|
|
31509
|
-
return jump(
|
|
31510
|
-
dx: hasFloor(policy.minW, contentMin.w) ? b.wMin - size.w : 0,
|
|
31511
|
-
dy: !widthOnly && hasFloor(policy.minH, contentMin.h) ? b.hMin - size.h : 0
|
|
31512
|
-
});
|
|
31596
|
+
return jump(sx !== 0 && hasFloor(policy.minW, contentMin.w) ? b.wMin - box.w : 0, sy !== 0 && hasFloor(policy.minH, contentMin.h) ? b.hMin - box.h : 0);
|
|
31513
31597
|
case "End":
|
|
31514
31598
|
// jump to the max corner; an unbounded axis simply doesn't move
|
|
31515
|
-
return jump(
|
|
31516
|
-
dx: Number.isFinite(b.wMax) ? b.wMax - size.w : 0,
|
|
31517
|
-
dy: !widthOnly && Number.isFinite(b.hMax) ? b.hMax - size.h : 0
|
|
31518
|
-
});
|
|
31599
|
+
return jump(sx !== 0 && Number.isFinite(b.wMax) ? b.wMax - box.w : 0, sy !== 0 && Number.isFinite(b.hMax) ? b.hMax - box.h : 0);
|
|
31519
31600
|
default:
|
|
31520
31601
|
return null;
|
|
31521
31602
|
}
|
|
@@ -32018,51 +32099,70 @@
|
|
|
32018
32099
|
* gesture. It returns the props to spread on the grip, including the live
|
|
32019
32100
|
* separator ARIA.
|
|
32020
32101
|
*
|
|
32102
|
+
* One hook instance drives one handle. A card has one, in the bottom-right
|
|
32103
|
+
* corner; a shape mounts one per handle and passes each its `anchor`, and the
|
|
32104
|
+
* previews then carry the position as well as the size, so a top-left handle
|
|
32105
|
+
* moves the element while it grows.
|
|
32106
|
+
*
|
|
32021
32107
|
* Preview versus commit (spec §7e): the continuous stream is live feedback
|
|
32022
32108
|
* only. A host creates an undo entry on the COMMIT, never on a preview — and a
|
|
32023
|
-
* gesture that never changed the
|
|
32109
|
+
* gesture that never changed the box commits nothing at all, so a bare click
|
|
32024
32110
|
* on the grip is not a change.
|
|
32025
32111
|
*
|
|
32026
|
-
* The hook never touches the
|
|
32112
|
+
* The hook never touches the element's content: the intrinsic minimum is read
|
|
32027
32113
|
* through `contentMin`, which may be a getter so a card that measures its own
|
|
32028
32114
|
* footer can answer at the moment it is asked.
|
|
32029
32115
|
*/
|
|
32030
32116
|
|
|
32031
32117
|
/** The props to spread on the grip — `StackedCard`'s `resizeHandleProps`. */
|
|
32032
32118
|
|
|
32033
|
-
var
|
|
32034
|
-
return a.w === b.w && a.h === b.h;
|
|
32119
|
+
var sameBox = function sameBox(a, b) {
|
|
32120
|
+
return a.w === b.w && a.h === b.h && a.x === b.x && a.y === b.y;
|
|
32121
|
+
};
|
|
32122
|
+
var toBox = function toBox(size, position) {
|
|
32123
|
+
var _position$x, _position$y;
|
|
32124
|
+
return {
|
|
32125
|
+
w: size.w,
|
|
32126
|
+
h: size.h,
|
|
32127
|
+
x: (_position$x = position === null || position === void 0 ? void 0 : position.x) !== null && _position$x !== void 0 ? _position$x : 0,
|
|
32128
|
+
y: (_position$y = position === null || position === void 0 ? void 0 : position.y) !== null && _position$y !== void 0 ? _position$y : 0
|
|
32129
|
+
};
|
|
32035
32130
|
};
|
|
32036
32131
|
var useStackedCardResize = function useStackedCardResize(_ref) {
|
|
32037
32132
|
var size = _ref.size,
|
|
32133
|
+
position = _ref.position,
|
|
32038
32134
|
policy = _ref.policy,
|
|
32039
32135
|
cardId = _ref.cardId,
|
|
32040
32136
|
contentMin = _ref.contentMin,
|
|
32041
32137
|
_ref$axis = _ref.axis,
|
|
32042
32138
|
axis = _ref$axis === void 0 ? "both" : _ref$axis,
|
|
32139
|
+
_ref$anchor = _ref.anchor,
|
|
32140
|
+
anchor = _ref$anchor === void 0 ? DEFAULT_RESIZE_ANCHOR : _ref$anchor,
|
|
32043
32141
|
_ref$scale = _ref.scale,
|
|
32044
32142
|
scale = _ref$scale === void 0 ? 1 : _ref$scale,
|
|
32045
32143
|
_ref$label = _ref.label,
|
|
32046
32144
|
label = _ref$label === void 0 ? "Resize card" : _ref$label,
|
|
32047
32145
|
onResize = _ref.onResize,
|
|
32048
32146
|
onResizeCommit = _ref.onResizeCommit;
|
|
32049
|
-
// The pointer gesture's anchor: the
|
|
32147
|
+
// The pointer gesture's anchor: the box + content-min captured on pointer
|
|
32050
32148
|
// down, plus the pointer origin the delta is measured from.
|
|
32051
32149
|
var pointerStart = React.useRef(null);
|
|
32052
|
-
// Mirrors the latest emitted
|
|
32150
|
+
// Mirrors the latest emitted box so pointer-up / key-up can commit exactly
|
|
32053
32151
|
// what preview last showed, without a stale closure.
|
|
32054
|
-
var latest = React.useRef(size);
|
|
32055
|
-
latest.current = size;
|
|
32056
|
-
// Whether this gesture actually moved the
|
|
32057
|
-
// axis with no floor, leaves it false and commits nothing.
|
|
32152
|
+
var latest = React.useRef(toBox(size, position));
|
|
32153
|
+
latest.current = toBox(size, position);
|
|
32154
|
+
// Whether this gesture actually moved the element. A bare click, or a Home on
|
|
32155
|
+
// an axis with no floor, leaves it false and commits nothing.
|
|
32058
32156
|
var dirty = React.useRef(false);
|
|
32059
32157
|
|
|
32060
32158
|
// Read through refs so the handlers below can stay stable across renders
|
|
32061
|
-
// while still seeing the current policy, axis and zoom.
|
|
32159
|
+
// while still seeing the current policy, axis, anchor and zoom.
|
|
32062
32160
|
var policyRef = React.useRef(policy);
|
|
32063
32161
|
policyRef.current = policy;
|
|
32064
32162
|
var axisRef = React.useRef(axis);
|
|
32065
32163
|
axisRef.current = axis;
|
|
32164
|
+
var anchorRef = React.useRef(anchor);
|
|
32165
|
+
anchorRef.current = anchor;
|
|
32066
32166
|
var scaleRef = React.useRef(scale);
|
|
32067
32167
|
scaleRef.current = scale;
|
|
32068
32168
|
var contentMinRef = React.useRef(contentMin);
|
|
@@ -32073,7 +32173,7 @@
|
|
|
32073
32173
|
}, []);
|
|
32074
32174
|
var emitPreview = React.useCallback(function (next, source) {
|
|
32075
32175
|
// Nothing changed — not a preview, and not something to commit later.
|
|
32076
|
-
if (
|
|
32176
|
+
if (sameBox(next, latest.current)) return;
|
|
32077
32177
|
latest.current = next;
|
|
32078
32178
|
dirty.current = true;
|
|
32079
32179
|
onResize(next, source);
|
|
@@ -32100,7 +32200,8 @@
|
|
|
32100
32200
|
// Shift held during a free-form drag = temporary proportional lock.
|
|
32101
32201
|
{
|
|
32102
32202
|
constrain: e.shiftKey,
|
|
32103
|
-
axis: axisRef.current
|
|
32203
|
+
axis: axisRef.current,
|
|
32204
|
+
anchor: anchorRef.current
|
|
32104
32205
|
});
|
|
32105
32206
|
emitPreview(next, "pointer");
|
|
32106
32207
|
}, [emitPreview]);
|
|
@@ -32113,7 +32214,8 @@
|
|
|
32113
32214
|
var handleKeyDown = React.useCallback(function (e) {
|
|
32114
32215
|
var next = keyboardResize(e.key, latest.current, policyRef.current, readContentMin(), {
|
|
32115
32216
|
shiftKey: e.shiftKey,
|
|
32116
|
-
axis: axisRef.current
|
|
32217
|
+
axis: axisRef.current,
|
|
32218
|
+
anchor: anchorRef.current
|
|
32117
32219
|
});
|
|
32118
32220
|
if (!next) return;
|
|
32119
32221
|
// The key is ours even when it resolves to no movement (already pinned at
|
|
@@ -32335,6 +32437,7 @@
|
|
|
32335
32437
|
exports.DEFAULT_DARK_THEME = DEFAULT_DARK_THEME;
|
|
32336
32438
|
exports.DEFAULT_KEYBOARD_STEP = DEFAULT_KEYBOARD_STEP;
|
|
32337
32439
|
exports.DEFAULT_PANE_WIDTH = DEFAULT_PANE_WIDTH;
|
|
32440
|
+
exports.DEFAULT_RESIZE_ANCHOR = DEFAULT_RESIZE_ANCHOR;
|
|
32338
32441
|
exports.DEFAULT_THEME = DEFAULT_THEME;
|
|
32339
32442
|
exports.DataTable = DataTable;
|
|
32340
32443
|
exports.DatePicker = DatePicker;
|
|
@@ -32551,6 +32654,7 @@
|
|
|
32551
32654
|
exports.ProjectTemplateIcon = ProjectTemplateIcon$1;
|
|
32552
32655
|
exports.ProjectsIcon = ProjectsIcon$1;
|
|
32553
32656
|
exports.PuzzleIcon = PuzzleIcon$1;
|
|
32657
|
+
exports.RESIZE_ANCHORS = RESIZE_ANCHORS;
|
|
32554
32658
|
exports.RESIZE_KEYS = RESIZE_KEYS;
|
|
32555
32659
|
exports.RadioBlankIcon = RadioBlankIcon$1;
|
|
32556
32660
|
exports.RadioButton = RadioButton;
|
|
@@ -32710,6 +32814,7 @@
|
|
|
32710
32814
|
exports._Dialog = _Dialog;
|
|
32711
32815
|
exports._List = _List;
|
|
32712
32816
|
exports.aiColors = aiColors;
|
|
32817
|
+
exports.anchorSigns = anchorSigns;
|
|
32713
32818
|
exports.applyResize = applyResize;
|
|
32714
32819
|
exports.clamp = clamp;
|
|
32715
32820
|
exports.colors = colors$1;
|