@krak-stack/registry 0.10.15 → 0.10.17
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/CHANGELOG.md +14 -0
- package/dist/components/support-dialog.d.ts +1 -49
- package/dist/components/support-dialog.js +440 -252
- package/dist/components/support.d.ts +66 -0
- package/dist/components/support.js +881 -0
- package/dist/components/ui/effect-form.d.ts +4 -0
- package/dist/components/ui/effect-form.js +78 -35
- package/dist/components/ui/error-component.d.ts +3 -1
- package/dist/components/ui/error-component.js +4 -2
- package/dist/components/ui/search-menu.d.ts +1 -1
- package/dist/components/ui/search-menu.js +70 -8
- package/dist/lib/docs.integrations.server.js +3 -3
- package/dist/lib/docs.js +72 -10
- package/dist/lib/docs.server.js +3 -3
- package/dist/lib/documentation-toolkit.js +3 -3
- package/package.json +5 -1
|
@@ -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 {
|
|
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(
|
|
1502
|
+
/* @__PURE__ */ jsx13(FieldLabel2, {
|
|
1474
1503
|
htmlFor: field.path,
|
|
1475
|
-
|
|
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 {
|
|
1516
|
-
|
|
1517
|
-
|
|
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(
|
|
1560
|
+
/* @__PURE__ */ jsx13(FieldLabel2, {
|
|
1525
1561
|
htmlFor: field.path,
|
|
1526
|
-
|
|
1562
|
+
options: { label, locale, optional }
|
|
1527
1563
|
}),
|
|
1528
1564
|
children
|
|
1529
1565
|
]
|
|
1530
1566
|
}),
|
|
1531
1567
|
/* @__PURE__ */ jsx13(Textarea, {
|
|
1532
|
-
...
|
|
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(
|
|
1602
|
+
/* @__PURE__ */ jsx13(FieldLabel2, {
|
|
1566
1603
|
htmlFor: field.path,
|
|
1567
|
-
|
|
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 {
|
|
1601
|
-
|
|
1602
|
-
|
|
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(
|
|
1652
|
+
/* @__PURE__ */ jsx13(FieldLabel2, {
|
|
1610
1653
|
htmlFor: field.path,
|
|
1611
|
-
|
|
1654
|
+
options: { label, locale, optional }
|
|
1612
1655
|
}),
|
|
1613
1656
|
children
|
|
1614
1657
|
]
|
|
1615
1658
|
}),
|
|
1616
1659
|
/* @__PURE__ */ jsx13(Textarea, {
|
|
1617
|
-
...
|
|
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(
|
|
1694
|
+
/* @__PURE__ */ jsx13(FieldLabel2, {
|
|
1652
1695
|
htmlFor: field.path,
|
|
1653
|
-
|
|
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(
|
|
1715
|
+
/* @__PURE__ */ jsx13(FieldLabel2, {
|
|
1673
1716
|
htmlFor: field.path,
|
|
1674
|
-
|
|
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(
|
|
1769
|
+
/* @__PURE__ */ jsx13(FieldLabel2, {
|
|
1727
1770
|
htmlFor: field.path,
|
|
1728
|
-
|
|
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(
|
|
1811
|
+
/* @__PURE__ */ jsx13(FieldLabel2, {
|
|
1769
1812
|
htmlFor: field.path,
|
|
1770
|
-
|
|
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(
|
|
1872
|
+
/* @__PURE__ */ jsx13(FieldLabel2, {
|
|
1830
1873
|
htmlFor: field.path,
|
|
1831
|
-
|
|
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(
|
|
1915
|
+
/* @__PURE__ */ jsx13(FieldLabel2, {
|
|
1873
1916
|
htmlFor: field.path,
|
|
1874
|
-
|
|
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(
|
|
1912
|
-
|
|
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(
|
|
1984
|
-
|
|
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(
|
|
2111
|
+
/* @__PURE__ */ jsx13(FieldLabel2, {
|
|
2069
2112
|
htmlFor: field.path,
|
|
2070
|
-
|
|
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, {
|
|
@@ -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";
|
|
@@ -263,14 +263,16 @@ var messages = {
|
|
|
263
263
|
description: "Search for an item to open.",
|
|
264
264
|
placeholder: "Search...",
|
|
265
265
|
inputPlaceholder: "Search...",
|
|
266
|
-
emptyMessage: "No results found."
|
|
266
|
+
emptyMessage: "No results found.",
|
|
267
|
+
clearSearch: "Clear search"
|
|
267
268
|
},
|
|
268
269
|
fr: {
|
|
269
270
|
title: "Recherche",
|
|
270
271
|
description: "Recherchez un élément à ouvrir.",
|
|
271
272
|
placeholder: "Rechercher...",
|
|
272
273
|
inputPlaceholder: "Rechercher...",
|
|
273
|
-
emptyMessage: "Aucun résultat trouvé."
|
|
274
|
+
emptyMessage: "Aucun résultat trouvé.",
|
|
275
|
+
clearSearch: "Effacer la recherche"
|
|
274
276
|
}
|
|
275
277
|
};
|
|
276
278
|
var searchMenuMessages = (locale, translations) => ({
|
|
@@ -304,8 +306,36 @@ function SearchMenu({
|
|
|
304
306
|
const resolvedInputPlaceholder = inputPlaceholder ?? labels.inputPlaceholder;
|
|
305
307
|
const resolvedEmptyMessage = emptyMessage ?? labels.emptyMessage;
|
|
306
308
|
const [uncontrolledOpen, setUncontrolledOpen] = useState(false);
|
|
309
|
+
const [uncontrolledQuery, setUncontrolledQuery] = useState("");
|
|
307
310
|
const isControlled = open !== undefined;
|
|
308
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]);
|
|
309
339
|
const setOpen = useCallback((value) => {
|
|
310
340
|
if (!isControlled)
|
|
311
341
|
setUncontrolledOpen(value);
|
|
@@ -351,15 +381,47 @@ function SearchMenu({
|
|
|
351
381
|
onOpenChange: setOpen,
|
|
352
382
|
title: resolvedTitle,
|
|
353
383
|
description: resolvedDescription,
|
|
384
|
+
className: "[&>[data-slot=dialog-close]]:hidden",
|
|
354
385
|
children: /* @__PURE__ */ jsxs3(Command, {
|
|
355
386
|
...shouldFilter === undefined ? {} : { shouldFilter },
|
|
387
|
+
...externalGroups && {
|
|
388
|
+
value: selectedValue,
|
|
389
|
+
onValueChange: (value) => setSelection({
|
|
390
|
+
groups: externalGroups,
|
|
391
|
+
query: searchQuery,
|
|
392
|
+
value
|
|
393
|
+
})
|
|
394
|
+
},
|
|
356
395
|
children: [
|
|
357
|
-
/* @__PURE__ */
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
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
|
+
]
|
|
361
422
|
}),
|
|
362
423
|
/* @__PURE__ */ jsxs3(CommandList, {
|
|
424
|
+
ref: listRef,
|
|
363
425
|
children: [
|
|
364
426
|
/* @__PURE__ */ jsx4(CommandEmpty, {
|
|
365
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";
|
|
@@ -140,7 +140,7 @@ import { Separator as SeparatorPrimitive } from "@base-ui/react/separator";
|
|
|
140
140
|
|
|
141
141
|
// ../../src/components/ui/sheet.tsx
|
|
142
142
|
import { Dialog as SheetPrimitive } from "@base-ui/react/dialog";
|
|
143
|
-
import { XIcon as
|
|
143
|
+
import { XIcon as XIcon3 } from "lucide-react";
|
|
144
144
|
"use client";
|
|
145
145
|
|
|
146
146
|
// ../../src/components/ui/tooltip.tsx
|
package/dist/lib/docs.js
CHANGED
|
@@ -448,8 +448,8 @@ function CollapsibleContent({ ...props }) {
|
|
|
448
448
|
}
|
|
449
449
|
|
|
450
450
|
// ../../src/components/ui/search-menu.tsx
|
|
451
|
-
import { SearchIcon as SearchIcon2 } from "lucide-react";
|
|
452
|
-
import { useCallback, useEffect as useEffect2, useState as useState2 } from "react";
|
|
451
|
+
import { SearchIcon as SearchIcon2, XIcon as XIcon2 } from "lucide-react";
|
|
452
|
+
import { useCallback, useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
|
|
453
453
|
|
|
454
454
|
// ../../src/components/ui/command.tsx
|
|
455
455
|
import { Command as CommandPrimitive } from "cmdk";
|
|
@@ -664,14 +664,16 @@ var messages3 = {
|
|
|
664
664
|
description: "Search for an item to open.",
|
|
665
665
|
placeholder: "Search...",
|
|
666
666
|
inputPlaceholder: "Search...",
|
|
667
|
-
emptyMessage: "No results found."
|
|
667
|
+
emptyMessage: "No results found.",
|
|
668
|
+
clearSearch: "Clear search"
|
|
668
669
|
},
|
|
669
670
|
fr: {
|
|
670
671
|
title: "Recherche",
|
|
671
672
|
description: "Recherchez un élément à ouvrir.",
|
|
672
673
|
placeholder: "Rechercher...",
|
|
673
674
|
inputPlaceholder: "Rechercher...",
|
|
674
|
-
emptyMessage: "Aucun résultat trouvé."
|
|
675
|
+
emptyMessage: "Aucun résultat trouvé.",
|
|
676
|
+
clearSearch: "Effacer la recherche"
|
|
675
677
|
}
|
|
676
678
|
};
|
|
677
679
|
var searchMenuMessages = (locale, translations) => ({
|
|
@@ -705,8 +707,36 @@ function SearchMenu({
|
|
|
705
707
|
const resolvedInputPlaceholder = inputPlaceholder ?? labels.inputPlaceholder;
|
|
706
708
|
const resolvedEmptyMessage = emptyMessage ?? labels.emptyMessage;
|
|
707
709
|
const [uncontrolledOpen, setUncontrolledOpen] = useState2(false);
|
|
710
|
+
const [uncontrolledQuery, setUncontrolledQuery] = useState2("");
|
|
708
711
|
const isControlled = open !== undefined;
|
|
709
712
|
const isOpen = open ?? uncontrolledOpen;
|
|
713
|
+
const searchQuery = query ?? uncontrolledQuery;
|
|
714
|
+
const externalGroups = shouldFilter === false ? groups : undefined;
|
|
715
|
+
const [selection, setSelection] = useState2();
|
|
716
|
+
const externalItems = externalGroups?.flatMap(({ items }) => items.filter(({ disabled }) => !disabled));
|
|
717
|
+
const selectedValue = selection?.groups === externalGroups && selection?.query === searchQuery && externalItems?.some(({ label }) => label.trim() === selection?.value) ? selection.value : externalItems?.[0]?.label.trim() ?? "";
|
|
718
|
+
const inputRef = useRef2(null);
|
|
719
|
+
const listRef = useRef2(null);
|
|
720
|
+
const setQuery = (value) => {
|
|
721
|
+
if (query === undefined)
|
|
722
|
+
setUncontrolledQuery(value);
|
|
723
|
+
onQueryChange?.(value);
|
|
724
|
+
};
|
|
725
|
+
useEffect2(() => {
|
|
726
|
+
if (!isOpen) {
|
|
727
|
+
setUncontrolledQuery("");
|
|
728
|
+
setSelection(undefined);
|
|
729
|
+
}
|
|
730
|
+
}, [isOpen]);
|
|
731
|
+
useEffect2(() => {
|
|
732
|
+
const list = listRef.current;
|
|
733
|
+
if (!isOpen || !list)
|
|
734
|
+
return;
|
|
735
|
+
const frame = requestAnimationFrame(() => {
|
|
736
|
+
list.scrollTop = 0;
|
|
737
|
+
});
|
|
738
|
+
return () => cancelAnimationFrame(frame);
|
|
739
|
+
}, [isOpen, searchQuery, externalGroups]);
|
|
710
740
|
const setOpen = useCallback((value) => {
|
|
711
741
|
if (!isControlled)
|
|
712
742
|
setUncontrolledOpen(value);
|
|
@@ -752,15 +782,47 @@ function SearchMenu({
|
|
|
752
782
|
onOpenChange: setOpen,
|
|
753
783
|
title: resolvedTitle,
|
|
754
784
|
description: resolvedDescription,
|
|
785
|
+
className: "[&>[data-slot=dialog-close]]:hidden",
|
|
755
786
|
children: /* @__PURE__ */ jsxs6(Command, {
|
|
756
787
|
...shouldFilter === undefined ? {} : { shouldFilter },
|
|
788
|
+
...externalGroups && {
|
|
789
|
+
value: selectedValue,
|
|
790
|
+
onValueChange: (value) => setSelection({
|
|
791
|
+
groups: externalGroups,
|
|
792
|
+
query: searchQuery,
|
|
793
|
+
value
|
|
794
|
+
})
|
|
795
|
+
},
|
|
757
796
|
children: [
|
|
758
|
-
/* @__PURE__ */
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
797
|
+
/* @__PURE__ */ jsxs6("div", {
|
|
798
|
+
className: cn("relative", searchQuery && "[&_[data-slot=command-input-wrapper]>div]:pr-10"),
|
|
799
|
+
children: [
|
|
800
|
+
/* @__PURE__ */ jsx9(CommandInput, {
|
|
801
|
+
ref: inputRef,
|
|
802
|
+
placeholder: resolvedInputPlaceholder,
|
|
803
|
+
value: searchQuery,
|
|
804
|
+
onValueChange: setQuery
|
|
805
|
+
}),
|
|
806
|
+
searchQuery && /* @__PURE__ */ jsx9(Button, {
|
|
807
|
+
type: "button",
|
|
808
|
+
variant: "ghost",
|
|
809
|
+
size: "icon-sm",
|
|
810
|
+
"aria-label": labels.clearSearch,
|
|
811
|
+
className: "absolute top-1.5 right-2",
|
|
812
|
+
onKeyDown: (event) => {
|
|
813
|
+
if (event.key === "Enter")
|
|
814
|
+
event.stopPropagation();
|
|
815
|
+
},
|
|
816
|
+
onClick: () => {
|
|
817
|
+
setQuery("");
|
|
818
|
+
inputRef.current?.focus();
|
|
819
|
+
},
|
|
820
|
+
children: /* @__PURE__ */ jsx9(XIcon2, {})
|
|
821
|
+
})
|
|
822
|
+
]
|
|
762
823
|
}),
|
|
763
824
|
/* @__PURE__ */ jsxs6(CommandList, {
|
|
825
|
+
ref: listRef,
|
|
764
826
|
children: [
|
|
765
827
|
/* @__PURE__ */ jsx9(CommandEmpty, {
|
|
766
828
|
children: resolvedEmptyMessage
|
|
@@ -844,7 +906,7 @@ import { Separator as SeparatorPrimitive } from "@base-ui/react/separator";
|
|
|
844
906
|
|
|
845
907
|
// ../../src/components/ui/sheet.tsx
|
|
846
908
|
import { Dialog as SheetPrimitive } from "@base-ui/react/dialog";
|
|
847
|
-
import { XIcon as
|
|
909
|
+
import { XIcon as XIcon3 } from "lucide-react";
|
|
848
910
|
import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
849
911
|
"use client";
|
|
850
912
|
function Sheet({ ...props }) {
|
|
@@ -891,7 +953,7 @@ function SheetContent({
|
|
|
891
953
|
size: "icon-sm"
|
|
892
954
|
}),
|
|
893
955
|
children: [
|
|
894
|
-
/* @__PURE__ */ jsx10(
|
|
956
|
+
/* @__PURE__ */ jsx10(XIcon3, {}),
|
|
895
957
|
/* @__PURE__ */ jsx10("span", {
|
|
896
958
|
className: "sr-only",
|
|
897
959
|
children: "Close"
|
package/dist/lib/docs.server.js
CHANGED
|
@@ -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";
|
|
@@ -140,7 +140,7 @@ import { Separator as SeparatorPrimitive } from "@base-ui/react/separator";
|
|
|
140
140
|
|
|
141
141
|
// ../../src/components/ui/sheet.tsx
|
|
142
142
|
import { Dialog as SheetPrimitive } from "@base-ui/react/dialog";
|
|
143
|
-
import { XIcon as
|
|
143
|
+
import { XIcon as XIcon3 } from "lucide-react";
|
|
144
144
|
"use client";
|
|
145
145
|
|
|
146
146
|
// ../../src/components/ui/tooltip.tsx
|
|
@@ -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";
|
|
@@ -140,7 +140,7 @@ import { Separator as SeparatorPrimitive } from "@base-ui/react/separator";
|
|
|
140
140
|
|
|
141
141
|
// ../../src/components/ui/sheet.tsx
|
|
142
142
|
import { Dialog as SheetPrimitive } from "@base-ui/react/dialog";
|
|
143
|
-
import { XIcon as
|
|
143
|
+
import { XIcon as XIcon3 } from "lucide-react";
|
|
144
144
|
"use client";
|
|
145
145
|
|
|
146
146
|
// ../../src/components/ui/tooltip.tsx
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@krak-stack/registry",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.17",
|
|
4
4
|
"description": "Tree-shakable KrakStack components and Effect services.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -17,6 +17,10 @@
|
|
|
17
17
|
"type": "module",
|
|
18
18
|
"sideEffects": false,
|
|
19
19
|
"exports": {
|
|
20
|
+
"./support": {
|
|
21
|
+
"types": "./dist/components/support.d.ts",
|
|
22
|
+
"import": "./dist/components/support.js"
|
|
23
|
+
},
|
|
20
24
|
"./support-dialog": {
|
|
21
25
|
"types": "./dist/components/support-dialog.d.ts",
|
|
22
26
|
"import": "./dist/components/support-dialog.js"
|