@jay-framework/aiditor 0.21.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-kit-template/plugin/aiditor-add-menu.md +470 -63
- package/dist/index.client.d.ts +219 -7
- package/dist/index.client.js +1184 -272
- package/dist/index.d.ts +21 -23
- package/dist/index.js +106 -137
- package/dist/pages/aiditor/page.css +55 -19
- package/dist/pages/aiditor/page.jay-html +513 -91
- package/dist/pages/aiditor/page.jay-html.d.ts +219 -7
- package/package.json +11 -10
- package/plugin.yaml +2 -3
package/dist/index.client.js
CHANGED
|
@@ -9657,10 +9657,7 @@ function initAddPageBriefFillPanel(deps) {
|
|
|
9657
9657
|
} catch (err) {
|
|
9658
9658
|
if (runId !== activeRuns[t]) return;
|
|
9659
9659
|
if (err instanceof Error && err.name === "AbortError") return;
|
|
9660
|
-
setTargetGenError(
|
|
9661
|
-
t,
|
|
9662
|
-
err instanceof Error ? err.message : String(err)
|
|
9663
|
-
);
|
|
9660
|
+
setTargetGenError(t, err instanceof Error ? err.message : String(err));
|
|
9664
9661
|
} finally {
|
|
9665
9662
|
abortHandles[t] = null;
|
|
9666
9663
|
if (runId === activeRuns[t]) {
|
|
@@ -9883,6 +9880,31 @@ function suggestMissingRouteSegments(route, segmentNames) {
|
|
|
9883
9880
|
if (trimmed === "/") return `/${suffix}`;
|
|
9884
9881
|
return `${trimmed}/${suffix}`;
|
|
9885
9882
|
}
|
|
9883
|
+
function isGifPath(src) {
|
|
9884
|
+
return /\.gif($|\?)/i.test(src.trim());
|
|
9885
|
+
}
|
|
9886
|
+
function normalizeAddMenuPresentation(item) {
|
|
9887
|
+
if (item.presentation) return item.presentation;
|
|
9888
|
+
const thumbnail = item.thumbnail?.trim();
|
|
9889
|
+
if (!thumbnail) return void 0;
|
|
9890
|
+
if (isGifPath(thumbnail)) {
|
|
9891
|
+
return { type: "gif", src: thumbnail };
|
|
9892
|
+
}
|
|
9893
|
+
return { type: "image", src: thumbnail };
|
|
9894
|
+
}
|
|
9895
|
+
const BLOCKED_TAGS = /<\s*(script|iframe|object|embed)\b[^>]*>[\s\S]*?<\/\s*\1\s*>|<\s*(script|iframe|object|embed)\b[^>]*\/?>/gi;
|
|
9896
|
+
const EVENT_HANDLER_ATTR = /\s+on[a-z]+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi;
|
|
9897
|
+
const JAVASCRIPT_URL = /\b(href|src|xlink:href)\s*=\s*("|')\s*javascript:/gi;
|
|
9898
|
+
function sanitizeAddMenuHtmlFragment(html) {
|
|
9899
|
+
let result = html;
|
|
9900
|
+
result = result.replace(BLOCKED_TAGS, "");
|
|
9901
|
+
BLOCKED_TAGS.lastIndex = 0;
|
|
9902
|
+
result = result.replace(EVENT_HANDLER_ATTR, "");
|
|
9903
|
+
EVENT_HANDLER_ATTR.lastIndex = 0;
|
|
9904
|
+
result = result.replace(JAVASCRIPT_URL, "");
|
|
9905
|
+
JAVASCRIPT_URL.lastIndex = 0;
|
|
9906
|
+
return result.trim();
|
|
9907
|
+
}
|
|
9886
9908
|
const PUBLIC_THUMBNAIL_PREFIX = "/aiditor-add-menu-thumbnails/";
|
|
9887
9909
|
function resolveAddMenuThumbnailUrl(thumbnail) {
|
|
9888
9910
|
const raw = thumbnail?.trim();
|
|
@@ -9891,31 +9913,84 @@ function resolveAddMenuThumbnailUrl(thumbnail) {
|
|
|
9891
9913
|
const withoutPrefix = raw.startsWith("thumbnails/") ? raw.slice("thumbnails/".length) : raw;
|
|
9892
9914
|
return `${PUBLIC_THUMBNAIL_PREFIX}${withoutPrefix}`;
|
|
9893
9915
|
}
|
|
9894
|
-
function
|
|
9895
|
-
const
|
|
9896
|
-
|
|
9897
|
-
|
|
9898
|
-
|
|
9916
|
+
function addMenuPresentationFields(item) {
|
|
9917
|
+
const empty = {
|
|
9918
|
+
showImage: false,
|
|
9919
|
+
showGif: false,
|
|
9920
|
+
showHtmlFragment: false,
|
|
9921
|
+
imageUrl: "",
|
|
9922
|
+
gifUrl: "",
|
|
9923
|
+
posterUrl: "",
|
|
9924
|
+
previewHtml: ""
|
|
9925
|
+
};
|
|
9926
|
+
const presentation = normalizeAddMenuPresentation(item);
|
|
9927
|
+
if (!presentation) return empty;
|
|
9928
|
+
switch (presentation.type) {
|
|
9929
|
+
case "image": {
|
|
9930
|
+
const imageUrl = resolveAddMenuThumbnailUrl(presentation.src) ?? "";
|
|
9931
|
+
return {
|
|
9932
|
+
...empty,
|
|
9933
|
+
showImage: imageUrl.length > 0,
|
|
9934
|
+
imageUrl
|
|
9935
|
+
};
|
|
9936
|
+
}
|
|
9937
|
+
case "gif": {
|
|
9938
|
+
const gifUrl = resolveAddMenuThumbnailUrl(presentation.src) ?? "";
|
|
9939
|
+
const posterUrl = resolveAddMenuThumbnailUrl(presentation.poster) ?? "";
|
|
9940
|
+
return {
|
|
9941
|
+
...empty,
|
|
9942
|
+
showGif: gifUrl.length > 0,
|
|
9943
|
+
gifUrl,
|
|
9944
|
+
posterUrl
|
|
9945
|
+
};
|
|
9946
|
+
}
|
|
9947
|
+
case "html-fragment": {
|
|
9948
|
+
const previewHtml = sanitizeAddMenuHtmlFragment(presentation.html);
|
|
9949
|
+
return {
|
|
9950
|
+
...empty,
|
|
9951
|
+
showHtmlFragment: previewHtml.length > 0,
|
|
9952
|
+
previewHtml
|
|
9953
|
+
};
|
|
9954
|
+
}
|
|
9955
|
+
default:
|
|
9956
|
+
return empty;
|
|
9957
|
+
}
|
|
9899
9958
|
}
|
|
9900
|
-
|
|
9901
|
-
const
|
|
9902
|
-
|
|
9903
|
-
|
|
9904
|
-
|
|
9959
|
+
function addMenuPresentationFallbackThumb(item) {
|
|
9960
|
+
const presentation = normalizeAddMenuPresentation(item);
|
|
9961
|
+
if (!presentation) {
|
|
9962
|
+
return { showThumbnail: false, showInfoIcon: true, thumbnailUrl: "" };
|
|
9963
|
+
}
|
|
9964
|
+
if (presentation.type === "image") {
|
|
9965
|
+
const thumbnailUrl = resolveAddMenuThumbnailUrl(presentation.src) ?? "";
|
|
9966
|
+
return {
|
|
9967
|
+
showThumbnail: thumbnailUrl.length > 0,
|
|
9968
|
+
showInfoIcon: thumbnailUrl.length === 0,
|
|
9969
|
+
thumbnailUrl
|
|
9970
|
+
};
|
|
9971
|
+
}
|
|
9972
|
+
if (presentation.type === "gif") {
|
|
9973
|
+
const posterUrl = resolveAddMenuThumbnailUrl(presentation.poster) ?? "";
|
|
9905
9974
|
return {
|
|
9906
|
-
|
|
9907
|
-
|
|
9908
|
-
|
|
9909
|
-
cardCssClass: PREVIEW_CARD_CLASS,
|
|
9910
|
-
isAnimatedThumbnail: isAddMenuThumbnailAnimated(thumbnail, thumbnailUrl)
|
|
9975
|
+
showThumbnail: posterUrl.length > 0,
|
|
9976
|
+
showInfoIcon: posterUrl.length === 0,
|
|
9977
|
+
thumbnailUrl: posterUrl
|
|
9911
9978
|
};
|
|
9912
9979
|
}
|
|
9980
|
+
return { showThumbnail: false, showInfoIcon: true, thumbnailUrl: "" };
|
|
9981
|
+
}
|
|
9982
|
+
function browseRowHasPreview(row) {
|
|
9983
|
+
return row.showImage || row.showGifAutoplay === true || row.showGifPoster === true || row.showHtmlFragment;
|
|
9984
|
+
}
|
|
9985
|
+
function applyReducedMotionToBrowseRow(row, prefersReducedMotion) {
|
|
9986
|
+
const showGifAutoplay = row.showGif && !prefersReducedMotion;
|
|
9987
|
+
const showGifPoster = row.showGif && prefersReducedMotion && row.posterUrl.length > 0;
|
|
9988
|
+
const showGifReducedInfoIcon = row.showGif && prefersReducedMotion && row.posterUrl.length === 0;
|
|
9913
9989
|
return {
|
|
9914
|
-
|
|
9915
|
-
|
|
9916
|
-
|
|
9917
|
-
|
|
9918
|
-
isAnimatedThumbnail: false
|
|
9990
|
+
...row,
|
|
9991
|
+
showGifAutoplay,
|
|
9992
|
+
showGifPoster,
|
|
9993
|
+
showGifReducedInfoIcon
|
|
9919
9994
|
};
|
|
9920
9995
|
}
|
|
9921
9996
|
function addMenuChipTooltip(title, subtitle) {
|
|
@@ -9925,13 +10000,115 @@ function addMenuChipTooltip(title, subtitle) {
|
|
|
9925
10000
|
return `${label} — ${meta}`;
|
|
9926
10001
|
}
|
|
9927
10002
|
function addMenuChipVisualFields(item) {
|
|
9928
|
-
const visual =
|
|
10003
|
+
const visual = addMenuPresentationFallbackThumb(item ?? {});
|
|
9929
10004
|
return {
|
|
9930
10005
|
showThumbnail: visual.showThumbnail,
|
|
9931
10006
|
showInfoIcon: visual.showInfoIcon,
|
|
9932
|
-
thumbnailUrl: visual.thumbnailUrl
|
|
10007
|
+
thumbnailUrl: visual.thumbnailUrl
|
|
9933
10008
|
};
|
|
9934
10009
|
}
|
|
10010
|
+
const ADD_MENU_FOLDER_NAV_ROOT = "__root__";
|
|
10011
|
+
const ADD_MENU_FOLDER_BREADCRUMB_ROOT_LABEL = "All";
|
|
10012
|
+
const FOLDER_NAV_SEP = "";
|
|
10013
|
+
const ADD_MENU_FOLDER_BREADCRUMB_MAX = 8;
|
|
10014
|
+
function normalizeItemFolderPath(item) {
|
|
10015
|
+
if (!item.folderPath || item.folderPath.length === 0) return [];
|
|
10016
|
+
return item.folderPath.map((segment) => segment.trim()).filter(Boolean);
|
|
10017
|
+
}
|
|
10018
|
+
function folderPathsEqual(a2, b) {
|
|
10019
|
+
if (a2.length !== b.length) return false;
|
|
10020
|
+
return a2.every((segment, index) => segment === b[index]);
|
|
10021
|
+
}
|
|
10022
|
+
function folderPathStartsWith(path, prefix) {
|
|
10023
|
+
if (prefix.length > path.length) return false;
|
|
10024
|
+
return prefix.every((segment, index) => path[index] === segment);
|
|
10025
|
+
}
|
|
10026
|
+
function folderNavKey(path) {
|
|
10027
|
+
if (path.length === 0) return ADD_MENU_FOLDER_NAV_ROOT;
|
|
10028
|
+
return path.join(FOLDER_NAV_SEP);
|
|
10029
|
+
}
|
|
10030
|
+
function parseFolderNavKey(navKey) {
|
|
10031
|
+
if (!navKey || navKey === ADD_MENU_FOLDER_NAV_ROOT) return [];
|
|
10032
|
+
return navKey.split(FOLDER_NAV_SEP);
|
|
10033
|
+
}
|
|
10034
|
+
function folderNodesAtPath(items, parentPath2) {
|
|
10035
|
+
const childMap = /* @__PURE__ */ new Map();
|
|
10036
|
+
for (const item of items) {
|
|
10037
|
+
const itemPath = normalizeItemFolderPath(item);
|
|
10038
|
+
if (!folderPathStartsWith(itemPath, parentPath2)) continue;
|
|
10039
|
+
const relative = itemPath.slice(parentPath2.length);
|
|
10040
|
+
if (relative.length === 0) continue;
|
|
10041
|
+
const segment = relative[0];
|
|
10042
|
+
const childPath = [...parentPath2, segment];
|
|
10043
|
+
const childKey = folderNavKey(childPath);
|
|
10044
|
+
let entry = childMap.get(childKey);
|
|
10045
|
+
if (!entry) {
|
|
10046
|
+
entry = { segment, path: childPath, direct: 0, total: 0 };
|
|
10047
|
+
childMap.set(childKey, entry);
|
|
10048
|
+
}
|
|
10049
|
+
entry.total++;
|
|
10050
|
+
if (relative.length === 1) entry.direct++;
|
|
10051
|
+
}
|
|
10052
|
+
return [...childMap.values()].sort((a2, b) => a2.segment.localeCompare(b.segment)).map(({ segment, path, direct, total }) => ({
|
|
10053
|
+
segment,
|
|
10054
|
+
path,
|
|
10055
|
+
directItemCount: direct,
|
|
10056
|
+
totalItemCount: total
|
|
10057
|
+
}));
|
|
10058
|
+
}
|
|
10059
|
+
function leafItemsAtPath(items, path) {
|
|
10060
|
+
return items.filter(
|
|
10061
|
+
(item) => folderPathsEqual(normalizeItemFolderPath(item), path)
|
|
10062
|
+
);
|
|
10063
|
+
}
|
|
10064
|
+
function folderRowsFromItems(items, parentPath2) {
|
|
10065
|
+
return folderNodesAtPath(items, parentPath2).map((node) => ({
|
|
10066
|
+
rowKey: folderNavKey(node.path),
|
|
10067
|
+
navKey: folderNavKey(node.path),
|
|
10068
|
+
segment: node.segment,
|
|
10069
|
+
label: node.segment,
|
|
10070
|
+
itemCountLabel: String(node.totalItemCount),
|
|
10071
|
+
totalItemCount: node.totalItemCount
|
|
10072
|
+
}));
|
|
10073
|
+
}
|
|
10074
|
+
function breadcrumbSegmentsForPath(path) {
|
|
10075
|
+
if (path.length === 0) return [];
|
|
10076
|
+
const displayPath = path.length > ADD_MENU_FOLDER_BREADCRUMB_MAX ? [
|
|
10077
|
+
"...",
|
|
10078
|
+
...path.slice(path.length - (ADD_MENU_FOLDER_BREADCRUMB_MAX - 1))
|
|
10079
|
+
] : [...path];
|
|
10080
|
+
const startIndex = path.length > ADD_MENU_FOLDER_BREADCRUMB_MAX ? path.length - (ADD_MENU_FOLDER_BREADCRUMB_MAX - 1) : 0;
|
|
10081
|
+
const folderSegments = displayPath.map((label, index) => {
|
|
10082
|
+
const isEllipsis = label === "...";
|
|
10083
|
+
const pathPrefix = isEllipsis ? path.slice(0, startIndex) : path.slice(0, startIndex + index + 1);
|
|
10084
|
+
const isLast = index === displayPath.length - 1;
|
|
10085
|
+
return {
|
|
10086
|
+
segmentKey: `${folderNavKey(pathPrefix)}:${index}`,
|
|
10087
|
+
navKey: folderNavKey(pathPrefix),
|
|
10088
|
+
label,
|
|
10089
|
+
isLast
|
|
10090
|
+
};
|
|
10091
|
+
});
|
|
10092
|
+
return [
|
|
10093
|
+
{
|
|
10094
|
+
segmentKey: `${ADD_MENU_FOLDER_NAV_ROOT}:root`,
|
|
10095
|
+
navKey: ADD_MENU_FOLDER_NAV_ROOT,
|
|
10096
|
+
label: ADD_MENU_FOLDER_BREADCRUMB_ROOT_LABEL,
|
|
10097
|
+
isLast: false
|
|
10098
|
+
},
|
|
10099
|
+
...folderSegments
|
|
10100
|
+
];
|
|
10101
|
+
}
|
|
10102
|
+
function addMenuSearchDisplayTitle(item) {
|
|
10103
|
+
const folderPath = normalizeItemFolderPath(item);
|
|
10104
|
+
if (folderPath.length === 0) return item.title;
|
|
10105
|
+
return `${folderPath.join(" / ")} / ${item.title}`;
|
|
10106
|
+
}
|
|
10107
|
+
function folderPathMatchesSearch(item, queryLower) {
|
|
10108
|
+
return normalizeItemFolderPath(item).some(
|
|
10109
|
+
(segment) => segment.toLowerCase().includes(queryLower)
|
|
10110
|
+
);
|
|
10111
|
+
}
|
|
9935
10112
|
function addMenuInteractionMode(item) {
|
|
9936
10113
|
return item.interaction?.mode ?? "reference";
|
|
9937
10114
|
}
|
|
@@ -9948,6 +10125,139 @@ function appendAssetMentionToStagePrompt(stagePrompt, insertTitle) {
|
|
|
9948
10125
|
function isStagePlaceItem(item) {
|
|
9949
10126
|
return addMenuInteractionMode(item) === "stage-place";
|
|
9950
10127
|
}
|
|
10128
|
+
function normalizeAddMenuBrowseSize(item) {
|
|
10129
|
+
return item.browse?.size ?? "medium";
|
|
10130
|
+
}
|
|
10131
|
+
const ROW_SLOT_CAPACITY = 8;
|
|
10132
|
+
function slotsForSize(size) {
|
|
10133
|
+
if (size === "large") return 8;
|
|
10134
|
+
if (size === "medium") return 4;
|
|
10135
|
+
return 1;
|
|
10136
|
+
}
|
|
10137
|
+
function slotsFreeInRow(row) {
|
|
10138
|
+
return ROW_SLOT_CAPACITY - row.slotsUsed;
|
|
10139
|
+
}
|
|
10140
|
+
function trailingFourItemsAreSmall(row, sizes) {
|
|
10141
|
+
const { itemIndices } = row;
|
|
10142
|
+
if (itemIndices.length < 4) return false;
|
|
10143
|
+
for (let offset = 0; offset < 4; offset++) {
|
|
10144
|
+
const itemIndex = itemIndices[itemIndices.length - 4 + offset];
|
|
10145
|
+
if (sizes[itemIndex] !== "small") return false;
|
|
10146
|
+
}
|
|
10147
|
+
return true;
|
|
10148
|
+
}
|
|
10149
|
+
function fillRow(row, sizes, startIndex) {
|
|
10150
|
+
let itemIndex = startIndex;
|
|
10151
|
+
while (itemIndex < sizes.length) {
|
|
10152
|
+
if (trailingFourItemsAreSmall(row, sizes)) {
|
|
10153
|
+
const peekRow = { itemIndices: [], slotsUsed: 0 };
|
|
10154
|
+
fillRow(peekRow, sizes, itemIndex);
|
|
10155
|
+
if (peekRow.slotsUsed === ROW_SLOT_CAPACITY) {
|
|
10156
|
+
break;
|
|
10157
|
+
}
|
|
10158
|
+
}
|
|
10159
|
+
const itemSlotCount = slotsForSize(sizes[itemIndex]);
|
|
10160
|
+
if (itemSlotCount > slotsFreeInRow(row)) {
|
|
10161
|
+
break;
|
|
10162
|
+
}
|
|
10163
|
+
row.itemIndices.push(itemIndex);
|
|
10164
|
+
row.slotsUsed += itemSlotCount;
|
|
10165
|
+
itemIndex++;
|
|
10166
|
+
}
|
|
10167
|
+
return itemIndex;
|
|
10168
|
+
}
|
|
10169
|
+
function packRows(sizes) {
|
|
10170
|
+
const rows = [];
|
|
10171
|
+
let itemIndex = 0;
|
|
10172
|
+
while (itemIndex < sizes.length) {
|
|
10173
|
+
const row = { itemIndices: [], slotsUsed: 0 };
|
|
10174
|
+
itemIndex = fillRow(row, sizes, itemIndex);
|
|
10175
|
+
if (row.itemIndices.length > 0) {
|
|
10176
|
+
rows.push(row);
|
|
10177
|
+
}
|
|
10178
|
+
}
|
|
10179
|
+
return rows;
|
|
10180
|
+
}
|
|
10181
|
+
function rowToMediumSlots(itemIndices, sizes) {
|
|
10182
|
+
const slots = [];
|
|
10183
|
+
let position2 = 0;
|
|
10184
|
+
while (position2 < itemIndices.length) {
|
|
10185
|
+
const catalogIndex = itemIndices[position2];
|
|
10186
|
+
const size = sizes[catalogIndex];
|
|
10187
|
+
if (size === "medium") {
|
|
10188
|
+
slots.push({ kind: "medium", index: catalogIndex });
|
|
10189
|
+
position2++;
|
|
10190
|
+
continue;
|
|
10191
|
+
}
|
|
10192
|
+
if (size === "large") {
|
|
10193
|
+
slots.push({ kind: "large", index: catalogIndex });
|
|
10194
|
+
position2++;
|
|
10195
|
+
continue;
|
|
10196
|
+
}
|
|
10197
|
+
const smallIndices = [];
|
|
10198
|
+
while (position2 < itemIndices.length) {
|
|
10199
|
+
const smallCatalogIndex = itemIndices[position2];
|
|
10200
|
+
if (sizes[smallCatalogIndex] !== "small") break;
|
|
10201
|
+
smallIndices.push(smallCatalogIndex);
|
|
10202
|
+
position2++;
|
|
10203
|
+
}
|
|
10204
|
+
slots.push({ kind: "small-quad", indices: smallIndices });
|
|
10205
|
+
}
|
|
10206
|
+
return slots;
|
|
10207
|
+
}
|
|
10208
|
+
function isThreeSlotLayout(slots) {
|
|
10209
|
+
return slots.length === 3 && slots[0]?.kind === "small-quad" && slots[1]?.kind === "medium" && slots[2]?.kind === "small-quad";
|
|
10210
|
+
}
|
|
10211
|
+
function rowToBand(row, sizes) {
|
|
10212
|
+
const { itemIndices } = row;
|
|
10213
|
+
if (itemIndices.length === 1 && sizes[itemIndices[0]] === "large") {
|
|
10214
|
+
return {
|
|
10215
|
+
kind: "medium-band",
|
|
10216
|
+
slots: [{ kind: "large", index: itemIndices[0] }]
|
|
10217
|
+
};
|
|
10218
|
+
}
|
|
10219
|
+
if (itemIndices.every((catalogIndex) => sizes[catalogIndex] === "small")) {
|
|
10220
|
+
return { kind: "small-strip", indices: [...itemIndices] };
|
|
10221
|
+
}
|
|
10222
|
+
const slots = rowToMediumSlots(itemIndices, sizes);
|
|
10223
|
+
return {
|
|
10224
|
+
kind: "medium-band",
|
|
10225
|
+
slots,
|
|
10226
|
+
threeSlotLayout: isThreeSlotLayout(slots)
|
|
10227
|
+
};
|
|
10228
|
+
}
|
|
10229
|
+
function packSizes(sizes) {
|
|
10230
|
+
return packRows(sizes).map((row) => rowToBand(row, sizes));
|
|
10231
|
+
}
|
|
10232
|
+
function toLayoutBand(band, bandIndex) {
|
|
10233
|
+
const bandKey = `band:${bandIndex}`;
|
|
10234
|
+
if (band.kind === "small-strip") {
|
|
10235
|
+
return {
|
|
10236
|
+
bandKey,
|
|
10237
|
+
kind: "small-strip",
|
|
10238
|
+
itemIndices: band.indices
|
|
10239
|
+
};
|
|
10240
|
+
}
|
|
10241
|
+
const slots = band.slots.map((slot, slotIndex) => {
|
|
10242
|
+
const slotKey = `${bandKey}:slot:${slotIndex}`;
|
|
10243
|
+
if (slot.kind === "medium") {
|
|
10244
|
+
return { slotKey, kind: "medium", itemIndex: slot.index };
|
|
10245
|
+
}
|
|
10246
|
+
if (slot.kind === "large") {
|
|
10247
|
+
return { slotKey, kind: "large", itemIndex: slot.index };
|
|
10248
|
+
}
|
|
10249
|
+
return { slotKey, kind: "small-quad", itemIndices: slot.indices };
|
|
10250
|
+
});
|
|
10251
|
+
return {
|
|
10252
|
+
bandKey,
|
|
10253
|
+
kind: "medium-band",
|
|
10254
|
+
slots,
|
|
10255
|
+
threeSlotLayout: band.threeSlotLayout
|
|
10256
|
+
};
|
|
10257
|
+
}
|
|
10258
|
+
function packAddMenuBrowseLayout(sizes) {
|
|
10259
|
+
return packSizes(sizes).map(toLayoutBand);
|
|
10260
|
+
}
|
|
9951
10261
|
function groupAddMenuItems(items) {
|
|
9952
10262
|
const byCategory = /* @__PURE__ */ new Map();
|
|
9953
10263
|
for (const item of items) {
|
|
@@ -9969,7 +10279,7 @@ function groupAddMenuItems(items) {
|
|
|
9969
10279
|
return sa.localeCompare(sb);
|
|
9970
10280
|
}).map(([subCategory, subItems]) => ({
|
|
9971
10281
|
subCategory,
|
|
9972
|
-
items: subItems
|
|
10282
|
+
items: subItems
|
|
9973
10283
|
}))
|
|
9974
10284
|
}));
|
|
9975
10285
|
}
|
|
@@ -9981,6 +10291,8 @@ const SUB_CATEGORY_SORT_ORDER = [
|
|
|
9981
10291
|
"Animation"
|
|
9982
10292
|
];
|
|
9983
10293
|
const PICKABLE_CARD_CLASS = "add-menu-picker-component-card";
|
|
10294
|
+
const PREVIEW_CARD_CLASS = "add-menu-picker-component-card add-menu-picker-component-card--preview";
|
|
10295
|
+
const INFO_CARD_CLASS = "add-menu-picker-component-card add-menu-picker-component-card--info";
|
|
9984
10296
|
const STAGE_PLACE_CARD_CLASS = "add-menu-picker-component-card--stage-place";
|
|
9985
10297
|
function stagePlaceCardClass(cardClass, isStagePlace) {
|
|
9986
10298
|
return isStagePlace ? `${cardClass} ${STAGE_PLACE_CARD_CLASS}` : cardClass;
|
|
@@ -9991,26 +10303,71 @@ function thumbCssClass(isAnimated, isSelected) {
|
|
|
9991
10303
|
if (isSelected) parts.push("add-menu-picker-component-thumb--selected");
|
|
9992
10304
|
return parts.join(" ");
|
|
9993
10305
|
}
|
|
9994
|
-
function
|
|
9995
|
-
|
|
10306
|
+
function emptyBrowseRowFields() {
|
|
10307
|
+
return {
|
|
10308
|
+
showImage: false,
|
|
10309
|
+
showGif: false,
|
|
10310
|
+
showHtmlFragment: false,
|
|
10311
|
+
imageUrl: "",
|
|
10312
|
+
gifUrl: "",
|
|
10313
|
+
posterUrl: "",
|
|
10314
|
+
previewHtml: "",
|
|
10315
|
+
showGifAutoplay: false,
|
|
10316
|
+
showGifPoster: false,
|
|
10317
|
+
showGifReducedInfoIcon: false,
|
|
10318
|
+
showThumbnail: false,
|
|
10319
|
+
showInfoIcon: false,
|
|
10320
|
+
thumbnailUrl: "",
|
|
10321
|
+
isAnimatedThumbnail: false,
|
|
10322
|
+
thumbCssClass: ""
|
|
10323
|
+
};
|
|
10324
|
+
}
|
|
10325
|
+
function cardClassForBrowseVisual(row) {
|
|
10326
|
+
if (browseRowHasPreview(row)) return PREVIEW_CARD_CLASS;
|
|
10327
|
+
if (row.showInfoIcon || row.showGifReducedInfoIcon) return INFO_CARD_CLASS;
|
|
10328
|
+
return PICKABLE_CARD_CLASS;
|
|
10329
|
+
}
|
|
10330
|
+
function sizeCssModifier(size) {
|
|
10331
|
+
return `add-menu-picker-component-card--size-${size}`;
|
|
10332
|
+
}
|
|
10333
|
+
function cardClassWithBrowseSize(baseCardClass, browseSize) {
|
|
10334
|
+
return `${baseCardClass} ${sizeCssModifier(browseSize)}`;
|
|
10335
|
+
}
|
|
10336
|
+
function toPickableRow(item, prefersReducedMotion = false, labelOverride) {
|
|
10337
|
+
const browseSize = normalizeAddMenuBrowseSize(item);
|
|
10338
|
+
const presentation = applyReducedMotionToBrowseRow(
|
|
10339
|
+
addMenuPresentationFields(item),
|
|
10340
|
+
prefersReducedMotion
|
|
10341
|
+
);
|
|
9996
10342
|
const stagePlace = isStagePlaceItem(item);
|
|
9997
|
-
const
|
|
10343
|
+
const showThumbnail = presentation.showImage;
|
|
10344
|
+
const thumbnailUrl = presentation.imageUrl;
|
|
10345
|
+
const showInfoIcon = !browseRowHasPreview(presentation) && !presentation.showGifReducedInfoIcon && !presentation.showGif;
|
|
10346
|
+
const baseCardClass = cardClassForBrowseVisual({
|
|
10347
|
+
...presentation,
|
|
10348
|
+
showInfoIcon: showInfoIcon || presentation.showGifReducedInfoIcon
|
|
10349
|
+
});
|
|
9998
10350
|
return {
|
|
9999
10351
|
rowKey: item.id,
|
|
10000
10352
|
isSectionHeader: false,
|
|
10001
|
-
label: item.title,
|
|
10353
|
+
label: labelOverride ?? item.title,
|
|
10002
10354
|
itemId: item.id,
|
|
10003
10355
|
isPickable: true,
|
|
10004
10356
|
showPickable: true,
|
|
10005
10357
|
showBrowseOnly: false,
|
|
10006
10358
|
isItemSelected: false,
|
|
10007
|
-
cardCssClass:
|
|
10008
|
-
|
|
10009
|
-
|
|
10010
|
-
|
|
10011
|
-
|
|
10012
|
-
|
|
10013
|
-
|
|
10359
|
+
cardCssClass: cardClassWithBrowseSize(
|
|
10360
|
+
stagePlaceCardClass(baseCardClass, stagePlace),
|
|
10361
|
+
browseSize
|
|
10362
|
+
),
|
|
10363
|
+
...presentation,
|
|
10364
|
+
showThumbnail,
|
|
10365
|
+
showInfoIcon: showInfoIcon || presentation.showGifReducedInfoIcon,
|
|
10366
|
+
thumbnailUrl,
|
|
10367
|
+
isAnimatedThumbnail: presentation.showGif || presentation.showGifAutoplay,
|
|
10368
|
+
thumbCssClass: thumbCssClass(presentation.showGif, false),
|
|
10369
|
+
isStagePlace: stagePlace,
|
|
10370
|
+
browseSize
|
|
10014
10371
|
};
|
|
10015
10372
|
}
|
|
10016
10373
|
function sectionHeaderRow(subCategory) {
|
|
@@ -10024,12 +10381,9 @@ function sectionHeaderRow(subCategory) {
|
|
|
10024
10381
|
showBrowseOnly: false,
|
|
10025
10382
|
isItemSelected: false,
|
|
10026
10383
|
cardCssClass: "",
|
|
10027
|
-
|
|
10028
|
-
|
|
10029
|
-
|
|
10030
|
-
isAnimatedThumbnail: false,
|
|
10031
|
-
thumbCssClass: "",
|
|
10032
|
-
isStagePlace: false
|
|
10384
|
+
...emptyBrowseRowFields(),
|
|
10385
|
+
isStagePlace: false,
|
|
10386
|
+
browseSize: "medium"
|
|
10033
10387
|
};
|
|
10034
10388
|
}
|
|
10035
10389
|
function formatSelectionCountSuffix(count) {
|
|
@@ -10043,40 +10397,198 @@ function countSelectedItems(items, selectedIds) {
|
|
|
10043
10397
|
}
|
|
10044
10398
|
return count;
|
|
10045
10399
|
}
|
|
10046
|
-
function
|
|
10400
|
+
function sectionHeaderBlock(subCategory) {
|
|
10401
|
+
const header = sectionHeaderRow(subCategory);
|
|
10402
|
+
return {
|
|
10403
|
+
blockKey: header.rowKey,
|
|
10404
|
+
kind: "section-header",
|
|
10405
|
+
showSectionHeader: true,
|
|
10406
|
+
showBand: false,
|
|
10407
|
+
sectionLabel: header.label,
|
|
10408
|
+
bandKind: "",
|
|
10409
|
+
bandCssClass: "",
|
|
10410
|
+
showSmallStrip: false,
|
|
10411
|
+
showMediumBand: false,
|
|
10412
|
+
stripCells: [],
|
|
10413
|
+
bandSlots: []
|
|
10414
|
+
};
|
|
10415
|
+
}
|
|
10416
|
+
function slotViewStateFromRow(slot, row) {
|
|
10417
|
+
return {
|
|
10418
|
+
...row,
|
|
10419
|
+
slotKey: slot.slotKey,
|
|
10420
|
+
slotKind: slot.kind,
|
|
10421
|
+
slotCssClass: slot.kind === "large" ? "add-menu-browse-slot add-menu-browse-slot--large" : "add-menu-browse-slot",
|
|
10422
|
+
showMediumSlot: slot.kind === "medium",
|
|
10423
|
+
showLargeSlot: slot.kind === "large",
|
|
10424
|
+
showSmallQuad: false,
|
|
10425
|
+
quadRows: []
|
|
10426
|
+
};
|
|
10427
|
+
}
|
|
10428
|
+
function quadSlotViewState(slot, quadRows) {
|
|
10429
|
+
const placeholder = quadRows[0] ?? emptyPickableRow();
|
|
10430
|
+
return {
|
|
10431
|
+
...placeholder,
|
|
10432
|
+
rowKey: slot.slotKey,
|
|
10433
|
+
itemId: "",
|
|
10434
|
+
label: "",
|
|
10435
|
+
isPickable: false,
|
|
10436
|
+
showPickable: false,
|
|
10437
|
+
cardCssClass: "",
|
|
10438
|
+
slotKey: slot.slotKey,
|
|
10439
|
+
slotKind: "small-quad",
|
|
10440
|
+
slotCssClass: "add-menu-browse-slot",
|
|
10441
|
+
showMediumSlot: false,
|
|
10442
|
+
showLargeSlot: false,
|
|
10443
|
+
showSmallQuad: true,
|
|
10444
|
+
quadRows
|
|
10445
|
+
};
|
|
10446
|
+
}
|
|
10447
|
+
function withSequentialBandKey(band, bandSequence) {
|
|
10448
|
+
const bandKey = `band:${bandSequence}`;
|
|
10449
|
+
if (band.kind === "small-strip") {
|
|
10450
|
+
return { ...band, bandKey };
|
|
10451
|
+
}
|
|
10452
|
+
return {
|
|
10453
|
+
...band,
|
|
10454
|
+
bandKey,
|
|
10455
|
+
slots: band.slots.map((slot, slotIndex) => ({
|
|
10456
|
+
...slot,
|
|
10457
|
+
slotKey: `${bandKey}:slot:${slotIndex}`
|
|
10458
|
+
}))
|
|
10459
|
+
};
|
|
10460
|
+
}
|
|
10461
|
+
function bandBlockFromLayout(band, rows) {
|
|
10462
|
+
if (band.kind === "small-strip") {
|
|
10463
|
+
const stripCells = band.itemIndices.map((index) => rows[index]);
|
|
10464
|
+
return {
|
|
10465
|
+
blockKey: band.bandKey,
|
|
10466
|
+
kind: "band",
|
|
10467
|
+
showSectionHeader: false,
|
|
10468
|
+
showBand: true,
|
|
10469
|
+
sectionLabel: "",
|
|
10470
|
+
bandKind: "small-strip",
|
|
10471
|
+
bandCssClass: "add-menu-browse-band add-menu-browse-band--small-strip",
|
|
10472
|
+
showSmallStrip: true,
|
|
10473
|
+
showMediumBand: false,
|
|
10474
|
+
stripCells,
|
|
10475
|
+
bandSlots: []
|
|
10476
|
+
};
|
|
10477
|
+
}
|
|
10478
|
+
const bandSlots = band.slots.map((slot) => {
|
|
10479
|
+
if (slot.kind === "medium") {
|
|
10480
|
+
return slotViewStateFromRow(slot, rows[slot.itemIndex]);
|
|
10481
|
+
}
|
|
10482
|
+
if (slot.kind === "large") {
|
|
10483
|
+
return slotViewStateFromRow(slot, rows[slot.itemIndex]);
|
|
10484
|
+
}
|
|
10485
|
+
return quadSlotViewState(
|
|
10486
|
+
slot,
|
|
10487
|
+
slot.itemIndices.map((index) => rows[index])
|
|
10488
|
+
);
|
|
10489
|
+
});
|
|
10490
|
+
const threeSlotLayout = band.kind === "medium-band" && band.threeSlotLayout === true;
|
|
10491
|
+
return {
|
|
10492
|
+
blockKey: band.bandKey,
|
|
10493
|
+
kind: "band",
|
|
10494
|
+
showSectionHeader: false,
|
|
10495
|
+
showBand: true,
|
|
10496
|
+
sectionLabel: "",
|
|
10497
|
+
bandKind: "medium-band",
|
|
10498
|
+
bandCssClass: threeSlotLayout ? "add-menu-browse-band add-menu-browse-band--medium-band add-menu-browse-band--slots-3" : "add-menu-browse-band add-menu-browse-band--medium-band",
|
|
10499
|
+
showSmallStrip: false,
|
|
10500
|
+
showMediumBand: true,
|
|
10501
|
+
stripCells: [],
|
|
10502
|
+
bandSlots
|
|
10503
|
+
};
|
|
10504
|
+
}
|
|
10505
|
+
function emptyPickableRow() {
|
|
10506
|
+
return {
|
|
10507
|
+
rowKey: "",
|
|
10508
|
+
isSectionHeader: false,
|
|
10509
|
+
label: "",
|
|
10510
|
+
itemId: "",
|
|
10511
|
+
isPickable: false,
|
|
10512
|
+
showPickable: false,
|
|
10513
|
+
showBrowseOnly: false,
|
|
10514
|
+
isItemSelected: false,
|
|
10515
|
+
cardCssClass: "",
|
|
10516
|
+
...emptyBrowseRowFields(),
|
|
10517
|
+
isStagePlace: false,
|
|
10518
|
+
browseSize: "small"
|
|
10519
|
+
};
|
|
10520
|
+
}
|
|
10521
|
+
function pickableRowsInBlock(block) {
|
|
10522
|
+
if (block.showSectionHeader) return [];
|
|
10523
|
+
if (block.showSmallStrip) return block.stripCells;
|
|
10524
|
+
const rows = [];
|
|
10525
|
+
for (const slot of block.bandSlots) {
|
|
10526
|
+
if (slot.showMediumSlot || slot.showLargeSlot) rows.push(slot);
|
|
10527
|
+
if (slot.showSmallQuad) rows.push(...slot.quadRows);
|
|
10528
|
+
}
|
|
10529
|
+
return rows;
|
|
10530
|
+
}
|
|
10531
|
+
function mapBrowseBlockRows(block, mapRow) {
|
|
10532
|
+
if (block.showSectionHeader) return block;
|
|
10533
|
+
if (block.showSmallStrip) {
|
|
10534
|
+
return { ...block, stripCells: block.stripCells.map(mapRow) };
|
|
10535
|
+
}
|
|
10536
|
+
return {
|
|
10537
|
+
...block,
|
|
10538
|
+
bandSlots: block.bandSlots.map((slot) => {
|
|
10539
|
+
if (slot.showSmallQuad) {
|
|
10540
|
+
return { ...slot, quadRows: slot.quadRows.map(mapRow) };
|
|
10541
|
+
}
|
|
10542
|
+
return { ...slot, ...mapRow(slot) };
|
|
10543
|
+
})
|
|
10544
|
+
};
|
|
10545
|
+
}
|
|
10546
|
+
function applySelectionToBrowseBlocks(blocks, selectedIds) {
|
|
10047
10547
|
const sectionSelectedCounts = /* @__PURE__ */ new Map();
|
|
10548
|
+
for (const block of blocks) {
|
|
10549
|
+
if (!block.showSectionHeader) continue;
|
|
10550
|
+
sectionSelectedCounts.set(block.blockKey, 0);
|
|
10551
|
+
}
|
|
10048
10552
|
let currentSectionKey = "";
|
|
10049
|
-
for (const
|
|
10050
|
-
if (
|
|
10051
|
-
currentSectionKey =
|
|
10052
|
-
sectionSelectedCounts.set(currentSectionKey, 0);
|
|
10553
|
+
for (const block of blocks) {
|
|
10554
|
+
if (block.showSectionHeader) {
|
|
10555
|
+
currentSectionKey = block.blockKey;
|
|
10053
10556
|
continue;
|
|
10054
10557
|
}
|
|
10055
|
-
|
|
10056
|
-
|
|
10057
|
-
|
|
10058
|
-
|
|
10059
|
-
|
|
10558
|
+
for (const row of pickableRowsInBlock(block)) {
|
|
10559
|
+
if (selectedIds.has(row.itemId) && currentSectionKey) {
|
|
10560
|
+
sectionSelectedCounts.set(
|
|
10561
|
+
currentSectionKey,
|
|
10562
|
+
(sectionSelectedCounts.get(currentSectionKey) ?? 0) + 1
|
|
10563
|
+
);
|
|
10564
|
+
}
|
|
10060
10565
|
}
|
|
10061
10566
|
}
|
|
10062
|
-
return
|
|
10063
|
-
if (
|
|
10064
|
-
const selectedCount = sectionSelectedCounts.get(
|
|
10567
|
+
return blocks.map((block) => {
|
|
10568
|
+
if (block.showSectionHeader) {
|
|
10569
|
+
const selectedCount = sectionSelectedCounts.get(block.blockKey) ?? 0;
|
|
10065
10570
|
return {
|
|
10066
|
-
...
|
|
10067
|
-
|
|
10571
|
+
...block,
|
|
10572
|
+
sectionLabel: (block.sectionLabel.split(" · ")[0] ?? block.sectionLabel) + formatSelectionCountSuffix(selectedCount)
|
|
10068
10573
|
};
|
|
10069
10574
|
}
|
|
10070
|
-
|
|
10071
|
-
|
|
10072
|
-
|
|
10073
|
-
|
|
10074
|
-
|
|
10075
|
-
|
|
10076
|
-
|
|
10077
|
-
|
|
10078
|
-
|
|
10079
|
-
|
|
10575
|
+
return mapBrowseBlockRows(block, (row) => {
|
|
10576
|
+
if (!row.isPickable) return row;
|
|
10577
|
+
const isItemSelected = selectedIds.has(row.itemId);
|
|
10578
|
+
const cardClass = stagePlaceCardClass(
|
|
10579
|
+
cardClassForBrowseVisual(row),
|
|
10580
|
+
row.isStagePlace
|
|
10581
|
+
);
|
|
10582
|
+
return {
|
|
10583
|
+
...row,
|
|
10584
|
+
isItemSelected,
|
|
10585
|
+
cardCssClass: isItemSelected ? `${cardClassWithBrowseSize(cardClass, row.browseSize)} add-menu-picker-component-card--selected` : cardClassWithBrowseSize(cardClass, row.browseSize),
|
|
10586
|
+
thumbCssClass: thumbCssClass(
|
|
10587
|
+
row.showGif || row.showGifAutoplay,
|
|
10588
|
+
isItemSelected
|
|
10589
|
+
)
|
|
10590
|
+
};
|
|
10591
|
+
});
|
|
10080
10592
|
});
|
|
10081
10593
|
}
|
|
10082
10594
|
function applySelectionToLeftNavRows(rows, items, selectedIds) {
|
|
@@ -10172,6 +10684,7 @@ function subCategoryFilterRows(subs, selectedSubCategory, options = {}) {
|
|
|
10172
10684
|
);
|
|
10173
10685
|
const populated = sorted.filter((sub) => sub.items.length > 0);
|
|
10174
10686
|
if (populated.length === 0) return [];
|
|
10687
|
+
if (populated.length <= 1) return [];
|
|
10175
10688
|
const allCount = populated.reduce(
|
|
10176
10689
|
(sum, sub) => sum + subCategoryItemCount(sub),
|
|
10177
10690
|
0
|
|
@@ -10239,7 +10752,58 @@ function leftNavRowsForBrowse(tree, selectedCategory) {
|
|
|
10239
10752
|
};
|
|
10240
10753
|
});
|
|
10241
10754
|
}
|
|
10242
|
-
function
|
|
10755
|
+
function pickableItemsForCategorySubCategory(group, selectedSubCategory) {
|
|
10756
|
+
if (isAllSubCategoryFilter(selectedSubCategory)) {
|
|
10757
|
+
return group.subCategories.flatMap((sub2) => sub2.items).filter(isPickableAddMenuItem);
|
|
10758
|
+
}
|
|
10759
|
+
const sub = group.subCategories.find(
|
|
10760
|
+
(entry) => (entry.subCategory ?? "") === (selectedSubCategory ?? "")
|
|
10761
|
+
);
|
|
10762
|
+
return (sub?.items ?? []).filter(isPickableAddMenuItem);
|
|
10763
|
+
}
|
|
10764
|
+
function browseBlocksFromLeafItems(leafItems, selectedSubCategory, prefersReducedMotion, useSearchLabels) {
|
|
10765
|
+
const bySubCategory = /* @__PURE__ */ new Map();
|
|
10766
|
+
for (const item of leafItems) {
|
|
10767
|
+
const key = item.subCategory ?? null;
|
|
10768
|
+
const list = bySubCategory.get(key) ?? [];
|
|
10769
|
+
list.push(item);
|
|
10770
|
+
bySubCategory.set(key, list);
|
|
10771
|
+
}
|
|
10772
|
+
const subs = [...bySubCategory.entries()].map(([subCategory, items]) => ({
|
|
10773
|
+
subCategory,
|
|
10774
|
+
items
|
|
10775
|
+
}));
|
|
10776
|
+
return browseBlocksFromSubCategories(
|
|
10777
|
+
subs,
|
|
10778
|
+
selectedSubCategory,
|
|
10779
|
+
prefersReducedMotion,
|
|
10780
|
+
useSearchLabels
|
|
10781
|
+
);
|
|
10782
|
+
}
|
|
10783
|
+
function browseViewForBrowse(tree, selectedCategory, selectedSubCategory = null, prefersReducedMotion = false, selectedFolderPath = []) {
|
|
10784
|
+
const group = categoryGroupForTree(tree, selectedCategory);
|
|
10785
|
+
if (!group) {
|
|
10786
|
+
return { folderRows: [], breadcrumbSegments: [], blocks: [] };
|
|
10787
|
+
}
|
|
10788
|
+
const scopedItems = pickableItemsForCategorySubCategory(
|
|
10789
|
+
group,
|
|
10790
|
+
selectedSubCategory
|
|
10791
|
+
);
|
|
10792
|
+
const folderRows = folderRowsFromItems(scopedItems, selectedFolderPath);
|
|
10793
|
+
const leafItems = leafItemsAtPath(scopedItems, selectedFolderPath);
|
|
10794
|
+
const blocks = browseBlocksFromLeafItems(
|
|
10795
|
+
leafItems,
|
|
10796
|
+
selectedSubCategory,
|
|
10797
|
+
prefersReducedMotion,
|
|
10798
|
+
false
|
|
10799
|
+
);
|
|
10800
|
+
return {
|
|
10801
|
+
folderRows,
|
|
10802
|
+
breadcrumbSegments: breadcrumbSegmentsForPath(selectedFolderPath),
|
|
10803
|
+
blocks
|
|
10804
|
+
};
|
|
10805
|
+
}
|
|
10806
|
+
function browseBlocksFromSubCategories(subs, selectedSubCategory, prefersReducedMotion = false, useSearchLabels = false) {
|
|
10243
10807
|
const sorted = [...subs].sort(
|
|
10244
10808
|
(a2, b) => compareSubCategoryNames(a2.subCategory, b.subCategory)
|
|
10245
10809
|
);
|
|
@@ -10251,27 +10815,42 @@ function browseRowsFromSubCategories(subs, selectedSubCategory) {
|
|
|
10251
10815
|
(sub) => sub.items.filter(isPickableAddMenuItem).length > 0
|
|
10252
10816
|
);
|
|
10253
10817
|
const showSectionHeaders = filterAll && populated.length > 1;
|
|
10254
|
-
const
|
|
10818
|
+
const blocks = [];
|
|
10819
|
+
let bandSequence = 0;
|
|
10255
10820
|
for (const sub of populated) {
|
|
10256
10821
|
const pickable = sub.items.filter(isPickableAddMenuItem);
|
|
10257
10822
|
if (pickable.length === 0) continue;
|
|
10258
10823
|
if (showSectionHeaders) {
|
|
10259
|
-
|
|
10824
|
+
blocks.push(sectionHeaderBlock(sub.subCategory));
|
|
10260
10825
|
}
|
|
10261
|
-
|
|
10262
|
-
|
|
10826
|
+
const rows = pickable.map(
|
|
10827
|
+
(item) => toPickableRow(
|
|
10828
|
+
item,
|
|
10829
|
+
prefersReducedMotion,
|
|
10830
|
+
useSearchLabels ? addMenuSearchDisplayTitle(item) : void 0
|
|
10831
|
+
)
|
|
10832
|
+
);
|
|
10833
|
+
const sizes = pickable.map((item) => normalizeAddMenuBrowseSize(item));
|
|
10834
|
+
const bands = packAddMenuBrowseLayout(sizes);
|
|
10835
|
+
for (const band of bands) {
|
|
10836
|
+
blocks.push(
|
|
10837
|
+
bandBlockFromLayout(withSequentialBandKey(band, bandSequence++), rows)
|
|
10838
|
+
);
|
|
10263
10839
|
}
|
|
10264
10840
|
}
|
|
10265
|
-
return
|
|
10266
|
-
}
|
|
10267
|
-
function browseRowsForBrowse(tree, selectedCategory, selectedSubCategory = null) {
|
|
10268
|
-
const group = categoryGroupForTree(tree, selectedCategory);
|
|
10269
|
-
if (!group) return [];
|
|
10270
|
-
return browseRowsFromSubCategories(group.subCategories, selectedSubCategory);
|
|
10841
|
+
return blocks;
|
|
10271
10842
|
}
|
|
10272
10843
|
function browseTitleForSelection(tree, selectedCategory) {
|
|
10273
10844
|
const group = categoryGroupForTree(tree, selectedCategory);
|
|
10274
|
-
|
|
10845
|
+
if (!group) return selectedCategory;
|
|
10846
|
+
const populated = group.subCategories.filter((sub) => sub.items.length > 0);
|
|
10847
|
+
if (populated.length === 1) {
|
|
10848
|
+
const onlyBucket = populated[0];
|
|
10849
|
+
if (onlyBucket.subCategory != null && onlyBucket.subCategory !== "") {
|
|
10850
|
+
return onlyBucket.subCategory;
|
|
10851
|
+
}
|
|
10852
|
+
}
|
|
10853
|
+
return group.category;
|
|
10275
10854
|
}
|
|
10276
10855
|
function inferBrowseCategoryFromItems(itemIds, itemById) {
|
|
10277
10856
|
for (let i = itemIds.length - 1; i >= 0; i--) {
|
|
@@ -10283,7 +10862,7 @@ function inferBrowseCategoryFromItems(itemIds, itemById) {
|
|
|
10283
10862
|
function matchesAddMenuSearch(item, query) {
|
|
10284
10863
|
const q = query.trim().toLowerCase();
|
|
10285
10864
|
if (!q) return false;
|
|
10286
|
-
return item.title.toLowerCase().includes(q) || item.category.toLowerCase().includes(q) || (item.subCategory ?? "").toLowerCase().includes(q) || item.id.toLowerCase().includes(q) || pluginNameForItem(item).toLowerCase().includes(q);
|
|
10865
|
+
return item.title.toLowerCase().includes(q) || item.category.toLowerCase().includes(q) || (item.subCategory ?? "").toLowerCase().includes(q) || folderPathMatchesSearch(item, q) || item.id.toLowerCase().includes(q) || pluginNameForItem(item).toLowerCase().includes(q);
|
|
10287
10866
|
}
|
|
10288
10867
|
function searchAddMenuItems(items, query) {
|
|
10289
10868
|
const q = query.trim();
|
|
@@ -10298,9 +10877,6 @@ function groupSearchItemsBySubCategory(items) {
|
|
|
10298
10877
|
list.push(item);
|
|
10299
10878
|
map2.set(key, list);
|
|
10300
10879
|
}
|
|
10301
|
-
for (const list of map2.values()) {
|
|
10302
|
-
list.sort((a2, b) => a2.title.localeCompare(b.title));
|
|
10303
|
-
}
|
|
10304
10880
|
return map2;
|
|
10305
10881
|
}
|
|
10306
10882
|
function searchSubCategoryFilterRows(items, selectedSubCategory) {
|
|
@@ -10314,40 +10890,93 @@ function searchSubCategoryFilterRows(items, selectedSubCategory) {
|
|
|
10314
10890
|
showCounts: true
|
|
10315
10891
|
});
|
|
10316
10892
|
}
|
|
10317
|
-
function
|
|
10893
|
+
function searchBrowseBlocks(items, selectedSubCategory, prefersReducedMotion = false) {
|
|
10318
10894
|
if (items.length === 0) return [];
|
|
10319
10895
|
const grouped = groupSearchItemsBySubCategory(items);
|
|
10320
10896
|
const subs = [...grouped.entries()].map(([subCategory, subItems]) => ({
|
|
10321
10897
|
subCategory: subCategory === "" ? null : subCategory,
|
|
10322
10898
|
items: subItems
|
|
10323
10899
|
}));
|
|
10324
|
-
return
|
|
10900
|
+
return browseBlocksFromSubCategories(
|
|
10901
|
+
subs,
|
|
10902
|
+
selectedSubCategory,
|
|
10903
|
+
prefersReducedMotion,
|
|
10904
|
+
true
|
|
10905
|
+
);
|
|
10906
|
+
}
|
|
10907
|
+
function countBrowsableEntries(folderRows, blocks) {
|
|
10908
|
+
return folderRows.length + countPickableBrowseBlocks(blocks);
|
|
10909
|
+
}
|
|
10910
|
+
function paginateBrowseView(folderRows, blocks, visibleLimit) {
|
|
10911
|
+
if (visibleLimit <= 0) {
|
|
10912
|
+
return { folderRows: [], blocks: [] };
|
|
10913
|
+
}
|
|
10914
|
+
const visibleFolders = folderRows.slice(0, visibleLimit);
|
|
10915
|
+
const remaining = visibleLimit - visibleFolders.length;
|
|
10916
|
+
return {
|
|
10917
|
+
folderRows: visibleFolders,
|
|
10918
|
+
blocks: paginateBrowseBlocks(blocks, remaining)
|
|
10919
|
+
};
|
|
10325
10920
|
}
|
|
10326
|
-
function
|
|
10921
|
+
function countPickableBrowseBlocks(blocks) {
|
|
10327
10922
|
let count = 0;
|
|
10328
|
-
for (const
|
|
10329
|
-
|
|
10923
|
+
for (const block of blocks) {
|
|
10924
|
+
count += pickableRowsInBlock(block).length;
|
|
10330
10925
|
}
|
|
10331
10926
|
return count;
|
|
10332
10927
|
}
|
|
10333
|
-
function
|
|
10928
|
+
function truncateBrowseBlock(block, limit) {
|
|
10929
|
+
if (block.showSectionHeader || limit <= 0) return null;
|
|
10930
|
+
if (block.showSmallStrip) {
|
|
10931
|
+
const stripCells = block.stripCells.slice(0, limit);
|
|
10932
|
+
if (stripCells.length === 0) return null;
|
|
10933
|
+
return { ...block, stripCells };
|
|
10934
|
+
}
|
|
10935
|
+
if (!block.showMediumBand) return null;
|
|
10936
|
+
let remaining = limit;
|
|
10937
|
+
const bandSlots = [];
|
|
10938
|
+
for (const slot of block.bandSlots) {
|
|
10939
|
+
if (remaining <= 0) break;
|
|
10940
|
+
if (slot.showSmallQuad) {
|
|
10941
|
+
const quadRows = slot.quadRows.slice(0, remaining);
|
|
10942
|
+
if (quadRows.length === 0) break;
|
|
10943
|
+
remaining -= quadRows.length;
|
|
10944
|
+
bandSlots.push({ ...slot, quadRows });
|
|
10945
|
+
continue;
|
|
10946
|
+
}
|
|
10947
|
+
if (slot.showMediumSlot || slot.showLargeSlot) {
|
|
10948
|
+
bandSlots.push(slot);
|
|
10949
|
+
remaining -= 1;
|
|
10950
|
+
}
|
|
10951
|
+
}
|
|
10952
|
+
if (bandSlots.length === 0) return null;
|
|
10953
|
+
return { ...block, bandSlots };
|
|
10954
|
+
}
|
|
10955
|
+
function paginateBrowseBlocks(blocks, visiblePickableLimit) {
|
|
10334
10956
|
if (visiblePickableLimit <= 0) return [];
|
|
10335
10957
|
const result = [];
|
|
10336
10958
|
let pickableCount = 0;
|
|
10337
10959
|
let pendingHeader = null;
|
|
10338
|
-
for (const
|
|
10339
|
-
if (
|
|
10340
|
-
pendingHeader =
|
|
10960
|
+
for (const block of blocks) {
|
|
10961
|
+
if (block.showSectionHeader) {
|
|
10962
|
+
pendingHeader = block;
|
|
10341
10963
|
continue;
|
|
10342
10964
|
}
|
|
10343
|
-
|
|
10344
|
-
if (
|
|
10965
|
+
const rows = pickableRowsInBlock(block);
|
|
10966
|
+
if (rows.length === 0) continue;
|
|
10967
|
+
const remaining = visiblePickableLimit - pickableCount;
|
|
10968
|
+
if (remaining <= 0) break;
|
|
10969
|
+
const blockToAdd = rows.length > remaining ? truncateBrowseBlock(block, remaining) : block;
|
|
10970
|
+
if (!blockToAdd) break;
|
|
10971
|
+
const added = pickableRowsInBlock(blockToAdd).length;
|
|
10972
|
+
if (added === 0) break;
|
|
10345
10973
|
if (pendingHeader) {
|
|
10346
10974
|
result.push(pendingHeader);
|
|
10347
10975
|
pendingHeader = null;
|
|
10348
10976
|
}
|
|
10349
|
-
result.push(
|
|
10350
|
-
pickableCount
|
|
10977
|
+
result.push(blockToAdd);
|
|
10978
|
+
pickableCount += added;
|
|
10979
|
+
if (pickableCount >= visiblePickableLimit) break;
|
|
10351
10980
|
}
|
|
10352
10981
|
return result;
|
|
10353
10982
|
}
|
|
@@ -10808,13 +11437,15 @@ function initAddPageComposer(deps) {
|
|
|
10808
11437
|
const addPageContentTabClass = createMemo(() => {
|
|
10809
11438
|
const parts = ["add-page-tab"];
|
|
10810
11439
|
if (showAddPageContentTab()) parts.push("add-page-tab--active");
|
|
10811
|
-
if (briefFillPanel.contentGenerating())
|
|
11440
|
+
if (briefFillPanel.contentGenerating())
|
|
11441
|
+
parts.push("add-page-tab--generating");
|
|
10812
11442
|
return parts.join(" ");
|
|
10813
11443
|
});
|
|
10814
11444
|
const addPageDesignTabClass = createMemo(() => {
|
|
10815
11445
|
const parts = ["add-page-tab"];
|
|
10816
11446
|
if (showAddPageDesignTab()) parts.push("add-page-tab--active");
|
|
10817
|
-
if (briefFillPanel.designGenerating())
|
|
11447
|
+
if (briefFillPanel.designGenerating())
|
|
11448
|
+
parts.push("add-page-tab--generating");
|
|
10818
11449
|
return parts.join(" ");
|
|
10819
11450
|
});
|
|
10820
11451
|
function trackTextareaSelection(el) {
|
|
@@ -11607,10 +12238,7 @@ function isMarkerImageAttachment(file) {
|
|
|
11607
12238
|
return file.type.startsWith("image/") || file.type === "";
|
|
11608
12239
|
}
|
|
11609
12240
|
function insertAttachmentReferenceAtCursor(textarea, currentValue, text, selection) {
|
|
11610
|
-
const start = Math.max(
|
|
11611
|
-
0,
|
|
11612
|
-
Math.min(selection.start, currentValue.length)
|
|
11613
|
-
);
|
|
12241
|
+
const start = Math.max(0, Math.min(selection.start, currentValue.length));
|
|
11614
12242
|
const end = Math.max(start, Math.min(selection.end, currentValue.length));
|
|
11615
12243
|
const before = currentValue.slice(0, start);
|
|
11616
12244
|
const after = currentValue.slice(end);
|
|
@@ -11637,7 +12265,7 @@ function insertTitleForAsset(asset, assets) {
|
|
|
11637
12265
|
return count >= 2 ? `${asset.title}|${asset.id}` : asset.title;
|
|
11638
12266
|
}
|
|
11639
12267
|
function assetMentionOptionFromItem(item, pageAssets) {
|
|
11640
|
-
const visual =
|
|
12268
|
+
const visual = addMenuPresentationFallbackThumb(item);
|
|
11641
12269
|
const existing = pageAssets.find(
|
|
11642
12270
|
(asset) => asset.itemId === item.id || asset.id === item.id
|
|
11643
12271
|
);
|
|
@@ -11654,167 +12282,170 @@ function assetMentionOptionFromItem(item, pageAssets) {
|
|
|
11654
12282
|
showInfoIcon: visual.showInfoIcon
|
|
11655
12283
|
};
|
|
11656
12284
|
}
|
|
11657
|
-
function
|
|
11658
|
-
|
|
11659
|
-
|
|
11660
|
-
|
|
11661
|
-
return itemsForPlugin(items, pluginName).filter(
|
|
11662
|
-
(item) => item.category === category
|
|
12285
|
+
function itemsInSubCategory(items, category, subCategory) {
|
|
12286
|
+
const group = catalogTreeForItems(items).find((g) => g.category === category);
|
|
12287
|
+
const sub = group?.subCategories.find(
|
|
12288
|
+
(entry) => (entry.subCategory ?? null) === subCategory
|
|
11663
12289
|
);
|
|
12290
|
+
return sub?.items ?? [];
|
|
11664
12291
|
}
|
|
11665
|
-
function
|
|
11666
|
-
return
|
|
11667
|
-
|
|
11668
|
-
|
|
12292
|
+
function categoryRows(items) {
|
|
12293
|
+
return catalogTreeForItems(items).map((group) => {
|
|
12294
|
+
const itemCount = group.subCategories.reduce(
|
|
12295
|
+
(sum, sub) => sum + sub.items.length,
|
|
12296
|
+
0
|
|
12297
|
+
);
|
|
12298
|
+
return {
|
|
12299
|
+
kind: "nav",
|
|
12300
|
+
rowKey: `category:${group.category}`,
|
|
12301
|
+
label: group.category,
|
|
12302
|
+
itemCount,
|
|
12303
|
+
nextPath: { category: group.category }
|
|
12304
|
+
};
|
|
12305
|
+
});
|
|
11669
12306
|
}
|
|
11670
|
-
function
|
|
11671
|
-
const
|
|
11672
|
-
|
|
11673
|
-
|
|
11674
|
-
const existing = map2.get(pluginName);
|
|
11675
|
-
if (existing) {
|
|
11676
|
-
existing.count++;
|
|
11677
|
-
} else {
|
|
11678
|
-
map2.set(pluginName, {
|
|
11679
|
-
packageName: item.packageName ?? pluginName,
|
|
11680
|
-
count: 1
|
|
11681
|
-
});
|
|
11682
|
-
}
|
|
11683
|
-
}
|
|
11684
|
-
return [...map2.entries()].sort(([a2], [b]) => a2.localeCompare(b)).map(([pluginName, { packageName, count }]) => ({
|
|
12307
|
+
function subCategoryRows(items, category) {
|
|
12308
|
+
const group = catalogTreeForItems(items).find((g) => g.category === category);
|
|
12309
|
+
if (!group) return [];
|
|
12310
|
+
return [...group.subCategories].sort((a2, b) => compareSubCategoryNames(a2.subCategory, b.subCategory)).map((sub) => ({
|
|
11685
12311
|
kind: "nav",
|
|
11686
|
-
rowKey: `
|
|
11687
|
-
label:
|
|
11688
|
-
subtitle:
|
|
11689
|
-
itemCount:
|
|
11690
|
-
nextPath: {
|
|
12312
|
+
rowKey: `sub:${category}:${sub.subCategory ?? ""}`,
|
|
12313
|
+
label: sub.subCategory ?? "General",
|
|
12314
|
+
subtitle: category,
|
|
12315
|
+
itemCount: sub.items.length,
|
|
12316
|
+
nextPath: { category, subCategory: sub.subCategory }
|
|
11691
12317
|
}));
|
|
11692
12318
|
}
|
|
11693
|
-
function
|
|
11694
|
-
|
|
11695
|
-
|
|
11696
|
-
|
|
11697
|
-
|
|
11698
|
-
|
|
11699
|
-
|
|
11700
|
-
|
|
11701
|
-
|
|
11702
|
-
|
|
11703
|
-
itemCount: count,
|
|
11704
|
-
nextPath: { pluginName, category }
|
|
11705
|
-
}));
|
|
12319
|
+
function leafRows(items, pageAssets, useSearchLabels = false) {
|
|
12320
|
+
return items.map((item) => {
|
|
12321
|
+
const option = assetMentionOptionFromItem(item, pageAssets);
|
|
12322
|
+
return {
|
|
12323
|
+
kind: "leaf",
|
|
12324
|
+
rowKey: item.id,
|
|
12325
|
+
option: useSearchLabels ? { ...option, title: addMenuSearchDisplayTitle(item) } : option,
|
|
12326
|
+
item
|
|
12327
|
+
};
|
|
12328
|
+
});
|
|
11706
12329
|
}
|
|
11707
|
-
function
|
|
11708
|
-
|
|
11709
|
-
|
|
11710
|
-
|
|
11711
|
-
|
|
11712
|
-
}
|
|
11713
|
-
return [...map2.entries()].sort(([a2], [b]) => compareSubCategoryNames(a2, b)).map(([subCategory, count]) => ({
|
|
12330
|
+
function hasChildFolders(items, folderPath) {
|
|
12331
|
+
return folderRowsFromItems(items, folderPath).length > 0;
|
|
12332
|
+
}
|
|
12333
|
+
function folderNavRows(folders, basePath) {
|
|
12334
|
+
return folders.map((folder) => ({
|
|
11714
12335
|
kind: "nav",
|
|
11715
|
-
rowKey: `
|
|
11716
|
-
label:
|
|
11717
|
-
|
|
11718
|
-
|
|
11719
|
-
|
|
12336
|
+
rowKey: `folder:${folder.rowKey}`,
|
|
12337
|
+
label: folder.label,
|
|
12338
|
+
itemCount: folder.totalItemCount,
|
|
12339
|
+
nextPath: {
|
|
12340
|
+
...basePath,
|
|
12341
|
+
folderPath: parseFolderNavKey(folder.navKey)
|
|
12342
|
+
}
|
|
11720
12343
|
}));
|
|
11721
12344
|
}
|
|
11722
|
-
function
|
|
11723
|
-
|
|
11724
|
-
|
|
11725
|
-
|
|
11726
|
-
|
|
11727
|
-
|
|
11728
|
-
|
|
12345
|
+
function folderAndLeafRows(scopedItems, folderPath, path, pageAssets) {
|
|
12346
|
+
const folders = folderRowsFromItems(scopedItems, folderPath);
|
|
12347
|
+
const leaves = leafItemsAtPath(scopedItems, folderPath);
|
|
12348
|
+
return [
|
|
12349
|
+
backRow(backLabelForPath(path)),
|
|
12350
|
+
...folderNavRows(folders, path),
|
|
12351
|
+
...leafRows(leaves, pageAssets)
|
|
12352
|
+
];
|
|
11729
12353
|
}
|
|
11730
12354
|
function backRow(label) {
|
|
11731
12355
|
return { kind: "back", rowKey: "__back__", label };
|
|
11732
12356
|
}
|
|
12357
|
+
function pathWithoutFolderPath(path) {
|
|
12358
|
+
const { folderPath: _folderPath, ...rest } = path;
|
|
12359
|
+
return rest;
|
|
12360
|
+
}
|
|
11733
12361
|
function parentPath(path) {
|
|
12362
|
+
const folderPath = path.folderPath ?? [];
|
|
12363
|
+
if (folderPath.length > 0) {
|
|
12364
|
+
const parentFolderPath = folderPath.slice(0, -1);
|
|
12365
|
+
const base = pathWithoutFolderPath(path);
|
|
12366
|
+
return parentFolderPath.length > 0 ? { ...base, folderPath: parentFolderPath } : base;
|
|
12367
|
+
}
|
|
11734
12368
|
if (path.subCategory !== void 0) {
|
|
11735
|
-
return {
|
|
12369
|
+
return { category: path.category };
|
|
11736
12370
|
}
|
|
11737
12371
|
if (path.category) {
|
|
11738
|
-
return { pluginName: path.pluginName };
|
|
11739
|
-
}
|
|
11740
|
-
if (path.pluginName) {
|
|
11741
12372
|
return {};
|
|
11742
12373
|
}
|
|
11743
12374
|
return {};
|
|
11744
12375
|
}
|
|
11745
12376
|
function mentionHeaderTitle(path) {
|
|
11746
|
-
|
|
11747
|
-
|
|
11748
|
-
|
|
12377
|
+
const folderPath = path.folderPath ?? [];
|
|
12378
|
+
if (folderPath.length > 0 && path.category) {
|
|
12379
|
+
const folderTrail = folderPath.join(" › ");
|
|
12380
|
+
if (path.subCategory !== void 0) {
|
|
12381
|
+
const sub = path.subCategory ?? "General";
|
|
12382
|
+
return `${path.category} › ${sub} › ${folderTrail}`;
|
|
12383
|
+
}
|
|
12384
|
+
return `${path.category} › ${folderTrail}`;
|
|
11749
12385
|
}
|
|
11750
|
-
if (path.
|
|
11751
|
-
|
|
12386
|
+
if (path.subCategory !== void 0 && path.category) {
|
|
12387
|
+
const sub = path.subCategory ?? "General";
|
|
12388
|
+
return `${path.category} › ${sub}`;
|
|
11752
12389
|
}
|
|
11753
|
-
if (path.
|
|
11754
|
-
return path.
|
|
12390
|
+
if (path.category) {
|
|
12391
|
+
return path.category;
|
|
11755
12392
|
}
|
|
11756
|
-
return "
|
|
12393
|
+
return "Categories";
|
|
11757
12394
|
}
|
|
11758
12395
|
function backLabelForPath(path) {
|
|
11759
|
-
|
|
11760
|
-
|
|
12396
|
+
const folderPath = path.folderPath ?? [];
|
|
12397
|
+
if (folderPath.length > 0) {
|
|
12398
|
+
if (folderPath.length === 1) {
|
|
12399
|
+
if (path.subCategory !== void 0 && path.category) {
|
|
12400
|
+
return path.subCategory ?? "General";
|
|
12401
|
+
}
|
|
12402
|
+
return path.category ?? "Categories";
|
|
12403
|
+
}
|
|
12404
|
+
return folderPath[folderPath.length - 2];
|
|
11761
12405
|
}
|
|
11762
|
-
if (path.
|
|
11763
|
-
return path.
|
|
12406
|
+
if (path.subCategory !== void 0 && path.category) {
|
|
12407
|
+
return path.category;
|
|
11764
12408
|
}
|
|
11765
|
-
if (path.
|
|
11766
|
-
return "
|
|
12409
|
+
if (path.category) {
|
|
12410
|
+
return "Categories";
|
|
11767
12411
|
}
|
|
11768
12412
|
return "";
|
|
11769
12413
|
}
|
|
11770
12414
|
function buildMentionRows(items, path, query, pageAssets) {
|
|
11771
12415
|
const q = query.trim();
|
|
11772
12416
|
if (q) {
|
|
11773
|
-
return leafRows(searchAddMenuItems(items, q), pageAssets);
|
|
12417
|
+
return leafRows(searchAddMenuItems(items, q), pageAssets, true);
|
|
11774
12418
|
}
|
|
11775
12419
|
const rows = [];
|
|
11776
|
-
if (path.
|
|
11777
|
-
|
|
11778
|
-
|
|
11779
|
-
|
|
11780
|
-
|
|
11781
|
-
|
|
11782
|
-
|
|
11783
|
-
|
|
11784
|
-
|
|
11785
|
-
|
|
11786
|
-
|
|
11787
|
-
|
|
11788
|
-
),
|
|
11789
|
-
pageAssets
|
|
11790
|
-
)
|
|
11791
|
-
];
|
|
12420
|
+
if (path.category && path.subCategory !== void 0) {
|
|
12421
|
+
const scopedItems = itemsInSubCategory(
|
|
12422
|
+
items,
|
|
12423
|
+
path.category,
|
|
12424
|
+
path.subCategory
|
|
12425
|
+
);
|
|
12426
|
+
return folderAndLeafRows(
|
|
12427
|
+
scopedItems,
|
|
12428
|
+
path.folderPath ?? [],
|
|
12429
|
+
path,
|
|
12430
|
+
pageAssets
|
|
12431
|
+
);
|
|
11792
12432
|
}
|
|
11793
|
-
if (path.
|
|
12433
|
+
if (path.category) {
|
|
11794
12434
|
rows.push(backRow(backLabelForPath(path)));
|
|
11795
|
-
const subs = subCategoryRows(items, path.
|
|
12435
|
+
const subs = subCategoryRows(items, path.category);
|
|
11796
12436
|
if (subs.length === 1 && subs[0]?.kind === "nav") {
|
|
11797
12437
|
const only = subs[0];
|
|
11798
|
-
|
|
11799
|
-
|
|
11800
|
-
|
|
11801
|
-
|
|
11802
|
-
|
|
11803
|
-
|
|
11804
|
-
|
|
11805
|
-
only.nextPath.subCategory ?? null
|
|
11806
|
-
),
|
|
11807
|
-
pageAssets
|
|
11808
|
-
)
|
|
11809
|
-
];
|
|
12438
|
+
const subCategory = only.nextPath.subCategory ?? null;
|
|
12439
|
+
const scopedItems = itemsInSubCategory(items, path.category, subCategory);
|
|
12440
|
+
const folderPath = path.folderPath ?? [];
|
|
12441
|
+
if (hasChildFolders(scopedItems, folderPath) || folderPath.length > 0) {
|
|
12442
|
+
return folderAndLeafRows(scopedItems, folderPath, path, pageAssets);
|
|
12443
|
+
}
|
|
12444
|
+
return [...rows, ...leafRows(scopedItems, pageAssets)];
|
|
11810
12445
|
}
|
|
11811
12446
|
return [...rows, ...subs];
|
|
11812
12447
|
}
|
|
11813
|
-
|
|
11814
|
-
rows.push(backRow(backLabelForPath(path)));
|
|
11815
|
-
return [...rows, ...categoryRows(items, path.pluginName)];
|
|
11816
|
-
}
|
|
11817
|
-
return pluginRows(items);
|
|
12448
|
+
return categoryRows(items);
|
|
11818
12449
|
}
|
|
11819
12450
|
const MENTION_QUERY_RE = /^[\w\-./()+:\u0590-\u05FF\u0600-\u06FF]+$/u;
|
|
11820
12451
|
function isAssetMentionTrigger(value, atIndex) {
|
|
@@ -11957,7 +12588,7 @@ function initAssetMentionAutocomplete(deps) {
|
|
|
11957
12588
|
function canHeaderGoBack() {
|
|
11958
12589
|
if (panelSearchOpen) return true;
|
|
11959
12590
|
if (isSearchMode()) return false;
|
|
11960
|
-
return !!
|
|
12591
|
+
return !!navPath.category;
|
|
11961
12592
|
}
|
|
11962
12593
|
function refreshRows() {
|
|
11963
12594
|
rows = buildMentionRows(
|
|
@@ -12157,7 +12788,10 @@ function initAssetMentionAutocomplete(deps) {
|
|
|
12157
12788
|
const row = listRows()[index];
|
|
12158
12789
|
if (!row) return;
|
|
12159
12790
|
if (row.kind === "nav") {
|
|
12160
|
-
|
|
12791
|
+
const next = row.nextPath;
|
|
12792
|
+
const categoryChanged = next.category !== void 0 && next.category !== navPath.category;
|
|
12793
|
+
const subCategoryChanged = next.subCategory !== void 0 && next.subCategory !== navPath.subCategory;
|
|
12794
|
+
navPath = categoryChanged || subCategoryChanged ? { ...next, folderPath: void 0 } : next;
|
|
12161
12795
|
selectIndex(0);
|
|
12162
12796
|
refreshRows();
|
|
12163
12797
|
syncHeader();
|
|
@@ -12950,12 +13584,58 @@ function initVisualAddMenuController(deps) {
|
|
|
12950
13584
|
}
|
|
12951
13585
|
};
|
|
12952
13586
|
}
|
|
13587
|
+
const BROWSE_SCROLL_LOAD_MORE_THRESHOLD_PX = 120;
|
|
13588
|
+
function resetBrowseContentScroll(browseContentRef) {
|
|
13589
|
+
browseContentRef?.exec$?.((element) => {
|
|
13590
|
+
element.scrollTop = 0;
|
|
13591
|
+
});
|
|
13592
|
+
}
|
|
13593
|
+
function isBrowseScrollNearBottom(element, thresholdPx = BROWSE_SCROLL_LOAD_MORE_THRESHOLD_PX) {
|
|
13594
|
+
return element.scrollTop + element.clientHeight >= element.scrollHeight - thresholdPx;
|
|
13595
|
+
}
|
|
13596
|
+
function bindAddMenuBrowseContentScrollLoadMore(options) {
|
|
13597
|
+
let detach;
|
|
13598
|
+
createEffect(() => {
|
|
13599
|
+
if (!options.isActive()) {
|
|
13600
|
+
detach?.();
|
|
13601
|
+
detach = void 0;
|
|
13602
|
+
return;
|
|
13603
|
+
}
|
|
13604
|
+
options.contentRevision();
|
|
13605
|
+
queueMicrotask(() => {
|
|
13606
|
+
options.browseContentRef?.exec$?.((element) => {
|
|
13607
|
+
detach?.();
|
|
13608
|
+
const maybeLoadMore = () => {
|
|
13609
|
+
if (!options.hasMore()) return;
|
|
13610
|
+
if (!isBrowseScrollNearBottom(element)) return;
|
|
13611
|
+
options.loadMore();
|
|
13612
|
+
};
|
|
13613
|
+
const onScroll = () => maybeLoadMore();
|
|
13614
|
+
element.addEventListener("scroll", onScroll, { passive: true });
|
|
13615
|
+
const resizeObserver = new ResizeObserver(() => maybeLoadMore());
|
|
13616
|
+
resizeObserver.observe(element);
|
|
13617
|
+
maybeLoadMore();
|
|
13618
|
+
detach = () => {
|
|
13619
|
+
element.removeEventListener("scroll", onScroll);
|
|
13620
|
+
resizeObserver.disconnect();
|
|
13621
|
+
};
|
|
13622
|
+
});
|
|
13623
|
+
});
|
|
13624
|
+
return () => {
|
|
13625
|
+
detach?.();
|
|
13626
|
+
detach = void 0;
|
|
13627
|
+
};
|
|
13628
|
+
});
|
|
13629
|
+
}
|
|
12953
13630
|
const ADD_MENU_PICKER_DISMISS_WARNING = "Your selections will not be added. Close anyway?";
|
|
12954
13631
|
function initAddMenuPickerModal(deps) {
|
|
12955
13632
|
const [open, setOpen] = createSignal(false);
|
|
12956
13633
|
const [target, setTarget] = createSignal(null);
|
|
12957
13634
|
const [selectedCategory, setSelectedCategory] = createSignal("");
|
|
12958
13635
|
const [selectedSubCategory, setSelectedSubCategory] = createSignal(null);
|
|
13636
|
+
const [selectedFolderPath, setSelectedFolderPath] = createSignal(
|
|
13637
|
+
[]
|
|
13638
|
+
);
|
|
12959
13639
|
const [searchQuery, setSearchQuery] = createSignal("");
|
|
12960
13640
|
const [catalogItems, setCatalogItems] = createSignal([]);
|
|
12961
13641
|
const [catalogLoading, setCatalogLoading] = createSignal(false);
|
|
@@ -13007,19 +13687,54 @@ function initAddMenuPickerModal(deps) {
|
|
|
13007
13687
|
);
|
|
13008
13688
|
}
|
|
13009
13689
|
);
|
|
13010
|
-
const
|
|
13011
|
-
const
|
|
13690
|
+
const addMenuPickerFullBrowseView = createMemo(() => {
|
|
13691
|
+
const reducedMotion = deps.prefersReducedMotion?.() ?? false;
|
|
13692
|
+
if (isSearchMode()) {
|
|
13693
|
+
return {
|
|
13694
|
+
folderRows: [],
|
|
13695
|
+
breadcrumbSegments: [],
|
|
13696
|
+
blocks: searchBrowseBlocks(
|
|
13697
|
+
searchMatches(),
|
|
13698
|
+
selectedSubCategory(),
|
|
13699
|
+
reducedMotion
|
|
13700
|
+
)
|
|
13701
|
+
};
|
|
13702
|
+
}
|
|
13703
|
+
return browseViewForBrowse(
|
|
13012
13704
|
catalogTree(),
|
|
13013
13705
|
selectedCategory(),
|
|
13014
|
-
selectedSubCategory()
|
|
13706
|
+
selectedSubCategory(),
|
|
13707
|
+
reducedMotion,
|
|
13708
|
+
selectedFolderPath()
|
|
13709
|
+
);
|
|
13710
|
+
});
|
|
13711
|
+
createMemo(
|
|
13712
|
+
() => addMenuPickerFullBrowseView().blocks
|
|
13713
|
+
);
|
|
13714
|
+
const addMenuPickerBrowseFolderRows = createMemo(
|
|
13715
|
+
() => addMenuPickerFullBrowseView().folderRows
|
|
13716
|
+
);
|
|
13717
|
+
const addMenuPickerBrowseBreadcrumbSegments = createMemo(
|
|
13718
|
+
() => addMenuPickerFullBrowseView().breadcrumbSegments
|
|
13719
|
+
);
|
|
13720
|
+
const addMenuPickerBrowsePickableTotal = createMemo(() => {
|
|
13721
|
+
const view = addMenuPickerFullBrowseView();
|
|
13722
|
+
return countBrowsableEntries(view.folderRows, view.blocks);
|
|
13723
|
+
});
|
|
13724
|
+
const addMenuPickerPaginatedBrowseView = createMemo(() => {
|
|
13725
|
+
const view = addMenuPickerFullBrowseView();
|
|
13726
|
+
const paginated = paginateBrowseView(
|
|
13727
|
+
view.folderRows,
|
|
13728
|
+
applySelectionToBrowseBlocks(view.blocks, selectedItemIdSet()),
|
|
13729
|
+
visibleBrowseLimit()
|
|
13015
13730
|
);
|
|
13016
|
-
return
|
|
13731
|
+
return paginated;
|
|
13017
13732
|
});
|
|
13018
|
-
const
|
|
13019
|
-
() =>
|
|
13733
|
+
const addMenuPickerBrowseBlocks = createMemo(
|
|
13734
|
+
() => addMenuPickerPaginatedBrowseView().blocks
|
|
13020
13735
|
);
|
|
13021
|
-
const
|
|
13022
|
-
() =>
|
|
13736
|
+
const addMenuPickerVisibleFolderRows = createMemo(
|
|
13737
|
+
() => addMenuPickerPaginatedBrowseView().folderRows
|
|
13023
13738
|
);
|
|
13024
13739
|
const showAddMenuPickerModal = open;
|
|
13025
13740
|
const showAddMenuPickerDismissConfirm = showDismissConfirm;
|
|
@@ -13045,8 +13760,9 @@ function initAddMenuPickerModal(deps) {
|
|
|
13045
13760
|
const showAddMenuPickerSearchSummary = showAddMenuPickerSearchMode;
|
|
13046
13761
|
const showAddMenuPickerSubCategoryFilters = createMemo(() => {
|
|
13047
13762
|
if (!showAddMenuPickerBrowse()) return false;
|
|
13763
|
+
if (addMenuPickerSubCategoryFilterRows().length === 0) return false;
|
|
13048
13764
|
if (isSearchMode()) return searchMatches().length > 0;
|
|
13049
|
-
return selectedCategory() !== ""
|
|
13765
|
+
return selectedCategory() !== "";
|
|
13050
13766
|
});
|
|
13051
13767
|
const showAddMenuPickerComponents = createMemo(() => {
|
|
13052
13768
|
if (!showAddMenuPickerBrowse()) return false;
|
|
@@ -13062,14 +13778,26 @@ function initAddMenuPickerModal(deps) {
|
|
|
13062
13778
|
addMenuPickerBrowsePickableTotal()
|
|
13063
13779
|
)
|
|
13064
13780
|
);
|
|
13065
|
-
const
|
|
13066
|
-
|
|
13067
|
-
|
|
13068
|
-
|
|
13781
|
+
const showAddMenuPickerBreadcrumb = createMemo(
|
|
13782
|
+
() => showAddMenuPickerBrowseLayout() && addMenuPickerBrowseBreadcrumbSegments().length > 0
|
|
13783
|
+
);
|
|
13784
|
+
const showAddMenuPickerFolderGrid = createMemo(
|
|
13785
|
+
() => showAddMenuPickerComponents() && !isSearchMode() && addMenuPickerVisibleFolderRows().length > 0
|
|
13786
|
+
);
|
|
13787
|
+
const showAddMenuPickerEmptyFolder = createMemo(() => {
|
|
13788
|
+
if (!showAddMenuPickerBrowse() || isSearchMode()) return false;
|
|
13789
|
+
if (!showAddMenuPickerComponents()) return false;
|
|
13790
|
+
const view = addMenuPickerFullBrowseView();
|
|
13791
|
+
return view.folderRows.length === 0 && countBrowsableEntries([], view.blocks) === 0 && selectedFolderPath().length > 0;
|
|
13069
13792
|
});
|
|
13070
13793
|
const showAddMenuPickerNoSearchResults = createMemo(
|
|
13071
13794
|
() => showAddMenuPickerSearchMode() && searchMatches().length === 0
|
|
13072
13795
|
);
|
|
13796
|
+
const showAddMenuPickerNoComponents = createMemo(() => {
|
|
13797
|
+
if (!showAddMenuPickerBrowse()) return false;
|
|
13798
|
+
if (isSearchMode()) return searchMatches().length === 0;
|
|
13799
|
+
return showAddMenuPickerComponents() && addMenuPickerBrowsePickableTotal() === 0 && !showAddMenuPickerEmptyFolder();
|
|
13800
|
+
});
|
|
13073
13801
|
const addMenuPickerOverlayClass = createMemo(
|
|
13074
13802
|
() => target()?.surface === "add-page" ? "add-menu-picker-overlay add-menu-picker-overlay--full" : "add-menu-picker-overlay"
|
|
13075
13803
|
);
|
|
@@ -13182,9 +13910,17 @@ function initAddMenuPickerModal(deps) {
|
|
|
13182
13910
|
const first = defaultCategoryForTree(tree);
|
|
13183
13911
|
if (first) setSelectedCategory(first);
|
|
13184
13912
|
}
|
|
13913
|
+
function resetFolderPath() {
|
|
13914
|
+
setSelectedFolderPath([]);
|
|
13915
|
+
}
|
|
13185
13916
|
function resetBrowsePagination() {
|
|
13186
13917
|
setVisibleBrowseLimit(ADD_MENU_BROWSE_PAGE_SIZE);
|
|
13187
13918
|
}
|
|
13919
|
+
function resetBrowseContentScrollPosition(refs) {
|
|
13920
|
+
queueMicrotask(() => {
|
|
13921
|
+
resetBrowseContentScroll(refs?.addMenuPickerBrowseContent);
|
|
13922
|
+
});
|
|
13923
|
+
}
|
|
13188
13924
|
function loadMoreBrowseItems() {
|
|
13189
13925
|
setVisibleBrowseLimit(
|
|
13190
13926
|
(prev) => Math.min(
|
|
@@ -13195,6 +13931,7 @@ function initAddMenuPickerModal(deps) {
|
|
|
13195
13931
|
}
|
|
13196
13932
|
function resetSubCategoryFilter() {
|
|
13197
13933
|
setSelectedSubCategory(null);
|
|
13934
|
+
resetFolderPath();
|
|
13198
13935
|
}
|
|
13199
13936
|
async function refreshCatalog() {
|
|
13200
13937
|
setCatalogLoading(true);
|
|
@@ -13218,6 +13955,7 @@ function initAddMenuPickerModal(deps) {
|
|
|
13218
13955
|
setTarget(nextTarget);
|
|
13219
13956
|
setSelectedCategory(options?.initialCategory ?? "");
|
|
13220
13957
|
setSelectedSubCategory(options?.initialSubCategory ?? null);
|
|
13958
|
+
setSelectedFolderPath(options?.initialFolderPath ?? []);
|
|
13221
13959
|
setSearchQuery("");
|
|
13222
13960
|
setSelectedItemIds([]);
|
|
13223
13961
|
setShowDismissConfirm(false);
|
|
@@ -13246,17 +13984,20 @@ function initAddMenuPickerModal(deps) {
|
|
|
13246
13984
|
const currentTarget = target();
|
|
13247
13985
|
const browseCategory = selectedCategory();
|
|
13248
13986
|
const browseSubCategory = selectedSubCategory();
|
|
13987
|
+
const browseFolderPath = selectedFolderPath();
|
|
13249
13988
|
setOpen(false);
|
|
13250
13989
|
setTarget(null);
|
|
13251
13990
|
setSelectedCategory("");
|
|
13252
13991
|
setSelectedSubCategory(null);
|
|
13992
|
+
setSelectedFolderPath([]);
|
|
13253
13993
|
setSearchQuery("");
|
|
13254
13994
|
setSelectedItemIds([]);
|
|
13255
13995
|
setShowDismissConfirm(false);
|
|
13256
13996
|
deps.onDismiss?.({
|
|
13257
13997
|
target: currentTarget,
|
|
13258
13998
|
category: browseCategory,
|
|
13259
|
-
subCategory: browseSubCategory
|
|
13999
|
+
subCategory: browseSubCategory,
|
|
14000
|
+
folderPath: browseFolderPath
|
|
13260
14001
|
});
|
|
13261
14002
|
const trigger = lastTrigger;
|
|
13262
14003
|
lastTrigger = null;
|
|
@@ -13264,20 +14005,26 @@ function initAddMenuPickerModal(deps) {
|
|
|
13264
14005
|
queueMicrotask(() => trigger.focus());
|
|
13265
14006
|
}
|
|
13266
14007
|
}
|
|
13267
|
-
function exitSearchMode() {
|
|
14008
|
+
function exitSearchMode(refs) {
|
|
13268
14009
|
setSearchQuery("");
|
|
13269
14010
|
resetSubCategoryFilter();
|
|
13270
14011
|
resetBrowsePagination();
|
|
14012
|
+
resetBrowseContentScrollPosition(refs);
|
|
13271
14013
|
}
|
|
13272
|
-
function handleLeftNav(navKey) {
|
|
14014
|
+
function handleLeftNav(navKey, refs) {
|
|
13273
14015
|
setSelectedCategory(navKey);
|
|
13274
|
-
|
|
13275
|
-
resetBrowsePagination();
|
|
13276
|
-
exitSearchMode();
|
|
14016
|
+
exitSearchMode(refs);
|
|
13277
14017
|
}
|
|
13278
|
-
function handleSubCategoryFilter(navKey) {
|
|
14018
|
+
function handleSubCategoryFilter(navKey, refs) {
|
|
13279
14019
|
setSelectedSubCategory(navKey === "" ? null : navKey);
|
|
14020
|
+
resetFolderPath();
|
|
14021
|
+
resetBrowsePagination();
|
|
14022
|
+
resetBrowseContentScrollPosition(refs);
|
|
14023
|
+
}
|
|
14024
|
+
function handleFolderNav(navKey, refs) {
|
|
14025
|
+
setSelectedFolderPath(parseFolderNavKey(navKey));
|
|
13280
14026
|
resetBrowsePagination();
|
|
14027
|
+
resetBrowseContentScrollPosition(refs);
|
|
13281
14028
|
}
|
|
13282
14029
|
function scrollSubCategoryFilters(direction2, fromEl) {
|
|
13283
14030
|
const root = fromEl.closest(".add-menu-picker-browse");
|
|
@@ -13312,6 +14059,16 @@ function initAddMenuPickerModal(deps) {
|
|
|
13312
14059
|
}
|
|
13313
14060
|
function bindAddMenuPickerRefs(refs) {
|
|
13314
14061
|
bindSubCategoryScrollMonitoring(refs.addMenuPickerSubCategoryFilters);
|
|
14062
|
+
bindAddMenuBrowseContentScrollLoadMore({
|
|
14063
|
+
browseContentRef: refs.addMenuPickerBrowseContent,
|
|
14064
|
+
isActive: () => showAddMenuPickerComponents(),
|
|
14065
|
+
hasMore: () => showAddMenuPickerLoadMore(),
|
|
14066
|
+
loadMore: loadMoreBrowseItems,
|
|
14067
|
+
contentRevision: () => {
|
|
14068
|
+
addMenuPickerBrowseBlocks();
|
|
14069
|
+
visibleBrowseLimit();
|
|
14070
|
+
}
|
|
14071
|
+
});
|
|
13315
14072
|
refs.addMenuPickerCloseBtn?.onclick(() => requestDismiss());
|
|
13316
14073
|
refs.addMenuPickerBackBtn?.onclick(() => requestDismiss());
|
|
13317
14074
|
refs.addMenuPickerSearchInput?.oninput(
|
|
@@ -13320,6 +14077,7 @@ function initAddMenuPickerModal(deps) {
|
|
|
13320
14077
|
setSearchQuery(value);
|
|
13321
14078
|
resetSubCategoryFilter();
|
|
13322
14079
|
resetBrowsePagination();
|
|
14080
|
+
resetBrowseContentScrollPosition(refs);
|
|
13323
14081
|
}
|
|
13324
14082
|
);
|
|
13325
14083
|
refs.addMenuPickerOverlay?.onclick(
|
|
@@ -13345,11 +14103,11 @@ function initAddMenuPickerModal(deps) {
|
|
|
13345
14103
|
const handleDialogClick = ({ event }) => {
|
|
13346
14104
|
const targetEl = event.target;
|
|
13347
14105
|
if (targetEl.closest("[data-add-menu-picker-search-back]")) {
|
|
13348
|
-
exitSearchMode();
|
|
14106
|
+
exitSearchMode(refs);
|
|
13349
14107
|
return;
|
|
13350
14108
|
}
|
|
13351
14109
|
if (targetEl.closest("[data-add-menu-picker-search-clear]")) {
|
|
13352
|
-
exitSearchMode();
|
|
14110
|
+
exitSearchMode(refs);
|
|
13353
14111
|
const input = targetEl.closest(".add-menu-picker-search-row")?.querySelector(".add-menu-picker-search-input");
|
|
13354
14112
|
if (input) input.focus();
|
|
13355
14113
|
return;
|
|
@@ -13369,14 +14127,28 @@ function initAddMenuPickerModal(deps) {
|
|
|
13369
14127
|
"[data-add-menu-picker-left-nav]"
|
|
13370
14128
|
);
|
|
13371
14129
|
if (navBtn?.dataset.navKey !== void 0) {
|
|
13372
|
-
handleLeftNav(navBtn.dataset.navKey);
|
|
14130
|
+
handleLeftNav(navBtn.dataset.navKey, refs);
|
|
13373
14131
|
return;
|
|
13374
14132
|
}
|
|
13375
14133
|
const subBtn = targetEl.closest(
|
|
13376
14134
|
"[data-add-menu-picker-subcategory-filter]"
|
|
13377
14135
|
);
|
|
13378
14136
|
if (subBtn?.dataset.navKey !== void 0) {
|
|
13379
|
-
handleSubCategoryFilter(subBtn.dataset.navKey);
|
|
14137
|
+
handleSubCategoryFilter(subBtn.dataset.navKey, refs);
|
|
14138
|
+
return;
|
|
14139
|
+
}
|
|
14140
|
+
const folderBtn = targetEl.closest(
|
|
14141
|
+
"[data-add-menu-picker-folder-nav]"
|
|
14142
|
+
);
|
|
14143
|
+
if (folderBtn?.dataset.navKey !== void 0) {
|
|
14144
|
+
handleFolderNav(folderBtn.dataset.navKey, refs);
|
|
14145
|
+
return;
|
|
14146
|
+
}
|
|
14147
|
+
const breadcrumbBtn = targetEl.closest(
|
|
14148
|
+
"[data-add-menu-picker-breadcrumb]"
|
|
14149
|
+
);
|
|
14150
|
+
if (breadcrumbBtn?.dataset.navKey !== void 0) {
|
|
14151
|
+
handleFolderNav(breadcrumbBtn.dataset.navKey, refs);
|
|
13380
14152
|
return;
|
|
13381
14153
|
}
|
|
13382
14154
|
if (targetEl.closest("[data-add-menu-picker-done]")) {
|
|
@@ -13442,7 +14214,12 @@ function initAddMenuPickerModal(deps) {
|
|
|
13442
14214
|
addMenuPickerBrowseLayoutClass,
|
|
13443
14215
|
addMenuPickerLeftNavRows,
|
|
13444
14216
|
addMenuPickerSubCategoryFilterRows,
|
|
13445
|
-
|
|
14217
|
+
addMenuPickerBrowseBlocks,
|
|
14218
|
+
addMenuPickerBrowseFolderRows,
|
|
14219
|
+
addMenuPickerBrowseBreadcrumbSegments,
|
|
14220
|
+
showAddMenuPickerBreadcrumb,
|
|
14221
|
+
showAddMenuPickerFolderGrid,
|
|
14222
|
+
showAddMenuPickerEmptyFolder,
|
|
13446
14223
|
bindAddMenuPickerRefs,
|
|
13447
14224
|
handleDocumentKeydown,
|
|
13448
14225
|
isOpen: open
|
|
@@ -13457,6 +14234,14 @@ function clampFloatingPanelPosition(left, top, panelWidth, panelHeight) {
|
|
|
13457
14234
|
top: Math.min(Math.max(8, top), maxTop)
|
|
13458
14235
|
};
|
|
13459
14236
|
}
|
|
14237
|
+
function hasPersistedPanelPosition(storageKey) {
|
|
14238
|
+
if (typeof localStorage === "undefined") return false;
|
|
14239
|
+
try {
|
|
14240
|
+
return localStorage.getItem(storageKey) !== null;
|
|
14241
|
+
} catch {
|
|
14242
|
+
return false;
|
|
14243
|
+
}
|
|
14244
|
+
}
|
|
13460
14245
|
function readPersistedPanelPosition(storageKey, defaults) {
|
|
13461
14246
|
if (typeof localStorage === "undefined") return defaults;
|
|
13462
14247
|
try {
|
|
@@ -13482,7 +14267,7 @@ const DOCK_POS_STORAGE_PREFIX = "aiditor:add-dock-pos:";
|
|
|
13482
14267
|
const DOCK_PANEL_WIDTH = 624;
|
|
13483
14268
|
const DOCK_PANEL_HEIGHT = 680;
|
|
13484
14269
|
const DOCK_DEFAULT_LEFT = 16;
|
|
13485
|
-
const DOCK_DEFAULT_TOP =
|
|
14270
|
+
const DOCK_DEFAULT_TOP = 16;
|
|
13486
14271
|
function dockPosStorageKey(projectDir) {
|
|
13487
14272
|
return `${DOCK_POS_STORAGE_PREFIX}${projectDir}`;
|
|
13488
14273
|
}
|
|
@@ -13492,12 +14277,16 @@ function initAddMenuDockPanel(deps) {
|
|
|
13492
14277
|
const [panelTop, setPanelTop] = createSignal(DOCK_DEFAULT_TOP);
|
|
13493
14278
|
const [selectedCategory, setSelectedCategory] = createSignal("");
|
|
13494
14279
|
const [selectedSubCategory, setSelectedSubCategory] = createSignal(null);
|
|
14280
|
+
const [selectedFolderPath, setSelectedFolderPath] = createSignal(
|
|
14281
|
+
[]
|
|
14282
|
+
);
|
|
13495
14283
|
const [searchQuery, setSearchQuery] = createSignal("");
|
|
13496
14284
|
const [catalogItems, setCatalogItems] = createSignal([]);
|
|
13497
14285
|
const [catalogLoading, setCatalogLoading] = createSignal(false);
|
|
13498
14286
|
const [visibleBrowseLimit, setVisibleBrowseLimit] = createSignal(
|
|
13499
14287
|
ADD_MENU_BROWSE_PAGE_SIZE
|
|
13500
14288
|
);
|
|
14289
|
+
let browseContentRef;
|
|
13501
14290
|
const catalogTree = createMemo(() => catalogTreeForItems(catalogItems()));
|
|
13502
14291
|
const isSearchMode = createMemo(() => searchQuery().trim().length > 0);
|
|
13503
14292
|
const searchMatches = createMemo(
|
|
@@ -13522,19 +14311,44 @@ function initAddMenuDockPanel(deps) {
|
|
|
13522
14311
|
/* @__PURE__ */ new Set()
|
|
13523
14312
|
);
|
|
13524
14313
|
});
|
|
13525
|
-
const
|
|
13526
|
-
const
|
|
14314
|
+
const dockFullBrowseView = createMemo(() => {
|
|
14315
|
+
const reducedMotion = deps.prefersReducedMotion?.() ?? false;
|
|
14316
|
+
if (isSearchMode()) {
|
|
14317
|
+
return {
|
|
14318
|
+
folderRows: [],
|
|
14319
|
+
breadcrumbSegments: [],
|
|
14320
|
+
blocks: searchBrowseBlocks(
|
|
14321
|
+
searchMatches(),
|
|
14322
|
+
selectedSubCategory(),
|
|
14323
|
+
reducedMotion
|
|
14324
|
+
)
|
|
14325
|
+
};
|
|
14326
|
+
}
|
|
14327
|
+
return browseViewForBrowse(
|
|
13527
14328
|
catalogTree(),
|
|
13528
14329
|
selectedCategory(),
|
|
13529
|
-
selectedSubCategory()
|
|
14330
|
+
selectedSubCategory(),
|
|
14331
|
+
reducedMotion,
|
|
14332
|
+
selectedFolderPath()
|
|
13530
14333
|
);
|
|
13531
|
-
return applySelectionToBrowseRows(base, /* @__PURE__ */ new Set());
|
|
13532
14334
|
});
|
|
13533
|
-
const dockBrowsePickableTotal = createMemo(
|
|
13534
|
-
|
|
14335
|
+
const dockBrowsePickableTotal = createMemo(() => {
|
|
14336
|
+
const view = dockFullBrowseView();
|
|
14337
|
+
return countBrowsableEntries(view.folderRows, view.blocks);
|
|
14338
|
+
});
|
|
14339
|
+
const dockPaginatedBrowseView = createMemo(
|
|
14340
|
+
() => paginateBrowseView(
|
|
14341
|
+
dockFullBrowseView().folderRows,
|
|
14342
|
+
applySelectionToBrowseBlocks(dockFullBrowseView().blocks, /* @__PURE__ */ new Set()),
|
|
14343
|
+
visibleBrowseLimit()
|
|
14344
|
+
)
|
|
14345
|
+
);
|
|
14346
|
+
const dockBrowseBlocks = createMemo(() => dockPaginatedBrowseView().blocks);
|
|
14347
|
+
const dockBrowseFolderRows = createMemo(
|
|
14348
|
+
() => dockPaginatedBrowseView().folderRows
|
|
13535
14349
|
);
|
|
13536
|
-
const
|
|
13537
|
-
() =>
|
|
14350
|
+
const dockBrowseBreadcrumbSegments = createMemo(
|
|
14351
|
+
() => dockFullBrowseView().breadcrumbSegments
|
|
13538
14352
|
);
|
|
13539
14353
|
const showAddMenuDock = open;
|
|
13540
14354
|
const showAddMenuDockLoading = createMemo(() => open() && catalogLoading());
|
|
@@ -13552,8 +14366,9 @@ function initAddMenuDockPanel(deps) {
|
|
|
13552
14366
|
);
|
|
13553
14367
|
const showAddMenuDockSubCategoryFilters = createMemo(() => {
|
|
13554
14368
|
if (!showAddMenuDockBrowse()) return false;
|
|
14369
|
+
if (dockSubCategoryFilterRows().length === 0) return false;
|
|
13555
14370
|
if (isSearchMode()) return searchMatches().length > 0;
|
|
13556
|
-
return selectedCategory() !== ""
|
|
14371
|
+
return selectedCategory() !== "";
|
|
13557
14372
|
});
|
|
13558
14373
|
const showAddMenuDockComponents = createMemo(() => {
|
|
13559
14374
|
if (!showAddMenuDockBrowse()) return false;
|
|
@@ -13563,10 +14378,22 @@ function initAddMenuDockPanel(deps) {
|
|
|
13563
14378
|
const showAddMenuDockLoadMore = createMemo(
|
|
13564
14379
|
() => showAddMenuDockComponents() && visibleBrowseLimit() < dockBrowsePickableTotal()
|
|
13565
14380
|
);
|
|
14381
|
+
const showAddMenuDockBreadcrumb = createMemo(
|
|
14382
|
+
() => showAddMenuDockBrowseLayout() && dockBrowseBreadcrumbSegments().length > 0
|
|
14383
|
+
);
|
|
14384
|
+
const showAddMenuDockFolderGrid = createMemo(
|
|
14385
|
+
() => showAddMenuDockComponents() && !isSearchMode() && dockBrowseFolderRows().length > 0
|
|
14386
|
+
);
|
|
14387
|
+
const showAddMenuDockEmptyFolder = createMemo(() => {
|
|
14388
|
+
if (!showAddMenuDockBrowse() || isSearchMode()) return false;
|
|
14389
|
+
if (!showAddMenuDockComponents()) return false;
|
|
14390
|
+
const view = dockFullBrowseView();
|
|
14391
|
+
return view.folderRows.length === 0 && countBrowsableEntries([], view.blocks) === 0 && selectedFolderPath().length > 0;
|
|
14392
|
+
});
|
|
13566
14393
|
const showAddMenuDockNoComponents = createMemo(() => {
|
|
13567
14394
|
if (!showAddMenuDockBrowse()) return false;
|
|
13568
14395
|
if (isSearchMode()) return searchMatches().length === 0;
|
|
13569
|
-
return showAddMenuDockComponents() && dockBrowsePickableTotal() === 0;
|
|
14396
|
+
return showAddMenuDockComponents() && dockBrowsePickableTotal() === 0 && !showAddMenuDockEmptyFolder();
|
|
13570
14397
|
});
|
|
13571
14398
|
const showAddMenuDockNoSearchResults = createMemo(
|
|
13572
14399
|
() => showAddMenuDockSearchMode() && searchMatches().length === 0
|
|
@@ -13609,16 +14436,20 @@ function initAddMenuDockPanel(deps) {
|
|
|
13609
14436
|
setCatalogLoading(false);
|
|
13610
14437
|
}
|
|
13611
14438
|
}
|
|
14439
|
+
function defaultPanelPosition() {
|
|
14440
|
+
const anchor = deps.getAnchorRect?.();
|
|
14441
|
+
if (anchor) {
|
|
14442
|
+
return { left: anchor.left, top: anchor.top };
|
|
14443
|
+
}
|
|
14444
|
+
return { left: DOCK_DEFAULT_LEFT, top: DOCK_DEFAULT_TOP };
|
|
14445
|
+
}
|
|
13612
14446
|
function restorePanelPosition() {
|
|
13613
14447
|
const pd = deps.projectDir();
|
|
13614
|
-
|
|
13615
|
-
const
|
|
13616
|
-
left: DOCK_DEFAULT_LEFT,
|
|
13617
|
-
top: DOCK_DEFAULT_TOP
|
|
13618
|
-
});
|
|
14448
|
+
const defaults = defaultPanelPosition();
|
|
14449
|
+
const position2 = pd && hasPersistedPanelPosition(dockPosStorageKey(pd)) ? readPersistedPanelPosition(dockPosStorageKey(pd), defaults) : defaults;
|
|
13619
14450
|
const clamped = clampFloatingPanelPosition(
|
|
13620
|
-
|
|
13621
|
-
|
|
14451
|
+
position2.left,
|
|
14452
|
+
position2.top,
|
|
13622
14453
|
DOCK_PANEL_WIDTH,
|
|
13623
14454
|
DOCK_PANEL_HEIGHT
|
|
13624
14455
|
);
|
|
@@ -13635,6 +14466,7 @@ function initAddMenuDockPanel(deps) {
|
|
|
13635
14466
|
setOpen(false);
|
|
13636
14467
|
setSearchQuery("");
|
|
13637
14468
|
setSelectedSubCategory(null);
|
|
14469
|
+
setSelectedFolderPath([]);
|
|
13638
14470
|
setVisibleBrowseLimit(ADD_MENU_BROWSE_PAGE_SIZE);
|
|
13639
14471
|
}
|
|
13640
14472
|
function toggleDock() {
|
|
@@ -13646,25 +14478,51 @@ function initAddMenuDockPanel(deps) {
|
|
|
13646
14478
|
if (!item || !isPickableAddMenuItem(item)) return;
|
|
13647
14479
|
await deps.onPickItem(item);
|
|
13648
14480
|
}
|
|
14481
|
+
function loadMoreBrowseItems() {
|
|
14482
|
+
setVisibleBrowseLimit(
|
|
14483
|
+
(prev) => Math.min(prev + ADD_MENU_BROWSE_PAGE_SIZE, dockBrowsePickableTotal())
|
|
14484
|
+
);
|
|
14485
|
+
}
|
|
14486
|
+
function resetDockBrowseScroll() {
|
|
14487
|
+
queueMicrotask(() => {
|
|
14488
|
+
resetBrowseContentScroll(browseContentRef);
|
|
14489
|
+
});
|
|
14490
|
+
}
|
|
13649
14491
|
function bindAddMenuDockRefs(refs) {
|
|
14492
|
+
browseContentRef = refs.addMenuDockBrowseContent;
|
|
13650
14493
|
refs.addMenuDockCloseBtn?.onclick(() => closeDock());
|
|
13651
14494
|
refs.addMenuDockBackdrop?.onclick(() => closeDock());
|
|
13652
14495
|
refs.addMenuDockSearchInput?.oninput(
|
|
13653
14496
|
({ event }) => {
|
|
13654
14497
|
setSearchQuery(event.target.value);
|
|
13655
14498
|
setSelectedSubCategory(null);
|
|
14499
|
+
setSelectedFolderPath([]);
|
|
13656
14500
|
setVisibleBrowseLimit(ADD_MENU_BROWSE_PAGE_SIZE);
|
|
14501
|
+
resetDockBrowseScroll();
|
|
13657
14502
|
}
|
|
13658
14503
|
);
|
|
14504
|
+
bindAddMenuBrowseContentScrollLoadMore({
|
|
14505
|
+
browseContentRef: refs.addMenuDockBrowseContent,
|
|
14506
|
+
isActive: () => showAddMenuDockComponents(),
|
|
14507
|
+
hasMore: () => showAddMenuDockLoadMore(),
|
|
14508
|
+
loadMore: loadMoreBrowseItems,
|
|
14509
|
+
contentRevision: () => {
|
|
14510
|
+
dockBrowseBlocks();
|
|
14511
|
+
visibleBrowseLimit();
|
|
14512
|
+
}
|
|
14513
|
+
});
|
|
13659
14514
|
}
|
|
13660
14515
|
function handleDockBrowseClick(targetEl) {
|
|
13661
14516
|
if (targetEl.closest("[data-add-menu-dock-search-back]")) {
|
|
13662
14517
|
setSearchQuery("");
|
|
13663
14518
|
setSelectedSubCategory(null);
|
|
14519
|
+
setSelectedFolderPath([]);
|
|
14520
|
+
resetDockBrowseScroll();
|
|
13664
14521
|
return true;
|
|
13665
14522
|
}
|
|
13666
14523
|
if (targetEl.closest("[data-add-menu-dock-search-clear]")) {
|
|
13667
14524
|
setSearchQuery("");
|
|
14525
|
+
resetDockBrowseScroll();
|
|
13668
14526
|
return true;
|
|
13669
14527
|
}
|
|
13670
14528
|
const navBtn = targetEl.closest(
|
|
@@ -13673,7 +14531,9 @@ function initAddMenuDockPanel(deps) {
|
|
|
13673
14531
|
if (navBtn?.dataset.navKey !== void 0) {
|
|
13674
14532
|
setSelectedCategory(navBtn.dataset.navKey);
|
|
13675
14533
|
setSelectedSubCategory(null);
|
|
14534
|
+
setSelectedFolderPath([]);
|
|
13676
14535
|
setVisibleBrowseLimit(ADD_MENU_BROWSE_PAGE_SIZE);
|
|
14536
|
+
resetDockBrowseScroll();
|
|
13677
14537
|
return true;
|
|
13678
14538
|
}
|
|
13679
14539
|
const subBtn = targetEl.closest(
|
|
@@ -13682,13 +14542,31 @@ function initAddMenuDockPanel(deps) {
|
|
|
13682
14542
|
if (subBtn) {
|
|
13683
14543
|
const key = subBtn.dataset.navKey ?? "";
|
|
13684
14544
|
setSelectedSubCategory(key === "" ? null : key);
|
|
14545
|
+
setSelectedFolderPath([]);
|
|
13685
14546
|
setVisibleBrowseLimit(ADD_MENU_BROWSE_PAGE_SIZE);
|
|
14547
|
+
resetDockBrowseScroll();
|
|
14548
|
+
return true;
|
|
14549
|
+
}
|
|
14550
|
+
const folderBtn = targetEl.closest(
|
|
14551
|
+
"[data-add-menu-dock-folder-nav]"
|
|
14552
|
+
);
|
|
14553
|
+
if (folderBtn?.dataset.navKey !== void 0) {
|
|
14554
|
+
setSelectedFolderPath(parseFolderNavKey(folderBtn.dataset.navKey));
|
|
14555
|
+
setVisibleBrowseLimit(ADD_MENU_BROWSE_PAGE_SIZE);
|
|
14556
|
+
resetDockBrowseScroll();
|
|
14557
|
+
return true;
|
|
14558
|
+
}
|
|
14559
|
+
const breadcrumbBtn = targetEl.closest(
|
|
14560
|
+
"[data-add-menu-dock-breadcrumb]"
|
|
14561
|
+
);
|
|
14562
|
+
if (breadcrumbBtn?.dataset.navKey !== void 0) {
|
|
14563
|
+
setSelectedFolderPath(parseFolderNavKey(breadcrumbBtn.dataset.navKey));
|
|
14564
|
+
setVisibleBrowseLimit(ADD_MENU_BROWSE_PAGE_SIZE);
|
|
14565
|
+
resetDockBrowseScroll();
|
|
13686
14566
|
return true;
|
|
13687
14567
|
}
|
|
13688
14568
|
if (targetEl.closest("[data-add-menu-dock-load-more]")) {
|
|
13689
|
-
|
|
13690
|
-
(prev) => Math.min(prev + ADD_MENU_BROWSE_PAGE_SIZE, dockBrowsePickableTotal())
|
|
13691
|
-
);
|
|
14569
|
+
loadMoreBrowseItems();
|
|
13692
14570
|
return true;
|
|
13693
14571
|
}
|
|
13694
14572
|
const card = targetEl.closest(
|
|
@@ -13726,7 +14604,12 @@ function initAddMenuDockPanel(deps) {
|
|
|
13726
14604
|
addMenuDockSearchSummary,
|
|
13727
14605
|
dockLeftNavRows,
|
|
13728
14606
|
dockSubCategoryFilterRows,
|
|
13729
|
-
|
|
14607
|
+
dockBrowseBlocks,
|
|
14608
|
+
dockBrowseFolderRows,
|
|
14609
|
+
dockBrowseBreadcrumbSegments,
|
|
14610
|
+
showAddMenuDockBreadcrumb,
|
|
14611
|
+
showAddMenuDockFolderGrid,
|
|
14612
|
+
showAddMenuDockEmptyFolder,
|
|
13730
14613
|
addMenuDockSearchQuery: searchQuery,
|
|
13731
14614
|
openDock,
|
|
13732
14615
|
closeDock,
|
|
@@ -19624,7 +20507,18 @@ function aiditorConstructor(_props, refs) {
|
|
|
19624
20507
|
const openAddMenuPicker = (target, trigger, options) => {
|
|
19625
20508
|
addMenuPicker.openModal(target, trigger, options);
|
|
19626
20509
|
};
|
|
20510
|
+
const [prefersReducedMotion, setPrefersReducedMotion] = createSignal(typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches);
|
|
20511
|
+
createEffect(() => {
|
|
20512
|
+
if (typeof window === "undefined")
|
|
20513
|
+
return;
|
|
20514
|
+
const media = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
20515
|
+
const onChange = () => setPrefersReducedMotion(media.matches);
|
|
20516
|
+
onChange();
|
|
20517
|
+
media.addEventListener("change", onChange);
|
|
20518
|
+
return () => media.removeEventListener("change", onChange);
|
|
20519
|
+
});
|
|
19627
20520
|
const addMenuPicker = initAddMenuPickerModal({
|
|
20521
|
+
prefersReducedMotion,
|
|
19628
20522
|
onDone: async (items, target) => {
|
|
19629
20523
|
if (target.surface === "add-page") {
|
|
19630
20524
|
for (const item of items) {
|
|
@@ -19704,6 +20598,14 @@ function aiditorConstructor(_props, refs) {
|
|
|
19704
20598
|
});
|
|
19705
20599
|
addMenuDock = initAddMenuDockPanel({
|
|
19706
20600
|
projectDir: () => projectDir(),
|
|
20601
|
+
prefersReducedMotion,
|
|
20602
|
+
getAnchorRect: () => {
|
|
20603
|
+
let rect = null;
|
|
20604
|
+
tryJayRefExec2(refs.harmonyStageAddBtn, (el) => {
|
|
20605
|
+
rect = el.getBoundingClientRect();
|
|
20606
|
+
});
|
|
20607
|
+
return rect;
|
|
20608
|
+
},
|
|
19707
20609
|
onBeforeOpen: () => pageInfoPanel.closePageInfoPanel(),
|
|
19708
20610
|
onPickItem: async (item) => {
|
|
19709
20611
|
if (isStagePlaceItem(item)) {
|
|
@@ -23706,7 +24608,12 @@ function aiditorConstructor(_props, refs) {
|
|
|
23706
24608
|
addMenuPickerBrowseLayoutClass: addMenuPicker.addMenuPickerBrowseLayoutClass,
|
|
23707
24609
|
addMenuPickerLeftNavRows: addMenuPicker.addMenuPickerLeftNavRows,
|
|
23708
24610
|
addMenuPickerSubCategoryFilterRows: addMenuPicker.addMenuPickerSubCategoryFilterRows,
|
|
23709
|
-
|
|
24611
|
+
addMenuPickerBrowseBlocks: addMenuPicker.addMenuPickerBrowseBlocks,
|
|
24612
|
+
addMenuPickerBrowseFolderRows: addMenuPicker.addMenuPickerBrowseFolderRows,
|
|
24613
|
+
addMenuPickerBrowseBreadcrumbSegments: addMenuPicker.addMenuPickerBrowseBreadcrumbSegments,
|
|
24614
|
+
showAddMenuPickerBreadcrumb: addMenuPicker.showAddMenuPickerBreadcrumb,
|
|
24615
|
+
showAddMenuPickerFolderGrid: addMenuPicker.showAddMenuPickerFolderGrid,
|
|
24616
|
+
showAddMenuPickerEmptyFolder: addMenuPicker.showAddMenuPickerEmptyFolder,
|
|
23710
24617
|
showPageInfoPanel: showPageInfoPanelVisible,
|
|
23711
24618
|
pageInfoPanelLeft: pageInfoPanel.panelLeft,
|
|
23712
24619
|
pageInfoPanelTop: pageInfoPanel.panelTop,
|
|
@@ -23772,7 +24679,12 @@ function aiditorConstructor(_props, refs) {
|
|
|
23772
24679
|
addMenuDockSearchSummary: addMenuDock.addMenuDockSearchSummary,
|
|
23773
24680
|
addMenuDockLeftNavRows: addMenuDock.dockLeftNavRows,
|
|
23774
24681
|
addMenuDockSubCategoryFilterRows: addMenuDock.dockSubCategoryFilterRows,
|
|
23775
|
-
|
|
24682
|
+
addMenuDockBrowseBlocks: addMenuDock.dockBrowseBlocks,
|
|
24683
|
+
addMenuDockBrowseFolderRows: addMenuDock.dockBrowseFolderRows,
|
|
24684
|
+
addMenuDockBrowseBreadcrumbSegments: addMenuDock.dockBrowseBreadcrumbSegments,
|
|
24685
|
+
showAddMenuDockBreadcrumb: addMenuDock.showAddMenuDockBreadcrumb,
|
|
24686
|
+
showAddMenuDockFolderGrid: addMenuDock.showAddMenuDockFolderGrid,
|
|
24687
|
+
showAddMenuDockEmptyFolder: addMenuDock.showAddMenuDockEmptyFolder,
|
|
23776
24688
|
addMenuDockSearchQuery: addMenuDock.addMenuDockSearchQuery,
|
|
23777
24689
|
showToastMessage,
|
|
23778
24690
|
toastMessage,
|