@sentropic/design-system-svelte 0.42.0 → 0.43.1
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/CommentAuthorship.svelte +186 -0
- package/dist/CommentAuthorship.svelte.d.ts +18 -0
- package/dist/CommentAuthorship.svelte.d.ts.map +1 -0
- package/dist/CommentComposer.svelte +336 -0
- package/dist/CommentComposer.svelte.d.ts +33 -0
- package/dist/CommentComposer.svelte.d.ts.map +1 -0
- package/dist/CommentLayer.svelte +1629 -0
- package/dist/CommentLayer.svelte.d.ts +64 -0
- package/dist/CommentLayer.svelte.d.ts.map +1 -0
- package/dist/CommentPin.svelte +219 -0
- package/dist/CommentPin.svelte.d.ts +26 -0
- package/dist/CommentPin.svelte.d.ts.map +1 -0
- package/dist/CommentThread.svelte +801 -0
- package/dist/CommentThread.svelte.d.ts +42 -0
- package/dist/CommentThread.svelte.d.ts.map +1 -0
- package/dist/DiagramCard.svelte +14 -4
- package/dist/DiagramCard.svelte.d.ts.map +1 -1
- package/dist/DiagramCardHeader.svelte +14 -2
- package/dist/DiagramCardHeader.svelte.d.ts +2 -0
- package/dist/DiagramCardHeader.svelte.d.ts.map +1 -1
- package/dist/DiagramSceneFigure.svelte +24 -3
- package/dist/DiagramSceneFigure.svelte.d.ts +1 -1
- package/dist/DiagramSceneFigure.svelte.d.ts.map +1 -1
- package/dist/DiagramZone.svelte +31 -13
- package/dist/DiagramZone.svelte.d.ts.map +1 -1
- package/dist/DiagramZoneHeader.svelte +1 -0
- package/dist/Drawer.svelte +96 -4
- package/dist/Drawer.svelte.d.ts.map +1 -1
- package/dist/OrphanList.svelte +267 -0
- package/dist/OrphanList.svelte.d.ts +18 -0
- package/dist/OrphanList.svelte.d.ts.map +1 -0
- package/dist/ReviewModeToggle.svelte +110 -0
- package/dist/ReviewModeToggle.svelte.d.ts +19 -0
- package/dist/ReviewModeToggle.svelte.d.ts.map +1 -0
- package/dist/ThreadPanel.svelte +654 -0
- package/dist/ThreadPanel.svelte.d.ts +42 -0
- package/dist/ThreadPanel.svelte.d.ts.map +1 -0
- package/dist/diagram-render/renderCardSvg.js +1 -1
- package/dist/diagram-render/renderZoneSvg.js +1 -1
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/dist/review-markdown.d.ts +90 -0
- package/dist/review-markdown.d.ts.map +1 -0
- package/dist/review-markdown.js +379 -0
- package/package.json +5 -4
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
3
|
+
import type { CollaborationActor, ReviewComment, ReviewThread, ThreadReadState } from "@sentropic/design-system-review-core";
|
|
4
|
+
import type { CommentRef } from "./review-markdown.js";
|
|
5
|
+
export type CommentThreadProps = Omit<HTMLAttributes<HTMLElement>, "class"> & {
|
|
6
|
+
thread: ReviewThread;
|
|
7
|
+
currentUser: CollaborationActor;
|
|
8
|
+
/** Server-side moderator override mirroring `author-or-admin` for edit/delete. */
|
|
9
|
+
canModerate?: boolean;
|
|
10
|
+
/** Whether replying is allowed when the thread is open. */
|
|
11
|
+
canReply?: boolean;
|
|
12
|
+
/** Optional host-held read state for unread comment indicators. */
|
|
13
|
+
readState?: ThreadReadState | string | null;
|
|
14
|
+
/** Optional display label for `thread.assignedTo` (defaults to the raw member id). */
|
|
15
|
+
assigneeLabel?: string;
|
|
16
|
+
/** Optional URL builder for live `authorship.runId` links. */
|
|
17
|
+
runHrefBuilder?: (runId: string, comment: ReviewComment) => string;
|
|
18
|
+
/** Optional URL builder for `Ref: decision:<id>` / `Ref: track:<id>` chips. */
|
|
19
|
+
refHrefBuilder?: (ref: CommentRef) => string;
|
|
20
|
+
class?: string;
|
|
21
|
+
onReply?: (threadId: string, body: string) => void | Promise<void>;
|
|
22
|
+
onResolve?: (threadId: string) => void | Promise<void>;
|
|
23
|
+
onReopen?: (threadId: string) => void | Promise<void>;
|
|
24
|
+
onEditComment?: (commentId: string, body: string) => void | Promise<void>;
|
|
25
|
+
onDeleteComment?: (commentId: string) => void | Promise<void>;
|
|
26
|
+
/** Optional re-anchor capability (hidden when absent per SPEC-r6 §2/§3). */
|
|
27
|
+
onReanchor?: (threadId: string) => void | Promise<void>;
|
|
28
|
+
onRunClick?: (runId: string, comment: ReviewComment) => void;
|
|
29
|
+
onRefClick?: (ref: CommentRef, comment: ReviewComment) => void;
|
|
30
|
+
/** Optional custom header slot. */
|
|
31
|
+
header?: Snippet<[{
|
|
32
|
+
thread: ReviewThread;
|
|
33
|
+
}]>;
|
|
34
|
+
/** Optional slot replacing the default safe markdown-lite comment body. */
|
|
35
|
+
commentBody?: Snippet<[{
|
|
36
|
+
comment: ReviewComment;
|
|
37
|
+
}]>;
|
|
38
|
+
};
|
|
39
|
+
declare const CommentThread: import("svelte").Component<CommentThreadProps, {}, "">;
|
|
40
|
+
type CommentThread = ReturnType<typeof CommentThread>;
|
|
41
|
+
export default CommentThread;
|
|
42
|
+
//# sourceMappingURL=CommentThread.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommentThread.svelte.d.ts","sourceRoot":"","sources":["../src/lib/CommentThread.svelte.ts"],"names":[],"mappings":"AAGE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EACV,kBAAkB,EAClB,aAAa,EACb,YAAY,EACZ,eAAe,EAChB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC,GAAG;IAC5E,MAAM,EAAE,YAAY,CAAC;IACrB,WAAW,EAAE,kBAAkB,CAAC;IAChC,kFAAkF;IAClF,WAAW,CAAC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Aa,KAAK,IAAI,CAAC;IAC/D,mCAAmC;IACnC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC;QAAE,MAAM,EAAE,YAAY,CAAA;KAAE,CAAC,CAAC,CAAC;IAC7C,2EAA2E;IAC3E,WAAW,CAAC,EAAE,OAAO,CAAC,CAAC;QAAE,OAAO,EAAE,aAAa,CAAA;KAAE,CAAC,CAAC,CAAC;CACrD,CAAC;AA4bJ,QAAA,MAAM,aAAa,wDAAwC,CAAC;AAC5D,KAAK,aAAa,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AACtD,eAAe,aAAa,CAAC"}
|
package/dist/DiagramCard.svelte
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { anatomyCardGeometry, lineBoxHeight } from "./diagramCardModel.js";
|
|
2
|
+
import { anatomyCardGeometry, lineBoxHeight, resolveDiagramAlign } from "./diagramCardModel.js";
|
|
3
3
|
const descriptionId = $props.id();
|
|
4
4
|
import DiagramCardHeader from "./DiagramCardHeader.svelte";
|
|
5
5
|
import { cardFullText, defaultCardMeasure, layoutCard } from "./diagramCardModel.js";
|
|
@@ -91,21 +91,31 @@
|
|
|
91
91
|
);
|
|
92
92
|
|
|
93
93
|
const effectiveAnatomy = $derived(layout.anatomyFallback ?? anatomy);
|
|
94
|
-
const effectiveAlign = $derived(
|
|
94
|
+
const effectiveAlign = $derived(resolveDiagramAlign(effectiveAnatomy, align));
|
|
95
95
|
const cardGeometry = $derived(anatomyCardGeometry(effectiveAnatomy));
|
|
96
96
|
|
|
97
97
|
/**
|
|
98
98
|
* Owner addendum 1: a folded zone keeps its depth background. Only
|
|
99
99
|
* zone-collapsed cards carry `surface`, so leaf cards never change.
|
|
100
|
+
* W1-12: when `surface === "surface2"` (where 0.41.5's surface-subtle hover
|
|
101
|
+
* collides with the zone background), switch the toggle hover token to
|
|
102
|
+
* secondaryHoverBackground; v1 leaf cards and surface1 zones keep exact
|
|
103
|
+
* 0.41.5 hover styling.
|
|
100
104
|
*/
|
|
101
105
|
const surfaceStyle = $derived(
|
|
102
106
|
surface === undefined
|
|
103
107
|
? ""
|
|
104
|
-
: `;--st-component-diagramCard-surface:var(--st-component-diagramZone-${surface}, var(--st-semantic-surface-${surface === "surface1" ? "raised" : "subtle"}))
|
|
108
|
+
: `;--st-component-diagramCard-surface:var(--st-component-diagramZone-${surface}, var(--st-semantic-surface-${surface === "surface1" ? "raised" : "subtle"}))${
|
|
109
|
+
surface === "surface2"
|
|
110
|
+
? ";--st-component-control-hoverBackground:var(--st-component-button-secondaryHoverBackground, var(--st-semantic-action-secondaryHover, var(--st-semantic-border-subtle)));--st-component-iconButton-hoverBackground:var(--st-component-button-secondaryHoverBackground, var(--st-semantic-action-secondaryHover, var(--st-semantic-border-subtle)))"
|
|
111
|
+
: ""
|
|
112
|
+
}`,
|
|
105
113
|
);
|
|
106
114
|
|
|
107
115
|
const overflowSlot = $derived(
|
|
108
|
-
layout.diagnostics.find(
|
|
116
|
+
layout.diagnostics.find(
|
|
117
|
+
(diagnostic) => diagnostic.code === "card-overflow" && diagnostic.reason !== "fallback-v1",
|
|
118
|
+
)?.slot,
|
|
109
119
|
);
|
|
110
120
|
const unknownIcon = $derived(
|
|
111
121
|
layout.diagnostics.some((diagnostic) => diagnostic.code === "card-icon-unknown"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DiagramCard.svelte.d.ts","sourceRoot":"","sources":["../src/lib/DiagramCard.svelte.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACR,cAAc,EACd,eAAe,EACf,gBAAgB,IAAI,eAAe,EACpC,MAAM,uBAAuB,CAAC;AAG/B;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,WAAW,gBAAiB,SAAQ,eAAe;IACvD;;;;OAIG;IACH,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACjD,iDAAiD;IACjD,YAAY,CAAC,EAAE,CAAC,UAAU,EAAE,cAAc,KAAK,IAAI,CAAC;CACrD;
|
|
1
|
+
{"version":3,"file":"DiagramCard.svelte.d.ts","sourceRoot":"","sources":["../src/lib/DiagramCard.svelte.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACR,cAAc,EACd,eAAe,EACf,gBAAgB,IAAI,eAAe,EACpC,MAAM,uBAAuB,CAAC;AAG/B;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,WAAW,gBAAiB,SAAQ,eAAe;IACvD;;;;OAIG;IACH,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACjD,iDAAiD;IACjD,YAAY,CAAC,EAAE,CAAC,UAAU,EAAE,cAAc,KAAK,IAAI,CAAC;CACrD;AAiIH,QAAA,MAAM,WAAW,sDAAwC,CAAC;AAC1D,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;AAClD,eAAe,WAAW,CAAC"}
|
|
@@ -18,6 +18,8 @@
|
|
|
18
18
|
iconGlyph?: DiagramGlyphPaths;
|
|
19
19
|
/** Pictogram box edge; defaults to the v1 `70` (v2: `52`). */
|
|
20
20
|
iconSize?: number;
|
|
21
|
+
/** Frame header inset when rendered inside a zone header (`16` in v1, `12` in v2). */
|
|
22
|
+
headerInset?: number;
|
|
21
23
|
/** Width the title/kicker block may take (toggle-aware). */
|
|
22
24
|
headerTextWidth: number;
|
|
23
25
|
/**
|
|
@@ -42,11 +44,22 @@
|
|
|
42
44
|
iconName,
|
|
43
45
|
iconGlyph = iconName === undefined || iconName === "none" ? undefined : getDiagramGlyph(iconName) ?? getDiagramGlyph("unknown"),
|
|
44
46
|
iconSize = 70,
|
|
47
|
+
headerInset,
|
|
45
48
|
headerTextWidth,
|
|
46
49
|
headerBlockHeight,
|
|
47
50
|
toggle,
|
|
48
51
|
toggleTopOffset,
|
|
49
52
|
}: DiagramCardHeaderProps = $props();
|
|
53
|
+
|
|
54
|
+
const toggleOffsetExpr = $derived(
|
|
55
|
+
toggleTopOffset === undefined
|
|
56
|
+
? "calc(var(--st-component-diagramZone-toggleInset, 8px) - var(--st-component-diagramCard-borderWidth, 2px))"
|
|
57
|
+
: toggleTopOffset === -8 && (headerInset === undefined || headerInset === 16)
|
|
58
|
+
? "calc(var(--st-component-diagramZone-toggleInset, 8px) - var(--st-component-diagramZone-headerInset, 16px) - var(--st-component-diagramZone-borderWidth, 1.5px))"
|
|
59
|
+
: headerInset !== undefined && toggleTopOffset === 8 - headerInset
|
|
60
|
+
? `calc(var(--st-component-diagramZone-toggleInset, 8px) - ${headerInset}px - var(--st-component-diagramZone-borderWidth, 1.5px))`
|
|
61
|
+
: `calc(${toggleTopOffset}px - var(--st-component-diagramZone-borderWidth, 1.5px))`,
|
|
62
|
+
);
|
|
50
63
|
</script>
|
|
51
64
|
|
|
52
65
|
<div class="st-diagramCardHeader" style={`height:${headerBlockHeight}px`}>
|
|
@@ -106,8 +119,7 @@
|
|
|
106
119
|
{#if toggle !== undefined}
|
|
107
120
|
<div
|
|
108
121
|
class="st-diagramCard-toggle"
|
|
109
|
-
style={`top:${
|
|
110
|
-
|
|
122
|
+
style={`top:${toggleOffsetExpr};right:${toggleOffsetExpr}`}
|
|
111
123
|
>
|
|
112
124
|
<IconButton
|
|
113
125
|
size="sm"
|
|
@@ -12,6 +12,8 @@ interface DiagramCardHeaderProps {
|
|
|
12
12
|
iconGlyph?: DiagramGlyphPaths;
|
|
13
13
|
/** Pictogram box edge; defaults to the v1 `70` (v2: `52`). */
|
|
14
14
|
iconSize?: number;
|
|
15
|
+
/** Frame header inset when rendered inside a zone header (`16` in v1, `12` in v2). */
|
|
16
|
+
headerInset?: number;
|
|
15
17
|
/** Width the title/kicker block may take (toggle-aware). */
|
|
16
18
|
headerTextWidth: number;
|
|
17
19
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DiagramCardHeader.svelte.d.ts","sourceRoot":"","sources":["../src/lib/DiagramCardHeader.svelte.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAG1E;;;;;GAKG;AACH,UAAU,sBAAsB;IAC9B,MAAM,EAAE,SAAS,WAAW,EAAE,CAAC;IAC/B,KAAK,EAAE,SAAS,WAAW,EAAE,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,iBAAiB,CAAC;IAC9B,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4DAA4D;IAC5D,eAAe,EAAE,MAAM,CAAC;IACxB;;;;;;OAMG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAC1B,MAAM,CAAC,EAAE;QAAE,SAAS,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;KAAE,CAAC;IACtE;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;
|
|
1
|
+
{"version":3,"file":"DiagramCardHeader.svelte.d.ts","sourceRoot":"","sources":["../src/lib/DiagramCardHeader.svelte.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAG1E;;;;;GAKG;AACH,UAAU,sBAAsB;IAC9B,MAAM,EAAE,SAAS,WAAW,EAAE,CAAC;IAC/B,KAAK,EAAE,SAAS,WAAW,EAAE,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,iBAAiB,CAAC;IAC9B,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sFAAsF;IACtF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4DAA4D;IAC5D,eAAe,EAAE,MAAM,CAAC;IACxB;;;;;;OAMG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAC1B,MAAM,CAAC,EAAE;QAAE,SAAS,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;KAAE,CAAC;IACtE;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAyEH,QAAA,MAAM,iBAAiB,4DAAwC,CAAC;AAChE,KAAK,iBAAiB,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC9D,eAAe,iBAAiB,CAAC"}
|
|
@@ -123,7 +123,7 @@
|
|
|
123
123
|
expand: (title: string) => string;
|
|
124
124
|
collapse: (title: string) => string;
|
|
125
125
|
/** Localized fallback label for containment relations without an explicit edge label (DE-1b). */
|
|
126
|
-
contains
|
|
126
|
+
contains?: string;
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
export interface DiagramSceneCamera {
|
|
@@ -635,6 +635,29 @@
|
|
|
635
635
|
cameraDocument = id;
|
|
636
636
|
});
|
|
637
637
|
|
|
638
|
+
// Refit the camera and reset pan on every fold or unfold (uncontrolled toggle
|
|
639
|
+
// or controlled `collapsed` change) so unfolding never leaves the diagram
|
|
640
|
+
// overflowing the frame. Explicit user zoom/pan is kept until the next fold.
|
|
641
|
+
const foldKey = $derived([...collapsedNow].sort().join("\0"));
|
|
642
|
+
let cameraFoldKey: string | undefined;
|
|
643
|
+
$effect.pre(() => {
|
|
644
|
+
const key = foldKey;
|
|
645
|
+
untrack(() => {
|
|
646
|
+
if (cameraFoldKey !== undefined && cameraFoldKey !== key) {
|
|
647
|
+
atFit = true;
|
|
648
|
+
requestedZoom = undefined;
|
|
649
|
+
const element = viewportEl;
|
|
650
|
+
if (element !== undefined) {
|
|
651
|
+
void tick().then(() => {
|
|
652
|
+
if (element.scrollLeft !== 0) element.scrollLeft = 0;
|
|
653
|
+
if (element.scrollTop !== 0) element.scrollTop = 0;
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
cameraFoldKey = key;
|
|
658
|
+
});
|
|
659
|
+
});
|
|
660
|
+
|
|
638
661
|
// Z-7: clamp a user-selected zoom. Until an interaction, keep the camera
|
|
639
662
|
// at fit through token, font and painted-bounds updates during mounting.
|
|
640
663
|
$effect(() => {
|
|
@@ -869,8 +892,6 @@
|
|
|
869
892
|
const entering = (node: SceneNodeModel): boolean => origin !== undefined && !origin.has(node.occurrence);
|
|
870
893
|
|
|
871
894
|
function toggleFold(node: SceneNodeModel): void {
|
|
872
|
-
requestedZoom = zoom;
|
|
873
|
-
atFit = false;
|
|
874
895
|
const next = node.collapsed
|
|
875
896
|
? collapsedNow.filter((id) => id !== node.occurrence)
|
|
876
897
|
: [...collapsedNow, node.occurrence];
|
|
@@ -58,7 +58,7 @@ export interface DiagramSceneFigureLabels {
|
|
|
58
58
|
expand: (title: string) => string;
|
|
59
59
|
collapse: (title: string) => string;
|
|
60
60
|
/** Localized fallback label for containment relations without an explicit edge label (DE-1b). */
|
|
61
|
-
contains
|
|
61
|
+
contains?: string;
|
|
62
62
|
}
|
|
63
63
|
export interface DiagramSceneCamera {
|
|
64
64
|
readonly zoom: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DiagramSceneFigure.svelte.d.ts","sourceRoot":"","sources":["../src/lib/DiagramSceneFigure.svelte.ts"],"names":[],"mappings":"AAMA,OAAO,EAMH,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,YAAY,EAEjB,KAAK,cAAc,EACpB,MAAM,2BAA2B,CAAC;AASrC,OAAO,EAA+L,KAAK,UAAU,EAAE,KAAK,eAAe,EAAoB,MAAM,qCAAqC,CAAC;AAC3S,O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kB;iBAiVqB,CAAC;AACjE,KAAK,kBAAkB,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAChE,eAAe,kBAAkB,CAAC"}
|
package/dist/DiagramZone.svelte
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import {
|
|
8
8
|
anatomyZoneGeometry,
|
|
9
9
|
defaultCardMeasure,
|
|
10
|
+
resolveDiagramAlign,
|
|
10
11
|
zoneFullText,
|
|
11
12
|
layoutZone,
|
|
12
13
|
zoneCollapsedCardProps,
|
|
@@ -106,17 +107,19 @@
|
|
|
106
107
|
const layout = $derived(layoutZone(zoneProps, measure, []));
|
|
107
108
|
/** Expanded chrome geometry for the pinned anatomy (v1 values by default). */
|
|
108
109
|
const zoneGeometry = $derived(anatomyZoneGeometry(anatomy));
|
|
109
|
-
const effectiveAlign = $derived(
|
|
110
|
+
const effectiveAlign = $derived(resolveDiagramAlign(anatomy, align));
|
|
110
111
|
|
|
111
112
|
/**
|
|
112
113
|
* Owner addendum 1: an explicitly threaded depth paints the resolved
|
|
113
|
-
* depth surface
|
|
114
|
-
*
|
|
114
|
+
* depth surface via non-inherited `background` (never mutating the
|
|
115
|
+
* inherited `--st-component-diagramZone-surface` custom property, so
|
|
116
|
+
* nested child zones keep their own surface); without depth the frame
|
|
117
|
+
* keeps its resting surface, byte-identical.
|
|
115
118
|
*/
|
|
116
119
|
const surfaceStyle = $derived(
|
|
117
120
|
zoneProps.depth === undefined && zoneProps.depthParityStart === undefined
|
|
118
121
|
? ""
|
|
119
|
-
:
|
|
122
|
+
: `;background:var(--st-component-diagramZone-${layout.surface ?? "surface1"}, var(--st-semantic-surface-${(layout.surface ?? "surface1") === "surface1" ? "raised" : "subtle"}))`,
|
|
120
123
|
);
|
|
121
124
|
|
|
122
125
|
const cardProps = $derived(
|
|
@@ -133,7 +136,9 @@
|
|
|
133
136
|
);
|
|
134
137
|
|
|
135
138
|
const overflowSlot = $derived(
|
|
136
|
-
layout.diagnostics.find(
|
|
139
|
+
layout.diagnostics.find(
|
|
140
|
+
(diagnostic) => diagnostic.code === "zone-overflow" && diagnostic.reason !== "fallback-v1",
|
|
141
|
+
)?.slot,
|
|
137
142
|
);
|
|
138
143
|
const unknownIcon = $derived(
|
|
139
144
|
layout.diagnostics.some((diagnostic) => diagnostic.code === "zone-icon-unknown"),
|
|
@@ -162,14 +167,29 @@
|
|
|
162
167
|
const borderToken = "var(--st-component-diagramZone-borderWidth, 1.5px)";
|
|
163
168
|
const frameTop = (frameY: number): string => `calc(${frameY - y}px - ${borderToken})`;
|
|
164
169
|
const frameInset = (inset: number): string => `calc(${inset}px - ${borderToken})`;
|
|
165
|
-
// Header band: frame top + headerInset
|
|
166
|
-
// (
|
|
167
|
-
//
|
|
168
|
-
//
|
|
170
|
+
// Header band: frame top + headerInset. For v1 keep the frozen 0.41.5 right
|
|
171
|
+
// inset (`containerPadding ?? contentInsetInline`); for v2 anchor right to
|
|
172
|
+
// `headerInset` (12px) and scope the v2 header CSS custom properties strictly
|
|
173
|
+
// to `.st-diagramZone-header` so they never leak into nested v1 cards/zones.
|
|
174
|
+
const headerRightInset = $derived(
|
|
175
|
+
anatomy === "v2" ? zoneGeometry.headerInset : (containerPadding ?? zoneGeometry.contentInsetInline),
|
|
176
|
+
);
|
|
177
|
+
const v2HeaderVars =
|
|
178
|
+
";--st-component-diagramCard-iconSize:var(--st-component-diagramCardCompact-iconSize, 52px);--st-component-diagramCard-iconTextGap:var(--st-component-diagramCardCompact-iconTextGap, 4px);--st-component-diagramZone-headerInset:var(--st-component-diagramCardCompact-headerInset, 12px)";
|
|
179
|
+
// W1-12: on surface2 zones only (where 0.41.5's surface-subtle hover equals
|
|
180
|
+
// the zone background and becomes invisible), switch the toggle's hover token
|
|
181
|
+
// to secondaryHoverBackground — scoped strictly to `.st-diagramZone-header`
|
|
182
|
+
// so nested children and v1/surface1 zones stay byte-identical to 0.41.5.
|
|
183
|
+
const surface2ToggleHoverVars =
|
|
184
|
+
";--st-component-control-hoverBackground:var(--st-component-button-secondaryHoverBackground, var(--st-semantic-action-secondaryHover, var(--st-semantic-border-subtle)));--st-component-iconButton-hoverBackground:var(--st-component-button-secondaryHoverBackground, var(--st-semantic-action-secondaryHover, var(--st-semantic-border-subtle)))";
|
|
185
|
+
const hasSurface2 = $derived(
|
|
186
|
+
(zoneProps.depth !== undefined || zoneProps.depthParityStart !== undefined) &&
|
|
187
|
+
layout.surface === "surface2",
|
|
188
|
+
);
|
|
169
189
|
const headerStyle = $derived(
|
|
170
190
|
header === undefined
|
|
171
191
|
? undefined
|
|
172
|
-
: `top:${frameTop(y + zoneGeometry.headerInset)};left:${frameInset(zoneGeometry.headerInset)};right:${frameInset(
|
|
192
|
+
: `top:${frameTop(y + zoneGeometry.headerInset)};left:${frameInset(zoneGeometry.headerInset)};right:${frameInset(headerRightInset)};height:${header.ruleY - zoneGeometry.headerRuleGap - y - zoneGeometry.headerInset}px${anatomy === "v2" ? v2HeaderVars : ""}${hasSurface2 ? surface2ToggleHoverVars : ""}`,
|
|
173
193
|
);
|
|
174
194
|
const ruleStyle = $derived(
|
|
175
195
|
header === undefined
|
|
@@ -223,9 +243,7 @@
|
|
|
223
243
|
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
224
244
|
<div
|
|
225
245
|
class="st-diagramZone st-diagramZone--expanded{effectiveAlign === "center" ? " st-diagramZone--center" : ""}{proposed === true ? " st-diagramZone--proposed" : ""}{anatomy === "v2" ? " st-diagramZone--v2" : ""}"
|
|
226
|
-
style={
|
|
227
|
-
? `width:${layout.box.width}px;height:${layout.box.height}px;--st-component-diagramCard-iconSize:var(--st-component-diagramCardCompact-iconSize, 52px);--st-component-diagramCard-iconTextGap:var(--st-component-diagramCardCompact-iconTextGap, 4px);--st-component-diagramZone-headerInset:var(--st-component-diagramCardCompact-headerInset, 12px)${surfaceStyle}`
|
|
228
|
-
: `width:${layout.box.width}px;height:${layout.box.height}px${surfaceStyle}`}
|
|
246
|
+
style={`width:${layout.box.width}px;height:${layout.box.height}px${surfaceStyle}`}
|
|
229
247
|
data-tone={tone}
|
|
230
248
|
data-proposed={proposed === true ? "true" : undefined}
|
|
231
249
|
role="group"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DiagramZone.svelte.d.ts","sourceRoot":"","sources":["../src/lib/DiagramZone.svelte.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAGtC,OAAO,
|
|
1
|
+
{"version":3,"file":"DiagramZone.svelte.d.ts","sourceRoot":"","sources":["../src/lib/DiagramZone.svelte.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAGtC,OAAO,EAOH,KAAK,eAAe,EACpB,KAAK,gBAAgB,IAAI,eAAe,EACxC,KAAK,cAAc,EACpB,MAAM,uBAAuB,CAAC;AAG/B;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,gBAAiB,SAAQ,eAAe;IACvD,iEAAiE;IACjE,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,gEAAgE;IAChE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;IACrE,4BAA4B;IAC5B,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACjD,sDAAsD;IACtD,YAAY,CAAC,EAAE,CAAC,UAAU,EAAE,cAAc,KAAK,IAAI,CAAC;IACpD,sEAAsE;IACtE,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAmOH,QAAA,MAAM,WAAW,sDAAwC,CAAC;AAC1D,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;AAClD,eAAe,WAAW,CAAC"}
|
package/dist/Drawer.svelte
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import { tick } from "svelte";
|
|
2
3
|
import type { Snippet } from "svelte";
|
|
3
4
|
import type { HTMLAttributes } from "svelte/elements";
|
|
4
5
|
|
|
@@ -27,8 +28,44 @@
|
|
|
27
28
|
...rest
|
|
28
29
|
}: DrawerProps = $props();
|
|
29
30
|
|
|
31
|
+
let drawerEl: HTMLElement | undefined = $state();
|
|
32
|
+
let closeButton: HTMLButtonElement | undefined = $state();
|
|
33
|
+
let previousFocus: HTMLElement | null = null;
|
|
34
|
+
let wasOpen = false;
|
|
35
|
+
|
|
36
|
+
const focusableSelector = [
|
|
37
|
+
"a[href]",
|
|
38
|
+
"button:not([disabled])",
|
|
39
|
+
"input:not([disabled]):not([type='hidden'])",
|
|
40
|
+
"select:not([disabled])",
|
|
41
|
+
"textarea:not([disabled])",
|
|
42
|
+
"[tabindex]:not([tabindex='-1'])",
|
|
43
|
+
].join(",");
|
|
44
|
+
|
|
30
45
|
const classes = () => ["st-drawer", `st-drawer--${side}`, className].filter(Boolean).join(" ");
|
|
31
46
|
|
|
47
|
+
$effect(() => {
|
|
48
|
+
if (open && !wasOpen) {
|
|
49
|
+
wasOpen = true;
|
|
50
|
+
previousFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
51
|
+
void tick().then(() => {
|
|
52
|
+
if (!open || !drawerEl) return;
|
|
53
|
+
if (!drawerEl.contains(document.activeElement)) {
|
|
54
|
+
(closeButton ?? drawerEl).focus();
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
} else if (!open && wasOpen) {
|
|
58
|
+
wasOpen = false;
|
|
59
|
+
const target = previousFocus;
|
|
60
|
+
previousFocus = null;
|
|
61
|
+
void tick().then(() => {
|
|
62
|
+
if (target?.isConnected) {
|
|
63
|
+
target.focus();
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
32
69
|
function close() {
|
|
33
70
|
open = false;
|
|
34
71
|
onclose?.();
|
|
@@ -40,11 +77,52 @@
|
|
|
40
77
|
}
|
|
41
78
|
}
|
|
42
79
|
|
|
80
|
+
function trapFocus(event: KeyboardEvent) {
|
|
81
|
+
if (!drawerEl || event.key !== "Tab") return;
|
|
82
|
+
const focusables = Array.from(drawerEl.querySelectorAll<HTMLElement>(focusableSelector)).filter(
|
|
83
|
+
(el) => !el.hasAttribute("disabled") && el.getAttribute("aria-hidden") !== "true",
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
if (focusables.length === 0) {
|
|
87
|
+
event.preventDefault();
|
|
88
|
+
drawerEl.focus();
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const first = focusables[0]!;
|
|
93
|
+
const last = focusables[focusables.length - 1]!;
|
|
94
|
+
const active = document.activeElement;
|
|
95
|
+
|
|
96
|
+
if (!drawerEl.contains(active)) {
|
|
97
|
+
event.preventDefault();
|
|
98
|
+
first.focus();
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (event.shiftKey && active === first) {
|
|
103
|
+
event.preventDefault();
|
|
104
|
+
last.focus();
|
|
105
|
+
} else if (!event.shiftKey && active === last) {
|
|
106
|
+
event.preventDefault();
|
|
107
|
+
first.focus();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
43
111
|
function onWindowKeydown(event: KeyboardEvent) {
|
|
44
|
-
if (event.
|
|
112
|
+
if (!open || event.defaultPrevented) return;
|
|
113
|
+
const targetEl = event.target instanceof Element ? event.target : null;
|
|
114
|
+
const activeEl = document.activeElement instanceof Element ? document.activeElement : null;
|
|
115
|
+
const otherModal =
|
|
116
|
+
targetEl?.closest('[aria-modal="true"]') ?? activeEl?.closest('[aria-modal="true"]');
|
|
117
|
+
if (otherModal && otherModal !== drawerEl) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (event.key === "Escape") {
|
|
45
121
|
event.preventDefault();
|
|
46
122
|
close();
|
|
123
|
+
return;
|
|
47
124
|
}
|
|
125
|
+
trapFocus(event);
|
|
48
126
|
}
|
|
49
127
|
</script>
|
|
50
128
|
|
|
@@ -52,13 +130,27 @@
|
|
|
52
130
|
|
|
53
131
|
{#if open}
|
|
54
132
|
<div class="st-drawer__backdrop" onclick={onBackdropClick} role="presentation">
|
|
55
|
-
<aside
|
|
133
|
+
<aside
|
|
134
|
+
{...rest}
|
|
135
|
+
bind:this={drawerEl}
|
|
136
|
+
class={classes()}
|
|
137
|
+
role="dialog"
|
|
138
|
+
aria-modal="true"
|
|
139
|
+
aria-label={title}
|
|
140
|
+
tabindex="-1"
|
|
141
|
+
>
|
|
56
142
|
<header class="st-drawer__header">
|
|
57
143
|
<div>
|
|
58
|
-
<h2 class="st-drawer__title">{title}</h2>
|
|
144
|
+
<h2 class="st-drawer__title" tabindex="-1">{title}</h2>
|
|
59
145
|
{#if description}<p class="st-drawer__description">{description}</p>{/if}
|
|
60
146
|
</div>
|
|
61
|
-
<button
|
|
147
|
+
<button
|
|
148
|
+
bind:this={closeButton}
|
|
149
|
+
class="st-drawer__close"
|
|
150
|
+
type="button"
|
|
151
|
+
aria-label={closeLabel}
|
|
152
|
+
onclick={close}
|
|
153
|
+
>
|
|
62
154
|
<span aria-hidden="true">x</span>
|
|
63
155
|
</button>
|
|
64
156
|
</header>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.svelte.d.ts","sourceRoot":"","sources":["../src/lib/Drawer.svelte.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Drawer.svelte.d.ts","sourceRoot":"","sources":["../src/lib/Drawer.svelte.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGpD,KAAK,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC,GAAG;IAC9D,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;IACnC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC;AAoJJ,QAAA,MAAM,MAAM,qDAAwC,CAAC;AACrD,KAAK,MAAM,GAAG,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC;AACxC,eAAe,MAAM,CAAC"}
|