@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":"Styles.js","names":["styled","css","STACKED_CARD_CONTROL_CLASS","STACKED_CARD_FIXED_ATTR","STACKED_CARD_RADIUS","STACKED_CARD_ROLE_PADDING","STACKED_CARD_WIDTH","BoxSizingStyle","SELECTION_RING","SCRIM","SCRIM_STRONG","SCRIM_FG","CONTROL","revealControls","StyledStackedCardStack","div","withConfig","displayName","componentId","StyledStackedCardRow","_ref","$direction","_ref2","_ref3","_ref4","$role","$bleed","_ref5","$background","_ref6","StyledStackedCardCoverMedia","_ref7","$aspectRatio","StyledStackedCardCoverFill","StyledStackedCardCoverCenter","StyledStackedCardCoverTopRight","StyledStackedCardCollapsedStrip","button","StyledStackedCardStripExpand","span","StyledStackedCardPlayBadge","StyledStackedCardCoverButton","StyledStackedCardResizeHandle","_ref8","$axis","hoverStyle","StyledStackedCard","_ref9","$forceHover","_ref0","$priorityColor","_ref1","$selected","_ref10","$disabled","_ref11","$pending","_ref12","$isDragSource","_ref13","$isDragPreview","_ref14","$entered"],"sources":["../../../../src/components/StackedCard/Styles.ts"],"sourcesContent":["import styled, { css } from \"styled-components\";\n\nimport {\n STACKED_CARD_CONTROL_CLASS,\n STACKED_CARD_FIXED_ATTR,\n STACKED_CARD_RADIUS,\n STACKED_CARD_ROLE_PADDING,\n STACKED_CARD_WIDTH,\n StackedCardRowDirection,\n StackedCardRowRole,\n} from \"./constants\";\nimport { StackedCardResizeAxis } from \"./resizePolicy\";\nimport { BoxSizingStyle } from \"../BoxSizingStyle\";\n\n/**\n * Theming hooks.\n *\n * Every colour a StackedCard part needs is read through a `--sc-*` custom\n * property with a built-in fallback, so the component looks right standing on\n * its own and a host surface can still retint it by declaring the variable on\n * any ancestor. No rgba/hex is baked into a rule; data colours (a swatch value,\n * a priority colour) are always passed in by the caller.\n */\nconst SELECTION_RING = \"var(--sc-selection-ring, var(--color-primary-500))\";\nconst SCRIM = \"var(--sc-scrim, rgba(0, 0, 0, 0.55))\";\nconst SCRIM_STRONG = \"var(--sc-scrim-strong, rgba(0, 0, 0, 0.72))\";\nconst SCRIM_FG = \"var(--sc-scrim-fg, #ffffff)\";\n\n/** Selector for anything carrying the control class. */\nconst CONTROL = `.${STACKED_CARD_CONTROL_CLASS}`;\n\n/**\n * The one reveal rule the whole subsystem shares: controls are hidden until the\n * card (or the cover) is hovered OR holds focus. The focus path is what keeps\n * them reachable by keyboard instead of mouse-only.\n */\nconst revealControls = css`\n ${CONTROL} {\n opacity: 0;\n transition: opacity 120ms ease;\n }\n\n &:hover ${CONTROL}, &:focus-within ${CONTROL} {\n opacity: 1;\n }\n`;\n\n/* ------------------------------------------------------------------ */\n/* Stack — the vertical column. A card is a Stack of rows. */\n/* ------------------------------------------------------------------ */\n\nexport const StyledStackedCardStack = styled.div`\n ${BoxSizingStyle}\n\n position: relative;\n display: flex;\n flex-direction: column;\n`;\nStyledStackedCardStack.displayName = \"StyledStackedCardStack\";\n\n/* ------------------------------------------------------------------ */\n/* Row — the only layout primitive, differentiated by `role`. */\n/* ------------------------------------------------------------------ */\n\ninterface IStyledRowProps {\n $role: StackedCardRowRole;\n $bleed?: boolean;\n $direction: StackedCardRowDirection;\n $background?: string;\n}\n\nexport const StyledStackedCardRow = styled.div<IStyledRowProps>`\n ${BoxSizingStyle}\n\n position: relative;\n display: flex;\n flex-direction: ${({ $direction }) => $direction};\n align-items: ${({ $direction }) =>\n $direction === \"column\" ? \"stretch\" : \"center\"};\n gap: ${({ $direction }) => ($direction === \"column\" ? \"4px\" : \"8px\")};\n\n /* bleed overrides any role and runs the row edge to edge. */\n padding: ${({ $role, $bleed }) =>\n $bleed ? \"0\" : STACKED_CARD_ROLE_PADDING[$role]};\n\n ${({ $background }) =>\n $background &&\n css`\n background: ${$background};\n `}\n\n /* Distribution (row direction only): fixed-width children keep their width,\n the rest share what remains evenly; drop an empty spacer to push items. */\n ${({ $direction }) =>\n $direction === \"row\" &&\n css`\n > * {\n flex: 1 1 0;\n min-width: 0;\n }\n\n > [${STACKED_CARD_FIXED_ATTR}] {\n flex: 0 0 auto;\n }\n `}\n`;\nStyledStackedCardRow.displayName = \"StyledStackedCardRow\";\n\n/* ------------------------------------------------------------------ */\n/* Cover — a bleed row that holds media. */\n/* ------------------------------------------------------------------ */\n\n/**\n * The media box reserves its height with `aspect-ratio` so the image (or the\n * skeleton standing in for it) never reflows the card when it arrives.\n */\nexport const StyledStackedCardCoverMedia = styled.div<{ $aspectRatio: string }>`\n position: relative;\n width: 100%;\n aspect-ratio: ${({ $aspectRatio }) => $aspectRatio};\n overflow: hidden;\n\n ${revealControls}\n`;\nStyledStackedCardCoverMedia.displayName = \"StyledStackedCardCoverMedia\";\n\n/* The fill (an <img>, an inline <svg> wrapper, or a solid-colour box) is laid\n over the reserved box and made to cover it. */\nexport const StyledStackedCardCoverFill = styled.div`\n position: absolute;\n inset: 0;\n\n > * {\n width: 100%;\n height: 100%;\n }\n\n > img {\n display: block;\n object-fit: cover;\n }\n\n /* Media must never be natively draggable. An <img> is a browser drag source\n by default, so grabbing the cover would start an image drag and swallow the\n mousemove/mouseup the HOST's drag depends on — the card would stay put and\n then jump on the next pointer move. The host owns dragging; the cover must\n not compete with it. */\n > img,\n > svg {\n -webkit-user-drag: none;\n user-select: none;\n pointer-events: none;\n }\n`;\nStyledStackedCardCoverFill.displayName = \"StyledStackedCardCoverFill\";\n\nexport const StyledStackedCardCoverCenter = styled.div`\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n`;\nStyledStackedCardCoverCenter.displayName = \"StyledStackedCardCoverCenter\";\n\nexport const StyledStackedCardCoverTopRight = styled.div`\n position: absolute;\n top: 8px;\n right: 8px;\n display: flex;\n gap: 6px;\n`;\nStyledStackedCardCoverTopRight.displayName = \"StyledStackedCardCoverTopRight\";\n\n/**\n * Collapsed cover — the media box gives way to a thin strip. The strip IS the\n * expand affordance: the whole bar is a button and a chevron hint is revealed\n * on hover or focus. It reserves no height of its own; the caller's\n * `collapsedStrip` (an ~8px colour bar, a favicon + domain row) sets how tall\n * it reads.\n */\nexport const StyledStackedCardCollapsedStrip = styled.button`\n ${BoxSizingStyle}\n\n position: relative;\n display: flex;\n align-items: center;\n width: 100%;\n min-height: 16px;\n padding: 0;\n border: 0;\n background: transparent;\n cursor: pointer;\n text-align: left;\n\n ${CONTROL} {\n opacity: 0;\n transition: opacity 120ms ease;\n }\n\n &:hover ${CONTROL}, &:focus-visible ${CONTROL} {\n opacity: 1;\n }\n\n &:focus-visible {\n outline: 2px solid ${SELECTION_RING};\n outline-offset: -2px;\n }\n`;\nStyledStackedCardCollapsedStrip.displayName = \"StyledStackedCardCollapsedStrip\";\n\n/* The expand chevron sits at the right, vertically centred, so it reads the\n same whether the strip is a hairline colour bar or a taller favicon row. */\nexport const StyledStackedCardStripExpand = styled.span`\n position: absolute;\n top: 50%;\n right: 8px;\n transform: translateY(-50%);\n display: inline-flex;\n width: 16px;\n height: 16px;\n color: var(--color-theme-600);\n\n svg {\n width: 14px;\n height: 14px;\n }\n`;\nStyledStackedCardStripExpand.displayName = \"StyledStackedCardStripExpand\";\n\n/* ------------------------------------------------------------------ */\n/* Cover chrome — scrim-backed controls that sit over media */\n/* ------------------------------------------------------------------ */\n\n/** Centered media control (a play button). The caller drops the glyph inside. */\nexport const StyledStackedCardPlayBadge = styled.span`\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 44px;\n height: 44px;\n border-radius: 12px;\n background: ${SCRIM};\n color: ${SCRIM_FG};\n\n svg {\n fill: currentColor;\n width: 20px;\n height: 20px;\n margin-left: 2px;\n }\n`;\nStyledStackedCardPlayBadge.displayName = \"StyledStackedCardPlayBadge\";\n\n/** Top-right cover-management button (collapse, remove …). */\nexport const StyledStackedCardCoverButton = styled.button`\n ${BoxSizingStyle}\n\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 30px;\n height: 30px;\n padding: 0;\n border: 0;\n border-radius: 8px;\n cursor: pointer;\n color: ${SCRIM_FG};\n background: ${SCRIM};\n\n svg {\n width: 16px;\n height: 16px;\n display: block;\n }\n\n &:hover {\n background: ${SCRIM_STRONG};\n }\n`;\nStyledStackedCardCoverButton.displayName = \"StyledStackedCardCoverButton\";\n\n/* ------------------------------------------------------------------ */\n/* Resize (opt-in): handle on hover, the card only reports deltas */\n/* ------------------------------------------------------------------ */\n\n/* The grip is a focusable separator, so it needs a focus ring of its own — a\n keyboard user has no pointer to tell them where they are. */\nexport const StyledStackedCardResizeHandle = styled.span<{\n $axis: StackedCardResizeAxis;\n}>`\n position: absolute;\n right: 2px;\n bottom: 2px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 14px;\n height: 14px;\n border-radius: 4px;\n cursor: ${({ $axis }) => ($axis === \"width\" ? \"ew-resize\" : \"nwse-resize\")};\n color: var(--color-theme-600);\n z-index: 2;\n\n &:hover {\n color: var(--color-theme-900);\n }\n\n &:focus-visible {\n outline: 2px solid ${SELECTION_RING};\n outline-offset: 1px;\n color: var(--color-theme-900);\n }\n\n svg {\n display: block;\n }\n`;\nStyledStackedCardResizeHandle.displayName = \"StyledStackedCardResizeHandle\";\n\n/* ------------------------------------------------------------------ */\n/* The shell */\n/* ------------------------------------------------------------------ */\n\nexport interface IStyledStackedCardProps {\n $selected?: boolean;\n $disabled?: boolean;\n $pending?: boolean;\n $isDragSource?: boolean;\n $isDragPreview?: boolean;\n $entered?: boolean;\n $forceHover?: boolean;\n $priorityColor?: string;\n}\n\nconst hoverStyle = css`\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);\n border-color: var(--color-theme-500);\n`;\n\nexport const StyledStackedCard = styled.div<IStyledStackedCardProps>`\n ${BoxSizingStyle}\n\n position: relative;\n display: flex;\n flex-direction: column;\n width: ${STACKED_CARD_WIDTH}px;\n border-radius: ${STACKED_CARD_RADIUS}px;\n background-color: var(--page-paper-main);\n border: 1px solid var(--border-primary);\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);\n overflow: hidden;\n transition: box-shadow 150ms ease, border-color 150ms ease;\n\n ${revealControls}\n\n &:hover {\n ${hoverStyle}\n }\n\n &:focus-visible {\n outline: none;\n ${hoverStyle}\n box-shadow: 0 0 0 2px ${SELECTION_RING};\n }\n\n /* Forced hover — for docs, snapshots and \"this is what hover looks like\"\n demos. The doubled ampersand gives it the specificity to beat the cover's\n own reveal rule. */\n ${({ $forceHover }) =>\n $forceHover &&\n css`\n ${hoverStyle}\n && ${CONTROL} {\n opacity: 1;\n }\n `}\n\n ${({ $priorityColor }) =>\n $priorityColor &&\n css`\n &::before {\n content: \"\";\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n width: 4px;\n background: ${$priorityColor};\n z-index: 2;\n }\n `}\n\n /* Selection outranks hover: a selected card must keep its ring while the\n pointer is over it — which, right after the click that selected it, is\n always. The doubled ampersand buys the specificity to beat the hover rule\n above (same reason the entered state below does it). */\n ${({ $selected }) =>\n $selected &&\n css`\n && {\n border-color: ${SELECTION_RING};\n box-shadow: 0 0 0 2px ${SELECTION_RING};\n }\n `}\n\n ${({ $disabled }) =>\n $disabled &&\n css`\n opacity: 0.5;\n pointer-events: none;\n `}\n\n /* Pending / optimistic — created or moved, not yet confirmed by the server.\n Dimmed, non-interactive and NOT draggable, but distinct from disabled: a\n transient in-flight state, not a policy. */\n ${({ $pending }) =>\n $pending &&\n css`\n opacity: 0.6;\n pointer-events: none;\n cursor: progress;\n `}\n\n /* Drag SOURCE — full-size outline placeholder. Content is hidden but keeps\n its box (visibility, not display) so the card holds identical dimensions\n and the surrounding cards never move. */\n ${({ $isDragSource }) =>\n $isDragSource &&\n css`\n background: transparent;\n border: 1px dashed var(--color-theme-500);\n box-shadow: none;\n\n &:hover {\n box-shadow: none;\n border-color: var(--color-theme-500);\n }\n\n > * {\n visibility: hidden;\n }\n `}\n\n /* Drag PREVIEW — the 1:1 copy the host floats in its drag layer. Elevated\n shadow ONLY: no rotate, no scale, no translate. */\n ${({ $isDragPreview }) =>\n $isDragPreview &&\n css`\n box-shadow: 0 12px 28px rgba(0, 0, 0, 0.24);\n cursor: grabbing;\n `}\n\n /* Entered (focus model) — focus has moved inside, onto an inner control. */\n ${({ $entered }) =>\n $entered &&\n css`\n && {\n border-color: ${SELECTION_RING};\n box-shadow: inset 0 0 0 2px ${SELECTION_RING},\n 0 0 0 2px ${SELECTION_RING};\n }\n `}\n`;\nStyledStackedCard.displayName = \"StyledStackedCard\";\n"],"mappings":"AAAA,OAAOA,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAE/C,SACEC,0BAA0B,EAC1BC,uBAAuB,EACvBC,mBAAmB,EACnBC,yBAAyB,EACzBC,kBAAkB,QAGb,aAAa;AAEpB,SAASC,cAAc,QAAQ,mBAAmB;;AAElD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,cAAc,GAAG,oDAAoD;AAC3E,MAAMC,KAAK,GAAG,sCAAsC;AACpD,MAAMC,YAAY,GAAG,6CAA6C;AAClE,MAAMC,QAAQ,GAAG,6BAA6B;;AAE9C;AACA,MAAMC,OAAO,SAAOV,0BAA4B;;AAEhD;AACA;AACA;AACA;AACA;AACA,MAAMW,cAAc,GAAGZ,GAAG,iGACtBW,OAAO,EAKCA,OAAO,EAAoBA,OAAO,CAG7C;;AAED;AACA;AACA;;AAEA,OAAO,MAAME,sBAAsB,GAAGd,MAAM,CAACe,GAAG,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,mEAC5CX,cAAc,CAKjB;AACDO,sBAAsB,CAACG,WAAW,GAAG,wBAAwB;;AAE7D;AACA;AACA;;AASA,OAAO,MAAME,oBAAoB,GAAGnB,MAAM,CAACe,GAAG,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,iHAC1CX,cAAc,EAIEa,IAAA;EAAA,IAAGC,UAAU,GAAAD,IAAA,CAAVC,UAAU;EAAA,OAAOA,UAAU;AAAA,GACjCC,KAAA;EAAA,IAAGD,UAAU,GAAAC,KAAA,CAAVD,UAAU;EAAA,OAC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A,CAARC,QAAQ;EAAA,OACXA,QAAQ,IACR7D,GAAG,4EAEiBO,cAAc,EACAA,cAAc,EAC9BA,cAAc,CAE/B;AAAA,EACJ;AACDsC,iBAAiB,CAAC7B,WAAW,GAAG,mBAAmB","ignoreList":[]}
1
+ {"version":3,"file":"Styles.js","names":["styled","css","STACKED_CARD_CONTROL_CLASS","STACKED_CARD_FIXED_ATTR","STACKED_CARD_RADIUS","STACKED_CARD_ROLE_PADDING","STACKED_CARD_WIDTH","BoxSizingStyle","SELECTION_RING","SCRIM","SCRIM_STRONG","SCRIM_FG","CONTROL","revealControls","StyledStackedCardStack","div","withConfig","displayName","componentId","StyledStackedCardRow","_ref","$direction","_ref2","_ref3","_ref4","$role","$bleed","_ref5","$background","_ref6","StyledStackedCardCoverMedia","_ref7","$aspectRatio","StyledStackedCardCoverFill","StyledStackedCardCoverCenter","StyledStackedCardCoverTopRight","StyledStackedCardCollapsedStrip","button","StyledStackedCardStripExpand","span","StyledStackedCardPlayBadge","StyledStackedCardCoverButton","StyledStackedCardResizeHandle","_ref8","$axis","hoverStyle","StyledStackedCard","_ref9","$forceHover","_ref0","$priorityColor","_ref1","$selected","_ref10","$disabled","_ref11","$pending","_ref12","$isDragSource","_ref13","$isDragPreview","_ref14","$entered"],"sources":["../../../../src/components/StackedCard/Styles.ts"],"sourcesContent":["import styled, { css } from \"styled-components\";\n\nimport {\n STACKED_CARD_CONTROL_CLASS,\n STACKED_CARD_FIXED_ATTR,\n STACKED_CARD_RADIUS,\n STACKED_CARD_ROLE_PADDING,\n STACKED_CARD_WIDTH,\n StackedCardRowDirection,\n StackedCardRowRole,\n} from \"./constants\";\nimport { ResizeAxis } from \"./resizePolicy\";\nimport { BoxSizingStyle } from \"../BoxSizingStyle\";\n\n/**\n * Theming hooks.\n *\n * Every colour a StackedCard part needs is read through a `--sc-*` custom\n * property with a built-in fallback, so the component looks right standing on\n * its own and a host surface can still retint it by declaring the variable on\n * any ancestor. No rgba/hex is baked into a rule; data colours (a swatch value,\n * a priority colour) are always passed in by the caller.\n */\nconst SELECTION_RING = \"var(--sc-selection-ring, var(--color-primary-500))\";\nconst SCRIM = \"var(--sc-scrim, rgba(0, 0, 0, 0.55))\";\nconst SCRIM_STRONG = \"var(--sc-scrim-strong, rgba(0, 0, 0, 0.72))\";\nconst SCRIM_FG = \"var(--sc-scrim-fg, #ffffff)\";\n\n/** Selector for anything carrying the control class. */\nconst CONTROL = `.${STACKED_CARD_CONTROL_CLASS}`;\n\n/**\n * The one reveal rule the whole subsystem shares: controls are hidden until the\n * card (or the cover) is hovered OR holds focus. The focus path is what keeps\n * them reachable by keyboard instead of mouse-only.\n */\nconst revealControls = css`\n ${CONTROL} {\n opacity: 0;\n transition: opacity 120ms ease;\n }\n\n &:hover ${CONTROL}, &:focus-within ${CONTROL} {\n opacity: 1;\n }\n`;\n\n/* ------------------------------------------------------------------ */\n/* Stack — the vertical column. A card is a Stack of rows. */\n/* ------------------------------------------------------------------ */\n\nexport const StyledStackedCardStack = styled.div`\n ${BoxSizingStyle}\n\n position: relative;\n display: flex;\n flex-direction: column;\n`;\nStyledStackedCardStack.displayName = \"StyledStackedCardStack\";\n\n/* ------------------------------------------------------------------ */\n/* Row — the only layout primitive, differentiated by `role`. */\n/* ------------------------------------------------------------------ */\n\ninterface IStyledRowProps {\n $role: StackedCardRowRole;\n $bleed?: boolean;\n $direction: StackedCardRowDirection;\n $background?: string;\n}\n\nexport const StyledStackedCardRow = styled.div<IStyledRowProps>`\n ${BoxSizingStyle}\n\n position: relative;\n display: flex;\n flex-direction: ${({ $direction }) => $direction};\n align-items: ${({ $direction }) =>\n $direction === \"column\" ? \"stretch\" : \"center\"};\n gap: ${({ $direction }) => ($direction === \"column\" ? \"4px\" : \"8px\")};\n\n /* bleed overrides any role and runs the row edge to edge. */\n padding: ${({ $role, $bleed }) =>\n $bleed ? \"0\" : STACKED_CARD_ROLE_PADDING[$role]};\n\n ${({ $background }) =>\n $background &&\n css`\n background: ${$background};\n `}\n\n /* Distribution (row direction only): fixed-width children keep their width,\n the rest share what remains evenly; drop an empty spacer to push items. */\n ${({ $direction }) =>\n $direction === \"row\" &&\n css`\n > * {\n flex: 1 1 0;\n min-width: 0;\n }\n\n > [${STACKED_CARD_FIXED_ATTR}] {\n flex: 0 0 auto;\n }\n `}\n`;\nStyledStackedCardRow.displayName = \"StyledStackedCardRow\";\n\n/* ------------------------------------------------------------------ */\n/* Cover — a bleed row that holds media. */\n/* ------------------------------------------------------------------ */\n\n/**\n * The media box reserves its height with `aspect-ratio` so the image (or the\n * skeleton standing in for it) never reflows the card when it arrives.\n */\nexport const StyledStackedCardCoverMedia = styled.div<{ $aspectRatio: string }>`\n position: relative;\n width: 100%;\n aspect-ratio: ${({ $aspectRatio }) => $aspectRatio};\n overflow: hidden;\n\n ${revealControls}\n`;\nStyledStackedCardCoverMedia.displayName = \"StyledStackedCardCoverMedia\";\n\n/* The fill (an <img>, an inline <svg> wrapper, or a solid-colour box) is laid\n over the reserved box and made to cover it. */\nexport const StyledStackedCardCoverFill = styled.div`\n position: absolute;\n inset: 0;\n\n > * {\n width: 100%;\n height: 100%;\n }\n\n > img {\n display: block;\n object-fit: cover;\n }\n\n /* Media must never be natively draggable. An <img> is a browser drag source\n by default, so grabbing the cover would start an image drag and swallow the\n mousemove/mouseup the HOST's drag depends on — the card would stay put and\n then jump on the next pointer move. The host owns dragging; the cover must\n not compete with it. */\n > img,\n > svg {\n -webkit-user-drag: none;\n user-select: none;\n pointer-events: none;\n }\n`;\nStyledStackedCardCoverFill.displayName = \"StyledStackedCardCoverFill\";\n\nexport const StyledStackedCardCoverCenter = styled.div`\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n`;\nStyledStackedCardCoverCenter.displayName = \"StyledStackedCardCoverCenter\";\n\nexport const StyledStackedCardCoverTopRight = styled.div`\n position: absolute;\n top: 8px;\n right: 8px;\n display: flex;\n gap: 6px;\n`;\nStyledStackedCardCoverTopRight.displayName = \"StyledStackedCardCoverTopRight\";\n\n/**\n * Collapsed cover — the media box gives way to a thin strip. The strip IS the\n * expand affordance: the whole bar is a button and a chevron hint is revealed\n * on hover or focus. It reserves no height of its own; the caller's\n * `collapsedStrip` (an ~8px colour bar, a favicon + domain row) sets how tall\n * it reads.\n */\nexport const StyledStackedCardCollapsedStrip = styled.button`\n ${BoxSizingStyle}\n\n position: relative;\n display: flex;\n align-items: center;\n width: 100%;\n min-height: 16px;\n padding: 0;\n border: 0;\n background: transparent;\n cursor: pointer;\n text-align: left;\n\n ${CONTROL} {\n opacity: 0;\n transition: opacity 120ms ease;\n }\n\n &:hover ${CONTROL}, &:focus-visible ${CONTROL} {\n opacity: 1;\n }\n\n &:focus-visible {\n outline: 2px solid ${SELECTION_RING};\n outline-offset: -2px;\n }\n`;\nStyledStackedCardCollapsedStrip.displayName = \"StyledStackedCardCollapsedStrip\";\n\n/* The expand chevron sits at the right, vertically centred, so it reads the\n same whether the strip is a hairline colour bar or a taller favicon row. */\nexport const StyledStackedCardStripExpand = styled.span`\n position: absolute;\n top: 50%;\n right: 8px;\n transform: translateY(-50%);\n display: inline-flex;\n width: 16px;\n height: 16px;\n color: var(--color-theme-600);\n\n svg {\n width: 14px;\n height: 14px;\n }\n`;\nStyledStackedCardStripExpand.displayName = \"StyledStackedCardStripExpand\";\n\n/* ------------------------------------------------------------------ */\n/* Cover chrome — scrim-backed controls that sit over media */\n/* ------------------------------------------------------------------ */\n\n/** Centered media control (a play button). The caller drops the glyph inside. */\nexport const StyledStackedCardPlayBadge = styled.span`\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 44px;\n height: 44px;\n border-radius: 12px;\n background: ${SCRIM};\n color: ${SCRIM_FG};\n\n svg {\n fill: currentColor;\n width: 20px;\n height: 20px;\n margin-left: 2px;\n }\n`;\nStyledStackedCardPlayBadge.displayName = \"StyledStackedCardPlayBadge\";\n\n/** Top-right cover-management button (collapse, remove …). */\nexport const StyledStackedCardCoverButton = styled.button`\n ${BoxSizingStyle}\n\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 30px;\n height: 30px;\n padding: 0;\n border: 0;\n border-radius: 8px;\n cursor: pointer;\n color: ${SCRIM_FG};\n background: ${SCRIM};\n\n svg {\n width: 16px;\n height: 16px;\n display: block;\n }\n\n &:hover {\n background: ${SCRIM_STRONG};\n }\n`;\nStyledStackedCardCoverButton.displayName = \"StyledStackedCardCoverButton\";\n\n/* ------------------------------------------------------------------ */\n/* Resize (opt-in): handle on hover, the card only reports deltas */\n/* ------------------------------------------------------------------ */\n\n/* The grip is a focusable separator, so it needs a focus ring of its own — a\n keyboard user has no pointer to tell them where they are. */\nexport const StyledStackedCardResizeHandle = styled.span<{\n $axis: ResizeAxis;\n}>`\n position: absolute;\n right: 2px;\n bottom: 2px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 14px;\n height: 14px;\n border-radius: 4px;\n cursor: ${({ $axis }) => ($axis === \"width\" ? \"ew-resize\" : \"nwse-resize\")};\n color: var(--color-theme-600);\n z-index: 2;\n\n &:hover {\n color: var(--color-theme-900);\n }\n\n &:focus-visible {\n outline: 2px solid ${SELECTION_RING};\n outline-offset: 1px;\n color: var(--color-theme-900);\n }\n\n svg {\n display: block;\n }\n`;\nStyledStackedCardResizeHandle.displayName = \"StyledStackedCardResizeHandle\";\n\n/* ------------------------------------------------------------------ */\n/* The shell */\n/* ------------------------------------------------------------------ */\n\nexport interface IStyledStackedCardProps {\n $selected?: boolean;\n $disabled?: boolean;\n $pending?: boolean;\n $isDragSource?: boolean;\n $isDragPreview?: boolean;\n $entered?: boolean;\n $forceHover?: boolean;\n $priorityColor?: string;\n}\n\nconst hoverStyle = css`\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);\n border-color: var(--color-theme-500);\n`;\n\nexport const StyledStackedCard = styled.div<IStyledStackedCardProps>`\n ${BoxSizingStyle}\n\n position: relative;\n display: flex;\n flex-direction: column;\n width: ${STACKED_CARD_WIDTH}px;\n border-radius: ${STACKED_CARD_RADIUS}px;\n background-color: var(--page-paper-main);\n border: 1px solid var(--border-primary);\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);\n overflow: hidden;\n transition: box-shadow 150ms ease, border-color 150ms ease;\n\n ${revealControls}\n\n &:hover {\n ${hoverStyle}\n }\n\n &:focus-visible {\n outline: none;\n ${hoverStyle}\n box-shadow: 0 0 0 2px ${SELECTION_RING};\n }\n\n /* Forced hover — for docs, snapshots and \"this is what hover looks like\"\n demos. The doubled ampersand gives it the specificity to beat the cover's\n own reveal rule. */\n ${({ $forceHover }) =>\n $forceHover &&\n css`\n ${hoverStyle}\n && ${CONTROL} {\n opacity: 1;\n }\n `}\n\n ${({ $priorityColor }) =>\n $priorityColor &&\n css`\n &::before {\n content: \"\";\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n width: 4px;\n background: ${$priorityColor};\n z-index: 2;\n }\n `}\n\n /* Selection outranks hover: a selected card must keep its ring while the\n pointer is over it — which, right after the click that selected it, is\n always. The doubled ampersand buys the specificity to beat the hover rule\n above (same reason the entered state below does it). */\n ${({ $selected }) =>\n $selected &&\n css`\n && {\n border-color: ${SELECTION_RING};\n box-shadow: 0 0 0 2px ${SELECTION_RING};\n }\n `}\n\n ${({ $disabled }) =>\n $disabled &&\n css`\n opacity: 0.5;\n pointer-events: none;\n `}\n\n /* Pending / optimistic — created or moved, not yet confirmed by the server.\n Dimmed, non-interactive and NOT draggable, but distinct from disabled: a\n transient in-flight state, not a policy. */\n ${({ $pending }) =>\n $pending &&\n css`\n opacity: 0.6;\n pointer-events: none;\n cursor: progress;\n `}\n\n /* Drag SOURCE — full-size outline placeholder. Content is hidden but keeps\n its box (visibility, not display) so the card holds identical dimensions\n and the surrounding cards never move. */\n ${({ $isDragSource }) =>\n $isDragSource &&\n css`\n background: transparent;\n border: 1px dashed var(--color-theme-500);\n box-shadow: none;\n\n &:hover {\n box-shadow: none;\n border-color: var(--color-theme-500);\n }\n\n > * {\n visibility: hidden;\n }\n `}\n\n /* Drag PREVIEW — the 1:1 copy the host floats in its drag layer. Elevated\n shadow ONLY: no rotate, no scale, no translate. */\n ${({ $isDragPreview }) =>\n $isDragPreview &&\n css`\n box-shadow: 0 12px 28px rgba(0, 0, 0, 0.24);\n cursor: grabbing;\n `}\n\n /* Entered (focus model) — focus has moved inside, onto an inner control. */\n ${({ $entered }) =>\n $entered &&\n css`\n && {\n border-color: ${SELECTION_RING};\n box-shadow: inset 0 0 0 2px ${SELECTION_RING},\n 0 0 0 2px ${SELECTION_RING};\n }\n `}\n`;\nStyledStackedCard.displayName = \"StyledStackedCard\";\n"],"mappings":"AAAA,OAAOA,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAE/C,SACEC,0BAA0B,EAC1BC,uBAAuB,EACvBC,mBAAmB,EACnBC,yBAAyB,EACzBC,kBAAkB,QAGb,aAAa;AAEpB,SAASC,cAAc,QAAQ,mBAAmB;;AAElD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,cAAc,GAAG,oDAAoD;AAC3E,MAAMC,KAAK,GAAG,sCAAsC;AACpD,MAAMC,YAAY,GAAG,6CAA6C;AAClE,MAAMC,QAAQ,GAAG,6BAA6B;;AAE9C;AACA,MAAMC,OAAO,SAAOV,0BAA4B;;AAEhD;AACA;AACA;AACA;AACA;AACA,MAAMW,cAAc,GAAGZ,GAAG,iGACtBW,OAAO,EAKCA,OAAO,EAAoBA,OAAO,CAG7C;;AAED;AACA;AACA;;AAEA,OAAO,MAAME,sBAAsB,GAAGd,MAAM,CAACe,GAAG,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,mEAC5CX,cAAc,CAKjB;AACDO,sBAAsB,CAACG,WAAW,GAAG,wBAAwB;;AAE7D;AACA;AACA;;AASA,OAAO,MAAME,oBAAoB,GAAGnB,MAAM,CAACe,GAAG,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,iHAC1CX,cAAc,EAIEa,IAAA;EAAA,IAAGC,UAAU,GAAAD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AD,MAAA,CAAdC,cAAc;EAAA,OACjBA,cAAc,IACd3D,GAAG,8DAGF;AAAA,GAGD4D,MAAA;EAAA,IAAGC,QAAQ,GAAAD,MAAA,CAARC,QAAQ;EAAA,OACXA,QAAQ,IACR7D,GAAG,4EAEiBO,cAAc,EACAA,cAAc,EAC9BA,cAAc,CAE/B;AAAA,EACJ;AACDsC,iBAAiB,CAAC7B,WAAW,GAAG,mBAAmB","ignoreList":[]}
@@ -1,13 +1,15 @@
1
1
  /**
2
- * StackedCard resize policy — pure math.
2
+ * Resize policy — pure math, shared by every resizable element.
3
3
  *
4
- * The card reports intent; the HOST applies a resize policy (spec §7). This
5
- * module is that policy, packaged as pure functions so the SAME code path
6
- * serves the pointer drag and the keyboard resize. Nothing here touches the
7
- * DOM, React or the card's content: it takes a start size, a delta and a
8
- * policy, and returns a clamped size. `useStackedCardResize` wires events to
9
- * it; the card's intrinsic content minimum is measured by the host and passed
10
- * in as `contentMin`, so this module knows nothing about heroes or footers.
4
+ * The element reports intent; the HOST applies a resize policy (StackedCard
5
+ * spec §7). This module is that policy, packaged as pure functions so the SAME
6
+ * code path serves the pointer drag and the keyboard resize, a card's single
7
+ * bottom-right grip and a shape's eight handles. Nothing here touches the DOM,
8
+ * React or the element's content: it takes a start box, a delta, a policy and
9
+ * the handle being dragged, and returns a clamped box — size AND position.
10
+ * `useStackedCardResize` wires events to it; an element's intrinsic content
11
+ * minimum is measured by the host and passed in as `contentMin`, so this module
12
+ * knows nothing about heroes or footers.
11
13
  *
12
14
  * The policy has four parts:
13
15
  * - bounds — optional min/max per axis; unset means unbounded.
@@ -16,18 +18,32 @@
16
18
  * distorts at a bound.
17
19
  * - step — optional grid snap; proportion wins over the grid.
18
20
  * - content min — the effective min is max(policyMin, contentMin) per axis,
19
- * so a card can never be crushed below what its content needs.
21
+ * so an element can never be crushed below what its content
22
+ * needs.
23
+ *
24
+ * The anchor is the handle being dragged. The edge or corner OPPOSITE to it
25
+ * never moves — not while the pointer travels, and not when a bound stops the
26
+ * resize — which is what makes a resize feel like a resize rather than a nudge.
27
+ * A `left` handle moves the position by exactly the amount the width grew; a
28
+ * `right` handle leaves it alone. An edge handle touches one axis only.
20
29
  */
21
- export interface StackedCardSize {
30
+ export interface ResizeSize {
22
31
  w: number;
23
32
  h: number;
24
33
  }
25
- /** The card's intrinsic minimum, measured from its real content. */
26
- export interface StackedCardContentMin {
34
+ export interface ResizePosition {
35
+ x: number;
36
+ y: number;
37
+ }
38
+ /** A resized element: its size and where its top-left corner now sits. */
39
+ export interface ResizeBox extends ResizeSize, ResizePosition {
40
+ }
41
+ /** The element's intrinsic minimum, measured from its real content. */
42
+ export interface ResizeContentMin {
27
43
  w: number;
28
44
  h: number;
29
45
  }
30
- export interface StackedCardResizePolicy {
46
+ export interface ResizePolicy {
31
47
  minW?: number;
32
48
  maxW?: number;
33
49
  minH?: number;
@@ -37,17 +53,26 @@ export interface StackedCardResizePolicy {
37
53
  /** Grid snap increment in px; omitted / 0 means continuous. */
38
54
  step?: number;
39
55
  }
40
- /** The size captured at the start of a gesture (pointer down or a key press). */
41
- export interface StackedCardResizeStart {
42
- w: number;
43
- h: number;
44
- contentMin: StackedCardContentMin;
56
+ /**
57
+ * The handle being dragged, named after the edge or corner it sits on. The
58
+ * opposite edge or corner is held in place.
59
+ */
60
+ export type ResizeAnchor = "top-left" | "top" | "top-right" | "right" | "bottom-right" | "bottom" | "bottom-left" | "left";
61
+ export declare const RESIZE_ANCHORS: ReadonlyArray<ResizeAnchor>;
62
+ /** A card's single grip: the top-left corner stays put. */
63
+ export declare const DEFAULT_RESIZE_ANCHOR: ResizeAnchor;
64
+ /**
65
+ * The box captured at the start of a gesture (pointer down or a key press).
66
+ * A host that only tracks a size leaves the position at the origin.
67
+ */
68
+ export interface ResizeStart extends ResizeBox {
69
+ contentMin: ResizeContentMin;
45
70
  }
46
- export interface StackedCardResizeDelta {
71
+ export interface ResizeDelta {
47
72
  dx: number;
48
73
  dy: number;
49
74
  }
50
- export interface StackedCardResizeBounds {
75
+ export interface ResizeBounds {
51
76
  wMin: number;
52
77
  wMax: number;
53
78
  hMin: number;
@@ -57,9 +82,16 @@ export interface StackedCardResizeBounds {
57
82
  * `width` locks the vertical axis: an auto-height card takes a width and lets
58
83
  * its rows set the height, so the gesture's vertical component is ignored.
59
84
  */
60
- export type StackedCardResizeAxis = "both" | "width";
85
+ export type ResizeAxis = "both" | "width";
61
86
  /** Which input drove a resize event. Hosts log undo entries per source. */
62
- export type StackedCardResizeSource = "pointer" | "keyboard";
87
+ export type ResizeSource = "pointer" | "keyboard";
88
+ export interface ResizeOptions {
89
+ /** Shift-to-constrain: one gesture behaves proportionally. */
90
+ constrain?: boolean;
91
+ axis?: ResizeAxis;
92
+ /** The handle being dragged. Defaults to a card's bottom-right grip. */
93
+ anchor?: ResizeAnchor;
94
+ }
63
95
  /** Keyboard resize nudges by the policy step, or this when no step is set. */
64
96
  export declare const DEFAULT_KEYBOARD_STEP = 8;
65
97
  /** Shift + arrow resizes by a larger increment (the familiar coarse nudge). */
@@ -69,43 +101,56 @@ export declare const RESIZE_KEYS: ReadonlyArray<string>;
69
101
  export declare const isResizeKey: (key: string) => boolean;
70
102
  export declare const clamp: (v: number, lo: number, hi?: number) => number;
71
103
  export declare const snap: (v: number, step?: number) => number;
72
- export declare const makeStart: (size: StackedCardSize, contentMin: StackedCardContentMin) => StackedCardResizeStart;
104
+ export declare const makeStart: (box: ResizeSize & Partial<ResizePosition>, contentMin: ResizeContentMin) => ResizeStart;
73
105
  /**
74
106
  * The effective bounds a size is clamped to: the policy min floored by the
75
107
  * content min, and the policy max (unbounded when unset). Independent of any
76
108
  * live gesture, so a host can also use it for the aria value and Home/End.
77
109
  */
78
- export declare const effectiveBounds: (policy: StackedCardResizePolicy, contentMin: StackedCardContentMin) => StackedCardResizeBounds;
110
+ export declare const effectiveBounds: (policy: ResizePolicy, contentMin: ResizeContentMin) => ResizeBounds;
111
+ type AxisSign = -1 | 0 | 1;
79
112
  /**
80
- * Apply a delta to the start size under the policy — the single path for both
81
- * inputs.
113
+ * Which way each axis grows for a handle: +1 when the handle is on the far
114
+ * edge (right/bottom), −1 when it is on the near edge (left/top), 0 when the
115
+ * handle does not touch that axis at all.
116
+ */
117
+ export declare const anchorSigns: (anchor: ResizeAnchor) => {
118
+ sx: AxisSign;
119
+ sy: AxisSign;
120
+ };
121
+ /**
122
+ * Apply a delta to the start box under the policy — the single path for both
123
+ * inputs and for every handle.
82
124
  *
83
125
  * `constrain` is the transient Shift-to-constrain lock: a free-form policy
84
126
  * behaves proportionally for that one gesture; a proportional policy is already
85
127
  * locked and ignores it. `axis: "width"` drops the gesture's vertical component;
86
128
  * the height then holds still in free-form mode, and still follows the ratio in
87
- * proportional mode (that is what proportional means).
129
+ * proportional mode (that is what proportional means). `anchor` is the handle
130
+ * being dragged: the opposite edge or corner is held, so the returned position
131
+ * moves only when a near-edge handle (left/top) grew or shrank the box.
88
132
  */
89
- export declare const applyResize: (start: StackedCardResizeStart, delta: StackedCardResizeDelta, policy: StackedCardResizePolicy, opts?: {
90
- constrain?: boolean;
91
- axis?: StackedCardResizeAxis;
92
- }) => StackedCardSize;
133
+ export declare const applyResize: (start: ResizeStart, delta: ResizeDelta, policy: ResizePolicy, opts?: ResizeOptions) => ResizeBox;
93
134
  /**
94
- * Translate a resize key into the next size, reusing `applyResize` so the
95
- * keyboard clamps exactly like the pointer. Arrows nudge by the step (Shift ×4);
96
- * Home/End jump to the min/max of the allowed range, leaving any axis without
97
- * that bound where it is. Returns null for a key the handle does not own, and
98
- * for a vertical key on a width-only card.
135
+ * Translate a resize key into the next box, reusing `applyResize` so the
136
+ * keyboard clamps exactly like the pointer. Arrows move the HANDLE by the step
137
+ * (Shift ×4) — so on a left handle ArrowLeft grows the element and ArrowRight
138
+ * shrinks it — and Home/End jump the handle to the min/max of the allowed
139
+ * range, leaving any axis without that bound where it is. Returns null for a
140
+ * key the handle does not own: a key on an axis the handle does not touch, or a
141
+ * vertical key on a width-only card.
99
142
  */
100
- export declare const keyboardResize: (key: string, size: StackedCardSize, policy: StackedCardResizePolicy, contentMin: StackedCardContentMin, opts?: {
143
+ export declare const keyboardResize: (key: string, box: ResizeSize & Partial<ResizePosition>, policy: ResizePolicy, contentMin: ResizeContentMin, opts?: {
101
144
  shiftKey?: boolean;
102
- axis?: StackedCardResizeAxis;
103
- }) => StackedCardSize | null;
145
+ axis?: ResizeAxis;
146
+ anchor?: ResizeAnchor;
147
+ }) => ResizeBox | null;
104
148
  /**
105
149
  * The handle's `aria-valuenow`: the current size as a percent (0–100) of its
106
150
  * allowed range. The corner resizes both axes, but the value must be a single
107
151
  * number, so it reports the WIDTH axis — the one axis the fixed-box and the
108
152
  * width-only cards share. Returns 0 when the range isn't finite (no max bound).
109
153
  */
110
- export declare const measurePercent: (size: StackedCardSize, policy: StackedCardResizePolicy, contentMin: StackedCardContentMin) => number;
154
+ export declare const measurePercent: (size: ResizeSize, policy: ResizePolicy, contentMin: ResizeContentMin) => number;
155
+ export {};
111
156
  //# sourceMappingURL=resizePolicy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resizePolicy.d.ts","sourceRoot":"","sources":["../../../../src/components/StackedCard/resizePolicy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,MAAM,WAAW,eAAe;IAC9B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,oEAAoE;AACpE,MAAM,WAAW,qBAAqB;IACpC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,uBAAuB;IACtC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mDAAmD;IACnD,YAAY,EAAE,OAAO,CAAC;IACtB,+DAA+D;IAC/D,IAAI,CAAC,EAAE,MAAM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A,CAAC;AAE5D,eAAO,MAAM,IAAI,GAAI,GAAG,MAAM,EAAE,OAAO,MAAM,KAAG,MACI,CAAC;AAErD,eAAO,MAAM,SAAS,GACpB,KAAK,UAAU,GAAG,OAAO,CAAC,cAAc,CAAC,EACzC,YAAY,gBAAgB,KAC3B,WAMD,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAC1B,QAAQ,YAAY,EACpB,YAAY,gBAAgB,KAC3B,YAKD,CAAC;AAUH,KAAK,QAAQ,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAE3B;;;;GAIG;AACH,eAAO,MAAM,WAAW,GACtB,QAAQ,YAAY,KACnB;IAAE,EAAE,EAAE,QAAQ,CAAC;IAAC,EAAE,EAAE,QAAQ,CAAA;CAG7B,CAAC;AA6BH;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,WAAW,GACtB,OAAO,WAAW,EAClB,OAAO,WAAW,EAClB,QAAQ,YAAY,EACpB,OAAM,aAAkB,KACvB,SAqFF,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,GACzB,KAAK,MAAM,EACX,KAAK,UAAU,GAAG,OAAO,CAAC,cAAc,CAAC,EACzC,QAAQ,YAAY,EACpB,YAAY,gBAAgB,EAC5B,OAAM;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,UAAU,CAAC;IAAC,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,KAC1E,SAAS,GAAG,IAyDd,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GACzB,MAAM,UAAU,EAChB,QAAQ,YAAY,EACpB,YAAY,gBAAgB,KAC3B,MAIF,CAAC"}
@@ -1,14 +1,16 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  /**
3
- * StackedCard resize policy — pure math.
3
+ * Resize policy — pure math, shared by every resizable element.
4
4
  *
5
- * The card reports intent; the HOST applies a resize policy (spec §7). This
6
- * module is that policy, packaged as pure functions so the SAME code path
7
- * serves the pointer drag and the keyboard resize. Nothing here touches the
8
- * DOM, React or the card's content: it takes a start size, a delta and a
9
- * policy, and returns a clamped size. `useStackedCardResize` wires events to
10
- * it; the card's intrinsic content minimum is measured by the host and passed
11
- * in as `contentMin`, so this module knows nothing about heroes or footers.
5
+ * The element reports intent; the HOST applies a resize policy (StackedCard
6
+ * spec §7). This module is that policy, packaged as pure functions so the SAME
7
+ * code path serves the pointer drag and the keyboard resize, a card's single
8
+ * bottom-right grip and a shape's eight handles. Nothing here touches the DOM,
9
+ * React or the element's content: it takes a start box, a delta, a policy and
10
+ * the handle being dragged, and returns a clamped box — size AND position.
11
+ * `useStackedCardResize` wires events to it; an element's intrinsic content
12
+ * minimum is measured by the host and passed in as `contentMin`, so this module
13
+ * knows nothing about heroes or footers.
12
14
  *
13
15
  * The policy has four parts:
14
16
  * - bounds — optional min/max per axis; unset means unbounded.
@@ -17,12 +19,34 @@ import _extends from "@babel/runtime/helpers/esm/extends";
17
19
  * distorts at a bound.
18
20
  * - step — optional grid snap; proportion wins over the grid.
19
21
  * - content min — the effective min is max(policyMin, contentMin) per axis,
20
- * so a card can never be crushed below what its content needs.
22
+ * so an element can never be crushed below what its content
23
+ * needs.
24
+ *
25
+ * The anchor is the handle being dragged. The edge or corner OPPOSITE to it
26
+ * never moves — not while the pointer travels, and not when a bound stops the
27
+ * resize — which is what makes a resize feel like a resize rather than a nudge.
28
+ * A `left` handle moves the position by exactly the amount the width grew; a
29
+ * `right` handle leaves it alone. An edge handle touches one axis only.
21
30
  */
22
31
 
23
- /** The card's intrinsic minimum, measured from its real content. */
32
+ /** A resized element: its size and where its top-left corner now sits. */
24
33
 
25
- /** The size captured at the start of a gesture (pointer down or a key press). */
34
+ /** The element's intrinsic minimum, measured from its real content. */
35
+
36
+ /**
37
+ * The handle being dragged, named after the edge or corner it sits on. The
38
+ * opposite edge or corner is held in place.
39
+ */
40
+
41
+ export const RESIZE_ANCHORS = ["top-left", "top", "top-right", "right", "bottom-right", "bottom", "bottom-left", "left"];
42
+
43
+ /** A card's single grip: the top-left corner stays put. */
44
+ export const DEFAULT_RESIZE_ANCHOR = "bottom-right";
45
+
46
+ /**
47
+ * The box captured at the start of a gesture (pointer down or a key press).
48
+ * A host that only tracks a size leaves the position at the origin.
49
+ */
26
50
 
27
51
  /**
28
52
  * `width` locks the vertical axis: an auto-height card takes a width and lets
@@ -42,11 +66,16 @@ export const RESIZE_KEYS = ["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "
42
66
  export const isResizeKey = key => RESIZE_KEYS.includes(key);
43
67
  export const clamp = (v, lo, hi) => Math.min(hi != null ? hi : Number.POSITIVE_INFINITY, Math.max(lo, v));
44
68
  export const snap = (v, step) => step && step > 0 ? Math.round(v / step) * step : v;
45
- export const makeStart = (size, contentMin) => ({
46
- w: size.w,
47
- h: size.h,
48
- contentMin
49
- });
69
+ export const makeStart = (box, contentMin) => {
70
+ var _box$x, _box$y;
71
+ return {
72
+ w: box.w,
73
+ h: box.h,
74
+ x: (_box$x = box.x) != null ? _box$x : 0,
75
+ y: (_box$y = box.y) != null ? _box$y : 0,
76
+ contentMin
77
+ };
78
+ };
50
79
 
51
80
  /**
52
81
  * The effective bounds a size is clamped to: the policy min floored by the
@@ -69,18 +98,44 @@ export const effectiveBounds = (policy, contentMin) => {
69
98
  * an axis nobody gave a minimum must not collapse to nothing.
70
99
  */
71
100
  const hasFloor = (policyMin, contentMin) => policyMin !== undefined || contentMin > 0;
101
+ /**
102
+ * Which way each axis grows for a handle: +1 when the handle is on the far
103
+ * edge (right/bottom), −1 when it is on the near edge (left/top), 0 when the
104
+ * handle does not touch that axis at all.
105
+ */
106
+ export const anchorSigns = anchor => ({
107
+ sx: anchor.includes("left") ? -1 : anchor.includes("right") ? 1 : 0,
108
+ sy: anchor.includes("top") ? -1 : anchor.includes("bottom") ? 1 : 0
109
+ });
72
110
 
73
111
  /**
74
- * Apply a delta to the start size under the policy — the single path for both
75
- * inputs.
112
+ * Snap the MOVING edge of one axis to the grid and return the length that
113
+ * leaves the anchored edge exactly where it was. A far-edge handle snaps
114
+ * `origin + length`; a near-edge handle snaps `origin + startLength − length`.
115
+ * With no step this is the identity.
116
+ */
117
+ const snapMovingEdge = (origin, startLength, length, sign, step) => {
118
+ if (!step || sign === 0) return length;
119
+ return sign > 0 ? snap(origin + length, step) - origin : origin + startLength - snap(origin + startLength - length, step);
120
+ };
121
+
122
+ /** The position that keeps the anchored edge of one axis in place. */
123
+ const anchoredOrigin = (origin, startLength, length, sign) => sign < 0 ? origin + startLength - length : origin;
124
+
125
+ /**
126
+ * Apply a delta to the start box under the policy — the single path for both
127
+ * inputs and for every handle.
76
128
  *
77
129
  * `constrain` is the transient Shift-to-constrain lock: a free-form policy
78
130
  * behaves proportionally for that one gesture; a proportional policy is already
79
131
  * locked and ignores it. `axis: "width"` drops the gesture's vertical component;
80
132
  * the height then holds still in free-form mode, and still follows the ratio in
81
- * proportional mode (that is what proportional means).
133
+ * proportional mode (that is what proportional means). `anchor` is the handle
134
+ * being dragged: the opposite edge or corner is held, so the returned position
135
+ * moves only when a near-edge handle (left/top) grew or shrank the box.
82
136
  */
83
137
  export const applyResize = function (start, delta, policy, opts) {
138
+ var _opts$anchor;
84
139
  if (opts === void 0) {
85
140
  opts = {};
86
141
  }
@@ -90,8 +145,12 @@ export const applyResize = function (start, delta, policy, opts) {
90
145
  wMax = _effectiveBounds.wMax,
91
146
  hMax = _effectiveBounds.hMax;
92
147
  const widthOnly = opts.axis === "width";
93
- const dx = delta.dx;
94
- const dy = widthOnly ? 0 : delta.dy;
148
+ const _anchorSigns = anchorSigns((_opts$anchor = opts.anchor) != null ? _opts$anchor : DEFAULT_RESIZE_ANCHOR),
149
+ sx = _anchorSigns.sx,
150
+ anchorSy = _anchorSigns.sy;
151
+ const sy = widthOnly ? 0 : anchorSy;
152
+ const dx = sx * delta.dx;
153
+ const dy = sy * delta.dy;
95
154
 
96
155
  // A ratio needs two non-zero sides to be a ratio at all; a width-only card
97
156
  // parks a placeholder height, so fall back to free-form rather than dividing
@@ -101,69 +160,95 @@ export const applyResize = function (start, delta, policy, opts) {
101
160
  let h;
102
161
  if (proportional) {
103
162
  // one scale drives both axes; the corner's dominant direction wins, so a
104
- // vertical drag is as effective as a horizontal one
105
- const sW = (start.w + dx) / start.w;
106
- const sH = (start.h + dy) / start.h;
107
- let scale = Math.abs(sW - 1) >= Math.abs(sH - 1) ? sW : sH;
108
-
109
- // step: proportion wins over the grid. Snap through the SCALE (driven off
110
- // the width edge) so both axes move together and the ratio survives; the
111
- // grid yields whenever honouring it would cost the ratio.
163
+ // vertical drag is as effective as a horizontal one. An edge handle has
164
+ // only its own axis to drive with.
165
+ const sW = sx === 0 ? 1 : (start.w + dx) / start.w;
166
+ const sH = sy === 0 ? 1 : (start.h + dy) / start.h;
167
+ const drivenByWidth = sx !== 0 && (sy === 0 || Math.abs(sW - 1) >= Math.abs(sH - 1));
168
+ let scale = drivenByWidth ? sW : sH;
169
+
170
+ // step: proportion wins over the grid. Snap through the SCALE, driven off
171
+ // the moving edge of the driving axis, so both axes move together and the
172
+ // ratio survives; the grid yields whenever honouring it would cost the
173
+ // ratio.
112
174
  if (policy.step) {
113
- scale = snap(start.w * scale, policy.step) / start.w;
175
+ 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;
114
176
  }
115
177
 
116
178
  // Then clamp the scale so both axes stay in bounds (the binding constraint):
117
179
  // the ratio can never break at a bound — whichever edge is limiting stops
118
- // both. The clamp comes last on purpose: a bound is a hard stop, so the card
119
- // sits exactly on it rather than at the nearest grid line inside it.
180
+ // both. The clamp comes last on purpose: a bound is a hard stop, so the
181
+ // element sits exactly on it rather than at the nearest grid line inside it.
120
182
  const scaleMin = Math.max(wMin / start.w, hMin / start.h);
121
183
  const scaleMax = Math.min(wMax / start.w, hMax / start.h);
122
184
  scale = clamp(scale, scaleMin, Math.max(scaleMin, scaleMax));
123
185
  w = start.w * scale;
124
186
  h = start.h * scale;
125
187
  } else {
126
- w = clamp(snap(start.w + dx, policy.step), wMin, wMax);
127
- h = widthOnly ? start.h : clamp(snap(start.h + dy, policy.step), hMin, hMax);
188
+ // An axis the handle does not touch holds its start value exactly — it is
189
+ // neither snapped nor clamped, because nothing about it changed.
190
+ w = sx === 0 ? start.w : clamp(snapMovingEdge(start.x, start.w, start.w + dx, sx, policy.step), wMin, wMax);
191
+ h = sy === 0 ? start.h : clamp(snapMovingEdge(start.y, start.h, start.h + dy, sy, policy.step), hMin, hMax);
128
192
  }
193
+
194
+ // Round the size first and derive the position from the rounded size, so
195
+ // the anchored edge lands on exactly the coordinate it started at.
196
+ w = Math.round(w);
197
+ h = Math.round(h);
129
198
  return {
130
- w: Math.round(w),
131
- h: Math.round(h)
199
+ w,
200
+ h,
201
+ x: anchoredOrigin(start.x, start.w, w, sx),
202
+ y: anchoredOrigin(start.y, start.h, h, sy)
132
203
  };
133
204
  };
134
205
 
135
206
  /**
136
- * Translate a resize key into the next size, reusing `applyResize` so the
137
- * keyboard clamps exactly like the pointer. Arrows nudge by the step (Shift ×4);
138
- * Home/End jump to the min/max of the allowed range, leaving any axis without
139
- * that bound where it is. Returns null for a key the handle does not own, and
140
- * for a vertical key on a width-only card.
207
+ * Translate a resize key into the next box, reusing `applyResize` so the
208
+ * keyboard clamps exactly like the pointer. Arrows move the HANDLE by the step
209
+ * (Shift ×4) — so on a left handle ArrowLeft grows the element and ArrowRight
210
+ * shrinks it — and Home/End jump the handle to the min/max of the allowed
211
+ * range, leaving any axis without that bound where it is. Returns null for a
212
+ * key the handle does not own: a key on an axis the handle does not touch, or a
213
+ * vertical key on a width-only card.
141
214
  */
142
- export const keyboardResize = function (key, size, policy, contentMin, opts) {
215
+ export const keyboardResize = function (key, box, policy, contentMin, opts) {
216
+ var _opts$anchor2;
143
217
  if (opts === void 0) {
144
218
  opts = {};
145
219
  }
146
220
  const widthOnly = opts.axis === "width";
147
- if (widthOnly && (key === "ArrowUp" || key === "ArrowDown")) return null;
221
+ const anchor = (_opts$anchor2 = opts.anchor) != null ? _opts$anchor2 : DEFAULT_RESIZE_ANCHOR;
222
+ const _anchorSigns2 = anchorSigns(anchor),
223
+ sx = _anchorSigns2.sx,
224
+ anchorSy = _anchorSigns2.sy;
225
+ const sy = widthOnly ? 0 : anchorSy;
226
+ const horizontalKey = key === "ArrowLeft" || key === "ArrowRight";
227
+ const verticalKey = key === "ArrowUp" || key === "ArrowDown";
228
+ if (horizontalKey && sx === 0 || verticalKey && sy === 0) return null;
148
229
  const base = policy.step && policy.step > 0 ? policy.step : DEFAULT_KEYBOARD_STEP;
149
230
  const step = base * (opts.shiftKey ? SHIFT_STEP_MULTIPLIER : 1);
150
- const start = makeStart(size, contentMin);
231
+ const start = makeStart(box, contentMin);
151
232
  const b = effectiveBounds(policy, contentMin);
152
- const apply = delta => applyResize(start, delta, policy, {
153
- axis: opts.axis
154
- });
233
+ const resizeOpts = {
234
+ axis: opts.axis,
235
+ anchor
236
+ };
237
+ const apply = delta => applyResize(start, delta, policy, resizeOpts);
155
238
 
156
239
  /**
157
240
  * Home and End are absolute jumps to a bound, not nudges, so they ignore the
158
241
  * grid: landing 4px off the minimum because that is where the nearest grid
159
242
  * line fell would mean the keyboard could never reach the bound the pointer
160
- * stops at.
243
+ * stops at. The jump is expressed as handle travel, so a near-edge handle
244
+ * moves the opposite way to reach the same size.
161
245
  */
162
- const jump = delta => applyResize(start, delta, _extends({}, policy, {
246
+ const jump = (growW, growH) => applyResize(start, {
247
+ dx: sx * growW,
248
+ dy: sy * growH
249
+ }, _extends({}, policy, {
163
250
  step: 0
164
- }), {
165
- axis: opts.axis
166
- });
251
+ }), resizeOpts);
167
252
  switch (key) {
168
253
  case "ArrowRight":
169
254
  return apply({
@@ -187,16 +272,10 @@ export const keyboardResize = function (key, size, policy, contentMin, opts) {
187
272
  });
188
273
  case "Home":
189
274
  // jump to the min corner; an axis with no floor of its own stays put
190
- return jump({
191
- dx: hasFloor(policy.minW, contentMin.w) ? b.wMin - size.w : 0,
192
- dy: !widthOnly && hasFloor(policy.minH, contentMin.h) ? b.hMin - size.h : 0
193
- });
275
+ 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);
194
276
  case "End":
195
277
  // jump to the max corner; an unbounded axis simply doesn't move
196
- return jump({
197
- dx: Number.isFinite(b.wMax) ? b.wMax - size.w : 0,
198
- dy: !widthOnly && Number.isFinite(b.hMax) ? b.hMax - size.h : 0
199
- });
278
+ return jump(sx !== 0 && Number.isFinite(b.wMax) ? b.wMax - box.w : 0, sy !== 0 && Number.isFinite(b.hMax) ? b.hMax - box.h : 0);
200
279
  default:
201
280
  return null;
202
281
  }