chore: bump version to 0.18.0-rc.10 in package.json and update EntityMediaFormField logic for single item handling

This commit is contained in:
dswbx
2025-09-29 22:10:07 +02:00
parent 6102759da8
commit 1eeb23232a
2 changed files with 5 additions and 3 deletions

View File

@@ -3,7 +3,7 @@
"type": "module", "type": "module",
"sideEffects": false, "sideEffects": false,
"bin": "./dist/cli/index.js", "bin": "./dist/cli/index.js",
"version": "0.18.0-rc.9", "version": "0.18.0-rc.10",
"description": "Lightweight Firebase/Supabase alternative built to run anywhere — incl. Next.js, React Router, Astro, Cloudflare, Bun, Node, AWS Lambda & more.", "description": "Lightweight Firebase/Supabase alternative built to run anywhere — incl. Next.js, React Router, Astro, Cloudflare, Bun, Node, AWS Lambda & more.",
"homepage": "https://bknd.io", "homepage": "https://bknd.io",
"repository": { "repository": {

View File

@@ -242,6 +242,8 @@ function EntityMediaFormField({
if (!entityId) return; if (!entityId) return;
const maxLimit = 50; const maxLimit = 50;
const maxItems = field.getMaxItems(); const maxItems = field.getMaxItems();
const isSingle = maxItems === 1;
const limit = isSingle ? 1 : maxItems && maxItems > maxLimit ? maxLimit : maxItems;
const value = useStore(formApi.store, (state) => { const value = useStore(formApi.store, (state) => {
const val = state.values[field.name]; const val = state.values[field.name];
@@ -264,7 +266,7 @@ function EntityMediaFormField({
key={key} key={key}
maxItems={maxItems} maxItems={maxItems}
allowedMimeTypes={field.getAllowedMimeTypes()} allowedMimeTypes={field.getAllowedMimeTypes()}
/* initialItems={value} @todo: test if better be omitted, so it fetches */ initialItems={isSingle ? value : undefined}
onClick={onClick} onClick={onClick}
entity={{ entity={{
name: entity.name, name: entity.name,
@@ -273,7 +275,7 @@ function EntityMediaFormField({
}} }}
query={{ query={{
sort: "-id", sort: "-id",
limit: maxItems && maxItems > maxLimit ? maxLimit : maxItems, limit,
}} }}
/> />
</Formy.Group> </Formy.Group>