@ai-matrx/associations 0.7.4 → 0.7.6
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 +17 -0
- package/dist/react/index.cjs +64 -19
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +64 -19
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -1
package/dist/react/index.js
CHANGED
|
@@ -2132,6 +2132,15 @@ function EntityCandidateList({
|
|
|
2132
2132
|
enabled,
|
|
2133
2133
|
...search.trim() ? { search: search.trim() } : {}
|
|
2134
2134
|
});
|
|
2135
|
+
const { results: recentCandidates, loading: recentsLoading } = useUniversalEntitySearch({
|
|
2136
|
+
query: "",
|
|
2137
|
+
tokens: [token],
|
|
2138
|
+
enabled: enabled && !search.trim()
|
|
2139
|
+
});
|
|
2140
|
+
const visibleRecents = search.trim() ? [] : recentCandidates;
|
|
2141
|
+
const recentIds = new Set(visibleRecents.map((candidate) => candidate.id));
|
|
2142
|
+
const ordinaryCandidates = search.trim() ? candidates : candidates.filter((candidate) => !recentIds.has(candidate.id));
|
|
2143
|
+
const visibleCount = visibleRecents.length + ordinaryCandidates.length;
|
|
2135
2144
|
const canCreate = info.titleColumn !== null && info.listCandidates === null;
|
|
2136
2145
|
const toggle = async (id, title) => {
|
|
2137
2146
|
if (busyId) return;
|
|
@@ -2162,7 +2171,7 @@ function EntityCandidateList({
|
|
|
2162
2171
|
}
|
|
2163
2172
|
)
|
|
2164
2173
|
] }),
|
|
2165
|
-
/* @__PURE__ */ jsx6("div", { className: "flex-1 min-h-0 overflow-y-auto -mx-1 px-1", children: loading &&
|
|
2174
|
+
/* @__PURE__ */ jsx6("div", { className: "flex-1 min-h-0 overflow-y-auto -mx-1 px-1", children: (loading || recentsLoading) && visibleCount === 0 ? /* @__PURE__ */ jsxs4(ListMessage, { children: [
|
|
2166
2175
|
/* @__PURE__ */ jsx6(SpinnerIcon, { className: "h-4 w-4 animate-spin" }),
|
|
2167
2176
|
"Loading\u2026"
|
|
2168
2177
|
] }) : error ? /* @__PURE__ */ jsxs4("div", { className: "rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[12px] text-destructive", children: [
|
|
@@ -2177,23 +2186,69 @@ function EntityCandidateList({
|
|
|
2177
2186
|
children: "Retry"
|
|
2178
2187
|
}
|
|
2179
2188
|
)
|
|
2180
|
-
] }) :
|
|
2181
|
-
|
|
2182
|
-
|
|
2189
|
+
] }) : visibleCount === 0 ? /* @__PURE__ */ jsx6(ListMessage, { children: canCreate ? `Nothing to attach yet \u2014 create a new ${info.label.toLowerCase()} below.` : "Nothing to attach." }) : /* @__PURE__ */ jsxs4("div", { className: "space-y-2", children: [
|
|
2190
|
+
visibleRecents.length > 0 && /* @__PURE__ */ jsx6(
|
|
2191
|
+
CandidateSection,
|
|
2192
|
+
{
|
|
2193
|
+
label: "Recent",
|
|
2194
|
+
candidates: visibleRecents,
|
|
2195
|
+
attachedIds,
|
|
2196
|
+
busyId,
|
|
2197
|
+
icon: /* @__PURE__ */ jsx6(Icon, { className: "h-4 w-4 shrink-0 text-muted-foreground" }),
|
|
2198
|
+
onToggle: toggle
|
|
2199
|
+
}
|
|
2200
|
+
),
|
|
2201
|
+
ordinaryCandidates.length > 0 && /* @__PURE__ */ jsx6(
|
|
2202
|
+
CandidateSection,
|
|
2203
|
+
{
|
|
2204
|
+
label: visibleRecents.length > 0 ? `All ${info.labelPlural}` : null,
|
|
2205
|
+
candidates: ordinaryCandidates,
|
|
2206
|
+
attachedIds,
|
|
2207
|
+
busyId,
|
|
2208
|
+
icon: /* @__PURE__ */ jsx6(Icon, { className: "h-4 w-4 shrink-0 text-muted-foreground" }),
|
|
2209
|
+
onToggle: toggle
|
|
2210
|
+
}
|
|
2211
|
+
)
|
|
2212
|
+
] }) }),
|
|
2213
|
+
canCreate && /* @__PURE__ */ jsx6(
|
|
2214
|
+
CreateAndAttachFooter,
|
|
2215
|
+
{
|
|
2216
|
+
token,
|
|
2217
|
+
orgId,
|
|
2218
|
+
seed: search.trim(),
|
|
2219
|
+
onAttach,
|
|
2220
|
+
onCreated: reload
|
|
2221
|
+
}
|
|
2222
|
+
)
|
|
2223
|
+
] });
|
|
2224
|
+
}
|
|
2225
|
+
function CandidateSection({
|
|
2226
|
+
label,
|
|
2227
|
+
candidates,
|
|
2228
|
+
attachedIds,
|
|
2229
|
+
busyId,
|
|
2230
|
+
icon,
|
|
2231
|
+
onToggle
|
|
2232
|
+
}) {
|
|
2233
|
+
return /* @__PURE__ */ jsxs4("section", { className: "space-y-0.5", children: [
|
|
2234
|
+
label && /* @__PURE__ */ jsx6("p", { className: "px-1 text-[10px] font-medium uppercase tracking-wider text-muted-foreground/60", children: label }),
|
|
2235
|
+
/* @__PURE__ */ jsx6("ul", { className: "space-y-0.5", children: candidates.map((candidate) => {
|
|
2236
|
+
const attached = attachedIds.has(candidate.id);
|
|
2237
|
+
const busy = busyId === candidate.id;
|
|
2183
2238
|
return /* @__PURE__ */ jsx6("li", { children: /* @__PURE__ */ jsxs4(
|
|
2184
2239
|
"button",
|
|
2185
2240
|
{
|
|
2186
2241
|
type: "button",
|
|
2187
2242
|
disabled: busy,
|
|
2188
|
-
onClick: () =>
|
|
2243
|
+
onClick: () => void onToggle(candidate.id, candidate.title),
|
|
2189
2244
|
className: cn2(
|
|
2190
2245
|
"group flex min-h-11 w-full items-center gap-2 rounded-md px-2.5 py-2 text-left text-sm transition-colors md:min-h-0",
|
|
2191
2246
|
"hover:bg-accent disabled:opacity-50",
|
|
2192
2247
|
attached && "bg-accent/40"
|
|
2193
2248
|
),
|
|
2194
2249
|
children: [
|
|
2195
|
-
|
|
2196
|
-
/* @__PURE__ */ jsx6("span", { className: "flex-1 min-w-0 truncate text-foreground", children:
|
|
2250
|
+
icon,
|
|
2251
|
+
/* @__PURE__ */ jsx6("span", { className: "flex-1 min-w-0 truncate text-foreground", children: candidate.title }),
|
|
2197
2252
|
/* @__PURE__ */ jsx6(
|
|
2198
2253
|
"span",
|
|
2199
2254
|
{
|
|
@@ -2206,18 +2261,8 @@ function EntityCandidateList({
|
|
|
2206
2261
|
)
|
|
2207
2262
|
]
|
|
2208
2263
|
}
|
|
2209
|
-
) },
|
|
2210
|
-
}) })
|
|
2211
|
-
canCreate && /* @__PURE__ */ jsx6(
|
|
2212
|
-
CreateAndAttachFooter,
|
|
2213
|
-
{
|
|
2214
|
-
token,
|
|
2215
|
-
orgId,
|
|
2216
|
-
seed: search.trim(),
|
|
2217
|
-
onAttach,
|
|
2218
|
-
onCreated: reload
|
|
2219
|
-
}
|
|
2220
|
-
)
|
|
2264
|
+
) }, candidate.id);
|
|
2265
|
+
}) })
|
|
2221
2266
|
] });
|
|
2222
2267
|
}
|
|
2223
2268
|
function CreateAndAttachFooter({
|