@panneau/fields 5.0.0-alpha.20 → 5.0.0-alpha.22

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.
@@ -1 +1 @@
1
- {"version":3,"file":"relation.js","names":["useEffect","useState","Definition","Item","ListQuery","RelationReference","id","label","RelationSource","search","resource","query","options","signal","AbortSignal","Promise","resolve","ids","create","text","canCreate","RelationListAdapter","list","data","get","values","Record","RelationSourceOptions","definition","Pick","Partial","perPage","getLabel","item","labelOf","value","locale","String","localized","first","undefined","Object","createRelationSource","adapter","resourceOf","resources","find","candidate","toReference","titleField","itemTitle","valuesOf","definitionResource","field","fields","name","locales","length","fromEntries","map","source","response","page","q","createItem","results","allSettled","call","flatMap","result","status","abilities","toReferences","Array","isArray","entry","ResolvedLabels","labels","Map","pending","resolved","WeakMap","resolvedOf","set","keyOf","resolveIds","fresh","filter","has","request","AbortController","then","found","forEach","delete","all","useRelationReferences","references","$","_c","cache","t0","Symbol","for","setLabels","missing","_temp","_temp2","id_0","missingKey","join","split","active","next","id_1","current","reference_1","reference","reference_0","_c"],"sources":["../../src/shared/relation.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport type { Definition, Item, ListQuery } from '@panneau/protocol';\n\n/** A related item: its id, and a label to show it. The value of a relation field. */\nexport interface RelationReference {\n id: string;\n label: string;\n}\n\n/** Where relation fields search for items. */\nexport interface RelationSource {\n /** Items of a resource that match a text, for the picker. */\n search(\n resource: string,\n query: string,\n options: { signal: AbortSignal },\n ): Promise<RelationReference[]>;\n /**\n * The references of items by id, for values that are only ids (`\"12\"`, `[\"12\", \"13\"]`), as a\n * product's own API gives them. In any order; ids it doesn't find are left out, and keep their\n * id as label. Without it, fields show the ids.\n */\n resolve?(\n resource: string,\n ids: readonly string[],\n options: { signal: AbortSignal },\n ): Promise<RelationReference[]>;\n /**\n * Creates an item from the text typed in the picker, which offers \"Create “…”\" when this\n * method exists. It can open a dialog, and resolves with the reference of the new item, or with\n * `null` when nothing was created.\n */\n create?(resource: string, text: string): Promise<RelationReference | null>;\n /** Whether `create()` can create items of a resource. Defaults to true. */\n canCreate?(resource: string): boolean;\n}\n\n/** What `createRelationSource()` needs from an adapter: the `list()`, `get()` and `create()` of `@panneau/data`. */\nexport interface RelationListAdapter {\n list(\n resource: string,\n query?: ListQuery,\n options?: { signal?: AbortSignal },\n ): Promise<{ data: Item[] }>;\n /** One item, for `resolve()`. Without it, the source doesn't resolve ids. */\n get?(resource: string, id: string, options?: { signal?: AbortSignal }): Promise<Item>;\n /** Creates an item, for `create()`. */\n create?(resource: string, values: Record<string, unknown>): Promise<Item>;\n}\n\nexport interface RelationSourceOptions {\n /** The definition, for the field that titles the items of each resource (`itemTitle`). */\n definition?: (Pick<Definition, 'resources'> & Partial<Pick<Definition, 'locales'>>) | null;\n /** Items per search. Defaults to 20. */\n perPage?: number;\n /** The label of an item, when `itemTitle` isn't enough. */\n getLabel?: (item: Item, resource: string) => string;\n /**\n * Lets the picker create items, with the adapter's `create()`. `true` sets the typed text as the\n * value of the resource's `itemTitle` field (in every locale of the definition when it is\n * localized), on the resources that allow `create`. A function gives the values of the new item\n * instead, or `null` for a resource where items can't be created.\n */\n create?: boolean | ((text: string, resource: string) => Record<string, unknown> | null);\n}\n\nfunction labelOf(value: unknown, locale?: string): string | null {\n if (typeof value === 'string' || typeof value === 'number') {\n return String(value);\n }\n if (value !== null && typeof value === 'object') {\n const localized = value as Record<string, unknown>;\n const first =\n (locale !== undefined ? localized[locale] : undefined) ?? Object.values(localized)[0];\n return typeof first === 'string' ? first : null;\n }\n return null;\n}\n\n/**\n * A relation source over an adapter, such as the `DataAdapter` of `@panneau/data`: a search is a\n * list query with `q`, ids are resolved with `get()`, and, with the `create` option, items are\n * created with `create()`. Labels come from the resource's `itemTitle`.\n */\nexport function createRelationSource(\n adapter: RelationListAdapter,\n { definition = null, perPage = 20, getLabel, create }: RelationSourceOptions = {},\n): RelationSource {\n const resourceOf = (resource: string) =>\n definition?.resources.find((candidate) => candidate.id === resource);\n const toReference = (item: Item, resource: string): RelationReference => {\n const titleField = resourceOf(resource)?.itemTitle;\n return {\n id: item.id,\n label:\n getLabel?.(item, resource) ??\n (titleField !== undefined ? labelOf(item[titleField]) : null) ??\n item.id,\n };\n };\n const valuesOf = (text: string, resource: string): Record<string, unknown> | null => {\n if (typeof create === 'function') {\n return create(text, resource);\n }\n const definitionResource = resourceOf(resource);\n const titleField = definitionResource?.itemTitle;\n if (definitionResource === undefined || titleField === undefined) {\n return null;\n }\n const field = definitionResource.fields.find((candidate) => candidate.name === titleField);\n const locales = definition?.locales ?? [];\n return {\n [titleField]:\n field?.localized === true && locales.length > 0\n ? Object.fromEntries(locales.map((locale) => [locale, text]))\n : text,\n };\n };\n const source: RelationSource = {\n async search(resource, query, { signal }) {\n const response = await adapter.list(\n resource,\n { page: 1, perPage, ...(query !== '' ? { q: query } : {}) },\n { signal },\n );\n return response.data.map((item) => toReference(item, resource));\n },\n };\n const { get, create: createItem } = adapter;\n if (get !== undefined) {\n source.resolve = async (resource, ids, { signal }) => {\n const results = await Promise.allSettled(\n ids.map((id) => get.call(adapter, resource, id, { signal })),\n );\n return results.flatMap((result) =>\n result.status === 'fulfilled' ? [toReference(result.value, resource)] : [],\n );\n };\n }\n if (create !== undefined && create !== false && createItem !== undefined) {\n source.canCreate = (resource) =>\n resourceOf(resource)?.abilities?.create !== false && valuesOf('', resource) !== null;\n source.create = async (resource, text) => {\n const values = valuesOf(text, resource);\n if (values === null) {\n return null;\n }\n return toReference(await createItem.call(adapter, resource, values), resource);\n };\n }\n return source;\n}\n\n/** Reads relation values: references, ids, or lists of them. */\nexport function toReferences(value: unknown): RelationReference[] {\n const list = Array.isArray(value)\n ? value\n : value === null || value === undefined\n ? []\n : [value];\n return list.flatMap((entry: unknown) => {\n if (typeof entry === 'string' || typeof entry === 'number') {\n return [{ id: String(entry), label: String(entry) }];\n }\n if (entry !== null && typeof entry === 'object' && 'id' in entry) {\n const { id, label } = entry as { id: unknown; label?: unknown };\n if (typeof id === 'string' || typeof id === 'number') {\n return [{ id: String(id), label: typeof label === 'string' ? label : String(id) }];\n }\n }\n return [];\n });\n}\n\ninterface ResolvedLabels {\n /** Labels by resource and id: `null` for ids that the source didn't find. */\n labels: Map<string, string | null>;\n /** Requests in flight, so that fields with the same ids share one. */\n pending: Map<string, Promise<void>>;\n}\n\nconst resolved = new WeakMap<RelationSource, ResolvedLabels>();\n\nfunction resolvedOf(source: RelationSource): ResolvedLabels {\n let entry = resolved.get(source);\n if (entry === undefined) {\n entry = { labels: new Map(), pending: new Map() };\n resolved.set(source, entry);\n }\n return entry;\n}\n\nconst keyOf = (resource: string, id: string) => `${resource}\\u0000${id}`;\n\n/** Resolves the ids that no request has resolved or is resolving yet, and waits for all of them. */\nfunction resolveIds(source: RelationSource, resource: string, ids: readonly string[]) {\n const { labels, pending } = resolvedOf(source);\n const fresh = ids.filter((id) => !pending.has(keyOf(resource, id)));\n if (fresh.length > 0 && source.resolve !== undefined) {\n // Shared by every field that asks for these ids: it isn't aborted when one unmounts.\n const request = source\n .resolve(resource, fresh, { signal: new AbortController().signal })\n .then(\n (found) => {\n fresh.forEach((id) =>\n labels.set(\n keyOf(resource, id),\n found.find((candidate) => candidate.id === id)?.label ?? null,\n ),\n );\n },\n () => {\n // Tried again the next time a field shows these ids.\n fresh.forEach((id) => pending.delete(keyOf(resource, id)));\n },\n );\n fresh.forEach((id) => pending.set(keyOf(resource, id), request));\n }\n return Promise.all(ids.map((id) => pending.get(keyOf(resource, id))));\n}\n\n/**\n * Relation references with the labels of plain ids: references whose label is their id (from\n * `\"12\"`) are resolved with the source's `resolve()`, once per source, resource and id. They keep\n * their id as label until then, or when the source doesn't find them.\n */\nexport function useRelationReferences(\n source: RelationSource | null,\n resource: string,\n references: readonly RelationReference[],\n): RelationReference[] {\n const cache = source !== null ? resolvedOf(source).labels : null;\n const [labels, setLabels] = useState<Readonly<Record<string, string>>>({});\n const label = (id: string): string | undefined =>\n labels[keyOf(resource, id)] ?? cache?.get(keyOf(resource, id)) ?? undefined;\n const missing =\n source?.resolve !== undefined && cache !== null\n ? references\n .filter((reference) => reference.label === reference.id)\n .map((reference) => reference.id)\n .filter((id) => !cache.has(keyOf(resource, id)))\n : [];\n const missingKey = missing.join('\\u0000');\n\n useEffect(() => {\n const ids = missingKey === '' ? [] : missingKey.split('\\u0000');\n if (source === null || cache === null || ids.length === 0) {\n return undefined;\n }\n let active = true;\n void resolveIds(source, resource, ids).then(() => {\n if (!active) {\n return;\n }\n const next: Record<string, string> = {};\n ids.forEach((id) => {\n const found = cache.get(keyOf(resource, id));\n if (typeof found === 'string') {\n next[keyOf(resource, id)] = found;\n }\n });\n setLabels((current) => ({ ...current, ...next }));\n });\n return () => {\n active = false;\n };\n }, [source, cache, resource, missingKey]);\n\n return references.map((reference) =>\n reference.label === reference.id\n ? { id: reference.id, label: label(reference.id) ?? reference.id }\n : reference,\n );\n}\n"],"mappings":";;;AAmEA,SAASkC,QAAQC,OAAgBC,QAAgC;CAC7D,IAAI,OAAOD,UAAU,YAAY,OAAOA,UAAU,UAC9C,OAAOE,OAAOF,KAAK;CAEvB,IAAIA,UAAU,QAAQ,OAAOA,UAAU,UAAU;EAC7C,MAAMG,YAAYH;EAClB,MAAMI,SACDH,WAAWI,KAAAA,IAAYF,UAAUF,UAAUI,KAAAA,MAAcC,OAAOhB,OAAOa,SAAS,CAAC,CAAC;EACvF,OAAO,OAAOC,UAAU,WAAWA,QAAQ;CAC/C;CACA,OAAO;AACX;;;;;;AAOA,SAAgBG,qBACZC,SACA,EAAEf,aAAa,MAAMG,UAAU,IAAIC,UAAUd,WAAkC,CAAC,GAClE;CACd,MAAM0B,cAAclC,aAChBkB,YAAYiB,UAAUC,MAAMC,cAAcA,UAAUzC,OAAOI,QAAQ;CACvE,MAAMsC,eAAef,MAAYvB,aAAwC;EACrE,MAAMuC,aAAaL,WAAWlC,QAAQ,CAAC,EAAEwC;EACzC,OAAO;GACH5C,IAAI2B,KAAK3B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W8G,YAAS/G,KAA7B;EAAAA,IACY+G,YAAS/G;EAAGC,OAASA,MAAM8G,YAAS/G,EAAmB,KAAX+G,YAAS/G;CACnD,IAFd8G,WAGJ;AAAC;AA9CE,SAAAT,OAAAW,aAAA;CAAA,OAa+BD,YAAS/G;AAAG;AAb3C,SAAAoG,MAAAW,WAAA;CAAA,OAYkCA,UAAS9G,UAAW8G,UAAS/G;AAAG"}
1
+ {"version":3,"file":"relation.js","names":["useEffect","useState","Definition","Item","ListQuery","getImageUrl","getItemImageField","RelationReference","id","label","description","imageUrl","RelationResourceInfo","icon","image","RelationSource","search","resource","query","options","signal","AbortSignal","Promise","resolve","ids","create","text","canCreate","describe","getItemHref","RelationListAdapter","list","data","get","values","Record","RelationSourceOptions","definition","Pick","Partial","perPage","getLabel","item","labelOf","value","locale","String","localized","first","undefined","Object","createRelationSource","adapter","resourceOf","resources","find","candidate","toReference","definitionResource","titleField","itemTitle","subtitleField","itemSubtitle","imageField","valuesOf","field","fields","name","locales","length","fromEntries","map","source","response","page","q","createItem","results","allSettled","call","flatMap","result","status","abilities","toReferences","Array","isArray","entry","ResolvedReferences","references","Map","pending","resolved","WeakMap","resolvedOf","set","keyOf","resolveIds","fresh","filter","has","request","AbortController","then","found","forEach","delete","all","needsResolving","reference","detailed","useRelationReferences","$","_c","cache","t0","Symbol","for","setFound","t1","info","missing","_temp","missingKey","join","t2","split","active","next","id_0","reference_1","current","t3","t4","t5","reference_2","known","reference_0","_c"],"sources":["../../src/shared/relation.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport type { Definition, Item, ListQuery } from '@panneau/protocol';\nimport { getImageUrl, getItemImageField } from '@panneau/protocol/runtime';\n\n/**\n * A related item: its id, and a label to show it. The value of a relation field. Its card also\n * shows its `description` and its image, when the source gives them (decision 0067).\n */\nexport interface RelationReference {\n id: string;\n label: string;\n /** A line under the label: the related resource's `itemSubtitle`, as text. */\n description?: string;\n /** The URL of its image: the related resource's `itemImage` (decision 0061). */\n imageUrl?: string;\n}\n\n/** How a relation field shows the items of a resource, in its cards (decision 0067). */\nexport interface RelationResourceInfo {\n /** The name of the resource's icon, for items without an image. */\n icon?: string;\n /** Whether its items have an image (`itemImage`). */\n image?: boolean;\n /** Whether its items have a description (`itemSubtitle`). */\n description?: boolean;\n}\n\n/** Where relation fields search for items. */\nexport interface RelationSource {\n /** Items of a resource that match a text, for the picker. */\n search(\n resource: string,\n query: string,\n options: { signal: AbortSignal },\n ): Promise<RelationReference[]>;\n /**\n * The references of items by id, for values that are only ids (`\"12\"`, `[\"12\", \"13\"]`), as a\n * product's own API gives them. In any order; ids it doesn't find are left out, and keep their\n * id as label. Without it, fields show the ids.\n */\n resolve?(\n resource: string,\n ids: readonly string[],\n options: { signal: AbortSignal },\n ): Promise<RelationReference[]>;\n /**\n * Creates an item from the text typed in the picker, which offers \"Create “…”\" when this\n * method exists. It can open a dialog, and resolves with the reference of the new item, or with\n * `null` when nothing was created.\n */\n create?(resource: string, text: string): Promise<RelationReference | null>;\n /** Whether `create()` can create items of a resource. Defaults to true. */\n canCreate?(resource: string): boolean;\n /**\n * How the items of a resource show in their cards: its icon, and whether they have an image or\n * a description. When they do, references that come without them (`{ id, label }`, from items)\n * get them from `resolve()`.\n */\n describe?(resource: string): RelationResourceInfo | null;\n /** Where an item opens, for the link of its card. Without it, or `null`, the card has none. */\n getItemHref?(resource: string, id: string): string | null;\n}\n\n/** What `createRelationSource()` needs from an adapter: the `list()`, `get()` and `create()` of `@panneau/data`. */\nexport interface RelationListAdapter {\n list(\n resource: string,\n query?: ListQuery,\n options?: { signal?: AbortSignal },\n ): Promise<{ data: Item[] }>;\n /** One item, for `resolve()`. Without it, the source doesn't resolve ids. */\n get?(resource: string, id: string, options?: { signal?: AbortSignal }): Promise<Item>;\n /** Creates an item, for `create()`. */\n create?(resource: string, values: Record<string, unknown>): Promise<Item>;\n}\n\nexport interface RelationSourceOptions {\n /** The definition, for the field that titles the items of each resource (`itemTitle`). */\n definition?: (Pick<Definition, 'resources'> & Partial<Pick<Definition, 'locales'>>) | null;\n /** Items per search. Defaults to 20. */\n perPage?: number;\n /** The label of an item, when `itemTitle` isn't enough. */\n getLabel?: (item: Item, resource: string) => string;\n /**\n * Lets the picker create items, with the adapter's `create()`. `true` sets the typed text as the\n * value of the resource's `itemTitle` field (in every locale of the definition when it is\n * localized), on the resources that allow `create`. A function gives the values of the new item\n * instead, or `null` for a resource where items can't be created.\n */\n create?: boolean | ((text: string, resource: string) => Record<string, unknown> | null);\n /** Where an item opens, for the link of its card, such as its page in the app. */\n getItemHref?: (resource: string, id: string) => string | null;\n}\n\nfunction labelOf(value: unknown, locale?: string): string | null {\n if (typeof value === 'string' || typeof value === 'number') {\n return String(value);\n }\n if (value !== null && typeof value === 'object') {\n const localized = value as Record<string, unknown>;\n const first =\n (locale !== undefined ? localized[locale] : undefined) ?? Object.values(localized)[0];\n return typeof first === 'string' ? first : null;\n }\n return null;\n}\n\n/**\n * A relation source over an adapter, such as the `DataAdapter` of `@panneau/data`: a search is a\n * list query with `q`, ids are resolved with `get()`, and, with the `create` option, items are\n * created with `create()`. Labels come from the resource's `itemTitle`.\n */\nexport function createRelationSource(\n adapter: RelationListAdapter,\n { definition = null, perPage = 20, getLabel, create, getItemHref }: RelationSourceOptions = {},\n): RelationSource {\n const resourceOf = (resource: string) =>\n definition?.resources.find((candidate) => candidate.id === resource);\n const toReference = (item: Item, resource: string): RelationReference => {\n const definitionResource = resourceOf(resource);\n const titleField = definitionResource?.itemTitle;\n const subtitleField = definitionResource?.itemSubtitle;\n const imageField =\n definitionResource !== undefined ? getItemImageField(definitionResource) : undefined;\n const description = subtitleField !== undefined ? labelOf(item[subtitleField]) : null;\n const imageUrl = imageField !== undefined ? getImageUrl(item[imageField]) : null;\n return {\n id: item.id,\n label:\n getLabel?.(item, resource) ??\n (titleField !== undefined ? labelOf(item[titleField]) : null) ??\n item.id,\n ...(description !== null && description !== '' ? { description } : {}),\n ...(imageUrl !== null ? { imageUrl } : {}),\n };\n };\n const valuesOf = (text: string, resource: string): Record<string, unknown> | null => {\n if (typeof create === 'function') {\n return create(text, resource);\n }\n const definitionResource = resourceOf(resource);\n const titleField = definitionResource?.itemTitle;\n if (definitionResource === undefined || titleField === undefined) {\n return null;\n }\n const field = definitionResource.fields.find((candidate) => candidate.name === titleField);\n const locales = definition?.locales ?? [];\n return {\n [titleField]:\n field?.localized === true && locales.length > 0\n ? Object.fromEntries(locales.map((locale) => [locale, text]))\n : text,\n };\n };\n const source: RelationSource = {\n async search(resource, query, { signal }) {\n const response = await adapter.list(\n resource,\n { page: 1, perPage, ...(query !== '' ? { q: query } : {}) },\n { signal },\n );\n return response.data.map((item) => toReference(item, resource));\n },\n describe(resource) {\n const definitionResource = resourceOf(resource);\n if (definitionResource === undefined) {\n return null;\n }\n return {\n ...(definitionResource.icon !== undefined ? { icon: definitionResource.icon } : {}),\n image: getItemImageField(definitionResource) !== undefined,\n description: definitionResource.itemSubtitle !== undefined,\n };\n },\n };\n if (getItemHref !== undefined) {\n source.getItemHref = getItemHref;\n }\n const { get, create: createItem } = adapter;\n if (get !== undefined) {\n source.resolve = async (resource, ids, { signal }) => {\n const results = await Promise.allSettled(\n ids.map((id) => get.call(adapter, resource, id, { signal })),\n );\n return results.flatMap((result) =>\n result.status === 'fulfilled' ? [toReference(result.value, resource)] : [],\n );\n };\n }\n if (create !== undefined && create !== false && createItem !== undefined) {\n source.canCreate = (resource) =>\n resourceOf(resource)?.abilities?.create !== false && valuesOf('', resource) !== null;\n source.create = async (resource, text) => {\n const values = valuesOf(text, resource);\n if (values === null) {\n return null;\n }\n return toReference(await createItem.call(adapter, resource, values), resource);\n };\n }\n return source;\n}\n\n/** Reads relation values: references, ids, or lists of them. */\nexport function toReferences(value: unknown): RelationReference[] {\n const list = Array.isArray(value)\n ? value\n : value === null || value === undefined\n ? []\n : [value];\n return list.flatMap((entry: unknown) => {\n if (typeof entry === 'string' || typeof entry === 'number') {\n return [{ id: String(entry), label: String(entry) }];\n }\n if (entry !== null && typeof entry === 'object' && 'id' in entry) {\n const { id, label, description, imageUrl } = entry as {\n id: unknown;\n label?: unknown;\n description?: unknown;\n imageUrl?: unknown;\n };\n if (typeof id === 'string' || typeof id === 'number') {\n return [\n {\n id: String(id),\n label: typeof label === 'string' ? label : String(id),\n ...(typeof description === 'string' ? { description } : {}),\n ...(typeof imageUrl === 'string' ? { imageUrl } : {}),\n },\n ];\n }\n }\n return [];\n });\n}\n\ninterface ResolvedReferences {\n /** References by resource and id: `null` for ids that the source didn't find. */\n references: Map<string, RelationReference | null>;\n /** Requests in flight, so that fields with the same ids share one. */\n pending: Map<string, Promise<void>>;\n}\n\nconst resolved = new WeakMap<RelationSource, ResolvedReferences>();\n\nfunction resolvedOf(source: RelationSource): ResolvedReferences {\n let entry = resolved.get(source);\n if (entry === undefined) {\n entry = { references: new Map(), pending: new Map() };\n resolved.set(source, entry);\n }\n return entry;\n}\n\nconst keyOf = (resource: string, id: string) => `${resource}\\u0000${id}`;\n\n/** Resolves the ids that no request has resolved or is resolving yet, and waits for all of them. */\nfunction resolveIds(source: RelationSource, resource: string, ids: readonly string[]) {\n const { references, pending } = resolvedOf(source);\n const fresh = ids.filter((id) => !pending.has(keyOf(resource, id)));\n if (fresh.length > 0 && source.resolve !== undefined) {\n // Shared by every field that asks for these ids: it isn't aborted when one unmounts.\n const request = source\n .resolve(resource, fresh, { signal: new AbortController().signal })\n .then(\n (found) => {\n fresh.forEach((id) =>\n references.set(\n keyOf(resource, id),\n found.find((candidate) => candidate.id === id) ?? null,\n ),\n );\n },\n () => {\n // Tried again the next time a field shows these ids.\n fresh.forEach((id) => pending.delete(keyOf(resource, id)));\n },\n );\n fresh.forEach((id) => pending.set(keyOf(resource, id), request));\n }\n return Promise.all(ids.map((id) => pending.get(keyOf(resource, id))));\n}\n\n/**\n * Whether a reference needs `resolve()`: a plain id (its label is its id), or a reference without\n * the description or the image that the items of its resource have (decision 0067).\n */\nfunction needsResolving(reference: RelationReference, detailed: boolean): boolean {\n return (\n reference.label === reference.id ||\n (detailed && reference.description === undefined && reference.imageUrl === undefined)\n );\n}\n\n/**\n * Relation references with what the source knows of them: plain ids (`\"12\"`) get their labels, and\n * references of a resource whose items have a description or an image (`describe()`) get them, from\n * the source's `resolve()`, once per source, resource and id. They stay as they are until then, or\n * when the source doesn't find them.\n */\nexport function useRelationReferences(\n source: RelationSource | null,\n resource: string,\n references: readonly RelationReference[],\n): RelationReference[] {\n const cache = source !== null ? resolvedOf(source).references : null;\n const [found, setFound] = useState<Readonly<Record<string, RelationReference>>>({});\n const info = source?.describe?.(resource) ?? null;\n const detailed = info?.image === true || info?.description === true;\n const missing =\n source?.resolve !== undefined && cache !== null\n ? references\n .filter((reference) => needsResolving(reference, detailed))\n .map((reference) => reference.id)\n .filter((id) => !cache.has(keyOf(resource, id)))\n : [];\n const missingKey = missing.join('\\u0000');\n\n useEffect(() => {\n const ids = missingKey === '' ? [] : missingKey.split('\\u0000');\n if (source === null || cache === null || ids.length === 0) {\n return undefined;\n }\n let active = true;\n void resolveIds(source, resource, ids).then(() => {\n if (!active) {\n return;\n }\n const next: Record<string, RelationReference> = {};\n ids.forEach((id) => {\n const reference = cache.get(keyOf(resource, id));\n if (reference !== undefined && reference !== null) {\n next[keyOf(resource, id)] = reference;\n }\n });\n setFound((current) => ({ ...current, ...next }));\n });\n return () => {\n active = false;\n };\n }, [source, cache, resource, missingKey]);\n\n return references.map((reference) => {\n if (!needsResolving(reference, detailed)) {\n return reference;\n }\n const known =\n found[keyOf(resource, reference.id)] ?? cache?.get(keyOf(resource, reference.id));\n if (known === undefined || known === null) {\n return reference;\n }\n // What the value says wins: its label, from the item that references it\n return {\n ...known,\n ...reference,\n label: reference.label === reference.id ? known.label : reference.label,\n };\n });\n}\n"],"mappings":";;;;AA+FA,SAAS2C,QAAQC,OAAgBC,QAAgC;CAC7D,IAAI,OAAOD,UAAU,YAAY,OAAOA,UAAU,UAC9C,OAAOE,OAAOF,KAAK;CAEvB,IAAIA,UAAU,QAAQ,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SAAAF,EAAA,QAAAF,YAAAE,EAAA,QAAAR,SAAAQ,EAAA,QAAA/F,UAAA;GAEnBqH,MAAAC,gBAAA;IAClB,IAAI,CAAC3B,eAAeC,aAAWC,QAAQ,GAAC,OAC7BD;IAEX,MAAA2B,QACIhC,MAAMR,MAAM/E,UAAU4F,YAASrG,EAAG,MAAM0G,OAAKjF,IAAM+D,MAAM/E,UAAU4F,YAASrG,EAAG,CAAC;IACpF,IAAIgI,UAAUvF,KAAAA,KAAauF,UAAU,MAAI,OAC9B3B;IACV,OAEM;KAAA,GACA2B;KAAK,GACL3B;KAASpG,OACLoG,YAASpG,UAAWoG,YAASrG,KAAMgI,MAAK/H,QAASoG,YAASpG;IACrE;GAAC;GACJuG,EAAA,MAAAE;GAAAF,EAAA,MAAAF;GAAAE,EAAA,MAAAR;GAAAQ,EAAA,MAAA/F;GAAA+F,EAAA,MAAAsB;EAAA,OAAAA,KAAAtB,EAAA;EAfMqB,KAAA5C,WAAUlB,IAAK+D,EAerB;EAACtB,EAAA,MAAAE;EAAAF,EAAA,MAAAF;EAAAE,EAAA,MAAAR;EAAAQ,EAAA,MAAAvB;EAAAuB,EAAA,MAAA/F;EAAA+F,EAAA,MAAAqB;CAAA,OAAAA,KAAArB,EAAA;CAAA,OAfKqB;AAeL;AAzDC,SAAAX,MAAAe,aAAA;CAAA,OAa+B5B,YAASrG;AAAG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panneau/fields",
3
- "version": "5.0.0-alpha.20",
3
+ "version": "5.0.0-alpha.22",
4
4
  "description": "Controlled field components of Panneau for the protocol's built-in field types, one subpath per field, and uploads to storage (Uppy 6 in its own entry point).",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -218,9 +218,9 @@
218
218
  },
219
219
  "dependencies": {
220
220
  "@internationalized/date": "^3.12.4",
221
- "@panneau/intl": "5.0.0-alpha.20",
222
- "@panneau/protocol": "5.0.0-alpha.20",
223
- "@panneau/ui": "5.0.0-alpha.20",
221
+ "@panneau/intl": "5.0.0-alpha.22",
222
+ "@panneau/protocol": "5.0.0-alpha.22",
223
+ "@panneau/ui": "5.0.0-alpha.22",
224
224
  "leaflet": "^1.9.4",
225
225
  "libphonenumber-js": "^1.13.15",
226
226
  "lucide-react": "^1.57.0"