@ox0/ui 3.9.0 → 3.10.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.
@@ -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":"AAEA,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,M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C,EAAE,SAAS,CAAA;IACzB,gDAAgD;IAChD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,kDAAkD;IAClD,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;IAC7B,4DAA4D;IAC5D,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,CAAA;CAC1B;AAED,mFAAmF;AACnF,wBAAgB,YAAY,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,iBAAiB,GAAG,SAAS,CAqB7F;AAsCD,eAAO,MAAM,YAAY;;;CAGvB,CAAA"}
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",
@@ -9285,7 +9329,7 @@ function useGlobalSearch() {
9285
9329
  if (!ctx) throw new Error("useGlobalSearch must be used inside <GlobalSearch>");
9286
9330
  return ctx;
9287
9331
  }
9288
- function GlobalSearchRoot({ children, defaultOpen = false, emptyState, isOpen: isOpenProp, isShortcutDisabled = false, onOpenChange, placeholder, sources, status }) {
9332
+ function GlobalSearchRoot({ children, defaultOpen = false, emptyState, history, isOpen: isOpenProp, isShortcutDisabled = false, onOpenChange, placeholder, sources, status }) {
9289
9333
  const os = useOS();
9290
9334
  const [isOpen, setIsOpen] = useControllableState({
9291
9335
  defaultValue: defaultOpen,
@@ -9350,6 +9394,7 @@ function GlobalSearchRoot({ children, defaultOpen = false, emptyState, isOpen: i
9350
9394
  }),
9351
9395
  isOpen && anchor ? /*#__PURE__*/ createPortal(/*#__PURE__*/ jsx(SearchPanel, {
9352
9396
  emptyState: emptyState,
9397
+ history: history,
9353
9398
  initialQuery: initialQuery,
9354
9399
  placeholder: placeholder,
9355
9400
  refreshRef: refreshRef,
@@ -9360,7 +9405,7 @@ function GlobalSearchRoot({ children, defaultOpen = false, emptyState, isOpen: i
9360
9405
  ]
9361
9406
  });
9362
9407
  }
9363
- function SearchPanel({ emptyState, initialQuery, onClose, placeholder, refreshRef, sources, status }) {
9408
+ function SearchPanel({ emptyState, history, initialQuery, onClose, placeholder, refreshRef, sources, status }) {
9364
9409
  const baseId = useId();
9365
9410
  const listboxId = `${baseId}-listbox`;
9366
9411
  const router = useRouter();
@@ -9381,6 +9426,8 @@ function SearchPanel({ emptyState, initialQuery, onClose, placeholder, refreshRe
9381
9426
  const navigateHint = useMessage("ox0.globalSearch.navigate", "Navigate");
9382
9427
  const openHint = useMessage("ox0.globalSearch.open", "Open");
9383
9428
  const closeHint = useMessage("ox0.globalSearch.close", "Close");
9429
+ const recentLabel = useMessage("ox0.globalSearch.recent", "Recent");
9430
+ const removeRecentLabel = useMessage("ox0.globalSearch.removeRecent", "Remove from recent searches");
9384
9431
  useEffect(()=>{
9385
9432
  runner.run(sources, query);
9386
9433
  }, [
@@ -9419,7 +9466,17 @@ function SearchPanel({ emptyState, initialQuery, onClose, placeholder, refreshRe
9419
9466
  baseId,
9420
9467
  groups
9421
9468
  ]);
9422
- const active = options.find((option)=>option.id === activeId) ?? options[0];
9469
+ const recents = "" === query.trim() ? (history?.entries ?? []).map((text, index)=>({
9470
+ id: `${baseId}-recent-${index}`,
9471
+ text
9472
+ })) : [];
9473
+ const rowIds = [
9474
+ ...recents.map((recent)=>recent.id),
9475
+ ...options.map((option)=>option.id)
9476
+ ];
9477
+ const activeRowId = null !== activeId && rowIds.includes(activeId) ? activeId : rowIds[0];
9478
+ const activeRecent = recents.find((recent)=>recent.id === activeRowId);
9479
+ const active = options.find((option)=>option.id === activeRowId);
9423
9480
  const isLoading = groups.some((group)=>"loading" === group.status);
9424
9481
  const hasPreviewPane = sources.some((source)=>void 0 !== source.renderPreview);
9425
9482
  const terms = useMemo(()=>query.trim().split(/\s+/).filter(Boolean), [
@@ -9429,15 +9486,16 @@ function SearchPanel({ emptyState, initialQuery, onClose, placeholder, refreshRe
9429
9486
  count: String(options.length)
9430
9487
  });
9431
9488
  useEffect(()=>{
9432
- if (!active) return;
9433
- document.getElementById(active.id)?.scrollIntoView?.({
9489
+ if (void 0 === activeRowId) return;
9490
+ document.getElementById(activeRowId)?.scrollIntoView?.({
9434
9491
  block: "nearest"
9435
9492
  });
9436
9493
  }, [
9437
- active
9494
+ activeRowId
9438
9495
  ]);
9439
9496
  function choose(option, inNewTab) {
9440
9497
  const href = option.source.getHref?.(option.item);
9498
+ history?.add(query);
9441
9499
  onClose();
9442
9500
  if (void 0 !== href && isSafeHref(href)) if (inNewTab) window.open(href, "_blank", "noopener,noreferrer");
9443
9501
  else if (router) router.navigate(href);
@@ -9445,10 +9503,21 @@ function SearchPanel({ emptyState, initialQuery, onClose, placeholder, refreshRe
9445
9503
  option.source.onAction?.(option.item);
9446
9504
  }
9447
9505
  function move(offset) {
9448
- if (0 === options.length || !active) return;
9449
- const index = options.indexOf(active);
9450
- const next = options[(index + offset + options.length) % options.length];
9451
- if (next) setActiveId(next.id);
9506
+ if (0 === rowIds.length || void 0 === activeRowId) return;
9507
+ const index = rowIds.indexOf(activeRowId);
9508
+ const next = rowIds[(index + offset + rowIds.length) % rowIds.length];
9509
+ if (next) setActiveId(next);
9510
+ }
9511
+ function searchAgain(recent) {
9512
+ setQuery(recent.text);
9513
+ setActiveId(null);
9514
+ inputRef.current?.focus();
9515
+ }
9516
+ function removeRecent(recent) {
9517
+ const index = recents.indexOf(recent);
9518
+ history?.remove(recent.text);
9519
+ const kept = index < recents.length - 1 ? index : index - 1;
9520
+ setActiveId(kept >= 0 ? `${baseId}-recent-${kept}` : null);
9452
9521
  }
9453
9522
  function handleInputKeyDown(e) {
9454
9523
  if (e.nativeEvent.isComposing) return;
@@ -9462,10 +9531,20 @@ function SearchPanel({ emptyState, initialQuery, onClose, placeholder, refreshRe
9462
9531
  move(-1);
9463
9532
  break;
9464
9533
  case "Enter":
9534
+ if (activeRecent) {
9535
+ e.preventDefault();
9536
+ searchAgain(activeRecent);
9537
+ return;
9538
+ }
9465
9539
  if (!active) return;
9466
9540
  e.preventDefault();
9467
9541
  choose(active, e.metaKey || e.ctrlKey);
9468
9542
  break;
9543
+ case "Delete":
9544
+ if (!activeRecent || !e.shiftKey) return;
9545
+ e.preventDefault();
9546
+ removeRecent(activeRecent);
9547
+ break;
9469
9548
  case "Escape":
9470
9549
  e.preventDefault();
9471
9550
  if (query) setQuery("");
@@ -9516,10 +9595,10 @@ function SearchPanel({ emptyState, initialQuery, onClose, placeholder, refreshRe
9516
9595
  /*#__PURE__*/ jsx(SearchIcon, {}),
9517
9596
  /*#__PURE__*/ jsx("input", {
9518
9597
  ref: inputRef,
9519
- "aria-activedescendant": active?.id,
9598
+ "aria-activedescendant": activeRowId,
9520
9599
  "aria-autocomplete": "list",
9521
9600
  "aria-controls": listboxId,
9522
- "aria-expanded": options.length > 0,
9601
+ "aria-expanded": rowIds.length > 0,
9523
9602
  "aria-label": label,
9524
9603
  autoComplete: "off",
9525
9604
  className: global_search_module.input,
@@ -9545,47 +9624,75 @@ function SearchPanel({ emptyState, initialQuery, onClose, placeholder, refreshRe
9545
9624
  children: /*#__PURE__*/ jsxs("div", {
9546
9625
  className: global_search_module.resultsPane,
9547
9626
  children: [
9548
- /*#__PURE__*/ jsx("div", {
9627
+ /*#__PURE__*/ jsxs("div", {
9549
9628
  "aria-label": label,
9550
9629
  className: global_search_module.results,
9551
9630
  id: listboxId,
9552
9631
  role: "listbox",
9553
- children: groups.map((group)=>{
9554
- const groupOptions = options.filter((option)=>option.source === group.source);
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", {
9632
+ children: [
9633
+ recents.length > 0 ? /*#__PURE__*/ jsxs("div", {
9559
9634
  className: global_search_module.group,
9560
9635
  role: "presentation",
9561
9636
  children: [
9562
- /*#__PURE__*/ jsxs("div", {
9637
+ /*#__PURE__*/ jsx("div", {
9563
9638
  className: global_search_module.groupHeading,
9564
- id: headingId,
9639
+ id: `${baseId}-recent-heading`,
9565
9640
  role: "presentation",
9566
- children: [
9567
- /*#__PURE__*/ jsx("span", {
9568
- children: group.source.label
9569
- }),
9570
- groupStatus ? /*#__PURE__*/ jsx("span", {
9571
- className: global_search_module.groupStatus,
9572
- children: groupStatus
9573
- }) : null
9574
- ]
9641
+ children: /*#__PURE__*/ jsx("span", {
9642
+ children: recentLabel
9643
+ })
9575
9644
  }),
9576
9645
  /*#__PURE__*/ jsx("div", {
9577
- "aria-labelledby": headingId,
9646
+ "aria-labelledby": `${baseId}-recent-heading`,
9578
9647
  role: "group",
9579
- children: groupOptions.map((option)=>/*#__PURE__*/ jsx(ResultRow, {
9580
- isActive: option === active,
9581
- option: option,
9582
- onChoose: choose,
9583
- onHover: setActiveId
9584
- }, option.id))
9648
+ children: recents.map((recent)=>/*#__PURE__*/ jsx(RecentRow, {
9649
+ isActive: recent.id === activeRowId,
9650
+ recent: recent,
9651
+ removeLabel: removeRecentLabel,
9652
+ onChoose: searchAgain,
9653
+ onHover: setActiveId,
9654
+ onRemove: removeRecent
9655
+ }, recent.id))
9585
9656
  })
9586
9657
  ]
9587
- }, group.source.id);
9588
- })
9658
+ }) : null,
9659
+ groups.map((group)=>{
9660
+ const groupOptions = options.filter((option)=>option.source === group.source);
9661
+ const groupStatus = "error" === group.status ? errorText : "loading" === group.status && 0 === groupOptions.length ? loadingText : null;
9662
+ if (0 === groupOptions.length && null === groupStatus) return null;
9663
+ const headingId = `${baseId}-${group.source.id}-heading`;
9664
+ return /*#__PURE__*/ jsxs("div", {
9665
+ className: global_search_module.group,
9666
+ role: "presentation",
9667
+ children: [
9668
+ /*#__PURE__*/ jsxs("div", {
9669
+ className: global_search_module.groupHeading,
9670
+ id: headingId,
9671
+ role: "presentation",
9672
+ children: [
9673
+ /*#__PURE__*/ jsx("span", {
9674
+ children: group.source.label
9675
+ }),
9676
+ groupStatus ? /*#__PURE__*/ jsx("span", {
9677
+ className: global_search_module.groupStatus,
9678
+ children: groupStatus
9679
+ }) : null
9680
+ ]
9681
+ }),
9682
+ /*#__PURE__*/ jsx("div", {
9683
+ "aria-labelledby": headingId,
9684
+ role: "group",
9685
+ children: groupOptions.map((option)=>/*#__PURE__*/ jsx(ResultRow, {
9686
+ isActive: option.id === activeRowId,
9687
+ option: option,
9688
+ onChoose: choose,
9689
+ onHover: setActiveId
9690
+ }, option.id))
9691
+ })
9692
+ ]
9693
+ }, group.source.id);
9694
+ })
9695
+ ]
9589
9696
  }),
9590
9697
  showEmpty ? /*#__PURE__*/ jsx("div", {
9591
9698
  className: global_search_module.empty,
@@ -9652,6 +9759,59 @@ function SearchPanel({ emptyState, initialQuery, onClose, placeholder, refreshRe
9652
9759
  ]
9653
9760
  });
9654
9761
  }
9762
+ function RecentRow({ isActive, onChoose, onHover, onRemove, recent, removeLabel }) {
9763
+ const { pressProps } = usePress({
9764
+ onPress: ()=>onChoose(recent),
9765
+ preventFocusOnPress: true
9766
+ });
9767
+ const { pressProps: removePressProps } = usePress({
9768
+ onPress: ()=>onRemove(recent),
9769
+ preventFocusOnPress: true
9770
+ });
9771
+ return /*#__PURE__*/ jsx("div", {
9772
+ ...pressProps,
9773
+ "aria-selected": isActive,
9774
+ className: global_search_module.option,
9775
+ "data-active": isActive || void 0,
9776
+ id: recent.id,
9777
+ role: "option",
9778
+ tabIndex: -1,
9779
+ onPointerMove: ()=>{
9780
+ if (!isActive) onHover(recent.id);
9781
+ },
9782
+ children: /*#__PURE__*/ jsxs("span", {
9783
+ className: global_search_module.recent,
9784
+ children: [
9785
+ /*#__PURE__*/ jsx(HistoryIcon, {}),
9786
+ /*#__PURE__*/ jsx("span", {
9787
+ className: global_search_module.recentText,
9788
+ children: recent.text
9789
+ }),
9790
+ /*#__PURE__*/ jsx("button", {
9791
+ ...removePressProps,
9792
+ "aria-label": removeLabel,
9793
+ className: global_search_module.removeRecent,
9794
+ tabIndex: -1,
9795
+ title: removeLabel,
9796
+ type: "button",
9797
+ children: /*#__PURE__*/ jsx("svg", {
9798
+ "aria-hidden": "true",
9799
+ fill: "none",
9800
+ height: "10",
9801
+ viewBox: "0 0 12 12",
9802
+ width: "10",
9803
+ children: /*#__PURE__*/ jsx("path", {
9804
+ d: "M2 2L10 10M10 2L2 10",
9805
+ stroke: "currentColor",
9806
+ strokeLinecap: "round",
9807
+ strokeWidth: "1.5"
9808
+ })
9809
+ })
9810
+ })
9811
+ ]
9812
+ })
9813
+ });
9814
+ }
9655
9815
  function ResultRow({ isActive, onChoose, onHover, option }) {
9656
9816
  const { pressProps } = usePress({
9657
9817
  onPress: (e)=>onChoose(option, e.metaKey || e.ctrlKey),
@@ -9757,6 +9917,25 @@ function SearchIcon() {
9757
9917
  })
9758
9918
  });
9759
9919
  }
9920
+ function HistoryIcon() {
9921
+ return /*#__PURE__*/ jsx("span", {
9922
+ "aria-hidden": "true",
9923
+ className: global_search_module.recentIcon,
9924
+ children: /*#__PURE__*/ jsx("svg", {
9925
+ fill: "none",
9926
+ height: "14",
9927
+ viewBox: "0 0 14 14",
9928
+ width: "14",
9929
+ children: /*#__PURE__*/ jsx("path", {
9930
+ d: "M2.5 7a4.5 4.5 0 1 0 1.3-3.2M2.5 2v2.5H5M7 4.5V7l1.75 1.25",
9931
+ stroke: "currentColor",
9932
+ strokeLinecap: "round",
9933
+ strokeLinejoin: "round",
9934
+ strokeWidth: "1.3"
9935
+ })
9936
+ })
9937
+ });
9938
+ }
9760
9939
  const GlobalSearch = Object.assign(GlobalSearchRoot, {
9761
9940
  displayName: "GlobalSearch",
9762
9941
  Trigger: GlobalSearchTrigger
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ox0/ui",
3
- "version": "3.9.0",
3
+ "version": "3.10.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/esturcke/ox0-platform.git",
@@ -25,8 +25,8 @@
25
25
  "@internationalized/date": "^3.12.4",
26
26
  "react-aria": "^3.52.1",
27
27
  "react-stately": "^3.50.0",
28
+ "@ox0/hooks": "0.3.0",
28
29
  "@ox0/i18n": "0.4.0",
29
- "@ox0/hooks": "0.2.2",
30
30
  "@ox0/tokens": "0.7.0"
31
31
  },
32
32
  "peerDependencies": {
@@ -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 && tsc --build --force tsconfig.build.json",
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"