mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
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:
@@ -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": {
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user