@rebasepro/cms 0.29.1 → 0.29.3

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.
Files changed (87) hide show
  1. package/dist/collection_editor/serializable_types.d.ts +2 -0
  2. package/dist/collection_editor/ui/collection_editor/CollectionRelationsTab.d.ts +1 -1
  3. package/dist/components/CollectionPanel.js +22 -13
  4. package/dist/components/CollectionPanel.js.map +1 -1
  5. package/dist/components/CollectionTableBinding/fields/TableStorageUpload.js +1 -1
  6. package/dist/components/CollectionTableBinding/fields/TableStorageUpload.js.map +1 -1
  7. package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.d.ts +1 -1
  8. package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js.map +1 -1
  9. package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js.map +1 -1
  10. package/dist/components/CollectionViewBinding/CollectionListViewBinding.js +39 -14
  11. package/dist/components/CollectionViewBinding/CollectionListViewBinding.js.map +1 -1
  12. package/dist/components/CollectionViewBinding/CollectionViewContent.d.ts +11 -0
  13. package/dist/components/CollectionViewBinding/CollectionViewContent.js +19 -2
  14. package/dist/components/CollectionViewBinding/CollectionViewContent.js.map +1 -1
  15. package/dist/components/CollectionViewBinding/EntityCardBinding.d.ts +1 -1
  16. package/dist/components/CollectionViewBinding/EntityCardBinding.js +1 -1
  17. package/dist/components/CollectionViewBinding/EntityCardBinding.js.map +1 -1
  18. package/dist/components/CollectionViewBinding/SlotValue.js.map +1 -1
  19. package/dist/components/CollectionViewBinding/usePreviewSlots.d.ts +19 -1
  20. package/dist/components/CollectionViewBinding/usePreviewSlots.js +18 -7
  21. package/dist/components/CollectionViewBinding/usePreviewSlots.js.map +1 -1
  22. package/dist/components/EntityPreviewBinding.d.ts +20 -0
  23. package/dist/components/EntityPreviewBinding.js +121 -18
  24. package/dist/components/EntityPreviewBinding.js.map +1 -1
  25. package/dist/components/HomePage/ContentHomePage.js +2 -3
  26. package/dist/components/HomePage/ContentHomePage.js.map +1 -1
  27. package/dist/components/RecordForm.d.ts +25 -4
  28. package/dist/components/RecordForm.js +21 -3
  29. package/dist/components/RecordForm.js.map +1 -1
  30. package/dist/components/RelationSelector.js.map +1 -1
  31. package/dist/components/SelectableTable/filters/FilterFieldBinding.d.ts +13 -1
  32. package/dist/components/SelectableTable/filters/FilterFieldBinding.js +19 -3
  33. package/dist/components/SelectableTable/filters/FilterFieldBinding.js.map +1 -1
  34. package/dist/components/SelectableTable/filters/RelationFilterField.d.ts +1 -1
  35. package/dist/components/SelectableTable/filters/RelationFilterField.js.map +1 -1
  36. package/dist/components/history/EntityHistoryEntry.js.map +1 -1
  37. package/dist/data_import/utils/save_entities.d.ts +10 -2
  38. package/dist/data_import/utils/save_entities.js.map +1 -1
  39. package/dist/editor/markdown.d.ts +10 -0
  40. package/dist/editor/markdown.js.map +1 -1
  41. package/dist/form/PropertyFieldBinding.js +4 -2
  42. package/dist/form/PropertyFieldBinding.js.map +1 -1
  43. package/dist/form/field_bindings/BinaryFieldBinding.js.map +1 -1
  44. package/dist/form/field_bindings/GeopointFieldBinding.js.map +1 -1
  45. package/dist/hooks/useBuildSidePanel.d.ts +10 -0
  46. package/dist/hooks/useBuildSidePanel.js +43 -4
  47. package/dist/hooks/useBuildSidePanel.js.map +1 -1
  48. package/dist/hooks/useResolvedNavigationFrom.d.ts +14 -2
  49. package/dist/hooks/useResolvedNavigationFrom.js.map +1 -1
  50. package/dist/index.d.ts +3 -1
  51. package/dist/index.js +4 -2
  52. package/dist/mcp_view/app_modules.js +4 -2
  53. package/dist/mcp_view/app_modules.js.map +1 -1
  54. package/dist/mcp_view/bridge.d.ts +21 -1
  55. package/dist/mcp_view/bridge.js.map +1 -1
  56. package/dist/mcp_view/index.d.ts +7 -7
  57. package/dist/mcp_view/index.js +7 -2
  58. package/dist/mcp_view/index.js.map +1 -1
  59. package/dist/mcp_view/payload.js +7 -2
  60. package/dist/mcp_view/payload.js.map +1 -1
  61. package/dist/mcp_view/screen.d.ts +6 -4
  62. package/dist/mcp_view/screen.js +15 -43
  63. package/dist/mcp_view/screen.js.map +1 -1
  64. package/dist/mcp_view/tool_driver.d.ts +58 -6
  65. package/dist/mcp_view/tool_driver.js +256 -117
  66. package/dist/mcp_view/tool_driver.js.map +1 -1
  67. package/dist/mcp_view/write_review.d.ts +35 -0
  68. package/dist/mcp_view/write_review.js +144 -0
  69. package/dist/mcp_view/write_review.js.map +1 -0
  70. package/dist/preview/compact_text.d.ts +1 -1
  71. package/dist/preview/compact_text.js.map +1 -1
  72. package/dist/preview/components/RelationPreview.js +7 -2
  73. package/dist/preview/components/RelationPreview.js.map +1 -1
  74. package/dist/saved_apps/SavedAppsView.d.ts +17 -0
  75. package/dist/saved_apps/SavedAppsView.js +167 -0
  76. package/dist/saved_apps/SavedAppsView.js.map +1 -0
  77. package/dist/saved_apps/admin_apps_client.d.ts +24 -0
  78. package/dist/saved_apps/admin_apps_client.js +46 -0
  79. package/dist/saved_apps/admin_apps_client.js.map +1 -0
  80. package/dist/saved_apps/saved_app_frame.d.ts +20 -0
  81. package/dist/saved_apps/saved_app_frame.js +143 -0
  82. package/dist/saved_apps/saved_app_frame.js.map +1 -0
  83. package/dist/selection/resolve_selection.d.ts +10 -2
  84. package/dist/selection/resolve_selection.js.map +1 -1
  85. package/dist/util/property_utils.d.ts +2 -2
  86. package/dist/util/property_utils.js.map +1 -1
  87. package/package.json +9 -9
@@ -1 +1 @@
1
- {"version":3,"file":"RecordForm.js","names":[],"sources":["../../src/components/RecordForm.tsx"],"sourcesContent":["import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from \"react\";\nimport { deepEqual as equal } from \"fast-equals\";\nimport { warnDeprecated } from \"@rebasepro/common\";\nimport type { Entity } from \"@rebasepro/types\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\nimport { Alert, Button, CenteredView, CircularProgressCenter } from \"@rebasepro/ui\";\nimport { CollectionScopeProvider, entityOfRow, ErrorView, rowOfEntity, useFetch, usePermissions, useTranslation } from \"@rebasepro/app\";\n\nimport { EntityFormBinding } from \"../form/EntityFormBinding\";\nimport type { EntityFormBindingProps } from \"../form/EntityFormBinding\";\nimport type { OnSavedParams } from \"../types/components/EntityFormProps\";\nimport { useCollectionRegistryController } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useNavigationStateController } from \"../hooks/navigation/contexts/NavigationStateContext\";\nimport { CollectionsScopeContext, isRegistered } from \"./CollectionsScopeContext\";\nimport { CollectionsProvider } from \"./CollectionsProvider\";\nimport { PanelNotFound } from \"./PanelNotFound\";\nimport { collectionPropOf, type ScopedRecordPanelProps } from \"./collection_prop\";\n\n/**\n * Props for {@link RecordForm}.\n *\n * @group Components\n */\nexport type RecordFormProps<M extends Record<string, unknown> = Record<string, unknown>> =\n RecordFormOptions<M> & RecordPanelCollection<M>;\n\n/**\n * Which collection a record panel's record belongs to: named, the way\n * {@link CollectionPanel} names it, or handed over as a value.\n *\n * @group Components\n */\nexport type RecordPanelCollection<M extends Record<string, unknown> = Record<string, unknown>> = {\n /**\n * The collection the record belongs to: its name (`\"orders\"`), registered\n * with `<RebaseCMS>` or a {@link CollectionsProvider} above, or the\n * collection as a value — a `defineCollection` config or a resolved\n * collection. Handed over as a value where no CMS navigation is mounted\n * above, the panel brings its own {@link CollectionsProvider} for it.\n */\n collection: AdminCollection<M> | string;\n /**\n * Where the record lives, where that is not the collection's name: a\n * subcollection's full path, `posts/p1/comments`.\n */\n path?: string;\n};\n\n/**\n * The options of an {@link RecordForm}, beside its collection.\n *\n * @group Components\n */\nexport type RecordFormOptions<M extends Record<string, unknown> = Record<string, unknown>> = {\n /**\n * The record to edit. When no record has this id yet, the form creates\n * it under this id — so a record kept at a known key (a settings record,\n * a profile keyed by its user's id) needs no seeding. Omit it to create a\n * new record under an id the data source assigns.\n */\n id?: string | number;\n\n /** Called after every successful save, with the saved record. */\n onSaved?: (params: OnSavedParams) => void;\n\n /**\n * Called when the form asks to be left — after its record is deleted, or\n * by an action that closes it. The form is your page's, so where that\n * leads is yours to say; without it, nothing happens.\n */\n onClose?: () => void;\n\n /** Values a new record starts with — one created without an id, or under an id no record has yet. */\n defaultValues?: Partial<M>;\n\n className?: string;\n\n /**\n * The fields the form shows, in this order; any other property is left\n * out. Sections and the rail keep their grouping, each holding only these\n * fields. The form validates only what it shows, and, creating a record,\n * refuses with an error naming them when a required field it leaves out\n * has no default value and is not filled by the server or the database.\n */\n fields?: string[];\n\n /**\n * A denser form, for a side card or a narrow panel: no rail beside the\n * fields, no record metadata, medium-height controls and tighter padding.\n */\n compact?: boolean;\n\n /**\n * Your own arrangement of the fields, in place of the generated ones:\n * `<FormField name=\"…\"/>`s inside any JSX. Validation covers the fields\n * its `<FormField>`s render, with the same create-time check as\n * {@link fields}. Wins over the collection's `formView.Builder`.\n *\n * ```tsx\n * <RecordForm collection=\"orders\" id={id}>\n * <div className=\"grid grid-cols-2 gap-3\">\n * <FormField name=\"status\"/>\n * <FormField name=\"tracking_number\"/>\n * </div>\n * <FormField name=\"notes\"/>\n * </RecordForm>\n * ```\n */\n children?: React.ReactNode;\n\n /**\n * Collection settings for this form only, applied over the registered\n * collection the way `CollectionPanel` applies its own: a shallow merge,\n * so `properties` given here replaces the collection's whole map.\n */\n collectionOverrides?: Partial<AdminCollection>;\n\n /** Anything else {@link EntityFormBinding} takes. */\n formProps?: Partial<Omit<EntityFormBindingProps<M>, \"path\" | \"collection\" | \"id\" | \"row\" | \"initialStatus\" | \"fields\" | \"layout\" | \"compact\">>;\n};\n\n/**\n * One record's form — loaded by id, saved through `<Rebase>`'s data layer —\n * to drop into a page of your own app.\n *\n * Needs `<Rebase>` and a React Router router above it (any router, any path).\n * Where no CMS navigation is mounted above, it brings its own\n * {@link CollectionsProvider}, so `<RebaseCMS>`, `<RebaseNavigation>` and\n * `<RebaseShell>` are not needed.\n *\n * @example\n * ```tsx\n * <Rebase client={client} authController={authController}>\n * <BrowserRouter>\n * <RecordForm collection={postsCollection} id=\"123\"\n * onSaved={({ id }) => toast(`Saved ${id}`)}/>\n * </BrowserRouter>\n * </Rebase>\n * ```\n *\n * @group Components\n */\nexport function RecordForm<M extends Record<string, unknown> = Record<string, unknown>>(rawProps: RecordFormProps<M>) {\n const inScope = useContext(CollectionsScopeContext);\n const collectionRegistry = useCollectionRegistryController();\n const navigationState = useNavigationStateController();\n const { collection, path } = collectionPropOf<AdminCollection<M>>(rawProps.collection, rawProps.path);\n const props: ScopedRecordPanelProps<RecordFormOptions<M>, M> = { ...rawProps, collection, path };\n const ownCollections = useMemo(() => collection ? [collection] : [], [collection]);\n\n // As `CollectionPanel`: a collection handed over as a value brings its own\n // scope where none is above, or where the one above has settled without\n // it. One named by path is looked up in the scope above.\n const needsOwnScope = collection !== undefined && (!inScope\n || (!navigationState.loading && !isRegistered(collectionRegistry.collections, path)));\n // One form per record: the binding keeps the id and status it mounted\n // with, so a page that hands over another id (a route `/posts/:id` going\n // from p1 to p2) gets a fresh form instead of one that shows p2 and saves\n // into p1. Keyed on the prop, so the id a create assigns keeps the form.\n const recordKey = `${path}/${props.id ?? \"new\"}`;\n // Named by path with no scope above to look it up in: nothing will ever\n // register it, so it is not found rather than loading.\n if (!inScope && collection === undefined) return <PanelNotFound className={props.className}/>;\n if (needsOwnScope) {\n return (\n <CollectionsProvider collections={ownCollections}>\n <RecordFormInScope key={recordKey} {...props}/>\n </CollectionsProvider>\n );\n }\n return <RecordFormInScope key={recordKey} {...props}/>;\n}\n\nfunction RecordFormInScope<M extends Record<string, unknown>>({\n collection: collectionProp,\n id: entityId,\n path: pathProp,\n onSaved,\n onClose,\n defaultValues,\n className,\n fields,\n children,\n compact,\n collectionOverrides,\n formProps\n}: ScopedRecordPanelProps<RecordFormOptions<M>, M>) {\n const { t } = useTranslation();\n const path = pathProp;\n const collectionRegistry = useCollectionRegistryController<Record<string, unknown>, AdminCollection<M>>();\n const navigationState = useNavigationStateController();\n const { canCreate, canEdit } = usePermissions();\n\n // The registry's copy: it carries the plugins' changes and the user's\n // saved overrides.\n // Looked up once per registry: each lookup builds a new object, and the\n // record's subscription is keyed on the collection it was opened with.\n // The overrides are compared by value for the same reason: they are an\n // inline object at most call sites, a new one on every render.\n const overridesRef = useRef(collectionOverrides);\n if (!equal(overridesRef.current, collectionOverrides)) overridesRef.current = collectionOverrides;\n const stableOverrides = overridesRef.current;\n const lookUp = collectionRegistry.initialised || !navigationState.loading;\n const collection = useMemo(() => {\n const registered = lookUp ? collectionRegistry.getCollection(path) : undefined;\n return registered && stableOverrides\n ? { ...registered, ...stableOverrides } as AdminCollection<M>\n : registered;\n }, [lookUp, collectionRegistry, path, stableOverrides]);\n\n const { entity, dataLoading, dataLoadingError } = useFetch<M>({\n path,\n entityId,\n collection: collection ?? collectionProp,\n relations: true,\n useCache: false\n });\n\n // The record as the form last saved it. A record created here has no id\n // to read it back by from the outside, and the form, existing from then\n // on, needs it.\n const [savedEntity, setSavedEntity] = useState<Entity<M> | undefined>(undefined);\n\n // The record as it was last delivered. A live read that stops delivering\n // it — someone deleted it — is not a record that was never there: as in\n // the CMS's own edit view, the form keeps showing it, with what was typed,\n // and says so. Without this the form lost its record mid-edit and threw.\n const [lastSeenEntity, setLastSeenEntity] = useState<Entity<M> | undefined>(undefined);\n useEffect(() => {\n if (entity) setLastSeenEntity(entity);\n }, [entity]);\n // \"Save as new\": the same values, in a form that creates a record. Counted,\n // so that each one is a fresh form.\n const [asNew, setAsNew] = useState<{ values: Partial<M>, n: number, saved?: Entity<M> } | null>(null);\n const typedValues = useRef<Partial<M> | undefined>(undefined);\n const deletedElsewhere = !asNew && entityId !== undefined && !dataLoading && !entity\n && lastSeenEntity !== undefined && String(lastSeenEntity.id) === String(entityId);\n const shownEntity = deletedElsewhere ? lastSeenEntity : (entity ?? savedEntity);\n\n const navigateBack = useCallback(() => onClose?.(), [onClose]);\n const saveAsNew = useCallback(() => {\n const values: Partial<M> = typedValues.current ?? lastSeenEntity?.values ?? {};\n setAsNew(previous => ({ values, n: (previous?.n ?? 0) + 1 }));\n }, [lastSeenEntity]);\n\n if (!collection) {\n if (navigationState.loading) return <CircularProgressCenter/>;\n return <PanelNotFound className={className}/>;\n }\n\n if (asNew) {\n return (\n <CollectionScopeProvider collection={collection}>\n <EntityFormBinding<M>\n {...formProps}\n key={`as-new-${asNew.n}`}\n className={className ?? formProps?.className}\n path={path}\n collection={collection}\n row={asNew.saved ? rowOfEntity(asNew.saved, collection) : undefined}\n initialStatus={\"new\"}\n initialDirtyValues={asNew.values}\n fields={fields}\n layout={children}\n compact={compact}\n disabled={!canCreate(collection, path) || formProps?.disabled}\n onRowChange={(changed) => {\n // The record it created, which it edits from then on.\n const saved = entityOfRow(changed.row, changed.id, path, collection) as Entity<M>;\n setAsNew(current => current && { ...current, saved });\n formProps?.onRowChange?.(changed);\n }}\n onSaved={(params) => {\n formProps?.onSaved?.(params);\n onSaved?.(params);\n }}\n navigateBack={navigateBack}\n />\n </CollectionScopeProvider>\n );\n }\n\n if (entityId !== undefined && dataLoadingError) {\n return <CenteredView className={className}><ErrorView error={dataLoadingError}/></CenteredView>;\n }\n if (entityId !== undefined && !shownEntity && dataLoading) return <CircularProgressCenter/>;\n\n // An id no record has yet is a record to create under that id. The form\n // keeps the status it opened with, so once it creates the record it edits\n // it from then on.\n const creating = shownEntity === undefined;\n // As the CMS's own New button and save actions: a record to create needs\n // canCreate (false while access is simulated), an existing one canEdit.\n const editable = creating ? canCreate(collection, path) : canEdit(collection, path, shownEntity?.values ?? null);\n\n return (\n <CollectionScopeProvider collection={collection}>\n <EntityFormBinding<M>\n {...formProps}\n className={className ?? formProps?.className}\n path={path}\n collection={collection}\n id={entityId}\n row={shownEntity ? rowOfEntity(shownEntity, collection) : undefined}\n initialStatus={creating ? \"new\" : \"existing\"}\n initialDirtyValues={creating ? defaultValues : formProps?.initialDirtyValues}\n fields={fields}\n layout={children}\n compact={compact}\n disabled={!editable || formProps?.disabled}\n onRowChange={(changed) => {\n setSavedEntity(entityOfRow(changed.row, changed.id, path, collection) as Entity<M>);\n formProps?.onRowChange?.(changed);\n }}\n onValuesModified={(modified, values) => {\n typedValues.current = values;\n formProps?.onValuesModified?.(modified, values);\n }}\n onSaved={(params) => {\n formProps?.onSaved?.(params);\n onSaved?.(params);\n }}\n navigateBack={navigateBack}\n >\n {deletedElsewhere &&\n <Alert color={\"warning\"} size={\"small\"} outerClassName={\"w-full mb-4\"}\n action={<Button size={\"small\"} variant={\"text\"} onClick={saveAsNew}>{t(\"save_as_new\")}</Button>}>\n {t(\"entity_deleted_elsewhere\")}\n </Alert>}\n {formProps?.children}\n </EntityFormBinding>\n </CollectionScopeProvider>\n );\n}\n\n/**\n * @deprecated Renamed {@link RecordForm}, with the same props. It warns once.\n * @group Components\n */\nexport type EntityFormPanelProps<M extends Record<string, unknown> = Record<string, unknown>> = RecordFormProps<M>;\n\n/**\n * @deprecated Renamed {@link RecordForm}, with the same props. It warns once.\n * @group Components\n */\nexport function EntityFormPanel<M extends Record<string, unknown> = Record<string, unknown>>(props: RecordFormProps<M>) {\n warnDeprecated(\"EntityFormPanel\", \"`EntityFormPanel` is now `RecordForm`, with the same props.\");\n return <RecordForm<M> {...props}/>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8IA,SAAgB,WAAwE,UAA8B;CAClH,MAAM,UAAU,WAAW,uBAAuB;CAClD,MAAM,qBAAqB,gCAAgC;CAC3D,MAAM,kBAAkB,6BAA6B;CACrD,MAAM,EAAE,YAAY,SAAS,iBAAqC,SAAS,YAAY,SAAS,IAAI;CACpG,MAAM,QAAyD;EAAE,GAAG;EAAU;EAAY;CAAK;CAC/F,MAAM,iBAAiB,cAAc,aAAa,CAAC,UAAU,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC;CAKjF,MAAM,gBAAgB,eAAe,KAAA,MAAc,CAAC,WAC5C,CAAC,gBAAgB,WAAW,CAAC,aAAa,mBAAmB,aAAa,IAAI;CAKtF,MAAM,YAAY,GAAG,KAAK,GAAG,MAAM,MAAM;CAGzC,IAAI,C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BAAkB,CAAA;CAAe,CAAA;CAElG,IAAI,aAAa,KAAA,KAAa,CAAC,eAAe,aAAa,OAAO,oBAAC,wBAAD,CAAwB,CAAA;CAK1F,MAAM,WAAW,gBAAgB,KAAA;CAGjC,MAAM,WAAW,WAAW,UAAU,YAAY,IAAI,IAAI,QAAQ,YAAY,MAAM,aAAa,UAAU,IAAI;CAE/G,OACI,oBAAC,yBAAD;EAAqC;YACjC,qBAAC,mBAAD;GACI,GAAI;GACJ,WAAW,aAAa,WAAW;GAC7B;GACM;GACZ,IAAI;GACJ,KAAK,cAAc,YAAY,aAAa,UAAU,IAAI,KAAA;GAC1D,eAAe,WAAW,QAAQ;GAClC,oBAAoB,WAAW,gBAAgB,WAAW;GAClD;GACR,QAAQ;GACC;GACT,UAAU,CAAC,YAAY,WAAW;GAClC,cAAc,YAAY;IACtB,eAAe,YAAY,QAAQ,KAAK,QAAQ,IAAI,MAAM,UAAU,CAAc;IAClF,WAAW,cAAc,OAAO;GACpC;GACA,mBAAmB,UAAU,WAAW;IACpC,YAAY,UAAU;IACtB,WAAW,mBAAmB,UAAU,MAAM;GAClD;GACA,UAAU,WAAW;IACjB,WAAW,UAAU,MAAM;IAC3B,UAAU,MAAM;GACpB;GACc;aAzBlB,CA2BK,oBACG,oBAAC,OAAD;IAAO,OAAO;IAAW,MAAM;IAAS,gBAAgB;IACpD,QAAQ,oBAAC,QAAD;KAAQ,MAAM;KAAS,SAAS;KAAQ,SAAS;eAAY,EAAE,aAAa;IAAU,CAAA;cAC7F,EAAE,0BAA0B;GAC1B,CAAA,GACV,WAAW,QACG;;CACE,CAAA;AAEjC;;;;;AAYA,SAAgB,gBAA6E,OAA2B;CACpH,eAAe,mBAAmB,6DAA6D;CAC/F,OAAO,oBAAC,YAAD,EAAe,GAAI,MAAO,CAAA;AACrC"}
1
+ {"version":3,"file":"RecordForm.js","names":[],"sources":["../../src/components/RecordForm.tsx"],"sourcesContent":["import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from \"react\";\nimport { deepEqual as equal } from \"fast-equals\";\nimport { warnDeprecated } from \"@rebasepro/common\";\nimport type { Entity } from \"@rebasepro/types\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\nimport { Alert, Button, CenteredView, CircularProgressCenter } from \"@rebasepro/ui\";\nimport { CollectionScopeProvider, entityOfRow, ErrorView, rowOfEntity, useFetch, usePermissions, useTranslation } from \"@rebasepro/app\";\n\nimport { EntityFormBinding } from \"../form/EntityFormBinding\";\nimport type { EntityFormBindingProps } from \"../form/EntityFormBinding\";\nimport type { OnSavedParams } from \"../types/components/EntityFormProps\";\nimport { useCollectionRegistryController } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useNavigationStateController } from \"../hooks/navigation/contexts/NavigationStateContext\";\nimport { CollectionsScopeContext, isRegistered } from \"./CollectionsScopeContext\";\nimport { CollectionsProvider } from \"./CollectionsProvider\";\nimport { PanelNotFound } from \"./PanelNotFound\";\nimport { collectionPropOf, type ScopedRecordPanelProps } from \"./collection_prop\";\n\n/**\n * Props for {@link RecordForm}.\n *\n * @group Components\n */\nexport type RecordFormProps<M extends Record<string, unknown> = Record<string, unknown>> =\n RecordFormOptions<M> & RecordPanelCollection<M>;\n\n/**\n * Which collection a record panel's record belongs to: named, the way\n * {@link CollectionPanel} names it, or handed over as a value.\n *\n * @group Components\n */\nexport type RecordPanelCollection<M extends Record<string, unknown> = Record<string, unknown>> = {\n /**\n * The collection the record belongs to: its name (`\"orders\"`), registered\n * with `<RebaseCMS>` or a {@link CollectionsProvider} above, or the\n * collection as a value — a `defineCollection` config or a resolved\n * collection. Handed over as a value where no CMS navigation is mounted\n * above, the panel brings its own {@link CollectionsProvider} for it.\n */\n collection: AdminCollection<M> | string;\n /**\n * Where the record lives, where that is not the collection's name: a\n * subcollection's full path, `posts/p1/comments`.\n */\n path?: string;\n};\n\n/**\n * The options of an {@link RecordForm}, beside its collection.\n *\n * @group Components\n */\nexport type RecordFormOptions<M extends Record<string, unknown> = Record<string, unknown>> = {\n /**\n * The record to edit. When no record has this id yet, the form creates\n * it under this id — so a record kept at a known key (a settings record,\n * a profile keyed by its user's id) needs no seeding. Omit it to create a\n * new record under an id the data source assigns.\n */\n id?: string | number;\n\n /** Called after every successful save, with the saved record. */\n onSaved?: (params: OnSavedParams) => void;\n\n /**\n * Called when the form asks to be left — after its record is deleted, or\n * by an action that closes it. The form is your page's, so where that\n * leads is yours to say; without it, nothing happens.\n */\n onClose?: () => void;\n\n /** Values a new record starts with — one created without an id, or under an id no record has yet. */\n defaultValues?: Partial<M>;\n\n className?: string;\n\n /**\n * The fields the form shows, in this order; any other property is left\n * out. Sections and the rail keep their grouping, each holding only these\n * fields. The form validates only what it shows, and, creating a record,\n * refuses with an error naming them when a required field it leaves out\n * has no default value and is not filled by the server or the database.\n */\n fields?: string[];\n\n /**\n * A denser form, for a side card or a narrow panel: no rail beside the\n * fields, no record metadata, medium-height controls and tighter padding.\n */\n compact?: boolean;\n\n /**\n * Your own arrangement of the fields, in place of the generated ones:\n * `<FormField name=\"…\"/>`s inside any JSX. Validation covers the fields\n * its `<FormField>`s render, with the same create-time check as\n * {@link fields}. Wins over the collection's `formView.Builder`.\n *\n * ```tsx\n * <RecordForm collection=\"orders\" id={id}>\n * <div className=\"grid grid-cols-2 gap-3\">\n * <FormField name=\"status\"/>\n * <FormField name=\"tracking_number\"/>\n * </div>\n * <FormField name=\"notes\"/>\n * </RecordForm>\n * ```\n */\n children?: React.ReactNode;\n\n /**\n * Collection settings for this form only, applied over the registered\n * collection the way `CollectionPanel` applies its own: a shallow merge,\n * so `properties` given here replaces the collection's whole map.\n */\n collectionOverrides?: Partial<AdminCollection>;\n\n /** Anything else {@link EntityFormBinding} takes. */\n formProps?: Partial<Omit<EntityFormBindingProps<M>, \"path\" | \"collection\" | \"id\" | \"row\" | \"initialStatus\" | \"fields\" | \"layout\" | \"compact\">>;\n};\n\n/**\n * One record's form — loaded by id, saved through `<Rebase>`'s data layer —\n * to drop into a page of your own app.\n *\n * Needs `<Rebase>` and a React Router router above it (any router, any path).\n * Where no CMS navigation is mounted above, it brings its own\n * {@link CollectionsProvider}, so `<RebaseCMS>`, `<RebaseNavigation>` and\n * `<RebaseShell>` are not needed.\n *\n * @example\n * ```tsx\n * <Rebase client={client} authController={authController}>\n * <BrowserRouter>\n * <RecordForm collection={postsCollection} id=\"123\"\n * onSaved={({ id }) => toast(`Saved ${id}`)}/>\n * </BrowserRouter>\n * </Rebase>\n * ```\n *\n * @group Components\n */\nexport function RecordForm<M extends Record<string, unknown> = Record<string, unknown>>(rawProps: RecordFormProps<M>) {\n const inScope = useContext(CollectionsScopeContext);\n const collectionRegistry = useCollectionRegistryController();\n const navigationState = useNavigationStateController();\n const { collection, path } = collectionPropOf<AdminCollection<M>>(rawProps.collection, rawProps.path);\n const props: ScopedRecordPanelProps<RecordFormOptions<M>, M> = { ...rawProps, collection, path };\n const ownCollections = useMemo(() => collection ? [collection] : [], [collection]);\n\n // As `CollectionPanel`: a collection handed over as a value brings its own\n // scope where none is above, or where the one above has settled without\n // it. One named by path is looked up in the scope above.\n const needsOwnScope = collection !== undefined && (!inScope\n || (!navigationState.loading && !isRegistered(collectionRegistry.collections, path)));\n // One form per record: the binding keeps the id and status it mounted\n // with, so a page that hands over another id (a route `/posts/:id` going\n // from p1 to p2) gets a fresh form instead of one that shows p2 and saves\n // into p1. Keyed on the prop, so the id a create assigns keeps the form.\n const recordKey = `${path}/${props.id ?? \"new\"}`;\n // Named by path with no scope above to look it up in: nothing will ever\n // register it, so it is not found rather than loading.\n if (!inScope && collection === undefined) return <PanelNotFound className={props.className}/>;\n if (needsOwnScope) {\n return (\n <CollectionsProvider collections={ownCollections}>\n <RecordFormInScope key={recordKey} {...props}/>\n </CollectionsProvider>\n );\n }\n return <RecordFormInScope key={recordKey} {...props}/>;\n}\n\nfunction RecordFormInScope<M extends Record<string, unknown>>({\n collection: collectionProp,\n id: entityId,\n path: pathProp,\n onSaved,\n onClose,\n defaultValues,\n className,\n fields,\n children,\n compact,\n collectionOverrides,\n formProps\n}: ScopedRecordPanelProps<RecordFormOptions<M>, M>) {\n const { t } = useTranslation();\n const path = pathProp;\n const collectionRegistry = useCollectionRegistryController<Record<string, unknown>, AdminCollection<M>>();\n const navigationState = useNavigationStateController();\n const { canCreate, canEdit } = usePermissions();\n\n // The registry's copy: it carries the plugins' changes and the user's\n // saved overrides.\n // Looked up once per registry: each lookup builds a new object, and the\n // record's subscription is keyed on the collection it was opened with.\n // The overrides are compared by value for the same reason: they are an\n // inline object at most call sites, a new one on every render.\n const overridesRef = useRef(collectionOverrides);\n if (!equal(overridesRef.current, collectionOverrides)) overridesRef.current = collectionOverrides;\n const stableOverrides = overridesRef.current;\n const lookUp = collectionRegistry.initialised || !navigationState.loading;\n const collection = useMemo(() => {\n const registered = lookUp ? collectionRegistry.getCollection(path) : undefined;\n return registered && stableOverrides\n ? { ...registered, ...stableOverrides } as AdminCollection<M>\n : registered;\n }, [lookUp, collectionRegistry, path, stableOverrides]);\n\n const { entity, dataLoading, dataLoadingError } = useFetch<M>({\n path,\n entityId,\n collection: collection ?? collectionProp,\n relations: true,\n useCache: false\n });\n\n // The record as the form last saved it. A record created here has no id\n // to read it back by from the outside, and the form, existing from then\n // on, needs it.\n const [savedEntity, setSavedEntity] = useState<Entity<M> | undefined>(undefined);\n\n // The record as it was last delivered. A live read that stops delivering\n // it — someone deleted it — is not a record that was never there: as in\n // the CMS's own edit view, the form keeps showing it, with what was typed,\n // and says so. Without this the form lost its record mid-edit and threw.\n const [lastSeenEntity, setLastSeenEntity] = useState<Entity<M> | undefined>(undefined);\n useEffect(() => {\n if (entity) setLastSeenEntity(entity);\n }, [entity]);\n // \"Save as new\": the same values, in a form that creates a record. Counted,\n // so that each one is a fresh form.\n const [asNew, setAsNew] = useState<{ values: Partial<M>, n: number, saved?: Entity<M> } | null>(null);\n const typedValues = useRef<Partial<M> | undefined>(undefined);\n const deletedElsewhere = !asNew && entityId !== undefined && !dataLoading && !entity\n && lastSeenEntity !== undefined && String(lastSeenEntity.id) === String(entityId);\n const shownEntity = deletedElsewhere ? lastSeenEntity : (entity ?? savedEntity);\n\n const navigateBack = useCallback(() => onClose?.(), [onClose]);\n const saveAsNew = useCallback(() => {\n const values: Partial<M> = typedValues.current ?? lastSeenEntity?.values ?? {};\n setAsNew(previous => ({ values, n: (previous?.n ?? 0) + 1 }));\n }, [lastSeenEntity]);\n\n if (!collection) {\n if (navigationState.loading) return <CircularProgressCenter/>;\n return <PanelNotFound className={className}/>;\n }\n\n if (asNew) {\n return (\n <CollectionScopeProvider collection={collection}>\n <EntityFormBinding<M>\n {...formProps}\n key={`as-new-${asNew.n}`}\n className={className ?? formProps?.className}\n path={path}\n collection={collection}\n row={asNew.saved ? rowOfEntity(asNew.saved, collection) : undefined}\n initialStatus={\"new\"}\n initialDirtyValues={asNew.values}\n fields={fields}\n layout={children}\n compact={compact}\n disabled={!canCreate(collection, path) || formProps?.disabled}\n onRowChange={(changed) => {\n // The record it created, which it edits from then on.\n const saved = entityOfRow(changed.row, changed.id, path, collection) as Entity<M>;\n setAsNew(current => current && { ...current, saved });\n formProps?.onRowChange?.(changed);\n }}\n onSaved={(params) => {\n formProps?.onSaved?.(params);\n onSaved?.(params);\n }}\n navigateBack={navigateBack}\n />\n </CollectionScopeProvider>\n );\n }\n\n if (entityId !== undefined && dataLoadingError) {\n return <CenteredView className={className}><ErrorView error={dataLoadingError}/></CenteredView>;\n }\n if (entityId !== undefined && !shownEntity && dataLoading) return <CircularProgressCenter/>;\n\n // An id no record has yet is a record to create under that id. The form\n // keeps the status it opened with, so once it creates the record it edits\n // it from then on.\n const creating = shownEntity === undefined;\n // As the CMS's own New button and save actions: a record to create needs\n // canCreate (false while access is simulated), an existing one canEdit.\n const editable = creating ? canCreate(collection, path) : canEdit(collection, path, shownEntity?.values ?? null);\n\n return (\n <CollectionScopeProvider collection={collection}>\n <EntityFormBinding<M>\n {...formProps}\n className={className ?? formProps?.className}\n path={path}\n collection={collection}\n id={entityId}\n row={shownEntity ? rowOfEntity(shownEntity, collection) : undefined}\n initialStatus={creating ? \"new\" : \"existing\"}\n initialDirtyValues={creating ? defaultValues : formProps?.initialDirtyValues}\n fields={fields}\n layout={children}\n compact={compact}\n disabled={!editable || formProps?.disabled}\n onRowChange={(changed) => {\n setSavedEntity(entityOfRow(changed.row, changed.id, path, collection) as Entity<M>);\n formProps?.onRowChange?.(changed);\n }}\n onValuesModified={(modified, values) => {\n typedValues.current = values;\n formProps?.onValuesModified?.(modified, values);\n }}\n onSaved={(params) => {\n formProps?.onSaved?.(params);\n onSaved?.(params);\n }}\n navigateBack={navigateBack}\n >\n {deletedElsewhere &&\n <Alert color={\"warning\"} size={\"small\"} outerClassName={\"w-full mb-4\"}\n action={<Button size={\"small\"} variant={\"text\"} onClick={saveAsNew}>{t(\"save_as_new\")}</Button>}>\n {t(\"entity_deleted_elsewhere\")}\n </Alert>}\n {formProps?.children}\n </EntityFormBinding>\n </CollectionScopeProvider>\n );\n}\n\n/**\n * What {@link EntityFormPanel}'s `onSaved` is called with: {@link OnSavedParams},\n * and the saved record as 0.28 handed it over.\n *\n * @deprecated Use {@link RecordForm}, whose `onSaved` gets {@link OnSavedParams}.\n * @group Components\n */\nexport type EntityFormPanelSavedParams = OnSavedParams & {\n /** @deprecated The saved record as an `Entity`: read `row` and `id`. It warns once. */\n entity: Entity<Record<string, unknown>>;\n};\n\n/**\n * @deprecated Renamed {@link RecordForm}. It also takes 0.28's `entityId`\n * for `id`, and hands `onSaved` the saved record as `entity` beside `row` and\n * `id`. It warns once.\n * @group Components\n */\nexport type EntityFormPanelProps<M extends Record<string, unknown> = Record<string, unknown>> =\n Omit<RecordFormProps<M>, \"onSaved\"> & {\n /** @deprecated The record to edit is `id`. It warns once. */\n entityId?: string | number;\n /** Called after every successful save, with the saved record. */\n onSaved?: (params: EntityFormPanelSavedParams) => void;\n };\n\n/**\n * @deprecated Renamed {@link RecordForm}. It also takes 0.28's `entityId`\n * for `id`, and hands `onSaved` the saved record as `entity` beside `row` and\n * `id`. It warns once.\n * @group Components\n */\nexport function EntityFormPanel<M extends Record<string, unknown> = Record<string, unknown>>({\n entityId,\n onSaved,\n ...props\n}: EntityFormPanelProps<M>) {\n warnDeprecated(\"EntityFormPanel\", \"`EntityFormPanel` is now `RecordForm`, with the same props.\");\n if (entityId !== undefined) {\n warnDeprecated(\"EntityFormPanel.entityId\", \"`EntityFormPanel`'s `entityId` is `id` now: `<RecordForm id=\\\"…\\\"/>`.\");\n }\n const onSavedWithEntity = onSaved && ((params: OnSavedParams) => {\n let entity: Entity<Record<string, unknown>> | undefined;\n onSaved({\n ...params,\n get entity() {\n warnDeprecated(\"EntityFormPanel.onSaved.entity\", \"`EntityFormPanel`'s `onSaved` hands over the saved record as `row` and `id` now; `entity` is going away.\");\n entity ??= entityOfRow(params.row, params.id, params.path, params.collection);\n return entity;\n }\n });\n });\n return <RecordForm<M> {...props} id={props.id ?? entityId} onSaved={onSavedWithEntity}/>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8IA,SAAgB,WAAwE,UAA8B;CAClH,MAAM,UAAU,WAAW,uBAAuB;CAClD,MAAM,qBAAqB,gCAAgC;CAC3D,MAAM,kBAAkB,6BAA6B;CACrD,MAAM,EAAE,YAAY,SAAS,iBAAqC,SAAS,YAAY,SAAS,IAAI;CACpG,MAAM,QAAyD;EAAE,GAAG;EAAU;EAAY;CAAK;CAC/F,MAAM,iBAAiB,cAAc,aAAa,CAAC,UAAU,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC;CAKjF,MAAM,gBAAgB,eAAe,KAAA,MAAc,CAAC,WAC5C,CAAC,gBAAgB,WAAW,CAAC,aAAa,mBAAmB,aAAa,IAAI;CAKtF,MAAM,YAAY,GAAG,KAAK,GAAG,MAAM,MAAM;CAGzC,IAAI,CAAC,WAAW,eAAe,KAAA,GAAW,OAAO,oBAAC,eAAD,EAAe,WAAW,MAAM,UAAW,CAAA;CAC5F,IAAI,eACA,OACI,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E,OAAO;GACX;EACJ,CAAC;CACL;CACA,OAAO,oBAAC,YAAD;EAAe,GAAI;EAAO,IAAI,MAAM,MAAM;EAAU,SAAS;CAAmB,CAAA;AAC3F"}
@@ -1 +1 @@
1
- {"version":3,"file":"RelationSelector.js","names":[],"sources":["../../src/components/RelationSelector.tsx"],"sourcesContent":["\nimport {\n ArrowRightToLineIcon,\n CheckIcon,\n ChevronDownIcon,\n Chip,\n CircularProgress,\n cls,\n defaultBorderMixin,\n fieldBackgroundDisabledMixin,\n fieldBackgroundHoverMixin,\n fieldBackgroundInvisibleMixin,\n fieldBackgroundMixin,\n focusedDisabled,\n IconButton,\n iconSize,\n PlusIcon,\n PopoverPrimitive,\n SearchIcon,\n Separator,\n Tooltip,\n usePortalContainer,\n XIcon\n} from \"@rebasepro/ui\";\nimport * as React from \"react\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport { Command as CommandPrimitive } from \"cmdk\";\nimport { Entity, EntityRelation, FilterValues, Relation, getCollectionDataPath } from \"@rebasepro/types\";\nimport { EntityPreviewBindingData } from \"./EntityPreviewBinding\";\nimport { PickerTrigger } from \"./PickerTrigger\";\nimport { getTitlePropertyKey, useData, usePermissions, useRelationSelector, useTranslation } from \"@rebasepro/app\";\nimport { useSidePanel } from \"../hooks/useSidePanel\";\nimport { normalizeToEntityRelation } from \"@rebasepro/common\";\nimport { findEntitiesByIds } from \"../util/find_entities_by_ids\";\nimport { entityOfRow } from \"@rebasepro/app\";\n\n/** Whether an authored relation yields many rows. Derived from its kind. */\nfunction relationCardinality(relation: { kind?: string; cardinality?: string } | undefined): \"one\" | \"many\" | undefined {\n if (!relation) return undefined;\n if (relation.kind === \"via\") return relation.cardinality as \"one\" | \"many\" | undefined;\n if (relation.kind === \"hasMany\" || relation.kind === \"manyToMany\") return \"many\";\n if (relation.kind === \"belongsTo\" || relation.kind === \"hasOne\") return \"one\";\n return relation.cardinality as \"one\" | \"many\" | undefined;\n}\n\n\nexport interface RelationItem {\n id: string | number;\n label: string;\n description?: string;\n data?: Entity;\n relation: EntityRelation;\n}\n\nexport interface RelationSelectorProps {\n className?: string;\n name?: string;\n id?: string;\n value?: EntityRelation | EntityRelation[] | null;\n /** Callback returning selected EntityRelation(s) */\n\n onValueChange?: (updatedValue: EntityRelation | EntityRelation[] | undefined) => void;\n placeholder?: React.ReactNode;\n /**\n * `large` is the form's size and is on the shared 28/32/40/48 control\n * scale, so a relation picker lines up with the text field beside it.\n *\n * `small` and `medium` predate that scale (42 and 56) and are kept as they\n * are because the filter row is built around them. A table cell passes\n * `triggerContent` instead, and has no size of its own.\n */\n size?: \"small\" | \"medium\" | \"large\";\n useChips?: boolean;\n disabled?: boolean;\n invisible?: boolean;\n\n relation: Relation;\n /**\n * Whether the selector picks many rows or one.\n *\n * Defaults to what the relation implies — a `hasMany` or `manyToMany`\n * picks many — which is right wherever the selector *edits* the relation,\n * because there the cardinality is the shape of the stored value.\n *\n * A filter is the case where it is not. `tags == <one tag>` asks a single\n * question about a to-many link, and the operator is what decides how many\n * values it takes. Deriving multiplicity from the relation there meant a\n * to-many relation could only ever emit a list, so the filter field had to\n * hide every single-value operator to avoid handing `==` an array.\n */\n multiple?: boolean;\n fixedFilter?: FilterValues<string>;\n pageSize?: number;\n emptyPlaceholder?: string;\n searchPlaceholder?: string;\n /** Shown in the open list when a search matched nothing. */\n noResultsText?: string;\n /**\n * Shown on the closed trigger when nothing is selected. Says only that the\n * field is empty — see the note by `resolvedPlaceholder` for why it cannot\n * say whether there is anything to pick.\n */\n emptyText?: string;\n /**\n * Shown in the open list when the target collection turned out to hold no\n * rows at all, as opposed to a search simply not matching. Defaults to a\n * sentence naming the target collection.\n */\n emptyCollectionText?: string;\n loadingText?: string;\n /**\n * Whether the list is open, for a caller that opens it from outside the\n * trigger — a table cell's opener. Every open and close the selector\n * makes itself is reported through `onOpenChange`, controlled or not.\n */\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n /**\n * Replaces everything the trigger draws — the value, the box, its padding\n * and the chevron — with this node. For a caller that frames the picker\n * itself: a table cell passes the preview it shows at rest, so the cell\n * looks the same whether the picker is mounted, closed or open.\n */\n triggerContent?: React.ReactNode;\n /**\n * Positions the list against this element instead of the trigger. A\n * table cell passes itself: the trigger inside it can be taller than the\n * cell that clips it, and the list belongs under what can be seen.\n */\n anchorRef?: React.RefObject<HTMLElement | null>;\n /**\n * Whether the open list offers to create a row in the target collection.\n * Defaults to `true`. The offer is shown only when the user could actually\n * insert into that collection — the same permission check the selection\n * dialog's \"Add\" button makes — so turning this off is for the cases where\n * creating is possible but not wanted, like a filter.\n */\n allowCreate?: boolean;\n}\n\nexport const RelationSelector = React.forwardRef<\n HTMLElement,\n RelationSelectorProps\n>(\n (\n {\n value,\n size = \"medium\",\n onValueChange,\n invisible,\n disabled,\n placeholder,\n useChips = true,\n className,\n relation,\n multiple: multipleOverride,\n fixedFilter,\n pageSize,\n emptyPlaceholder,\n searchPlaceholder = \"Search...\",\n noResultsText = \"No matches.\",\n emptyText = \"Select…\",\n emptyCollectionText,\n loadingText = \"Loading...\",\n allowCreate = true,\n open: openProp,\n onOpenChange,\n triggerContent,\n anchorRef\n },\n ref\n ) => {\n\n const collection = relation.target();\n const dataPath = getCollectionDataPath(collection);\n const dataClient = useData();\n const sidePanelController = useSidePanel();\n const { canCreate } = usePermissions();\n const { t } = useTranslation();\n const contextPortalContainer = usePortalContainer();\n const multiple = multipleOverride ?? relationCardinality(relation) === \"many\";\n\n const [isPopoverOpen, setIsPopoverOpenState] = useState(false);\n const isPopoverOpenRef = useRef(false);\n // The list is only worth fetching once the picker has been opened. A\n // table cell mounts one of these per row, and the selected value is\n // resolved by its own effect below, not from the list. Latches on the\n // first open so a closed popover keeps its results.\n const [listRequested, setListRequested] = useState(false);\n const [selectedItems, setSelectedItems] = useState<RelationItem[]>([]);\n const [isLoadingSelectedItems, setIsLoadingSelectedItems] = useState(false);\n const [searchString, setSearchString] = useState<string>(\"\");\n\n // Track IDs that were set via local user interaction (onItemClick / handleClear / handleRemoveItem).\n // When an incoming value change matches these IDs exactly, we skip async re-resolution.\n const localSelectionIdsRef = useRef<string | null>(null);\n // Entity of selected IDs captured when the popover opens.\n // Used to sort the dropdown list so selected items appear at the top.\n // Stays stable for the entire popover session so items don't jump around.\n const pinnedIdsRef = useRef<Set<string> | null>(null);\n\n const selectedItemsForPinRef = useRef<RelationItem[]>([]);\n selectedItemsForPinRef.current = selectedItems;\n const onOpenChangeRef = useRef(onOpenChange);\n onOpenChangeRef.current = onOpenChange;\n\n // Every open and close goes through here. Opening pins the current\n // selection to the top of the list for as long as it stays open, and\n // is what first requests the list at all.\n const setPopoverOpen = useCallback((next: boolean, notify = true) => {\n if (next) {\n // From the value as well as the resolved items: a picker a\n // table cell mounts already open has not resolved them yet.\n pinnedIdsRef.current = new Set([\n ...selectedItemsForPinRef.current.map(i => String(i.id)),\n ...relationsArrayRef.current.map(rel =>\n String(typeof rel === \"string\" || typeof rel === \"number\" ? rel : rel.id))\n ]);\n setListRequested(true);\n } else {\n pinnedIdsRef.current = null;\n }\n const changed = isPopoverOpenRef.current !== next;\n isPopoverOpenRef.current = next;\n setIsPopoverOpenState(next);\n if (changed && notify) onOpenChangeRef.current?.(next);\n }, []);\n\n useEffect(() => {\n if (openProp === undefined || openProp === isPopoverOpenRef.current) return;\n if (openProp && disabled) {\n onOpenChangeRef.current?.(false);\n return;\n }\n setPopoverOpen(openProp, false);\n }, [openProp, disabled, setPopoverOpen]);\n\n const {\n items: availableItems,\n isLoading,\n hasMore,\n search,\n loadMore,\n entityToRelationItem\n } = useRelationSelector({\n path: dataPath,\n collection,\n fixedFilter,\n pageSize,\n enabled: listRequested\n });\n\n const scrollContainerRef = useRef<HTMLDivElement>(null);\n const sentinelRef = useRef<HTMLDivElement>(null);\n const observerRef = useRef<IntersectionObserver | null>(null);\n const localTriggerRef = useRef<HTMLElement | null>(null);\n\n const handleButtonRef = useCallback((node: HTMLElement | null) => {\n localTriggerRef.current = node;\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n ref.current = node;\n }\n }, [ref]);\n const contentRef = useRef<HTMLDivElement | null>(null);\n const searchInputRef = useRef<HTMLInputElement | null>(null);\n\n // Keep stable refs for dependencies used in the value-resolution effect\n // so the effect only re-fires when the actual `value` identity changes.\n const dataClientRef = useRef(dataClient);\n dataClientRef.current = dataClient;\n const entityToRelationItemRef = useRef(entityToRelationItem);\n entityToRelationItemRef.current = entityToRelationItem;\n const collectionSlugRef = useRef(collection.slug);\n collectionSlugRef.current = collection.slug;\n const collectionRef = useRef(collection);\n collectionRef.current = collection;\n\n // Stable ref to track which IDs we've already resolved\n const resolvedIdsRef = useRef<string>(\"\");\n // Track whether we have resolved items (used for skip guard without adding to deps)\n const hasResolvedItemsRef = useRef(false);\n\n const selectedItemsRef = useRef(selectedItems);\n selectedItemsRef.current = selectedItems;\n\n // Normalize incoming values — plain { __type: \"relation\" } objects\n // from the server are converted to proper EntityRelation instances.\n const rawArray = !value ? [] : Array.isArray(value) ? value : [value];\n const relationsArray = rawArray.map(rel => {\n if (typeof rel === \"string\" || typeof rel === \"number\") return rel;\n return normalizeToEntityRelation(rel) ?? rel;\n });\n\n // Build a fingerprint of the incoming value's IDs\n const incomingIds = relationsArray\n .map(rel => {\n const isPrimitive = typeof rel === \"string\" || typeof rel === \"number\";\n return String(isPrimitive ? rel : (rel as EntityRelation).id);\n })\n .sort()\n .join(\",\");\n\n // CheckIcon if every relation already has embedded data\n const allHaveData = relationsArray.length > 0 && relationsArray.every(rel => {\n if (typeof rel === \"string\" || typeof rel === \"number\") return false;\n return !!(rel as EntityRelation)?.data;\n });\n\n const relationsArrayRef = useRef(relationsArray);\n relationsArrayRef.current = relationsArray;\n\n useEffect(() => {\n let active = true;\n const currentRelationsArray = relationsArrayRef.current;\n\n // If the IDs haven't changed and we already resolved them, skip entirely\n if (incomingIds === resolvedIdsRef.current && (allHaveData || hasResolvedItemsRef.current)) {\n return;\n }\n\n // FAST PATH: If the incoming IDs match what we just set locally via user interaction,\n // our selectedItems already have the correct data — no re-resolution needed.\n //\n // The fingerprint answers for one echo only, and is dropped on the\n // first incoming value whether it matches or not. Kept, it also\n // matched a *later* return to the same ids — pick A, discard to B,\n // undo back to A — and the chip went on showing B.\n const localSelectionIds = localSelectionIdsRef.current;\n localSelectionIdsRef.current = null;\n if (localSelectionIds !== null && incomingIds === localSelectionIds) {\n resolvedIdsRef.current = incomingIds;\n hasResolvedItemsRef.current = true;\n // Do NOT call setSelectedItems or setIsLoadingSelectedItems — they are already correct.\n return;\n }\n\n const currentSelected = selectedItemsRef.current;\n const currentSelectedMap = new Map(currentSelected.map(item => [String(item.id), item]));\n\n let allCovered = true;\n const newResolvedItems: RelationItem[] = [];\n const toRelationItem = entityToRelationItemRef.current;\n const slug = collectionSlugRef.current;\n\n for (const rel of currentRelationsArray) {\n const isPrimitive = typeof rel === \"string\" || typeof rel === \"number\";\n const relId = String(isPrimitive ? rel : (rel as EntityRelation).id);\n const hasEmbeddedData = !isPrimitive && !!(rel as EntityRelation).data;\n\n if (hasEmbeddedData) {\n const r = rel as EntityRelation;\n // admin wire format embeds relation data as { id, path, values }\n newResolvedItems.push(toRelationItem(r.data as unknown as Entity, r));\n } else if (currentSelectedMap.has(relId)) {\n // We already have it in currentSelected\n const existingItem = currentSelectedMap.get(relId)!;\n newResolvedItems.push(existingItem);\n } else {\n allCovered = false;\n break;\n }\n }\n\n // FAST PATH: We have all necessary data embedded or in local cache\n if (allCovered) {\n setSelectedItems(newResolvedItems);\n hasResolvedItemsRef.current = true;\n resolvedIdsRef.current = incomingIds;\n setIsLoadingSelectedItems(false);\n return;\n }\n\n // SLOW PATH: fetch missing data — but don't show loading if popover is open\n // (user is actively interacting; showing a spinner is disruptive)\n if (!isPopoverOpenRef.current) {\n setIsLoadingSelectedItems(true);\n }\n const client = dataClientRef.current;\n const target = collectionRef.current;\n\n // The ids nothing above resolves, by the path they are read at:\n // one request per path (per 1,000 ids), not one per id.\n const unresolved = new Map<string, (string | number)[]>();\n for (const rel of currentRelationsArray) {\n const isPrimitive = typeof rel === \"string\" || typeof rel === \"number\";\n const relId = isPrimitive ? rel : (rel as EntityRelation).id;\n if (!isPrimitive && (rel as EntityRelation).data) continue;\n if (currentSelectedMap.has(String(relId))) continue;\n const path = isPrimitive ? slug : (rel as EntityRelation).path;\n unresolved.set(path, [...(unresolved.get(path) ?? []), relId]);\n }\n\n Promise.all(\n [...unresolved].map(async ([path, ids]): Promise<[string, Map<string, Entity>]> => {\n try {\n return [path, await findEntitiesByIds(client.collection(path), target, ids)];\n } catch (e) {\n console.warn(\"RelationSelector: could not fetch the entities for relations\", path, ids, e);\n return [path, new Map()];\n }\n })\n ).then(read => {\n const readByPath = new Map(read);\n return currentRelationsArray.map((rel) => {\n const isPrimitive = typeof rel === \"string\" || typeof rel === \"number\";\n const relId = isPrimitive ? rel : (rel as EntityRelation).id;\n const path = isPrimitive ? slug : (rel as EntityRelation).path;\n const relation = isPrimitive ? new EntityRelation(relId, path) : rel as EntityRelation;\n\n if (!isPrimitive && (rel as EntityRelation).data) {\n // admin wire format embeds relation data as { id, path, values }\n return toRelationItem((rel as EntityRelation).data as unknown as Entity, relation);\n }\n if (currentSelectedMap.has(String(relId))) {\n return currentSelectedMap.get(String(relId))!;\n }\n const entity = readByPath.get(path)?.get(String(relId));\n if (entity) return toRelationItem(entity, relation);\n return { id: relId,\nlabel: String(relId),\nrelation } as RelationItem;\n });\n }).then(resolved => {\n if (active) {\n setSelectedItems(resolved);\n setIsLoadingSelectedItems(false);\n hasResolvedItemsRef.current = true;\n resolvedIdsRef.current = incomingIds;\n }\n });\n\n return () => {\n active = false;\n };\n }, [incomingIds, allHaveData]);\n\n const sentinelCallbackRef = useCallback((node: HTMLDivElement | null) => {\n if (observerRef.current) {\n observerRef.current.disconnect();\n observerRef.current = null;\n }\n if (sentinelRef.current !== node) {\n (sentinelRef as React.MutableRefObject<HTMLDivElement | null>).current = node;\n }\n if (!node || !hasMore || isLoading || !loadMore) return;\n const observer = new IntersectionObserver(\n (entries) => {\n const entry = entries[0];\n if (entry.isIntersecting && hasMore && !isLoading) loadMore();\n },\n {\n root: scrollContainerRef.current,\n rootMargin: \"20px\",\n threshold: 0\n }\n );\n observer.observe(node);\n observerRef.current = observer;\n }, [hasMore, isLoading, loadMore]);\n\n useEffect(() => () => {\n if (observerRef.current) observerRef.current.disconnect();\n }, []);\n\n // Enhanced scroll event listener specifically for dialog contexts\n useEffect(() => {\n const scrollContainer = scrollContainerRef.current;\n if (!scrollContainer || !hasMore || isLoading || !isPopoverOpen) return;\n\n const handleScroll = () => {\n const { scrollTop, scrollHeight, clientHeight } = scrollContainer;\n const isNearBottom = scrollTop + clientHeight >= scrollHeight - 100;\n\n if (isNearBottom && hasMore && !isLoading) {\n loadMore();\n }\n };\n\n // Add scroll listener directly to the container\n scrollContainer.addEventListener(\"scroll\", handleScroll, { passive: true });\n\n return () => {\n scrollContainer.removeEventListener(\"scroll\", handleScroll);\n };\n }, [hasMore, isLoading, loadMore, isPopoverOpen]);\n\n const handleSearchChange = useCallback((newSearchString: string) => {\n setSearchString(newSearchString);\n search(newSearchString);\n }, [search]);\n\n const emitValueChange = useCallback((selected: RelationItem[]) => {\n if (multiple) onValueChange?.(selected.length ? selected.map(i => i.relation) : undefined);\n else onValueChange?.(selected[0]?.relation);\n }, [onValueChange, multiple]);\n\n // The picker can hand its selection over long after the render that\n // built the callback — a row created in the side panel arrives whenever\n // the person saves it — so the emitter is read from a ref rather than\n // captured.\n const emitValueChangeRef = useRef(emitValueChange);\n emitValueChangeRef.current = emitValueChange;\n\n // Helper: compute the \"IDs fingerprint\" for a set of RelationItems\n // so we can mark it in localSelectionIdsRef and skip re-resolution.\n const computeSelectionFingerprint = useCallback((items: RelationItem[]): string => {\n return items.map(i => String(i.id)).sort().join(\",\");\n }, []);\n\n const onItemClick = useCallback((item: RelationItem) => {\n let newSelected: RelationItem[];\n if (multiple) {\n const isSelected = selectedItems.some(v => String(v.id) === String(item.id));\n newSelected = isSelected\n ? selectedItems.filter(v => String(v.id) !== String(item.id))\n : [...selectedItems, item];\n } else {\n newSelected = [item];\n setPopoverOpen(false);\n }\n setSelectedItems(newSelected);\n // Mark this fingerprint so the resolution effect skips async work\n // when the parent echoes the same IDs back via props.\n localSelectionIdsRef.current = computeSelectionFingerprint(newSelected);\n emitValueChange(newSelected);\n }, [multiple, selectedItems, emitValueChange, computeSelectionFingerprint, setPopoverOpen]);\n\n const handleClear = useCallback(() => {\n setSelectedItems([]);\n localSelectionIdsRef.current = \"\";\n onValueChange?.(undefined);\n }, [onValueChange]);\n\n const handleRemoveItem = useCallback((itemToRemove: RelationItem) => {\n const newSelected = selectedItems.filter(v => String(v.id) !== String(itemToRemove.id));\n setSelectedItems(newSelected);\n localSelectionIdsRef.current = computeSelectionFingerprint(newSelected);\n emitValueChange(newSelected);\n }, [selectedItems, emitValueChange, computeSelectionFingerprint]);\n\n const handleRootOpenChange = useCallback((next: boolean) => {\n if (disabled) return;\n // We control open manually; only allow opening attempts from Radix (e.g. trigger press)\n if (next) setPopoverOpen(true);\n // Ignore close attempts here; outside click/Escape handled manually; single select closes explicitly on selection.\n }, [disabled, setPopoverOpen]);\n\n // Outside click + Escape handling (simple and reliable)\n useEffect(() => {\n if (!isPopoverOpen) return;\n\n function handlePointerDown(ev: MouseEvent) {\n const target = ev.target as Node;\n const triggerEl = localTriggerRef.current;\n const contentEl = contentRef.current;\n if (triggerEl?.contains(target)) return;\n if (contentEl?.contains(target)) return;\n // Outside\n setPopoverOpen(false);\n }\n\n // A layer of its own, so capture phase — and it claims the Escape\n // it acts on, so the record view underneath leaves the record open.\n function handleKey(ev: KeyboardEvent) {\n if (ev.key !== \"Escape\") return;\n ev.preventDefault();\n setPopoverOpen(false);\n }\n\n document.addEventListener(\"mousedown\", handlePointerDown, true);\n document.addEventListener(\"keydown\", handleKey, true);\n return () => {\n document.removeEventListener(\"mousedown\", handlePointerDown, true);\n document.removeEventListener(\"keydown\", handleKey, true);\n };\n }, [isPopoverOpen, setPopoverOpen]);\n\n const closePopover = useCallback(() => setPopoverOpen(false), [setPopoverOpen]);\n\n const toggleOpen = useCallback(() => {\n if (disabled) return;\n setPopoverOpen(!isPopoverOpenRef.current);\n }, [disabled, setPopoverOpen]);\n\n // Pointing at a row that does not exist yet.\n //\n // Until now the only way out of that was to abandon the form, go to the\n // other collection, create the row, come back and start again — and on\n // a new record that meant losing everything typed so far. The side\n // panel already stacks (the selection dialog creates from inside itself\n // this way), so the picker can open a create form over the form it\n // belongs to and select what comes back.\n const canCreateTarget = allowCreate && canCreate(collection, dataPath);\n\n // A search that matched nothing is the name the person was looking for,\n // so it seeds the new row. Only when the title lands on a plain string\n // property: putting free text into an enum, a relation or a computed\n // property would be worse than not prefilling at all.\n const buildDefaultValues = useCallback((searchText: string): Record<string, unknown> | undefined => {\n const trimmed = searchText.trim();\n if (!trimmed) return undefined;\n const titleKey = getTitlePropertyKey(collection);\n if (!titleKey || titleKey.includes(\".\")) return undefined;\n const titleProperty = collection.properties?.[titleKey];\n // A property builder is a function, and it decides its own value.\n if (!titleProperty || typeof titleProperty === \"function\") return undefined;\n if (titleProperty.type !== \"string\" || titleProperty.enum) return undefined;\n return { [titleKey]: trimmed };\n }, [collection]);\n\n const handleCreateNew = useCallback(() => {\n const defaultValues = buildDefaultValues(searchString);\n closePopover();\n sidePanelController.open({\n path: dataPath,\n collection,\n // No URL. This panel is a detour inside the form you are\n // filling in, not somewhere you navigated to, and its address\n // would restore nothing anyway — a record that does not exist\n // yet has none.\n //\n // Pushing one made closing it a *pathname* change, which is\n // exactly what the unsaved-changes blocker watches\n // (`useUnsavedChangesDialog`). So saving the new row raced the\n // panel clearing its own dirty flag, and often enough lost:\n // \"There are unsaved changes\" over a record that had just been\n // saved, with the URL stranded on the target collection. Worst\n // of all in the case this feature exists for — the outer form\n // has content in it, which is the whole reason not to leave.\n updateUrl: false,\n // Saving is the whole point of the detour; the panel goes away\n // and the picker is left holding the row it made.\n closeOnSave: true,\n defaultValues,\n onSaved: ({ row, id }) => {\n const entity = entityOfRow(row, id, dataPath, collection);\n const item = entityToRelationItemRef.current(entity, new EntityRelation(entity.id, dataPath));\n const current = selectedItemsRef.current;\n const newSelected = multiple\n ? [...current.filter(i => String(i.id) !== String(item.id)), item]\n : [item];\n setSelectedItems(newSelected);\n // Same bookkeeping `onItemClick` does: mark the fingerprint\n // so the resolution effect does not re-fetch the row we\n // already hold when the form echoes the value back.\n localSelectionIdsRef.current = newSelected.map(i => String(i.id)).sort().join(\",\");\n emitValueChangeRef.current(newSelected);\n }\n });\n }, [buildDefaultValues, searchString, closePopover, sidePanelController, dataPath, collection, multiple]);\n\n // Text, not `EmptyValue`. That component draws a small grey rounded bar\n // with no text in it, which is the same shape the `Skeleton` component\n // uses while data is in flight — so a relation you simply had not filled\n // in was indistinguishable from one that was still loading, and an empty\n // Author or Tags field read as permanently stuck. It also left the trigger\n // button with no accessible name, since the bar contains no text at all.\n //\n // This says \"not filled in\" rather than \"nothing to choose from\": which of\n // those it is cannot be known here. The list is deliberately not fetched\n // until the picker is first opened (`enabled: listRequested`, guarded by\n // relation_cell_picker_gating.test.tsx, because a table renders one of\n // these per row), so before that `availableItems` is empty because nobody\n // asked, not because the target collection is. The genuine \"nothing to\n // pick yet\" state is reported inside the popover below, where the fetch\n // has actually happened.\n const resolvedPlaceholder = placeholder || emptyPlaceholder || emptyText;\n\n // Whatever dialog, side dialog or sheet we are inside offers as its\n // portal host, falling back to `document.body`. This is not cosmetic:\n // those are modal, and a modal locks scrolling everywhere outside its\n // own content — a list portaled to the body opens and then refuses to\n // scroll, because every wheel event over it is cancelled.\n const portalContainer = (contextPortalContainer ?? (typeof document !== \"undefined\" ? document.body : undefined)) ?? undefined;\n\n return (\n <>\n <PopoverPrimitive.Root open={isPopoverOpen} onOpenChange={handleRootOpenChange} modal={false}>\n <PickerTrigger anchorRef={anchorRef}>\n {triggerContent !== undefined\n // Bare: the caller frames it. No box, no padding,\n // no height of its own — the node it passed,\n // exactly where it would be anyway. A `div`, not a\n // `button`: what it wraps can hold buttons of its\n // own (a record card's open button, at tall rows).\n ? <div\n ref={handleButtonRef}\n role=\"button\"\n tabIndex={disabled ? -1 : 0}\n aria-disabled={disabled || undefined}\n aria-haspopup=\"listbox\"\n aria-expanded={isPopoverOpen}\n data-relation-selector-trigger\n onClick={toggleOpen}\n // A record's title in the value opens that\n // record, and the list has no business staying\n // open over it.\n onClickCapture={(event) => {\n const target = event.target;\n if (!(target instanceof Element) || !isPopoverOpenRef.current) return;\n const interactive = target.closest(\"a, button, [role=\\\"button\\\"]\");\n if (interactive && interactive !== event.currentTarget) setPopoverOpen(false);\n }}\n onKeyDown={(event) => {\n if (event.key !== \"Enter\" && event.key !== \" \") return;\n event.preventDefault();\n toggleOpen();\n }}\n className={cls(\"w-full select-none text-left text-sm relative flex items-center outline-none\", className)}>\n {triggerContent}\n </div>\n : <button\n ref={handleButtonRef}\n type=\"button\"\n aria-haspopup=\"listbox\"\n aria-expanded={isPopoverOpen}\n data-relation-selector-trigger\n disabled={disabled}\n onClick={toggleOpen}\n className={cls(\n {\n \"min-h-[42px] py-1 px-2\": size === \"small\",\n \"min-h-[56px] py-2 px-4\": size === \"medium\",\n \"min-h-[48px] py-1 px-4\": size === \"large\"\n },\n // `rounded-lg` like every other field box —\n // `rounded-md` made this the one control in a\n // row with a different corner.\n \"w-full select-none rounded-lg text-sm relative flex items-center\",\n invisible ? fieldBackgroundInvisibleMixin : fieldBackgroundMixin,\n disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin,\n className\n )}\n >\n <div className=\"flex justify-between items-center w-full\">\n {isLoadingSelectedItems ? (\n <div className=\"flex items-center gap-2\">\n <CircularProgress size=\"smallest\"/>\n <span className=\"text-sm text-text-secondary dark:text-text-secondary-dark\">{loadingText}</span>\n </div>\n ) : selectedItems.length > 0 ? (\n <div\n className=\"flex flex-wrap items-center gap-1.5 text-start flex-1 min-w-0 mr-2\">\n {selectedItems.map((item) => {\n if (!useChips || !multiple) {\n return (\n <div key={String(item.id)}\n className=\"flex flex-row items-center gap-1 truncate\">\n {item.data ? (\n <EntityPreviewBindingData size={\"medium\"}\n entity={item.data}\n includeEntityLink={false}\n includeId={false}\n onSidePanelClick={closePopover}\n />\n ) : (\n <span className=\"text-sm truncate\">{item.label}</span>\n )}\n </div>\n );\n }\n return (\n <Chip\n size={\"small\"}\n key={String(item.id)}\n className={cls(\"flex flex-row items-center gap-1 truncate\")}\n >\n {item.data ? (\n <EntityPreviewBindingData size={\"smallest\"} entity={item.data}\n includeEntityLink={false}\n includeId={false}/>\n ) : (\n <span className=\"text-sm truncate\">{item.label}</span>\n )}\n <XIcon\n size={iconSize.smallest}\n onClick={(event) => {\n event.stopPropagation();\n handleRemoveItem(item);\n }}\n />\n </Chip>\n );\n })}\n </div>\n ) :\n (\n <span className=\"text-sm text-text-secondary dark:text-text-secondary-dark\">\n {resolvedPlaceholder}\n </span>\n )}\n\n <div className=\"flex items-center flex-shrink-0\">\n {!multiple && selectedItems.length === 1 && selectedItems[0]?.data && (\n <Tooltip title={t(\"relation_open_record\", { label: selectedItems[0].label })}>\n <IconButton aria-label={t(\"relation_open_record\", { label: selectedItems[0].label })}\n component={\"div\"}\n size={\"small\"}\n className=\"opacity-60 hover:opacity-100\"\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n const entity = selectedItems[0].data!;\n setPopoverOpen(false);\n sidePanelController.open({\n id: entity.id,\n path: entity.path,\n collection,\n updateUrl: true\n });\n }}>\n <ArrowRightToLineIcon size={iconSize.small}/>\n </IconButton>\n </Tooltip>\n )}\n <ChevronDownIcon\n size={size === \"small\" ? iconSize.small : iconSize.medium}\n className={cls(\"transition\", isPopoverOpen ? \"rotate-180\" : \"\")}\n />\n </div>\n </div>\n\n </button>}\n </PickerTrigger>\n <PopoverPrimitive.Portal container={portalContainer}>\n <PopoverPrimitive.Content\n ref={contentRef}\n data-relation-selector-content\n className={cls(\"z-50 overflow-hidden border bg-surface-card rounded-lg min-w-72\", defaultBorderMixin)}\n align=\"start\"\n sideOffset={8}\n side=\"bottom\"\n avoidCollisions={true}\n collisionPadding={16}\n // Allow default auto focus (we manually refocus anyway)\n onOpenAutoFocus={(_e) => { /* leave default or custom manual focus */\n }}\n onCloseAutoFocus={(e) => {\n e.preventDefault();\n }}\n style={{ width: \"var(--radix-popover-trigger-width)\" }}\n >\n <CommandPrimitive shouldFilter={false}>\n <div className=\"flex flex-row items-center\">\n <div className=\"relative flex-1\">\n <SearchIcon\n className=\"absolute left-3 top-1/2 transform -translate-y-1/2 text-text-secondary dark:text-text-secondary-dark\"\n size={iconSize.smallest}/>\n <CommandPrimitive.Input\n ref={searchInputRef}\n className={cls(\n focusedDisabled,\n \"bg-transparent outline-hidden flex-1 h-full w-full pl-10 pr-4 py-3 text-text-primary dark:text-text-primary-dark placeholder:text-text-secondary dark:placeholder:text-text-secondary-dark\"\n )}\n placeholder={searchPlaceholder}\n value={searchString}\n onValueChange={handleSearchChange}\n />\n </div>\n {isLoading && (\n <div className=\"flex items-center justify-center px-3\">\n <CircularProgress size=\"smallest\"/>\n </div>\n )}\n {selectedItems.length > 0 && (\n <div\n onClick={handleClear}\n className=\"text-sm justify-center cursor-pointer py-3 px-4 text-text-secondary dark:text-text-secondary-dark hover:text-text-primary dark:hover:text-text-primary-dark\"\n >\n Clear\n </div>\n )}\n </div>\n <Separator orientation=\"horizontal\" className=\"my-0\"/>\n <CommandPrimitive.List\n ref={scrollContainerRef}\n style={{\n maxHeight: \"40vh\",\n overflowY: \"auto\"\n }}\n >\n {isLoading && availableItems.length === 0 && (\n <div className=\"flex items-center justify-center py-6\">\n <CircularProgress size=\"small\"/>\n <span\n className=\"ml-2 text-sm text-text-secondary dark:text-text-secondary-dark\">{loadingText}</span>\n </div>\n )}\n {/* Two different nothings, which used to share one\n message (\"No relations found.\") even though the\n fix for each is the opposite: clear the search, or\n go and create the first row. With the fetch done,\n the search string is what tells them apart. */}\n {!isLoading && availableItems.length === 0 && (\n <CommandPrimitive.Empty\n className=\"px-4 py-6 text-center text-text-secondary dark:text-text-secondary-dark\">\n {searchString\n ? noResultsText\n : (emptyCollectionText ?? `No ${collection.name ?? \"entries\"} yet.`)}\n </CommandPrimitive.Empty>\n )}\n <CommandPrimitive.Group>\n {(() => {\n // Sort items so that initially-selected (pinned) items appear first.\n // We use the entity taken when the popover opened so items don't\n // jump around as the user checks/unchecks.\n const pinned = pinnedIdsRef.current;\n const sortedItems = pinned && pinned.size > 0\n ? [...availableItems].sort((a, b) => {\n const aP = pinned.has(String(a.id)) ? 0 : 1;\n const bP = pinned.has(String(b.id)) ? 0 : 1;\n return aP - bP;\n })\n : availableItems;\n return sortedItems;\n })().map((item) => {\n const isSelected = selectedItems.some(v => String(v.id) === String(item.id));\n return (\n <CommandPrimitive.Item\n key={String(item.id)}\n value={String(item.id)}\n onMouseDown={(e) => {\n e.preventDefault();\n e.stopPropagation();\n }}\n onSelect={() => onItemClick(item)}\n className={cls(\n \"flex flex-row items-center gap-1.5 m-1 p-1 rounded-xs cursor-pointer ring-offset-transparent\",\n isSelected && \"bg-surface-active\",\n \"aria-selected:outline-hidden aria-selected:bg-surface-active\"\n )}\n >\n {multiple && (<InnerCheckBox checked={isSelected}/>)}\n {item.data ? (\n <div\n className=\"flex flex-row items-center gap-2 min-w-0 w-full\">\n <EntityPreviewBindingData\n size={multiple ? \"smallest\" : \"medium\"}\n entity={item.data}\n includeId={false}\n includeEntityLink={true}\n />\n </div>\n ) : (\n <div>\n <div\n className=\"text-sm font-medium text-text-primary dark:text-text-primary-dark\">{item.label}</div>\n {item.description && (\n <div\n className=\"text-xs text-text-secondary dark:text-text-secondary-dark\">{item.description}</div>\n )}\n </div>\n )}\n </CommandPrimitive.Item>\n );\n })}\n {availableItems.length > 0 && hasMore && (\n <div ref={sentinelCallbackRef} className=\"h-1 w-full\"\n style={{ visibility: \"hidden\" }}/>\n )}\n {isLoading && availableItems.length > 0 && (\n <div className=\"flex items-center justify-center py-4\">\n <CircularProgress size=\"smallest\"/>\n <span\n className=\"ml-2 text-xs text-text-secondary dark:text-text-secondary-dark\">Loading...</span>\n </div>\n )}\n </CommandPrimitive.Group>\n </CommandPrimitive.List>\n {canCreateTarget && <>\n <Separator orientation=\"horizontal\" className=\"my-0\"/>\n {/* Outside the scrolling list on purpose: it\n is most wanted exactly when the list is\n long and nothing in it matched. */}\n <button\n type=\"button\"\n data-relation-selector-create\n onMouseDown={(e) => {\n e.preventDefault();\n e.stopPropagation();\n }}\n onClick={handleCreateNew}\n className={cls(\n \"w-full flex flex-row items-center gap-2 px-4 py-3 text-sm text-left\",\n \"text-primary hover:bg-surface-hover\"\n )}>\n <PlusIcon size={iconSize.smallest}/>\n <span className=\"truncate\">\n {searchString.trim()\n ? t(\"add_named\", { name: searchString.trim() })\n : t(\"add_specific\", { name: collection.singularName ?? collection.name })}\n </span>\n </button>\n </>}\n </CommandPrimitive>\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n </PopoverPrimitive.Root>\n </>\n );\n }\n);\n\nRelationSelector.displayName = \"RelationSelector\";\n\nfunction InnerCheckBox({ checked }: { checked: boolean }) {\n return (\n <div className={cls(\n \"p-2 w-8 h-8 inline-flex items-center justify-center text-sm font-medium focus:outline-hidden transition-colors ease-in-out duration-150\"\n )}>\n <div\n className={cls(\n \"border-2 relative transition-colors ease-in-out duration-150 w-4 h-4 rounded-xs flex items-center justify-center\",\n checked ? \"bg-primary text-surface-accent-100 dark:text-surface-accent-900 border-transparent\" : \"bg-surface-card border-surface-accent-800 dark:border-surface-accent-500\"\n )}\n >\n {checked && <CheckIcon size={iconSize.smallest} className=\"absolute\"/>}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAqCA,SAAS,oBAAoB,UAA2F;CACpH,IAAI,CAAC,UAAU,OAAO,KAAA;CACtB,IAAI,SAAS,SAAS,OAAO,OAAO,SAAS;CAC7C,IAAI,SAAS,SAAS,aAAa,SAAS,SAAS,cAAc,OAAO;CAC1E,IAAI,SAAS,SAAS,eAAe,SAAS,SAAS,UAA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"RelationSelector.js","names":[],"sources":["../../src/components/RelationSelector.tsx"],"sourcesContent":["\nimport {\n ArrowRightToLineIcon,\n CheckIcon,\n ChevronDownIcon,\n Chip,\n CircularProgress,\n cls,\n defaultBorderMixin,\n fieldBackgroundDisabledMixin,\n fieldBackgroundHoverMixin,\n fieldBackgroundInvisibleMixin,\n fieldBackgroundMixin,\n focusedDisabled,\n IconButton,\n iconSize,\n PlusIcon,\n PopoverPrimitive,\n SearchIcon,\n Separator,\n Tooltip,\n usePortalContainer,\n XIcon\n} from \"@rebasepro/ui\";\nimport * as React from \"react\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport { Command as CommandPrimitive } from \"cmdk\";\nimport { Entity, EntityRelation, FilterValues, Relation, getCollectionDataPath } from \"@rebasepro/types\";\nimport { EntityPreviewBindingData } from \"./EntityPreviewBinding\";\nimport { PickerTrigger } from \"./PickerTrigger\";\nimport { getTitlePropertyKey, useData, usePermissions, useRelationSelector, useTranslation } from \"@rebasepro/app\";\nimport { useSidePanel } from \"../hooks/useSidePanel\";\nimport { normalizeToEntityRelation } from \"@rebasepro/common\";\nimport { findEntitiesByIds } from \"../util/find_entities_by_ids\";\nimport { entityOfRow } from \"@rebasepro/app\";\n\n/** Whether an authored relation yields many rows. Derived from its kind. */\nfunction relationCardinality(relation: { kind?: string; cardinality?: string } | undefined): \"one\" | \"many\" | undefined {\n if (!relation) return undefined;\n if (relation.kind === \"via\") return relation.cardinality as \"one\" | \"many\" | undefined;\n if (relation.kind === \"hasMany\" || relation.kind === \"manyToMany\") return \"many\";\n if (relation.kind === \"belongsTo\" || relation.kind === \"hasOne\") return \"one\";\n return relation.cardinality as \"one\" | \"many\" | undefined;\n}\n\n\nexport interface RelationItem {\n id: string | number;\n label: string;\n description?: string;\n data?: Entity;\n relation: EntityRelation;\n}\n\nexport interface RelationSelectorProps {\n className?: string;\n name?: string;\n id?: string;\n value?: EntityRelation | EntityRelation[] | null;\n /** Callback returning selected EntityRelation(s) */\n\n onValueChange?: (updatedValue: EntityRelation | EntityRelation[] | undefined) => void;\n placeholder?: React.ReactNode;\n /**\n * `large` is the form's size and is on the shared 28/32/40/48 control\n * scale, so a relation picker lines up with the text field beside it.\n *\n * `small` and `medium` predate that scale (42 and 56) and are kept as they\n * are because the filter row is built around them. A table cell passes\n * `triggerContent` instead, and has no size of its own.\n */\n size?: \"small\" | \"medium\" | \"large\";\n useChips?: boolean;\n disabled?: boolean;\n invisible?: boolean;\n\n relation: Relation;\n /**\n * Whether the selector picks many rows or one.\n *\n * Defaults to what the relation implies — a `hasMany` or `manyToMany`\n * picks many — which is right wherever the selector *edits* the relation,\n * because there the cardinality is the shape of the stored value.\n *\n * A filter is the case where it is not. `tags == <one tag>` asks a single\n * question about a to-many link, and the operator is what decides how many\n * values it takes. Deriving multiplicity from the relation there meant a\n * to-many relation could only ever emit a list, so the filter field had to\n * hide every single-value operator to avoid handing `==` an array.\n */\n multiple?: boolean;\n fixedFilter?: FilterValues<string>;\n pageSize?: number;\n emptyPlaceholder?: string;\n searchPlaceholder?: string;\n /** Shown in the open list when a search matched nothing. */\n noResultsText?: string;\n /**\n * Shown on the closed trigger when nothing is selected. Says only that the\n * field is empty — see the note by `resolvedPlaceholder` for why it cannot\n * say whether there is anything to pick.\n */\n emptyText?: string;\n /**\n * Shown in the open list when the target collection turned out to hold no\n * rows at all, as opposed to a search simply not matching. Defaults to a\n * sentence naming the target collection.\n */\n emptyCollectionText?: string;\n loadingText?: string;\n /**\n * Whether the list is open, for a caller that opens it from outside the\n * trigger — a table cell's opener. Every open and close the selector\n * makes itself is reported through `onOpenChange`, controlled or not.\n */\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n /**\n * Replaces everything the trigger draws — the value, the box, its padding\n * and the chevron — with this node. For a caller that frames the picker\n * itself: a table cell passes the preview it shows at rest, so the cell\n * looks the same whether the picker is mounted, closed or open.\n */\n triggerContent?: React.ReactNode;\n /**\n * Positions the list against this element instead of the trigger. A\n * table cell passes itself: the trigger inside it can be taller than the\n * cell that clips it, and the list belongs under what can be seen.\n */\n anchorRef?: React.RefObject<HTMLElement | null>;\n /**\n * Whether the open list offers to create a row in the target collection.\n * Defaults to `true`. The offer is shown only when the user could actually\n * insert into that collection — the same permission check the selection\n * dialog's \"Add\" button makes — so turning this off is for the cases where\n * creating is possible but not wanted, like a filter.\n */\n allowCreate?: boolean;\n}\n\nexport const RelationSelector = React.forwardRef<\n HTMLElement,\n RelationSelectorProps\n>(\n (\n {\n value,\n size = \"medium\",\n onValueChange,\n invisible,\n disabled,\n placeholder,\n useChips = true,\n className,\n relation,\n multiple: multipleOverride,\n fixedFilter,\n pageSize,\n emptyPlaceholder,\n searchPlaceholder = \"Search...\",\n noResultsText = \"No matches.\",\n emptyText = \"Select…\",\n emptyCollectionText,\n loadingText = \"Loading...\",\n allowCreate = true,\n open: openProp,\n onOpenChange,\n triggerContent,\n anchorRef\n },\n ref\n ) => {\n\n const collection = relation.target();\n const dataPath = getCollectionDataPath(collection);\n const dataClient = useData();\n const sidePanelController = useSidePanel();\n const { canCreate } = usePermissions();\n const { t } = useTranslation();\n const contextPortalContainer = usePortalContainer();\n const multiple = multipleOverride ?? relationCardinality(relation) === \"many\";\n\n const [isPopoverOpen, setIsPopoverOpenState] = useState(false);\n const isPopoverOpenRef = useRef(false);\n // The list is only worth fetching once the picker has been opened. A\n // table cell mounts one of these per row, and the selected value is\n // resolved by its own effect below, not from the list. Latches on the\n // first open so a closed popover keeps its results.\n const [listRequested, setListRequested] = useState(false);\n const [selectedItems, setSelectedItems] = useState<RelationItem[]>([]);\n const [isLoadingSelectedItems, setIsLoadingSelectedItems] = useState(false);\n const [searchString, setSearchString] = useState<string>(\"\");\n\n // Track IDs that were set via local user interaction (onItemClick / handleClear / handleRemoveItem).\n // When an incoming value change matches these IDs exactly, we skip async re-resolution.\n const localSelectionIdsRef = useRef<string | null>(null);\n // Entity of selected IDs captured when the popover opens.\n // Used to sort the dropdown list so selected items appear at the top.\n // Stays stable for the entire popover session so items don't jump around.\n const pinnedIdsRef = useRef<Set<string> | null>(null);\n\n const selectedItemsForPinRef = useRef<RelationItem[]>([]);\n selectedItemsForPinRef.current = selectedItems;\n const onOpenChangeRef = useRef(onOpenChange);\n onOpenChangeRef.current = onOpenChange;\n\n // Every open and close goes through here. Opening pins the current\n // selection to the top of the list for as long as it stays open, and\n // is what first requests the list at all.\n const setPopoverOpen = useCallback((next: boolean, notify = true) => {\n if (next) {\n // From the value as well as the resolved items: a picker a\n // table cell mounts already open has not resolved them yet.\n pinnedIdsRef.current = new Set([\n ...selectedItemsForPinRef.current.map(i => String(i.id)),\n ...relationsArrayRef.current.map(rel =>\n String(typeof rel === \"string\" || typeof rel === \"number\" ? rel : rel.id))\n ]);\n setListRequested(true);\n } else {\n pinnedIdsRef.current = null;\n }\n const changed = isPopoverOpenRef.current !== next;\n isPopoverOpenRef.current = next;\n setIsPopoverOpenState(next);\n if (changed && notify) onOpenChangeRef.current?.(next);\n }, []);\n\n useEffect(() => {\n if (openProp === undefined || openProp === isPopoverOpenRef.current) return;\n if (openProp && disabled) {\n onOpenChangeRef.current?.(false);\n return;\n }\n setPopoverOpen(openProp, false);\n }, [openProp, disabled, setPopoverOpen]);\n\n const {\n items: availableItems,\n isLoading,\n hasMore,\n search,\n loadMore,\n entityToRelationItem\n } = useRelationSelector({\n path: dataPath,\n collection,\n fixedFilter,\n pageSize,\n enabled: listRequested\n });\n\n const scrollContainerRef = useRef<HTMLDivElement>(null);\n const sentinelRef = useRef<HTMLDivElement>(null);\n const observerRef = useRef<IntersectionObserver | null>(null);\n const localTriggerRef = useRef<HTMLElement | null>(null);\n\n const handleButtonRef = useCallback((node: HTMLElement | null) => {\n localTriggerRef.current = node;\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n ref.current = node;\n }\n }, [ref]);\n const contentRef = useRef<HTMLDivElement | null>(null);\n const searchInputRef = useRef<HTMLInputElement | null>(null);\n\n // Keep stable refs for dependencies used in the value-resolution effect\n // so the effect only re-fires when the actual `value` identity changes.\n const dataClientRef = useRef(dataClient);\n dataClientRef.current = dataClient;\n const entityToRelationItemRef = useRef(entityToRelationItem);\n entityToRelationItemRef.current = entityToRelationItem;\n const collectionSlugRef = useRef(collection.slug);\n collectionSlugRef.current = collection.slug;\n const collectionRef = useRef(collection);\n collectionRef.current = collection;\n\n // Stable ref to track which IDs we've already resolved\n const resolvedIdsRef = useRef<string>(\"\");\n // Track whether we have resolved items (used for skip guard without adding to deps)\n const hasResolvedItemsRef = useRef(false);\n\n const selectedItemsRef = useRef(selectedItems);\n selectedItemsRef.current = selectedItems;\n\n // Normalize incoming values — plain { __type: \"relation\" } objects\n // from the server are converted to proper EntityRelation instances.\n const rawArray = !value ? [] : Array.isArray(value) ? value : [value];\n const relationsArray = rawArray.map(rel => {\n if (typeof rel === \"string\" || typeof rel === \"number\") return rel;\n return normalizeToEntityRelation(rel) ?? rel;\n });\n\n // Build a fingerprint of the incoming value's IDs\n const incomingIds = relationsArray\n .map(rel => {\n const isPrimitive = typeof rel === \"string\" || typeof rel === \"number\";\n return String(isPrimitive ? rel : (rel as EntityRelation).id);\n })\n .sort()\n .join(\",\");\n\n // CheckIcon if every relation already has embedded data\n const allHaveData = relationsArray.length > 0 && relationsArray.every(rel => {\n if (typeof rel === \"string\" || typeof rel === \"number\") return false;\n return !!(rel as EntityRelation)?.data;\n });\n\n const relationsArrayRef = useRef(relationsArray);\n relationsArrayRef.current = relationsArray;\n\n useEffect(() => {\n let active = true;\n const currentRelationsArray = relationsArrayRef.current;\n\n // If the IDs haven't changed and we already resolved them, skip entirely\n if (incomingIds === resolvedIdsRef.current && (allHaveData || hasResolvedItemsRef.current)) {\n return;\n }\n\n // FAST PATH: If the incoming IDs match what we just set locally via user interaction,\n // our selectedItems already have the correct data — no re-resolution needed.\n //\n // The fingerprint answers for one echo only, and is dropped on the\n // first incoming value whether it matches or not. Kept, it also\n // matched a *later* return to the same ids — pick A, discard to B,\n // undo back to A — and the chip went on showing B.\n const localSelectionIds = localSelectionIdsRef.current;\n localSelectionIdsRef.current = null;\n if (localSelectionIds !== null && incomingIds === localSelectionIds) {\n resolvedIdsRef.current = incomingIds;\n hasResolvedItemsRef.current = true;\n // Do NOT call setSelectedItems or setIsLoadingSelectedItems — they are already correct.\n return;\n }\n\n const currentSelected = selectedItemsRef.current;\n const currentSelectedMap = new Map(currentSelected.map(item => [String(item.id), item]));\n\n let allCovered = true;\n const newResolvedItems: RelationItem[] = [];\n const toRelationItem = entityToRelationItemRef.current;\n const slug = collectionSlugRef.current;\n\n for (const rel of currentRelationsArray) {\n const isPrimitive = typeof rel === \"string\" || typeof rel === \"number\";\n const relId = String(isPrimitive ? rel : (rel as EntityRelation).id);\n const hasEmbeddedData = !isPrimitive && !!(rel as EntityRelation).data;\n\n if (hasEmbeddedData) {\n const r = rel as EntityRelation;\n // admin wire format embeds relation data as { id, path, values };\n // `EntityRelation.data` is typed as the open record the wire sends.\n newResolvedItems.push(toRelationItem(r.data as unknown as Entity, r));\n } else if (currentSelectedMap.has(relId)) {\n // We already have it in currentSelected\n const existingItem = currentSelectedMap.get(relId)!;\n newResolvedItems.push(existingItem);\n } else {\n allCovered = false;\n break;\n }\n }\n\n // FAST PATH: We have all necessary data embedded or in local cache\n if (allCovered) {\n setSelectedItems(newResolvedItems);\n hasResolvedItemsRef.current = true;\n resolvedIdsRef.current = incomingIds;\n setIsLoadingSelectedItems(false);\n return;\n }\n\n // SLOW PATH: fetch missing data — but don't show loading if popover is open\n // (user is actively interacting; showing a spinner is disruptive)\n if (!isPopoverOpenRef.current) {\n setIsLoadingSelectedItems(true);\n }\n const client = dataClientRef.current;\n const target = collectionRef.current;\n\n // The ids nothing above resolves, by the path they are read at:\n // one request per path (per 1,000 ids), not one per id.\n const unresolved = new Map<string, (string | number)[]>();\n for (const rel of currentRelationsArray) {\n const isPrimitive = typeof rel === \"string\" || typeof rel === \"number\";\n const relId = isPrimitive ? rel : (rel as EntityRelation).id;\n if (!isPrimitive && (rel as EntityRelation).data) continue;\n if (currentSelectedMap.has(String(relId))) continue;\n const path = isPrimitive ? slug : (rel as EntityRelation).path;\n unresolved.set(path, [...(unresolved.get(path) ?? []), relId]);\n }\n\n Promise.all(\n [...unresolved].map(async ([path, ids]): Promise<[string, Map<string, Entity>]> => {\n try {\n return [path, await findEntitiesByIds(client.collection(path), target, ids)];\n } catch (e) {\n console.warn(\"RelationSelector: could not fetch the entities for relations\", path, ids, e);\n return [path, new Map()];\n }\n })\n ).then(read => {\n const readByPath = new Map(read);\n return currentRelationsArray.map((rel) => {\n const isPrimitive = typeof rel === \"string\" || typeof rel === \"number\";\n const relId = isPrimitive ? rel : (rel as EntityRelation).id;\n const path = isPrimitive ? slug : (rel as EntityRelation).path;\n const relation = isPrimitive ? new EntityRelation(relId, path) : rel as EntityRelation;\n\n if (!isPrimitive && (rel as EntityRelation).data) {\n // admin wire format embeds relation data as { id, path, values };\n // `EntityRelation.data` is typed as the open record the wire sends.\n return toRelationItem((rel as EntityRelation).data as unknown as Entity, relation);\n }\n if (currentSelectedMap.has(String(relId))) {\n return currentSelectedMap.get(String(relId))!;\n }\n const entity = readByPath.get(path)?.get(String(relId));\n if (entity) return toRelationItem(entity, relation);\n return { id: relId,\nlabel: String(relId),\nrelation } as RelationItem;\n });\n }).then(resolved => {\n if (active) {\n setSelectedItems(resolved);\n setIsLoadingSelectedItems(false);\n hasResolvedItemsRef.current = true;\n resolvedIdsRef.current = incomingIds;\n }\n });\n\n return () => {\n active = false;\n };\n }, [incomingIds, allHaveData]);\n\n const sentinelCallbackRef = useCallback((node: HTMLDivElement | null) => {\n if (observerRef.current) {\n observerRef.current.disconnect();\n observerRef.current = null;\n }\n if (sentinelRef.current !== node) {\n (sentinelRef as React.MutableRefObject<HTMLDivElement | null>).current = node;\n }\n if (!node || !hasMore || isLoading || !loadMore) return;\n const observer = new IntersectionObserver(\n (entries) => {\n const entry = entries[0];\n if (entry.isIntersecting && hasMore && !isLoading) loadMore();\n },\n {\n root: scrollContainerRef.current,\n rootMargin: \"20px\",\n threshold: 0\n }\n );\n observer.observe(node);\n observerRef.current = observer;\n }, [hasMore, isLoading, loadMore]);\n\n useEffect(() => () => {\n if (observerRef.current) observerRef.current.disconnect();\n }, []);\n\n // Enhanced scroll event listener specifically for dialog contexts\n useEffect(() => {\n const scrollContainer = scrollContainerRef.current;\n if (!scrollContainer || !hasMore || isLoading || !isPopoverOpen) return;\n\n const handleScroll = () => {\n const { scrollTop, scrollHeight, clientHeight } = scrollContainer;\n const isNearBottom = scrollTop + clientHeight >= scrollHeight - 100;\n\n if (isNearBottom && hasMore && !isLoading) {\n loadMore();\n }\n };\n\n // Add scroll listener directly to the container\n scrollContainer.addEventListener(\"scroll\", handleScroll, { passive: true });\n\n return () => {\n scrollContainer.removeEventListener(\"scroll\", handleScroll);\n };\n }, [hasMore, isLoading, loadMore, isPopoverOpen]);\n\n const handleSearchChange = useCallback((newSearchString: string) => {\n setSearchString(newSearchString);\n search(newSearchString);\n }, [search]);\n\n const emitValueChange = useCallback((selected: RelationItem[]) => {\n if (multiple) onValueChange?.(selected.length ? selected.map(i => i.relation) : undefined);\n else onValueChange?.(selected[0]?.relation);\n }, [onValueChange, multiple]);\n\n // The picker can hand its selection over long after the render that\n // built the callback — a row created in the side panel arrives whenever\n // the person saves it — so the emitter is read from a ref rather than\n // captured.\n const emitValueChangeRef = useRef(emitValueChange);\n emitValueChangeRef.current = emitValueChange;\n\n // Helper: compute the \"IDs fingerprint\" for a set of RelationItems\n // so we can mark it in localSelectionIdsRef and skip re-resolution.\n const computeSelectionFingerprint = useCallback((items: RelationItem[]): string => {\n return items.map(i => String(i.id)).sort().join(\",\");\n }, []);\n\n const onItemClick = useCallback((item: RelationItem) => {\n let newSelected: RelationItem[];\n if (multiple) {\n const isSelected = selectedItems.some(v => String(v.id) === String(item.id));\n newSelected = isSelected\n ? selectedItems.filter(v => String(v.id) !== String(item.id))\n : [...selectedItems, item];\n } else {\n newSelected = [item];\n setPopoverOpen(false);\n }\n setSelectedItems(newSelected);\n // Mark this fingerprint so the resolution effect skips async work\n // when the parent echoes the same IDs back via props.\n localSelectionIdsRef.current = computeSelectionFingerprint(newSelected);\n emitValueChange(newSelected);\n }, [multiple, selectedItems, emitValueChange, computeSelectionFingerprint, setPopoverOpen]);\n\n const handleClear = useCallback(() => {\n setSelectedItems([]);\n localSelectionIdsRef.current = \"\";\n onValueChange?.(undefined);\n }, [onValueChange]);\n\n const handleRemoveItem = useCallback((itemToRemove: RelationItem) => {\n const newSelected = selectedItems.filter(v => String(v.id) !== String(itemToRemove.id));\n setSelectedItems(newSelected);\n localSelectionIdsRef.current = computeSelectionFingerprint(newSelected);\n emitValueChange(newSelected);\n }, [selectedItems, emitValueChange, computeSelectionFingerprint]);\n\n const handleRootOpenChange = useCallback((next: boolean) => {\n if (disabled) return;\n // We control open manually; only allow opening attempts from Radix (e.g. trigger press)\n if (next) setPopoverOpen(true);\n // Ignore close attempts here; outside click/Escape handled manually; single select closes explicitly on selection.\n }, [disabled, setPopoverOpen]);\n\n // Outside click + Escape handling (simple and reliable)\n useEffect(() => {\n if (!isPopoverOpen) return;\n\n function handlePointerDown(ev: MouseEvent) {\n const target = ev.target as Node;\n const triggerEl = localTriggerRef.current;\n const contentEl = contentRef.current;\n if (triggerEl?.contains(target)) return;\n if (contentEl?.contains(target)) return;\n // Outside\n setPopoverOpen(false);\n }\n\n // A layer of its own, so capture phase — and it claims the Escape\n // it acts on, so the record view underneath leaves the record open.\n function handleKey(ev: KeyboardEvent) {\n if (ev.key !== \"Escape\") return;\n ev.preventDefault();\n setPopoverOpen(false);\n }\n\n document.addEventListener(\"mousedown\", handlePointerDown, true);\n document.addEventListener(\"keydown\", handleKey, true);\n return () => {\n document.removeEventListener(\"mousedown\", handlePointerDown, true);\n document.removeEventListener(\"keydown\", handleKey, true);\n };\n }, [isPopoverOpen, setPopoverOpen]);\n\n const closePopover = useCallback(() => setPopoverOpen(false), [setPopoverOpen]);\n\n const toggleOpen = useCallback(() => {\n if (disabled) return;\n setPopoverOpen(!isPopoverOpenRef.current);\n }, [disabled, setPopoverOpen]);\n\n // Pointing at a row that does not exist yet.\n //\n // Until now the only way out of that was to abandon the form, go to the\n // other collection, create the row, come back and start again — and on\n // a new record that meant losing everything typed so far. The side\n // panel already stacks (the selection dialog creates from inside itself\n // this way), so the picker can open a create form over the form it\n // belongs to and select what comes back.\n const canCreateTarget = allowCreate && canCreate(collection, dataPath);\n\n // A search that matched nothing is the name the person was looking for,\n // so it seeds the new row. Only when the title lands on a plain string\n // property: putting free text into an enum, a relation or a computed\n // property would be worse than not prefilling at all.\n const buildDefaultValues = useCallback((searchText: string): Record<string, unknown> | undefined => {\n const trimmed = searchText.trim();\n if (!trimmed) return undefined;\n const titleKey = getTitlePropertyKey(collection);\n if (!titleKey || titleKey.includes(\".\")) return undefined;\n const titleProperty = collection.properties?.[titleKey];\n // A property builder is a function, and it decides its own value.\n if (!titleProperty || typeof titleProperty === \"function\") return undefined;\n if (titleProperty.type !== \"string\" || titleProperty.enum) return undefined;\n return { [titleKey]: trimmed };\n }, [collection]);\n\n const handleCreateNew = useCallback(() => {\n const defaultValues = buildDefaultValues(searchString);\n closePopover();\n sidePanelController.open({\n path: dataPath,\n collection,\n // No URL. This panel is a detour inside the form you are\n // filling in, not somewhere you navigated to, and its address\n // would restore nothing anyway — a record that does not exist\n // yet has none.\n //\n // Pushing one made closing it a *pathname* change, which is\n // exactly what the unsaved-changes blocker watches\n // (`useUnsavedChangesDialog`). So saving the new row raced the\n // panel clearing its own dirty flag, and often enough lost:\n // \"There are unsaved changes\" over a record that had just been\n // saved, with the URL stranded on the target collection. Worst\n // of all in the case this feature exists for — the outer form\n // has content in it, which is the whole reason not to leave.\n updateUrl: false,\n // Saving is the whole point of the detour; the panel goes away\n // and the picker is left holding the row it made.\n closeOnSave: true,\n defaultValues,\n onSaved: ({ row, id }) => {\n const entity = entityOfRow(row, id, dataPath, collection);\n const item = entityToRelationItemRef.current(entity, new EntityRelation(entity.id, dataPath));\n const current = selectedItemsRef.current;\n const newSelected = multiple\n ? [...current.filter(i => String(i.id) !== String(item.id)), item]\n : [item];\n setSelectedItems(newSelected);\n // Same bookkeeping `onItemClick` does: mark the fingerprint\n // so the resolution effect does not re-fetch the row we\n // already hold when the form echoes the value back.\n localSelectionIdsRef.current = newSelected.map(i => String(i.id)).sort().join(\",\");\n emitValueChangeRef.current(newSelected);\n }\n });\n }, [buildDefaultValues, searchString, closePopover, sidePanelController, dataPath, collection, multiple]);\n\n // Text, not `EmptyValue`. That component draws a small grey rounded bar\n // with no text in it, which is the same shape the `Skeleton` component\n // uses while data is in flight — so a relation you simply had not filled\n // in was indistinguishable from one that was still loading, and an empty\n // Author or Tags field read as permanently stuck. It also left the trigger\n // button with no accessible name, since the bar contains no text at all.\n //\n // This says \"not filled in\" rather than \"nothing to choose from\": which of\n // those it is cannot be known here. The list is deliberately not fetched\n // until the picker is first opened (`enabled: listRequested`, guarded by\n // relation_cell_picker_gating.test.tsx, because a table renders one of\n // these per row), so before that `availableItems` is empty because nobody\n // asked, not because the target collection is. The genuine \"nothing to\n // pick yet\" state is reported inside the popover below, where the fetch\n // has actually happened.\n const resolvedPlaceholder = placeholder || emptyPlaceholder || emptyText;\n\n // Whatever dialog, side dialog or sheet we are inside offers as its\n // portal host, falling back to `document.body`. This is not cosmetic:\n // those are modal, and a modal locks scrolling everywhere outside its\n // own content — a list portaled to the body opens and then refuses to\n // scroll, because every wheel event over it is cancelled.\n const portalContainer = (contextPortalContainer ?? (typeof document !== \"undefined\" ? document.body : undefined)) ?? undefined;\n\n return (\n <>\n <PopoverPrimitive.Root open={isPopoverOpen} onOpenChange={handleRootOpenChange} modal={false}>\n <PickerTrigger anchorRef={anchorRef}>\n {triggerContent !== undefined\n // Bare: the caller frames it. No box, no padding,\n // no height of its own — the node it passed,\n // exactly where it would be anyway. A `div`, not a\n // `button`: what it wraps can hold buttons of its\n // own (a record card's open button, at tall rows).\n ? <div\n ref={handleButtonRef}\n role=\"button\"\n tabIndex={disabled ? -1 : 0}\n aria-disabled={disabled || undefined}\n aria-haspopup=\"listbox\"\n aria-expanded={isPopoverOpen}\n data-relation-selector-trigger\n onClick={toggleOpen}\n // A record's title in the value opens that\n // record, and the list has no business staying\n // open over it.\n onClickCapture={(event) => {\n const target = event.target;\n if (!(target instanceof Element) || !isPopoverOpenRef.current) return;\n const interactive = target.closest(\"a, button, [role=\\\"button\\\"]\");\n if (interactive && interactive !== event.currentTarget) setPopoverOpen(false);\n }}\n onKeyDown={(event) => {\n if (event.key !== \"Enter\" && event.key !== \" \") return;\n event.preventDefault();\n toggleOpen();\n }}\n className={cls(\"w-full select-none text-left text-sm relative flex items-center outline-none\", className)}>\n {triggerContent}\n </div>\n : <button\n ref={handleButtonRef}\n type=\"button\"\n aria-haspopup=\"listbox\"\n aria-expanded={isPopoverOpen}\n data-relation-selector-trigger\n disabled={disabled}\n onClick={toggleOpen}\n className={cls(\n {\n \"min-h-[42px] py-1 px-2\": size === \"small\",\n \"min-h-[56px] py-2 px-4\": size === \"medium\",\n \"min-h-[48px] py-1 px-4\": size === \"large\"\n },\n // `rounded-lg` like every other field box —\n // `rounded-md` made this the one control in a\n // row with a different corner.\n \"w-full select-none rounded-lg text-sm relative flex items-center\",\n invisible ? fieldBackgroundInvisibleMixin : fieldBackgroundMixin,\n disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin,\n className\n )}\n >\n <div className=\"flex justify-between items-center w-full\">\n {isLoadingSelectedItems ? (\n <div className=\"flex items-center gap-2\">\n <CircularProgress size=\"smallest\"/>\n <span className=\"text-sm text-text-secondary dark:text-text-secondary-dark\">{loadingText}</span>\n </div>\n ) : selectedItems.length > 0 ? (\n <div\n className=\"flex flex-wrap items-center gap-1.5 text-start flex-1 min-w-0 mr-2\">\n {selectedItems.map((item) => {\n if (!useChips || !multiple) {\n return (\n <div key={String(item.id)}\n className=\"flex flex-row items-center gap-1 truncate\">\n {item.data ? (\n <EntityPreviewBindingData size={\"medium\"}\n entity={item.data}\n includeEntityLink={false}\n includeId={false}\n onSidePanelClick={closePopover}\n />\n ) : (\n <span className=\"text-sm truncate\">{item.label}</span>\n )}\n </div>\n );\n }\n return (\n <Chip\n size={\"small\"}\n key={String(item.id)}\n className={cls(\"flex flex-row items-center gap-1 truncate\")}\n >\n {item.data ? (\n <EntityPreviewBindingData size={\"smallest\"} entity={item.data}\n includeEntityLink={false}\n includeId={false}/>\n ) : (\n <span className=\"text-sm truncate\">{item.label}</span>\n )}\n <XIcon\n size={iconSize.smallest}\n onClick={(event) => {\n event.stopPropagation();\n handleRemoveItem(item);\n }}\n />\n </Chip>\n );\n })}\n </div>\n ) :\n (\n <span className=\"text-sm text-text-secondary dark:text-text-secondary-dark\">\n {resolvedPlaceholder}\n </span>\n )}\n\n <div className=\"flex items-center flex-shrink-0\">\n {!multiple && selectedItems.length === 1 && selectedItems[0]?.data && (\n <Tooltip title={t(\"relation_open_record\", { label: selectedItems[0].label })}>\n <IconButton aria-label={t(\"relation_open_record\", { label: selectedItems[0].label })}\n component={\"div\"}\n size={\"small\"}\n className=\"opacity-60 hover:opacity-100\"\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n const entity = selectedItems[0].data!;\n setPopoverOpen(false);\n sidePanelController.open({\n id: entity.id,\n path: entity.path,\n collection,\n updateUrl: true\n });\n }}>\n <ArrowRightToLineIcon size={iconSize.small}/>\n </IconButton>\n </Tooltip>\n )}\n <ChevronDownIcon\n size={size === \"small\" ? iconSize.small : iconSize.medium}\n className={cls(\"transition\", isPopoverOpen ? \"rotate-180\" : \"\")}\n />\n </div>\n </div>\n\n </button>}\n </PickerTrigger>\n <PopoverPrimitive.Portal container={portalContainer}>\n <PopoverPrimitive.Content\n ref={contentRef}\n data-relation-selector-content\n className={cls(\"z-50 overflow-hidden border bg-surface-card rounded-lg min-w-72\", defaultBorderMixin)}\n align=\"start\"\n sideOffset={8}\n side=\"bottom\"\n avoidCollisions={true}\n collisionPadding={16}\n // Allow default auto focus (we manually refocus anyway)\n onOpenAutoFocus={(_e) => { /* leave default or custom manual focus */\n }}\n onCloseAutoFocus={(e) => {\n e.preventDefault();\n }}\n style={{ width: \"var(--radix-popover-trigger-width)\" }}\n >\n <CommandPrimitive shouldFilter={false}>\n <div className=\"flex flex-row items-center\">\n <div className=\"relative flex-1\">\n <SearchIcon\n className=\"absolute left-3 top-1/2 transform -translate-y-1/2 text-text-secondary dark:text-text-secondary-dark\"\n size={iconSize.smallest}/>\n <CommandPrimitive.Input\n ref={searchInputRef}\n className={cls(\n focusedDisabled,\n \"bg-transparent outline-hidden flex-1 h-full w-full pl-10 pr-4 py-3 text-text-primary dark:text-text-primary-dark placeholder:text-text-secondary dark:placeholder:text-text-secondary-dark\"\n )}\n placeholder={searchPlaceholder}\n value={searchString}\n onValueChange={handleSearchChange}\n />\n </div>\n {isLoading && (\n <div className=\"flex items-center justify-center px-3\">\n <CircularProgress size=\"smallest\"/>\n </div>\n )}\n {selectedItems.length > 0 && (\n <div\n onClick={handleClear}\n className=\"text-sm justify-center cursor-pointer py-3 px-4 text-text-secondary dark:text-text-secondary-dark hover:text-text-primary dark:hover:text-text-primary-dark\"\n >\n Clear\n </div>\n )}\n </div>\n <Separator orientation=\"horizontal\" className=\"my-0\"/>\n <CommandPrimitive.List\n ref={scrollContainerRef}\n style={{\n maxHeight: \"40vh\",\n overflowY: \"auto\"\n }}\n >\n {isLoading && availableItems.length === 0 && (\n <div className=\"flex items-center justify-center py-6\">\n <CircularProgress size=\"small\"/>\n <span\n className=\"ml-2 text-sm text-text-secondary dark:text-text-secondary-dark\">{loadingText}</span>\n </div>\n )}\n {/* Two different nothings, which used to share one\n message (\"No relations found.\") even though the\n fix for each is the opposite: clear the search, or\n go and create the first row. With the fetch done,\n the search string is what tells them apart. */}\n {!isLoading && availableItems.length === 0 && (\n <CommandPrimitive.Empty\n className=\"px-4 py-6 text-center text-text-secondary dark:text-text-secondary-dark\">\n {searchString\n ? noResultsText\n : (emptyCollectionText ?? `No ${collection.name ?? \"entries\"} yet.`)}\n </CommandPrimitive.Empty>\n )}\n <CommandPrimitive.Group>\n {(() => {\n // Sort items so that initially-selected (pinned) items appear first.\n // We use the entity taken when the popover opened so items don't\n // jump around as the user checks/unchecks.\n const pinned = pinnedIdsRef.current;\n const sortedItems = pinned && pinned.size > 0\n ? [...availableItems].sort((a, b) => {\n const aP = pinned.has(String(a.id)) ? 0 : 1;\n const bP = pinned.has(String(b.id)) ? 0 : 1;\n return aP - bP;\n })\n : availableItems;\n return sortedItems;\n })().map((item) => {\n const isSelected = selectedItems.some(v => String(v.id) === String(item.id));\n return (\n <CommandPrimitive.Item\n key={String(item.id)}\n value={String(item.id)}\n onMouseDown={(e) => {\n e.preventDefault();\n e.stopPropagation();\n }}\n onSelect={() => onItemClick(item)}\n className={cls(\n \"flex flex-row items-center gap-1.5 m-1 p-1 rounded-xs cursor-pointer ring-offset-transparent\",\n isSelected && \"bg-surface-active\",\n \"aria-selected:outline-hidden aria-selected:bg-surface-active\"\n )}\n >\n {multiple && (<InnerCheckBox checked={isSelected}/>)}\n {item.data ? (\n <div\n className=\"flex flex-row items-center gap-2 min-w-0 w-full\">\n <EntityPreviewBindingData\n size={multiple ? \"smallest\" : \"medium\"}\n entity={item.data}\n includeId={false}\n includeEntityLink={true}\n />\n </div>\n ) : (\n <div>\n <div\n className=\"text-sm font-medium text-text-primary dark:text-text-primary-dark\">{item.label}</div>\n {item.description && (\n <div\n className=\"text-xs text-text-secondary dark:text-text-secondary-dark\">{item.description}</div>\n )}\n </div>\n )}\n </CommandPrimitive.Item>\n );\n })}\n {availableItems.length > 0 && hasMore && (\n <div ref={sentinelCallbackRef} className=\"h-1 w-full\"\n style={{ visibility: \"hidden\" }}/>\n )}\n {isLoading && availableItems.length > 0 && (\n <div className=\"flex items-center justify-center py-4\">\n <CircularProgress size=\"smallest\"/>\n <span\n className=\"ml-2 text-xs text-text-secondary dark:text-text-secondary-dark\">Loading...</span>\n </div>\n )}\n </CommandPrimitive.Group>\n </CommandPrimitive.List>\n {canCreateTarget && <>\n <Separator orientation=\"horizontal\" className=\"my-0\"/>\n {/* Outside the scrolling list on purpose: it\n is most wanted exactly when the list is\n long and nothing in it matched. */}\n <button\n type=\"button\"\n data-relation-selector-create\n onMouseDown={(e) => {\n e.preventDefault();\n e.stopPropagation();\n }}\n onClick={handleCreateNew}\n className={cls(\n \"w-full flex flex-row items-center gap-2 px-4 py-3 text-sm text-left\",\n \"text-primary hover:bg-surface-hover\"\n )}>\n <PlusIcon size={iconSize.smallest}/>\n <span className=\"truncate\">\n {searchString.trim()\n ? t(\"add_named\", { name: searchString.trim() })\n : t(\"add_specific\", { name: collection.singularName ?? collection.name })}\n </span>\n </button>\n </>}\n </CommandPrimitive>\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n </PopoverPrimitive.Root>\n </>\n );\n }\n);\n\nRelationSelector.displayName = \"RelationSelector\";\n\nfunction InnerCheckBox({ checked }: { checked: boolean }) {\n return (\n <div className={cls(\n \"p-2 w-8 h-8 inline-flex items-center justify-center text-sm font-medium focus:outline-hidden transition-colors ease-in-out duration-150\"\n )}>\n <div\n className={cls(\n \"border-2 relative transition-colors ease-in-out duration-150 w-4 h-4 rounded-xs flex items-center justify-center\",\n checked ? \"bg-primary text-surface-accent-100 dark:text-surface-accent-900 border-transparent\" : \"bg-surface-card border-surface-accent-800 dark:border-surface-accent-500\"\n )}\n >\n {checked && <CheckIcon size={iconSize.smallest} className=\"absolute\"/>}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAqCA,SAAS,oBAAoB,UAA2F;CACpH,IAAI,CAAC,UAAU,OAAO,KAAA;CACtB,IAAI,SAAS,SAAS,OAAO,OAAO,SAAS;CAC7C,IAAI,SAAS,SAAS,aAAa,SAAS,SAAS,cAAc,OAAO;CAC1E,IAAI,SAAS,SAAS,eAAe,SAAS,SAAS,UAAU,OAAO;CACxE,OAAO,SAAS;AACpB;AAiGA,IAAa,mBAAmB,QAAM,YAK9B,EACI,OACA,OAAO,UACP,eACA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AC;SACA,eAAe,SAAS,KAAK,WAC1B,oBAAC,OAAD;UAAK,KAAK;UAAqB,WAAU;UACrC,OAAO,EAAE,YAAY,SAAS;SAAG,CAAA;SAExC,aAAa,eAAe,SAAS,KAClC,qBAAC,OAAD;UAAK,WAAU;oBAAf,CACI,oBAAC,kBAAD,EAAkB,MAAK,WAAW,CAAA,GAClC,oBAAC,QAAD;WACI,WAAU;qBAAiE;UAAgB,CAAA,CAC9F;;QAEW,EAAA,CAAA;OACL;;MACtB,mBAAmB,qBAAA,UAAA,EAAA,UAAA,CAChB,oBAAC,WAAD;OAAW,aAAY;OAAa,WAAU;MAAO,CAAA,GAIrD,qBAAC,UAAD;OACI,MAAK;OACL,iCAAA;OACA,cAAc,MAAM;QAChB,EAAE,eAAe;QACjB,EAAE,gBAAgB;OACtB;OACA,SAAS;OACT,WAAW,IACP,uEACA,qCACJ;iBAXJ,CAYI,oBAAC,UAAD,EAAU,MAAM,SAAS,SAAU,CAAA,GACnC,oBAAC,QAAD;QAAM,WAAU;kBACX,aAAa,KAAK,IACb,EAAE,aAAa,EAAE,MAAM,aAAa,KAAK,EAAE,CAAC,IAC5C,EAAE,gBAAgB,EAAE,MAAM,WAAW,gBAAgB,WAAW,KAAK,CAAC;OAC1E,CAAA,CACF;QACV,EAAA,CAAA;KACY;;GACI,CAAA;EACL,CAAA,CACN;IACzB,CAAA;AAEV,CACJ;AAEA,iBAAiB,cAAc;AAE/B,SAAS,cAAc,EAAE,WAAiC;CACtD,OACI,oBAAC,OAAD;EAAK,WAAW,IACZ,yIACJ;YACI,oBAAC,OAAD;GACI,WAAW,IACP,oHACA,UAAU,uFAAuF,0EACrG;aAEC,WAAW,oBAAC,WAAD;IAAW,MAAM,SAAS;IAAU,WAAU;GAAW,CAAA;EACpE,CAAA;CACJ,CAAA;AAEb"}
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { Property, WhereFilterOp } from "@rebasepro/types";
2
+ import { Property, EntityRelation, WhereFilterOp } from "@rebasepro/types";
3
3
  export interface FilterFieldBindingInput {
4
4
  /** Key of the property being filtered (the column id). */
5
5
  propertyKey: string;
@@ -38,3 +38,15 @@ export interface FilterFieldBindingInput {
38
38
  * @group Components
39
39
  */
40
40
  export declare function FilterFieldBinding({ propertyKey, property, engine, value, setValue, hidden, setHidden }: FilterFieldBindingInput): React.ReactNode;
41
+ /**
42
+ * Built-in filter field dispatch by property type. This is the
43
+ * `OriginalComponent` received by `"Collection.FilterField"` overrides in
44
+ * wrap mode.
45
+ */
46
+ /**
47
+ * A relation filter's value as `EntityRelation`s. The URL decoder builds them,
48
+ * but a saved `defaultFilter` has been through JSON and holds plain
49
+ * `{ __type: "relation", id, path }` objects. Returns `undefined` for anything
50
+ * that is not a relation, so the field shows no selection rather than a wrong one.
51
+ */
52
+ export declare function toRelationFilterValue(value: unknown): EntityRelation | EntityRelation[] | null | undefined;
@@ -6,7 +6,7 @@ import { ReferenceFilterField } from "./ReferenceFilterField.js";
6
6
  import { RelationFilterField } from "./RelationFilterField.js";
7
7
  import { Suspense } from "react";
8
8
  import { jsx } from "react/jsx-runtime";
9
- import { enumToObjectEntries } from "@rebasepro/common";
9
+ import { enumToObjectEntries, normalizeToEntityRelation } from "@rebasepro/common";
10
10
  import { resolveFilterOperators, useCollectionScope, useComponentOverride, useResolvedComponent } from "@rebasepro/app";
11
11
  //#region src/components/SelectableTable/filters/FilterFieldBinding.tsx
12
12
  /**
@@ -64,6 +64,21 @@ function FilterFieldBinding({ propertyKey, property, engine, value, setValue, hi
64
64
  * `OriginalComponent` received by `"Collection.FilterField"` overrides in
65
65
  * wrap mode.
66
66
  */
67
+ /**
68
+ * A relation filter's value as `EntityRelation`s. The URL decoder builds them,
69
+ * but a saved `defaultFilter` has been through JSON and holds plain
70
+ * `{ __type: "relation", id, path }` objects. Returns `undefined` for anything
71
+ * that is not a relation, so the field shows no selection rather than a wrong one.
72
+ */
73
+ function toRelationFilterValue(value) {
74
+ if (value === null) return null;
75
+ if (value === void 0) return void 0;
76
+ if (Array.isArray(value)) {
77
+ const relations = value.map((item) => normalizeToEntityRelation(item, "relation"));
78
+ return relations.every((r) => r !== null) ? relations : void 0;
79
+ }
80
+ return normalizeToEntityRelation(value, "relation") ?? void 0;
81
+ }
67
82
  function DefaultFilterField({ propertyKey, property, isArray, operators, value, setValue, title, hidden, setHidden }) {
68
83
  if (property.type === "reference") {
69
84
  const referenceProperty = property;
@@ -84,8 +99,9 @@ function DefaultFilterField({ propertyKey, property, isArray, operators, value,
84
99
  if (property.type === "relation") {
85
100
  const relation = property.relation;
86
101
  if (!relation) return null;
102
+ const relations = value ? toRelationFilterValue(value[1]) : void 0;
87
103
  return /* @__PURE__ */ jsx(RelationFilterField, {
88
- value,
104
+ value: value && (relations !== void 0 || value[1] === void 0) ? [value[0], relations] : void 0,
89
105
  setValue,
90
106
  name: propertyKey,
91
107
  operators,
@@ -127,6 +143,6 @@ function DefaultFilterField({ propertyKey, property, isArray, operators, value,
127
143
  return null;
128
144
  }
129
145
  //#endregion
130
- export { FilterFieldBinding };
146
+ export { FilterFieldBinding, toRelationFilterValue };
131
147
 
132
148
  //# sourceMappingURL=FilterFieldBinding.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FilterFieldBinding.js","names":[],"sources":["../../../../src/components/SelectableTable/filters/FilterFieldBinding.tsx"],"sourcesContent":["import React, { Suspense } from \"react\";\nimport {\n ArrayProperty,\n Property,\n ReferenceProperty,\n RelationProperty,\n WhereFilterOp\n} from \"@rebasepro/types\";\nimport {\n FilterFieldBindingProps\n} from \"@rebasepro/cms-types\";\nimport { enumToObjectEntries } from \"@rebasepro/common\";\nimport { resolveFilterOperators } from \"@rebasepro/app\";\nimport { useCollectionScope, useComponentOverride, useResolvedComponent } from \"@rebasepro/app\";\nimport { StringNumberFilterField } from \"./StringNumberFilterField\";\nimport { BooleanFilterField } from \"./BooleanFilterField\";\nimport { DateTimeFilterField } from \"./DateTimeFilterField\";\nimport { ReferenceFilterField } from \"./ReferenceFilterField\";\nimport { RelationFilterField } from \"./RelationFilterField\";\nimport { getDatePropertyMode, getDatePropertyTimezone } from \"../../../preview/util\";\n\nexport interface FilterFieldBindingInput {\n /** Key of the property being filtered (the column id). */\n propertyKey: string;\n /** The raw property — array properties are unwrapped internally. */\n property: Property;\n /**\n * Engine backing the collection (`collection.engine`). Drives which\n * operators the engine can execute. Usually omitted — it is read from\n * the surrounding {@link CollectionScopeProvider}; pass it explicitly\n * only when rendering outside any collection scope.\n */\n engine?: string;\n value?: [WhereFilterOp, unknown];\n setValue: (value?: [WhereFilterOp, unknown]) => void;\n /** Coordination flags for fields that open their own dialogs. */\n hidden?: boolean;\n setHidden?: (hidden: boolean) => void;\n}\n\n/**\n * The single entry point for rendering a collection filter field.\n * Used by both the table header filters ({@link SelectableTable}) and the\n * Filters dialog.\n *\n * Resolution order:\n * 1. `property.admin.Filter` — per-property replacement (rendered even when the\n * resolved operator list is empty; the component owns filterability).\n * 2. `components[\"Collection.FilterField\"]` — collection-level or app-level\n * override (wrap mode supported via `OriginalComponent`).\n * 3. Built-in field dispatched by property type.\n *\n * The operators handed to the field are the intersection of the engine's\n * capabilities, the property-type defaults, and `property.admin.filterOperators`\n * (see `resolveFilterOperators`). When that intersection is empty and no\n * per-property `Filter` is set, nothing is rendered.\n *\n * @group Components\n */\nexport function FilterFieldBinding({\n propertyKey,\n property,\n engine,\n value,\n setValue,\n hidden,\n setHidden\n}: FilterFieldBindingInput): React.ReactNode {\n\n const isArray = property.type === \"array\";\n const ofVal = isArray ? (property as ArrayProperty).of : undefined;\n const baseProperty: Property | undefined = isArray\n ? (Array.isArray(ofVal) ? ofVal[0] : ofVal) as Property | undefined\n : property;\n\n // Hooks must run unconditionally — before any early return.\n const scopeCollection = useCollectionScope();\n const ResolvedFilterField = useComponentOverride<FilterFieldBindingProps>(\"Collection.FilterField\", DefaultFilterField);\n const PropertyFilter = useResolvedComponent<FilterFieldBindingProps>(baseProperty?.admin?.Filter);\n\n if (!baseProperty) return null;\n\n const operators = resolveFilterOperators({\n property: baseProperty,\n isArray,\n engine: engine ?? scopeCollection?.engine\n });\n\n const bindingProps: FilterFieldBindingProps = {\n propertyKey,\n property: baseProperty,\n isArray,\n operators,\n value,\n setValue,\n title: property.name,\n hidden,\n setHidden\n };\n\n // 1. Per-property replacement — always rendered, the dev owns filterability.\n if (PropertyFilter) {\n return (\n <Suspense fallback={null}>\n <PropertyFilter {...bindingProps}/>\n </Suspense>\n );\n }\n\n // 2/3. Override or built-in — only when the property is filterable here.\n if (operators.length === 0) return null;\n\n return <ResolvedFilterField {...bindingProps}/>;\n}\n\n/**\n * Built-in filter field dispatch by property type. This is the\n * `OriginalComponent` received by `\"Collection.FilterField\"` overrides in\n * wrap mode.\n */\nfunction DefaultFilterField({\n propertyKey,\n property,\n isArray,\n operators,\n value,\n setValue,\n title,\n hidden,\n setHidden\n}: FilterFieldBindingProps): React.ReactNode {\n\n if (property.type === \"reference\") {\n const referenceProperty = property as ReferenceProperty;\n return <ReferenceFilterField value={value}\n setValue={setValue}\n name={propertyKey}\n isArray={isArray}\n operators={operators}\n path={referenceProperty.path}\n title={title}\n includeId={referenceProperty.admin?.includeId}\n previewProperties={referenceProperty.admin?.previewProperties}\n hidden={hidden ?? false}\n setHidden={setHidden ?? (() => undefined)}/>;\n }\n\n if (property.type === \"relation\") {\n const relation = (property as RelationProperty).relation;\n if (!relation) return null;\n return <RelationFilterField value={value as never}\n setValue={setValue}\n name={propertyKey}\n operators={operators}\n relation={relation}\n hidden={hidden ?? false}\n setHidden={setHidden ?? (() => undefined)}/>;\n }\n\n if (property.type === \"number\" || property.type === \"string\") {\n const enumValues = property.enum ? enumToObjectEntries(property.enum) : undefined;\n return <StringNumberFilterField value={value}\n setValue={setValue}\n name={propertyKey}\n type={property.type}\n isArray={isArray}\n operators={operators}\n enumValues={enumValues}\n title={title}/>;\n }\n\n if (property.type === \"boolean\") {\n return <BooleanFilterField value={value}\n setValue={setValue}\n name={propertyKey}\n operators={operators}\n title={title}/>;\n }\n\n if (property.type === \"date\") {\n return <DateTimeFilterField value={value}\n setValue={setValue}\n name={propertyKey}\n mode={getDatePropertyMode(property)}\n timezone={getDatePropertyTimezone(property)}\n isArray={isArray}\n operators={operators}\n title={title}/>;\n }\n\n return null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DA,SAAgB,mBAAmB,EAC/B,aACA,UACA,QACA,OACA,UACA,QACA,aACyC;CAEzC,MAAM,UAAU,SAAS,SAAS;CAClC,MAAM,QAAQ,UAAW,SAA2B,KAAK,KAAA;CACzD,MAAM,eAAqC,UACpC,MAAM,QAAQ,KAAK,IAAI,MAAM,KAAK,QACnC;CAGN,MAAM,kBAAkB,mBAAmB;CAC3C,MAAM,sBAAsB,qBAA8C,0BAA0B,kBAAkB;CACtH,MAAM,iBAAiB,qBAA8C,cAAc,OAAO,MAAM;CAEhG,IAAI,CAAC,cAAc,OAAO;CAE1B,MAAM,YAAY,uBAAuB;EACrC,UAAU;EACV;EACA,QAAQ,UAAU,iBAAiB;CACvC,CAAC;CAED,MAAM,eAAwC;EAC1C;EACA,UAAU;EACV;EACA;EACA;EACA;EACA,OAAO,SAAS;EAChB;EACA;CACJ;CAGA,IAAI,gBACA,OACI,oBAAC,UAAD;EAAU,UAAU;YAChB,oBAAC,gBAAD,EAAgB,GAAI,aAAc,CAAA;CAC5B,CAAA;CAKlB,IAAI,UAAU,WAAW,GAAG,OAAO;CAEnC,OAAO,oBAAC,qBAAD,EAAqB,GAAI,aAAc,CAAA;AAClD;;;;;;AAOA,SAAS,mBAAmB,EACxB,aACA,UACA,SACA,WACA,OACA,UACA,OACA,QACA,aACyC;CAEzC,IAAI,SAAS,SAAS,aAAa;EAC/B,MAAM,oBAAoB;EAC1B,OAAO,oBAAC,sBAAD;GAA6B;GACtB;GACV,MAAM;GACG;GACE;GACX,MAAM,kBAAkB;GACjB;GACP,WAAW,kBAAkB,OAAO;GACpC,mBAAmB,kBAAkB,OAAO;GAC5C,QAAQ,UAAU;GAClB,WAAW,oBAAoB,KAAA;EAAY,CAAA;CACnD;CAEA,IAAI,SAAS,SAAS,YAAY;EAC9B,MAAM,WAAY,SAA8B;EAChD,IAAI,CAAC,UAAU,OAAO;EACtB,OAAO,oBAAC,qBAAD;GAA4B;GACrB;GACV,MAAM;GACK;GACD;GACV,QAAQ,UAAU;GAClB,WAAW,oBAAoB,KAAA;EAAY,CAAA;CACnD;CAEA,IAAI,SAAS,SAAS,YAAY,SAAS,SAAS,UAAU;EAC1D,MAAM,aAAa,SAAS,OAAO,oBAAoB,SAAS,IAAI,IAAI,KAAA;EACxE,OAAO,oBAAC,yBAAD;GAAgC;GACzB;GACV,MAAM;GACN,MAAM,SAAS;GACN;GACE;GACC;GACL;EAAO,CAAA;CACtB;CAEA,IAAI,SAAS,SAAS,WAClB,OAAO,oBAAC,oBAAD;EAA2B;EACpB;EACV,MAAM;EACK;EACJ;CAAO,CAAA;CAGtB,IAAI,SAAS,SAAS,QAClB,OAAO,oBAAC,qBAAD;EAA4B;EACrB;EACV,MAAM;EACN,MAAM,oBAAoB,QAAQ;EAClC,UAAU,wBAAwB,QAAQ;EACjC;EACE;EACJ;CAAO,CAAA;CAGtB,OAAO;AACX"}
1
+ {"version":3,"file":"FilterFieldBinding.js","names":[],"sources":["../../../../src/components/SelectableTable/filters/FilterFieldBinding.tsx"],"sourcesContent":["import React, { Suspense } from \"react\";\nimport {\n ArrayProperty,\n Property,\n ReferenceProperty,\n EntityRelation,\n RelationProperty,\n WhereFilterOp\n} from \"@rebasepro/types\";\nimport {\n FilterFieldBindingProps\n} from \"@rebasepro/cms-types\";\nimport { enumToObjectEntries, normalizeToEntityRelation } from \"@rebasepro/common\";\nimport { resolveFilterOperators } from \"@rebasepro/app\";\nimport { useCollectionScope, useComponentOverride, useResolvedComponent } from \"@rebasepro/app\";\nimport { StringNumberFilterField } from \"./StringNumberFilterField\";\nimport { BooleanFilterField } from \"./BooleanFilterField\";\nimport { DateTimeFilterField } from \"./DateTimeFilterField\";\nimport { ReferenceFilterField } from \"./ReferenceFilterField\";\nimport { RelationFilterField } from \"./RelationFilterField\";\nimport { getDatePropertyMode, getDatePropertyTimezone } from \"../../../preview/util\";\n\nexport interface FilterFieldBindingInput {\n /** Key of the property being filtered (the column id). */\n propertyKey: string;\n /** The raw property — array properties are unwrapped internally. */\n property: Property;\n /**\n * Engine backing the collection (`collection.engine`). Drives which\n * operators the engine can execute. Usually omitted — it is read from\n * the surrounding {@link CollectionScopeProvider}; pass it explicitly\n * only when rendering outside any collection scope.\n */\n engine?: string;\n value?: [WhereFilterOp, unknown];\n setValue: (value?: [WhereFilterOp, unknown]) => void;\n /** Coordination flags for fields that open their own dialogs. */\n hidden?: boolean;\n setHidden?: (hidden: boolean) => void;\n}\n\n/**\n * The single entry point for rendering a collection filter field.\n * Used by both the table header filters ({@link SelectableTable}) and the\n * Filters dialog.\n *\n * Resolution order:\n * 1. `property.admin.Filter` — per-property replacement (rendered even when the\n * resolved operator list is empty; the component owns filterability).\n * 2. `components[\"Collection.FilterField\"]` — collection-level or app-level\n * override (wrap mode supported via `OriginalComponent`).\n * 3. Built-in field dispatched by property type.\n *\n * The operators handed to the field are the intersection of the engine's\n * capabilities, the property-type defaults, and `property.admin.filterOperators`\n * (see `resolveFilterOperators`). When that intersection is empty and no\n * per-property `Filter` is set, nothing is rendered.\n *\n * @group Components\n */\nexport function FilterFieldBinding({\n propertyKey,\n property,\n engine,\n value,\n setValue,\n hidden,\n setHidden\n}: FilterFieldBindingInput): React.ReactNode {\n\n const isArray = property.type === \"array\";\n const ofVal = isArray ? (property as ArrayProperty).of : undefined;\n const baseProperty: Property | undefined = isArray\n ? (Array.isArray(ofVal) ? ofVal[0] : ofVal) as Property | undefined\n : property;\n\n // Hooks must run unconditionally — before any early return.\n const scopeCollection = useCollectionScope();\n const ResolvedFilterField = useComponentOverride<FilterFieldBindingProps>(\"Collection.FilterField\", DefaultFilterField);\n const PropertyFilter = useResolvedComponent<FilterFieldBindingProps>(baseProperty?.admin?.Filter);\n\n if (!baseProperty) return null;\n\n const operators = resolveFilterOperators({\n property: baseProperty,\n isArray,\n engine: engine ?? scopeCollection?.engine\n });\n\n const bindingProps: FilterFieldBindingProps = {\n propertyKey,\n property: baseProperty,\n isArray,\n operators,\n value,\n setValue,\n title: property.name,\n hidden,\n setHidden\n };\n\n // 1. Per-property replacement — always rendered, the dev owns filterability.\n if (PropertyFilter) {\n return (\n <Suspense fallback={null}>\n <PropertyFilter {...bindingProps}/>\n </Suspense>\n );\n }\n\n // 2/3. Override or built-in — only when the property is filterable here.\n if (operators.length === 0) return null;\n\n return <ResolvedFilterField {...bindingProps}/>;\n}\n\n/**\n * Built-in filter field dispatch by property type. This is the\n * `OriginalComponent` received by `\"Collection.FilterField\"` overrides in\n * wrap mode.\n */\n/**\n * A relation filter's value as `EntityRelation`s. The URL decoder builds them,\n * but a saved `defaultFilter` has been through JSON and holds plain\n * `{ __type: \"relation\", id, path }` objects. Returns `undefined` for anything\n * that is not a relation, so the field shows no selection rather than a wrong one.\n */\nexport function toRelationFilterValue(value: unknown): EntityRelation | EntityRelation[] | null | undefined {\n if (value === null) return null;\n if (value === undefined) return undefined;\n if (Array.isArray(value)) {\n const relations = value.map(item => normalizeToEntityRelation(item, \"relation\"));\n return relations.every((r): r is EntityRelation => r !== null) ? relations : undefined;\n }\n return normalizeToEntityRelation(value, \"relation\") ?? undefined;\n}\n\nfunction DefaultFilterField({\n propertyKey,\n property,\n isArray,\n operators,\n value,\n setValue,\n title,\n hidden,\n setHidden\n}: FilterFieldBindingProps): React.ReactNode {\n\n if (property.type === \"reference\") {\n const referenceProperty = property as ReferenceProperty;\n return <ReferenceFilterField value={value}\n setValue={setValue}\n name={propertyKey}\n isArray={isArray}\n operators={operators}\n path={referenceProperty.path}\n title={title}\n includeId={referenceProperty.admin?.includeId}\n previewProperties={referenceProperty.admin?.previewProperties}\n hidden={hidden ?? false}\n setHidden={setHidden ?? (() => undefined)}/>;\n }\n\n if (property.type === \"relation\") {\n const relation = (property as RelationProperty).relation;\n if (!relation) return null;\n const relations = value ? toRelationFilterValue(value[1]) : undefined;\n return <RelationFilterField value={value && (relations !== undefined || value[1] === undefined) ? [value[0], relations] : undefined}\n setValue={setValue}\n name={propertyKey}\n operators={operators}\n relation={relation}\n hidden={hidden ?? false}\n setHidden={setHidden ?? (() => undefined)}/>;\n }\n\n if (property.type === \"number\" || property.type === \"string\") {\n const enumValues = property.enum ? enumToObjectEntries(property.enum) : undefined;\n return <StringNumberFilterField value={value}\n setValue={setValue}\n name={propertyKey}\n type={property.type}\n isArray={isArray}\n operators={operators}\n enumValues={enumValues}\n title={title}/>;\n }\n\n if (property.type === \"boolean\") {\n return <BooleanFilterField value={value}\n setValue={setValue}\n name={propertyKey}\n operators={operators}\n title={title}/>;\n }\n\n if (property.type === \"date\") {\n return <DateTimeFilterField value={value}\n setValue={setValue}\n name={propertyKey}\n mode={getDatePropertyMode(property)}\n timezone={getDatePropertyTimezone(property)}\n isArray={isArray}\n operators={operators}\n title={title}/>;\n }\n\n return null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,SAAgB,mBAAmB,EAC/B,aACA,UACA,QACA,OACA,UACA,QACA,aACyC;CAEzC,MAAM,UAAU,SAAS,SAAS;CAClC,MAAM,QAAQ,UAAW,SAA2B,KAAK,KAAA;CACzD,MAAM,eAAqC,UACpC,MAAM,QAAQ,KAAK,IAAI,MAAM,KAAK,QACnC;CAGN,MAAM,kBAAkB,mBAAmB;CAC3C,MAAM,sBAAsB,qBAA8C,0BAA0B,kBAAkB;CACtH,MAAM,iBAAiB,qBAA8C,cAAc,OAAO,MAAM;CAEhG,IAAI,CAAC,cAAc,OAAO;CAE1B,MAAM,YAAY,uBAAuB;EACrC,UAAU;EACV;EACA,QAAQ,UAAU,iBAAiB;CACvC,CAAC;CAED,MAAM,eAAwC;EAC1C;EACA,UAAU;EACV;EACA;EACA;EACA;EACA,OAAO,SAAS;EAChB;EACA;CACJ;CAGA,IAAI,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S,SAAS,YAAY,SAAS,SAAS,UAAU;EAC1D,MAAM,aAAa,SAAS,OAAO,oBAAoB,SAAS,IAAI,IAAI,KAAA;EACxE,OAAO,oBAAC,yBAAD;GAAgC;GACzB;GACV,MAAM;GACN,MAAM,SAAS;GACN;GACE;GACC;GACL;EAAO,CAAA;CACtB;CAEA,IAAI,SAAS,SAAS,WAClB,OAAO,oBAAC,oBAAD;EAA2B;EACpB;EACV,MAAM;EACK;EACJ;CAAO,CAAA;CAGtB,IAAI,SAAS,SAAS,QAClB,OAAO,oBAAC,qBAAD;EAA4B;EACrB;EACV,MAAM;EACN,MAAM,oBAAoB,QAAQ;EAClC,UAAU,wBAAwB,QAAQ;EACjC;EACE;EACJ;CAAO,CAAA;CAGtB,OAAO;AACX"}
@@ -3,7 +3,7 @@ import { VirtualTableWhereFilterOp } from "@rebasepro/ui";
3
3
  import { EntityRelation, Relation } from "@rebasepro/types";
4
4
  interface RelationFilterFieldProps {
5
5
  name: string;
6
- value?: [VirtualTableWhereFilterOp, EntityRelation | EntityRelation[] | null];
6
+ value?: [VirtualTableWhereFilterOp, EntityRelation | EntityRelation[] | null | undefined];
7
7
  setValue: (value?: [VirtualTableWhereFilterOp, EntityRelation | EntityRelation[] | null]) => void;
8
8
  relation: Relation;
9
9
  hidden: boolean;