@krizaka/ui 4.5.0 → 4.7.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 +1 -0
- package/dist/account-settings.js +56 -43
- package/dist/account-settings.js.map +1 -1
- package/dist/architecture-diagram.d.ts +46 -0
- package/dist/architecture-diagram.js +324 -0
- package/dist/architecture-diagram.js.map +1 -0
- package/dist/argument-card.js +3 -3
- package/dist/blocks.css +33 -0
- package/dist/{chunk-CZHPWLNW.js → chunk-WKQ5CB3I.js} +18 -5
- package/dist/chunk-WKQ5CB3I.js.map +1 -0
- package/dist/columns.js +3 -1
- package/dist/columns.js.map +1 -1
- package/dist/comparison-table.js +3 -3
- package/dist/comparison-table.js.map +1 -1
- package/dist/filter-bar.d.ts +3 -3
- package/dist/kind-config-editor.js +1 -1
- package/dist/language-switch.d.ts +9 -9
- package/dist/map.d.ts +6 -6
- package/dist/nav-bar.d.ts +1 -1
- package/dist/notification-preferences.js +1 -1
- package/dist/router.js +2 -2
- package/dist/router.js.map +1 -1
- package/dist/{schema-Dd05m48Q.d.ts → schema-Dkn0uX72.d.ts} +1 -1
- package/dist/schema-form.js +1 -1
- package/dist/shop-composer.d.ts +2 -2
- package/dist/shop.d.ts +2 -2
- package/dist/site-cahier.d.ts +2 -0
- package/dist/site-cahier.js +2 -1
- package/dist/site-cahier.js.map +1 -1
- package/dist/site-footer.d.ts +52 -6
- package/dist/site-footer.js +98 -60
- package/dist/site-footer.js.map +1 -1
- package/dist/{sites-iJkCPeiH.d.ts → sites-BPshUouf.d.ts} +2 -2
- package/dist/switch.d.ts +25 -3
- package/dist/switch.js +1 -1
- package/dist/virtual.d.ts +3 -3
- package/package.json +30 -11
- package/registry/account-menu.json +1 -1
- package/registry/account-settings.json +1 -1
- package/registry/achievement.json +1 -1
- package/registry/action-bar.json +1 -1
- package/registry/activity-feed.json +1 -1
- package/registry/agenda.json +1 -1
- package/registry/alert.json +1 -1
- package/registry/analysis-report.json +1 -1
- package/registry/anatomy-plate.json +1 -1
- package/registry/app-frame.json +2 -2
- package/registry/app-header.json +1 -1
- package/registry/app-shell.json +1 -1
- package/registry/architecture-diagram.json +239 -0
- package/registry/argument-card.json +1 -1
- package/registry/auth-layout.json +1 -1
- package/registry/avatar.json +1 -1
- package/registry/badge.json +1 -1
- package/registry/bird-plate.json +1 -1
- package/registry/button.json +1 -1
- package/registry/captcha.json +1 -1
- package/registry/card-grid.json +1 -1
- package/registry/card.json +1 -1
- package/registry/catalogue-page.json +1 -1
- package/registry/changelog-page.json +1 -1
- package/registry/chapter.json +1 -1
- package/registry/chat.json +1 -1
- package/registry/checkbox.json +1 -1
- package/registry/chip-link.json +1 -1
- package/registry/chip-row.json +1 -1
- package/registry/chip.json +1 -1
- package/registry/choice-grid.json +1 -1
- package/registry/code-block.json +1 -1
- package/registry/collection-switcher.json +1 -1
- package/registry/columns.json +2 -2
- package/registry/combobox.json +1 -1
- package/registry/command.json +1 -1
- package/registry/comparison-table.json +2 -2
- package/registry/component-page.json +1 -1
- package/registry/confirm-button.json +1 -1
- package/registry/contact-page.json +1 -1
- package/registry/continue-prompt.json +1 -1
- package/registry/copy-button.json +1 -1
- package/registry/countdown.json +1 -1
- package/registry/cover-hero.json +1 -1
- package/registry/cta-panel.json +1 -1
- package/registry/dashboard-layout.json +1 -1
- package/registry/data-table.json +1 -1
- package/registry/date-picker.json +1 -1
- package/registry/decision-list.json +1 -1
- package/registry/description-list.json +1 -1
- package/registry/desktop-window.json +1 -1
- package/registry/detail-layout.json +1 -1
- package/registry/dialog.json +1 -1
- package/registry/docs-article-page.json +1 -1
- package/registry/docs-hub-page.json +1 -1
- package/registry/docs-layout.json +1 -1
- package/registry/docs-nav.json +1 -1
- package/registry/document-viewer.json +1 -1
- package/registry/doodle.json +1 -1
- package/registry/drop-overlay.json +1 -1
- package/registry/dropdown-menu.json +1 -1
- package/registry/elephant.json +1 -1
- package/registry/embed-facade.json +1 -1
- package/registry/empty-state.json +1 -1
- package/registry/engine-flow.json +1 -1
- package/registry/entity-header.json +1 -1
- package/registry/environment-notice.json +1 -1
- package/registry/error-page.json +1 -1
- package/registry/examples/architecture-diagram/containers.d.ts +4 -0
- package/registry/examples/architecture-diagram/containers.js +28 -0
- package/registry/examples/architecture-diagram/containers.tsx +24 -0
- package/registry/examples/architecture-diagram/context.d.ts +4 -0
- package/registry/examples/architecture-diagram/context.js +26 -0
- package/registry/examples/architecture-diagram/context.tsx +22 -0
- package/registry/examples/architecture-diagram/dynamic.d.ts +4 -0
- package/registry/examples/architecture-diagram/dynamic.js +27 -0
- package/registry/examples/architecture-diagram/dynamic.tsx +23 -0
- package/registry/examples/site-footer/family.d.ts +4 -0
- package/registry/examples/site-footer/family.js +25 -0
- package/registry/examples/site-footer/family.tsx +28 -0
- package/registry/examples/switch/row.d.ts +4 -0
- package/registry/examples/switch/row.js +14 -0
- package/registry/examples/switch/row.tsx +13 -0
- package/registry/field.json +1 -1
- package/registry/file-upload.json +1 -1
- package/registry/filter-bar.json +1 -1
- package/registry/flock.json +1 -1
- package/registry/footnote.json +1 -1
- package/registry/force-update-screen.json +1 -1
- package/registry/form.json +1 -1
- package/registry/gallery-page.json +1 -1
- package/registry/genui.json +1 -1
- package/registry/glossary-term.json +1 -1
- package/registry/glossary.json +1 -1
- package/registry/glow-card.json +1 -1
- package/registry/goal-gauge.json +1 -1
- package/registry/grade-stamp.json +1 -1
- package/registry/identity-card.json +1 -1
- package/registry/image-cropper.json +1 -1
- package/registry/index.json +38 -9
- package/registry/kanban.json +1 -1
- package/registry/kbd.json +1 -1
- package/registry/kind-config-editor.json +1 -1
- package/registry/kpi-explained.json +1 -1
- package/registry/landing-page.json +1 -1
- package/registry/landscape.json +1 -1
- package/registry/language-switch.json +1 -1
- package/registry/legal-page.json +1 -1
- package/registry/link-card.json +1 -1
- package/registry/list.json +1 -1
- package/registry/loader.json +1 -1
- package/registry/longform-page.json +1 -1
- package/registry/maintenance-screen.json +1 -1
- package/registry/map.json +2 -2
- package/registry/margin-layout.json +1 -1
- package/registry/markdown.json +1 -1
- package/registry/marketing-layout.json +1 -1
- package/registry/mascot-quote.json +1 -1
- package/registry/mascot-state.json +1 -1
- package/registry/mascots.json +1 -1
- package/registry/match-dialog.json +1 -1
- package/registry/media-capture.json +1 -1
- package/registry/media-gallery.json +1 -1
- package/registry/meter.json +1 -1
- package/registry/money-input.json +1 -1
- package/registry/nav-bar.json +2 -2
- package/registry/next-actions.json +1 -1
- package/registry/notification-preferences.json +1 -1
- package/registry/number-ticker.json +1 -1
- package/registry/opening-hours.json +1 -1
- package/registry/page-header.json +1 -1
- package/registry/page-hero.json +1 -1
- package/registry/page-index.json +1 -1
- package/registry/page.json +1 -1
- package/registry/pagination.json +1 -1
- package/registry/pointer-light.json +1 -1
- package/registry/popover.json +1 -1
- package/registry/price-catalogue-editor.json +1 -1
- package/registry/pricing-page.json +1 -1
- package/registry/product-page.json +1 -1
- package/registry/profile-card.json +1 -1
- package/registry/progress.json +1 -1
- package/registry/promise-card.json +1 -1
- package/registry/promo-code-field.json +1 -1
- package/registry/proposal.json +1 -1
- package/registry/qr-code.json +1 -1
- package/registry/quota-meter.json +1 -1
- package/registry/radio-group.json +1 -1
- package/registry/rail-nav.json +2 -2
- package/registry/recipes.json +1 -1
- package/registry/retro-tv.json +1 -1
- package/registry/reviews.json +1 -1
- package/registry/router.json +2 -2
- package/registry/schema-form.json +1 -1
- package/registry/scroll-stage.json +1 -1
- package/registry/search-field.json +1 -1
- package/registry/section-backdrop.json +1 -1
- package/registry/separator.json +1 -1
- package/registry/service-card.json +1 -1
- package/registry/settings-layout.json +1 -1
- package/registry/shop-composer.json +1 -1
- package/registry/shop-gallery.json +1 -1
- package/registry/shop.json +2 -2
- package/registry/showcase.json +1 -1
- package/registry/signature.json +1 -1
- package/registry/site-cahier.json +1 -1
- package/registry/site-footer.json +307 -6
- package/registry/sites.json +1 -1
- package/registry/skeleton.json +1 -1
- package/registry/skip-link.json +1 -1
- package/registry/slider.json +1 -1
- package/registry/slot-picker.json +1 -1
- package/registry/slot.json +1 -1
- package/registry/specimen-tag.json +1 -1
- package/registry/speed-lines.json +1 -1
- package/registry/spinner.json +1 -1
- package/registry/split-view.json +1 -1
- package/registry/stage-banner.json +1 -1
- package/registry/stat.json +1 -1
- package/registry/status-chip.json +1 -1
- package/registry/status-page.json +1 -1
- package/registry/step-progress.json +1 -1
- package/registry/step-showcase.json +1 -1
- package/registry/stepper.json +1 -1
- package/registry/sticky-action.json +1 -1
- package/registry/stuck.json +1 -1
- package/registry/swipe-deck.json +1 -1
- package/registry/switch.json +44 -7
- package/registry/tabs.json +1 -1
- package/registry/tag-input.json +1 -1
- package/registry/tag-selector.json +1 -1
- package/registry/taped-photo.json +1 -1
- package/registry/terminal-replay.json +1 -1
- package/registry/text-style.json +1 -1
- package/registry/theme.json +1 -1
- package/registry/toast.json +1 -1
- package/registry/toc.json +1 -1
- package/registry/tooltip.json +1 -1
- package/registry/tree-view.json +1 -1
- package/registry/update-prompt.json +1 -1
- package/registry/upload-queue.json +1 -1
- package/registry/usage.json +1 -1
- package/registry/verified-badge.json +1 -1
- package/registry/versus-card.json +1 -1
- package/registry/vertical-video.json +1 -1
- package/registry/video-player.json +1 -1
- package/registry/video-trimmer.json +1 -1
- package/registry/virtual.json +1 -1
- package/registry/wall.json +1 -1
- package/registry/waveform.json +1 -1
- package/dist/chunk-CZHPWLNW.js.map +0 -1
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
// src/cx.ts
|
|
2
|
+
function cx(...parts) {
|
|
3
|
+
return parts.filter(Boolean).join(" ");
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
// src/architecture-diagram/architecture-diagram.tsx
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
var SIZE = {
|
|
9
|
+
/** The room around the view's bounds. */
|
|
10
|
+
margin: 24,
|
|
11
|
+
/** The offset of the paper shadow under each element. */
|
|
12
|
+
shadow: 5,
|
|
13
|
+
/** The title, the technology and the edge label's font sizes. */
|
|
14
|
+
title: 21,
|
|
15
|
+
technology: 15,
|
|
16
|
+
label: 14,
|
|
17
|
+
/** Line heights, as a multiple of the font size. */
|
|
18
|
+
titleLeading: 1.2,
|
|
19
|
+
technologyLeading: 1.3,
|
|
20
|
+
/** Where the first baseline sits under the top of its line, as a multiple of the font size. */
|
|
21
|
+
ascent: 0.85,
|
|
22
|
+
/** The room between the title and the technology. */
|
|
23
|
+
gap: 10,
|
|
24
|
+
/** The words' side padding in a box, and in a queue (its rounded ends take room). */
|
|
25
|
+
pad: 12,
|
|
26
|
+
queuePad: 30,
|
|
27
|
+
/** The average glyph width as a share of the font size, to wrap words without measuring them. */
|
|
28
|
+
sansEm: 0.54,
|
|
29
|
+
monoEm: 0.6,
|
|
30
|
+
/** The fewest characters a wrapped line may hold. */
|
|
31
|
+
minLine: 4,
|
|
32
|
+
/** A person's head, a browser's bar and its three dots, a component's two tabs. */
|
|
33
|
+
head: 11,
|
|
34
|
+
browserBar: 20,
|
|
35
|
+
browserDots: [14, 28, 42],
|
|
36
|
+
browserDot: 3.5,
|
|
37
|
+
tab: { width: 20, height: 14, at: [0.3, 0.55] },
|
|
38
|
+
/** A cylinder's lid, and a queue's rounded ends. */
|
|
39
|
+
lid: 14,
|
|
40
|
+
lidRoom: 18,
|
|
41
|
+
queueEnd: 16,
|
|
42
|
+
/** A phone's corner and its home dot. */
|
|
43
|
+
phoneCorner: 14,
|
|
44
|
+
phoneDot: 4,
|
|
45
|
+
/** A group's title, from its top left corner. */
|
|
46
|
+
groupTitle: { dx: 18, dy: 30 },
|
|
47
|
+
/** The arrowhead: its length and its half-angle (radians). */
|
|
48
|
+
arrow: 16,
|
|
49
|
+
arrowAngle: 0.42,
|
|
50
|
+
/** The plate under an edge's label. */
|
|
51
|
+
labelPad: 4,
|
|
52
|
+
/** A step's numbered badge. */
|
|
53
|
+
badge: 13,
|
|
54
|
+
badgeText: 14,
|
|
55
|
+
badgeGap: 6,
|
|
56
|
+
/** The narrowest the drawing may shrink to fit its column, as a share of its own width: below, it scrolls in its frame. */
|
|
57
|
+
minScale: 0.6
|
|
58
|
+
};
|
|
59
|
+
var SHAPES = /* @__PURE__ */ new Map([
|
|
60
|
+
["rectangle", "box"],
|
|
61
|
+
["person", "person"],
|
|
62
|
+
["browser", "browser"],
|
|
63
|
+
["mobile", "mobile"],
|
|
64
|
+
["storage", "storage"],
|
|
65
|
+
["cylinder", "storage"],
|
|
66
|
+
["queue", "queue"],
|
|
67
|
+
["component", "component"]
|
|
68
|
+
]);
|
|
69
|
+
var OUTSIDE = /* @__PURE__ */ new Set(["external"]);
|
|
70
|
+
var SCROLL_FOCUS = { tabIndex: 0 };
|
|
71
|
+
var WORDS = {
|
|
72
|
+
summary: "The diagram in words",
|
|
73
|
+
elements: "Elements",
|
|
74
|
+
relations: "Relations",
|
|
75
|
+
steps: "Steps"
|
|
76
|
+
};
|
|
77
|
+
var RELATIVE_BASE = "https://relative.invalid";
|
|
78
|
+
function safeHref(href) {
|
|
79
|
+
if (!URL.canParse(href, RELATIVE_BASE)) return void 0;
|
|
80
|
+
const url = new URL(href, RELATIVE_BASE);
|
|
81
|
+
if (url.origin === RELATIVE_BASE) return href.startsWith("#") ? url.hash : `${url.pathname}${url.search}${url.hash}`;
|
|
82
|
+
return url.protocol === "https:" || url.protocol === "http:" ? url.href : void 0;
|
|
83
|
+
}
|
|
84
|
+
function wrap(text, width, size, em) {
|
|
85
|
+
const max = Math.max(SIZE.minLine, Math.floor(width / (size * em)));
|
|
86
|
+
const rows = [];
|
|
87
|
+
const glued = text.replaceAll("\xAB ", "\xAB\xA0").replaceAll(" \xBB", "\xA0\xBB");
|
|
88
|
+
for (const word of glued.split(/\s+/).filter(Boolean)) {
|
|
89
|
+
const last = rows.at(-1);
|
|
90
|
+
if (last !== void 0 && last.length + 1 + word.length <= max) rows[rows.length - 1] = `${last} ${word}`;
|
|
91
|
+
else rows.push(word);
|
|
92
|
+
}
|
|
93
|
+
return rows;
|
|
94
|
+
}
|
|
95
|
+
function pathOf(points) {
|
|
96
|
+
const [first, ...rest] = points;
|
|
97
|
+
if (!first || rest.length === 0) return "";
|
|
98
|
+
const parts = [`M${first[0]},${first[1]}`];
|
|
99
|
+
if (rest.length % 3 === 0) {
|
|
100
|
+
for (let i = 0; i < rest.length; i += 3) parts.push(`C${rest[i].join(",")} ${rest[i + 1].join(",")} ${rest[i + 2].join(",")}`);
|
|
101
|
+
} else {
|
|
102
|
+
for (const [x, y] of rest) parts.push(`L${x},${y}`);
|
|
103
|
+
}
|
|
104
|
+
return parts.join(" ");
|
|
105
|
+
}
|
|
106
|
+
function arrowOf(points) {
|
|
107
|
+
const tip = points.at(-1);
|
|
108
|
+
const from = points.at(-2);
|
|
109
|
+
if (!tip || !from) return null;
|
|
110
|
+
const angle = Math.atan2(tip[1] - from[1], tip[0] - from[0]);
|
|
111
|
+
const wing = (da) => `${tip[0] - SIZE.arrow * Math.cos(angle + da)},${tip[1] - SIZE.arrow * Math.sin(angle + da)}`;
|
|
112
|
+
return `${tip[0]},${tip[1]} ${wing(SIZE.arrowAngle)} ${wing(-SIZE.arrowAngle)}`;
|
|
113
|
+
}
|
|
114
|
+
function Lines({ rows, x, y, size, leading, className }) {
|
|
115
|
+
return rows.map((row, i) => /* @__PURE__ */ jsx("text", { x, y: y + i * size * leading, fontSize: size, textAnchor: "middle", className, children: row }, `${i}:${row}`));
|
|
116
|
+
}
|
|
117
|
+
function ShapeOf({ node, shape }) {
|
|
118
|
+
const { x, y, width: w, height: h } = node;
|
|
119
|
+
const s = SIZE.shadow;
|
|
120
|
+
const rect = /* @__PURE__ */ jsx("rect", { x, y, width: w, height: h, className: "kz-arch-body" });
|
|
121
|
+
const shadow = /* @__PURE__ */ jsx("rect", { x: x + s, y: y + s, width: w, height: h, className: "kz-arch-shadow" });
|
|
122
|
+
switch (shape) {
|
|
123
|
+
case "person":
|
|
124
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
125
|
+
shadow,
|
|
126
|
+
rect,
|
|
127
|
+
/* @__PURE__ */ jsx("circle", { cx: x + w / 2, cy: y, r: SIZE.head, className: "kz-arch-body" })
|
|
128
|
+
] });
|
|
129
|
+
case "browser":
|
|
130
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
131
|
+
shadow,
|
|
132
|
+
rect,
|
|
133
|
+
/* @__PURE__ */ jsx("line", { x1: x, y1: y + SIZE.browserBar, x2: x + w, y2: y + SIZE.browserBar, className: "kz-arch-detail" }),
|
|
134
|
+
SIZE.browserDots.map((dx) => /* @__PURE__ */ jsx("circle", { cx: x + dx, cy: y + SIZE.browserBar / 2, r: SIZE.browserDot, className: "kz-arch-dot" }, dx))
|
|
135
|
+
] });
|
|
136
|
+
case "mobile":
|
|
137
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
138
|
+
/* @__PURE__ */ jsx("rect", { x: x + s, y: y + s, width: w, height: h, rx: SIZE.phoneCorner, className: "kz-arch-shadow" }),
|
|
139
|
+
/* @__PURE__ */ jsx("rect", { x, y, width: w, height: h, rx: SIZE.phoneCorner, className: "kz-arch-body" }),
|
|
140
|
+
/* @__PURE__ */ jsx("circle", { cx: x + w / 2, cy: y + h - SIZE.phoneCorner / 2, r: SIZE.phoneDot, className: "kz-arch-dot" })
|
|
141
|
+
] });
|
|
142
|
+
case "storage": {
|
|
143
|
+
const ry = SIZE.lid;
|
|
144
|
+
const d = `M${x},${y + ry} A${w / 2},${ry} 0 0 1 ${x + w},${y + ry} V${y + h - ry} A${w / 2},${ry} 0 0 1 ${x},${y + h - ry} Z`;
|
|
145
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
146
|
+
/* @__PURE__ */ jsx("path", { d, transform: `translate(${s},${s})`, className: "kz-arch-shadow" }),
|
|
147
|
+
/* @__PURE__ */ jsx("path", { d, className: "kz-arch-body" }),
|
|
148
|
+
/* @__PURE__ */ jsx("path", { d: `M${x},${y + ry} A${w / 2},${ry} 0 0 0 ${x + w},${y + ry}`, className: "kz-arch-detail" })
|
|
149
|
+
] });
|
|
150
|
+
}
|
|
151
|
+
case "queue": {
|
|
152
|
+
const rx = SIZE.queueEnd;
|
|
153
|
+
const d = `M${x + rx},${y} H${x + w - rx} A${rx},${h / 2} 0 0 1 ${x + w - rx},${y + h} H${x + rx} A${rx},${h / 2} 0 0 1 ${x + rx},${y} Z`;
|
|
154
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
155
|
+
/* @__PURE__ */ jsx("path", { d, transform: `translate(${s},${s})`, className: "kz-arch-shadow" }),
|
|
156
|
+
/* @__PURE__ */ jsx("path", { d, className: "kz-arch-body" }),
|
|
157
|
+
/* @__PURE__ */ jsx("path", { d: `M${x + w - rx},${y} A${rx},${h / 2} 0 0 0 ${x + w - rx},${y + h}`, className: "kz-arch-detail" })
|
|
158
|
+
] });
|
|
159
|
+
}
|
|
160
|
+
case "component":
|
|
161
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
162
|
+
shadow,
|
|
163
|
+
rect,
|
|
164
|
+
SIZE.tab.at.map((k) => /* @__PURE__ */ jsx(
|
|
165
|
+
"rect",
|
|
166
|
+
{
|
|
167
|
+
x: x - SIZE.tab.width / 2,
|
|
168
|
+
y: y + h * k,
|
|
169
|
+
width: SIZE.tab.width,
|
|
170
|
+
height: SIZE.tab.height,
|
|
171
|
+
className: "kz-arch-body kz-arch-tab"
|
|
172
|
+
},
|
|
173
|
+
k
|
|
174
|
+
))
|
|
175
|
+
] });
|
|
176
|
+
case "box":
|
|
177
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
178
|
+
shadow,
|
|
179
|
+
rect
|
|
180
|
+
] });
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
function Group({ node }) {
|
|
184
|
+
return /* @__PURE__ */ jsxs("g", { className: "kz-arch-group", children: [
|
|
185
|
+
/* @__PURE__ */ jsx("rect", { x: node.x, y: node.y, width: node.width, height: node.height, className: "kz-arch-group-frame" }),
|
|
186
|
+
/* @__PURE__ */ jsx("text", { x: node.x + SIZE.groupTitle.dx, y: node.y + SIZE.groupTitle.dy, fontSize: SIZE.technology, className: "kz-arch-group-title", children: node.title })
|
|
187
|
+
] });
|
|
188
|
+
}
|
|
189
|
+
function Element({ node }) {
|
|
190
|
+
const shape = SHAPES.get(node.shape) ?? "box";
|
|
191
|
+
const pad = shape === "queue" ? SIZE.queuePad : SIZE.pad;
|
|
192
|
+
const room = node.width - 2 * pad;
|
|
193
|
+
const title = wrap(node.title, room, SIZE.title, SIZE.sansEm);
|
|
194
|
+
const tech = node.technology ? wrap(node.technology, room, SIZE.technology, SIZE.monoEm) : [];
|
|
195
|
+
const titleHeight = title.length * SIZE.title * SIZE.titleLeading;
|
|
196
|
+
const block = titleHeight + (tech.length ? SIZE.gap + tech.length * SIZE.technology * SIZE.technologyLeading : 0);
|
|
197
|
+
const lid = shape === "storage" ? SIZE.lidRoom : 0;
|
|
198
|
+
const top = node.y + lid + (node.height - lid - block) / 2 + SIZE.title * SIZE.ascent;
|
|
199
|
+
const cx2 = node.x + node.width / 2;
|
|
200
|
+
return /* @__PURE__ */ jsxs("g", { className: "kz-arch-element", "data-shape": shape, "data-outside": OUTSIDE.has(node.kind) || void 0, children: [
|
|
201
|
+
/* @__PURE__ */ jsx(ShapeOf, { node, shape }),
|
|
202
|
+
/* @__PURE__ */ jsx(Lines, { rows: title, x: cx2, y: top, size: SIZE.title, leading: SIZE.titleLeading, className: "kz-arch-title" }),
|
|
203
|
+
/* @__PURE__ */ jsx(Lines, { rows: tech, x: cx2, y: top + titleHeight + SIZE.gap, size: SIZE.technology, leading: SIZE.technologyLeading, className: "kz-arch-technology" })
|
|
204
|
+
] });
|
|
205
|
+
}
|
|
206
|
+
function middleOf(points) {
|
|
207
|
+
return points[Math.floor(points.length / 2)];
|
|
208
|
+
}
|
|
209
|
+
function Stroke({ edge, dynamic }) {
|
|
210
|
+
const arrow = arrowOf(edge.back ? [...edge.points].reverse() : edge.points);
|
|
211
|
+
return /* @__PURE__ */ jsxs("g", { className: "kz-arch-edge", "data-dynamic": dynamic || void 0, children: [
|
|
212
|
+
/* @__PURE__ */ jsx("path", { d: pathOf(edge.points), className: "kz-arch-line" }),
|
|
213
|
+
arrow && /* @__PURE__ */ jsx("polygon", { points: arrow, className: "kz-arch-arrow" })
|
|
214
|
+
] });
|
|
215
|
+
}
|
|
216
|
+
function EdgeLabel({ edge, dynamic }) {
|
|
217
|
+
const step = dynamic ? edge.step : null;
|
|
218
|
+
const box = edge.labelBBox;
|
|
219
|
+
const rows = edge.label && box ? wrap(edge.label, box.width + 2 * SIZE.labelPad, SIZE.label, SIZE.monoEm) : [];
|
|
220
|
+
if (rows.length === 0 && step === null) return null;
|
|
221
|
+
const centre = box ? [box.x + box.width / 2, box.y + box.height / 2] : middleOf(edge.points);
|
|
222
|
+
if (!centre) return null;
|
|
223
|
+
const [cx2, cy] = centre;
|
|
224
|
+
const width = (box?.width ?? 0) + 4 * SIZE.labelPad;
|
|
225
|
+
const height = rows.length * SIZE.label * SIZE.technologyLeading + 2 * SIZE.labelPad;
|
|
226
|
+
const badgeX = rows.length ? cx2 - width / 2 - SIZE.badgeGap - SIZE.badge : cx2;
|
|
227
|
+
return /* @__PURE__ */ jsxs("g", { className: "kz-arch-label", children: [
|
|
228
|
+
rows.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
229
|
+
/* @__PURE__ */ jsx("rect", { x: cx2 - width / 2, y: cy - height / 2, width, height, className: "kz-arch-label-plate" }),
|
|
230
|
+
/* @__PURE__ */ jsx(
|
|
231
|
+
Lines,
|
|
232
|
+
{
|
|
233
|
+
rows,
|
|
234
|
+
x: cx2,
|
|
235
|
+
y: cy - height / 2 + SIZE.labelPad + SIZE.label * SIZE.ascent,
|
|
236
|
+
size: SIZE.label,
|
|
237
|
+
leading: SIZE.technologyLeading,
|
|
238
|
+
className: "kz-arch-label-text"
|
|
239
|
+
}
|
|
240
|
+
)
|
|
241
|
+
] }),
|
|
242
|
+
step !== null && /* @__PURE__ */ jsxs("g", { className: "kz-arch-step", "data-step": step, children: [
|
|
243
|
+
/* @__PURE__ */ jsx("circle", { cx: badgeX, cy, r: SIZE.badge, className: "kz-arch-step-badge" }),
|
|
244
|
+
/* @__PURE__ */ jsx("text", { x: badgeX, y: cy, fontSize: SIZE.badgeText, textAnchor: "middle", dominantBaseline: "central", className: "kz-arch-step-number", children: step })
|
|
245
|
+
] })
|
|
246
|
+
] });
|
|
247
|
+
}
|
|
248
|
+
function ElementText({ node, links }) {
|
|
249
|
+
const given = links && Object.hasOwn(links, node.id) ? links[node.id] : void 0;
|
|
250
|
+
const href = given === void 0 ? void 0 : safeHref(given);
|
|
251
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
252
|
+
href ? /* @__PURE__ */ jsx("a", { href, children: node.title }) : /* @__PURE__ */ jsx("b", { children: node.title }),
|
|
253
|
+
node.technology && /* @__PURE__ */ jsxs("span", { className: "kz-arch-text-tech", children: [
|
|
254
|
+
" (",
|
|
255
|
+
node.technology,
|
|
256
|
+
")"
|
|
257
|
+
] }),
|
|
258
|
+
node.description && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
259
|
+
": ",
|
|
260
|
+
node.description
|
|
261
|
+
] })
|
|
262
|
+
] });
|
|
263
|
+
}
|
|
264
|
+
function ElementList({ nodes, parent, links }) {
|
|
265
|
+
const ids = new Set(nodes.map((n) => n.id));
|
|
266
|
+
const here = nodes.filter((n) => parent === null ? n.parent === null || !ids.has(n.parent) : n.parent === parent);
|
|
267
|
+
if (here.length === 0) return null;
|
|
268
|
+
return /* @__PURE__ */ jsx("ul", { className: "kz-arch-text-list", children: here.map((n) => /* @__PURE__ */ jsxs("li", { children: [
|
|
269
|
+
/* @__PURE__ */ jsx(ElementText, { node: n, links }),
|
|
270
|
+
n.compound && /* @__PURE__ */ jsx(ElementList, { nodes, parent: n.id, links })
|
|
271
|
+
] }, n.id)) });
|
|
272
|
+
}
|
|
273
|
+
function relationText(edge, titles) {
|
|
274
|
+
const said = edge.label ? `: ${edge.label}` : "";
|
|
275
|
+
return `${titles.get(edge.source) ?? edge.source} \u2192 ${titles.get(edge.target) ?? edge.target}${said}`;
|
|
276
|
+
}
|
|
277
|
+
function ArchitectureDiagram({ view, title, subtitle, links, words, textOpen = false, className, ...props }) {
|
|
278
|
+
const w = { ...WORDS, ...words };
|
|
279
|
+
const name = title ?? view.title;
|
|
280
|
+
const m = SIZE.margin;
|
|
281
|
+
const { x, y, width, height } = view.bounds;
|
|
282
|
+
const vbWidth = width + 2 * m + SIZE.shadow;
|
|
283
|
+
const vbHeight = height + 2 * m + SIZE.shadow;
|
|
284
|
+
const groups = view.nodes.filter((n) => n.compound);
|
|
285
|
+
const elements = view.nodes.filter((n) => !n.compound);
|
|
286
|
+
const titles = new Map(view.nodes.map((n) => [n.id, n.title]));
|
|
287
|
+
const relations = view.dynamic ? [...view.edges].sort((a, b) => (a.step ?? Number.MAX_SAFE_INTEGER) - (b.step ?? Number.MAX_SAFE_INTEGER)) : view.edges;
|
|
288
|
+
return /* @__PURE__ */ jsxs("figure", { className: cx("kz-plate kz-arch", className), "data-dynamic": view.dynamic || void 0, ...props, children: [
|
|
289
|
+
/* @__PURE__ */ jsxs("figcaption", { className: "kz-plate-head", children: [
|
|
290
|
+
/* @__PURE__ */ jsx("span", { className: "kz-plate-title", children: name }),
|
|
291
|
+
subtitle && /* @__PURE__ */ jsx("span", { className: "kz-plate-sub", children: subtitle })
|
|
292
|
+
] }),
|
|
293
|
+
/* @__PURE__ */ jsx("section", { className: "kz-arch-frame", "aria-label": name, ...SCROLL_FOCUS, children: /* @__PURE__ */ jsxs(
|
|
294
|
+
"svg",
|
|
295
|
+
{
|
|
296
|
+
viewBox: `${x - m} ${y - m} ${vbWidth} ${vbHeight}`,
|
|
297
|
+
role: "img",
|
|
298
|
+
"aria-label": name,
|
|
299
|
+
className: "kz-arch-svg",
|
|
300
|
+
style: { minWidth: vbWidth * SIZE.minScale, maxWidth: vbWidth },
|
|
301
|
+
children: [
|
|
302
|
+
groups.map((n) => /* @__PURE__ */ jsx(Group, { node: n }, n.id)),
|
|
303
|
+
view.edges.map((e) => /* @__PURE__ */ jsx(Stroke, { edge: e, dynamic: view.dynamic }, e.id)),
|
|
304
|
+
elements.map((n) => /* @__PURE__ */ jsx(Element, { node: n }, n.id)),
|
|
305
|
+
view.edges.map((e) => /* @__PURE__ */ jsx(EdgeLabel, { edge: e, dynamic: view.dynamic }, e.id))
|
|
306
|
+
]
|
|
307
|
+
}
|
|
308
|
+
) }),
|
|
309
|
+
/* @__PURE__ */ jsxs("details", { className: "kz-arch-text", open: textOpen, children: [
|
|
310
|
+
/* @__PURE__ */ jsx("summary", { children: w.summary }),
|
|
311
|
+
/* @__PURE__ */ jsx("p", { className: "kz-arch-text-head", children: w.elements }),
|
|
312
|
+
/* @__PURE__ */ jsx(ElementList, { nodes: view.nodes, parent: null, links }),
|
|
313
|
+
relations.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
314
|
+
/* @__PURE__ */ jsx("p", { className: "kz-arch-text-head", children: view.dynamic ? w.steps : w.relations }),
|
|
315
|
+
view.dynamic ? /* @__PURE__ */ jsx("ol", { className: "kz-arch-text-list", children: relations.map((e, i) => /* @__PURE__ */ jsx("li", { value: e.step ?? i + 1, children: relationText(e, titles) }, e.id)) }) : /* @__PURE__ */ jsx("ul", { className: "kz-arch-text-list", children: relations.map((e) => /* @__PURE__ */ jsx("li", { children: relationText(e, titles) }, e.id)) })
|
|
316
|
+
] })
|
|
317
|
+
] })
|
|
318
|
+
] });
|
|
319
|
+
}
|
|
320
|
+
export {
|
|
321
|
+
ArchitectureDiagram,
|
|
322
|
+
safeHref
|
|
323
|
+
};
|
|
324
|
+
//# sourceMappingURL=architecture-diagram.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cx.ts","../src/architecture-diagram/architecture-diagram.tsx"],"sourcesContent":["/** Joins class names, skipping the falsy ones. */\nexport function cx(...parts: Array<string | false | null | undefined>): string {\n return parts.filter(Boolean).join(\" \");\n}\n","// Server-safe. One laid-out C4 view drawn as a figure of the plate (blocks.css: `kz-plate`, `kz-arch-*`): the layout\n// comes from @krizaka/architecture, this file only draws it. Safe by construction: every SVG element is written here\n// from typed fields; no tag or attribute name is read from the view, every word is a React text child, and a link is\n// only an href the host passes, checked by `safeHref`. The drawing is an image (`role=\"img\"`, named by `aria-label`: an\n// SVG `<title>` would count as a second document title for the sites' SEO check); its full text version\n// (elements, relations or the numbered steps) is a `<details>` built from the same view.\nimport type { ArchEdge, ArchNode, ArchView, Box, Point } from \"@krizaka/architecture\";\nimport type * as React from \"react\";\n\nimport { cx } from \"../cx\";\n\n/* Every size of the drawing, in the layout's units (the view's pixels): the SVG scales them with its column. */\nconst SIZE = {\n /** The room around the view's bounds. */\n margin: 24,\n /** The offset of the paper shadow under each element. */\n shadow: 5,\n /** The title, the technology and the edge label's font sizes. */\n title: 21,\n technology: 15,\n label: 14,\n /** Line heights, as a multiple of the font size. */\n titleLeading: 1.2,\n technologyLeading: 1.3,\n /** Where the first baseline sits under the top of its line, as a multiple of the font size. */\n ascent: 0.85,\n /** The room between the title and the technology. */\n gap: 10,\n /** The words' side padding in a box, and in a queue (its rounded ends take room). */\n pad: 12,\n queuePad: 30,\n /** The average glyph width as a share of the font size, to wrap words without measuring them. */\n sansEm: 0.54,\n monoEm: 0.6,\n /** The fewest characters a wrapped line may hold. */\n minLine: 4,\n /** A person's head, a browser's bar and its three dots, a component's two tabs. */\n head: 11,\n browserBar: 20,\n browserDots: [14, 28, 42],\n browserDot: 3.5,\n tab: { width: 20, height: 14, at: [0.3, 0.55] },\n /** A cylinder's lid, and a queue's rounded ends. */\n lid: 14,\n lidRoom: 18,\n queueEnd: 16,\n /** A phone's corner and its home dot. */\n phoneCorner: 14,\n phoneDot: 4,\n /** A group's title, from its top left corner. */\n groupTitle: { dx: 18, dy: 30 },\n /** The arrowhead: its length and its half-angle (radians). */\n arrow: 16,\n arrowAngle: 0.42,\n /** The plate under an edge's label. */\n labelPad: 4,\n /** A step's numbered badge. */\n badge: 13,\n badgeText: 14,\n badgeGap: 6,\n /** The narrowest the drawing may shrink to fit its column, as a share of its own width: below, it scrolls in its frame. */\n minScale: 0.6,\n} as const;\n\n/** The shapes the component draws: anything else in the view is drawn as a box. */\ntype Shape = \"box\" | \"person\" | \"browser\" | \"mobile\" | \"storage\" | \"queue\" | \"component\";\nconst SHAPES: ReadonlyMap<string, Shape> = new Map([\n [\"rectangle\", \"box\"],\n [\"person\", \"person\"],\n [\"browser\", \"browser\"],\n [\"mobile\", \"mobile\"],\n [\"storage\", \"storage\"],\n [\"cylinder\", \"storage\"],\n [\"queue\", \"queue\"],\n [\"component\", \"component\"],\n]);\n/** The kinds drawn as outside the system (a paler body). */\nconst OUTSIDE: ReadonlySet<string> = new Set([\"external\"]);\n\n/** The words of the text version: props, never translated here. */\nexport interface ArchitectureDiagramWords {\n /** The disclosure that opens the text version. @default \"The diagram in words\" */\n summary: string;\n /** The heading of the elements. @default \"Elements\" */\n elements: string;\n /** The heading of a static view's relations. @default \"Relations\" */\n relations: string;\n /** The heading of a dynamic view's ordered steps. @default \"Steps\" */\n steps: string;\n}\n\n/* The frame scrolls sideways on a narrow screen: it takes the keyboard focus so the arrow keys can scroll it (axe: scrollable-region-focusable). */\nconst SCROLL_FOCUS = { tabIndex: 0 } as const;\n\nconst WORDS: ArchitectureDiagramWords = {\n summary: \"The diagram in words\",\n elements: \"Elements\",\n relations: \"Relations\",\n steps: \"Steps\",\n};\n\nexport type ArchitectureDiagramProps = Omit<React.HTMLAttributes<HTMLElement>, \"title\" | \"children\"> & {\n /** One laid-out view, as `@krizaka/architecture` emits it: the component draws it and lays out nothing. */\n view: ArchView;\n /** The figure's title, shown above the drawing and read as the image's name. @default view.title */\n title?: string;\n /** One line beside the title: the view's scope, its source. */\n subtitle?: React.ReactNode;\n /**\n * Links of the elements, by node id: each title of the text version becomes a link. Only `http:`/`https:` addresses\n * and same-site paths are kept (`safeHref`); any other is dropped and the title stays plain text.\n */\n links?: Readonly<Record<string, string>>;\n /** The words of the text version. */\n words?: Partial<ArchitectureDiagramWords>;\n /** Opens the text version from the start (a page where the words are the main reading). @default false */\n textOpen?: boolean;\n};\n\nconst RELATIVE_BASE = \"https://relative.invalid\";\n\n/**\n * The address a link may point at, or `undefined`: an `http:`/`https:` URL, a path on the same site (read from its root)\n * or an anchor of the page. Any other scheme (`javascript:`, `data:`, `mailto:`) is refused; a protocol-relative\n * `//host` is read as `https:`. The returned value is the parsed address, never the raw string.\n */\nexport function safeHref(href: string): string | undefined {\n if (!URL.canParse(href, RELATIVE_BASE)) return undefined;\n const url = new URL(href, RELATIVE_BASE);\n if (url.origin === RELATIVE_BASE) return href.startsWith(\"#\") ? url.hash : `${url.pathname}${url.search}${url.hash}`;\n return url.protocol === \"https:\" || url.protocol === \"http:\" ? url.href : undefined;\n}\n\n/** Words wrapped to lines no wider than `width`, for a font of `size` whose average glyph is `em` of it. */\nfunction wrap(text: string, width: number, size: number, em: number): string[] {\n const max = Math.max(SIZE.minLine, Math.floor(width / (size * em)));\n const rows: string[] = [];\n /* French quotes stay with their word: a line never starts with « » » nor ends with « « ». */\n const glued = text.replaceAll(\"« \", \"« \").replaceAll(\" »\", \" »\");\n for (const word of glued.split(/\\s+/).filter(Boolean)) {\n const last = rows.at(-1);\n if (last !== undefined && last.length + 1 + word.length <= max) rows[rows.length - 1] = `${last} ${word}`;\n else rows.push(word);\n }\n return rows;\n}\n\n/** The SVG path of the layout's edge points: a start, then cubic Bézier segments of three points each (else a polyline). */\nfunction pathOf(points: readonly Point[]): string {\n const [first, ...rest] = points;\n if (!first || rest.length === 0) return \"\";\n const parts = [`M${first[0]},${first[1]}`];\n if (rest.length % 3 === 0) {\n for (let i = 0; i < rest.length; i += 3) parts.push(`C${rest[i]!.join(\",\")} ${rest[i + 1]!.join(\",\")} ${rest[i + 2]!.join(\",\")}`);\n } else {\n for (const [x, y] of rest) parts.push(`L${x},${y}`);\n }\n return parts.join(\" \");\n}\n\n/** The arrowhead at the last point, pointing along the last segment. */\nfunction arrowOf(points: readonly Point[]): string | null {\n const tip = points.at(-1);\n const from = points.at(-2);\n if (!tip || !from) return null;\n const angle = Math.atan2(tip[1] - from[1], tip[0] - from[0]);\n const wing = (da: number) => `${tip[0] - SIZE.arrow * Math.cos(angle + da)},${tip[1] - SIZE.arrow * Math.sin(angle + da)}`;\n return `${tip[0]},${tip[1]} ${wing(SIZE.arrowAngle)} ${wing(-SIZE.arrowAngle)}`;\n}\n\n/** Lines of text, one `<text>` each, centred on `x`. */\nfunction Lines({ rows, x, y, size, leading, className }: Readonly<{ rows: string[]; x: number; y: number; size: number; leading: number; className: string }>) {\n /* A row's text is its identity: the same line twice in one block is told apart by its place. */\n return rows.map((row, i) => (\n <text key={`${i}:${row}`} x={x} y={y + i * size * leading} fontSize={size} textAnchor=\"middle\" className={className}>\n {row}\n </text>\n ));\n}\n\nfunction ShapeOf({ node, shape }: Readonly<{ node: ArchNode; shape: Shape }>) {\n const { x, y, width: w, height: h } = node;\n const s = SIZE.shadow;\n const rect = <rect x={x} y={y} width={w} height={h} className=\"kz-arch-body\" />;\n const shadow = <rect x={x + s} y={y + s} width={w} height={h} className=\"kz-arch-shadow\" />;\n switch (shape) {\n case \"person\":\n return (\n <>\n {shadow}\n {rect}\n <circle cx={x + w / 2} cy={y} r={SIZE.head} className=\"kz-arch-body\" />\n </>\n );\n case \"browser\":\n return (\n <>\n {shadow}\n {rect}\n <line x1={x} y1={y + SIZE.browserBar} x2={x + w} y2={y + SIZE.browserBar} className=\"kz-arch-detail\" />\n {SIZE.browserDots.map((dx) => (\n <circle key={dx} cx={x + dx} cy={y + SIZE.browserBar / 2} r={SIZE.browserDot} className=\"kz-arch-dot\" />\n ))}\n </>\n );\n case \"mobile\":\n return (\n <>\n <rect x={x + s} y={y + s} width={w} height={h} rx={SIZE.phoneCorner} className=\"kz-arch-shadow\" />\n <rect x={x} y={y} width={w} height={h} rx={SIZE.phoneCorner} className=\"kz-arch-body\" />\n <circle cx={x + w / 2} cy={y + h - SIZE.phoneCorner / 2} r={SIZE.phoneDot} className=\"kz-arch-dot\" />\n </>\n );\n case \"storage\": {\n const ry = SIZE.lid;\n const d = `M${x},${y + ry} A${w / 2},${ry} 0 0 1 ${x + w},${y + ry} V${y + h - ry} A${w / 2},${ry} 0 0 1 ${x},${y + h - ry} Z`;\n return (\n <>\n <path d={d} transform={`translate(${s},${s})`} className=\"kz-arch-shadow\" />\n <path d={d} className=\"kz-arch-body\" />\n <path d={`M${x},${y + ry} A${w / 2},${ry} 0 0 0 ${x + w},${y + ry}`} className=\"kz-arch-detail\" />\n </>\n );\n }\n case \"queue\": {\n const rx = SIZE.queueEnd;\n const d = `M${x + rx},${y} H${x + w - rx} A${rx},${h / 2} 0 0 1 ${x + w - rx},${y + h} H${x + rx} A${rx},${h / 2} 0 0 1 ${x + rx},${y} Z`;\n return (\n <>\n <path d={d} transform={`translate(${s},${s})`} className=\"kz-arch-shadow\" />\n <path d={d} className=\"kz-arch-body\" />\n <path d={`M${x + w - rx},${y} A${rx},${h / 2} 0 0 0 ${x + w - rx},${y + h}`} className=\"kz-arch-detail\" />\n </>\n );\n }\n case \"component\":\n return (\n <>\n {shadow}\n {rect}\n {SIZE.tab.at.map((k) => (\n <rect\n key={k}\n x={x - SIZE.tab.width / 2}\n y={y + h * k}\n width={SIZE.tab.width}\n height={SIZE.tab.height}\n className=\"kz-arch-body kz-arch-tab\"\n />\n ))}\n </>\n );\n case \"box\":\n return (\n <>\n {shadow}\n {rect}\n </>\n );\n }\n}\n\n/** A group (a compound node): a dashed frame and its name in capitals at the top left. */\nfunction Group({ node }: Readonly<{ node: ArchNode }>) {\n return (\n <g className=\"kz-arch-group\">\n <rect x={node.x} y={node.y} width={node.width} height={node.height} className=\"kz-arch-group-frame\" />\n <text x={node.x + SIZE.groupTitle.dx} y={node.y + SIZE.groupTitle.dy} fontSize={SIZE.technology} className=\"kz-arch-group-title\">\n {node.title}\n </text>\n </g>\n );\n}\n\n/** An element: its shape, its title and its technology centred in it. */\nfunction Element({ node }: Readonly<{ node: ArchNode }>) {\n const shape = SHAPES.get(node.shape) ?? \"box\";\n const pad = shape === \"queue\" ? SIZE.queuePad : SIZE.pad;\n const room = node.width - 2 * pad;\n const title = wrap(node.title, room, SIZE.title, SIZE.sansEm);\n const tech = node.technology ? wrap(node.technology, room, SIZE.technology, SIZE.monoEm) : [];\n const titleHeight = title.length * SIZE.title * SIZE.titleLeading;\n const block = titleHeight + (tech.length ? SIZE.gap + tech.length * SIZE.technology * SIZE.technologyLeading : 0);\n /* A cylinder's lid takes the top of its box: the words sit under it. */\n const lid = shape === \"storage\" ? SIZE.lidRoom : 0;\n const top = node.y + lid + (node.height - lid - block) / 2 + SIZE.title * SIZE.ascent;\n const cx = node.x + node.width / 2;\n return (\n <g className=\"kz-arch-element\" data-shape={shape} data-outside={OUTSIDE.has(node.kind) || undefined}>\n <ShapeOf node={node} shape={shape} />\n <Lines rows={title} x={cx} y={top} size={SIZE.title} leading={SIZE.titleLeading} className=\"kz-arch-title\" />\n <Lines rows={tech} x={cx} y={top + titleHeight + SIZE.gap} size={SIZE.technology} leading={SIZE.technologyLeading} className=\"kz-arch-technology\" />\n </g>\n );\n}\n\n/** The middle of an edge's points: where its step badge goes when it has no label. */\nfunction middleOf(points: readonly Point[]): Point | undefined {\n return points[Math.floor(points.length / 2)];\n}\n\n/** An edge's line and arrowhead (drawn under the elements). */\nfunction Stroke({ edge, dynamic }: Readonly<{ edge: ArchEdge; dynamic: boolean }>) {\n const arrow = arrowOf(edge.back ? [...edge.points].reverse() : edge.points);\n return (\n <g className=\"kz-arch-edge\" data-dynamic={dynamic || undefined}>\n <path d={pathOf(edge.points)} className=\"kz-arch-line\" />\n {arrow && <polygon points={arrow} className=\"kz-arch-arrow\" />}\n </g>\n );\n}\n\n/** An edge's label on its plate and, in a dynamic view, its numbered badge (drawn over the elements). */\nfunction EdgeLabel({ edge, dynamic }: Readonly<{ edge: ArchEdge; dynamic: boolean }>) {\n const step = dynamic ? edge.step : null;\n const box: Box | null = edge.labelBBox;\n const rows = edge.label && box ? wrap(edge.label, box.width + 2 * SIZE.labelPad, SIZE.label, SIZE.monoEm) : [];\n if (rows.length === 0 && step === null) return null;\n const centre = box ? ([box.x + box.width / 2, box.y + box.height / 2] as const) : middleOf(edge.points);\n if (!centre) return null;\n const [cx, cy] = centre;\n const width = (box?.width ?? 0) + 4 * SIZE.labelPad;\n const height = rows.length * SIZE.label * SIZE.technologyLeading + 2 * SIZE.labelPad;\n const badgeX = rows.length ? cx - width / 2 - SIZE.badgeGap - SIZE.badge : cx;\n return (\n <g className=\"kz-arch-label\">\n {rows.length > 0 && (\n <>\n <rect x={cx - width / 2} y={cy - height / 2} width={width} height={height} className=\"kz-arch-label-plate\" />\n <Lines\n rows={rows}\n x={cx}\n y={cy - height / 2 + SIZE.labelPad + SIZE.label * SIZE.ascent}\n size={SIZE.label}\n leading={SIZE.technologyLeading}\n className=\"kz-arch-label-text\"\n />\n </>\n )}\n {step !== null && (\n <g className=\"kz-arch-step\" data-step={step}>\n <circle cx={badgeX} cy={cy} r={SIZE.badge} className=\"kz-arch-step-badge\" />\n <text x={badgeX} y={cy} fontSize={SIZE.badgeText} textAnchor=\"middle\" dominantBaseline=\"central\" className=\"kz-arch-step-number\">\n {step}\n </text>\n </g>\n )}\n </g>\n );\n}\n\n/** An element's line of the text version: its title (a link when the host gave a safe one), technology, description. */\nfunction ElementText({ node, links }: Readonly<{ node: ArchNode; links: Readonly<Record<string, string>> | undefined }>) {\n const given = links && Object.hasOwn(links, node.id) ? links[node.id] : undefined;\n const href = given === undefined ? undefined : safeHref(given);\n return (\n <>\n {href ? <a href={href}>{node.title}</a> : <b>{node.title}</b>}\n {node.technology && <span className=\"kz-arch-text-tech\"> ({node.technology})</span>}\n {node.description && <>: {node.description}</>}\n </>\n );\n}\n\n/** The elements as nested lists: a group lists the elements inside it. */\nfunction ElementList({ nodes, parent, links }: Readonly<{ nodes: readonly ArchNode[]; parent: string | null; links: Readonly<Record<string, string>> | undefined }>) {\n const ids = new Set(nodes.map((n) => n.id));\n const here = nodes.filter((n) => (parent === null ? n.parent === null || !ids.has(n.parent) : n.parent === parent));\n if (here.length === 0) return null;\n return (\n <ul className=\"kz-arch-text-list\">\n {here.map((n) => (\n <li key={n.id}>\n <ElementText node={n} links={links} />\n {n.compound && <ElementList nodes={nodes} parent={n.id} links={links} />}\n </li>\n ))}\n </ul>\n );\n}\n\n/** One relation in words: `Source → Target: label`. */\nfunction relationText(edge: ArchEdge, titles: ReadonlyMap<string, string>): string {\n const said = edge.label ? `: ${edge.label}` : \"\";\n return `${titles.get(edge.source) ?? edge.source} → ${titles.get(edge.target) ?? edge.target}${said}`;\n}\n\n/**\n * One laid-out C4 view (context, containers, components, or a dynamic flow) drawn on the plate: groups, elements by\n * shape, edges with their labels and, in a dynamic view, numbered steps. The full text version follows it.\n */\nexport function ArchitectureDiagram({ view, title, subtitle, links, words, textOpen = false, className, ...props }: ArchitectureDiagramProps) {\n const w = { ...WORDS, ...words };\n const name = title ?? view.title;\n const m = SIZE.margin;\n const { x, y, width, height } = view.bounds;\n const vbWidth = width + 2 * m + SIZE.shadow;\n const vbHeight = height + 2 * m + SIZE.shadow;\n const groups = view.nodes.filter((n) => n.compound);\n const elements = view.nodes.filter((n) => !n.compound);\n const titles = new Map(view.nodes.map((n) => [n.id, n.title]));\n const relations = view.dynamic\n ? [...view.edges].sort((a, b) => (a.step ?? Number.MAX_SAFE_INTEGER) - (b.step ?? Number.MAX_SAFE_INTEGER))\n : view.edges;\n return (\n <figure className={cx(\"kz-plate kz-arch\", className)} data-dynamic={view.dynamic || undefined} {...props}>\n <figcaption className=\"kz-plate-head\">\n <span className=\"kz-plate-title\">{name}</span>\n {subtitle && <span className=\"kz-plate-sub\">{subtitle}</span>}\n </figcaption>\n <section className=\"kz-arch-frame\" aria-label={name} {...SCROLL_FOCUS}>\n <svg\n viewBox={`${x - m} ${y - m} ${vbWidth} ${vbHeight}`}\n role=\"img\"\n aria-label={name}\n className=\"kz-arch-svg\"\n style={{ minWidth: vbWidth * SIZE.minScale, maxWidth: vbWidth }}\n >\n {groups.map((n) => (\n <Group key={n.id} node={n} />\n ))}\n {view.edges.map((e) => (\n <Stroke key={e.id} edge={e} dynamic={view.dynamic} />\n ))}\n {elements.map((n) => (\n <Element key={n.id} node={n} />\n ))}\n {view.edges.map((e) => (\n <EdgeLabel key={e.id} edge={e} dynamic={view.dynamic} />\n ))}\n </svg>\n </section>\n <details className=\"kz-arch-text\" open={textOpen}>\n <summary>{w.summary}</summary>\n <p className=\"kz-arch-text-head\">{w.elements}</p>\n <ElementList nodes={view.nodes} parent={null} links={links} />\n {relations.length > 0 && (\n <>\n <p className=\"kz-arch-text-head\">{view.dynamic ? w.steps : w.relations}</p>\n {view.dynamic ? (\n <ol className=\"kz-arch-text-list\">\n {relations.map((e, i) => (\n <li key={e.id} value={e.step ?? i + 1}>\n {relationText(e, titles)}\n </li>\n ))}\n </ol>\n ) : (\n <ul className=\"kz-arch-text-list\">\n {relations.map((e) => (\n <li key={e.id}>{relationText(e, titles)}</li>\n ))}\n </ul>\n )}\n </>\n )}\n </details>\n </figure>\n );\n}\n"],"mappings":";AACO,SAAS,MAAM,OAAyD;AAC7E,SAAO,MAAM,OAAO,OAAO,EAAE,KAAK,GAAG;AACvC;;;AC2KI,SAcI,UAdJ,KAcI,YAdJ;AAlKJ,IAAM,OAAO;AAAA;AAAA,EAEX,QAAQ;AAAA;AAAA,EAER,QAAQ;AAAA;AAAA,EAER,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,OAAO;AAAA;AAAA,EAEP,cAAc;AAAA,EACd,mBAAmB;AAAA;AAAA,EAEnB,QAAQ;AAAA;AAAA,EAER,KAAK;AAAA;AAAA,EAEL,KAAK;AAAA,EACL,UAAU;AAAA;AAAA,EAEV,QAAQ;AAAA,EACR,QAAQ;AAAA;AAAA,EAER,SAAS;AAAA;A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A,oBAAC,QAAG,WAAU,qBACX,oBAAU,IAAI,CAAC,MACd,oBAAC,QAAe,uBAAa,GAAG,MAAM,KAA7B,EAAE,EAA6B,CACzC,GACH;AAAA,SAEJ;AAAA,OAEJ;AAAA,KACF;AAEJ;","names":["cx"]}
|
package/dist/argument-card.js
CHANGED
package/dist/blocks.css
CHANGED
|
@@ -1636,6 +1636,39 @@ a.kz-fact:focus-visible { outline: 2px solid var(--kz-ring, var(--kz-accent)); o
|
|
|
1636
1636
|
.kz-plate[data-layout="single"] .kz-plate-caption::after { top: 0; left: calc(50% - 2.5px); }
|
|
1637
1637
|
}
|
|
1638
1638
|
|
|
1639
|
+
/* ArchitectureDiagram — one laid-out C4 view on the plate (`kz-plate`): the drawing scrolls in its frame on a phone, its
|
|
1640
|
+
text version follows in a disclosure. Every colour and font of the SVG is here; its geometry is the component's. */
|
|
1641
|
+
.kz-arch-frame { overflow-x: auto; overscroll-behavior-x: contain; }
|
|
1642
|
+
.kz-arch-frame:focus-visible { outline: 2px solid var(--kz-ring, var(--kz-accent)); outline-offset: -2px; }
|
|
1643
|
+
.kz-arch-svg { display: block; width: 100%; height: auto; margin-inline: auto; }
|
|
1644
|
+
.kz-arch-body { fill: var(--kz-surface-1); stroke: var(--kz-text-primary); stroke-width: 2; }
|
|
1645
|
+
.kz-arch-element[data-outside] .kz-arch-body { fill: var(--kz-surface-0); stroke: var(--kz-text-muted); }
|
|
1646
|
+
.kz-arch-tab { stroke-width: 1.5; }
|
|
1647
|
+
.kz-arch-shadow { fill: var(--kz-border-default); }
|
|
1648
|
+
.kz-arch-detail { fill: none; stroke: var(--kz-text-primary); stroke-width: 1.5; }
|
|
1649
|
+
.kz-arch-element[data-outside] .kz-arch-detail { stroke: var(--kz-text-muted); }
|
|
1650
|
+
.kz-arch-dot { fill: var(--kz-text-primary); }
|
|
1651
|
+
.kz-arch-element[data-outside] .kz-arch-dot { fill: var(--kz-text-muted); }
|
|
1652
|
+
.kz-arch-title { font-family: var(--kz-font-sans); font-weight: 700; fill: var(--kz-text-primary); }
|
|
1653
|
+
.kz-arch-element[data-outside] .kz-arch-title { fill: var(--kz-text-secondary); }
|
|
1654
|
+
.kz-arch-technology { font-family: var(--kz-font-mono); fill: var(--kz-text-muted); }
|
|
1655
|
+
.kz-arch-group-frame { fill: none; stroke: var(--kz-border-strong); stroke-width: 2; stroke-dasharray: 10 7; }
|
|
1656
|
+
.kz-arch-group-title { font-family: var(--kz-font-mono); letter-spacing: 1px; text-transform: uppercase; fill: var(--kz-text-muted); }
|
|
1657
|
+
.kz-arch-line { fill: none; stroke: var(--kz-text-secondary); stroke-width: 1.75; stroke-dasharray: 7 5; }
|
|
1658
|
+
.kz-arch-edge[data-dynamic] .kz-arch-line { stroke-dasharray: none; }
|
|
1659
|
+
.kz-arch-arrow { fill: var(--kz-text-secondary); }
|
|
1660
|
+
.kz-arch-label-plate { fill: var(--kz-surface-1); opacity: .92; }
|
|
1661
|
+
.kz-arch-label-text { font-family: var(--kz-font-mono); fill: var(--kz-text-secondary); }
|
|
1662
|
+
.kz-arch[data-dynamic] .kz-arch-label-text { fill: var(--kz-accent-text); }
|
|
1663
|
+
.kz-arch-step-badge { fill: var(--kz-surface-1); stroke: var(--kz-accent-text); stroke-width: 2; }
|
|
1664
|
+
.kz-arch-step-number { font-family: var(--kz-font-sans); font-weight: 700; fill: var(--kz-accent-text); }
|
|
1665
|
+
.kz-arch-text { margin-top: 16px; font-size: 14px; line-height: 22px; color: var(--kz-text-secondary); }
|
|
1666
|
+
.kz-arch-text > summary { cursor: pointer; font-family: var(--kz-font-mono); font-size: 13px; color: var(--kz-text-primary); }
|
|
1667
|
+
.kz-arch-text-head { margin: 12px 0 4px; font-family: var(--kz-font-mono); font-size: 12.5px; font-weight: 700; color: var(--kz-text-primary); }
|
|
1668
|
+
.kz-arch-text-list { margin: 0; padding-inline-start: 20px; overflow-wrap: anywhere; }
|
|
1669
|
+
.kz-arch-text-list b, .kz-arch-text-list a { color: var(--kz-text-primary); }
|
|
1670
|
+
.kz-arch-text-tech { font-family: var(--kz-font-mono); font-size: 13px; }
|
|
1671
|
+
|
|
1639
1672
|
/* PageIndex — a book's index: dotted leaders and page numbers; the current entry marked in the margin. */
|
|
1640
1673
|
.kz-index { font-size: 15px; line-height: 24px; }
|
|
1641
1674
|
.kz-index-group + .kz-index-group { margin-top: 16px; }
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
// src/switch/switch.tsx
|
|
4
4
|
import { Switch as SwitchPrimitive } from "radix-ui";
|
|
5
|
+
import * as React from "react";
|
|
5
6
|
import { tv } from "tailwind-variants";
|
|
6
|
-
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
8
|
var switchVariants = tv({
|
|
8
9
|
slots: {
|
|
10
|
+
row: "flex min-h-11 w-full items-center justify-between gap-4",
|
|
9
11
|
root: "peer relative inline-flex shrink-0 cursor-pointer items-center rounded-full border border-transparent bg-fg-muted transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-surface-0 disabled:cursor-not-allowed disabled:opacity-40 data-[state=checked]:bg-accent aria-invalid:border-danger",
|
|
10
12
|
thumb: "pointer-events-none block rounded-full bg-fg-on-media shadow-sm transition-transform data-[state=unchecked]:translate-x-0.5 motion-reduce:transition-none"
|
|
11
13
|
},
|
|
@@ -17,23 +19,34 @@ var switchVariants = tv({
|
|
|
17
19
|
},
|
|
18
20
|
defaultVariants: { size: "md" }
|
|
19
21
|
});
|
|
20
|
-
function Switch({ label, size, invalid, className, ...props }) {
|
|
22
|
+
function Switch({ label, size, invalid, className, children, description, ...props }) {
|
|
21
23
|
const s = switchVariants({ size });
|
|
22
|
-
|
|
24
|
+
const id = React.useId();
|
|
25
|
+
const row = children !== void 0;
|
|
26
|
+
const control = /* @__PURE__ */ jsx(
|
|
23
27
|
SwitchPrimitive.Root,
|
|
24
28
|
{
|
|
25
29
|
"aria-label": label,
|
|
26
30
|
"aria-invalid": invalid || void 0,
|
|
27
31
|
"data-invalid": invalid ? "" : void 0,
|
|
28
|
-
|
|
32
|
+
"aria-labelledby": row ? `${id}t` : void 0,
|
|
33
|
+
"aria-describedby": row && description ? `${id}h` : void 0,
|
|
34
|
+
className: s.root({ className: row ? void 0 : className }),
|
|
29
35
|
...props,
|
|
30
36
|
children: /* @__PURE__ */ jsx(SwitchPrimitive.Thumb, { className: s.thumb() })
|
|
31
37
|
}
|
|
32
38
|
);
|
|
39
|
+
return row ? /* @__PURE__ */ jsxs("label", { className: s.row({ className }), children: [
|
|
40
|
+
/* @__PURE__ */ jsxs("span", { className: "grid min-w-0", children: [
|
|
41
|
+
/* @__PURE__ */ jsx("span", { id: `${id}t`, className: "text-sm text-fg", children }),
|
|
42
|
+
description ? /* @__PURE__ */ jsx("span", { id: `${id}h`, className: "text-xs text-fg-muted", children: description }) : null
|
|
43
|
+
] }),
|
|
44
|
+
control
|
|
45
|
+
] }) : control;
|
|
33
46
|
}
|
|
34
47
|
|
|
35
48
|
export {
|
|
36
49
|
switchVariants,
|
|
37
50
|
Switch
|
|
38
51
|
};
|
|
39
|
-
//# sourceMappingURL=chunk-
|
|
52
|
+
//# sourceMappingURL=chunk-WKQ5CB3I.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/switch/switch.tsx"],"sourcesContent":["// Client. Radix Switch: role=\"switch\", aria-checked, Space and Enter toggle, a hidden input inside a form.\nimport { Switch as SwitchPrimitive } from \"radix-ui\";\nimport * as React from \"react\";\nimport { tv, type VariantProps } from \"tailwind-variants\";\n\nexport const switchVariants = tv({\n slots: {\n row: \"flex min-h-11 w-full items-center justify-between gap-4\",\n root:\n \"peer relative inline-flex shrink-0 cursor-pointer items-center rounded-full border border-transparent bg-fg-muted transition-colors \" +\n \"focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-surface-0 \" +\n \"disabled:cursor-not-allowed disabled:opacity-40 data-[state=checked]:bg-accent aria-invalid:border-danger\",\n thumb:\n \"pointer-events-none block rounded-full bg-fg-on-media shadow-sm transition-transform data-[state=unchecked]:translate-x-0.5 motion-reduce:transition-none\",\n },\n variants: {\n size: {\n sm: { root: \"h-5 w-9\", thumb: \"h-4 w-4 data-[state=checked]:translate-x-[1.125rem]\" },\n md: { root: \"h-6 w-11\", thumb: \"h-5 w-5 data-[state=checked]:translate-x-[1.375rem]\" },\n },\n },\n defaultVariants: { size: \"md\" },\n});\n\nexport type SwitchVariants = VariantProps<typeof switchVariants>;\n\ntype Named =\n | {\n /** The accessible name — required when no visible label names it, passed translated. */\n label: string;\n }\n /** Named by a visible `<label htmlFor={id}>` (e.g. `Field.Label`). */\n | { label?: undefined; id: string }\n /** Named by another element. */\n | { label?: undefined; \"aria-labelledby\": string }\n /** Named by its own settings row: `children` is the visible label. */\n | { label?: undefined; children: React.ReactNode };\n\n/** The settings row: the words at the start, the switch at the end, the whole row clickable. */\ntype Row =\n | { children?: undefined; description?: undefined }\n | {\n /** The visible words, at the start of the row: they name the switch and the whole row toggles it. */\n children: React.ReactNode;\n /** A line under the words, read with the switch as its hint. */\n description?: React.ReactNode;\n };\n\nexport type SwitchProps = Omit<React.ComponentProps<typeof SwitchPrimitive.Root>, \"children\"> &\n SwitchVariants &\n Named &\n Row & {\n /**\n * sm · md.\n * @default \"md\"\n */\n size?: SwitchVariants[\"size\"];\n /** Marks it invalid: aria-invalid and data-invalid. */\n invalid?: boolean;\n };\n\n/**\n * An on/off switch: `checked`/`defaultChecked` + `onCheckedChange`. With `children` (and a `description`) it draws its\n * own settings row: the words at the start, the switch at the end (mirrored under `dir=\"rtl\"`), the whole row\n * clickable, 44 px high or more. It stays one control with one name (`children`) and one hint (`description`).\n */\nexport function Switch({ label, size, invalid, className, children, description, ...props }: SwitchProps) {\n const s = switchVariants({ size });\n const id = React.useId();\n const row = children !== undefined;\n const control = (\n <SwitchPrimitive.Root\n aria-label={label}\n aria-invalid={invalid || undefined}\n data-invalid={invalid ? \"\" : undefined}\n aria-labelledby={row ? `${id}t` : undefined}\n aria-describedby={row && description ? `${id}h` : undefined}\n className={s.root({ className: row ? undefined : className })}\n {...props}\n >\n <SwitchPrimitive.Thumb className={s.thumb()} />\n </SwitchPrimitive.Root>\n );\n return row ? (\n <label className={s.row({ className })}>\n <span className=\"grid min-w-0\">\n <span id={`${id}t`} className=\"text-sm text-fg\">\n {children}\n </span>\n {description ? (\n <span id={`${id}h`} className=\"text-xs text-fg-muted\">\n {description}\n </span>\n ) : null}\n </span>\n {control}\n </label>\n ) : (\n control\n );\n}\n"],"mappings":";;;AACA,SAAS,UAAU,uBAAuB;AAC1C,YAAY,WAAW;AACvB,SAAS,UAA6B;AA6EhC,cAKA,YALA;AA3EC,IAAM,iBAAiB,GAAG;AAAA,EAC/B,OAAO;AAAA,IACL,KAAK;AAAA,IACL,MACE;AAAA,IAGF,OACE;AAAA,EACJ;AAAA,EACA,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,IAAI,EAAE,MAAM,WAAW,OAAO,sDAAsD;AAAA,MACpF,IAAI,EAAE,MAAM,YAAY,OAAO,sDAAsD;AAAA,IACvF;AAAA,EACF;AAAA,EACA,iBAAiB,EAAE,MAAM,KAAK;AAChC,CAAC;AA4CM,SAAS,OAAO,EAAE,OAAO,MAAM,SAAS,WAAW,UAAU,aAAa,GAAG,MAAM,GAAgB;AACxG,QAAM,IAAI,eAAe,EAAE,KAAK,CAAC;AACjC,QAAM,KAAW,YAAM;AACvB,QAAM,MAAM,aAAa;AACzB,QAAM,UACJ;AAAA,IAAC,gBAAgB;AAAA,IAAhB;AAAA,MACC,cAAY;AAAA,MACZ,gBAAc,WAAW;AAAA,MACzB,gBAAc,UAAU,KAAK;AAAA,MAC7B,mBAAiB,MAAM,GAAG,EAAE,MAAM;AAAA,MAClC,oBAAkB,OAAO,cAAc,GAAG,EAAE,MAAM;AAAA,MAClD,WAAW,EAAE,KAAK,EAAE,WAAW,MAAM,SAAY,UAAU,CAAC;AAAA,MAC3D,GAAG;AAAA,MAEJ,8BAAC,gBAAgB,OAAhB,EAAsB,WAAW,EAAE,MAAM,GAAG;AAAA;AAAA,EAC/C;AAEF,SAAO,MACL,qBAAC,WAAM,WAAW,EAAE,IAAI,EAAE,UAAU,CAAC,GACnC;AAAA,yBAAC,UAAK,WAAU,gBACd;AAAA,0BAAC,UAAK,IAAI,GAAG,EAAE,KAAK,WAAU,mBAC3B,UACH;AAAA,MACC,cACC,oBAAC,UAAK,IAAI,GAAG,EAAE,KAAK,WAAU,yBAC3B,uBACH,IACE;AAAA,OACN;AAAA,IACC;AAAA,KACH,IAEA;AAEJ;","names":[]}
|
package/dist/columns.js
CHANGED
|
@@ -47,7 +47,9 @@ function Grid({ children, columns, minItemWidth = 160, gap = "md", maxColumns =
|
|
|
47
47
|
// As many tracks as `--kz-grid-cols` allows, none narrower than the minimum: the ceiling drops on its own.
|
|
48
48
|
gridTemplateColumns: "repeat(auto-fill, minmax(max(var(--kz-grid-min), calc((100% - (var(--kz-grid-cols) - 1) * var(--kz-grid-gap)) / var(--kz-grid-cols))), 1fr))"
|
|
49
49
|
};
|
|
50
|
-
|
|
50
|
+
const Track = label ? "ul" : "div";
|
|
51
|
+
const Cell = label ? "li" : "div";
|
|
52
|
+
return /* @__PURE__ */ jsx("div", { className: s.grid({ className }), style, ...props, children: /* @__PURE__ */ jsx(Track, { className: s.track({ className: label ? "m-0 list-none p-0" : void 0 }), style: vars, "aria-label": label, children: items.map((child, index) => /* @__PURE__ */ jsx(Cell, { className: s.cell(), children: child }, React.isValidElement(child) && child.key != null ? child.key : index)) }) });
|
|
51
53
|
}
|
|
52
54
|
function columnsNeed(count, minColumnWidth, gapPx, fontScale = 1) {
|
|
53
55
|
return count * minColumnWidth * Math.max(1, fontScale) + gapPx * (count - 1);
|
package/dist/columns.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/columns/columns.tsx"],"sourcesContent":["// Server-safe. Layouts that decide on the width of the room they sit in — their container, never the viewport or a device —\n// like the native `Grid` and `Columns` (src/native/grid.tsx), with the same props and the same size classes\n// (compact < 600 px, regular < 840 px, expanded from there). No JS measures anything: `Grid` is a CSS container\n// (`@container`) whose columns come from the size class of that container, and `Columns` stacks by container-relative\n// sizing (a `flex-basis` that is huge below the width the columns need and zero above it). Every width is in `rem`, so a\n// larger text size grows the room an item needs: at 200 % a card that held two per row stacks into one. The order is the\n// reading order and it mirrors in `rtl`: no physical edge is used.\nimport * as React from \"react\";\nimport { tv } from \"tailwind-variants\";\n\n/** The size class of a container: where each one begins, in px of the room (Material's window size classes, as on native). */\nexport const SIZE_CLASS_FROM = { regular: 600, expanded: 840 } as const;\n\n/** The gap tokens, in px — the spacing scale (`gap-1` … `gap-6`), the same numbers as native. */\nexport const GRID_GAPS = { none: 0, xs: 4, sm: 8, md: 12, lg: 16, xl: 24 } as const;\nexport type GridGap = keyof typeof GRID_GAPS;\n\n/** How many columns per size class, or one number for all. A size class left out takes the one before it (compact → regular → expanded). */\nexport type GridColumns = number | Partial<Record<\"compact\" | \"regular\" | \"expanded\", number>>;\n\n/** One column on a compact room, two on a regular one, three on an expanded one. */\nexport const DEFAULT_COLUMNS = { compact: 1, regular: 2, expanded: 3 } as const;\n\nconst PX_PER_REM = 16;\nconst rem = (px: number) => `${px / PX_PER_REM}rem`;\n\nexport const columnsLayout = tv({\n slots: {\n // `@container`: the grid reads the width of this element. The track inside switches its columns at its widths.\n grid: \"@container w-full min-w-0\",\n track:\n \"grid [--kz-grid-cols:var(--kz-grid-compact)] @min-[600px]:[--kz-grid-cols:var(--kz-grid-regular)] @min-[840px]:[--kz-grid-cols:var(--kz-grid-expanded)]\",\n cell: \"flex min-w-0 flex-col\",\n columns: \"flex w-full min-w-0 flex-wrap\",\n column: \"min-w-0\",\n },\n variants: {\n gap: Object.fromEntries(\n Object.entries({ none: \"gap-0\", xs: \"gap-1\", sm: \"gap-2\", md: \"gap-3\", lg: \"gap-4\", xl: \"gap-6\" }).map(([name, cls]) => [name, { track: cls, columns: cls }]),\n ) as Record<GridGap, { track: string; columns: string }>,\n equalHeight: { true: { track: \"items-stretch\", cell: \"*:flex-1\" }, false: { track: \"items-start\" } },\n },\n});\n\n/** The columns of a size class: a size class left out takes the one before it. */\nexport function columnsFor(columns: GridColumns | undefined, sizeClass: keyof typeof DEFAULT_COLUMNS): number {\n const asked = columns ?? DEFAULT_COLUMNS;\n if (typeof asked === \"number\") return Math.max(1, Math.floor(asked));\n const order = [\"compact\", \"regular\", \"expanded\"] as const;\n for (let i = order.indexOf(sizeClass); i >= 0; i--) {\n const value = asked[order[i] as (typeof order)[number]];\n if (value) return Math.max(1, Math.floor(value));\n }\n return 1;\n}\n\nexport type GridProps = Omit<React.ComponentProps<\"div\">, \"children\"> & {\n /** The items. Each is one cell. */\n children: React.ReactNode;\n /** Columns per size class of the container the grid is in (default 1 · 2 · 3), or one number. A ceiling: it drops when `minItemWidth` does not fit. */\n columns?: GridColumns;\n /** No cell is narrower than this, in px (default 160); it grows with the text scale. */\n minItemWidth?: number;\n /** The space between cells (default `md`). */\n gap?: GridGap;\n /** The most columns, whatever the container (default 6). */\n maxColumns?: number;\n /** The cells of a row are as tall as the tallest (default true); `false` lets each keep its own height. */\n equalHeight?: boolean;\n /** The text scale to lay out for, on top of the browser's (widths are in `rem`, so a larger text size is followed already). Pass 2 to see 200 % text. */\n fontScale?: number;\n};\n\n/**\n * A grid that fits its container: the columns come from the size class of the container's width, and no cell is narrower\n * than `minItemWidth`, so nothing overflows in a page, a side panel or a split. The order mirrors in right-to-left.\n */\nexport function Grid({ children, columns, minItemWidth = 160, gap = \"md\", maxColumns = 6, equalHeight = true, fontScale = 1, \"aria-label\": label, className, style, ...props }: GridProps) {\n const s = columnsLayout({ gap, equalHeight });\n const items = React.Children.toArray(children);\n const cap = Math.max(1, Math.floor(maxColumns));\n const at = (sizeClass: keyof typeof DEFAULT_COLUMNS) => Math.min(columnsFor(columns, sizeClass), cap);\n const vars = {\n \"--kz-grid-compact\": at(\"compact\"),\n \"--kz-grid-regular\": at(\"regular\"),\n \"--kz-grid-expanded\": at(\"expanded\"),\n \"--kz-grid-min\": rem(minItemWidth * Math.max(1, fontScale)),\n \"--kz-grid-gap\": rem(GRID_GAPS[gap]),\n // As many tracks as `--kz-grid-cols` allows, none narrower than the minimum: the ceiling drops on its own.\n gridTemplateColumns:\n \"repeat(auto-fill, minmax(max(var(--kz-grid-min), calc((100% - (var(--kz-grid-cols) - 1) * var(--kz-grid-gap)) / var(--kz-grid-cols))), 1fr))\",\n } as React.CSSProperties;\n return (\n <div className={s.grid({ className })} style={style} {...props}>\n <div className={s.track()} style={vars} role={label ? \"list\" : undefined} aria-label={label}>\n {items.map((child, index) => (\n <div key={React.isValidElement(child) && child.key != null ? child.key : index} className={s.cell()} role={label ? \"listitem\" : undefined}>\n {child}\n </div>\n ))}\n </div>\n </div>\n );\n}\n\nexport type ColumnsProps = Omit<React.ComponentProps<\"div\">, \"children\"> & {\n /** The columns, in reading order (the first is at the start edge, on the right in right-to-left). */\n children: React.ReactNode;\n /** The share of each column (default equal); `[1, 2]` is a third and two thirds. */\n weights?: readonly number[];\n /** Below this width per column, in px, the columns stack top to bottom (default 280); it grows with the text scale. */\n minColumnWidth?: number;\n /** The space between columns, and between stacked ones (default `lg`). */\n gap?: GridGap;\n /** The text scale to lay out for, on top of the browser's. Pass 2 to see 200 % text. */\n fontScale?: number;\n};\n\n/** The width, in px, that `count` columns need to sit side by side. */\nexport function columnsNeed(count: number, minColumnWidth: number, gapPx: number, fontScale = 1): number {\n return count * minColumnWidth * Math.max(1, fontScale) + gapPx * (count - 1);\n}\n\n/**\n * A few columns that sit side by side when their container holds them and stack when it does not — the master and the\n * detail, a form and its summary. Stacked, they keep their order and each takes the full width.\n */\nexport function Columns({ children, weights, minColumnWidth = 280, gap = \"lg\", fontScale = 1, className, style, ...props }: ColumnsProps) {\n const s = columnsLayout({ gap });\n const items = React.Children.toArray(children);\n const need = columnsNeed(items.length, minColumnWidth, GRID_GAPS[gap], fontScale);\n const side = items.length > 1;\n return (\n <div\n className={s.columns({ className })}\n style={{ \"--kz-columns-need\": rem(need), ...style } as React.CSSProperties}\n data-layout=\"columns\"\n {...props}\n >\n {items.map((child, index) => (\n <div\n key={React.isValidElement(child) && child.key != null ? child.key : index}\n className={s.column()}\n // Container-relative: a basis above the row's width wraps the column onto its own line (stacked, full width);\n // below it the basis is 0 and the free space is shared by weight.\n style={{ flexGrow: weights?.[index] ?? 1, flexBasis: side ? \"calc((var(--kz-columns-need) - 100%) * 999)\" : \"100%\" }}\n >\n {child}\n </div>\n ))}\n </div>\n );\n}\n"],"mappings":";AAOA,YAAY,WAAW;AACvB,SAAS,UAAU;AAwFT;AArFH,IAAM,kBAAkB,EAAE,SAAS,KAAK,UAAU,IAAI;AAGtD,IAAM,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,IAAI,IAAI,IAAI,IAAI,GAAG;AAOlE,IAAM,kBAAkB,EAAE,SAAS,GAAG,SAAS,GAAG,UAAU,EAAE;AAErE,IAAM,aAAa;AACnB,IAAM,MAAM,CAAC,OAAe,GAAG,KAAK,UAAU;AAEvC,IAAM,gBAAgB,GAAG;AAAA,EAC9B,OAAO;AAAA;AAAA,IAEL,MAAM;AAAA,IACN,OACE;AAAA,IACF,MAAM;AAAA,IACN,SAAS;AAAA,IACT,QAAQ;AAAA,EACV;AAAA,EACA,UAAU;AAAA,IACR,KAAK,OAAO;AAAA,MACV,OAAO,QAAQ,EAAE,MAAM,SAAS,IAAI,SAAS,IAAI,SAAS,IAAI,SAAS,IAAI,SAAS,IAAI,QAAQ,CAAC,EAAE,IAAI,CAAC,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,KAAK,SAAS,IAAI,CAAC,CAAC;AAAA,IAC9J;AAAA,IACA,aAAa,EAAE,MAAM,EAAE,OAAO,iBAAiB,MAAM,WAAW,GAAG,O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,IAAI,CAAC,OAAO,UACjB,oBAAC,SAA+E,WAAW,EAAE,KAAK,GAAG,MAAM,QAAQ,aAAa,QAC7H,mBADa,qBAAe,KAAK,KAAK,MAAM,OAAO,OAAO,MAAM,MAAM,KAEzE,CACD,GACH,GACF;AAEJ;AAgBO,SAAS,YAAY,OAAe,gBAAwB,OAAe,YAAY,GAAW;AACvG,SAAO,QAAQ,iBAAiB,KAAK,IAAI,GAAG,SAAS,IAAI,SAAS,QAAQ;AAC5E;AAMO,SAAS,QAAQ,EAAE,UAAU,SAAS,iBAAiB,KAAK,MAAM,MAAM,YAAY,GAAG,WAAW,OAAO,GAAG,MAAM,GAAiB;AACxI,QAAM,IAAI,cAAc,EAAE,IAAI,CAAC;AAC/B,QAAM,QAAc,eAAS,QAAQ,QAAQ;AAC7C,QAAM,OAAO,YAAY,MAAM,QAAQ,gBAAgB,UAAU,GAAG,GAAG,SAAS;AAChF,QAAM,OAAO,MAAM,SAAS;AAC5B,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,EAAE,QAAQ,EAAE,UAAU,CAAC;AAAA,MAClC,OAAO,EAAE,qBAAqB,IAAI,IAAI,GAAG,GAAG,MAAM;AAAA,MAClD,eAAY;AAAA,MACX,GAAG;AAAA,MAEH,gBAAM,IAAI,CAAC,OAAO,UACjB;AAAA,QAAC;AAAA;AAAA,UAEC,WAAW,EAAE,OAAO;AAAA,UAGpB,OAAO,EAAE,UAAU,UAAU,KAAK,KAAK,GAAG,WAAW,OAAO,gDAAgD,OAAO;AAAA,UAElH;AAAA;AAAA,QANU,qBAAe,KAAK,KAAK,MAAM,OAAO,OAAO,MAAM,MAAM;AAAA,MAOtE,CACD;AAAA;AAAA,EACH;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/columns/columns.tsx"],"sourcesContent":["// Server-safe. Layouts that decide on the width of the room they sit in — their container, never the viewport or a device —\n// like the native `Grid` and `Columns` (src/native/grid.tsx), with the same props and the same size classes\n// (compact < 600 px, regular < 840 px, expanded from there). No JS measures anything: `Grid` is a CSS container\n// (`@container`) whose columns come from the size class of that container, and `Columns` stacks by container-relative\n// sizing (a `flex-basis` that is huge below the width the columns need and zero above it). Every width is in `rem`, so a\n// larger text size grows the room an item needs: at 200 % a card that held two per row stacks into one. The order is the\n// reading order and it mirrors in `rtl`: no physical edge is used.\nimport * as React from \"react\";\nimport { tv } from \"tailwind-variants\";\n\n/** The size class of a container: where each one begins, in px of the room (Material's window size classes, as on native). */\nexport const SIZE_CLASS_FROM = { regular: 600, expanded: 840 } as const;\n\n/** The gap tokens, in px — the spacing scale (`gap-1` … `gap-6`), the same numbers as native. */\nexport const GRID_GAPS = { none: 0, xs: 4, sm: 8, md: 12, lg: 16, xl: 24 } as const;\nexport type GridGap = keyof typeof GRID_GAPS;\n\n/** How many columns per size class, or one number for all. A size class left out takes the one before it (compact → regular → expanded). */\nexport type GridColumns = number | Partial<Record<\"compact\" | \"regular\" | \"expanded\", number>>;\n\n/** One column on a compact room, two on a regular one, three on an expanded one. */\nexport const DEFAULT_COLUMNS = { compact: 1, regular: 2, expanded: 3 } as const;\n\nconst PX_PER_REM = 16;\nconst rem = (px: number) => `${px / PX_PER_REM}rem`;\n\nexport const columnsLayout = tv({\n slots: {\n // `@container`: the grid reads the width of this element. The track inside switches its columns at its widths.\n grid: \"@container w-full min-w-0\",\n track:\n \"grid [--kz-grid-cols:var(--kz-grid-compact)] @min-[600px]:[--kz-grid-cols:var(--kz-grid-regular)] @min-[840px]:[--kz-grid-cols:var(--kz-grid-expanded)]\",\n cell: \"flex min-w-0 flex-col\",\n columns: \"flex w-full min-w-0 flex-wrap\",\n column: \"min-w-0\",\n },\n variants: {\n gap: Object.fromEntries(\n Object.entries({ none: \"gap-0\", xs: \"gap-1\", sm: \"gap-2\", md: \"gap-3\", lg: \"gap-4\", xl: \"gap-6\" }).map(([name, cls]) => [name, { track: cls, columns: cls }]),\n ) as Record<GridGap, { track: string; columns: string }>,\n equalHeight: { true: { track: \"items-stretch\", cell: \"*:flex-1\" }, false: { track: \"items-start\" } },\n },\n});\n\n/** The columns of a size class: a size class left out takes the one before it. */\nexport function columnsFor(columns: GridColumns | undefined, sizeClass: keyof typeof DEFAULT_COLUMNS): number {\n const asked = columns ?? DEFAULT_COLUMNS;\n if (typeof asked === \"number\") return Math.max(1, Math.floor(asked));\n const order = [\"compact\", \"regular\", \"expanded\"] as const;\n for (let i = order.indexOf(sizeClass); i >= 0; i--) {\n const value = asked[order[i] as (typeof order)[number]];\n if (value) return Math.max(1, Math.floor(value));\n }\n return 1;\n}\n\nexport type GridProps = Omit<React.ComponentProps<\"div\">, \"children\"> & {\n /** The items. Each is one cell. */\n children: React.ReactNode;\n /** Columns per size class of the container the grid is in (default 1 · 2 · 3), or one number. A ceiling: it drops when `minItemWidth` does not fit. */\n columns?: GridColumns;\n /** No cell is narrower than this, in px (default 160); it grows with the text scale. */\n minItemWidth?: number;\n /** The space between cells (default `md`). */\n gap?: GridGap;\n /** The most columns, whatever the container (default 6). */\n maxColumns?: number;\n /** The cells of a row are as tall as the tallest (default true); `false` lets each keep its own height. */\n equalHeight?: boolean;\n /** The text scale to lay out for, on top of the browser's (widths are in `rem`, so a larger text size is followed already). Pass 2 to see 200 % text. */\n fontScale?: number;\n};\n\n/**\n * A grid that fits its container: the columns come from the size class of the container's width, and no cell is narrower\n * than `minItemWidth`, so nothing overflows in a page, a side panel or a split. The order mirrors in right-to-left.\n */\nexport function Grid({ children, columns, minItemWidth = 160, gap = \"md\", maxColumns = 6, equalHeight = true, fontScale = 1, \"aria-label\": label, className, style, ...props }: GridProps) {\n const s = columnsLayout({ gap, equalHeight });\n const items = React.Children.toArray(children);\n const cap = Math.max(1, Math.floor(maxColumns));\n const at = (sizeClass: keyof typeof DEFAULT_COLUMNS) => Math.min(columnsFor(columns, sizeClass), cap);\n const vars = {\n \"--kz-grid-compact\": at(\"compact\"),\n \"--kz-grid-regular\": at(\"regular\"),\n \"--kz-grid-expanded\": at(\"expanded\"),\n \"--kz-grid-min\": rem(minItemWidth * Math.max(1, fontScale)),\n \"--kz-grid-gap\": rem(GRID_GAPS[gap]),\n // As many tracks as `--kz-grid-cols` allows, none narrower than the minimum: the ceiling drops on its own.\n gridTemplateColumns:\n \"repeat(auto-fill, minmax(max(var(--kz-grid-min), calc((100% - (var(--kz-grid-cols) - 1) * var(--kz-grid-gap)) / var(--kz-grid-cols))), 1fr))\",\n } as React.CSSProperties;\n // A labelled grid is a list: real <ul>/<li> (native semantics on every device), never a div with an ARIA role.\n const Track = label ? \"ul\" : \"div\";\n const Cell = label ? \"li\" : \"div\";\n return (\n <div className={s.grid({ className })} style={style} {...props}>\n <Track className={s.track({ className: label ? \"m-0 list-none p-0\" : undefined })} style={vars} aria-label={label}>\n {items.map((child, index) => (\n <Cell key={React.isValidElement(child) && child.key != null ? child.key : index} className={s.cell()}>\n {child}\n </Cell>\n ))}\n </Track>\n </div>\n );\n}\n\nexport type ColumnsProps = Omit<React.ComponentProps<\"div\">, \"children\"> & {\n /** The columns, in reading order (the first is at the start edge, on the right in right-to-left). */\n children: React.ReactNode;\n /** The share of each column (default equal); `[1, 2]` is a third and two thirds. */\n weights?: readonly number[];\n /** Below this width per column, in px, the columns stack top to bottom (default 280); it grows with the text scale. */\n minColumnWidth?: number;\n /** The space between columns, and between stacked ones (default `lg`). */\n gap?: GridGap;\n /** The text scale to lay out for, on top of the browser's. Pass 2 to see 200 % text. */\n fontScale?: number;\n};\n\n/** The width, in px, that `count` columns need to sit side by side. */\nexport function columnsNeed(count: number, minColumnWidth: number, gapPx: number, fontScale = 1): number {\n return count * minColumnWidth * Math.max(1, fontScale) + gapPx * (count - 1);\n}\n\n/**\n * A few columns that sit side by side when their container holds them and stack when it does not — the master and the\n * detail, a form and its summary. Stacked, they keep their order and each takes the full width.\n */\nexport function Columns({ children, weights, minColumnWidth = 280, gap = \"lg\", fontScale = 1, className, style, ...props }: ColumnsProps) {\n const s = columnsLayout({ gap });\n const items = React.Children.toArray(children);\n const need = columnsNeed(items.length, minColumnWidth, GRID_GAPS[gap], fontScale);\n const side = items.length > 1;\n return (\n <div\n className={s.columns({ className })}\n style={{ \"--kz-columns-need\": rem(need), ...style } as React.CSSProperties}\n data-layout=\"columns\"\n {...props}\n >\n {items.map((child, index) => (\n <div\n key={React.isValidElement(child) && child.key != null ? child.key : index}\n className={s.column()}\n // Container-relative: a basis above the row's width wraps the column onto its own line (stacked, full width);\n // below it the basis is 0 and the free space is shared by weight.\n style={{ flexGrow: weights?.[index] ?? 1, flexBasis: side ? \"calc((var(--kz-columns-need) - 100%) * 999)\" : \"100%\" }}\n >\n {child}\n </div>\n ))}\n </div>\n );\n}\n"],"mappings":";AAOA,YAAY,WAAW;AACvB,SAAS,UAAU;AA2FT;AAxFH,IAAM,kBAAkB,EAAE,SAAS,KAAK,UAAU,IAAI;AAGtD,IAAM,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,IAAI,IAAI,IAAI,IAAI,GAAG;AAOlE,IAAM,kBAAkB,EAAE,SAAS,GAAG,SAAS,GAAG,UAAU,EAAE;AAErE,IAAM,aAAa;AACnB,IAAM,MAAM,CAAC,OAAe,GAAG,KAAK,UAAU;AAEvC,IAAM,gBAAgB,GAAG;AAAA,EAC9B,OAAO;AAAA;AAAA,IAEL,MAAM;AAAA,IACN,OACE;AAAA,IACF,MAAM;AAAA,IACN,SAAS;AAAA,IACT,QAAQ;AAAA,EACV;AAAA,EACA,UAAU;AAAA,IACR,KAAK,OAAO;AAAA,MACV,OAAO,QAAQ,EAAE,MAAM,SAAS,IAAI,SAAS,IAAI,SAAS,IAAI,SAAS,IAAI,SAAS,IAAI,QAAQ,CAAC,EAAE,IAAI,CAAC,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,KAAK,SAAS,IAAI,CAAC,CAAC;AAAA,IAC9J;AAAA,IACA,aAAa,EAAE,MAAM,EAAE,OAAO,iBAAiB,MAAM,WAAW,GAAG,OAAO,EAAE,OAAO,cAA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true,
|
|
29
29
|
"data-band": true,
|
|
30
|
-
className: "pointer-events-none rounded-
|
|
30
|
+
className: "pointer-events-none rounded-none border border-accent bg-accent-soft",
|
|
31
31
|
style: { gridColumn: at + 2, gridRow: `1 / span ${rows.length + 1}` }
|
|
32
32
|
}
|
|
33
33
|
),
|
|
@@ -66,12 +66,12 @@ function ComparisonTable({ label, topicLabel, columns, highlight, rows, reveal =
|
|
|
66
66
|
))
|
|
67
67
|
] }, row.id))
|
|
68
68
|
] }),
|
|
69
|
-
/* @__PURE__ */ jsx("ul", { "aria-label": label, className: "grid gap-4 md:hidden", children: rows.map((row, r) => /* @__PURE__ */ jsxs("li", { "data-reveal": reveal ? "soft" : void 0, style: stagger(r), className: "rounded-
|
|
69
|
+
/* @__PURE__ */ jsx("ul", { "aria-label": label, className: "grid gap-4 md:hidden", children: rows.map((row, r) => /* @__PURE__ */ jsxs("li", { "data-reveal": reveal ? "soft" : void 0, style: stagger(r), className: "rounded-none border border-border-subtle bg-surface-1/80 p-4", children: [
|
|
70
70
|
/* @__PURE__ */ jsxs("p", { className: "flex items-center gap-3 text-base font-semibold text-fg", children: [
|
|
71
71
|
row.icon && /* @__PURE__ */ jsx("span", { className: "flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-border-default bg-surface-2 text-fg-accent [&>svg]:h-4 [&>svg]:w-4", children: row.icon }),
|
|
72
72
|
row.topic
|
|
73
73
|
] }),
|
|
74
|
-
/* @__PURE__ */ jsx("dl", { className: "mt-3 grid gap-2", children: columns.map((c, i) => /* @__PURE__ */ jsxs("div", { "data-highlight": band(i) ? "" : void 0, className: cn("rounded-
|
|
74
|
+
/* @__PURE__ */ jsx("dl", { className: "mt-3 grid gap-2", children: columns.map((c, i) => /* @__PURE__ */ jsxs("div", { "data-highlight": band(i) ? "" : void 0, className: cn("rounded-none p-3 text-sm leading-relaxed", band(i) ? "border border-accent bg-accent-soft" : "bg-surface-2/60"), children: [
|
|
75
75
|
/* @__PURE__ */ jsx("dt", { className: cn("mb-1 flex items-center gap-1.5 font-mono text-[11px] ", band(i) ? "text-fg-accent" : "text-fg-secondary"), children: c.label }),
|
|
76
76
|
/* @__PURE__ */ jsx("dd", { children: /* @__PURE__ */ jsx(Answer, { answer: row.answers[c.id] }) })
|
|
77
77
|
] }, c.id)) })
|