@adea-ai/ui 0.107.0 → 0.109.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/dist/NOTICE +13 -0
- package/dist/components/layout/contextual-sidebar/contextual-sidebar.d.ts +55 -0
- package/dist/components/layout/contextual-sidebar/contextual-sidebar.d.ts.map +1 -0
- package/dist/components/layout/contextual-sidebar/contextual-sidebar.js +199 -0
- package/dist/components/layout/contextual-sidebar/contextual-sidebar.js.map +1 -0
- package/dist/components/layout/contextual-sidebar/index.d.ts +3 -0
- package/dist/components/layout/contextual-sidebar/index.d.ts.map +1 -0
- package/dist/components/layout/contextual-sidebar/index.js +3 -0
- package/dist/components/layout/pixel-resize-handle/index.d.ts +2 -0
- package/dist/components/layout/pixel-resize-handle/index.d.ts.map +1 -0
- package/dist/components/layout/pixel-resize-handle/index.js +2 -0
- package/dist/components/layout/pixel-resize-handle/pixel-resize-handle.d.ts +29 -0
- package/dist/components/layout/pixel-resize-handle/pixel-resize-handle.d.ts.map +1 -0
- package/dist/components/layout/pixel-resize-handle/pixel-resize-handle.js +183 -0
- package/dist/components/layout/pixel-resize-handle/pixel-resize-handle.js.map +1 -0
- package/dist/components/layout/sidebar-nav/sidebar-nav-resize-handle.d.ts +3 -19
- package/dist/components/layout/sidebar-nav/sidebar-nav-resize-handle.d.ts.map +1 -1
- package/dist/components/layout/sidebar-nav/sidebar-nav-resize-handle.js +8 -76
- package/dist/components/layout/sidebar-nav/sidebar-nav-resize-handle.js.map +1 -1
- package/dist/components/ui/annotation-surface/annotation-surface.css +27 -0
- package/dist/components/ui/annotation-surface/annotation-surface.d.ts +66 -0
- package/dist/components/ui/annotation-surface/annotation-surface.d.ts.map +1 -0
- package/dist/components/ui/annotation-surface/annotation-surface.js +244 -0
- package/dist/components/ui/annotation-surface/annotation-surface.js.map +1 -0
- package/dist/components/ui/annotation-surface/geometry.d.ts +10 -0
- package/dist/components/ui/annotation-surface/geometry.d.ts.map +1 -0
- package/dist/components/ui/annotation-surface/geometry.js +19 -0
- package/dist/components/ui/annotation-surface/geometry.js.map +1 -0
- package/dist/components/ui/annotation-surface/index.d.ts +4 -0
- package/dist/components/ui/annotation-surface/index.d.ts.map +1 -0
- package/dist/components/ui/annotation-surface/index.js +2 -0
- package/dist/components/ui/resizable/resizable.d.ts.map +1 -1
- package/dist/components/ui/resizable/resizable.js +2 -2
- package/dist/components/ui/resizable/resizable.js.map +1 -1
- package/dist/components/ui/sheet/sheet.d.ts +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/lint/index.d.ts.map +1 -1
- package/dist/lint.js +154 -20
- package/dist/lint.js.map +1 -1
- package/dist/r/annotation-surface.json +32 -0
- package/dist/r/contextual-sidebar.json +25 -0
- package/dist/r/pixel-resize-handle.json +23 -0
- package/dist/r/registry.json +81 -1
- package/dist/r/sidebar-nav.json +1 -1
- package/dist/r/src/components/layout/contextual-sidebar/contextual-sidebar.tsx +180 -0
- package/dist/r/src/components/layout/contextual-sidebar/index.ts +6 -0
- package/dist/r/src/components/layout/pixel-resize-handle/index.ts +1 -0
- package/dist/r/src/components/layout/pixel-resize-handle/pixel-resize-handle.tsx +177 -0
- package/dist/r/src/components/layout/sidebar-nav/sidebar-nav-resize-handle.tsx +7 -55
- package/dist/r/src/components/ui/annotation-surface/annotation-surface.css +27 -0
- package/dist/r/src/components/ui/annotation-surface/annotation-surface.tsx +316 -0
- package/dist/r/src/components/ui/annotation-surface/geometry.ts +31 -0
- package/dist/r/src/components/ui/annotation-surface/index.ts +13 -0
- package/dist/r/src/components/ui/resizable/resizable.tsx +4 -2
- package/package.json +5 -2
- package/registry.json +81 -1
- package/src/components/layout/contextual-sidebar/contextual-sidebar.tsx +180 -0
- package/src/components/layout/contextual-sidebar/index.ts +6 -0
- package/src/components/layout/pixel-resize-handle/index.ts +1 -0
- package/src/components/layout/pixel-resize-handle/pixel-resize-handle.tsx +177 -0
- package/src/components/layout/sidebar-nav/sidebar-nav-resize-handle.tsx +7 -55
- package/src/components/ui/annotation-surface/annotation-surface.css +27 -0
- package/src/components/ui/annotation-surface/annotation-surface.tsx +316 -0
- package/src/components/ui/annotation-surface/geometry.ts +31 -0
- package/src/components/ui/annotation-surface/index.ts +13 -0
- package/src/components/ui/resizable/resizable.tsx +4 -2
- package/src/index.ts +2 -0
- package/src/lint/index.ts +234 -22
|
@@ -1,82 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createComponent } from "solid-js/web";
|
|
3
|
-
import Resizable from "@corvu/resizable";
|
|
1
|
+
import { PixelResizeHandle } from "../pixel-resize-handle/pixel-resize-handle.js";
|
|
2
|
+
import { createComponent, mergeProps } from "solid-js/web";
|
|
4
3
|
//#region src/components/layout/sidebar-nav/sidebar-nav-resize-handle.tsx
|
|
5
|
-
/**
|
|
6
|
-
* Resize a contextual sidebar without making its host recreate a separator
|
|
7
|
-
* widget. Corvu owns pointer capture, cancellation, constraints, keyboard
|
|
8
|
-
* movement and cleanup. Its two invisible panels provide a bounded pixel
|
|
9
|
-
* ruler; the host retains the real pane layout and preference persistence.
|
|
10
|
-
* Place this inside the positioned sidebar. The ruler can extend over the
|
|
11
|
-
* adjacent content, but only its handle participates in pointer hit testing.
|
|
12
|
-
*/
|
|
4
|
+
/** Keep the established left-sidebar API as a thin adapter over the shared edge ruler. */
|
|
13
5
|
function SidebarNavResizeHandle(props) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return createComponent(Resizable, {
|
|
19
|
-
orientation: "horizontal",
|
|
20
|
-
get sizes() {
|
|
21
|
-
return [value() / maximum(), 1 - value() / maximum()];
|
|
22
|
-
},
|
|
23
|
-
get keyboardDelta() {
|
|
24
|
-
return `${props.step ?? 16}px`;
|
|
25
|
-
},
|
|
26
|
-
get style() {
|
|
27
|
-
return { width: `${maximum()}px` };
|
|
28
|
-
},
|
|
29
|
-
get ["class"]() {
|
|
30
|
-
return cn("pointer-events-none absolute inset-y-0 start-0 flex", props.class);
|
|
31
|
-
},
|
|
32
|
-
onSizesChange: (sizes) => {
|
|
33
|
-
const next = Math.round((sizes[0] ?? 0) * maximum());
|
|
34
|
-
if (next !== value()) props.onChange(Math.min(maximum(), Math.max(minimum(), next)));
|
|
35
|
-
},
|
|
36
|
-
get children() {
|
|
37
|
-
return [
|
|
38
|
-
createComponent(Resizable.Panel, {
|
|
39
|
-
get minSize() {
|
|
40
|
-
return minimum() / maximum();
|
|
41
|
-
},
|
|
42
|
-
maxSize: 1,
|
|
43
|
-
"aria-hidden": "true"
|
|
44
|
-
}),
|
|
45
|
-
createComponent(Resizable.Handle, {
|
|
46
|
-
get ["aria-label"]() {
|
|
47
|
-
return props.label ?? "Resize navigation";
|
|
48
|
-
},
|
|
49
|
-
get ["aria-controls"]() {
|
|
50
|
-
return props.controls;
|
|
51
|
-
},
|
|
52
|
-
"aria-orientation": "vertical",
|
|
53
|
-
get ["aria-valuemin"]() {
|
|
54
|
-
return minimum();
|
|
55
|
-
},
|
|
56
|
-
get ["aria-valuemax"]() {
|
|
57
|
-
return maximum();
|
|
58
|
-
},
|
|
59
|
-
get ["aria-valuenow"]() {
|
|
60
|
-
return value();
|
|
61
|
-
},
|
|
62
|
-
onHandleDragEnd: commit,
|
|
63
|
-
onKeyUp: (event) => {
|
|
64
|
-
if ([
|
|
65
|
-
"ArrowLeft",
|
|
66
|
-
"ArrowRight",
|
|
67
|
-
"Home",
|
|
68
|
-
"End"
|
|
69
|
-
].includes(event.key)) commit();
|
|
70
|
-
},
|
|
71
|
-
"class": "pointer-events-auto relative z-(--z-docked) w-px -translate-x-full shrink-0 bg-transparent after:absolute after:inset-y-0 after:-inset-x-1 after:w-3 hover:bg-primary focus-visible:bg-primary focus-visible:ring-3 focus-visible:ring-primary-subtle focus-visible:outline-none"
|
|
72
|
-
}),
|
|
73
|
-
createComponent(Resizable.Panel, {
|
|
74
|
-
minSize: 0,
|
|
75
|
-
"aria-hidden": "true"
|
|
76
|
-
})
|
|
77
|
-
];
|
|
6
|
+
return createComponent(PixelResizeHandle, mergeProps(props, {
|
|
7
|
+
side: "left",
|
|
8
|
+
get label() {
|
|
9
|
+
return props.label ?? "Resize navigation";
|
|
78
10
|
}
|
|
79
|
-
});
|
|
11
|
+
}));
|
|
80
12
|
}
|
|
81
13
|
//#endregion
|
|
82
14
|
export { SidebarNavResizeHandle };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sidebar-nav-resize-handle.js","names":["
|
|
1
|
+
{"version":3,"file":"sidebar-nav-resize-handle.js","names":["PixelResizeHandle","PixelResizeHandleProps","SidebarNavResizeHandleProps","Omit","SidebarNavResizeHandle","props","_$createComponent","_$mergeProps","side","label","_$createComponent","_$mergeProps"],"sources":["../../../../src/components/layout/sidebar-nav/sidebar-nav-resize-handle.tsx"],"sourcesContent":["import {\n PixelResizeHandle,\n type PixelResizeHandleProps,\n} from '../pixel-resize-handle/pixel-resize-handle'\n\nexport type SidebarNavResizeHandleProps = Omit<PixelResizeHandleProps, 'side'>\n\n/** Keep the established left-sidebar API as a thin adapter over the shared edge ruler. */\nexport function SidebarNavResizeHandle(props: SidebarNavResizeHandleProps) {\n return <PixelResizeHandle {...props} side=\"left\" label={props.label ?? 'Resize navigation'} />\n}\n"],"mappings":";;;;AAQA,SAAgBI,uBAAuBC,OAAoC;CACzE,OAAAC,gBAAQN,mBAAiBO,WAAKF,OAAK;EAAEG,MAAI;EAAA,IAAQC,QAAK;GAAA,OAAEJ,MAAMI,SAAS;EAAmB;CAAA,CAAA,CAAA;AAC5F"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
.dev-annotation-surface {
|
|
2
|
+
touch-action: none;
|
|
3
|
+
cursor: crosshair;
|
|
4
|
+
background-image: repeating-linear-gradient(
|
|
5
|
+
45deg,
|
|
6
|
+
color-mix(in oklch, var(--muted) 55%, transparent) 0 calc(var(--spacing) * 2),
|
|
7
|
+
transparent calc(var(--spacing) * 2) calc(var(--spacing) * 4)
|
|
8
|
+
);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.dev-annotation-surface[data-tool='point'] {
|
|
12
|
+
cursor: cell;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.dev-annotation-surface[data-dragging='true'] {
|
|
16
|
+
cursor: grabbing;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.dev-annotation-surface[aria-disabled='true'] {
|
|
20
|
+
touch-action: auto;
|
|
21
|
+
cursor: default;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.dev-annotation-surface__region,
|
|
25
|
+
.dev-annotation-surface__hint {
|
|
26
|
+
pointer-events: none;
|
|
27
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { type JSX } from 'solid-js';
|
|
2
|
+
import './annotation-surface.css';
|
|
3
|
+
import { type AnnotationSurfacePoint } from './geometry';
|
|
4
|
+
export type AnnotationSurfaceRegion = Readonly<{
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
}>;
|
|
10
|
+
export type AnnotationSurfaceDrag = Readonly<{
|
|
11
|
+
start: AnnotationSurfacePoint;
|
|
12
|
+
current: AnnotationSurfacePoint;
|
|
13
|
+
}>;
|
|
14
|
+
export type AnnotationSurfaceTool = 'region' | 'point';
|
|
15
|
+
export type AnnotationSurfaceDragPhase = 'start' | 'move' | 'end' | 'cancel' | 'keyboard';
|
|
16
|
+
export type AnnotationSurfacePointerEvent = PointerEvent & {
|
|
17
|
+
currentTarget: HTMLDivElement;
|
|
18
|
+
};
|
|
19
|
+
export type AnnotationSurfaceKeyboardEvent = KeyboardEvent & {
|
|
20
|
+
currentTarget: HTMLDivElement;
|
|
21
|
+
};
|
|
22
|
+
export type AnnotationSurfaceInputEvent = AnnotationSurfacePointerEvent | AnnotationSurfaceKeyboardEvent;
|
|
23
|
+
type SurfaceElementProps = Pick<JSX.HTMLAttributes<HTMLDivElement>, 'id' | 'aria-describedby'>;
|
|
24
|
+
export type AnnotationSurfaceProps = SurfaceElementProps & {
|
|
25
|
+
/** Accessible instructions for the keyboard-operated surface. */
|
|
26
|
+
label: string;
|
|
27
|
+
/** Region draws a captured drag; point reports a single placement point. */
|
|
28
|
+
tool: AnnotationSurfaceTool;
|
|
29
|
+
/** Normalized 0..1 geometry supplied by the host; absent means no region. */
|
|
30
|
+
region?: AnnotationSurfaceRegion;
|
|
31
|
+
/** Visible idle guidance. It is hidden while a region is present. */
|
|
32
|
+
hint?: JSX.Element;
|
|
33
|
+
/** Disable new drawing while the host is busy. Defaults to true. */
|
|
34
|
+
interactive?: boolean;
|
|
35
|
+
/** Changing this value cancels an in-flight drag owned by the host context. */
|
|
36
|
+
resetKey?: string | number;
|
|
37
|
+
/** Receives one normalized point in point mode. */
|
|
38
|
+
onPoint?: (point: AnnotationSurfacePoint, event: AnnotationSurfaceInputEvent) => void;
|
|
39
|
+
/** Receives drag phases; cancel has no drag and fires at most once per capture. */
|
|
40
|
+
onDragChange?: (drag: AnnotationSurfaceDrag | undefined, phase: AnnotationSurfaceDragPhase, event?: AnnotationSurfaceInputEvent) => void;
|
|
41
|
+
/** Domain keyboard policy stays with the host and receives the native event. */
|
|
42
|
+
onKeyDown?: (event: AnnotationSurfaceKeyboardEvent) => void;
|
|
43
|
+
/** Ref to the actual focusable and pointer-capturing HTMLDivElement. */
|
|
44
|
+
ref?: (element: HTMLDivElement) => void;
|
|
45
|
+
/** Layout only; appearance remains owned by the shared component. */
|
|
46
|
+
class?: string;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* AnnotationSurface.
|
|
50
|
+
*
|
|
51
|
+
* A keyboard-focusable, viewport-shaped drawing surface for hosts that own an
|
|
52
|
+
* annotation domain. It renders normalized region geometry and idle guidance,
|
|
53
|
+
* captures region drags, and reports normalized points without reading or
|
|
54
|
+
* rendering screenshot pixels. The host keeps tool policy, domain geometry,
|
|
55
|
+
* persistence and capture commands.
|
|
56
|
+
*
|
|
57
|
+
* This bespoke application widget is necessary because a generic button or
|
|
58
|
+
* slider cannot represent a two-dimensional drawing viewport. Its keyboard
|
|
59
|
+
* behavior is supplied by the host and forwarded as a native key event. Space
|
|
60
|
+
* creates a centered region or places a point at the center; Escape is left to
|
|
61
|
+
* the host first, which can prevent the default gesture cancellation while it
|
|
62
|
+
* applies its own draft and mode rules.
|
|
63
|
+
*/
|
|
64
|
+
export declare function AnnotationSurface(props: AnnotationSurfaceProps): JSX.Element;
|
|
65
|
+
export {};
|
|
66
|
+
//# sourceMappingURL=annotation-surface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotation-surface.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/annotation-surface/annotation-surface.tsx"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,GAAG,EACT,MAAM,UAAU,CAAA;AAEjB,OAAO,0BAA0B,CAAA;AACjC,OAAO,EAGL,KAAK,sBAAsB,EAC5B,MAAM,YAAY,CAAA;AAEnB,MAAM,MAAM,uBAAuB,GAAG,QAAQ,CAAC;IAC7C,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf,CAAC,CAAA;AAEF,MAAM,MAAM,qBAAqB,GAAG,QAAQ,CAAC;IAC3C,KAAK,EAAE,sBAAsB,CAAA;IAC7B,OAAO,EAAE,sBAAsB,CAAA;CAChC,CAAC,CAAA;AAEF,MAAM,MAAM,qBAAqB,GAAG,QAAQ,GAAG,OAAO,CAAA;AACtD,MAAM,MAAM,0BAA0B,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,UAAU,CAAA;AACzF,MAAM,MAAM,6BAA6B,GAAG,YAAY,GAAG;IAAE,aAAa,EAAE,cAAc,CAAA;CAAE,CAAA;AAC5F,MAAM,MAAM,8BAA8B,GAA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../lib/utils.js";
|
|
2
|
+
import { clampSurfaceFraction, normalizedSurfacePoint } from "./geometry.js";
|
|
3
|
+
import { className, createComponent, delegateEvents, effect, insert, memo, setAttribute, template, use } from "solid-js/web";
|
|
4
|
+
import { Show, createEffect, createSignal, createUniqueId, onCleanup, splitProps } from "solid-js";
|
|
5
|
+
import "./annotation-surface.css";
|
|
6
|
+
//#region src/components/ui/annotation-surface/annotation-surface.tsx
|
|
7
|
+
var _tmpl$ = /*#__PURE__*/ template(`<span class="dev-annotation-surface__hint pointer-events-none absolute inset-0 grid place-items-center p-4 text-center text-xs text-muted-foreground">`);
|
|
8
|
+
var _tmpl$2 = /*#__PURE__*/ template(`<div role=application aria-roledescription="annotation surface"tabindex=0>`);
|
|
9
|
+
var _tmpl$3 = /*#__PURE__*/ template(`<svg class="dev-annotation-surface__region pointer-events-none absolute inset-0 size-full"viewBox="0 0 10000 10000"preserveAspectRatio=none aria-hidden=true><rect class="fill-primary-subtle stroke-primary"stroke-width=1.5 vector-effect=non-scaling-stroke>`);
|
|
10
|
+
function pointFrom(event, target) {
|
|
11
|
+
const bounds = target.getBoundingClientRect();
|
|
12
|
+
return normalizedSurfacePoint(event.clientX, event.clientY, bounds);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* AnnotationSurface.
|
|
16
|
+
*
|
|
17
|
+
* A keyboard-focusable, viewport-shaped drawing surface for hosts that own an
|
|
18
|
+
* annotation domain. It renders normalized region geometry and idle guidance,
|
|
19
|
+
* captures region drags, and reports normalized points without reading or
|
|
20
|
+
* rendering screenshot pixels. The host keeps tool policy, domain geometry,
|
|
21
|
+
* persistence and capture commands.
|
|
22
|
+
*
|
|
23
|
+
* This bespoke application widget is necessary because a generic button or
|
|
24
|
+
* slider cannot represent a two-dimensional drawing viewport. Its keyboard
|
|
25
|
+
* behavior is supplied by the host and forwarded as a native key event. Space
|
|
26
|
+
* creates a centered region or places a point at the center; Escape is left to
|
|
27
|
+
* the host first, which can prevent the default gesture cancellation while it
|
|
28
|
+
* applies its own draft and mode rules.
|
|
29
|
+
*/
|
|
30
|
+
function AnnotationSurface(props) {
|
|
31
|
+
const [local] = splitProps(props, [
|
|
32
|
+
"id",
|
|
33
|
+
"aria-describedby",
|
|
34
|
+
"label",
|
|
35
|
+
"tool",
|
|
36
|
+
"region",
|
|
37
|
+
"hint",
|
|
38
|
+
"interactive",
|
|
39
|
+
"resetKey",
|
|
40
|
+
"onPoint",
|
|
41
|
+
"onDragChange",
|
|
42
|
+
"onKeyDown",
|
|
43
|
+
"ref",
|
|
44
|
+
"class"
|
|
45
|
+
]);
|
|
46
|
+
const [dragging, setDragging] = createSignal(false);
|
|
47
|
+
const hintId = createUniqueId();
|
|
48
|
+
let activeDrag;
|
|
49
|
+
let previousResetKey = local.resetKey;
|
|
50
|
+
let previousTool = local.tool;
|
|
51
|
+
const isInteractive = () => local.interactive ?? true;
|
|
52
|
+
function releaseCapture(drag) {
|
|
53
|
+
try {
|
|
54
|
+
if (drag.target.hasPointerCapture(drag.pointerId)) drag.target.releasePointerCapture(drag.pointerId);
|
|
55
|
+
} catch {}
|
|
56
|
+
}
|
|
57
|
+
function cancelDrag(event, release = true) {
|
|
58
|
+
const drag = activeDrag;
|
|
59
|
+
if (!drag) return;
|
|
60
|
+
activeDrag = void 0;
|
|
61
|
+
setDragging(false);
|
|
62
|
+
if (release) releaseCapture(drag);
|
|
63
|
+
local.onDragChange?.(void 0, "cancel", event);
|
|
64
|
+
}
|
|
65
|
+
createEffect(() => {
|
|
66
|
+
const resetKey = local.resetKey;
|
|
67
|
+
const tool = local.tool;
|
|
68
|
+
const interactive = isInteractive();
|
|
69
|
+
if (activeDrag && (resetKey !== previousResetKey || tool !== previousTool || !interactive)) cancelDrag();
|
|
70
|
+
previousResetKey = resetKey;
|
|
71
|
+
previousTool = tool;
|
|
72
|
+
});
|
|
73
|
+
onCleanup(() => cancelDrag());
|
|
74
|
+
function handlePointerDown(event) {
|
|
75
|
+
if (!isInteractive() || !event.isPrimary || event.button !== 0) return;
|
|
76
|
+
event.preventDefault();
|
|
77
|
+
event.currentTarget.focus({ preventScroll: true });
|
|
78
|
+
const point = pointFrom(event, event.currentTarget);
|
|
79
|
+
if (activeDrag) return;
|
|
80
|
+
if (local.tool === "point") {
|
|
81
|
+
local.onPoint?.(point, event);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
86
|
+
} catch {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
activeDrag = {
|
|
90
|
+
pointerId: event.pointerId,
|
|
91
|
+
target: event.currentTarget,
|
|
92
|
+
start: point,
|
|
93
|
+
current: point
|
|
94
|
+
};
|
|
95
|
+
setDragging(true);
|
|
96
|
+
local.onDragChange?.({
|
|
97
|
+
start: point,
|
|
98
|
+
current: point
|
|
99
|
+
}, "start", event);
|
|
100
|
+
}
|
|
101
|
+
function handlePointerMove(event) {
|
|
102
|
+
const drag = activeDrag;
|
|
103
|
+
if (!drag || drag.pointerId !== event.pointerId) return;
|
|
104
|
+
const current = pointFrom(event, event.currentTarget);
|
|
105
|
+
activeDrag = {
|
|
106
|
+
...drag,
|
|
107
|
+
current
|
|
108
|
+
};
|
|
109
|
+
local.onDragChange?.({
|
|
110
|
+
start: drag.start,
|
|
111
|
+
current
|
|
112
|
+
}, "move", event);
|
|
113
|
+
}
|
|
114
|
+
function handlePointerUp(event) {
|
|
115
|
+
const drag = activeDrag;
|
|
116
|
+
if (!drag || drag.pointerId !== event.pointerId) return;
|
|
117
|
+
const current = pointFrom(event, event.currentTarget);
|
|
118
|
+
activeDrag = void 0;
|
|
119
|
+
setDragging(false);
|
|
120
|
+
releaseCapture(drag);
|
|
121
|
+
local.onDragChange?.({
|
|
122
|
+
start: drag.start,
|
|
123
|
+
current
|
|
124
|
+
}, "end", event);
|
|
125
|
+
}
|
|
126
|
+
function handlePointerCancel(event) {
|
|
127
|
+
if (activeDrag?.pointerId === event.pointerId) cancelDrag(event);
|
|
128
|
+
}
|
|
129
|
+
function handleLostPointerCapture(event) {
|
|
130
|
+
if (activeDrag?.pointerId === event.pointerId) cancelDrag(event, false);
|
|
131
|
+
}
|
|
132
|
+
function handleKeyDown(event) {
|
|
133
|
+
local.onKeyDown?.(event);
|
|
134
|
+
if (event.key === "Escape") {
|
|
135
|
+
if (!event.defaultPrevented) cancelDrag();
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (event.defaultPrevented || !isInteractive() || event.key !== " " || event.repeat || event.isComposing || event.altKey || event.ctrlKey || event.metaKey || activeDrag) return;
|
|
139
|
+
event.preventDefault();
|
|
140
|
+
if (local.tool === "point") {
|
|
141
|
+
local.onPoint?.({
|
|
142
|
+
x: .5,
|
|
143
|
+
y: .5
|
|
144
|
+
}, event);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
local.onDragChange?.({
|
|
148
|
+
start: {
|
|
149
|
+
x: .25,
|
|
150
|
+
y: .25
|
|
151
|
+
},
|
|
152
|
+
current: {
|
|
153
|
+
x: .75,
|
|
154
|
+
y: .75
|
|
155
|
+
}
|
|
156
|
+
}, "keyboard", event);
|
|
157
|
+
}
|
|
158
|
+
const visibleRegion = () => {
|
|
159
|
+
const region = local.region;
|
|
160
|
+
if (!region) return void 0;
|
|
161
|
+
const x = clampSurfaceFraction(region.x);
|
|
162
|
+
const y = clampSurfaceFraction(region.y);
|
|
163
|
+
return {
|
|
164
|
+
x,
|
|
165
|
+
y,
|
|
166
|
+
width: Math.min(clampSurfaceFraction(region.width), 1 - x),
|
|
167
|
+
height: Math.min(clampSurfaceFraction(region.height), 1 - y)
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
const describedBy = () => [local["aria-describedby"], local.hint && !visibleRegion() ? hintId : void 0].filter(Boolean).join(" ") || void 0;
|
|
171
|
+
return (() => {
|
|
172
|
+
var _el$ = _tmpl$2();
|
|
173
|
+
_el$.$$keydown = handleKeyDown;
|
|
174
|
+
_el$.addEventListener("lostpointercapture", handleLostPointerCapture);
|
|
175
|
+
_el$.addEventListener("pointercancel", handlePointerCancel);
|
|
176
|
+
_el$.$$pointerup = handlePointerUp;
|
|
177
|
+
_el$.$$pointermove = handlePointerMove;
|
|
178
|
+
_el$.$$pointerdown = handlePointerDown;
|
|
179
|
+
use((element) => local.ref?.(element), _el$);
|
|
180
|
+
insert(_el$, createComponent(Show, {
|
|
181
|
+
get when() {
|
|
182
|
+
return visibleRegion();
|
|
183
|
+
},
|
|
184
|
+
children: (region) => (() => {
|
|
185
|
+
var _el$3 = _tmpl$3(), _el$4 = _el$3.firstChild;
|
|
186
|
+
effect((_p$) => {
|
|
187
|
+
var _v$8 = region().x * 1e4, _v$9 = region().y * 1e4, _v$0 = region().width * 1e4, _v$1 = region().height * 1e4;
|
|
188
|
+
_v$8 !== _p$.e && setAttribute(_el$4, "x", _p$.e = _v$8);
|
|
189
|
+
_v$9 !== _p$.t && setAttribute(_el$4, "y", _p$.t = _v$9);
|
|
190
|
+
_v$0 !== _p$.a && setAttribute(_el$4, "width", _p$.a = _v$0);
|
|
191
|
+
_v$1 !== _p$.o && setAttribute(_el$4, "height", _p$.o = _v$1);
|
|
192
|
+
return _p$;
|
|
193
|
+
}, {
|
|
194
|
+
e: void 0,
|
|
195
|
+
t: void 0,
|
|
196
|
+
a: void 0,
|
|
197
|
+
o: void 0
|
|
198
|
+
});
|
|
199
|
+
return _el$3;
|
|
200
|
+
})()
|
|
201
|
+
}), null);
|
|
202
|
+
insert(_el$, createComponent(Show, {
|
|
203
|
+
get when() {
|
|
204
|
+
return memo(() => !!local.hint)() && !visibleRegion();
|
|
205
|
+
},
|
|
206
|
+
get children() {
|
|
207
|
+
var _el$2 = _tmpl$();
|
|
208
|
+
setAttribute(_el$2, "id", hintId);
|
|
209
|
+
insert(_el$2, () => local.hint);
|
|
210
|
+
return _el$2;
|
|
211
|
+
}
|
|
212
|
+
}), null);
|
|
213
|
+
effect((_p$) => {
|
|
214
|
+
var _v$ = local.id, _v$2 = describedBy(), _v$3 = local.label, _v$4 = isInteractive() ? void 0 : "true", _v$5 = local.tool, _v$6 = dragging() ? "true" : "false", _v$7 = cn("dev-annotation-surface relative isolate block w-full aspect-video select-none overflow-hidden rounded-md border border-border bg-muted/20 text-muted-foreground outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-primary-subtle", local.class);
|
|
215
|
+
_v$ !== _p$.e && setAttribute(_el$, "id", _p$.e = _v$);
|
|
216
|
+
_v$2 !== _p$.t && setAttribute(_el$, "aria-describedby", _p$.t = _v$2);
|
|
217
|
+
_v$3 !== _p$.a && setAttribute(_el$, "aria-label", _p$.a = _v$3);
|
|
218
|
+
_v$4 !== _p$.o && setAttribute(_el$, "aria-disabled", _p$.o = _v$4);
|
|
219
|
+
_v$5 !== _p$.i && setAttribute(_el$, "data-tool", _p$.i = _v$5);
|
|
220
|
+
_v$6 !== _p$.n && setAttribute(_el$, "data-dragging", _p$.n = _v$6);
|
|
221
|
+
_v$7 !== _p$.s && className(_el$, _p$.s = _v$7);
|
|
222
|
+
return _p$;
|
|
223
|
+
}, {
|
|
224
|
+
e: void 0,
|
|
225
|
+
t: void 0,
|
|
226
|
+
a: void 0,
|
|
227
|
+
o: void 0,
|
|
228
|
+
i: void 0,
|
|
229
|
+
n: void 0,
|
|
230
|
+
s: void 0
|
|
231
|
+
});
|
|
232
|
+
return _el$;
|
|
233
|
+
})();
|
|
234
|
+
}
|
|
235
|
+
delegateEvents([
|
|
236
|
+
"pointerdown",
|
|
237
|
+
"pointermove",
|
|
238
|
+
"pointerup",
|
|
239
|
+
"keydown"
|
|
240
|
+
]);
|
|
241
|
+
//#endregion
|
|
242
|
+
export { AnnotationSurface };
|
|
243
|
+
|
|
244
|
+
//# sourceMappingURL=annotation-surface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotation-surface.js","names":["createEffect","createSignal","createUniqueId","onCleanup","Show","splitProps","JSX","cn","clampSurfaceFraction","normalizedSurfacePoint","AnnotationSurfacePoint","AnnotationSurfaceRegion","Readonly","x","y","width","height","AnnotationSurfaceDrag","start","current","AnnotationSurfaceTool","AnnotationSurfaceDragPhase","AnnotationSurfacePointerEvent","PointerEvent","currentTarget","HTMLDivElement","AnnotationSurfaceKeyboardEvent","KeyboardEvent","AnnotationSurfaceInputEvent","SurfaceElementProps","Pick","HTMLAttributes","AnnotationSurfaceProps","label","tool","region","hint","Element","interactive","resetKey","onPoint","point","event","onDragChange","drag","phase","onKeyDown","ref","element","class","ActiveDrag","pointerId","target","pointFrom","bounds","getBoundingClientRect","clientX","clientY","AnnotationSurface","props","local","dragging","setDragging","hintId","activeDrag","previousResetKey","previousTool","isInteractive","releaseCapture","hasPointerCapture","releasePointerCapture","cancelDrag","release","undefined","handlePointerDown","isPrimary","button","preventDefault","focus","preventScroll","setPointerCapture","handlePointerMove","handlePointerUp","handlePointerCancel","handleLostPointerCapture","handleKeyDown","key","defaultPrevented","repeat","isComposing","altKey","ctrlKey","metaKey","visibleRegion","Math","min","describedBy","filter","Boolean","join","_el$","_tmpl$2","$$keydown","addEventListener","$$pointerup","$$pointermove","$$pointerdown","_$use","_$insert","_$createComponent","when","children","_el$3","_tmpl$3","_el$4","firstChild","_$effect","_p$","_v$8","_v$9","_v$0","_v$1","e","_$setAttribute","t","a","o","_$memo","_el$2","_tmpl$","_v$","id","_v$2","_v$3","_v$4","_v$5","_v$6","_v$7","i","n","s","_$className","_$delegateEvents","_$createComponent","_$setAttribute","_$memo","_$className","_$delegateEvents"],"sources":["../../../../src/components/ui/annotation-surface/annotation-surface.tsx"],"sourcesContent":["import {\n createEffect,\n createSignal,\n createUniqueId,\n onCleanup,\n Show,\n splitProps,\n type JSX,\n} from 'solid-js'\nimport { cn } from '#lib/utils'\nimport './annotation-surface.css'\nimport {\n clampSurfaceFraction,\n normalizedSurfacePoint,\n type AnnotationSurfacePoint,\n} from './geometry'\n\nexport type AnnotationSurfaceRegion = Readonly<{\n x: number\n y: number\n width: number\n height: number\n}>\n\nexport type AnnotationSurfaceDrag = Readonly<{\n start: AnnotationSurfacePoint\n current: AnnotationSurfacePoint\n}>\n\nexport type AnnotationSurfaceTool = 'region' | 'point'\nexport type AnnotationSurfaceDragPhase = 'start' | 'move' | 'end' | 'cancel' | 'keyboard'\nexport type AnnotationSurfacePointerEvent = PointerEvent & { currentTarget: HTMLDivElement }\nexport type AnnotationSurfaceKeyboardEvent = KeyboardEvent & { currentTarget: HTMLDivElement }\nexport type AnnotationSurfaceInputEvent =\n | AnnotationSurfacePointerEvent\n | AnnotationSurfaceKeyboardEvent\n\ntype SurfaceElementProps = Pick<JSX.HTMLAttributes<HTMLDivElement>, 'id' | 'aria-describedby'>\n\nexport type AnnotationSurfaceProps = SurfaceElementProps & {\n /** Accessible instructions for the keyboard-operated surface. */\n label: string\n /** Region draws a captured drag; point reports a single placement point. */\n tool: AnnotationSurfaceTool\n /** Normalized 0..1 geometry supplied by the host; absent means no region. */\n region?: AnnotationSurfaceRegion\n /** Visible idle guidance. It is hidden while a region is present. */\n hint?: JSX.Element\n /** Disable new drawing while the host is busy. Defaults to true. */\n interactive?: boolean\n /** Changing this value cancels an in-flight drag owned by the host context. */\n resetKey?: string | number\n /** Receives one normalized point in point mode. */\n onPoint?: (point: AnnotationSurfacePoint, event: AnnotationSurfaceInputEvent) => void\n /** Receives drag phases; cancel has no drag and fires at most once per capture. */\n onDragChange?: (\n drag: AnnotationSurfaceDrag | undefined,\n phase: AnnotationSurfaceDragPhase,\n event?: AnnotationSurfaceInputEvent\n ) => void\n /** Domain keyboard policy stays with the host and receives the native event. */\n onKeyDown?: (event: AnnotationSurfaceKeyboardEvent) => void\n /** Ref to the actual focusable and pointer-capturing HTMLDivElement. */\n ref?: (element: HTMLDivElement) => void\n /** Layout only; appearance remains owned by the shared component. */\n class?: string\n}\n\ntype ActiveDrag = AnnotationSurfaceDrag & {\n pointerId: number\n target: HTMLDivElement\n}\n\nfunction pointFrom(event: PointerEvent, target: HTMLDivElement): AnnotationSurfacePoint {\n const bounds = target.getBoundingClientRect()\n return normalizedSurfacePoint(event.clientX, event.clientY, bounds)\n}\n\n/**\n * AnnotationSurface.\n *\n * A keyboard-focusable, viewport-shaped drawing surface for hosts that own an\n * annotation domain. It renders normalized region geometry and idle guidance,\n * captures region drags, and reports normalized points without reading or\n * rendering screenshot pixels. The host keeps tool policy, domain geometry,\n * persistence and capture commands.\n *\n * This bespoke application widget is necessary because a generic button or\n * slider cannot represent a two-dimensional drawing viewport. Its keyboard\n * behavior is supplied by the host and forwarded as a native key event. Space\n * creates a centered region or places a point at the center; Escape is left to\n * the host first, which can prevent the default gesture cancellation while it\n * applies its own draft and mode rules.\n */\nexport function AnnotationSurface(props: AnnotationSurfaceProps) {\n const [local] = splitProps(props, [\n 'id',\n 'aria-describedby',\n 'label',\n 'tool',\n 'region',\n 'hint',\n 'interactive',\n 'resetKey',\n 'onPoint',\n 'onDragChange',\n 'onKeyDown',\n 'ref',\n 'class',\n ])\n\n const [dragging, setDragging] = createSignal(false)\n const hintId = createUniqueId()\n let activeDrag: ActiveDrag | undefined\n let previousResetKey = local.resetKey\n let previousTool = local.tool\n\n const isInteractive = () => local.interactive ?? true\n\n function releaseCapture(drag: ActiveDrag): void {\n try {\n if (drag.target.hasPointerCapture(drag.pointerId))\n drag.target.releasePointerCapture(drag.pointerId)\n } catch {\n // The browser may release capture while a host reset or unmount is running.\n }\n }\n\n function cancelDrag(event?: AnnotationSurfaceInputEvent, release = true): void {\n const drag = activeDrag\n if (!drag) return\n\n activeDrag = undefined\n setDragging(false)\n if (release) releaseCapture(drag)\n local.onDragChange?.(undefined, 'cancel', event)\n }\n\n createEffect(() => {\n const resetKey = local.resetKey\n const tool = local.tool\n const interactive = isInteractive()\n if (activeDrag && (resetKey !== previousResetKey || tool !== previousTool || !interactive)) {\n cancelDrag()\n }\n previousResetKey = resetKey\n previousTool = tool\n })\n\n onCleanup(() => cancelDrag())\n\n function handlePointerDown(event: AnnotationSurfacePointerEvent): void {\n if (!isInteractive() || !event.isPrimary || event.button !== 0) return\n event.preventDefault()\n event.currentTarget.focus({ preventScroll: true })\n const point = pointFrom(event, event.currentTarget)\n if (activeDrag) return\n\n if (local.tool === 'point') {\n local.onPoint?.(point, event)\n return\n }\n\n try {\n event.currentTarget.setPointerCapture(event.pointerId)\n } catch {\n // A drag without real pointer capture can lose its final coordinates.\n return\n }\n\n const drag: ActiveDrag = {\n pointerId: event.pointerId,\n target: event.currentTarget,\n start: point,\n current: point,\n }\n activeDrag = drag\n setDragging(true)\n local.onDragChange?.({ start: point, current: point }, 'start', event)\n }\n\n function handlePointerMove(event: AnnotationSurfacePointerEvent): void {\n const drag = activeDrag\n if (!drag || drag.pointerId !== event.pointerId) return\n\n const current = pointFrom(event, event.currentTarget)\n activeDrag = { ...drag, current }\n local.onDragChange?.({ start: drag.start, current }, 'move', event)\n }\n\n function handlePointerUp(event: AnnotationSurfacePointerEvent): void {\n const drag = activeDrag\n if (!drag || drag.pointerId !== event.pointerId) return\n\n const current = pointFrom(event, event.currentTarget)\n activeDrag = undefined\n setDragging(false)\n releaseCapture(drag)\n local.onDragChange?.({ start: drag.start, current }, 'end', event)\n }\n\n function handlePointerCancel(event: AnnotationSurfacePointerEvent): void {\n if (activeDrag?.pointerId === event.pointerId) cancelDrag(event)\n }\n\n function handleLostPointerCapture(event: AnnotationSurfacePointerEvent): void {\n if (activeDrag?.pointerId === event.pointerId) cancelDrag(event, false)\n }\n\n function handleKeyDown(event: AnnotationSurfaceKeyboardEvent): void {\n local.onKeyDown?.(event)\n if (event.key === 'Escape') {\n if (!event.defaultPrevented) cancelDrag()\n return\n }\n if (\n event.defaultPrevented ||\n !isInteractive() ||\n event.key !== ' ' ||\n event.repeat ||\n event.isComposing ||\n event.altKey ||\n event.ctrlKey ||\n event.metaKey ||\n activeDrag\n )\n return\n\n event.preventDefault()\n if (local.tool === 'point') {\n local.onPoint?.({ x: 0.5, y: 0.5 }, event)\n return\n }\n\n local.onDragChange?.(\n {\n start: { x: 0.25, y: 0.25 },\n current: { x: 0.75, y: 0.75 },\n },\n 'keyboard',\n event\n )\n }\n\n const visibleRegion = (): AnnotationSurfaceRegion | undefined => {\n const region = local.region\n if (!region) return undefined\n const x = clampSurfaceFraction(region.x)\n const y = clampSurfaceFraction(region.y)\n return {\n x,\n y,\n width: Math.min(clampSurfaceFraction(region.width), 1 - x),\n height: Math.min(clampSurfaceFraction(region.height), 1 - y),\n }\n }\n\n const describedBy = () =>\n [local['aria-describedby'], local.hint && !visibleRegion() ? hintId : undefined]\n .filter(Boolean)\n .join(' ') || undefined\n\n return (\n <div\n id={local.id}\n aria-describedby={describedBy()}\n role=\"application\"\n aria-roledescription=\"annotation surface\"\n aria-label={local.label}\n aria-disabled={isInteractive() ? undefined : 'true'}\n tabIndex={0}\n data-tool={local.tool}\n data-dragging={dragging() ? 'true' : 'false'}\n class={cn(\n 'dev-annotation-surface relative isolate block w-full aspect-video select-none overflow-hidden rounded-md border border-border bg-muted/20 text-muted-foreground outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-primary-subtle',\n local.class\n )}\n ref={(element) => local.ref?.(element)}\n onPointerDown={handlePointerDown}\n onPointerMove={handlePointerMove}\n onPointerUp={handlePointerUp}\n onPointerCancel={handlePointerCancel}\n onLostPointerCapture={handleLostPointerCapture}\n onKeyDown={handleKeyDown}\n >\n <Show when={visibleRegion()}>\n {(region) => (\n <svg\n class=\"dev-annotation-surface__region pointer-events-none absolute inset-0 size-full\"\n viewBox=\"0 0 10000 10000\"\n preserveAspectRatio=\"none\"\n aria-hidden=\"true\"\n >\n <rect\n class=\"fill-primary-subtle stroke-primary\"\n x={region().x * 10_000}\n y={region().y * 10_000}\n width={region().width * 10_000}\n height={region().height * 10_000}\n stroke-width=\"1.5\"\n vector-effect=\"non-scaling-stroke\"\n />\n </svg>\n )}\n </Show>\n <Show when={local.hint && !visibleRegion()}>\n <span\n id={hintId}\n class=\"dev-annotation-surface__hint pointer-events-none absolute inset-0 grid place-items-center p-4 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EAAA,CAAA;EAAA,OAAA2B;CAAA,EAAA,CAAA;AAuCP;AAAC0C,eAAA;CAAA;CAAA;CAAA;CAAA;AAAA,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type AnnotationSurfacePoint = Readonly<{
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
}>;
|
|
5
|
+
type SurfaceBounds = Readonly<Pick<DOMRectReadOnly, 'left' | 'top' | 'width' | 'height'>>;
|
|
6
|
+
/** Pointer coordinates normalized to the surface; degenerate bounds resolve to the origin. */
|
|
7
|
+
export declare function normalizedSurfacePoint(clientX: number, clientY: number, bounds: SurfaceBounds): AnnotationSurfacePoint;
|
|
8
|
+
export declare function clampSurfaceFraction(value: number): number;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=geometry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometry.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/annotation-surface/geometry.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CAAC;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAAA;AAEvE,KAAK,aAAa,GAAG,QAAQ,CAAC,IAAI,CAAC,eAAe,EAAE,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAA;AAczF,8FAA8F;AAC9F,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,aAAa,GACpB,sBAAsB,CAKxB;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE1D"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/components/ui/annotation-surface/geometry.ts
|
|
2
|
+
function fraction(client, start, length) {
|
|
3
|
+
if (!Number.isFinite(client) || !Number.isFinite(start) || !Number.isFinite(length) || length <= 0) return 0;
|
|
4
|
+
return Math.min(1, Math.max(0, (client - start) / length));
|
|
5
|
+
}
|
|
6
|
+
/** Pointer coordinates normalized to the surface; degenerate bounds resolve to the origin. */
|
|
7
|
+
function normalizedSurfacePoint(clientX, clientY, bounds) {
|
|
8
|
+
return {
|
|
9
|
+
x: fraction(clientX, bounds.left, bounds.width),
|
|
10
|
+
y: fraction(clientY, bounds.top, bounds.height)
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function clampSurfaceFraction(value) {
|
|
14
|
+
return Number.isFinite(value) ? Math.min(1, Math.max(0, value)) : 0;
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { clampSurfaceFraction, normalizedSurfacePoint };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=geometry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometry.js","names":[],"sources":["../../../../src/components/ui/annotation-surface/geometry.ts"],"sourcesContent":["export type AnnotationSurfacePoint = Readonly<{ x: number; y: number }>\n\ntype SurfaceBounds = Readonly<Pick<DOMRectReadOnly, 'left' | 'top' | 'width' | 'height'>>\n\nfunction fraction(client: number, start: number, length: number): number {\n if (\n !Number.isFinite(client) ||\n !Number.isFinite(start) ||\n !Number.isFinite(length) ||\n length <= 0\n )\n return 0\n\n return Math.min(1, Math.max(0, (client - start) / length))\n}\n\n/** Pointer coordinates normalized to the surface; degenerate bounds resolve to the origin. */\nexport function normalizedSurfacePoint(\n clientX: number,\n clientY: number,\n bounds: SurfaceBounds\n): AnnotationSurfacePoint {\n return {\n x: fraction(clientX, bounds.left, bounds.width),\n y: fraction(clientY, bounds.top, bounds.height),\n }\n}\n\nexport function clampSurfaceFraction(value: number): number {\n return Number.isFinite(value) ? Math.min(1, Math.max(0, value)) : 0\n}\n"],"mappings":";AAIA,SAAS,SAAS,QAAgB,OAAe,QAAwB;CACvE,IACE,CAAC,OAAO,SAAS,MAAM,KACvB,CAAC,OAAO,SAAS,KAAK,KACtB,CAAC,OAAO,SAAS,MAAM,KACvB,UAAU,GAEV,OAAO;CAET,OAAO,KAAK,IAAI,GAAG,KAAK,IAAI,IAAI,SAAS,SAAS,MAAM,CAAC;AAC3D;;AAGA,SAAgB,uBACd,SACA,SACA,QACwB;CACxB,OAAO;EACL,GAAG,SAAS,SAAS,OAAO,MAAM,OAAO,KAAK;EAC9C,GAAG,SAAS,SAAS,OAAO,KAAK,OAAO,MAAM;CAChD;AACF;AAEA,SAAgB,qBAAqB,OAAuB;CAC1D,OAAO,OAAO,SAAS,KAAK,IAAI,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,KAAK,CAAC,IAAI;AACpE"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Keyboard-operable normalized drawing surface; hosts retain domain geometry and actions. */
|
|
2
|
+
export { AnnotationSurface, type AnnotationSurfaceDrag, type AnnotationSurfaceDragPhase, type AnnotationSurfaceInputEvent, type AnnotationSurfaceKeyboardEvent, type AnnotationSurfacePointerEvent, type AnnotationSurfaceProps, type AnnotationSurfaceRegion, type AnnotationSurfaceTool, } from './annotation-surface';
|
|
3
|
+
export type { AnnotationSurfacePoint } from './geometry';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/annotation-surface/index.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,OAAO,EACL,iBAAiB,EACjB,KAAK,qBAAqB,EAC1B,KAAK,0BAA0B,EAC/B,KAAK,2BAA2B,EAChC,KAAK,8BAA8B,EACnC,KAAK,6BAA6B,EAClC,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,GAC3B,MAAM,sBAAsB,CAAA;AAC7B,YAAY,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resizable.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/resizable/resizable.tsx"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,kBAAkB,CAAA;AAExC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAuB9C,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,cAAc,CAAC,OAAO,SAAS,CAAC,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"resizable.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/resizable/resizable.tsx"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,kBAAkB,CAAA;AAExC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAuB9C,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,cAAc,CAAC,OAAO,SAAS,CAAC,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,kCAa/F;AAgBD,wBAAgB,cAAc,CAAC,KAAK,EAAE,cAAc,CAAC,OAAO,SAAS,CAAC,KAAK,CAAC,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,kCAchG;AAED,MAAM,MAAM,oBAAoB,GAAG,cAAc,CAAC,OAAO,SAAS,CAAC,MAAM,CAAC,GAAG;IAC3E,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,wDAAwD;IACxD,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,kCA+B1D"}
|
|
@@ -18,7 +18,7 @@ var _tmpl$ = /*#__PURE__*/ template(`<div class="bg-border z-(--z-docked) flex h
|
|
|
18
18
|
* adjusted from the keyboard; a bare `cursor-col-resize` div cannot.
|
|
19
19
|
*/
|
|
20
20
|
/**
|
|
21
|
-
* Whether the group was given `initialSizes`. Those are corvu's to apply, and a
|
|
21
|
+
* Whether the group was given `initialSizes` or controlled `sizes`. Those are corvu's to apply, and a
|
|
22
22
|
* panel's own `initialSize` overrides them — so an unsized panel must not invent
|
|
23
23
|
* one when the group already has an answer.
|
|
24
24
|
*/
|
|
@@ -26,7 +26,7 @@ var GroupSizesContext = createContext(() => false);
|
|
|
26
26
|
function ResizablePanelGroup(props) {
|
|
27
27
|
const [local, rest] = splitProps(props, ["class"]);
|
|
28
28
|
return createComponent(GroupSizesContext.Provider, {
|
|
29
|
-
value: () => rest.initialSizes !== void 0,
|
|
29
|
+
value: () => rest.initialSizes !== void 0 || rest.sizes !== void 0,
|
|
30
30
|
get children() {
|
|
31
31
|
return createComponent(Resizable, mergeProps({ get ["class"]() {
|
|
32
32
|
return cn("flex size-full data-[orientation=vertical]:flex-col", local.class);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resizable.js","names":["Resizable","GripVertical","ComponentProps","createContext","splitProps","useContext","cn","GroupSizesContext","ResizablePanelGroup","props","class","local","rest","_$createComponent","Provider","value","initialSizes","undefined","children","_$mergeProps","remainingSize","
|
|
1
|
+
{"version":3,"file":"resizable.js","names":["Resizable","GripVertical","ComponentProps","createContext","splitProps","useContext","cn","GroupSizesContext","ResizablePanelGroup","props","class","local","rest","_$createComponent","Provider","value","initialSizes","undefined","sizes","children","_$mergeProps","remainingSize","left","reduce","total","size","length","ResizablePanel","Panel","group","contextId","groupHasSizes","initialSize","ResizableHandleProps","Handle","withHandle","label","ResizableHandle","aria-label","aria-orientation","orientation","_$memo","_el$","_tmpl$","_$insert","_$createComponent","_$mergeProps","_$memo"],"sources":["../../../../src/components/ui/resizable/resizable.tsx"],"sourcesContent":["import Resizable from '@corvu/resizable'\nimport { GripVertical } from 'lucide-solid'\nimport type { ComponentProps } from 'solid-js'\nimport { createContext, splitProps, useContext } from 'solid-js'\nimport { cn } from '#lib/utils'\n\n/**\n * Resizable.\n *\n * A split layout: panels the user can resize, with a handle between them. This\n * is the shape of every IDE-like surface — rail, file tree, editor, terminal —\n * and the reason it is a primitive rather than something each view improvises.\n *\n * corvu supplies the pointer capture, the min/max constraints and the keyboard\n * resizing, which is what makes a divider operable without a mouse. The handle\n * is a real focusable element with an accessible role, so a split pane can be\n * adjusted from the keyboard; a bare `cursor-col-resize` div cannot.\n */\n/**\n * Whether the group was given `initialSizes` or controlled `sizes`. Those are corvu's to apply, and a\n * panel's own `initialSize` overrides them — so an unsized panel must not invent\n * one when the group already has an answer.\n */\nconst GroupSizesContext = createContext<() => boolean>(() => false)\n\nexport function ResizablePanelGroup(props: ComponentProps<typeof Resizable> & { class?: string }) {\n const [local, rest] = splitProps(props, ['class'])\n\n return (\n <GroupSizesContext.Provider\n value={() => rest.initialSizes !== undefined || rest.sizes !== undefined}\n >\n <Resizable\n class={cn('flex size-full data-[orientation=vertical]:flex-col', local.class)}\n {...rest}\n />\n </GroupSizesContext.Provider>\n )\n}\n\n/**\n * The size an unsized panel registers with: whatever its earlier siblings left.\n *\n * corvu registers a panel without `initialSize` at a flat 50%, so `0.28` beside\n * an unsized panel summed to 78% and left a gap. Panels register in document\n * order, so at registration `sizes` holds exactly the panels before this one.\n * When nothing is left — a second unsized panel — it takes an equal share, and\n * corvu shrinks the earlier panels by that share to keep the total at 100%.\n */\nfunction remainingSize(sizes: readonly number[]): number {\n const left = 1 - sizes.reduce((total, size) => total + size, 0)\n return left > 0.001 ? left : 1 / (sizes.length + 1)\n}\n\nexport function ResizablePanel(props: ComponentProps<typeof Resizable.Panel> & { class?: string }) {\n const [local, rest] = splitProps(props, ['class', 'initialSize'])\n const group = Resizable.useContext(rest.contextId)\n const groupHasSizes = useContext(GroupSizesContext)\n\n return (\n <Resizable.Panel\n initialSize={\n local.initialSize ?? (groupHasSizes() ? undefined : remainingSize(group.sizes()))\n }\n class={cn('min-h-0 min-w-0 overflow-hidden', local.class)}\n {...rest}\n />\n )\n}\n\nexport type ResizableHandleProps = ComponentProps<typeof Resizable.Handle> & {\n class?: string\n /** Draw a visible grip in the middle of the divider. */\n withHandle?: boolean\n /**\n * The divider's accessible name. It is a focusable control — arrow keys move\n * the split — so it needs one; without it a screen reader announces an\n * unlabelled button between the two panels.\n */\n label?: string\n}\n\nexport function ResizableHandle(props: ResizableHandleProps) {\n const [local, rest] = splitProps(props, ['class', 'withHandle', 'label'])\n const group = Resizable.useContext(rest.contextId)\n\n return (\n <Resizable.Handle\n aria-label={local.label ?? 'Resize panels'}\n // A separator's orientation is the line's own, which runs across the\n // group: a row of panels is divided by a vertical line, a column by a\n // horizontal one. corvu reports the group's orientation instead.\n aria-orientation={group.orientation() === 'horizontal' ? 'vertical' : 'horizontal'}\n class={cn(\n 'group/resize bg-border relative flex w-px shrink-0 items-center justify-center',\n /* Widen the hit target without moving the visual line: the divider is\n a hairline, but a hairline is far too small to grab. */\n 'after:absolute after:inset-y-0 after:-inset-x-1 after:w-3',\n 'transition-colors ease-out hover:bg-primary',\n 'focus-visible:bg-primary focus-visible:outline-none',\n 'data-[orientation=vertical]:h-px data-[orientation=vertical]:w-full',\n 'data-[orientation=vertical]:after:inset-x-0 data-[orientation=vertical]:after:-inset-y-1 data-[orientation=vertical]:after:h-3 data-[orientation=vertical]:after:w-full',\n local.class\n )}\n {...rest}\n >\n {local.withHandle ? (\n <div class=\"bg-border z-(--z-docked) flex h-4 w-2.5 items-center justify-center rounded-sm border border-border\">\n <GripVertical class=\"size-2.5 text-muted-foreground\" />\n </div>\n ) : null}\n </Resizable.Handle>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAuBA,IAAMO,oBAAoBJ,oBAAmC,KAAK;AAElE,SAAgBK,oBAAoBC,OAA8D;CAChG,MAAM,CAACE,OAAOC,QAAQR,WAAWK,OAAO,CAAC,OAAO,CAAC;CAEjD,OAAAI,gBACGN,kBAAkBO,UAAQ;EACzBC,aAAaH,KAAKI,iBAAiBC,KAAAA,KAAaL,KAAKM,UAAUD,KAAAA;EAAS,IAAAE,WAAA;GAAA,OAAAN,gBAEvEb,W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,CAAA9B,MAAMwB,UAAU,CAAA,CAAA,WAAA;GAAA,IAAAO,OAAAC,OAAA;GAAAC,OAAAF,MAAA7B,gBAEZZ,cAAY,EAAA,SAAA,iCAAA,CAAA,CAAA;GAAA,OAAAyC;EAAA,EAAA,CAAA,IAEb;CAAI,EAAA,CAAA,CAAA;AAGd"}
|
|
@@ -32,7 +32,7 @@ import { type VariantProps } from '#lib/variants';
|
|
|
32
32
|
* sheet opens.
|
|
33
33
|
*/
|
|
34
34
|
declare const sheetVariants: (props?: ({
|
|
35
|
-
side?: "
|
|
35
|
+
side?: "top" | "bottom" | "start" | "end" | null | undefined;
|
|
36
36
|
variant?: "inset" | "edge" | null | undefined;
|
|
37
37
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
38
38
|
export type SheetContentProps = ComponentProps<typeof KobalteDialogContent> & VariantProps<typeof sheetVariants> & {
|