@ox0/ui 3.9.0 → 3.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/global-search.d.ts +8 -1
- package/dist/components/global-search.d.ts.map +1 -1
- package/dist/components/theme-root.d.ts.map +1 -1
- package/dist/components/theme-root.test.d.ts +2 -0
- package/dist/components/theme-root.test.d.ts.map +1 -0
- package/dist/index.js +223 -42
- package/dist/providers/ox0-provider.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type SearchHistory } from "@ox0/hooks";
|
|
1
2
|
import { type ReactNode } from "react";
|
|
2
3
|
import { type SearchSource } from "./search-runner";
|
|
3
4
|
export { defineSearchSource, matchSearchItems } from "./search-runner";
|
|
@@ -38,8 +39,14 @@ export interface GlobalSearchProps {
|
|
|
38
39
|
* announced politely when it changes. Keep it to a short line or two.
|
|
39
40
|
*/
|
|
40
41
|
readonly status?: ReactNode;
|
|
42
|
+
/**
|
|
43
|
+
* Recent searches, from `useSearchHistory("<key>")` in `@ox0/hooks`. Listed when the box is
|
|
44
|
+
* empty; picking one searches for it again. A search is recorded when a result is opened from
|
|
45
|
+
* it. Without it, no history is kept.
|
|
46
|
+
*/
|
|
47
|
+
readonly history?: SearchHistory;
|
|
41
48
|
}
|
|
42
|
-
declare function GlobalSearchRoot({ children, defaultOpen, emptyState, isOpen: isOpenProp, isShortcutDisabled, onOpenChange, placeholder, sources, status, }: GlobalSearchProps): ReactNode;
|
|
49
|
+
declare function GlobalSearchRoot({ children, defaultOpen, emptyState, history, isOpen: isOpenProp, isShortcutDisabled, onOpenChange, placeholder, sources, status, }: GlobalSearchProps): ReactNode;
|
|
43
50
|
export interface GlobalSearchTriggerProps {
|
|
44
51
|
/** Text in the box. Default "Search…". */
|
|
45
52
|
readonly placeholder?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global-search.d.ts","sourceRoot":"","sources":["../../src/components/global-search.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"global-search.d.ts","sourceRoot":"","sources":["../../src/components/global-search.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAyC,MAAM,YAAY,CAAA;AAEtF,OAAO,EAEL,KAAK,SAAS,EAWf,MAAM,OAAO,CAAA;AAOd,OAAO,EAAE,KAAK,YAAY,EAAgB,MAAM,iBAAiB,CAAA;AAKjE,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AACtE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAelE,MAAM,WAAW,oBAAoB;IACnC,0DAA0D;IAC1D,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;IACvC,QAAQ,CAAC,KAAK,EAAE,MAAM,IAAI,CAAA;IAC1B;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAA;IAC5B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;IACxB,6EAA6E;IAC7E,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;CAC/B;AAID,oEAAoE;AACpE,wBAAgB,eAAe,IAAI,oBAAoB,CAItD;AAID,MAAM,WAAW,iBAAiB;IAChC,qFAAqF;IACrF,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;IAC7B,yFAAyF;IACzF,QAAQ,CAAC,OAAO,EAAE,SAAS,YAAY,CAAC,OAAO,CAAC,EAAE,CAAA;IAClD,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAA;IAC9B,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAA;IACjD,0CAA0C;IAC1C,QAAQ,CAAC,kBAAkB,CAAC,EAAE,OAAO,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
|
+
{"version":3,"file":"theme-root.d.ts","sourceRoot":"","sources":["../../src/components/theme-root.ts"],"names":[],"mappings":"AAOA,wBAAgB,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,CAIrF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-root.test.d.ts","sourceRoot":"","sources":["../../src/components/theme-root.test.ts"],"names":[],"mappings":""}
|
package/dist/index.js
CHANGED
|
@@ -2621,7 +2621,8 @@ label:hover > .control-TGnWDN[aria-invalid="true"]:not(:disabled) {
|
|
|
2621
2621
|
align-items: center;
|
|
2622
2622
|
gap: var(--ox0-space-sm);
|
|
2623
2623
|
height: var(--ox0-control-height-md);
|
|
2624
|
-
min-inline-size: 14rem;
|
|
2624
|
+
min-inline-size: min(14rem, 100%);
|
|
2625
|
+
max-inline-size: 100%;
|
|
2625
2626
|
padding-inline: var(--ox0-space-md) var(--ox0-space-sm);
|
|
2626
2627
|
transition: border-color var(--ox0-duration-fast) var(--ox0-ease-crisp);
|
|
2627
2628
|
display: inline-flex;
|
|
@@ -2784,6 +2785,45 @@ label:hover > .control-TGnWDN[aria-invalid="true"]:not(:disabled) {
|
|
|
2784
2785
|
background: color-mix(in srgb, var(--ox0-color-foreground) 10%, transparent);
|
|
2785
2786
|
}
|
|
2786
2787
|
|
|
2788
|
+
.recent-oZybBM {
|
|
2789
|
+
align-items: center;
|
|
2790
|
+
gap: var(--ox0-space-sm);
|
|
2791
|
+
display: flex;
|
|
2792
|
+
}
|
|
2793
|
+
|
|
2794
|
+
.recentIcon-MrJTxU {
|
|
2795
|
+
color: var(--ox0-color-muted);
|
|
2796
|
+
display: inline-flex;
|
|
2797
|
+
}
|
|
2798
|
+
|
|
2799
|
+
.recentText-CGQFAg {
|
|
2800
|
+
text-overflow: ellipsis;
|
|
2801
|
+
white-space: nowrap;
|
|
2802
|
+
flex: auto;
|
|
2803
|
+
min-width: 0;
|
|
2804
|
+
overflow: hidden;
|
|
2805
|
+
}
|
|
2806
|
+
|
|
2807
|
+
.removeRecent-yVJYOj {
|
|
2808
|
+
border-radius: var(--ox0-radius-xs);
|
|
2809
|
+
color: var(--ox0-color-muted);
|
|
2810
|
+
cursor: pointer;
|
|
2811
|
+
padding: var(--ox0-space-2xs);
|
|
2812
|
+
visibility: hidden;
|
|
2813
|
+
background: none;
|
|
2814
|
+
border: none;
|
|
2815
|
+
align-items: center;
|
|
2816
|
+
display: inline-flex;
|
|
2817
|
+
}
|
|
2818
|
+
|
|
2819
|
+
.option-qf4Q7q:hover .removeRecent-yVJYOj, .option-qf4Q7q[data-active] .removeRecent-yVJYOj {
|
|
2820
|
+
visibility: visible;
|
|
2821
|
+
}
|
|
2822
|
+
|
|
2823
|
+
.removeRecent-yVJYOj:hover {
|
|
2824
|
+
color: var(--ox0-color-foreground);
|
|
2825
|
+
}
|
|
2826
|
+
|
|
2787
2827
|
.preview-s52x7t {
|
|
2788
2828
|
border-inline-start: 1px solid var(--ox0-color-border-subtle);
|
|
2789
2829
|
min-height: 0;
|
|
@@ -2960,6 +3000,10 @@ label:hover > .control-TGnWDN[aria-invalid="true"]:not(:disabled) {
|
|
|
2960
3000
|
groupHeading: "groupHeading-wlm1Bd",
|
|
2961
3001
|
groupStatus: "groupStatus-xQbH9H",
|
|
2962
3002
|
option: "option-qf4Q7q",
|
|
3003
|
+
recent: "recent-oZybBM",
|
|
3004
|
+
recentIcon: "recentIcon-MrJTxU",
|
|
3005
|
+
recentText: "recentText-CGQFAg",
|
|
3006
|
+
removeRecent: "removeRecent-yVJYOj",
|
|
2963
3007
|
preview: "preview-s52x7t",
|
|
2964
3008
|
result: "result-HpbdT2",
|
|
2965
3009
|
resultIcon: "resultIcon-qmtpm2",
|
|
@@ -6694,9 +6738,10 @@ const button_Button = /*#__PURE__*/ forwardRef(function({ children, icon: Icon,
|
|
|
6694
6738
|
})
|
|
6695
6739
|
});
|
|
6696
6740
|
});
|
|
6697
|
-
const THEME_SCOPE = "[data-theme], [data-color-scheme], [data-density]";
|
|
6741
|
+
const THEME_SCOPE = "[data-ox0-root], [data-theme], [data-color-scheme], [data-density]";
|
|
6698
6742
|
function themeRoot(anchor) {
|
|
6699
|
-
|
|
6743
|
+
const root = anchor?.closest(THEME_SCOPE);
|
|
6744
|
+
return root && root !== root.ownerDocument.documentElement ? root : void 0;
|
|
6700
6745
|
}
|
|
6701
6746
|
const WARMUP_MS = 1000;
|
|
6702
6747
|
const COOLDOWN_MS = 500;
|
|
@@ -9285,7 +9330,7 @@ function useGlobalSearch() {
|
|
|
9285
9330
|
if (!ctx) throw new Error("useGlobalSearch must be used inside <GlobalSearch>");
|
|
9286
9331
|
return ctx;
|
|
9287
9332
|
}
|
|
9288
|
-
function GlobalSearchRoot({ children, defaultOpen = false, emptyState, isOpen: isOpenProp, isShortcutDisabled = false, onOpenChange, placeholder, sources, status }) {
|
|
9333
|
+
function GlobalSearchRoot({ children, defaultOpen = false, emptyState, history, isOpen: isOpenProp, isShortcutDisabled = false, onOpenChange, placeholder, sources, status }) {
|
|
9289
9334
|
const os = useOS();
|
|
9290
9335
|
const [isOpen, setIsOpen] = useControllableState({
|
|
9291
9336
|
defaultValue: defaultOpen,
|
|
@@ -9350,6 +9395,7 @@ function GlobalSearchRoot({ children, defaultOpen = false, emptyState, isOpen: i
|
|
|
9350
9395
|
}),
|
|
9351
9396
|
isOpen && anchor ? /*#__PURE__*/ createPortal(/*#__PURE__*/ jsx(SearchPanel, {
|
|
9352
9397
|
emptyState: emptyState,
|
|
9398
|
+
history: history,
|
|
9353
9399
|
initialQuery: initialQuery,
|
|
9354
9400
|
placeholder: placeholder,
|
|
9355
9401
|
refreshRef: refreshRef,
|
|
@@ -9360,7 +9406,7 @@ function GlobalSearchRoot({ children, defaultOpen = false, emptyState, isOpen: i
|
|
|
9360
9406
|
]
|
|
9361
9407
|
});
|
|
9362
9408
|
}
|
|
9363
|
-
function SearchPanel({ emptyState, initialQuery, onClose, placeholder, refreshRef, sources, status }) {
|
|
9409
|
+
function SearchPanel({ emptyState, history, initialQuery, onClose, placeholder, refreshRef, sources, status }) {
|
|
9364
9410
|
const baseId = useId();
|
|
9365
9411
|
const listboxId = `${baseId}-listbox`;
|
|
9366
9412
|
const router = useRouter();
|
|
@@ -9381,6 +9427,8 @@ function SearchPanel({ emptyState, initialQuery, onClose, placeholder, refreshRe
|
|
|
9381
9427
|
const navigateHint = useMessage("ox0.globalSearch.navigate", "Navigate");
|
|
9382
9428
|
const openHint = useMessage("ox0.globalSearch.open", "Open");
|
|
9383
9429
|
const closeHint = useMessage("ox0.globalSearch.close", "Close");
|
|
9430
|
+
const recentLabel = useMessage("ox0.globalSearch.recent", "Recent");
|
|
9431
|
+
const removeRecentLabel = useMessage("ox0.globalSearch.removeRecent", "Remove from recent searches");
|
|
9384
9432
|
useEffect(()=>{
|
|
9385
9433
|
runner.run(sources, query);
|
|
9386
9434
|
}, [
|
|
@@ -9419,7 +9467,17 @@ function SearchPanel({ emptyState, initialQuery, onClose, placeholder, refreshRe
|
|
|
9419
9467
|
baseId,
|
|
9420
9468
|
groups
|
|
9421
9469
|
]);
|
|
9422
|
-
const
|
|
9470
|
+
const recents = "" === query.trim() ? (history?.entries ?? []).map((text, index)=>({
|
|
9471
|
+
id: `${baseId}-recent-${index}`,
|
|
9472
|
+
text
|
|
9473
|
+
})) : [];
|
|
9474
|
+
const rowIds = [
|
|
9475
|
+
...recents.map((recent)=>recent.id),
|
|
9476
|
+
...options.map((option)=>option.id)
|
|
9477
|
+
];
|
|
9478
|
+
const activeRowId = null !== activeId && rowIds.includes(activeId) ? activeId : rowIds[0];
|
|
9479
|
+
const activeRecent = recents.find((recent)=>recent.id === activeRowId);
|
|
9480
|
+
const active = options.find((option)=>option.id === activeRowId);
|
|
9423
9481
|
const isLoading = groups.some((group)=>"loading" === group.status);
|
|
9424
9482
|
const hasPreviewPane = sources.some((source)=>void 0 !== source.renderPreview);
|
|
9425
9483
|
const terms = useMemo(()=>query.trim().split(/\s+/).filter(Boolean), [
|
|
@@ -9429,15 +9487,16 @@ function SearchPanel({ emptyState, initialQuery, onClose, placeholder, refreshRe
|
|
|
9429
9487
|
count: String(options.length)
|
|
9430
9488
|
});
|
|
9431
9489
|
useEffect(()=>{
|
|
9432
|
-
if (
|
|
9433
|
-
document.getElementById(
|
|
9490
|
+
if (void 0 === activeRowId) return;
|
|
9491
|
+
document.getElementById(activeRowId)?.scrollIntoView?.({
|
|
9434
9492
|
block: "nearest"
|
|
9435
9493
|
});
|
|
9436
9494
|
}, [
|
|
9437
|
-
|
|
9495
|
+
activeRowId
|
|
9438
9496
|
]);
|
|
9439
9497
|
function choose(option, inNewTab) {
|
|
9440
9498
|
const href = option.source.getHref?.(option.item);
|
|
9499
|
+
history?.add(query);
|
|
9441
9500
|
onClose();
|
|
9442
9501
|
if (void 0 !== href && isSafeHref(href)) if (inNewTab) window.open(href, "_blank", "noopener,noreferrer");
|
|
9443
9502
|
else if (router) router.navigate(href);
|
|
@@ -9445,10 +9504,21 @@ function SearchPanel({ emptyState, initialQuery, onClose, placeholder, refreshRe
|
|
|
9445
9504
|
option.source.onAction?.(option.item);
|
|
9446
9505
|
}
|
|
9447
9506
|
function move(offset) {
|
|
9448
|
-
if (0 ===
|
|
9449
|
-
const index =
|
|
9450
|
-
const next =
|
|
9451
|
-
if (next) setActiveId(next
|
|
9507
|
+
if (0 === rowIds.length || void 0 === activeRowId) return;
|
|
9508
|
+
const index = rowIds.indexOf(activeRowId);
|
|
9509
|
+
const next = rowIds[(index + offset + rowIds.length) % rowIds.length];
|
|
9510
|
+
if (next) setActiveId(next);
|
|
9511
|
+
}
|
|
9512
|
+
function searchAgain(recent) {
|
|
9513
|
+
setQuery(recent.text);
|
|
9514
|
+
setActiveId(null);
|
|
9515
|
+
inputRef.current?.focus();
|
|
9516
|
+
}
|
|
9517
|
+
function removeRecent(recent) {
|
|
9518
|
+
const index = recents.indexOf(recent);
|
|
9519
|
+
history?.remove(recent.text);
|
|
9520
|
+
const kept = index < recents.length - 1 ? index : index - 1;
|
|
9521
|
+
setActiveId(kept >= 0 ? `${baseId}-recent-${kept}` : null);
|
|
9452
9522
|
}
|
|
9453
9523
|
function handleInputKeyDown(e) {
|
|
9454
9524
|
if (e.nativeEvent.isComposing) return;
|
|
@@ -9462,10 +9532,20 @@ function SearchPanel({ emptyState, initialQuery, onClose, placeholder, refreshRe
|
|
|
9462
9532
|
move(-1);
|
|
9463
9533
|
break;
|
|
9464
9534
|
case "Enter":
|
|
9535
|
+
if (activeRecent) {
|
|
9536
|
+
e.preventDefault();
|
|
9537
|
+
searchAgain(activeRecent);
|
|
9538
|
+
return;
|
|
9539
|
+
}
|
|
9465
9540
|
if (!active) return;
|
|
9466
9541
|
e.preventDefault();
|
|
9467
9542
|
choose(active, e.metaKey || e.ctrlKey);
|
|
9468
9543
|
break;
|
|
9544
|
+
case "Delete":
|
|
9545
|
+
if (!activeRecent || !e.shiftKey) return;
|
|
9546
|
+
e.preventDefault();
|
|
9547
|
+
removeRecent(activeRecent);
|
|
9548
|
+
break;
|
|
9469
9549
|
case "Escape":
|
|
9470
9550
|
e.preventDefault();
|
|
9471
9551
|
if (query) setQuery("");
|
|
@@ -9516,10 +9596,10 @@ function SearchPanel({ emptyState, initialQuery, onClose, placeholder, refreshRe
|
|
|
9516
9596
|
/*#__PURE__*/ jsx(SearchIcon, {}),
|
|
9517
9597
|
/*#__PURE__*/ jsx("input", {
|
|
9518
9598
|
ref: inputRef,
|
|
9519
|
-
"aria-activedescendant":
|
|
9599
|
+
"aria-activedescendant": activeRowId,
|
|
9520
9600
|
"aria-autocomplete": "list",
|
|
9521
9601
|
"aria-controls": listboxId,
|
|
9522
|
-
"aria-expanded":
|
|
9602
|
+
"aria-expanded": rowIds.length > 0,
|
|
9523
9603
|
"aria-label": label,
|
|
9524
9604
|
autoComplete: "off",
|
|
9525
9605
|
className: global_search_module.input,
|
|
@@ -9545,47 +9625,75 @@ function SearchPanel({ emptyState, initialQuery, onClose, placeholder, refreshRe
|
|
|
9545
9625
|
children: /*#__PURE__*/ jsxs("div", {
|
|
9546
9626
|
className: global_search_module.resultsPane,
|
|
9547
9627
|
children: [
|
|
9548
|
-
/*#__PURE__*/
|
|
9628
|
+
/*#__PURE__*/ jsxs("div", {
|
|
9549
9629
|
"aria-label": label,
|
|
9550
9630
|
className: global_search_module.results,
|
|
9551
9631
|
id: listboxId,
|
|
9552
9632
|
role: "listbox",
|
|
9553
|
-
children:
|
|
9554
|
-
|
|
9555
|
-
const groupStatus = "error" === group.status ? errorText : "loading" === group.status && 0 === groupOptions.length ? loadingText : null;
|
|
9556
|
-
if (0 === groupOptions.length && null === groupStatus) return null;
|
|
9557
|
-
const headingId = `${baseId}-${group.source.id}-heading`;
|
|
9558
|
-
return /*#__PURE__*/ jsxs("div", {
|
|
9633
|
+
children: [
|
|
9634
|
+
recents.length > 0 ? /*#__PURE__*/ jsxs("div", {
|
|
9559
9635
|
className: global_search_module.group,
|
|
9560
9636
|
role: "presentation",
|
|
9561
9637
|
children: [
|
|
9562
|
-
/*#__PURE__*/
|
|
9638
|
+
/*#__PURE__*/ jsx("div", {
|
|
9563
9639
|
className: global_search_module.groupHeading,
|
|
9564
|
-
id:
|
|
9640
|
+
id: `${baseId}-recent-heading`,
|
|
9565
9641
|
role: "presentation",
|
|
9566
|
-
children:
|
|
9567
|
-
|
|
9568
|
-
|
|
9569
|
-
}),
|
|
9570
|
-
groupStatus ? /*#__PURE__*/ jsx("span", {
|
|
9571
|
-
className: global_search_module.groupStatus,
|
|
9572
|
-
children: groupStatus
|
|
9573
|
-
}) : null
|
|
9574
|
-
]
|
|
9642
|
+
children: /*#__PURE__*/ jsx("span", {
|
|
9643
|
+
children: recentLabel
|
|
9644
|
+
})
|
|
9575
9645
|
}),
|
|
9576
9646
|
/*#__PURE__*/ jsx("div", {
|
|
9577
|
-
"aria-labelledby":
|
|
9647
|
+
"aria-labelledby": `${baseId}-recent-heading`,
|
|
9578
9648
|
role: "group",
|
|
9579
|
-
children:
|
|
9580
|
-
isActive:
|
|
9581
|
-
|
|
9582
|
-
|
|
9583
|
-
|
|
9584
|
-
|
|
9649
|
+
children: recents.map((recent)=>/*#__PURE__*/ jsx(RecentRow, {
|
|
9650
|
+
isActive: recent.id === activeRowId,
|
|
9651
|
+
recent: recent,
|
|
9652
|
+
removeLabel: removeRecentLabel,
|
|
9653
|
+
onChoose: searchAgain,
|
|
9654
|
+
onHover: setActiveId,
|
|
9655
|
+
onRemove: removeRecent
|
|
9656
|
+
}, recent.id))
|
|
9585
9657
|
})
|
|
9586
9658
|
]
|
|
9587
|
-
},
|
|
9588
|
-
|
|
9659
|
+
}) : null,
|
|
9660
|
+
groups.map((group)=>{
|
|
9661
|
+
const groupOptions = options.filter((option)=>option.source === group.source);
|
|
9662
|
+
const groupStatus = "error" === group.status ? errorText : "loading" === group.status && 0 === groupOptions.length ? loadingText : null;
|
|
9663
|
+
if (0 === groupOptions.length && null === groupStatus) return null;
|
|
9664
|
+
const headingId = `${baseId}-${group.source.id}-heading`;
|
|
9665
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
9666
|
+
className: global_search_module.group,
|
|
9667
|
+
role: "presentation",
|
|
9668
|
+
children: [
|
|
9669
|
+
/*#__PURE__*/ jsxs("div", {
|
|
9670
|
+
className: global_search_module.groupHeading,
|
|
9671
|
+
id: headingId,
|
|
9672
|
+
role: "presentation",
|
|
9673
|
+
children: [
|
|
9674
|
+
/*#__PURE__*/ jsx("span", {
|
|
9675
|
+
children: group.source.label
|
|
9676
|
+
}),
|
|
9677
|
+
groupStatus ? /*#__PURE__*/ jsx("span", {
|
|
9678
|
+
className: global_search_module.groupStatus,
|
|
9679
|
+
children: groupStatus
|
|
9680
|
+
}) : null
|
|
9681
|
+
]
|
|
9682
|
+
}),
|
|
9683
|
+
/*#__PURE__*/ jsx("div", {
|
|
9684
|
+
"aria-labelledby": headingId,
|
|
9685
|
+
role: "group",
|
|
9686
|
+
children: groupOptions.map((option)=>/*#__PURE__*/ jsx(ResultRow, {
|
|
9687
|
+
isActive: option.id === activeRowId,
|
|
9688
|
+
option: option,
|
|
9689
|
+
onChoose: choose,
|
|
9690
|
+
onHover: setActiveId
|
|
9691
|
+
}, option.id))
|
|
9692
|
+
})
|
|
9693
|
+
]
|
|
9694
|
+
}, group.source.id);
|
|
9695
|
+
})
|
|
9696
|
+
]
|
|
9589
9697
|
}),
|
|
9590
9698
|
showEmpty ? /*#__PURE__*/ jsx("div", {
|
|
9591
9699
|
className: global_search_module.empty,
|
|
@@ -9652,6 +9760,59 @@ function SearchPanel({ emptyState, initialQuery, onClose, placeholder, refreshRe
|
|
|
9652
9760
|
]
|
|
9653
9761
|
});
|
|
9654
9762
|
}
|
|
9763
|
+
function RecentRow({ isActive, onChoose, onHover, onRemove, recent, removeLabel }) {
|
|
9764
|
+
const { pressProps } = usePress({
|
|
9765
|
+
onPress: ()=>onChoose(recent),
|
|
9766
|
+
preventFocusOnPress: true
|
|
9767
|
+
});
|
|
9768
|
+
const { pressProps: removePressProps } = usePress({
|
|
9769
|
+
onPress: ()=>onRemove(recent),
|
|
9770
|
+
preventFocusOnPress: true
|
|
9771
|
+
});
|
|
9772
|
+
return /*#__PURE__*/ jsx("div", {
|
|
9773
|
+
...pressProps,
|
|
9774
|
+
"aria-selected": isActive,
|
|
9775
|
+
className: global_search_module.option,
|
|
9776
|
+
"data-active": isActive || void 0,
|
|
9777
|
+
id: recent.id,
|
|
9778
|
+
role: "option",
|
|
9779
|
+
tabIndex: -1,
|
|
9780
|
+
onPointerMove: ()=>{
|
|
9781
|
+
if (!isActive) onHover(recent.id);
|
|
9782
|
+
},
|
|
9783
|
+
children: /*#__PURE__*/ jsxs("span", {
|
|
9784
|
+
className: global_search_module.recent,
|
|
9785
|
+
children: [
|
|
9786
|
+
/*#__PURE__*/ jsx(HistoryIcon, {}),
|
|
9787
|
+
/*#__PURE__*/ jsx("span", {
|
|
9788
|
+
className: global_search_module.recentText,
|
|
9789
|
+
children: recent.text
|
|
9790
|
+
}),
|
|
9791
|
+
/*#__PURE__*/ jsx("button", {
|
|
9792
|
+
...removePressProps,
|
|
9793
|
+
"aria-label": removeLabel,
|
|
9794
|
+
className: global_search_module.removeRecent,
|
|
9795
|
+
tabIndex: -1,
|
|
9796
|
+
title: removeLabel,
|
|
9797
|
+
type: "button",
|
|
9798
|
+
children: /*#__PURE__*/ jsx("svg", {
|
|
9799
|
+
"aria-hidden": "true",
|
|
9800
|
+
fill: "none",
|
|
9801
|
+
height: "10",
|
|
9802
|
+
viewBox: "0 0 12 12",
|
|
9803
|
+
width: "10",
|
|
9804
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
9805
|
+
d: "M2 2L10 10M10 2L2 10",
|
|
9806
|
+
stroke: "currentColor",
|
|
9807
|
+
strokeLinecap: "round",
|
|
9808
|
+
strokeWidth: "1.5"
|
|
9809
|
+
})
|
|
9810
|
+
})
|
|
9811
|
+
})
|
|
9812
|
+
]
|
|
9813
|
+
})
|
|
9814
|
+
});
|
|
9815
|
+
}
|
|
9655
9816
|
function ResultRow({ isActive, onChoose, onHover, option }) {
|
|
9656
9817
|
const { pressProps } = usePress({
|
|
9657
9818
|
onPress: (e)=>onChoose(option, e.metaKey || e.ctrlKey),
|
|
@@ -9757,6 +9918,25 @@ function SearchIcon() {
|
|
|
9757
9918
|
})
|
|
9758
9919
|
});
|
|
9759
9920
|
}
|
|
9921
|
+
function HistoryIcon() {
|
|
9922
|
+
return /*#__PURE__*/ jsx("span", {
|
|
9923
|
+
"aria-hidden": "true",
|
|
9924
|
+
className: global_search_module.recentIcon,
|
|
9925
|
+
children: /*#__PURE__*/ jsx("svg", {
|
|
9926
|
+
fill: "none",
|
|
9927
|
+
height: "14",
|
|
9928
|
+
viewBox: "0 0 14 14",
|
|
9929
|
+
width: "14",
|
|
9930
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
9931
|
+
d: "M2.5 7a4.5 4.5 0 1 0 1.3-3.2M2.5 2v2.5H5M7 4.5V7l1.75 1.25",
|
|
9932
|
+
stroke: "currentColor",
|
|
9933
|
+
strokeLinecap: "round",
|
|
9934
|
+
strokeLinejoin: "round",
|
|
9935
|
+
strokeWidth: "1.3"
|
|
9936
|
+
})
|
|
9937
|
+
})
|
|
9938
|
+
});
|
|
9939
|
+
}
|
|
9760
9940
|
const GlobalSearch = Object.assign(GlobalSearchRoot, {
|
|
9761
9941
|
displayName: "GlobalSearch",
|
|
9762
9942
|
Trigger: GlobalSearchTrigger
|
|
@@ -13470,6 +13650,7 @@ function Ox0Provider({ children, colorScheme, density, locale, messages, navigat
|
|
|
13470
13650
|
value: routerValue,
|
|
13471
13651
|
children: /*#__PURE__*/ jsx("div", {
|
|
13472
13652
|
className: ox0_provider_module.root,
|
|
13653
|
+
"data-ox0-root": "",
|
|
13473
13654
|
"data-theme": neutralTheme,
|
|
13474
13655
|
"data-color-scheme": dataColorScheme,
|
|
13475
13656
|
"data-density": dataDensity,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ox0-provider.d.ts","sourceRoot":"","sources":["../../src/providers/ox0-provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAEnF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAG9C,OAAO,EAAE,KAAK,UAAU,EAAoB,MAAM,oBAAoB,CAAA;AAKtE,OAAO,wBAAwB,CAAA;AAG/B,MAAM,WAAW,gBAAiB,SAAQ,iBAAiB;IACzD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC1C;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAC1B;;;;OAIG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,CAAA;IACjC;;;;;OAKG;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cAAc,CAAC,EAAE,WAAW,CAAA;IACrC;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,CAAA;IAChC;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,WAAW,CAAA;IAC9B;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;CAC3C;AAED,wBAAgB,WAAW,CAAC,EAC1B,QAAQ,EACR,WAAW,EACX,OAAO,EACP,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,cAAc,GACf,EAAE,gBAAgB,+BA6BlB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ox0/ui",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.10.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/esturcke/ox0-platform.git",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"react-aria": "^3.52.1",
|
|
27
27
|
"react-stately": "^3.50.0",
|
|
28
28
|
"@ox0/i18n": "0.4.0",
|
|
29
|
-
"@ox0/
|
|
30
|
-
"@ox0/
|
|
29
|
+
"@ox0/tokens": "0.7.0",
|
|
30
|
+
"@ox0/hooks": "0.3.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"react": "^19.0.0",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"react-intl": "^7.0.0 || ^8.0.0"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
|
-
"build": "rslib build -c ../../rslib.config.ts &&
|
|
38
|
+
"build": "rslib build -c ../../rslib.config.ts && rm -f tsconfig.build.tsbuildinfo && tsc -p tsconfig.build.json",
|
|
39
39
|
"typecheck": "tsc -p tsconfig.json",
|
|
40
40
|
"lint": "oxlint .",
|
|
41
41
|
"test": "vitest run"
|