@krak-stack/registry 0.10.14 → 0.10.16

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.
@@ -5,9 +5,13 @@ declare function DialogTrigger({ ...props }: DialogPrimitive.Trigger.Props): Rea
5
5
  declare function DialogPortal({ ...props }: DialogPrimitive.Portal.Props): React.JSX.Element;
6
6
  declare function DialogClose({ ...props }: DialogPrimitive.Close.Props): React.JSX.Element;
7
7
  declare function DialogOverlay({ className, ...props }: DialogPrimitive.Backdrop.Props): React.JSX.Element;
8
- declare function DialogContent({ className, children, ...props }: DialogPrimitive.Popup.Props): React.JSX.Element;
8
+ declare function DialogContent({ className, children, showCloseButton, ...props }: DialogPrimitive.Popup.Props & {
9
+ showCloseButton?: boolean;
10
+ }): React.JSX.Element;
9
11
  declare function DialogHeader({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
10
- declare function DialogFooter({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
11
- declare function DialogTitle({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Title>): React.JSX.Element;
12
- declare function DialogDescription({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Description>): React.JSX.Element;
12
+ declare function DialogFooter({ className, showCloseButton, children, ...props }: React.ComponentProps<"div"> & {
13
+ showCloseButton?: boolean;
14
+ }): React.JSX.Element;
15
+ declare function DialogTitle({ className, ...props }: DialogPrimitive.Title.Props): React.JSX.Element;
16
+ declare function DialogDescription({ className, ...props }: DialogPrimitive.Description.Props): React.JSX.Element;
13
17
  export { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, };
@@ -36,6 +36,9 @@ export type FieldOptions = {
36
36
  label: JSX.Element | string;
37
37
  description?: string;
38
38
  children?: ReactNode;
39
+ locale?: string;
40
+ /** Adds a localized marker to the label. The field schema still controls validation. */
41
+ optional?: boolean;
39
42
  };
40
43
  export type FieldWrapperOptions = {
41
44
  children: ReactNode;
@@ -161,6 +164,7 @@ export declare const RevertButton: ({ field, props, }: {
161
164
  type ImageFieldOptions = {
162
165
  label: string;
163
166
  locale?: string;
167
+ optional?: boolean;
164
168
  messages?: EffectFormMessageTranslations;
165
169
  filePickerMessages?: FilePickerMessageTranslations;
166
170
  size: {
@@ -1373,6 +1373,27 @@ var getCauseErrorMessage = (cause, labels) => {
1373
1373
  return error.message.trim() || labels.submitFailed;
1374
1374
  return Option.getOrElse(Schema2.decodeUnknownOption(Schema2.String)(error), () => "").trim() || labels.submitFailed;
1375
1375
  };
1376
+ var FieldLabel2 = ({
1377
+ htmlFor,
1378
+ options
1379
+ }) => {
1380
+ const locale = useKrakstackLocale3(options.locale);
1381
+ return /* @__PURE__ */ jsxs6(FieldLabel, {
1382
+ htmlFor,
1383
+ children: [
1384
+ options.label,
1385
+ options.optional && /* @__PURE__ */ jsxs6("span", {
1386
+ className: "text-muted-foreground font-normal",
1387
+ children: [
1388
+ " ",
1389
+ "(",
1390
+ locale.startsWith("fr") ? "facultatif" : "optional",
1391
+ ")"
1392
+ ]
1393
+ })
1394
+ ]
1395
+ });
1396
+ };
1376
1397
  var FieldWrapper = ({
1377
1398
  children,
1378
1399
  description,
@@ -1463,16 +1484,24 @@ var TextField = ({
1463
1484
  field,
1464
1485
  props
1465
1486
  }) => {
1466
- const { children, description, errorMessage, label, ...inputProps } = props;
1487
+ const {
1488
+ children,
1489
+ description,
1490
+ errorMessage,
1491
+ label,
1492
+ locale,
1493
+ optional,
1494
+ ...inputProps
1495
+ } = props;
1467
1496
  return /* @__PURE__ */ jsxs6(Field, {
1468
1497
  "data-invalid": Option.isSome(field.error),
1469
1498
  children: [
1470
1499
  /* @__PURE__ */ jsxs6("div", {
1471
1500
  className: "flex w-full items-center gap-2",
1472
1501
  children: [
1473
- /* @__PURE__ */ jsx13(FieldLabel, {
1502
+ /* @__PURE__ */ jsx13(FieldLabel2, {
1474
1503
  htmlFor: field.path,
1475
- children: label
1504
+ options: { label, locale, optional }
1476
1505
  }),
1477
1506
  children
1478
1507
  ]
@@ -1506,30 +1535,37 @@ var NameField = ({
1506
1535
  field,
1507
1536
  props: {
1508
1537
  ...fieldProps,
1538
+ locale,
1509
1539
  label: labels.name,
1510
1540
  errorMessage: props.errorMessage ?? labels.nameRequired
1511
1541
  }
1512
1542
  });
1513
1543
  };
1514
1544
  var TextAreaField = ({ field, props }) => {
1515
- const { children, description, label, ...textareaProps } = props;
1516
- const nativeTextareaProps = { ...textareaProps };
1517
- delete nativeTextareaProps.original;
1545
+ const {
1546
+ children,
1547
+ description,
1548
+ label,
1549
+ locale,
1550
+ optional,
1551
+ original: _original,
1552
+ ...textareaProps
1553
+ } = props;
1518
1554
  return /* @__PURE__ */ jsxs6(Field, {
1519
1555
  "data-invalid": Option.isSome(field.error),
1520
1556
  children: [
1521
1557
  /* @__PURE__ */ jsxs6("div", {
1522
1558
  className: "flex w-full items-center gap-2",
1523
1559
  children: [
1524
- /* @__PURE__ */ jsx13(FieldLabel, {
1560
+ /* @__PURE__ */ jsx13(FieldLabel2, {
1525
1561
  htmlFor: field.path,
1526
- children: label
1562
+ options: { label, locale, optional }
1527
1563
  }),
1528
1564
  children
1529
1565
  ]
1530
1566
  }),
1531
1567
  /* @__PURE__ */ jsx13(Textarea, {
1532
- ...nativeTextareaProps,
1568
+ ...textareaProps,
1533
1569
  id: field.path,
1534
1570
  name: field.path,
1535
1571
  value: field.value,
@@ -1553,6 +1589,7 @@ var DescriptionField = ({ field, props }) => {
1553
1589
  field,
1554
1590
  props: {
1555
1591
  ...fieldProps,
1592
+ locale,
1556
1593
  label: labels.description
1557
1594
  }
1558
1595
  });
@@ -1562,9 +1599,9 @@ var FileField = ({ field, props }) => {
1562
1599
  return /* @__PURE__ */ jsxs6(Field, {
1563
1600
  "data-invalid": invalid,
1564
1601
  children: [
1565
- /* @__PURE__ */ jsx13(FieldLabel, {
1602
+ /* @__PURE__ */ jsx13(FieldLabel2, {
1566
1603
  htmlFor: field.path,
1567
- children: props.label
1604
+ options: props
1568
1605
  }),
1569
1606
  /* @__PURE__ */ jsx13(FilePicker, {
1570
1607
  accept: props.accept ?? "",
@@ -1597,24 +1634,30 @@ var FileField = ({ field, props }) => {
1597
1634
  });
1598
1635
  };
1599
1636
  var NullableTextAreaField = ({ field, props }) => {
1600
- const { children, description, label, ...textareaProps } = props;
1601
- const nativeTextareaProps = { ...textareaProps };
1602
- delete nativeTextareaProps.original;
1637
+ const {
1638
+ children,
1639
+ description,
1640
+ label,
1641
+ locale,
1642
+ optional,
1643
+ original: _original,
1644
+ ...textareaProps
1645
+ } = props;
1603
1646
  return /* @__PURE__ */ jsxs6(Field, {
1604
1647
  "data-invalid": Option.isSome(field.error),
1605
1648
  children: [
1606
1649
  /* @__PURE__ */ jsxs6("div", {
1607
1650
  className: "flex w-full items-center gap-2",
1608
1651
  children: [
1609
- /* @__PURE__ */ jsx13(FieldLabel, {
1652
+ /* @__PURE__ */ jsx13(FieldLabel2, {
1610
1653
  htmlFor: field.path,
1611
- children: label
1654
+ options: { label, locale, optional }
1612
1655
  }),
1613
1656
  children
1614
1657
  ]
1615
1658
  }),
1616
1659
  /* @__PURE__ */ jsx13(Textarea, {
1617
- ...nativeTextareaProps,
1660
+ ...textareaProps,
1618
1661
  id: field.path,
1619
1662
  name: field.path,
1620
1663
  value: field.value ?? "",
@@ -1648,9 +1691,9 @@ var CheckboxField = ({
1648
1691
  onCheckedChange: field.onChange,
1649
1692
  "aria-invalid": Option.isSome(field.error)
1650
1693
  }),
1651
- /* @__PURE__ */ jsx13(FieldLabel, {
1694
+ /* @__PURE__ */ jsx13(FieldLabel2, {
1652
1695
  htmlFor: field.path,
1653
- children: props.label
1696
+ options: props
1654
1697
  }),
1655
1698
  props.children
1656
1699
  ]
@@ -1669,9 +1712,9 @@ var SelectField = ({
1669
1712
  }) => /* @__PURE__ */ jsxs6(Field, {
1670
1713
  "data-invalid": Option.isSome(field.error),
1671
1714
  children: [
1672
- /* @__PURE__ */ jsx13(FieldLabel, {
1715
+ /* @__PURE__ */ jsx13(FieldLabel2, {
1673
1716
  htmlFor: field.path,
1674
- children: props.label
1717
+ options: props
1675
1718
  }),
1676
1719
  /* @__PURE__ */ jsxs6(Select, {
1677
1720
  items: props.options,
@@ -1723,9 +1766,9 @@ var MultiSelectField = ({
1723
1766
  }) => /* @__PURE__ */ jsxs6(Field, {
1724
1767
  "data-invalid": Option.isSome(field.error),
1725
1768
  children: [
1726
- /* @__PURE__ */ jsx13(FieldLabel, {
1769
+ /* @__PURE__ */ jsx13(FieldLabel2, {
1727
1770
  htmlFor: field.path,
1728
- children: props.label
1771
+ options: props
1729
1772
  }),
1730
1773
  /* @__PURE__ */ jsxs6(Select, {
1731
1774
  items: props.options,
@@ -1765,9 +1808,9 @@ var NullableMultiSelectField = ({
1765
1808
  }) => /* @__PURE__ */ jsxs6(Field, {
1766
1809
  "data-invalid": Option.isSome(field.error),
1767
1810
  children: [
1768
- /* @__PURE__ */ jsx13(FieldLabel, {
1811
+ /* @__PURE__ */ jsx13(FieldLabel2, {
1769
1812
  htmlFor: field.path,
1770
- children: props.label
1813
+ options: props
1771
1814
  }),
1772
1815
  /* @__PURE__ */ jsxs6(Select, {
1773
1816
  items: props.options,
@@ -1826,9 +1869,9 @@ var SearchableSelectField = ({
1826
1869
  className: "min-w-0",
1827
1870
  "data-invalid": invalid,
1828
1871
  children: [
1829
- /* @__PURE__ */ jsx13(FieldLabel, {
1872
+ /* @__PURE__ */ jsx13(FieldLabel2, {
1830
1873
  htmlFor: field.path,
1831
- children: props.label
1874
+ options: props
1832
1875
  }),
1833
1876
  /* @__PURE__ */ jsx13(VirtualizedCombobox, {
1834
1877
  contentClassName: props.contentClassName,
@@ -1869,9 +1912,9 @@ var SingleSearchableSelectField = ({
1869
1912
  className: "min-w-0",
1870
1913
  "data-invalid": invalid,
1871
1914
  children: [
1872
- /* @__PURE__ */ jsx13(FieldLabel, {
1915
+ /* @__PURE__ */ jsx13(FieldLabel2, {
1873
1916
  htmlFor: field.path,
1874
- children: props.label
1917
+ options: props
1875
1918
  }),
1876
1919
  /* @__PURE__ */ jsx13(VirtualizedCombobox, {
1877
1920
  contentClassName: props.contentClassName,
@@ -1908,8 +1951,8 @@ var NullableKeyValueField = ({
1908
1951
  return /* @__PURE__ */ jsxs6(Field, {
1909
1952
  "data-invalid": Option.isSome(field.error),
1910
1953
  children: [
1911
- /* @__PURE__ */ jsx13(FieldLabel, {
1912
- children: props.label
1954
+ /* @__PURE__ */ jsx13(FieldLabel2, {
1955
+ options: props
1913
1956
  }),
1914
1957
  entries.map(([key, value], index) => /* @__PURE__ */ jsxs6("div", {
1915
1958
  className: "flex w-full flex-row items-center gap-2",
@@ -1980,8 +2023,8 @@ var KeyValueField = ({
1980
2023
  return /* @__PURE__ */ jsxs6(Field, {
1981
2024
  "data-invalid": Option.isSome(field.error),
1982
2025
  children: [
1983
- /* @__PURE__ */ jsx13(FieldLabel, {
1984
- children: props.label
2026
+ /* @__PURE__ */ jsx13(FieldLabel2, {
2027
+ options: props
1985
2028
  }),
1986
2029
  entries.map(([key, value], index) => /* @__PURE__ */ jsxs6("div", {
1987
2030
  className: "flex w-full flex-row items-center gap-2",
@@ -2065,9 +2108,9 @@ var ImageField = ({ field, props }) => {
2065
2108
  return /* @__PURE__ */ jsxs6(Field, {
2066
2109
  "data-invalid": invalid,
2067
2110
  children: [
2068
- /* @__PURE__ */ jsx13(FieldLabel, {
2111
+ /* @__PURE__ */ jsx13(FieldLabel2, {
2069
2112
  htmlFor: field.path,
2070
- children: props.label
2113
+ options: props
2071
2114
  }),
2072
2115
  /* @__PURE__ */ jsx13(FilePicker, {
2073
2116
  accept: "image/*",
@@ -1,4 +1,5 @@
1
1
  import { type ErrorComponentProps as RouterErrorComponentProps } from "@tanstack/react-router";
2
+ import { type ReactNode } from "react";
2
3
  export type ErrorComponentMessages = {
3
4
  title: string;
4
5
  description: string;
@@ -23,10 +24,11 @@ export type ErrorComponentProps = RouterErrorComponentProps & {
23
24
  messages?: ErrorComponentMessageTranslations;
24
25
  retryable?: boolean;
25
26
  className?: string;
27
+ renderFeedback?: (errorDetails: string) => ReactNode;
26
28
  diagnostics?: {
27
29
  app?: string;
28
30
  version?: string;
29
31
  reference?: string;
30
32
  };
31
33
  };
32
- export declare const ErrorComponent: ({ error, locale: localeOverride, messages, retryable, className, diagnostics, }: ErrorComponentProps) => import("react").JSX.Element;
34
+ export declare const ErrorComponent: ({ error, locale: localeOverride, messages, retryable, className, diagnostics, renderFeedback, }: ErrorComponentProps) => import("react").JSX.Element;
@@ -278,7 +278,8 @@ var ErrorComponent = ({
278
278
  messages,
279
279
  retryable = true,
280
280
  className,
281
- diagnostics
281
+ diagnostics,
282
+ renderFeedback
282
283
  }) => {
283
284
  const locale = useKrakstackLocale2(localeOverride);
284
285
  const pathname = useRouterState({
@@ -346,7 +347,8 @@ var ErrorComponent = ({
346
347
  to: "/",
347
348
  className: cn(buttonVariants({ variant: "outline" })),
348
349
  children: labels.home
349
- })
350
+ }),
351
+ renderFeedback?.(report)
350
352
  ]
351
353
  }),
352
354
  /* @__PURE__ */ jsx5(CopyButton, {
@@ -53,6 +53,7 @@ function Button({
53
53
 
54
54
  // ../../src/components/ui/dialog.tsx
55
55
  import { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
56
+ import { cn as cn2 } from "cn";
56
57
  import { XIcon } from "lucide-react";
57
58
  import { jsx as jsx2, jsxs } from "react/jsx-runtime";
58
59
  function Dialog({ ...props }) {
@@ -73,31 +74,42 @@ function DialogOverlay({
73
74
  }) {
74
75
  return /* @__PURE__ */ jsx2(DialogPrimitive.Backdrop, {
75
76
  "data-slot": "dialog-overlay",
76
- className: cn("fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0", className),
77
+ className: cn2("data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0 fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs", className),
77
78
  ...props
78
79
  });
79
80
  }
80
81
  function DialogHeader({ className, ...props }) {
81
82
  return /* @__PURE__ */ jsx2("div", {
82
83
  "data-slot": "dialog-header",
83
- className: cn("grid gap-1.5", className),
84
+ className: cn2("flex flex-col gap-2", className),
84
85
  ...props
85
86
  });
86
87
  }
87
- function DialogFooter({ className, ...props }) {
88
- return /* @__PURE__ */ jsx2("div", {
89
- "data-slot": "dialog-footer",
90
- className: cn("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", className),
91
- ...props
92
- });
93
- }
94
- function DialogTitle({
88
+ function DialogFooter({
95
89
  className,
90
+ showCloseButton = false,
91
+ children,
96
92
  ...props
97
93
  }) {
94
+ return /* @__PURE__ */ jsxs("div", {
95
+ "data-slot": "dialog-footer",
96
+ className: cn2("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", className),
97
+ ...props,
98
+ children: [
99
+ children,
100
+ showCloseButton && /* @__PURE__ */ jsx2(DialogPrimitive.Close, {
101
+ render: /* @__PURE__ */ jsx2(Button, {
102
+ variant: "outline"
103
+ }),
104
+ children: "Close"
105
+ })
106
+ ]
107
+ });
108
+ }
109
+ function DialogTitle({ className, ...props }) {
98
110
  return /* @__PURE__ */ jsx2(DialogPrimitive.Title, {
99
111
  "data-slot": "dialog-title",
100
- className: cn("text-lg font-medium", className),
112
+ className: cn2("leading-none font-medium", className),
101
113
  ...props
102
114
  });
103
115
  }
@@ -1,5 +1,5 @@
1
1
  import type { ReactNode } from "react";
2
- export type SearchMenuMessages = Partial<Record<"title" | "description" | "placeholder" | "inputPlaceholder" | "emptyMessage", string>>;
2
+ export type SearchMenuMessages = Partial<Record<"title" | "description" | "placeholder" | "inputPlaceholder" | "emptyMessage" | "clearSearch", string>>;
3
3
  export type SearchMenuMessageTranslations = Partial<Record<string, SearchMenuMessages>>;
4
4
  export type SearchMenuItem = {
5
5
  id: string;
@@ -1,6 +1,6 @@
1
1
  // ../../src/components/ui/search-menu.tsx
2
- import { SearchIcon as SearchIcon2 } from "lucide-react";
3
- import { useCallback, useEffect, useState } from "react";
2
+ import { SearchIcon as SearchIcon2, XIcon as XIcon2 } from "lucide-react";
3
+ import { useCallback, useEffect, useRef, useState } from "react";
4
4
 
5
5
  // ../../src/components/ui/button.tsx
6
6
  import { Button as ButtonPrimitive } from "@base-ui/react/button";
@@ -56,6 +56,7 @@ import { SearchIcon } from "lucide-react";
56
56
 
57
57
  // ../../src/components/ui/dialog.tsx
58
58
  import { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
59
+ import { cn as cn2 } from "cn";
59
60
  import { XIcon } from "lucide-react";
60
61
  import { jsx as jsx2, jsxs } from "react/jsx-runtime";
61
62
  function Dialog({ ...props }) {
@@ -76,13 +77,14 @@ function DialogOverlay({
76
77
  }) {
77
78
  return /* @__PURE__ */ jsx2(DialogPrimitive.Backdrop, {
78
79
  "data-slot": "dialog-overlay",
79
- className: cn("fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0", className),
80
+ className: cn2("data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0 fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs", className),
80
81
  ...props
81
82
  });
82
83
  }
83
84
  function DialogContent({
84
85
  className,
85
86
  children,
87
+ showCloseButton = true,
86
88
  ...props
87
89
  }) {
88
90
  return /* @__PURE__ */ jsxs(DialogPortal, {
@@ -90,16 +92,19 @@ function DialogContent({
90
92
  /* @__PURE__ */ jsx2(DialogOverlay, {}),
91
93
  /* @__PURE__ */ jsxs(DialogPrimitive.Popup, {
92
94
  "data-slot": "dialog-content",
93
- className: cn("fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-6 text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-lg data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className),
95
+ className: cn2("bg-popover text-popover-foreground ring-foreground/10 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-6 rounded-xl p-6 text-sm ring-1 duration-100 outline-none sm:max-w-md", className),
94
96
  ...props,
95
97
  children: [
96
98
  children,
97
- /* @__PURE__ */ jsxs(DialogPrimitive.Close, {
98
- className: "focus-visible:ring-ring absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus-visible:ring-2 focus-visible:outline-none disabled:pointer-events-none",
99
+ showCloseButton && /* @__PURE__ */ jsxs(DialogPrimitive.Close, {
100
+ "data-slot": "dialog-close",
101
+ render: /* @__PURE__ */ jsx2(Button, {
102
+ variant: "ghost",
103
+ className: "absolute top-4 right-4",
104
+ size: "icon-sm"
105
+ }),
99
106
  children: [
100
- /* @__PURE__ */ jsx2(XIcon, {
101
- className: "size-4"
102
- }),
107
+ /* @__PURE__ */ jsx2(XIcon, {}),
103
108
  /* @__PURE__ */ jsx2("span", {
104
109
  className: "sr-only",
105
110
  children: "Close"
@@ -114,17 +119,14 @@ function DialogContent({
114
119
  function DialogHeader({ className, ...props }) {
115
120
  return /* @__PURE__ */ jsx2("div", {
116
121
  "data-slot": "dialog-header",
117
- className: cn("grid gap-1.5", className),
122
+ className: cn2("flex flex-col gap-2", className),
118
123
  ...props
119
124
  });
120
125
  }
121
- function DialogTitle({
122
- className,
123
- ...props
124
- }) {
126
+ function DialogTitle({ className, ...props }) {
125
127
  return /* @__PURE__ */ jsx2(DialogPrimitive.Title, {
126
128
  "data-slot": "dialog-title",
127
- className: cn("text-lg font-medium", className),
129
+ className: cn2("leading-none font-medium", className),
128
130
  ...props
129
131
  });
130
132
  }
@@ -134,7 +136,7 @@ function DialogDescription({
134
136
  }) {
135
137
  return /* @__PURE__ */ jsx2(DialogPrimitive.Description, {
136
138
  "data-slot": "dialog-description",
137
- className: cn("text-sm text-muted-foreground", className),
139
+ className: cn2("text-muted-foreground *:[a]:hover:text-foreground text-sm *:[a]:underline *:[a]:underline-offset-3", className),
138
140
  ...props
139
141
  });
140
142
  }
@@ -261,14 +263,16 @@ var messages = {
261
263
  description: "Search for an item to open.",
262
264
  placeholder: "Search...",
263
265
  inputPlaceholder: "Search...",
264
- emptyMessage: "No results found."
266
+ emptyMessage: "No results found.",
267
+ clearSearch: "Clear search"
265
268
  },
266
269
  fr: {
267
270
  title: "Recherche",
268
271
  description: "Recherchez un élément à ouvrir.",
269
272
  placeholder: "Rechercher...",
270
273
  inputPlaceholder: "Rechercher...",
271
- emptyMessage: "Aucun résultat trouvé."
274
+ emptyMessage: "Aucun résultat trouvé.",
275
+ clearSearch: "Effacer la recherche"
272
276
  }
273
277
  };
274
278
  var searchMenuMessages = (locale, translations) => ({
@@ -302,8 +306,36 @@ function SearchMenu({
302
306
  const resolvedInputPlaceholder = inputPlaceholder ?? labels.inputPlaceholder;
303
307
  const resolvedEmptyMessage = emptyMessage ?? labels.emptyMessage;
304
308
  const [uncontrolledOpen, setUncontrolledOpen] = useState(false);
309
+ const [uncontrolledQuery, setUncontrolledQuery] = useState("");
305
310
  const isControlled = open !== undefined;
306
311
  const isOpen = open ?? uncontrolledOpen;
312
+ const searchQuery = query ?? uncontrolledQuery;
313
+ const externalGroups = shouldFilter === false ? groups : undefined;
314
+ const [selection, setSelection] = useState();
315
+ const externalItems = externalGroups?.flatMap(({ items }) => items.filter(({ disabled }) => !disabled));
316
+ const selectedValue = selection?.groups === externalGroups && selection?.query === searchQuery && externalItems?.some(({ label }) => label.trim() === selection?.value) ? selection.value : externalItems?.[0]?.label.trim() ?? "";
317
+ const inputRef = useRef(null);
318
+ const listRef = useRef(null);
319
+ const setQuery = (value) => {
320
+ if (query === undefined)
321
+ setUncontrolledQuery(value);
322
+ onQueryChange?.(value);
323
+ };
324
+ useEffect(() => {
325
+ if (!isOpen) {
326
+ setUncontrolledQuery("");
327
+ setSelection(undefined);
328
+ }
329
+ }, [isOpen]);
330
+ useEffect(() => {
331
+ const list = listRef.current;
332
+ if (!isOpen || !list)
333
+ return;
334
+ const frame = requestAnimationFrame(() => {
335
+ list.scrollTop = 0;
336
+ });
337
+ return () => cancelAnimationFrame(frame);
338
+ }, [isOpen, searchQuery, externalGroups]);
307
339
  const setOpen = useCallback((value) => {
308
340
  if (!isControlled)
309
341
  setUncontrolledOpen(value);
@@ -349,15 +381,47 @@ function SearchMenu({
349
381
  onOpenChange: setOpen,
350
382
  title: resolvedTitle,
351
383
  description: resolvedDescription,
384
+ className: "[&>[data-slot=dialog-close]]:hidden",
352
385
  children: /* @__PURE__ */ jsxs3(Command, {
353
386
  ...shouldFilter === undefined ? {} : { shouldFilter },
387
+ ...externalGroups && {
388
+ value: selectedValue,
389
+ onValueChange: (value) => setSelection({
390
+ groups: externalGroups,
391
+ query: searchQuery,
392
+ value
393
+ })
394
+ },
354
395
  children: [
355
- /* @__PURE__ */ jsx4(CommandInput, {
356
- placeholder: resolvedInputPlaceholder,
357
- ...query === undefined ? {} : { value: query },
358
- ...onQueryChange ? { onValueChange: onQueryChange } : {}
396
+ /* @__PURE__ */ jsxs3("div", {
397
+ className: cn("relative", searchQuery && "[&_[data-slot=command-input-wrapper]>div]:pr-10"),
398
+ children: [
399
+ /* @__PURE__ */ jsx4(CommandInput, {
400
+ ref: inputRef,
401
+ placeholder: resolvedInputPlaceholder,
402
+ value: searchQuery,
403
+ onValueChange: setQuery
404
+ }),
405
+ searchQuery && /* @__PURE__ */ jsx4(Button, {
406
+ type: "button",
407
+ variant: "ghost",
408
+ size: "icon-sm",
409
+ "aria-label": labels.clearSearch,
410
+ className: "absolute top-1.5 right-2",
411
+ onKeyDown: (event) => {
412
+ if (event.key === "Enter")
413
+ event.stopPropagation();
414
+ },
415
+ onClick: () => {
416
+ setQuery("");
417
+ inputRef.current?.focus();
418
+ },
419
+ children: /* @__PURE__ */ jsx4(XIcon2, {})
420
+ })
421
+ ]
359
422
  }),
360
423
  /* @__PURE__ */ jsxs3(CommandList, {
424
+ ref: listRef,
361
425
  children: [
362
426
  /* @__PURE__ */ jsx4(CommandEmpty, {
363
427
  children: resolvedEmptyMessage
@@ -102,8 +102,8 @@ var themeCss = `${createThemeCss({
102
102
  import { Collapsible as CollapsiblePrimitive } from "@base-ui/react/collapsible";
103
103
 
104
104
  // ../../src/components/ui/search-menu.tsx
105
- import { SearchIcon as SearchIcon2 } from "lucide-react";
106
- import { useCallback, useEffect as useEffect2, useState as useState2 } from "react";
105
+ import { SearchIcon as SearchIcon2, XIcon as XIcon2 } from "lucide-react";
106
+ import { useCallback, useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
107
107
 
108
108
  // ../../src/components/ui/command.tsx
109
109
  import { Command as CommandPrimitive } from "cmdk";
@@ -111,6 +111,7 @@ import { SearchIcon } from "lucide-react";
111
111
 
112
112
  // ../../src/components/ui/dialog.tsx
113
113
  import { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
114
+ import { cn as cn2 } from "cn";
114
115
  import { XIcon } from "lucide-react";
115
116
 
116
117
  // ../../src/components/ui/search-menu.tsx
@@ -139,7 +140,7 @@ import { Separator as SeparatorPrimitive } from "@base-ui/react/separator";
139
140
 
140
141
  // ../../src/components/ui/sheet.tsx
141
142
  import { Dialog as SheetPrimitive } from "@base-ui/react/dialog";
142
- import { XIcon as XIcon2 } from "lucide-react";
143
+ import { XIcon as XIcon3 } from "lucide-react";
143
144
  "use client";
144
145
 
145
146
  // ../../src/components/ui/tooltip.tsx