@aglyn/plugins-mui 1.15.0 → 1.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aglyn/plugins-mui",
3
- "version": "1.15.0",
3
+ "version": "1.15.1",
4
4
  "license": "Apache-2.0",
5
5
  "homepage": "https://aglyn.com",
6
6
  "repository": {
@@ -25,12 +25,12 @@
25
25
  "./package.json": "./package.json"
26
26
  },
27
27
  "dependencies": {
28
- "@aglyn/aglyn": "1.15.0",
29
- "@aglyn/shared-data-enums": "1.15.0",
30
- "@aglyn/shared-data-mdi": "1.15.0",
31
- "@aglyn/shared-ui-jsx": "1.15.0",
32
- "@aglyn/shared-ui-theme": "1.15.0",
33
- "@aglyn/shared-util-vendor": "1.15.0",
28
+ "@aglyn/aglyn": "1.15.1",
29
+ "@aglyn/shared-data-enums": "1.15.1",
30
+ "@aglyn/shared-data-mdi": "1.15.1",
31
+ "@aglyn/shared-ui-jsx": "1.15.1",
32
+ "@aglyn/shared-ui-theme": "1.15.1",
33
+ "@aglyn/shared-util-vendor": "1.15.1",
34
34
  "@swc/helpers": "0.5.23",
35
35
  "dayjs": "^1.11.23",
36
36
  "mobx": "^7.0.5",
@@ -32,11 +32,21 @@ export interface AglynAppBarProps extends AppBarProps {
32
32
  /**
33
33
  * Sits over a photo hero (AGL-3660): on a page whose first band runs under
34
34
  * the header (a Section with `underHeader`), the bar lies over that band
35
- * with no background of its own and its words in white, and scrolls away
36
- * with it; on every other page it is the bar it always was.
35
+ * with no background of its own and its words in white. A Sticky or Fixed
36
+ * bar stays pinned and turns back into its own solid self once the page
37
+ * has scrolled (`OVER_HERO_SOLID_ATTRIBUTE`); any other bar scrolls away
38
+ * with the band. On every other page it is the bar it always was.
37
39
  */
38
40
  overHero?: boolean;
39
41
  }
42
+ /**
43
+ * Set on an over-hero bar that is pinned (Sticky or Fixed), and on one that
44
+ * has scrolled past the top and turned solid. A logo that swaps to a white
45
+ * version over the photo reads the second one to swap back:
46
+ * `body:has([data-aglyn-under-header]) header:not([data-over-hero-solid]) &`.
47
+ */
48
+ export declare const OVER_HERO_PINNED_ATTRIBUTE = "data-over-hero-pinned";
49
+ export declare const OVER_HERO_SOLID_ATTRIBUTE = "data-over-hero-solid";
40
50
  /**
41
51
  * Over a page that opens under the header, the bar lies on the photo. One
42
52
  * rule the browser applies by what the page holds, so the server render, the
@@ -49,12 +59,19 @@ export declare const overHeroSx: (theme: Theme) => {
49
59
  top: string;
50
60
  left: number;
51
61
  right: number;
62
+ transition: string;
63
+ };
64
+ "body:has([data-aglyn-under-header]) &:not([data-over-hero-solid])": {
52
65
  backgroundColor: string;
53
66
  backgroundImage: string;
54
67
  boxShadow: string;
55
- borderBottom: number;
68
+ borderBottomColor: string;
56
69
  color: string;
57
70
  };
71
+ "body:has([data-aglyn-under-header]) &[data-over-hero-pinned][data-over-hero-solid]": {
72
+ position: string;
73
+ top: string;
74
+ };
58
75
  };
59
76
  /**
60
77
  * MUI's AppBar behind the cleared-prop guard (AGL-1226).
@@ -65,6 +82,13 @@ export declare const overHeroSx: (theme: Theme) => {
65
82
  * wrapper is the only place to intercept it, since the schema's props reach
66
83
  * MUI directly. `createElement` rather than JSX keeps this a `.ts` file.
67
84
  */
85
+ /**
86
+ * Has the page scrolled past where a pinned over-hero bar should turn solid?
87
+ * That is the announcement bar's height: until it has gone, the bar is still
88
+ * lying on the photo below it. Listens only for a bar that asked to be pinned
89
+ * over a hero; SSR and the first paint read "not yet".
90
+ */
91
+ export declare function useOverHeroSolid(enabled: boolean): boolean;
68
92
  declare const AppBar: import("react").ForwardRefExoticComponent<Omit<AglynAppBarProps, "ref"> & import("react").RefAttributes<HTMLElement>>;
69
93
  export declare const ID: Aglyn.ComponentId;
70
94
  export declare const schema: Aglyn.ComponentSchema<AglynAppBarProps>;
@@ -19,7 +19,7 @@ import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_wi
19
19
  import { mdiPageLayoutHeader } from "@aglyn/shared-data-mdi";
20
20
  import { ScrollReaction } from "@aglyn/shared-ui-jsx/components/scroll-reaction";
21
21
  import MuiAppBar from "@mui/material/AppBar";
22
- import { createElement, forwardRef } from "react";
22
+ import { createElement, forwardRef, useEffect, useState } from "react";
23
23
  import { BUNDLE_ID } from "../constants/bundle-common.js";
24
24
  import { applySemanticElement, semanticElementAttribute, semanticElementLabelAttribute } from "../utils/element-picker.js";
25
25
  import { FIELD_COLOR_ALT1, FIELD_POSITION } from "../constants/field-presets.js";
@@ -27,6 +27,13 @@ import { dropClearedProps } from "../utils/drop-cleared-props.js";
27
27
  import { generatePresetId } from "../utils/generate-preset-id.js";
28
28
  import { UNDER_HEADER_ATTRIBUTE } from "./section.js";
29
29
  import { ID as toolbarId } from "./toolbar.js";
30
+ /**
31
+ * Set on an over-hero bar that is pinned (Sticky or Fixed), and on one that
32
+ * has scrolled past the top and turned solid. A logo that swaps to a white
33
+ * version over the photo reads the second one to swap back:
34
+ * `body:has([data-aglyn-under-header]) header:not([data-over-hero-solid]) &`.
35
+ */ export const OVER_HERO_PINNED_ATTRIBUTE = 'data-over-hero-pinned';
36
+ export const OVER_HERO_SOLID_ATTRIBUTE = 'data-over-hero-solid';
30
37
  /**
31
38
  * Over a page that opens under the header, the bar lies on the photo. One
32
39
  * rule the browser applies by what the page holds, so the server render, the
@@ -42,11 +49,31 @@ import { ID as toolbarId } from "./toolbar.js";
42
49
  top: 'calc(var(--aglyn-admin-bar-height, 0px) + var(--aglyn-announcement-bar-height, 0px))',
43
50
  left: 0,
44
51
  right: 0,
52
+ transition: theme.transitions.create([
53
+ 'background-color',
54
+ 'color',
55
+ 'box-shadow',
56
+ 'border-color'
57
+ ], {
58
+ duration: theme.transitions.duration.shorter
59
+ })
60
+ },
61
+ // Clear over the photo until a pinned bar turns solid.
62
+ [`body:has([${UNDER_HEADER_ATTRIBUTE}]) &:not([${OVER_HERO_SOLID_ATTRIBUTE}])`]: {
45
63
  backgroundColor: 'transparent',
46
64
  backgroundImage: 'none',
47
65
  boxShadow: 'none',
48
- borderBottom: 0,
66
+ borderBottomColor: 'transparent',
49
67
  color: theme.palette.common.white
68
+ },
69
+ // A Sticky or Fixed bar, once the announcement bar has scrolled away,
70
+ // pins to the top as the bar it is on every other page: its own
71
+ // background, colors and border, which the rule above no longer clears.
72
+ // The switch happens exactly where the absolute bar reaches the top, so
73
+ // nothing jumps.
74
+ [`body:has([${UNDER_HEADER_ATTRIBUTE}]) &[${OVER_HERO_PINNED_ATTRIBUTE}][${OVER_HERO_SOLID_ATTRIBUTE}]`]: {
75
+ position: 'fixed',
76
+ top: 'var(--aglyn-admin-bar-height, 0px)'
50
77
  }
51
78
  });
52
79
  function withOverHeroSx(sx) {
@@ -131,7 +158,43 @@ ScrollAwareAppBar.displayName = 'AglynScrollAwareAppBar';
131
158
  * either one persists a null that throws during SSR and 500s the page. A
132
159
  * wrapper is the only place to intercept it, since the schema's props reach
133
160
  * MUI directly. `createElement` rather than JSX keeps this a `.ts` file.
134
- */ const AppBar = forwardRef((_0, _1)=>{
161
+ */ /**
162
+ * Has the page scrolled past where a pinned over-hero bar should turn solid?
163
+ * That is the announcement bar's height: until it has gone, the bar is still
164
+ * lying on the photo below it. Listens only for a bar that asked to be pinned
165
+ * over a hero; SSR and the first paint read "not yet".
166
+ */ export function useOverHeroSolid(enabled) {
167
+ const [solid, setSolid] = useState(false);
168
+ useEffect(()=>{
169
+ if (!enabled || typeof window === 'undefined') return undefined;
170
+ let frame = 0;
171
+ let pending = false;
172
+ const read = ()=>{
173
+ pending = false;
174
+ const announcement = parseFloat(getComputedStyle(document.documentElement).getPropertyValue('--aglyn-announcement-bar-height')) || 0;
175
+ setSolid(window.scrollY > announcement);
176
+ };
177
+ const schedule = ()=>{
178
+ if (pending) return;
179
+ pending = true;
180
+ frame = window.requestAnimationFrame(read);
181
+ };
182
+ read();
183
+ window.addEventListener('scroll', schedule, {
184
+ passive: true
185
+ });
186
+ window.addEventListener('resize', schedule);
187
+ return ()=>{
188
+ window.removeEventListener('scroll', schedule);
189
+ window.removeEventListener('resize', schedule);
190
+ if (pending) window.cancelAnimationFrame(frame);
191
+ };
192
+ }, [
193
+ enabled
194
+ ]);
195
+ return enabled && solid;
196
+ }
197
+ const AppBar = forwardRef((_0, _1)=>{
135
198
  let _ref = [
136
199
  _0,
137
200
  _1
@@ -140,9 +203,17 @@ ScrollAwareAppBar.displayName = 'AglynScrollAwareAppBar';
140
203
  "hideOnScroll",
141
204
  "overHero"
142
205
  ]), [ref] = _rest;
206
+ // Over a hero, Sticky and Fixed used to be silently ignored: the bar was
207
+ // made absolute and scrolled away with the photo (AGL-4200).
208
+ const pinned = Boolean(overHero) && (rest.position === 'sticky' || rest.position === 'fixed');
209
+ const solid = useOverHeroSolid(pinned);
143
210
  const props = overHero ? _extends({}, rest, {
144
211
  sx: withOverHeroSx(rest.sx)
145
- }) : rest;
212
+ }, pinned ? {
213
+ [OVER_HERO_PINNED_ATTRIBUTE]: ''
214
+ } : {}, solid ? {
215
+ [OVER_HERO_SOLID_ATTRIBUTE]: ''
216
+ } : {}) : rest;
146
217
  return shrinkOnScroll || hideOnScroll ? createElement(ScrollAwareAppBar, _extends({}, props, {
147
218
  shrink: Boolean(shrinkOnScroll),
148
219
  hide: Boolean(hideOnScroll),
@@ -183,7 +254,7 @@ export const schema = {
183
254
  },
184
255
  {
185
256
  name: 'overHero',
186
- description: 'On a page whose first band is set to run under the header, the bar ' + 'sits over that photo with no background and white words. Other ' + 'pages keep the bar as it is.',
257
+ description: 'On a page whose first band is set to run under the header, the bar ' + 'sits over that photo with no background and white words. A Sticky ' + 'or Fixed bar stays at the top and turns solid once the page ' + 'scrolls. Other pages keep the bar as it is.',
187
258
  component: Aglyn.FieldComponentType.SWITCH,
188
259
  label: 'Sit over a photo hero?'
189
260
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/mui/src/lib/components/app-bar.ts"],"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 { mdiPageLayoutHeader } from '@aglyn/shared-data-mdi'\nimport { ScrollReaction } from '@aglyn/shared-ui-jsx/components/scroll-reaction'\nimport MuiAppBar, { type AppBarProps } from '@mui/material/AppBar'\nimport { type SxProps, type Theme } from '@mui/material/styles'\nimport { createElement, forwardRef, type Ref } from 'react'\nimport { BUNDLE_ID } from '../constants/bundle-common'\nimport {\n applySemanticElement,\n semanticElementAttribute,\n semanticElementLabelAttribute,\n} from '../utils/element-picker'\nimport { FIELD_COLOR_ALT1, FIELD_POSITION } from '../constants/field-presets'\nimport { dropClearedProps } from '../utils/drop-cleared-props'\nimport { generatePresetId } from '../utils/generate-preset-id'\nimport { UNDER_HEADER_ATTRIBUTE } from './section'\nimport { ID as toolbarId } from './toolbar'\n\nexport interface AglynAppBarProps extends AppBarProps {\n /**\n * Compacts the bar's Toolbar Content to the dense height once the page\n * has scrolled, and back at the top. Meant for a pinned (sticky/fixed)\n * bar, where the full height costs the reader a band of every screen.\n */\n shrinkOnScroll?: boolean\n /**\n * Slides the bar up out of view while the visitor scrolls down, and back\n * the moment they scroll up. Meant for a pinned (sticky/fixed) bar.\n */\n hideOnScroll?: boolean\n /**\n * Sits over a photo hero (AGL-3660): on a page whose first band runs under\n * the header (a Section with `underHeader`), the bar lies over that band\n * with no background of its own and its words in white, and scrolls away\n * with it; on every other page it is the bar it always was.\n */\n overHero?: boolean\n}\n\n/**\n * Over a page that opens under the header, the bar lies on the photo. One\n * rule the browser applies by what the page holds, so the server render, the\n * published page and every page of a layout share one class, and a page\n * without such a band is untouched.\n */\nexport const overHeroSx = (theme: Theme) => ({\n [`body:has([${UNDER_HEADER_ATTRIBUTE}]) &`]: {\n position: 'absolute',\n // Below the owner's admin bar and the site's announcement bar when they\n // are up (each publishes its live height on `<html>`), at the very top\n // otherwise. Absolute to the initial containing block, nothing in flow\n // moves this header — the variables are what do (AGL-3660, AGL-4176).\n top: 'calc(var(--aglyn-admin-bar-height, 0px) + var(--aglyn-announcement-bar-height, 0px))',\n left: 0,\n right: 0,\n backgroundColor: 'transparent',\n backgroundImage: 'none',\n boxShadow: 'none',\n borderBottom: 0,\n color: theme.palette.common.white,\n },\n})\n\nfunction withOverHeroSx(sx: AppBarProps['sx']): AppBarProps['sx'] {\n return [overHeroSx, ...(Array.isArray(sx) ? sx : [sx])] as AppBarProps['sx']\n}\n\n/** Scroll distance before a shrinking bar compacts. */\nconst SHRINK_THRESHOLD = 16\n/** Scroll distance before a hiding bar may slide away — past its own height. */\nconst HIDE_THRESHOLD = 120\n\n/**\n * Both scroll states ride data attributes, not a re-styled sx, so the\n * server render and every scroll position share one emotion class.\n */\nconst scrollSx: SxProps<Theme> = (theme) => ({\n transition: theme.transitions.create(['transform', 'box-shadow'], {\n duration: theme.transitions.duration.shorter,\n }),\n '& .MuiToolbar-root': {\n transition: theme.transitions.create('min-height', {\n duration: theme.transitions.duration.shorter,\n }),\n },\n '&[data-scrolled] .MuiToolbar-root': {\n // MUI's dense toolbar height.\n minHeight: theme.spacing(6),\n },\n '&[data-scroll-hidden]': {\n transform: 'translateY(-100%)',\n },\n})\n\nfunction withScrollSx(sx: AppBarProps['sx']): AppBarProps['sx'] {\n return [scrollSx, ...(Array.isArray(sx) ? sx : [sx])] as AppBarProps['sx']\n}\n\nfunction renderAppBar(props: AppBarProps, ref: Ref<HTMLElement>) {\n return createElement(MuiAppBar, {\n // Unset leaves MUI's own default, which is `header` — the banner\n // landmark every site's chrome depends on (AGL-2525). A resolver that\n // answered `div` for \"unset\" would have stripped it the moment the\n // picker appeared.\n ...applySemanticElement(dropClearedProps(props) as Record<string, unknown>),\n ref,\n })\n}\n\ninterface ScrollAwareAppBarProps extends AppBarProps {\n shrink: boolean\n hide: boolean\n}\n\n/**\n * Its own component so the scroll listeners exist only on a bar that asked\n * to react — a hook behind a prop check would break the rules of hooks.\n * `ScrollReaction` answers both questions: past the threshold (shrink),\n * and scrolling down rather than up (hide), which is what MUI's scroll\n * trigger means by hysteresis.\n */\nconst ScrollAwareAppBar = forwardRef<HTMLElement, ScrollAwareAppBarProps>(\n ({ shrink, hide, ...props }, ref) =>\n createElement(ScrollReaction, {\n threshold: SHRINK_THRESHOLD,\n withHysteresis: { threshold: HIDE_THRESHOLD },\n children: ({ activeWithHysteresis, activeWithoutHysteresis }) =>\n renderAppBar(\n {\n ...props,\n sx: withScrollSx(props.sx),\n ...({\n 'data-scrolled':\n shrink && activeWithoutHysteresis ? '' : undefined,\n 'data-scroll-hidden':\n hide && activeWithHysteresis ? '' : undefined,\n } as AppBarProps),\n },\n ref,\n ),\n }),\n)\nScrollAwareAppBar.displayName = 'AglynScrollAwareAppBar'\n\n/**\n * MUI's AppBar behind the cleared-prop guard (AGL-1226).\n *\n * It was exported raw, which left BOTH of its authorable attributes exposed:\n * `color` and `position` are each run through MUI's `capitalize`, so clearing\n * either one persists a null that throws during SSR and 500s the page. A\n * wrapper is the only place to intercept it, since the schema's props reach\n * MUI directly. `createElement` rather than JSX keeps this a `.ts` file.\n */\nconst AppBar = forwardRef<HTMLElement, AglynAppBarProps>(\n ({ shrinkOnScroll, hideOnScroll, overHero, ...rest }, ref) => {\n const props = overHero ? { ...rest, sx: withOverHeroSx(rest.sx) } : rest\n return shrinkOnScroll || hideOnScroll\n ? createElement(ScrollAwareAppBar, {\n ...props,\n shrink: Boolean(shrinkOnScroll),\n hide: Boolean(hideOnScroll),\n ref,\n })\n : renderAppBar(props, ref)\n },\n)\nAppBar.displayName = 'AglynAppBar'\n\n// Component ids are persisted in screen documents; keep the legacy ids.\nexport const ID: Aglyn.ComponentId = 'muiAppBar'\n\nexport const schema: Aglyn.ComponentSchema<AglynAppBarProps> = {\n $id: ID,\n pluginId: BUNDLE_ID,\n displayName: 'App Bar',\n description:\n 'The bar across the top of the site — put a Toolbar Content inside it.',\n category: Aglyn.ComponentCategory.NAVIGATION,\n icon: {\n path: mdiPageLayoutHeader.path,\n sx: { color: '#2196f3' },\n },\n attributes: [\n semanticElementAttribute('this bar'),\n semanticElementLabelAttribute(),\n FIELD_COLOR_ALT1,\n FIELD_POSITION,\n {\n name: 'shrinkOnScroll',\n description:\n 'Compacts the bar to the dense height once the page scrolls, and ' +\n 'restores it at the top. Pair with a Sticky or Fixed position.',\n component: Aglyn.FieldComponentType.SWITCH,\n label: 'Shrink when scrolled?',\n },\n {\n name: 'hideOnScroll',\n description:\n 'Slides the bar up out of view while the visitor scrolls down, and ' +\n 'back as soon as they scroll up. Pair with a Sticky or Fixed position.',\n component: Aglyn.FieldComponentType.SWITCH,\n label: 'Hide while scrolling down?',\n },\n {\n name: 'overHero',\n description:\n 'On a page whose first band is set to run under the header, the bar ' +\n 'sits over that photo with no background and white words. Other ' +\n 'pages keep the bar as it is.',\n component: Aglyn.FieldComponentType.SWITCH,\n label: 'Sit over a photo hero?',\n },\n ],\n}\n\nexport const presets: Aglyn.PresetSchema[] = [\n {\n $id: generatePresetId(ID),\n type: Aglyn.NodeType.PRESET,\n displayName: 'App Bar',\n pluginId: BUNDLE_ID,\n description: 'An app bar preset with the app bar and toolbar content nodes',\n category: Aglyn.ComponentCategory.NAVIGATION,\n icon: schema.icon,\n data: {\n $id: null,\n componentId: ID,\n pluginId: BUNDLE_ID,\n nodes: [\n {\n $id: null,\n componentId: toolbarId,\n pluginId: BUNDLE_ID,\n props: {},\n },\n ],\n },\n },\n]\n\nexport default AppBar\n"],"names":["Aglyn","mdiPageLayoutHeader","ScrollReaction","MuiAppBar","createElement","forwardRef","BUNDLE_ID","applySemanticElement","semanticElementAttribute","semanticElementLabelAttribute","FIELD_COLOR_ALT1","FIELD_POSITION","dropClearedProps","generatePresetId","UNDER_HEADER_ATTRIBUTE","ID","toolbarId","overHeroSx","theme","position","top","left","right","backgroundColor","backgroundImage","boxShadow","borderBottom","color","palette","common","white","withOverHeroSx","sx","Array","isArray","SHRINK_THRESHOLD","HIDE_THRESHOLD","scrollSx","transition","transitions","create","duration","shorter","minHeight","spacing","transform","withScrollSx","renderAppBar","props","ref","ScrollAwareAppBar","shrink","hide","threshold","withHysteresis","children","activeWithHysteresis","activeWithoutHysteresis","undefined","displayName","AppBar","shrinkOnScroll","hideOnScroll","overHero","rest","Boolean","schema","$id","pluginId","description","category","ComponentCategory","NAVIGATION","icon","path","attributes","name","component","FieldComponentType","SWITCH","label","presets","type","NodeType","PRESET","data","componentId","nodes"],"mappings":";;AAAA;;;;;;;;;;;;;;;CAeC,GAED,YAAYA,WAAW,eAAc;AACrC,SAASC,mBAAmB,QAAQ,yBAAwB;AAC5D,SAASC,cAAc,QAAQ,kDAAiD;AAChF,OAAOC,eAAqC,uBAAsB;AAElE,SAASC,aAAa,EAAEC,UAAU,QAAkB,QAAO;AAC3D,SAASC,SAAS,QAAQ,gCAA4B;AACtD,SACEC,oBAAoB,EACpBC,wBAAwB,EACxBC,6BAA6B,QACxB,6BAAyB;AAChC,SAASC,gBAAgB,EAAEC,cAAc,QAAQ,gCAA4B;AAC7E,SAASC,gBAAgB,QAAQ,iCAA6B;AAC9D,SAASC,gBAAgB,QAAQ,iCAA6B;AAC9D,SAASC,sBAAsB,QAAQ,eAAW;AAClD,SAASC,MAAMC,SAAS,QAAQ,eAAW;AAuB3C;;;;;CAKC,GACD,OAAO,MAAMC,aAAa,CAACC,QAAkB,CAAA;QAC3C,CAAC,CAAC,UAAU,EAAEJ,uBAAuB,IAAI,CAAC,CAAC,EAAE;YAC3CK,UAAU;YACV,wEAAwE;YACxE,uEAAuE;YACvE,uEAAuE;YACvE,sEAAsE;YACtEC,KAAK;YACLC,MAAM;YACNC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BE;QACtBmE,MAAMlF,MAAMmF,QAAQ,CAACC,MAAM;QAC3BzB,aAAa;QACbS,UAAU9D;QACV+D,aAAa;QACbC,UAAUtE,MAAMuE,iBAAiB,CAACC,UAAU;QAC5CC,MAAMP,OAAOO,IAAI;QACjBY,MAAM;YACJlB,KAAK;YACLmB,aAAavE;YACbqD,UAAU9D;YACViF,OAAO;gBACL;oBACEpB,KAAK;oBACLmB,aAAatE;oBACboD,UAAU9D;oBACV0C,OAAO,CAAC;gBACV;aACD;QACH;IACF;CACD,CAAA;AAED,eAAeY,OAAM"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/mui/src/lib/components/app-bar.ts"],"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 { mdiPageLayoutHeader } from '@aglyn/shared-data-mdi'\nimport { ScrollReaction } from '@aglyn/shared-ui-jsx/components/scroll-reaction'\nimport MuiAppBar, { type AppBarProps } from '@mui/material/AppBar'\nimport { type SxProps, type Theme } from '@mui/material/styles'\nimport { createElement, forwardRef, useEffect, useState, type Ref } from 'react'\nimport { BUNDLE_ID } from '../constants/bundle-common'\nimport {\n applySemanticElement,\n semanticElementAttribute,\n semanticElementLabelAttribute,\n} from '../utils/element-picker'\nimport { FIELD_COLOR_ALT1, FIELD_POSITION } from '../constants/field-presets'\nimport { dropClearedProps } from '../utils/drop-cleared-props'\nimport { generatePresetId } from '../utils/generate-preset-id'\nimport { UNDER_HEADER_ATTRIBUTE } from './section'\nimport { ID as toolbarId } from './toolbar'\n\nexport interface AglynAppBarProps extends AppBarProps {\n /**\n * Compacts the bar's Toolbar Content to the dense height once the page\n * has scrolled, and back at the top. Meant for a pinned (sticky/fixed)\n * bar, where the full height costs the reader a band of every screen.\n */\n shrinkOnScroll?: boolean\n /**\n * Slides the bar up out of view while the visitor scrolls down, and back\n * the moment they scroll up. Meant for a pinned (sticky/fixed) bar.\n */\n hideOnScroll?: boolean\n /**\n * Sits over a photo hero (AGL-3660): on a page whose first band runs under\n * the header (a Section with `underHeader`), the bar lies over that band\n * with no background of its own and its words in white. A Sticky or Fixed\n * bar stays pinned and turns back into its own solid self once the page\n * has scrolled (`OVER_HERO_SOLID_ATTRIBUTE`); any other bar scrolls away\n * with the band. On every other page it is the bar it always was.\n */\n overHero?: boolean\n}\n\n/**\n * Set on an over-hero bar that is pinned (Sticky or Fixed), and on one that\n * has scrolled past the top and turned solid. A logo that swaps to a white\n * version over the photo reads the second one to swap back:\n * `body:has([data-aglyn-under-header]) header:not([data-over-hero-solid]) &`.\n */\nexport const OVER_HERO_PINNED_ATTRIBUTE = 'data-over-hero-pinned'\nexport const OVER_HERO_SOLID_ATTRIBUTE = 'data-over-hero-solid'\n\n/**\n * Over a page that opens under the header, the bar lies on the photo. One\n * rule the browser applies by what the page holds, so the server render, the\n * published page and every page of a layout share one class, and a page\n * without such a band is untouched.\n */\nexport const overHeroSx = (theme: Theme) => ({\n [`body:has([${UNDER_HEADER_ATTRIBUTE}]) &`]: {\n position: 'absolute',\n // Below the owner's admin bar and the site's announcement bar when they\n // are up (each publishes its live height on `<html>`), at the very top\n // otherwise. Absolute to the initial containing block, nothing in flow\n // moves this header — the variables are what do (AGL-3660, AGL-4176).\n top: 'calc(var(--aglyn-admin-bar-height, 0px) + var(--aglyn-announcement-bar-height, 0px))',\n left: 0,\n right: 0,\n transition: theme.transitions.create(\n ['background-color', 'color', 'box-shadow', 'border-color'],\n { duration: theme.transitions.duration.shorter },\n ),\n },\n // Clear over the photo until a pinned bar turns solid.\n [`body:has([${UNDER_HEADER_ATTRIBUTE}]) &:not([${OVER_HERO_SOLID_ATTRIBUTE}])`]: {\n backgroundColor: 'transparent',\n backgroundImage: 'none',\n boxShadow: 'none',\n borderBottomColor: 'transparent',\n color: theme.palette.common.white,\n },\n // A Sticky or Fixed bar, once the announcement bar has scrolled away,\n // pins to the top as the bar it is on every other page: its own\n // background, colors and border, which the rule above no longer clears.\n // The switch happens exactly where the absolute bar reaches the top, so\n // nothing jumps.\n [`body:has([${UNDER_HEADER_ATTRIBUTE}]) &[${OVER_HERO_PINNED_ATTRIBUTE}][${OVER_HERO_SOLID_ATTRIBUTE}]`]: {\n position: 'fixed',\n top: 'var(--aglyn-admin-bar-height, 0px)',\n },\n})\n\nfunction withOverHeroSx(sx: AppBarProps['sx']): AppBarProps['sx'] {\n return [overHeroSx, ...(Array.isArray(sx) ? sx : [sx])] as AppBarProps['sx']\n}\n\n/** Scroll distance before a shrinking bar compacts. */\nconst SHRINK_THRESHOLD = 16\n/** Scroll distance before a hiding bar may slide away — past its own height. */\nconst HIDE_THRESHOLD = 120\n\n/**\n * Both scroll states ride data attributes, not a re-styled sx, so the\n * server render and every scroll position share one emotion class.\n */\nconst scrollSx: SxProps<Theme> = (theme) => ({\n transition: theme.transitions.create(['transform', 'box-shadow'], {\n duration: theme.transitions.duration.shorter,\n }),\n '& .MuiToolbar-root': {\n transition: theme.transitions.create('min-height', {\n duration: theme.transitions.duration.shorter,\n }),\n },\n '&[data-scrolled] .MuiToolbar-root': {\n // MUI's dense toolbar height.\n minHeight: theme.spacing(6),\n },\n '&[data-scroll-hidden]': {\n transform: 'translateY(-100%)',\n },\n})\n\nfunction withScrollSx(sx: AppBarProps['sx']): AppBarProps['sx'] {\n return [scrollSx, ...(Array.isArray(sx) ? sx : [sx])] as AppBarProps['sx']\n}\n\nfunction renderAppBar(props: AppBarProps, ref: Ref<HTMLElement>) {\n return createElement(MuiAppBar, {\n // Unset leaves MUI's own default, which is `header` — the banner\n // landmark every site's chrome depends on (AGL-2525). A resolver that\n // answered `div` for \"unset\" would have stripped it the moment the\n // picker appeared.\n ...applySemanticElement(dropClearedProps(props) as Record<string, unknown>),\n ref,\n })\n}\n\ninterface ScrollAwareAppBarProps extends AppBarProps {\n shrink: boolean\n hide: boolean\n}\n\n/**\n * Its own component so the scroll listeners exist only on a bar that asked\n * to react — a hook behind a prop check would break the rules of hooks.\n * `ScrollReaction` answers both questions: past the threshold (shrink),\n * and scrolling down rather than up (hide), which is what MUI's scroll\n * trigger means by hysteresis.\n */\nconst ScrollAwareAppBar = forwardRef<HTMLElement, ScrollAwareAppBarProps>(\n ({ shrink, hide, ...props }, ref) =>\n createElement(ScrollReaction, {\n threshold: SHRINK_THRESHOLD,\n withHysteresis: { threshold: HIDE_THRESHOLD },\n children: ({ activeWithHysteresis, activeWithoutHysteresis }) =>\n renderAppBar(\n {\n ...props,\n sx: withScrollSx(props.sx),\n ...({\n 'data-scrolled':\n shrink && activeWithoutHysteresis ? '' : undefined,\n 'data-scroll-hidden':\n hide && activeWithHysteresis ? '' : undefined,\n } as AppBarProps),\n },\n ref,\n ),\n }),\n)\nScrollAwareAppBar.displayName = 'AglynScrollAwareAppBar'\n\n/**\n * MUI's AppBar behind the cleared-prop guard (AGL-1226).\n *\n * It was exported raw, which left BOTH of its authorable attributes exposed:\n * `color` and `position` are each run through MUI's `capitalize`, so clearing\n * either one persists a null that throws during SSR and 500s the page. A\n * wrapper is the only place to intercept it, since the schema's props reach\n * MUI directly. `createElement` rather than JSX keeps this a `.ts` file.\n */\n/**\n * Has the page scrolled past where a pinned over-hero bar should turn solid?\n * That is the announcement bar's height: until it has gone, the bar is still\n * lying on the photo below it. Listens only for a bar that asked to be pinned\n * over a hero; SSR and the first paint read \"not yet\".\n */\nexport function useOverHeroSolid(enabled: boolean): boolean {\n const [solid, setSolid] = useState(false)\n useEffect(() => {\n if (!enabled || typeof window === 'undefined') return undefined\n let frame = 0\n let pending = false\n const read = () => {\n pending = false\n const announcement =\n parseFloat(\n getComputedStyle(document.documentElement).getPropertyValue(\n '--aglyn-announcement-bar-height',\n ),\n ) || 0\n setSolid(window.scrollY > announcement)\n }\n const schedule = () => {\n if (pending) return\n pending = true\n frame = window.requestAnimationFrame(read)\n }\n read()\n window.addEventListener('scroll', schedule, { passive: true })\n window.addEventListener('resize', schedule)\n return () => {\n window.removeEventListener('scroll', schedule)\n window.removeEventListener('resize', schedule)\n if (pending) window.cancelAnimationFrame(frame)\n }\n }, [enabled])\n return enabled && solid\n}\n\nconst AppBar = forwardRef<HTMLElement, AglynAppBarProps>(\n ({ shrinkOnScroll, hideOnScroll, overHero, ...rest }, ref) => {\n // Over a hero, Sticky and Fixed used to be silently ignored: the bar was\n // made absolute and scrolled away with the photo (AGL-4200).\n const pinned =\n Boolean(overHero) &&\n (rest.position === 'sticky' || rest.position === 'fixed')\n const solid = useOverHeroSolid(pinned)\n const props = overHero\n ? ({\n ...rest,\n sx: withOverHeroSx(rest.sx),\n ...(pinned ? { [OVER_HERO_PINNED_ATTRIBUTE]: '' } : {}),\n ...(solid ? { [OVER_HERO_SOLID_ATTRIBUTE]: '' } : {}),\n } as AppBarProps)\n : rest\n return shrinkOnScroll || hideOnScroll\n ? createElement(ScrollAwareAppBar, {\n ...props,\n shrink: Boolean(shrinkOnScroll),\n hide: Boolean(hideOnScroll),\n ref,\n })\n : renderAppBar(props, ref)\n },\n)\nAppBar.displayName = 'AglynAppBar'\n\n// Component ids are persisted in screen documents; keep the legacy ids.\nexport const ID: Aglyn.ComponentId = 'muiAppBar'\n\nexport const schema: Aglyn.ComponentSchema<AglynAppBarProps> = {\n $id: ID,\n pluginId: BUNDLE_ID,\n displayName: 'App Bar',\n description:\n 'The bar across the top of the site — put a Toolbar Content inside it.',\n category: Aglyn.ComponentCategory.NAVIGATION,\n icon: {\n path: mdiPageLayoutHeader.path,\n sx: { color: '#2196f3' },\n },\n attributes: [\n semanticElementAttribute('this bar'),\n semanticElementLabelAttribute(),\n FIELD_COLOR_ALT1,\n FIELD_POSITION,\n {\n name: 'shrinkOnScroll',\n description:\n 'Compacts the bar to the dense height once the page scrolls, and ' +\n 'restores it at the top. Pair with a Sticky or Fixed position.',\n component: Aglyn.FieldComponentType.SWITCH,\n label: 'Shrink when scrolled?',\n },\n {\n name: 'hideOnScroll',\n description:\n 'Slides the bar up out of view while the visitor scrolls down, and ' +\n 'back as soon as they scroll up. Pair with a Sticky or Fixed position.',\n component: Aglyn.FieldComponentType.SWITCH,\n label: 'Hide while scrolling down?',\n },\n {\n name: 'overHero',\n description:\n 'On a page whose first band is set to run under the header, the bar ' +\n 'sits over that photo with no background and white words. A Sticky ' +\n 'or Fixed bar stays at the top and turns solid once the page ' +\n 'scrolls. Other pages keep the bar as it is.',\n component: Aglyn.FieldComponentType.SWITCH,\n label: 'Sit over a photo hero?',\n },\n ],\n}\n\nexport const presets: Aglyn.PresetSchema[] = [\n {\n $id: generatePresetId(ID),\n type: Aglyn.NodeType.PRESET,\n displayName: 'App Bar',\n pluginId: BUNDLE_ID,\n description: 'An app bar preset with the app bar and toolbar content nodes',\n category: Aglyn.ComponentCategory.NAVIGATION,\n icon: schema.icon,\n data: {\n $id: null,\n componentId: ID,\n pluginId: BUNDLE_ID,\n nodes: [\n {\n $id: null,\n componentId: toolbarId,\n pluginId: BUNDLE_ID,\n props: {},\n },\n ],\n },\n },\n]\n\nexport default AppBar\n"],"names":["Aglyn","mdiPageLayoutHeader","ScrollReaction","MuiAppBar","createElement","forwardRef","useEffect","useState","BUNDLE_ID","applySemanticElement","semanticElementAttribute","semanticElementLabelAttribute","FIELD_COLOR_ALT1","FIELD_POSITION","dropClearedProps","generatePresetId","UNDER_HEADER_ATTRIBUTE","ID","toolbarId","OVER_HERO_PINNED_ATTRIBUTE","OVER_HERO_SOLID_ATTRIBUTE","overHeroSx","theme","position","top","left","right","transition","transitions","create","duration","shorter","backgroundColor","backgroundImage","boxShadow","borderBottomColor","color","palette","common","white","withOverHeroSx","sx","Array","isArray","SHRINK_THRESHOLD","HIDE_THRESHOLD","scrollSx","minHeight","spacing","transform","withScrollSx","renderAppBar","props","ref","ScrollAwareAppBar","shrink","hide","threshold","withHysteresis","children","activeWithHysteresis","activeWithoutHysteresis","undefined","displayName","useOverHeroSolid","enabled","solid","setSolid","window","frame","pending","read","announcement","parseFloat","getComputedStyle","document","documentElement","getPropertyValue","scrollY","schedule","requestAnimationFrame","addEventListener","passive","removeEventListener","cancelAnimationFrame","AppBar","shrinkOnScroll","hideOnScroll","overHero","rest","pinned","Boolean","schema","$id","pluginId","description","category","ComponentCategory","NAVIGATION","icon","path","attributes","name","component","FieldComponentType","SWITCH","label","presets","type","NodeType","PRESET","data","componentId","nodes"],"mappings":";;AAAA;;;;;;;;;;;;;;;CAeC,GAED,YAAYA,WAAW,eAAc;AACrC,SAASC,mBAAmB,QAAQ,yBAAwB;AAC5D,SAASC,cAAc,QAAQ,kDAAiD;AAChF,OAAOC,eAAqC,uBAAsB;AAElE,SAASC,aAAa,EAAEC,UAAU,EAAEC,SAAS,EAAEC,QAAQ,QAAkB,QAAO;AAChF,SAASC,SAAS,QAAQ,gCAA4B;AACtD,SACEC,oBAAoB,EACpBC,wBAAwB,EACxBC,6BAA6B,QACxB,6BAAyB;AAChC,SAASC,gBAAgB,EAAEC,cAAc,QAAQ,gCAA4B;AAC7E,SAASC,gBAAgB,QAAQ,iCAA6B;AAC9D,SAASC,gBAAgB,QAAQ,iCAA6B;AAC9D,SAASC,sBAAsB,QAAQ,eAAW;AAClD,SAASC,MAAMC,SAAS,QAAQ,eAAW;AAyB3C;;;;;CAKC,GACD,OAAO,MAAMC,6BAA6B,wBAAuB;AACjE,OAAO,MAAMC,4BAA4B,uBAAsB;AAE/D;;;;;CAKC,GACD,OAAO,MAAMC,aAAa,CAACC,QAAkB,CAAA;QAC3C,CAAC,CAAC,UAAU,EAAEN,uBAAuB,IAAI,CAAC,CAAC,EAAE;YAC3CO,UAAU;YACV,wEAAwE;YACxE,uEAAuE;YACvE,uEAAuE;YACvE,sEAAsE;YACtEC,KAAK;YAC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AAM;YACNP,aACE,uEACA;YACFQ,WAAWvG,MAAMwG,kBAAkB,CAACC,MAAM;YAC1CC,OAAO;QACT;QACA;YACEJ,MAAM;YACNP,aACE,wEACA,uEACA,iEACA;YACFQ,WAAWvG,MAAMwG,kBAAkB,CAACC,MAAM;YAC1CC,OAAO;QACT;KACD;AACH,EAAC;AAED,OAAO,MAAMC,UAAgC;IAC3C;QACEd,KAAK9E,iBAAiBE;QACtB2F,MAAM5G,MAAM6G,QAAQ,CAACC,MAAM;QAC3B/C,aAAa;QACb+B,UAAUtF;QACVuF,aAAa;QACbC,UAAUhG,MAAMiG,iBAAiB,CAACC,UAAU;QAC5CC,MAAMP,OAAOO,IAAI;QACjBY,MAAM;YACJlB,KAAK;YACLmB,aAAa/F;YACb6E,UAAUtF;YACVyG,OAAO;gBACL;oBACEpB,KAAK;oBACLmB,aAAa9F;oBACb4E,UAAUtF;oBACV4C,OAAO,CAAC;gBACV;aACD;QACH;IACF;CACD,CAAA;AAED,eAAeiC,OAAM"}
@@ -46,6 +46,32 @@ export interface MegaMenuProps {
46
46
  * SSR markup is stable.
47
47
  */
48
48
  export declare function megaMenuPanelSx(panelWidth: MegaMenuPanelWidth): SxProps;
49
+ /** How far a dropdown panel keeps from the window's edges, in px. */
50
+ export declare const PANEL_EDGE_MARGIN = 16;
51
+ /** The gap between a trigger and its open panel, in px. */
52
+ export declare const PANEL_GAP = 8;
53
+ /** Where an open panel must move to sit inside the window, and how tall it may be. */
54
+ export interface PanelFit {
55
+ /** Horizontal nudge in px, applied on top of the panel's own placement. */
56
+ shift: number;
57
+ /** The most the panel may be before it scrolls inside itself, or null. */
58
+ maxHeight: number | null;
59
+ }
60
+ /**
61
+ * Keeps an open panel inside the window (AGL-4200). A wide or full panel is
62
+ * centered under its trigger with CSS alone, which runs it off the left edge
63
+ * when the trigger sits near it; a left-anchored one can run off the right.
64
+ * `left` and `width` are the panel as placed, before any nudge.
65
+ */
66
+ export declare function fitPanel(rect: {
67
+ left: number;
68
+ top: number;
69
+ width: number;
70
+ height: number;
71
+ }, viewport: {
72
+ width: number;
73
+ height: number;
74
+ }, margin?: number): PanelFit;
49
75
  /**
50
76
  * Dropdown nav item (AGL-562): a labeled nav button whose children —
51
77
  * screen links, buttons, anything — open in a dropdown panel. Clicking
@@ -25,7 +25,7 @@ import ClickAwayListener from "@mui/material/ClickAwayListener";
25
25
  import Paper from "@mui/material/Paper";
26
26
  import Stack from "@mui/material/Stack";
27
27
  import Typography from "@mui/material/Typography";
28
- import { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from "react";
28
+ import { forwardRef, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
29
29
  import { BUNDLE_ID } from "../constants/bundle-common.js";
30
30
  import { generatePresetId } from "../utils/generate-preset-id.js";
31
31
  import { isLeafSelectedWithin, parseLeafNodeId } from "./drawer.js";
@@ -117,6 +117,31 @@ export const MEGA_MENU_ID = 'muiMegaMenu';
117
117
  marginRight: 0
118
118
  }
119
119
  };
120
+ /** How far a dropdown panel keeps from the window's edges, in px. */ export const PANEL_EDGE_MARGIN = 16;
121
+ /** The gap between a trigger and its open panel, in px. */ export const PANEL_GAP = 8;
122
+ /**
123
+ * Keeps an open panel inside the window (AGL-4200). A wide or full panel is
124
+ * centered under its trigger with CSS alone, which runs it off the left edge
125
+ * when the trigger sits near it; a left-anchored one can run off the right.
126
+ * `left` and `width` are the panel as placed, before any nudge.
127
+ */ export function fitPanel(rect, viewport, margin = PANEL_EDGE_MARGIN) {
128
+ const room = viewport.width - margin * 2;
129
+ let shift = 0;
130
+ if (rect.width >= room) {
131
+ // Wider than the window allows: center it on the window.
132
+ shift = (viewport.width - rect.width) / 2 - rect.left;
133
+ } else if (rect.left < margin) {
134
+ shift = margin - rect.left;
135
+ } else if (rect.left + rect.width > viewport.width - margin) {
136
+ shift = viewport.width - margin - (rect.left + rect.width);
137
+ }
138
+ const available = Math.floor(viewport.height - rect.top - margin);
139
+ const maxHeight = rect.height > available && available > 160 ? available : null;
140
+ return {
141
+ shift: Math.round(shift),
142
+ maxHeight
143
+ };
144
+ }
120
145
  const MenuShell = /*#__PURE__*/ forwardRef((props, ref)=>{
121
146
  const { label, editorHint, panelSx, sx, children } = props, rest = _object_without_properties_loose(props, [
122
147
  "label",
@@ -132,6 +157,36 @@ const MenuShell = /*#__PURE__*/ forwardRef((props, ref)=>{
132
157
  ] : [];
133
158
  const { editorInert } = Aglyn.useScreenLink(undefined);
134
159
  const [open, setOpen] = useState(false);
160
+ const panelRef = useRef(null);
161
+ const [fit, setFit] = useState({
162
+ shift: 0,
163
+ maxHeight: null
164
+ });
165
+ // Measured once the panel is on screen and before it paints, so it never
166
+ // flashes off the edge. Placement is CSS; this only nudges it back inside.
167
+ useLayoutEffect(()=>{
168
+ if (!open) {
169
+ setFit({
170
+ shift: 0,
171
+ maxHeight: null
172
+ });
173
+ return;
174
+ }
175
+ const panel = panelRef.current;
176
+ if (!panel || typeof window === 'undefined') return;
177
+ const rect = panel.getBoundingClientRect();
178
+ setFit(fitPanel({
179
+ left: rect.left,
180
+ top: rect.top,
181
+ width: rect.width,
182
+ height: panel.scrollHeight
183
+ }, {
184
+ width: document.documentElement.clientWidth,
185
+ height: window.innerHeight
186
+ }));
187
+ }, [
188
+ open
189
+ ]);
135
190
  // True while the menu is open BECAUSE a hover interaction opened it —
136
191
  // only then does pointer leave close the menu.
137
192
  const hoverOpenRef = useRef(false);
@@ -296,14 +351,42 @@ const MenuShell = /*#__PURE__*/ forwardRef((props, ref)=>{
296
351
  children: label
297
352
  }),
298
353
  open ? /*#__PURE__*/ _jsx(Paper, {
354
+ ref: panelRef,
299
355
  elevation: 4,
300
356
  "aria-label": label,
357
+ style: _extends({}, fit.shift ? {
358
+ translate: `${fit.shift}px 0`
359
+ } : {}, fit.maxHeight ? {
360
+ maxHeight: fit.maxHeight,
361
+ overflowY: 'auto'
362
+ } : {}),
301
363
  sx: [
302
364
  {
303
365
  position: 'absolute',
304
- top: '100%',
366
+ top: `calc(100% + ${PANEL_GAP}px)`,
305
367
  zIndex: (theme)=>theme.zIndex.modal,
306
- p: 1
368
+ p: 1,
369
+ // A shadow alone vanishes on a dark theme or photo (AGL-4200).
370
+ border: 1,
371
+ borderColor: 'divider',
372
+ // The node's own styles are for its trigger, and they land on
373
+ // the wrapper this panel sits in. Without a reset an
374
+ // uppercase, letter-spaced or no-wrap nav item made every
375
+ // line of its panel the same (AGL-4200). Color needs no
376
+ // reset: Paper sets its own.
377
+ textTransform: 'none',
378
+ letterSpacing: 'normal',
379
+ whiteSpace: 'normal',
380
+ // The gap is still the menu: a pointer crossing it from the
381
+ // trigger stays inside, so a hover-opened menu stays open.
382
+ '&::before': {
383
+ content: '""',
384
+ position: 'absolute',
385
+ left: 0,
386
+ right: 0,
387
+ top: -PANEL_GAP - 1,
388
+ height: PANEL_GAP + 1
389
+ }
307
390
  },
308
391
  panelSx
309
392
  ],
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/mui/src/lib/components/nav-menu.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 { mdiChevronDown, mdiFormDropdown, mdiViewGridOutline } from '@aglyn/shared-data-mdi'\nimport { MdiIcon } from '@aglyn/shared-ui-jsx'\nimport Box, { type BoxProps } from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport ClickAwayListener from '@mui/material/ClickAwayListener'\nimport Paper from '@mui/material/Paper'\nimport Stack from '@mui/material/Stack'\nimport Typography from '@mui/material/Typography'\nimport {\n forwardRef,\n type KeyboardEvent,\n type ReactNode,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react'\nimport type { SxProps } from '@mui/material/styles'\nimport { BUNDLE_ID } from '../constants/bundle-common'\nimport { generatePresetId } from '../utils/generate-preset-id'\nimport { isLeafSelectedWithin, parseLeafNodeId } from './drawer'\n\n// Component ids are persisted in screen documents; never rename.\nexport const NAV_MENU_ID: Aglyn.ComponentId = 'muiNavMenu'\nexport const MEGA_MENU_ID: Aglyn.ComponentId = 'muiMegaMenu'\n\nexport type MegaMenuPanelWidth = 'auto' | 'wide' | 'full'\n\n/** Hover close grace period so the pointer can cross into the panel. */\nconst HOVER_CLOSE_DELAY_MS = 150\n\nexport interface NavMenuProps {\n /** Visible trigger text of the nav item. */\n label?: string\n /**\n * Authored node styles, handed over by the renderer rather than typed into\n * an attribute. It lands on the element root and the trigger inherits, which\n * is what lets an author override the default text transform (AGL-1198) —\n * so it has to be expressible by a typed caller too (AGL-1323).\n */\n sx?: SxProps\n children?: ReactNode\n}\n\nexport interface MegaMenuProps {\n label?: string\n /** Panel width preset: content-sized, wide (720px), or full-bleed. */\n panelWidth?: MegaMenuPanelWidth\n /** Authored node styles — see `NavMenuProps.sx`. */\n sx?: SxProps\n children?: ReactNode\n}\n\n/**\n * Mounted menus in mount order (AGL-568). Broadcast commands (no target\n * node id) are answered by the FIRST registered menu only, mirroring the\n * drawer bus, so a page with one menu needs no wiring at all.\n */\nconst mountedMenus: string[] = []\n\n/**\n * The panel sx per mega-menu width preset. Wide/full center under the\n * trigger with the 50%/translate trick, so no measuring is needed and\n * SSR markup is stable.\n */\nexport function megaMenuPanelSx(panelWidth: MegaMenuPanelWidth): SxProps {\n switch (panelWidth) {\n case 'full':\n return {\n width: '100vw',\n maxWidth: '100vw',\n left: '50%',\n transform: 'translateX(-50%)',\n borderRadius: 0,\n }\n case 'wide':\n return {\n width: 'min(90vw, 720px)',\n left: '50%',\n transform: 'translateX(-50%)',\n }\n default:\n return { minWidth: 280, left: 0 }\n }\n}\n\n/**\n * Shared dropdown shell (AGL-562, interactions-driven since AGL-568): a\n * trigger button plus an absolutely positioned panel inside a relative\n * wrapper. Keeping the panel inside the wrapper's DOM (no portal) makes\n * pointer leave of trigger + panel a single mouseleave and keeps SSR\n * hydration trivial — the panel simply isn't rendered until opened, so\n * the server ships a closed menu.\n *\n * Open/close behavior: clicking the trigger toggles the menu (the\n * zero-config default), and the interactions system drives it over the\n * menu command bus (`dispatchMenuCommand`) keyed by node id — e.g. \"On\n * hover → Open menu (this element)\". Hover-opened menus close on their\n * own when the pointer leaves the trigger + panel surface (with a short\n * grace period); click/command opens stay put until click-away, Escape,\n * or an explicit close.\n *\n * On the static besigner canvas (flagged by ScreenLinkContext.editorInert)\n * the menu mirrors the live site's collapsed state: just the trigger, no\n * panel (AGL-571). Only while the menu or one of its descendants is selected\n * (the renderer stamps `data-aglyn-selected-within` on the leaf) does the\n * panel expand inline, like form fields do, so its contents stay selectable\n * and editable without fighting a popup — and it collapses again the moment\n * selection leaves the subtree. The Preview surface is NOT inert (AGL-830):\n * it suppresses link navigation but runs interactions for real, so the menu\n * takes the live branch and opens on hover exactly like the tenant site.\n */\ninterface MenuShellProps extends BoxProps {\n label: string\n editorHint: string\n panelSx: SxProps\n}\n\n/**\n * Trigger typography (AGL-1198). A menu label sits in a nav beside plain\n * links, so it reads as navigation, not as a call to action — MUI's\n * uppercase Button transform shouts \"PRODUCT\" next to \"Pricing\". The\n * default lives on the WRAPPER and the Button inherits it, so an author\n * who does want uppercase can set it in STYLES → Typography on the\n * element and have it win; before this there was no way to change it at\n * all, because the Button is internal to the element.\n */\nconst TRIGGER_SHELL_SX = {\n position: 'relative',\n display: 'inline-flex',\n textTransform: 'none',\n} as const\n/**\n * The rest of the same argument, generalized (AGL-2542).\n *\n * `textTransform` was one symptom of a whole button's worth of them. The\n * trigger still arrived as a `Button`: 0.875rem where the links beside it\n * were 15px, `min-width: 64px` padding \"Docs\" out to a width its own text\n * never asked for, and `6px 8px` of padding widening the visual gap on two\n * items out of five. In a nav laid out on a flat gap, that is a rhythm one\n * element breaks and no author can fix — the Button is internal, so a font\n * size set in STYLES lands on the wrapper and MUI's own class outranks it.\n *\n * So every typographic property is handed back to the wrapper the same way\n * `textTransform` was, and the button chrome that has no meaning on a nav\n * item is dropped. The element now renders as what it is — a label in a nav\n * — and STYLES → Typography on it reaches the label, which is the control an\n * author was reaching for when they found there wasn't one.\n *\n * `endIcon`'s negative right margin goes with the padding it was tucking\n * into; left at -4px against zero padding, the chevron would hang outside\n * the element and break the gap it just stopped breaking.\n *\n * ⚠️ Padding is where the hover target came from, and a hover-opened menu is\n * only as reachable as its trigger. It belongs on the WRAPPER now — which is\n * both what an author can actually edit and what `onMouseLeave` measures, so\n * padding added there enlarges the target instead of merely looking like it.\n */\nconst TRIGGER_SX = {\n fontFamily: 'inherit',\n fontSize: 'inherit',\n fontWeight: 'inherit',\n lineHeight: 'inherit',\n letterSpacing: 'inherit',\n textTransform: 'inherit',\n color: 'inherit',\n minWidth: 0,\n padding: 0,\n '& .MuiButton-endIcon': { marginRight: 0 },\n} as const\n\nconst MenuShell = forwardRef<HTMLDivElement, MenuShellProps>((props, ref) => {\n const { label, editorHint, panelSx, sx, children, ...rest } = props\n // Node styles ride the sx prop the renderer merges; keep them by\n // composing with the shell's own layout sx (stack.ts pattern).\n const nodeSx = Array.isArray(sx) ? sx : sx ? [sx] : []\n const { editorInert } = Aglyn.useScreenLink(undefined)\n const [open, setOpen] = useState(false)\n // True while the menu is open BECAUSE a hover interaction opened it —\n // only then does pointer leave close the menu.\n const hoverOpenRef = useRef(false)\n const closeTimer = useRef<ReturnType<typeof setTimeout> | null>(null)\n // The renderer stamps the node id on every leaf; commands target it.\n const nodeId = useMemo(\n () => parseLeafNodeId((rest as Record<string, unknown>)['data-aglyn']),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [(rest as Record<string, unknown>)['data-aglyn']],\n )\n\n const cancelClose = useCallback(() => {\n if (closeTimer.current) {\n clearTimeout(closeTimer.current)\n closeTimer.current = null\n }\n }, [])\n const closeNow = useCallback(() => {\n cancelClose()\n hoverOpenRef.current = false\n setOpen(false)\n }, [cancelClose])\n const scheduleClose = useCallback(() => {\n cancelClose()\n closeTimer.current = setTimeout(closeNow, HOVER_CLOSE_DELAY_MS)\n }, [cancelClose, closeNow])\n\n // Menu command bus enrollment (AGL-568): mirrors the drawer exactly —\n // live surfaces only, keyed by node id, broadcasts answered by the\n // first mounted menu.\n useEffect(() => {\n if (editorInert || !nodeId) return undefined\n mountedMenus.push(nodeId)\n const unsubscribe = Aglyn.subscribeMenuCommands((detail) => {\n // Match on the un-namespaced suffix (AGL-573): a command authored on\n // a layout-scoped menu carries the raw canvas id while this menu's\n // live id is `layout__`-namespaced (or vice versa) — leafIdsMatch\n // compares them equal without re-authoring the persisted action.\n const targeted = detail.nodeId\n ? Aglyn.leafIdsMatch(detail.nodeId, nodeId)\n : mountedMenus[0] === nodeId\n if (!targeted) return\n cancelClose()\n if (detail.command === 'close') {\n hoverOpenRef.current = false\n setOpen(false)\n return\n }\n // open/toggle: remember hover provenance so pointer leave closes\n // hover-opened menus (and never click/command-opened ones).\n hoverOpenRef.current = Boolean(detail.hover)\n if (detail.command === 'open') setOpen(true)\n else setOpen((value) => !value)\n })\n return () => {\n unsubscribe()\n cancelClose()\n const index = mountedMenus.indexOf(nodeId)\n if (index >= 0) mountedMenus.splice(index, 1)\n }\n }, [editorInert, nodeId, cancelClose])\n\n if (editorInert) {\n // Editor affordance (AGL-571): collapsed trigger by default — exactly\n // what the live site shows — expanding to the editable panel only while\n // the menu subtree holds the selection.\n const authoring = isLeafSelectedWithin(rest as Record<string, unknown>)\n return (\n <Box\n ref={ref}\n {...rest}\n // Relative so the authoring panel drops UNDER the trigger as an\n // overlay (AGL-830). The old inline-block expanded the panel in the\n // toolbar's flow, shoving and overlapping the other nav items in a\n // horizontal app bar; positioning it like the live popup keeps the\n // bar intact while the panel stays selectable and editable in place.\n sx={[TRIGGER_SHELL_SX, ...nodeSx]}\n >\n <Button\n color=\"inherit\"\n aria-expanded={authoring || undefined}\n endIcon={<MdiIcon path={mdiChevronDown.path} />}\n sx={TRIGGER_SX}\n >\n {label}\n </Button>\n {authoring ? (\n <Paper\n elevation={4}\n aria-label={label}\n sx={[\n {\n position: 'absolute',\n top: '100%',\n mt: 0.5,\n zIndex: (theme) => theme.zIndex.modal,\n p: 1,\n border: '1px dashed',\n borderColor: 'divider',\n },\n panelSx as never,\n ]}\n >\n <Typography\n variant=\"caption\"\n color=\"text.secondary\"\n sx={{ display: 'block', mb: 0.5, px: 1 }}\n >\n {editorHint}\n </Typography>\n {children}\n </Paper>\n ) : null}\n </Box>\n )\n }\n\n return (\n <ClickAwayListener onClickAway={() => open && closeNow()}>\n <Box\n ref={ref}\n {...rest}\n // Hover-close choreography (AGL-568): the panel renders inside\n // this wrapper (no portal), so trigger + panel share one\n // enter/leave pair. Only hover-opened menus follow the pointer\n // out; enter always cancels a pending close so the pointer can\n // travel between trigger and panel.\n onMouseEnter={cancelClose}\n onMouseLeave={() => {\n if (hoverOpenRef.current) scheduleClose()\n }}\n onKeyDown={(event: KeyboardEvent) => {\n if (event.key === 'Escape') closeNow()\n }}\n sx={[TRIGGER_SHELL_SX, ...nodeSx]}\n >\n <Button\n color=\"inherit\"\n aria-haspopup=\"true\"\n aria-expanded={open || undefined}\n endIcon={<MdiIcon path={mdiChevronDown.path} />}\n sx={TRIGGER_SX}\n onClick={() => {\n // Zero-config default: the trigger click-toggles its menu;\n // a click also \"pins\" a hover-opened menu.\n cancelClose()\n hoverOpenRef.current = false\n setOpen((value) => !value)\n }}\n >\n {label}\n </Button>\n {open ? (\n <Paper\n elevation={4}\n aria-label={label}\n sx={[\n {\n position: 'absolute',\n top: '100%',\n zIndex: (theme) => theme.zIndex.modal,\n p: 1,\n },\n panelSx as never,\n ]}\n >\n {children}\n </Paper>\n ) : null}\n </Box>\n </ClickAwayListener>\n )\n})\nMenuShell.displayName = 'AglynMenuShell'\n\n/**\n * Strips the pre-AGL-568 \"Open on\" attribute persisted docs may still\n * carry. Behavior configuration rides the interactions system now; the\n * stored value is ignored silently — no migrations, no warnings — and\n * must never leak onto the DOM.\n */\nfunction stripLegacyTrigger(rest: Record<string, unknown>): void {\n delete rest['trigger']\n}\n\n/**\n * Dropdown nav item (AGL-562): a labeled nav button whose children —\n * screen links, buttons, anything — open in a dropdown panel. Clicking\n * the trigger toggles it; interactions drive it over the menu command\n * bus (AGL-568). SSR ships the menu closed; no window access happens at\n * render.\n */\nconst NavMenu = forwardRef<HTMLDivElement, NavMenuProps>((props, ref) => {\n const { label, children, ...rest } = props\n stripLegacyTrigger(rest as Record<string, unknown>)\n return (\n <MenuShell\n ref={ref}\n label={label || 'Menu'}\n editorHint=\"Dropdown items — shown in a menu on the live site\"\n panelSx={{ minWidth: 220, left: 0 }}\n {...rest}\n >\n <Stack spacing={0.5} sx={{ alignItems: 'stretch' }}>\n {children}\n </Stack>\n </MenuShell>\n )\n})\nNavMenu.displayName = 'AglynNavMenu'\n\n/**\n * Mega menu (AGL-562): a SaaS-style wide panel anchored under a nav\n * item with a free-form canvas slot — columns of links, promos,\n * whatever the author drops in. Click-toggles like the dropdown; the\n * SaaS hover-open convention is one interaction away (\"On hover → Open\n * menu\", AGL-568) and then closes itself on pointer leave.\n */\nexport const MegaMenu = forwardRef<HTMLDivElement, MegaMenuProps>(\n (props, ref) => {\n const { label, panelWidth, children, ...rest } = props\n stripLegacyTrigger(rest as Record<string, unknown>)\n return (\n <MenuShell\n ref={ref}\n label={label || 'Menu'}\n editorHint=\"Mega menu panel — opens under the nav item on the live site\"\n panelSx={{ p: 3, ...megaMenuPanelSx(panelWidth || 'auto') } as never}\n {...rest}\n >\n {children}\n </MenuShell>\n )\n },\n)\nMegaMenu.displayName = 'AglynMegaMenu'\n\nexport const navMenuSchema: Aglyn.ComponentSchema<NavMenuProps> = {\n $id: NAV_MENU_ID,\n pluginId: BUNDLE_ID,\n displayName: 'Dropdown Menu',\n description: 'A nav item that opens a dropdown of links beneath it.',\n category: Aglyn.ComponentCategory.NAVIGATION,\n icon: { path: mdiFormDropdown.path, sx: { color: '#2196f3' } },\n // Open/close behavior deliberately has NO attribute (AGL-568): click\n // toggles by default and everything else is authored as an\n // interaction (e.g. \"On hover → Open menu\").\n attributes: [\n {\n name: 'label',\n description: 'Text on the nav item that opens the dropdown.',\n component: Aglyn.FieldComponentType.TEXT_FIELD,\n label: 'Label',\n },\n ],\n}\n\nexport const megaMenuSchema: Aglyn.ComponentSchema<MegaMenuProps> = {\n $id: MEGA_MENU_ID,\n pluginId: BUNDLE_ID,\n displayName: 'Mega Menu',\n description:\n 'A nav item that opens a wide panel — columns of links, promos, whatever you build.',\n category: Aglyn.ComponentCategory.NAVIGATION,\n icon: { path: mdiViewGridOutline.path, sx: { color: '#2196f3' } },\n // Open/close behavior deliberately has NO attribute (AGL-568) — see\n // navMenuSchema.\n attributes: [\n {\n name: 'label',\n description: 'Text on the nav item that opens the panel.',\n component: Aglyn.FieldComponentType.TEXT_FIELD,\n label: 'Label',\n },\n {\n name: 'panelWidth',\n description: 'How wide the opened panel is.',\n component: Aglyn.FieldComponentType.SELECT,\n label: 'Panel width',\n // `auto` is the `MegaMenuPanelWidth` member `megaMenuPanelSx` already\n // switches on, so the sentinel names the case that existed in code\n // but not in the option list (AGL-1451); `''` could not persist\n // (AGL-1191), so a wide panel could not be narrowed again.\n options: [\n { value: 'auto', label: 'Fit content' },\n { value: 'wide', label: 'Wide (720px)' },\n { value: 'full', label: 'Full width' },\n ],\n },\n ],\n}\n\nconst navLink = (label: string) => ({\n $id: null,\n componentId: 'muiScreenLink',\n pluginId: BUNDLE_ID,\n props: { children: label, color: 'inherit' },\n})\n\nconst megaColumn = (title: string, links: string[]) => ({\n $id: null,\n componentId: 'muiStack',\n pluginId: BUNDLE_ID,\n props: { spacing: 0.5 },\n // Styling goes on the node's own sx, never in props (AGL-1346) — that is\n // the record the Styles panel edits.\n sx: { minWidth: 180, alignItems: 'flex-start' },\n nodes: [\n {\n $id: null,\n componentId: 'muiTypography',\n pluginId: BUNDLE_ID,\n props: { variant: 'overline', color: 'text.secondary', children: title },\n },\n ...links.map(navLink),\n ],\n})\n\nexport const navMenuPresets: Aglyn.PresetSchema[] = [\n {\n $id: generatePresetId(NAV_MENU_ID),\n type: Aglyn.NodeType.PRESET,\n displayName: 'Dropdown Menu',\n pluginId: BUNDLE_ID,\n description: 'Nav item that opens a dropdown of links',\n category: Aglyn.ComponentCategory.NAVIGATION,\n icon: navMenuSchema.icon,\n data: {\n $id: null,\n componentId: NAV_MENU_ID,\n pluginId: BUNDLE_ID,\n props: { label: 'More' },\n nodes: [navLink('About'), navLink('Blog'), navLink('Contact')],\n },\n },\n // Primitive dropdown scaffold (AGL-589): the same result as the menu\n // elements but built from a Stack + Button + hidden panel, with the\n // hover choreography (grace delay, Esc/outside-click dismissal)\n // pre-wired as real interactions the user can edit or remove. The\n // panel carries `aglyn-hidden` so it starts closed on the live site;\n // the canvas shows it for editing (the hidden style only injects at\n // runtime).\n {\n $id: generatePresetId('muiStack', 'dropdown-panel'),\n type: Aglyn.NodeType.PRESET,\n displayName: 'Dropdown Panel',\n pluginId: BUNDLE_ID,\n description:\n 'Trigger + hover panel built from primitives — opens on hover, ' +\n 'closes on leave with a grace delay, dismisses on Esc or outside ' +\n 'click; the wiring arrives as editable interactions',\n category: Aglyn.ComponentCategory.NAVIGATION,\n icon: { path: mdiFormDropdown.path, sx: { color: '#2196f3' } },\n data: {\n $id: null,\n presetRef: 'wrapper',\n componentId: 'muiStack',\n pluginId: BUNDLE_ID,\n props: {},\n sx: { position: 'relative', display: 'inline-flex' },\n nodes: [\n {\n $id: null,\n presetRef: 'trigger',\n componentId: 'muiButton',\n pluginId: BUNDLE_ID,\n props: { children: 'Explore', color: 'inherit' },\n },\n {\n $id: null,\n presetRef: 'panel',\n componentId: 'muiStack',\n pluginId: BUNDLE_ID,\n props: {\n className: 'aglyn-hidden',\n direction: 'row',\n spacing: 4,\n },\n // The panel's whole positioning. It lived in `props.sx` on the\n // documents this preset seeded, where the Styles panel could\n // neither show nor clear it (AGL-1339/AGL-1346); a fresh insert\n // now puts it where a click can reach it. Same keys, same order,\n // and `node.sx` composes last — the panel renders identically.\n sx: {\n position: 'absolute',\n top: '100%',\n left: 0,\n zIndex: 1300,\n paddingTop: 3,\n paddingRight: 3,\n paddingBottom: 3,\n paddingLeft: 3,\n minWidth: 560,\n flexWrap: 'wrap',\n backgroundColor: 'background.paper',\n color: 'text.primary',\n boxShadow: 8,\n borderRadius: 1,\n },\n nodes: [\n megaColumn('Shop', ['New arrivals', 'Best sellers', 'Sale']),\n megaColumn('Company', ['About', 'Careers', 'Press']),\n megaColumn('Support', ['Help center', 'Contact']),\n ],\n },\n ],\n },\n interactionTemplates: [\n {\n name: 'Dropdown panel — open on hover',\n event: 'elementHoverEnter',\n triggerRef: 'wrapper',\n steps: [\n {\n type: 'showElement',\n targetRef: 'panel',\n dismissOn: ['escape', 'outsideClick'],\n },\n ],\n },\n {\n name: 'Dropdown panel — close on hover leave',\n event: 'elementHoverLeave',\n triggerRef: 'wrapper',\n steps: [{ type: 'hideElement', targetRef: 'panel', delayMs: 250 }],\n },\n ],\n },\n {\n $id: generatePresetId(MEGA_MENU_ID),\n type: Aglyn.NodeType.PRESET,\n displayName: 'Mega Menu',\n pluginId: BUNDLE_ID,\n description:\n 'Wide panel with columns of links; add a hover interaction to ' +\n 'open it on hover',\n category: Aglyn.ComponentCategory.NAVIGATION,\n icon: megaMenuSchema.icon,\n data: {\n $id: null,\n componentId: MEGA_MENU_ID,\n pluginId: BUNDLE_ID,\n props: { label: 'Products', panelWidth: 'wide' },\n nodes: [\n {\n $id: null,\n componentId: 'muiStack',\n pluginId: BUNDLE_ID,\n props: { direction: 'row', spacing: 4 },\n sx: { flexWrap: 'wrap' },\n nodes: [\n megaColumn('Shop', ['New arrivals', 'Best sellers', 'Sale']),\n megaColumn('Company', ['About', 'Careers', 'Press']),\n megaColumn('Support', ['Help center', 'Contact']),\n ],\n },\n ],\n },\n },\n]\n\nexport default NavMenu\n"],"names":["Aglyn","mdiChevronDown","mdiFormDropdown","mdiViewGridOutline","MdiIcon","Box","Button","ClickAwayListener","Paper","Stack","Typography","forwardRef","useCallback","useEffect","useMemo","useRef","useState","BUNDLE_ID","generatePresetId","isLeafSelectedWithin","parseLeafNodeId","NAV_MENU_ID","MEGA_MENU_ID","HOVER_CLOSE_DELAY_MS","mountedMenus","megaMenuPanelSx","panelWidth","width","maxWidth","left","transform","borderRadius","minWidth","TRIGGER_SHELL_SX","position","display","textTransform","TRIGGER_SX","fontFamily","fontSize","fontWeight","lineHeight","letterSpacing","color","padding","marginRight","MenuShell","props","ref","label","editorHint","panelSx","sx","children","rest","nodeSx","Array","isArray","editorInert","useScreenLink","undefined","open","setOpen","hoverOpenRef","closeTimer","nodeId","cancelClose","current","clearTimeout","closeNow","scheduleClose","setTimeout","push","unsubscribe","subscribeMenuCommands","detail","targeted","leafIdsMatch","command","Boolean","hover","value","index","indexOf","splice","authoring","aria-expanded","endIcon","path","elevation","aria-label","top","mt","zIndex","theme","modal","p","border","borderColor","variant","mb","px","onClickAway","onMouseEnter","onMouseLeave","onKeyDown","event","key","aria-haspopup","onClick","displayName","stripLegacyTrigger","NavMenu","spacing","alignItems","MegaMenu","navMenuSchema","$id","pluginId","description","category","ComponentCategory","NAVIGATION","icon","attributes","name","component","FieldComponentType","TEXT_FIELD","megaMenuSchema","SELECT","options","navLink","componentId","megaColumn","title","links","nodes","map","navMenuPresets","type","NodeType","PRESET","data","presetRef","className","direction","paddingTop","paddingRight","paddingBottom","paddingLeft","flexWrap","backgroundColor","boxShadow","interactionTemplates","triggerRef","steps","targetRef","dismissOn","delayMs"],"mappings":";;;AAAA;;;;;;;;;;;;;;;CAeC,GAED,YAAYA,WAAW,eAAc;AACrC,SAASC,cAAc,EAAEC,eAAe,EAAEC,kBAAkB,QAAQ,yBAAwB;AAC5F,SAASC,OAAO,QAAQ,uBAAsB;AAC9C,OAAO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;gBACZC,OAAO;oBACL;wBACEhB,MAAM;wBACNiB,WAAW;wBACXC,WAAW;4BAAC;4BAAU;yBAAe;oBACvC;iBACD;YACH;YACA;gBACEjC,MAAM;gBACNnB,OAAO;gBACPiD,YAAY;gBACZC,OAAO;oBAAC;wBAAEhB,MAAM;wBAAeiB,WAAW;wBAASE,SAAS;oBAAI;iBAAE;YACpE;SACD;IACH;IACA;QACE1C,KAAKnG,iBAAiBI;QACtBsH,MAAM5I,MAAM6I,QAAQ,CAACC,MAAM;QAC3BhC,aAAa;QACbQ,UAAUrG;QACVsG,aACE,kEACA;QACFC,UAAUxH,MAAMyH,iBAAiB,CAACC,UAAU;QAC5CC,MAAMM,eAAeN,IAAI;QACzBoB,MAAM;YACJ1B,KAAK;YACLgB,aAAa/G;YACbgG,UAAUrG;YACV8B,OAAO;gBAAEE,OAAO;gBAAYvB,YAAY;YAAO;YAC/C+G,OAAO;gBACL;oBACEpB,KAAK;oBACLgB,aAAa;oBACbf,UAAUrG;oBACV8B,OAAO;wBAAEmG,WAAW;wBAAOjC,SAAS;oBAAE;oBACtC7D,IAAI;wBAAEmG,UAAU;oBAAO;oBACvBd,OAAO;wBACLH,WAAW,QAAQ;4BAAC;4BAAgB;4BAAgB;yBAAO;wBAC3DA,WAAW,WAAW;4BAAC;4BAAS;4BAAW;yBAAQ;wBACnDA,WAAW,WAAW;4BAAC;4BAAe;yBAAU;qBACjD;gBACH;aACD;QACH;IACF;CACD,CAAA;AAED,eAAetB,QAAO"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/mui/src/lib/components/nav-menu.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 { mdiChevronDown, mdiFormDropdown, mdiViewGridOutline } from '@aglyn/shared-data-mdi'\nimport { MdiIcon } from '@aglyn/shared-ui-jsx'\nimport Box, { type BoxProps } from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport ClickAwayListener from '@mui/material/ClickAwayListener'\nimport Paper from '@mui/material/Paper'\nimport Stack from '@mui/material/Stack'\nimport Typography from '@mui/material/Typography'\nimport {\n forwardRef,\n type KeyboardEvent,\n type ReactNode,\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react'\nimport type { SxProps } from '@mui/material/styles'\nimport { BUNDLE_ID } from '../constants/bundle-common'\nimport { generatePresetId } from '../utils/generate-preset-id'\nimport { isLeafSelectedWithin, parseLeafNodeId } from './drawer'\n\n// Component ids are persisted in screen documents; never rename.\nexport const NAV_MENU_ID: Aglyn.ComponentId = 'muiNavMenu'\nexport const MEGA_MENU_ID: Aglyn.ComponentId = 'muiMegaMenu'\n\nexport type MegaMenuPanelWidth = 'auto' | 'wide' | 'full'\n\n/** Hover close grace period so the pointer can cross into the panel. */\nconst HOVER_CLOSE_DELAY_MS = 150\n\nexport interface NavMenuProps {\n /** Visible trigger text of the nav item. */\n label?: string\n /**\n * Authored node styles, handed over by the renderer rather than typed into\n * an attribute. It lands on the element root and the trigger inherits, which\n * is what lets an author override the default text transform (AGL-1198) —\n * so it has to be expressible by a typed caller too (AGL-1323).\n */\n sx?: SxProps\n children?: ReactNode\n}\n\nexport interface MegaMenuProps {\n label?: string\n /** Panel width preset: content-sized, wide (720px), or full-bleed. */\n panelWidth?: MegaMenuPanelWidth\n /** Authored node styles — see `NavMenuProps.sx`. */\n sx?: SxProps\n children?: ReactNode\n}\n\n/**\n * Mounted menus in mount order (AGL-568). Broadcast commands (no target\n * node id) are answered by the FIRST registered menu only, mirroring the\n * drawer bus, so a page with one menu needs no wiring at all.\n */\nconst mountedMenus: string[] = []\n\n/**\n * The panel sx per mega-menu width preset. Wide/full center under the\n * trigger with the 50%/translate trick, so no measuring is needed and\n * SSR markup is stable.\n */\nexport function megaMenuPanelSx(panelWidth: MegaMenuPanelWidth): SxProps {\n switch (panelWidth) {\n case 'full':\n return {\n width: '100vw',\n maxWidth: '100vw',\n left: '50%',\n transform: 'translateX(-50%)',\n borderRadius: 0,\n }\n case 'wide':\n return {\n width: 'min(90vw, 720px)',\n left: '50%',\n transform: 'translateX(-50%)',\n }\n default:\n return { minWidth: 280, left: 0 }\n }\n}\n\n/**\n * Shared dropdown shell (AGL-562, interactions-driven since AGL-568): a\n * trigger button plus an absolutely positioned panel inside a relative\n * wrapper. Keeping the panel inside the wrapper's DOM (no portal) makes\n * pointer leave of trigger + panel a single mouseleave and keeps SSR\n * hydration trivial — the panel simply isn't rendered until opened, so\n * the server ships a closed menu.\n *\n * Open/close behavior: clicking the trigger toggles the menu (the\n * zero-config default), and the interactions system drives it over the\n * menu command bus (`dispatchMenuCommand`) keyed by node id — e.g. \"On\n * hover → Open menu (this element)\". Hover-opened menus close on their\n * own when the pointer leaves the trigger + panel surface (with a short\n * grace period); click/command opens stay put until click-away, Escape,\n * or an explicit close.\n *\n * On the static besigner canvas (flagged by ScreenLinkContext.editorInert)\n * the menu mirrors the live site's collapsed state: just the trigger, no\n * panel (AGL-571). Only while the menu or one of its descendants is selected\n * (the renderer stamps `data-aglyn-selected-within` on the leaf) does the\n * panel expand inline, like form fields do, so its contents stay selectable\n * and editable without fighting a popup — and it collapses again the moment\n * selection leaves the subtree. The Preview surface is NOT inert (AGL-830):\n * it suppresses link navigation but runs interactions for real, so the menu\n * takes the live branch and opens on hover exactly like the tenant site.\n */\ninterface MenuShellProps extends BoxProps {\n label: string\n editorHint: string\n panelSx: SxProps\n}\n\n/**\n * Trigger typography (AGL-1198). A menu label sits in a nav beside plain\n * links, so it reads as navigation, not as a call to action — MUI's\n * uppercase Button transform shouts \"PRODUCT\" next to \"Pricing\". The\n * default lives on the WRAPPER and the Button inherits it, so an author\n * who does want uppercase can set it in STYLES → Typography on the\n * element and have it win; before this there was no way to change it at\n * all, because the Button is internal to the element.\n */\nconst TRIGGER_SHELL_SX = {\n position: 'relative',\n display: 'inline-flex',\n textTransform: 'none',\n} as const\n/**\n * The rest of the same argument, generalized (AGL-2542).\n *\n * `textTransform` was one symptom of a whole button's worth of them. The\n * trigger still arrived as a `Button`: 0.875rem where the links beside it\n * were 15px, `min-width: 64px` padding \"Docs\" out to a width its own text\n * never asked for, and `6px 8px` of padding widening the visual gap on two\n * items out of five. In a nav laid out on a flat gap, that is a rhythm one\n * element breaks and no author can fix — the Button is internal, so a font\n * size set in STYLES lands on the wrapper and MUI's own class outranks it.\n *\n * So every typographic property is handed back to the wrapper the same way\n * `textTransform` was, and the button chrome that has no meaning on a nav\n * item is dropped. The element now renders as what it is — a label in a nav\n * — and STYLES → Typography on it reaches the label, which is the control an\n * author was reaching for when they found there wasn't one.\n *\n * `endIcon`'s negative right margin goes with the padding it was tucking\n * into; left at -4px against zero padding, the chevron would hang outside\n * the element and break the gap it just stopped breaking.\n *\n * ⚠️ Padding is where the hover target came from, and a hover-opened menu is\n * only as reachable as its trigger. It belongs on the WRAPPER now — which is\n * both what an author can actually edit and what `onMouseLeave` measures, so\n * padding added there enlarges the target instead of merely looking like it.\n */\nconst TRIGGER_SX = {\n fontFamily: 'inherit',\n fontSize: 'inherit',\n fontWeight: 'inherit',\n lineHeight: 'inherit',\n letterSpacing: 'inherit',\n textTransform: 'inherit',\n color: 'inherit',\n minWidth: 0,\n padding: 0,\n '& .MuiButton-endIcon': { marginRight: 0 },\n} as const\n\n/** How far a dropdown panel keeps from the window's edges, in px. */\nexport const PANEL_EDGE_MARGIN = 16\n/** The gap between a trigger and its open panel, in px. */\nexport const PANEL_GAP = 8\n\n/** Where an open panel must move to sit inside the window, and how tall it may be. */\nexport interface PanelFit {\n /** Horizontal nudge in px, applied on top of the panel's own placement. */\n shift: number\n /** The most the panel may be before it scrolls inside itself, or null. */\n maxHeight: number | null\n}\n\n/**\n * Keeps an open panel inside the window (AGL-4200). A wide or full panel is\n * centered under its trigger with CSS alone, which runs it off the left edge\n * when the trigger sits near it; a left-anchored one can run off the right.\n * `left` and `width` are the panel as placed, before any nudge.\n */\nexport function fitPanel(\n rect: { left: number; top: number; width: number; height: number },\n viewport: { width: number; height: number },\n margin = PANEL_EDGE_MARGIN,\n): PanelFit {\n const room = viewport.width - margin * 2\n let shift = 0\n if (rect.width >= room) {\n // Wider than the window allows: center it on the window.\n shift = (viewport.width - rect.width) / 2 - rect.left\n } else if (rect.left < margin) {\n shift = margin - rect.left\n } else if (rect.left + rect.width > viewport.width - margin) {\n shift = viewport.width - margin - (rect.left + rect.width)\n }\n const available = Math.floor(viewport.height - rect.top - margin)\n const maxHeight = rect.height > available && available > 160 ? available : null\n return { shift: Math.round(shift), maxHeight }\n}\n\nconst MenuShell = forwardRef<HTMLDivElement, MenuShellProps>((props, ref) => {\n const { label, editorHint, panelSx, sx, children, ...rest } = props\n // Node styles ride the sx prop the renderer merges; keep them by\n // composing with the shell's own layout sx (stack.ts pattern).\n const nodeSx = Array.isArray(sx) ? sx : sx ? [sx] : []\n const { editorInert } = Aglyn.useScreenLink(undefined)\n const [open, setOpen] = useState(false)\n const panelRef = useRef<HTMLDivElement | null>(null)\n const [fit, setFit] = useState<PanelFit>({ shift: 0, maxHeight: null })\n // Measured once the panel is on screen and before it paints, so it never\n // flashes off the edge. Placement is CSS; this only nudges it back inside.\n useLayoutEffect(() => {\n if (!open) {\n setFit({ shift: 0, maxHeight: null })\n return\n }\n const panel = panelRef.current\n if (!panel || typeof window === 'undefined') return\n const rect = panel.getBoundingClientRect()\n setFit(\n fitPanel(\n { left: rect.left, top: rect.top, width: rect.width, height: panel.scrollHeight },\n { width: document.documentElement.clientWidth, height: window.innerHeight },\n ),\n )\n }, [open])\n // True while the menu is open BECAUSE a hover interaction opened it —\n // only then does pointer leave close the menu.\n const hoverOpenRef = useRef(false)\n const closeTimer = useRef<ReturnType<typeof setTimeout> | null>(null)\n // The renderer stamps the node id on every leaf; commands target it.\n const nodeId = useMemo(\n () => parseLeafNodeId((rest as Record<string, unknown>)['data-aglyn']),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [(rest as Record<string, unknown>)['data-aglyn']],\n )\n\n const cancelClose = useCallback(() => {\n if (closeTimer.current) {\n clearTimeout(closeTimer.current)\n closeTimer.current = null\n }\n }, [])\n const closeNow = useCallback(() => {\n cancelClose()\n hoverOpenRef.current = false\n setOpen(false)\n }, [cancelClose])\n const scheduleClose = useCallback(() => {\n cancelClose()\n closeTimer.current = setTimeout(closeNow, HOVER_CLOSE_DELAY_MS)\n }, [cancelClose, closeNow])\n\n // Menu command bus enrollment (AGL-568): mirrors the drawer exactly —\n // live surfaces only, keyed by node id, broadcasts answered by the\n // first mounted menu.\n useEffect(() => {\n if (editorInert || !nodeId) return undefined\n mountedMenus.push(nodeId)\n const unsubscribe = Aglyn.subscribeMenuCommands((detail) => {\n // Match on the un-namespaced suffix (AGL-573): a command authored on\n // a layout-scoped menu carries the raw canvas id while this menu's\n // live id is `layout__`-namespaced (or vice versa) — leafIdsMatch\n // compares them equal without re-authoring the persisted action.\n const targeted = detail.nodeId\n ? Aglyn.leafIdsMatch(detail.nodeId, nodeId)\n : mountedMenus[0] === nodeId\n if (!targeted) return\n cancelClose()\n if (detail.command === 'close') {\n hoverOpenRef.current = false\n setOpen(false)\n return\n }\n // open/toggle: remember hover provenance so pointer leave closes\n // hover-opened menus (and never click/command-opened ones).\n hoverOpenRef.current = Boolean(detail.hover)\n if (detail.command === 'open') setOpen(true)\n else setOpen((value) => !value)\n })\n return () => {\n unsubscribe()\n cancelClose()\n const index = mountedMenus.indexOf(nodeId)\n if (index >= 0) mountedMenus.splice(index, 1)\n }\n }, [editorInert, nodeId, cancelClose])\n\n if (editorInert) {\n // Editor affordance (AGL-571): collapsed trigger by default — exactly\n // what the live site shows — expanding to the editable panel only while\n // the menu subtree holds the selection.\n const authoring = isLeafSelectedWithin(rest as Record<string, unknown>)\n return (\n <Box\n ref={ref}\n {...rest}\n // Relative so the authoring panel drops UNDER the trigger as an\n // overlay (AGL-830). The old inline-block expanded the panel in the\n // toolbar's flow, shoving and overlapping the other nav items in a\n // horizontal app bar; positioning it like the live popup keeps the\n // bar intact while the panel stays selectable and editable in place.\n sx={[TRIGGER_SHELL_SX, ...nodeSx]}\n >\n <Button\n color=\"inherit\"\n aria-expanded={authoring || undefined}\n endIcon={<MdiIcon path={mdiChevronDown.path} />}\n sx={TRIGGER_SX}\n >\n {label}\n </Button>\n {authoring ? (\n <Paper\n elevation={4}\n aria-label={label}\n sx={[\n {\n position: 'absolute',\n top: '100%',\n mt: 0.5,\n zIndex: (theme) => theme.zIndex.modal,\n p: 1,\n border: '1px dashed',\n borderColor: 'divider',\n },\n panelSx as never,\n ]}\n >\n <Typography\n variant=\"caption\"\n color=\"text.secondary\"\n sx={{ display: 'block', mb: 0.5, px: 1 }}\n >\n {editorHint}\n </Typography>\n {children}\n </Paper>\n ) : null}\n </Box>\n )\n }\n\n return (\n <ClickAwayListener onClickAway={() => open && closeNow()}>\n <Box\n ref={ref}\n {...rest}\n // Hover-close choreography (AGL-568): the panel renders inside\n // this wrapper (no portal), so trigger + panel share one\n // enter/leave pair. Only hover-opened menus follow the pointer\n // out; enter always cancels a pending close so the pointer can\n // travel between trigger and panel.\n onMouseEnter={cancelClose}\n onMouseLeave={() => {\n if (hoverOpenRef.current) scheduleClose()\n }}\n onKeyDown={(event: KeyboardEvent) => {\n if (event.key === 'Escape') closeNow()\n }}\n sx={[TRIGGER_SHELL_SX, ...nodeSx]}\n >\n <Button\n color=\"inherit\"\n aria-haspopup=\"true\"\n aria-expanded={open || undefined}\n endIcon={<MdiIcon path={mdiChevronDown.path} />}\n sx={TRIGGER_SX}\n onClick={() => {\n // Zero-config default: the trigger click-toggles its menu;\n // a click also \"pins\" a hover-opened menu.\n cancelClose()\n hoverOpenRef.current = false\n setOpen((value) => !value)\n }}\n >\n {label}\n </Button>\n {open ? (\n <Paper\n ref={panelRef}\n elevation={4}\n aria-label={label}\n style={{\n // `translate` composes with a centered panel's own transform.\n ...(fit.shift ? { translate: `${fit.shift}px 0` } : {}),\n ...(fit.maxHeight ? { maxHeight: fit.maxHeight, overflowY: 'auto' } : {}),\n }}\n sx={[\n {\n position: 'absolute',\n top: `calc(100% + ${PANEL_GAP}px)`,\n zIndex: (theme) => theme.zIndex.modal,\n p: 1,\n // A shadow alone vanishes on a dark theme or photo (AGL-4200).\n border: 1,\n borderColor: 'divider',\n // The node's own styles are for its trigger, and they land on\n // the wrapper this panel sits in. Without a reset an\n // uppercase, letter-spaced or no-wrap nav item made every\n // line of its panel the same (AGL-4200). Color needs no\n // reset: Paper sets its own.\n textTransform: 'none',\n letterSpacing: 'normal',\n whiteSpace: 'normal',\n // The gap is still the menu: a pointer crossing it from the\n // trigger stays inside, so a hover-opened menu stays open.\n '&::before': {\n content: '\"\"',\n position: 'absolute',\n left: 0,\n right: 0,\n top: -PANEL_GAP - 1,\n height: PANEL_GAP + 1,\n },\n },\n panelSx as never,\n ]}\n >\n {children}\n </Paper>\n ) : null}\n </Box>\n </ClickAwayListener>\n )\n})\nMenuShell.displayName = 'AglynMenuShell'\n\n/**\n * Strips the pre-AGL-568 \"Open on\" attribute persisted docs may still\n * carry. Behavior configuration rides the interactions system now; the\n * stored value is ignored silently — no migrations, no warnings — and\n * must never leak onto the DOM.\n */\nfunction stripLegacyTrigger(rest: Record<string, unknown>): void {\n delete rest['trigger']\n}\n\n/**\n * Dropdown nav item (AGL-562): a labeled nav button whose children —\n * screen links, buttons, anything — open in a dropdown panel. Clicking\n * the trigger toggles it; interactions drive it over the menu command\n * bus (AGL-568). SSR ships the menu closed; no window access happens at\n * render.\n */\nconst NavMenu = forwardRef<HTMLDivElement, NavMenuProps>((props, ref) => {\n const { label, children, ...rest } = props\n stripLegacyTrigger(rest as Record<string, unknown>)\n return (\n <MenuShell\n ref={ref}\n label={label || 'Menu'}\n editorHint=\"Dropdown items — shown in a menu on the live site\"\n panelSx={{ minWidth: 220, left: 0 }}\n {...rest}\n >\n <Stack spacing={0.5} sx={{ alignItems: 'stretch' }}>\n {children}\n </Stack>\n </MenuShell>\n )\n})\nNavMenu.displayName = 'AglynNavMenu'\n\n/**\n * Mega menu (AGL-562): a SaaS-style wide panel anchored under a nav\n * item with a free-form canvas slot — columns of links, promos,\n * whatever the author drops in. Click-toggles like the dropdown; the\n * SaaS hover-open convention is one interaction away (\"On hover → Open\n * menu\", AGL-568) and then closes itself on pointer leave.\n */\nexport const MegaMenu = forwardRef<HTMLDivElement, MegaMenuProps>(\n (props, ref) => {\n const { label, panelWidth, children, ...rest } = props\n stripLegacyTrigger(rest as Record<string, unknown>)\n return (\n <MenuShell\n ref={ref}\n label={label || 'Menu'}\n editorHint=\"Mega menu panel — opens under the nav item on the live site\"\n panelSx={{ p: 3, ...megaMenuPanelSx(panelWidth || 'auto') } as never}\n {...rest}\n >\n {children}\n </MenuShell>\n )\n },\n)\nMegaMenu.displayName = 'AglynMegaMenu'\n\nexport const navMenuSchema: Aglyn.ComponentSchema<NavMenuProps> = {\n $id: NAV_MENU_ID,\n pluginId: BUNDLE_ID,\n displayName: 'Dropdown Menu',\n description: 'A nav item that opens a dropdown of links beneath it.',\n category: Aglyn.ComponentCategory.NAVIGATION,\n icon: { path: mdiFormDropdown.path, sx: { color: '#2196f3' } },\n // Open/close behavior deliberately has NO attribute (AGL-568): click\n // toggles by default and everything else is authored as an\n // interaction (e.g. \"On hover → Open menu\").\n attributes: [\n {\n name: 'label',\n description: 'Text on the nav item that opens the dropdown.',\n component: Aglyn.FieldComponentType.TEXT_FIELD,\n label: 'Label',\n },\n ],\n}\n\nexport const megaMenuSchema: Aglyn.ComponentSchema<MegaMenuProps> = {\n $id: MEGA_MENU_ID,\n pluginId: BUNDLE_ID,\n displayName: 'Mega Menu',\n description:\n 'A nav item that opens a wide panel — columns of links, promos, whatever you build.',\n category: Aglyn.ComponentCategory.NAVIGATION,\n icon: { path: mdiViewGridOutline.path, sx: { color: '#2196f3' } },\n // Open/close behavior deliberately has NO attribute (AGL-568) — see\n // navMenuSchema.\n attributes: [\n {\n name: 'label',\n description: 'Text on the nav item that opens the panel.',\n component: Aglyn.FieldComponentType.TEXT_FIELD,\n label: 'Label',\n },\n {\n name: 'panelWidth',\n description: 'How wide the opened panel is.',\n component: Aglyn.FieldComponentType.SELECT,\n label: 'Panel width',\n // `auto` is the `MegaMenuPanelWidth` member `megaMenuPanelSx` already\n // switches on, so the sentinel names the case that existed in code\n // but not in the option list (AGL-1451); `''` could not persist\n // (AGL-1191), so a wide panel could not be narrowed again.\n options: [\n { value: 'auto', label: 'Fit content' },\n { value: 'wide', label: 'Wide (720px)' },\n { value: 'full', label: 'Full width' },\n ],\n },\n ],\n}\n\nconst navLink = (label: string) => ({\n $id: null,\n componentId: 'muiScreenLink',\n pluginId: BUNDLE_ID,\n props: { children: label, color: 'inherit' },\n})\n\nconst megaColumn = (title: string, links: string[]) => ({\n $id: null,\n componentId: 'muiStack',\n pluginId: BUNDLE_ID,\n props: { spacing: 0.5 },\n // Styling goes on the node's own sx, never in props (AGL-1346) — that is\n // the record the Styles panel edits.\n sx: { minWidth: 180, alignItems: 'flex-start' },\n nodes: [\n {\n $id: null,\n componentId: 'muiTypography',\n pluginId: BUNDLE_ID,\n props: { variant: 'overline', color: 'text.secondary', children: title },\n },\n ...links.map(navLink),\n ],\n})\n\nexport const navMenuPresets: Aglyn.PresetSchema[] = [\n {\n $id: generatePresetId(NAV_MENU_ID),\n type: Aglyn.NodeType.PRESET,\n displayName: 'Dropdown Menu',\n pluginId: BUNDLE_ID,\n description: 'Nav item that opens a dropdown of links',\n category: Aglyn.ComponentCategory.NAVIGATION,\n icon: navMenuSchema.icon,\n data: {\n $id: null,\n componentId: NAV_MENU_ID,\n pluginId: BUNDLE_ID,\n props: { label: 'More' },\n nodes: [navLink('About'), navLink('Blog'), navLink('Contact')],\n },\n },\n // Primitive dropdown scaffold (AGL-589): the same result as the menu\n // elements but built from a Stack + Button + hidden panel, with the\n // hover choreography (grace delay, Esc/outside-click dismissal)\n // pre-wired as real interactions the user can edit or remove. The\n // panel carries `aglyn-hidden` so it starts closed on the live site;\n // the canvas shows it for editing (the hidden style only injects at\n // runtime).\n {\n $id: generatePresetId('muiStack', 'dropdown-panel'),\n type: Aglyn.NodeType.PRESET,\n displayName: 'Dropdown Panel',\n pluginId: BUNDLE_ID,\n description:\n 'Trigger + hover panel built from primitives — opens on hover, ' +\n 'closes on leave with a grace delay, dismisses on Esc or outside ' +\n 'click; the wiring arrives as editable interactions',\n category: Aglyn.ComponentCategory.NAVIGATION,\n icon: { path: mdiFormDropdown.path, sx: { color: '#2196f3' } },\n data: {\n $id: null,\n presetRef: 'wrapper',\n componentId: 'muiStack',\n pluginId: BUNDLE_ID,\n props: {},\n sx: { position: 'relative', display: 'inline-flex' },\n nodes: [\n {\n $id: null,\n presetRef: 'trigger',\n componentId: 'muiButton',\n pluginId: BUNDLE_ID,\n props: { children: 'Explore', color: 'inherit' },\n },\n {\n $id: null,\n presetRef: 'panel',\n componentId: 'muiStack',\n pluginId: BUNDLE_ID,\n props: {\n className: 'aglyn-hidden',\n direction: 'row',\n spacing: 4,\n },\n // The panel's whole positioning. It lived in `props.sx` on the\n // documents this preset seeded, where the Styles panel could\n // neither show nor clear it (AGL-1339/AGL-1346); a fresh insert\n // now puts it where a click can reach it. Same keys, same order,\n // and `node.sx` composes last — the panel renders identically.\n sx: {\n position: 'absolute',\n top: '100%',\n left: 0,\n zIndex: 1300,\n paddingTop: 3,\n paddingRight: 3,\n paddingBottom: 3,\n paddingLeft: 3,\n minWidth: 560,\n flexWrap: 'wrap',\n backgroundColor: 'background.paper',\n color: 'text.primary',\n boxShadow: 8,\n borderRadius: 1,\n },\n nodes: [\n megaColumn('Shop', ['New arrivals', 'Best sellers', 'Sale']),\n megaColumn('Company', ['About', 'Careers', 'Press']),\n megaColumn('Support', ['Help center', 'Contact']),\n ],\n },\n ],\n },\n interactionTemplates: [\n {\n name: 'Dropdown panel — open on hover',\n event: 'elementHoverEnter',\n triggerRef: 'wrapper',\n steps: [\n {\n type: 'showElement',\n targetRef: 'panel',\n dismissOn: ['escape', 'outsideClick'],\n },\n ],\n },\n {\n name: 'Dropdown panel — close on hover leave',\n event: 'elementHoverLeave',\n triggerRef: 'wrapper',\n steps: [{ type: 'hideElement', targetRef: 'panel', delayMs: 250 }],\n },\n ],\n },\n {\n $id: generatePresetId(MEGA_MENU_ID),\n type: Aglyn.NodeType.PRESET,\n displayName: 'Mega Menu',\n pluginId: BUNDLE_ID,\n description:\n 'Wide panel with columns of links; add a hover interaction to ' +\n 'open it on hover',\n category: Aglyn.ComponentCategory.NAVIGATION,\n icon: megaMenuSchema.icon,\n data: {\n $id: null,\n componentId: MEGA_MENU_ID,\n pluginId: BUNDLE_ID,\n props: { label: 'Products', panelWidth: 'wide' },\n nodes: [\n {\n $id: null,\n componentId: 'muiStack',\n pluginId: BUNDLE_ID,\n props: { direction: 'row', spacing: 4 },\n sx: { flexWrap: 'wrap' },\n nodes: [\n megaColumn('Shop', ['New arrivals', 'Best sellers', 'Sale']),\n megaColumn('Company', ['About', 'Careers', 'Press']),\n megaColumn('Support', ['Help center', 'Contact']),\n ],\n },\n ],\n },\n },\n]\n\nexport default NavMenu\n"],"names":["Aglyn","mdiChevronDown","mdiFormDropdown","mdiViewGridOutline","MdiIcon","Box","Button","ClickAwayListener","Paper","Stack","Typography","forwardRef","useCallback","useEffect","useLayoutEffect","useMemo","useRef","useState","BUNDLE_ID","generatePresetId","isLeafSelectedWithin","parseLeafNodeId","NAV_MENU_ID","MEGA_MENU_ID","HOVER_CLOSE_DELAY_MS","mountedMenus","megaMenuPanelSx","panelWidth","width","maxWidth","left","transform","borderRadius","minWidth","TRIGGER_SHELL_SX","position","display","textTransform","TRIGGER_SX","fontFamily","fontSize","fontWeight","lineHeight","letterSpacing","color","padding","marginRight","PANEL_EDGE_MARGIN","PANEL_GAP","fitPanel","rect","viewport","margin","room","shift","available","Math","floor","height","top","maxHeight","round","MenuShell","props","ref","label","editorHint","panelSx","sx","children","rest","nodeSx","Array","isArray","editorInert","useScreenLink","undefined","open","setOpen","panelRef","fit","setFit","panel","current","window","getBoundingClientRect","scrollHeight","document","documentElement","clientWidth","innerHeight","hoverOpenRef","closeTimer","nodeId","cancelClose","clearTimeout","closeNow","scheduleClose","setTimeout","push","unsubscribe","subscribeMenuCommands","detail","targeted","leafIdsMatch","command","Boolean","hover","value","index","indexOf","splice","authoring","aria-expanded","endIcon","path","elevation","aria-label","mt","zIndex","theme","modal","p","border","borderColor","variant","mb","px","onClickAway","onMouseEnter","onMouseLeave","onKeyDown","event","key","aria-haspopup","onClick","style","translate","overflowY","whiteSpace","content","right","displayName","stripLegacyTrigger","NavMenu","spacing","alignItems","MegaMenu","navMenuSchema","$id","pluginId","description","category","ComponentCategory","NAVIGATION","icon","attributes","name","component","FieldComponentType","TEXT_FIELD","megaMenuSchema","SELECT","options","navLink","componentId","megaColumn","title","links","nodes","map","navMenuPresets","type","NodeType","PRESET","data","presetRef","className","direction","paddingTop","paddingRight","paddingBottom","paddingLeft","flexWrap","backgroundColor","boxShadow","interactionTemplates","triggerRef","steps","targetRef","dismissOn","delayMs"],"mappings":";;;AAAA;;;;;;;;;;;;;;;CAeC,GAED,YAAYA,WAAW,eAAc;AACrC,SAASC,cAAc,EAAEC,eAAe,EAAEC,kBAAkB,QAAQ,yBAAwB;AAC5F,SAASC,OAAO,QAAQ,uBAAsB;AAC9C,OAAOC,SAA4B,oBAAmB;AACtD,OAAOC,YAAY,uBAAsB;AACzC,OAAOC,uBAAuB,kCAAiC;AAC/D,OAAOC,WAAW,sBAAqB;AACvC,OAAOC,WAAW,sBAAqB;AACvC,OAAOC,gBAAgB,2BAA0B;AACjD,SACEC,UAAU,EAGVC,WAAW,EACXC,SAAS,EACTC,eAAe,EACfC,OAAO,E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,OAAO;gBAAEE,OAAO;gBAAYtC,YAAY;YAAO;YAC/C8I,OAAO;gBACL;oBACEpB,KAAK;oBACLgB,aAAa;oBACbf,UAAUpI;oBACV6C,OAAO;wBAAEmH,WAAW;wBAAOjC,SAAS;oBAAE;oBACtC7E,IAAI;wBAAEmH,UAAU;oBAAO;oBACvBd,OAAO;wBACLH,WAAW,QAAQ;4BAAC;4BAAgB;4BAAgB;yBAAO;wBAC3DA,WAAW,WAAW;4BAAC;4BAAS;4BAAW;yBAAQ;wBACnDA,WAAW,WAAW;4BAAC;4BAAe;yBAAU;qBACjD;gBACH;aACD;QACH;IACF;CACD,CAAA;AAED,eAAetB,QAAO"}
@@ -27,8 +27,11 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
27
27
  * kept (AGL-3401).
28
28
  */ import * as Aglyn from "@aglyn/aglyn";
29
29
  import { MdiIcons, mdiPuzzle } from "@aglyn/shared-data-mdi";
30
+ // The narrow module, not the barrel: these through the barrel load the
31
+ // manifest validators on every published page (AGL-4201).
32
+ import { PLUGIN_COMPONENT_ID, resolvePluginElements } from "@aglyn/aglyn/app-utils/plugin-elements";
30
33
  import { BUNDLE_ID } from "../constants/bundle-common.js";
31
- /** The Plugin element's component id, as the presets name it. */ const ID = Aglyn.PLUGIN_COMPONENT_ID;
34
+ /** The Plugin element's component id, as the presets name it. */ const ID = PLUGIN_COMPONENT_ID;
32
35
  /** The besigner drawer category installed plugins register under (AGL-190). */ export const PLUGIN_DRAWER_CATEGORY = 'Marketplace';
33
36
  /**
34
37
  * Builds a besigner preset for an installed plugin (AGL-190): a named,
@@ -90,7 +93,7 @@ import { BUNDLE_ID } from "../constants/bundle-common.js";
90
93
  ] : [];
91
94
  const listingId = (_install_listingId = install.listingId) != null ? _install_listingId : install.$id;
92
95
  if (!listingId) return presets;
93
- for (const element of Aglyn.resolvePluginElements({
96
+ for (const element of resolvePluginElements({
94
97
  listingId,
95
98
  capabilities: (_install_manifest = install.manifest) == null ? void 0 : _install_manifest.capabilities,
96
99
  manifest: install.manifest
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/mui/src/lib/components/plugin-install-presets.ts"],"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'use client'\n\n/**\n * The drawer presets an installed marketplace plugin contributes (AGL-190,\n * AGL-1031), apart from the element that renders them.\n *\n * `plugin.ts` registers these mappers on every surface, published pages\n * included, and the Plugin element itself loads only where it is placed. In\n * the element's module the mappers pinned the whole module — its component\n * and the sandboxed frame — to every published page, because a module a\n * surface imports statically and also lazily is one module, with every export\n * kept (AGL-3401).\n */\n\nimport * as Aglyn from '@aglyn/aglyn'\nimport { MdiIcons, mdiPuzzle } from '@aglyn/shared-data-mdi'\nimport { BUNDLE_ID } from '../constants/bundle-common'\n\n/** The Plugin element's component id, as the presets name it. */\nconst ID: Aglyn.ComponentId = Aglyn.PLUGIN_COMPONENT_ID\n\n/** The besigner drawer category installed plugins register under (AGL-190). */\nexport const PLUGIN_DRAWER_CATEGORY = 'Marketplace'\n\nexport interface PluginInstallLike {\n listingId?: string\n $id?: string\n displayName?: string\n pluginId?: string\n manifest?: {\n name?: string\n restrictParent?: string[]\n restrictChildren?: string[]\n }\n}\n\n/**\n * Builds a besigner preset for an installed plugin (AGL-190): a named,\n * draggable drawer entry that drops a `marketplacePlugin` node with the\n * listing id pre-pinned, so editors never hand-type ids. Reuses the single\n * `marketplacePlugin` renderer — no per-plugin component registration. The\n * manifest's lineal rules ride on the node data for later enforcement.\n * Returns null for an install without a resolvable listing id.\n */\nexport function muiPluginInstallToPreset(\n install: PluginInstallLike,\n): Aglyn.PresetSchema | null {\n const listingId = install.listingId ?? install.$id\n if (!listingId) return null\n const name =\n install.displayName || install.manifest?.name || 'Marketplace plugin'\n return {\n $id: `plugin__${listingId}`,\n type: Aglyn.NodeType.PRESET,\n displayName: name,\n pluginId: BUNDLE_ID,\n description: 'Installed marketplace plugin',\n category: PLUGIN_DRAWER_CATEGORY,\n icon: { path: mdiPuzzle.path, sx: { color: '#5e35b1' } },\n data: {\n $id: null,\n componentId: ID,\n pluginId: BUNDLE_ID,\n props: { listingId },\n ...(install.manifest?.restrictParent\n ? { restrictParent: install.manifest.restrictParent }\n : {}),\n ...(install.manifest?.restrictChildren\n ? { restrictChildren: install.manifest.restrictChildren }\n : {}),\n } as any,\n }\n}\n\n/**\n * Every drawer preset an installed plugin contributes (AGL-1031).\n *\n * The generic Plugin element, plus one per element the PINNED version\n * declares. Declared elements save as the same node with an `elementId`\n * alongside the listing id — the issue's preferred answer, and the one that\n * keeps a single compose path and a single sandbox. What changes is the\n * palette entry and the label, not what executes.\n *\n * Resolved from the pin, so an element appears only where the plugin is\n * installed and disappears with a revoked or downgraded version.\n */\nexport function muiPluginInstallToPresets(\n install: PluginInstallLike,\n): Aglyn.PresetSchema[] {\n const generic = muiPluginInstallToPreset(install)\n const presets = generic ? [generic] : []\n const listingId = install.listingId ?? install.$id\n if (!listingId) return presets\n\n for (const element of Aglyn.resolvePluginElements({\n listingId,\n capabilities: (install as any).manifest?.capabilities,\n manifest: (install as any).manifest,\n })) {\n // The declared icon is an mdi NAME; look it up in the set the host already\n // ships. An unresolved name falls back to the puzzle mark rather than\n // rendering nothing — the entry is still placeable, which matters more\n // than the glyph.\n const declared = element.icon ? MdiIcons.get(element.icon as never) : undefined\n presets.push({\n $id: `plugin__${listingId}__${element.elementId}`,\n type: Aglyn.NodeType.PRESET,\n displayName: element.displayName,\n pluginId: BUNDLE_ID,\n description: element.description ?? 'Installed marketplace plugin',\n category: element.category,\n icon: {\n path: (declared as { path?: string } | undefined)?.path ?? mdiPuzzle.path,\n sx: { color: '#5e35b1' },\n },\n data: {\n $id: null,\n componentId: ID,\n pluginId: BUNDLE_ID,\n props: { listingId, elementId: element.elementId },\n ...(install.manifest?.restrictParent\n ? { restrictParent: install.manifest.restrictParent }\n : {}),\n ...(install.manifest?.restrictChildren\n ? { restrictChildren: install.manifest.restrictChildren }\n : {}),\n } as any,\n })\n }\n return presets\n}\n"],"names":["Aglyn","MdiIcons","mdiPuzzle","BUNDLE_ID","ID","PLUGIN_COMPONENT_ID","PLUGIN_DRAWER_CATEGORY","muiPluginInstallToPreset","install","listingId","$id","name","displayName","manifest","type","NodeType","PRESET","pluginId","description","category","icon","path","sx","color","data","componentId","props","restrictParent","restrictChildren","muiPluginInstallToPresets","generic","presets","element","resolvePluginElements","capabilities","declared","get","undefined","push","elementId"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAEA;;;;;;;;;;CAUC,GAED,YAAYA,WAAW,eAAc;AACrC,SAASC,QAAQ,EAAEC,SAAS,QAAQ,yBAAwB;AAC5D,SAASC,SAAS,QAAQ,gCAA4B;AAEtD,+DAA+D,GAC/D,MAAMC,KAAwBJ,MAAMK,mBAAmB;AAEvD,6EAA6E,GAC7E,OAAO,MAAMC,yBAAyB,cAAa;AAcnD;;;;;;;CAOC,GACD,OAAO,SAASC,yBACdC,OAA0B;QAERA;QAGOA,mBAcjBA,oBAGAA;IApBR,MAAMC,aAAYD,qBAAAA,QAAQC,SAAS,YAAjBD,qBAAqBA,QAAQE,GAAG;IAClD,IAAI,CAACD,WAAW,OAAO;IACvB,MAAME,OACJH,QAAQI,WAAW,MAAIJ,oBAAAA,QAAQK,QAAQ,qBAAhBL,kBAAkBG,IAAI,KAAI;IACnD,OAAO;QACLD,KAAK,CAAC,QAAQ,EAAED,WAAW;QAC3BK,MAAMd,MAAMe,QAAQ,CAACC,MAAM;QAC3BJ,aAAaD;QACbM,UAAUd;QACVe,aAAa;QACbC,UAAUb;QACVc,M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UAAUd;YACVe,WAAW,GAAEc,uBAAAA,QAAQd,WAAW,YAAnBc,uBAAuB;YACpCb,UAAUa,QAAQb,QAAQ;YAC1BC,MAAM;gBACJC,IAAI,UAAGc,4BAAD,AAACA,SAA4Cd,IAAI,mBAAInB,UAAUmB,IAAI;gBACzEC,IAAI;oBAAEC,OAAO;gBAAU;YACzB;YACAC,MAAM;gBACJd,KAAK;gBACLe,aAAarB;gBACba,UAAUd;gBACVuB,OAAO;oBAAEjB;oBAAW8B,WAAWP,QAAQO,SAAS;gBAAC;eAC7C/B,EAAAA,qBAAAA,QAAQK,QAAQ,qBAAhBL,mBAAkBmB,cAAc,IAChC;gBAAEA,gBAAgBnB,QAAQK,QAAQ,CAACc,cAAc;YAAC,IAClD,CAAC,GACDnB,EAAAA,qBAAAA,QAAQK,QAAQ,qBAAhBL,mBAAkBoB,gBAAgB,IAClC;gBAAEA,kBAAkBpB,QAAQK,QAAQ,CAACe,gBAAgB;YAAC,IACtD,CAAC;QAET;IACF;IACA,OAAOG;AACT"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/mui/src/lib/components/plugin-install-presets.ts"],"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'use client'\n\n/**\n * The drawer presets an installed marketplace plugin contributes (AGL-190,\n * AGL-1031), apart from the element that renders them.\n *\n * `plugin.ts` registers these mappers on every surface, published pages\n * included, and the Plugin element itself loads only where it is placed. In\n * the element's module the mappers pinned the whole module — its component\n * and the sandboxed frame — to every published page, because a module a\n * surface imports statically and also lazily is one module, with every export\n * kept (AGL-3401).\n */\n\nimport * as Aglyn from '@aglyn/aglyn'\nimport { MdiIcons, mdiPuzzle } from '@aglyn/shared-data-mdi'\n// The narrow module, not the barrel: these through the barrel load the\n// manifest validators on every published page (AGL-4201).\nimport {\n PLUGIN_COMPONENT_ID,\n resolvePluginElements,\n} from '@aglyn/aglyn/app-utils/plugin-elements'\nimport { BUNDLE_ID } from '../constants/bundle-common'\n\n/** The Plugin element's component id, as the presets name it. */\nconst ID: Aglyn.ComponentId = PLUGIN_COMPONENT_ID\n\n/** The besigner drawer category installed plugins register under (AGL-190). */\nexport const PLUGIN_DRAWER_CATEGORY = 'Marketplace'\n\nexport interface PluginInstallLike {\n listingId?: string\n $id?: string\n displayName?: string\n pluginId?: string\n manifest?: {\n name?: string\n restrictParent?: string[]\n restrictChildren?: string[]\n }\n}\n\n/**\n * Builds a besigner preset for an installed plugin (AGL-190): a named,\n * draggable drawer entry that drops a `marketplacePlugin` node with the\n * listing id pre-pinned, so editors never hand-type ids. Reuses the single\n * `marketplacePlugin` renderer — no per-plugin component registration. The\n * manifest's lineal rules ride on the node data for later enforcement.\n * Returns null for an install without a resolvable listing id.\n */\nexport function muiPluginInstallToPreset(\n install: PluginInstallLike,\n): Aglyn.PresetSchema | null {\n const listingId = install.listingId ?? install.$id\n if (!listingId) return null\n const name =\n install.displayName || install.manifest?.name || 'Marketplace plugin'\n return {\n $id: `plugin__${listingId}`,\n type: Aglyn.NodeType.PRESET,\n displayName: name,\n pluginId: BUNDLE_ID,\n description: 'Installed marketplace plugin',\n category: PLUGIN_DRAWER_CATEGORY,\n icon: { path: mdiPuzzle.path, sx: { color: '#5e35b1' } },\n data: {\n $id: null,\n componentId: ID,\n pluginId: BUNDLE_ID,\n props: { listingId },\n ...(install.manifest?.restrictParent\n ? { restrictParent: install.manifest.restrictParent }\n : {}),\n ...(install.manifest?.restrictChildren\n ? { restrictChildren: install.manifest.restrictChildren }\n : {}),\n } as any,\n }\n}\n\n/**\n * Every drawer preset an installed plugin contributes (AGL-1031).\n *\n * The generic Plugin element, plus one per element the PINNED version\n * declares. Declared elements save as the same node with an `elementId`\n * alongside the listing id — the issue's preferred answer, and the one that\n * keeps a single compose path and a single sandbox. What changes is the\n * palette entry and the label, not what executes.\n *\n * Resolved from the pin, so an element appears only where the plugin is\n * installed and disappears with a revoked or downgraded version.\n */\nexport function muiPluginInstallToPresets(\n install: PluginInstallLike,\n): Aglyn.PresetSchema[] {\n const generic = muiPluginInstallToPreset(install)\n const presets = generic ? [generic] : []\n const listingId = install.listingId ?? install.$id\n if (!listingId) return presets\n\n for (const element of resolvePluginElements({\n listingId,\n capabilities: (install as any).manifest?.capabilities,\n manifest: (install as any).manifest,\n })) {\n // The declared icon is an mdi NAME; look it up in the set the host already\n // ships. An unresolved name falls back to the puzzle mark rather than\n // rendering nothing — the entry is still placeable, which matters more\n // than the glyph.\n const declared = element.icon ? MdiIcons.get(element.icon as never) : undefined\n presets.push({\n $id: `plugin__${listingId}__${element.elementId}`,\n type: Aglyn.NodeType.PRESET,\n displayName: element.displayName,\n pluginId: BUNDLE_ID,\n description: element.description ?? 'Installed marketplace plugin',\n category: element.category,\n icon: {\n path: (declared as { path?: string } | undefined)?.path ?? mdiPuzzle.path,\n sx: { color: '#5e35b1' },\n },\n data: {\n $id: null,\n componentId: ID,\n pluginId: BUNDLE_ID,\n props: { listingId, elementId: element.elementId },\n ...(install.manifest?.restrictParent\n ? { restrictParent: install.manifest.restrictParent }\n : {}),\n ...(install.manifest?.restrictChildren\n ? { restrictChildren: install.manifest.restrictChildren }\n : {}),\n } as any,\n })\n }\n return presets\n}\n"],"names":["Aglyn","MdiIcons","mdiPuzzle","PLUGIN_COMPONENT_ID","resolvePluginElements","BUNDLE_ID","ID","PLUGIN_DRAWER_CATEGORY","muiPluginInstallToPreset","install","listingId","$id","name","displayName","manifest","type","NodeType","PRESET","pluginId","description","category","icon","path","sx","color","data","componentId","props","restrictParent","restrictChildren","muiPluginInstallToPresets","generic","presets","element","capabilities","declared","get","undefined","push","elementId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