@rebasepro/app 0.13.0 → 0.13.1-canary.g394d868

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 (36) hide show
  1. package/dist/collections/entity-display-cache.d.ts +75 -0
  2. package/dist/collections/entity-display.d.ts +35 -0
  3. package/dist/collections/entity_image_preview.d.ts +8 -0
  4. package/dist/collections/form-layout.d.ts +6 -0
  5. package/dist/collections/index.d.ts +4 -0
  6. package/dist/collections/property-path.d.ts +16 -0
  7. package/dist/collections/property_presentation.d.ts +18 -3
  8. package/dist/collections/summary-property.d.ts +65 -0
  9. package/dist/components/common/useColumnsIds.d.ts +22 -0
  10. package/dist/index.es.js +604 -187
  11. package/dist/index.es.js.map +1 -1
  12. package/dist/util/entity_cache.d.ts +19 -3
  13. package/dist/util/previews.d.ts +19 -0
  14. package/package.json +7 -7
  15. package/src/auth/useRebaseAuthController.ts +9 -1
  16. package/src/collections/entity-display-cache.ts +195 -0
  17. package/src/collections/entity-display.ts +105 -0
  18. package/src/collections/entity_image_preview.ts +13 -0
  19. package/src/collections/form-layout.ts +8 -1
  20. package/src/collections/index.ts +4 -0
  21. package/src/collections/property-path.ts +30 -0
  22. package/src/collections/property_presentation.ts +39 -4
  23. package/src/collections/summary-property.ts +114 -0
  24. package/src/collections/title-property.ts +13 -16
  25. package/src/components/common/useColumnsIds.tsx +67 -29
  26. package/src/core/Rebase.tsx +19 -1
  27. package/src/hooks/useAuthSubscription.ts +18 -2
  28. package/src/locales/de.ts +1 -0
  29. package/src/locales/en.ts +2 -0
  30. package/src/locales/es.ts +1 -0
  31. package/src/locales/fr.ts +1 -0
  32. package/src/locales/hi.ts +2 -1
  33. package/src/locales/it.ts +1 -0
  34. package/src/locales/pt.ts +1 -0
  35. package/src/util/entity_cache.ts +34 -31
  36. package/src/util/previews.ts +49 -29
package/dist/index.es.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import React, { createContext, lazy, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
2
2
  import { Alert, AlertCircleIcon, AlertTriangleIcon, AppWindow, ArrowDownIcon, ArrowLeftIcon, ArrowRightLeftIcon, ArrowUpDownIcon, ArrowUpIcon, Avatar, BooleanSwitch, Button, CalendarIcon, Card, CenteredView, CheckCircle2Icon, CheckIcon, Checkbox, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronsLeftIcon, ChevronsRightIcon, Chip, CircleDotIcon, CircleUserIcon, CircularProgress, ColumnsIcon, Container, Dialog, DialogActions, DialogContent, DialogTitle, DollarSignIcon, ErrorBoundary, FileIcon, FileTextIcon, FilterChip, FilterIcon, FolderIcon, FolderKanbanIcon, IconButton, KanbanIcon, KanbanView, LanguagesIcon, LayoutGridIcon, ListIcon, ListPlusIcon, ListTodoIcon, LoadingButton, LogOutIcon, MailIcon, Menu, MenuItem, MessageCircleIcon, MoonIcon, MultiSelect, MultiSelectItem, PanelLeftIcon, Paper, PenLineIcon, PencilIcon, PhoneIcon, PinIcon, PlusIcon, Popover, RefreshCwIcon, SearchBar, Select, SelectItem, Separator, SettingsIcon, Skeleton, StickyNoteIcon, SunIcon, SunMoonIcon, Tab, Table, TableBody, TableCell, TableHeader, TableRow, Tabs, TagIcon, TextField, ToggleButtonGroup, Tooltip, Trash2Icon, TrendingUpIcon, TypeIcon, Typography, UserIcon, UserPlus, UsersIcon, VideoIcon, Wand2Icon, WrenchIcon, XIcon, cls, colorClassesMapping, coolIconKeys, defaultBorderMixin, getColorSchemeForKey, getColorSchemeForSeed, iconKeys, iconSize, lucideIcons } from "@rebasepro/ui";
3
3
  import { ALL_WHERE_FILTER_OPS, DEFAULT_DATA_SOURCE_KEY, DEFAULT_FILTERABLE_RELATION_KINDS, DEFAULT_STORAGE_SOURCE_KEY, EntityReference, EntityRelation, GeoPoint, RebaseApiError, Vector, getDataSourceCapabilities, isLazyComponentRef, isRelationalCollectionConfig } from "@rebasepro/types";
4
+ import { UNRENDERED_SLOTS, resolveAdminCollection } from "@rebasepro/admin-types";
4
5
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
6
  import { SnackbarProvider as SnackbarProvider$1, useSnackbar } from "notistack";
6
- import { buildRebaseData, canCreateEntity, canDeleteEntity, canEditEntity, canReadCollection, evaluateCondition, getEntityChildViews, getLabelOrConfigFrom, getPrimaryKeys, getSubcollections, isPropertyBuilder, resolveStorageFilenameString, resolveStoragePathString, resolveStorageSource, stripCollectionPath, wrapAsEntityData, wrapAsSdkData } from "@rebasepro/common";
7
+ import { buildRebaseData, canCreateEntity, canDeleteEntity, canEditEntity, canReadCollection, evaluateCondition, getChildViewDeclaringProperties, getChildViewRelationPropertyKeys, getEntityChildViews, getLabelOrConfigFrom, getPrimaryKeys, getSubcollections, isPropertyBuilder, resolveStorageFilenameString, resolveStoragePathString, resolveStorageSource, stripCollectionPath, wrapAsEntityData, wrapAsSdkData } from "@rebasepro/common";
7
8
  import { getTitlePropertyKey as getTitlePropertyKey$1, removeInitialAndTrailingSlashes as removeInitialAndTrailingSlashes$1 } from "@rebasepro/app";
8
9
  import { Link, Routes, createBrowserRouter, useBlocker, useLocation } from "react-router";
9
10
  import { generateForeignKeyName, hashString, isObject, isPlainObject, mergeDeep, randomString, slugify } from "@rebasepro/utils";
@@ -13,7 +14,6 @@ import i18next from "i18next";
13
14
  import { RouterProvider } from "react-router/dom";
14
15
  import Fuse from "fuse.js";
15
16
  import Compressor from "compressorjs";
16
- import { resolveAdminCollection } from "@rebasepro/admin-types";
17
17
  //#region src/core/PluginProviderStack.tsx
18
18
  /**
19
19
  * Wraps children with all provider components from plugins that match the given scope.
@@ -414,6 +414,97 @@ function SchemaDriftBanner({ className }) {
414
414
  });
415
415
  }
416
416
  //#endregion
417
+ //#region src/collections/summary-property.ts
418
+ /**
419
+ * Whether a property can stand in for a record in *one line*.
420
+ *
421
+ * Preview surfaces — the reference card, a list row, a board card — have a
422
+ * single line per property and no way to grow. That is a constraint on the
423
+ * *value*, not on the property's importance: a Markdown biography is the most
424
+ * interesting column on an author, and it is still the wrong thing to paste
425
+ * into a 44px card. Ranking it here means the picker can skip it without
426
+ * anyone having to configure their way out of a broken card.
427
+ *
428
+ * Kept beside {@link getTitlePropertyCandidates} because the two answer
429
+ * neighbouring questions — "what is this record called" and "what else can be
430
+ * said about it in a line" — from the same property schema.
431
+ *
432
+ * @group Collections
433
+ */
434
+ var SUMMARY_RANK = {
435
+ /**
436
+ * No single-line form exists. A map renders as a key/value table and an
437
+ * array of maps as a stack of them; there is no first line to take.
438
+ */
439
+ UNUSABLE: 0,
440
+ /**
441
+ * Readable in one line, but only as an excerpt — the property holds a
442
+ * document, and the line is its opening. Worth showing when nothing better
443
+ * is available, never in preference to a value that fits whole.
444
+ */
445
+ EXCERPT: 1,
446
+ /** Short and self-contained: the line *is* the value. */
447
+ DIRECT: 2
448
+ };
449
+ /**
450
+ * File-storage backed content (single image, array of images, generic upload…).
451
+ * Preview surfaces give these their own image slot, so they are never also a
452
+ * text line.
453
+ *
454
+ * @group Collections
455
+ */
456
+ function isStorageProperty(property) {
457
+ if (!property) return false;
458
+ if (property.type === "string" && (property.storage || property.admin?.urlPreview === "image")) return true;
459
+ if (property.type === "array" && property.of && !Array.isArray(property.of)) {
460
+ const inner = property.of;
461
+ if (inner.type === "string" && (inner.storage || inner.admin?.urlPreview === "image")) return true;
462
+ }
463
+ return false;
464
+ }
465
+ /**
466
+ * True when the property holds free text long enough to be a document rather
467
+ * than a value — Markdown, or an explicitly multi-line string.
468
+ *
469
+ * @group Collections
470
+ */
471
+ function isLongTextProperty(property) {
472
+ if (!property || property.type !== "string") return false;
473
+ return Boolean(property.admin?.markdown || property.admin?.multiline);
474
+ }
475
+ /**
476
+ * How well a property reads as one line of a preview. See {@link SUMMARY_RANK}.
477
+ *
478
+ * Decided from the property *schema* only: no values are consulted, so the
479
+ * answer is stable for a collection and can be memoised per collection rather
480
+ * than per row.
481
+ *
482
+ * @group Collections
483
+ */
484
+ function rankSummaryProperty(property) {
485
+ if (!property) return SUMMARY_RANK.UNUSABLE;
486
+ if (isStorageProperty(property)) return SUMMARY_RANK.UNUSABLE;
487
+ if (property.type === "map") return SUMMARY_RANK.UNUSABLE;
488
+ if (property.type === "array") {
489
+ if (Array.isArray(property.of)) return SUMMARY_RANK.UNUSABLE;
490
+ if (!property.of) return property.oneOf ? SUMMARY_RANK.UNUSABLE : SUMMARY_RANK.DIRECT;
491
+ const innerRank = rankSummaryProperty(property.of);
492
+ if (innerRank === SUMMARY_RANK.UNUSABLE) return SUMMARY_RANK.UNUSABLE;
493
+ if (innerRank === SUMMARY_RANK.EXCERPT) return SUMMARY_RANK.UNUSABLE;
494
+ return SUMMARY_RANK.DIRECT;
495
+ }
496
+ if (isLongTextProperty(property)) return SUMMARY_RANK.EXCERPT;
497
+ return SUMMARY_RANK.DIRECT;
498
+ }
499
+ /**
500
+ * True when the property has any single-line form at all.
501
+ *
502
+ * @group Collections
503
+ */
504
+ function canSummariseProperty(property) {
505
+ return rankSummaryProperty(property) !== SUMMARY_RANK.UNUSABLE;
506
+ }
507
+ //#endregion
417
508
  //#region src/util/previews.ts
418
509
  function isReferenceProperty(property) {
419
510
  if (!property) return null;
@@ -434,35 +525,47 @@ function isHiddenProperty(property) {
434
525
  return Boolean(property.admin?.hideFromCollection);
435
526
  }
436
527
  /**
437
- * Returns true when the property holds file-storage content (single image,
438
- * array of images, generic upload, …). These properties are rendered by the
439
- * dedicated image-slot and should NOT appear as regular preview columns.
528
+ * The properties a preview surface should render for a record, best first.
529
+ *
530
+ * Three things decide the answer, in this order:
531
+ *
532
+ * 1. `previewProperties` — passed in, or declared on the collection. A stated
533
+ * list is returned verbatim, ranking and limit included: a developer who
534
+ * asks for the Markdown biography gets the Markdown biography.
535
+ * 2. Whether the value has a one-line form at all. A map renders as a
536
+ * key/value table and a Markdown field as a document; neither fits a card
537
+ * line, so they never take a slot from a value that does. See
538
+ * {@link rankSummaryProperty}.
539
+ * 3. `propertiesOrder`, which breaks ties.
540
+ *
541
+ * The middle step is the one that is easy to get wrong by leaving out.
542
+ * `propertiesOrder` states the *column* order of a collection table — it is
543
+ * not a statement that the first three columns summarise a record, and reading
544
+ * it as one is how a card ends up rendering somebody's entire biography.
440
545
  */
441
- function isStorageProperty$1(property) {
442
- if (!property) return false;
443
- if (property.type === "string" && property.storage) return true;
444
- if (property.type === "string" && property.admin?.urlPreview === "image") return true;
445
- if (property.type === "array" && property.of && !Array.isArray(property.of)) {
446
- const inner = property.of;
447
- if (inner.type === "string" && (inner.storage || inner.admin?.urlPreview === "image")) return true;
448
- }
449
- return false;
450
- }
451
546
  function getEntityPreviewKeys(authController, targetCollection, fields, previewProperties, limit = 3) {
452
547
  const allProperties = Object.keys(targetCollection.properties);
453
548
  let listProperties = previewProperties?.filter((p) => allProperties.includes(p));
454
549
  if (!listProperties && targetCollection.previewProperties) listProperties = targetCollection.previewProperties?.filter((p) => allProperties.includes(p));
455
550
  if (listProperties && listProperties.length > 0) return listProperties;
456
- else {
457
- listProperties = targetCollection.propertiesOrder || allProperties;
458
- return listProperties.filter((key) => {
459
- const prop = targetCollection.properties[key];
460
- return !(prop && typeof prop === "object" && "isId" in prop && Boolean(prop.isId)) && key !== "id";
461
- }).filter((key) => {
462
- const property = targetCollection.properties[key];
463
- return property && !isPropertyBuilder(property) && !isReferenceProperty(property) && !isRelationProperty(property) && !isHiddenProperty(property) && !isStorageProperty$1(property);
464
- }).slice(0, limit);
551
+ const hasExplicitOrder = !!targetCollection.propertiesOrder;
552
+ const order = targetCollection.propertiesOrder || allProperties;
553
+ const direct = [];
554
+ const excerpt = [];
555
+ for (const key of order) {
556
+ const property = targetCollection.properties[key];
557
+ if (!property || isPropertyBuilder(property)) continue;
558
+ if (key === "id" || "isId" in property && Boolean(property.isId)) continue;
559
+ if (isReferenceProperty(property)) continue;
560
+ if (!hasExplicitOrder && isRelationProperty(property)) continue;
561
+ if (isHiddenProperty(property)) continue;
562
+ if (isStorageProperty(property)) continue;
563
+ const rank = rankSummaryProperty(property);
564
+ if (rank === SUMMARY_RANK.UNUSABLE) continue;
565
+ (rank === SUMMARY_RANK.EXCERPT ? excerpt : direct).push(key);
566
+ if (direct.length >= limit) break;
465
567
  }
568
+ return [...direct, ...excerpt].slice(0, limit);
466
569
  }
467
570
  var INCLUDE_ALL_RELATIONS = ["*"];
468
571
  /**
@@ -1254,7 +1357,15 @@ function useAuthSubscription(authClient) {
1254
1357
  setInitialLoading(true);
1255
1358
  authClient.getUser().then((user) => {
1256
1359
  if (user) setUser(user);
1257
- }).catch((e) => {}).finally(() => {
1360
+ setAuthError(void 0);
1361
+ }).catch((e) => {
1362
+ const status = e?.status;
1363
+ if (status === 401 || status === 403) {
1364
+ setAuthError(void 0);
1365
+ return;
1366
+ }
1367
+ setAuthError(e instanceof Error ? e : new Error(String(e)));
1368
+ }).finally(() => {
1258
1369
  setInitialLoading(false);
1259
1370
  });
1260
1371
  }
@@ -2325,24 +2436,202 @@ function useDebouncedData(data, deps, timeoutMs = 5e3) {
2325
2436
  return immediateUpdate ? data : deferredData;
2326
2437
  }
2327
2438
  //#endregion
2328
- //#region src/components/common/useColumnsIds.tsx
2439
+ //#region src/collections/property-path.ts
2329
2440
  /**
2330
- * Get a property in a property tree from a dot-path like `address.street`.
2331
- * Inlined here to avoid importing property-aware utilities from the admin layer.
2441
+ * The property at a dotted path, walking `map` children — `address.street`.
2442
+ *
2443
+ * The value counterpart is `getValueInPath` in `@rebasepro/utils`; this is the
2444
+ * schema half, and the two have to be used together. Reading a dotted path off
2445
+ * an entity while looking its property up with a flat `properties[path]` gives
2446
+ * the value and `undefined` for how to render it, which is how a declared title
2447
+ * on a nested field silently fell back to a derived one.
2448
+ *
2449
+ * There were three copies of this: one private to `useColumnsIds`, one exported
2450
+ * from the admin layer, and the flat lookup in the title resolver that was not
2451
+ * this function at all. This is the one, in the lowest layer that needs it —
2452
+ * admin re-exports it under the name it already published.
2332
2453
  */
2333
2454
  function getPropertyInPath(properties, path) {
2334
- if (typeof properties === "object") {
2335
- if (path in properties) return properties[path];
2336
- if (path.includes(".")) {
2337
- const pathSegments = path.split(".");
2338
- const childProperty = properties[pathSegments[0]];
2339
- if (typeof childProperty === "object" && childProperty.type === "map" && childProperty.properties) return getPropertyInPath(childProperty.properties, pathSegments.slice(1).join("."));
2455
+ if (typeof properties !== "object" || !properties) return void 0;
2456
+ if (path in properties) return properties[path];
2457
+ if (path.includes(".")) {
2458
+ const pathSegments = path.split(".");
2459
+ const childProperty = properties[pathSegments[0]];
2460
+ if (typeof childProperty === "object" && childProperty?.type === "map" && childProperty.properties) return getPropertyInPath(childProperty.properties, pathSegments.slice(1).join("."));
2461
+ }
2462
+ }
2463
+ //#endregion
2464
+ //#region src/collections/property_presentation.ts
2465
+ /**
2466
+ * A condition stated as a literal rather than as a rule.
2467
+ *
2468
+ * `PropertyConditions` accepts either, and the two are answered in different
2469
+ * places: a rule needs a context and so can only be evaluated while rendering a
2470
+ * particular entity, but a literal is already the answer. Reading it here is
2471
+ * what makes `hidden: true` work without every gate below having to build a
2472
+ * condition context first — and without the caller reaching for
2473
+ * `{ "==": [1, 1] }` to say something it can say with a boolean.
2474
+ */
2475
+ function literalCondition(condition) {
2476
+ return condition === true;
2477
+ }
2478
+ function isReadOnly(property) {
2479
+ if (property.admin?.readOnly) return true;
2480
+ if (literalCondition(property.conditions?.readOnly)) return true;
2481
+ if (property.type === "date") {
2482
+ if (property.autoValue) return true;
2483
+ }
2484
+ if (property.type === "reference") return !property.path && !("Field" in (property.admin || {}) && property.admin?.Field);
2485
+ return false;
2486
+ }
2487
+ function isHidden(property) {
2488
+ if (literalCondition(property.conditions?.hidden)) return true;
2489
+ return typeof property.admin?.disabled === "object" && Boolean(property.admin?.disabled.hidden);
2490
+ }
2491
+ /**
2492
+ * Whether the field is disabled by its own declaration, ignoring form state.
2493
+ *
2494
+ * The `admin.disabled` block and `conditions.disabled: true` say the same thing
2495
+ * two ways, so every caller that gated on the first now asks here instead of
2496
+ * growing a second check of its own.
2497
+ */
2498
+ function isDisabled(property) {
2499
+ return Boolean(property.admin?.disabled) || literalCondition(property.conditions?.disabled);
2500
+ }
2501
+ function applyPropertyConditions(property, context) {
2502
+ const { conditions } = property;
2503
+ if (!conditions) return property;
2504
+ const result = { ...property };
2505
+ if (conditions.disabled) {
2506
+ if (evaluateCondition(conditions.disabled, context)) {
2507
+ result.admin = result.admin || {};
2508
+ result.admin.disabled = {
2509
+ clearOnDisabled: conditions.clearOnDisabled ?? false,
2510
+ disabledMessage: conditions.disabledMessage,
2511
+ hidden: false
2512
+ };
2340
2513
  }
2341
2514
  }
2515
+ if (conditions.hidden) {
2516
+ if (evaluateCondition(conditions.hidden, context)) {
2517
+ result.admin = result.admin || {};
2518
+ result.admin.disabled = {
2519
+ ...typeof result.admin?.disabled === "object" ? result.admin.disabled : {},
2520
+ hidden: true,
2521
+ clearOnDisabled: conditions.clearOnDisabled ?? false
2522
+ };
2523
+ }
2524
+ }
2525
+ if (conditions.readOnly) {
2526
+ if (evaluateCondition(conditions.readOnly, context)) {
2527
+ result.admin = result.admin || {};
2528
+ result.admin.readOnly = true;
2529
+ }
2530
+ }
2531
+ if (conditions.required !== void 0) {
2532
+ const isRequired = evaluateCondition(conditions.required, context);
2533
+ result.validation = {
2534
+ ...result.validation,
2535
+ required: isRequired,
2536
+ requiredMessage: conditions.requiredMessage
2537
+ };
2538
+ }
2539
+ if (context.isNew && conditions.defaultValue !== void 0) result.defaultValue = evaluateCondition(conditions.defaultValue, context);
2540
+ if ("enum" in result && result.enum && (conditions.enumConditions || conditions.allowedEnumValues || conditions.excludedEnumValues)) result.enum = applyEnumConditions(result.enum, conditions, context);
2541
+ if (result.type === "reference") {
2542
+ if (conditions.referencePath) result.path = evaluateCondition(conditions.referencePath, context);
2543
+ if (conditions.referenceFilter) {
2544
+ result.admin = result.admin || {};
2545
+ result.admin.fixedFilter = evaluateCondition(conditions.referenceFilter, context);
2546
+ }
2547
+ }
2548
+ if (result.type === "array") {
2549
+ if (conditions.canAddElements !== void 0) {
2550
+ result.admin = result.admin || {};
2551
+ result.admin.canAddElements = evaluateCondition(conditions.canAddElements, context);
2552
+ }
2553
+ if (conditions.sortable !== void 0) {
2554
+ result.admin = result.admin || {};
2555
+ result.admin.sortable = evaluateCondition(conditions.sortable, context);
2556
+ }
2557
+ }
2558
+ return result;
2559
+ }
2560
+ /**
2561
+ * Convert an object with numeric keys back to an array.
2562
+ * Firestore stores arrays as {"0": "a", "1": "b"} to avoid nested arrays.
2563
+ */
2564
+ function objectToArray(obj) {
2565
+ if (Array.isArray(obj)) return obj.map(String);
2566
+ if (obj && typeof obj === "object") {
2567
+ const keys = Object.keys(obj);
2568
+ if (keys.length > 0 && keys.every((k) => !isNaN(Number(k)))) return keys.sort((a, b) => Number(a) - Number(b)).map((k) => obj[k]).filter((v) => typeof v === "string" || typeof v === "number").map(String);
2569
+ }
2570
+ return [];
2342
2571
  }
2572
+ /**
2573
+ * Apply enum-specific conditions to filter and modify enum values.
2574
+ */
2575
+ function applyEnumConditions(enumValues, conditions, context) {
2576
+ let result = [...enumValues];
2577
+ if (conditions.allowedEnumValues) {
2578
+ const allowedArray = objectToArray(evaluateCondition(conditions.allowedEnumValues, context));
2579
+ if (allowedArray.length > 0) result = result.filter((ev) => allowedArray.includes(String(ev.id)));
2580
+ }
2581
+ if (conditions.excludedEnumValues) {
2582
+ const excludedArray = objectToArray(evaluateCondition(conditions.excludedEnumValues, context));
2583
+ if (excludedArray.length > 0) result = result.filter((ev) => !excludedArray.includes(String(ev.id)));
2584
+ }
2585
+ if (conditions.enumConditions) result = result.map((ev) => {
2586
+ const evConditions = conditions.enumConditions?.[ev.id];
2587
+ if (!evConditions) return ev;
2588
+ if (evConditions.hidden && evaluateCondition(evConditions.hidden, context)) return null;
2589
+ if (evConditions.disabled && evaluateCondition(evConditions.disabled, context)) return {
2590
+ ...ev,
2591
+ disabled: true
2592
+ };
2593
+ return ev;
2594
+ }).filter((ev) => ev !== null);
2595
+ return result;
2596
+ }
2597
+ //#endregion
2598
+ //#region src/components/common/useColumnsIds.tsx
2343
2599
  function getSubcollectionColumnId(collection) {
2344
2600
  return `subcollection:${collection.slug}`;
2345
2601
  }
2602
+ /**
2603
+ * The jump-to-tab columns a collection table does not need, because the relation
2604
+ * behind them already has a column of its own.
2605
+ *
2606
+ * Every child view gets a 200px button column that opens its tab. For a relation
2607
+ * declared in `relations` that button is the relation's only presence in the
2608
+ * table. For one declared as a property it is the second: the property's own
2609
+ * column is already there, hydrated by the list fetch's `include: ["*"]`, showing
2610
+ * the child rows themselves — and carrying the *same heading*, because the tab
2611
+ * takes its name from the declaring property. Two columns called "Applications",
2612
+ * one of them a button, and nothing in the header to tell them apart.
2613
+ *
2614
+ * The property column wins: it shows what the children are, and each chip in it
2615
+ * opens one. The tab stays reachable by opening the record, which is what the
2616
+ * rest of the table's rows do anyway.
2617
+ *
2618
+ * Unless the author hid that column — `hideFromCollection` on the property, or a
2619
+ * `propertiesOrder` that omits it, is a statement about the column and not about
2620
+ * the relation, so the button comes back rather than the relation dropping out
2621
+ * of the table altogether.
2622
+ */
2623
+ function getRedundantChildViewColumnIds(collection) {
2624
+ const redundant = /* @__PURE__ */ new Set();
2625
+ const properties = collection.properties ?? {};
2626
+ const order = collection.propertiesOrder;
2627
+ for (const [viewKey, propertyKey] of getChildViewDeclaringProperties(collection)) {
2628
+ const property = properties[propertyKey];
2629
+ if (!property || property.admin?.hideFromCollection) continue;
2630
+ if (order && !order.includes(propertyKey)) continue;
2631
+ redundant.add(`subcollection:${viewKey}`);
2632
+ }
2633
+ return redundant;
2634
+ }
2346
2635
  function useColumnIds(collection, includeSubcollections) {
2347
2636
  return useMemo(() => {
2348
2637
  if (collection.propertiesOrder) return hideAndExpandKeys(collection, collection.propertiesOrder);
@@ -2357,8 +2646,10 @@ function hideAndExpandKeys(collection, keys) {
2357
2646
  if (rootProperty && rootProperty.type === "map" && rootProperty.admin?.spreadChildren && rootProperty.properties) rootsWithExplicitChildren.add(rootKey);
2358
2647
  }
2359
2648
  const processedPropertyKeys = /* @__PURE__ */ new Set();
2649
+ const redundantChildViewColumns = getRedundantChildViewColumnIds(collection);
2360
2650
  const result = keys.flatMap((key) => {
2361
2651
  if (processedPropertyKeys.has(key)) return [null];
2652
+ if (redundantChildViewColumns.has(key)) return [null];
2362
2653
  const property = collection.properties[key];
2363
2654
  if (property) {
2364
2655
  processedPropertyKeys.add(key);
@@ -2372,7 +2663,7 @@ function hideAndExpandKeys(collection, keys) {
2372
2663
  }
2373
2664
  return [{
2374
2665
  key,
2375
- disabled: Boolean(property.admin?.disabled) || Boolean(property.admin?.readOnly)
2666
+ disabled: isDisabled(property) || Boolean(property.admin?.readOnly)
2376
2667
  }];
2377
2668
  }
2378
2669
  if (key.includes(".")) {
@@ -2387,7 +2678,7 @@ function hideAndExpandKeys(collection, keys) {
2387
2678
  if (nestedProperty.admin?.disabled && typeof nestedProperty.admin?.disabled === "object" && nestedProperty.admin?.disabled.hidden) return [null];
2388
2679
  return [{
2389
2680
  key,
2390
- disabled: Boolean(rootProperty.admin?.disabled) || Boolean(rootProperty.admin?.readOnly) || Boolean(nestedProperty.admin?.disabled) || Boolean(nestedProperty.admin?.readOnly)
2681
+ disabled: isDisabled(rootProperty) || Boolean(rootProperty.admin?.readOnly) || isDisabled(nestedProperty) || Boolean(nestedProperty.admin?.readOnly)
2391
2682
  }];
2392
2683
  }
2393
2684
  }
@@ -2420,7 +2711,7 @@ function hideAndExpandKeys(collection, keys) {
2420
2711
  } else {
2421
2712
  result.push({
2422
2713
  key: propKey,
2423
- disabled: Boolean(property.admin?.disabled) || Boolean(property.admin?.readOnly)
2714
+ disabled: isDisabled(property) || Boolean(property.admin?.readOnly)
2424
2715
  });
2425
2716
  processedPropertyKeys.add(propKey);
2426
2717
  }
@@ -2439,14 +2730,20 @@ function getDefaultColumnKeys(collection, includeSubCollections) {
2439
2730
  return hideAndExpandKeys(collection, columnIds);
2440
2731
  }
2441
2732
  function getColumnKeysForProperty(property, key, disabled) {
2442
- if (property.type === "map" && property.admin?.spreadChildren && property.properties) return Object.entries(property.properties).flatMap(([childKey, childProperty]) => getColumnKeysForProperty(childProperty, `${key}.${childKey}`, disabled || Boolean(property.admin?.disabled) || Boolean(property.admin?.readOnly)));
2733
+ if (!property) return [];
2734
+ if (property.type === "map" && property.admin?.spreadChildren && property.properties) return Object.entries(property.properties).flatMap(([childKey, childProperty]) => getColumnKeysForProperty(childProperty, `${key}.${childKey}`, disabled || isDisabled(property) || Boolean(property.admin?.readOnly)));
2443
2735
  return [{
2444
2736
  key,
2445
- disabled: disabled || Boolean(property.admin?.disabled) || Boolean(property.admin?.readOnly)
2737
+ disabled: disabled || isDisabled(property) || Boolean(property.admin?.readOnly)
2446
2738
  }];
2447
2739
  }
2448
2740
  function getFormFieldKeys(collection) {
2449
- const propertyKeys = collection.properties ? Object.keys(collection.properties) : [];
2741
+ const properties = collection.properties ?? {};
2742
+ const consumedByChildView = getChildViewRelationPropertyKeys(collection);
2743
+ const propertyKeys = Object.keys(properties).filter((key) => {
2744
+ if (!consumedByChildView.has(key)) return true;
2745
+ return properties[key].admin?.renderInForm === true;
2746
+ });
2450
2747
  const additionalFields = collection.additionalFields ?? [];
2451
2748
  const allKeys = [...propertyKeys, ...additionalFields.map((field) => field.key)];
2452
2749
  if (collection.propertiesOrder) return collection.propertiesOrder.filter((key) => allKeys.includes(key));
@@ -9821,6 +10118,7 @@ var en = {
9821
10118
  column_cannot_be_edited: "This column can't be edited directly",
9822
10119
  close: "Close",
9823
10120
  hide_list: "Hide list",
10121
+ show_list: "Show list",
9824
10122
  unsaved_local_changes: "Unsaved Local changes",
9825
10123
  unsaved_local_changes_description: "This document was edited locally and has unsaved changes. These local changes will be lost if you don't apply them.",
9826
10124
  preview_changes: "Preview Changes",
@@ -10632,6 +10930,7 @@ var en = {
10632
10930
  inspect_record: "Inspect record",
10633
10931
  inspect: "Inspect",
10634
10932
  close_inspector: "Close inspector",
10933
+ open_in_live_site: "Open in the live site",
10635
10934
  history_revert: "Revert to this version",
10636
10935
  history_revert_title: "Revert data to this version?",
10637
10936
  history_reverted: "Reverted to selected version",
@@ -10720,6 +11019,7 @@ var es = {
10720
11019
  column_cannot_be_edited: "Esta columna no se puede editar directamente",
10721
11020
  close: "Cerrar",
10722
11021
  hide_list: "Ocultar lista",
11022
+ show_list: "Mostrar lista",
10723
11023
  unsaved_local_changes: "Cambios locales sin guardar",
10724
11024
  unsaved_local_changes_description: "Este documento ha sido editado localmente y tiene cambios sin guardar. Estos cambios locales se perderán si no los aplicas.",
10725
11025
  preview_changes: "Previsualizar cambios",
@@ -11576,6 +11876,7 @@ var de = {
11576
11876
  column_cannot_be_edited: "Diese Spalte kann nicht direkt bearbeitet werden",
11577
11877
  close: "Schließen",
11578
11878
  hide_list: "Liste ausblenden",
11879
+ show_list: "Liste einblenden",
11579
11880
  unsaved_local_changes: "Ungespeicherte lokale Änderungen",
11580
11881
  unsaved_local_changes_description: "Dieses Dokument wurde lokal bearbeitet und weist ungespeicherte Änderungen auf. Diese lokalen Änderungen gehen verloren, wenn Sie sie nicht anwenden.",
11581
11882
  preview_changes: "Änderungen in der Vorschau anzeigen",
@@ -12422,6 +12723,7 @@ var fr = {
12422
12723
  column_cannot_be_edited: "Cette colonne ne peut pas être modifiée directement",
12423
12724
  close: "Fermer",
12424
12725
  hide_list: "Masquer la liste",
12726
+ show_list: "Afficher la liste",
12425
12727
  unsaved_local_changes: "Modifications locales non enregistrées",
12426
12728
  unsaved_local_changes_description: "Ce document a été modifié localement et contient des modifications non enregistrées. Ces modifications locales seront perdues si vous ne les appliquez pas.",
12427
12729
  preview_changes: "Aperçu des modifications",
@@ -13268,6 +13570,7 @@ var it = {
13268
13570
  column_cannot_be_edited: "Questa colonna non può essere modificata direttamente",
13269
13571
  close: "Chiudi",
13270
13572
  hide_list: "Nascondi elenco",
13573
+ show_list: "Mostra elenco",
13271
13574
  unsaved_local_changes: "Modifiche locali non salvate",
13272
13575
  unsaved_local_changes_description: "Questo documento è stato modificato localmente e ha modifiche non salvate. Queste modifiche locali andranno perse se non le applichi.",
13273
13576
  preview_changes: "Anteprima modifiche",
@@ -14106,7 +14409,7 @@ var hi = {
14106
14409
  group_by: "इसके द्वारा समूहित करें",
14107
14410
  initialize_kanban_order: "कानबन क्रम प्रारंभ करें",
14108
14411
  copy_id: "ID कॉपी करें",
14109
- add_specific: "विशिष्ट {{name}} जोड़ें",
14412
+ add_specific: "{{name}} जोड़ें",
14110
14413
  select_specific: "विशिष्ट {{name}} चुनें",
14111
14414
  select_from: "{{name}} से चुनें",
14112
14415
  done: "हो गया",
@@ -14114,6 +14417,7 @@ var hi = {
14114
14417
  column_cannot_be_edited: "इस कॉलम को सीधे संपादित नहीं किया जा सकता",
14115
14418
  close: "बंद करें",
14116
14419
  hide_list: "सूची छिपाएँ",
14420
+ show_list: "सूची दिखाएँ",
14117
14421
  unsaved_local_changes: "सहेजे नहीं गए स्थानीय परिवर्तन",
14118
14422
  unsaved_local_changes_description: "इस दस्तावेज़ को स्थानीय स्तर पर संपादित किया गया था और इसमें सहेजे नहीं गए परिवर्तन हैं। यदि आप इन्हें लागू नहीं करते हैं तो ये स्थानीय परिवर्तन खो जाएंगे।",
14119
14423
  preview_changes: "परिवर्तनों का पूर्वावलोकन करें",
@@ -14965,6 +15269,7 @@ var pt = {
14965
15269
  column_cannot_be_edited: "Esta coluna não pode ser editada diretamente",
14966
15270
  close: "Fechar",
14967
15271
  hide_list: "Ocultar lista",
15272
+ show_list: "Mostrar lista",
14968
15273
  unsaved_local_changes: "Alterações locais não guardadas",
14969
15274
  unsaved_local_changes_description: "Este documento foi editado localmente e tem alterações não guardadas. Estas alterações locais serão perdidas se não as aplicar.",
14970
15275
  preview_changes: "Pré-visualizar alterações",
@@ -15840,6 +16145,11 @@ function Rebase(props) {
15840
16145
  if (new Set(keys).size !== keys.length) console.error("Duplicate plugin keys detected:", keys.filter((k, i) => keys.indexOf(k) !== i));
15841
16146
  }
15842
16147
  const resolvedSlots = useMemo(() => [...directSlots, ...(plugins ?? []).flatMap((p) => p.slots ?? [])], [directSlots, plugins]);
16148
+ useEffect(() => {
16149
+ const dead = new Set(UNRENDERED_SLOTS);
16150
+ const registered = new Set(resolvedSlots.map((s) => s.slot).filter((slot) => dead.has(slot)));
16151
+ for (const slot of registered) console.warn(`[Rebase] A component is registered for the "${slot}" slot, which this build declares but renders nowhere — nothing will appear. This is a gap in Rebase, not in your plugin.`);
16152
+ }, [resolvedSlots]);
15843
16153
  const clientAuthController = useAuthSubscription(authControllerProp ? void 0 : client?.auth);
15844
16154
  const authController = authControllerProp ?? clientAuthController;
15845
16155
  const normalizedDataSources = useMemo(() => {
@@ -16201,7 +16511,9 @@ function useRebaseAuthController(props = {}) {
16201
16511
  });
16202
16512
  auth.getAuthConfig().then((config) => {
16203
16513
  if (isMountedRef.current) setAuthConfig(config);
16204
- }).catch(() => {});
16514
+ }).catch((e) => {
16515
+ console.warn("[Rebase] Could not load the backend auth configuration; the login view will fall back to defaults.", e);
16516
+ });
16205
16517
  const unsubscribe = auth.onAuthStateChange(syncState);
16206
16518
  return () => {
16207
16519
  isMountedRef.current = false;
@@ -16636,6 +16948,21 @@ function createFormexStub(values) {
16636
16948
  //#endregion
16637
16949
  //#region src/util/entity_cache.ts
16638
16950
  var LOCAL_STORAGE_PREFIX = "entity_cache::";
16951
+ /**
16952
+ * The in-session handoff channel: an edit in flight, parked here by the layout
16953
+ * that is being replaced and picked up by the one taking over — the split's
16954
+ * "hide list", full screen's "show list", the side panel's "open full screen".
16955
+ * A record loaded from it opens *dirty*, because that is what it is for.
16956
+ *
16957
+ * Deliberately **not** hydrated from `sessionStorage`, and it is the one thing
16958
+ * here that isn't. The persisted half of this file is the local-changes backup:
16959
+ * a draft that outlives a reload, offered back through the banner or applied on
16960
+ * open, according to the collection's `localChangesBackup`. Loading those
16961
+ * drafts into this map on startup made every one of them look like a handoff —
16962
+ * the first visit to the record after a reload silently opened dirty carrying a
16963
+ * draft the user had walked away from, and the banner that exists to ask about
16964
+ * it never appeared.
16965
+ */
16639
16966
  var entityCache = /* @__PURE__ */ new Map();
16640
16967
  var isSessionStorageAvailable = typeof sessionStorage !== "undefined";
16641
16968
  function customReplacer(key) {
@@ -16690,25 +17017,12 @@ function customReviver(_key, value) {
16690
17017
  }
16691
17018
  return value;
16692
17019
  }
16693
- if (isSessionStorageAvailable) try {
16694
- for (let i = 0; i < sessionStorage.length; i++) {
16695
- const fullKey = sessionStorage.key(i);
16696
- if (fullKey && fullKey.startsWith(LOCAL_STORAGE_PREFIX)) {
16697
- const path = fullKey.substring(14);
16698
- const entityString = sessionStorage.getItem(fullKey);
16699
- if (entityString) try {
16700
- const entity = JSON.parse(entityString, customReviver);
16701
- entityCache.set(path, entity);
16702
- } catch (parseError) {
16703
- console.error(`Failed to parse entity for path "${path}" from sessionStorage:`, parseError);
16704
- }
16705
- }
16706
- }
16707
- } catch (error) {
16708
- console.error("Error accessing sessionStorage during initialization:", error);
16709
- }
16710
17020
  /**
16711
- * Saves data to the in-memory cache and persists it individually in `sessionStorage`.
17021
+ * Saves data to the local-changes backup in `sessionStorage`.
17022
+ *
17023
+ * The backup only — a draft that survives a reload is not an edit in flight.
17024
+ * {@link saveEntityToMemoryCache} is the other channel; see {@link entityCache}
17025
+ * for what separates them.
16712
17026
  * @param path - The unique path/key for the data.
16713
17027
  * @param data - The data to cache and persist.
16714
17028
  */
@@ -16721,9 +17035,18 @@ function saveEntityToCache(path, data) {
16721
17035
  console.error(`Failed to save entity for path "${path}" to sessionStorage:`, error);
16722
17036
  }
16723
17037
  }
17038
+ /**
17039
+ * Consumes a handoff. The channel is one-shot: whoever picks an edit up owns it
17040
+ * from then on, and an edit left behind here is one that reopens a record dirty
17041
+ * long after the user stopped looking at it.
17042
+ */
16724
17043
  function removeEntityFromMemoryCache(path) {
16725
17044
  entityCache.delete(path);
16726
17045
  }
17046
+ /**
17047
+ * Parks an edit in flight for the layout about to take over. See
17048
+ * {@link entityCache}: this is the handoff, not the backup.
17049
+ */
16727
17050
  function saveEntityToMemoryCache(path, data) {
16728
17051
  entityCache.set(path, data);
16729
17052
  }
@@ -16731,8 +17054,11 @@ function getEntityFromMemoryCache(path) {
16731
17054
  return entityCache.get(path);
16732
17055
  }
16733
17056
  /**
16734
- * Retrieves a entity from the in-memory cache or `sessionStorage`.
16735
- * If the entity is not in the cache but exists in `sessionStorage`, it loads it into the cache.
17057
+ * Retrieves a entity from the local-changes backup in `sessionStorage`.
17058
+ *
17059
+ * The backup only — the handoff channel is read through
17060
+ * {@link getEntityFromMemoryCache}, and the two mean different things to the
17061
+ * form that receives them.
16736
17062
  * @param path - The unique path/key for the entity.
16737
17063
  * @returns The cached entity or `undefined` if not found.
16738
17064
  */
@@ -17359,8 +17685,82 @@ function getAdminEntityChildViews(collection) {
17359
17685
  }));
17360
17686
  }
17361
17687
  //#endregion
17688
+ //#region src/collections/entity-display.ts
17689
+ /**
17690
+ * Collections that have already warned about a deprecated field, so a list of
17691
+ * fifty rows produces one line in the console rather than fifty.
17692
+ */
17693
+ var deprecationWarned = /* @__PURE__ */ new Set();
17694
+ function collectionId(collection) {
17695
+ return collection.slug ?? collection.name ?? "collection";
17696
+ }
17697
+ function warnOnce(id, message) {
17698
+ const key = `${id}:${message}`;
17699
+ if (deprecationWarned.has(key)) return;
17700
+ deprecationWarned.add(key);
17701
+ console.warn(message);
17702
+ }
17703
+ /**
17704
+ * What the collection declares for a role, before deciding which form it is.
17705
+ *
17706
+ * `display.title` wins over the deprecated `titleProperty`: a collection setting
17707
+ * both is mid-migration, and the new field is the one it means.
17708
+ */
17709
+ function getDeclaredSource(collection, role) {
17710
+ const declared = collection.display?.[role];
17711
+ if (declared !== void 0) return declared;
17712
+ if (role === "title" && collection.titleProperty) {
17713
+ const id = collectionId(collection);
17714
+ warnOnce(id, `[rebase] Collection "${id}" uses admin.titleProperty, which is deprecated. Move it to admin.display.title — the same string works there, and display.title also accepts a resolver for a title the record does not carry.`);
17715
+ return collection.titleProperty;
17716
+ }
17717
+ }
17718
+ /**
17719
+ * The property path a role is declared to read, when it is declared as a path.
17720
+ *
17721
+ * Returns `undefined` for a role filled by a resolver — a resolver has no key —
17722
+ * and for a role the collection says nothing about, which is then derived.
17723
+ *
17724
+ * @group Collections
17725
+ */
17726
+ function getDisplayPropertyKey(collection, role) {
17727
+ const declared = getDeclaredSource(collection, role);
17728
+ return typeof declared === "string" ? declared : void 0;
17729
+ }
17730
+ /**
17731
+ * The resolver a role is declared to use, when it is declared as one.
17732
+ *
17733
+ * @group Collections
17734
+ */
17735
+ function getDisplayResolver(collection, role) {
17736
+ const declared = getDeclaredSource(collection, role);
17737
+ return typeof declared === "function" ? declared : void 0;
17738
+ }
17739
+ /**
17740
+ * True when the collection states this role at all, in either form.
17741
+ *
17742
+ * The derivation is a guess about what a collection probably means; a statement
17743
+ * outranks it, and the heuristics that look for "the first enum" or "the leading
17744
+ * relation" have to stand down when one exists.
17745
+ *
17746
+ * @group Collections
17747
+ */
17748
+ function hasDeclaredDisplay(collection, role) {
17749
+ return getDeclaredSource(collection, role) !== void 0;
17750
+ }
17751
+ //#endregion
17362
17752
  //#region src/collections/entity_image_preview.ts
17753
+ /**
17754
+ * The property that fills a record's image slot.
17755
+ *
17756
+ * `admin.display.image` first, then six fallbacks in descending confidence —
17757
+ * the first image-typed storage property, an array of them, a URL rendered as an
17758
+ * image, and so on. The ladder stays for collections that say nothing; a
17759
+ * collection that names its picture is not guessed at.
17760
+ */
17363
17761
  function getEntityImagePreviewPropertyKey(collection) {
17762
+ const declared = getDisplayPropertyKey(collection, "image");
17763
+ if (declared) return declared;
17364
17764
  for (const key in collection.properties) {
17365
17765
  const property = collection.properties[key];
17366
17766
  if (property.type === "string" && property.storage?.acceptedFiles?.includes("image/*")) return key;
@@ -17387,6 +17787,142 @@ function getEntityImagePreviewPropertyKey(collection) {
17387
17787
  }
17388
17788
  }
17389
17789
  //#endregion
17790
+ //#region src/collections/entity-display-cache.ts
17791
+ /** The identity of one role of one record, as a cache key. */
17792
+ function entityDisplayKey(path, entityId, role) {
17793
+ return `${role} ${path} ${entityId ?? ""}`;
17794
+ }
17795
+ var EntityDisplayCache = class {
17796
+ entries = /* @__PURE__ */ new Map();
17797
+ listeners = /* @__PURE__ */ new Set();
17798
+ /**
17799
+ * The resolved value, or `undefined` when this pair has not been resolved
17800
+ * yet. `null` is a resolved absence, and the two must stay distinct: a
17801
+ * caller that reads "not yet" as "nothing" flickers its fallback in on every
17802
+ * mount.
17803
+ */
17804
+ peek(key) {
17805
+ const entry = this.entries.get(key);
17806
+ if (!entry || "promise" in entry) return void 0;
17807
+ return entry.value;
17808
+ }
17809
+ /** True while a resolution for this pair is in flight. */
17810
+ isLoading(key) {
17811
+ const entry = this.entries.get(key);
17812
+ return Boolean(entry && "promise" in entry);
17813
+ }
17814
+ /**
17815
+ * Resolve once per record and role. Concurrent callers share the first
17816
+ * call's promise; later callers get the cached value with no promise at all.
17817
+ *
17818
+ * A resolver that throws is recorded as "nothing" rather than retried: the
17819
+ * alternative is every render re-running a call that just failed. And it is
17820
+ * reported here, which is a correction.
17821
+ *
17822
+ * It used to say "the caller that saw the rejection is the one that logs
17823
+ * it", and `useEntityDisplay` duly attached a `.catch()` that warned. But
17824
+ * both failure paths below swallow and return a *resolved* promise, so that
17825
+ * catch could never run — the two halves each did the reasonable thing and
17826
+ * between them the log was unreachable. A resolver that blew up produced a
17827
+ * blank chip and total silence, which is the failure mode
17828
+ * `EntityDisplayResolver`'s own contract ("treated as `undefined` and logged
17829
+ * once") exists to rule out.
17830
+ *
17831
+ * Reporting belongs here for the reason the caller could not do it: this is
17832
+ * the one place that runs exactly once per key, so "once" is a property of
17833
+ * the code rather than a hope about how many components mount.
17834
+ */
17835
+ resolve(key, resolver) {
17836
+ const entry = this.entries.get(key);
17837
+ if (entry) return "promise" in entry ? entry.promise : Promise.resolve(entry.value);
17838
+ let produced;
17839
+ try {
17840
+ produced = resolver();
17841
+ } catch (error) {
17842
+ this.fail(key, error);
17843
+ return Promise.resolve(null);
17844
+ }
17845
+ if (!isPromise(produced)) {
17846
+ const value = normalize(produced);
17847
+ this.set(key, value);
17848
+ return Promise.resolve(value);
17849
+ }
17850
+ const promise = produced.then((resolved) => {
17851
+ const value = normalize(resolved);
17852
+ this.set(key, value);
17853
+ return value;
17854
+ }).catch((error) => {
17855
+ this.fail(key, error);
17856
+ return null;
17857
+ });
17858
+ this.entries.set(key, { promise });
17859
+ return promise;
17860
+ }
17861
+ /**
17862
+ * Drop what is known about a record, so the next ask resolves again. Called
17863
+ * after a write: the row that just saved may be called something else now.
17864
+ */
17865
+ invalidate(path, entityId) {
17866
+ const suffix = ` ${path} ${entityId ?? ""}`;
17867
+ let changed = false;
17868
+ for (const key of [...this.entries.keys()]) if (entityId === void 0 ? key.includes(` ${path} `) || key.endsWith(` ${path} `) : key.endsWith(suffix)) {
17869
+ this.entries.delete(key);
17870
+ changed = true;
17871
+ }
17872
+ if (changed) this.emit();
17873
+ }
17874
+ /** Drop everything. The user signed out, or the app swapped datasource. */
17875
+ clear() {
17876
+ if (this.entries.size === 0) return;
17877
+ this.entries.clear();
17878
+ this.emit();
17879
+ }
17880
+ subscribe(listener) {
17881
+ this.listeners.add(listener);
17882
+ return () => {
17883
+ this.listeners.delete(listener);
17884
+ };
17885
+ }
17886
+ set(key, value) {
17887
+ this.entries.set(key, { value });
17888
+ this.emit();
17889
+ }
17890
+ /**
17891
+ * Record a failed resolution as "nothing", and say so once.
17892
+ *
17893
+ * The key is the message: it is `<role> <path> <id>`, which is exactly what a
17894
+ * reader needs to find the resolver that blew up. A warning with no key would
17895
+ * tell them a display resolver failed somewhere in a list of fifty rows.
17896
+ *
17897
+ * `console.warn` rather than a thrown error, because this runs while a row is
17898
+ * rendering: the contract is that a title which cannot be fetched must not
17899
+ * take down the row that shows it.
17900
+ */
17901
+ fail(key, error) {
17902
+ console.warn(`[rebase] Could not resolve display value for ${key}:`, error);
17903
+ this.set(key, null);
17904
+ }
17905
+ emit() {
17906
+ for (const listener of [...this.listeners]) listener();
17907
+ }
17908
+ };
17909
+ /**
17910
+ * Empty strings and empty arrays are absences, not values — a title of `" "`
17911
+ * would otherwise beat the derived one and render as a blank heading.
17912
+ */
17913
+ function normalize(value) {
17914
+ if (value === void 0 || value === null) return null;
17915
+ if (typeof value === "string") {
17916
+ const trimmed = value.trim();
17917
+ return trimmed.length > 0 ? trimmed : null;
17918
+ }
17919
+ if (Array.isArray(value)) return value.length > 0 ? value : null;
17920
+ return value;
17921
+ }
17922
+ function isPromise(value) {
17923
+ return typeof value?.then === "function";
17924
+ }
17925
+ //#endregion
17390
17926
  //#region src/collections/filter-operator-resolution.ts
17391
17927
  /**
17392
17928
  * Default operators offered per property type, before engine capabilities and
@@ -17497,115 +18033,6 @@ function resolveFilterOperators({ property, isArray, engine }) {
17497
18033
  return typeDefaults.filter((op) => engineOps.has(op) && (narrowingSet === void 0 || narrowingSet.has(op)));
17498
18034
  }
17499
18035
  //#endregion
17500
- //#region src/collections/property_presentation.ts
17501
- function isReadOnly(property) {
17502
- if (property.admin?.readOnly) return true;
17503
- if (property.type === "date") {
17504
- if (property.autoValue) return true;
17505
- }
17506
- if (property.type === "reference") return !property.path && !("Field" in (property.admin || {}) && property.admin?.Field);
17507
- return false;
17508
- }
17509
- function isHidden(property) {
17510
- return typeof property.admin?.disabled === "object" && Boolean(property.admin?.disabled.hidden);
17511
- }
17512
- function applyPropertyConditions(property, context) {
17513
- const { conditions } = property;
17514
- if (!conditions) return property;
17515
- const result = { ...property };
17516
- if (conditions.disabled) {
17517
- if (evaluateCondition(conditions.disabled, context)) {
17518
- result.admin = result.admin || {};
17519
- result.admin.disabled = {
17520
- clearOnDisabled: conditions.clearOnDisabled ?? false,
17521
- disabledMessage: conditions.disabledMessage,
17522
- hidden: false
17523
- };
17524
- }
17525
- }
17526
- if (conditions.hidden) {
17527
- if (evaluateCondition(conditions.hidden, context)) {
17528
- result.admin = result.admin || {};
17529
- result.admin.disabled = {
17530
- ...typeof result.admin?.disabled === "object" ? result.admin.disabled : {},
17531
- hidden: true,
17532
- clearOnDisabled: conditions.clearOnDisabled ?? false
17533
- };
17534
- }
17535
- }
17536
- if (conditions.readOnly) {
17537
- if (evaluateCondition(conditions.readOnly, context)) {
17538
- result.admin = result.admin || {};
17539
- result.admin.readOnly = true;
17540
- }
17541
- }
17542
- if (conditions.required !== void 0) {
17543
- const isRequired = evaluateCondition(conditions.required, context);
17544
- result.validation = {
17545
- ...result.validation,
17546
- required: isRequired,
17547
- requiredMessage: conditions.requiredMessage
17548
- };
17549
- }
17550
- if (context.isNew && conditions.defaultValue !== void 0) result.defaultValue = evaluateCondition(conditions.defaultValue, context);
17551
- if ("enum" in result && result.enum && (conditions.enumConditions || conditions.allowedEnumValues || conditions.excludedEnumValues)) result.enum = applyEnumConditions(result.enum, conditions, context);
17552
- if (result.type === "reference") {
17553
- if (conditions.referencePath) result.path = evaluateCondition(conditions.referencePath, context);
17554
- if (conditions.referenceFilter) {
17555
- result.admin = result.admin || {};
17556
- result.admin.fixedFilter = evaluateCondition(conditions.referenceFilter, context);
17557
- }
17558
- }
17559
- if (result.type === "array") {
17560
- if (conditions.canAddElements !== void 0) {
17561
- result.admin = result.admin || {};
17562
- result.admin.canAddElements = evaluateCondition(conditions.canAddElements, context);
17563
- }
17564
- if (conditions.sortable !== void 0) {
17565
- result.admin = result.admin || {};
17566
- result.admin.sortable = evaluateCondition(conditions.sortable, context);
17567
- }
17568
- }
17569
- return result;
17570
- }
17571
- /**
17572
- * Convert an object with numeric keys back to an array.
17573
- * Firestore stores arrays as {"0": "a", "1": "b"} to avoid nested arrays.
17574
- */
17575
- function objectToArray(obj) {
17576
- if (Array.isArray(obj)) return obj.map(String);
17577
- if (obj && typeof obj === "object") {
17578
- const keys = Object.keys(obj);
17579
- if (keys.length > 0 && keys.every((k) => !isNaN(Number(k)))) return keys.sort((a, b) => Number(a) - Number(b)).map((k) => obj[k]).filter((v) => typeof v === "string" || typeof v === "number").map(String);
17580
- }
17581
- return [];
17582
- }
17583
- /**
17584
- * Apply enum-specific conditions to filter and modify enum values.
17585
- */
17586
- function applyEnumConditions(enumValues, conditions, context) {
17587
- let result = [...enumValues];
17588
- if (conditions.allowedEnumValues) {
17589
- const allowedArray = objectToArray(evaluateCondition(conditions.allowedEnumValues, context));
17590
- if (allowedArray.length > 0) result = result.filter((ev) => allowedArray.includes(String(ev.id)));
17591
- }
17592
- if (conditions.excludedEnumValues) {
17593
- const excludedArray = objectToArray(evaluateCondition(conditions.excludedEnumValues, context));
17594
- if (excludedArray.length > 0) result = result.filter((ev) => !excludedArray.includes(String(ev.id)));
17595
- }
17596
- if (conditions.enumConditions) result = result.map((ev) => {
17597
- const evConditions = conditions.enumConditions?.[ev.id];
17598
- if (!evConditions) return ev;
17599
- if (evConditions.hidden && evaluateCondition(evConditions.hidden, context)) return null;
17600
- if (evConditions.disabled && evaluateCondition(evConditions.disabled, context)) return {
17601
- ...ev,
17602
- disabled: true
17603
- };
17604
- return ev;
17605
- }).filter((ev) => ev !== null);
17606
- return result;
17607
- }
17608
- //#endregion
17609
18036
  //#region src/collections/form-layout.ts
17610
18037
  /**
17611
18038
  * Columns in the form grid.
@@ -17796,7 +18223,8 @@ function resolveFormLayout({ collection, fieldKeys, status }) {
17796
18223
  title: section.title,
17797
18224
  collapsible: section.collapsible ?? titled,
17798
18225
  collapsed: titled ? Boolean(section.collapsed) : false,
17799
- fields
18226
+ fields,
18227
+ readVariant: section.readVariant
17800
18228
  });
17801
18229
  }
17802
18230
  const leftovers = fieldKeys.map((key) => available.get(key)).filter((f) => Boolean(f));
@@ -18079,18 +18507,6 @@ function isHidden$1(property) {
18079
18507
  return Boolean(property.admin?.hideFromCollection);
18080
18508
  }
18081
18509
  /**
18082
- * File-storage backed content (single image, array of images, generic upload…).
18083
- * Rendered by the dedicated image slot, so never a title.
18084
- */
18085
- function isStorageProperty(property) {
18086
- if (property.type === "string" && (property.storage || property.admin?.urlPreview === "image")) return true;
18087
- if (property.type === "array" && property.of && !Array.isArray(property.of)) {
18088
- const inner = property.of;
18089
- if (inner.type === "string" && (inner.storage || inner.admin?.urlPreview === "image")) return true;
18090
- }
18091
- return false;
18092
- }
18093
- /**
18094
18510
  * Every column on this collection that stores a foreign key: the `localKey` of
18095
18511
  * each owning relation (declared inline on a property or in `relations[]`), the
18096
18512
  * source column of a junction, and the key a many-to-many joins on.
@@ -18170,7 +18586,8 @@ function scoreTitleCandidate(property, key, idKeys, foreignKeys) {
18170
18586
  */
18171
18587
  function getTitlePropertyCandidates(collection) {
18172
18588
  if (!collection.properties) return [];
18173
- if (collection.titleProperty && collection.properties[collection.titleProperty]) return [collection.titleProperty];
18589
+ const declared = getDisplayPropertyKey(collection, "title");
18590
+ if (declared && getPropertyInPath(collection.properties, declared)) return [declared];
18174
18591
  const idKeys = new Set(getPrimaryKeys(collection));
18175
18592
  const foreignKeys = getForeignKeyColumns(collection);
18176
18593
  const explicitOrder = collection.propertiesOrder;
@@ -18213,7 +18630,7 @@ function getTitlePropertyCandidates(collection) {
18213
18630
  */
18214
18631
  function getLeadingRelationTitleKey(collection) {
18215
18632
  if (!collection.properties) return void 0;
18216
- if (collection.titleProperty) return void 0;
18633
+ if (hasDeclaredDisplay(collection, "title")) return void 0;
18217
18634
  const idKeys = new Set(getPrimaryKeys(collection));
18218
18635
  const foreignKeys = getForeignKeyColumns(collection);
18219
18636
  const order = collection.propertiesOrder ?? Object.keys(collection.properties);
@@ -18274,6 +18691,6 @@ function getTitlePropertyKeyForValues(collection, values, entityId) {
18274
18691
  return candidates[0];
18275
18692
  }
18276
18693
  //#endregion
18277
- export { AIIcon, AIModifiedIndicator, AdminModeControllerContext, AdminModeControllerProvider, AnalyticsContext, ApiConfigProvider, AuthControllerContext, CONTAINER_FULL_WIDTH, CollectionComponentOverrideProvider, CollectionResolverRegistrationContext, CollectionScopeContext, CollectionScopeProvider, ComponentOverrideContext, ConfirmationDialog, CrmDashboardDemo, CustomizationControllerContext, DEFAULT_API_PATH, DEFAULT_PAGE_SIZE, DataDriverContext, DataSourcesContext, DialogsControllerContext, DialogsProvider, EffectiveRoleControllerContext, EffectiveRoleControllerProvider, ErrorTooltip, ErrorView, FORM_CONTAINER_WIDTH, GlobalComponentOverrideProvider, IconForView, LanguageToggle, LoginView, ModeControllerContext, ModeControllerProvider, NavigationBlockerProvider, NotFoundPage, PluginProviderStack, REBASE_LOCALE_STORAGE_KEY, Rebase, RebaseAuth, RebaseClientInstanceContext, RebaseDataContext, RebaseI18nProvider, RebaseLogo, RebaseRegistryProvider, RebaseRouter, RebaseRoutes, SIDE_PANEL_DEFAULT_WIDTH, STUDIO_NAVIGATION_GROUPS, SchemaDriftBanner, SchemaDriftProvider, SnackbarProvider, StorageSourceContext, StorageSourcesContext, StudioBridgeContext, StudioBridgeProvider, StudioBridgeRegistryContext, StudioBridgeRegistryProvider, UIReferenceView, UIStyleGuide, UnsavedChangesDialog, UserConfigurationPersistenceContext, UserDisplay, UserSelectPopover, UserSettingsView, addInitialSlash, apiBaseOf, applyPropertyConditions, buildCollapsedDefaults, buildEnumLabel, clearAuthConfigCache, clearFetchCache, createAuthConfigCache, createFormexStub, deleteEntityWithCallbacks, deriveSpan, en, es, fetchAuthConfig, fillRows, flattenKeys, getAdminEntityChildViews, getAdminSubcollections, getCollectionBySlugWithin, getCollectionPathsCombinations, getColorScheme, getColumnKeysForProperty, getEntityFromCache, getEntityFromMemoryCache, getEntityImagePreviewPropertyKey, getEntityPreviewKeys, getEntityTitlePropertyKey, getFormFieldKeys, getIcon, getLastSegment, getLeadingRelationTitleKey, getLocalChangesBackup, getNavigationEntriesFromPath, getParentReferencesFromPath, getRelationIncludeParams, getRowHeight, getSubcollectionColumnId, getTitlePropertyCandidates, getTitlePropertyKey, getTitlePropertyKeyForValues, iconsSearch, isAuditTimestamp, isEnumValueDisabled, isFilterableRelation, isHidden, isIdPropertyEditable, isReadOnly, isSchemaDriftError, looksLikeIdentifierValue, populateFetchCache, removeEntityFromCache, removeEntityFromMemoryCache, removeInitialAndTrailingSlashes, removeInitialSlash, removeTrailingSlash, resolveCollectionPathIds, resolveComponentRef, resolveDefaultSelectedView, resolveFilterOperators, resolveFormLayout, saveEntityToCache, saveEntityToMemoryCache, saveEntityWithCallbacks, useAdminModeController, useAnalyticsController, useApiBase, useApiConfig, useAuthController, useAuthSubscription, useBackendStorageSource, useBridgeRegistration, useBrowserTitleAndIcon, useBuildAdminModeController, useBuildEffectiveRoleController, useBuildLocalConfigurationPersistence, useBuildModeController, useClipboard, useCollapsedGroups, useCollection, useCollectionScope, useColumnIds, useComponentOverride, useCustomizationController, useData, useDataSources, useDataTableController, useDebouncedData, useDialogsController, useEffectiveRoleController, useFetch, useLargeLayout, useModeController, useNavigationBlocker, usePermissions, useRebaseAuthController, useRebaseClient, useRebaseContext, useRebaseRegistry, useRebaseRegistryDispatch, useRelationSelector, useResolvedComponent, useRestoreScroll, useSchemaDriftContext, useScrollRestoration, useSlot, useSnackbarController, useStorageSource, useStorageSources, useStorageUploadController, useStudioBreadcrumbs, useStudioCapabilities, useStudioCollectionRegistry, useStudioNavigationState, useStudioSidePanelController, useStudioUrlController, useTranslation, useUnsavedChangesDialog, useUserConfigurationPersistence };
18694
+ export { AIIcon, AIModifiedIndicator, AdminModeControllerContext, AdminModeControllerProvider, AnalyticsContext, ApiConfigProvider, AuthControllerContext, CONTAINER_FULL_WIDTH, CollectionComponentOverrideProvider, CollectionResolverRegistrationContext, CollectionScopeContext, CollectionScopeProvider, ComponentOverrideContext, ConfirmationDialog, CrmDashboardDemo, CustomizationControllerContext, DEFAULT_API_PATH, DEFAULT_PAGE_SIZE, DataDriverContext, DataSourcesContext, DialogsControllerContext, DialogsProvider, EffectiveRoleControllerContext, EffectiveRoleControllerProvider, EntityDisplayCache, ErrorTooltip, ErrorView, FORM_CONTAINER_WIDTH, GlobalComponentOverrideProvider, IconForView, LanguageToggle, LoginView, ModeControllerContext, ModeControllerProvider, NavigationBlockerProvider, NotFoundPage, PluginProviderStack, REBASE_LOCALE_STORAGE_KEY, Rebase, RebaseAuth, RebaseClientInstanceContext, RebaseDataContext, RebaseI18nProvider, RebaseLogo, RebaseRegistryProvider, RebaseRouter, RebaseRoutes, SIDE_PANEL_DEFAULT_WIDTH, STUDIO_NAVIGATION_GROUPS, SUMMARY_RANK, SchemaDriftBanner, SchemaDriftProvider, SnackbarProvider, StorageSourceContext, StorageSourcesContext, StudioBridgeContext, StudioBridgeProvider, StudioBridgeRegistryContext, StudioBridgeRegistryProvider, UIReferenceView, UIStyleGuide, UnsavedChangesDialog, UserConfigurationPersistenceContext, UserDisplay, UserSelectPopover, UserSettingsView, addInitialSlash, apiBaseOf, applyPropertyConditions, buildCollapsedDefaults, buildEnumLabel, canSummariseProperty, clearAuthConfigCache, clearFetchCache, createAuthConfigCache, createFormexStub, deleteEntityWithCallbacks, deriveSpan, en, entityDisplayKey, es, fetchAuthConfig, fillRows, flattenKeys, getAdminEntityChildViews, getAdminSubcollections, getCollectionBySlugWithin, getCollectionPathsCombinations, getColorScheme, getColumnKeysForProperty, getDisplayPropertyKey, getDisplayResolver, getEntityFromCache, getEntityFromMemoryCache, getEntityImagePreviewPropertyKey, getEntityPreviewKeys, getEntityTitlePropertyKey, getFormFieldKeys, getIcon, getLastSegment, getLeadingRelationTitleKey, getLocalChangesBackup, getNavigationEntriesFromPath, getParentReferencesFromPath, getPropertyInPath, getRedundantChildViewColumnIds, getRelationIncludeParams, getRowHeight, getSubcollectionColumnId, getTitlePropertyCandidates, getTitlePropertyKey, getTitlePropertyKeyForValues, hasDeclaredDisplay, iconsSearch, isAuditTimestamp, isDisabled, isEnumValueDisabled, isFilterableRelation, isHidden, isIdPropertyEditable, isLongTextProperty, isReadOnly, isSchemaDriftError, isStorageProperty, looksLikeIdentifierValue, populateFetchCache, rankSummaryProperty, removeEntityFromCache, removeEntityFromMemoryCache, removeInitialAndTrailingSlashes, removeInitialSlash, removeTrailingSlash, resolveCollectionPathIds, resolveComponentRef, resolveDefaultSelectedView, resolveFilterOperators, resolveFormLayout, saveEntityToCache, saveEntityToMemoryCache, saveEntityWithCallbacks, useAdminModeController, useAnalyticsController, useApiBase, useApiConfig, useAuthController, useAuthSubscription, useBackendStorageSource, useBridgeRegistration, useBrowserTitleAndIcon, useBuildAdminModeController, useBuildEffectiveRoleController, useBuildLocalConfigurationPersistence, useBuildModeController, useClipboard, useCollapsedGroups, useCollection, useCollectionScope, useColumnIds, useComponentOverride, useCustomizationController, useData, useDataSources, useDataTableController, useDebouncedData, useDialogsController, useEffectiveRoleController, useFetch, useLargeLayout, useModeController, useNavigationBlocker, usePermissions, useRebaseAuthController, useRebaseClient, useRebaseContext, useRebaseRegistry, useRebaseRegistryDispatch, useRelationSelector, useResolvedComponent, useRestoreScroll, useSchemaDriftContext, useScrollRestoration, useSlot, useSnackbarController, useStorageSource, useStorageSources, useStorageUploadController, useStudioBreadcrumbs, useStudioCapabilities, useStudioCollectionRegistry, useStudioNavigationState, useStudioSidePanelController, useStudioUrlController, useTranslation, useUnsavedChangesDialog, useUserConfigurationPersistence };
18278
18695
 
18279
18696
  //# sourceMappingURL=index.es.js.map