@kumix/ui 0.7.0 → 0.8.0
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/README.md +3 -2
- package/dist/components/agents/ai-sidebar/resource-row.js +1 -1
- package/dist/components/agents/ai-sidebar.js +1 -1
- package/dist/components/agents/approval-card.js +1 -1
- package/dist/components/agents/code-block.js +1 -1
- package/dist/components/agents/context-meter.js +1 -1
- package/dist/components/agents/file-diff.js +1 -1
- package/dist/components/agents/message-scroller.js +1 -1
- package/dist/components/agents/prompt-input.js +1 -1
- package/dist/components/agents/streaming-response.js +1 -1
- package/dist/components/agents/tool-result.js +1 -1
- package/dist/components/agents/voice-note.js +1 -1
- package/dist/components/charts/bar-chart/context.d.ts +3 -3
- package/dist/components/charts/bar-chart/tooltip.js +1 -1
- package/dist/components/charts/bump-chart/context.d.ts +1 -1
- package/dist/components/charts/bump-chart/point.js +1 -1
- package/dist/components/charts/bump-chart/series.d.ts +1 -1
- package/dist/components/charts/bump-chart.d.ts +1 -1
- package/dist/components/charts/candlestick-chart/context.d.ts +3 -3
- package/dist/components/charts/composition-chart/context.d.ts +1 -1
- package/dist/components/charts/composition-chart/plot.js +1 -1
- package/dist/components/charts/composition-chart.d.ts +1 -1
- package/dist/components/charts/funnel-chart.js +1 -1
- package/dist/components/charts/heat-calendar/tooltip.d.ts +1 -1
- package/dist/components/charts/heat-calendar/tooltip.js +1 -1
- package/dist/components/charts/heat-calendar.d.ts +1 -1
- package/dist/components/charts/liquidity-heatmap.js +1 -1
- package/dist/components/charts/order-book.d.ts +1 -1
- package/dist/components/charts/price-target-fan/tooltip.js +1 -1
- package/dist/components/charts/returns-calendar/tooltip.js +1 -1
- package/dist/components/charts/sankey-chart/tooltip.js +1 -1
- package/dist/components/charts/status-bar/tooltip.d.ts +1 -1
- package/dist/components/charts/status-bar/tooltip.js +1 -1
- package/dist/components/charts/status-bar.d.ts +1 -1
- package/dist/components/charts/treemap/tooltip.js +1 -1
- package/dist/components/charts/treemap.d.ts +1 -1
- package/dist/components/charts/volume-profile/tooltip.js +1 -1
- package/dist/components/charts/volume-profile.d.ts +1 -1
- package/dist/components/motion/animated-toast-stack/toast-body.js +1 -1
- package/dist/components/motion/attachment-upload/image-thumbnail.js +1 -1
- package/dist/components/motion/attachment-upload/row-action.js +1 -1
- package/dist/components/motion/availability-scheduler/copy-menu.js +1 -1
- package/dist/components/motion/availability-scheduler/day-row.js +2 -2
- package/dist/components/motion/availability-scheduler.js +1 -1
- package/dist/components/motion/avatar-group.js +1 -1
- package/dist/components/motion/casino/game-parts.js +1 -1
- package/dist/components/motion/center-morph-modal.js +1 -1
- package/dist/components/motion/combobox/trigger.d.ts.map +1 -1
- package/dist/components/motion/combobox/trigger.js +7 -2
- package/dist/components/motion/combobox/trigger.js.map +1 -1
- package/dist/components/motion/date-range-picker/header.js +1 -1
- package/dist/components/motion/file-upload.js +1 -1
- package/dist/components/motion/knockout-bracket.js +1 -1
- package/dist/components/motion/knockout-wheel.js +1 -1
- package/dist/components/motion/mines.js +1 -1
- package/dist/components/motion/plinko.js +1 -1
- package/dist/components/motion/prediction-market-card.js +1 -1
- package/dist/components/motion/qr-code.d.ts +42 -0
- package/dist/components/motion/qr-code.d.ts.map +1 -0
- package/dist/components/motion/qr-code.js +443 -0
- package/dist/components/motion/qr-code.js.map +1 -0
- package/dist/components/motion/swap/controls.js +1 -1
- package/dist/components/motion/tooltip.d.ts +2 -2
- package/dist/components/motion/tooltip.d.ts.map +1 -1
- package/dist/components/motion/tooltip.js +1 -1
- package/dist/components/reui/alert.d.ts +1 -1
- package/dist/components/reui/badge.d.ts +1 -1
- package/dist/components/reui/icon-tile.d.ts +1 -1
- package/dist/components/ui/attachment.d.ts +2 -2
- package/dist/components/ui/button-group.d.ts +1 -1
- package/dist/components/ui/button.d.ts +1 -1
- package/dist/components/ui/empty.d.ts +1 -1
- package/dist/components/ui/field.d.ts +1 -1
- package/dist/components/ui/item.d.ts +1 -1
- package/dist/{context-DMIy-rFm.d.ts → context-Cyjsttyl.d.ts} +4 -4
- package/dist/{context-DMIy-rFm.d.ts.map → context-Cyjsttyl.d.ts.map} +1 -1
- package/dist/{context-jX-r_7EP.d.ts → context-D7eAawR3.d.ts} +4 -4
- package/dist/{context-jX-r_7EP.d.ts.map → context-D7eAawR3.d.ts.map} +1 -1
- package/dist/{copy-menu-Bgoo5oWq.js → copy-menu-Di77fZ9p.js} +2 -2
- package/dist/{copy-menu-Bgoo5oWq.js.map → copy-menu-Di77fZ9p.js.map} +1 -1
- package/dist/hooks/use-dismiss.d.ts +9 -1
- package/dist/hooks/use-dismiss.d.ts.map +1 -1
- package/dist/hooks/use-dismiss.js +6 -3
- package/dist/hooks/use-dismiss.js.map +1 -1
- package/dist/lib/layers.d.ts +1 -1
- package/dist/lib/layers.js.map +1 -1
- package/dist/{resource-row-PkgPS9Hk.js → resource-row-DByzjie0.js} +2 -2
- package/dist/{resource-row-PkgPS9Hk.js.map → resource-row-DByzjie0.js.map} +1 -1
- package/dist/{tooltip-X7sMXf98.d.ts → tooltip-CwsBzl7m.d.ts} +2 -2
- package/dist/{tooltip-X7sMXf98.d.ts.map → tooltip-CwsBzl7m.d.ts.map} +1 -1
- package/dist/{tooltip-gKOUHp_1.d.ts → tooltip-TdY1OH4j.d.ts} +2 -2
- package/dist/{tooltip-gKOUHp_1.d.ts.map → tooltip-TdY1OH4j.d.ts.map} +1 -1
- package/dist/{tooltip-gHv-6eOs.js → tooltip-eecPhLtC.js} +54 -7
- package/dist/tooltip-eecPhLtC.js.map +1 -0
- package/package.json +11 -6
- package/dist/tooltip-gHv-6eOs.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qr-code.js","names":[],"sources":["../../../src/components/motion/qr-code.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useLayoutEffect, useMemo, useRef } from \"react\";\nimport { useReducedMotion } from \"motion/react\";\nimport { encode } from \"uqr\";\n\nimport { cn } from \"@kumix/utils\";\nimport { useMessages } from \"../../lib/i18n\";\n\nexport type QrCodeVariant = \"swarm\" | \"ripple\" | \"scan\" | \"smoke\";\n\nexport const qrCodeMessages = {\n label: \"QR code for {value}\",\n};\n\nexport type QrCodeMessages = typeof qrCodeMessages;\n\nexport interface QrCodeOrigin {\n /** Horizontal position as a fraction of the canvas width, 0 is the left edge. */\n x: number;\n /** Vertical position as a fraction of the canvas height, 0 is the top edge. */\n y: number;\n}\n\nexport interface AnimatedQrCodeProps {\n /** Text or URL the code encodes. */\n value: string;\n /** Whether the code is drawn. Turning it on builds the code; turning it off plays the build backwards from wherever it is. */\n shown: boolean;\n /** How the code builds: every piece flies in on a curved path, pops in place behind a spreading ring, drops into place behind a bar sweeping down, or rises as smoke and condenses from the bottom row up. Default: \"swarm\" */\n variant?: QrCodeVariant;\n /** Side of the square canvas, in px, quiet zone included. Default: 296 */\n size?: number;\n /** Where swarm pieces fly from and where the ripple ring starts. Scan and smoke ignore it. Default: bottom centre for swarm, centre for ripple */\n origin?: QrCodeOrigin;\n /** Dot colour, any CSS colour. Default: \"#0a0a0a\" */\n ink?: string;\n /** Background colour, any CSS colour. Keep it light so cameras can read the code. Default: \"#ffffff\" */\n paper?: string;\n /** Called when a build or teardown finishes, with the `shown` value it ended on. */\n onSettled?: (shown: boolean) => void;\n /** Translated strings, merged over the English defaults. */\n labels?: Partial<QrCodeMessages>;\n /** Classes merged onto the canvas. */\n className?: string;\n}\n\n/** Empty modules kept around the code on every side. */\nconst QUIET = 2;\n/** Gap between the first and the last piece starting, in ms. */\nconst SPREAD = 600;\n/** One piece's own arrival, in ms. */\nconst PIECE_IN = 500;\nconst TOTAL = SPREAD + PIECE_IN;\n/** Taking the code down runs this much faster than building it. */\nconst EXIT_RATE = 1.6;\n/** Time constant for the clock turning around after a press mid-run, in ms. */\nconst TURN_MS = 90;\n/** Reduced motion keeps only an opacity fade of this length, in ms. */\nconst REDUCED_MS = 200;\n/** Random offset added to each swarm piece's start, in ms, so the order is not mechanical. */\nconst JITTER = 70;\n/** How far a swarm path bows outward, as a share of its length; each piece adds up to BEND_SPREAD more. */\nconst BEND = 0.14;\nconst BEND_SPREAD = 0.12;\n/** Extra length of a piece at top speed on the longest flight, as a share of its size. Width shrinks to keep its area. */\nconst STRETCH = 1.3;\n/** Share of that stretch an eye takes. */\nconst EYE_STRETCH = 0.2;\n/** How far a scan piece drops into place, in modules. */\nconst DROP = 1.6;\n/** Height of the soft trail behind the scan bar, in px. */\nconst SCAN_TRAIL = 28;\n/** Soft puffs in the smoke plume. */\nconst PUFFS = 90;\n/** Life of one puff, in ms. Puffs are released over SMOKE_EMIT so the last fades out as the build ends. */\nconst PUFF_LIFE = 560;\nconst SMOKE_EMIT = SPREAD * 0.9;\n/** Width of the band puffs rise from, as a share of the canvas. */\nconst SMOKE_BAND = 0.75;\n/** A puff's radius at birth and at the end of its life, in modules. */\nconst PUFF_START = 1.4;\nconst PUFF_END = 3.6;\n/** Peak opacity of one puff. Overlap builds the density. Fewer, smaller puffs keep the fill cost near 3ms a frame. */\nconst PUFF_ALPHA = 0.22;\n/** How far a condensing piece drifts up into place, in modules. */\nconst SMOKE_DRIFT = 1;\nconst TAU = Math.PI * 2;\n\n/**\n * One soft puff: a radial falloff tinted with the ink colour, drawn scaled\n * per puff. A sprite is far cheaper than a gradient or a blur per draw, and\n * blur filters would re-render every frame.\n */\nconst puffSprites = new Map<string, HTMLCanvasElement>();\nfunction puffSprite(ink: string) {\n const cached = puffSprites.get(ink);\n if (cached) return cached;\n const s = 96;\n const sprite = document.createElement(\"canvas\");\n sprite.width = s;\n sprite.height = s;\n const g = sprite.getContext(\"2d\");\n if (g) {\n const fall = g.createRadialGradient(s / 2, s / 2, 0, s / 2, s / 2, s / 2);\n fall.addColorStop(0, \"rgba(0,0,0,1)\");\n fall.addColorStop(0.45, \"rgba(0,0,0,0.55)\");\n fall.addColorStop(1, \"rgba(0,0,0,0)\");\n g.fillStyle = fall;\n g.fillRect(0, 0, s, s);\n g.globalCompositeOperation = \"source-in\";\n g.fillStyle = ink;\n g.fillRect(0, 0, s, s);\n }\n puffSprites.set(ink, sprite);\n return sprite;\n}\n\n/**\n * Smoke is soft, so it is drawn at half the canvas resolution in CSS px (a\n * quarter of the device pixels on a 2x screen) and scaled up in one draw.\n * The puffs overlap heavily, and filling them at full resolution cost\n * several ms a frame.\n */\nconst SMOKE_RES = 0.5;\nconst smokeLayers = new Map<number, CanvasRenderingContext2D | null>();\nfunction smokeLayer(size: number) {\n if (!smokeLayers.has(size)) {\n const layer = document.createElement(\"canvas\");\n layer.width = Math.ceil(size * SMOKE_RES);\n layer.height = layer.width;\n const lctx = layer.getContext(\"2d\");\n lctx?.scale(SMOKE_RES, SMOKE_RES);\n smokeLayers.set(size, lctx);\n }\n return smokeLayers.get(size) ?? null;\n}\n\nfunction drawSmoke(ctx: CanvasRenderingContext2D, layout: Layout, clock: number, ink: string) {\n const { size, cell, pieces } = layout;\n const lctx = smokeLayer(size);\n if (!lctx) return;\n const sprite = puffSprite(ink);\n lctx.clearRect(0, 0, size, size);\n\n // A soft haze where each condensing piece is gathering.\n for (const p of pieces) {\n const t = (clock - pieceStart(p, \"smoke\", size)) / PIECE_IN;\n if (t <= 0 || t >= 1) continue;\n const k = settle(t);\n const half = p.side / 2;\n const haze = (p.eye ? half * 1.3 : cell * 1.6) * (1.4 - k);\n lctx.globalAlpha = 0.35 * Math.min(1, t * 4) * (1 - k);\n lctx.drawImage(\n sprite,\n p.x + half - haze,\n p.y + half - haze + (1 - k) * cell * SMOKE_DRIFT,\n haze * 2,\n haze * 2,\n );\n }\n\n for (let i = 0; i < PUFFS; i++) {\n const age = clock - (i / PUFFS) * SMOKE_EMIT;\n const u = age / PUFF_LIFE;\n if (u <= 0 || u >= 1) continue;\n const h1 = hash(i * 3 + 1);\n const h2 = hash(i * 3 + 2);\n const h3 = hash(i * 3 + 3);\n // Rises fast, then slows and spreads as it cools.\n const rise = size * (0.55 + 0.6 * h2) * (1 - (1 - u) ** 2);\n const curl = Math.sin(h3 * TAU + u * 4) * cell * 2.4 * u;\n const x = size / 2 + (h1 - 0.5) * size * SMOKE_BAND + curl;\n const y = size + cell * 2 - rise;\n const r = cell * (PUFF_START + (PUFF_END - PUFF_START) * u);\n lctx.globalAlpha = PUFF_ALPHA * Math.min(1, u * 6) * (1 - u) ** 1.5;\n lctx.drawImage(sprite, x - r, y - r, r * 2, r * 2);\n }\n ctx.globalAlpha = 1;\n ctx.drawImage(lctx.canvas, 0, 0, size, size);\n}\nconst QUARTER = Math.PI / 2;\n\n/**\n * Each piece moves like a critically damped spring pulled to its cell: it\n * leaves at rest, speeds up, and eases in with no overshoot. An ease-out\n * curve would start at full speed, which reads as a jolt at launch. The\n * curve is scaled to land exactly at t = 1. Local because it has to run per\n * piece on a canvas, where the shared motion tokens cannot.\n */\nconst OMEGA = 7;\nconst SETTLE_END = 1 - (1 + OMEGA) * Math.exp(-OMEGA);\nconst settle = (t: number) => (1 - (1 + OMEGA * t) * Math.exp(-OMEGA * t)) / SETTLE_END;\n/** Speed of `settle` at t, 0 to 1, peaking at t = 1 / OMEGA. */\nconst speedAt = (t: number) => OMEGA * t * Math.exp(1 - OMEGA * t);\nconst DEFAULT_ORIGIN: Record<\"swarm\" | \"ripple\", QrCodeOrigin> = {\n swarm: { x: 0.5, y: 1 },\n ripple: { x: 0.5, y: 0.5 },\n};\n\nconst clamp01 = (v: number) => (v < 0 ? 0 : Math.min(v, 1));\n\nfunction hash(n: number) {\n let t = Math.imul(n ^ 0x9e3779b9, 0x85ebca6b);\n t ^= t >>> 13;\n t = Math.imul(t, 0xc2b2ae35);\n return ((t ^ (t >>> 16)) >>> 0) / 4294967296;\n}\n\n/** One thing that arrives: a data dot, or a whole finder eye. */\ninterface Piece {\n eye: boolean;\n /** Top-left corner, in px. */\n x: number;\n y: number;\n /** Side, in px. */\n side: number;\n /** Distance of its centre from the origin, 0 to 1. */\n d: number;\n /** Small per-piece random value, 0 to 1. */\n r: number;\n}\n\ninterface Layout {\n cell: number;\n dot: number;\n radius: number;\n pieces: Piece[];\n /** Largest origin distance, in px, so the ripple ring meets each piece as it starts. */\n reach: number;\n ox: number;\n oy: number;\n size: number;\n}\n\nfunction isEye(x: number, y: number, n: number) {\n return (x < 7 && y < 7) || (x >= n - 7 && y < 7) || (x < 7 && y >= n - 7);\n}\n\nfunction buildLayout(value: string, size: number, origin: QrCodeOrigin): Layout {\n const { data, size: n } = encode(value || \" \", { ecc: \"M\", border: 0 });\n const cell = Math.max(2, Math.floor(size / (n + QUIET * 2)));\n const gap = Math.max(1, Math.round(cell * 0.12));\n const dot = cell - gap;\n const start = Math.round((size - n * cell) / 2);\n const ox = origin.x * size;\n const oy = origin.y * size;\n\n const pieces: Piece[] = [];\n const add = (eye: boolean, x: number, y: number, side: number, seed: number) => {\n pieces.push({\n eye,\n x,\n y,\n side,\n d: Math.hypot(x + side / 2 - ox, y + side / 2 - oy),\n r: hash(seed),\n });\n };\n const eyeSide = cell * 7 - gap;\n const far = start + (n - 7) * cell;\n add(true, start, start, eyeSide, -1);\n add(true, far, start, eyeSide, -2);\n add(true, start, far, eyeSide, -3);\n data.forEach((row, y) => {\n row.forEach((dark, x) => {\n if (dark && !isEye(x, y, n)) add(false, start + x * cell, start + y * cell, dot, y * n + x);\n });\n });\n const reach = Math.max(1, ...pieces.map((p) => p.d));\n for (const p of pieces) p.d /= reach;\n\n return { cell, dot, radius: dot * 0.32, pieces, reach, ox, oy, size };\n}\n\n/** A finder eye: a rounded ring and a rounded core, radii concentric. */\nfunction drawEye(\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n side: number,\n cell: number,\n radius: number,\n) {\n const r = cell * 2;\n ctx.beginPath();\n ctx.roundRect(x, y, side, side, r);\n ctx.roundRect(x + cell, y + cell, side - cell * 2, side - cell * 2, r - cell);\n ctx.fill(\"evenodd\");\n ctx.beginPath();\n ctx.roundRect(\n x + cell * 2,\n y + cell * 2,\n side - cell * 4,\n side - cell * 4,\n Math.max(radius, r - cell * 2),\n );\n ctx.fill();\n}\n\nfunction pieceStart(p: Piece, variant: QrCodeVariant, size: number) {\n if (variant === \"scan\") return clamp01((p.y + p.side / 2) / size) * SPREAD;\n if (variant === \"smoke\")\n return (1 - clamp01((p.y + p.side / 2) / size)) * (SPREAD - JITTER) + p.r * JITTER;\n if (variant === \"ripple\") return p.d * SPREAD;\n return p.d * (SPREAD - JITTER) + p.r * JITTER;\n}\n\nfunction draw(\n ctx: CanvasRenderingContext2D,\n layout: Layout,\n clock: number,\n variant: QrCodeVariant,\n reduce: boolean,\n ink: string,\n paper: string,\n) {\n const { cell, dot, radius, pieces, reach, ox, oy, size } = layout;\n ctx.globalAlpha = 1;\n ctx.fillStyle = paper;\n ctx.fillRect(0, 0, size, size);\n ctx.fillStyle = ink;\n\n if (reduce) {\n ctx.globalAlpha = clock / TOTAL;\n ctx.beginPath();\n for (const p of pieces) if (!p.eye) ctx.roundRect(p.x, p.y, dot, dot, radius);\n ctx.fill();\n for (const p of pieces) if (p.eye) drawEye(ctx, p.x, p.y, p.side, cell, radius);\n ctx.globalAlpha = 1;\n return;\n }\n\n // Landed pieces sit on whole pixels with no transform. Dots share one fill.\n ctx.beginPath();\n for (const p of pieces) {\n if (!p.eye && clock - pieceStart(p, variant, size) >= PIECE_IN)\n ctx.roundRect(p.x, p.y, dot, dot, radius);\n }\n ctx.fill();\n for (const p of pieces) {\n if (p.eye && clock - pieceStart(p, variant, size) >= PIECE_IN)\n drawEye(ctx, p.x, p.y, p.side, cell, radius);\n }\n\n // The wavefront each piece waits for, drawn faintly while it moves.\n const q = clock / SPREAD;\n if (q > 0 && q < 1 && (variant === \"ripple\" || variant === \"scan\")) {\n ctx.save();\n const fade = Math.sin(Math.PI * q);\n if (variant === \"ripple\") {\n ctx.strokeStyle = ink;\n ctx.lineWidth = 1.5;\n ctx.globalAlpha = 0.22 * fade;\n ctx.beginPath();\n ctx.arc(ox, oy, q * reach, 0, Math.PI * 2);\n ctx.stroke();\n } else {\n const y = q * size;\n const trail = ctx.createLinearGradient(0, y - SCAN_TRAIL, 0, y);\n trail.addColorStop(0, \"transparent\");\n trail.addColorStop(1, ink);\n ctx.globalAlpha = 0.08 * fade;\n ctx.fillStyle = trail;\n ctx.fillRect(0, y - SCAN_TRAIL, size, SCAN_TRAIL);\n ctx.globalAlpha = 0.3 * fade;\n ctx.fillStyle = ink;\n ctx.fillRect(0, y - 1, size, 1.5);\n }\n ctx.restore();\n }\n\n for (const p of pieces) {\n const t = (clock - pieceStart(p, variant, size)) / PIECE_IN;\n if (t <= 0 || t >= 1) continue;\n const k = settle(t);\n const half = p.side / 2;\n const cx = p.x + half;\n const cy = p.y + half;\n ctx.save();\n\n if (variant === \"ripple\") {\n // Pops in place from a round seed.\n ctx.globalAlpha = Math.min(1, t * 4);\n ctx.translate(cx, cy);\n if (p.eye) {\n ctx.scale(k, k);\n drawEye(ctx, -half, -half, p.side, cell, radius);\n } else {\n const s = dot * k;\n ctx.beginPath();\n ctx.roundRect(-s / 2, -s / 2, s, s, s / 2 + (radius - s / 2) * k);\n ctx.fill();\n }\n } else if (variant === \"smoke\") {\n // Condenses out of the plume: the solid piece firms up as it drifts up\n // into place, under a haze drawn with the smoke layer.\n ctx.globalAlpha = k ** 1.4;\n ctx.translate(0, (1 - k) * cell * SMOKE_DRIFT);\n if (p.eye) drawEye(ctx, p.x, p.y, p.side, cell, radius);\n else {\n ctx.beginPath();\n ctx.roundRect(p.x, p.y, dot, dot, radius);\n ctx.fill();\n }\n } else if (variant === \"scan\") {\n // Drops a little way into place as the bar passes over it.\n ctx.globalAlpha = Math.min(1, t * 3);\n ctx.translate(0, -(1 - k) * cell * DROP);\n if (p.eye) drawEye(ctx, p.x, p.y, p.side, cell, radius);\n else {\n ctx.beginPath();\n ctx.roundRect(p.x, p.y, dot, dot, radius);\n ctx.fill();\n }\n } else {\n // Swarm: a curved flight from the origin, bowing away from the centre\n // line so the paths fan out like a fountain instead of crossing.\n const dx = cx - ox;\n const dy = cy - oy;\n const side = dx < 0 ? 1 : -1;\n const bend = (BEND + BEND_SPREAD * p.r) * side;\n const qx = ox + dx / 2 + dy * bend;\n const qy = oy + dy / 2 - dx * bend;\n const u = 1 - k;\n const x = u * u * ox + 2 * u * k * qx + k * k * cx;\n const y = u * u * oy + 2 * u * k * qy + k * k * cy;\n const angle = Math.atan2(u * (qy - oy) + k * (cy - qy), u * (qx - ox) + k * (cx - qx));\n const rest = Math.round(angle / QUARTER) * QUARTER;\n // Real speed along the curve, so it stretches most where it moves\n // fastest, and longer flights move faster. 0 at launch and on landing.\n const v = speedAt(t) * p.d;\n // Eyes are seven modules wide, so the same stretch would turn them into long bars.\n const along = 1 + STRETCH * v * (p.eye ? EYE_STRETCH : 1);\n const across = 1 / along;\n ctx.globalAlpha = Math.min(1, t * 6);\n ctx.translate(x, y);\n // Faces its heading in flight and turns square as it settles.\n ctx.rotate(rest + (angle - rest) * (1 - k) ** 2);\n if (p.eye) {\n ctx.scale(along, across);\n drawEye(ctx, -half, -half, p.side, cell, radius);\n } else {\n const l = dot * along;\n const w = dot * across;\n ctx.beginPath();\n ctx.roundRect(\n -l / 2,\n -w / 2,\n l,\n w,\n Math.min(w / 2, radius + (w / 2 - radius) * Math.min(1, v * 2)),\n );\n ctx.fill();\n }\n }\n ctx.restore();\n }\n // The plume drifts over the code, so the dots seem to come out of it.\n if (variant === \"smoke\") drawSmoke(ctx, layout, clock, ink);\n ctx.globalAlpha = 1;\n}\n\n/**\n * A QR code drawn on a canvas that builds itself piece by piece: the dots and\n * the three finder eyes fly in on curved paths, pop in behind a spreading\n * ring, or drop in behind a bar sweeping down. One reversible clock runs it,\n * so hiding plays the build backwards and a press mid-run turns around from\n * where it is.\n */\nexport function AnimatedQrCode({\n value,\n shown,\n variant = \"swarm\",\n size = 296,\n origin,\n ink = \"#0a0a0a\",\n paper = \"#ffffff\",\n onSettled,\n labels,\n className,\n}: AnimatedQrCodeProps) {\n const t = useMessages(\"AnimatedQrCode\", qrCodeMessages, labels);\n const reduce = useReducedMotion() ?? false;\n const canvasRef = useRef<HTMLCanvasElement>(null);\n const ctxRef = useRef<CanvasRenderingContext2D | null>(null);\n // Read from the first render only. The clock must never be reset by a\n // change of `shown`, or a press would skip straight to the end.\n const clockRef = useRef(shown ? TOTAL : 0);\n /** Clock ms per real ms, signed. Eased toward its goal on a turnaround. */\n const rateRef = useRef(0);\n const fallback = DEFAULT_ORIGIN[variant === \"ripple\" ? \"ripple\" : \"swarm\"];\n const ox = origin?.x ?? fallback.x;\n const oy = origin?.y ?? fallback.y;\n const layout = useMemo(() => buildLayout(value, size, { x: ox, y: oy }), [value, size, ox, oy]);\n\n const live = useRef({ layout, variant, reduce, ink, paper, onSettled });\n useLayoutEffect(() => {\n live.current = { layout, variant, reduce, ink, paper, onSettled };\n });\n\n // Backing store at device resolution, scaled once. Draws only push and pop\n // their own transforms, so the scale is never lost.\n useLayoutEffect(() => {\n const canvas = canvasRef.current;\n if (!canvas) return;\n const dpr = Math.max(1, window.devicePixelRatio || 1);\n canvas.width = Math.round(size * dpr);\n canvas.height = Math.round(size * dpr);\n const ctx = canvas.getContext(\"2d\");\n if (!ctx) return;\n ctx.scale(dpr, dpr);\n ctxRef.current = ctx;\n }, [size]);\n\n // Repaint at the current time when the look changes, without moving it.\n useLayoutEffect(() => {\n const ctx = ctxRef.current;\n if (ctx) draw(ctx, layout, clockRef.current, variant, reduce, ink, paper);\n }, [layout, variant, reduce, ink, paper]);\n\n // Run the clock toward the end `shown` asks for, from wherever it is.\n useEffect(() => {\n const target = shown ? TOTAL : 0;\n if (clockRef.current === target) return;\n // From rest, start at full rate: each piece already eases out of rest.\n if (clockRef.current === 0 || clockRef.current === TOTAL)\n rateRef.current = shown ? 1 : -EXIT_RATE;\n let frame = 0;\n let last = performance.now();\n const tick = (now: number) => {\n // Real time, so slow frames drop instead of slowing the build. The cap\n // only stops a long stall, like a background tab, from skipping to the end.\n const dt = Math.min(250, now - last);\n last = now;\n const cur = live.current;\n // A press mid-run eases the clock's rate into the new direction\n // instead of flipping it, so every piece slows, stops and turns back.\n const goal = shown ? 1 : -EXIT_RATE;\n rateRef.current += (goal - rateRef.current) * (1 - Math.exp(-dt / TURN_MS));\n const scale = cur.reduce ? TOTAL / REDUCED_MS : 1;\n const next = Math.min(TOTAL, Math.max(0, clockRef.current + dt * rateRef.current * scale));\n clockRef.current = next;\n const ctx = ctxRef.current;\n if (ctx) draw(ctx, cur.layout, next, cur.variant, cur.reduce, cur.ink, cur.paper);\n if (next === target) {\n cur.onSettled?.(shown);\n return;\n }\n frame = requestAnimationFrame(tick);\n };\n frame = requestAnimationFrame(tick);\n return () => cancelAnimationFrame(frame);\n }, [shown]);\n\n return (\n <canvas\n ref={canvasRef}\n role=\"img\"\n aria-label={shown ? t(\"label\", { value }) : undefined}\n aria-hidden={shown ? undefined : true}\n width={size}\n height={size}\n // A ring, not a border, so the canvas keeps its exact pixel size.\n className={cn(\"ring-border aspect-square h-auto max-w-full rounded-2xl ring-1\", className)}\n style={{ width: size, backgroundColor: paper }}\n />\n );\n}\n"],"mappings":";;;;;;;;AAWA,MAAa,iBAAiB,EAC5B,OAAO,sBACT;;AAqCA,MAAM,SAAS;;AAEf,MAAM,WAAW;AACjB,MAAM,QAAQ;;AAId,MAAM,UAAU;;AAEhB,MAAM,aAAa;;AAEnB,MAAM,SAAS;;AAEf,MAAM,OAAO;AACb,MAAM,cAAc;;AAEpB,MAAM,UAAU;;AAEhB,MAAM,cAAc;;AAEpB,MAAM,OAAO;;AAEb,MAAM,aAAa;;AAEnB,MAAM,QAAQ;;AAEd,MAAM,YAAY;AAClB,MAAM,aAAa,SAAS;;AAE5B,MAAM,aAAa;;AAEnB,MAAM,aAAa;;AAGnB,MAAM,aAAa;;AAEnB,MAAM,cAAc;AACpB,MAAM,MAAM,KAAK,KAAK;;;;;;AAOtB,MAAM,8BAAc,IAAI,IAA+B;AACvD,SAAS,WAAW,KAAa;CAC/B,MAAM,SAAS,YAAY,IAAI,GAAG;CAClC,IAAI,QAAQ,OAAO;CACnB,MAAM,IAAI;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ChF,IAAI,SAAS,QAAQ;IACnB,IAAI,YAAY,KAAK;IACrB;GACF;GACA,QAAQ,sBAAsB,IAAI;EACpC;EACA,QAAQ,sBAAsB,IAAI;EAClC,aAAa,qBAAqB,KAAK;CACzC,GAAG,CAAC,KAAK,CAAC;CAEV,OACE,oBAAC,UAAD;EACE,KAAK;EACL,MAAK;EACL,cAAY,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,IAAI,KAAA;EAC5C,eAAa,QAAQ,KAAA,IAAY;EACjC,OAAO;EACP,QAAQ;EAER,WAAW,GAAG,kEAAkE,SAAS;EACzF,OAAO;GAAE,OAAO;GAAM,iBAAiB;EAAM;CAC9C,CAAA;AAEL"}
|
|
@@ -5,7 +5,7 @@ import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
|
5
5
|
import { cn } from "@kumix/utils";
|
|
6
6
|
import { EASE_OUT, SPRING_LAYOUT, SPRING_PRESS } from "../../../lib/ease.js";
|
|
7
7
|
import { useMessages } from "../../../lib/i18n.js";
|
|
8
|
-
import { t as Tooltip } from "../../../tooltip-
|
|
8
|
+
import { t as Tooltip } from "../../../tooltip-eecPhLtC.js";
|
|
9
9
|
import { a as swapMessages, i as truncateAddress, n as isValidAddress } from "../../../utils-Dve5wIjB.js";
|
|
10
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
11
|
// src/components/motion/swap/controls.tsx
|
|
@@ -15,11 +15,11 @@ export interface TooltipProviderProps extends Partial<TooltipTiming> {
|
|
|
15
15
|
export declare function TooltipProvider({ children, ...timing }: TooltipProviderProps): import("react").JSX.Element;
|
|
16
16
|
export interface TooltipRootProps {
|
|
17
17
|
children?: ReactNode;
|
|
18
|
-
/** Whether the tooltip
|
|
18
|
+
/** Whether to show the tooltip in controlled use. An inert anchor keeps it hidden. */
|
|
19
19
|
open?: boolean;
|
|
20
20
|
/** Whether the tooltip starts shown when uncontrolled. Default: false */
|
|
21
21
|
defaultOpen?: boolean;
|
|
22
|
-
/** Called
|
|
22
|
+
/** Called when the tooltip requests to show or hide, including when its anchor becomes inert. */
|
|
23
23
|
onOpenChange?: (open: boolean) => void;
|
|
24
24
|
/** Delay before showing on hover (ms). Keyboard focus shows immediately. */
|
|
25
25
|
delay?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.d.ts","names":[],"sources":["../../../src/components/motion/tooltip.tsx"],"mappings":";;UA8CU;;EAER;;EAEA;;EAEA;;iBAKe,6BAA6B,QAAQ;EACpD,UAAU;;;wBAII,kBAAkB,aAAa,UAAU,uCAAoB,IAAA;iBAsD5D;EACf,WAAW;;EAEX;;EAEA;;EAEA,gBAAgB;;EAEhB;;EAEA;;EAEA;;;;;EAKA;;EAEA;;EAEA,YAAY,UAAU;;EAEtB;;
|
|
1
|
+
{"version":3,"file":"tooltip.d.ts","names":[],"sources":["../../../src/components/motion/tooltip.tsx"],"mappings":";;UA8CU;;EAER;;EAEA;;EAEA;;iBAKe,6BAA6B,QAAQ;EACpD,UAAU;;;wBAII,kBAAkB,aAAa,UAAU,uCAAoB,IAAA;iBAsD5D;EACf,WAAW;;EAEX;;EAEA;;EAEA,gBAAgB;;EAEhB;;EAEA;;EAEA;;;;;EAKA;;EAEA;;EAEA,YAAY,UAAU;;EAEtB;;iBAmae,4BAA4B;;EAE3C;;wBAGc,iBAAiB,SAAiB,UAAU,QAAQ,SAAS,2EAAmB,IAAA,UAAA,SAAA,aAAA,6DAAA,cAAA,+CAAA,8BAAA,SAAA;iBA0D/E;EACf,WAAW;;EAEX,OAAO;;EAEP,QAAQ;;EAER;;EAEA;;EAEA,cAAc;;EAEd;;wBAGc,iBACd,UACA,MACA,OACA,YACA,OACA,aACA,aACC,sCAAmB;iBAiFL,qBACP,kBACN,KAAK;;;;;EAKP,UAAU;;EAEV;;wBAGc,QAAQ,OAAO,oEAAY,IAAA,UAAA,SAAA,aAAA,6DAAA,cAAA,+CAAA,8BAAA,SAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
export { t as Tooltip, n as TooltipContent, r as TooltipProvider, i as TooltipTrigger } from "../../tooltip-
|
|
2
|
+
export { t as Tooltip, n as TooltipContent, r as TooltipProvider, i as TooltipTrigger } from "../../tooltip-eecPhLtC.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { VariantProps } from "class-variance-authority";
|
|
2
2
|
declare const alertVariants: (props?: ({
|
|
3
|
-
variant?: "
|
|
3
|
+
variant?: "success" | "default" | "destructive" | "info" | "warning" | "invert" | null | undefined;
|
|
4
4
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
5
5
|
declare function Alert({ className, variant, ...props }: React.ComponentProps<"div"> & VariantProps<typeof alertVariants>): import("react").JSX.Element;
|
|
6
6
|
declare function AlertTitle({ className, ...props }: React.ComponentProps<"div">): import("react").JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useRender } from "@base-ui/react/use-render";
|
|
2
2
|
import { VariantProps } from "class-variance-authority";
|
|
3
3
|
declare const badgeVariants: (props?: ({
|
|
4
|
-
variant?: "
|
|
4
|
+
variant?: "success" | "outline" | "default" | "focus" | "destructive" | "info" | "warning" | "invert" | "secondary" | "primary-light" | "warning-light" | "success-light" | "info-light" | "destructive-light" | "invert-light" | "focus-light" | "primary-outline" | "warning-outline" | "success-outline" | "info-outline" | "destructive-outline" | "invert-outline" | "focus-outline" | null | undefined;
|
|
5
5
|
size?: "default" | "sm" | "lg" | "xs" | "xl" | null | undefined;
|
|
6
6
|
radius?: "default" | "full" | null | undefined;
|
|
7
7
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
@@ -21,7 +21,7 @@ import { VariantProps } from "class-variance-authority";
|
|
|
21
21
|
* default to `text-primary`; override it to recolor without touching internals.
|
|
22
22
|
*/
|
|
23
23
|
declare const iconTileVariants: (props?: ({
|
|
24
|
-
variant?: "outline" | "solid" | "
|
|
24
|
+
variant?: "outline" | "solid" | "frame" | "soft" | "elevated" | null | undefined;
|
|
25
25
|
size?: "default" | "sm" | "lg" | "xs" | "xl" | null | undefined;
|
|
26
26
|
radius?: "default" | "full" | null | undefined;
|
|
27
27
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
@@ -4,13 +4,13 @@ import { VariantProps } from "class-variance-authority";
|
|
|
4
4
|
import { Button } from "./button.js";
|
|
5
5
|
declare const attachmentVariants: (props?: ({
|
|
6
6
|
size?: "default" | "sm" | "xs" | null | undefined;
|
|
7
|
-
orientation?: "
|
|
7
|
+
orientation?: "vertical" | "horizontal" | null | undefined;
|
|
8
8
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
9
9
|
declare function Attachment({ className, state, size, orientation, ...props }: React.ComponentProps<"div"> & VariantProps<typeof attachmentVariants> & {
|
|
10
10
|
state?: "idle" | "uploading" | "processing" | "error" | "done";
|
|
11
11
|
}): React.JSX.Element;
|
|
12
12
|
declare const attachmentMediaVariants: (props?: ({
|
|
13
|
-
variant?: "
|
|
13
|
+
variant?: "icon" | "image" | null | undefined;
|
|
14
14
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
15
15
|
declare function AttachmentMedia({ className, variant, ...props }: React.ComponentProps<"div"> & VariantProps<typeof attachmentMediaVariants>): React.JSX.Element;
|
|
16
16
|
declare function AttachmentContent({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
@@ -2,7 +2,7 @@ import { useRender } from "@base-ui/react/use-render";
|
|
|
2
2
|
import { VariantProps } from "class-variance-authority";
|
|
3
3
|
import { Separator } from "./separator.js";
|
|
4
4
|
declare const buttonGroupVariants: (props?: ({
|
|
5
|
-
orientation?: "
|
|
5
|
+
orientation?: "vertical" | "horizontal" | null | undefined;
|
|
6
6
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
7
|
declare function ButtonGroup({ className, orientation, ...props }: React.ComponentProps<"div"> & VariantProps<typeof buttonGroupVariants>): import("react").JSX.Element;
|
|
8
8
|
declare function ButtonGroupText({ className, render, ...props }: useRender.ComponentProps<"div">): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
@@ -2,7 +2,7 @@ import { Button as Button$1 } from "@base-ui/react/button";
|
|
|
2
2
|
import { VariantProps } from "class-variance-authority";
|
|
3
3
|
declare const buttonVariants: (props?: ({
|
|
4
4
|
variant?: "link" | "outline" | "default" | "ghost" | "destructive" | "secondary" | null | undefined;
|
|
5
|
-
size?: "
|
|
5
|
+
size?: "icon" | "default" | "sm" | "lg" | "xs" | "icon-xs" | "icon-sm" | "icon-lg" | null | undefined;
|
|
6
6
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
7
|
declare function Button({ className, variant, size, ...props }: Button$1.Props & VariantProps<typeof buttonVariants>): import("react").JSX.Element;
|
|
8
8
|
export { Button, buttonVariants };
|
|
@@ -2,7 +2,7 @@ import { VariantProps } from "class-variance-authority";
|
|
|
2
2
|
declare function Empty({ className, ...props }: React.ComponentProps<"div">): import("react").JSX.Element;
|
|
3
3
|
declare function EmptyHeader({ className, ...props }: React.ComponentProps<"div">): import("react").JSX.Element;
|
|
4
4
|
declare const emptyMediaVariants: (props?: ({
|
|
5
|
-
variant?: "
|
|
5
|
+
variant?: "icon" | "default" | null | undefined;
|
|
6
6
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
7
|
declare function EmptyMedia({ className, variant, ...props }: React.ComponentProps<"div"> & VariantProps<typeof emptyMediaVariants>): import("react").JSX.Element;
|
|
8
8
|
declare function EmptyTitle({ className, ...props }: React.ComponentProps<"div">): import("react").JSX.Element;
|
|
@@ -6,7 +6,7 @@ declare function FieldLegend({ className, variant, ...props }: React.ComponentPr
|
|
|
6
6
|
}): import("react").JSX.Element;
|
|
7
7
|
declare function FieldGroup({ className, ...props }: React.ComponentProps<"div">): import("react").JSX.Element;
|
|
8
8
|
declare const fieldVariants: (props?: ({
|
|
9
|
-
orientation?: "
|
|
9
|
+
orientation?: "vertical" | "horizontal" | "responsive" | null | undefined;
|
|
10
10
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
11
11
|
declare function Field({ className, orientation, ...props }: React.ComponentProps<"div"> & VariantProps<typeof fieldVariants>): import("react").JSX.Element;
|
|
12
12
|
declare function FieldContent({ className, ...props }: React.ComponentProps<"div">): import("react").JSX.Element;
|
|
@@ -10,7 +10,7 @@ declare const itemVariants: (props?: ({
|
|
|
10
10
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
11
11
|
declare function Item({ className, variant, size, render, ...props }: useRender.ComponentProps<"div"> & VariantProps<typeof itemVariants>): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
12
12
|
declare const itemMediaVariants: (props?: ({
|
|
13
|
-
variant?: "
|
|
13
|
+
variant?: "icon" | "image" | "default" | null | undefined;
|
|
14
14
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
15
15
|
declare function ItemMedia({ className, variant, ...props }: React.ComponentProps<"div"> & VariantProps<typeof itemMediaVariants>): React.JSX.Element;
|
|
16
16
|
declare function ItemContent({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
@@ -60,7 +60,7 @@ declare function useCompositionModel({ series, periods, view, period, defaultPer
|
|
|
60
60
|
select: (next: string) => void;
|
|
61
61
|
view: "area" | "bar";
|
|
62
62
|
label: string;
|
|
63
|
-
t: (key: "label" | "
|
|
63
|
+
t: (key: "label" | "highlight" | "empty" | "noData" | "inspect" | "missingValue" | "incomplete", values?: Record<string, string | number>) => string;
|
|
64
64
|
formatValue: (value: number) => string;
|
|
65
65
|
pinned: string | null;
|
|
66
66
|
setPinned: import("react").Dispatch<import("react").SetStateAction<string | null>>;
|
|
@@ -102,7 +102,7 @@ declare const CompositionContext: import("react").Context<{
|
|
|
102
102
|
select: (next: string) => void;
|
|
103
103
|
view: "area" | "bar";
|
|
104
104
|
label: string;
|
|
105
|
-
t: (key: "label" | "
|
|
105
|
+
t: (key: "label" | "highlight" | "empty" | "noData" | "inspect" | "missingValue" | "incomplete", values?: Record<string, string | number>) => string;
|
|
106
106
|
formatValue: (value: number) => string;
|
|
107
107
|
pinned: string | null;
|
|
108
108
|
setPinned: import("react").Dispatch<import("react").SetStateAction<string | null>>;
|
|
@@ -144,7 +144,7 @@ declare function useCompositionChart(): {
|
|
|
144
144
|
select: (next: string) => void;
|
|
145
145
|
view: "area" | "bar";
|
|
146
146
|
label: string;
|
|
147
|
-
t: (key: "label" | "
|
|
147
|
+
t: (key: "label" | "highlight" | "empty" | "noData" | "inspect" | "missingValue" | "incomplete", values?: Record<string, string | number>) => string;
|
|
148
148
|
formatValue: (value: number) => string;
|
|
149
149
|
pinned: string | null;
|
|
150
150
|
setPinned: import("react").Dispatch<import("react").SetStateAction<string | null>>;
|
|
@@ -169,4 +169,4 @@ declare function useCompositionChart(): {
|
|
|
169
169
|
}[];
|
|
170
170
|
};
|
|
171
171
|
export { CompositionSeries as a, useCompositionModel as i, CompositionContext as n, CompositionChartMessages as o, useCompositionChart as r, compositionChartMessages as s, CompositionChartProps as t };
|
|
172
|
-
//# sourceMappingURL=context-
|
|
172
|
+
//# sourceMappingURL=context-Cyjsttyl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-
|
|
1
|
+
{"version":3,"file":"context-Cyjsttyl.d.ts","names":[],"sources":["../src/components/charts/composition-chart/messages.ts","../src/components/charts/composition-chart/model.ts","../src/components/charts/composition-chart/context.tsx"],"mappings":";cAEa;;;;;;;;;KAUD,kCAAkC;UCV7B;;EAEf;;EAEA;;EAEA;;EAEA;;UCAe;;EAEf,iBAAiB;;EAEjB;;EAEA;;EAEA;;EAEA;;EAEA,kBAAkB;;EAElB,eAAe;;EAEf;;EAEA,SAAS,QAAQ;;EAEjB;EACA,WAAW;;iBAIG,sBACd,QACA,SACA,MACA,QACA,eACA,gBACA,aACA,OAAO,aACP,UACC;;;;;;;;;;;;;;;EAiBqB,SAAA;;;;EAtCA,cAAA;;;;;;;;;;;;;;;;;;;;;;;cA8DX,oCAAkB;;;;;;;;;;;;;;;EAxBP,SAAA;;;;EAtCA,cAAA;;;;;;;;;;;;;;;;;;;;;;;iBAiER;;;;;;;;;;;;;;;EA3BQ,SAAA;;;;EAtCA,cAAA"}
|
|
@@ -49,7 +49,7 @@ interface BumpChartProps {
|
|
|
49
49
|
declare function useBumpChartModel({ series, periods, active, defaultActive, onActiveChange, label, labels }: BumpChartProps): {
|
|
50
50
|
periods: readonly string[];
|
|
51
51
|
label: string;
|
|
52
|
-
t: (key: "
|
|
52
|
+
t: (key: "label" | "highlight" | "caption" | "empty" | "noData" | "series" | "plot" | "description" | "changeUnavailable" | "unchanged" | "noPrevious" | "noChange" | "upOne" | "up" | "downOne" | "down" | "previously" | "point", values?: Record<string, string | number>) => string;
|
|
53
53
|
pinned: string | null;
|
|
54
54
|
highlighted: string | null;
|
|
55
55
|
select: (next: string | null) => void;
|
|
@@ -72,7 +72,7 @@ declare function useBumpChartModel({ series, periods, active, defaultActive, onA
|
|
|
72
72
|
declare const BumpChartContext: import("react").Context<{
|
|
73
73
|
periods: readonly string[];
|
|
74
74
|
label: string;
|
|
75
|
-
t: (key: "
|
|
75
|
+
t: (key: "label" | "highlight" | "caption" | "empty" | "noData" | "series" | "plot" | "description" | "changeUnavailable" | "unchanged" | "noPrevious" | "noChange" | "upOne" | "up" | "downOne" | "down" | "previously" | "point", values?: Record<string, string | number>) => string;
|
|
76
76
|
pinned: string | null;
|
|
77
77
|
highlighted: string | null;
|
|
78
78
|
select: (next: string | null) => void;
|
|
@@ -95,7 +95,7 @@ declare const BumpChartContext: import("react").Context<{
|
|
|
95
95
|
declare function useBumpChart(): {
|
|
96
96
|
periods: readonly string[];
|
|
97
97
|
label: string;
|
|
98
|
-
t: (key: "
|
|
98
|
+
t: (key: "label" | "highlight" | "caption" | "empty" | "noData" | "series" | "plot" | "description" | "changeUnavailable" | "unchanged" | "noPrevious" | "noChange" | "upOne" | "up" | "downOne" | "down" | "previously" | "point", values?: Record<string, string | number>) => string;
|
|
99
99
|
pinned: string | null;
|
|
100
100
|
highlighted: string | null;
|
|
101
101
|
select: (next: string | null) => void;
|
|
@@ -116,4 +116,4 @@ declare function useBumpChart(): {
|
|
|
116
116
|
y: (rank: number) => number;
|
|
117
117
|
};
|
|
118
118
|
export { BumpChartMessages as a, useBumpChartModel as i, BumpChartProps as n, bumpChartMessages as o, useBumpChart as r, BumpSeries as s, BumpChartContext as t };
|
|
119
|
-
//# sourceMappingURL=context-
|
|
119
|
+
//# sourceMappingURL=context-D7eAawR3.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-
|
|
1
|
+
{"version":3,"file":"context-D7eAawR3.d.ts","names":[],"sources":["../src/components/charts/bump-chart/model.ts","../src/components/charts/bump-chart/messages.ts","../src/components/charts/bump-chart/context.tsx"],"mappings":";UAEiB;EACf;EACA;;EAEA;EACA;;cCLW;;;;;;;;;;;;;;;;;;;;KAqBD,2BAA2B;UCZtB;;EAEf,iBAAiB;;EAEjB;;EAEA;;EAEA;;EAEA,kBAAkB;;EAElB;;EAEA,SAAS,QAAQ;EACjB,WAAW;;EAEX;;iBAGc,oBACd,QACA,SACA,QACA,eACA,gBACA,OACA,UACC;;;;;;;;;;;;;;;;;;;;;;;cAgCU,kCAAgB;;;;;;;;;;;;;;;;;;;;;;;iBACb"}
|
|
@@ -5,7 +5,7 @@ import { SPRING_PRESS } from "./lib/ease.js";
|
|
|
5
5
|
import { useLocale } from "./lib/i18n.js";
|
|
6
6
|
import { Checkbox } from "./components/motion/checkbox.js";
|
|
7
7
|
import { MorphPopover, MorphPopoverContent } from "./components/motion/popover-morph.js";
|
|
8
|
-
import { t as Tooltip } from "./tooltip-
|
|
8
|
+
import { t as Tooltip } from "./tooltip-eecPhLtC.js";
|
|
9
9
|
import { IconButton } from "./components/motion/availability-scheduler/icon-button.js";
|
|
10
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
11
|
// src/components/motion/availability-scheduler/types.ts
|
|
@@ -287,4 +287,4 @@ function CopyMenu({ from, fromLabel, t, reduce, onApply }) {
|
|
|
287
287
|
}
|
|
288
288
|
export { defaultWeek as a, startOptions as c, weekdayLabel as d, clampRange as i, toMinutes as l, WEEKDAYS as n, endOptions as o, buildOptions as r, panelKey as s, CopyMenu as t, toValue as u };
|
|
289
289
|
|
|
290
|
-
//# sourceMappingURL=copy-menu-
|
|
290
|
+
//# sourceMappingURL=copy-menu-Di77fZ9p.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copy-menu-Bgoo5oWq.js","names":[],"sources":["../src/components/motion/availability-scheduler/types.ts","../src/components/motion/availability-scheduler/copy-menu.tsx"],"sourcesContent":["\"use client\";\n\nexport type DayKey = \"mon\" | \"tue\" | \"wed\" | \"thu\" | \"fri\" | \"sat\" | \"sun\";\n\nexport type TimeRange = { id: string; start: string; end: string };\nexport type DayAvailability = { enabled: boolean; ranges: TimeRange[] };\nexport type WeekAvailability = Record<DayKey, DayAvailability>;\nexport type TimeOption = { value: string; label: string };\n\nexport const WEEKDAYS: { key: DayKey; label: string }[] = [\n { key: \"mon\", label: \"Monday\" },\n { key: \"tue\", label: \"Tuesday\" },\n { key: \"wed\", label: \"Wednesday\" },\n { key: \"thu\", label: \"Thursday\" },\n { key: \"fri\", label: \"Friday\" },\n { key: \"sat\", label: \"Saturday\" },\n { key: \"sun\", label: \"Sunday\" },\n];\n\n// ─── panels ──────────────────────────────────────────────────────────────────\n\n/**\n * Names one time field week-wide, because the scheduler holds a single open\n * panel for the whole week. Range ids belong to the value and are only unique\n * within a day, so the day is part of the name - and the scheduler builds the\n * same keys to ask whether the panel it is holding is still on screen.\n */\nexport const panelKey = (day: DayKey, rangeId: string, edge: \"start\" | \"end\") =>\n `${day}:${rangeId}:${edge}`;\n\n// ─── time helpers ────────────────────────────────────────────────────────────\n\nexport const toMinutes = (v: string) => {\n const [h, m] = v.split(\":\").map(Number);\n return h * 60 + m;\n};\n\nexport const toValue = (mins: number) => {\n const clamped = Math.max(0, Math.min(24 * 60 - 1, mins));\n const h = Math.floor(clamped / 60);\n const m = clamped % 60;\n return `${String(h).padStart(2, \"0\")}:${String(m).padStart(2, \"0\")}`;\n};\n\n/** Without a locale, keeps the English `9:00 AM` form so server and client agree. */\nexport const timeLabel = (v: string, locale?: string) => {\n const [h, m] = v.split(\":\").map(Number);\n if (locale) {\n return new Intl.DateTimeFormat(locale, {\n hour: \"numeric\",\n minute: \"2-digit\",\n timeZone: \"UTC\",\n }).format(new Date(Date.UTC(2024, 0, 1, h, m)));\n }\n const ap = h < 12 ? \"AM\" : \"PM\";\n const h12 = h % 12 === 0 ? 12 : h % 12;\n return `${h12}:${String(m).padStart(2, \"0\")} ${ap}`;\n};\n\n/** Weekday name for the locale; English `WEEKDAYS` labels without one. */\nexport const weekdayLabel = (index: number, locale?: string) =>\n locale\n ? new Intl.DateTimeFormat(locale, { weekday: \"long\", timeZone: \"UTC\" }).format(\n // 1 Jan 2024 was a Monday, matching WEEKDAYS order.\n new Date(Date.UTC(2024, 0, 1 + index)),\n )\n : WEEKDAYS[index].label;\n\nexport function buildOptions(step: number, locale?: string): TimeOption[] {\n const out: TimeOption[] = [];\n for (let m = 0; m < 24 * 60; m += step) {\n const value = toValue(m);\n out.push({ value, label: timeLabel(value, locale) });\n }\n return out;\n}\n\nfunction snapToOption(mins: number, slots: number[]) {\n let best = slots[0];\n for (const slot of slots) {\n if (Math.abs(slot - mins) < Math.abs(best - mins)) best = slot;\n }\n return best;\n}\n\nfunction withCurrentOption(\n filtered: TimeOption[],\n all: TimeOption[],\n current?: string,\n locale?: string,\n) {\n if (!current || filtered.some((o) => o.value === current)) return filtered;\n const extra =\n all.find((o) => o.value === current) ??\n ({ value: current, label: timeLabel(current, locale) } satisfies TimeOption);\n return [...filtered, extra].sort((a, b) => toMinutes(a.value) - toMinutes(b.value));\n}\n\n/**\n * Same-day ranges only. A valid pair is left alone so an off-grid persisted\n * end (17:00 with `step={720}`) is not rewritten. When the invariant fails,\n * the just-selected endpoint stays and only the opposite side moves onto a\n * neighboring generated option.\n */\nexport function clampRange(\n start: string,\n end: string,\n options: TimeOption[],\n changed: \"start\" | \"end\" = \"start\",\n): { start: string; end: string } {\n const slots = options.map((o) => toMinutes(o.value));\n if (slots.length === 0) return { start, end };\n\n const startM = toMinutes(start);\n const endM = toMinutes(end);\n if (endM > startM) return { start, end };\n\n const keepOrSnap = (value: string) => {\n const mins = toMinutes(value);\n return slots.includes(mins) ? mins : snapToOption(mins, slots);\n };\n\n if (changed === \"end\") {\n const e = keepOrSnap(end);\n const earlier = [...slots].reverse().find((slot) => slot < e);\n if (earlier === undefined && slots.length > 1) {\n // Midnight cannot end a positive same-day range, so use the first pair.\n return { start: toValue(slots[0]), end: toValue(slots[1]) };\n }\n return {\n start: toValue(earlier ?? keepOrSnap(start)),\n end: toValue(e),\n };\n }\n\n const s = keepOrSnap(start);\n const later = slots.find((slot) => slot > s);\n if (later === undefined && slots.length > 1) {\n // The last slot cannot start a positive range, so use the final pair.\n return {\n start: toValue(slots[slots.length - 2]),\n end: toValue(slots[slots.length - 1]),\n };\n }\n return {\n start: toValue(s),\n end: toValue(later ?? keepOrSnap(end)),\n };\n}\n\nexport function startOptions(\n options: TimeOption[],\n end: string,\n current?: string,\n locale?: string,\n) {\n const filtered = options.filter((o) => toMinutes(o.value) < toMinutes(end));\n // An invalid midnight end has no earlier option; expose midnight so choosing\n // it can move the end forward through clampRange instead of trapping the row.\n const recovery = filtered.length === 0 ? options.slice(0, 1) : filtered;\n return withCurrentOption(recovery, options, current, locale);\n}\n\nexport function endOptions(\n options: TimeOption[],\n start: string,\n current?: string,\n locale?: string,\n) {\n const filtered = options.filter((o) => toMinutes(o.value) > toMinutes(start));\n // An invalid last-slot start has no later option; expose the last slot so\n // choosing it can move the start backward through clampRange.\n const recovery = filtered.length === 0 ? options.slice(-1) : filtered;\n return withCurrentOption(recovery, options, current, locale);\n}\n\n// Default: Mon–Fri 9–5, weekend off. Fixed ids so SSR and first client render\n// agree (new ranges get counter ids afterwards).\nexport function defaultWeek(): WeekAvailability {\n const workday = (day: DayKey): DayAvailability => ({\n enabled: true,\n ranges: [{ id: `${day}-0`, start: \"09:00\", end: \"17:00\" }],\n });\n const off = (day: DayKey): DayAvailability => ({\n enabled: false,\n ranges: [{ id: `${day}-0`, start: \"09:00\", end: \"17:00\" }],\n });\n return {\n mon: workday(\"mon\"),\n tue: workday(\"tue\"),\n wed: workday(\"wed\"),\n thu: workday(\"thu\"),\n fri: workday(\"fri\"),\n sat: off(\"sat\"),\n sun: off(\"sun\"),\n };\n}\n","\"use client\";\n\nimport { useEffect, useRef, useState } from \"react\";\nimport { Check, Copy } from \"lucide-react\";\nimport { AnimatePresence, motion } from \"motion/react\";\n\nimport { SPRING_PRESS } from \"../../../lib/ease\";\nimport { useLocale } from \"../../../lib/i18n\";\nimport { Checkbox } from \"../checkbox\";\nimport { MorphPopover, MorphPopoverContent } from \"../popover-morph\";\nimport { Tooltip } from \"../tooltip\";\nimport { IconButton } from \"./icon-button\";\nimport type { AvailabilitySchedulerTranslate } from \"./messages\";\nimport { type DayKey, WEEKDAYS, weekdayLabel } from \"./types\";\n\n// Copy this day's hours to other days: a morph popover with a day picker.\nexport function CopyMenu({\n from,\n fromLabel,\n t,\n reduce,\n onApply,\n}: {\n from: DayKey;\n fromLabel: string;\n t: AvailabilitySchedulerTranslate;\n reduce: boolean;\n onApply: (targets: DayKey[]) => void;\n}) {\n const [open, setOpen] = useState(false);\n const [copied, setCopied] = useState(false);\n const [picked, setPicked] = useState<Set<DayKey>>(new Set());\n const { locale } = useLocale();\n const copiedTimer = useRef<number | undefined>(undefined);\n useEffect(() => () => window.clearTimeout(copiedTimer.current), []);\n const others = WEEKDAYS.flatMap((d, index) =>\n d.key === from ? [] : [{ key: d.key, label: weekdayLabel(index, locale) }],\n );\n\n const toggle = (k: DayKey) =>\n setPicked((prev) => {\n const next = new Set(prev);\n if (next.has(k)) next.delete(k);\n else next.add(k);\n return next;\n });\n\n const apply = (targets: DayKey[]) => {\n if (!targets.length) return;\n onApply(targets);\n setOpen(false);\n setPicked(new Set());\n setCopied(true);\n window.clearTimeout(copiedTimer.current);\n copiedTimer.current = window.setTimeout(() => setCopied(false), 1200);\n };\n\n return (\n <MorphPopover open={open} onOpenChange={setOpen}>\n <Tooltip content={t(\"copyTimes\")}>\n <IconButton\n label={t(\"copyDay\", { day: fromLabel })}\n reduce={reduce}\n expanded={open}\n onClick={() => setOpen(!open)}\n >\n <AnimatePresence mode=\"popLayout\" initial={false}>\n {copied ? (\n <motion.span\n key=\"done\"\n initial={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.5 }}\n animate={{ opacity: 1, scale: 1 }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.5 }}\n transition={SPRING_PRESS}\n className=\"text-foreground\"\n >\n <Check className=\"h-4 w-4\" />\n </motion.span>\n ) : (\n <motion.span\n key=\"copy\"\n initial={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.5 }}\n animate={{ opacity: 1, scale: 1 }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.5 }}\n transition={SPRING_PRESS}\n >\n <Copy className=\"h-4 w-4\" />\n </motion.span>\n )}\n </AnimatePresence>\n </IconButton>\n </Tooltip>\n\n <MorphPopoverContent align=\"end\" className=\"w-52 p-2\">\n <p className=\"text-muted-foreground px-2 py-1.5 text-xs font-medium\">{t(\"copyTo\")}</p>\n <div className=\"flex flex-col\">\n {others.map((d) => (\n <Checkbox\n key={d.key}\n checked={picked.has(d.key)}\n onCheckedChange={() => toggle(d.key)}\n label={d.label}\n className=\"hover:bg-muted [&_button[data-state=unchecked]]:border-border-strong w-full flex-row-reverse justify-between rounded-full px-3 py-1.5 transition-colors [&_button]:size-4 [&_button]:rounded-[5px] [&_button]:border\"\n />\n ))}\n </div>\n <div className=\"border-border mt-1 flex items-center gap-2 border-t px-1 pt-2\">\n <button\n type=\"button\"\n onClick={() => apply(others.map((d) => d.key))}\n className=\"text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:bg-muted flex-1 rounded-full px-2 py-1.5 text-xs font-medium transition-colors outline-none\"\n >\n {t(\"everyDay\")}\n </button>\n <button\n type=\"button\"\n onClick={() => apply([...picked])}\n disabled={picked.size === 0}\n className=\"bg-primary text-primary-foreground focus-visible:ring-ring flex-1 rounded-full px-2 py-1.5 text-xs font-medium transition-opacity outline-none hover:opacity-90 focus-visible:ring-2 disabled:opacity-40\"\n >\n {t(\"apply\")}\n </button>\n </div>\n </MorphPopoverContent>\n </MorphPopover>\n );\n}\n"],"mappings":";;;;;;;;;;;AASA,MAAa,WAA6C;CACxD;EAAE,KAAK;EAAO,OAAO;CAAS;CAC9B;EAAE,KAAK;EAAO,OAAO;CAAU;CAC/B;EAAE,KAAK;EAAO,OAAO;CAAY;CACjC;EAAE,KAAK;EAAO,OAAO;CAAW;CAChC;EAAE,KAAK;EAAO,OAAO;CAAS;CAC9B;EAAE,KAAK;EAAO,OAAO;CAAW;CAChC;EAAE,KAAK;EAAO,OAAO;CAAS;AAChC;;;;;;;AAUA,MAAa,YAAY,KAAa,SAAiB,SACrD,GAAG,IAAI,GAAG,QAAQ,GAAG;AAIvB,MAAa,aAAa,MAAc;CACtC,MAAM,CAAC,GAAG,KAAK,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,MAAM;CACtC,OAAO,IAAI,KAAK;AAClB;AAEA,MAAa,WAAW,SAAiB;CACvC,MAAM,UAAU,KAAK,IAAI,GAAG,KAAK,IAAI,MAAa,IAAI,CAAC;CACvD,MAAM,IAAI,KAAK,MAAM,UAAU,EAAE;CACjC,MAAM,IAAI,UAAU;CACpB,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG;AACnE;;AAGA,MAAa,aAAa,GAAW,WAAoB;CACvD,MAAM,CAAC,GAAG,KAAK,EAAE,MAAM,GAAG,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S;OAAG,OAAO;MAAI;MACzD,YAAY;MAEZ,UAAA,oBAAC,MAAD,EAAM,WAAU,UAAW,CAAA;KAChB,GAPP,MAOO;IAEA,CAAA;GACP,CAAA;EACL,CAAA,GAET,qBAAC,qBAAD;GAAqB,OAAM;GAAM,WAAU;GAA3C,UAAA;IACE,oBAAC,KAAD;KAAG,WAAU;KAAyD,UAAA,EAAE,QAAQ;IAAK,CAAA;IACrF,oBAAC,OAAD;KAAK,WAAU;KACZ,UAAA,OAAO,KAAK,MACX,oBAAC,UAAD;MAEE,SAAS,OAAO,IAAI,EAAE,GAAG;MACzB,uBAAuB,OAAO,EAAE,GAAG;MACnC,OAAO,EAAE;MACT,WAAU;KACX,GALM,EAAE,GAKR,CACF;IACE,CAAA;IACL,qBAAC,OAAD;KAAK,WAAU;KAAf,UAAA,CACE,oBAAC,UAAD;MACE,MAAK;MACL,eAAe,MAAM,OAAO,KAAK,MAAM,EAAE,GAAG,CAAC;MAC7C,WAAU;MAET,UAAA,EAAE,UAAU;KACP,CAAA,GACR,oBAAC,UAAD;MACE,MAAK;MACL,eAAe,MAAM,CAAC,GAAG,MAAM,CAAC;MAChC,UAAU,OAAO,SAAS;MAC1B,WAAU;MAET,UAAA,EAAE,OAAO;KACJ,CAAA,CACL;;GACc;EACT,CAAA,CAAA;;AAElB"}
|
|
1
|
+
{"version":3,"file":"copy-menu-Di77fZ9p.js","names":[],"sources":["../src/components/motion/availability-scheduler/types.ts","../src/components/motion/availability-scheduler/copy-menu.tsx"],"sourcesContent":["\"use client\";\n\nexport type DayKey = \"mon\" | \"tue\" | \"wed\" | \"thu\" | \"fri\" | \"sat\" | \"sun\";\n\nexport type TimeRange = { id: string; start: string; end: string };\nexport type DayAvailability = { enabled: boolean; ranges: TimeRange[] };\nexport type WeekAvailability = Record<DayKey, DayAvailability>;\nexport type TimeOption = { value: string; label: string };\n\nexport const WEEKDAYS: { key: DayKey; label: string }[] = [\n { key: \"mon\", label: \"Monday\" },\n { key: \"tue\", label: \"Tuesday\" },\n { key: \"wed\", label: \"Wednesday\" },\n { key: \"thu\", label: \"Thursday\" },\n { key: \"fri\", label: \"Friday\" },\n { key: \"sat\", label: \"Saturday\" },\n { key: \"sun\", label: \"Sunday\" },\n];\n\n// ─── panels ──────────────────────────────────────────────────────────────────\n\n/**\n * Names one time field week-wide, because the scheduler holds a single open\n * panel for the whole week. Range ids belong to the value and are only unique\n * within a day, so the day is part of the name - and the scheduler builds the\n * same keys to ask whether the panel it is holding is still on screen.\n */\nexport const panelKey = (day: DayKey, rangeId: string, edge: \"start\" | \"end\") =>\n `${day}:${rangeId}:${edge}`;\n\n// ─── time helpers ────────────────────────────────────────────────────────────\n\nexport const toMinutes = (v: string) => {\n const [h, m] = v.split(\":\").map(Number);\n return h * 60 + m;\n};\n\nexport const toValue = (mins: number) => {\n const clamped = Math.max(0, Math.min(24 * 60 - 1, mins));\n const h = Math.floor(clamped / 60);\n const m = clamped % 60;\n return `${String(h).padStart(2, \"0\")}:${String(m).padStart(2, \"0\")}`;\n};\n\n/** Without a locale, keeps the English `9:00 AM` form so server and client agree. */\nexport const timeLabel = (v: string, locale?: string) => {\n const [h, m] = v.split(\":\").map(Number);\n if (locale) {\n return new Intl.DateTimeFormat(locale, {\n hour: \"numeric\",\n minute: \"2-digit\",\n timeZone: \"UTC\",\n }).format(new Date(Date.UTC(2024, 0, 1, h, m)));\n }\n const ap = h < 12 ? \"AM\" : \"PM\";\n const h12 = h % 12 === 0 ? 12 : h % 12;\n return `${h12}:${String(m).padStart(2, \"0\")} ${ap}`;\n};\n\n/** Weekday name for the locale; English `WEEKDAYS` labels without one. */\nexport const weekdayLabel = (index: number, locale?: string) =>\n locale\n ? new Intl.DateTimeFormat(locale, { weekday: \"long\", timeZone: \"UTC\" }).format(\n // 1 Jan 2024 was a Monday, matching WEEKDAYS order.\n new Date(Date.UTC(2024, 0, 1 + index)),\n )\n : WEEKDAYS[index].label;\n\nexport function buildOptions(step: number, locale?: string): TimeOption[] {\n const out: TimeOption[] = [];\n for (let m = 0; m < 24 * 60; m += step) {\n const value = toValue(m);\n out.push({ value, label: timeLabel(value, locale) });\n }\n return out;\n}\n\nfunction snapToOption(mins: number, slots: number[]) {\n let best = slots[0];\n for (const slot of slots) {\n if (Math.abs(slot - mins) < Math.abs(best - mins)) best = slot;\n }\n return best;\n}\n\nfunction withCurrentOption(\n filtered: TimeOption[],\n all: TimeOption[],\n current?: string,\n locale?: string,\n) {\n if (!current || filtered.some((o) => o.value === current)) return filtered;\n const extra =\n all.find((o) => o.value === current) ??\n ({ value: current, label: timeLabel(current, locale) } satisfies TimeOption);\n return [...filtered, extra].sort((a, b) => toMinutes(a.value) - toMinutes(b.value));\n}\n\n/**\n * Same-day ranges only. A valid pair is left alone so an off-grid persisted\n * end (17:00 with `step={720}`) is not rewritten. When the invariant fails,\n * the just-selected endpoint stays and only the opposite side moves onto a\n * neighboring generated option.\n */\nexport function clampRange(\n start: string,\n end: string,\n options: TimeOption[],\n changed: \"start\" | \"end\" = \"start\",\n): { start: string; end: string } {\n const slots = options.map((o) => toMinutes(o.value));\n if (slots.length === 0) return { start, end };\n\n const startM = toMinutes(start);\n const endM = toMinutes(end);\n if (endM > startM) return { start, end };\n\n const keepOrSnap = (value: string) => {\n const mins = toMinutes(value);\n return slots.includes(mins) ? mins : snapToOption(mins, slots);\n };\n\n if (changed === \"end\") {\n const e = keepOrSnap(end);\n const earlier = [...slots].reverse().find((slot) => slot < e);\n if (earlier === undefined && slots.length > 1) {\n // Midnight cannot end a positive same-day range, so use the first pair.\n return { start: toValue(slots[0]), end: toValue(slots[1]) };\n }\n return {\n start: toValue(earlier ?? keepOrSnap(start)),\n end: toValue(e),\n };\n }\n\n const s = keepOrSnap(start);\n const later = slots.find((slot) => slot > s);\n if (later === undefined && slots.length > 1) {\n // The last slot cannot start a positive range, so use the final pair.\n return {\n start: toValue(slots[slots.length - 2]),\n end: toValue(slots[slots.length - 1]),\n };\n }\n return {\n start: toValue(s),\n end: toValue(later ?? keepOrSnap(end)),\n };\n}\n\nexport function startOptions(\n options: TimeOption[],\n end: string,\n current?: string,\n locale?: string,\n) {\n const filtered = options.filter((o) => toMinutes(o.value) < toMinutes(end));\n // An invalid midnight end has no earlier option; expose midnight so choosing\n // it can move the end forward through clampRange instead of trapping the row.\n const recovery = filtered.length === 0 ? options.slice(0, 1) : filtered;\n return withCurrentOption(recovery, options, current, locale);\n}\n\nexport function endOptions(\n options: TimeOption[],\n start: string,\n current?: string,\n locale?: string,\n) {\n const filtered = options.filter((o) => toMinutes(o.value) > toMinutes(start));\n // An invalid last-slot start has no later option; expose the last slot so\n // choosing it can move the start backward through clampRange.\n const recovery = filtered.length === 0 ? options.slice(-1) : filtered;\n return withCurrentOption(recovery, options, current, locale);\n}\n\n// Default: Mon–Fri 9–5, weekend off. Fixed ids so SSR and first client render\n// agree (new ranges get counter ids afterwards).\nexport function defaultWeek(): WeekAvailability {\n const workday = (day: DayKey): DayAvailability => ({\n enabled: true,\n ranges: [{ id: `${day}-0`, start: \"09:00\", end: \"17:00\" }],\n });\n const off = (day: DayKey): DayAvailability => ({\n enabled: false,\n ranges: [{ id: `${day}-0`, start: \"09:00\", end: \"17:00\" }],\n });\n return {\n mon: workday(\"mon\"),\n tue: workday(\"tue\"),\n wed: workday(\"wed\"),\n thu: workday(\"thu\"),\n fri: workday(\"fri\"),\n sat: off(\"sat\"),\n sun: off(\"sun\"),\n };\n}\n","\"use client\";\n\nimport { useEffect, useRef, useState } from \"react\";\nimport { Check, Copy } from \"lucide-react\";\nimport { AnimatePresence, motion } from \"motion/react\";\n\nimport { SPRING_PRESS } from \"../../../lib/ease\";\nimport { useLocale } from \"../../../lib/i18n\";\nimport { Checkbox } from \"../checkbox\";\nimport { MorphPopover, MorphPopoverContent } from \"../popover-morph\";\nimport { Tooltip } from \"../tooltip\";\nimport { IconButton } from \"./icon-button\";\nimport type { AvailabilitySchedulerTranslate } from \"./messages\";\nimport { type DayKey, WEEKDAYS, weekdayLabel } from \"./types\";\n\n// Copy this day's hours to other days: a morph popover with a day picker.\nexport function CopyMenu({\n from,\n fromLabel,\n t,\n reduce,\n onApply,\n}: {\n from: DayKey;\n fromLabel: string;\n t: AvailabilitySchedulerTranslate;\n reduce: boolean;\n onApply: (targets: DayKey[]) => void;\n}) {\n const [open, setOpen] = useState(false);\n const [copied, setCopied] = useState(false);\n const [picked, setPicked] = useState<Set<DayKey>>(new Set());\n const { locale } = useLocale();\n const copiedTimer = useRef<number | undefined>(undefined);\n useEffect(() => () => window.clearTimeout(copiedTimer.current), []);\n const others = WEEKDAYS.flatMap((d, index) =>\n d.key === from ? [] : [{ key: d.key, label: weekdayLabel(index, locale) }],\n );\n\n const toggle = (k: DayKey) =>\n setPicked((prev) => {\n const next = new Set(prev);\n if (next.has(k)) next.delete(k);\n else next.add(k);\n return next;\n });\n\n const apply = (targets: DayKey[]) => {\n if (!targets.length) return;\n onApply(targets);\n setOpen(false);\n setPicked(new Set());\n setCopied(true);\n window.clearTimeout(copiedTimer.current);\n copiedTimer.current = window.setTimeout(() => setCopied(false), 1200);\n };\n\n return (\n <MorphPopover open={open} onOpenChange={setOpen}>\n <Tooltip content={t(\"copyTimes\")}>\n <IconButton\n label={t(\"copyDay\", { day: fromLabel })}\n reduce={reduce}\n expanded={open}\n onClick={() => setOpen(!open)}\n >\n <AnimatePresence mode=\"popLayout\" initial={false}>\n {copied ? (\n <motion.span\n key=\"done\"\n initial={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.5 }}\n animate={{ opacity: 1, scale: 1 }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.5 }}\n transition={SPRING_PRESS}\n className=\"text-foreground\"\n >\n <Check className=\"h-4 w-4\" />\n </motion.span>\n ) : (\n <motion.span\n key=\"copy\"\n initial={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.5 }}\n animate={{ opacity: 1, scale: 1 }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.5 }}\n transition={SPRING_PRESS}\n >\n <Copy className=\"h-4 w-4\" />\n </motion.span>\n )}\n </AnimatePresence>\n </IconButton>\n </Tooltip>\n\n <MorphPopoverContent align=\"end\" className=\"w-52 p-2\">\n <p className=\"text-muted-foreground px-2 py-1.5 text-xs font-medium\">{t(\"copyTo\")}</p>\n <div className=\"flex flex-col\">\n {others.map((d) => (\n <Checkbox\n key={d.key}\n checked={picked.has(d.key)}\n onCheckedChange={() => toggle(d.key)}\n label={d.label}\n className=\"hover:bg-muted [&_button[data-state=unchecked]]:border-border-strong w-full flex-row-reverse justify-between rounded-full px-3 py-1.5 transition-colors [&_button]:size-4 [&_button]:rounded-[5px] [&_button]:border\"\n />\n ))}\n </div>\n <div className=\"border-border mt-1 flex items-center gap-2 border-t px-1 pt-2\">\n <button\n type=\"button\"\n onClick={() => apply(others.map((d) => d.key))}\n className=\"text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:bg-muted flex-1 rounded-full px-2 py-1.5 text-xs font-medium transition-colors outline-none\"\n >\n {t(\"everyDay\")}\n </button>\n <button\n type=\"button\"\n onClick={() => apply([...picked])}\n disabled={picked.size === 0}\n className=\"bg-primary text-primary-foreground focus-visible:ring-ring flex-1 rounded-full px-2 py-1.5 text-xs font-medium transition-opacity outline-none hover:opacity-90 focus-visible:ring-2 disabled:opacity-40\"\n >\n {t(\"apply\")}\n </button>\n </div>\n </MorphPopoverContent>\n </MorphPopover>\n );\n}\n"],"mappings":";;;;;;;;;;;AASA,MAAa,WAA6C;CACxD;EAAE,KAAK;EAAO,OAAO;CAAS;CAC9B;EAAE,KAAK;EAAO,OAAO;CAAU;CAC/B;EAAE,KAAK;EAAO,OAAO;CAAY;CACjC;EAAE,KAAK;EAAO,OAAO;CAAW;CAChC;EAAE,KAAK;EAAO,OAAO;CAAS;CAC9B;EAAE,KAAK;EAAO,OAAO;CAAW;CAChC;EAAE,KAAK;EAAO,OAAO;CAAS;AAChC;;;;;;;AAUA,MAAa,YAAY,KAAa,SAAiB,SACrD,GAAG,IAAI,GAAG,QAAQ,G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WAAU;MAET,UAAA,EAAE,OAAO;KACJ,CAAA,CACL;;GACc;EACT,CAAA,CAAA;;AAElB"}
|
|
@@ -25,6 +25,12 @@ export interface DismissOptions {
|
|
|
25
25
|
outsidePress?: boolean;
|
|
26
26
|
/** Return true for an outside target that should *not* dismiss. */
|
|
27
27
|
ignore?: (target: Element) => boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Element other overlays treat as part of this layer for outside presses
|
|
30
|
+
* and focus traps. When set, the layer uses this element alone.
|
|
31
|
+
* Default: the elements matched by `ref` and `ignore`.
|
|
32
|
+
*/
|
|
33
|
+
layerRef?: RefObject<HTMLElement | SVGElement | null>;
|
|
28
34
|
}
|
|
29
35
|
/**
|
|
30
36
|
* Close an open overlay on Escape or a pointerdown outside `ref`. Pass `null`
|
|
@@ -38,6 +44,8 @@ export interface DismissOptions {
|
|
|
38
44
|
* Each open dismissal is a layer in `lib/layers.ts`, so only the innermost
|
|
39
45
|
* open overlay answers Escape (a menu inside a drawer closes, the drawer
|
|
40
46
|
* stays), and a drawer's focus trap leaves focus in a menu it portaled out.
|
|
47
|
+
* Pass `layerRef` when other overlays should recognize a different boundary.
|
|
48
|
+
* The hook still uses `ref` and `ignore` for its own dismissal checks.
|
|
41
49
|
*/
|
|
42
|
-
export declare function useDismiss(open: boolean, onDismiss: (reason: DismissReason) => void, ref: RefObject<HTMLElement | SVGElement | null> | null, { behavior, escape: dismissOnEscape, focusOutside, outsidePress, ignore }?: DismissOptions): void;
|
|
50
|
+
export declare function useDismiss(open: boolean, onDismiss: (reason: DismissReason) => void, ref: RefObject<HTMLElement | SVGElement | null> | null, { behavior, escape: dismissOnEscape, focusOutside, outsidePress, ignore, layerRef }?: DismissOptions): void;
|
|
43
51
|
//# sourceMappingURL=use-dismiss.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-dismiss.d.ts","names":[],"sources":["../../src/hooks/use-dismiss.ts"],"mappings":";;;;;;;;;;YAeY;;YAGA;iBAEK;;EAEf,WAAW;;EAEX;;EAEA;;;;;EAKA;;EAEA,UAAU,QAAQ
|
|
1
|
+
{"version":3,"file":"use-dismiss.d.ts","names":[],"sources":["../../src/hooks/use-dismiss.ts"],"mappings":";;;;;;;;;;YAeY;;YAGA;iBAEK;;EAEf,WAAW;;EAEX;;EAEA;;;;;EAKA;;EAEA,UAAU,QAAQ;;;;;;EAMlB,WAAW,UAAU,cAAc;;;;;;;;;;;;;;;;;wBAgDrB,WACd,eACA,YAAY,QAAQ,wBACpB,KAAK,UAAU,cAAc,6BAE3B,UACA,QAAQ,iBACR,cACA,cACA,QACA,aACC"}
|
|
@@ -34,8 +34,10 @@ function consumeActivation(source) {
|
|
|
34
34
|
* Each open dismissal is a layer in `lib/layers.ts`, so only the innermost
|
|
35
35
|
* open overlay answers Escape (a menu inside a drawer closes, the drawer
|
|
36
36
|
* stays), and a drawer's focus trap leaves focus in a menu it portaled out.
|
|
37
|
+
* Pass `layerRef` when other overlays should recognize a different boundary.
|
|
38
|
+
* The hook still uses `ref` and `ignore` for its own dismissal checks.
|
|
37
39
|
*/
|
|
38
|
-
function useDismiss(open, onDismiss, ref, { behavior = "pass-through", escape: dismissOnEscape = true, focusOutside = false, outsidePress = true, ignore } = {}) {
|
|
40
|
+
function useDismiss(open, onDismiss, ref, { behavior = "pass-through", escape: dismissOnEscape = true, focusOutside = false, outsidePress = true, ignore, layerRef } = {}) {
|
|
39
41
|
const dismissRef = useRef(onDismiss);
|
|
40
42
|
const ignoreRef = useRef(ignore);
|
|
41
43
|
useLayoutEffect(() => {
|
|
@@ -46,7 +48,7 @@ function useDismiss(open, onDismiss, ref, { behavior = "pass-through", escape: d
|
|
|
46
48
|
if (!open) return;
|
|
47
49
|
const inside = (target) => Boolean(ref?.current?.contains(target)) || target instanceof Element && Boolean(ignoreRef.current?.(target));
|
|
48
50
|
const layer = {
|
|
49
|
-
contains: inside,
|
|
51
|
+
contains: layerRef ? (target) => Boolean(layerRef.current?.contains(target)) : inside,
|
|
50
52
|
escape: dismissOnEscape
|
|
51
53
|
};
|
|
52
54
|
const closeLayer = openLayer(layer);
|
|
@@ -81,7 +83,8 @@ function useDismiss(open, onDismiss, ref, { behavior = "pass-through", escape: d
|
|
|
81
83
|
behavior,
|
|
82
84
|
dismissOnEscape,
|
|
83
85
|
focusOutside,
|
|
84
|
-
outsidePress
|
|
86
|
+
outsidePress,
|
|
87
|
+
layerRef
|
|
85
88
|
]);
|
|
86
89
|
}
|
|
87
90
|
export { useDismiss };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-dismiss.js","names":[],"sources":["../../src/hooks/use-dismiss.ts"],"sourcesContent":["\"use client\";\n\nimport { type RefObject, useEffect, useLayoutEffect, useRef } from \"react\";\n\nimport { inLayerAbove, inOtherLayer, type Layer, openLayer, ownsEscape } from \"../lib/layers\";\n\n/**\n * What the dismissing gesture does to the control it landed on.\n *\n * `\"pass-through\"` is the platform norm (native popover light-dismiss): the\n * tap closes the overlay *and* activates whatever was under it. Use\n * `\"consume\"` where the open overlay sits over or beside controls that would\n * be costly to trigger by accident - the dismissal then swallows the\n * activation too, so the gesture only closes.\n */\nexport type DismissBehavior = \"pass-through\" | \"consume\";\n\n/** What closed the overlay: Escape, a pointerdown outside it, or focus leaving it. */\nexport type DismissReason = \"escape\" | \"pointer\" | \"focus\";\n\nexport interface DismissOptions {\n /** Default `\"pass-through\"`. */\n behavior?: DismissBehavior;\n /** Dismiss on Escape as well. Default true. */\n escape?: boolean;\n /** Dismiss when focus moves outside, as a combobox does on Tab. Default false. */\n focusOutside?: boolean;\n /**\n * Dismiss on a pointerdown outside. Default true. Turn it off for an overlay\n * whose own backdrop handles presses and only needs Escape and layering.\n */\n outsidePress?: boolean;\n /** Return true for an outside target that should *not* dismiss. */\n ignore?: (target: Element) => boolean;\n}\n\n// preventDefault on pointerdown does not suppress the click that follows, so\n// consuming a gesture means swallowing that click itself. The swallower\n// deliberately outlives the effect that installed it - the dismissal it\n// belongs to has already unmounted or re-rendered by the time the click lands.\n// It releases on that click, or on the next gesture if the pointer is dragged\n// away and no click ever arrives, so it can never eat a later one. A keydown\n// releases it too: a gesture that ends with neither a click nor a cancel would\n// otherwise leave it armed, and the click Enter synthesizes on some focused\n// control is not the one this dismissal was owed.\nfunction consumeActivation(source: Event) {\n const swallow = (event: MouseEvent) => {\n event.preventDefault();\n event.stopPropagation();\n release();\n };\n const restart = (event: Event) => {\n if (event !== source) release();\n };\n const release = () => {\n window.removeEventListener(\"click\", swallow, true);\n window.removeEventListener(\"pointerdown\", restart, true);\n window.removeEventListener(\"pointercancel\", restart, true);\n window.removeEventListener(\"keydown\", release, true);\n };\n window.addEventListener(\"click\", swallow, true);\n window.addEventListener(\"pointerdown\", restart, true);\n window.addEventListener(\"pointercancel\", restart, true);\n window.addEventListener(\"keydown\", release, true);\n}\n\n/**\n * Close an open overlay on Escape or a pointerdown outside `ref`. Pass `null`\n * for `ref` when what counts as inside isn't one element, and say so with\n * `ignore` instead.\n *\n * The pointerdown listener is capture-phase: a bubble-phase one is blinded by\n * any handler in between that stops propagation, and an overlay cannot know\n * what it is layered over.\n *\n * Each open dismissal is a layer in `lib/layers.ts`, so only the innermost\n * open overlay answers Escape (a menu inside a drawer closes, the drawer\n * stays), and a drawer's focus trap leaves focus in a menu it portaled out.\n */\nexport function useDismiss(\n open: boolean,\n onDismiss: (reason: DismissReason) => void,\n ref: RefObject<HTMLElement | SVGElement | null> | null,\n {\n behavior = \"pass-through\",\n escape: dismissOnEscape = true,\n focusOutside = false,\n outsidePress = true,\n ignore,\n }: DismissOptions = {},\n) {\n // Read through refs, so a callback rebuilt each render neither re-binds the\n // listeners nor moves this layer to the top of the stack.\n const dismissRef = useRef(onDismiss);\n const ignoreRef = useRef(ignore);\n useLayoutEffect(() => {\n dismissRef.current = onDismiss;\n ignoreRef.current = ignore;\n });\n\n useEffect(() => {\n if (!open) return;\n const inside = (target: Node) =>\n Boolean(ref?.current?.contains(target)) ||\n (target instanceof Element && Boolean(ignoreRef.current?.(target)));\n const layer: Layer = { contains: inside
|
|
1
|
+
{"version":3,"file":"use-dismiss.js","names":[],"sources":["../../src/hooks/use-dismiss.ts"],"sourcesContent":["\"use client\";\n\nimport { type RefObject, useEffect, useLayoutEffect, useRef } from \"react\";\n\nimport { inLayerAbove, inOtherLayer, type Layer, openLayer, ownsEscape } from \"../lib/layers\";\n\n/**\n * What the dismissing gesture does to the control it landed on.\n *\n * `\"pass-through\"` is the platform norm (native popover light-dismiss): the\n * tap closes the overlay *and* activates whatever was under it. Use\n * `\"consume\"` where the open overlay sits over or beside controls that would\n * be costly to trigger by accident - the dismissal then swallows the\n * activation too, so the gesture only closes.\n */\nexport type DismissBehavior = \"pass-through\" | \"consume\";\n\n/** What closed the overlay: Escape, a pointerdown outside it, or focus leaving it. */\nexport type DismissReason = \"escape\" | \"pointer\" | \"focus\";\n\nexport interface DismissOptions {\n /** Default `\"pass-through\"`. */\n behavior?: DismissBehavior;\n /** Dismiss on Escape as well. Default true. */\n escape?: boolean;\n /** Dismiss when focus moves outside, as a combobox does on Tab. Default false. */\n focusOutside?: boolean;\n /**\n * Dismiss on a pointerdown outside. Default true. Turn it off for an overlay\n * whose own backdrop handles presses and only needs Escape and layering.\n */\n outsidePress?: boolean;\n /** Return true for an outside target that should *not* dismiss. */\n ignore?: (target: Element) => boolean;\n /**\n * Element other overlays treat as part of this layer for outside presses\n * and focus traps. When set, the layer uses this element alone.\n * Default: the elements matched by `ref` and `ignore`.\n */\n layerRef?: RefObject<HTMLElement | SVGElement | null>;\n}\n\n// preventDefault on pointerdown does not suppress the click that follows, so\n// consuming a gesture means swallowing that click itself. The swallower\n// deliberately outlives the effect that installed it - the dismissal it\n// belongs to has already unmounted or re-rendered by the time the click lands.\n// It releases on that click, or on the next gesture if the pointer is dragged\n// away and no click ever arrives, so it can never eat a later one. A keydown\n// releases it too: a gesture that ends with neither a click nor a cancel would\n// otherwise leave it armed, and the click Enter synthesizes on some focused\n// control is not the one this dismissal was owed.\nfunction consumeActivation(source: Event) {\n const swallow = (event: MouseEvent) => {\n event.preventDefault();\n event.stopPropagation();\n release();\n };\n const restart = (event: Event) => {\n if (event !== source) release();\n };\n const release = () => {\n window.removeEventListener(\"click\", swallow, true);\n window.removeEventListener(\"pointerdown\", restart, true);\n window.removeEventListener(\"pointercancel\", restart, true);\n window.removeEventListener(\"keydown\", release, true);\n };\n window.addEventListener(\"click\", swallow, true);\n window.addEventListener(\"pointerdown\", restart, true);\n window.addEventListener(\"pointercancel\", restart, true);\n window.addEventListener(\"keydown\", release, true);\n}\n\n/**\n * Close an open overlay on Escape or a pointerdown outside `ref`. Pass `null`\n * for `ref` when what counts as inside isn't one element, and say so with\n * `ignore` instead.\n *\n * The pointerdown listener is capture-phase: a bubble-phase one is blinded by\n * any handler in between that stops propagation, and an overlay cannot know\n * what it is layered over.\n *\n * Each open dismissal is a layer in `lib/layers.ts`, so only the innermost\n * open overlay answers Escape (a menu inside a drawer closes, the drawer\n * stays), and a drawer's focus trap leaves focus in a menu it portaled out.\n * Pass `layerRef` when other overlays should recognize a different boundary.\n * The hook still uses `ref` and `ignore` for its own dismissal checks.\n */\nexport function useDismiss(\n open: boolean,\n onDismiss: (reason: DismissReason) => void,\n ref: RefObject<HTMLElement | SVGElement | null> | null,\n {\n behavior = \"pass-through\",\n escape: dismissOnEscape = true,\n focusOutside = false,\n outsidePress = true,\n ignore,\n layerRef,\n }: DismissOptions = {},\n) {\n // Read through refs, so a callback rebuilt each render neither re-binds the\n // listeners nor moves this layer to the top of the stack.\n const dismissRef = useRef(onDismiss);\n const ignoreRef = useRef(ignore);\n useLayoutEffect(() => {\n dismissRef.current = onDismiss;\n ignoreRef.current = ignore;\n });\n\n useEffect(() => {\n if (!open) return;\n const inside = (target: Node) =>\n Boolean(ref?.current?.contains(target)) ||\n (target instanceof Element && Boolean(ignoreRef.current?.(target)));\n const layer: Layer = {\n contains: layerRef ? (target) => Boolean(layerRef.current?.contains(target)) : inside,\n escape: dismissOnEscape,\n };\n const closeLayer = openLayer(layer);\n const onKey = (event: KeyboardEvent) => {\n if (!dismissOnEscape || event.key !== \"Escape\" || !ownsEscape(layer, event)) return;\n event.preventDefault();\n dismissRef.current(\"escape\");\n };\n const onPointer = (event: PointerEvent) => {\n const target = event.target as Element | null;\n if (!target || inside(target)) return;\n // A press in an overlay opened on top of this one (a tooltip or menu\n // portaled to the body) belongs to that overlay, not outside this one.\n if (inLayerAbove(layer, target)) return;\n // Outside this overlay, but inside another open one: the gesture is\n // that overlay's to answer, and swallowing its click from behind would\n // cost the user the control they actually aimed at.\n if (behavior === \"consume\" && !inOtherLayer(layer, target, { traps: false })) {\n consumeActivation(event);\n }\n dismissRef.current(\"pointer\");\n };\n const onFocus = (event: FocusEvent) => {\n const target = event.target;\n if (target instanceof Node && !inside(target)) dismissRef.current(\"focus\");\n };\n window.addEventListener(\"keydown\", onKey);\n if (outsidePress) window.addEventListener(\"pointerdown\", onPointer, true);\n if (focusOutside) window.addEventListener(\"focusin\", onFocus);\n return () => {\n closeLayer();\n window.removeEventListener(\"keydown\", onKey);\n window.removeEventListener(\"pointerdown\", onPointer, true);\n window.removeEventListener(\"focusin\", onFocus);\n };\n }, [open, ref, behavior, dismissOnEscape, focusOutside, outsidePress, layerRef]);\n}\n"],"mappings":";;;;AAmDA,SAAS,kBAAkB,QAAe;CACxC,MAAM,WAAW,UAAsB;EACrC,MAAM,eAAe;EACrB,MAAM,gBAAgB;EACtB,QAAQ;CACV;CACA,MAAM,WAAW,UAAiB;EAChC,IAAI,UAAU,QAAQ,QAAQ;CAChC;CACA,MAAM,gBAAgB;EACpB,OAAO,oBAAoB,SAAS,SAAS,IAAI;EACjD,OAAO,oBAAoB,eAAe,SAAS,IAAI;EACvD,OAAO,oBAAoB,iBAAiB,SAAS,IAAI;EACzD,OAAO,oBAAoB,WAAW,SAAS,IAAI;CACrD;CACA,OAAO,iBAAiB,SAAS,SAAS,IAAI;CAC9C,OAAO,iBAAiB,eAAe,SAAS,IAAI;CACpD,OAAO,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EACxE,IAAI,cAAc,OAAO,iBAAiB,WAAW,OAAO;EAC5D,aAAa;GACX,WAAW;GACX,OAAO,oBAAoB,WAAW,KAAK;GAC3C,OAAO,oBAAoB,eAAe,WAAW,IAAI;GACzD,OAAO,oBAAoB,WAAW,OAAO;EAC/C;CACF,GAAG;EAAC;EAAM;EAAK;EAAU;EAAiB;EAAc;EAAc;CAAQ,CAAC;AACjF"}
|
package/dist/lib/layers.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export interface Layer {
|
|
2
|
-
/** Whether `target` belongs to this layer
|
|
2
|
+
/** Whether `target` belongs to this layer for outside presses and focus. */
|
|
3
3
|
contains: (target: Node) => boolean;
|
|
4
4
|
/** True for focus traps and modal scopes, which pull stray focus back. */
|
|
5
5
|
traps?: boolean;
|
package/dist/lib/layers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layers.js","names":[],"sources":["../../src/lib/layers.ts"],"sourcesContent":["export interface Layer {\n /** Whether `target` belongs to this layer
|
|
1
|
+
{"version":3,"file":"layers.js","names":[],"sources":["../../src/lib/layers.ts"],"sourcesContent":["export interface Layer {\n /** Whether `target` belongs to this layer for outside presses and focus. */\n contains: (target: Node) => boolean;\n /** True for focus traps and modal scopes, which pull stray focus back. */\n traps?: boolean;\n /** False for a layer that ignores Escape, so the key reaches the one below. */\n escape?: boolean;\n}\n\nconst stack: Layer[] = [];\n// The innermost layer when each Escape began, read before any handler runs,\n// so a layer that closes itself mid-event can't hand the key to the one below.\nconst escapeOwners = new WeakMap<Event, Layer | undefined>();\nlet listening = false;\n\nfunction innermostEscapeLayer() {\n for (let index = stack.length - 1; index >= 0; index--) {\n if (stack[index].escape !== false) return stack[index];\n }\n return undefined;\n}\n\nfunction recordEscapeOwner(event: KeyboardEvent) {\n if (event.key === \"Escape\") escapeOwners.set(event, innermostEscapeLayer());\n}\n\n/** Registers an open layer. Call the returned function when it closes. */\nexport function openLayer(layer: Layer) {\n if (!listening) {\n document.addEventListener(\"keydown\", recordEscapeOwner, true);\n listening = true;\n }\n stack.push(layer);\n return () => {\n const index = stack.indexOf(layer);\n if (index !== -1) stack.splice(index, 1);\n };\n}\n\n/** Whether this Escape is `layer`'s to answer: it was innermost when the key went down. */\nexport function ownsEscape(layer: Layer, event: KeyboardEvent) {\n if (event.defaultPrevented) return false;\n const owner = escapeOwners.has(event) ? escapeOwners.get(event) : innermostEscapeLayer();\n return owner === layer;\n}\n\n/** Whether `target` sits in a layer opened on top of `layer`. */\nexport function inLayerAbove(layer: Layer, target: Node) {\n const index = stack.indexOf(layer);\n return stack.slice(index + 1).some((above) => above.contains(target));\n}\n\n/** Whether a focus trap is open on top of `layer`; stray focus is that one's to pull back. */\nexport function trapAbove(layer: Layer) {\n const index = stack.indexOf(layer);\n return stack.slice(index + 1).some((above) => above.traps);\n}\n\n/**\n * Whether `target` belongs to any open layer other than `layer`. Pass\n * `traps: false` to count only dismissable overlays, not the traps under them.\n */\nexport function inOtherLayer(layer: Layer, target: Node, { traps = true } = {}) {\n return stack.some(\n (other) => other !== layer && (traps || !other.traps) && other.contains(target),\n );\n}\n"],"mappings":";AASA,MAAM,QAAiB,CAAC;AAGxB,MAAM,+BAAe,IAAI,QAAkC;AAC3D,IAAI,YAAY;AAEhB,SAAS,uBAAuB;CAC9B,KAAK,IAAI,QAAQ,MAAM,SAAS,GAAG,SAAS,GAAG,SAC7C,IAAI,MAAM,MAAM,CAAC,WAAW,OAAO,OAAO,MAAM;AAGpD;AAEA,SAAS,kBAAkB,OAAsB;CAC/C,IAAI,MAAM,QAAQ,UAAU,aAAa,IAAI,OAAO,qBAAqB,CAAC;AAC5E;;AAGA,SAAgB,UAAU,OAAc;CACtC,IAAI,CAAC,WAAW;EACd,SAAS,iBAAiB,WAAW,mBAAmB,IAAI;EAC5D,YAAY;CACd;CACA,MAAM,KAAK,KAAK;CAChB,aAAa;EACX,MAAM,QAAQ,MAAM,QAAQ,KAAK;EACjC,IAAI,UAAU,IAAI,MAAM,OAAO,OAAO,CAAC;CACzC;AACF;;AAGA,SAAgB,WAAW,OAAc,OAAsB;CAC7D,IAAI,MAAM,kBAAkB,OAAO;CAEnC,QADc,aAAa,IAAI,KAAK,IAAI,aAAa,IAAI,KAAK,IAAI,qBAAqB,OACtE;AACnB;;AAGA,SAAgB,aAAa,OAAc,QAAc;CACvD,MAAM,QAAQ,MAAM,QAAQ,KAAK;CACjC,OAAO,MAAM,MAAM,QAAQ,CAAC,CAAC,CAAC,MAAM,UAAU,MAAM,SAAS,MAAM,CAAC;AACtE;;AAGA,SAAgB,UAAU,OAAc;CACtC,MAAM,QAAQ,MAAM,QAAQ,KAAK;CACjC,OAAO,MAAM,MAAM,QAAQ,CAAC,CAAC,CAAC,MAAM,UAAU,MAAM,KAAK;AAC3D;;;;;AAMA,SAAgB,aAAa,OAAc,QAAc,EAAE,QAAQ,SAAS,CAAC,GAAG;CAC9E,OAAO,MAAM,MACV,UAAU,UAAU,UAAU,SAAS,CAAC,MAAM,UAAU,MAAM,SAAS,MAAM,CAChF;AACF"}
|
|
@@ -5,7 +5,7 @@ import { cn } from "@kumix/utils";
|
|
|
5
5
|
import { useTouchCapable } from "./hooks/use-touch-capable.js";
|
|
6
6
|
import { SPRING_LAYOUT } from "./lib/ease.js";
|
|
7
7
|
import { MorphPopover, MorphPopoverContent, MorphPopoverTrigger } from "./components/motion/popover-morph.js";
|
|
8
|
-
import { t as Tooltip } from "./tooltip-
|
|
8
|
+
import { t as Tooltip } from "./tooltip-eecPhLtC.js";
|
|
9
9
|
import { MarqueeLabel } from "./components/agents/ai-sidebar/marquee-label.js";
|
|
10
10
|
import { ResourceMenuAction } from "./components/agents/ai-sidebar/resource-menu-action.js";
|
|
11
11
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -287,4 +287,4 @@ function ActionsTrigger({ className, ...props }) {
|
|
|
287
287
|
}
|
|
288
288
|
export { flattenResources as a, findResource as i, canContain as n, moveResource as o, containsResource as r, renameResource as s, ResourceRow as t };
|
|
289
289
|
|
|
290
|
-
//# sourceMappingURL=resource-row-
|
|
290
|
+
//# sourceMappingURL=resource-row-DByzjie0.js.map
|