@aglyn/plugins-mui 1.0.0-beta.143
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/LICENSE +201 -0
- package/README.md +22 -0
- package/package.json +47 -0
- package/src/index.d.ts +21 -0
- package/src/index.js +22 -0
- package/src/index.js.map +1 -0
- package/src/lib/components/accordion.d.ts +96 -0
- package/src/lib/components/accordion.js +392 -0
- package/src/lib/components/accordion.js.map +1 -0
- package/src/lib/components/app-bar.d.ts +32 -0
- package/src/lib/components/app-bar.js +86 -0
- package/src/lib/components/app-bar.js.map +1 -0
- package/src/lib/components/blocks.d.ts +46 -0
- package/src/lib/components/blocks.js +1007 -0
- package/src/lib/components/blocks.js.map +1 -0
- package/src/lib/components/box.d.ts +47 -0
- package/src/lib/components/box.js +125 -0
- package/src/lib/components/box.js.map +1 -0
- package/src/lib/components/breadcrumbs.d.ts +44 -0
- package/src/lib/components/breadcrumbs.js +172 -0
- package/src/lib/components/breadcrumbs.js.map +1 -0
- package/src/lib/components/button.d.ts +89 -0
- package/src/lib/components/button.js +272 -0
- package/src/lib/components/button.js.map +1 -0
- package/src/lib/components/card.d.ts +61 -0
- package/src/lib/components/card.js +336 -0
- package/src/lib/components/card.js.map +1 -0
- package/src/lib/components/collection.d.ts +514 -0
- package/src/lib/components/collection.js +2999 -0
- package/src/lib/components/collection.js.map +1 -0
- package/src/lib/components/container.d.ts +42 -0
- package/src/lib/components/container.js +169 -0
- package/src/lib/components/container.js.map +1 -0
- package/src/lib/components/custom-html.d.ts +78 -0
- package/src/lib/components/custom-html.js +219 -0
- package/src/lib/components/custom-html.js.map +1 -0
- package/src/lib/components/data-table.d.ts +57 -0
- package/src/lib/components/data-table.js +216 -0
- package/src/lib/components/data-table.js.map +1 -0
- package/src/lib/components/document-root.d.ts +77 -0
- package/src/lib/components/document-root.js +118 -0
- package/src/lib/components/document-root.js.map +1 -0
- package/src/lib/components/drawer.d.ts +93 -0
- package/src/lib/components/drawer.js +566 -0
- package/src/lib/components/drawer.js.map +1 -0
- package/src/lib/components/function-controls.d.ts +66 -0
- package/src/lib/components/function-controls.js +207 -0
- package/src/lib/components/function-controls.js.map +1 -0
- package/src/lib/components/function-scope.d.ts +110 -0
- package/src/lib/components/function-scope.js +478 -0
- package/src/lib/components/function-scope.js.map +1 -0
- package/src/lib/components/function-widget.d.ts +75 -0
- package/src/lib/components/function-widget.js +307 -0
- package/src/lib/components/function-widget.js.map +1 -0
- package/src/lib/components/grid.d.ts +91 -0
- package/src/lib/components/grid.js +322 -0
- package/src/lib/components/grid.js.map +1 -0
- package/src/lib/components/icon.d.ts +54 -0
- package/src/lib/components/icon.js +163 -0
- package/src/lib/components/icon.js.map +1 -0
- package/src/lib/components/image-list.d.ts +58 -0
- package/src/lib/components/image-list.js +336 -0
- package/src/lib/components/image-list.js.map +1 -0
- package/src/lib/components/image.d.ts +154 -0
- package/src/lib/components/image.js +451 -0
- package/src/lib/components/image.js.map +1 -0
- package/src/lib/components/inline-text.d.ts +74 -0
- package/src/lib/components/inline-text.js +407 -0
- package/src/lib/components/inline-text.js.map +1 -0
- package/src/lib/components/language-switcher.d.ts +35 -0
- package/src/lib/components/language-switcher.js +179 -0
- package/src/lib/components/language-switcher.js.map +1 -0
- package/src/lib/components/layout-slot.d.ts +68 -0
- package/src/lib/components/layout-slot.js +192 -0
- package/src/lib/components/layout-slot.js.map +1 -0
- package/src/lib/components/link-box-accessible-name.d.ts +79 -0
- package/src/lib/components/link-box-accessible-name.js +158 -0
- package/src/lib/components/link-box-accessible-name.js.map +1 -0
- package/src/lib/components/link-box.d.ts +66 -0
- package/src/lib/components/link-box.js +212 -0
- package/src/lib/components/link-box.js.map +1 -0
- package/src/lib/components/list-item-text.d.ts +22 -0
- package/src/lib/components/list-item-text.js +86 -0
- package/src/lib/components/list-item-text.js.map +1 -0
- package/src/lib/components/list-item.d.ts +32 -0
- package/src/lib/components/list-item.js +127 -0
- package/src/lib/components/list-item.js.map +1 -0
- package/src/lib/components/list.d.ts +34 -0
- package/src/lib/components/list.js +108 -0
- package/src/lib/components/list.js.map +1 -0
- package/src/lib/components/markdown.d.ts +129 -0
- package/src/lib/components/markdown.js +853 -0
- package/src/lib/components/markdown.js.map +1 -0
- package/src/lib/components/nav-menu.d.ts +68 -0
- package/src/lib/components/nav-menu.js +683 -0
- package/src/lib/components/nav-menu.js.map +1 -0
- package/src/lib/components/pagination.d.ts +59 -0
- package/src/lib/components/pagination.js +243 -0
- package/src/lib/components/pagination.js.map +1 -0
- package/src/lib/components/paper.d.ts +47 -0
- package/src/lib/components/paper.js +202 -0
- package/src/lib/components/paper.js.map +1 -0
- package/src/lib/components/plugin-frame.d.ts +64 -0
- package/src/lib/components/plugin-frame.js +335 -0
- package/src/lib/components/plugin-frame.js.map +1 -0
- package/src/lib/components/plugin.d.ts +95 -0
- package/src/lib/components/plugin.js +304 -0
- package/src/lib/components/plugin.js.map +1 -0
- package/src/lib/components/product.d.ts +40 -0
- package/src/lib/components/product.js +287 -0
- package/src/lib/components/product.js.map +1 -0
- package/src/lib/components/reusable-instance.d.ts +57 -0
- package/src/lib/components/reusable-instance.js +126 -0
- package/src/lib/components/reusable-instance.js.map +1 -0
- package/src/lib/components/screen-link.d.ts +85 -0
- package/src/lib/components/screen-link.js +324 -0
- package/src/lib/components/screen-link.js.map +1 -0
- package/src/lib/components/search-box.d.ts +41 -0
- package/src/lib/components/search-box.js +125 -0
- package/src/lib/components/search-box.js.map +1 -0
- package/src/lib/components/section.d.ts +56 -0
- package/src/lib/components/section.js +132 -0
- package/src/lib/components/section.js.map +1 -0
- package/src/lib/components/stack.d.ts +55 -0
- package/src/lib/components/stack.js +309 -0
- package/src/lib/components/stack.js.map +1 -0
- package/src/lib/components/tabs.d.ts +288 -0
- package/src/lib/components/tabs.js +788 -0
- package/src/lib/components/tabs.js.map +1 -0
- package/src/lib/components/theme-mode-switcher.d.ts +38 -0
- package/src/lib/components/theme-mode-switcher.js +168 -0
- package/src/lib/components/theme-mode-switcher.js.map +1 -0
- package/src/lib/components/toolbar.d.ts +37 -0
- package/src/lib/components/toolbar.js +117 -0
- package/src/lib/components/toolbar.js.map +1 -0
- package/src/lib/components/typography.d.ts +33 -0
- package/src/lib/components/typography.js +433 -0
- package/src/lib/components/typography.js.map +1 -0
- package/src/lib/components/video-lightbox-controls.d.ts +131 -0
- package/src/lib/components/video-lightbox-controls.js +536 -0
- package/src/lib/components/video-lightbox-controls.js.map +1 -0
- package/src/lib/components/video-lightbox.d.ts +60 -0
- package/src/lib/components/video-lightbox.js +247 -0
- package/src/lib/components/video-lightbox.js.map +1 -0
- package/src/lib/components/video-playback-beacon.d.ts +80 -0
- package/src/lib/components/video-playback-beacon.js +128 -0
- package/src/lib/components/video-playback-beacon.js.map +1 -0
- package/src/lib/components/video-player-frame.d.ts +58 -0
- package/src/lib/components/video-player-frame.js +51 -0
- package/src/lib/components/video-player-frame.js.map +1 -0
- package/src/lib/components/video.d.ts +220 -0
- package/src/lib/components/video.js +874 -0
- package/src/lib/components/video.js.map +1 -0
- package/src/lib/constants/bundle-common.d.ts +17 -0
- package/src/lib/constants/bundle-common.js +18 -0
- package/src/lib/constants/bundle-common.js.map +1 -0
- package/src/lib/constants/field-presets.d.ts +93 -0
- package/src/lib/constants/field-presets.js +248 -0
- package/src/lib/constants/field-presets.js.map +1 -0
- package/src/lib/plugin.d.ts +80 -0
- package/src/lib/plugin.js +599 -0
- package/src/lib/plugin.js.map +1 -0
- package/src/lib/utils/author-html-label.d.ts +73 -0
- package/src/lib/utils/author-html-label.js +89 -0
- package/src/lib/utils/author-html-label.js.map +1 -0
- package/src/lib/utils/drop-cleared-props.d.ts +18 -0
- package/src/lib/utils/drop-cleared-props.js +74 -0
- package/src/lib/utils/drop-cleared-props.js.map +1 -0
- package/src/lib/utils/element-picker.d.ts +99 -0
- package/src/lib/utils/element-picker.js +140 -0
- package/src/lib/utils/element-picker.js.map +1 -0
- package/src/lib/utils/generate-preset-id.d.ts +19 -0
- package/src/lib/utils/generate-preset-id.js +25 -0
- package/src/lib/utils/generate-preset-id.js.map +1 -0
- package/src/lib/utils/link-target-props.d.ts +53 -0
- package/src/lib/utils/link-target-props.js +53 -0
- package/src/lib/utils/link-target-props.js.map +1 -0
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
2
|
+
import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_without_properties_loose";
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
/**
|
|
5
|
+
* @license
|
|
6
|
+
* Copyright 2026 Aglyn LLC
|
|
7
|
+
*
|
|
8
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
* you may not use this file except in compliance with the License.
|
|
10
|
+
* You may obtain a copy of the License at
|
|
11
|
+
*
|
|
12
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
*
|
|
14
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
* See the License for the specific language governing permissions and
|
|
18
|
+
* limitations under the License.
|
|
19
|
+
*/ import * as Aglyn from "@aglyn/aglyn";
|
|
20
|
+
import { mdiImage } from "@aglyn/shared-data-mdi";
|
|
21
|
+
import { AppLink } from "@aglyn/shared-ui-jsx";
|
|
22
|
+
import Box from "@mui/material/Box";
|
|
23
|
+
import { forwardRef } from "react";
|
|
24
|
+
import { BUNDLE_ID } from "../constants/bundle-common.js";
|
|
25
|
+
import { generatePresetId } from "../utils/generate-preset-id.js";
|
|
26
|
+
// Component ids are persisted in screen documents; never rename.
|
|
27
|
+
export const ID = 'image';
|
|
28
|
+
/**
|
|
29
|
+
* The node ids of the images that load eagerly: the first image the LAYOUT
|
|
30
|
+
* chain renders and the first image the SCREEN renders, each in document
|
|
31
|
+
* order (AGL-2486).
|
|
32
|
+
*
|
|
33
|
+
* Every image used to render `loading="lazy"` — the hero included. That is
|
|
34
|
+
* the worst possible default for the one image that is almost always the LCP
|
|
35
|
+
* element: a lazy image is not fetched until layout has run and the browser
|
|
36
|
+
* has decided it is near the viewport, and it is fetched at LOW priority when
|
|
37
|
+
* it finally is. Lighthouse reports that as "LCP request discovery", and it is
|
|
38
|
+
* also why an image four sections down could finish before the one the reader
|
|
39
|
+
* is looking at: with everything lazy and everything low, nothing outranked
|
|
40
|
+
* anything, so the order was whatever the network felt like.
|
|
41
|
+
*
|
|
42
|
+
* So the lead images get `loading="eager"` and the rest get
|
|
43
|
+
* `fetchpriority="low"`, which is the browser-level knob that stops
|
|
44
|
+
* below-the-fold images competing with the ones above them.
|
|
45
|
+
*
|
|
46
|
+
* ONE lead image was not enough. On any site whose header carries a logo, the
|
|
47
|
+
* first image in document order is that logo, so the screen's own hero — the
|
|
48
|
+
* element Lighthouse names as the LCP on aglyn.com's solution pages at
|
|
49
|
+
* 375x812 — stayed `lazy` + `low`: undiscovered until layout, then fetched
|
|
50
|
+
* behind every script on the page (measured 2026-09-08: 1.5 s of load delay
|
|
51
|
+
* and 1.5 s of load time for a 13 KB image). Composition namespaces layout
|
|
52
|
+
* nodes by origin ({@link Aglyn.isLayoutComposedNodeId}), so the walk keeps
|
|
53
|
+
* one lead PER ORIGIN: the layout's first image (the logo) and the screen's
|
|
54
|
+
* first image (the hero). A layout image further down — a mega-menu
|
|
55
|
+
* illustration, the footer mark — is still deferred, as is every later
|
|
56
|
+
* screen image. In the besigner canvas nothing is layout-composed, so the
|
|
57
|
+
* screen's first image is the only lead, exactly as before.
|
|
58
|
+
*
|
|
59
|
+
* Neither lead gets `fetchpriority="high"`, and the reasoning is at the
|
|
60
|
+
* `fetchPriority` prop below. Short version: "first image of its origin" is
|
|
61
|
+
* still not "the LCP element", and a ranking claim needs evidence this
|
|
62
|
+
* function does not have.
|
|
63
|
+
*
|
|
64
|
+
* Resolved from the tree rather than a render-order counter on purpose: the
|
|
65
|
+
* renderer walks the tree in document order on the server AND on hydrate, but
|
|
66
|
+
* a mutable counter would double-count under React's concurrent re-renders
|
|
67
|
+
* and hand the priority to a different image on the client than the one the
|
|
68
|
+
* HTML gave it. A pure function of the tree cannot disagree with itself — and
|
|
69
|
+
* it is deliberately NOT memoized on the root object, because the canvas
|
|
70
|
+
* mutates that tree in place while an author works.
|
|
71
|
+
*
|
|
72
|
+
* The walk STOPS once both leads are known — on a page with a header logo
|
|
73
|
+
* and a hero that is O(nodes above the hero), a dozen or two on a normal
|
|
74
|
+
* page — and at the first image on a screen with no layout.
|
|
75
|
+
*
|
|
76
|
+
* An image with no `src` renders a placeholder box and no `<img>` at all, so
|
|
77
|
+
* it cannot be the LCP element and is skipped.
|
|
78
|
+
*/ export function leadImageNodeIds(root) {
|
|
79
|
+
let layoutLead;
|
|
80
|
+
let screenLead;
|
|
81
|
+
const walk = (node)=>{
|
|
82
|
+
var _node_children;
|
|
83
|
+
if (!node) return false;
|
|
84
|
+
if (node.componentId === ID) {
|
|
85
|
+
var _ref, _node_resolvedProps, _props_src;
|
|
86
|
+
const props = (_ref = (_node_resolvedProps = node.resolvedProps) != null ? _node_resolvedProps : node.props) != null ? _ref : {};
|
|
87
|
+
if (String((_props_src = props['src']) != null ? _props_src : '').trim()) {
|
|
88
|
+
if (Aglyn.isLayoutComposedNodeId(node.$id)) {
|
|
89
|
+
if (!layoutLead) layoutLead = node.$id;
|
|
90
|
+
} else if (!screenLead) {
|
|
91
|
+
screenLead = node.$id;
|
|
92
|
+
}
|
|
93
|
+
if (layoutLead && screenLead) return true;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
for (const child of (_node_children = node.children) != null ? _node_children : []){
|
|
97
|
+
if (walk(child)) return true;
|
|
98
|
+
}
|
|
99
|
+
return false;
|
|
100
|
+
};
|
|
101
|
+
walk(root);
|
|
102
|
+
return [
|
|
103
|
+
layoutLead,
|
|
104
|
+
screenLead
|
|
105
|
+
].filter((id)=>Boolean(id));
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Image element (AGL-74): renders a plain img with fit/size/radius
|
|
109
|
+
* controls; an empty src shows a labeled placeholder so the element stays
|
|
110
|
+
* visible and selectable in the editor.
|
|
111
|
+
*/ const Image = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
112
|
+
const { src: storedSrc, alt, decorative, title, loading, objectFit, width, height, intrinsicWidth, intrinsicHeight, radius, screenId, href: externalHref, // Never forward children to the <img> below — React throws on ANY
|
|
113
|
+
// children value reaching a void element, which 500'd whole pages
|
|
114
|
+
// when a renderer passed empty JSX children through (AGL-579).
|
|
115
|
+
children: _children, // Pull `sx` out of the spread: the literals below are composed AFTER
|
|
116
|
+
// `{...rest}`, so leaving it there REPLACED every style the author set
|
|
117
|
+
// from the Styles panel. The hero mockups' 16px radius and drop shadow
|
|
118
|
+
// were being discarded on every published page (AGL-1240).
|
|
119
|
+
sx: nodeSxProp } = props, rest = _object_without_properties_loose(props, [
|
|
120
|
+
"src",
|
|
121
|
+
"alt",
|
|
122
|
+
"decorative",
|
|
123
|
+
"title",
|
|
124
|
+
"loading",
|
|
125
|
+
"objectFit",
|
|
126
|
+
"width",
|
|
127
|
+
"height",
|
|
128
|
+
"intrinsicWidth",
|
|
129
|
+
"intrinsicHeight",
|
|
130
|
+
"radius",
|
|
131
|
+
"screenId",
|
|
132
|
+
"href",
|
|
133
|
+
"children",
|
|
134
|
+
"sx"
|
|
135
|
+
]);
|
|
136
|
+
// Node styles ride the renderer-merged sx; recompose (stack.ts pattern).
|
|
137
|
+
const nodeSx = Array.isArray(nodeSxProp) ? nodeSxProp : nodeSxProp ? [
|
|
138
|
+
nodeSxProp
|
|
139
|
+
] : [];
|
|
140
|
+
// Optional link mode (AGL-339): screen id first (rename-safe), external
|
|
141
|
+
// URL as fallback; suppressed in the besigner canvas like Screen Link.
|
|
142
|
+
// Shared with every other linking element since AGL-1335, so a `Link`
|
|
143
|
+
// component prop bound here behaves as it does on a Button.
|
|
144
|
+
const { href: linkHref, suppressNavigation } = Aglyn.useLinkTarget(screenId, externalHref);
|
|
145
|
+
/**
|
|
146
|
+
* Eagerness (AGL-2486). An explicit author choice always wins — including
|
|
147
|
+
* an explicit `lazy`, so someone who deliberately deferred the top image
|
|
148
|
+
* keeps that. Only an UNSET `loading` is decided here, and only for the
|
|
149
|
+
* lead images: the layout's first and the screen's first.
|
|
150
|
+
*
|
|
151
|
+
* `leafIdsMatch` rather than `===`: a reusable component instance suffixes
|
|
152
|
+
* its leaf ids, so the id in the tree and the id in the context are the
|
|
153
|
+
* same leaf spelled two ways (the markdown block resolves the same way).
|
|
154
|
+
*/ const nodeId = Aglyn.useNodeId();
|
|
155
|
+
const isLeadImage = Boolean(nodeId) && leadImageNodeIds(Aglyn.canvas.rootNode).some((leadId)=>Aglyn.leafIdsMatch(leadId, nodeId));
|
|
156
|
+
const eager = loading === 'eager' || loading == null && isLeadImage;
|
|
157
|
+
/**
|
|
158
|
+
* Resolve the stored value to a URL (AGL-1215). A media reference becomes
|
|
159
|
+
* a CDN URL here rather than in the document, so the route shape stays an
|
|
160
|
+
* app concern; every other value — a legacy firebasestorage URL, a legacy
|
|
161
|
+
* `/api/media/cdn/…` path, an author-typed hotlink — passes through.
|
|
162
|
+
*
|
|
163
|
+
* `useSite().hostId` is the site being rendered: present on the tenant and
|
|
164
|
+
* in Preview, absent in the besigner canvas. When it is there it names the
|
|
165
|
+
* asking site in the org scope, which is what lets ONE reference in a
|
|
166
|
+
* layout or reusable component resolve on each site that uses it.
|
|
167
|
+
*/ const { hostId } = Aglyn.useSite();
|
|
168
|
+
const src = Aglyn.resolveMediaSrc(storedSrc, {
|
|
169
|
+
hostId
|
|
170
|
+
});
|
|
171
|
+
const wrapLink = (element)=>linkHref && !suppressNavigation ? /*#__PURE__*/ _jsx(AppLink, {
|
|
172
|
+
componentVariant: "naked",
|
|
173
|
+
href: linkHref,
|
|
174
|
+
style: {
|
|
175
|
+
display: 'block'
|
|
176
|
+
},
|
|
177
|
+
children: element
|
|
178
|
+
}) : element;
|
|
179
|
+
if (!src) {
|
|
180
|
+
// The labeled box is for the author, so only editing surfaces draw it; a
|
|
181
|
+
// published page renders the bare element.
|
|
182
|
+
if (!suppressNavigation) return /*#__PURE__*/ _jsx(Box, _extends({
|
|
183
|
+
ref: ref
|
|
184
|
+
}, rest, {
|
|
185
|
+
sx: nodeSx
|
|
186
|
+
}));
|
|
187
|
+
return /*#__PURE__*/ _jsx(Box, _extends({
|
|
188
|
+
ref: ref
|
|
189
|
+
}, rest, {
|
|
190
|
+
sx: [
|
|
191
|
+
{
|
|
192
|
+
width: width || '100%',
|
|
193
|
+
height: height || 120,
|
|
194
|
+
display: 'flex',
|
|
195
|
+
alignItems: 'center',
|
|
196
|
+
justifyContent: 'center',
|
|
197
|
+
border: '1px dashed',
|
|
198
|
+
borderColor: 'divider',
|
|
199
|
+
borderRadius: radius != null ? `${radius}px` : undefined,
|
|
200
|
+
color: 'text.secondary',
|
|
201
|
+
fontSize: 12,
|
|
202
|
+
fontFamily: 'system-ui, sans-serif'
|
|
203
|
+
},
|
|
204
|
+
...nodeSx
|
|
205
|
+
],
|
|
206
|
+
children: 'Image — choose a source'
|
|
207
|
+
}));
|
|
208
|
+
}
|
|
209
|
+
// CDN URLs (AGL-175) carry WebP variants selected by `?w=`; widths
|
|
210
|
+
// without a variant fall back to the original server-side, so a static
|
|
211
|
+
// srcSet is safe for any CDN-form URL. Asked of the RESOLVED url, so a
|
|
212
|
+
// reference and a legacy stored path both keep their WebP variants.
|
|
213
|
+
const isCdnUrl = Aglyn.isMediaCdnUrl(src);
|
|
214
|
+
/** A CSS width that is a plain pixel value, and therefore a real `sizes`. */ const pinnedWidth = /^\d+(?:\.\d+)?px$/.test(String(width != null ? width : '').trim()) ? String(width).trim() : undefined;
|
|
215
|
+
/**
|
|
216
|
+
* The intrinsic attribute pair, or nothing.
|
|
217
|
+
*
|
|
218
|
+
* Both-or-neither: the browser derives an aspect-ratio only from the pair,
|
|
219
|
+
* and a lone `width` is read as a real dimension instead — which would
|
|
220
|
+
* reserve a box of the wrong shape rather than no box at all. Finite and
|
|
221
|
+
* positive because a media document may carry `0` or a partial capture
|
|
222
|
+
* (dimensions are best-effort at upload), and `width="0"` collapses the
|
|
223
|
+
* element.
|
|
224
|
+
*/ const usable = (value)=>typeof value === 'number' && Number.isFinite(value) && value > 0;
|
|
225
|
+
const intrinsicAttributes = usable(intrinsicWidth) && usable(intrinsicHeight) ? {
|
|
226
|
+
width: intrinsicWidth,
|
|
227
|
+
height: intrinsicHeight
|
|
228
|
+
} : undefined;
|
|
229
|
+
return wrapLink(/*#__PURE__*/ _jsx(Box, _extends({
|
|
230
|
+
ref: ref,
|
|
231
|
+
component: "img",
|
|
232
|
+
src: src,
|
|
233
|
+
// EVERY CANDIDATE IS A `?w=` URL, and the bare one is gone (2026-08-26).
|
|
234
|
+
// Why that is worth 335 KB against 4 KB, and why each candidate merges
|
|
235
|
+
// its width into the url's existing query, are documented where the list
|
|
236
|
+
// and the builder live — `MEDIA_CDN_VARIANT_WIDTHS` and `mediaCdnSrcSet`
|
|
237
|
+
// in `media-ref.ts`.
|
|
238
|
+
//
|
|
239
|
+
// Called rather than restated so the Markdown and entry-body renderers
|
|
240
|
+
// can ask for the same list (AGL-3149). Building it here is the reason
|
|
241
|
+
// they had none: a candidate list inside a component is a candidate list
|
|
242
|
+
// no other component can have.
|
|
243
|
+
srcSet: Aglyn.mediaCdnSrcSet(src),
|
|
244
|
+
// `sizes` is NOT only a delivery hint, and treating it as one broke every
|
|
245
|
+
// fluid image (AGL-2486). With `w` descriptors the browser derives the
|
|
246
|
+
// image's density-corrected INTRINSIC size from `sizes`, so `sizes` is
|
|
247
|
+
// what a CSS `width: 100%` resolves against whenever the containing block
|
|
248
|
+
// is content-sized — shrink-to-fit, inline-block, a flex item sized on its
|
|
249
|
+
// content. Measured in Chrome at a 1200px viewport with the author CSS
|
|
250
|
+
// `width:100%;height:auto;display:block`:
|
|
251
|
+
//
|
|
252
|
+
// parent sizes=100vw sizes=auto
|
|
253
|
+
// inline-block (shrink-to-fit) 1184px 300px
|
|
254
|
+
// block / fixed-width flex 900px 900px
|
|
255
|
+
//
|
|
256
|
+
// 300px is the spec's default object size, used because resolving `auto`
|
|
257
|
+
// against a content-sized parent is circular. So `sizes="auto"` — which
|
|
258
|
+
// genuinely does pick a better candidate, `?w=320` instead of a 357 KB
|
|
259
|
+
// original in a 158px slot — rendered those images tiny and centred in
|
|
260
|
+
// their box, on the canvas, in _preview and on published sites alike.
|
|
261
|
+
//
|
|
262
|
+
// A delivery win may not be paid for in layout, so this is back to
|
|
263
|
+
// `100vw`: it overfetches, but it is the value every published document
|
|
264
|
+
// was authored against. A pinned pixel width is still the better answer
|
|
265
|
+
// where the author gave one, because it is a definite length and cannot
|
|
266
|
+
// be circular. Getting image delivery right for fluid images needs the
|
|
267
|
+
// media pipeline (a WebP variant at source width) or real intrinsic
|
|
268
|
+
// `width`/`height` attributes from media metadata — neither of which
|
|
269
|
+
// perturbs layout the way `sizes` does.
|
|
270
|
+
sizes: isCdnUrl ? pinnedWidth != null ? pinnedWidth : '100vw' : undefined,
|
|
271
|
+
// Unset alt keeps rendering `alt=""` exactly as it always has —
|
|
272
|
+
// existing documents must not change output (AGL-1305). Decorative
|
|
273
|
+
// ON forces `alt=""` over any alt text and suppresses the tooltip,
|
|
274
|
+
// so the a11y intent is explicit rather than an accident of blank.
|
|
275
|
+
alt: decorative ? '' : alt != null ? alt : '',
|
|
276
|
+
title: decorative ? undefined : title || undefined
|
|
277
|
+
}, eager ? {
|
|
278
|
+
loading: 'eager'
|
|
279
|
+
} : Aglyn.DEFERRED_IMAGE_ATTRIBUTES, intrinsicAttributes, rest, {
|
|
280
|
+
sx: [
|
|
281
|
+
{
|
|
282
|
+
display: 'block',
|
|
283
|
+
width: width || '100%',
|
|
284
|
+
height: height || 'auto',
|
|
285
|
+
objectFit: objectFit || 'cover',
|
|
286
|
+
borderRadius: radius != null ? `${radius}px` : undefined
|
|
287
|
+
},
|
|
288
|
+
...nodeSx
|
|
289
|
+
]
|
|
290
|
+
})));
|
|
291
|
+
});
|
|
292
|
+
Image.displayName = 'Image';
|
|
293
|
+
/** Alt text and tooltip make no sense on an explicitly decorative image. */ const NOT_DECORATIVE = {
|
|
294
|
+
when: 'decorative',
|
|
295
|
+
is: true,
|
|
296
|
+
notMatch: true
|
|
297
|
+
};
|
|
298
|
+
export const schema = {
|
|
299
|
+
$id: ID,
|
|
300
|
+
pluginId: BUNDLE_ID,
|
|
301
|
+
displayName: 'Image',
|
|
302
|
+
description: 'A picture from your media library or any URL, with fit, size and an optional link.',
|
|
303
|
+
category: Aglyn.ComponentCategory.MEDIA,
|
|
304
|
+
icon: {
|
|
305
|
+
path: mdiImage.path,
|
|
306
|
+
sx: {
|
|
307
|
+
color: '#7b1fa2'
|
|
308
|
+
}
|
|
309
|
+
},
|
|
310
|
+
flags: {
|
|
311
|
+
selfClosing: Aglyn.FEATURE_FLAG.ENABLED
|
|
312
|
+
},
|
|
313
|
+
attributes: [
|
|
314
|
+
{
|
|
315
|
+
name: 'src',
|
|
316
|
+
// "Browse media" is the path an author should take (AGL-1215) — it
|
|
317
|
+
// stores a reference to the asset, which survives moves, replaces and
|
|
318
|
+
// any future change to how media is delivered. Typing a URL stays
|
|
319
|
+
// supported for hotlinking somebody else's image; nobody should ever
|
|
320
|
+
// be pasting one of OUR paths in here.
|
|
321
|
+
description: 'Pick from your media library with "Browse media", or paste the ' + 'URL of an image hosted somewhere else.',
|
|
322
|
+
component: Aglyn.FieldComponentType.TEXT_FIELD,
|
|
323
|
+
label: 'Image source'
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
name: 'alt',
|
|
327
|
+
// AGL-1896: "Browse media" now fills this in from the asset's own alt
|
|
328
|
+
// text when it is empty, so the description says where the value came
|
|
329
|
+
// from — otherwise a field that populates itself reads as a bug.
|
|
330
|
+
description: 'Describes the image for screen readers and search engines. ' + 'Filled in from the media library when you pick a file that has ' + 'alt text; anything you type here wins for this placement only.',
|
|
331
|
+
component: Aglyn.FieldComponentType.TEXT_FIELD,
|
|
332
|
+
label: 'Alt text',
|
|
333
|
+
// Hidden while Decorative is on — the renderer forces alt="" then,
|
|
334
|
+
// but the text is kept on the node so toggling back restores it.
|
|
335
|
+
condition: NOT_DECORATIVE
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
name: 'decorative',
|
|
339
|
+
description: 'Turn on when the image is purely decorative so screen readers ' + 'skip it — no alt text is needed then.',
|
|
340
|
+
component: Aglyn.FieldComponentType.SWITCH,
|
|
341
|
+
label: 'Decorative image'
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
name: 'title',
|
|
345
|
+
description: 'Optional tooltip shown when a visitor hovers over the image.',
|
|
346
|
+
component: Aglyn.FieldComponentType.TEXT_FIELD,
|
|
347
|
+
label: 'Tooltip',
|
|
348
|
+
condition: NOT_DECORATIVE
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
name: 'objectFit',
|
|
352
|
+
description: 'How the image fills its box.',
|
|
353
|
+
component: Aglyn.FieldComponentType.SELECT,
|
|
354
|
+
label: 'Fit',
|
|
355
|
+
// Both selects on this element take real sentinels (AGL-1451):
|
|
356
|
+
// `cover` and `lazy` are members of their own declared prop unions
|
|
357
|
+
// and the values the render already falls back to. As `''` neither
|
|
358
|
+
// could persist (AGL-1191) — an image switched to Contain or Eager
|
|
359
|
+
// could not be switched back.
|
|
360
|
+
options: [
|
|
361
|
+
{
|
|
362
|
+
value: 'cover',
|
|
363
|
+
label: 'Cover (default)'
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
value: 'contain',
|
|
367
|
+
label: 'Contain'
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
value: 'fill',
|
|
371
|
+
label: 'Fill'
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
value: 'none',
|
|
375
|
+
label: 'None'
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
value: 'scale-down',
|
|
379
|
+
label: 'Scale down'
|
|
380
|
+
}
|
|
381
|
+
]
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
name: 'width',
|
|
385
|
+
description: 'Width of the image — a number plus a unit, e.g. 100% or 320px.',
|
|
386
|
+
component: Aglyn.FieldComponentType.CSS_DIMENSION,
|
|
387
|
+
label: 'Width'
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
name: 'height',
|
|
391
|
+
description: 'Height of the image. Leave empty for auto.',
|
|
392
|
+
component: Aglyn.FieldComponentType.CSS_DIMENSION,
|
|
393
|
+
label: 'Height'
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
name: 'loading',
|
|
397
|
+
description: 'Lazy waits to load the image until a visitor scrolls near it; ' + 'pick Eager for the first image at the top of a screen so it ' + 'shows immediately.',
|
|
398
|
+
component: Aglyn.FieldComponentType.SELECT,
|
|
399
|
+
label: 'Loading',
|
|
400
|
+
options: [
|
|
401
|
+
{
|
|
402
|
+
value: 'lazy',
|
|
403
|
+
label: 'Lazy (default)'
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
value: 'eager',
|
|
407
|
+
label: 'Eager'
|
|
408
|
+
}
|
|
409
|
+
]
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
name: 'screenId',
|
|
413
|
+
description: 'Optional: navigate to this screen when the image is clicked — ' + 'follows the published path like a Screen Link.',
|
|
414
|
+
component: Aglyn.FieldComponentType.SCREEN_SELECT,
|
|
415
|
+
label: 'Link to screen'
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
name: 'href',
|
|
419
|
+
description: 'Makes the image a link to somewhere off this site. Ignored while ' + 'Link to screen names one. Leave both blank and the image is not ' + 'clickable at all.',
|
|
420
|
+
component: Aglyn.FieldComponentType.TEXT_FIELD,
|
|
421
|
+
label: 'External URL',
|
|
422
|
+
// A bare `#fragment` saves and goes nowhere (AGL-2867).
|
|
423
|
+
resolveProps: Aglyn.bareFragmentLinkFieldProps
|
|
424
|
+
}
|
|
425
|
+
]
|
|
426
|
+
};
|
|
427
|
+
export const presets = [
|
|
428
|
+
{
|
|
429
|
+
$id: generatePresetId(ID),
|
|
430
|
+
type: Aglyn.NodeType.PRESET,
|
|
431
|
+
displayName: 'Image',
|
|
432
|
+
pluginId: BUNDLE_ID,
|
|
433
|
+
description: 'Image from your media library or any URL',
|
|
434
|
+
category: Aglyn.ComponentCategory.MEDIA,
|
|
435
|
+
icon: {
|
|
436
|
+
path: mdiImage.path,
|
|
437
|
+
sx: {
|
|
438
|
+
color: '#7b1fa2'
|
|
439
|
+
}
|
|
440
|
+
},
|
|
441
|
+
data: {
|
|
442
|
+
$id: null,
|
|
443
|
+
componentId: ID,
|
|
444
|
+
pluginId: BUNDLE_ID,
|
|
445
|
+
props: {}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
];
|
|
449
|
+
export default Image;
|
|
450
|
+
|
|
451
|
+
//# sourceMappingURL=image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/mui/src/lib/components/image.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as Aglyn from '@aglyn/aglyn'\nimport { mdiImage } from '@aglyn/shared-data-mdi'\nimport { AppLink } from '@aglyn/shared-ui-jsx'\nimport Box from '@mui/material/Box'\nimport type { SxProps } from '@mui/material/styles'\nimport { forwardRef, type ReactNode } from 'react'\nimport { BUNDLE_ID } from '../constants/bundle-common'\nimport { generatePresetId } from '../utils/generate-preset-id'\n\n// Component ids are persisted in screen documents; never rename.\nexport const ID: Aglyn.ComponentId = 'image'\n\n/**\n * The node ids of the images that load eagerly: the first image the LAYOUT\n * chain renders and the first image the SCREEN renders, each in document\n * order (AGL-2486).\n *\n * Every image used to render `loading=\"lazy\"` — the hero included. That is\n * the worst possible default for the one image that is almost always the LCP\n * element: a lazy image is not fetched until layout has run and the browser\n * has decided it is near the viewport, and it is fetched at LOW priority when\n * it finally is. Lighthouse reports that as \"LCP request discovery\", and it is\n * also why an image four sections down could finish before the one the reader\n * is looking at: with everything lazy and everything low, nothing outranked\n * anything, so the order was whatever the network felt like.\n *\n * So the lead images get `loading=\"eager\"` and the rest get\n * `fetchpriority=\"low\"`, which is the browser-level knob that stops\n * below-the-fold images competing with the ones above them.\n *\n * ONE lead image was not enough. On any site whose header carries a logo, the\n * first image in document order is that logo, so the screen's own hero — the\n * element Lighthouse names as the LCP on aglyn.com's solution pages at\n * 375x812 — stayed `lazy` + `low`: undiscovered until layout, then fetched\n * behind every script on the page (measured 2026-09-08: 1.5 s of load delay\n * and 1.5 s of load time for a 13 KB image). Composition namespaces layout\n * nodes by origin ({@link Aglyn.isLayoutComposedNodeId}), so the walk keeps\n * one lead PER ORIGIN: the layout's first image (the logo) and the screen's\n * first image (the hero). A layout image further down — a mega-menu\n * illustration, the footer mark — is still deferred, as is every later\n * screen image. In the besigner canvas nothing is layout-composed, so the\n * screen's first image is the only lead, exactly as before.\n *\n * Neither lead gets `fetchpriority=\"high\"`, and the reasoning is at the\n * `fetchPriority` prop below. Short version: \"first image of its origin\" is\n * still not \"the LCP element\", and a ranking claim needs evidence this\n * function does not have.\n *\n * Resolved from the tree rather than a render-order counter on purpose: the\n * renderer walks the tree in document order on the server AND on hydrate, but\n * a mutable counter would double-count under React's concurrent re-renders\n * and hand the priority to a different image on the client than the one the\n * HTML gave it. A pure function of the tree cannot disagree with itself — and\n * it is deliberately NOT memoized on the root object, because the canvas\n * mutates that tree in place while an author works.\n *\n * The walk STOPS once both leads are known — on a page with a header logo\n * and a hero that is O(nodes above the hero), a dozen or two on a normal\n * page — and at the first image on a screen with no layout.\n *\n * An image with no `src` renders a placeholder box and no `<img>` at all, so\n * it cannot be the LCP element and is skipped.\n */\nexport function leadImageNodeIds(\n root: Aglyn.NodeSchema | undefined,\n): readonly string[] {\n let layoutLead: string | undefined\n let screenLead: string | undefined\n const walk = (node: Aglyn.NodeSchema | undefined): boolean => {\n if (!node) return false\n if (node.componentId === ID) {\n const props = (node.resolvedProps ?? node.props ?? {}) as Record<\n string,\n unknown\n >\n if (String(props['src'] ?? '').trim()) {\n if (Aglyn.isLayoutComposedNodeId(node.$id)) {\n if (!layoutLead) layoutLead = node.$id\n } else if (!screenLead) {\n screenLead = node.$id\n }\n if (layoutLead && screenLead) return true\n }\n }\n for (const child of node.children ?? []) {\n if (walk(child)) return true\n }\n return false\n }\n walk(root)\n return [layoutLead, screenLead].filter((id): id is string => Boolean(id))\n}\n\nexport interface ImageProps {\n /**\n * Where the image comes from (AGL-72). Either a **media reference** —\n * `media:{scope}/{mediaId}`, what \"Browse media\" now stores (AGL-1215) —\n * or any URL, which covers both the legacy values already in published\n * documents and an author-typed hotlink. `resolveMediaSrc` decides.\n */\n src?: string\n alt?: string\n /**\n * Explicit decorative choice (AGL-1305): ON forces `alt=\"\"` (and drops\n * the tooltip) no matter what the alt field says, so screen readers skip\n * the image. Distinct from simply leaving alt unset, which also renders\n * `alt=\"\"` today but records no intent.\n */\n decorative?: boolean\n /** Tooltip shown on hover — the native img `title` attribute. */\n title?: string\n /** Native loading hint; unset stays lazy, exactly as before AGL-1305. */\n loading?: 'lazy' | 'eager'\n objectFit?: 'cover' | 'contain' | 'fill' | 'none' | 'scale-down'\n /** CSS width (e.g. \"100%\", \"320px\"); defaults to 100%. */\n width?: string\n /** CSS height (e.g. \"240px\"); defaults to auto. */\n height?: string\n /**\n * The asset's own pixel dimensions, copied off the media document when the\n * image was picked (AGL-2486), and read from the asset again when the page\n * is composed, so a replace with a different shape reaches every page that\n * places it (AGL-2833).\n *\n * NOT author controls, which is why neither appears in the schema below:\n * they describe the file, and the CSS `width`/`height` above describe the\n * placement. The pair becomes the `<img>`'s intrinsic `width`/`height`\n * attributes, which is the only thing that lets the browser reserve the\n * right box before the bytes arrive — with `width: 100%; height: auto` the\n * element is otherwise zero-height until the image decodes, and every image\n * on the page shifts the layout as it lands.\n *\n * An attribute pair is a RATIO here, not a size: CSS wins for the used\n * dimensions either way, so a stale value costs nothing but a reservation\n * of the wrong shape. Both must be present and positive or neither is\n * emitted — one alone gives the browser no ratio and would be read as a\n * real dimension.\n *\n * Read from the node like any other prop, so this element never fetches a\n * media document: the composition has already laid the asset's current\n * pair over the pick's (`media-asset-facts.ts`), and the pick's copy is\n * what renders wherever that read cannot answer. `srcSet` still selects\n * which variant is downloaded; these only say what shape it will be.\n */\n intrinsicWidth?: number\n /** See `intrinsicWidth` — the two are only ever used as a pair. */\n intrinsicHeight?: number\n /** Border radius in px. */\n radius?: number\n /** Target screen id — resolved rename-safe like Screen Link (AGL-339). */\n screenId?: string\n /** External URL, used only when no `screenId` is set. */\n href?: string\n /**\n * Authored node styles, handed over by the renderer rather than typed into\n * an attribute — recomposed below so the author's Styles-panel values are\n * merged rather than replaced (AGL-1240).\n */\n sx?: SxProps\n /**\n * Accepted and dropped: an `<img>` is a void element and React throws on\n * ANY children value reaching one, which 500'd whole pages (AGL-579).\n * Declared because the implementation deliberately discards it (AGL-1323).\n */\n children?: ReactNode\n}\n\n/**\n * Image element (AGL-74): renders a plain img with fit/size/radius\n * controls; an empty src shows a labeled placeholder so the element stays\n * visible and selectable in the editor.\n */\nconst Image = forwardRef<HTMLElement, ImageProps>((props, ref) => {\n const {\n src: storedSrc,\n alt,\n decorative,\n title,\n loading,\n objectFit,\n width,\n height,\n intrinsicWidth,\n intrinsicHeight,\n radius,\n screenId,\n href: externalHref,\n // Never forward children to the <img> below — React throws on ANY\n // children value reaching a void element, which 500'd whole pages\n // when a renderer passed empty JSX children through (AGL-579).\n children: _children,\n // Pull `sx` out of the spread: the literals below are composed AFTER\n // `{...rest}`, so leaving it there REPLACED every style the author set\n // from the Styles panel. The hero mockups' 16px radius and drop shadow\n // were being discarded on every published page (AGL-1240).\n sx: nodeSxProp,\n ...rest\n } = props\n // Node styles ride the renderer-merged sx; recompose (stack.ts pattern).\n const nodeSx = Array.isArray(nodeSxProp)\n ? nodeSxProp\n : nodeSxProp\n ? [nodeSxProp]\n : []\n // Optional link mode (AGL-339): screen id first (rename-safe), external\n // URL as fallback; suppressed in the besigner canvas like Screen Link.\n // Shared with every other linking element since AGL-1335, so a `Link`\n // component prop bound here behaves as it does on a Button.\n const { href: linkHref, suppressNavigation } = Aglyn.useLinkTarget(\n screenId,\n externalHref,\n )\n /**\n * Eagerness (AGL-2486). An explicit author choice always wins — including\n * an explicit `lazy`, so someone who deliberately deferred the top image\n * keeps that. Only an UNSET `loading` is decided here, and only for the\n * lead images: the layout's first and the screen's first.\n *\n * `leafIdsMatch` rather than `===`: a reusable component instance suffixes\n * its leaf ids, so the id in the tree and the id in the context are the\n * same leaf spelled two ways (the markdown block resolves the same way).\n */\n const nodeId = Aglyn.useNodeId()\n const isLeadImage =\n Boolean(nodeId) &&\n leadImageNodeIds(Aglyn.canvas.rootNode).some((leadId) =>\n Aglyn.leafIdsMatch(leadId, nodeId),\n )\n const eager = loading === 'eager' || (loading == null && isLeadImage)\n /**\n * Resolve the stored value to a URL (AGL-1215). A media reference becomes\n * a CDN URL here rather than in the document, so the route shape stays an\n * app concern; every other value — a legacy firebasestorage URL, a legacy\n * `/api/media/cdn/…` path, an author-typed hotlink — passes through.\n *\n * `useSite().hostId` is the site being rendered: present on the tenant and\n * in Preview, absent in the besigner canvas. When it is there it names the\n * asking site in the org scope, which is what lets ONE reference in a\n * layout or reusable component resolve on each site that uses it.\n */\n const { hostId } = Aglyn.useSite()\n const src = Aglyn.resolveMediaSrc(storedSrc, { hostId })\n const wrapLink = (element: JSX.Element) =>\n linkHref && !suppressNavigation ? (\n <AppLink\n componentVariant=\"naked\"\n href={linkHref}\n style={{ display: 'block' }}\n >\n {element}\n </AppLink>\n ) : (\n element\n )\n if (!src) {\n // The labeled box is for the author, so only editing surfaces draw it; a\n // published page renders the bare element.\n if (!suppressNavigation) return <Box ref={ref} {...rest} sx={nodeSx} />\n return (\n <Box\n ref={ref}\n {...rest}\n sx={[\n {\n width: width || '100%',\n height: height || 120,\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n border: '1px dashed',\n borderColor: 'divider',\n borderRadius: radius != null ? `${radius}px` : undefined,\n color: 'text.secondary',\n fontSize: 12,\n fontFamily: 'system-ui, sans-serif',\n },\n ...nodeSx,\n ]}\n >\n {'Image — choose a source'}\n </Box>\n )\n }\n // CDN URLs (AGL-175) carry WebP variants selected by `?w=`; widths\n // without a variant fall back to the original server-side, so a static\n // srcSet is safe for any CDN-form URL. Asked of the RESOLVED url, so a\n // reference and a legacy stored path both keep their WebP variants.\n const isCdnUrl = Aglyn.isMediaCdnUrl(src)\n /** A CSS width that is a plain pixel value, and therefore a real `sizes`. */\n const pinnedWidth = /^\\d+(?:\\.\\d+)?px$/.test(String(width ?? '').trim())\n ? String(width).trim()\n : undefined\n /**\n * The intrinsic attribute pair, or nothing.\n *\n * Both-or-neither: the browser derives an aspect-ratio only from the pair,\n * and a lone `width` is read as a real dimension instead — which would\n * reserve a box of the wrong shape rather than no box at all. Finite and\n * positive because a media document may carry `0` or a partial capture\n * (dimensions are best-effort at upload), and `width=\"0\"` collapses the\n * element.\n */\n const usable = (value: unknown): value is number =>\n typeof value === 'number' && Number.isFinite(value) && value > 0\n const intrinsicAttributes =\n usable(intrinsicWidth) && usable(intrinsicHeight)\n ? { width: intrinsicWidth, height: intrinsicHeight }\n : undefined\n return wrapLink(\n <Box\n ref={ref}\n component=\"img\"\n src={src}\n // EVERY CANDIDATE IS A `?w=` URL, and the bare one is gone (2026-08-26).\n // Why that is worth 335 KB against 4 KB, and why each candidate merges\n // its width into the url's existing query, are documented where the list\n // and the builder live — `MEDIA_CDN_VARIANT_WIDTHS` and `mediaCdnSrcSet`\n // in `media-ref.ts`.\n //\n // Called rather than restated so the Markdown and entry-body renderers\n // can ask for the same list (AGL-3149). Building it here is the reason\n // they had none: a candidate list inside a component is a candidate list\n // no other component can have.\n srcSet={Aglyn.mediaCdnSrcSet(src)}\n // `sizes` is NOT only a delivery hint, and treating it as one broke every\n // fluid image (AGL-2486). With `w` descriptors the browser derives the\n // image's density-corrected INTRINSIC size from `sizes`, so `sizes` is\n // what a CSS `width: 100%` resolves against whenever the containing block\n // is content-sized — shrink-to-fit, inline-block, a flex item sized on its\n // content. Measured in Chrome at a 1200px viewport with the author CSS\n // `width:100%;height:auto;display:block`:\n //\n // parent sizes=100vw sizes=auto\n // inline-block (shrink-to-fit) 1184px 300px\n // block / fixed-width flex 900px 900px\n //\n // 300px is the spec's default object size, used because resolving `auto`\n // against a content-sized parent is circular. So `sizes=\"auto\"` — which\n // genuinely does pick a better candidate, `?w=320` instead of a 357 KB\n // original in a 158px slot — rendered those images tiny and centred in\n // their box, on the canvas, in _preview and on published sites alike.\n //\n // A delivery win may not be paid for in layout, so this is back to\n // `100vw`: it overfetches, but it is the value every published document\n // was authored against. A pinned pixel width is still the better answer\n // where the author gave one, because it is a definite length and cannot\n // be circular. Getting image delivery right for fluid images needs the\n // media pipeline (a WebP variant at source width) or real intrinsic\n // `width`/`height` attributes from media metadata — neither of which\n // perturbs layout the way `sizes` does.\n sizes={isCdnUrl ? (pinnedWidth ?? '100vw') : undefined}\n // Unset alt keeps rendering `alt=\"\"` exactly as it always has —\n // existing documents must not change output (AGL-1305). Decorative\n // ON forces `alt=\"\"` over any alt text and suppresses the tooltip,\n // so the a11y intent is explicit rather than an accident of blank.\n alt={decorative ? '' : (alt ?? '')}\n title={decorative ? undefined : title || undefined}\n // The ordering signal, ONE-DIRECTIONAL on purpose (AGL-2486).\n //\n // `low` on every deferred image, so a footer image cannot be fetched\n // ahead of the section the reader is in. That half is safe in a way the\n // other half is not: deprioritising an image that is provably not being\n // looked at cannot starve whatever the LCP turns out to be.\n //\n // The lead image gets NO `fetchpriority` — the browser's `auto` — where\n // it used to get `high`. `high` is not a statement about this image, it\n // is a claim that this image outranks everything else in flight,\n // including the stylesheet and the webfont that a TEXT LCP is waiting\n // on. We are not in a position to make that claim: the only evidence\n // behind it was \"first `<img>` in document order\", and document order's\n // first image is the HEADER LOGO on any site whose header has one.\n //\n // Measured on aglyn.com at a 375x812 viewport, which is what sent this\n // back: the element carrying `fetchpriority=\"high\"` was the logo at\n // 145x44 = 6,380 px², while the `<h1>` under it was 343x113 =\n // 38,893 px² — six times the area, and the element Lighthouse named as\n // the LCP. So the hint was being spent to make a text LCP arrive later.\n //\n // `auto` is not a retreat to the old behaviour. The old bug was that\n // everything was `lazy`, so the lead image was not discovered until\n // after layout; it still gets `loading=\"eager\"` above, which is the\n // discovery fix and the part that actually earned the win. What goes is\n // only the RANKING claim, back to Chrome's own in-viewport heuristic —\n // which decides after layout, with the viewport and the geometry this\n // function provably does not have.\n //\n // Deliberately not replaced with a size heuristic: nothing here knows\n // the rendered size. `width`/`height` are optional author CSS strings,\n // routinely `100%`, and a logo constrained by its container measures\n // small while declaring nothing. A guess that fails the same way is not\n // an improvement on a guess.\n //\n // An author who genuinely has an image LCP should be able to SAY so —\n // but not through this control. The `loading` field is labelled\n // \"Loading\" and described in terms of lazy versus eager; an author\n // picking Eager for the top image is not asserting a priority ranking,\n // and reading one out of that choice is how the logo got `high` in the\n // first place. A real priority affordance needs its own control and its\n // own words. After September 1.\n // Decoding off the main thread for the deferred ones — they have no\n // paint deadline, and decoding them synchronously is main-thread time\n // spent on pixels nobody is looking at yet. The eager image keeps the\n // browser's default (`auto`) so it is free to decode in time to paint.\n //\n // The deferred set is `DEFERRED_IMAGE_ATTRIBUTES` rather than three\n // literals because every OTHER `<img>` a published page renders has to\n // land in the same rank to be ranked at all — a product grid, an event\n // list, a cart line. Those carried no hint whatsoever and so were\n // fetched EAGERLY, ahead of anything this component deferred. The set\n // is documented at its definition; the reasoning for each member is\n // the two paragraphs above and the two below.\n {...(eager\n ? { loading: 'eager' as const }\n : Aglyn.DEFERRED_IMAGE_ATTRIBUTES)}\n // Ahead of `{...rest}` so an author who has typed a literal width or\n // height attribute onto the node still wins, and ahead of `sx` because\n // these are ATTRIBUTES: the CSS block below sets the used size, and\n // these only supply the ratio it is laid out against. `Box` in this\n // version applies `styleFunctionSx` alone — it has no system-props\n // layer — so both forward to the `<img>` rather than becoming CSS.\n {...intrinsicAttributes}\n {...rest}\n sx={[\n {\n display: 'block',\n width: width || '100%',\n height: height || 'auto',\n objectFit: objectFit || 'cover',\n borderRadius: radius != null ? `${radius}px` : undefined,\n },\n ...nodeSx,\n ]}\n />,\n )\n})\nImage.displayName = 'Image'\n\n/** Alt text and tooltip make no sense on an explicitly decorative image. */\nconst NOT_DECORATIVE = { when: 'decorative', is: true, notMatch: true }\n\nexport const schema: Aglyn.ComponentSchema<ImageProps> = {\n $id: ID,\n pluginId: BUNDLE_ID,\n displayName: 'Image',\n description:\n 'A picture from your media library or any URL, with fit, size and an optional link.',\n category: Aglyn.ComponentCategory.MEDIA,\n icon: {\n path: mdiImage.path,\n sx: { color: '#7b1fa2' },\n },\n flags: {\n selfClosing: Aglyn.FEATURE_FLAG.ENABLED,\n },\n attributes: [\n {\n name: 'src',\n // \"Browse media\" is the path an author should take (AGL-1215) — it\n // stores a reference to the asset, which survives moves, replaces and\n // any future change to how media is delivered. Typing a URL stays\n // supported for hotlinking somebody else's image; nobody should ever\n // be pasting one of OUR paths in here.\n description:\n 'Pick from your media library with \"Browse media\", or paste the ' +\n 'URL of an image hosted somewhere else.',\n component: Aglyn.FieldComponentType.TEXT_FIELD,\n label: 'Image source',\n },\n {\n name: 'alt',\n // AGL-1896: \"Browse media\" now fills this in from the asset's own alt\n // text when it is empty, so the description says where the value came\n // from — otherwise a field that populates itself reads as a bug.\n description:\n 'Describes the image for screen readers and search engines. ' +\n 'Filled in from the media library when you pick a file that has ' +\n 'alt text; anything you type here wins for this placement only.',\n component: Aglyn.FieldComponentType.TEXT_FIELD,\n label: 'Alt text',\n // Hidden while Decorative is on — the renderer forces alt=\"\" then,\n // but the text is kept on the node so toggling back restores it.\n condition: NOT_DECORATIVE,\n },\n {\n name: 'decorative',\n description:\n 'Turn on when the image is purely decorative so screen readers ' +\n 'skip it — no alt text is needed then.',\n component: Aglyn.FieldComponentType.SWITCH,\n label: 'Decorative image',\n },\n {\n name: 'title',\n description:\n 'Optional tooltip shown when a visitor hovers over the image.',\n component: Aglyn.FieldComponentType.TEXT_FIELD,\n label: 'Tooltip',\n condition: NOT_DECORATIVE,\n },\n {\n name: 'objectFit',\n description: 'How the image fills its box.',\n component: Aglyn.FieldComponentType.SELECT,\n label: 'Fit',\n // Both selects on this element take real sentinels (AGL-1451):\n // `cover` and `lazy` are members of their own declared prop unions\n // and the values the render already falls back to. As `''` neither\n // could persist (AGL-1191) — an image switched to Contain or Eager\n // could not be switched back.\n options: [\n { value: 'cover', label: 'Cover (default)' },\n { value: 'contain', label: 'Contain' },\n { value: 'fill', label: 'Fill' },\n { value: 'none', label: 'None' },\n { value: 'scale-down', label: 'Scale down' },\n ],\n },\n {\n name: 'width',\n description:\n 'Width of the image — a number plus a unit, e.g. 100% or 320px.',\n component: Aglyn.FieldComponentType.CSS_DIMENSION,\n label: 'Width',\n },\n {\n name: 'height',\n description: 'Height of the image. Leave empty for auto.',\n component: Aglyn.FieldComponentType.CSS_DIMENSION,\n label: 'Height',\n },\n {\n name: 'loading',\n description:\n 'Lazy waits to load the image until a visitor scrolls near it; ' +\n 'pick Eager for the first image at the top of a screen so it ' +\n 'shows immediately.',\n component: Aglyn.FieldComponentType.SELECT,\n label: 'Loading',\n options: [\n { value: 'lazy', label: 'Lazy (default)' },\n { value: 'eager', label: 'Eager' },\n ],\n },\n {\n name: 'screenId',\n description:\n 'Optional: navigate to this screen when the image is clicked — ' +\n 'follows the published path like a Screen Link.',\n component: Aglyn.FieldComponentType.SCREEN_SELECT,\n label: 'Link to screen',\n },\n {\n name: 'href',\n description:\n 'Makes the image a link to somewhere off this site. Ignored while ' +\n 'Link to screen names one. Leave both blank and the image is not ' +\n 'clickable at all.',\n component: Aglyn.FieldComponentType.TEXT_FIELD,\n label: 'External URL',\n // A bare `#fragment` saves and goes nowhere (AGL-2867).\n resolveProps: Aglyn.bareFragmentLinkFieldProps,\n },\n ],\n}\n\nexport const presets: Aglyn.PresetSchema[] = [\n {\n $id: generatePresetId(ID),\n type: Aglyn.NodeType.PRESET,\n displayName: 'Image',\n pluginId: BUNDLE_ID,\n description: 'Image from your media library or any URL',\n category: Aglyn.ComponentCategory.MEDIA,\n icon: {\n path: mdiImage.path,\n sx: { color: '#7b1fa2' },\n },\n data: {\n $id: null,\n componentId: ID,\n pluginId: BUNDLE_ID,\n props: {},\n },\n },\n]\n\nexport default Image\n"],"names":["Aglyn","mdiImage","AppLink","Box","forwardRef","BUNDLE_ID","generatePresetId","ID","leadImageNodeIds","root","layoutLead","screenLead","walk","node","componentId","props","resolvedProps","String","trim","isLayoutComposedNodeId","$id","child","children","filter","id","Boolean","Image","ref","src","storedSrc","alt","decorative","title","loading","objectFit","width","height","intrinsicWidth","intrinsicHeight","radius","screenId","href","externalHref","_children","sx","nodeSxProp","rest","nodeSx","Array","isArray","linkHref","suppressNavigation","useLinkTarget","nodeId","useNodeId","isLeadImage","canvas","rootNode","some","leadId","leafIdsMatch","eager","hostId","useSite","resolveMediaSrc","wrapLink","element","componentVariant","style","display","alignItems","justifyContent","border","borderColor","borderRadius","undefined","color","fontSize","fontFamily","isCdnUrl","isMediaCdnUrl","pinnedWidth","test","usable","value","Number","isFinite","intrinsicAttributes","component","srcSet","mediaCdnSrcSet","sizes","DEFERRED_IMAGE_ATTRIBUTES","displayName","NOT_DECORATIVE","when","is","notMatch","schema","pluginId","description","category","ComponentCategory","MEDIA","icon","path","flags","selfClosing","FEATURE_FLAG","ENABLED","attributes","name","FieldComponentType","TEXT_FIELD","label","condition","SWITCH","SELECT","options","CSS_DIMENSION","SCREEN_SELECT","resolveProps","bareFragmentLinkFieldProps","presets","type","NodeType","PRESET","data"],"mappings":";;;AAAA;;;;;;;;;;;;;;;CAeC,GAED,YAAYA,WAAW,eAAc;AACrC,SAASC,QAAQ,QAAQ,yBAAwB;AACjD,SAASC,OAAO,QAAQ,uBAAsB;AAC9C,OAAOC,SAAS,oBAAmB;AAEnC,SAASC,UAAU,QAAwB,QAAO;AAClD,SAASC,SAAS,QAAQ,gCAA4B;AACtD,SAASC,gBAAgB,QAAQ,iCAA6B;AAE9D,iEAAiE;AACjE,OAAO,MAAMC,KAAwB,QAAO;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkDC,GACD,OAAO,SAASC,iBACdC,IAAkC;IAElC,IAAIC;IACJ,IAAIC;IACJ,MAAMC,OAAO,CAACC;YAgBQA;QAfpB,IAAI,CAACA,MAAM,OAAO;QAClB,IAAIA,KAAKC,WAAW,KAAKP,IAAI;gBACZM,MAAAA,qBAIJE;YAJX,MAAMA,SAASF,QAAAA,sBAAAA,KAAKG,aAAa,YAAlBH,sBAAsBA,KAAKE,KAAK,YAAhCF,OAAoC,CAAC;YAIpD,IAAII,QAAOF,aAAAA,KAAK,CAAC,MAAM,YAAZA,aAAgB,IAAIG,IAAI,IAAI;gBACrC,IAAIlB,MAAMmB,sBAAsB,CAACN,KAAKO,GAAG,GAAG;oBAC1C,IAAI,CAACV,YAAYA,aAAaG,KAAKO,GAAG;gBACxC,OAAO,IAAI,CAACT,YAAY;oBACtBA,aAAaE,KAAKO,GAAG;gBACvB;gBACA,IAAIV,cAAcC,YAAY,OAAO;YACvC;QACF;QACA,KAAK,MAAMU,UAASR,iBAAAA,KAAKS,QAAQ,YAAbT,iBAAiB,EAAE,CAAE;YACvC,IAAID,KAAKS,QAAQ,OAAO;QAC1B;QACA,OAAO;IACT;IACAT,KAAKH;IACL,OAAO;QAACC;QAAYC;KAAW,C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OAAO;gBAAiB;gBACzC;oBAAE9B,OAAO;oBAAS8B,OAAO;gBAAQ;aAClC;QACH;QACA;YACEH,MAAM;YACNX,aACE,mEACA;YACFZ,WAAWxF,MAAMgH,kBAAkB,CAACQ,aAAa;YACjDN,OAAO;QACT;QACA;YACEH,MAAM;YACNX,aACE,sEACA,qEACA;YACFZ,WAAWxF,MAAMgH,kBAAkB,CAACC,UAAU;YAC9CC,OAAO;YACP,wDAAwD;YACxDO,cAAczH,MAAM0H,0BAA0B;QAChD;KACD;AACH,EAAC;AAED,OAAO,MAAMC,UAAgC;IAC3C;QACEvG,KAAKd,iBAAiBC;QACtBqH,MAAM5H,MAAM6H,QAAQ,CAACC,MAAM;QAC3BjC,aAAa;QACbM,UAAU9F;QACV+F,aAAa;QACbC,UAAUrG,MAAMsG,iBAAiB,CAACC,KAAK;QACvCC,MAAM;YACJC,MAAMxG,SAASwG,IAAI;YACnB7D,IAAI;gBAAEgC,OAAO;YAAU;QACzB;QACAmD,MAAM;YACJ3G,KAAK;YACLN,aAAaP;YACb4F,UAAU9F;YACVU,OAAO,CAAC;QACV;IACF;CACD,CAAA;AAED,eAAeW,MAAK"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import * as Aglyn from '@aglyn/aglyn';
|
|
18
|
+
import type { SxProps } from '@mui/material/styles';
|
|
19
|
+
import { type ReactNode } from 'react';
|
|
20
|
+
export declare const ID: Aglyn.ComponentId;
|
|
21
|
+
/**
|
|
22
|
+
* Inline elements the run may render as. An allow-list rather than a
|
|
23
|
+
* free-text field, for the same reason Box's is (AGL-1201): `element` is
|
|
24
|
+
* persisted and rendered verbatim into every visitor's page, so a typed
|
|
25
|
+
* value would let an author put `script`/`iframe` there.
|
|
26
|
+
*
|
|
27
|
+
* All five are phrasing content, so a run is always legal inside a
|
|
28
|
+
* paragraph — which is the whole point of the element.
|
|
29
|
+
*/
|
|
30
|
+
export declare const INLINE_TEXT_ELEMENTS: readonly ["span", "strong", "em", "mark", "small"];
|
|
31
|
+
export type InlineTextElement = (typeof INLINE_TEXT_ELEMENTS)[number];
|
|
32
|
+
export interface InlineTextProps {
|
|
33
|
+
/** The DOM element rendered; defaults to `span`. */
|
|
34
|
+
element?: InlineTextElement;
|
|
35
|
+
/** Palette token key from {@link TONE_COLOR}. */
|
|
36
|
+
tone?: string;
|
|
37
|
+
/** Named weight key from {@link FONT_WEIGHT}. */
|
|
38
|
+
weight?: string;
|
|
39
|
+
/** Decoration behaviour key from {@link DECORATION_SX}. */
|
|
40
|
+
decoration?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Authored node styles, handed over by the renderer rather than typed
|
|
43
|
+
* into an attribute. Declared because the merge below reads it —
|
|
44
|
+
* undeclared, no typed caller could style a run (AGL-1323).
|
|
45
|
+
*/
|
|
46
|
+
sx?: SxProps;
|
|
47
|
+
/**
|
|
48
|
+
* Sanitized emphasis markup for the run, written by the inline editor's
|
|
49
|
+
* rich mode (AGL-2557). `children` keeps the plain-text reading of it, and
|
|
50
|
+
* is what every surface that cannot render markup falls back to.
|
|
51
|
+
*/
|
|
52
|
+
html?: string;
|
|
53
|
+
/** The text of this run; edited inline on the canvas. */
|
|
54
|
+
children?: ReactNode;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* One run of text inside a sentence (AGL-1235).
|
|
58
|
+
*
|
|
59
|
+
* The gap this fills: `muiTypography` is `textEditable`, therefore a leaf —
|
|
60
|
+
* `nodeAcceptsChildren` reports false, so no span can be nested inside it.
|
|
61
|
+
* A statement whose argument lives in an emphasised phrase ("Aglyn commerce
|
|
62
|
+
* is **part of the platform**") could not be authored at all; the whole line
|
|
63
|
+
* was one flat colour.
|
|
64
|
+
*
|
|
65
|
+
* This is a leaf too, deliberately: the shape that renders correctly is a
|
|
66
|
+
* block container holding SIBLING inline runs, not a nested span. Sibling
|
|
67
|
+
* runs flow and wrap as a single paragraph, so the sentence breaks
|
|
68
|
+
* naturally with the emphasis landing in the right place. Drop a Box as
|
|
69
|
+
* `p`, then one of these per style change.
|
|
70
|
+
*/
|
|
71
|
+
declare const InlineText: import("react").ForwardRefExoticComponent<InlineTextProps & import("react").RefAttributes<HTMLElement>>;
|
|
72
|
+
export declare const schema: Aglyn.ComponentSchema<InlineTextProps>;
|
|
73
|
+
export declare const presets: Aglyn.PresetSchema[];
|
|
74
|
+
export default InlineText;
|