@agent-native/core 0.131.3 → 0.131.4
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/corpus/README.md +1 -1
- package/corpus/core/CHANGELOG.md +6 -0
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/client/AgentPanel.tsx +58 -34
- package/corpus/core/src/localization/default-messages.ts +6 -0
- package/corpus/templates/design/.generated/bridge/editor-chrome.generated.ts +3 -1
- package/corpus/templates/design/actions/get-design.ts +11 -3
- package/corpus/templates/design/actions/present-design-variants.ts +62 -5
- package/corpus/templates/design/app/components/design/BreakpointBar.tsx +64 -1
- package/corpus/templates/design/app/components/design/EditPanel.tsx +199 -25
- package/corpus/templates/design/app/components/design/MultiScreenCanvas.tsx +160 -46
- package/corpus/templates/design/app/components/design/bridge/editor-chrome.bridge.ts +7 -1
- package/corpus/templates/design/app/components/design/edit-panel/effects-properties.tsx +59 -12
- package/corpus/templates/design/app/components/design/edit-panel/fill-properties.tsx +1 -1
- package/corpus/templates/design/app/components/design/edit-panel/inspector-controls.tsx +34 -29
- package/corpus/templates/design/app/components/design/edit-panel/stroke-properties.tsx +2 -2
- package/corpus/templates/design/app/components/design/inspector/ExportSettingsPanel.tsx +28 -10
- package/corpus/templates/design/app/components/design/inspector/design-icons.tsx +15 -28
- package/corpus/templates/design/app/components/design/keyboard-shortcuts.ts +4 -3
- package/corpus/templates/design/app/components/design/multi-screen/chrome-transitions.ts +12 -8
- package/corpus/templates/design/app/components/design/multi-screen/culling.ts +34 -9
- package/corpus/templates/design/app/components/design/multi-screen/frame-geometry.ts +13 -27
- package/corpus/templates/design/app/components/design/multi-screen/types.ts +8 -1
- package/corpus/templates/design/app/components/design/multi-screen/zoom-gesture.ts +95 -0
- package/corpus/templates/design/app/i18n-data.ts +121 -10
- package/corpus/templates/design/app/pages/design-editor/data-operations.ts +45 -0
- package/corpus/templates/design/app/pages/design-editor/layout-operations.ts +59 -0
- package/corpus/templates/design/app/pages/design-editor/text-edit-utils.ts +115 -40
- package/corpus/templates/design/changelog/2026-07-28-generated-design-variants-no-longer-overlap-each-other-on-th.md +6 -0
- package/corpus/templates/design/changelog/2026-07-29-auto-layout-direction-icons-show-an-arrow.md +6 -0
- package/corpus/templates/design/changelog/2026-07-29-breakpoints-no-longer-overlap-neighbouring-screens.md +6 -0
- package/corpus/templates/design/changelog/2026-07-29-canvas-is-more-responsive-when-selecting-and-adding-frames.md +6 -0
- package/corpus/templates/design/changelog/2026-07-29-canvas-zoom-is-smoother-and-labels-hold-their-size.md +6 -0
- package/corpus/templates/design/changelog/2026-07-29-double-click-a-frame-now-drills-into-its-layers.md +6 -0
- package/corpus/templates/design/changelog/2026-07-29-export-preview-shows-the-real-render.md +6 -0
- package/corpus/templates/design/changelog/2026-07-29-figma-parity-shortcuts.md +6 -0
- package/corpus/templates/design/changelog/2026-07-29-more-breakpoint-width-presets.md +6 -0
- package/corpus/templates/design/changelog/2026-07-29-resize-a-selected-frame-to-a-device-preset.md +6 -0
- package/corpus/templates/design/changelog/2026-07-29-text-tool-reaches-the-right-surface.md +6 -0
- package/corpus/templates/design/shared/canvas-frames.ts +23 -0
- package/corpus/templates/design/shared/code-layer.ts +54 -2
- package/corpus/templates/design/shared/responsive-frame-layout.ts +55 -0
- package/dist/client/AgentPanel.d.ts.map +1 -1
- package/dist/client/AgentPanel.js +16 -5
- package/dist/client/AgentPanel.js.map +1 -1
- package/dist/collab/awareness.d.ts +2 -2
- package/dist/collab/awareness.d.ts.map +1 -1
- package/dist/collab/routes.d.ts +1 -1
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/localization/default-messages.d.ts +6 -0
- package/dist/localization/default-messages.d.ts.map +1 -1
- package/dist/localization/default-messages.js +6 -0
- package/dist/localization/default-messages.js.map +1 -1
- package/dist/mcp/screen-memory-stdio.d.ts +7 -7
- package/dist/mcp/screen-memory-stdio.d.ts.map +1 -1
- package/dist/notifications/routes.d.ts +3 -3
- package/dist/observability/routes.d.ts +3 -3
- package/dist/progress/routes.d.ts +1 -1
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/server/realtime-token.d.ts +1 -1
- package/dist/server/transcribe-voice.d.ts +1 -1
- package/package.json +1 -1
- package/src/client/AgentPanel.tsx +58 -34
- package/src/localization/default-messages.ts +6 -0
package/corpus/README.md
CHANGED
package/corpus/core/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @agent-native/core
|
|
2
2
|
|
|
3
|
+
## 0.131.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 13f7e6b: Simplify the agent panel's error-recovery copy and move it into the message catalog, so it no longer shows untranslated English or explains the failure as an "internal UI error".
|
|
8
|
+
|
|
3
9
|
## 0.131.3
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/corpus/core/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-native/core",
|
|
3
|
-
"version": "0.131.
|
|
3
|
+
"version": "0.131.4",
|
|
4
4
|
"description": "Framework for agent-native application development — where AI agents and UI share SQL state, actions, and context",
|
|
5
5
|
"homepage": "https://github.com/BuilderIO/agent-native#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -2585,47 +2585,71 @@ class AgentPanelErrorBoundary extends React.Component<
|
|
|
2585
2585
|
assistantUiRecoverableRenderErrorKind(this.state.error) &&
|
|
2586
2586
|
this.state.staleIndexRecoveryCount < 2
|
|
2587
2587
|
) {
|
|
2588
|
-
return
|
|
2589
|
-
<div className="flex h-full items-center justify-center p-6 text-center text-xs text-muted-foreground">
|
|
2590
|
-
Reloading chat UI...
|
|
2591
|
-
</div>
|
|
2592
|
-
);
|
|
2588
|
+
return <AgentPanelReloadingNotice />;
|
|
2593
2589
|
}
|
|
2594
2590
|
|
|
2595
2591
|
return (
|
|
2596
|
-
<
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
</p>
|
|
2604
|
-
</div>
|
|
2605
|
-
<button
|
|
2606
|
-
type="button"
|
|
2607
|
-
className="rounded-md border border-border bg-background px-3 py-1.5 text-xs font-medium text-foreground hover:bg-accent"
|
|
2608
|
-
onClick={() => {
|
|
2609
|
-
this.setState({ error: null, staleIndexRecoveryCount: 0 });
|
|
2610
|
-
this.props.onReset();
|
|
2611
|
-
}}
|
|
2612
|
-
>
|
|
2613
|
-
Reset agent panel
|
|
2614
|
-
</button>
|
|
2615
|
-
<ErrorReportActions
|
|
2616
|
-
appName="Agent panel"
|
|
2617
|
-
title="Agent panel UI error"
|
|
2618
|
-
details={this.state.error.message}
|
|
2619
|
-
issueTitle="Agent panel UI error"
|
|
2620
|
-
className="max-w-[260px]"
|
|
2621
|
-
feedbackClassName="h-7"
|
|
2622
|
-
githubClassName="h-7"
|
|
2623
|
-
/>
|
|
2624
|
-
</div>
|
|
2592
|
+
<AgentPanelErrorFallback
|
|
2593
|
+
details={this.state.error.message}
|
|
2594
|
+
onReset={() => {
|
|
2595
|
+
this.setState({ error: null, staleIndexRecoveryCount: 0 });
|
|
2596
|
+
this.props.onReset();
|
|
2597
|
+
}}
|
|
2598
|
+
/>
|
|
2625
2599
|
);
|
|
2626
2600
|
}
|
|
2627
2601
|
}
|
|
2628
2602
|
|
|
2603
|
+
// The boundary must stay a class (componentDidCatch), but its copy still has to
|
|
2604
|
+
// come from the catalog like every other string in this file — so the fallback
|
|
2605
|
+
// UI lives in function components that can call useT.
|
|
2606
|
+
function AgentPanelReloadingNotice() {
|
|
2607
|
+
const t = useT();
|
|
2608
|
+
return (
|
|
2609
|
+
<div className="flex h-full items-center justify-center p-6 text-center text-xs text-muted-foreground">
|
|
2610
|
+
{t("agentPanel.uiError.reloading")}
|
|
2611
|
+
</div>
|
|
2612
|
+
);
|
|
2613
|
+
}
|
|
2614
|
+
|
|
2615
|
+
function AgentPanelErrorFallback({
|
|
2616
|
+
details,
|
|
2617
|
+
onReset,
|
|
2618
|
+
}: {
|
|
2619
|
+
details: string;
|
|
2620
|
+
onReset: () => void;
|
|
2621
|
+
}) {
|
|
2622
|
+
const t = useT();
|
|
2623
|
+
return (
|
|
2624
|
+
<div className="flex h-full flex-col items-center justify-center gap-3 p-6 text-center">
|
|
2625
|
+
<div className="max-w-[260px] space-y-1">
|
|
2626
|
+
<p className="text-sm font-medium text-foreground">
|
|
2627
|
+
{t("agentPanel.uiError.title")}
|
|
2628
|
+
</p>
|
|
2629
|
+
<p className="text-xs leading-relaxed text-muted-foreground">
|
|
2630
|
+
{t("agentPanel.uiError.description")}
|
|
2631
|
+
</p>
|
|
2632
|
+
</div>
|
|
2633
|
+
<button
|
|
2634
|
+
type="button"
|
|
2635
|
+
className="rounded-md border border-border bg-background px-3 py-1.5 text-xs font-medium text-foreground hover:bg-accent"
|
|
2636
|
+
onClick={onReset}
|
|
2637
|
+
>
|
|
2638
|
+
{t("agentPanel.uiError.reset")}
|
|
2639
|
+
</button>
|
|
2640
|
+
<ErrorReportActions
|
|
2641
|
+
appName="Agent panel"
|
|
2642
|
+
title={t("agentPanel.uiError.title")}
|
|
2643
|
+
details={details}
|
|
2644
|
+
issueTitle="Agent panel UI error"
|
|
2645
|
+
className="max-w-[260px]"
|
|
2646
|
+
feedbackClassName="h-7"
|
|
2647
|
+
githubClassName="h-7"
|
|
2648
|
+
/>
|
|
2649
|
+
</div>
|
|
2650
|
+
);
|
|
2651
|
+
}
|
|
2652
|
+
|
|
2629
2653
|
export function AgentPanel(props: AgentPanelProps) {
|
|
2630
2654
|
const [resetKey, setResetKey] = useState(0);
|
|
2631
2655
|
const resetPanel = useCallback(() => {
|
|
@@ -336,6 +336,12 @@ const messages = {
|
|
|
336
336
|
},
|
|
337
337
|
},
|
|
338
338
|
agentPanel: {
|
|
339
|
+
uiError: {
|
|
340
|
+
title: "Agent panel hit a glitch",
|
|
341
|
+
description: "The app's still usable. Reset to reload the chat.",
|
|
342
|
+
reset: "Reset agent panel",
|
|
343
|
+
reloading: "Reloading chat…",
|
|
344
|
+
},
|
|
339
345
|
useBuilder: "Use Builder",
|
|
340
346
|
openDesktopToEditCode: "Open Desktop to edit code",
|
|
341
347
|
codeUnavailableDescription:
|
|
@@ -8199,7 +8199,7 @@ export const editorChromeBridgeScript: string = `"use strict";
|
|
|
8199
8199
|
if (e.data.type === "agent-native:text-edit-status") {
|
|
8200
8200
|
var textEditStatusCorrelationId = typeof e.data.correlationId === "string" ? e.data.correlationId : "";
|
|
8201
8201
|
var textEditStatusNodeId = typeof e.data.nodeId === "string" ? e.data.nodeId : "";
|
|
8202
|
-
var textEditStatus =
|
|
8202
|
+
var textEditStatus = "missing";
|
|
8203
8203
|
if (textEditStatusNodeId) {
|
|
8204
8204
|
var escapedTextEditStatusNodeId = textEditStatusNodeId.replace(/\\\\/g, "\\\\\\\\").replace(/"/g, '\\\\"');
|
|
8205
8205
|
var textEditStatusNode = document.querySelector(
|
|
@@ -8212,6 +8212,8 @@ export const editorChromeBridgeScript: string = `"use strict";
|
|
|
8212
8212
|
textEditStatus = "active";
|
|
8213
8213
|
} else if (textEditStatusNode && (textEditStatusNode.textContent ?? "").trim().length > 0) {
|
|
8214
8214
|
textEditStatus = "done";
|
|
8215
|
+
} else if (textEditStatusNode) {
|
|
8216
|
+
textEditStatus = false;
|
|
8215
8217
|
}
|
|
8216
8218
|
}
|
|
8217
8219
|
window.parent.postMessage(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineAction } from "@agent-native/core";
|
|
2
2
|
import { resolveAccess } from "@agent-native/core/sharing";
|
|
3
|
-
import { eq } from "drizzle-orm";
|
|
3
|
+
import { asc, eq } from "drizzle-orm";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
|
|
6
6
|
import { getDb, schema } from "../server/db/index.js";
|
|
@@ -26,11 +26,19 @@ export default defineAction({
|
|
|
26
26
|
const row = access.resource;
|
|
27
27
|
const db = getDb();
|
|
28
28
|
|
|
29
|
-
// Fetch associated files
|
|
29
|
+
// Fetch associated files in a stable order. This array feeds the overview
|
|
30
|
+
// canvas's screen stack and each screen's index within its layout group, so
|
|
31
|
+
// unordered rows (Postgres returns heap order, which an UPDATE can change)
|
|
32
|
+
// meant the same design could lay itself out differently on two loads.
|
|
33
|
+
// Note this is deterministic, not creation-ordered: files written in one
|
|
34
|
+
// batch share a `createdAt` to the millisecond and fall back to the id
|
|
35
|
+
// tiebreak. Nothing may depend on the index matching the order a generator
|
|
36
|
+
// wrote in — see the order-independence case in variant-lineup.test.ts.
|
|
30
37
|
const files = await db
|
|
31
38
|
.select()
|
|
32
39
|
.from(schema.designFiles)
|
|
33
|
-
.where(eq(schema.designFiles.designId, id))
|
|
40
|
+
.where(eq(schema.designFiles.designId, id))
|
|
41
|
+
.orderBy(asc(schema.designFiles.createdAt), asc(schema.designFiles.id));
|
|
34
42
|
|
|
35
43
|
return {
|
|
36
44
|
id: row.id,
|
|
@@ -16,11 +16,16 @@ import { getDb, schema } from "../server/db/index.js";
|
|
|
16
16
|
import { mutateDesignData } from "../server/lib/design-data-mutation.js";
|
|
17
17
|
import {
|
|
18
18
|
mergeCanvasFramePlacements,
|
|
19
|
+
nextFreeCanvasRowY,
|
|
19
20
|
type CanvasFramePlacement,
|
|
20
21
|
} from "../shared/canvas-frames.js";
|
|
21
22
|
import { isUniqueConstraintViolation } from "../shared/db-conflict.js";
|
|
22
23
|
import { assertDesignHtmlWellFormed } from "../shared/html-integrity.js";
|
|
23
24
|
import { widthToPrefix } from "../shared/responsive-classes.js";
|
|
25
|
+
import {
|
|
26
|
+
getResponsiveGroupWidth,
|
|
27
|
+
visibleBreakpointWidths,
|
|
28
|
+
} from "../shared/responsive-frame-layout.js";
|
|
24
29
|
import { annotateScreenHtmlForPersist } from "../shared/screen-annotation.js";
|
|
25
30
|
|
|
26
31
|
const VARIANT_GAP = 96;
|
|
@@ -735,10 +740,24 @@ ${compact ? ".sidebar { padding: 16px; } .nav { grid-template-columns: repeat(2,
|
|
|
735
740
|
</html>`;
|
|
736
741
|
}
|
|
737
742
|
|
|
738
|
-
|
|
743
|
+
/**
|
|
744
|
+
* Lays the generated directions out in rows of up to three.
|
|
745
|
+
*
|
|
746
|
+
* Each cell reserves the screen's WHOLE painted footprint, not just its
|
|
747
|
+
* primary frame: this action also installs a design-wide breakpoint set, and
|
|
748
|
+
* the overview paints one preview per breakpoint to the right of every primary
|
|
749
|
+
* frame. Spacing by `width + VARIANT_GAP` alone drops the next direction on top
|
|
750
|
+
* of the previous one's breakpoint row.
|
|
751
|
+
*/
|
|
752
|
+
function placeVariantScreens(
|
|
753
|
+
screens: VariantScreen[],
|
|
754
|
+
breakpointWidths: readonly number[],
|
|
755
|
+
/** Y to start the lineup at, so an additional set clears the existing one. */
|
|
756
|
+
originY = 0,
|
|
757
|
+
) {
|
|
739
758
|
const placements: CanvasFramePlacement[] = [];
|
|
740
759
|
const columns = Math.min(MAX_COLUMNS, Math.max(1, screens.length));
|
|
741
|
-
let rowY =
|
|
760
|
+
let rowY = originY;
|
|
742
761
|
|
|
743
762
|
for (let rowStart = 0; rowStart < screens.length; rowStart += columns) {
|
|
744
763
|
const row = screens.slice(rowStart, rowStart + columns);
|
|
@@ -755,7 +774,17 @@ function placeVariantScreens(screens: VariantScreen[]) {
|
|
|
755
774
|
height: screen.height,
|
|
756
775
|
z: rowStart + offset,
|
|
757
776
|
});
|
|
758
|
-
x +=
|
|
777
|
+
x +=
|
|
778
|
+
getResponsiveGroupWidth({
|
|
779
|
+
primaryWidth: screen.width,
|
|
780
|
+
// Frames are placed at their natural device width, so the breakpoint
|
|
781
|
+
// previews beside them are drawn unscaled.
|
|
782
|
+
scale: 1,
|
|
783
|
+
visibleWidths: visibleBreakpointWidths(
|
|
784
|
+
breakpointWidths,
|
|
785
|
+
screen.width,
|
|
786
|
+
),
|
|
787
|
+
}) + VARIANT_GAP;
|
|
759
788
|
rowHeight = Math.max(rowHeight, screen.height);
|
|
760
789
|
}
|
|
761
790
|
|
|
@@ -765,6 +794,22 @@ function placeVariantScreens(screens: VariantScreen[]) {
|
|
|
765
794
|
return placements;
|
|
766
795
|
}
|
|
767
796
|
|
|
797
|
+
/** Widths the overview will paint beside each primary frame once this call
|
|
798
|
+
* settles: the design's own set when it has one, otherwise the set this action
|
|
799
|
+
* is about to install. */
|
|
800
|
+
function effectiveBreakpointWidths(currentBreakpointSet: unknown): number[] {
|
|
801
|
+
const breakpoints = hasBreakpointSet(currentBreakpointSet)
|
|
802
|
+
? ((currentBreakpointSet as { breakpoints: Array<{ widthPx?: unknown }> })
|
|
803
|
+
.breakpoints ?? [])
|
|
804
|
+
: DEFAULT_RESPONSIVE_BREAKPOINTS;
|
|
805
|
+
return breakpoints
|
|
806
|
+
.map((breakpoint) => breakpoint.widthPx)
|
|
807
|
+
.filter(
|
|
808
|
+
(widthPx): widthPx is number =>
|
|
809
|
+
typeof widthPx === "number" && Number.isFinite(widthPx) && widthPx > 0,
|
|
810
|
+
);
|
|
811
|
+
}
|
|
812
|
+
|
|
768
813
|
export default defineAction({
|
|
769
814
|
description:
|
|
770
815
|
"Present generated design directions as normal screens on the Design " +
|
|
@@ -933,13 +978,25 @@ export default defineAction({
|
|
|
933
978
|
});
|
|
934
979
|
}
|
|
935
980
|
|
|
936
|
-
const placements = placeVariantScreens(screens);
|
|
937
981
|
await mutateDesignData({
|
|
938
982
|
designId,
|
|
939
983
|
mutate: (current, { updatedAt }) => {
|
|
984
|
+
// Placement depends on the breakpoint set in effect after this call, so
|
|
985
|
+
// it is resolved here (inside the compare-and-set body) rather than
|
|
986
|
+
// against a design snapshot that a concurrent write may have moved on
|
|
987
|
+
// from.
|
|
940
988
|
const mergedFrames = mergeCanvasFramePlacements({
|
|
941
989
|
existing: current.canvasFrames,
|
|
942
|
-
placements
|
|
990
|
+
placements: placeVariantScreens(
|
|
991
|
+
screens,
|
|
992
|
+
effectiveBreakpointWidths(current.breakpointSet),
|
|
993
|
+
// Start below what is already on the board. The set being written is
|
|
994
|
+
// excluded so re-running the same set lands where it was instead of
|
|
995
|
+
// marching further down each time.
|
|
996
|
+
nextFreeCanvasRowY(current.canvasFrames, VARIANT_GAP, {
|
|
997
|
+
ignoreFileIds: screens.map((screen) => screen.id),
|
|
998
|
+
}),
|
|
999
|
+
),
|
|
943
1000
|
resolveFileId: (placement) => placement.fileId,
|
|
944
1001
|
});
|
|
945
1002
|
const previousMetadata = isRecord(current.screenMetadata)
|
|
@@ -26,6 +26,8 @@ import {
|
|
|
26
26
|
import { Switch } from "@/components/ui/switch";
|
|
27
27
|
import { cn } from "@/lib/utils";
|
|
28
28
|
|
|
29
|
+
import { FRAME_SIZE_PRESET_CATEGORIES } from "./inspector/frame-size-presets";
|
|
30
|
+
|
|
29
31
|
/** Framer's default breakpoint widths, offered by the "+" affordance. */
|
|
30
32
|
export const FRAMER_BREAKPOINT_PRESETS: ReadonlyArray<{
|
|
31
33
|
labelKey: "desktop" | "tablet" | "phone";
|
|
@@ -45,6 +47,35 @@ export function availableBreakpointPresets(
|
|
|
45
47
|
);
|
|
46
48
|
}
|
|
47
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Device widths offered beyond the three Framer defaults, drawn from the frame
|
|
52
|
+
* tool's own preset catalog so both surfaces agree on what a "Tablet" is.
|
|
53
|
+
*
|
|
54
|
+
* Without these the "+" popover empties out as soon as Desktop/Tablet/Phone are
|
|
55
|
+
* added — `availableBreakpointPresets` filters by exact width — leaving a bare
|
|
56
|
+
* number input and no way to pick a real device size. Only width matters for a
|
|
57
|
+
* breakpoint, so widths are de-duplicated (many devices share one) and the
|
|
58
|
+
* first device at each width names it. Device names are untranslated product
|
|
59
|
+
* literals, matching frame-size-presets' documented policy.
|
|
60
|
+
*/
|
|
61
|
+
export function extraBreakpointWidthPresets(
|
|
62
|
+
existingWidths: readonly number[],
|
|
63
|
+
): Array<{ name: string; widthPx: number }> {
|
|
64
|
+
const taken = new Set<number>(existingWidths);
|
|
65
|
+
FRAMER_BREAKPOINT_PRESETS.forEach((preset) => taken.add(preset.widthPx));
|
|
66
|
+
const seen = new Set<number>();
|
|
67
|
+
const out: Array<{ name: string; widthPx: number }> = [];
|
|
68
|
+
for (const category of FRAME_SIZE_PRESET_CATEGORIES) {
|
|
69
|
+
for (const preset of category.presets) {
|
|
70
|
+
if (taken.has(preset.width) || seen.has(preset.width)) continue;
|
|
71
|
+
if (preset.width < 320 || preset.width > 3840) continue;
|
|
72
|
+
seen.add(preset.width);
|
|
73
|
+
out.push({ name: preset.name, widthPx: preset.width });
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return out.sort((a, b) => b.widthPx - a.widthPx);
|
|
77
|
+
}
|
|
78
|
+
|
|
48
79
|
/** Default English label for a preset/custom width (used for add-breakpoint). */
|
|
49
80
|
export function breakpointLabelForWidth(widthPx: number): string {
|
|
50
81
|
if (widthPx >= 1024) return "Desktop";
|
|
@@ -128,6 +159,7 @@ export function BreakpointDeviceControl({
|
|
|
128
159
|
const ordered = [...breakpoints].sort((a, b) => b.widthPx - a.widthPx);
|
|
129
160
|
const existingWidths = ordered.map((bp) => bp.widthPx);
|
|
130
161
|
const presets = availableBreakpointPresets(existingWidths);
|
|
162
|
+
const devicePresets = extraBreakpointWidthPresets(existingWidths);
|
|
131
163
|
const baseActive = activeWidthPx === undefined;
|
|
132
164
|
|
|
133
165
|
const submitCustomWidth = () => {
|
|
@@ -323,7 +355,38 @@ export function BreakpointDeviceControl({
|
|
|
323
355
|
</span>
|
|
324
356
|
</button>
|
|
325
357
|
))}
|
|
326
|
-
{
|
|
358
|
+
{devicePresets.length > 0 ? (
|
|
359
|
+
<>
|
|
360
|
+
{presets.length > 0 ? (
|
|
361
|
+
<div className="my-1 h-px bg-border" />
|
|
362
|
+
) : null}
|
|
363
|
+
<div className="max-h-48 overflow-y-auto overscroll-contain">
|
|
364
|
+
{devicePresets.map((preset) => (
|
|
365
|
+
<button
|
|
366
|
+
key={preset.widthPx}
|
|
367
|
+
type="button"
|
|
368
|
+
className="flex w-full cursor-pointer items-center justify-between gap-2 rounded-md px-2 py-1.5 text-left !text-[12px] hover:bg-muted"
|
|
369
|
+
onClick={() => {
|
|
370
|
+
onAdd(
|
|
371
|
+
preset.widthPx,
|
|
372
|
+
breakpointLabelForWidth(preset.widthPx),
|
|
373
|
+
);
|
|
374
|
+
setAddOpen(false);
|
|
375
|
+
}}
|
|
376
|
+
>
|
|
377
|
+
<span className="flex min-w-0 items-center gap-2">
|
|
378
|
+
<DeviceIcon widthPx={preset.widthPx} />
|
|
379
|
+
<span className="truncate">{preset.name}</span>
|
|
380
|
+
</span>
|
|
381
|
+
<span className="shrink-0 tabular-nums text-muted-foreground/60">
|
|
382
|
+
{preset.widthPx}
|
|
383
|
+
</span>
|
|
384
|
+
</button>
|
|
385
|
+
))}
|
|
386
|
+
</div>
|
|
387
|
+
</>
|
|
388
|
+
) : null}
|
|
389
|
+
{presets.length > 0 || devicePresets.length > 0 ? (
|
|
327
390
|
<div className="my-1 h-px bg-border" />
|
|
328
391
|
) : null}
|
|
329
392
|
<form
|