@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.
- 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/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/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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StackedCard.js","names":["_react","_interopRequireWildcard","require","_classnames","_interopRequireDefault","_constants","_Glyphs","_resizePolicy","_Styles","_excluded","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_extends","assign","bind","arguments","length","apply","_objectWithoutProperties","_objectWithoutPropertiesLoose","getOwnPropertySymbols","indexOf","propertyIsEnumerable","StackedCard","exports","React","forwardRef","_ref","ref","selected","disabled","pending","isDragSource","isDragPreview","entered","forceHover","resizable","_ref$resizeAxis","resizeAxis","_ref$resizeLabel","resizeLabel","priorityColor","onResizeStart","onResizeDelta","onResizeCommit","resizeHandleProps","className","children","rest","gesture","useRef","emitDelta","useCallback","dx","dy","g","current","moved","source","endGesture","handlePointerDown","_setPointerCapture","_ref2","x","clientX","y","clientY","target","setPointerCapture","pointerId","preventDefault","handlePointerMove","handleKeyDown","step","DEFAULT_KEYBOARD_STEP","shiftKey","SHIFT_STEP_MULTIPLIER","key","handleKeyUp","isResizeKey","createElement","StyledStackedCard","$selected","$disabled","$pending","$isDragSource","$isDragPreview","$entered","$forceHover","$priorityColor","classnames","StyledStackedCardResizeHandle","$axis","STACKED_CARD_CONTROL_CLASS","role","tabIndex","onPointerDown","onPointerMove","onPointerUp","onLostPointerCapture","onKeyDown","onKeyUp","StackedCardResizeHandleGlyph","displayName"],"sources":["../../../../src/components/StackedCard/StackedCard.tsx"],"sourcesContent":["import React, { ReactElement, ReactNode, useCallback, useRef } from \"react\";\n\nimport classnames from \"classnames\";\n\nimport { STACKED_CARD_CONTROL_CLASS } from \"./constants\";\nimport { StackedCardResizeHandleGlyph } from \"./Glyphs\";\nimport {\n DEFAULT_KEYBOARD_STEP,\n SHIFT_STEP_MULTIPLIER,\n StackedCardResizeAxis,\n StackedCardResizeSource,\n isResizeKey,\n} from \"./resizePolicy\";\nimport { StyledStackedCard, StyledStackedCardResizeHandle } from \"./Styles\";\n\n/**\n * StackedCard — the hollow shell for cards on drag-and-drop surfaces.\n *\n * This is NOT the base for cards in lists. It is the card for surfaces where\n * dragging is a primary interaction: column boards and canvases. Content is\n * laid out top to bottom in `StackedCardRow`s, which makes every card a\n * portrait presentation of its data.\n *\n * ── The rule the whole subsystem hangs on ──────────────────────────────────\n * THE SHELL STAYS HOLLOW. There is no `contentType` enum here, no per-type\n * prop soup, no `if task …`. The shell owns only VISUAL STATES (selected,\n * disabled, pending, priority, drag source/preview, entered) and one intent\n * callback (`onResizeDelta`). Content is passed as `children` and composes the\n * layout primitives. Typed cards — an ImageCard, a LinkCard, a TaskCard — are\n * facades built on top of it in the consuming app, and adding one requires\n * ZERO changes in this file.\n *\n * ── What the shell does NOT do ────────────────────────────────────────────\n * It implements no drag-and-drop, no selection bookkeeping, no resize policy\n * and no keyboard navigation. The card reports; the host decides. Drag\n * choreography (the drag layer, the landing indicator, the drop) belongs to\n * the host surface, which then feeds the result back as `isDragSource` /\n * `isDragPreview`. The shell forwards its ref and spreads DOM props, so a host\n * can attach `tabIndex`, ARIA, pointer and keyboard handlers to it.\n *\n * ── Resize ────────────────────────────────────────────────────────────────\n * The grip is opt-in (`resizable`) and reports intent as a gesture: one\n * `onResizeStart`, a stream of `onResizeDelta` previews measured FROM THE\n * GESTURE START, and one `onResizeCommit` at the end — and only if the gesture\n * moved anything. A host applies previews for live feedback and records an undo\n * entry on the commit alone (spec §7e).\n *\n * Because the deltas are gesture-relative rather than incremental, a host can\n * resolve every event against the size it snapshotted on start, and never has\n * to keep a running accumulator. That is what makes a slow, few-pixels-at-a-time\n * drag keep growing instead of stalling under a snap step.\n *\n * The grip itself is a focusable `role=\"separator\"` and handles arrow keys\n * (Shift for a coarse nudge). For the full policy — bounds, proportional mode,\n * step snapping, content minimums, Home/End and the live `aria-valuenow` — use\n * `useStackedCardResize` and spread its result through `resizeHandleProps`;\n * those handlers then own the grip and the three callbacks above stay quiet.\n *\n * ── Theming ───────────────────────────────────────────────────────────────\n * Colours resolve through `--sc-*` custom properties with built-in fallbacks:\n * `--sc-selection-ring` (selection / focus / entered) and the cover scrim\n * family `--sc-scrim`, `--sc-scrim-strong`, `--sc-scrim-fg`. Declare any of\n * them on an ancestor to retint a whole surface.\n */\n\nexport interface IStackedCardProps\n extends Omit<React.HTMLAttributes<HTMLDivElement>, \"onResize\"> {\n /** Host-owned selection state — a ring around the card. */\n selected?: boolean;\n /** Policy state: the card cannot be acted on. Dimmed, inert. */\n disabled?: boolean;\n /**\n * Optimistic in-flight state — created or moved, not yet confirmed. Dimmed,\n * non-interactive and not draggable, but distinct from `disabled`: it is\n * transient, not a policy.\n */\n pending?: boolean;\n /**\n * The full-size outline placeholder left behind in the source position while\n * a drag is in flight. Content is hidden but keeps its box, so neighbouring\n * cards never move.\n */\n isDragSource?: boolean;\n /**\n * The 1:1 copy the host floats in its drag layer. Elevated shadow only — no\n * tilt, no scale, no translate.\n */\n isDragPreview?: boolean;\n /** Focus model: the card has been entered and focus is on an inner control. */\n entered?: boolean;\n /** Pin the hover treatment on, including revealed controls. For docs and specs. */\n forceHover?: boolean;\n /** Show the bottom-right resize grip. Opt-in, off by default. */\n resizable?: boolean;\n /**\n * Which axes the grip offers, as a cursor: `width` reads as a horizontal\n * handle for an auto-height card. Purely the affordance — what a delta means\n * is still the host's call. Defaults to `both`.\n */\n resizeAxis?: StackedCardResizeAxis;\n /** Accessible name for the resize grip. Defaults to \"Resize card\". */\n resizeLabel?: string;\n /**\n * Draws the emphasis border down the left edge. A data colour, passed in by\n * the caller (high priority, a label colour) — never baked into the shell.\n */\n priorityColor?: string;\n /** Fired once when a resize gesture begins, before the first delta. */\n onResizeStart?: (source: StackedCardResizeSource) => void;\n /**\n * Fired throughout a resize gesture with the delta measured FROM THE GESTURE\n * START — not from the previous event. The card reports; the host decides what\n * a delta means. Previews are live feedback, never an undoable change.\n */\n onResizeDelta?: (\n dx: number,\n dy: number,\n source: StackedCardResizeSource\n ) => void;\n /**\n * Fired once when the gesture ends (pointer up, lost pointer capture, key up),\n * and only if it moved the card. A bare click on the grip is not a change.\n */\n onResizeCommit?: (source: StackedCardResizeSource) => void;\n /**\n * Props spread onto the grip, overriding the built-in behaviour entirely —\n * this is where `useStackedCardResize`'s return value goes when a host wants\n * the full policy instead of raw deltas.\n */\n resizeHandleProps?: React.HTMLAttributes<HTMLSpanElement>;\n children: ReactNode;\n}\n\nexport const StackedCard = React.forwardRef<HTMLDivElement, IStackedCardProps>(\n (\n {\n selected,\n disabled,\n pending,\n isDragSource,\n isDragPreview,\n entered,\n forceHover,\n resizable,\n resizeAxis = \"both\",\n resizeLabel = \"Resize card\",\n priorityColor,\n onResizeStart,\n onResizeDelta,\n onResizeCommit,\n resizeHandleProps,\n className,\n children,\n ...rest\n },\n ref\n ): ReactElement => {\n /**\n * One live gesture. `x`/`y` anchor a pointer drag; `dx`/`dy` carry the\n * running total a keyboard gesture has nudged. `moved` gates the commit, so\n * a click that never travelled is not a change.\n */\n const gesture = useRef<{\n source: StackedCardResizeSource;\n x: number;\n y: number;\n dx: number;\n dy: number;\n moved: boolean;\n } | null>(null);\n\n const emitDelta = useCallback(\n (dx: number, dy: number) => {\n const g = gesture.current;\n if (!g) return;\n if (dx !== 0 || dy !== 0) g.moved = true;\n onResizeDelta?.(dx, dy, g.source);\n },\n [onResizeDelta]\n );\n\n const endGesture = useCallback(() => {\n const g = gesture.current;\n if (!g) return;\n gesture.current = null;\n if (g.moved) onResizeCommit?.(g.source);\n }, [onResizeCommit]);\n\n const handlePointerDown = useCallback(\n (e: React.PointerEvent) => {\n gesture.current = {\n source: \"pointer\",\n x: e.clientX,\n y: e.clientY,\n dx: 0,\n dy: 0,\n moved: false,\n };\n (e.target as HTMLElement).setPointerCapture?.(e.pointerId);\n e.preventDefault();\n onResizeStart?.(\"pointer\");\n },\n [onResizeStart]\n );\n\n const handlePointerMove = useCallback(\n (e: React.PointerEvent) => {\n const g = gesture.current;\n if (!g || g.source !== \"pointer\") return;\n // Measured from the gesture start, so the host resolves every event\n // against one snapshot instead of accumulating.\n emitDelta(e.clientX - g.x, e.clientY - g.y);\n },\n [emitDelta]\n );\n\n /**\n * Arrows nudge the running total; Shift makes it coarse. Home and End need\n * bounds to resolve, which the bare shell does not have — they fall through\n * to `useStackedCardResize`, or to the browser.\n */\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent) => {\n const step =\n DEFAULT_KEYBOARD_STEP * (e.shiftKey ? SHIFT_STEP_MULTIPLIER : 1);\n let dx = 0;\n let dy = 0;\n\n if (e.key === \"ArrowRight\") dx = step;\n else if (e.key === \"ArrowLeft\") dx = -step;\n else if (e.key === \"ArrowDown\") dy = step;\n else if (e.key === \"ArrowUp\") dy = -step;\n else return;\n\n e.preventDefault();\n if (!gesture.current || gesture.current.source !== \"keyboard\") {\n gesture.current = {\n source: \"keyboard\",\n x: 0,\n y: 0,\n dx: 0,\n dy: 0,\n moved: false,\n };\n onResizeStart?.(\"keyboard\");\n }\n const g = gesture.current;\n g.dx += dx;\n g.dy += dy;\n emitDelta(g.dx, g.dy);\n },\n [emitDelta, onResizeStart]\n );\n\n const handleKeyUp = useCallback(\n (e: React.KeyboardEvent) => {\n // One commit per hold, mirroring pointer-up after a stream of moves.\n if (isResizeKey(e.key)) endGesture();\n },\n [endGesture]\n );\n\n return (\n <StyledStackedCard\n ref={ref}\n $selected={selected}\n $disabled={disabled}\n $pending={pending}\n $isDragSource={isDragSource}\n $isDragPreview={isDragPreview}\n $entered={entered}\n $forceHover={forceHover}\n $priorityColor={priorityColor}\n className={classnames(\"c-stacked-card\", className)}\n {...rest}\n >\n {children}\n {resizable ? (\n <StyledStackedCardResizeHandle\n $axis={resizeAxis}\n className={classnames(\n \"c-stacked-card__resize-handle\",\n STACKED_CARD_CONTROL_CLASS\n )}\n role=\"separator\"\n tabIndex={0}\n aria-label={resizeLabel}\n onPointerDown={handlePointerDown}\n onPointerMove={handlePointerMove}\n onPointerUp={endGesture}\n onLostPointerCapture={endGesture}\n onKeyDown={handleKeyDown}\n onKeyUp={handleKeyUp}\n {...resizeHandleProps}\n >\n <Stacked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;EAAE,GAC/CE,IAAI,GAEPD,QAAQ,EACRX,SAAS,gBACRtD,MAAA,CAAAY,OAAA,CAAAsF,aAAA,CAAC1F,OAAA,CAAAqG,6BAA6B,EAAA/E,QAAA;IAC5BgF,KAAK,EAAEtD,UAAW;IAClBQ,SAAS,EAAE,IAAA4C,mBAAU,EACnB,+BAA+B,EAC/BG,qCACF,CAAE;IACFC,IAAI,EAAC,WAAW;IAChBC,QAAQ,EAAE,CAAE;IACZ,cAAYvD,WAAY;IACxBwD,aAAa,EAAEpC,iBAAkB;IACjCqC,aAAa,EAAE1B,iBAAkB;IACjC2B,WAAW,EAAEvC,UAAW;IACxBwC,oBAAoB,EAAExC,UAAW;IACjCyC,SAAS,EAAE5B,aAAc;IACzB6B,OAAO,EAAEvB;EAAY,GACjBjC,iBAAiB,gBAErB/D,MAAA,CAAAY,OAAA,CAAAsF,aAAA,CAAC5F,OAAA,CAAAkH,4BAA4B,MAAE,CACF,CAAC,GAC9B,IACa,CAAC;AAExB,CACF,CAAC;AAED/E,WAAW,CAACgF,WAAW,GAAG,aAAa","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"StackedCard.js","names":["_react","_interopRequireWildcard","require","_classnames","_interopRequireDefault","_constants","_Glyphs","_resizePolicy","_Styles","_excluded","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_extends","assign","bind","arguments","length","apply","_objectWithoutProperties","_objectWithoutPropertiesLoose","getOwnPropertySymbols","indexOf","propertyIsEnumerable","StackedCard","exports","React","forwardRef","_ref","ref","selected","disabled","pending","isDragSource","isDragPreview","entered","forceHover","resizable","_ref$resizeAxis","resizeAxis","_ref$resizeLabel","resizeLabel","priorityColor","onResizeStart","onResizeDelta","onResizeCommit","resizeHandleProps","className","children","rest","gesture","useRef","emitDelta","useCallback","dx","dy","g","current","moved","source","endGesture","handlePointerDown","_setPointerCapture","_ref2","x","clientX","y","clientY","target","setPointerCapture","pointerId","preventDefault","handlePointerMove","handleKeyDown","step","DEFAULT_KEYBOARD_STEP","shiftKey","SHIFT_STEP_MULTIPLIER","key","handleKeyUp","isResizeKey","createElement","StyledStackedCard","$selected","$disabled","$pending","$isDragSource","$isDragPreview","$entered","$forceHover","$priorityColor","classnames","StyledStackedCardResizeHandle","$axis","STACKED_CARD_CONTROL_CLASS","role","tabIndex","onPointerDown","onPointerMove","onPointerUp","onLostPointerCapture","onKeyDown","onKeyUp","StackedCardResizeHandleGlyph","displayName"],"sources":["../../../../src/components/StackedCard/StackedCard.tsx"],"sourcesContent":["import React, { ReactElement, ReactNode, useCallback, useRef } from \"react\";\n\nimport classnames from \"classnames\";\n\nimport { STACKED_CARD_CONTROL_CLASS } from \"./constants\";\nimport { StackedCardResizeHandleGlyph } from \"./Glyphs\";\nimport {\n DEFAULT_KEYBOARD_STEP,\n SHIFT_STEP_MULTIPLIER,\n ResizeAxis,\n ResizeSource,\n isResizeKey,\n} from \"./resizePolicy\";\nimport { StyledStackedCard, StyledStackedCardResizeHandle } from \"./Styles\";\n\n/**\n * StackedCard — the hollow shell for cards on drag-and-drop surfaces.\n *\n * This is NOT the base for cards in lists. It is the card for surfaces where\n * dragging is a primary interaction: column boards and canvases. Content is\n * laid out top to bottom in `StackedCardRow`s, which makes every card a\n * portrait presentation of its data.\n *\n * ── The rule the whole subsystem hangs on ──────────────────────────────────\n * THE SHELL STAYS HOLLOW. There is no `contentType` enum here, no per-type\n * prop soup, no `if task …`. The shell owns only VISUAL STATES (selected,\n * disabled, pending, priority, drag source/preview, entered) and one intent\n * callback (`onResizeDelta`). Content is passed as `children` and composes the\n * layout primitives. Typed cards — an ImageCard, a LinkCard, a TaskCard — are\n * facades built on top of it in the consuming app, and adding one requires\n * ZERO changes in this file.\n *\n * ── What the shell does NOT do ────────────────────────────────────────────\n * It implements no drag-and-drop, no selection bookkeeping, no resize policy\n * and no keyboard navigation. The card reports; the host decides. Drag\n * choreography (the drag layer, the landing indicator, the drop) belongs to\n * the host surface, which then feeds the result back as `isDragSource` /\n * `isDragPreview`. The shell forwards its ref and spreads DOM props, so a host\n * can attach `tabIndex`, ARIA, pointer and keyboard handlers to it.\n *\n * ── Resize ────────────────────────────────────────────────────────────────\n * The grip is opt-in (`resizable`) and reports intent as a gesture: one\n * `onResizeStart`, a stream of `onResizeDelta` previews measured FROM THE\n * GESTURE START, and one `onResizeCommit` at the end — and only if the gesture\n * moved anything. A host applies previews for live feedback and records an undo\n * entry on the commit alone (spec §7e).\n *\n * Because the deltas are gesture-relative rather than incremental, a host can\n * resolve every event against the size it snapshotted on start, and never has\n * to keep a running accumulator. That is what makes a slow, few-pixels-at-a-time\n * drag keep growing instead of stalling under a snap step.\n *\n * The grip itself is a focusable `role=\"separator\"` and handles arrow keys\n * (Shift for a coarse nudge). For the full policy — bounds, proportional mode,\n * step snapping, content minimums, Home/End and the live `aria-valuenow` — use\n * `useStackedCardResize` and spread its result through `resizeHandleProps`;\n * those handlers then own the grip and the three callbacks above stay quiet.\n *\n * ── Theming ───────────────────────────────────────────────────────────────\n * Colours resolve through `--sc-*` custom properties with built-in fallbacks:\n * `--sc-selection-ring` (selection / focus / entered) and the cover scrim\n * family `--sc-scrim`, `--sc-scrim-strong`, `--sc-scrim-fg`. Declare any of\n * them on an ancestor to retint a whole surface.\n */\n\nexport interface IStackedCardProps\n extends Omit<React.HTMLAttributes<HTMLDivElement>, \"onResize\"> {\n /** Host-owned selection state — a ring around the card. */\n selected?: boolean;\n /** Policy state: the card cannot be acted on. Dimmed, inert. */\n disabled?: boolean;\n /**\n * Optimistic in-flight state — created or moved, not yet confirmed. Dimmed,\n * non-interactive and not draggable, but distinct from `disabled`: it is\n * transient, not a policy.\n */\n pending?: boolean;\n /**\n * The full-size outline placeholder left behind in the source position while\n * a drag is in flight. Content is hidden but keeps its box, so neighbouring\n * cards never move.\n */\n isDragSource?: boolean;\n /**\n * The 1:1 copy the host floats in its drag layer. Elevated shadow only — no\n * tilt, no scale, no translate.\n */\n isDragPreview?: boolean;\n /** Focus model: the card has been entered and focus is on an inner control. */\n entered?: boolean;\n /** Pin the hover treatment on, including revealed controls. For docs and specs. */\n forceHover?: boolean;\n /** Show the bottom-right resize grip. Opt-in, off by default. */\n resizable?: boolean;\n /**\n * Which axes the grip offers, as a cursor: `width` reads as a horizontal\n * handle for an auto-height card. Purely the affordance — what a delta means\n * is still the host's call. Defaults to `both`.\n */\n resizeAxis?: ResizeAxis;\n /** Accessible name for the resize grip. Defaults to \"Resize card\". */\n resizeLabel?: string;\n /**\n * Draws the emphasis border down the left edge. A data colour, passed in by\n * the caller (high priority, a label colour) — never baked into the shell.\n */\n priorityColor?: string;\n /** Fired once when a resize gesture begins, before the first delta. */\n onResizeStart?: (source: ResizeSource) => void;\n /**\n * Fired throughout a resize gesture with the delta measured FROM THE GESTURE\n * START — not from the previous event. The card reports; the host decides what\n * a delta means. Previews are live feedback, never an undoable change.\n */\n onResizeDelta?: (dx: number, dy: number, source: ResizeSource) => void;\n /**\n * Fired once when the gesture ends (pointer up, lost pointer capture, key up),\n * and only if it moved the card. A bare click on the grip is not a change.\n */\n onResizeCommit?: (source: ResizeSource) => void;\n /**\n * Props spread onto the grip, overriding the built-in behaviour entirely —\n * this is where `useStackedCardResize`'s return value goes when a host wants\n * the full policy instead of raw deltas.\n */\n resizeHandleProps?: React.HTMLAttributes<HTMLSpanElement>;\n children: ReactNode;\n}\n\nexport const StackedCard = React.forwardRef<HTMLDivElement, IStackedCardProps>(\n (\n {\n selected,\n disabled,\n pending,\n isDragSource,\n isDragPreview,\n entered,\n forceHover,\n resizable,\n resizeAxis = \"both\",\n resizeLabel = \"Resize card\",\n priorityColor,\n onResizeStart,\n onResizeDelta,\n onResizeCommit,\n resizeHandleProps,\n className,\n children,\n ...rest\n },\n ref\n ): ReactElement => {\n /**\n * One live gesture. `x`/`y` anchor a pointer drag; `dx`/`dy` carry the\n * running total a keyboard gesture has nudged. `moved` gates the commit, so\n * a click that never travelled is not a change.\n */\n const gesture = useRef<{\n source: ResizeSource;\n x: number;\n y: number;\n dx: number;\n dy: number;\n moved: boolean;\n } | null>(null);\n\n const emitDelta = useCallback(\n (dx: number, dy: number) => {\n const g = gesture.current;\n if (!g) return;\n if (dx !== 0 || dy !== 0) g.moved = true;\n onResizeDelta?.(dx, dy, g.source);\n },\n [onResizeDelta]\n );\n\n const endGesture = useCallback(() => {\n const g = gesture.current;\n if (!g) return;\n gesture.current = null;\n if (g.moved) onResizeCommit?.(g.source);\n }, [onResizeCommit]);\n\n const handlePointerDown = useCallback(\n (e: React.PointerEvent) => {\n gesture.current = {\n source: \"pointer\",\n x: e.clientX,\n y: e.clientY,\n dx: 0,\n dy: 0,\n moved: false,\n };\n (e.target as HTMLElement).setPointerCapture?.(e.pointerId);\n e.preventDefault();\n onResizeStart?.(\"pointer\");\n },\n [onResizeStart]\n );\n\n const handlePointerMove = useCallback(\n (e: React.PointerEvent) => {\n const g = gesture.current;\n if (!g || g.source !== \"pointer\") return;\n // Measured from the gesture start, so the host resolves every event\n // against one snapshot instead of accumulating.\n emitDelta(e.clientX - g.x, e.clientY - g.y);\n },\n [emitDelta]\n );\n\n /**\n * Arrows nudge the running total; Shift makes it coarse. Home and End need\n * bounds to resolve, which the bare shell does not have — they fall through\n * to `useStackedCardResize`, or to the browser.\n */\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent) => {\n const step =\n DEFAULT_KEYBOARD_STEP * (e.shiftKey ? SHIFT_STEP_MULTIPLIER : 1);\n let dx = 0;\n let dy = 0;\n\n if (e.key === \"ArrowRight\") dx = step;\n else if (e.key === \"ArrowLeft\") dx = -step;\n else if (e.key === \"ArrowDown\") dy = step;\n else if (e.key === \"ArrowUp\") dy = -step;\n else return;\n\n e.preventDefault();\n if (!gesture.current || gesture.current.source !== \"keyboard\") {\n gesture.current = {\n source: \"keyboard\",\n x: 0,\n y: 0,\n dx: 0,\n dy: 0,\n moved: false,\n };\n onResizeStart?.(\"keyboard\");\n }\n const g = gesture.current;\n g.dx += dx;\n g.dy += dy;\n emitDelta(g.dx, g.dy);\n },\n [emitDelta, onResizeStart]\n );\n\n const handleKeyUp = useCallback(\n (e: React.KeyboardEvent) => {\n // One commit per hold, mirroring pointer-up after a stream of moves.\n if (isResizeKey(e.key)) endGesture();\n },\n [endGesture]\n );\n\n return (\n <StyledStackedCard\n ref={ref}\n $selected={selected}\n $disabled={disabled}\n $pending={pending}\n $isDragSource={isDragSource}\n $isDragPreview={isDragPreview}\n $entered={entered}\n $forceHover={forceHover}\n $priorityColor={priorityColor}\n className={classnames(\"c-stacked-card\", className)}\n {...rest}\n >\n {children}\n {resizable ? (\n <StyledStackedCardResizeHandle\n $axis={resizeAxis}\n className={classnames(\n \"c-stacked-card__resize-handle\",\n STACKED_CARD_CONTROL_CLASS\n )}\n role=\"separator\"\n tabIndex={0}\n aria-label={resizeLabel}\n onPointerDown={handlePointerDown}\n onPointerMove={handlePointerMove}\n onPointerUp={endGesture}\n onLostPointerCapture={endGesture}\n onKeyDown={handleKeyDown}\n onKeyUp={handleKeyUp}\n {...resizeHandleProps}\n >\n <StackedCardResizeHandleGlyph />\n </StyledStackedCardResizeHandle>\n ) : null}\n </StyledStackedCard>\n );\n }\n);\n\nStackedCard.displayName = \"StackedCard\";\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AAOA,IAAAM,OAAA,GAAAN,OAAA;AAA4E,IAAAO,SAAA;AAAA,SAAAL,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAT,wBAAAS,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA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,CAAAkH,4BAA4B,MAAE,CACF,CAAC,GAC9B,IACa,CAAC;AAExB,CACF,CAAC;AAED/E,WAAW,CAACgF,WAAW,GAAG,aAAa","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Styles.js","names":["_styledComponents","_interopRequireWildcard","require","_constants","_BoxSizingStyle","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","SELECTION_RING","SCRIM","SCRIM_STRONG","SCRIM_FG","CONTROL","concat","STACKED_CARD_CONTROL_CLASS","revealControls","css","StyledStackedCardStack","exports","styled","div","withConfig","displayName","componentId","BoxSizingStyle","StyledStackedCardRow","_ref","$direction","_ref2","_ref3","_ref4","$role","$bleed","STACKED_CARD_ROLE_PADDING","_ref5","$background","_ref6","STACKED_CARD_FIXED_ATTR","StyledStackedCardCoverMedia","_ref7","$aspectRatio","StyledStackedCardCoverFill","StyledStackedCardCoverCenter","StyledStackedCardCoverTopRight","StyledStackedCardCollapsedStrip","button","StyledStackedCardStripExpand","span","StyledStackedCardPlayBadge","StyledStackedCardCoverButton","StyledStackedCardResizeHandle","_ref8","$axis","hoverStyle","StyledStackedCard","STACKED_CARD_WIDTH","STACKED_CARD_RADIUS","_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,IAAAA,iBAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AAUA,IAAAE,eAAA,GAAAF,OAAA;AAAmD,SAAAD,wBAAAI,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAN,uBAAA,YAAAA,wBAAAI,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,cAAAM,EAAA,IAAAd,CAAA,gBAAAc,EAAA,OAAAC,cAAA,CAAAC,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,GAAAD,MAAA,CAARC,QAAQ;EAAA,OACXA,QAAQ,QACRlD,qBAAG,uDAIF;AAAA,GAKD,UAAAmD,MAAA;EAAA,IAAGC,aAAa,GAAAD,MAAA,CAAbC,aAAa;EAAA,OAChBA,aAAa,QACbpD,qBAAG,2KAaF;AAAA,GAID,UAAAqD,MAAA;EAAA,IAAGC,cAAc,GAAAD,MAAA,CAAdC,cAAc;EAAA,OACjBA,cAAc,QACdtD,qBAAG,+DAGF;AAAA,GAGD,UAAAuD,MAAA;EAAA,IAAGC,QAAQ,GAAAD,MAAA,CAARC,QAAQ;EAAA,OACXA,QAAQ,QACRxD,qBAAG,6EAEiBR,cAAc,EACAA,cAAc,EAC9BA,cAAc,CAE/B;AAAA,EACJ;AACD8C,iBAAiB,CAAChC,WAAW,GAAG,mBAAmB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Styles.js","names":["_styledComponents","_interopRequireWildcard","require","_constants","_BoxSizingStyle","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","SELECTION_RING","SCRIM","SCRIM_STRONG","SCRIM_FG","CONTROL","concat","STACKED_CARD_CONTROL_CLASS","revealControls","css","StyledStackedCardStack","exports","styled","div","withConfig","displayName","componentId","BoxSizingStyle","StyledStackedCardRow","_ref","$direction","_ref2","_ref3","_ref4","$role","$bleed","STACKED_CARD_ROLE_PADDING","_ref5","$background","_ref6","STACKED_CARD_FIXED_ATTR","StyledStackedCardCoverMedia","_ref7","$aspectRatio","StyledStackedCardCoverFill","StyledStackedCardCoverCenter","StyledStackedCardCoverTopRight","StyledStackedCardCollapsedStrip","button","StyledStackedCardStripExpand","span","StyledStackedCardPlayBadge","StyledStackedCardCoverButton","StyledStackedCardResizeHandle","_ref8","$axis","hoverStyle","StyledStackedCard","STACKED_CARD_WIDTH","STACKED_CARD_RADIUS","_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,IAAAA,iBAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AAUA,IAAAE,eAAA,GAAAF,OAAA;AAAmD,SAAAD,wBAAAI,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAN,uBAAA,YAAAA,wBAAAI,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,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AAA,CAAdC,cAAc;EAAA,OACjBA,cAAc,QACd5C,qBAAG,4GAQe4C,cAAc,CAG/B;AAAA,GAMD,UAAAC,KAAA;EAAA,IAAGC,SAAS,GAAAD,KAAA,CAATC,SAAS;EAAA,OACZA,SAAS,QACT9C,qBAAG,wDAEiBR,cAAc,EACNA,cAAc,CAEzC;AAAA,GAED,UAAAuD,MAAA;EAAA,IAAGC,SAAS,GAAAD,MAAA,CAATC,SAAS;EAAA,OACZA,SAAS,QACThD,qBAAG,uCAGF;AAAA,GAKD,UAAAiD,MAAA;EAAA,IAAGC,QAAQ,GAAAD,MAAA,CAARC,QAAQ;EAAA,OACXA,QAAQ,QACRlD,qBAAG,uDAIF;AAAA,GAKD,UAAAmD,MAAA;EAAA,IAAGC,aAAa,GAAAD,MAAA,CAAbC,aAAa;EAAA,OAChBA,aAAa,QACbpD,qBAAG,2KAaF;AAAA,GAID,UAAAqD,MAAA;EAAA,IAAGC,cAAc,GAAAD,MAAA,CAAdC,cAAc;EAAA,OACjBA,cAAc,QACdtD,qBAAG,+DAGF;AAAA,GAGD,UAAAuD,MAAA;EAAA,IAAGC,QAAQ,GAAAD,MAAA,CAARC,QAAQ;EAAA,OACXA,QAAQ,QACRxD,qBAAG,6EAEiBR,cAAc,EACAA,cAAc,EAC9BA,cAAc,CAE/B;AAAA,EACJ;AACD8C,iBAAiB,CAAChC,WAAW,GAAG,mBAAmB","ignoreList":[]}
|
|
@@ -3,22 +3,24 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.snap = exports.measurePercent = exports.makeStart = exports.keyboardResize = exports.isResizeKey = exports.effectiveBounds = exports.clamp = exports.applyResize = exports.SHIFT_STEP_MULTIPLIER = exports.RESIZE_KEYS = exports.DEFAULT_KEYBOARD_STEP = void 0;
|
|
6
|
+
exports.snap = exports.measurePercent = exports.makeStart = exports.keyboardResize = exports.isResizeKey = exports.effectiveBounds = exports.clamp = exports.applyResize = exports.anchorSigns = exports.SHIFT_STEP_MULTIPLIER = exports.RESIZE_KEYS = exports.RESIZE_ANCHORS = exports.DEFAULT_RESIZE_ANCHOR = exports.DEFAULT_KEYBOARD_STEP = void 0;
|
|
7
7
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
8
8
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
9
9
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
10
10
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
11
11
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Resize policy — pure math, shared by every resizable element.
|
|
14
14
|
*
|
|
15
|
-
* The
|
|
16
|
-
* module is that policy, packaged as pure functions so the SAME
|
|
17
|
-
* serves the pointer drag and the keyboard resize
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
15
|
+
* The element reports intent; the HOST applies a resize policy (StackedCard
|
|
16
|
+
* spec §7). This module is that policy, packaged as pure functions so the SAME
|
|
17
|
+
* code path serves the pointer drag and the keyboard resize, a card's single
|
|
18
|
+
* bottom-right grip and a shape's eight handles. Nothing here touches the DOM,
|
|
19
|
+
* React or the element's content: it takes a start box, a delta, a policy and
|
|
20
|
+
* the handle being dragged, and returns a clamped box — size AND position.
|
|
21
|
+
* `useStackedCardResize` wires events to it; an element's intrinsic content
|
|
22
|
+
* minimum is measured by the host and passed in as `contentMin`, so this module
|
|
23
|
+
* knows nothing about heroes or footers.
|
|
22
24
|
*
|
|
23
25
|
* The policy has four parts:
|
|
24
26
|
* - bounds — optional min/max per axis; unset means unbounded.
|
|
@@ -27,12 +29,34 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
27
29
|
* distorts at a bound.
|
|
28
30
|
* - step — optional grid snap; proportion wins over the grid.
|
|
29
31
|
* - content min — the effective min is max(policyMin, contentMin) per axis,
|
|
30
|
-
* so
|
|
32
|
+
* so an element can never be crushed below what its content
|
|
33
|
+
* needs.
|
|
34
|
+
*
|
|
35
|
+
* The anchor is the handle being dragged. The edge or corner OPPOSITE to it
|
|
36
|
+
* never moves — not while the pointer travels, and not when a bound stops the
|
|
37
|
+
* resize — which is what makes a resize feel like a resize rather than a nudge.
|
|
38
|
+
* A `left` handle moves the position by exactly the amount the width grew; a
|
|
39
|
+
* `right` handle leaves it alone. An edge handle touches one axis only.
|
|
31
40
|
*/
|
|
32
41
|
|
|
33
|
-
/**
|
|
42
|
+
/** A resized element: its size and where its top-left corner now sits. */
|
|
34
43
|
|
|
35
|
-
/** The
|
|
44
|
+
/** The element's intrinsic minimum, measured from its real content. */
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The handle being dragged, named after the edge or corner it sits on. The
|
|
48
|
+
* opposite edge or corner is held in place.
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
var RESIZE_ANCHORS = exports.RESIZE_ANCHORS = ["top-left", "top", "top-right", "right", "bottom-right", "bottom", "bottom-left", "left"];
|
|
52
|
+
|
|
53
|
+
/** A card's single grip: the top-left corner stays put. */
|
|
54
|
+
var DEFAULT_RESIZE_ANCHOR = exports.DEFAULT_RESIZE_ANCHOR = "bottom-right";
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The box captured at the start of a gesture (pointer down or a key press).
|
|
58
|
+
* A host that only tracks a size leaves the position at the origin.
|
|
59
|
+
*/
|
|
36
60
|
|
|
37
61
|
/**
|
|
38
62
|
* `width` locks the vertical axis: an auto-height card takes a width and lets
|
|
@@ -58,10 +82,13 @@ var clamp = exports.clamp = function clamp(v, lo, hi) {
|
|
|
58
82
|
var snap = exports.snap = function snap(v, step) {
|
|
59
83
|
return step && step > 0 ? Math.round(v / step) * step : v;
|
|
60
84
|
};
|
|
61
|
-
var makeStart = exports.makeStart = function makeStart(
|
|
85
|
+
var makeStart = exports.makeStart = function makeStart(box, contentMin) {
|
|
86
|
+
var _box$x, _box$y;
|
|
62
87
|
return {
|
|
63
|
-
w:
|
|
64
|
-
h:
|
|
88
|
+
w: box.w,
|
|
89
|
+
h: box.h,
|
|
90
|
+
x: (_box$x = box.x) !== null && _box$x !== void 0 ? _box$x : 0,
|
|
91
|
+
y: (_box$y = box.y) !== null && _box$y !== void 0 ? _box$y : 0,
|
|
65
92
|
contentMin
|
|
66
93
|
};
|
|
67
94
|
};
|
|
@@ -89,18 +116,48 @@ var effectiveBounds = exports.effectiveBounds = function effectiveBounds(policy,
|
|
|
89
116
|
var hasFloor = function hasFloor(policyMin, contentMin) {
|
|
90
117
|
return policyMin !== undefined || contentMin > 0;
|
|
91
118
|
};
|
|
119
|
+
/**
|
|
120
|
+
* Which way each axis grows for a handle: +1 when the handle is on the far
|
|
121
|
+
* edge (right/bottom), −1 when it is on the near edge (left/top), 0 when the
|
|
122
|
+
* handle does not touch that axis at all.
|
|
123
|
+
*/
|
|
124
|
+
var anchorSigns = exports.anchorSigns = function anchorSigns(anchor) {
|
|
125
|
+
return {
|
|
126
|
+
sx: anchor.includes("left") ? -1 : anchor.includes("right") ? 1 : 0,
|
|
127
|
+
sy: anchor.includes("top") ? -1 : anchor.includes("bottom") ? 1 : 0
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Snap the MOVING edge of one axis to the grid and return the length that
|
|
133
|
+
* leaves the anchored edge exactly where it was. A far-edge handle snaps
|
|
134
|
+
* `origin + length`; a near-edge handle snaps `origin + startLength − length`.
|
|
135
|
+
* With no step this is the identity.
|
|
136
|
+
*/
|
|
137
|
+
var snapMovingEdge = function snapMovingEdge(origin, startLength, length, sign, step) {
|
|
138
|
+
if (!step || sign === 0) return length;
|
|
139
|
+
return sign > 0 ? snap(origin + length, step) - origin : origin + startLength - snap(origin + startLength - length, step);
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
/** The position that keeps the anchored edge of one axis in place. */
|
|
143
|
+
var anchoredOrigin = function anchoredOrigin(origin, startLength, length, sign) {
|
|
144
|
+
return sign < 0 ? origin + startLength - length : origin;
|
|
145
|
+
};
|
|
92
146
|
|
|
93
147
|
/**
|
|
94
|
-
* Apply a delta to the start
|
|
95
|
-
* inputs.
|
|
148
|
+
* Apply a delta to the start box under the policy — the single path for both
|
|
149
|
+
* inputs and for every handle.
|
|
96
150
|
*
|
|
97
151
|
* `constrain` is the transient Shift-to-constrain lock: a free-form policy
|
|
98
152
|
* behaves proportionally for that one gesture; a proportional policy is already
|
|
99
153
|
* locked and ignores it. `axis: "width"` drops the gesture's vertical component;
|
|
100
154
|
* the height then holds still in free-form mode, and still follows the ratio in
|
|
101
|
-
* proportional mode (that is what proportional means).
|
|
155
|
+
* proportional mode (that is what proportional means). `anchor` is the handle
|
|
156
|
+
* being dragged: the opposite edge or corner is held, so the returned position
|
|
157
|
+
* moves only when a near-edge handle (left/top) grew or shrank the box.
|
|
102
158
|
*/
|
|
103
159
|
var applyResize = exports.applyResize = function applyResize(start, delta, policy) {
|
|
160
|
+
var _opts$anchor;
|
|
104
161
|
var opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
105
162
|
var _effectiveBounds = effectiveBounds(policy, start.contentMin),
|
|
106
163
|
wMin = _effectiveBounds.wMin,
|
|
@@ -108,8 +165,12 @@ var applyResize = exports.applyResize = function applyResize(start, delta, polic
|
|
|
108
165
|
wMax = _effectiveBounds.wMax,
|
|
109
166
|
hMax = _effectiveBounds.hMax;
|
|
110
167
|
var widthOnly = opts.axis === "width";
|
|
111
|
-
var
|
|
112
|
-
|
|
168
|
+
var _anchorSigns = anchorSigns((_opts$anchor = opts.anchor) !== null && _opts$anchor !== void 0 ? _opts$anchor : DEFAULT_RESIZE_ANCHOR),
|
|
169
|
+
sx = _anchorSigns.sx,
|
|
170
|
+
anchorSy = _anchorSigns.sy;
|
|
171
|
+
var sy = widthOnly ? 0 : anchorSy;
|
|
172
|
+
var dx = sx * delta.dx;
|
|
173
|
+
var dy = sy * delta.dy;
|
|
113
174
|
|
|
114
175
|
// A ratio needs two non-zero sides to be a ratio at all; a width-only card
|
|
115
176
|
// parks a placeholder height, so fall back to free-form rather than dividing
|
|
@@ -119,70 +180,96 @@ var applyResize = exports.applyResize = function applyResize(start, delta, polic
|
|
|
119
180
|
var h;
|
|
120
181
|
if (proportional) {
|
|
121
182
|
// one scale drives both axes; the corner's dominant direction wins, so a
|
|
122
|
-
// vertical drag is as effective as a horizontal one
|
|
123
|
-
|
|
124
|
-
var
|
|
125
|
-
var
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
//
|
|
183
|
+
// vertical drag is as effective as a horizontal one. An edge handle has
|
|
184
|
+
// only its own axis to drive with.
|
|
185
|
+
var sW = sx === 0 ? 1 : (start.w + dx) / start.w;
|
|
186
|
+
var sH = sy === 0 ? 1 : (start.h + dy) / start.h;
|
|
187
|
+
var drivenByWidth = sx !== 0 && (sy === 0 || Math.abs(sW - 1) >= Math.abs(sH - 1));
|
|
188
|
+
var scale = drivenByWidth ? sW : sH;
|
|
189
|
+
|
|
190
|
+
// step: proportion wins over the grid. Snap through the SCALE, driven off
|
|
191
|
+
// the moving edge of the driving axis, so both axes move together and the
|
|
192
|
+
// ratio survives; the grid yields whenever honouring it would cost the
|
|
193
|
+
// ratio.
|
|
130
194
|
if (policy.step) {
|
|
131
|
-
scale =
|
|
195
|
+
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;
|
|
132
196
|
}
|
|
133
197
|
|
|
134
198
|
// Then clamp the scale so both axes stay in bounds (the binding constraint):
|
|
135
199
|
// the ratio can never break at a bound — whichever edge is limiting stops
|
|
136
|
-
// both. The clamp comes last on purpose: a bound is a hard stop, so the
|
|
137
|
-
// sits exactly on it rather than at the nearest grid line inside it.
|
|
200
|
+
// both. The clamp comes last on purpose: a bound is a hard stop, so the
|
|
201
|
+
// element sits exactly on it rather than at the nearest grid line inside it.
|
|
138
202
|
var scaleMin = Math.max(wMin / start.w, hMin / start.h);
|
|
139
203
|
var scaleMax = Math.min(wMax / start.w, hMax / start.h);
|
|
140
204
|
scale = clamp(scale, scaleMin, Math.max(scaleMin, scaleMax));
|
|
141
205
|
w = start.w * scale;
|
|
142
206
|
h = start.h * scale;
|
|
143
207
|
} else {
|
|
144
|
-
|
|
145
|
-
|
|
208
|
+
// An axis the handle does not touch holds its start value exactly — it is
|
|
209
|
+
// neither snapped nor clamped, because nothing about it changed.
|
|
210
|
+
w = sx === 0 ? start.w : clamp(snapMovingEdge(start.x, start.w, start.w + dx, sx, policy.step), wMin, wMax);
|
|
211
|
+
h = sy === 0 ? start.h : clamp(snapMovingEdge(start.y, start.h, start.h + dy, sy, policy.step), hMin, hMax);
|
|
146
212
|
}
|
|
213
|
+
|
|
214
|
+
// Round the size first and derive the position from the rounded size, so
|
|
215
|
+
// the anchored edge lands on exactly the coordinate it started at.
|
|
216
|
+
w = Math.round(w);
|
|
217
|
+
h = Math.round(h);
|
|
147
218
|
return {
|
|
148
|
-
w
|
|
149
|
-
h
|
|
219
|
+
w,
|
|
220
|
+
h,
|
|
221
|
+
x: anchoredOrigin(start.x, start.w, w, sx),
|
|
222
|
+
y: anchoredOrigin(start.y, start.h, h, sy)
|
|
150
223
|
};
|
|
151
224
|
};
|
|
152
225
|
|
|
153
226
|
/**
|
|
154
|
-
* Translate a resize key into the next
|
|
155
|
-
* keyboard clamps exactly like the pointer. Arrows
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
227
|
+
* Translate a resize key into the next box, reusing `applyResize` so the
|
|
228
|
+
* keyboard clamps exactly like the pointer. Arrows move the HANDLE by the step
|
|
229
|
+
* (Shift ×4) — so on a left handle ArrowLeft grows the element and ArrowRight
|
|
230
|
+
* shrinks it — and Home/End jump the handle to the min/max of the allowed
|
|
231
|
+
* range, leaving any axis without that bound where it is. Returns null for a
|
|
232
|
+
* key the handle does not own: a key on an axis the handle does not touch, or a
|
|
233
|
+
* vertical key on a width-only card.
|
|
159
234
|
*/
|
|
160
|
-
var keyboardResize = exports.keyboardResize = function keyboardResize(key,
|
|
235
|
+
var keyboardResize = exports.keyboardResize = function keyboardResize(key, box, policy, contentMin) {
|
|
236
|
+
var _opts$anchor2;
|
|
161
237
|
var opts = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
162
238
|
var widthOnly = opts.axis === "width";
|
|
163
|
-
|
|
239
|
+
var anchor = (_opts$anchor2 = opts.anchor) !== null && _opts$anchor2 !== void 0 ? _opts$anchor2 : DEFAULT_RESIZE_ANCHOR;
|
|
240
|
+
var _anchorSigns2 = anchorSigns(anchor),
|
|
241
|
+
sx = _anchorSigns2.sx,
|
|
242
|
+
anchorSy = _anchorSigns2.sy;
|
|
243
|
+
var sy = widthOnly ? 0 : anchorSy;
|
|
244
|
+
var horizontalKey = key === "ArrowLeft" || key === "ArrowRight";
|
|
245
|
+
var verticalKey = key === "ArrowUp" || key === "ArrowDown";
|
|
246
|
+
if (horizontalKey && sx === 0 || verticalKey && sy === 0) return null;
|
|
164
247
|
var base = policy.step && policy.step > 0 ? policy.step : DEFAULT_KEYBOARD_STEP;
|
|
165
248
|
var step = base * (opts.shiftKey ? SHIFT_STEP_MULTIPLIER : 1);
|
|
166
|
-
var start = makeStart(
|
|
249
|
+
var start = makeStart(box, contentMin);
|
|
167
250
|
var b = effectiveBounds(policy, contentMin);
|
|
251
|
+
var resizeOpts = {
|
|
252
|
+
axis: opts.axis,
|
|
253
|
+
anchor
|
|
254
|
+
};
|
|
168
255
|
var apply = function apply(delta) {
|
|
169
|
-
return applyResize(start, delta, policy,
|
|
170
|
-
axis: opts.axis
|
|
171
|
-
});
|
|
256
|
+
return applyResize(start, delta, policy, resizeOpts);
|
|
172
257
|
};
|
|
173
258
|
|
|
174
259
|
/**
|
|
175
260
|
* Home and End are absolute jumps to a bound, not nudges, so they ignore the
|
|
176
261
|
* grid: landing 4px off the minimum because that is where the nearest grid
|
|
177
262
|
* line fell would mean the keyboard could never reach the bound the pointer
|
|
178
|
-
* stops at.
|
|
263
|
+
* stops at. The jump is expressed as handle travel, so a near-edge handle
|
|
264
|
+
* moves the opposite way to reach the same size.
|
|
179
265
|
*/
|
|
180
|
-
var jump = function jump(
|
|
181
|
-
return applyResize(start,
|
|
266
|
+
var jump = function jump(growW, growH) {
|
|
267
|
+
return applyResize(start, {
|
|
268
|
+
dx: sx * growW,
|
|
269
|
+
dy: sy * growH
|
|
270
|
+
}, _objectSpread(_objectSpread({}, policy), {}, {
|
|
182
271
|
step: 0
|
|
183
|
-
}),
|
|
184
|
-
axis: opts.axis
|
|
185
|
-
});
|
|
272
|
+
}), resizeOpts);
|
|
186
273
|
};
|
|
187
274
|
switch (key) {
|
|
188
275
|
case "ArrowRight":
|
|
@@ -207,16 +294,10 @@ var keyboardResize = exports.keyboardResize = function keyboardResize(key, size,
|
|
|
207
294
|
});
|
|
208
295
|
case "Home":
|
|
209
296
|
// jump to the min corner; an axis with no floor of its own stays put
|
|
210
|
-
return jump(
|
|
211
|
-
dx: hasFloor(policy.minW, contentMin.w) ? b.wMin - size.w : 0,
|
|
212
|
-
dy: !widthOnly && hasFloor(policy.minH, contentMin.h) ? b.hMin - size.h : 0
|
|
213
|
-
});
|
|
297
|
+
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);
|
|
214
298
|
case "End":
|
|
215
299
|
// jump to the max corner; an unbounded axis simply doesn't move
|
|
216
|
-
return jump(
|
|
217
|
-
dx: Number.isFinite(b.wMax) ? b.wMax - size.w : 0,
|
|
218
|
-
dy: !widthOnly && Number.isFinite(b.hMax) ? b.hMax - size.h : 0
|
|
219
|
-
});
|
|
300
|
+
return jump(sx !== 0 && Number.isFinite(b.wMax) ? b.wMax - box.w : 0, sy !== 0 && Number.isFinite(b.hMax) ? b.hMax - box.h : 0);
|
|
220
301
|
default:
|
|
221
302
|
return null;
|
|
222
303
|
}
|