@adea-ai/ui 0.161.8 → 0.162.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/components/composites/catalog-browser/catalog-browser.d.ts.map +1 -1
- package/dist/components/composites/catalog-browser/catalog-browser.js +77 -40
- package/dist/components/composites/catalog-browser/catalog-browser.js.map +1 -1
- package/dist/components/composites/catalog-browser/catalog-types.d.ts +5 -0
- package/dist/components/composites/catalog-browser/catalog-types.d.ts.map +1 -1
- package/dist/components/ui/message/parse-message-text.d.ts.map +1 -1
- package/dist/components/ui/message/parse-message-text.js +7 -1
- package/dist/components/ui/message/parse-message-text.js.map +1 -1
- package/dist/lib/observe-resize.d.ts.map +1 -1
- package/dist/lib/observe-resize.js +16 -7
- package/dist/lib/observe-resize.js.map +1 -1
- package/dist/r/src/components/composites/catalog-browser/catalog-browser.tsx +27 -6
- package/dist/r/src/components/composites/catalog-browser/catalog-types.ts +5 -0
- package/dist/r/src/components/ui/message/parse-message-text.ts +9 -1
- package/dist/r/src/lib/observe-resize.ts +21 -7
- package/package.json +1 -1
- package/src/components/composites/catalog-browser/catalog-browser.tsx +27 -6
- package/src/components/composites/catalog-browser/catalog-types.ts +5 -0
- package/src/components/ui/message/parse-message-text.ts +9 -1
- package/src/lib/observe-resize.ts +21 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog-browser.d.ts","sourceRoot":"","sources":["../../../../src/components/composites/catalog-browser/catalog-browser.tsx"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAU1D,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,mBAAmB,CAAC,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"catalog-browser.d.ts","sourceRoot":"","sources":["../../../../src/components/composites/catalog-browser/catalog-browser.tsx"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAU1D,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,mBAAmB,CAAC,KAAK,CAAC,sCA0QtE"}
|
|
@@ -10,14 +10,15 @@ import { CatalogBrowserGroup, CatalogLoadingState } from "./catalog-browser-grou
|
|
|
10
10
|
import { fastIcon } from "../../../lib/fast-icon.js";
|
|
11
11
|
import { className, createComponent, effect, insert, memo, readShallow, setAttribute, template } from "@solidjs/web";
|
|
12
12
|
import { ArrowLeft, Blocks, Search } from "@lucide/solid";
|
|
13
|
-
import { For, Show, createEffect, createMemo, createSignal, onSettled } from "solid-js";
|
|
13
|
+
import { For, Show, children, createEffect, createMemo, createSignal, onSettled } from "solid-js";
|
|
14
14
|
// src/components/composites/catalog-browser/catalog-browser.tsx
|
|
15
15
|
var _tmpl$ = /* @__PURE__ */ template(`<div>`);
|
|
16
16
|
var _tmpl$2 = /* @__PURE__ */ template(`<div class="flex min-h-0 min-w-0 flex-1 flex-col gap-3"data-catalog-browser-detail><!><!>`);
|
|
17
|
-
var _tmpl$3 = /* @__PURE__ */ template(`<div class="flex min-w-0 shrink-0 flex-wrap items-center gap-2 px-4 pt-2"
|
|
18
|
-
var _tmpl$4 = /* @__PURE__ */ template(`<
|
|
19
|
-
var _tmpl$5 = /* @__PURE__ */ template(`<
|
|
20
|
-
var _tmpl$6 = /* @__PURE__ */ template(`<
|
|
17
|
+
var _tmpl$3 = /* @__PURE__ */ template(`<div class="flex min-w-0 shrink-0 flex-wrap items-center gap-2 px-4 pt-2"data-slot=catalog-browser-tabs-row><!><!>`);
|
|
18
|
+
var _tmpl$4 = /* @__PURE__ */ template(`<div class="flex min-w-0 shrink-0 flex-wrap items-center gap-2 px-4 pt-2"><!><span class="text-primary ms-auto text-sm font-medium tabular-nums"role=status>`);
|
|
19
|
+
var _tmpl$5 = /* @__PURE__ */ template(`<p class="text-destructive px-4 pt-2 text-sm"role=alert>`);
|
|
20
|
+
var _tmpl$6 = /* @__PURE__ */ template(`<div class="grid min-w-0 gap-5">`);
|
|
21
|
+
var _tmpl$7 = /* @__PURE__ */ template(`<p class="text-muted-foreground text-sm">`);
|
|
21
22
|
var ArrowLeft$1 = fastIcon(ArrowLeft);
|
|
22
23
|
var Blocks$1 = fastIcon(Blocks);
|
|
23
24
|
var Search$1 = fastIcon(Search);
|
|
@@ -90,6 +91,7 @@ function CatalogBrowser(props) {
|
|
|
90
91
|
const previewCount = () => wide() ? 6 : 3;
|
|
91
92
|
const countLabel = () => props.status === "loading" ? props.loadingLabel : props.resultLabel(props.resultCount);
|
|
92
93
|
const supplementalContent = () => props.renderSupplementalView?.(props.tab);
|
|
94
|
+
const tabsLeading = children(() => props.tabsLeading);
|
|
93
95
|
var _el$ = _tmpl$();
|
|
94
96
|
insert(_el$, (() => {
|
|
95
97
|
var _c$ = memo(() => {
|
|
@@ -134,25 +136,60 @@ function CatalogBrowser(props) {
|
|
|
134
136
|
},
|
|
135
137
|
onChange: (value) => value && props.onTabChange(value),
|
|
136
138
|
get children() {
|
|
137
|
-
return [createComponent(
|
|
138
|
-
get
|
|
139
|
-
return
|
|
139
|
+
return [createComponent(Show, {
|
|
140
|
+
get when() {
|
|
141
|
+
return tabsLeading();
|
|
140
142
|
},
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
return props.tabs;
|
|
143
|
+
get fallback() {
|
|
144
|
+
return createComponent(TabsList, {
|
|
145
|
+
get "aria-label"() {
|
|
146
|
+
return props.tabsLabel;
|
|
146
147
|
},
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
148
|
+
class: "ms-auto max-w-full flex-wrap px-4 pt-2",
|
|
149
|
+
get children() {
|
|
150
|
+
return createComponent(For, {
|
|
151
|
+
get each() {
|
|
152
|
+
return props.tabs;
|
|
153
|
+
},
|
|
154
|
+
children: (tab) => createComponent(TabsTrigger, {
|
|
155
|
+
get value() {
|
|
156
|
+
return tab.id;
|
|
157
|
+
},
|
|
158
|
+
get children() {
|
|
159
|
+
return tab.label;
|
|
160
|
+
}
|
|
161
|
+
})
|
|
162
|
+
});
|
|
163
|
+
}
|
|
155
164
|
});
|
|
165
|
+
},
|
|
166
|
+
get children() {
|
|
167
|
+
var _el$5 = _tmpl$3();
|
|
168
|
+
var _el$6 = _el$5.firstChild;
|
|
169
|
+
var _el$7 = _el$6.nextSibling;
|
|
170
|
+
insert(_el$5, tabsLeading, _el$6);
|
|
171
|
+
insert(_el$5, createComponent(TabsList, {
|
|
172
|
+
get "aria-label"() {
|
|
173
|
+
return props.tabsLabel;
|
|
174
|
+
},
|
|
175
|
+
class: "ms-auto max-w-full flex-wrap",
|
|
176
|
+
get children() {
|
|
177
|
+
return createComponent(For, {
|
|
178
|
+
get each() {
|
|
179
|
+
return props.tabs;
|
|
180
|
+
},
|
|
181
|
+
children: (tab) => createComponent(TabsTrigger, {
|
|
182
|
+
get value() {
|
|
183
|
+
return tab.id;
|
|
184
|
+
},
|
|
185
|
+
get children() {
|
|
186
|
+
return tab.label;
|
|
187
|
+
}
|
|
188
|
+
})
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
}), _el$7);
|
|
192
|
+
return _el$5;
|
|
156
193
|
}
|
|
157
194
|
}), createComponent(TabsContent, {
|
|
158
195
|
get value() {
|
|
@@ -171,19 +208,19 @@ function CatalogBrowser(props) {
|
|
|
171
208
|
return props.installError;
|
|
172
209
|
},
|
|
173
210
|
children: (message) => (() => {
|
|
174
|
-
var _el$
|
|
175
|
-
insert(_el$
|
|
176
|
-
return _el$
|
|
211
|
+
var _el$11 = _tmpl$5();
|
|
212
|
+
insert(_el$11, message);
|
|
213
|
+
return _el$11;
|
|
177
214
|
})()
|
|
178
215
|
}),
|
|
179
216
|
(() => {
|
|
180
|
-
var _el$
|
|
181
|
-
var _el$
|
|
182
|
-
var _el$
|
|
183
|
-
insert(_el$
|
|
217
|
+
var _el$8 = _tmpl$4();
|
|
218
|
+
var _el$9 = _el$8.firstChild;
|
|
219
|
+
var _el$10 = _el$9.nextSibling;
|
|
220
|
+
insert(_el$8, () => {
|
|
184
221
|
return props.filterControl;
|
|
185
|
-
}, _el$
|
|
186
|
-
insert(_el$
|
|
222
|
+
}, _el$9);
|
|
223
|
+
insert(_el$8, createComponent(InputGroup, {
|
|
187
224
|
class: "min-w-0 flex-1 sm:max-w-md",
|
|
188
225
|
get children() {
|
|
189
226
|
return [createComponent(InputGroupAddon, {
|
|
@@ -206,9 +243,9 @@ function CatalogBrowser(props) {
|
|
|
206
243
|
onInput: (event) => props.onQueryChange(event.currentTarget.value)
|
|
207
244
|
})];
|
|
208
245
|
}
|
|
209
|
-
}), _el$
|
|
210
|
-
insert(_el$
|
|
211
|
-
return _el$
|
|
246
|
+
}), _el$10);
|
|
247
|
+
insert(_el$10, countLabel);
|
|
248
|
+
return _el$8;
|
|
212
249
|
})(),
|
|
213
250
|
createComponent(ScrollArea, {
|
|
214
251
|
role: "region",
|
|
@@ -276,8 +313,8 @@ function CatalogBrowser(props) {
|
|
|
276
313
|
return memo(() => {
|
|
277
314
|
return props.resultCount > 0;
|
|
278
315
|
})() ? (() => {
|
|
279
|
-
var _el$
|
|
280
|
-
insert(_el$
|
|
316
|
+
var _el$12 = _tmpl$6();
|
|
317
|
+
insert(_el$12, createComponent(For, {
|
|
281
318
|
get each() {
|
|
282
319
|
return groupRows();
|
|
283
320
|
},
|
|
@@ -311,7 +348,7 @@ function CatalogBrowser(props) {
|
|
|
311
348
|
onToggle: toggleGroup
|
|
312
349
|
})
|
|
313
350
|
}));
|
|
314
|
-
return _el$
|
|
351
|
+
return _el$12;
|
|
315
352
|
})() : createComponent(Empty, {
|
|
316
353
|
class: "min-h-0 min-w-0 flex-1",
|
|
317
354
|
role: "status",
|
|
@@ -349,14 +386,14 @@ function CatalogBrowser(props) {
|
|
|
349
386
|
return props.notices ?? [];
|
|
350
387
|
},
|
|
351
388
|
children: (notice) => (() => {
|
|
352
|
-
var _el$
|
|
353
|
-
insert(_el$
|
|
389
|
+
var _el$13 = _tmpl$7();
|
|
390
|
+
insert(_el$13, () => {
|
|
354
391
|
return notice.message;
|
|
355
392
|
});
|
|
356
393
|
effect(() => notice.role, (_v$) => {
|
|
357
|
-
setAttribute(_el$
|
|
394
|
+
setAttribute(_el$13, "role", _v$);
|
|
358
395
|
});
|
|
359
|
-
return _el$
|
|
396
|
+
return _el$13;
|
|
360
397
|
})()
|
|
361
398
|
})
|
|
362
399
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog-browser.js","names":["<Button\n ref={(element: HTMLButtonElement) => (backButton = element)}\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => props.onBack()}\n class=\"mx-4 mt-2 self-start\"\n >\n <ArrowLeft data-icon=\"inline-start\" aria-hidden=\"true\" />\n {props.backLabel}\n </Button>","ref={(element: HTMLButtonElement) => (backButton = element)}","variant=\"ghost\"","size=\"sm\"","onClick={() => props.onBack()}","class=\"mx-4 mt-2 self-start\"","<ArrowLeft data-icon=\"inline-start\" aria-hidden=\"true\" />","props.backLabel","<div class=\"flex min-h-0 min-w-0 flex-1 flex-col gap-3\" data-catalog-browser-detail>\n <Button\n ref={(element: HTMLButtonElement) => (backButton = element)}\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => props.onBack()}\n class=\"mx-4 mt-2 self-start\"\n >\n <ArrowLeft data-icon=\"inline-start\" aria-hidden=\"true\" />\n {props.backLabel}\n </Button>\n <ScrollArea\n role=\"region\"\n aria-label={props.detailRegionLabel}\n orientation=\"vertical\"\n class=\"min-h-0 min-w-0 flex-1 px-4 pb-4\"\n >\n {props.renderDetail(entry().value)}\n </ScrollArea>\n </div>","<ScrollArea\n role=\"region\"\n aria-label={props.detailRegionLabel}\n orientation=\"vertical\"\n class=\"min-h-0 min-w-0 flex-1 px-4 pb-4\"\n >\n {props.renderDetail(entry().value)}\n </ScrollArea>","role=\"region\"","orientation=\"vertical\"","class=\"min-h-0 min-w-0 flex-1 px-4 pb-4\"","<Tabs\n class=\"flex min-h-0 min-w-0 flex-1 flex-col gap-0\"\n value={props.tab}\n onChange={(value: string | undefined) => value && props.onTabChange(value)}\n >\n <TabsList aria-label={props.tabsLabel} class=\"ms-auto max-w-full flex-wrap px-4 pt-2\">\n <For each={props.tabs}>\n {(tab) => <TabsTrigger value={tab.id}>{tab.label}</TabsTrigger>}\n </For>\n </TabsList>\n <TabsContent value={props.tab} class=\"flex min-h-0 min-w-0 flex-1 flex-col gap-3\">\n <Show\n when={supplemental()}\n fallback={\n <>\n <Show when={props.installError}>\n {(message) => (\n <p class=\"text-destructive px-4 pt-2 text-sm\" role=\"alert\">\n {message()}\n </p>\n )}\n </Show>\n <div class=\"flex min-w-0 shrink-0 flex-wrap items-center gap-2 px-4 pt-2\">\n {props.filterControl}\n <InputGroup class=\"min-w-0 flex-1 sm:max-w-md\">\n <InputGroupAddon class=\"text-primary\">\n <Search aria-hidden=\"true\" />\n </InputGroupAddon>\n <InputGroupInput\n ref={(element) => (searchInput = element)}\n type=\"search\"\n aria-label={props.searchLabel}\n placeholder={props.searchPlaceholder}\n value={props.query}\n onInput={(event) => props.onQueryChange(event.currentTarget.value)}\n />\n </InputGroup>\n <span\n class=\"text-primary ms-auto text-sm font-medium tabular-nums\"\n role=\"status\"\n >\n {countLabel()}\n </span>\n </div>\n <ScrollArea\n role=\"region\"\n aria-label={props.resultsRegionLabel}\n orientation=\"vertical\"\n class=\"flex min-h-0 min-w-0 flex-1 flex-col gap-5 px-4 pb-4\"\n >\n <Show when={props.status === 'error'}>\n <Empty\n class=\"min-h-0 min-w-0 flex-1\"\n role={props.catalogError.role ?? 'alert'}\n >\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>\n <EmptyTitle>{props.catalogError.title}</EmptyTitle>\n <EmptyDescription>{props.catalogError.description}</EmptyDescription>\n </EmptyHeader>\n <Show when={props.catalogErrorAction}>\n {(catalogErrorActionSlot) => (\n <EmptyContent>{catalogErrorActionSlot()}</EmptyContent>\n )}\n </Show>\n </Empty>\n </Show>\n <Show when={props.status === 'loading'}>\n <CatalogLoadingState label={props.loadingLabel} />\n </Show>\n <Show when={props.status === 'ready'}>\n <Show\n when={props.resultCount > 0}\n fallback={\n <Empty class=\"min-h-0 min-w-0 flex-1\" role=\"status\">\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>\n <EmptyTitle>{props.emptyState.title}</EmptyTitle>\n <EmptyDescription>{props.emptyState.description}</EmptyDescription>\n </EmptyHeader>\n <Show when={props.emptyStateAction}>\n {(emptyStateActionSlot) => (\n <EmptyContent>{emptyStateActionSlot()}</EmptyContent>\n )}\n </Show>\n </Empty>\n }\n >\n <div class=\"grid min-w-0 gap-5\">\n <For each={groupRows()}>\n {(row) => (\n <CatalogBrowserGroup\n group={row.item()}\n expanded={expandedGroups().has(row.item().id)}\n previewCount={previewCount()}\n disabled={props.interactionDisabled ?? false}\n installedLabel={props.installedLabel}\n showMoreLabel={props.showMoreLabel}\n showLessLabel={props.showLessLabel}\n renderIcon={props.renderIcon}\n onSelect={(entry, key) => selectEntry(key, entry.value)}\n onRef={registerRow}\n onToggle={toggleGroup}\n />\n )}\n </For>\n </div>\n </Show>\n </Show>\n <For each={props.notices ?? []}>\n {(notice) => (\n <p class=\"text-muted-foreground text-sm\" role={notice.role}>\n {notice.message}\n </p>\n )}\n </For>\n </ScrollArea>\n </>\n }\n >\n {supplementalContent()}\n </Show>\n </TabsContent>\n </Tabs>","class=\"flex min-h-0 min-w-0 flex-1 flex-col gap-0\"","onChange={(value: string | undefined) => value && props.onTabChange(value)}","<TabsList aria-label={props.tabsLabel} class=\"ms-auto max-w-full flex-wrap px-4 pt-2\">\n <For each={props.tabs}>\n {(tab) => <TabsTrigger value={tab.id}>{tab.label}</TabsTrigger>}\n </For>\n </TabsList>","class=\"ms-auto max-w-full flex-wrap px-4 pt-2\"","<For each={props.tabs}>\n {(tab) => <TabsTrigger value={tab.id}>{tab.label}</TabsTrigger>}\n </For>","<TabsTrigger value={tab.id}>{tab.label}</TabsTrigger>","<TabsContent value={props.tab} class=\"flex min-h-0 min-w-0 flex-1 flex-col gap-3\">\n <Show\n when={supplemental()}\n fallback={\n <>\n <Show when={props.installError}>\n {(message) => (\n <p class=\"text-destructive px-4 pt-2 text-sm\" role=\"alert\">\n {message()}\n </p>\n )}\n </Show>\n <div class=\"flex min-w-0 shrink-0 flex-wrap items-center gap-2 px-4 pt-2\">\n {props.filterControl}\n <InputGroup class=\"min-w-0 flex-1 sm:max-w-md\">\n <InputGroupAddon class=\"text-primary\">\n <Search aria-hidden=\"true\" />\n </InputGroupAddon>\n <InputGroupInput\n ref={(element) => (searchInput = element)}\n type=\"search\"\n aria-label={props.searchLabel}\n placeholder={props.searchPlaceholder}\n value={props.query}\n onInput={(event) => props.onQueryChange(event.currentTarget.value)}\n />\n </InputGroup>\n <span\n class=\"text-primary ms-auto text-sm font-medium tabular-nums\"\n role=\"status\"\n >\n {countLabel()}\n </span>\n </div>\n <ScrollArea\n role=\"region\"\n aria-label={props.resultsRegionLabel}\n orientation=\"vertical\"\n class=\"flex min-h-0 min-w-0 flex-1 flex-col gap-5 px-4 pb-4\"\n >\n <Show when={props.status === 'error'}>\n <Empty\n class=\"min-h-0 min-w-0 flex-1\"\n role={props.catalogError.role ?? 'alert'}\n >\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>\n <EmptyTitle>{props.catalogError.title}</EmptyTitle>\n <EmptyDescription>{props.catalogError.description}</EmptyDescription>\n </EmptyHeader>\n <Show when={props.catalogErrorAction}>\n {(catalogErrorActionSlot) => (\n <EmptyContent>{catalogErrorActionSlot()}</EmptyContent>\n )}\n </Show>\n </Empty>\n </Show>\n <Show when={props.status === 'loading'}>\n <CatalogLoadingState label={props.loadingLabel} />\n </Show>\n <Show when={props.status === 'ready'}>\n <Show\n when={props.resultCount > 0}\n fallback={\n <Empty class=\"min-h-0 min-w-0 flex-1\" role=\"status\">\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>\n <EmptyTitle>{props.emptyState.title}</EmptyTitle>\n <EmptyDescription>{props.emptyState.description}</EmptyDescription>\n </EmptyHeader>\n <Show when={props.emptyStateAction}>\n {(emptyStateActionSlot) => (\n <EmptyContent>{emptyStateActionSlot()}</EmptyContent>\n )}\n </Show>\n </Empty>\n }\n >\n <div class=\"grid min-w-0 gap-5\">\n <For each={groupRows()}>\n {(row) => (\n <CatalogBrowserGroup\n group={row.item()}\n expanded={expandedGroups().has(row.item().id)}\n previewCount={previewCount()}\n disabled={props.interactionDisabled ?? false}\n installedLabel={props.installedLabel}\n showMoreLabel={props.showMoreLabel}\n showLessLabel={props.showLessLabel}\n renderIcon={props.renderIcon}\n onSelect={(entry, key) => selectEntry(key, entry.value)}\n onRef={registerRow}\n onToggle={toggleGroup}\n />\n )}\n </For>\n </div>\n </Show>\n </Show>\n <For each={props.notices ?? []}>\n {(notice) => (\n <p class=\"text-muted-foreground text-sm\" role={notice.role}>\n {notice.message}\n </p>\n )}\n </For>\n </ScrollArea>\n </>\n }\n >\n {supplementalContent()}\n </Show>\n </TabsContent>","class=\"flex min-h-0 min-w-0 flex-1 flex-col gap-3\"","<Show\n when={supplemental()}\n fallback={\n <>\n <Show when={props.installError}>\n {(message) => (\n <p class=\"text-destructive px-4 pt-2 text-sm\" role=\"alert\">\n {message()}\n </p>\n )}\n </Show>\n <div class=\"flex min-w-0 shrink-0 flex-wrap items-center gap-2 px-4 pt-2\">\n {props.filterControl}\n <InputGroup class=\"min-w-0 flex-1 sm:max-w-md\">\n <InputGroupAddon class=\"text-primary\">\n <Search aria-hidden=\"true\" />\n </InputGroupAddon>\n <InputGroupInput\n ref={(element) => (searchInput = element)}\n type=\"search\"\n aria-label={props.searchLabel}\n placeholder={props.searchPlaceholder}\n value={props.query}\n onInput={(event) => props.onQueryChange(event.currentTarget.value)}\n />\n </InputGroup>\n <span\n class=\"text-primary ms-auto text-sm font-medium tabular-nums\"\n role=\"status\"\n >\n {countLabel()}\n </span>\n </div>\n <ScrollArea\n role=\"region\"\n aria-label={props.resultsRegionLabel}\n orientation=\"vertical\"\n class=\"flex min-h-0 min-w-0 flex-1 flex-col gap-5 px-4 pb-4\"\n >\n <Show when={props.status === 'error'}>\n <Empty\n class=\"min-h-0 min-w-0 flex-1\"\n role={props.catalogError.role ?? 'alert'}\n >\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>\n <EmptyTitle>{props.catalogError.title}</EmptyTitle>\n <EmptyDescription>{props.catalogError.description}</EmptyDescription>\n </EmptyHeader>\n <Show when={props.catalogErrorAction}>\n {(catalogErrorActionSlot) => (\n <EmptyContent>{catalogErrorActionSlot()}</EmptyContent>\n )}\n </Show>\n </Empty>\n </Show>\n <Show when={props.status === 'loading'}>\n <CatalogLoadingState label={props.loadingLabel} />\n </Show>\n <Show when={props.status === 'ready'}>\n <Show\n when={props.resultCount > 0}\n fallback={\n <Empty class=\"min-h-0 min-w-0 flex-1\" role=\"status\">\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>\n <EmptyTitle>{props.emptyState.title}</EmptyTitle>\n <EmptyDescription>{props.emptyState.description}</EmptyDescription>\n </EmptyHeader>\n <Show when={props.emptyStateAction}>\n {(emptyStateActionSlot) => (\n <EmptyContent>{emptyStateActionSlot()}</EmptyContent>\n )}\n </Show>\n </Empty>\n }\n >\n <div class=\"grid min-w-0 gap-5\">\n <For each={groupRows()}>\n {(row) => (\n <CatalogBrowserGroup\n group={row.item()}\n expanded={expandedGroups().has(row.item().id)}\n previewCount={previewCount()}\n disabled={props.interactionDisabled ?? false}\n installedLabel={props.installedLabel}\n showMoreLabel={props.showMoreLabel}\n showLessLabel={props.showLessLabel}\n renderIcon={props.renderIcon}\n onSelect={(entry, key) => selectEntry(key, entry.value)}\n onRef={registerRow}\n onToggle={toggleGroup}\n />\n )}\n </For>\n </div>\n </Show>\n </Show>\n <For each={props.notices ?? []}>\n {(notice) => (\n <p class=\"text-muted-foreground text-sm\" role={notice.role}>\n {notice.message}\n </p>\n )}\n </For>\n </ScrollArea>\n </>\n }\n >\n {supplementalContent()}\n </Show>","<Show when={props.installError}>\n {(message) => (\n <p class=\"text-destructive px-4 pt-2 text-sm\" role=\"alert\">\n {message()}\n </p>\n )}\n </Show>","<div class=\"flex min-w-0 shrink-0 flex-wrap items-center gap-2 px-4 pt-2\">\n {props.filterControl}\n <InputGroup class=\"min-w-0 flex-1 sm:max-w-md\">\n <InputGroupAddon class=\"text-primary\">\n <Search aria-hidden=\"true\" />\n </InputGroupAddon>\n <InputGroupInput\n ref={(element) => (searchInput = element)}\n type=\"search\"\n aria-label={props.searchLabel}\n placeholder={props.searchPlaceholder}\n value={props.query}\n onInput={(event) => props.onQueryChange(event.currentTarget.value)}\n />\n </InputGroup>\n <span\n class=\"text-primary ms-auto text-sm font-medium tabular-nums\"\n role=\"status\"\n >\n {countLabel()}\n </span>\n </div>","<InputGroup class=\"min-w-0 flex-1 sm:max-w-md\">\n <InputGroupAddon class=\"text-primary\">\n <Search aria-hidden=\"true\" />\n </InputGroupAddon>\n <InputGroupInput\n ref={(element) => (searchInput = element)}\n type=\"search\"\n aria-label={props.searchLabel}\n placeholder={props.searchPlaceholder}\n value={props.query}\n onInput={(event) => props.onQueryChange(event.currentTarget.value)}\n />\n </InputGroup>","class=\"min-w-0 flex-1 sm:max-w-md\"","<InputGroupAddon class=\"text-primary\">\n <Search aria-hidden=\"true\" />\n </InputGroupAddon>","class=\"text-primary\"","<Search aria-hidden=\"true\" />","<InputGroupInput\n ref={(element) => (searchInput = element)}\n type=\"search\"\n aria-label={props.searchLabel}\n placeholder={props.searchPlaceholder}\n value={props.query}\n onInput={(event) => props.onQueryChange(event.currentTarget.value)}\n />","ref={(element) => (searchInput = element)}","type=\"search\"","onInput={(event) => props.onQueryChange(event.currentTarget.value)}","<ScrollArea\n role=\"region\"\n aria-label={props.resultsRegionLabel}\n orientation=\"vertical\"\n class=\"flex min-h-0 min-w-0 flex-1 flex-col gap-5 px-4 pb-4\"\n >\n <Show when={props.status === 'error'}>\n <Empty\n class=\"min-h-0 min-w-0 flex-1\"\n role={props.catalogError.role ?? 'alert'}\n >\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>\n <EmptyTitle>{props.catalogError.title}</EmptyTitle>\n <EmptyDescription>{props.catalogError.description}</EmptyDescription>\n </EmptyHeader>\n <Show when={props.catalogErrorAction}>\n {(catalogErrorActionSlot) => (\n <EmptyContent>{catalogErrorActionSlot()}</EmptyContent>\n )}\n </Show>\n </Empty>\n </Show>\n <Show when={props.status === 'loading'}>\n <CatalogLoadingState label={props.loadingLabel} />\n </Show>\n <Show when={props.status === 'ready'}>\n <Show\n when={props.resultCount > 0}\n fallback={\n <Empty class=\"min-h-0 min-w-0 flex-1\" role=\"status\">\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>\n <EmptyTitle>{props.emptyState.title}</EmptyTitle>\n <EmptyDescription>{props.emptyState.description}</EmptyDescription>\n </EmptyHeader>\n <Show when={props.emptyStateAction}>\n {(emptyStateActionSlot) => (\n <EmptyContent>{emptyStateActionSlot()}</EmptyContent>\n )}\n </Show>\n </Empty>\n }\n >\n <div class=\"grid min-w-0 gap-5\">\n <For each={groupRows()}>\n {(row) => (\n <CatalogBrowserGroup\n group={row.item()}\n expanded={expandedGroups().has(row.item().id)}\n previewCount={previewCount()}\n disabled={props.interactionDisabled ?? false}\n installedLabel={props.installedLabel}\n showMoreLabel={props.showMoreLabel}\n showLessLabel={props.showLessLabel}\n renderIcon={props.renderIcon}\n onSelect={(entry, key) => selectEntry(key, entry.value)}\n onRef={registerRow}\n onToggle={toggleGroup}\n />\n )}\n </For>\n </div>\n </Show>\n </Show>\n <For each={props.notices ?? []}>\n {(notice) => (\n <p class=\"text-muted-foreground text-sm\" role={notice.role}>\n {notice.message}\n </p>\n )}\n </For>\n </ScrollArea>","class=\"flex min-h-0 min-w-0 flex-1 flex-col gap-5 px-4 pb-4\"","<Show when={props.status === 'error'}>\n <Empty\n class=\"min-h-0 min-w-0 flex-1\"\n role={props.catalogError.role ?? 'alert'}\n >\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>\n <EmptyTitle>{props.catalogError.title}</EmptyTitle>\n <EmptyDescription>{props.catalogError.description}</EmptyDescription>\n </EmptyHeader>\n <Show when={props.catalogErrorAction}>\n {(catalogErrorActionSlot) => (\n <EmptyContent>{catalogErrorActionSlot()}</EmptyContent>\n )}\n </Show>\n </Empty>\n </Show>","<Empty\n class=\"min-h-0 min-w-0 flex-1\"\n role={props.catalogError.role ?? 'alert'}\n >\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>\n <EmptyTitle>{props.catalogError.title}</EmptyTitle>\n <EmptyDescription>{props.catalogError.description}</EmptyDescription>\n </EmptyHeader>\n <Show when={props.catalogErrorAction}>\n {(catalogErrorActionSlot) => (\n <EmptyContent>{catalogErrorActionSlot()}</EmptyContent>\n )}\n </Show>\n </Empty>","class=\"min-h-0 min-w-0 flex-1\"","<EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>\n <EmptyTitle>{props.catalogError.title}</EmptyTitle>\n <EmptyDescription>{props.catalogError.description}</EmptyDescription>\n </EmptyHeader>","<EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>","variant=\"icon\"","<Blocks aria-hidden=\"true\" />","<EmptyTitle>{props.catalogError.title}</EmptyTitle>","<EmptyDescription>{props.catalogError.description}</EmptyDescription>","<Show when={props.catalogErrorAction}>\n {(catalogErrorActionSlot) => (\n <EmptyContent>{catalogErrorActionSlot()}</EmptyContent>\n )}\n </Show>","<EmptyContent>{catalogErrorActionSlot()}</EmptyContent>","<Show when={props.status === 'loading'}>\n <CatalogLoadingState label={props.loadingLabel} />\n </Show>","<CatalogLoadingState label={props.loadingLabel} />","<Show when={props.status === 'ready'}>\n <Show\n when={props.resultCount > 0}\n fallback={\n <Empty class=\"min-h-0 min-w-0 flex-1\" role=\"status\">\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>\n <EmptyTitle>{props.emptyState.title}</EmptyTitle>\n <EmptyDescription>{props.emptyState.description}</EmptyDescription>\n </EmptyHeader>\n <Show when={props.emptyStateAction}>\n {(emptyStateActionSlot) => (\n <EmptyContent>{emptyStateActionSlot()}</EmptyContent>\n )}\n </Show>\n </Empty>\n }\n >\n <div class=\"grid min-w-0 gap-5\">\n <For each={groupRows()}>\n {(row) => (\n <CatalogBrowserGroup\n group={row.item()}\n expanded={expandedGroups().has(row.item().id)}\n previewCount={previewCount()}\n disabled={props.interactionDisabled ?? false}\n installedLabel={props.installedLabel}\n showMoreLabel={props.showMoreLabel}\n showLessLabel={props.showLessLabel}\n renderIcon={props.renderIcon}\n onSelect={(entry, key) => selectEntry(key, entry.value)}\n onRef={registerRow}\n onToggle={toggleGroup}\n />\n )}\n </For>\n </div>\n </Show>\n </Show>","<Show\n when={props.resultCount > 0}\n fallback={\n <Empty class=\"min-h-0 min-w-0 flex-1\" role=\"status\">\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>\n <EmptyTitle>{props.emptyState.title}</EmptyTitle>\n <EmptyDescription>{props.emptyState.description}</EmptyDescription>\n </EmptyHeader>\n <Show when={props.emptyStateAction}>\n {(emptyStateActionSlot) => (\n <EmptyContent>{emptyStateActionSlot()}</EmptyContent>\n )}\n </Show>\n </Empty>\n }\n >\n <div class=\"grid min-w-0 gap-5\">\n <For each={groupRows()}>\n {(row) => (\n <CatalogBrowserGroup\n group={row.item()}\n expanded={expandedGroups().has(row.item().id)}\n previewCount={previewCount()}\n disabled={props.interactionDisabled ?? false}\n installedLabel={props.installedLabel}\n showMoreLabel={props.showMoreLabel}\n showLessLabel={props.showLessLabel}\n renderIcon={props.renderIcon}\n onSelect={(entry, key) => selectEntry(key, entry.value)}\n onRef={registerRow}\n onToggle={toggleGroup}\n />\n )}\n </For>\n </div>\n </Show>","<For each={groupRows()}>\n {(row) => (\n <CatalogBrowserGroup\n group={row.item()}\n expanded={expandedGroups().has(row.item().id)}\n previewCount={previewCount()}\n disabled={props.interactionDisabled ?? false}\n installedLabel={props.installedLabel}\n showMoreLabel={props.showMoreLabel}\n showLessLabel={props.showLessLabel}\n renderIcon={props.renderIcon}\n onSelect={(entry, key) => selectEntry(key, entry.value)}\n onRef={registerRow}\n onToggle={toggleGroup}\n />\n )}\n </For>","<CatalogBrowserGroup\n group={row.item()}\n expanded={expandedGroups().has(row.item().id)}\n previewCount={previewCount()}\n disabled={props.interactionDisabled ?? false}\n installedLabel={props.installedLabel}\n showMoreLabel={props.showMoreLabel}\n showLessLabel={props.showLessLabel}\n renderIcon={props.renderIcon}\n onSelect={(entry, key) => selectEntry(key, entry.value)}\n onRef={registerRow}\n onToggle={toggleGroup}\n />","onSelect={(entry, key) => selectEntry(key, entry.value)}","onRef={registerRow}","onToggle={toggleGroup}","<Empty class=\"min-h-0 min-w-0 flex-1\" role=\"status\">\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>\n <EmptyTitle>{props.emptyState.title}</EmptyTitle>\n <EmptyDescription>{props.emptyState.description}</EmptyDescription>\n </EmptyHeader>\n <Show when={props.emptyStateAction}>\n {(emptyStateActionSlot) => (\n <EmptyContent>{emptyStateActionSlot()}</EmptyContent>\n )}\n </Show>\n </Empty>","role=\"status\"","<EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>\n <EmptyTitle>{props.emptyState.title}</EmptyTitle>\n <EmptyDescription>{props.emptyState.description}</EmptyDescription>\n </EmptyHeader>","<EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>","<EmptyTitle>{props.emptyState.title}</EmptyTitle>","<EmptyDescription>{props.emptyState.description}</EmptyDescription>","<Show when={props.emptyStateAction}>\n {(emptyStateActionSlot) => (\n <EmptyContent>{emptyStateActionSlot()}</EmptyContent>\n )}\n </Show>","<EmptyContent>{emptyStateActionSlot()}</EmptyContent>","<For each={props.notices ?? []}>\n {(notice) => (\n <p class=\"text-muted-foreground text-sm\" role={notice.role}>\n {notice.message}\n </p>\n )}\n </For>","<div class={cn('flex min-h-0 min-w-0 flex-1 flex-col', props.class)}>\n <Show\n when={selected()}\n fallback={\n <Tabs\n class=\"flex min-h-0 min-w-0 flex-1 flex-col gap-0\"\n value={props.tab}\n onChange={(value: string | undefined) => value && props.onTabChange(value)}\n >\n <TabsList aria-label={props.tabsLabel} class=\"ms-auto max-w-full flex-wrap px-4 pt-2\">\n <For each={props.tabs}>\n {(tab) => <TabsTrigger value={tab.id}>{tab.label}</TabsTrigger>}\n </For>\n </TabsList>\n <TabsContent value={props.tab} class=\"flex min-h-0 min-w-0 flex-1 flex-col gap-3\">\n <Show\n when={supplemental()}\n fallback={\n <>\n <Show when={props.installError}>\n {(message) => (\n <p class=\"text-destructive px-4 pt-2 text-sm\" role=\"alert\">\n {message()}\n </p>\n )}\n </Show>\n <div class=\"flex min-w-0 shrink-0 flex-wrap items-center gap-2 px-4 pt-2\">\n {props.filterControl}\n <InputGroup class=\"min-w-0 flex-1 sm:max-w-md\">\n <InputGroupAddon class=\"text-primary\">\n <Search aria-hidden=\"true\" />\n </InputGroupAddon>\n <InputGroupInput\n ref={(element) => (searchInput = element)}\n type=\"search\"\n aria-label={props.searchLabel}\n placeholder={props.searchPlaceholder}\n value={props.query}\n onInput={(event) => props.onQueryChange(event.currentTarget.value)}\n />\n </InputGroup>\n <span\n class=\"text-primary ms-auto text-sm font-medium tabular-nums\"\n role=\"status\"\n >\n {countLabel()}\n </span>\n </div>\n <ScrollArea\n role=\"region\"\n aria-label={props.resultsRegionLabel}\n orientation=\"vertical\"\n class=\"flex min-h-0 min-w-0 flex-1 flex-col gap-5 px-4 pb-4\"\n >\n <Show when={props.status === 'error'}>\n <Empty\n class=\"min-h-0 min-w-0 flex-1\"\n role={props.catalogError.role ?? 'alert'}\n >\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>\n <EmptyTitle>{props.catalogError.title}</EmptyTitle>\n <EmptyDescription>{props.catalogError.description}</EmptyDescription>\n </EmptyHeader>\n <Show when={props.catalogErrorAction}>\n {(catalogErrorActionSlot) => (\n <EmptyContent>{catalogErrorActionSlot()}</EmptyContent>\n )}\n </Show>\n </Empty>\n </Show>\n <Show when={props.status === 'loading'}>\n <CatalogLoadingState label={props.loadingLabel} />\n </Show>\n <Show when={props.status === 'ready'}>\n <Show\n when={props.resultCount > 0}\n fallback={\n <Empty class=\"min-h-0 min-w-0 flex-1\" role=\"status\">\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>\n <EmptyTitle>{props.emptyState.title}</EmptyTitle>\n <EmptyDescription>{props.emptyState.description}</EmptyDescription>\n </EmptyHeader>\n <Show when={props.emptyStateAction}>\n {(emptyStateActionSlot) => (\n <EmptyContent>{emptyStateActionSlot()}</EmptyContent>\n )}\n </Show>\n </Empty>\n }\n >\n <div class=\"grid min-w-0 gap-5\">\n <For each={groupRows()}>\n {(row) => (\n <CatalogBrowserGroup\n group={row.item()}\n expanded={expandedGroups().has(row.item().id)}\n previewCount={previewCount()}\n disabled={props.interactionDisabled ?? false}\n installedLabel={props.installedLabel}\n showMoreLabel={props.showMoreLabel}\n showLessLabel={props.showLessLabel}\n renderIcon={props.renderIcon}\n onSelect={(entry, key) => selectEntry(key, entry.value)}\n onRef={registerRow}\n onToggle={toggleGroup}\n />\n )}\n </For>\n </div>\n </Show>\n </Show>\n <For each={props.notices ?? []}>\n {(notice) => (\n <p class=\"text-muted-foreground text-sm\" role={notice.role}>\n {notice.message}\n </p>\n )}\n </For>\n </ScrollArea>\n </>\n }\n >\n {supplementalContent()}\n </Show>\n </TabsContent>\n </Tabs>\n }\n >\n {(entry) => (\n <div class=\"flex min-h-0 min-w-0 flex-1 flex-col gap-3\" data-catalog-browser-detail>\n <Button\n ref={(element: HTMLButtonElement) => (backButton = element)}\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => props.onBack()}\n class=\"mx-4 mt-2 self-start\"\n >\n <ArrowLeft data-icon=\"inline-start\" aria-hidden=\"true\" />\n {props.backLabel}\n </Button>\n <ScrollArea\n role=\"region\"\n aria-label={props.detailRegionLabel}\n orientation=\"vertical\"\n class=\"min-h-0 min-w-0 flex-1 px-4 pb-4\"\n >\n {props.renderDetail(entry().value)}\n </ScrollArea>\n </div>\n )}\n </Show>\n </div>","ArrowLeft","LucideArrowLeft","Blocks","LucideBlocks","Search","LucideSearch","_$readShallow"],"sources":["../../../../src/components/composites/catalog-browser/catalog-browser.tsx"],"sourcesContent":["import { createEffect, createMemo, createSignal, For, onSettled, Show } from 'solid-js'\nimport {\n ArrowLeft as LucideArrowLeft,\n Blocks as LucideBlocks,\n Search as LucideSearch,\n} from '@lucide/solid'\nimport { MD_BREAKPOINT } from '#lib/breakpoints'\nimport { keyedRows } from '#lib/keyed-rows'\nimport { Button } from '../../ui/button'\nimport {\n Empty,\n EmptyContent,\n EmptyDescription,\n EmptyHeader,\n EmptyMedia,\n EmptyTitle,\n} from '../../ui/empty'\nimport { InputGroup, InputGroupAddon, InputGroupInput } from '../../ui/input-group'\nimport { Tabs, TabsContent, TabsList, TabsTrigger } from '../../ui/tabs'\nimport { ScrollArea } from '../../ui/scroll-area'\nimport { cn } from '#lib/utils'\nimport { CatalogBrowserGroup, CatalogLoadingState } from './catalog-browser-group'\nimport type { CatalogBrowserProps } from './catalog-types'\nimport { fastIcon } from '#lib/fast-icon'\n\n// lucide icons drawn from a cloned template (see fastIcon).\nconst ArrowLeft = fastIcon(LucideArrowLeft)\nconst Blocks = fastIcon(LucideBlocks)\nconst Search = fastIcon(LucideSearch)\n\nconst WIDE_QUERY = `(min-width: ${MD_BREAKPOINT})`\n\nexport function CatalogBrowser<Value>(props: CatalogBrowserProps<Value>) {\n const [expandedGroups, setExpandedGroups] = createSignal<ReadonlySet<string>>(new Set())\n const [returnKey, setReturnKey] = createSignal<string>()\n const [lastSelectedId, setLastSelectedId] = createSignal<string>()\n const rowRefs = new Map<string, HTMLButtonElement>()\n let searchInput: HTMLInputElement | undefined\n let backButton: HTMLButtonElement | undefined\n\n const selectedTab = createMemo(() => props.tabs.find((tab) => tab.id === props.tab))\n const supplemental = () => selectedTab()?.kind === 'supplemental'\n const selected = createMemo(() => {\n const id = props.selectedId\n return id && !supplemental() ? props.entries.find((entry) => entry.id === id) : undefined\n })\n const groupRows = keyedRows(\n () => props.groups,\n (group) => group.id\n )\n const [wide, setWide] = createSignal(\n typeof window === 'undefined' || window.matchMedia(WIDE_QUERY).matches\n )\n const updateWide = (event: MediaQueryListEvent) => setWide(event.matches)\n\n onSettled(() => {\n if (typeof window === 'undefined') return\n const query = window.matchMedia(WIDE_QUERY)\n query.addEventListener('change', updateWide)\n return () => query.removeEventListener('change', updateWide)\n })\n\n // Focus follows the view: into the detail's back button when an entry opens,\n // and back to the row it was opened from (or the search) when it closes. The\n // bookkeeping signals are read in the apply phase, so only the view re-runs it.\n createEffect(\n () => ({ open: props.open, selectedId: props.selectedId, selectedEntry: selected() }),\n ({ open, selectedId, selectedEntry }) => {\n if (!open) {\n setExpandedGroups(new Set<string>())\n setLastSelectedId(undefined)\n setReturnKey(undefined)\n return\n }\n if (selectedId && selectedEntry) {\n const previous = lastSelectedId()\n setLastSelectedId(selectedId)\n if (selectedId !== previous) backButton?.focus()\n return\n }\n const previous = lastSelectedId()\n if (!previous) return\n const key = returnKey()\n setLastSelectedId(undefined)\n setReturnKey(undefined)\n // The list mounts again in this same flush, and each row registers itself\n // from its own effect, which may run after this one. Look the row up once\n // the flush has finished.\n queueMicrotask(() => {\n const row = key ? rowRefs.get(key) : undefined\n if (row?.isConnected) row.focus()\n else searchInput?.focus()\n })\n }\n )\n\n const registerRow = (key: string, element: HTMLButtonElement | undefined) => {\n if (element) rowRefs.set(key, element)\n else rowRefs.delete(key)\n }\n const selectEntry = (key: string, value: Value) => {\n setReturnKey(key)\n props.onSelect(value)\n }\n const toggleGroup = (id: string) => {\n setExpandedGroups((current) => {\n const next = new Set(current)\n if (next.has(id)) next.delete(id)\n else next.add(id)\n return next\n })\n }\n const previewCount = () => (wide() ? 6 : 3)\n const countLabel = () =>\n props.status === 'loading' ? props.loadingLabel : props.resultLabel(props.resultCount)\n const supplementalContent = () => props.renderSupplementalView?.(props.tab)\n\n return (\n <div class={cn('flex min-h-0 min-w-0 flex-1 flex-col', props.class)}>\n <Show\n when={selected()}\n fallback={\n <Tabs\n class=\"flex min-h-0 min-w-0 flex-1 flex-col gap-0\"\n value={props.tab}\n onChange={(value: string | undefined) => value && props.onTabChange(value)}\n >\n <TabsList aria-label={props.tabsLabel} class=\"ms-auto max-w-full flex-wrap px-4 pt-2\">\n <For each={props.tabs}>\n {(tab) => <TabsTrigger value={tab.id}>{tab.label}</TabsTrigger>}\n </For>\n </TabsList>\n <TabsContent value={props.tab} class=\"flex min-h-0 min-w-0 flex-1 flex-col gap-3\">\n <Show\n when={supplemental()}\n fallback={\n <>\n <Show when={props.installError}>\n {(message) => (\n <p class=\"text-destructive px-4 pt-2 text-sm\" role=\"alert\">\n {message()}\n </p>\n )}\n </Show>\n <div class=\"flex min-w-0 shrink-0 flex-wrap items-center gap-2 px-4 pt-2\">\n {props.filterControl}\n <InputGroup class=\"min-w-0 flex-1 sm:max-w-md\">\n <InputGroupAddon class=\"text-primary\">\n <Search aria-hidden=\"true\" />\n </InputGroupAddon>\n <InputGroupInput\n ref={(element) => (searchInput = element)}\n type=\"search\"\n aria-label={props.searchLabel}\n placeholder={props.searchPlaceholder}\n value={props.query}\n onInput={(event) => props.onQueryChange(event.currentTarget.value)}\n />\n </InputGroup>\n <span\n class=\"text-primary ms-auto text-sm font-medium tabular-nums\"\n role=\"status\"\n >\n {countLabel()}\n </span>\n </div>\n <ScrollArea\n role=\"region\"\n aria-label={props.resultsRegionLabel}\n orientation=\"vertical\"\n class=\"flex min-h-0 min-w-0 flex-1 flex-col gap-5 px-4 pb-4\"\n >\n <Show when={props.status === 'error'}>\n <Empty\n class=\"min-h-0 min-w-0 flex-1\"\n role={props.catalogError.role ?? 'alert'}\n >\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>\n <EmptyTitle>{props.catalogError.title}</EmptyTitle>\n <EmptyDescription>{props.catalogError.description}</EmptyDescription>\n </EmptyHeader>\n <Show when={props.catalogErrorAction}>\n {(catalogErrorActionSlot) => (\n <EmptyContent>{catalogErrorActionSlot()}</EmptyContent>\n )}\n </Show>\n </Empty>\n </Show>\n <Show when={props.status === 'loading'}>\n <CatalogLoadingState label={props.loadingLabel} />\n </Show>\n <Show when={props.status === 'ready'}>\n <Show\n when={props.resultCount > 0}\n fallback={\n <Empty class=\"min-h-0 min-w-0 flex-1\" role=\"status\">\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>\n <EmptyTitle>{props.emptyState.title}</EmptyTitle>\n <EmptyDescription>{props.emptyState.description}</EmptyDescription>\n </EmptyHeader>\n <Show when={props.emptyStateAction}>\n {(emptyStateActionSlot) => (\n <EmptyContent>{emptyStateActionSlot()}</EmptyContent>\n )}\n </Show>\n </Empty>\n }\n >\n <div class=\"grid min-w-0 gap-5\">\n <For each={groupRows()}>\n {(row) => (\n <CatalogBrowserGroup\n group={row.item()}\n expanded={expandedGroups().has(row.item().id)}\n previewCount={previewCount()}\n disabled={props.interactionDisabled ?? false}\n installedLabel={props.installedLabel}\n showMoreLabel={props.showMoreLabel}\n showLessLabel={props.showLessLabel}\n renderIcon={props.renderIcon}\n onSelect={(entry, key) => selectEntry(key, entry.value)}\n onRef={registerRow}\n onToggle={toggleGroup}\n />\n )}\n </For>\n </div>\n </Show>\n </Show>\n <For each={props.notices ?? []}>\n {(notice) => (\n <p class=\"text-muted-foreground text-sm\" role={notice.role}>\n {notice.message}\n </p>\n )}\n </For>\n </ScrollArea>\n </>\n }\n >\n {supplementalContent()}\n </Show>\n </TabsContent>\n </Tabs>\n }\n >\n {(entry) => (\n <div class=\"flex min-h-0 min-w-0 flex-1 flex-col gap-3\" data-catalog-browser-detail>\n <Button\n ref={(element: HTMLButtonElement) => (backButton = element)}\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => props.onBack()}\n class=\"mx-4 mt-2 self-start\"\n >\n <ArrowLeft data-icon=\"inline-start\" aria-hidden=\"true\" />\n {props.backLabel}\n </Button>\n <ScrollArea\n role=\"region\"\n aria-label={props.detailRegionLabel}\n orientation=\"vertical\"\n class=\"min-h-0 min-w-0 flex-1 px-4 pb-4\"\n >\n {props.renderDetail(entry().value)}\n </ScrollArea>\n </div>\n )}\n </Show>\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA0BA,IAAMkE,cAAY,SAASC,SAAe;AAC1C,IAAMC,WAAS,SAASC,MAAY;AACpC,IAAMC,WAAS,SAASC,MAAY;AAEpC,IAAM,aAAa,eAAe,cAAc;AAEhD,SAAgB,eAAsB,OAAmC;CACvE,MAAM,CAAC,gBAAgB,qBAAqB,6BAAkC,IAAI,IAAI,CAAC;CACvF,MAAM,CAAC,WAAW,gBAAgB,aAAqB;CACvD,MAAM,CAAC,gBAAgB,qBAAqB,aAAqB;CACjE,MAAM,0BAAU,IA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ButtonElement) => (backButton = element)}\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => props.onBack()}\n class=\"mx-4 mt-2 self-start\"\n >\n <ArrowLeft data-icon=\"inline-start\" aria-hidden=\"true\" />\n {props.backLabel}\n </Button>","ref={(element: HTMLButtonElement) => (backButton = element)}","variant=\"ghost\"","size=\"sm\"","onClick={() => props.onBack()}","class=\"mx-4 mt-2 self-start\"","<ArrowLeft data-icon=\"inline-start\" aria-hidden=\"true\" />","props.backLabel","<div class=\"flex min-h-0 min-w-0 flex-1 flex-col gap-3\" data-catalog-browser-detail>\n <Button\n ref={(element: HTMLButtonElement) => (backButton = element)}\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => props.onBack()}\n class=\"mx-4 mt-2 self-start\"\n >\n <ArrowLeft data-icon=\"inline-start\" aria-hidden=\"true\" />\n {props.backLabel}\n </Button>\n <ScrollArea\n role=\"region\"\n aria-label={props.detailRegionLabel}\n orientation=\"vertical\"\n class=\"min-h-0 min-w-0 flex-1 px-4 pb-4\"\n >\n {props.renderDetail(entry().value)}\n </ScrollArea>\n </div>","<ScrollArea\n role=\"region\"\n aria-label={props.detailRegionLabel}\n orientation=\"vertical\"\n class=\"min-h-0 min-w-0 flex-1 px-4 pb-4\"\n >\n {props.renderDetail(entry().value)}\n </ScrollArea>","role=\"region\"","orientation=\"vertical\"","class=\"min-h-0 min-w-0 flex-1 px-4 pb-4\"","<Tabs\n class=\"flex min-h-0 min-w-0 flex-1 flex-col gap-0\"\n value={props.tab}\n onChange={(value: string | undefined) => value && props.onTabChange(value)}\n >\n <Show\n when={tabsLeading()}\n fallback={\n <TabsList\n aria-label={props.tabsLabel}\n class=\"ms-auto max-w-full flex-wrap px-4 pt-2\"\n >\n <For each={props.tabs}>\n {(tab) => <TabsTrigger value={tab.id}>{tab.label}</TabsTrigger>}\n </For>\n </TabsList>\n }\n >\n <div\n class=\"flex min-w-0 shrink-0 flex-wrap items-center gap-2 px-4 pt-2\"\n data-slot=\"catalog-browser-tabs-row\"\n >\n {tabsLeading()}\n <TabsList aria-label={props.tabsLabel} class=\"ms-auto max-w-full flex-wrap\">\n <For each={props.tabs}>\n {(tab) => <TabsTrigger value={tab.id}>{tab.label}</TabsTrigger>}\n </For>\n </TabsList>\n </div>\n </Show>\n <TabsContent value={props.tab} class=\"flex min-h-0 min-w-0 flex-1 flex-col gap-3\">\n <Show\n when={supplemental()}\n fallback={\n <>\n <Show when={props.installError}>\n {(message) => (\n <p class=\"text-destructive px-4 pt-2 text-sm\" role=\"alert\">\n {message()}\n </p>\n )}\n </Show>\n <div class=\"flex min-w-0 shrink-0 flex-wrap items-center gap-2 px-4 pt-2\">\n {props.filterControl}\n <InputGroup class=\"min-w-0 flex-1 sm:max-w-md\">\n <InputGroupAddon class=\"text-primary\">\n <Search aria-hidden=\"true\" />\n </InputGroupAddon>\n <InputGroupInput\n ref={(element) => (searchInput = element)}\n type=\"search\"\n aria-label={props.searchLabel}\n placeholder={props.searchPlaceholder}\n value={props.query}\n onInput={(event) => props.onQueryChange(event.currentTarget.value)}\n />\n </InputGroup>\n <span\n class=\"text-primary ms-auto text-sm font-medium tabular-nums\"\n role=\"status\"\n >\n {countLabel()}\n </span>\n </div>\n <ScrollArea\n role=\"region\"\n aria-label={props.resultsRegionLabel}\n orientation=\"vertical\"\n class=\"flex min-h-0 min-w-0 flex-1 flex-col gap-5 px-4 pb-4\"\n >\n <Show when={props.status === 'error'}>\n <Empty\n class=\"min-h-0 min-w-0 flex-1\"\n role={props.catalogError.role ?? 'alert'}\n >\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>\n <EmptyTitle>{props.catalogError.title}</EmptyTitle>\n <EmptyDescription>{props.catalogError.description}</EmptyDescription>\n </EmptyHeader>\n <Show when={props.catalogErrorAction}>\n {(catalogErrorActionSlot) => (\n <EmptyContent>{catalogErrorActionSlot()}</EmptyContent>\n )}\n </Show>\n </Empty>\n </Show>\n <Show when={props.status === 'loading'}>\n <CatalogLoadingState label={props.loadingLabel} />\n </Show>\n <Show when={props.status === 'ready'}>\n <Show\n when={props.resultCount > 0}\n fallback={\n <Empty class=\"min-h-0 min-w-0 flex-1\" role=\"status\">\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>\n <EmptyTitle>{props.emptyState.title}</EmptyTitle>\n <EmptyDescription>{props.emptyState.description}</EmptyDescription>\n </EmptyHeader>\n <Show when={props.emptyStateAction}>\n {(emptyStateActionSlot) => (\n <EmptyContent>{emptyStateActionSlot()}</EmptyContent>\n )}\n </Show>\n </Empty>\n }\n >\n <div class=\"grid min-w-0 gap-5\">\n <For each={groupRows()}>\n {(row) => (\n <CatalogBrowserGroup\n group={row.item()}\n expanded={expandedGroups().has(row.item().id)}\n previewCount={previewCount()}\n disabled={props.interactionDisabled ?? false}\n installedLabel={props.installedLabel}\n showMoreLabel={props.showMoreLabel}\n showLessLabel={props.showLessLabel}\n renderIcon={props.renderIcon}\n onSelect={(entry, key) => selectEntry(key, entry.value)}\n onRef={registerRow}\n onToggle={toggleGroup}\n />\n )}\n </For>\n </div>\n </Show>\n </Show>\n <For each={props.notices ?? []}>\n {(notice) => (\n <p class=\"text-muted-foreground text-sm\" role={notice.role}>\n {notice.message}\n </p>\n )}\n </For>\n </ScrollArea>\n </>\n }\n >\n {supplementalContent()}\n </Show>\n </TabsContent>\n </Tabs>","class=\"flex min-h-0 min-w-0 flex-1 flex-col gap-0\"","onChange={(value: string | undefined) => value && props.onTabChange(value)}","<Show\n when={tabsLeading()}\n fallback={\n <TabsList\n aria-label={props.tabsLabel}\n class=\"ms-auto max-w-full flex-wrap px-4 pt-2\"\n >\n <For each={props.tabs}>\n {(tab) => <TabsTrigger value={tab.id}>{tab.label}</TabsTrigger>}\n </For>\n </TabsList>\n }\n >\n <div\n class=\"flex min-w-0 shrink-0 flex-wrap items-center gap-2 px-4 pt-2\"\n data-slot=\"catalog-browser-tabs-row\"\n >\n {tabsLeading()}\n <TabsList aria-label={props.tabsLabel} class=\"ms-auto max-w-full flex-wrap\">\n <For each={props.tabs}>\n {(tab) => <TabsTrigger value={tab.id}>{tab.label}</TabsTrigger>}\n </For>\n </TabsList>\n </div>\n </Show>","<TabsList\n aria-label={props.tabsLabel}\n class=\"ms-auto max-w-full flex-wrap px-4 pt-2\"\n >\n <For each={props.tabs}>\n {(tab) => <TabsTrigger value={tab.id}>{tab.label}</TabsTrigger>}\n </For>\n </TabsList>","class=\"ms-auto max-w-full flex-wrap px-4 pt-2\"","<For each={props.tabs}>\n {(tab) => <TabsTrigger value={tab.id}>{tab.label}</TabsTrigger>}\n </For>","<TabsTrigger value={tab.id}>{tab.label}</TabsTrigger>","<div\n class=\"flex min-w-0 shrink-0 flex-wrap items-center gap-2 px-4 pt-2\"\n data-slot=\"catalog-browser-tabs-row\"\n >\n {tabsLeading()}\n <TabsList aria-label={props.tabsLabel} class=\"ms-auto max-w-full flex-wrap\">\n <For each={props.tabs}>\n {(tab) => <TabsTrigger value={tab.id}>{tab.label}</TabsTrigger>}\n </For>\n </TabsList>\n </div>","<TabsList aria-label={props.tabsLabel} class=\"ms-auto max-w-full flex-wrap\">\n <For each={props.tabs}>\n {(tab) => <TabsTrigger value={tab.id}>{tab.label}</TabsTrigger>}\n </For>\n </TabsList>","class=\"ms-auto max-w-full flex-wrap\"","<TabsContent value={props.tab} class=\"flex min-h-0 min-w-0 flex-1 flex-col gap-3\">\n <Show\n when={supplemental()}\n fallback={\n <>\n <Show when={props.installError}>\n {(message) => (\n <p class=\"text-destructive px-4 pt-2 text-sm\" role=\"alert\">\n {message()}\n </p>\n )}\n </Show>\n <div class=\"flex min-w-0 shrink-0 flex-wrap items-center gap-2 px-4 pt-2\">\n {props.filterControl}\n <InputGroup class=\"min-w-0 flex-1 sm:max-w-md\">\n <InputGroupAddon class=\"text-primary\">\n <Search aria-hidden=\"true\" />\n </InputGroupAddon>\n <InputGroupInput\n ref={(element) => (searchInput = element)}\n type=\"search\"\n aria-label={props.searchLabel}\n placeholder={props.searchPlaceholder}\n value={props.query}\n onInput={(event) => props.onQueryChange(event.currentTarget.value)}\n />\n </InputGroup>\n <span\n class=\"text-primary ms-auto text-sm font-medium tabular-nums\"\n role=\"status\"\n >\n {countLabel()}\n </span>\n </div>\n <ScrollArea\n role=\"region\"\n aria-label={props.resultsRegionLabel}\n orientation=\"vertical\"\n class=\"flex min-h-0 min-w-0 flex-1 flex-col gap-5 px-4 pb-4\"\n >\n <Show when={props.status === 'error'}>\n <Empty\n class=\"min-h-0 min-w-0 flex-1\"\n role={props.catalogError.role ?? 'alert'}\n >\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>\n <EmptyTitle>{props.catalogError.title}</EmptyTitle>\n <EmptyDescription>{props.catalogError.description}</EmptyDescription>\n </EmptyHeader>\n <Show when={props.catalogErrorAction}>\n {(catalogErrorActionSlot) => (\n <EmptyContent>{catalogErrorActionSlot()}</EmptyContent>\n )}\n </Show>\n </Empty>\n </Show>\n <Show when={props.status === 'loading'}>\n <CatalogLoadingState label={props.loadingLabel} />\n </Show>\n <Show when={props.status === 'ready'}>\n <Show\n when={props.resultCount > 0}\n fallback={\n <Empty class=\"min-h-0 min-w-0 flex-1\" role=\"status\">\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>\n <EmptyTitle>{props.emptyState.title}</EmptyTitle>\n <EmptyDescription>{props.emptyState.description}</EmptyDescription>\n </EmptyHeader>\n <Show when={props.emptyStateAction}>\n {(emptyStateActionSlot) => (\n <EmptyContent>{emptyStateActionSlot()}</EmptyContent>\n )}\n </Show>\n </Empty>\n }\n >\n <div class=\"grid min-w-0 gap-5\">\n <For each={groupRows()}>\n {(row) => (\n <CatalogBrowserGroup\n group={row.item()}\n expanded={expandedGroups().has(row.item().id)}\n previewCount={previewCount()}\n disabled={props.interactionDisabled ?? false}\n installedLabel={props.installedLabel}\n showMoreLabel={props.showMoreLabel}\n showLessLabel={props.showLessLabel}\n renderIcon={props.renderIcon}\n onSelect={(entry, key) => selectEntry(key, entry.value)}\n onRef={registerRow}\n onToggle={toggleGroup}\n />\n )}\n </For>\n </div>\n </Show>\n </Show>\n <For each={props.notices ?? []}>\n {(notice) => (\n <p class=\"text-muted-foreground text-sm\" role={notice.role}>\n {notice.message}\n </p>\n )}\n </For>\n </ScrollArea>\n </>\n }\n >\n {supplementalContent()}\n </Show>\n </TabsContent>","class=\"flex min-h-0 min-w-0 flex-1 flex-col gap-3\"","<Show\n when={supplemental()}\n fallback={\n <>\n <Show when={props.installError}>\n {(message) => (\n <p class=\"text-destructive px-4 pt-2 text-sm\" role=\"alert\">\n {message()}\n </p>\n )}\n </Show>\n <div class=\"flex min-w-0 shrink-0 flex-wrap items-center gap-2 px-4 pt-2\">\n {props.filterControl}\n <InputGroup class=\"min-w-0 flex-1 sm:max-w-md\">\n <InputGroupAddon class=\"text-primary\">\n <Search aria-hidden=\"true\" />\n </InputGroupAddon>\n <InputGroupInput\n ref={(element) => (searchInput = element)}\n type=\"search\"\n aria-label={props.searchLabel}\n placeholder={props.searchPlaceholder}\n value={props.query}\n onInput={(event) => props.onQueryChange(event.currentTarget.value)}\n />\n </InputGroup>\n <span\n class=\"text-primary ms-auto text-sm font-medium tabular-nums\"\n role=\"status\"\n >\n {countLabel()}\n </span>\n </div>\n <ScrollArea\n role=\"region\"\n aria-label={props.resultsRegionLabel}\n orientation=\"vertical\"\n class=\"flex min-h-0 min-w-0 flex-1 flex-col gap-5 px-4 pb-4\"\n >\n <Show when={props.status === 'error'}>\n <Empty\n class=\"min-h-0 min-w-0 flex-1\"\n role={props.catalogError.role ?? 'alert'}\n >\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>\n <EmptyTitle>{props.catalogError.title}</EmptyTitle>\n <EmptyDescription>{props.catalogError.description}</EmptyDescription>\n </EmptyHeader>\n <Show when={props.catalogErrorAction}>\n {(catalogErrorActionSlot) => (\n <EmptyContent>{catalogErrorActionSlot()}</EmptyContent>\n )}\n </Show>\n </Empty>\n </Show>\n <Show when={props.status === 'loading'}>\n <CatalogLoadingState label={props.loadingLabel} />\n </Show>\n <Show when={props.status === 'ready'}>\n <Show\n when={props.resultCount > 0}\n fallback={\n <Empty class=\"min-h-0 min-w-0 flex-1\" role=\"status\">\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>\n <EmptyTitle>{props.emptyState.title}</EmptyTitle>\n <EmptyDescription>{props.emptyState.description}</EmptyDescription>\n </EmptyHeader>\n <Show when={props.emptyStateAction}>\n {(emptyStateActionSlot) => (\n <EmptyContent>{emptyStateActionSlot()}</EmptyContent>\n )}\n </Show>\n </Empty>\n }\n >\n <div class=\"grid min-w-0 gap-5\">\n <For each={groupRows()}>\n {(row) => (\n <CatalogBrowserGroup\n group={row.item()}\n expanded={expandedGroups().has(row.item().id)}\n previewCount={previewCount()}\n disabled={props.interactionDisabled ?? false}\n installedLabel={props.installedLabel}\n showMoreLabel={props.showMoreLabel}\n showLessLabel={props.showLessLabel}\n renderIcon={props.renderIcon}\n onSelect={(entry, key) => selectEntry(key, entry.value)}\n onRef={registerRow}\n onToggle={toggleGroup}\n />\n )}\n </For>\n </div>\n </Show>\n </Show>\n <For each={props.notices ?? []}>\n {(notice) => (\n <p class=\"text-muted-foreground text-sm\" role={notice.role}>\n {notice.message}\n </p>\n )}\n </For>\n </ScrollArea>\n </>\n }\n >\n {supplementalContent()}\n </Show>","<Show when={props.installError}>\n {(message) => (\n <p class=\"text-destructive px-4 pt-2 text-sm\" role=\"alert\">\n {message()}\n </p>\n )}\n </Show>","<div class=\"flex min-w-0 shrink-0 flex-wrap items-center gap-2 px-4 pt-2\">\n {props.filterControl}\n <InputGroup class=\"min-w-0 flex-1 sm:max-w-md\">\n <InputGroupAddon class=\"text-primary\">\n <Search aria-hidden=\"true\" />\n </InputGroupAddon>\n <InputGroupInput\n ref={(element) => (searchInput = element)}\n type=\"search\"\n aria-label={props.searchLabel}\n placeholder={props.searchPlaceholder}\n value={props.query}\n onInput={(event) => props.onQueryChange(event.currentTarget.value)}\n />\n </InputGroup>\n <span\n class=\"text-primary ms-auto text-sm font-medium tabular-nums\"\n role=\"status\"\n >\n {countLabel()}\n </span>\n </div>","<InputGroup class=\"min-w-0 flex-1 sm:max-w-md\">\n <InputGroupAddon class=\"text-primary\">\n <Search aria-hidden=\"true\" />\n </InputGroupAddon>\n <InputGroupInput\n ref={(element) => (searchInput = element)}\n type=\"search\"\n aria-label={props.searchLabel}\n placeholder={props.searchPlaceholder}\n value={props.query}\n onInput={(event) => props.onQueryChange(event.currentTarget.value)}\n />\n </InputGroup>","class=\"min-w-0 flex-1 sm:max-w-md\"","<InputGroupAddon class=\"text-primary\">\n <Search aria-hidden=\"true\" />\n </InputGroupAddon>","class=\"text-primary\"","<Search aria-hidden=\"true\" />","<InputGroupInput\n ref={(element) => (searchInput = element)}\n type=\"search\"\n aria-label={props.searchLabel}\n placeholder={props.searchPlaceholder}\n value={props.query}\n onInput={(event) => props.onQueryChange(event.currentTarget.value)}\n />","ref={(element) => (searchInput = element)}","type=\"search\"","onInput={(event) => props.onQueryChange(event.currentTarget.value)}","<ScrollArea\n role=\"region\"\n aria-label={props.resultsRegionLabel}\n orientation=\"vertical\"\n class=\"flex min-h-0 min-w-0 flex-1 flex-col gap-5 px-4 pb-4\"\n >\n <Show when={props.status === 'error'}>\n <Empty\n class=\"min-h-0 min-w-0 flex-1\"\n role={props.catalogError.role ?? 'alert'}\n >\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>\n <EmptyTitle>{props.catalogError.title}</EmptyTitle>\n <EmptyDescription>{props.catalogError.description}</EmptyDescription>\n </EmptyHeader>\n <Show when={props.catalogErrorAction}>\n {(catalogErrorActionSlot) => (\n <EmptyContent>{catalogErrorActionSlot()}</EmptyContent>\n )}\n </Show>\n </Empty>\n </Show>\n <Show when={props.status === 'loading'}>\n <CatalogLoadingState label={props.loadingLabel} />\n </Show>\n <Show when={props.status === 'ready'}>\n <Show\n when={props.resultCount > 0}\n fallback={\n <Empty class=\"min-h-0 min-w-0 flex-1\" role=\"status\">\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>\n <EmptyTitle>{props.emptyState.title}</EmptyTitle>\n <EmptyDescription>{props.emptyState.description}</EmptyDescription>\n </EmptyHeader>\n <Show when={props.emptyStateAction}>\n {(emptyStateActionSlot) => (\n <EmptyContent>{emptyStateActionSlot()}</EmptyContent>\n )}\n </Show>\n </Empty>\n }\n >\n <div class=\"grid min-w-0 gap-5\">\n <For each={groupRows()}>\n {(row) => (\n <CatalogBrowserGroup\n group={row.item()}\n expanded={expandedGroups().has(row.item().id)}\n previewCount={previewCount()}\n disabled={props.interactionDisabled ?? false}\n installedLabel={props.installedLabel}\n showMoreLabel={props.showMoreLabel}\n showLessLabel={props.showLessLabel}\n renderIcon={props.renderIcon}\n onSelect={(entry, key) => selectEntry(key, entry.value)}\n onRef={registerRow}\n onToggle={toggleGroup}\n />\n )}\n </For>\n </div>\n </Show>\n </Show>\n <For each={props.notices ?? []}>\n {(notice) => (\n <p class=\"text-muted-foreground text-sm\" role={notice.role}>\n {notice.message}\n </p>\n )}\n </For>\n </ScrollArea>","class=\"flex min-h-0 min-w-0 flex-1 flex-col gap-5 px-4 pb-4\"","<Show when={props.status === 'error'}>\n <Empty\n class=\"min-h-0 min-w-0 flex-1\"\n role={props.catalogError.role ?? 'alert'}\n >\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>\n <EmptyTitle>{props.catalogError.title}</EmptyTitle>\n <EmptyDescription>{props.catalogError.description}</EmptyDescription>\n </EmptyHeader>\n <Show when={props.catalogErrorAction}>\n {(catalogErrorActionSlot) => (\n <EmptyContent>{catalogErrorActionSlot()}</EmptyContent>\n )}\n </Show>\n </Empty>\n </Show>","<Empty\n class=\"min-h-0 min-w-0 flex-1\"\n role={props.catalogError.role ?? 'alert'}\n >\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>\n <EmptyTitle>{props.catalogError.title}</EmptyTitle>\n <EmptyDescription>{props.catalogError.description}</EmptyDescription>\n </EmptyHeader>\n <Show when={props.catalogErrorAction}>\n {(catalogErrorActionSlot) => (\n <EmptyContent>{catalogErrorActionSlot()}</EmptyContent>\n )}\n </Show>\n </Empty>","class=\"min-h-0 min-w-0 flex-1\"","<EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>\n <EmptyTitle>{props.catalogError.title}</EmptyTitle>\n <EmptyDescription>{props.catalogError.description}</EmptyDescription>\n </EmptyHeader>","<EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>","variant=\"icon\"","<Blocks aria-hidden=\"true\" />","<EmptyTitle>{props.catalogError.title}</EmptyTitle>","<EmptyDescription>{props.catalogError.description}</EmptyDescription>","<Show when={props.catalogErrorAction}>\n {(catalogErrorActionSlot) => (\n <EmptyContent>{catalogErrorActionSlot()}</EmptyContent>\n )}\n </Show>","<EmptyContent>{catalogErrorActionSlot()}</EmptyContent>","<Show when={props.status === 'loading'}>\n <CatalogLoadingState label={props.loadingLabel} />\n </Show>","<CatalogLoadingState label={props.loadingLabel} />","<Show when={props.status === 'ready'}>\n <Show\n when={props.resultCount > 0}\n fallback={\n <Empty class=\"min-h-0 min-w-0 flex-1\" role=\"status\">\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>\n <EmptyTitle>{props.emptyState.title}</EmptyTitle>\n <EmptyDescription>{props.emptyState.description}</EmptyDescription>\n </EmptyHeader>\n <Show when={props.emptyStateAction}>\n {(emptyStateActionSlot) => (\n <EmptyContent>{emptyStateActionSlot()}</EmptyContent>\n )}\n </Show>\n </Empty>\n }\n >\n <div class=\"grid min-w-0 gap-5\">\n <For each={groupRows()}>\n {(row) => (\n <CatalogBrowserGroup\n group={row.item()}\n expanded={expandedGroups().has(row.item().id)}\n previewCount={previewCount()}\n disabled={props.interactionDisabled ?? false}\n installedLabel={props.installedLabel}\n showMoreLabel={props.showMoreLabel}\n showLessLabel={props.showLessLabel}\n renderIcon={props.renderIcon}\n onSelect={(entry, key) => selectEntry(key, entry.value)}\n onRef={registerRow}\n onToggle={toggleGroup}\n />\n )}\n </For>\n </div>\n </Show>\n </Show>","<Show\n when={props.resultCount > 0}\n fallback={\n <Empty class=\"min-h-0 min-w-0 flex-1\" role=\"status\">\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>\n <EmptyTitle>{props.emptyState.title}</EmptyTitle>\n <EmptyDescription>{props.emptyState.description}</EmptyDescription>\n </EmptyHeader>\n <Show when={props.emptyStateAction}>\n {(emptyStateActionSlot) => (\n <EmptyContent>{emptyStateActionSlot()}</EmptyContent>\n )}\n </Show>\n </Empty>\n }\n >\n <div class=\"grid min-w-0 gap-5\">\n <For each={groupRows()}>\n {(row) => (\n <CatalogBrowserGroup\n group={row.item()}\n expanded={expandedGroups().has(row.item().id)}\n previewCount={previewCount()}\n disabled={props.interactionDisabled ?? false}\n installedLabel={props.installedLabel}\n showMoreLabel={props.showMoreLabel}\n showLessLabel={props.showLessLabel}\n renderIcon={props.renderIcon}\n onSelect={(entry, key) => selectEntry(key, entry.value)}\n onRef={registerRow}\n onToggle={toggleGroup}\n />\n )}\n </For>\n </div>\n </Show>","<For each={groupRows()}>\n {(row) => (\n <CatalogBrowserGroup\n group={row.item()}\n expanded={expandedGroups().has(row.item().id)}\n previewCount={previewCount()}\n disabled={props.interactionDisabled ?? false}\n installedLabel={props.installedLabel}\n showMoreLabel={props.showMoreLabel}\n showLessLabel={props.showLessLabel}\n renderIcon={props.renderIcon}\n onSelect={(entry, key) => selectEntry(key, entry.value)}\n onRef={registerRow}\n onToggle={toggleGroup}\n />\n )}\n </For>","<CatalogBrowserGroup\n group={row.item()}\n expanded={expandedGroups().has(row.item().id)}\n previewCount={previewCount()}\n disabled={props.interactionDisabled ?? false}\n installedLabel={props.installedLabel}\n showMoreLabel={props.showMoreLabel}\n showLessLabel={props.showLessLabel}\n renderIcon={props.renderIcon}\n onSelect={(entry, key) => selectEntry(key, entry.value)}\n onRef={registerRow}\n onToggle={toggleGroup}\n />","onSelect={(entry, key) => selectEntry(key, entry.value)}","onRef={registerRow}","onToggle={toggleGroup}","<Empty class=\"min-h-0 min-w-0 flex-1\" role=\"status\">\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>\n <EmptyTitle>{props.emptyState.title}</EmptyTitle>\n <EmptyDescription>{props.emptyState.description}</EmptyDescription>\n </EmptyHeader>\n <Show when={props.emptyStateAction}>\n {(emptyStateActionSlot) => (\n <EmptyContent>{emptyStateActionSlot()}</EmptyContent>\n )}\n </Show>\n </Empty>","role=\"status\"","<EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>\n <EmptyTitle>{props.emptyState.title}</EmptyTitle>\n <EmptyDescription>{props.emptyState.description}</EmptyDescription>\n </EmptyHeader>","<EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>","<EmptyTitle>{props.emptyState.title}</EmptyTitle>","<EmptyDescription>{props.emptyState.description}</EmptyDescription>","<Show when={props.emptyStateAction}>\n {(emptyStateActionSlot) => (\n <EmptyContent>{emptyStateActionSlot()}</EmptyContent>\n )}\n </Show>","<EmptyContent>{emptyStateActionSlot()}</EmptyContent>","<For each={props.notices ?? []}>\n {(notice) => (\n <p class=\"text-muted-foreground text-sm\" role={notice.role}>\n {notice.message}\n </p>\n )}\n </For>","<div class={cn('flex min-h-0 min-w-0 flex-1 flex-col', props.class)}>\n <Show\n when={selected()}\n fallback={\n <Tabs\n class=\"flex min-h-0 min-w-0 flex-1 flex-col gap-0\"\n value={props.tab}\n onChange={(value: string | undefined) => value && props.onTabChange(value)}\n >\n <Show\n when={tabsLeading()}\n fallback={\n <TabsList\n aria-label={props.tabsLabel}\n class=\"ms-auto max-w-full flex-wrap px-4 pt-2\"\n >\n <For each={props.tabs}>\n {(tab) => <TabsTrigger value={tab.id}>{tab.label}</TabsTrigger>}\n </For>\n </TabsList>\n }\n >\n <div\n class=\"flex min-w-0 shrink-0 flex-wrap items-center gap-2 px-4 pt-2\"\n data-slot=\"catalog-browser-tabs-row\"\n >\n {tabsLeading()}\n <TabsList aria-label={props.tabsLabel} class=\"ms-auto max-w-full flex-wrap\">\n <For each={props.tabs}>\n {(tab) => <TabsTrigger value={tab.id}>{tab.label}</TabsTrigger>}\n </For>\n </TabsList>\n </div>\n </Show>\n <TabsContent value={props.tab} class=\"flex min-h-0 min-w-0 flex-1 flex-col gap-3\">\n <Show\n when={supplemental()}\n fallback={\n <>\n <Show when={props.installError}>\n {(message) => (\n <p class=\"text-destructive px-4 pt-2 text-sm\" role=\"alert\">\n {message()}\n </p>\n )}\n </Show>\n <div class=\"flex min-w-0 shrink-0 flex-wrap items-center gap-2 px-4 pt-2\">\n {props.filterControl}\n <InputGroup class=\"min-w-0 flex-1 sm:max-w-md\">\n <InputGroupAddon class=\"text-primary\">\n <Search aria-hidden=\"true\" />\n </InputGroupAddon>\n <InputGroupInput\n ref={(element) => (searchInput = element)}\n type=\"search\"\n aria-label={props.searchLabel}\n placeholder={props.searchPlaceholder}\n value={props.query}\n onInput={(event) => props.onQueryChange(event.currentTarget.value)}\n />\n </InputGroup>\n <span\n class=\"text-primary ms-auto text-sm font-medium tabular-nums\"\n role=\"status\"\n >\n {countLabel()}\n </span>\n </div>\n <ScrollArea\n role=\"region\"\n aria-label={props.resultsRegionLabel}\n orientation=\"vertical\"\n class=\"flex min-h-0 min-w-0 flex-1 flex-col gap-5 px-4 pb-4\"\n >\n <Show when={props.status === 'error'}>\n <Empty\n class=\"min-h-0 min-w-0 flex-1\"\n role={props.catalogError.role ?? 'alert'}\n >\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>\n <EmptyTitle>{props.catalogError.title}</EmptyTitle>\n <EmptyDescription>{props.catalogError.description}</EmptyDescription>\n </EmptyHeader>\n <Show when={props.catalogErrorAction}>\n {(catalogErrorActionSlot) => (\n <EmptyContent>{catalogErrorActionSlot()}</EmptyContent>\n )}\n </Show>\n </Empty>\n </Show>\n <Show when={props.status === 'loading'}>\n <CatalogLoadingState label={props.loadingLabel} />\n </Show>\n <Show when={props.status === 'ready'}>\n <Show\n when={props.resultCount > 0}\n fallback={\n <Empty class=\"min-h-0 min-w-0 flex-1\" role=\"status\">\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>\n <EmptyTitle>{props.emptyState.title}</EmptyTitle>\n <EmptyDescription>{props.emptyState.description}</EmptyDescription>\n </EmptyHeader>\n <Show when={props.emptyStateAction}>\n {(emptyStateActionSlot) => (\n <EmptyContent>{emptyStateActionSlot()}</EmptyContent>\n )}\n </Show>\n </Empty>\n }\n >\n <div class=\"grid min-w-0 gap-5\">\n <For each={groupRows()}>\n {(row) => (\n <CatalogBrowserGroup\n group={row.item()}\n expanded={expandedGroups().has(row.item().id)}\n previewCount={previewCount()}\n disabled={props.interactionDisabled ?? false}\n installedLabel={props.installedLabel}\n showMoreLabel={props.showMoreLabel}\n showLessLabel={props.showLessLabel}\n renderIcon={props.renderIcon}\n onSelect={(entry, key) => selectEntry(key, entry.value)}\n onRef={registerRow}\n onToggle={toggleGroup}\n />\n )}\n </For>\n </div>\n </Show>\n </Show>\n <For each={props.notices ?? []}>\n {(notice) => (\n <p class=\"text-muted-foreground text-sm\" role={notice.role}>\n {notice.message}\n </p>\n )}\n </For>\n </ScrollArea>\n </>\n }\n >\n {supplementalContent()}\n </Show>\n </TabsContent>\n </Tabs>\n }\n >\n {(entry) => (\n <div class=\"flex min-h-0 min-w-0 flex-1 flex-col gap-3\" data-catalog-browser-detail>\n <Button\n ref={(element: HTMLButtonElement) => (backButton = element)}\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => props.onBack()}\n class=\"mx-4 mt-2 self-start\"\n >\n <ArrowLeft data-icon=\"inline-start\" aria-hidden=\"true\" />\n {props.backLabel}\n </Button>\n <ScrollArea\n role=\"region\"\n aria-label={props.detailRegionLabel}\n orientation=\"vertical\"\n class=\"min-h-0 min-w-0 flex-1 px-4 pb-4\"\n >\n {props.renderDetail(entry().value)}\n </ScrollArea>\n </div>\n )}\n </Show>\n </div>","ArrowLeft","LucideArrowLeft","Blocks","LucideBlocks","Search","LucideSearch","_$readShallow"],"sources":["../../../../src/components/composites/catalog-browser/catalog-browser.tsx"],"sourcesContent":["import { children, createEffect, createMemo, createSignal, For, onSettled, Show } from 'solid-js'\nimport {\n ArrowLeft as LucideArrowLeft,\n Blocks as LucideBlocks,\n Search as LucideSearch,\n} from '@lucide/solid'\nimport { MD_BREAKPOINT } from '#lib/breakpoints'\nimport { keyedRows } from '#lib/keyed-rows'\nimport { Button } from '../../ui/button'\nimport {\n Empty,\n EmptyContent,\n EmptyDescription,\n EmptyHeader,\n EmptyMedia,\n EmptyTitle,\n} from '../../ui/empty'\nimport { InputGroup, InputGroupAddon, InputGroupInput } from '../../ui/input-group'\nimport { Tabs, TabsContent, TabsList, TabsTrigger } from '../../ui/tabs'\nimport { ScrollArea } from '../../ui/scroll-area'\nimport { cn } from '#lib/utils'\nimport { CatalogBrowserGroup, CatalogLoadingState } from './catalog-browser-group'\nimport type { CatalogBrowserProps } from './catalog-types'\nimport { fastIcon } from '#lib/fast-icon'\n\n// lucide icons drawn from a cloned template (see fastIcon).\nconst ArrowLeft = fastIcon(LucideArrowLeft)\nconst Blocks = fastIcon(LucideBlocks)\nconst Search = fastIcon(LucideSearch)\n\nconst WIDE_QUERY = `(min-width: ${MD_BREAKPOINT})`\n\nexport function CatalogBrowser<Value>(props: CatalogBrowserProps<Value>) {\n const [expandedGroups, setExpandedGroups] = createSignal<ReadonlySet<string>>(new Set())\n const [returnKey, setReturnKey] = createSignal<string>()\n const [lastSelectedId, setLastSelectedId] = createSignal<string>()\n const rowRefs = new Map<string, HTMLButtonElement>()\n let searchInput: HTMLInputElement | undefined\n let backButton: HTMLButtonElement | undefined\n\n const selectedTab = createMemo(() => props.tabs.find((tab) => tab.id === props.tab))\n const supplemental = () => selectedTab()?.kind === 'supplemental'\n const selected = createMemo(() => {\n const id = props.selectedId\n return id && !supplemental() ? props.entries.find((entry) => entry.id === id) : undefined\n })\n const groupRows = keyedRows(\n () => props.groups,\n (group) => group.id\n )\n const [wide, setWide] = createSignal(\n typeof window === 'undefined' || window.matchMedia(WIDE_QUERY).matches\n )\n const updateWide = (event: MediaQueryListEvent) => setWide(event.matches)\n\n onSettled(() => {\n if (typeof window === 'undefined') return\n const query = window.matchMedia(WIDE_QUERY)\n query.addEventListener('change', updateWide)\n return () => query.removeEventListener('change', updateWide)\n })\n\n // Focus follows the view: into the detail's back button when an entry opens,\n // and back to the row it was opened from (or the search) when it closes. The\n // bookkeeping signals are read in the apply phase, so only the view re-runs it.\n createEffect(\n () => ({ open: props.open, selectedId: props.selectedId, selectedEntry: selected() }),\n ({ open, selectedId, selectedEntry }) => {\n if (!open) {\n setExpandedGroups(new Set<string>())\n setLastSelectedId(undefined)\n setReturnKey(undefined)\n return\n }\n if (selectedId && selectedEntry) {\n const previous = lastSelectedId()\n setLastSelectedId(selectedId)\n if (selectedId !== previous) backButton?.focus()\n return\n }\n const previous = lastSelectedId()\n if (!previous) return\n const key = returnKey()\n setLastSelectedId(undefined)\n setReturnKey(undefined)\n // The list mounts again in this same flush, and each row registers itself\n // from its own effect, which may run after this one. Look the row up once\n // the flush has finished.\n queueMicrotask(() => {\n const row = key ? rowRefs.get(key) : undefined\n if (row?.isConnected) row.focus()\n else searchInput?.focus()\n })\n }\n )\n\n const registerRow = (key: string, element: HTMLButtonElement | undefined) => {\n if (element) rowRefs.set(key, element)\n else rowRefs.delete(key)\n }\n const selectEntry = (key: string, value: Value) => {\n setReturnKey(key)\n props.onSelect(value)\n }\n const toggleGroup = (id: string) => {\n setExpandedGroups((current) => {\n const next = new Set(current)\n if (next.has(id)) next.delete(id)\n else next.add(id)\n return next\n })\n }\n const previewCount = () => (wide() ? 6 : 3)\n const countLabel = () =>\n props.status === 'loading' ? props.loadingLabel : props.resultLabel(props.resultCount)\n const supplementalContent = () => props.renderSupplementalView?.(props.tab)\n const tabsLeading = children(() => props.tabsLeading)\n\n return (\n <div class={cn('flex min-h-0 min-w-0 flex-1 flex-col', props.class)}>\n <Show\n when={selected()}\n fallback={\n <Tabs\n class=\"flex min-h-0 min-w-0 flex-1 flex-col gap-0\"\n value={props.tab}\n onChange={(value: string | undefined) => value && props.onTabChange(value)}\n >\n <Show\n when={tabsLeading()}\n fallback={\n <TabsList\n aria-label={props.tabsLabel}\n class=\"ms-auto max-w-full flex-wrap px-4 pt-2\"\n >\n <For each={props.tabs}>\n {(tab) => <TabsTrigger value={tab.id}>{tab.label}</TabsTrigger>}\n </For>\n </TabsList>\n }\n >\n <div\n class=\"flex min-w-0 shrink-0 flex-wrap items-center gap-2 px-4 pt-2\"\n data-slot=\"catalog-browser-tabs-row\"\n >\n {tabsLeading()}\n <TabsList aria-label={props.tabsLabel} class=\"ms-auto max-w-full flex-wrap\">\n <For each={props.tabs}>\n {(tab) => <TabsTrigger value={tab.id}>{tab.label}</TabsTrigger>}\n </For>\n </TabsList>\n </div>\n </Show>\n <TabsContent value={props.tab} class=\"flex min-h-0 min-w-0 flex-1 flex-col gap-3\">\n <Show\n when={supplemental()}\n fallback={\n <>\n <Show when={props.installError}>\n {(message) => (\n <p class=\"text-destructive px-4 pt-2 text-sm\" role=\"alert\">\n {message()}\n </p>\n )}\n </Show>\n <div class=\"flex min-w-0 shrink-0 flex-wrap items-center gap-2 px-4 pt-2\">\n {props.filterControl}\n <InputGroup class=\"min-w-0 flex-1 sm:max-w-md\">\n <InputGroupAddon class=\"text-primary\">\n <Search aria-hidden=\"true\" />\n </InputGroupAddon>\n <InputGroupInput\n ref={(element) => (searchInput = element)}\n type=\"search\"\n aria-label={props.searchLabel}\n placeholder={props.searchPlaceholder}\n value={props.query}\n onInput={(event) => props.onQueryChange(event.currentTarget.value)}\n />\n </InputGroup>\n <span\n class=\"text-primary ms-auto text-sm font-medium tabular-nums\"\n role=\"status\"\n >\n {countLabel()}\n </span>\n </div>\n <ScrollArea\n role=\"region\"\n aria-label={props.resultsRegionLabel}\n orientation=\"vertical\"\n class=\"flex min-h-0 min-w-0 flex-1 flex-col gap-5 px-4 pb-4\"\n >\n <Show when={props.status === 'error'}>\n <Empty\n class=\"min-h-0 min-w-0 flex-1\"\n role={props.catalogError.role ?? 'alert'}\n >\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>\n <EmptyTitle>{props.catalogError.title}</EmptyTitle>\n <EmptyDescription>{props.catalogError.description}</EmptyDescription>\n </EmptyHeader>\n <Show when={props.catalogErrorAction}>\n {(catalogErrorActionSlot) => (\n <EmptyContent>{catalogErrorActionSlot()}</EmptyContent>\n )}\n </Show>\n </Empty>\n </Show>\n <Show when={props.status === 'loading'}>\n <CatalogLoadingState label={props.loadingLabel} />\n </Show>\n <Show when={props.status === 'ready'}>\n <Show\n when={props.resultCount > 0}\n fallback={\n <Empty class=\"min-h-0 min-w-0 flex-1\" role=\"status\">\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <Blocks aria-hidden=\"true\" />\n </EmptyMedia>\n <EmptyTitle>{props.emptyState.title}</EmptyTitle>\n <EmptyDescription>{props.emptyState.description}</EmptyDescription>\n </EmptyHeader>\n <Show when={props.emptyStateAction}>\n {(emptyStateActionSlot) => (\n <EmptyContent>{emptyStateActionSlot()}</EmptyContent>\n )}\n </Show>\n </Empty>\n }\n >\n <div class=\"grid min-w-0 gap-5\">\n <For each={groupRows()}>\n {(row) => (\n <CatalogBrowserGroup\n group={row.item()}\n expanded={expandedGroups().has(row.item().id)}\n previewCount={previewCount()}\n disabled={props.interactionDisabled ?? false}\n installedLabel={props.installedLabel}\n showMoreLabel={props.showMoreLabel}\n showLessLabel={props.showLessLabel}\n renderIcon={props.renderIcon}\n onSelect={(entry, key) => selectEntry(key, entry.value)}\n onRef={registerRow}\n onToggle={toggleGroup}\n />\n )}\n </For>\n </div>\n </Show>\n </Show>\n <For each={props.notices ?? []}>\n {(notice) => (\n <p class=\"text-muted-foreground text-sm\" role={notice.role}>\n {notice.message}\n </p>\n )}\n </For>\n </ScrollArea>\n </>\n }\n >\n {supplementalContent()}\n </Show>\n </TabsContent>\n </Tabs>\n }\n >\n {(entry) => (\n <div class=\"flex min-h-0 min-w-0 flex-1 flex-col gap-3\" data-catalog-browser-detail>\n <Button\n ref={(element: HTMLButtonElement) => (backButton = element)}\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => props.onBack()}\n class=\"mx-4 mt-2 self-start\"\n >\n <ArrowLeft data-icon=\"inline-start\" aria-hidden=\"true\" />\n {props.backLabel}\n </Button>\n <ScrollArea\n role=\"region\"\n aria-label={props.detailRegionLabel}\n orientation=\"vertical\"\n class=\"min-h-0 min-w-0 flex-1 px-4 pb-4\"\n >\n {props.renderDetail(entry().value)}\n </ScrollArea>\n </div>\n )}\n </Show>\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA0BA,IAAMsE,cAAY,SAASC,SAAe;AAC1C,IAAMC,WAAS,SAASC,MAAY;AACpC,IAAMC,WAAS,SAASC,MAAY;AAEpC,IAAM,aAAa,eAAe,cAAc;AAEhD,SAAgB,eAAsB,OAAmC;CACvE,MAAM,CAAC,gBAAgB,qBAAqB,6BAAkC,IAAI,IAAI,CAAC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AAA,IAAAA,WAAAA;oBAAe,OAAA,qBAAqB;mBAAgB,EAAA,CAAA;kBAElD,CAAA,CAXP;iBAYM;;eAsBL,CAAA;cACF;;aACNC,gBAAAA,KAAAA;cAAK,IAAA,OAAA;eAAM,OAAA,MAAM,WAAW,CAAC;cAAC;cAA9BA,WACI,kBACA;eAEG,IAAA,SAAA,QAAA;eAFH,OAAA,cACE;gBAAC,OAAA,OAAO;eAAO,CACd;eAFsC,aAAM,OAAO,OAAb,QAAA;gBAAiB,aAAA,QAAA,QAAA,GAAA;;eAA1D,OAAA;cAEG,EAAA,CAAA;aAEF,CAAA;YArEN;WAsEW;;SAzGb;QA2GH;QA/GF,IAAA,WAAA;SAiHG,OAAA,oBAAoB;QACjB;;MACK;KA7Id,CAAA,CAAA;IA8IK;;EAyBJ;CAAC,EAAA,CAAD,CACH;CAjLA,aAAAQ,YAAO,GAAG,wCAAwC,MAAM,KAAK,CAAC,IAA9D,KAAA,QAAA;EAA8D,UAAA,MAAA,KAAA,GAAA;;CADrE,OACEP;AAmLJ"}
|
|
@@ -39,6 +39,11 @@ export type CatalogBrowserProps<Value> = Readonly<{
|
|
|
39
39
|
tabs: readonly CatalogBrowserTab[];
|
|
40
40
|
tab: string;
|
|
41
41
|
tabsLabel: string;
|
|
42
|
+
/**
|
|
43
|
+
* A host control drawn at the start of the tabs row, such as a switch between two
|
|
44
|
+
* catalogs that share this frame. Without it the row holds the tabs alone.
|
|
45
|
+
*/
|
|
46
|
+
tabsLeading?: JSX.Element;
|
|
42
47
|
onTabChange: (tab: string) => void;
|
|
43
48
|
/** A host-owned view is rendered in the same tab frame without catalog assumptions. */
|
|
44
49
|
renderSupplementalView?: (tab: string) => JSX.Element | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog-types.d.ts","sourceRoot":"","sources":["../../../../src/components/composites/catalog-browser/catalog-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,C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,MAAM,CAAA;IACzB,cAAc,EAAE,MAAM,CAAA;IACtB,iFAAiF;IACjF,gBAAgB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAA;IAChD,aAAa,EAAE,CAAC,OAAO,EAAE,SAAS,mBAAmB,CAAC,KAAK,CAAC,EAAE,EAAE,cAAc,EAAE,MAAM,KAAK,MAAM,CAAA;IACjG,aAAa,EAAE,MAAM,CAAA;IACrB,gFAAgF;IAChF,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,UAAU,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,GAAG,CAAC,OAAO,CAAA;IACzC,YAAY,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,GAAG,CAAC,OAAO,CAAA;CAC5C,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"catalog-types.d.ts","sourceRoot":"","sources":["../../../../src/components/composites/catalog-browser/catalog-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAEvC,+EAA+E;AAC/E,MAAM,MAAM,mBAAmB,CAAC,KAAK,IAAI,QAAQ,CAAC;IAChD,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,KAAK,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,OAAO,CAAA;CACnB,CAAC,CAAA;AAEF,wDAAwD;AACxD,MAAM,MAAM,mBAAmB,CAAC,KAAK,IAAI,QAAQ,CAAC;IAChD,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,SAAS,mBAAmB,CAAC,KAAK,CAAC,EAAE,CAAA;CAC/C,CAAC,CAAA;AAEF,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IACvC,EAAE,EAAE,MAAM,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G;IAC/B,yEAAyE;IACzE,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,6EAA6E;IAC7E,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,CAAA;AAYD,mFAAmF;AACnF,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,KAAK,SAAI,EACT,OAAO,GAAE,kBAAuB,GAC/B,SAAS,aAAa,EAAE,CA6G1B;AAsDD,+EAA+E;AAC/E,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE;IAAE,SAAS,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GACxD,SAAS,YAAY,EAAE,CAEzB;AAED,MAAM,MAAM,mBAAmB,GAAG;IAAE,SAAS,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAE7E;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC;IAClC,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,OAAO,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,SAAS,YAAY,EAAE,CAAA;IAC/B,iEAAiE;IACjE,MAAM,EAAE,SAAS,MAAM,EAAE,CAAA;CAC1B,CAAC,CAAA;AAEF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,YAAY,GAAG,SAAS,EAClC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,mBAAwB,GAChC,YAAY,CAmCd"}
|
|
@@ -239,7 +239,13 @@ function parseInline(text, depth = 0, options = {}) {
|
|
|
239
239
|
continue;
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
|
-
if (depth < MAX_INLINE_DEPTH && char === "[") {
|
|
242
|
+
if (depth < MAX_INLINE_DEPTH && char === "[" && paren !== -1) {
|
|
243
|
+
if (paren < index) paren = text.indexOf(")", index + 1);
|
|
244
|
+
if (paren === -1) {
|
|
245
|
+
buffer += char;
|
|
246
|
+
index += 1;
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
243
249
|
brackets ??= bracketMatches(text);
|
|
244
250
|
const labelEnd = brackets.get(index) ?? -1;
|
|
245
251
|
if (labelEnd > index && text[labelEnd + 1] === "(") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-message-text.js","names":[],"sources":["../../../../src/components/ui/message/parse-message-text.ts"],"sourcesContent":["/**\n * A small, safe reading of model and user text.\n *\n * Assistant output is untrusted: it can contain anything a model, a tool result\n * or a pasted web page put there. This parser therefore produces *data* —\n * blocks and inline spans — and the renderer turns that data into text nodes and\n * a fixed set of elements. There is no HTML pass, no `innerHTML`, and no\n * attribute built from the text other than a link `href` that has passed\n * `safeHref`.\n *\n * It reads a deliberately small subset of Markdown: fenced code, headings,\n * flat lists, block quotes, paragraphs, and inline code, bold, italic and links.\n * Anything it does not recognise stays as paragraph text with its line breaks\n * (the paragraph renders `white-space: pre-wrap`), so unsupported syntax\n * degrades to readable source instead of vanishing.\n *\n * A citation marker, `[^1]` or `[^1,2]`, is read only when the caller says how\n * many sources it has (`citations`) and every number names one of them. A marker\n * the host cannot resolve stays literal text: it is never a citation by shape\n * alone, and `arr[1]` or a footnote the model invented is not one either.\n *\n * Streaming is a first-class input. `streaming: true` means the text may end\n * mid-construct, so an unterminated fence is a *partial* code block — shown as\n * code from its first line, flagged incomplete — and an unterminated inline\n * span stays literal until its closing delimiter arrives. Once streaming stops,\n * an unterminated fence is just a code block that ends at the end of the text.\n */\n\nimport { safeHref } from '#lib/url'\n\nexport { safeHref }\n\nexport type MessageInline =\n | Readonly<{ kind: 'text'; text: string }>\n | Readonly<{ kind: 'code'; text: string }>\n | Readonly<{ kind: 'strong'; children: readonly MessageInline[] }>\n | Readonly<{ kind: 'em'; children: readonly MessageInline[] }>\n | Readonly<{ kind: 'link'; href: string; children: readonly MessageInline[] }>\n /** A resolved citation marker: 1-based source numbers, each within `citations`. */\n | Readonly<{ kind: 'cite'; numbers: readonly number[]; raw: string }>\n\nexport type MessageBlock =\n | Readonly<{ kind: 'paragraph'; inline: readonly MessageInline[]; raw: string }>\n | Readonly<{\n kind: 'heading'\n level: 1 | 2 | 3 | 4\n inline: readonly MessageInline[]\n raw: string\n }>\n | Readonly<{\n kind: 'list'\n ordered: boolean\n start: number\n items: readonly (readonly MessageInline[])[]\n raw: string\n }>\n | Readonly<{ kind: 'quote'; inline: readonly MessageInline[]; raw: string }>\n | Readonly<{\n kind: 'code'\n language: string | undefined\n code: string\n /** False while the fence is still open and the text may still grow. */\n complete: boolean\n raw: string\n }>\n\nconst WHITESPACE = /\\s/\n\n/**\n * An opening fence: up to three spaces, a run of three or more backticks or of\n * three or more tildes, then an info string that holds no backtick. The first\n * word of the info string is the language. This is a scan, not one pattern,\n * because a pattern whose classes overlap (`[^\\s`]*` then `[^`]*`) retries every\n * split of a long info string when a stray backtick ends it: three backticks, a\n * long run of `a` and a trailing backtick took quadratic time.\n */\nfunction fenceOpen(line: string): Readonly<{ marker: string; language: string }> | undefined {\n let start = 0\n while (start < 3 && line.charCodeAt(start) === 32) start += 1\n const mark = line[start]\n if (mark !== '`' && mark !== '~') return undefined\n let end = start + 1\n while (line[end] === mark) end += 1\n if (end - start < 3) return undefined\n if (line.includes('`', end)) return undefined\n let wordStart = end\n while (line[wordStart] === ' ' || line[wordStart] === '\\t') wordStart += 1\n let wordEnd = wordStart\n while (wordEnd < line.length && !WHITESPACE.test(line[wordEnd]!)) wordEnd += 1\n return { marker: line.slice(start, end), language: line.slice(wordStart, wordEnd) }\n}\ntype FenceOpen = NonNullable<ReturnType<typeof fenceOpen>>\n\n/**\n * The body of a fence that opened on `lines[start - 1]`: every line up to a\n * closing run of the same mark at least as long as the opening one, or to the end\n * of the text when none comes.\n */\nfunction readFence(\n lines: readonly string[],\n start: number,\n fence: FenceOpen\n): Readonly<{ code: string; closed: boolean; next: number }> {\n const body: string[] = []\n let index = start\n while (index < lines.length) {\n const candidate = lines[index]!\n const close = /^ {0,3}(`{3,}|~{3,})[ \\t]*$/.exec(candidate)\n if (close && close[1]![0] === fence.marker[0] && close[1]!.length >= fence.marker.length)\n return { code: body.join('\\n'), closed: true, next: index + 1 }\n body.push(candidate)\n index += 1\n }\n return { code: body.join('\\n'), closed: false, next: index }\n}\n\nexport type FenceSegment =\n | Readonly<{ kind: 'prose'; text: string }>\n | Readonly<{\n kind: 'code'\n language: string | undefined\n code: string\n /** False while the fence is still open and the text may still grow. */\n complete: boolean\n }>\n\n/**\n * Text split into fenced code and the prose between, by the same fence grammar\n * `parseMessageText` reads. For a renderer that draws code blocks but leaves the\n * prose as written (`MessageBody`).\n */\nexport function splitCodeFences(\n text: string,\n options: { streaming?: boolean } = {}\n): readonly FenceSegment[] {\n const lines = text.replace(/\\r\\n?/g, '\\n').split('\\n')\n const segments: FenceSegment[] = []\n let prose: string[] = []\n const flushProse = () => {\n if (prose.length > 0) segments.push({ kind: 'prose', text: prose.join('\\n') })\n prose = []\n }\n let index = 0\n while (index < lines.length) {\n const line = lines[index]!\n const fence = fenceOpen(line)\n if (!fence) {\n prose.push(line)\n index += 1\n continue\n }\n flushProse()\n const block = readFence(lines, index + 1, fence)\n segments.push({\n kind: 'code',\n language: fence.language || undefined,\n code: block.code,\n complete: block.closed || !options.streaming,\n })\n index = block.next\n }\n flushProse()\n return segments\n}\n\n// The lookahead after each marker's spaces makes that run maximal, so a line\n// that fails later (`.` stops at U+2028) cannot retry every shorter run.\nconst BULLET = /^ {0,3}[-*+][ \\t]+(?![ \\t])(.*)$/\nconst ORDERED = /^ {0,3}(\\d{1,9})[.)][ \\t]+(?![ \\t])(.*)$/\nconst QUOTE = /^ {0,3}>[ \\t]?(.*)$/\n\nconst isBlank = (char: string | undefined) => char === ' ' || char === '\\t'\nconst LINE_TERMINATOR = /[\\n\\r\\u2028\\u2029]/\n\n/**\n * An ATX heading: up to three spaces, one to four `#`, spaces or tabs, then the\n * text, with any trailing spaces and closing `#` run removed. This is a scan for\n * the reason `fenceOpen` is: the equivalent pattern (`(.+?)[ \\t]*#*[ \\t]*$`)\n * retries the closing check from every position of a long run of spaces.\n */\nfunction headingOf(line: string): Readonly<{ level: 1 | 2 | 3 | 4; text: string }> | undefined {\n let start = 0\n while (start < 3 && line.charCodeAt(start) === 32) start += 1\n let marks = start\n while (line[marks] === '#') marks += 1\n const level = marks - start\n if (level < 1 || level > 4 || !isBlank(line[marks])) return undefined\n let textStart = marks\n while (isBlank(line[textStart])) textStart += 1\n if (textStart === line.length) {\n // Only blanks follow the marker: the text is the last of them, which needs a second one.\n return textStart - marks >= 2\n ? { level: level as 1 | 2 | 3 | 4, text: line[line.length - 1]! }\n : undefined\n }\n if (LINE_TERMINATOR.test(line.slice(textStart))) return undefined\n // Drop the longest tail of blanks, a run of `#`, and blanks again.\n let textEnd = line.length\n while (textEnd > textStart && isBlank(line[textEnd - 1])) textEnd -= 1\n while (textEnd > textStart && line[textEnd - 1] === '#') textEnd -= 1\n while (textEnd > textStart && isBlank(line[textEnd - 1])) textEnd -= 1\n // Text that is nothing but a closing run keeps its first character.\n return {\n level: level as 1 | 2 | 3 | 4,\n text: line.slice(textStart, Math.max(textEnd, textStart + 1)),\n }\n}\n\nconst MAX_INLINE_DEPTH = 4\n\n/** A marker may cite at most this many sources, so one cannot flood a sentence. */\nconst MAX_CITED_SOURCES = 6\nconst CITATION = /\\[\\^(\\d{1,4}(?:[ \\t]*,[ \\t]*\\d{1,4}){0,5})\\]/y\n\nexport type ParseInlineOptions = {\n /** How many sources the host has. Without it no marker is a citation. */\n citations?: number\n /** Inside a link label, where a citation (itself a button) must not nest. */\n inLink?: boolean\n}\n\nfunction citationAt(text: string, index: number, count: number): MessageInline | undefined {\n CITATION.lastIndex = index\n const match = CITATION.exec(text)\n if (!match) return undefined\n const numbers = [...new Set(match[1]!.split(',').map((part) => Number(part.trim())))]\n if (numbers.length > MAX_CITED_SOURCES) return undefined\n if (numbers.some((number) => number < 1 || number > count)) return undefined\n return { kind: 'cite', numbers, raw: match[0] }\n}\n\n/** Inline spans. Delimiters must close on the same block, or they stay literal. */\nexport function parseInline(\n text: string,\n depth = 0,\n options: ParseInlineOptions = {}\n): readonly MessageInline[] {\n const out: MessageInline[] = []\n let brackets: ReadonlyMap<number, number> | undefined\n let paren = -2\n let buffer = ''\n const flush = () => {\n if (buffer) out.push({ kind: 'text', text: buffer })\n buffer = ''\n }\n let index = 0\n while (index < text.length) {\n const char = text[index]!\n if (char === '`') {\n let ticks = 1\n while (text[index + ticks] === '`') ticks += 1\n const fence = '`'.repeat(ticks)\n const close = text.indexOf(fence, index + ticks)\n if (close > index + ticks) {\n flush()\n out.push({ kind: 'code', text: text.slice(index + ticks, close).replace(/^ (.*) $/, '$1') })\n index = close + ticks\n continue\n }\n buffer += fence\n index += ticks\n continue\n }\n if (depth < MAX_INLINE_DEPTH && (char === '*' || char === '_')) {\n const double = text[index + 1] === char\n const delimiter = double ? char + char : char\n const start = index + delimiter.length\n // Word-internal underscores cannot open emphasis. Reject before scanning,\n // and consume both marks so the second cannot rescan the remaining pairs.\n if (char === '_' && index > 0 && /[A-Za-z0-9]/.test(text[index - 1] ?? '')) {\n buffer += delimiter\n index = start\n continue\n }\n const next = text[start]\n // A delimiter opens only before a non-space, so `a * b * c` and `2 * 3` stay arithmetic.\n if (next !== undefined && !/\\s/.test(next)) {\n const close = findClosing(text, delimiter, start)\n if (double && !(close > start && !/\\s/.test(text[close - 1] ?? ' '))) {\n // An opener that does not close stays literal as a pair. Retrying its\n // second mark as emphasis would scan to the end of the line again, so a\n // line of unclosed `**a ` would be quadratic.\n buffer += delimiter\n index = start\n continue\n }\n if (close > start && !/\\s/.test(text[close - 1] ?? ' ')) {\n flush()\n out.push({\n kind: double ? 'strong' : 'em',\n children: parseInline(text.slice(start, close), depth + 1, options),\n })\n index = close + delimiter.length\n continue\n }\n }\n }\n if (char === '[' && text[index + 1] === '^' && options.citations && !options.inLink) {\n const cite = citationAt(text, index, options.citations)\n if (cite && cite.kind === 'cite') {\n flush()\n out.push(cite)\n index += cite.raw.length\n continue\n }\n }\n if (depth < MAX_INLINE_DEPTH && char === '[') {\n brackets ??= bracketMatches(text)\n const labelEnd = brackets.get(index) ?? -1\n if (labelEnd > index && text[labelEnd + 1] === '(') {\n // The nearest `)` is remembered: a run of `[a](` with no `)` after it\n // would otherwise search to the end of the text from every opener.\n if (paren !== -1 && paren < labelEnd + 2) paren = text.indexOf(')', labelEnd + 2)\n const hrefEnd = paren\n if (hrefEnd > labelEnd + 1) {\n const href = safeHref(text.slice(labelEnd + 2, hrefEnd))\n if (href) {\n flush()\n out.push({\n kind: 'link',\n href,\n children: parseInline(text.slice(index + 1, labelEnd), depth + 1, {\n ...options,\n inLink: true,\n }),\n })\n index = hrefEnd + 1\n continue\n }\n }\n }\n }\n buffer += char\n index += 1\n }\n flush()\n return out\n}\n\nfunction findClosing(text: string, delimiter: string, from: number): number {\n let index = from\n while (index < text.length) {\n if (text[index] === '`') {\n // Skip a code span so `**a `**` b**` closes where the code ends.\n const close = text.indexOf('`', index + 1)\n if (close < 0) return -1\n index = close + 1\n continue\n }\n if (text[index] === delimiter[0]) {\n let end = index + 1\n while (text[end] === delimiter[0]) end += 1\n const run = end - index\n if (delimiter.length === 1) {\n // Emphasis closes on a run of one (or an odd run, whose last mark closes).\n // An even run is `**` pairs: strong spans inside the emphasis, which the\n // inner parse reads. One pass, and the scan stops at the next odd run, so\n // a line of unclosed delimiters is still linear.\n if (run % 2 === 1) return end - 1\n } else if (run >= delimiter.length) {\n // Strong closes on the last two marks of a run.\n return end - delimiter.length\n }\n index = end\n continue\n }\n index += 1\n }\n return -1\n}\n\n/**\n * The `]` that closes each `[`, found in one pass. A match never crosses a\n * newline, and an unmatched `[` has no entry. Scanning forward from every `[`\n * instead is quadratic on a long line of unclosed brackets, which a pasted page\n * or a hostile model can use to hang the renderer.\n */\nfunction bracketMatches(text: string): ReadonlyMap<number, number> {\n const matches = new Map<number, number>()\n const open: number[] = []\n for (let index = 0; index < text.length; index += 1) {\n const char = text[index]\n if (char === '[') open.push(index)\n else if (char === ']') {\n const start = open.pop()\n if (start !== undefined) matches.set(start, index)\n } else if (char === '\\n') open.length = 0\n }\n return matches\n}\n\n/** Parse text into blocks. Pure, total, and linear in the length of `text`. */\nexport function parseMessageText(\n text: string,\n options: { streaming?: boolean; citations?: number } = {}\n): readonly MessageBlock[] {\n return parseLines(text.replace(/\\r\\n?/g, '\\n'), options).blocks\n}\n\nexport type MessageParseOptions = { streaming?: boolean; citations?: number }\n\n/**\n * A parse that the next, longer text can continue from. See\n * {@link parseMessageTextIncremental}.\n */\nexport type MessageParse = Readonly<{\n /** The normalised text that was parsed. */\n text: string\n streaming: boolean\n citations: number\n blocks: readonly MessageBlock[]\n /** The offset in `text` where each block's first line starts. */\n starts: readonly number[]\n}>\n\n/**\n * `parseMessageText`, resumed.\n *\n * A streaming reply grows by appending, and reparsing the whole text per token\n * makes a long reply quadratic. When `text` extends `previous.text` under the same\n * options, only its final line can still change, since it may be unfinished. A block\n * that ends before that line is terminated by a finished line (a blank line, a\n * closing fence, or the line that starts the next block), so appending cannot\n * change it. Only the tail from the last block that starts before the final line\n * is parsed again, and the earlier blocks are returned as the same objects. The\n * parser keeps no state across a block boundary, so the tail parsed alone gives\n * exactly the blocks a full parse gives there. Anything else (an edit, a\n * different option) is a full parse.\n */\nexport function parseMessageTextIncremental(\n previous: MessageParse | undefined,\n text: string,\n options: MessageParseOptions = {}\n): MessageParse {\n const normalized = text.replace(/\\r\\n?/g, '\\n')\n const streaming = options.streaming ?? false\n const citations = options.citations ?? 0\n if (\n previous &&\n previous.streaming === streaming &&\n previous.citations === citations &&\n previous.blocks.length > 0 &&\n normalized.length >= previous.text.length &&\n normalized.startsWith(previous.text)\n ) {\n // Only the final line can still change (it may not be finished), and with it\n // the block it belongs to or the one it ends. Resume from the last block that\n // starts before that line: every block before it ends at a finished line.\n const lastLine = previous.text.lastIndexOf('\\n') + 1\n let keep = previous.starts.length - 1\n while (keep >= 0 && previous.starts[keep]! >= lastLine) keep -= 1\n if (keep > 0) {\n const resumeAt = previous.starts[keep]!\n const tail = parseLines(normalized.slice(resumeAt), options)\n return {\n text: normalized,\n streaming,\n citations,\n blocks: [...previous.blocks.slice(0, keep), ...tail.blocks],\n starts: [\n ...previous.starts.slice(0, keep),\n ...tail.starts.map((start) => start + resumeAt),\n ],\n }\n }\n }\n const full = parseLines(normalized, options)\n return { text: normalized, streaming, citations, ...full }\n}\n\nfunction parseLines(\n text: string,\n options: MessageParseOptions\n): { blocks: MessageBlock[]; starts: number[] } {\n const inline = (source: string) => parseInline(source, 0, { citations: options.citations })\n const lines = text.split('\\n')\n // The offset where each line starts, so a block can record where it began.\n const lineStarts: number[] = []\n for (let line = 0, offset = 0; line < lines.length; line++) {\n lineStarts.push(offset)\n offset += lines[line]!.length + 1\n }\n const blocks: MessageBlock[] = []\n const starts: number[] = []\n let paragraph: string[] = []\n let paragraphStart = 0\n const flushParagraph = () => {\n if (paragraph.length === 0) return\n const raw = paragraph.join('\\n')\n blocks.push({ kind: 'paragraph', inline: inline(raw), raw })\n starts.push(lineStarts[paragraphStart]!)\n paragraph = []\n }\n\n let index = 0\n while (index < lines.length) {\n const line = lines[index]!\n const fence = fenceOpen(line)\n if (fence) {\n flushParagraph()\n const marker = fence.marker\n const language = fence.language || undefined\n const { code, closed, next } = readFence(lines, index + 1, fence)\n starts.push(lineStarts[index]!)\n index = next\n blocks.push({\n kind: 'code',\n language,\n code,\n complete: closed || !options.streaming,\n raw: `${marker}${language ?? ''}\\n${code}${closed ? `\\n${marker}` : ''}`,\n })\n continue\n }\n if (line.trim() === '') {\n flushParagraph()\n index += 1\n continue\n }\n const heading = headingOf(line)\n if (heading) {\n flushParagraph()\n starts.push(lineStarts[index]!)\n blocks.push({\n kind: 'heading',\n level: heading.level,\n inline: inline(heading.text),\n raw: line,\n })\n index += 1\n continue\n }\n const bullet = BULLET.exec(line)\n const ordered = bullet ? null : ORDERED.exec(line)\n if (bullet || ordered) {\n flushParagraph()\n starts.push(lineStarts[index]!)\n const items: MessageInline[][] = []\n const rawLines: string[] = []\n const isOrdered = ordered !== null\n const start = ordered ? Number(ordered[1]) : 1\n while (index < lines.length) {\n const current = lines[index]!\n const match = isOrdered ? ORDERED.exec(current) : BULLET.exec(current)\n if (match) {\n items.push([...inline(isOrdered ? match[2]! : match[1]!)])\n rawLines.push(current)\n index += 1\n continue\n }\n // An indented continuation belongs to the previous item.\n if (/^ {2,}\\S/.test(current) && items.length > 0) {\n // Append in place: copying the accumulated spans on every continuation\n // makes a long item quadratic in its number of lines. Push one span at\n // a time, because spreading a line of many spans into `push` exceeds\n // the engine's argument limit and throws.\n const item = items[items.length - 1]!\n item.push({ kind: 'text', text: ' ' })\n for (const span of inline(current.trim())) item.push(span)\n rawLines.push(current)\n index += 1\n continue\n }\n break\n }\n blocks.push({ kind: 'list', ordered: isOrdered, start, items, raw: rawLines.join('\\n') })\n continue\n }\n const quote = QUOTE.exec(line)\n if (quote) {\n flushParagraph()\n starts.push(lineStarts[index]!)\n const quoted: string[] = []\n while (index < lines.length) {\n const match = QUOTE.exec(lines[index]!)\n if (!match) break\n quoted.push(match[1]!)\n index += 1\n }\n const raw = quoted.join('\\n')\n blocks.push({ kind: 'quote', inline: inline(raw), raw })\n continue\n }\n if (paragraph.length === 0) paragraphStart = index\n paragraph.push(line)\n index += 1\n }\n flushParagraph()\n return { blocks, starts }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkEA,IAAM,aAAa;;;;;;;;;AAUnB,SAAS,UAAU,MAA0E;CAC3F,IAAI,QAAQ;CACZ,OAAO,QAAQ,KAAK,KAAK,WAAW,KAAK,MAAM,IAAI,SAAS;CAC5D,MAAM,OAAO,KAAK;CAClB,IAAI,SAAS,OAAO,SAAS,KAAK,OAAO,KAAA;CACzC,IAAI,MAAM,QAAQ;CAClB,OAAO,KAAK,SAAS,MAAM,OAAO;CAClC,IAAI,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M,OAAO,KAAK,IAAI;GAC5B,OAAO,KAAK;IAAE,MAAM;IAAS,QAAQ,OAAO,GAAG;IAAG;GAAI,CAAC;GACvD;EACF;EACA,IAAI,UAAU,WAAW,GAAG,iBAAiB;EAC7C,UAAU,KAAK,IAAI;EACnB,SAAS;CACX;CACA,eAAe;CACf,OAAO;EAAE;EAAQ;CAAO;AAC1B"}
|
|
1
|
+
{"version":3,"file":"parse-message-text.js","names":[],"sources":["../../../../src/components/ui/message/parse-message-text.ts"],"sourcesContent":["/**\n * A small, safe reading of model and user text.\n *\n * Assistant output is untrusted: it can contain anything a model, a tool result\n * or a pasted web page put there. This parser therefore produces *data* —\n * blocks and inline spans — and the renderer turns that data into text nodes and\n * a fixed set of elements. There is no HTML pass, no `innerHTML`, and no\n * attribute built from the text other than a link `href` that has passed\n * `safeHref`.\n *\n * It reads a deliberately small subset of Markdown: fenced code, headings,\n * flat lists, block quotes, paragraphs, and inline code, bold, italic and links.\n * Anything it does not recognise stays as paragraph text with its line breaks\n * (the paragraph renders `white-space: pre-wrap`), so unsupported syntax\n * degrades to readable source instead of vanishing.\n *\n * A citation marker, `[^1]` or `[^1,2]`, is read only when the caller says how\n * many sources it has (`citations`) and every number names one of them. A marker\n * the host cannot resolve stays literal text: it is never a citation by shape\n * alone, and `arr[1]` or a footnote the model invented is not one either.\n *\n * Streaming is a first-class input. `streaming: true` means the text may end\n * mid-construct, so an unterminated fence is a *partial* code block — shown as\n * code from its first line, flagged incomplete — and an unterminated inline\n * span stays literal until its closing delimiter arrives. Once streaming stops,\n * an unterminated fence is just a code block that ends at the end of the text.\n */\n\nimport { safeHref } from '#lib/url'\n\nexport { safeHref }\n\nexport type MessageInline =\n | Readonly<{ kind: 'text'; text: string }>\n | Readonly<{ kind: 'code'; text: string }>\n | Readonly<{ kind: 'strong'; children: readonly MessageInline[] }>\n | Readonly<{ kind: 'em'; children: readonly MessageInline[] }>\n | Readonly<{ kind: 'link'; href: string; children: readonly MessageInline[] }>\n /** A resolved citation marker: 1-based source numbers, each within `citations`. */\n | Readonly<{ kind: 'cite'; numbers: readonly number[]; raw: string }>\n\nexport type MessageBlock =\n | Readonly<{ kind: 'paragraph'; inline: readonly MessageInline[]; raw: string }>\n | Readonly<{\n kind: 'heading'\n level: 1 | 2 | 3 | 4\n inline: readonly MessageInline[]\n raw: string\n }>\n | Readonly<{\n kind: 'list'\n ordered: boolean\n start: number\n items: readonly (readonly MessageInline[])[]\n raw: string\n }>\n | Readonly<{ kind: 'quote'; inline: readonly MessageInline[]; raw: string }>\n | Readonly<{\n kind: 'code'\n language: string | undefined\n code: string\n /** False while the fence is still open and the text may still grow. */\n complete: boolean\n raw: string\n }>\n\nconst WHITESPACE = /\\s/\n\n/**\n * An opening fence: up to three spaces, a run of three or more backticks or of\n * three or more tildes, then an info string that holds no backtick. The first\n * word of the info string is the language. This is a scan, not one pattern,\n * because a pattern whose classes overlap (`[^\\s`]*` then `[^`]*`) retries every\n * split of a long info string when a stray backtick ends it: three backticks, a\n * long run of `a` and a trailing backtick took quadratic time.\n */\nfunction fenceOpen(line: string): Readonly<{ marker: string; language: string }> | undefined {\n let start = 0\n while (start < 3 && line.charCodeAt(start) === 32) start += 1\n const mark = line[start]\n if (mark !== '`' && mark !== '~') return undefined\n let end = start + 1\n while (line[end] === mark) end += 1\n if (end - start < 3) return undefined\n if (line.includes('`', end)) return undefined\n let wordStart = end\n while (line[wordStart] === ' ' || line[wordStart] === '\\t') wordStart += 1\n let wordEnd = wordStart\n while (wordEnd < line.length && !WHITESPACE.test(line[wordEnd]!)) wordEnd += 1\n return { marker: line.slice(start, end), language: line.slice(wordStart, wordEnd) }\n}\ntype FenceOpen = NonNullable<ReturnType<typeof fenceOpen>>\n\n/**\n * The body of a fence that opened on `lines[start - 1]`: every line up to a\n * closing run of the same mark at least as long as the opening one, or to the end\n * of the text when none comes.\n */\nfunction readFence(\n lines: readonly string[],\n start: number,\n fence: FenceOpen\n): Readonly<{ code: string; closed: boolean; next: number }> {\n const body: string[] = []\n let index = start\n while (index < lines.length) {\n const candidate = lines[index]!\n const close = /^ {0,3}(`{3,}|~{3,})[ \\t]*$/.exec(candidate)\n if (close && close[1]![0] === fence.marker[0] && close[1]!.length >= fence.marker.length)\n return { code: body.join('\\n'), closed: true, next: index + 1 }\n body.push(candidate)\n index += 1\n }\n return { code: body.join('\\n'), closed: false, next: index }\n}\n\nexport type FenceSegment =\n | Readonly<{ kind: 'prose'; text: string }>\n | Readonly<{\n kind: 'code'\n language: string | undefined\n code: string\n /** False while the fence is still open and the text may still grow. */\n complete: boolean\n }>\n\n/**\n * Text split into fenced code and the prose between, by the same fence grammar\n * `parseMessageText` reads. For a renderer that draws code blocks but leaves the\n * prose as written (`MessageBody`).\n */\nexport function splitCodeFences(\n text: string,\n options: { streaming?: boolean } = {}\n): readonly FenceSegment[] {\n const lines = text.replace(/\\r\\n?/g, '\\n').split('\\n')\n const segments: FenceSegment[] = []\n let prose: string[] = []\n const flushProse = () => {\n if (prose.length > 0) segments.push({ kind: 'prose', text: prose.join('\\n') })\n prose = []\n }\n let index = 0\n while (index < lines.length) {\n const line = lines[index]!\n const fence = fenceOpen(line)\n if (!fence) {\n prose.push(line)\n index += 1\n continue\n }\n flushProse()\n const block = readFence(lines, index + 1, fence)\n segments.push({\n kind: 'code',\n language: fence.language || undefined,\n code: block.code,\n complete: block.closed || !options.streaming,\n })\n index = block.next\n }\n flushProse()\n return segments\n}\n\n// The lookahead after each marker's spaces makes that run maximal, so a line\n// that fails later (`.` stops at U+2028) cannot retry every shorter run.\nconst BULLET = /^ {0,3}[-*+][ \\t]+(?![ \\t])(.*)$/\nconst ORDERED = /^ {0,3}(\\d{1,9})[.)][ \\t]+(?![ \\t])(.*)$/\nconst QUOTE = /^ {0,3}>[ \\t]?(.*)$/\n\nconst isBlank = (char: string | undefined) => char === ' ' || char === '\\t'\nconst LINE_TERMINATOR = /[\\n\\r\\u2028\\u2029]/\n\n/**\n * An ATX heading: up to three spaces, one to four `#`, spaces or tabs, then the\n * text, with any trailing spaces and closing `#` run removed. This is a scan for\n * the reason `fenceOpen` is: the equivalent pattern (`(.+?)[ \\t]*#*[ \\t]*$`)\n * retries the closing check from every position of a long run of spaces.\n */\nfunction headingOf(line: string): Readonly<{ level: 1 | 2 | 3 | 4; text: string }> | undefined {\n let start = 0\n while (start < 3 && line.charCodeAt(start) === 32) start += 1\n let marks = start\n while (line[marks] === '#') marks += 1\n const level = marks - start\n if (level < 1 || level > 4 || !isBlank(line[marks])) return undefined\n let textStart = marks\n while (isBlank(line[textStart])) textStart += 1\n if (textStart === line.length) {\n // Only blanks follow the marker: the text is the last of them, which needs a second one.\n return textStart - marks >= 2\n ? { level: level as 1 | 2 | 3 | 4, text: line[line.length - 1]! }\n : undefined\n }\n if (LINE_TERMINATOR.test(line.slice(textStart))) return undefined\n // Drop the longest tail of blanks, a run of `#`, and blanks again.\n let textEnd = line.length\n while (textEnd > textStart && isBlank(line[textEnd - 1])) textEnd -= 1\n while (textEnd > textStart && line[textEnd - 1] === '#') textEnd -= 1\n while (textEnd > textStart && isBlank(line[textEnd - 1])) textEnd -= 1\n // Text that is nothing but a closing run keeps its first character.\n return {\n level: level as 1 | 2 | 3 | 4,\n text: line.slice(textStart, Math.max(textEnd, textStart + 1)),\n }\n}\n\nconst MAX_INLINE_DEPTH = 4\n\n/** A marker may cite at most this many sources, so one cannot flood a sentence. */\nconst MAX_CITED_SOURCES = 6\nconst CITATION = /\\[\\^(\\d{1,4}(?:[ \\t]*,[ \\t]*\\d{1,4}){0,5})\\]/y\n\nexport type ParseInlineOptions = {\n /** How many sources the host has. Without it no marker is a citation. */\n citations?: number\n /** Inside a link label, where a citation (itself a button) must not nest. */\n inLink?: boolean\n}\n\nfunction citationAt(text: string, index: number, count: number): MessageInline | undefined {\n CITATION.lastIndex = index\n const match = CITATION.exec(text)\n if (!match) return undefined\n const numbers = [...new Set(match[1]!.split(',').map((part) => Number(part.trim())))]\n if (numbers.length > MAX_CITED_SOURCES) return undefined\n if (numbers.some((number) => number < 1 || number > count)) return undefined\n return { kind: 'cite', numbers, raw: match[0] }\n}\n\n/** Inline spans. Delimiters must close on the same block, or they stay literal. */\nexport function parseInline(\n text: string,\n depth = 0,\n options: ParseInlineOptions = {}\n): readonly MessageInline[] {\n const out: MessageInline[] = []\n let brackets: ReadonlyMap<number, number> | undefined\n let paren = -2\n let buffer = ''\n const flush = () => {\n if (buffer) out.push({ kind: 'text', text: buffer })\n buffer = ''\n }\n let index = 0\n while (index < text.length) {\n const char = text[index]!\n if (char === '`') {\n let ticks = 1\n while (text[index + ticks] === '`') ticks += 1\n const fence = '`'.repeat(ticks)\n const close = text.indexOf(fence, index + ticks)\n if (close > index + ticks) {\n flush()\n out.push({ kind: 'code', text: text.slice(index + ticks, close).replace(/^ (.*) $/, '$1') })\n index = close + ticks\n continue\n }\n buffer += fence\n index += ticks\n continue\n }\n if (depth < MAX_INLINE_DEPTH && (char === '*' || char === '_')) {\n const double = text[index + 1] === char\n const delimiter = double ? char + char : char\n const start = index + delimiter.length\n // Word-internal underscores cannot open emphasis. Reject before scanning,\n // and consume both marks so the second cannot rescan the remaining pairs.\n if (char === '_' && index > 0 && /[A-Za-z0-9]/.test(text[index - 1] ?? '')) {\n buffer += delimiter\n index = start\n continue\n }\n const next = text[start]\n // A delimiter opens only before a non-space, so `a * b * c` and `2 * 3` stay arithmetic.\n if (next !== undefined && !/\\s/.test(next)) {\n const close = findClosing(text, delimiter, start)\n if (double && !(close > start && !/\\s/.test(text[close - 1] ?? ' '))) {\n // An opener that does not close stays literal as a pair. Retrying its\n // second mark as emphasis would scan to the end of the line again, so a\n // line of unclosed `**a ` would be quadratic.\n buffer += delimiter\n index = start\n continue\n }\n if (close > start && !/\\s/.test(text[close - 1] ?? ' ')) {\n flush()\n out.push({\n kind: double ? 'strong' : 'em',\n children: parseInline(text.slice(start, close), depth + 1, options),\n })\n index = close + delimiter.length\n continue\n }\n }\n }\n if (char === '[' && text[index + 1] === '^' && options.citations && !options.inLink) {\n const cite = citationAt(text, index, options.citations)\n if (cite && cite.kind === 'cite') {\n flush()\n out.push(cite)\n index += cite.raw.length\n continue\n }\n }\n if (depth < MAX_INLINE_DEPTH && char === '[' && paren !== -1) {\n // Don't allocate bracket pairs for text that cannot contain a complete\n // link. Remember the last miss so later literal openers are O(1).\n if (paren < index) paren = text.indexOf(')', index + 1)\n if (paren === -1) {\n buffer += char\n index += 1\n continue\n }\n brackets ??= bracketMatches(text)\n const labelEnd = brackets.get(index) ?? -1\n if (labelEnd > index && text[labelEnd + 1] === '(') {\n // The nearest `)` is remembered: a run of `[a](` with no `)` after it\n // would otherwise search to the end of the text from every opener.\n if (paren !== -1 && paren < labelEnd + 2) paren = text.indexOf(')', labelEnd + 2)\n const hrefEnd = paren\n if (hrefEnd > labelEnd + 1) {\n const href = safeHref(text.slice(labelEnd + 2, hrefEnd))\n if (href) {\n flush()\n out.push({\n kind: 'link',\n href,\n children: parseInline(text.slice(index + 1, labelEnd), depth + 1, {\n ...options,\n inLink: true,\n }),\n })\n index = hrefEnd + 1\n continue\n }\n }\n }\n }\n buffer += char\n index += 1\n }\n flush()\n return out\n}\n\nfunction findClosing(text: string, delimiter: string, from: number): number {\n let index = from\n while (index < text.length) {\n if (text[index] === '`') {\n // Skip a code span so `**a `**` b**` closes where the code ends.\n const close = text.indexOf('`', index + 1)\n if (close < 0) return -1\n index = close + 1\n continue\n }\n if (text[index] === delimiter[0]) {\n let end = index + 1\n while (text[end] === delimiter[0]) end += 1\n const run = end - index\n if (delimiter.length === 1) {\n // Emphasis closes on a run of one (or an odd run, whose last mark closes).\n // An even run is `**` pairs: strong spans inside the emphasis, which the\n // inner parse reads. One pass, and the scan stops at the next odd run, so\n // a line of unclosed delimiters is still linear.\n if (run % 2 === 1) return end - 1\n } else if (run >= delimiter.length) {\n // Strong closes on the last two marks of a run.\n return end - delimiter.length\n }\n index = end\n continue\n }\n index += 1\n }\n return -1\n}\n\n/**\n * The `]` that closes each `[`, found in one pass. A match never crosses a\n * newline, and an unmatched `[` has no entry. Scanning forward from every `[`\n * instead is quadratic on a long line of unclosed brackets, which a pasted page\n * or a hostile model can use to hang the renderer.\n */\nfunction bracketMatches(text: string): ReadonlyMap<number, number> {\n const matches = new Map<number, number>()\n const open: number[] = []\n for (let index = 0; index < text.length; index += 1) {\n const char = text[index]\n if (char === '[') open.push(index)\n else if (char === ']') {\n const start = open.pop()\n if (start !== undefined) matches.set(start, index)\n } else if (char === '\\n') open.length = 0\n }\n return matches\n}\n\n/** Parse text into blocks. Pure, total, and linear in the length of `text`. */\nexport function parseMessageText(\n text: string,\n options: { streaming?: boolean; citations?: number } = {}\n): readonly MessageBlock[] {\n return parseLines(text.replace(/\\r\\n?/g, '\\n'), options).blocks\n}\n\nexport type MessageParseOptions = { streaming?: boolean; citations?: number }\n\n/**\n * A parse that the next, longer text can continue from. See\n * {@link parseMessageTextIncremental}.\n */\nexport type MessageParse = Readonly<{\n /** The normalised text that was parsed. */\n text: string\n streaming: boolean\n citations: number\n blocks: readonly MessageBlock[]\n /** The offset in `text` where each block's first line starts. */\n starts: readonly number[]\n}>\n\n/**\n * `parseMessageText`, resumed.\n *\n * A streaming reply grows by appending, and reparsing the whole text per token\n * makes a long reply quadratic. When `text` extends `previous.text` under the same\n * options, only its final line can still change, since it may be unfinished. A block\n * that ends before that line is terminated by a finished line (a blank line, a\n * closing fence, or the line that starts the next block), so appending cannot\n * change it. Only the tail from the last block that starts before the final line\n * is parsed again, and the earlier blocks are returned as the same objects. The\n * parser keeps no state across a block boundary, so the tail parsed alone gives\n * exactly the blocks a full parse gives there. Anything else (an edit, a\n * different option) is a full parse.\n */\nexport function parseMessageTextIncremental(\n previous: MessageParse | undefined,\n text: string,\n options: MessageParseOptions = {}\n): MessageParse {\n const normalized = text.replace(/\\r\\n?/g, '\\n')\n const streaming = options.streaming ?? false\n const citations = options.citations ?? 0\n if (\n previous &&\n previous.streaming === streaming &&\n previous.citations === citations &&\n previous.blocks.length > 0 &&\n normalized.length >= previous.text.length &&\n normalized.startsWith(previous.text)\n ) {\n // Only the final line can still change (it may not be finished), and with it\n // the block it belongs to or the one it ends. Resume from the last block that\n // starts before that line: every block before it ends at a finished line.\n const lastLine = previous.text.lastIndexOf('\\n') + 1\n let keep = previous.starts.length - 1\n while (keep >= 0 && previous.starts[keep]! >= lastLine) keep -= 1\n if (keep > 0) {\n const resumeAt = previous.starts[keep]!\n const tail = parseLines(normalized.slice(resumeAt), options)\n return {\n text: normalized,\n streaming,\n citations,\n blocks: [...previous.blocks.slice(0, keep), ...tail.blocks],\n starts: [\n ...previous.starts.slice(0, keep),\n ...tail.starts.map((start) => start + resumeAt),\n ],\n }\n }\n }\n const full = parseLines(normalized, options)\n return { text: normalized, streaming, citations, ...full }\n}\n\nfunction parseLines(\n text: string,\n options: MessageParseOptions\n): { blocks: MessageBlock[]; starts: number[] } {\n const inline = (source: string) => parseInline(source, 0, { citations: options.citations })\n const lines = text.split('\\n')\n // The offset where each line starts, so a block can record where it began.\n const lineStarts: number[] = []\n for (let line = 0, offset = 0; line < lines.length; line++) {\n lineStarts.push(offset)\n offset += lines[line]!.length + 1\n }\n const blocks: MessageBlock[] = []\n const starts: number[] = []\n let paragraph: string[] = []\n let paragraphStart = 0\n const flushParagraph = () => {\n if (paragraph.length === 0) return\n const raw = paragraph.join('\\n')\n blocks.push({ kind: 'paragraph', inline: inline(raw), raw })\n starts.push(lineStarts[paragraphStart]!)\n paragraph = []\n }\n\n let index = 0\n while (index < lines.length) {\n const line = lines[index]!\n const fence = fenceOpen(line)\n if (fence) {\n flushParagraph()\n const marker = fence.marker\n const language = fence.language || undefined\n const { code, closed, next } = readFence(lines, index + 1, fence)\n starts.push(lineStarts[index]!)\n index = next\n blocks.push({\n kind: 'code',\n language,\n code,\n complete: closed || !options.streaming,\n raw: `${marker}${language ?? ''}\\n${code}${closed ? `\\n${marker}` : ''}`,\n })\n continue\n }\n if (line.trim() === '') {\n flushParagraph()\n index += 1\n continue\n }\n const heading = headingOf(line)\n if (heading) {\n flushParagraph()\n starts.push(lineStarts[index]!)\n blocks.push({\n kind: 'heading',\n level: heading.level,\n inline: inline(heading.text),\n raw: line,\n })\n index += 1\n continue\n }\n const bullet = BULLET.exec(line)\n const ordered = bullet ? null : ORDERED.exec(line)\n if (bullet || ordered) {\n flushParagraph()\n starts.push(lineStarts[index]!)\n const items: MessageInline[][] = []\n const rawLines: string[] = []\n const isOrdered = ordered !== null\n const start = ordered ? Number(ordered[1]) : 1\n while (index < lines.length) {\n const current = lines[index]!\n const match = isOrdered ? ORDERED.exec(current) : BULLET.exec(current)\n if (match) {\n items.push([...inline(isOrdered ? match[2]! : match[1]!)])\n rawLines.push(current)\n index += 1\n continue\n }\n // An indented continuation belongs to the previous item.\n if (/^ {2,}\\S/.test(current) && items.length > 0) {\n // Append in place: copying the accumulated spans on every continuation\n // makes a long item quadratic in its number of lines. Push one span at\n // a time, because spreading a line of many spans into `push` exceeds\n // the engine's argument limit and throws.\n const item = items[items.length - 1]!\n item.push({ kind: 'text', text: ' ' })\n for (const span of inline(current.trim())) item.push(span)\n rawLines.push(current)\n index += 1\n continue\n }\n break\n }\n blocks.push({ kind: 'list', ordered: isOrdered, start, items, raw: rawLines.join('\\n') })\n continue\n }\n const quote = QUOTE.exec(line)\n if (quote) {\n flushParagraph()\n starts.push(lineStarts[index]!)\n const quoted: string[] = []\n while (index < lines.length) {\n const match = QUOTE.exec(lines[index]!)\n if (!match) break\n quoted.push(match[1]!)\n index += 1\n }\n const raw = quoted.join('\\n')\n blocks.push({ kind: 'quote', inline: inline(raw), raw })\n continue\n }\n if (paragraph.length === 0) paragraphStart = index\n paragraph.push(line)\n index += 1\n }\n flushParagraph()\n return { blocks, starts }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkEA,IAAM,aAAa;;;;;;;;;AAUnB,SAAS,UAAU,MAA0E;CAC3F,IAAI,QAAQ;CACZ,OAAO,QAAQ,KAAK,KAAK,WAAW,KAAK,MAAM,IAAI,SAAS;CAC5D,MAAM,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;EAEA,IADc,MAAM,KAAK,IACrB,GAAO;GACT,eAAe;GACf,OAAO,KAAK,WAAW,MAAO;GAC9B,MAAM,SAAmB,CAAC;GAC1B,OAAO,QAAQ,MAAM,QAAQ;IAC3B,MAAM,QAAQ,MAAM,KAAK,MAAM,MAAO;IACtC,IAAI,CAAC,OAAO;IACZ,OAAO,KAAK,MAAM,EAAG;IACrB,SAAS;GACX;GACA,MAAM,MAAM,OAAO,KAAK,IAAI;GAC5B,OAAO,KAAK;IAAE,MAAM;IAAS,QAAQ,OAAO,GAAG;IAAG;GAAI,CAAC;GACvD;EACF;EACA,IAAI,UAAU,WAAW,GAAG,iBAAiB;EAC7C,UAAU,KAAK,IAAI;EACnB,SAAS;CACX;CACA,eAAe;CACf,OAAO;EAAE;EAAQ;CAAO;AAC1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observe-resize.d.ts","sourceRoot":"","sources":["../../src/lib/observe-resize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,KAAK,cAAc,GAAG,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAA;
|
|
1
|
+
{"version":3,"file":"observe-resize.d.ts","sourceRoot":"","sources":["../../src/lib/observe-resize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,KAAK,cAAc,GAAG,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAA;AAW1D,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,cAAc,GAAG,MAAM,IAAI,CAoBpF"}
|
|
@@ -1,17 +1,26 @@
|
|
|
1
1
|
// src/lib/observe-resize.ts
|
|
2
|
-
var
|
|
3
|
-
var callbacks = /* @__PURE__ */ new WeakMap();
|
|
2
|
+
var watchers = /* @__PURE__ */ new WeakMap();
|
|
4
3
|
function observeResize(element, callback) {
|
|
5
4
|
if (typeof ResizeObserver === "undefined") return () => {};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
const Constructor = ResizeObserver;
|
|
6
|
+
let watcher = watchers.get(Constructor);
|
|
7
|
+
if (!watcher) {
|
|
8
|
+
const callbacks = /* @__PURE__ */ new WeakMap();
|
|
9
|
+
watcher = {
|
|
10
|
+
observer: new Constructor((entries) => {
|
|
11
|
+
for (const entry of entries) callbacks.get(entry.target)?.(entry);
|
|
12
|
+
}),
|
|
13
|
+
callbacks
|
|
14
|
+
};
|
|
15
|
+
watchers.set(Constructor, watcher);
|
|
16
|
+
}
|
|
17
|
+
const { observer, callbacks } = watcher;
|
|
9
18
|
callbacks.set(element, callback);
|
|
10
|
-
|
|
19
|
+
observer.observe(element);
|
|
11
20
|
return () => {
|
|
12
21
|
if (callbacks.get(element) !== callback) return;
|
|
13
22
|
callbacks.delete(element);
|
|
14
|
-
|
|
23
|
+
observer.unobserve(element);
|
|
15
24
|
};
|
|
16
25
|
}
|
|
17
26
|
export { observeResize };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observe-resize.js","names":[],"sources":["../../src/lib/observe-resize.ts"],"sourcesContent":["/**\n * Watch an element's size through one ResizeObserver shared by every caller.\n *\n * A component that creates its own observer per instance pays for one observer\n * object, one browser registration and one delivery callback per mount; a reply\n * with a dozen code blocks made a dozen. The shared observer delivers every\n * changed element in one batch per frame and calls each element's callback.\n *\n * Returns a function that stops watching. Outside a browser it does nothing.\n */\ntype ResizeCallback = (entry: ResizeObserverEntry) => void\n\
|
|
1
|
+
{"version":3,"file":"observe-resize.js","names":[],"sources":["../../src/lib/observe-resize.ts"],"sourcesContent":["/**\n * Watch an element's size through one ResizeObserver shared by every caller.\n *\n * A component that creates its own observer per instance pays for one observer\n * object, one browser registration and one delivery callback per mount; a reply\n * with a dozen code blocks made a dozen. The shared observer delivers every\n * changed element in one batch per frame and calls each element's callback.\n *\n * Returns a function that stops watching. Outside a browser it does nothing.\n */\ntype ResizeCallback = (entry: ResizeObserverEntry) => void\n\ntype Watcher = {\n observer: ResizeObserver\n callbacks: WeakMap<Element, ResizeCallback>\n}\n\n// Reuse a single observer for a platform constructor. Replacing the constructor\n// (for example, installing a polyfill) must not leave new callers using the old observer.\nconst watchers = new WeakMap<typeof ResizeObserver, Watcher>()\n\nexport function observeResize(element: Element, callback: ResizeCallback): () => void {\n if (typeof ResizeObserver === 'undefined') return () => {}\n const Constructor = ResizeObserver\n let watcher = watchers.get(Constructor)\n if (!watcher) {\n const callbacks = new WeakMap<Element, ResizeCallback>()\n const observer = new Constructor((entries) => {\n for (const entry of entries) callbacks.get(entry.target)?.(entry)\n })\n watcher = { observer, callbacks }\n watchers.set(Constructor, watcher)\n }\n const { observer, callbacks } = watcher\n callbacks.set(element, callback)\n observer.observe(element)\n return () => {\n if (callbacks.get(element) !== callback) return\n callbacks.delete(element)\n observer.unobserve(element)\n }\n}\n"],"mappings":";AAmBA,IAAM,2BAAW,IAAI,QAAwC;AAE7D,SAAgB,cAAc,SAAkB,UAAsC;CACpF,IAAI,OAAO,mBAAmB,aAAa,aAAa,CAAC;CACzD,MAAM,cAAc;CACpB,IAAI,UAAU,SAAS,IAAI,WAAW;CACtC,IAAI,CAAC,SAAS;EACZ,MAAM,4BAAY,IAAI,QAAiC;EAIvD,UAAU;GAAE,UAAA,IAHS,aAAa,YAAY;IAC5C,KAAK,MAAM,SAAS,SAAS,UAAU,IAAI,MAAM,MAAM,CAAC,GAAG,KAAK;GAClE,CACY;GAAU;EAAU;EAChC,SAAS,IAAI,aAAa,OAAO;CACnC;CACA,MAAM,EAAE,UAAU,cAAc;CAChC,UAAU,IAAI,SAAS,QAAQ;CAC/B,SAAS,QAAQ,OAAO;CACxB,aAAa;EACX,IAAI,UAAU,IAAI,OAAO,MAAM,UAAU;EACzC,UAAU,OAAO,OAAO;EACxB,SAAS,UAAU,OAAO;CAC5B;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createEffect, createMemo, createSignal, For, onSettled, Show } from 'solid-js'
|
|
1
|
+
import { children, createEffect, createMemo, createSignal, For, onSettled, Show } from 'solid-js'
|
|
2
2
|
import {
|
|
3
3
|
ArrowLeft as LucideArrowLeft,
|
|
4
4
|
Blocks as LucideBlocks,
|
|
@@ -114,6 +114,7 @@ export function CatalogBrowser<Value>(props: CatalogBrowserProps<Value>) {
|
|
|
114
114
|
const countLabel = () =>
|
|
115
115
|
props.status === 'loading' ? props.loadingLabel : props.resultLabel(props.resultCount)
|
|
116
116
|
const supplementalContent = () => props.renderSupplementalView?.(props.tab)
|
|
117
|
+
const tabsLeading = children(() => props.tabsLeading)
|
|
117
118
|
|
|
118
119
|
return (
|
|
119
120
|
<div class={cn('flex min-h-0 min-w-0 flex-1 flex-col', props.class)}>
|
|
@@ -125,11 +126,31 @@ export function CatalogBrowser<Value>(props: CatalogBrowserProps<Value>) {
|
|
|
125
126
|
value={props.tab}
|
|
126
127
|
onChange={(value: string | undefined) => value && props.onTabChange(value)}
|
|
127
128
|
>
|
|
128
|
-
<
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
129
|
+
<Show
|
|
130
|
+
when={tabsLeading()}
|
|
131
|
+
fallback={
|
|
132
|
+
<TabsList
|
|
133
|
+
aria-label={props.tabsLabel}
|
|
134
|
+
class="ms-auto max-w-full flex-wrap px-4 pt-2"
|
|
135
|
+
>
|
|
136
|
+
<For each={props.tabs}>
|
|
137
|
+
{(tab) => <TabsTrigger value={tab.id}>{tab.label}</TabsTrigger>}
|
|
138
|
+
</For>
|
|
139
|
+
</TabsList>
|
|
140
|
+
}
|
|
141
|
+
>
|
|
142
|
+
<div
|
|
143
|
+
class="flex min-w-0 shrink-0 flex-wrap items-center gap-2 px-4 pt-2"
|
|
144
|
+
data-slot="catalog-browser-tabs-row"
|
|
145
|
+
>
|
|
146
|
+
{tabsLeading()}
|
|
147
|
+
<TabsList aria-label={props.tabsLabel} class="ms-auto max-w-full flex-wrap">
|
|
148
|
+
<For each={props.tabs}>
|
|
149
|
+
{(tab) => <TabsTrigger value={tab.id}>{tab.label}</TabsTrigger>}
|
|
150
|
+
</For>
|
|
151
|
+
</TabsList>
|
|
152
|
+
</div>
|
|
153
|
+
</Show>
|
|
133
154
|
<TabsContent value={props.tab} class="flex min-h-0 min-w-0 flex-1 flex-col gap-3">
|
|
134
155
|
<Show
|
|
135
156
|
when={supplemental()}
|
|
@@ -45,6 +45,11 @@ export type CatalogBrowserProps<Value> = Readonly<{
|
|
|
45
45
|
tabs: readonly CatalogBrowserTab[]
|
|
46
46
|
tab: string
|
|
47
47
|
tabsLabel: string
|
|
48
|
+
/**
|
|
49
|
+
* A host control drawn at the start of the tabs row, such as a switch between two
|
|
50
|
+
* catalogs that share this frame. Without it the row holds the tabs alone.
|
|
51
|
+
*/
|
|
52
|
+
tabsLeading?: JSX.Element
|
|
48
53
|
onTabChange: (tab: string) => void
|
|
49
54
|
/** A host-owned view is rendered in the same tab frame without catalog assumptions. */
|
|
50
55
|
renderSupplementalView?: (tab: string) => JSX.Element | undefined
|
|
@@ -304,7 +304,15 @@ export function parseInline(
|
|
|
304
304
|
continue
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
|
-
if (depth < MAX_INLINE_DEPTH && char === '[') {
|
|
307
|
+
if (depth < MAX_INLINE_DEPTH && char === '[' && paren !== -1) {
|
|
308
|
+
// Don't allocate bracket pairs for text that cannot contain a complete
|
|
309
|
+
// link. Remember the last miss so later literal openers are O(1).
|
|
310
|
+
if (paren < index) paren = text.indexOf(')', index + 1)
|
|
311
|
+
if (paren === -1) {
|
|
312
|
+
buffer += char
|
|
313
|
+
index += 1
|
|
314
|
+
continue
|
|
315
|
+
}
|
|
308
316
|
brackets ??= bracketMatches(text)
|
|
309
317
|
const labelEnd = brackets.get(index) ?? -1
|
|
310
318
|
if (labelEnd > index && text[labelEnd + 1] === '(') {
|
|
@@ -10,19 +10,33 @@
|
|
|
10
10
|
*/
|
|
11
11
|
type ResizeCallback = (entry: ResizeObserverEntry) => void
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
type Watcher = {
|
|
14
|
+
observer: ResizeObserver
|
|
15
|
+
callbacks: WeakMap<Element, ResizeCallback>
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Reuse a single observer for a platform constructor. Replacing the constructor
|
|
19
|
+
// (for example, installing a polyfill) must not leave new callers using the old observer.
|
|
20
|
+
const watchers = new WeakMap<typeof ResizeObserver, Watcher>()
|
|
15
21
|
|
|
16
22
|
export function observeResize(element: Element, callback: ResizeCallback): () => void {
|
|
17
23
|
if (typeof ResizeObserver === 'undefined') return () => {}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
const Constructor = ResizeObserver
|
|
25
|
+
let watcher = watchers.get(Constructor)
|
|
26
|
+
if (!watcher) {
|
|
27
|
+
const callbacks = new WeakMap<Element, ResizeCallback>()
|
|
28
|
+
const observer = new Constructor((entries) => {
|
|
29
|
+
for (const entry of entries) callbacks.get(entry.target)?.(entry)
|
|
30
|
+
})
|
|
31
|
+
watcher = { observer, callbacks }
|
|
32
|
+
watchers.set(Constructor, watcher)
|
|
33
|
+
}
|
|
34
|
+
const { observer, callbacks } = watcher
|
|
21
35
|
callbacks.set(element, callback)
|
|
22
|
-
|
|
36
|
+
observer.observe(element)
|
|
23
37
|
return () => {
|
|
24
38
|
if (callbacks.get(element) !== callback) return
|
|
25
39
|
callbacks.delete(element)
|
|
26
|
-
|
|
40
|
+
observer.unobserve(element)
|
|
27
41
|
}
|
|
28
42
|
}
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createEffect, createMemo, createSignal, For, onSettled, Show } from 'solid-js'
|
|
1
|
+
import { children, createEffect, createMemo, createSignal, For, onSettled, Show } from 'solid-js'
|
|
2
2
|
import {
|
|
3
3
|
ArrowLeft as LucideArrowLeft,
|
|
4
4
|
Blocks as LucideBlocks,
|
|
@@ -114,6 +114,7 @@ export function CatalogBrowser<Value>(props: CatalogBrowserProps<Value>) {
|
|
|
114
114
|
const countLabel = () =>
|
|
115
115
|
props.status === 'loading' ? props.loadingLabel : props.resultLabel(props.resultCount)
|
|
116
116
|
const supplementalContent = () => props.renderSupplementalView?.(props.tab)
|
|
117
|
+
const tabsLeading = children(() => props.tabsLeading)
|
|
117
118
|
|
|
118
119
|
return (
|
|
119
120
|
<div class={cn('flex min-h-0 min-w-0 flex-1 flex-col', props.class)}>
|
|
@@ -125,11 +126,31 @@ export function CatalogBrowser<Value>(props: CatalogBrowserProps<Value>) {
|
|
|
125
126
|
value={props.tab}
|
|
126
127
|
onChange={(value: string | undefined) => value && props.onTabChange(value)}
|
|
127
128
|
>
|
|
128
|
-
<
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
129
|
+
<Show
|
|
130
|
+
when={tabsLeading()}
|
|
131
|
+
fallback={
|
|
132
|
+
<TabsList
|
|
133
|
+
aria-label={props.tabsLabel}
|
|
134
|
+
class="ms-auto max-w-full flex-wrap px-4 pt-2"
|
|
135
|
+
>
|
|
136
|
+
<For each={props.tabs}>
|
|
137
|
+
{(tab) => <TabsTrigger value={tab.id}>{tab.label}</TabsTrigger>}
|
|
138
|
+
</For>
|
|
139
|
+
</TabsList>
|
|
140
|
+
}
|
|
141
|
+
>
|
|
142
|
+
<div
|
|
143
|
+
class="flex min-w-0 shrink-0 flex-wrap items-center gap-2 px-4 pt-2"
|
|
144
|
+
data-slot="catalog-browser-tabs-row"
|
|
145
|
+
>
|
|
146
|
+
{tabsLeading()}
|
|
147
|
+
<TabsList aria-label={props.tabsLabel} class="ms-auto max-w-full flex-wrap">
|
|
148
|
+
<For each={props.tabs}>
|
|
149
|
+
{(tab) => <TabsTrigger value={tab.id}>{tab.label}</TabsTrigger>}
|
|
150
|
+
</For>
|
|
151
|
+
</TabsList>
|
|
152
|
+
</div>
|
|
153
|
+
</Show>
|
|
133
154
|
<TabsContent value={props.tab} class="flex min-h-0 min-w-0 flex-1 flex-col gap-3">
|
|
134
155
|
<Show
|
|
135
156
|
when={supplemental()}
|
|
@@ -45,6 +45,11 @@ export type CatalogBrowserProps<Value> = Readonly<{
|
|
|
45
45
|
tabs: readonly CatalogBrowserTab[]
|
|
46
46
|
tab: string
|
|
47
47
|
tabsLabel: string
|
|
48
|
+
/**
|
|
49
|
+
* A host control drawn at the start of the tabs row, such as a switch between two
|
|
50
|
+
* catalogs that share this frame. Without it the row holds the tabs alone.
|
|
51
|
+
*/
|
|
52
|
+
tabsLeading?: JSX.Element
|
|
48
53
|
onTabChange: (tab: string) => void
|
|
49
54
|
/** A host-owned view is rendered in the same tab frame without catalog assumptions. */
|
|
50
55
|
renderSupplementalView?: (tab: string) => JSX.Element | undefined
|
|
@@ -304,7 +304,15 @@ export function parseInline(
|
|
|
304
304
|
continue
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
|
-
if (depth < MAX_INLINE_DEPTH && char === '[') {
|
|
307
|
+
if (depth < MAX_INLINE_DEPTH && char === '[' && paren !== -1) {
|
|
308
|
+
// Don't allocate bracket pairs for text that cannot contain a complete
|
|
309
|
+
// link. Remember the last miss so later literal openers are O(1).
|
|
310
|
+
if (paren < index) paren = text.indexOf(')', index + 1)
|
|
311
|
+
if (paren === -1) {
|
|
312
|
+
buffer += char
|
|
313
|
+
index += 1
|
|
314
|
+
continue
|
|
315
|
+
}
|
|
308
316
|
brackets ??= bracketMatches(text)
|
|
309
317
|
const labelEnd = brackets.get(index) ?? -1
|
|
310
318
|
if (labelEnd > index && text[labelEnd + 1] === '(') {
|
|
@@ -10,19 +10,33 @@
|
|
|
10
10
|
*/
|
|
11
11
|
type ResizeCallback = (entry: ResizeObserverEntry) => void
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
type Watcher = {
|
|
14
|
+
observer: ResizeObserver
|
|
15
|
+
callbacks: WeakMap<Element, ResizeCallback>
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Reuse a single observer for a platform constructor. Replacing the constructor
|
|
19
|
+
// (for example, installing a polyfill) must not leave new callers using the old observer.
|
|
20
|
+
const watchers = new WeakMap<typeof ResizeObserver, Watcher>()
|
|
15
21
|
|
|
16
22
|
export function observeResize(element: Element, callback: ResizeCallback): () => void {
|
|
17
23
|
if (typeof ResizeObserver === 'undefined') return () => {}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
const Constructor = ResizeObserver
|
|
25
|
+
let watcher = watchers.get(Constructor)
|
|
26
|
+
if (!watcher) {
|
|
27
|
+
const callbacks = new WeakMap<Element, ResizeCallback>()
|
|
28
|
+
const observer = new Constructor((entries) => {
|
|
29
|
+
for (const entry of entries) callbacks.get(entry.target)?.(entry)
|
|
30
|
+
})
|
|
31
|
+
watcher = { observer, callbacks }
|
|
32
|
+
watchers.set(Constructor, watcher)
|
|
33
|
+
}
|
|
34
|
+
const { observer, callbacks } = watcher
|
|
21
35
|
callbacks.set(element, callback)
|
|
22
|
-
|
|
36
|
+
observer.observe(element)
|
|
23
37
|
return () => {
|
|
24
38
|
if (callbacks.get(element) !== callback) return
|
|
25
39
|
callbacks.delete(element)
|
|
26
|
-
|
|
40
|
+
observer.unobserve(element)
|
|
27
41
|
}
|
|
28
42
|
}
|