@burojs/ui-shadcn 0.7.0 → 0.8.0
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/dist/{bulk-summary-CrEij5vq.cjs → bulk-summary-2HLgz7Il.cjs} +31 -5
- package/dist/bulk-summary-2HLgz7Il.cjs.map +1 -0
- package/dist/{bulk-summary-BWSAS7k2.js → bulk-summary-D6A0ua21.js} +32 -6
- package/dist/bulk-summary-D6A0ua21.js.map +1 -0
- package/dist/{candidates-relation-picker-y5M6_oe4.cjs → candidates-relation-picker-C47mF260.cjs} +3 -3
- package/dist/{candidates-relation-picker-y5M6_oe4.cjs.map → candidates-relation-picker-C47mF260.cjs.map} +1 -1
- package/dist/{candidates-relation-picker-CS_JZ4Fd.js → candidates-relation-picker-CGXItMN0.js} +3 -3
- package/dist/{candidates-relation-picker-CS_JZ4Fd.js.map → candidates-relation-picker-CGXItMN0.js.map} +1 -1
- package/dist/{check-confirm-dialog-C-NHgMST.cjs → check-confirm-dialog-BT04Mieo.cjs} +13 -6
- package/dist/check-confirm-dialog-BT04Mieo.cjs.map +1 -0
- package/dist/{check-confirm-dialog-2j0gOd7x.js → check-confirm-dialog-CtiRzOAt.js} +14 -7
- package/dist/{check-confirm-dialog-2j0gOd7x.js.map → check-confirm-dialog-CtiRzOAt.js.map} +1 -1
- package/dist/{filter-builder-DFu0JP-1.cjs → filter-builder-ByGhxLf_.cjs} +127 -63
- package/dist/filter-builder-ByGhxLf_.cjs.map +1 -0
- package/dist/{filter-builder-DaWHUZuV.js → filter-builder-z3Axzf9Y.js} +114 -56
- package/dist/filter-builder-z3Axzf9Y.js.map +1 -0
- package/dist/{flow-runtime-BpmrIUb6.cjs → flow-runtime-BVFjMU5-.cjs} +6 -3
- package/dist/{flow-runtime-BpmrIUb6.cjs.map → flow-runtime-BVFjMU5-.cjs.map} +1 -1
- package/dist/{flow-runtime-DyqTmK3H.js → flow-runtime-DrUWyTS0.js} +6 -3
- package/dist/{flow-runtime-DyqTmK3H.js.map → flow-runtime-DrUWyTS0.js.map} +1 -1
- package/dist/{flow-screen-DCdli6Ha.js → flow-screen-3fk6J33y.js} +6 -4
- package/dist/flow-screen-3fk6J33y.js.map +1 -0
- package/dist/{flow-screen-Bcz9NF2V.cjs → flow-screen-6y5E_HT6.cjs} +5 -3
- package/dist/flow-screen-6y5E_HT6.cjs.map +1 -0
- package/dist/index.cjs +518 -107
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +187 -86
- package/dist/index.d.ts +187 -86
- package/dist/index.js +519 -108
- package/dist/index.js.map +1 -1
- package/dist/{inline-flow-host-3vw7LzzD.cjs → inline-flow-host-C4KmZIYE.cjs} +3 -3
- package/dist/{inline-flow-host-3vw7LzzD.cjs.map → inline-flow-host-C4KmZIYE.cjs.map} +1 -1
- package/dist/{inline-flow-host-C0rI9B7f.js → inline-flow-host-YnnvWjdU.js} +3 -3
- package/dist/{inline-flow-host-C0rI9B7f.js.map → inline-flow-host-YnnvWjdU.js.map} +1 -1
- package/dist/{lazy-relation-picker-dialog-Bt8lrEIu.cjs → lazy-relation-picker-dialog-BAKBRn3V.cjs} +2 -2
- package/dist/{lazy-relation-picker-dialog-Bt8lrEIu.cjs.map → lazy-relation-picker-dialog-BAKBRn3V.cjs.map} +1 -1
- package/dist/{lazy-relation-picker-dialog-CAScLPb2.js → lazy-relation-picker-dialog-DN4bvQfg.js} +2 -2
- package/dist/{lazy-relation-picker-dialog-CAScLPb2.js.map → lazy-relation-picker-dialog-DN4bvQfg.js.map} +1 -1
- package/dist/{page-flow-route-BHUEpn0I.js → page-flow-route-CtEfqAvU.js} +5 -6
- package/dist/page-flow-route-CtEfqAvU.js.map +1 -0
- package/dist/{page-flow-route-DS8IVTVH.cjs → page-flow-route-DEjAxHe3.cjs} +6 -7
- package/dist/page-flow-route-DEjAxHe3.cjs.map +1 -0
- package/dist/{place-node-CfzQvh4Y.js → place-node-BdxT-30h.js} +149 -108
- package/dist/place-node-BdxT-30h.js.map +1 -0
- package/dist/{place-node-CNb3w-c7.cjs → place-node-Bhl8B3fF.cjs} +163 -134
- package/dist/place-node-Bhl8B3fF.cjs.map +1 -0
- package/dist/{related-list-cards-CelMxl4q.cjs → related-list-cards-Bc_vfCE_.cjs} +3 -3
- package/dist/{related-list-cards-CelMxl4q.cjs.map → related-list-cards-Bc_vfCE_.cjs.map} +1 -1
- package/dist/{related-list-cards-BIqqY69Y.js → related-list-cards-BvkD5OcC.js} +3 -3
- package/dist/{related-list-cards-BIqqY69Y.js.map → related-list-cards-BvkD5OcC.js.map} +1 -1
- package/dist/related-list-timeline-DCrwN9oO.js +167 -0
- package/dist/related-list-timeline-DCrwN9oO.js.map +1 -0
- package/dist/related-list-timeline-k0DtnxTs.cjs +167 -0
- package/dist/related-list-timeline-k0DtnxTs.cjs.map +1 -0
- package/dist/{related-rows-MPnLCmPF.cjs → related-rows-BW9Jr07T.cjs} +3 -3
- package/dist/{related-rows-MPnLCmPF.cjs.map → related-rows-BW9Jr07T.cjs.map} +1 -1
- package/dist/{related-rows--uP2iKQC.js → related-rows-CPE-9FFr.js} +3 -3
- package/dist/{related-rows--uP2iKQC.js.map → related-rows-CPE-9FFr.js.map} +1 -1
- package/dist/{relation-many-picker-BJhaEqxz.js → relation-many-picker-BlrGRwMV.js} +10 -5
- package/dist/relation-many-picker-BlrGRwMV.js.map +1 -0
- package/dist/{relation-many-picker-DzuGJpEl.cjs → relation-many-picker-Br-zBHxT.cjs} +10 -5
- package/dist/relation-many-picker-Br-zBHxT.cjs.map +1 -0
- package/dist/{relation-picker-DaIMzf2H.cjs → relation-picker-ADjxI_TI.cjs} +11 -6
- package/dist/relation-picker-ADjxI_TI.cjs.map +1 -0
- package/dist/{relation-picker-dialog-DoEY8EkH.js → relation-picker-dialog-CyKliBkN.js} +2 -2
- package/dist/{relation-picker-dialog-DoEY8EkH.js.map → relation-picker-dialog-CyKliBkN.js.map} +1 -1
- package/dist/{relation-picker-dialog-9Vg5vvR1.cjs → relation-picker-dialog-DimVQF9Y.cjs} +2 -2
- package/dist/{relation-picker-dialog-9Vg5vvR1.cjs.map → relation-picker-dialog-DimVQF9Y.cjs.map} +1 -1
- package/dist/{relation-picker-D-tBBZW_.js → relation-picker-x7P5HKie.js} +11 -6
- package/dist/relation-picker-x7P5HKie.js.map +1 -0
- package/dist/{resource-page-router-Diw6S6TK.js → resource-page-router-BRpUnhay.js} +144 -17
- package/dist/resource-page-router-BRpUnhay.js.map +1 -0
- package/dist/{resource-page-router-C_kGW2o_.cjs → resource-page-router-qEd2xb55.cjs} +158 -19
- package/dist/resource-page-router-qEd2xb55.cjs.map +1 -0
- package/dist/use-record-subtitle-bfwIoUme.cjs +70 -0
- package/dist/use-record-subtitle-bfwIoUme.cjs.map +1 -0
- package/dist/use-record-subtitle-gIaCGgbI.js +53 -0
- package/dist/use-record-subtitle-gIaCGgbI.js.map +1 -0
- package/package.json +9 -9
- package/dist/bulk-summary-BWSAS7k2.js.map +0 -1
- package/dist/bulk-summary-CrEij5vq.cjs.map +0 -1
- package/dist/check-confirm-dialog-C-NHgMST.cjs.map +0 -1
- package/dist/filter-builder-DFu0JP-1.cjs.map +0 -1
- package/dist/filter-builder-DaWHUZuV.js.map +0 -1
- package/dist/flow-screen-Bcz9NF2V.cjs.map +0 -1
- package/dist/flow-screen-DCdli6Ha.js.map +0 -1
- package/dist/page-flow-route-BHUEpn0I.js.map +0 -1
- package/dist/page-flow-route-DS8IVTVH.cjs.map +0 -1
- package/dist/place-node-CNb3w-c7.cjs.map +0 -1
- package/dist/place-node-CfzQvh4Y.js.map +0 -1
- package/dist/related-list-timeline-CRh7xwLD.js +0 -141
- package/dist/related-list-timeline-CRh7xwLD.js.map +0 -1
- package/dist/related-list-timeline-DsLdi8sv.cjs +0 -141
- package/dist/related-list-timeline-DsLdi8sv.cjs.map +0 -1
- package/dist/relation-many-picker-BJhaEqxz.js.map +0 -1
- package/dist/relation-many-picker-DzuGJpEl.cjs.map +0 -1
- package/dist/relation-picker-D-tBBZW_.js.map +0 -1
- package/dist/relation-picker-DaIMzf2H.cjs.map +0 -1
- package/dist/resource-page-router-C_kGW2o_.cjs.map +0 -1
- package/dist/resource-page-router-Diw6S6TK.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"related-rows--uP2iKQC.js","names":[],"sources":["../src/blocks/default-item.tsx","../src/blocks/related-rows.tsx"],"sourcesContent":["'use client';\nimport {\n type ColumnEntry,\n columnName,\n type EntityRef,\n resolveFieldLabel,\n declaredText,\n} from '@burojs/core';\nimport { useApp, useI18nCaps } from '@burojs/react';\nimport { Fragment, type ReactElement } from 'react';\nimport { toDisplayText } from '../fields/display-value.js';\nimport { FieldValueFrame } from '../fields/field-value-frame.js';\nimport { ResolvedFieldDisplay } from '../fields/resolved-field.js';\nimport {\n type PeekFieldSource,\n peekFieldDefinition,\n peekLeafAllowed,\n} from '../quick/peek-filter.js';\nimport { recordDisplayName } from '../resource/record-display-name.js';\nimport { type ListRow, useRowAccess, useViewVisible } from './related-rows.js';\n\n/** What a default item reads of the target's definition. */\ninterface TargetDefinition extends PeekFieldSource {\n readonly views?: { readonly list?: { readonly columns?: readonly ColumnEntry[] } };\n readonly ref?: EntityRef;\n}\n\n/** A field the default item puts in its trailing part: a number reads best right-aligned. */\nconst isNumeric = (field: { readonly kind?: unknown } | undefined) => field?.kind === 'number';\n\n/**\n * The item of a related list that names none (P6 3.13). As a card: the row's title (weight 500),\n * its other fields as muted label / value pairs, and its numbers in a trailing part set off by a\n * rule. As a timeline entry (`variant: 'entry'`): the title and the field values on one muted\n * meta line. `row` is the projected row, so a field the viewer may not see is already `null` and\n * is not listed.\n */\nexport function DefaultItem({\n resource,\n row,\n raw,\n columns,\n variant = 'card',\n}: {\n readonly resource: string;\n readonly row: Readonly<Record<string, unknown>>;\n /** The row as the list read it: column rules resolve over it. */\n readonly raw: ListRow;\n readonly columns?: readonly string[] | undefined;\n readonly variant?: 'card' | 'entry';\n}): ReactElement {\n const app = useApp();\n const def = app.registry.get(resource) as TargetDefinition | undefined;\n const caps = useI18nCaps(resource);\n const access = useRowAccess(resource)(raw);\n const viewVisible = useViewVisible(resource);\n const fields =\n def === undefined\n ? []\n : (columns ?? def.views?.list?.columns?.map(columnName) ?? Object.keys(def.fields)).filter(\n (name, index, names) =>\n name !== def.displayField &&\n names.indexOf(name) === index &&\n peekLeafAllowed(def, name, access, viewVisible),\n );\n const ref = def?.ref ?? { namespace: 'default', id: resource };\n const definition = (name: string) =>\n peekFieldDefinition(def!, name) as { readonly label?: string; readonly kind?: unknown };\n // A card draws the `card` surface (`ui.card` applies, REF-117 §4.13); a timeline entry is a\n // record display, so it reads `ui.display` alone.\n const surface = variant === 'card' ? 'card' : 'display';\n const value = (name: string) => (\n <FieldValueFrame\n field={{ ...(definition(name) as object), name }}\n value={row[name]}\n surface={surface}\n >\n <ResolvedFieldDisplay\n resource={ref}\n name={name}\n field={definition(name) as never}\n value={row[name]}\n record={row}\n uiSurface={surface}\n fallback={toDisplayText(row[name]).text}\n />\n </FieldValueFrame>\n );\n const title = (\n <p className=\"truncate text-sm font-medium\">{recordDisplayName(row, def?.displayField)}</p>\n );\n if (variant === 'entry') {\n const shown = fields.filter((name) => row[name] != null && row[name] !== '');\n return (\n <div className=\"flex min-w-0 flex-col gap-0.5\" data-buro-default-item=\"\">\n {title}\n {shown.length === 0 ? null : (\n <div data-buro-item-meta=\"\" className=\"truncate text-xs text-muted-foreground\">\n {shown.map((name, index) => (\n <Fragment key={name}>\n {index > 0 ? ' · ' : null}\n {value(name)}\n </Fragment>\n ))}\n </div>\n )}\n </div>\n );\n }\n const numbers = fields.filter((name) => isNumeric(definition(name)));\n const pairs = fields.filter((name) => !isNumeric(definition(name)));\n return (\n <div className=\"flex min-w-0 items-start gap-3\" data-buro-default-item=\"\">\n <div className=\"flex min-w-0 flex-1 flex-col gap-2\">\n {title}\n {pairs.length === 0 ? null : (\n <dl className=\"grid gap-1.5\">\n {pairs.map((name) => (\n <div key={name} className=\"flex min-w-0 items-baseline gap-2 text-sm\">\n <dt className=\"w-24 shrink-0 truncate text-xs text-muted-foreground\">\n {resolveFieldLabel(caps, name, declaredText('field', definition(name), 'label'))}\n </dt>\n <dd className=\"min-w-0 break-words\">{value(name)}</dd>\n </div>\n ))}\n </dl>\n )}\n </div>\n {numbers.length === 0 ? null : (\n <div\n data-buro-item-trailing=\"\"\n className=\"flex shrink-0 flex-col items-end gap-1 border-l pl-3 text-sm tabular-nums\"\n >\n {numbers.map((name) => (\n <span\n key={name}\n title={resolveFieldLabel(\n caps,\n name,\n declaredText('field', definition(name), 'label'),\n )}\n >\n {value(name)}\n </span>\n ))}\n </div>\n )}\n </div>\n );\n}\n","'use client';\nimport { type AppContext, RECORD_PROBE, resolveCapability, ruleContextFor } from '@burojs/core';\nimport {\n type CapabilityResolver,\n useApp,\n useCtx,\n scopeValueOf,\n useFieldAccess,\n useScopeSource,\n useViewRow,\n} from '@burojs/react';\nimport { type ReactElement, type ReactNode, useCallback, useMemo } from 'react';\nimport { QUICK_ANCHOR_ATTRIBUTE } from '@burojs/react';\nimport { ClaimedQuickLink, isPlainLeftClick } from '../fields/claimed-quick-link.js';\nimport { useLinkComponent } from '../layout/link-component.js';\nimport { type PeekFieldSource, peekLeafAllowed, peekRow } from '../quick/peek-filter.js';\nimport { recordDisplayName } from '../resource/record-display-name.js';\nimport { DefaultItem } from './default-item.js';\nimport { type ItemHandle, RelatedItem, useItemDrawn } from './related-item.js';\n\nexport type ListRow = { readonly id: string } & Readonly<Record<string, unknown>>;\n\n/** What `related-list` hands a rows view: the list's rows and how a row opens. */\nexport interface RelatedRowsProps {\n /** The target resource. */\n readonly resource: string;\n /** The placement's key (test ids). */\n readonly placementKey: string;\n readonly rows: readonly ListRow[];\n readonly item?: ItemHandle | undefined;\n /** The placement's `columns`, for the default item. */\n readonly columns?: readonly string[] | undefined;\n readonly rowQuick?: ((row: ListRow) => (() => void) | null) | undefined;\n readonly rowHref?: ((row: ListRow) => string | undefined) | undefined;\n /** The placement's `empty` text, drawn when there is no row to draw. */\n readonly empty?: string;\n}\n\n/**\n * A capability resolver per row: column rules resolve over the row they hide a field of, as the\n * peek's do (P6-B review), so a rule reading the record sees this row.\n */\nexport function useRowAccess(resource: string): (row: ListRow) => CapabilityResolver {\n const app = useApp();\n // `ctx.scope` (7d Q3): the record frames around the rows (the card), then the selection; a\n // row's own value is not read, as on a list.\n const scope = scopeValueOf(useScopeSource({ mode: 'record' }));\n const user = useCtx((c: AppContext) => c.user);\n const permissions = useCtx((c: AppContext) => c.permissions);\n return useCallback(\n (row) =>\n (capability, target, defaultAllowed = true) => {\n const rules = app.ruleSource.rules(resource);\n if (rules.length === 0) return { allowed: defaultAllowed };\n const ctx = ruleContextFor({\n user,\n scope: scope as never,\n permissions,\n record: row,\n mode: 'show',\n resource,\n });\n return resolveCapability(rules, capability, target, ctx, defaultAllowed);\n },\n [app.ruleSource, resource, scope, user, permissions],\n );\n}\n\n/**\n * Whether a field may be drawn on every row by its P5 view (P5 spec 3.6.6): a decision that is\n * not `visible` (`hidden`, `restricted`, `failed` and `pending` alike, so nothing is drawn while\n * the permission map loads) withholds it. A field the map does not decide is not withheld here. The decision\n * is the any-record one ({@link RECORD_PROBE}), so a rule reading the record counts as hiding.\n */\nexport function useViewVisible(resource: string): (field: string) => boolean {\n const access = useFieldAccess(resource, 'every');\n return useCallback(\n (field) => {\n const decision = access[field];\n return decision === undefined || decision.view === 'visible';\n },\n [access],\n );\n}\n\ninterface ProjectedRows {\n readonly def:\n | (PeekFieldSource & { readonly displayField?: string; readonly data?: unknown })\n | undefined;\n /** The row a card or an entry sees: the id and what the viewer may see; the rest read `null`. */\n readonly project: (row: ListRow) => ListRow;\n /** Whether the item block is drawn (decided once for the list), else the default item. */\n readonly drawn: boolean;\n readonly title: (row: ListRow) => string;\n}\n\n/**\n * The rows of a cards or timeline view, projected once and the item decided once per list.\n *\n * The rows arrive as the list read them (policy). A row is first projected by P5's field view\n * (`viewRow`: a field its user may not view for every row is left out) and then by the peek's\n * rule ({@link peekRow}): the id field and every field that is not `sensitive`, not withheld by\n * a field `requires.view` and not hidden by a `column` rule keep their values; every other\n * field reads `null`. It is the one place a row's fields are filtered before an item block or\n * the default item sees them (P6-66), and the timeline's axis reads the same row.\n */\nexport function useProjectedRows(\n resource: string,\n rows: readonly ListRow[],\n item: ItemHandle | undefined,\n): ProjectedRows {\n const app = useApp();\n const def = app.registry.get(resource) as ProjectedRows['def'];\n const accessOf = useRowAccess(resource);\n const viewRow = useViewRow(resource);\n const viewVisible = useViewVisible(resource);\n const idField = (def?.data as { readonly idField?: string } | undefined)?.idField ?? 'id';\n const project = useCallback(\n (row: ListRow): ListRow =>\n (def === undefined\n ? viewRow(row)\n : peekRow(def, viewRow(row), idField, accessOf(row), viewVisible)) as ListRow,\n [def, idField, accessOf, viewRow, viewVisible],\n );\n const hidden = useCallback(\n (field: string) =>\n field !== idField &&\n (def === undefined ||\n !peekLeafAllowed(def, field, accessOf(RECORD_PROBE as ListRow), viewVisible)),\n [def, idField, accessOf, viewVisible],\n );\n const probe = useMemo(\n () => (rows[0] === undefined ? undefined : project(rows[0])),\n [rows, project],\n );\n const drawn = useItemDrawn(item, hidden, probe);\n const title = useCallback(\n (row: ListRow) => recordDisplayName(project(row), def?.displayField),\n [project, def],\n );\n return { def, project, drawn, title };\n}\n\n/** The item block (or the default item) of one row. */\nexport function RowContent({\n resource,\n raw,\n row,\n item,\n drawn,\n columns,\n variant,\n}: {\n readonly resource: string;\n /** The row as the list read it (column rules resolve over it). */\n readonly raw: ListRow;\n /** The projected row. */\n readonly row: ListRow;\n readonly item: ItemHandle | undefined;\n readonly drawn: boolean;\n readonly columns?: readonly string[] | undefined;\n /** How the default item lays the row out: a card's, or a timeline entry's. */\n readonly variant?: 'card' | 'entry';\n}): ReactElement {\n const fallback = (\n <DefaultItem\n resource={resource}\n row={row}\n raw={raw}\n columns={columns}\n {...(variant === undefined ? {} : { variant })}\n />\n );\n if (item === undefined || !drawn) return fallback;\n return <RelatedItem handle={item} row={row} fallback={fallback} />;\n}\n\n/**\n * A card's or an entry's one opener (P6-74): the row's title as the accessible name of a single\n * anchor whose `::after` covers the positioned parent. A quick row is the page anchor claimed\n * for the opener (a modified click follows the `href`), or a link-role button without a page.\n * `open: 'none'` draws nothing.\n */\nexport function RowOpener({\n title,\n href,\n quick,\n}: {\n readonly title: string;\n readonly href: string | undefined;\n readonly quick: (() => void) | null;\n}): ReactElement | null {\n const RouterLink = useLinkComponent();\n const className =\n 'outline-none after:absolute after:inset-0 after:rounded-[inherit] focus-visible:after:ring-2 focus-visible:after:ring-ring';\n const name: ReactNode = <span className=\"sr-only\">{title}</span>;\n if (quick !== null)\n return href ? (\n <ClaimedQuickLink href={href} className={className} onOpen={quick}>\n {name}\n </ClaimedQuickLink>\n ) : (\n <button\n type=\"button\"\n role=\"link\"\n {...{ [QUICK_ANCHOR_ATTRIBUTE]: '' }}\n // A button is inline-block, so even with only an `sr-only` name it took a line of the\n // card and pushed the content down (REF-40). Zero-size and unpositioned, its `::after`\n // still covers the card.\n className={`${className} block size-0 p-0`}\n onClick={(event) => {\n if (!isPlainLeftClick(event)) return;\n quick();\n }}\n >\n {name}\n </button>\n );\n if (href)\n return (\n <RouterLink href={href} className={className}>\n {name}\n </RouterLink>\n );\n return null;\n}\n\n/**\n * The wrapper that raises an item's interactive descendants above the opener's cover (P6-74):\n * the wrapper itself lets clicks through to the opener, its controls take them.\n */\nexport const ITEM_LAYER_CLASS =\n 'relative z-[1] pointer-events-none [&_a]:pointer-events-auto [&_button]:pointer-events-auto [&_input]:pointer-events-auto [&_select]:pointer-events-auto [&_textarea]:pointer-events-auto [&_summary]:pointer-events-auto [&_[role=button]]:pointer-events-auto [&_[role=link]]:pointer-events-auto [&_[role=checkbox]]:pointer-events-auto [&_[role=switch]]:pointer-events-auto';\n"],"mappings":";;;;;;;;;AA4BA,MAAM,aAAa,UAAmD,OAAO,SAAS;AAStF,SAAgB,YAAY,EAC1B,UACA,KACA,KACA,SACA,UAA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GAAG,KAAK,YAAY,GACnE,CAAC,SAAS,GAAG,CAEmB;CAAE;AACtC;AAGA,SAAgB,WAAW,EACzB,UACA,KACA,KACA,MACA,OACA,SACA,WAYe;CACf,MAAM,WACJ,IAAC,aAAD;EACY;EACL;EACA;EACI;EACT,GAAK,YAAY,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ;CAC7C,CAAA;CAEH,IAAI,SAAS,KAAA,KAAa,CAAC,OAAO,OAAO;CACzC,OAAO,IAAC,aAAD;EAAa,QAAQ;EAAW;EAAe;CAAW,CAAA;AACnE;AAQA,SAAgB,UAAU,EACxB,OACA,MACA,SAKsB;CACtB,MAAM,aAAa,iBAAiB;CACpC,MAAM,YACJ;CACF,MAAM,OAAkB,IAAC,QAAD;EAAM,WAAU;EAAW,UAAA;CAAY,CAAA;CAC/D,IAAI,UAAU,MACZ,OAAO,OACL,IAAC,kBAAD;EAAwB;EAAiB;EAAW,QAAQ;EACzD,UAAA;CACe,CAAA,IAElB,IAAC,UAAD;EACE,MAAK;EACL,MAAK;GACE,yBAAyB;EAIhC,WAAW,GAAG,UAAU;EACxB,UAAU,UAAU;GAClB,IAAI,CAAC,iBAAiB,KAAK,GAAG;GAC9B,MAAM;EACR;EAEC,UAAA;CACK,CAAA;CAEZ,IAAI,MACF,OACE,IAAC,YAAD;EAAkB;EAAiB;EAChC,UAAA;CACS,CAAA;CAEhB,OAAO;AACT;AAMA,MAAa,mBACX"}
|
|
1
|
+
{"version":3,"file":"related-rows-CPE-9FFr.js","names":[],"sources":["../src/blocks/default-item.tsx","../src/blocks/related-rows.tsx"],"sourcesContent":["'use client';\nimport {\n type ColumnEntry,\n columnName,\n type EntityRef,\n resolveFieldLabel,\n declaredText,\n} from '@burojs/core';\nimport { useApp, useI18nCaps } from '@burojs/react';\nimport { Fragment, type ReactElement } from 'react';\nimport { toDisplayText } from '../fields/display-value.js';\nimport { FieldValueFrame } from '../fields/field-value-frame.js';\nimport { ResolvedFieldDisplay } from '../fields/resolved-field.js';\nimport {\n type PeekFieldSource,\n peekFieldDefinition,\n peekLeafAllowed,\n} from '../quick/peek-filter.js';\nimport { recordDisplayName } from '../resource/record-display-name.js';\nimport { type ListRow, useRowAccess, useViewVisible } from './related-rows.js';\n\n/** What a default item reads of the target's definition. */\ninterface TargetDefinition extends PeekFieldSource {\n readonly views?: { readonly list?: { readonly columns?: readonly ColumnEntry[] } };\n readonly ref?: EntityRef;\n}\n\n/** A field the default item puts in its trailing part: a number reads best right-aligned. */\nconst isNumeric = (field: { readonly kind?: unknown } | undefined) => field?.kind === 'number';\n\n/**\n * The item of a related list that names none (P6 3.13). As a card: the row's title (weight 500),\n * its other fields as muted label / value pairs, and its numbers in a trailing part set off by a\n * rule. As a timeline entry (`variant: 'entry'`): the title and the field values on one muted\n * meta line. `row` is the projected row, so a field the viewer may not see is already `null` and\n * is not listed.\n */\nexport function DefaultItem({\n resource,\n row,\n raw,\n columns,\n variant = 'card',\n}: {\n readonly resource: string;\n readonly row: Readonly<Record<string, unknown>>;\n /** The row as the list read it: column rules resolve over it. */\n readonly raw: ListRow;\n readonly columns?: readonly string[] | undefined;\n readonly variant?: 'card' | 'entry';\n}): ReactElement {\n const app = useApp();\n const def = app.registry.get(resource) as TargetDefinition | undefined;\n const caps = useI18nCaps(resource);\n const access = useRowAccess(resource)(raw);\n const viewVisible = useViewVisible(resource);\n const fields =\n def === undefined\n ? []\n : (columns ?? def.views?.list?.columns?.map(columnName) ?? Object.keys(def.fields)).filter(\n (name, index, names) =>\n name !== def.displayField &&\n names.indexOf(name) === index &&\n peekLeafAllowed(def, name, access, viewVisible),\n );\n const ref = def?.ref ?? { namespace: 'default', id: resource };\n const definition = (name: string) =>\n peekFieldDefinition(def!, name) as { readonly label?: string; readonly kind?: unknown };\n // A card draws the `card` surface (`ui.card` applies, REF-117 §4.13); a timeline entry is a\n // record display, so it reads `ui.display` alone.\n const surface = variant === 'card' ? 'card' : 'display';\n const value = (name: string) => (\n <FieldValueFrame\n field={{ ...(definition(name) as object), name }}\n value={row[name]}\n surface={surface}\n >\n <ResolvedFieldDisplay\n resource={ref}\n name={name}\n field={definition(name) as never}\n value={row[name]}\n record={row}\n uiSurface={surface}\n fallback={toDisplayText(row[name]).text}\n />\n </FieldValueFrame>\n );\n const title = (\n <p className=\"truncate text-sm font-medium\">{recordDisplayName(row, def?.displayField)}</p>\n );\n if (variant === 'entry') {\n const shown = fields.filter((name) => row[name] != null && row[name] !== '');\n return (\n <div className=\"flex min-w-0 flex-col gap-0.5\" data-buro-default-item=\"\">\n {title}\n {shown.length === 0 ? null : (\n <div data-buro-item-meta=\"\" className=\"truncate text-xs text-muted-foreground\">\n {shown.map((name, index) => (\n <Fragment key={name}>\n {index > 0 ? ' · ' : null}\n {value(name)}\n </Fragment>\n ))}\n </div>\n )}\n </div>\n );\n }\n const numbers = fields.filter((name) => isNumeric(definition(name)));\n const pairs = fields.filter((name) => !isNumeric(definition(name)));\n return (\n <div className=\"flex min-w-0 items-start gap-3\" data-buro-default-item=\"\">\n <div className=\"flex min-w-0 flex-1 flex-col gap-2\">\n {title}\n {pairs.length === 0 ? null : (\n <dl className=\"grid gap-1.5\">\n {pairs.map((name) => (\n <div key={name} className=\"flex min-w-0 items-baseline gap-2 text-sm\">\n <dt className=\"w-24 shrink-0 truncate text-xs text-muted-foreground\">\n {resolveFieldLabel(caps, name, declaredText('field', definition(name), 'label'))}\n </dt>\n <dd className=\"min-w-0 break-words\">{value(name)}</dd>\n </div>\n ))}\n </dl>\n )}\n </div>\n {numbers.length === 0 ? null : (\n <div\n data-buro-item-trailing=\"\"\n className=\"flex shrink-0 flex-col items-end gap-1 border-l pl-3 text-sm tabular-nums\"\n >\n {numbers.map((name) => (\n <span\n key={name}\n title={resolveFieldLabel(\n caps,\n name,\n declaredText('field', definition(name), 'label'),\n )}\n >\n {value(name)}\n </span>\n ))}\n </div>\n )}\n </div>\n );\n}\n","'use client';\nimport { type AppContext, RECORD_PROBE, resolveCapability, ruleContextFor } from '@burojs/core';\nimport {\n type CapabilityResolver,\n useApp,\n useCtx,\n scopeValueOf,\n useFieldAccess,\n useScopeSource,\n useViewRow,\n} from '@burojs/react';\nimport { type ReactElement, type ReactNode, useCallback, useMemo } from 'react';\nimport { QUICK_ANCHOR_ATTRIBUTE } from '@burojs/react';\nimport { ClaimedQuickLink, isPlainLeftClick } from '../fields/claimed-quick-link.js';\nimport { useLinkComponent } from '../layout/link-component.js';\nimport { type PeekFieldSource, peekLeafAllowed, peekRow } from '../quick/peek-filter.js';\nimport { recordDisplayName } from '../resource/record-display-name.js';\nimport { DefaultItem } from './default-item.js';\nimport { type ItemHandle, RelatedItem, useItemDrawn } from './related-item.js';\n\nexport type ListRow = { readonly id: string } & Readonly<Record<string, unknown>>;\n\n/** What `related-list` hands a rows view: the list's rows and how a row opens. */\nexport interface RelatedRowsProps {\n /** The target resource. */\n readonly resource: string;\n /** The placement's key (test ids). */\n readonly placementKey: string;\n readonly rows: readonly ListRow[];\n readonly item?: ItemHandle | undefined;\n /** The placement's `columns`, for the default item. */\n readonly columns?: readonly string[] | undefined;\n readonly rowQuick?: ((row: ListRow) => (() => void) | null) | undefined;\n readonly rowHref?: ((row: ListRow) => string | undefined) | undefined;\n /** The placement's `empty` text, drawn when there is no row to draw. */\n readonly empty?: string;\n}\n\n/**\n * A capability resolver per row: column rules resolve over the row they hide a field of, as the\n * peek's do (P6-B review), so a rule reading the record sees this row.\n */\nexport function useRowAccess(resource: string): (row: ListRow) => CapabilityResolver {\n const app = useApp();\n // `ctx.scope` (7d Q3): the record frames around the rows (the card), then the selection; a\n // row's own value is not read, as on a list.\n const scope = scopeValueOf(useScopeSource({ mode: 'record' }));\n const user = useCtx((c: AppContext) => c.user);\n const permissions = useCtx((c: AppContext) => c.permissions);\n return useCallback(\n (row) =>\n (capability, target, defaultAllowed = true) => {\n const rules = app.ruleSource.rules(resource);\n if (rules.length === 0) return { allowed: defaultAllowed };\n const ctx = ruleContextFor({\n user,\n scope: scope as never,\n permissions,\n record: row,\n mode: 'show',\n resource,\n });\n return resolveCapability(rules, capability, target, ctx, defaultAllowed);\n },\n [app.ruleSource, resource, scope, user, permissions],\n );\n}\n\n/**\n * Whether a field may be drawn on every row by its P5 view (P5 spec 3.6.6): a decision that is\n * not `visible` (`hidden`, `restricted`, `failed` and `pending` alike, so nothing is drawn while\n * the permission map loads) withholds it. A field the map does not decide is not withheld here. The decision\n * is the any-record one ({@link RECORD_PROBE}), so a rule reading the record counts as hiding.\n */\nexport function useViewVisible(resource: string): (field: string) => boolean {\n const access = useFieldAccess(resource, 'every');\n return useCallback(\n (field) => {\n const decision = access[field];\n return decision === undefined || decision.view === 'visible';\n },\n [access],\n );\n}\n\ninterface ProjectedRows {\n readonly def:\n | (PeekFieldSource & { readonly displayField?: string; readonly data?: unknown })\n | undefined;\n /** The row a card or an entry sees: the id and what the viewer may see; the rest read `null`. */\n readonly project: (row: ListRow) => ListRow;\n /** Whether the item block is drawn (decided once for the list), else the default item. */\n readonly drawn: boolean;\n readonly title: (row: ListRow) => string;\n}\n\n/**\n * The rows of a cards or timeline view, projected once and the item decided once per list.\n *\n * The rows arrive as the list read them (policy). A row is first projected by P5's field view\n * (`viewRow`: a field its user may not view for every row is left out) and then by the peek's\n * rule ({@link peekRow}): the id field and every field that is not `sensitive`, not withheld by\n * a field `requires.view` and not hidden by a `column` rule keep their values; every other\n * field reads `null`. It is the one place a row's fields are filtered before an item block or\n * the default item sees them (P6-66), and the timeline's axis reads the same row.\n */\nexport function useProjectedRows(\n resource: string,\n rows: readonly ListRow[],\n item: ItemHandle | undefined,\n): ProjectedRows {\n const app = useApp();\n const def = app.registry.get(resource) as ProjectedRows['def'];\n const accessOf = useRowAccess(resource);\n const viewRow = useViewRow(resource);\n const viewVisible = useViewVisible(resource);\n const idField = (def?.data as { readonly idField?: string } | undefined)?.idField ?? 'id';\n const project = useCallback(\n (row: ListRow): ListRow =>\n (def === undefined\n ? viewRow(row)\n : peekRow(def, viewRow(row), idField, accessOf(row), viewVisible)) as ListRow,\n [def, idField, accessOf, viewRow, viewVisible],\n );\n const hidden = useCallback(\n (field: string) =>\n field !== idField &&\n (def === undefined ||\n !peekLeafAllowed(def, field, accessOf(RECORD_PROBE as ListRow), viewVisible)),\n [def, idField, accessOf, viewVisible],\n );\n const probe = useMemo(\n () => (rows[0] === undefined ? undefined : project(rows[0])),\n [rows, project],\n );\n const drawn = useItemDrawn(item, hidden, probe);\n const title = useCallback(\n (row: ListRow) => recordDisplayName(project(row), def?.displayField),\n [project, def],\n );\n return { def, project, drawn, title };\n}\n\n/** The item block (or the default item) of one row. */\nexport function RowContent({\n resource,\n raw,\n row,\n item,\n drawn,\n columns,\n variant,\n}: {\n readonly resource: string;\n /** The row as the list read it (column rules resolve over it). */\n readonly raw: ListRow;\n /** The projected row. */\n readonly row: ListRow;\n readonly item: ItemHandle | undefined;\n readonly drawn: boolean;\n readonly columns?: readonly string[] | undefined;\n /** How the default item lays the row out: a card's, or a timeline entry's. */\n readonly variant?: 'card' | 'entry';\n}): ReactElement {\n const fallback = (\n <DefaultItem\n resource={resource}\n row={row}\n raw={raw}\n columns={columns}\n {...(variant === undefined ? {} : { variant })}\n />\n );\n if (item === undefined || !drawn) return fallback;\n return <RelatedItem handle={item} row={row} fallback={fallback} />;\n}\n\n/**\n * A card's or an entry's one opener (P6-74): the row's title as the accessible name of a single\n * anchor whose `::after` covers the positioned parent. A quick row is the page anchor claimed\n * for the opener (a modified click follows the `href`), or a link-role button without a page.\n * `open: 'none'` draws nothing.\n */\nexport function RowOpener({\n title,\n href,\n quick,\n}: {\n readonly title: string;\n readonly href: string | undefined;\n readonly quick: (() => void) | null;\n}): ReactElement | null {\n const RouterLink = useLinkComponent();\n const className =\n 'outline-none after:absolute after:inset-0 after:rounded-[inherit] focus-visible:after:ring-2 focus-visible:after:ring-ring';\n const name: ReactNode = <span className=\"sr-only\">{title}</span>;\n if (quick !== null)\n return href ? (\n <ClaimedQuickLink href={href} className={className} onOpen={quick}>\n {name}\n </ClaimedQuickLink>\n ) : (\n <button\n type=\"button\"\n role=\"link\"\n {...{ [QUICK_ANCHOR_ATTRIBUTE]: '' }}\n // A button is inline-block, so even with only an `sr-only` name it took a line of the\n // card and pushed the content down (REF-40). Zero-size and unpositioned, its `::after`\n // still covers the card.\n className={`${className} block size-0 p-0`}\n onClick={(event) => {\n if (!isPlainLeftClick(event)) return;\n quick();\n }}\n >\n {name}\n </button>\n );\n if (href)\n return (\n <RouterLink href={href} className={className}>\n {name}\n </RouterLink>\n );\n return null;\n}\n\n/**\n * The wrapper that raises an item's interactive descendants above the opener's cover (P6-74):\n * the wrapper itself lets clicks through to the opener, its controls take them.\n */\nexport const ITEM_LAYER_CLASS =\n 'relative z-[1] pointer-events-none [&_a]:pointer-events-auto [&_button]:pointer-events-auto [&_input]:pointer-events-auto [&_select]:pointer-events-auto [&_textarea]:pointer-events-auto [&_summary]:pointer-events-auto [&_[role=button]]:pointer-events-auto [&_[role=link]]:pointer-events-auto [&_[role=checkbox]]:pointer-events-auto [&_[role=switch]]:pointer-events-auto';\n"],"mappings":";;;;;;;;;AA4BA,MAAM,aAAa,UAAmD,OAAO,SAAS;AAStF,SAAgB,YAAY,EAC1B,UACA,KACA,KACA,SACA,UAAU,UAQK;CAEf,MAAM,MADM,OACE,CAAC,CAAC,SAAS,IAAI,QAAQ;CACrC,MAAM,OAAO,YAAY,QAAQ;CACjC,MAAM,SAAS,aAAa,QAAQ,CAAC,CAAC,GAAG;CACzC,MAAM,cAAc,eAAe,QAAQ;CAC3C,MAAM,SACJ,QAAQ,KAAA,IACJ,CAAC,KACA,WAAW,IAAI,OAAO,MAAM,SAAS,IAAI,UAAU,KAAK,OAAO,KAAK,IAAI,MAAM,EAAA,CAAG,QAC/E,MAAM,OAAO,UACZ,SAAS,IAAI,gBACb,MAAM,QAAQ,IAAI,MAAM,SACxB,gBAAgB,KAAK,MAAM,QAAQ,WAAW,CAClD;CACN,MAAM,MAAM,KAAK,OAAO;EAAE,WAAW;EAAW,IAAI;CAAS;CAC7D,MAAM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;CAAY,CAAA;CAC/D,IAAI,UAAU,MACZ,OAAO,OACL,IAAC,kBAAD;EAAwB;EAAiB;EAAW,QAAQ;EACzD,UAAA;CACe,CAAA,IAElB,IAAC,UAAD;EACE,MAAK;EACL,MAAK;GACE,yBAAyB;EAIhC,WAAW,GAAG,UAAU;EACxB,UAAU,UAAU;GAClB,IAAI,CAAC,iBAAiB,KAAK,GAAG;GAC9B,MAAM;EACR;EAEC,UAAA;CACK,CAAA;CAEZ,IAAI,MACF,OACE,IAAC,YAAD;EAAkB;EAAiB;EAChC,UAAA;CACS,CAAA;CAEhB,OAAO;AACT;AAMA,MAAa,mBACX"}
|
|
@@ -2,7 +2,8 @@ import { l as cn } from "./use-theme-dnE3Od3I.js";
|
|
|
2
2
|
import { m as PopoverTrigger, p as PopoverContent, u as Popover } from "./toaster-Ct_YHGs6.js";
|
|
3
3
|
import { t as Button } from "./button-MWVeZaqj.js";
|
|
4
4
|
import { C as CommandEmpty, D as CommandList, E as CommandItem, T as CommandInput, a as namesHiddenField, i as selectKey, m as useRowTitle, n as useSelectCreate, o as narrowSearchDecl, r as RelationViewButton, t as RelationCreateButton, x as Command, y as LoadError } from "./relation-create-C43cdPQt.js";
|
|
5
|
-
import { r as useCandidatesGate, t as LazyRelationPickerDialog } from "./lazy-relation-picker-dialog-
|
|
5
|
+
import { r as useCandidatesGate, t as LazyRelationPickerDialog } from "./lazy-relation-picker-dialog-DN4bvQfg.js";
|
|
6
|
+
import { r as useRowSubtitle, t as optionSubtitle } from "./use-record-subtitle-gIaCGgbI.js";
|
|
6
7
|
import { composeListFilter, normalizeFixedFilters, relationOpenOf, resolveResourceLabel, resourceKey } from "@burojs/core";
|
|
7
8
|
import { resolveErrorText, useApp, useI18nCaps, useList, useListAccess, useOptionalT, useRelatedRecord, useTestIds } from "@burojs/react";
|
|
8
9
|
import { IconCheck, IconChevronDown, IconLoader2, IconX } from "@tabler/icons-react";
|
|
@@ -84,6 +85,7 @@ function RelationManyPickerInput(props) {
|
|
|
84
85
|
count: keyRead.keys.length
|
|
85
86
|
} : !link.ready ? { kind: "pending" } : void 0;
|
|
86
87
|
const filters = gate.filters.length === 0 ? fixedFilters : [...gate.filters, ...fixedFilters ?? []];
|
|
88
|
+
const subtitle = props.optionSubtitle;
|
|
87
89
|
return jsx(ManyPicker, {
|
|
88
90
|
to,
|
|
89
91
|
keys: keysOf(value),
|
|
@@ -100,6 +102,7 @@ function RelationManyPickerInput(props) {
|
|
|
100
102
|
resource: resource ?? "",
|
|
101
103
|
fieldName: field?.name ?? name,
|
|
102
104
|
open: relationOpenOf(field ?? {}),
|
|
105
|
+
...subtitle === void 0 ? {} : { optionSubtitle: subtitle },
|
|
103
106
|
...linkRights === void 0 ? {} : {
|
|
104
107
|
canAdd: linkRights.attach.allowed,
|
|
105
108
|
canRemove: linkRights.detach.allowed,
|
|
@@ -115,13 +118,14 @@ function RelationManyPickerInput(props) {
|
|
|
115
118
|
ariaErrorMessage
|
|
116
119
|
});
|
|
117
120
|
}
|
|
118
|
-
function ManyPicker({ to, keys, onChange, by, searchField, fixedFilters, gate, createSeeds, name, id, testid, resource, fieldName, open: openMode, canAdd = true, canRemove = true, hidden = NO_KEYS, notAtomic = false, readOnly = false, keyNotice, scope = "context", disabled, required, ariaInvalid, ariaDescribedBy, ariaErrorMessage }) {
|
|
121
|
+
function ManyPicker({ to, keys, onChange, by, searchField, fixedFilters, gate, createSeeds, name, id, testid, resource, fieldName, open: openMode, optionSubtitle: optionSubtitle$1, canAdd = true, canRemove = true, hidden = NO_KEYS, notAtomic = false, readOnly = false, keyNotice, scope = "context", disabled, required, ariaInvalid, ariaDescribedBy, ariaErrorMessage }) {
|
|
119
122
|
const app = useApp();
|
|
120
123
|
const caps = useI18nCaps();
|
|
121
124
|
const t = useOptionalT();
|
|
122
125
|
const tid = useTestIds();
|
|
123
126
|
const targetDef = app.registry.get(to);
|
|
124
127
|
const rowTitle = useRowTitle(to, targetDef?.displayField);
|
|
128
|
+
const rowSubtitle = useRowSubtitle(to, optionSubtitle$1);
|
|
125
129
|
const targetLabel = resolveResourceLabel(caps, to, "single", targetDef).toLowerCase();
|
|
126
130
|
const childPrefix = `relation-picker:${to}`;
|
|
127
131
|
const effectiveSearchField = searchField ?? targetDef?.displayField ?? "name";
|
|
@@ -456,6 +460,7 @@ function ManyPicker({ to, keys, onChange, by, searchField, fixedFilters, gate, c
|
|
|
456
460
|
if (rowValue === null || rowValue === void 0 || rowValue === "") return null;
|
|
457
461
|
const idStr = String(rowValue);
|
|
458
462
|
const label = rowTitle(row);
|
|
463
|
+
const subtitle = optionSubtitle(rowSubtitle(row), label, idStr);
|
|
459
464
|
const chosen = keys.some((key) => String(key) === idStr);
|
|
460
465
|
return jsxs(CommandItem, {
|
|
461
466
|
value: `${label} ${idStr}`,
|
|
@@ -472,9 +477,9 @@ function ManyPicker({ to, keys, onChange, by, searchField, fixedFilters, gate, c
|
|
|
472
477
|
className: "truncate",
|
|
473
478
|
children: label
|
|
474
479
|
}),
|
|
475
|
-
|
|
480
|
+
subtitle === null ? null : jsx("span", {
|
|
476
481
|
className: "ml-auto shrink-0 pl-2 text-xs text-muted-foreground",
|
|
477
|
-
children:
|
|
482
|
+
children: subtitle
|
|
478
483
|
})
|
|
479
484
|
]
|
|
480
485
|
}, idStr);
|
|
@@ -564,4 +569,4 @@ function Chip({ to, keyValue, by, resource, fieldName, testId, open: openMode, d
|
|
|
564
569
|
//#endregion
|
|
565
570
|
export { RelationManyPickerInput };
|
|
566
571
|
|
|
567
|
-
//# sourceMappingURL=relation-many-picker-
|
|
572
|
+
//# sourceMappingURL=relation-many-picker-BlrGRwMV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relation-many-picker-BlrGRwMV.js","names":["optionSubtitle","optionSubtitleText"],"sources":["../src/lib/error-title.ts","../src/fields/relation-many-picker.tsx"],"sourcesContent":["import { type ErrorTextCaps, resolveErrorText } from '@burojs/react';\n\n/**\n * The text a user may read for a failure a hook handed to the kit as an `Error`-typed value.\n * The value is a `DataError` at runtime when it came from a data provider (its `message` is a\n * reference, so it is resolved through the bundle) and a plain `Error` when the framework raised\n * it (its `message` is already a sentence). Anything else has nothing to show.\n */\nexport function errorTitle(error: unknown, caps: ErrorTextCaps): string | undefined {\n if (error instanceof Error) return error.message;\n if (error !== null && typeof error === 'object') {\n const { code, message } = error as { readonly code?: unknown; readonly message?: unknown };\n if (typeof code === 'string') {\n return resolveErrorText(\n {\n code,\n ...(message !== null && typeof message === 'object' ? { message } : {}),\n } as Parameters<typeof resolveErrorText>[0],\n caps,\n );\n }\n }\n return undefined;\n}\n","'use client';\n\nimport {\n type ErasedResourceHandle,\n type FilterExpression,\n type FixedFilterInput,\n type RelationCandidate,\n type RelationOpen,\n relationOpenOf,\n type ResourceRefInput,\n type ScopeSource,\n type SearchDecl,\n composeListFilter,\n normalizeFixedFilters,\n resolveResourceLabel,\n resourceKey,\n} from '@burojs/core';\nimport {\n useApp,\n useI18nCaps,\n useList,\n useListAccess,\n useOptionalT,\n useRelatedRecord,\n useTestIds,\n} from '@burojs/react';\nimport { errorTitle } from '../lib/error-title.js';\nimport { LoadError } from '../load-error/load-error-view.js';\nimport { IconCheck, IconChevronDown, IconLoader2, IconX } from '@tabler/icons-react';\nimport * as React from 'react';\nimport { cn } from '../lib/cn.js';\nimport { Button } from '../primitives/button.js';\nimport {\n Command,\n CommandEmpty,\n CommandInput,\n CommandItem,\n CommandList,\n} from '../primitives/command.js';\nimport { Popover, PopoverContent, PopoverTrigger } from '../primitives/popover.js';\nimport {\n optionSubtitle as optionSubtitleText,\n type RecordSubtitleFn,\n useRowSubtitle,\n} from '../resource/use-record-subtitle.js';\nimport { useRowTitle } from '../resource/use-row-title.js';\nimport { useCandidatesGate } from './candidates-gate.js';\nimport { RelationCreateButton, useSelectCreate } from './relation-create.js';\nimport { LazyRelationPickerDialog } from './lazy-relation-picker-dialog.js';\nimport { RelationViewButton, selectKey } from './relation-view-button.js';\nimport type { FieldInputProps } from './registry.js';\nimport { namesHiddenField, narrowSearchDecl } from './search-access.js';\n\ntype ErasedExpression = FilterExpression<ErasedResourceHandle>;\ntype Key = string | number;\n\nconst DEBOUNCE_MS = 250;\nconst NO_KEYS: readonly Key[] = Object.freeze([]);\n\n/** The keys a to-many field holds: strings and finite numbers, the user's order, no repeats. */\nfunction keysOf(value: unknown): readonly Key[] {\n if (!Array.isArray(value)) return [];\n const seen = new Set<string>();\n const out: Key[] = [];\n for (const entry of value) {\n const key = selectKey(entry);\n if (key === null || seen.has(key)) continue;\n seen.add(key);\n out.push(entry as Key);\n }\n return out;\n}\n\n/**\n * Form input of `f.relationMany` (P7 3.5): the chosen rows as chips (titles through the relation\n * aggregator, one batched read), a popover that searches the same option query a single select\n * does (candidates, field access and the create hand-back included), \"Advanced search\" in a\n * multiple-choice dialog, a \"view\" on every chip and \"+ create\" that appends what it created.\n * The value is `row[by ?? id]` for each chosen row. Loaded lazily: it is not on any screen's\n * first paint.\n */\nexport function RelationManyPickerInput(props: FieldInputProps): React.ReactElement {\n const {\n name,\n id,\n value,\n onChange,\n testid,\n field,\n disabled,\n required,\n ariaInvalid,\n ariaDescribedBy,\n ariaErrorMessage,\n relationSeeds,\n fixedFilters,\n metaSources,\n resource,\n link,\n } = props;\n const meta = field?.meta as\n | {\n to?: ResourceRefInput;\n by?: unknown;\n searchField?: string;\n candidates?: unknown;\n scope?: ScopeSource;\n }\n | undefined;\n let to: string | undefined;\n try {\n to = meta?.to === undefined ? undefined : resourceKey(meta.to);\n } catch {\n to = undefined;\n }\n const gate = useCandidatesGate({\n to,\n candidates: Array.isArray(meta?.candidates)\n ? (meta.candidates as readonly RelationCandidate[])\n : undefined,\n sources: metaSources,\n resource: resource ?? '',\n fieldName: field?.name ?? name,\n });\n if (!to) {\n return (\n <Button\n type=\"button\"\n variant=\"outline\"\n disabled\n data-testid={`${testid ?? `relation-many:${name}`}:no-target`}\n className=\"w-full justify-between font-normal\"\n name={name}\n id={id}\n >\n <span className=\"truncate text-muted-foreground\">—</span>\n </Button>\n );\n }\n // An inline link: the form controller's rights decide what the select offers, and the keys the\n // user cannot see ride along in the value. A link denied `not-atomic` is read-only with a notice.\n const linkRights = link?.rights;\n const notAtomic =\n linkRights !== undefined &&\n [linkRights.edit, linkRights.attach, linkRights.detach].some(\n (right) => !right.allowed && right.reason === 'not-atomic',\n );\n const denied =\n linkRights !== undefined &&\n !notAtomic &&\n !linkRights.edit.allowed &&\n ['field-readonly', 'rule-denied', 'operation-absent'].includes(linkRights.edit.reason);\n // The form holds a link's keys only once they are read whole: a failed or capped read, or one\n // still running, leaves the field read-only, and the user is told why.\n const keyRead = link?.keys;\n const keyNotice: KeyNotice | undefined =\n link === undefined\n ? undefined\n : keyRead?.error\n ? { kind: 'error', error: keyRead.error }\n : keyRead !== undefined &&\n !keyRead.isLoading &&\n keyRead.keys !== undefined &&\n !keyRead.complete\n ? { kind: 'incomplete', count: keyRead.keys.length }\n : !link.ready\n ? { kind: 'pending' }\n : undefined;\n const filters =\n gate.filters.length === 0 ? fixedFilters : [...gate.filters, ...(fixedFilters ?? [])];\n const subtitle = props.optionSubtitle;\n return (\n <ManyPicker\n to={to}\n keys={keysOf(value)}\n onChange={(next) => onChange(next)}\n {...(typeof meta?.by === 'string' ? { by: meta.by } : {})}\n searchField={meta?.searchField}\n {...(meta?.scope === undefined ? {} : { scope: meta.scope })}\n fixedFilters={filters}\n {...(gate.gate === undefined ? {} : { gate: gate.gate })}\n createSeeds={relationSeeds}\n name={name}\n id={id}\n testid={testid ?? `relation-many:${to}`}\n resource={resource ?? ''}\n fieldName={field?.name ?? name}\n open={relationOpenOf(field ?? {})}\n {...(subtitle === undefined ? {} : { optionSubtitle: subtitle })}\n {...(linkRights === undefined\n ? {}\n : {\n canAdd: linkRights.attach.allowed,\n canRemove: linkRights.detach.allowed,\n hidden: link?.hidden ?? [],\n notAtomic,\n readOnly: denied,\n ...(keyNotice === undefined ? {} : { keyNotice }),\n })}\n disabled={disabled}\n required={required}\n ariaInvalid={ariaInvalid}\n ariaDescribedBy={ariaDescribedBy}\n ariaErrorMessage={ariaErrorMessage}\n />\n );\n}\n\n/** Why a link whose keys the form does not hold whole is read-only. */\ntype KeyNotice =\n | { readonly kind: 'error'; readonly error: unknown }\n | { readonly kind: 'incomplete'; readonly count: number }\n | { readonly kind: 'pending' };\n\ninterface ManyPickerProps {\n readonly to: string;\n readonly keys: readonly Key[];\n readonly onChange: (next: readonly Key[]) => void;\n readonly by?: string;\n readonly searchField?: string | undefined;\n readonly fixedFilters: readonly FixedFilterInput[] | undefined;\n readonly gate?: import('./candidates-gate.js').CandidatesGate;\n readonly createSeeds: Readonly<Record<string, unknown>> | undefined;\n readonly name: string;\n readonly id: string | undefined;\n readonly testid: string;\n readonly resource: string;\n readonly fieldName: string;\n readonly open: RelationOpen;\n /** The options' second line (the field's `optionSubtitle`); see `RelationPickerProps`. */\n readonly optionSubtitle?: RecordSubtitleFn;\n /** False: no search box, no \"Advanced search\", no create, and no key can be added. Default true. */\n readonly canAdd?: boolean;\n /** False: no chip remove button, no Backspace removal, no clear-all. Default true. */\n readonly canRemove?: boolean;\n /**\n * Keys of `keys` whose target the user cannot see: one \"N not visible\" chip stands for them, it\n * has no remove button, and neither Backspace nor clear-all drops them.\n */\n readonly hidden?: readonly Key[];\n /** The link is edited with the record but its provider does not write it so: read-only, say so. */\n readonly notAtomic?: boolean;\n /** The user may see the link but not change it: say so. */\n readonly readOnly?: boolean;\n /** The link's keys are not held whole (failed, cut at the read cap, or still loading). */\n readonly keyNotice?: KeyNotice;\n /**\n * The read scope of the option reads (popover, dialog, create hand-back). Default `'context'`:\n * the record around the select narrows them, except by the field the select writes.\n */\n readonly scope?: ScopeSource;\n readonly disabled: boolean | undefined;\n readonly required: boolean | undefined;\n readonly ariaInvalid: boolean | undefined;\n readonly ariaDescribedBy: string | undefined;\n readonly ariaErrorMessage: string | undefined;\n}\n\nfunction ManyPicker({\n to,\n keys,\n onChange,\n by,\n searchField,\n fixedFilters,\n gate,\n createSeeds,\n name,\n id,\n testid,\n resource,\n fieldName,\n open: openMode,\n optionSubtitle,\n canAdd = true,\n canRemove = true,\n hidden = NO_KEYS,\n notAtomic = false,\n readOnly = false,\n keyNotice,\n scope = 'context',\n disabled,\n required,\n ariaInvalid,\n ariaDescribedBy,\n ariaErrorMessage,\n}: ManyPickerProps): React.ReactElement {\n const app = useApp();\n const caps = useI18nCaps();\n const t = useOptionalT();\n const tid = useTestIds();\n const targetDef = app.registry.get(to);\n const rowTitle = useRowTitle(to, targetDef?.displayField);\n const rowSubtitle = useRowSubtitle(to, optionSubtitle);\n const targetLabel = resolveResourceLabel(caps, to, 'single', targetDef).toLowerCase();\n const childPrefix = `relation-picker:${to}`;\n const effectiveSearchField = searchField ?? targetDef?.displayField ?? 'name';\n const [open, setOpen] = React.useState(false);\n const [dialogOpen, setDialogOpen] = React.useState(false);\n // Mounted on the first open, and only while no candidates gate holds the read: without the\n // candidate filters the dialog would list rows the field must not offer.\n const gated = gate !== undefined;\n const [dialogMounted, setDialogMounted] = React.useState(false);\n React.useEffect(() => {\n if (gated) setDialogOpen(false);\n }, [gated]);\n React.useEffect(() => {\n if (dialogOpen) setDialogMounted(true);\n }, [dialogOpen]);\n const [search, setSearch] = React.useState('');\n const [debouncedSearch, setDebouncedSearch] = React.useState('');\n const triggerRef = React.useRef<HTMLButtonElement | null>(null);\n const focusTrigger = React.useCallback(() => triggerRef.current?.focus(), []);\n\n React.useEffect(() => {\n const handle = setTimeout(() => setDebouncedSearch(search), DEBOUNCE_MS);\n return () => clearTimeout(handle);\n }, [search]);\n React.useEffect(() => {\n if (!open) {\n setSearch('');\n setDebouncedSearch('');\n }\n }, [open]);\n\n const targetIdField = (targetDef?.data as { readonly idField?: unknown } | undefined)?.idField;\n const idField =\n typeof targetIdField === 'string' && targetIdField.length > 0 ? targetIdField : 'id';\n const valueField = by ?? idField;\n const access = useListAccess(to);\n const accessReady = access.status === 'ready';\n const searchDecl = React.useMemo<SearchDecl | undefined>(\n () =>\n narrowSearchDecl(\n targetDef?.views?.list?.search ?? { fields: [effectiveSearchField] },\n (field) => access.fieldVisible(field),\n ),\n [targetDef, effectiveSearchField, access],\n );\n const filter = React.useMemo<ErasedExpression | undefined>(\n () =>\n composeListFilter({\n fixed: normalizeFixedFilters(fixedFilters),\n search: debouncedSearch,\n searchDecl,\n searchContext: { resource: to, def: targetDef },\n }),\n [fixedFilters, debouncedSearch, searchDecl, to, targetDef],\n );\n const blocked =\n !accessReady ||\n gate !== undefined ||\n namesHiddenField(filter, (field) => access.fieldVisible(field));\n\n const hiddenSet = React.useMemo(() => new Set(hidden.map(String)), [hidden]);\n const visibleKeys = React.useMemo(\n () => keys.filter((key) => !hiddenSet.has(String(key))),\n [keys, hiddenSet],\n );\n const hiddenHeld = keys.length - visibleKeys.length;\n const append = React.useCallback(\n (next: Key) => {\n if (!canAdd || keys.some((key) => String(key) === String(next))) return;\n onChange([...keys, next]);\n },\n [keys, onChange, canAdd],\n );\n const toggle = React.useCallback(\n (next: Key) => {\n const held = keys.some((key) => String(key) === String(next));\n if (held ? !canRemove || hiddenSet.has(String(next)) : !canAdd) return;\n onChange(held ? keys.filter((key) => String(key) !== String(next)) : [...keys, next]);\n },\n [keys, onChange, canAdd, canRemove, hiddenSet],\n );\n const { create, reader: createReader } = useSelectCreate({\n to,\n by,\n valueField,\n idField,\n fixedFilters,\n scope,\n scopeField: fieldName,\n held: gated,\n searchDecl,\n searchContext: { resource: to, def: targetDef },\n // What was created and fits is appended, as a pick would be; the dialog it came from is done.\n onValue: (picked) => {\n append(picked);\n setDialogOpen(false);\n },\n });\n\n const listQuery = useList(to, {\n ...(filter ? { filter } : {}),\n pagination: { kind: 'offset', page: 1, pageSize: 10 },\n scope,\n scopeField: fieldName,\n enabled: open && targetDef != null && !blocked,\n });\n const rows = (listQuery.data?.data ?? []) as Array<Record<string, unknown>>;\n const isLoading = listQuery.isLoading || listQuery.isFetching;\n const error = listQuery.isError ? (listQuery.error as unknown as Error) : null;\n\n if (!targetDef) {\n return (\n <Button\n type=\"button\"\n variant=\"outline\"\n disabled\n data-testid={`${childPrefix}:unregistered`}\n className=\"w-full justify-between font-normal\"\n name={name}\n id={id}\n >\n <span className=\"truncate text-muted-foreground\">{keys.map(String).join(', ') || '—'}</span>\n </Button>\n );\n }\n\n const placeholder = t('relation.select', {\n params: { name: targetLabel },\n defaultValue: `Select ${targetLabel}…`,\n });\n // Nothing held, nothing drawn: an empty row would still take the column's gap above the trigger.\n const chips =\n visibleKeys.length === 0 && hiddenHeld === 0 ? null : (\n <div className=\"flex flex-wrap items-center gap-1\" data-testid={`${testid}:chips`}>\n {visibleKeys.map((key) => (\n <Chip\n key={String(key)}\n to={to}\n keyValue={key}\n by={by}\n resource={resource}\n fieldName={fieldName}\n open={openMode}\n testId={tid.relationManyChip(resource, fieldName, String(key))}\n disabled={disabled === true || !canRemove}\n focusTrigger={focusTrigger}\n onRemove={() => onChange(keys.filter((entry) => String(entry) !== String(key)))}\n />\n ))}\n {hiddenHeld > 0 ? (\n <span\n data-testid={tid.linkHidden(resource, fieldName)}\n className=\"inline-flex items-center rounded-md border bg-secondary px-2 py-0.5 text-sm text-muted-foreground\"\n >\n {t('field.link.hidden', {\n count: hiddenHeld,\n defaultValue: '{{count}} not visible',\n })}\n </span>\n ) : null}\n {canRemove && disabled !== true && visibleKeys.length > 0 ? (\n <button\n type=\"button\"\n onClick={() => {\n // The button leaves with the chips it clears: focus goes where chip removal sends it.\n focusTrigger();\n onChange(keys.filter((key) => hiddenSet.has(String(key))));\n }}\n data-testid={`${testid}:clear-all`}\n className=\"rounded-sm px-1 text-xs text-muted-foreground hover:text-foreground focus:outline-hidden focus-visible:ring-2 focus-visible:ring-ring\"\n >\n {t('relationPicker.clearAll', { defaultValue: 'Clear all' })}\n </button>\n ) : null}\n </div>\n );\n const notice = keyNotice ? (\n <p\n data-testid={`${testid}:keys-${keyNotice.kind}`}\n role={keyNotice.kind === 'error' ? 'status' : undefined}\n className={cn(\n 'text-xs',\n keyNotice.kind === 'error' ? 'text-destructive' : 'text-muted-foreground',\n )}\n >\n {keyNotice.kind === 'error'\n ? `${t('field.link.failed', { defaultValue: 'Links could not be loaded' })}: ${errorTitle(keyNotice.error, caps) ?? ''}`\n : keyNotice.kind === 'incomplete'\n ? t('field.link.incomplete', {\n count: keyNotice.count,\n defaultValue: 'More than {{count}} links',\n })\n : t('table.loading', { defaultValue: 'Loading…' })}\n </p>\n ) : readOnly ? (\n <p data-testid={`${testid}:read-only`} className=\"text-xs text-muted-foreground\">\n {t('field.link.readOnly', { defaultValue: 'You cannot change this link.' })}\n </p>\n ) : notAtomic ? (\n <p data-testid={`${testid}:not-atomic`} className=\"text-xs text-muted-foreground\">\n {t('field.link.notAtomic', {\n defaultValue:\n 'This link cannot be edited here: its data source does not save it with the record.',\n })}\n </p>\n ) : null;\n\n if (gate?.kind === 'pending')\n return (\n <div className=\"flex flex-col gap-1.5\">\n {chips}\n {notice}\n <Button\n type=\"button\"\n variant=\"outline\"\n disabled\n aria-busy=\"true\"\n data-testid={testid}\n data-buro-candidates=\"pending\"\n className=\"w-full justify-between font-normal\"\n >\n <span className=\"truncate text-muted-foreground\">{placeholder}</span>\n <IconLoader2 className=\"h-4 w-4 shrink-0 animate-spin opacity-50\" aria-hidden />\n </Button>\n </div>\n );\n if (gate?.kind === 'forbidden')\n return (\n <div className=\"flex flex-col gap-1.5\">\n {chips}\n {notice}\n <Button\n type=\"button\"\n variant=\"outline\"\n disabled\n data-testid={testid}\n data-buro-candidates=\"forbidden\"\n aria-describedby={gate.testId}\n className=\"w-full justify-between font-normal\"\n >\n <span className=\"truncate text-muted-foreground\">{placeholder}</span>\n <IconChevronDown className=\"h-4 w-4 shrink-0 opacity-50\" aria-hidden />\n </Button>\n <p id={gate.testId} data-testid={gate.testId} className=\"text-xs text-muted-foreground\">\n {gate.message}\n </p>\n </div>\n );\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <div className=\"flex flex-col gap-1.5\">\n {chips}\n {notice}\n <PopoverTrigger asChild>\n <Button\n ref={triggerRef}\n type=\"button\"\n variant=\"outline\"\n role=\"combobox\"\n aria-expanded={open}\n aria-haspopup=\"listbox\"\n aria-required={required}\n aria-invalid={ariaInvalid || undefined}\n aria-describedby={ariaDescribedBy}\n {...(ariaErrorMessage ? { 'aria-errormessage': ariaErrorMessage } : {})}\n disabled={disabled}\n data-testid={testid}\n name={name}\n id={id}\n className=\"w-full justify-between font-normal\"\n >\n <span className=\"truncate text-left text-muted-foreground\">{placeholder}</span>\n <IconChevronDown className=\"h-4 w-4 shrink-0 opacity-50\" aria-hidden />\n </Button>\n </PopoverTrigger>\n </div>\n <PopoverContent className=\"w-[var(--radix-popover-trigger-width)] p-0\" align=\"start\">\n {gate?.kind === 'empty' ? (\n <p\n className=\"px-3 py-6 text-center text-sm text-muted-foreground\"\n data-testid={gate.testId}\n >\n {gate.message}\n </p>\n ) : (\n <Command shouldFilter={false}>\n {searchDecl !== undefined && canAdd && (\n <CommandInput\n value={search}\n onValueChange={setSearch}\n placeholder={t('toolbar.search', {\n params: { name: targetLabel },\n defaultValue: `Search ${targetLabel}…`,\n })}\n data-testid={`${childPrefix}:search`}\n aria-label={t('toolbar.search', {\n params: { name: targetLabel },\n defaultValue: `Search ${targetLabel}`,\n })}\n onKeyDown={(event) => {\n // Backspace in an empty search takes the last chip off.\n if (event.key === 'Backspace' && search === '' && canRemove) {\n event.preventDefault();\n const last = visibleKeys.at(-1);\n if (last !== undefined)\n onChange(keys.filter((key) => String(key) !== String(last)));\n }\n // Space toggles the highlighted option while nothing is typed.\n if (event.key === ' ' && search === '') {\n event.preventDefault();\n document\n .querySelector<HTMLElement>(\n `[data-testid=\"${childPrefix}:list\"] [aria-selected=\"true\"]`,\n )\n ?.click();\n }\n }}\n />\n )}\n <CommandList\n data-testid={`${childPrefix}:list`}\n aria-multiselectable=\"true\"\n aria-label={targetLabel}\n >\n {isLoading && (\n <div\n className=\"flex items-center justify-center gap-2 py-6 text-sm text-muted-foreground\"\n data-testid={`${childPrefix}:loading`}\n >\n <IconLoader2 className=\"h-4 w-4 animate-spin\" aria-hidden />\n <span>{t('table.loading', { defaultValue: 'Loading…' })}</span>\n </div>\n )}\n {!isLoading && error && (\n <LoadError\n surface=\"picker\"\n error={error}\n testId={`${childPrefix}:error`}\n className=\"block px-3 py-6 text-center text-sm text-muted-foreground\"\n fallback={{ key: 'relation.failed', default: 'Failed to load options.' }}\n />\n )}\n {!isLoading && !error && rows.length === 0 && (\n <CommandEmpty data-testid={`${childPrefix}:empty`}>\n {t('relation.noResults', { defaultValue: 'No results.' })}\n </CommandEmpty>\n )}\n {!isLoading &&\n !error &&\n rows.map((row) => {\n const rowValue = row[valueField];\n if (rowValue === null || rowValue === undefined || rowValue === '') return null;\n const idStr = String(rowValue);\n const label = rowTitle(row);\n const subtitle = optionSubtitleText(rowSubtitle(row), label, idStr);\n const chosen = keys.some((key) => String(key) === idStr);\n return (\n <CommandItem\n key={idStr}\n value={`${label} ${idStr}`}\n data-testid={`${childPrefix}:option:${idStr}`}\n aria-checked={chosen}\n disabled={chosen ? !canRemove : !canAdd}\n onSelect={() => toggle(rowValue as Key)}\n >\n <IconCheck\n className={cn(\n 'mr-2 h-4 w-4 shrink-0',\n chosen ? 'opacity-100' : 'opacity-0',\n )}\n aria-hidden\n />\n <span className=\"truncate\">{label}</span>\n {/* The declared subtitle, else `#<id>` unless the label already is the id\n (REF-40). */}\n {subtitle === null ? null : (\n <span className=\"ml-auto shrink-0 pl-2 text-xs text-muted-foreground\">\n {subtitle}\n </span>\n )}\n </CommandItem>\n );\n })}\n </CommandList>\n <div className=\"flex items-center justify-between gap-2 border-t px-3 py-2 text-sm\">\n {canAdd ? (\n <button\n type=\"button\"\n onClick={() => {\n setOpen(false);\n setDialogOpen(true);\n }}\n data-testid={`${childPrefix}:advanced`}\n className=\"text-foreground hover:underline focus:outline-hidden focus-visible:underline\"\n >\n {t('relationPicker.advancedSearch', { defaultValue: 'Advanced search' })}\n </button>\n ) : (\n <span />\n )}\n {!disabled && canAdd && (\n <RelationCreateButton\n to={to}\n fieldName={fieldName}\n create={create}\n seeds={createSeeds}\n search={search}\n beforeOpen={() => {\n setOpen(false);\n focusTrigger();\n }}\n className=\"text-foreground hover:underline focus:outline-hidden focus-visible:underline disabled:opacity-50\"\n />\n )}\n </div>\n </Command>\n )}\n </PopoverContent>\n {dialogMounted && !gated && canAdd && (\n <LazyRelationPickerDialog\n to={to}\n open={dialogOpen}\n onOpenChange={setDialogOpen}\n onSelect={() => undefined}\n multiple\n selected={keys}\n onToggle={toggle}\n valueField={valueField}\n searchField={searchField}\n fixedFilters={fixedFilters}\n scope={scope}\n scopeField={fieldName}\n {...(disabled ? {} : { create })}\n createSeeds={createSeeds}\n fieldName={fieldName}\n onBeforeCreate={focusTrigger}\n />\n )}\n {createReader}\n </Popover>\n );\n}\n\n/** One chosen row: its title (the aggregator batches every chip's read), which views it, and remove. */\nfunction Chip({\n to,\n keyValue,\n by,\n resource,\n fieldName,\n testId,\n open: openMode,\n disabled,\n focusTrigger,\n onRemove,\n}: {\n readonly to: string;\n readonly keyValue: Key;\n readonly by: string | undefined;\n readonly resource: string;\n readonly fieldName: string;\n readonly testId: string;\n readonly open: RelationOpen;\n readonly disabled: boolean;\n readonly focusTrigger: () => void;\n readonly onRemove: () => void;\n}): React.ReactElement {\n const t = useOptionalT();\n const app = useApp();\n const targetDef = app.registry.get(to);\n const rowTitle = useRowTitle(to, targetDef?.displayField);\n const { record, isLoading } = useRelatedRecord(\n to,\n keyValue,\n by === undefined ? undefined : { by },\n );\n const title = record ? rowTitle(record as Record<string, unknown>) : String(keyValue);\n return (\n <span\n data-testid={testId}\n data-resource={resource}\n className=\"inline-flex items-center gap-0.5 rounded-md border bg-secondary pl-2 text-sm text-secondary-foreground\"\n >\n <RelationViewButton\n to={to}\n value={keyValue}\n by={by}\n fieldName={`${fieldName}:${String(keyValue)}`}\n beforeOpen={focusTrigger}\n open={openMode}\n title={isLoading ? t('table.loading', { defaultValue: 'Loading…' }) : title}\n />\n {!disabled && (\n <button\n type=\"button\"\n onClick={onRemove}\n data-testid={`${testId}:remove`}\n aria-label={`${t('relationPicker.clear', { defaultValue: 'Clear' })} ${title}`}\n className=\"inline-flex size-6 items-center justify-center rounded-sm text-muted-foreground hover:text-foreground focus:outline-hidden focus-visible:ring-2 focus-visible:ring-ring\"\n >\n <IconX className=\"size-3.5\" aria-hidden />\n </button>\n )}\n </span>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAQA,SAAgB,WAAW,OAAgB,MAAyC;CAClF,IAAI,iBAAiB,OAAO,OAAO,MAAM;CACzC,IAAI,UAAU,QAAQ,OAAO,UAAU,UAAU;EAC/C,MAAM,EAAE,MAAM,YAAY;EAC1B,IAAI,OAAO,SAAS,UAClB,OAAO,iBACL;GACE;GACA,GAAI,YAAY,QAAQ,OAAO,YAAY,WAAW,EAAE,QAAQ,IAAI,CAAC;EACvE,GACA,IACF;CAEJ;AAEF;;;ACiCA,MAAM,cAAc;AACpB,MAAM,UAA0B,OAAO,OAAO,CAAC,CAAC;AAGhD,SAAS,OAAO,OAAgC;CAC9C,IAAI,CAAC,MAAM,QAAQ,KAAK,GAAG,OAAO,CAAC;CACnC,MAAM,OAAO,IAAI,IAAY;CAC7B,MAAM,MAAa,CAAC;CACpB,KAAK,MAAM,SAAS,OAAO;EACzB,MAAM,MAAM,UAAU,KAAK;EAC3B,IAAI,QAAQ,QAAQ,KAAK,IAAI,GAAG,GAAG;EACnC,KAAK,IAAI,GAAG;EACZ,IAAI,KAAK,KAAY;CACvB;CACA,OAAO;AACT;AAUA,SAAgB,wBAAwB,OAA4C;CAClF,MAAM,EACJ,MACA,IACA,OACA,UACA,QACA,OACA,UACA,UACA,aACA,iBACA,kBACA,eACA,cACA,aACA,UACA,SACE;CACJ,MAAM,OAAO,OAAO;CASpB,IAAI;CACJ,IAAI;EACF,KAAK,MAAM,OAAO,KAAA,IAAY,KAAA,IAAY,YAAY,KAAK,EAAE;CAC/D,QAAQ;EACN,KAAK,KAAA;CAC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AAO;IACjB;IACF;IACX,gBAAgB;GACjB,CAAA;GAEF;EACM;;AAEb;AAGA,SAAS,KAAK,EACZ,IACA,UACA,IACA,UACA,WACA,QACA,MAAM,UACN,UACA,cACA,YAYqB;CACrB,MAAM,IAAI,aAAa;CAEvB,MAAM,YADM,OACQ,CAAC,CAAC,SAAS,IAAI,EAAE;CACrC,MAAM,WAAW,YAAY,IAAI,WAAW,YAAY;CACxD,MAAM,EAAE,QAAQ,cAAc,iBAC5B,IACA,UACA,OAAO,KAAA,IAAY,KAAA,IAAY,EAAE,GAAG,CACtC;CACA,MAAM,QAAQ,SAAS,SAAS,MAAiC,IAAI,OAAO,QAAQ;CACpF,OACE,KAAC,QAAD;EACE,eAAa;EACb,iBAAe;EACf,WAAU;EAHZ,UAAA,CAKE,IAAC,oBAAD;GACM;GACJ,OAAO;GACH;GACJ,WAAW,GAAG,UAAU,GAAG,OAAO,QAAQ;GAC1C,YAAY;GACZ,MAAM;GACN,OAAO,YAAY,EAAE,iBAAiB,EAAE,cAAc,WAAW,CAAC,IAAI;EACvE,CAAA,GACA,CAAC,YACA,IAAC,UAAD;GACE,MAAK;GACL,SAAS;GACT,eAAa,GAAG,OAAO;GACvB,cAAY,GAAG,EAAE,wBAAwB,EAAE,cAAc,QAAQ,CAAC,EAAE,GAAG;GACvE,WAAU;GAEV,UAAA,IAAC,OAAD;IAAO,WAAU;IAAW,eAAA;GAAa,CAAA;EACnC,CAAA,CAEN;;AAEV"}
|
|
@@ -2,7 +2,8 @@ const require_use_theme = require("./use-theme-DFlpXils.cjs");
|
|
|
2
2
|
const require_toaster = require("./toaster-BbByOytP.cjs");
|
|
3
3
|
const require_button = require("./button-BxnnE28H.cjs");
|
|
4
4
|
const require_relation_create = require("./relation-create-DDEYcKfw.cjs");
|
|
5
|
-
const require_lazy_relation_picker_dialog = require("./lazy-relation-picker-dialog-
|
|
5
|
+
const require_lazy_relation_picker_dialog = require("./lazy-relation-picker-dialog-BAKBRn3V.cjs");
|
|
6
|
+
const require_use_record_subtitle = require("./use-record-subtitle-bfwIoUme.cjs");
|
|
6
7
|
let _burojs_core = require("@burojs/core");
|
|
7
8
|
let _burojs_react = require("@burojs/react");
|
|
8
9
|
let _tabler_icons_react = require("@tabler/icons-react");
|
|
@@ -85,6 +86,7 @@ function RelationManyPickerInput(props) {
|
|
|
85
86
|
count: keyRead.keys.length
|
|
86
87
|
} : !link.ready ? { kind: "pending" } : void 0;
|
|
87
88
|
const filters = gate.filters.length === 0 ? fixedFilters : [...gate.filters, ...fixedFilters ?? []];
|
|
89
|
+
const subtitle = props.optionSubtitle;
|
|
88
90
|
return (0, react_jsx_runtime.jsx)(ManyPicker, {
|
|
89
91
|
to,
|
|
90
92
|
keys: keysOf(value),
|
|
@@ -101,6 +103,7 @@ function RelationManyPickerInput(props) {
|
|
|
101
103
|
resource: resource ?? "",
|
|
102
104
|
fieldName: field?.name ?? name,
|
|
103
105
|
open: (0, _burojs_core.relationOpenOf)(field ?? {}),
|
|
106
|
+
...subtitle === void 0 ? {} : { optionSubtitle: subtitle },
|
|
104
107
|
...linkRights === void 0 ? {} : {
|
|
105
108
|
canAdd: linkRights.attach.allowed,
|
|
106
109
|
canRemove: linkRights.detach.allowed,
|
|
@@ -116,13 +119,14 @@ function RelationManyPickerInput(props) {
|
|
|
116
119
|
ariaErrorMessage
|
|
117
120
|
});
|
|
118
121
|
}
|
|
119
|
-
function ManyPicker({ to, keys, onChange, by, searchField, fixedFilters, gate, createSeeds, name, id, testid, resource, fieldName, open: openMode, canAdd = true, canRemove = true, hidden = NO_KEYS, notAtomic = false, readOnly = false, keyNotice, scope = "context", disabled, required, ariaInvalid, ariaDescribedBy, ariaErrorMessage }) {
|
|
122
|
+
function ManyPicker({ to, keys, onChange, by, searchField, fixedFilters, gate, createSeeds, name, id, testid, resource, fieldName, open: openMode, optionSubtitle: optionSubtitle$1, canAdd = true, canRemove = true, hidden = NO_KEYS, notAtomic = false, readOnly = false, keyNotice, scope = "context", disabled, required, ariaInvalid, ariaDescribedBy, ariaErrorMessage }) {
|
|
120
123
|
const app = (0, _burojs_react.useApp)();
|
|
121
124
|
const caps = (0, _burojs_react.useI18nCaps)();
|
|
122
125
|
const t = (0, _burojs_react.useOptionalT)();
|
|
123
126
|
const tid = (0, _burojs_react.useTestIds)();
|
|
124
127
|
const targetDef = app.registry.get(to);
|
|
125
128
|
const rowTitle = require_relation_create.useRowTitle(to, targetDef?.displayField);
|
|
129
|
+
const rowSubtitle = require_use_record_subtitle.useRowSubtitle(to, optionSubtitle$1);
|
|
126
130
|
const targetLabel = (0, _burojs_core.resolveResourceLabel)(caps, to, "single", targetDef).toLowerCase();
|
|
127
131
|
const childPrefix = `relation-picker:${to}`;
|
|
128
132
|
const effectiveSearchField = searchField ?? targetDef?.displayField ?? "name";
|
|
@@ -457,6 +461,7 @@ function ManyPicker({ to, keys, onChange, by, searchField, fixedFilters, gate, c
|
|
|
457
461
|
if (rowValue === null || rowValue === void 0 || rowValue === "") return null;
|
|
458
462
|
const idStr = String(rowValue);
|
|
459
463
|
const label = rowTitle(row);
|
|
464
|
+
const subtitle = require_use_record_subtitle.optionSubtitle(rowSubtitle(row), label, idStr);
|
|
460
465
|
const chosen = keys.some((key) => String(key) === idStr);
|
|
461
466
|
return (0, react_jsx_runtime.jsxs)(require_relation_create.CommandItem, {
|
|
462
467
|
value: `${label} ${idStr}`,
|
|
@@ -473,9 +478,9 @@ function ManyPicker({ to, keys, onChange, by, searchField, fixedFilters, gate, c
|
|
|
473
478
|
className: "truncate",
|
|
474
479
|
children: label
|
|
475
480
|
}),
|
|
476
|
-
|
|
481
|
+
subtitle === null ? null : (0, react_jsx_runtime.jsx)("span", {
|
|
477
482
|
className: "ml-auto shrink-0 pl-2 text-xs text-muted-foreground",
|
|
478
|
-
children:
|
|
483
|
+
children: subtitle
|
|
479
484
|
})
|
|
480
485
|
]
|
|
481
486
|
}, idStr);
|
|
@@ -565,4 +570,4 @@ function Chip({ to, keyValue, by, resource, fieldName, testId, open: openMode, d
|
|
|
565
570
|
//#endregion
|
|
566
571
|
exports.RelationManyPickerInput = RelationManyPickerInput;
|
|
567
572
|
|
|
568
|
-
//# sourceMappingURL=relation-many-picker-
|
|
573
|
+
//# sourceMappingURL=relation-many-picker-Br-zBHxT.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relation-many-picker-Br-zBHxT.cjs","names":["resolveErrorText","selectKey","resourceKey","useCandidatesGate","Button","relationOpenOf","useApp","useI18nCaps","useOptionalT","useTestIds","useRowTitle","useRowSubtitle","optionSubtitle","resolveResourceLabel","React","useListAccess","narrowSearchDecl","composeListFilter","normalizeFixedFilters","namesHiddenField","useSelectCreate","useList","cn","IconLoader2","IconChevronDown","Popover","PopoverTrigger","PopoverContent","Command","CommandInput","CommandList","LoadError","CommandEmpty","optionSubtitleText","CommandItem","IconCheck","RelationCreateButton","LazyRelationPickerDialog","useRelatedRecord","RelationViewButton","IconX"],"sources":["../src/lib/error-title.ts","../src/fields/relation-many-picker.tsx"],"sourcesContent":["import { type ErrorTextCaps, resolveErrorText } from '@burojs/react';\n\n/**\n * The text a user may read for a failure a hook handed to the kit as an `Error`-typed value.\n * The value is a `DataError` at runtime when it came from a data provider (its `message` is a\n * reference, so it is resolved through the bundle) and a plain `Error` when the framework raised\n * it (its `message` is already a sentence). Anything else has nothing to show.\n */\nexport function errorTitle(error: unknown, caps: ErrorTextCaps): string | undefined {\n if (error instanceof Error) return error.message;\n if (error !== null && typeof error === 'object') {\n const { code, message } = error as { readonly code?: unknown; readonly message?: unknown };\n if (typeof code === 'string') {\n return resolveErrorText(\n {\n code,\n ...(message !== null && typeof message === 'object' ? { message } : {}),\n } as Parameters<typeof resolveErrorText>[0],\n caps,\n );\n }\n }\n return undefined;\n}\n","'use client';\n\nimport {\n type ErasedResourceHandle,\n type FilterExpression,\n type FixedFilterInput,\n type RelationCandidate,\n type RelationOpen,\n relationOpenOf,\n type ResourceRefInput,\n type ScopeSource,\n type SearchDecl,\n composeListFilter,\n normalizeFixedFilters,\n resolveResourceLabel,\n resourceKey,\n} from '@burojs/core';\nimport {\n useApp,\n useI18nCaps,\n useList,\n useListAccess,\n useOptionalT,\n useRelatedRecord,\n useTestIds,\n} from '@burojs/react';\nimport { errorTitle } from '../lib/error-title.js';\nimport { LoadError } from '../load-error/load-error-view.js';\nimport { IconCheck, IconChevronDown, IconLoader2, IconX } from '@tabler/icons-react';\nimport * as React from 'react';\nimport { cn } from '../lib/cn.js';\nimport { Button } from '../primitives/button.js';\nimport {\n Command,\n CommandEmpty,\n CommandInput,\n CommandItem,\n CommandList,\n} from '../primitives/command.js';\nimport { Popover, PopoverContent, PopoverTrigger } from '../primitives/popover.js';\nimport {\n optionSubtitle as optionSubtitleText,\n type RecordSubtitleFn,\n useRowSubtitle,\n} from '../resource/use-record-subtitle.js';\nimport { useRowTitle } from '../resource/use-row-title.js';\nimport { useCandidatesGate } from './candidates-gate.js';\nimport { RelationCreateButton, useSelectCreate } from './relation-create.js';\nimport { LazyRelationPickerDialog } from './lazy-relation-picker-dialog.js';\nimport { RelationViewButton, selectKey } from './relation-view-button.js';\nimport type { FieldInputProps } from './registry.js';\nimport { namesHiddenField, narrowSearchDecl } from './search-access.js';\n\ntype ErasedExpression = FilterExpression<ErasedResourceHandle>;\ntype Key = string | number;\n\nconst DEBOUNCE_MS = 250;\nconst NO_KEYS: readonly Key[] = Object.freeze([]);\n\n/** The keys a to-many field holds: strings and finite numbers, the user's order, no repeats. */\nfunction keysOf(value: unknown): readonly Key[] {\n if (!Array.isArray(value)) return [];\n const seen = new Set<string>();\n const out: Key[] = [];\n for (const entry of value) {\n const key = selectKey(entry);\n if (key === null || seen.has(key)) continue;\n seen.add(key);\n out.push(entry as Key);\n }\n return out;\n}\n\n/**\n * Form input of `f.relationMany` (P7 3.5): the chosen rows as chips (titles through the relation\n * aggregator, one batched read), a popover that searches the same option query a single select\n * does (candidates, field access and the create hand-back included), \"Advanced search\" in a\n * multiple-choice dialog, a \"view\" on every chip and \"+ create\" that appends what it created.\n * The value is `row[by ?? id]` for each chosen row. Loaded lazily: it is not on any screen's\n * first paint.\n */\nexport function RelationManyPickerInput(props: FieldInputProps): React.ReactElement {\n const {\n name,\n id,\n value,\n onChange,\n testid,\n field,\n disabled,\n required,\n ariaInvalid,\n ariaDescribedBy,\n ariaErrorMessage,\n relationSeeds,\n fixedFilters,\n metaSources,\n resource,\n link,\n } = props;\n const meta = field?.meta as\n | {\n to?: ResourceRefInput;\n by?: unknown;\n searchField?: string;\n candidates?: unknown;\n scope?: ScopeSource;\n }\n | undefined;\n let to: string | undefined;\n try {\n to = meta?.to === undefined ? undefined : resourceKey(meta.to);\n } catch {\n to = undefined;\n }\n const gate = useCandidatesGate({\n to,\n candidates: Array.isArray(meta?.candidates)\n ? (meta.candidates as readonly RelationCandidate[])\n : undefined,\n sources: metaSources,\n resource: resource ?? '',\n fieldName: field?.name ?? name,\n });\n if (!to) {\n return (\n <Button\n type=\"button\"\n variant=\"outline\"\n disabled\n data-testid={`${testid ?? `relation-many:${name}`}:no-target`}\n className=\"w-full justify-between font-normal\"\n name={name}\n id={id}\n >\n <span className=\"truncate text-muted-foreground\">—</span>\n </Button>\n );\n }\n // An inline link: the form controller's rights decide what the select offers, and the keys the\n // user cannot see ride along in the value. A link denied `not-atomic` is read-only with a notice.\n const linkRights = link?.rights;\n const notAtomic =\n linkRights !== undefined &&\n [linkRights.edit, linkRights.attach, linkRights.detach].some(\n (right) => !right.allowed && right.reason === 'not-atomic',\n );\n const denied =\n linkRights !== undefined &&\n !notAtomic &&\n !linkRights.edit.allowed &&\n ['field-readonly', 'rule-denied', 'operation-absent'].includes(linkRights.edit.reason);\n // The form holds a link's keys only once they are read whole: a failed or capped read, or one\n // still running, leaves the field read-only, and the user is told why.\n const keyRead = link?.keys;\n const keyNotice: KeyNotice | undefined =\n link === undefined\n ? undefined\n : keyRead?.error\n ? { kind: 'error', error: keyRead.error }\n : keyRead !== undefined &&\n !keyRead.isLoading &&\n keyRead.keys !== undefined &&\n !keyRead.complete\n ? { kind: 'incomplete', count: keyRead.keys.length }\n : !link.ready\n ? { kind: 'pending' }\n : undefined;\n const filters =\n gate.filters.length === 0 ? fixedFilters : [...gate.filters, ...(fixedFilters ?? [])];\n const subtitle = props.optionSubtitle;\n return (\n <ManyPicker\n to={to}\n keys={keysOf(value)}\n onChange={(next) => onChange(next)}\n {...(typeof meta?.by === 'string' ? { by: meta.by } : {})}\n searchField={meta?.searchField}\n {...(meta?.scope === undefined ? {} : { scope: meta.scope })}\n fixedFilters={filters}\n {...(gate.gate === undefined ? {} : { gate: gate.gate })}\n createSeeds={relationSeeds}\n name={name}\n id={id}\n testid={testid ?? `relation-many:${to}`}\n resource={resource ?? ''}\n fieldName={field?.name ?? name}\n open={relationOpenOf(field ?? {})}\n {...(subtitle === undefined ? {} : { optionSubtitle: subtitle })}\n {...(linkRights === undefined\n ? {}\n : {\n canAdd: linkRights.attach.allowed,\n canRemove: linkRights.detach.allowed,\n hidden: link?.hidden ?? [],\n notAtomic,\n readOnly: denied,\n ...(keyNotice === undefined ? {} : { keyNotice }),\n })}\n disabled={disabled}\n required={required}\n ariaInvalid={ariaInvalid}\n ariaDescribedBy={ariaDescribedBy}\n ariaErrorMessage={ariaErrorMessage}\n />\n );\n}\n\n/** Why a link whose keys the form does not hold whole is read-only. */\ntype KeyNotice =\n | { readonly kind: 'error'; readonly error: unknown }\n | { readonly kind: 'incomplete'; readonly count: number }\n | { readonly kind: 'pending' };\n\ninterface ManyPickerProps {\n readonly to: string;\n readonly keys: readonly Key[];\n readonly onChange: (next: readonly Key[]) => void;\n readonly by?: string;\n readonly searchField?: string | undefined;\n readonly fixedFilters: readonly FixedFilterInput[] | undefined;\n readonly gate?: import('./candidates-gate.js').CandidatesGate;\n readonly createSeeds: Readonly<Record<string, unknown>> | undefined;\n readonly name: string;\n readonly id: string | undefined;\n readonly testid: string;\n readonly resource: string;\n readonly fieldName: string;\n readonly open: RelationOpen;\n /** The options' second line (the field's `optionSubtitle`); see `RelationPickerProps`. */\n readonly optionSubtitle?: RecordSubtitleFn;\n /** False: no search box, no \"Advanced search\", no create, and no key can be added. Default true. */\n readonly canAdd?: boolean;\n /** False: no chip remove button, no Backspace removal, no clear-all. Default true. */\n readonly canRemove?: boolean;\n /**\n * Keys of `keys` whose target the user cannot see: one \"N not visible\" chip stands for them, it\n * has no remove button, and neither Backspace nor clear-all drops them.\n */\n readonly hidden?: readonly Key[];\n /** The link is edited with the record but its provider does not write it so: read-only, say so. */\n readonly notAtomic?: boolean;\n /** The user may see the link but not change it: say so. */\n readonly readOnly?: boolean;\n /** The link's keys are not held whole (failed, cut at the read cap, or still loading). */\n readonly keyNotice?: KeyNotice;\n /**\n * The read scope of the option reads (popover, dialog, create hand-back). Default `'context'`:\n * the record around the select narrows them, except by the field the select writes.\n */\n readonly scope?: ScopeSource;\n readonly disabled: boolean | undefined;\n readonly required: boolean | undefined;\n readonly ariaInvalid: boolean | undefined;\n readonly ariaDescribedBy: string | undefined;\n readonly ariaErrorMessage: string | undefined;\n}\n\nfunction ManyPicker({\n to,\n keys,\n onChange,\n by,\n searchField,\n fixedFilters,\n gate,\n createSeeds,\n name,\n id,\n testid,\n resource,\n fieldName,\n open: openMode,\n optionSubtitle,\n canAdd = true,\n canRemove = true,\n hidden = NO_KEYS,\n notAtomic = false,\n readOnly = false,\n keyNotice,\n scope = 'context',\n disabled,\n required,\n ariaInvalid,\n ariaDescribedBy,\n ariaErrorMessage,\n}: ManyPickerProps): React.ReactElement {\n const app = useApp();\n const caps = useI18nCaps();\n const t = useOptionalT();\n const tid = useTestIds();\n const targetDef = app.registry.get(to);\n const rowTitle = useRowTitle(to, targetDef?.displayField);\n const rowSubtitle = useRowSubtitle(to, optionSubtitle);\n const targetLabel = resolveResourceLabel(caps, to, 'single', targetDef).toLowerCase();\n const childPrefix = `relation-picker:${to}`;\n const effectiveSearchField = searchField ?? targetDef?.displayField ?? 'name';\n const [open, setOpen] = React.useState(false);\n const [dialogOpen, setDialogOpen] = React.useState(false);\n // Mounted on the first open, and only while no candidates gate holds the read: without the\n // candidate filters the dialog would list rows the field must not offer.\n const gated = gate !== undefined;\n const [dialogMounted, setDialogMounted] = React.useState(false);\n React.useEffect(() => {\n if (gated) setDialogOpen(false);\n }, [gated]);\n React.useEffect(() => {\n if (dialogOpen) setDialogMounted(true);\n }, [dialogOpen]);\n const [search, setSearch] = React.useState('');\n const [debouncedSearch, setDebouncedSearch] = React.useState('');\n const triggerRef = React.useRef<HTMLButtonElement | null>(null);\n const focusTrigger = React.useCallback(() => triggerRef.current?.focus(), []);\n\n React.useEffect(() => {\n const handle = setTimeout(() => setDebouncedSearch(search), DEBOUNCE_MS);\n return () => clearTimeout(handle);\n }, [search]);\n React.useEffect(() => {\n if (!open) {\n setSearch('');\n setDebouncedSearch('');\n }\n }, [open]);\n\n const targetIdField = (targetDef?.data as { readonly idField?: unknown } | undefined)?.idField;\n const idField =\n typeof targetIdField === 'string' && targetIdField.length > 0 ? targetIdField : 'id';\n const valueField = by ?? idField;\n const access = useListAccess(to);\n const accessReady = access.status === 'ready';\n const searchDecl = React.useMemo<SearchDecl | undefined>(\n () =>\n narrowSearchDecl(\n targetDef?.views?.list?.search ?? { fields: [effectiveSearchField] },\n (field) => access.fieldVisible(field),\n ),\n [targetDef, effectiveSearchField, access],\n );\n const filter = React.useMemo<ErasedExpression | undefined>(\n () =>\n composeListFilter({\n fixed: normalizeFixedFilters(fixedFilters),\n search: debouncedSearch,\n searchDecl,\n searchContext: { resource: to, def: targetDef },\n }),\n [fixedFilters, debouncedSearch, searchDecl, to, targetDef],\n );\n const blocked =\n !accessReady ||\n gate !== undefined ||\n namesHiddenField(filter, (field) => access.fieldVisible(field));\n\n const hiddenSet = React.useMemo(() => new Set(hidden.map(String)), [hidden]);\n const visibleKeys = React.useMemo(\n () => keys.filter((key) => !hiddenSet.has(String(key))),\n [keys, hiddenSet],\n );\n const hiddenHeld = keys.length - visibleKeys.length;\n const append = React.useCallback(\n (next: Key) => {\n if (!canAdd || keys.some((key) => String(key) === String(next))) return;\n onChange([...keys, next]);\n },\n [keys, onChange, canAdd],\n );\n const toggle = React.useCallback(\n (next: Key) => {\n const held = keys.some((key) => String(key) === String(next));\n if (held ? !canRemove || hiddenSet.has(String(next)) : !canAdd) return;\n onChange(held ? keys.filter((key) => String(key) !== String(next)) : [...keys, next]);\n },\n [keys, onChange, canAdd, canRemove, hiddenSet],\n );\n const { create, reader: createReader } = useSelectCreate({\n to,\n by,\n valueField,\n idField,\n fixedFilters,\n scope,\n scopeField: fieldName,\n held: gated,\n searchDecl,\n searchContext: { resource: to, def: targetDef },\n // What was created and fits is appended, as a pick would be; the dialog it came from is done.\n onValue: (picked) => {\n append(picked);\n setDialogOpen(false);\n },\n });\n\n const listQuery = useList(to, {\n ...(filter ? { filter } : {}),\n pagination: { kind: 'offset', page: 1, pageSize: 10 },\n scope,\n scopeField: fieldName,\n enabled: open && targetDef != null && !blocked,\n });\n const rows = (listQuery.data?.data ?? []) as Array<Record<string, unknown>>;\n const isLoading = listQuery.isLoading || listQuery.isFetching;\n const error = listQuery.isError ? (listQuery.error as unknown as Error) : null;\n\n if (!targetDef) {\n return (\n <Button\n type=\"button\"\n variant=\"outline\"\n disabled\n data-testid={`${childPrefix}:unregistered`}\n className=\"w-full justify-between font-normal\"\n name={name}\n id={id}\n >\n <span className=\"truncate text-muted-foreground\">{keys.map(String).join(', ') || '—'}</span>\n </Button>\n );\n }\n\n const placeholder = t('relation.select', {\n params: { name: targetLabel },\n defaultValue: `Select ${targetLabel}…`,\n });\n // Nothing held, nothing drawn: an empty row would still take the column's gap above the trigger.\n const chips =\n visibleKeys.length === 0 && hiddenHeld === 0 ? null : (\n <div className=\"flex flex-wrap items-center gap-1\" data-testid={`${testid}:chips`}>\n {visibleKeys.map((key) => (\n <Chip\n key={String(key)}\n to={to}\n keyValue={key}\n by={by}\n resource={resource}\n fieldName={fieldName}\n open={openMode}\n testId={tid.relationManyChip(resource, fieldName, String(key))}\n disabled={disabled === true || !canRemove}\n focusTrigger={focusTrigger}\n onRemove={() => onChange(keys.filter((entry) => String(entry) !== String(key)))}\n />\n ))}\n {hiddenHeld > 0 ? (\n <span\n data-testid={tid.linkHidden(resource, fieldName)}\n className=\"inline-flex items-center rounded-md border bg-secondary px-2 py-0.5 text-sm text-muted-foreground\"\n >\n {t('field.link.hidden', {\n count: hiddenHeld,\n defaultValue: '{{count}} not visible',\n })}\n </span>\n ) : null}\n {canRemove && disabled !== true && visibleKeys.length > 0 ? (\n <button\n type=\"button\"\n onClick={() => {\n // The button leaves with the chips it clears: focus goes where chip removal sends it.\n focusTrigger();\n onChange(keys.filter((key) => hiddenSet.has(String(key))));\n }}\n data-testid={`${testid}:clear-all`}\n className=\"rounded-sm px-1 text-xs text-muted-foreground hover:text-foreground focus:outline-hidden focus-visible:ring-2 focus-visible:ring-ring\"\n >\n {t('relationPicker.clearAll', { defaultValue: 'Clear all' })}\n </button>\n ) : null}\n </div>\n );\n const notice = keyNotice ? (\n <p\n data-testid={`${testid}:keys-${keyNotice.kind}`}\n role={keyNotice.kind === 'error' ? 'status' : undefined}\n className={cn(\n 'text-xs',\n keyNotice.kind === 'error' ? 'text-destructive' : 'text-muted-foreground',\n )}\n >\n {keyNotice.kind === 'error'\n ? `${t('field.link.failed', { defaultValue: 'Links could not be loaded' })}: ${errorTitle(keyNotice.error, caps) ?? ''}`\n : keyNotice.kind === 'incomplete'\n ? t('field.link.incomplete', {\n count: keyNotice.count,\n defaultValue: 'More than {{count}} links',\n })\n : t('table.loading', { defaultValue: 'Loading…' })}\n </p>\n ) : readOnly ? (\n <p data-testid={`${testid}:read-only`} className=\"text-xs text-muted-foreground\">\n {t('field.link.readOnly', { defaultValue: 'You cannot change this link.' })}\n </p>\n ) : notAtomic ? (\n <p data-testid={`${testid}:not-atomic`} className=\"text-xs text-muted-foreground\">\n {t('field.link.notAtomic', {\n defaultValue:\n 'This link cannot be edited here: its data source does not save it with the record.',\n })}\n </p>\n ) : null;\n\n if (gate?.kind === 'pending')\n return (\n <div className=\"flex flex-col gap-1.5\">\n {chips}\n {notice}\n <Button\n type=\"button\"\n variant=\"outline\"\n disabled\n aria-busy=\"true\"\n data-testid={testid}\n data-buro-candidates=\"pending\"\n className=\"w-full justify-between font-normal\"\n >\n <span className=\"truncate text-muted-foreground\">{placeholder}</span>\n <IconLoader2 className=\"h-4 w-4 shrink-0 animate-spin opacity-50\" aria-hidden />\n </Button>\n </div>\n );\n if (gate?.kind === 'forbidden')\n return (\n <div className=\"flex flex-col gap-1.5\">\n {chips}\n {notice}\n <Button\n type=\"button\"\n variant=\"outline\"\n disabled\n data-testid={testid}\n data-buro-candidates=\"forbidden\"\n aria-describedby={gate.testId}\n className=\"w-full justify-between font-normal\"\n >\n <span className=\"truncate text-muted-foreground\">{placeholder}</span>\n <IconChevronDown className=\"h-4 w-4 shrink-0 opacity-50\" aria-hidden />\n </Button>\n <p id={gate.testId} data-testid={gate.testId} className=\"text-xs text-muted-foreground\">\n {gate.message}\n </p>\n </div>\n );\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <div className=\"flex flex-col gap-1.5\">\n {chips}\n {notice}\n <PopoverTrigger asChild>\n <Button\n ref={triggerRef}\n type=\"button\"\n variant=\"outline\"\n role=\"combobox\"\n aria-expanded={open}\n aria-haspopup=\"listbox\"\n aria-required={required}\n aria-invalid={ariaInvalid || undefined}\n aria-describedby={ariaDescribedBy}\n {...(ariaErrorMessage ? { 'aria-errormessage': ariaErrorMessage } : {})}\n disabled={disabled}\n data-testid={testid}\n name={name}\n id={id}\n className=\"w-full justify-between font-normal\"\n >\n <span className=\"truncate text-left text-muted-foreground\">{placeholder}</span>\n <IconChevronDown className=\"h-4 w-4 shrink-0 opacity-50\" aria-hidden />\n </Button>\n </PopoverTrigger>\n </div>\n <PopoverContent className=\"w-[var(--radix-popover-trigger-width)] p-0\" align=\"start\">\n {gate?.kind === 'empty' ? (\n <p\n className=\"px-3 py-6 text-center text-sm text-muted-foreground\"\n data-testid={gate.testId}\n >\n {gate.message}\n </p>\n ) : (\n <Command shouldFilter={false}>\n {searchDecl !== undefined && canAdd && (\n <CommandInput\n value={search}\n onValueChange={setSearch}\n placeholder={t('toolbar.search', {\n params: { name: targetLabel },\n defaultValue: `Search ${targetLabel}…`,\n })}\n data-testid={`${childPrefix}:search`}\n aria-label={t('toolbar.search', {\n params: { name: targetLabel },\n defaultValue: `Search ${targetLabel}`,\n })}\n onKeyDown={(event) => {\n // Backspace in an empty search takes the last chip off.\n if (event.key === 'Backspace' && search === '' && canRemove) {\n event.preventDefault();\n const last = visibleKeys.at(-1);\n if (last !== undefined)\n onChange(keys.filter((key) => String(key) !== String(last)));\n }\n // Space toggles the highlighted option while nothing is typed.\n if (event.key === ' ' && search === '') {\n event.preventDefault();\n document\n .querySelector<HTMLElement>(\n `[data-testid=\"${childPrefix}:list\"] [aria-selected=\"true\"]`,\n )\n ?.click();\n }\n }}\n />\n )}\n <CommandList\n data-testid={`${childPrefix}:list`}\n aria-multiselectable=\"true\"\n aria-label={targetLabel}\n >\n {isLoading && (\n <div\n className=\"flex items-center justify-center gap-2 py-6 text-sm text-muted-foreground\"\n data-testid={`${childPrefix}:loading`}\n >\n <IconLoader2 className=\"h-4 w-4 animate-spin\" aria-hidden />\n <span>{t('table.loading', { defaultValue: 'Loading…' })}</span>\n </div>\n )}\n {!isLoading && error && (\n <LoadError\n surface=\"picker\"\n error={error}\n testId={`${childPrefix}:error`}\n className=\"block px-3 py-6 text-center text-sm text-muted-foreground\"\n fallback={{ key: 'relation.failed', default: 'Failed to load options.' }}\n />\n )}\n {!isLoading && !error && rows.length === 0 && (\n <CommandEmpty data-testid={`${childPrefix}:empty`}>\n {t('relation.noResults', { defaultValue: 'No results.' })}\n </CommandEmpty>\n )}\n {!isLoading &&\n !error &&\n rows.map((row) => {\n const rowValue = row[valueField];\n if (rowValue === null || rowValue === undefined || rowValue === '') return null;\n const idStr = String(rowValue);\n const label = rowTitle(row);\n const subtitle = optionSubtitleText(rowSubtitle(row), label, idStr);\n const chosen = keys.some((key) => String(key) === idStr);\n return (\n <CommandItem\n key={idStr}\n value={`${label} ${idStr}`}\n data-testid={`${childPrefix}:option:${idStr}`}\n aria-checked={chosen}\n disabled={chosen ? !canRemove : !canAdd}\n onSelect={() => toggle(rowValue as Key)}\n >\n <IconCheck\n className={cn(\n 'mr-2 h-4 w-4 shrink-0',\n chosen ? 'opacity-100' : 'opacity-0',\n )}\n aria-hidden\n />\n <span className=\"truncate\">{label}</span>\n {/* The declared subtitle, else `#<id>` unless the label already is the id\n (REF-40). */}\n {subtitle === null ? null : (\n <span className=\"ml-auto shrink-0 pl-2 text-xs text-muted-foreground\">\n {subtitle}\n </span>\n )}\n </CommandItem>\n );\n })}\n </CommandList>\n <div className=\"flex items-center justify-between gap-2 border-t px-3 py-2 text-sm\">\n {canAdd ? (\n <button\n type=\"button\"\n onClick={() => {\n setOpen(false);\n setDialogOpen(true);\n }}\n data-testid={`${childPrefix}:advanced`}\n className=\"text-foreground hover:underline focus:outline-hidden focus-visible:underline\"\n >\n {t('relationPicker.advancedSearch', { defaultValue: 'Advanced search' })}\n </button>\n ) : (\n <span />\n )}\n {!disabled && canAdd && (\n <RelationCreateButton\n to={to}\n fieldName={fieldName}\n create={create}\n seeds={createSeeds}\n search={search}\n beforeOpen={() => {\n setOpen(false);\n focusTrigger();\n }}\n className=\"text-foreground hover:underline focus:outline-hidden focus-visible:underline disabled:opacity-50\"\n />\n )}\n </div>\n </Command>\n )}\n </PopoverContent>\n {dialogMounted && !gated && canAdd && (\n <LazyRelationPickerDialog\n to={to}\n open={dialogOpen}\n onOpenChange={setDialogOpen}\n onSelect={() => undefined}\n multiple\n selected={keys}\n onToggle={toggle}\n valueField={valueField}\n searchField={searchField}\n fixedFilters={fixedFilters}\n scope={scope}\n scopeField={fieldName}\n {...(disabled ? {} : { create })}\n createSeeds={createSeeds}\n fieldName={fieldName}\n onBeforeCreate={focusTrigger}\n />\n )}\n {createReader}\n </Popover>\n );\n}\n\n/** One chosen row: its title (the aggregator batches every chip's read), which views it, and remove. */\nfunction Chip({\n to,\n keyValue,\n by,\n resource,\n fieldName,\n testId,\n open: openMode,\n disabled,\n focusTrigger,\n onRemove,\n}: {\n readonly to: string;\n readonly keyValue: Key;\n readonly by: string | undefined;\n readonly resource: string;\n readonly fieldName: string;\n readonly testId: string;\n readonly open: RelationOpen;\n readonly disabled: boolean;\n readonly focusTrigger: () => void;\n readonly onRemove: () => void;\n}): React.ReactElement {\n const t = useOptionalT();\n const app = useApp();\n const targetDef = app.registry.get(to);\n const rowTitle = useRowTitle(to, targetDef?.displayField);\n const { record, isLoading } = useRelatedRecord(\n to,\n keyValue,\n by === undefined ? undefined : { by },\n );\n const title = record ? rowTitle(record as Record<string, unknown>) : String(keyValue);\n return (\n <span\n data-testid={testId}\n data-resource={resource}\n className=\"inline-flex items-center gap-0.5 rounded-md border bg-secondary pl-2 text-sm text-secondary-foreground\"\n >\n <RelationViewButton\n to={to}\n value={keyValue}\n by={by}\n fieldName={`${fieldName}:${String(keyValue)}`}\n beforeOpen={focusTrigger}\n open={openMode}\n title={isLoading ? t('table.loading', { defaultValue: 'Loading…' }) : title}\n />\n {!disabled && (\n <button\n type=\"button\"\n onClick={onRemove}\n data-testid={`${testId}:remove`}\n aria-label={`${t('relationPicker.clear', { defaultValue: 'Clear' })} ${title}`}\n className=\"inline-flex size-6 items-center justify-center rounded-sm text-muted-foreground hover:text-foreground focus:outline-hidden focus-visible:ring-2 focus-visible:ring-ring\"\n >\n <IconX className=\"size-3.5\" aria-hidden />\n </button>\n )}\n </span>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAQA,SAAgB,WAAW,OAAgB,MAAyC;CAClF,IAAI,iBAAiB,OAAO,OAAO,MAAM;CACzC,IAAI,UAAU,QAAQ,OAAO,UAAU,UAAU;EAC/C,MAAM,EAAE,MAAM,YAAY;EAC1B,IAAI,OAAO,SAAS,UAClB,QAAA,GAAOA,cAAAA,iBAAAA,CACL;GACE;GACA,GAAI,YAAY,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ACxD,MAAM,EAAE,QAAQ,eAAA,GAAc4B,cAAAA,iBAAAA,CAC5B,IACA,UACA,OAAO,KAAA,IAAY,KAAA,IAAY,EAAE,GAAG,CACtC;CACA,MAAM,QAAQ,SAAS,SAAS,MAAiC,IAAI,OAAO,QAAQ;CACpF,QACE,GAAA,kBAAA,KAAA,CAAC,QAAD;EACE,eAAa;EACb,iBAAe;EACf,WAAU;EAHZ,UAAA,EAKE,GAAA,kBAAA,IAAA,CAACC,wBAAAA,oBAAD;GACM;GACJ,OAAO;GACH;GACJ,WAAW,GAAG,UAAU,GAAG,OAAO,QAAQ;GAC1C,YAAY;GACZ,MAAM;GACN,OAAO,YAAY,EAAE,iBAAiB,EAAE,cAAc,WAAW,CAAC,IAAI;EACvE,CAAA,GACA,CAAC,aACA,GAAA,kBAAA,IAAA,CAAC,UAAD;GACE,MAAK;GACL,SAAS;GACT,eAAa,GAAG,OAAO;GACvB,cAAY,GAAG,EAAE,wBAAwB,EAAE,cAAc,QAAQ,CAAC,EAAE,GAAG;GACvE,WAAU;GAEV,WAAA,GAAA,kBAAA,IAAA,CAACC,oBAAAA,OAAD;IAAO,WAAU;IAAW,eAAA;GAAa,CAAA;EACnC,CAAA,CAEN;;AAEV"}
|
|
@@ -3,8 +3,9 @@ const require_toaster = require("./toaster-BbByOytP.cjs");
|
|
|
3
3
|
const require_button = require("./button-BxnnE28H.cjs");
|
|
4
4
|
const require_relation_create = require("./relation-create-DDEYcKfw.cjs");
|
|
5
5
|
const require_skeleton = require("./skeleton-_1gP7wan.cjs");
|
|
6
|
-
const require_lazy_relation_picker_dialog = require("./lazy-relation-picker-dialog-
|
|
6
|
+
const require_lazy_relation_picker_dialog = require("./lazy-relation-picker-dialog-BAKBRn3V.cjs");
|
|
7
7
|
const require_relation_select = require("./relation-select-Cr3CfNLy.cjs");
|
|
8
|
+
const require_use_record_subtitle = require("./use-record-subtitle-bfwIoUme.cjs");
|
|
8
9
|
let _burojs_core = require("@burojs/core");
|
|
9
10
|
let _burojs_react = require("@burojs/react");
|
|
10
11
|
let _tabler_icons_react = require("@tabler/icons-react");
|
|
@@ -12,7 +13,7 @@ let react = require("react");
|
|
|
12
13
|
react = require_use_theme.__toESM(react, 1);
|
|
13
14
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
14
15
|
//#region src/fields/lazy-candidates-picker.tsx
|
|
15
|
-
const CandidatesRelationPicker = (0, react.lazy)(() => Promise.resolve().then(() => require("./candidates-relation-picker-
|
|
16
|
+
const CandidatesRelationPicker = (0, react.lazy)(() => Promise.resolve().then(() => require("./candidates-relation-picker-C47mF260.cjs")).then((module) => ({ default: module.CandidatesRelationPicker })));
|
|
16
17
|
function LazyCandidatesRelationPicker(props) {
|
|
17
18
|
return (0, react_jsx_runtime.jsx)(react.Suspense, {
|
|
18
19
|
fallback: (0, react_jsx_runtime.jsx)(require_skeleton.Skeleton, {
|
|
@@ -26,13 +27,14 @@ function LazyCandidatesRelationPicker(props) {
|
|
|
26
27
|
//#endregion
|
|
27
28
|
//#region src/fields/relation-picker.tsx
|
|
28
29
|
const DEBOUNCE_MS = 250;
|
|
29
|
-
function RelationPicker({ to: toInput, value, onChange, by, searchField, pageSize = 10, clearable = true, placeholder, name, id, testid, fixedFilters, createSeeds, candidatesGate, rowFits, fieldName, open: openMode, scope = "context", disabled, required, className, ariaInvalid, ariaDescribedBy, ariaErrorMessage }) {
|
|
30
|
+
function RelationPicker({ to: toInput, value, onChange, by, searchField, pageSize = 10, clearable = true, placeholder, name, id, testid, fixedFilters, createSeeds, candidatesGate, rowFits, fieldName, open: openMode, optionSubtitle: optionSubtitle$1, scope = "context", disabled, required, className, ariaInvalid, ariaDescribedBy, ariaErrorMessage }) {
|
|
30
31
|
const to = (0, _burojs_core.routeResourceKey)(toInput);
|
|
31
32
|
const app = (0, _burojs_react.useApp)();
|
|
32
33
|
const caps = (0, _burojs_react.useI18nCaps)();
|
|
33
34
|
const t = (0, _burojs_react.useOptionalT)();
|
|
34
35
|
const targetDef = app.registry.get(to);
|
|
35
36
|
const rowTitle = require_relation_create.useRowTitle(to, targetDef?.displayField);
|
|
37
|
+
const rowSubtitle = require_use_record_subtitle.useRowSubtitle(to, optionSubtitle$1);
|
|
36
38
|
const targetLabel = (0, _burojs_core.resolveResourceLabel)(caps, to, "single", targetDef).toLowerCase();
|
|
37
39
|
const RouterLink = require_toaster.useLinkComponent();
|
|
38
40
|
const tid = testid ?? `relation-picker:${to}`;
|
|
@@ -294,6 +296,7 @@ function RelationPicker({ to: toInput, value, onChange, by, searchField, pageSiz
|
|
|
294
296
|
if (rowId === null || rowId === void 0 || rowId === "") return null;
|
|
295
297
|
const idStr = String(rowId);
|
|
296
298
|
const label = rowTitle(row);
|
|
299
|
+
const subtitle = require_use_record_subtitle.optionSubtitle(rowSubtitle(row), label, idStr);
|
|
297
300
|
const isSelected = value != null && String(value) === idStr;
|
|
298
301
|
return (0, react_jsx_runtime.jsxs)(require_relation_create.CommandItem, {
|
|
299
302
|
value: `${label} ${idStr}`,
|
|
@@ -308,9 +311,9 @@ function RelationPicker({ to: toInput, value, onChange, by, searchField, pageSiz
|
|
|
308
311
|
className: "truncate",
|
|
309
312
|
children: label
|
|
310
313
|
}),
|
|
311
|
-
|
|
314
|
+
subtitle === null ? null : (0, react_jsx_runtime.jsx)("span", {
|
|
312
315
|
className: "ml-auto shrink-0 pl-2 text-xs text-muted-foreground",
|
|
313
|
-
children:
|
|
316
|
+
children: subtitle
|
|
314
317
|
})
|
|
315
318
|
]
|
|
316
319
|
}, idStr);
|
|
@@ -428,6 +431,7 @@ function FieldRelationPicker({ props, to, extra }) {
|
|
|
428
431
|
const { name, id, value, onChange, testid, field, disabled, required, relationSeeds } = props;
|
|
429
432
|
const { ariaInvalid, ariaDescribedBy, ariaErrorMessage } = props;
|
|
430
433
|
const meta = field?.meta;
|
|
434
|
+
const subtitle = props.optionSubtitle;
|
|
431
435
|
return (0, react_jsx_runtime.jsx)(RelationPicker, {
|
|
432
436
|
to,
|
|
433
437
|
value,
|
|
@@ -444,6 +448,7 @@ function FieldRelationPicker({ props, to, extra }) {
|
|
|
444
448
|
...relationSeeds === void 0 ? {} : { createSeeds: relationSeeds },
|
|
445
449
|
fieldName: field?.name ?? name,
|
|
446
450
|
open: (0, _burojs_core.relationOpenOf)(field ?? {}),
|
|
451
|
+
...subtitle === void 0 ? {} : { optionSubtitle: subtitle },
|
|
447
452
|
disabled,
|
|
448
453
|
required,
|
|
449
454
|
ariaInvalid,
|
|
@@ -471,4 +476,4 @@ Object.defineProperty(exports, "RelationPickerInput", {
|
|
|
471
476
|
}
|
|
472
477
|
});
|
|
473
478
|
|
|
474
|
-
//# sourceMappingURL=relation-picker-
|
|
479
|
+
//# sourceMappingURL=relation-picker-ADjxI_TI.cjs.map
|