@sanity/embeddings-index-ui 1.0.0 → 1.0.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/README.md +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +15 -18
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +14 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/api/embeddingsApi.ts +1 -1
- package/src/embeddingsIndexDashboard/QueryIndex.tsx +2 -1
- package/src/preview/DocumentPreview.tsx +7 -11
- package/src/referenceInput/SemanticSearchReferenceInput.tsx +4 -3
package/dist/index.js
CHANGED
|
@@ -1751,20 +1751,12 @@ function DocumentPreview(_ref) {
|
|
|
1751
1751
|
let {
|
|
1752
1752
|
documentId,
|
|
1753
1753
|
style,
|
|
1754
|
+
schemaTypeName,
|
|
1754
1755
|
...buttonProps
|
|
1755
1756
|
} = _ref;
|
|
1756
|
-
const client = sanity.useClient({
|
|
1757
|
-
apiVersion: "2023-06-06"
|
|
1758
|
-
});
|
|
1759
|
-
const [type, setType] = require$$0.useState(void 0);
|
|
1760
1757
|
const schema = sanity.useSchema();
|
|
1761
|
-
const schemaType =
|
|
1762
|
-
|
|
1763
|
-
client.fetch("* [_id==$id]._type", {
|
|
1764
|
-
id: documentId
|
|
1765
|
-
}).then(setType);
|
|
1766
|
-
}, [documentId, client]);
|
|
1767
|
-
if (!type) {
|
|
1758
|
+
const schemaType = schemaTypeName ? schema.get(schemaTypeName) : void 0;
|
|
1759
|
+
if (!schemaTypeName) {
|
|
1768
1760
|
return /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
|
|
1769
1761
|
style: {
|
|
1770
1762
|
minHeight: "36px"
|
|
@@ -1786,7 +1778,7 @@ function DocumentPreview(_ref) {
|
|
|
1786
1778
|
media: () => /* @__PURE__ */jsxRuntime.jsx(icons.ErrorOutlineIcon, {}),
|
|
1787
1779
|
title: /* @__PURE__ */jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1788
1780
|
children: ["Unknown type ", /* @__PURE__ */jsxRuntime.jsx("code", {
|
|
1789
|
-
children:
|
|
1781
|
+
children: schemaTypeName != null ? schemaTypeName : "N/A"
|
|
1790
1782
|
}), " for ", documentId]
|
|
1791
1783
|
})
|
|
1792
1784
|
})
|
|
@@ -1794,6 +1786,7 @@ function DocumentPreview(_ref) {
|
|
|
1794
1786
|
}
|
|
1795
1787
|
return /* @__PURE__ */jsxRuntime.jsx(DocumentPreviewInner, {
|
|
1796
1788
|
documentId,
|
|
1789
|
+
schemaTypeName,
|
|
1797
1790
|
schemaType,
|
|
1798
1791
|
style,
|
|
1799
1792
|
...buttonProps
|
|
@@ -1976,7 +1969,7 @@ function SemanticSearchInput(props) {
|
|
|
1976
1969
|
const handleFocus = require$$0.useCallback(() => onPathFocus(["_ref"]), [onPathFocus]);
|
|
1977
1970
|
const handleBlur = require$$0.useCallback(() => onPathFocus([]), [onPathFocus]);
|
|
1978
1971
|
const runIndexQuery = require$$0.useCallback(queryString => {
|
|
1979
|
-
var _a, _b, _c, _d;
|
|
1972
|
+
var _a, _b, _c, _d, _e;
|
|
1980
1973
|
setSearching(true);
|
|
1981
1974
|
const refSchema = schemaType;
|
|
1982
1975
|
const indexName = (_b = (_a = refSchema.options) == null ? void 0 : _a.embeddingsIndex) == null ? void 0 : _b.indexName;
|
|
@@ -1986,7 +1979,7 @@ function SemanticSearchInput(props) {
|
|
|
1986
1979
|
throw new Error("Reference option embeddingsIndex.indexName is required, but was missing in type ".concat(refSchema.name));
|
|
1987
1980
|
}
|
|
1988
1981
|
queryIndex({
|
|
1989
|
-
query: queryString,
|
|
1982
|
+
query: queryString.trim().length ? queryString : (_e = JSON.stringify(docRef.current)) != null ? _e : "",
|
|
1990
1983
|
indexName,
|
|
1991
1984
|
maxResults,
|
|
1992
1985
|
filter: {
|
|
@@ -2035,7 +2028,7 @@ function SemanticSearchInput(props) {
|
|
|
2035
2028
|
id,
|
|
2036
2029
|
ref: autocompleteRef,
|
|
2037
2030
|
"data-testid": "semantic-autocomplete",
|
|
2038
|
-
placeholder: "Type to search",
|
|
2031
|
+
placeholder: "Type to search...",
|
|
2039
2032
|
openButton: openButtonConfig,
|
|
2040
2033
|
onFocus: handleFocus,
|
|
2041
2034
|
onChange: handleChange,
|
|
@@ -2049,6 +2042,7 @@ function SemanticSearchInput(props) {
|
|
|
2049
2042
|
});
|
|
2050
2043
|
}
|
|
2051
2044
|
function AutocompleteOption(props) {
|
|
2045
|
+
const value = props.result.value;
|
|
2052
2046
|
return /* @__PURE__ */jsxRuntime.jsx(ui.Button, {
|
|
2053
2047
|
mode: "bleed",
|
|
2054
2048
|
padding: 1,
|
|
@@ -2061,7 +2055,8 @@ function AutocompleteOption(props) {
|
|
|
2061
2055
|
children: [/* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
2062
2056
|
flex: 1,
|
|
2063
2057
|
children: /* @__PURE__ */jsxRuntime.jsx(DocumentPreview, {
|
|
2064
|
-
documentId:
|
|
2058
|
+
documentId: value.documentId,
|
|
2059
|
+
schemaTypeName: value.type
|
|
2065
2060
|
})
|
|
2066
2061
|
}), /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
2067
2062
|
padding: 2,
|
|
@@ -2512,13 +2507,15 @@ function ResultList(props) {
|
|
|
2512
2507
|
});
|
|
2513
2508
|
}
|
|
2514
2509
|
function ResultEntry(props) {
|
|
2510
|
+
const value = props.result.value;
|
|
2515
2511
|
return /* @__PURE__ */jsxRuntime.jsxs(ui.Flex, {
|
|
2516
2512
|
gap: 4,
|
|
2517
2513
|
align: "center",
|
|
2518
2514
|
children: [/* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
2519
2515
|
flex: 1,
|
|
2520
2516
|
children: /* @__PURE__ */jsxRuntime.jsx(DocumentPreview, {
|
|
2521
|
-
documentId:
|
|
2517
|
+
documentId: value.documentId,
|
|
2518
|
+
schemaTypeName: value.type,
|
|
2522
2519
|
button: true
|
|
2523
2520
|
})
|
|
2524
2521
|
}), /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|