@rebasepro/app 0.10.0 → 0.10.1-canary.0a881d4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/types.d.ts +2 -1
- package/dist/collections/collection_view_config.d.ts +32 -0
- package/dist/collections/entity_image_preview.d.ts +2 -0
- package/dist/collections/filter-operator-resolution.d.ts +32 -0
- package/dist/collections/index.d.ts +8 -0
- package/dist/collections/navigation_from_path.d.ts +34 -0
- package/dist/collections/navigation_utils.d.ts +20 -0
- package/dist/collections/parent_references_from_path.d.ts +7 -0
- package/dist/collections/property_presentation.d.ts +20 -0
- package/dist/collections/title-property.d.ts +43 -0
- package/dist/components/Debug/UIReferenceView.d.ts +10 -3
- package/dist/components/LoginView/LoginView.d.ts +1 -1
- package/dist/components/RebaseAuth.d.ts +1 -1
- package/dist/components/common/types.d.ts +1 -1
- package/dist/components/common/useColumnsIds.d.ts +5 -4
- package/dist/components/common/useDataTableController.d.ts +3 -3
- package/dist/contexts/AnalyticsContext.d.ts +1 -1
- package/dist/contexts/AuthControllerContext.d.ts +1 -1
- package/dist/contexts/CollectionScopeContext.d.ts +4 -4
- package/dist/contexts/ComponentOverrideContext.d.ts +1 -1
- package/dist/contexts/CustomizationControllerContext.d.ts +1 -1
- package/dist/contexts/DialogsProvider.d.ts +1 -1
- package/dist/contexts/UserConfigurationPersistenceContext.d.ts +1 -1
- package/dist/core/PluginLifecycleManager.d.ts +1 -1
- package/dist/core/PluginProviderStack.d.ts +1 -1
- package/dist/core/RebaseProps.d.ts +2 -1
- package/dist/hooks/data/delete.d.ts +4 -4
- package/dist/hooks/data/save.d.ts +5 -5
- package/dist/hooks/data/useCollection.d.ts +2 -2
- package/dist/hooks/data/useFetch.d.ts +2 -2
- package/dist/hooks/data/useRelationSelector.d.ts +2 -2
- package/dist/hooks/useAnalyticsController.d.ts +1 -1
- package/dist/hooks/useAuthController.d.ts +2 -1
- package/dist/hooks/useAuthSubscription.d.ts +2 -1
- package/dist/hooks/useBuildLocalConfigurationPersistence.d.ts +1 -1
- package/dist/hooks/useComponentOverride.d.ts +1 -1
- package/dist/hooks/useCustomizationController.d.ts +1 -1
- package/dist/hooks/useDialogsController.d.ts +1 -1
- package/dist/hooks/usePermissions.d.ts +5 -5
- package/dist/hooks/useRebaseContext.d.ts +2 -1
- package/dist/hooks/useRebaseRegistry.d.ts +1 -1
- package/dist/hooks/useSlot.d.ts +1 -1
- package/dist/hooks/useSnackbarController.d.ts +1 -1
- package/dist/hooks/useStudioBridge.d.ts +2 -1
- package/dist/hooks/useUserConfigurationPersistence.d.ts +1 -1
- package/dist/i18n/RebaseI18nProvider.d.ts +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +799 -121
- package/dist/index.es.js.map +1 -1
- package/dist/locales/de.d.ts +1 -1
- package/dist/locales/en.d.ts +1 -1
- package/dist/locales/es.d.ts +1 -1
- package/dist/locales/fr.d.ts +1 -1
- package/dist/locales/hi.d.ts +1 -1
- package/dist/locales/it.d.ts +1 -1
- package/dist/locales/pt.d.ts +1 -1
- package/dist/util/previews.d.ts +10 -5
- package/dist/vitePlugin.js +1 -1
- package/package.json +9 -7
- package/src/auth/types.ts +2 -1
- package/src/collections/collection_view_config.ts +57 -0
- package/src/collections/entity_image_preview.ts +48 -0
- package/src/collections/filter-operator-resolution.ts +81 -0
- package/src/collections/index.ts +8 -0
- package/src/collections/navigation_from_path.ts +123 -0
- package/src/collections/navigation_utils.ts +171 -0
- package/src/collections/parent_references_from_path.ts +59 -0
- package/src/collections/property_presentation.ts +224 -0
- package/src/collections/title-property.ts +264 -0
- package/src/components/Debug/UIReferenceView.tsx +31 -27
- package/src/components/Debug/collection-views/CardViewDemo.tsx +4 -2
- package/src/components/Debug/collection-views/CollectionTableDemo.tsx +2 -2
- package/src/components/Debug/collection-views/KanbanBoardDemo.tsx +1 -2
- package/src/components/Debug/crm-dashboard/CalendarWidget.tsx +5 -7
- package/src/components/Debug/crm-dashboard/CrmDashboardDemo.tsx +14 -20
- package/src/components/Debug/crm-dashboard/DashboardMetrics.tsx +7 -9
- package/src/components/Debug/crm-dashboard/PipelineOverview.tsx +8 -10
- package/src/components/Debug/crm-dashboard/RecentActivity.tsx +25 -27
- package/src/components/Debug/crm-dashboard/TaskFilters.tsx +7 -9
- package/src/components/Debug/crm-dashboard/TaskTable.tsx +8 -10
- package/src/components/LoginView/LoginView.tsx +55 -4
- package/src/components/RebaseAuth.tsx +1 -1
- package/src/components/common/types.tsx +1 -1
- package/src/components/common/useColumnsIds.tsx +24 -23
- package/src/components/common/useDataTableController.tsx +4 -4
- package/src/contexts/AnalyticsContext.tsx +1 -1
- package/src/contexts/AuthControllerContext.tsx +1 -1
- package/src/contexts/CollectionScopeContext.tsx +6 -5
- package/src/contexts/ComponentOverrideContext.tsx +1 -1
- package/src/contexts/CustomizationControllerContext.tsx +1 -1
- package/src/contexts/DialogsProvider.tsx +1 -1
- package/src/contexts/UserConfigurationPersistenceContext.tsx +1 -1
- package/src/core/PluginLifecycleManager.tsx +2 -1
- package/src/core/PluginProviderStack.tsx +1 -1
- package/src/core/Rebase.tsx +4 -3
- package/src/core/RebaseProps.tsx +2 -1
- package/src/core/RebaseRouter.tsx +1 -1
- package/src/hooks/data/delete.ts +5 -4
- package/src/hooks/data/save.ts +6 -5
- package/src/hooks/data/useCollection.tsx +3 -2
- package/src/hooks/data/useFetch.tsx +4 -3
- package/src/hooks/data/useRelationSelector.tsx +3 -2
- package/src/hooks/useAnalyticsController.tsx +1 -1
- package/src/hooks/useAuthController.tsx +2 -1
- package/src/hooks/useAuthSubscription.ts +2 -1
- package/src/hooks/useBuildLocalConfigurationPersistence.tsx +1 -1
- package/src/hooks/useComponentOverride.tsx +1 -1
- package/src/hooks/useCustomizationController.tsx +1 -1
- package/src/hooks/useDialogsController.tsx +1 -1
- package/src/hooks/usePermissions.ts +6 -5
- package/src/hooks/useRebaseContext.tsx +2 -1
- package/src/hooks/useRebaseRegistry.tsx +1 -1
- package/src/hooks/useResolvedComponent.tsx +44 -11
- package/src/hooks/useSlot.tsx +1 -1
- package/src/hooks/useSnackbarController.tsx +1 -1
- package/src/hooks/useStudioBridge.tsx +4 -2
- package/src/hooks/useUserConfigurationPersistence.tsx +1 -1
- package/src/i18n/RebaseI18nProvider.tsx +1 -1
- package/src/index.ts +1 -0
- package/src/locales/de.ts +1 -1
- package/src/locales/en.ts +1 -1
- package/src/locales/es.ts +1 -1
- package/src/locales/fr.ts +1 -1
- package/src/locales/hi.ts +1 -1
- package/src/locales/it.ts +1 -1
- package/src/locales/pt.ts +1 -1
- package/src/util/previews.ts +16 -34
- package/src/vitePlugin.ts +5 -1
package/dist/index.es.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import React, { createContext, lazy, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
2
|
-
import { Alert, AlertCircleIcon, AlertTriangleIcon, AppWindow, ArrowLeftIcon, Avatar, BooleanSwitch, Button, CHIP_COLORS, Card, CenteredView, CheckIcon, Checkbox, ChevronDownIcon, ChevronsLeftIcon, ChevronsRightIcon, Chip, CircleUserIcon, CircularProgress, ColumnsIcon, Container, Dialog, DialogActions, DialogContent, DialogTitle, ErrorBoundary, FileIcon, FileTextIcon, FilterChip, FilterIcon, FolderIcon, IconButton, KanbanIcon, KanbanView, LanguagesIcon, LayoutGridIcon, ListIcon, LoadingButton, LogOutIcon, MailIcon, Menu, MenuItem, MoonIcon, MultiSelect, MultiSelectItem, PanelLeftIcon, Paper, PencilIcon, PlusIcon, Popover, SearchBar, Select, SelectItem, Separator, SettingsIcon, Skeleton, SunIcon, SunMoonIcon, Tab, Table, TableBody, TableCell, TableHeader, TableRow, Tabs, TagIcon, TextField, ToggleButtonGroup, Tooltip, Trash2Icon, TypeIcon, Typography, UserIcon, Wand2Icon, cls, colorClassesMapping, coolIconKeys, defaultBorderMixin, getColorSchemeForSeed, iconKeys, iconSize, lucideIcons } from "@rebasepro/ui";
|
|
3
|
-
import { DEFAULT_DATA_SOURCE_KEY, DEFAULT_STORAGE_SOURCE_KEY, EntityReference, EntityRelation, GeoPoint, RebaseApiError, Vector, isLazyComponentRef } from "@rebasepro/types";
|
|
2
|
+
import { Alert, AlertCircleIcon, AlertTriangleIcon, AppWindow, ArrowDownIcon, ArrowLeftIcon, ArrowRightLeftIcon, ArrowUpDownIcon, ArrowUpIcon, Avatar, BooleanSwitch, Button, CHIP_COLORS, 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, getColorSchemeForSeed, iconKeys, iconSize, lucideIcons } from "@rebasepro/ui";
|
|
3
|
+
import { ALL_WHERE_FILTER_OPS, DEFAULT_DATA_SOURCE_KEY, DEFAULT_STORAGE_SOURCE_KEY, EntityReference, EntityRelation, GeoPoint, RebaseApiError, Vector, getDataSourceCapabilities, isLazyComponentRef } from "@rebasepro/types";
|
|
4
4
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import { SnackbarProvider as SnackbarProvider$1, useSnackbar } from "notistack";
|
|
6
|
-
import { buildRebaseData, canCreateEntity, canDeleteEntity, canEditEntity, canReadCollection, getLabelOrConfigFrom, getSubcollections, isPropertyBuilder,
|
|
6
|
+
import { buildRebaseData, canCreateEntity, canDeleteEntity, canEditEntity, canReadCollection, evaluateCondition, getLabelOrConfigFrom, getPrimaryKeys, getSubcollections, isPropertyBuilder, resolveStorageFilenameString, resolveStoragePathString, resolveStorageSource, stripCollectionPath, wrapAsEntityData, wrapAsSdkData } from "@rebasepro/common";
|
|
7
|
+
import { getTitlePropertyKey as getTitlePropertyKey$1, removeInitialAndTrailingSlashes as removeInitialAndTrailingSlashes$1 } from "@rebasepro/app";
|
|
7
8
|
import { Link, RouterProvider, Routes, createBrowserRouter, useBlocker, useLocation } from "react-router-dom";
|
|
8
|
-
import { hashString, isObject, isPlainObject, mergeDeep, randomString, slugify } from "@rebasepro/utils";
|
|
9
|
+
import { generateForeignKeyName, hashString, isObject, isPlainObject, mergeDeep, randomString, slugify } from "@rebasepro/utils";
|
|
9
10
|
import { I18nextProvider, initReactI18next, useTranslation as useTranslation$1 } from "react-i18next";
|
|
10
11
|
import { deepEqual } from "fast-equals";
|
|
11
|
-
import { AlertTriangle, ArrowDownIcon, ArrowRightLeft, ArrowUpDownIcon, ArrowUpIcon, Calendar, Check, CheckCircle2, ChevronLeft, ChevronRight, CircleDot, DollarSign, FileText, FolderKanbanIcon, LayoutGridIcon as LayoutGridIcon$1, ListIcon as ListIcon$1, ListPlus, ListTodo, Mail, MessageCircle, PenLine, PencilIcon as PencilIcon$1, Phone, Pin, RefreshCw, Settings, StickyNote, Trash2Icon as Trash2Icon$1, TrendingUp, UserPlus, Users, Video, Wrench, X } from "lucide-react";
|
|
12
12
|
import i18next from "i18next";
|
|
13
13
|
import Fuse from "fuse.js";
|
|
14
14
|
import Compressor from "compressorjs";
|
|
15
|
+
import { resolveAdminCollection } from "@rebasepro/admin-types";
|
|
15
16
|
//#region src/core/PluginProviderStack.tsx
|
|
16
17
|
/**
|
|
17
18
|
* Wraps children with all provider components from plugins that match the given scope.
|
|
@@ -426,20 +427,20 @@ function isRelationProperty(property) {
|
|
|
426
427
|
}
|
|
427
428
|
function isHiddenProperty(property) {
|
|
428
429
|
if (!property) return false;
|
|
429
|
-
return Boolean(property.
|
|
430
|
+
return Boolean(property.admin?.hideFromCollection);
|
|
430
431
|
}
|
|
431
432
|
/**
|
|
432
433
|
* Returns true when the property holds file-storage content (single image,
|
|
433
434
|
* array of images, generic upload, …). These properties are rendered by the
|
|
434
435
|
* dedicated image-slot and should NOT appear as regular preview columns.
|
|
435
436
|
*/
|
|
436
|
-
function isStorageProperty(property) {
|
|
437
|
+
function isStorageProperty$1(property) {
|
|
437
438
|
if (!property) return false;
|
|
438
439
|
if (property.type === "string" && property.storage) return true;
|
|
439
|
-
if (property.type === "string" && property.
|
|
440
|
+
if (property.type === "string" && property.admin?.urlPreview === "image") return true;
|
|
440
441
|
if (property.type === "array" && property.of && !Array.isArray(property.of)) {
|
|
441
442
|
const inner = property.of;
|
|
442
|
-
if (inner.type === "string" && (inner.storage || inner.
|
|
443
|
+
if (inner.type === "string" && (inner.storage || inner.admin?.urlPreview === "image")) return true;
|
|
443
444
|
}
|
|
444
445
|
return false;
|
|
445
446
|
}
|
|
@@ -455,7 +456,7 @@ function getEntityPreviewKeys(authController, targetCollection, fields, previewP
|
|
|
455
456
|
return !(prop && typeof prop === "object" && "isId" in prop && Boolean(prop.isId)) && key !== "id";
|
|
456
457
|
}).filter((key) => {
|
|
457
458
|
const property = targetCollection.properties[key];
|
|
458
|
-
return property && !isPropertyBuilder(property) && !isReferenceProperty(property) && !isRelationProperty(property) && !isHiddenProperty(property) && !isStorageProperty(property);
|
|
459
|
+
return property && !isPropertyBuilder(property) && !isReferenceProperty(property) && !isRelationProperty(property) && !isHiddenProperty(property) && !isStorageProperty$1(property);
|
|
459
460
|
}).slice(0, limit);
|
|
460
461
|
}
|
|
461
462
|
}
|
|
@@ -472,29 +473,13 @@ function getRelationIncludeParams(collection) {
|
|
|
472
473
|
if (!collection.properties) return void 0;
|
|
473
474
|
return Object.values(collection.properties).some((property) => property && !isPropertyBuilder(property) && (isRelationProperty(property) || isReferenceProperty(property))) ? INCLUDE_ALL_RELATIONS : void 0;
|
|
474
475
|
}
|
|
476
|
+
/**
|
|
477
|
+
* The property that fills the title slot for a collection. Ranking lives in
|
|
478
|
+
* `@rebasepro/common`, shared with the admin package so both agree on what an
|
|
479
|
+
* entity is called.
|
|
480
|
+
*/
|
|
475
481
|
function getEntityTitlePropertyKey(collection, propertyConfigs) {
|
|
476
|
-
|
|
477
|
-
const orderToSearch = collection.propertiesOrder || Object.keys(collection.properties);
|
|
478
|
-
let firstStringCandidate;
|
|
479
|
-
for (const key of orderToSearch) {
|
|
480
|
-
const property = collection.properties[key];
|
|
481
|
-
if (property && !isPropertyBuilder(property)) {
|
|
482
|
-
const prop = property;
|
|
483
|
-
if (isHiddenProperty(prop)) continue;
|
|
484
|
-
if (prop.type === "string" && !prop.ui?.multiline && !prop.ui?.markdown && !prop.storage && !prop.isId) {
|
|
485
|
-
if (!firstStringCandidate) firstStringCandidate = key;
|
|
486
|
-
const lowerKey = key.toLowerCase();
|
|
487
|
-
if ([
|
|
488
|
-
"name",
|
|
489
|
-
"title",
|
|
490
|
-
"label",
|
|
491
|
-
"displayname",
|
|
492
|
-
"username"
|
|
493
|
-
].includes(lowerKey)) return key;
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
return firstStringCandidate;
|
|
482
|
+
return getTitlePropertyKey$1(collection);
|
|
498
483
|
}
|
|
499
484
|
//#endregion
|
|
500
485
|
//#region src/hooks/data/useCollection.tsx
|
|
@@ -2084,8 +2069,14 @@ function resolveComponentRef(ref) {
|
|
|
2084
2069
|
if (fn.prototype?.isReactComponent) return ref;
|
|
2085
2070
|
if ("$$typeof" in fn) return ref;
|
|
2086
2071
|
if (fn.length > 0) return ref;
|
|
2087
|
-
const
|
|
2088
|
-
|
|
2072
|
+
const source = (() => {
|
|
2073
|
+
try {
|
|
2074
|
+
return Function.prototype.toString.call(fn);
|
|
2075
|
+
} catch {
|
|
2076
|
+
return "";
|
|
2077
|
+
}
|
|
2078
|
+
})();
|
|
2079
|
+
if (!/\b(?:import|require)\s*\(/.test(source) && fn.name && /^[A-Z]/.test(fn.name)) return ref;
|
|
2089
2080
|
return getOrCreateLazy(fn, ref);
|
|
2090
2081
|
}
|
|
2091
2082
|
if (typeof ref === "object" && "$$typeof" in ref) return ref;
|
|
@@ -2287,7 +2278,7 @@ function hideAndExpandKeys(collection, keys) {
|
|
|
2287
2278
|
for (const key of keys) if (key.includes(".")) {
|
|
2288
2279
|
const rootKey = key.split(".")[0];
|
|
2289
2280
|
const rootProperty = collection.properties[rootKey];
|
|
2290
|
-
if (rootProperty && rootProperty.type === "map" && rootProperty.
|
|
2281
|
+
if (rootProperty && rootProperty.type === "map" && rootProperty.admin?.spreadChildren && rootProperty.properties) rootsWithExplicitChildren.add(rootKey);
|
|
2291
2282
|
}
|
|
2292
2283
|
const processedPropertyKeys = /* @__PURE__ */ new Set();
|
|
2293
2284
|
const result = keys.flatMap((key) => {
|
|
@@ -2295,9 +2286,9 @@ function hideAndExpandKeys(collection, keys) {
|
|
|
2295
2286
|
const property = collection.properties[key];
|
|
2296
2287
|
if (property) {
|
|
2297
2288
|
processedPropertyKeys.add(key);
|
|
2298
|
-
if (property.
|
|
2299
|
-
if (property.
|
|
2300
|
-
if (property.type === "map" && property.
|
|
2289
|
+
if (property.admin?.hideFromCollection) return [null];
|
|
2290
|
+
if (property.admin?.disabled && typeof property.admin?.disabled === "object" && property.admin?.disabled.hidden) return [null];
|
|
2291
|
+
if (property.type === "map" && property.admin?.spreadChildren && property.properties) {
|
|
2301
2292
|
if (rootsWithExplicitChildren.has(key)) return [null];
|
|
2302
2293
|
const childConfigs = getColumnKeysForProperty(property, key);
|
|
2303
2294
|
childConfigs.forEach((c) => processedPropertyKeys.add(c.key));
|
|
@@ -2305,7 +2296,7 @@ function hideAndExpandKeys(collection, keys) {
|
|
|
2305
2296
|
}
|
|
2306
2297
|
return [{
|
|
2307
2298
|
key,
|
|
2308
|
-
disabled: Boolean(property.
|
|
2299
|
+
disabled: Boolean(property.admin?.disabled) || Boolean(property.admin?.readOnly)
|
|
2309
2300
|
}];
|
|
2310
2301
|
}
|
|
2311
2302
|
if (key.includes(".")) {
|
|
@@ -2316,11 +2307,11 @@ function hideAndExpandKeys(collection, keys) {
|
|
|
2316
2307
|
if (nestedProperty) {
|
|
2317
2308
|
processedPropertyKeys.add(key);
|
|
2318
2309
|
processedPropertyKeys.add(rootKey);
|
|
2319
|
-
if (nestedProperty.
|
|
2320
|
-
if (nestedProperty.
|
|
2310
|
+
if (nestedProperty.admin?.hideFromCollection) return [null];
|
|
2311
|
+
if (nestedProperty.admin?.disabled && typeof nestedProperty.admin?.disabled === "object" && nestedProperty.admin?.disabled.hidden) return [null];
|
|
2321
2312
|
return [{
|
|
2322
2313
|
key,
|
|
2323
|
-
disabled: Boolean(rootProperty.
|
|
2314
|
+
disabled: Boolean(rootProperty.admin?.disabled) || Boolean(rootProperty.admin?.readOnly) || Boolean(nestedProperty.admin?.disabled) || Boolean(nestedProperty.admin?.readOnly)
|
|
2324
2315
|
}];
|
|
2325
2316
|
}
|
|
2326
2317
|
}
|
|
@@ -2342,9 +2333,9 @@ function hideAndExpandKeys(collection, keys) {
|
|
|
2342
2333
|
if (processedPropertyKeys.has(propKey)) continue;
|
|
2343
2334
|
const property = collection.properties[propKey];
|
|
2344
2335
|
if (!property) continue;
|
|
2345
|
-
if (property.
|
|
2346
|
-
if (property.
|
|
2347
|
-
if (property.type === "map" && property.
|
|
2336
|
+
if (property.admin?.hideFromCollection) continue;
|
|
2337
|
+
if (property.admin?.disabled && typeof property.admin?.disabled === "object" && property.admin?.disabled.hidden) continue;
|
|
2338
|
+
if (property.type === "map" && property.admin?.spreadChildren && property.properties) {
|
|
2348
2339
|
const allChildConfigs = getColumnKeysForProperty(property, propKey);
|
|
2349
2340
|
for (const childConfig of allChildConfigs) if (!processedPropertyKeys.has(childConfig.key)) {
|
|
2350
2341
|
result.push(childConfig);
|
|
@@ -2353,7 +2344,7 @@ function hideAndExpandKeys(collection, keys) {
|
|
|
2353
2344
|
} else {
|
|
2354
2345
|
result.push({
|
|
2355
2346
|
key: propKey,
|
|
2356
|
-
disabled: Boolean(property.
|
|
2347
|
+
disabled: Boolean(property.admin?.disabled) || Boolean(property.admin?.readOnly)
|
|
2357
2348
|
});
|
|
2358
2349
|
processedPropertyKeys.add(propKey);
|
|
2359
2350
|
}
|
|
@@ -2372,10 +2363,10 @@ function getDefaultColumnKeys(collection, includeSubCollections) {
|
|
|
2372
2363
|
return hideAndExpandKeys(collection, columnIds);
|
|
2373
2364
|
}
|
|
2374
2365
|
function getColumnKeysForProperty(property, key, disabled) {
|
|
2375
|
-
if (property.type === "map" && property.
|
|
2366
|
+
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)));
|
|
2376
2367
|
return [{
|
|
2377
2368
|
key,
|
|
2378
|
-
disabled: disabled || Boolean(property.
|
|
2369
|
+
disabled: disabled || Boolean(property.admin?.disabled) || Boolean(property.admin?.readOnly)
|
|
2379
2370
|
}];
|
|
2380
2371
|
}
|
|
2381
2372
|
function getFormFieldKeys(collection) {
|
|
@@ -3187,7 +3178,7 @@ function DashboardMetrics({ loading, insights, totalInPipeline, totalRevenue })
|
|
|
3187
3178
|
className: "flex items-center gap-3",
|
|
3188
3179
|
children: [/* @__PURE__ */ jsx("div", {
|
|
3189
3180
|
className: "flex items-center justify-center w-5 h-5 text-surface-400 dark:text-surface-500",
|
|
3190
|
-
children: /* @__PURE__ */ jsx(
|
|
3181
|
+
children: /* @__PURE__ */ jsx(UsersIcon, { className: "h-4 w-4" })
|
|
3191
3182
|
}), /* @__PURE__ */ jsxs("div", {
|
|
3192
3183
|
className: "flex-1 min-w-0",
|
|
3193
3184
|
children: [/* @__PURE__ */ jsx(Typography, {
|
|
@@ -3209,7 +3200,7 @@ function DashboardMetrics({ loading, insights, totalInPipeline, totalRevenue })
|
|
|
3209
3200
|
className: "flex items-center gap-3",
|
|
3210
3201
|
children: [/* @__PURE__ */ jsx("div", {
|
|
3211
3202
|
className: "flex items-center justify-center w-5 h-5 text-surface-400 dark:text-surface-500",
|
|
3212
|
-
children: /* @__PURE__ */ jsx(
|
|
3203
|
+
children: /* @__PURE__ */ jsx(TrendingUpIcon, { className: "h-4 w-4" })
|
|
3213
3204
|
}), /* @__PURE__ */ jsxs("div", {
|
|
3214
3205
|
className: "flex-1 min-w-0",
|
|
3215
3206
|
children: [/* @__PURE__ */ jsx(Typography, {
|
|
@@ -3231,7 +3222,7 @@ function DashboardMetrics({ loading, insights, totalInPipeline, totalRevenue })
|
|
|
3231
3222
|
className: "flex items-center gap-3",
|
|
3232
3223
|
children: [/* @__PURE__ */ jsx("div", {
|
|
3233
3224
|
className: "flex items-center justify-center w-5 h-5 text-surface-400 dark:text-surface-500",
|
|
3234
|
-
children: /* @__PURE__ */ jsx(
|
|
3225
|
+
children: /* @__PURE__ */ jsx(DollarSignIcon, { className: "h-4 w-4" })
|
|
3235
3226
|
}), /* @__PURE__ */ jsxs("div", {
|
|
3236
3227
|
className: "flex-1 min-w-0",
|
|
3237
3228
|
children: [/* @__PURE__ */ jsx(Typography, {
|
|
@@ -3265,7 +3256,7 @@ function DashboardMetrics({ loading, insights, totalInPipeline, totalRevenue })
|
|
|
3265
3256
|
className: "flex items-center gap-3",
|
|
3266
3257
|
children: [/* @__PURE__ */ jsx("div", {
|
|
3267
3258
|
className: cls("flex items-center justify-center w-5 h-5", insights && insights.overdueTaskCount > 0 ? "text-red-500" : "text-surface-400 dark:text-surface-500"),
|
|
3268
|
-
children: /* @__PURE__ */ jsx(
|
|
3259
|
+
children: /* @__PURE__ */ jsx(AlertTriangleIcon, { className: "h-4 w-4" })
|
|
3269
3260
|
}), /* @__PURE__ */ jsxs("div", {
|
|
3270
3261
|
className: "flex-1 min-w-0",
|
|
3271
3262
|
children: [/* @__PURE__ */ jsx(Typography, {
|
|
@@ -3318,7 +3309,7 @@ function PipelineOverview({ loading, insights, selectedPipelineId, onPipelineCha
|
|
|
3318
3309
|
onClick: () => {
|
|
3319
3310
|
onNavigate("/c/engagements");
|
|
3320
3311
|
},
|
|
3321
|
-
endIcon: /* @__PURE__ */ jsx(
|
|
3312
|
+
endIcon: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-4 w-4" }),
|
|
3322
3313
|
children: "View All"
|
|
3323
3314
|
})]
|
|
3324
3315
|
}), loading ? /* @__PURE__ */ jsx(Skeleton, { className: "h-20 w-full rounded-lg" }) : insights && sortedStages.length === 0 ? /* @__PURE__ */ jsxs("div", {
|
|
@@ -3326,7 +3317,7 @@ function PipelineOverview({ loading, insights, selectedPipelineId, onPipelineCha
|
|
|
3326
3317
|
children: [
|
|
3327
3318
|
/* @__PURE__ */ jsx("div", {
|
|
3328
3319
|
className: "flex items-center justify-center w-5 h-5 text-surface-400 dark:text-surface-500 mb-3",
|
|
3329
|
-
children: /* @__PURE__ */ jsx(
|
|
3320
|
+
children: /* @__PURE__ */ jsx(SettingsIcon, { className: "h-4 w-4" })
|
|
3330
3321
|
}),
|
|
3331
3322
|
/* @__PURE__ */ jsx(Typography, {
|
|
3332
3323
|
variant: "body2",
|
|
@@ -3352,7 +3343,7 @@ function PipelineOverview({ loading, insights, selectedPipelineId, onPipelineCha
|
|
|
3352
3343
|
children: [
|
|
3353
3344
|
/* @__PURE__ */ jsx("div", {
|
|
3354
3345
|
className: "flex items-center justify-center w-5 h-5 text-surface-400 dark:text-surface-500 mb-3",
|
|
3355
|
-
children: /* @__PURE__ */ jsx(
|
|
3346
|
+
children: /* @__PURE__ */ jsx(UsersIcon, { className: "h-4 w-4" })
|
|
3356
3347
|
}),
|
|
3357
3348
|
/* @__PURE__ */ jsx(Typography, {
|
|
3358
3349
|
variant: "body2",
|
|
@@ -3379,7 +3370,7 @@ function PipelineOverview({ loading, insights, selectedPipelineId, onPipelineCha
|
|
|
3379
3370
|
const displayLabel = useShortLabels ? stage.shortLabel : stage.label;
|
|
3380
3371
|
return /* @__PURE__ */ jsxs(React.Fragment, { children: [idx > 0 && /* @__PURE__ */ jsx("div", {
|
|
3381
3372
|
className: "flex items-center shrink-0 text-surface-300 dark:text-surface-600 -mx-0.5",
|
|
3382
|
-
children: /* @__PURE__ */ jsx(
|
|
3373
|
+
children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-4 w-4" })
|
|
3383
3374
|
}), /* @__PURE__ */ jsx(Tooltip, {
|
|
3384
3375
|
title: `${stage.label} — ${stage.count} client${stage.count !== 1 ? "s" : ""}`,
|
|
3385
3376
|
children: /* @__PURE__ */ jsxs("div", {
|
|
@@ -3418,7 +3409,7 @@ function PipelineOverview({ loading, insights, selectedPipelineId, onPipelineCha
|
|
|
3418
3409
|
const displayLabel = useShortLabels ? stage.shortLabel : stage.label;
|
|
3419
3410
|
return /* @__PURE__ */ jsxs(React.Fragment, { children: [idx > 0 && /* @__PURE__ */ jsx("div", {
|
|
3420
3411
|
className: "flex items-center shrink-0 text-surface-300 dark:text-surface-600 -mx-0.5",
|
|
3421
|
-
children: /* @__PURE__ */ jsx(
|
|
3412
|
+
children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-4 w-4" })
|
|
3422
3413
|
}), /* @__PURE__ */ jsx(Tooltip, {
|
|
3423
3414
|
title: `${stage.label} — ${stage.count} client${stage.count !== 1 ? "s" : ""}`,
|
|
3424
3415
|
children: /* @__PURE__ */ jsxs("div", {
|
|
@@ -3455,17 +3446,17 @@ function PipelineOverview({ loading, insights, selectedPipelineId, onPipelineCha
|
|
|
3455
3446
|
//#endregion
|
|
3456
3447
|
//#region src/components/Debug/crm-dashboard/RecentActivity.tsx
|
|
3457
3448
|
var ACTIVITY_ICONS = {
|
|
3458
|
-
incoming: /* @__PURE__ */ jsx(
|
|
3459
|
-
status_changed: /* @__PURE__ */ jsx(
|
|
3460
|
-
email_sent: /* @__PURE__ */ jsx(
|
|
3461
|
-
agreements_sent: /* @__PURE__ */ jsx(
|
|
3462
|
-
agreements_signed: /* @__PURE__ */ jsx(
|
|
3463
|
-
zoom_setup: /* @__PURE__ */ jsx(
|
|
3464
|
-
whatsapp_setup: /* @__PURE__ */ jsx(
|
|
3465
|
-
note: /* @__PURE__ */ jsx(
|
|
3466
|
-
task_created: /* @__PURE__ */ jsx(
|
|
3467
|
-
task_completed: /* @__PURE__ */ jsx(
|
|
3468
|
-
manual_action: /* @__PURE__ */ jsx(
|
|
3449
|
+
incoming: /* @__PURE__ */ jsx(CircleDotIcon, { className: "h-4 w-4 text-blue-500" }),
|
|
3450
|
+
status_changed: /* @__PURE__ */ jsx(ArrowRightLeftIcon, { className: "h-4 w-4 text-violet-500" }),
|
|
3451
|
+
email_sent: /* @__PURE__ */ jsx(MailIcon, { className: "h-4 w-4 text-sky-500" }),
|
|
3452
|
+
agreements_sent: /* @__PURE__ */ jsx(FileTextIcon, { className: "h-4 w-4 text-amber-500" }),
|
|
3453
|
+
agreements_signed: /* @__PURE__ */ jsx(PenLineIcon, { className: "h-4 w-4 text-emerald-500" }),
|
|
3454
|
+
zoom_setup: /* @__PURE__ */ jsx(VideoIcon, { className: "h-4 w-4 text-blue-600" }),
|
|
3455
|
+
whatsapp_setup: /* @__PURE__ */ jsx(MessageCircleIcon, { className: "h-4 w-4 text-green-500" }),
|
|
3456
|
+
note: /* @__PURE__ */ jsx(StickyNoteIcon, { className: "h-4 w-4 text-yellow-500" }),
|
|
3457
|
+
task_created: /* @__PURE__ */ jsx(ListPlusIcon, { className: "h-4 w-4 text-teal-500" }),
|
|
3458
|
+
task_completed: /* @__PURE__ */ jsx(CheckCircle2Icon, { className: "h-4 w-4 text-emerald-500" }),
|
|
3459
|
+
manual_action: /* @__PURE__ */ jsx(WrenchIcon, { className: "h-4 w-4 text-orange-500" })
|
|
3469
3460
|
};
|
|
3470
3461
|
function relativeTime(dateStr) {
|
|
3471
3462
|
const now = Date.now();
|
|
@@ -3518,7 +3509,7 @@ function RecentActivity({ activities, activitiesLoading, tasksMap, onCompleteTas
|
|
|
3518
3509
|
className: "flex items-start gap-2.5 py-2.5",
|
|
3519
3510
|
children: [/* @__PURE__ */ jsx("span", {
|
|
3520
3511
|
className: "shrink-0 mt-0.5 flex items-center",
|
|
3521
|
-
children: ACTIVITY_ICONS[actType] ?? /* @__PURE__ */ jsx(
|
|
3512
|
+
children: ACTIVITY_ICONS[actType] ?? /* @__PURE__ */ jsx(PinIcon, { className: "h-4 w-4 text-surface-400 dark:text-surface-500" })
|
|
3522
3513
|
}), /* @__PURE__ */ jsxs("div", {
|
|
3523
3514
|
className: "flex-1 min-w-0",
|
|
3524
3515
|
children: [
|
|
@@ -3615,7 +3606,7 @@ function TaskFilters({ quickFilter, onQuickFilterChange, stageFilter, onStageFil
|
|
|
3615
3606
|
children: [
|
|
3616
3607
|
/* @__PURE__ */ jsx("div", {
|
|
3617
3608
|
className: "flex items-center justify-center w-5 h-5 text-surface-400 dark:text-surface-500",
|
|
3618
|
-
children: /* @__PURE__ */ jsx(
|
|
3609
|
+
children: /* @__PURE__ */ jsx(ListTodoIcon, { className: "h-4 w-4" })
|
|
3619
3610
|
}),
|
|
3620
3611
|
/* @__PURE__ */ jsx(Typography, {
|
|
3621
3612
|
variant: "subtitle1",
|
|
@@ -3653,7 +3644,7 @@ function TaskFilters({ quickFilter, onQuickFilterChange, stageFilter, onStageFil
|
|
|
3653
3644
|
onQuickFilterChange(quickFilter === "overdue" ? "all" : "overdue");
|
|
3654
3645
|
},
|
|
3655
3646
|
size: "small",
|
|
3656
|
-
icon: /* @__PURE__ */ jsx(
|
|
3647
|
+
icon: /* @__PURE__ */ jsx(AlertTriangleIcon, { className: "h-3 w-3" }),
|
|
3657
3648
|
children: ["Overdue", overdueTasks.length > 0 ? ` (${overdueTasks.length})` : ""]
|
|
3658
3649
|
}),
|
|
3659
3650
|
hasActiveFilter && /* @__PURE__ */ jsx(Button, {
|
|
@@ -3662,7 +3653,7 @@ function TaskFilters({ quickFilter, onQuickFilterChange, stageFilter, onStageFil
|
|
|
3662
3653
|
color: "neutral",
|
|
3663
3654
|
className: "p-0 h-auto min-w-0 text-xs text-text-secondary dark:text-text-secondary-dark hover:text-primary dark:hover:text-primary-light",
|
|
3664
3655
|
onClick: onClearAllFilters,
|
|
3665
|
-
startIcon: /* @__PURE__ */ jsx(
|
|
3656
|
+
startIcon: /* @__PURE__ */ jsx(XIcon, { className: "h-3 w-3" }),
|
|
3666
3657
|
children: "Clear"
|
|
3667
3658
|
})
|
|
3668
3659
|
]
|
|
@@ -3892,7 +3883,7 @@ function TaskTable({ tasks, loading, pendingTasks, visiblePendingTasks, hasMoreP
|
|
|
3892
3883
|
children: [
|
|
3893
3884
|
dueLabel && /* @__PURE__ */ jsxs("span", {
|
|
3894
3885
|
className: cls("inline-flex items-center gap-1 text-[11px]", overdue && "text-red-600 dark:text-red-400 font-medium", soon && !overdue && "text-amber-600 dark:text-amber-400 font-medium", !overdue && !soon && "text-text-secondary dark:text-text-secondary-dark"),
|
|
3895
|
-
children: [overdue ? /* @__PURE__ */ jsx(
|
|
3886
|
+
children: [overdue ? /* @__PURE__ */ jsx(AlertTriangleIcon, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(CalendarIcon, { className: "h-3 w-3" }), dueLabel]
|
|
3896
3887
|
}),
|
|
3897
3888
|
clientName && task.values?.clientId && /* @__PURE__ */ jsxs(Typography, {
|
|
3898
3889
|
variant: "body2",
|
|
@@ -3972,7 +3963,7 @@ function TaskTable({ tasks, loading, pendingTasks, visiblePendingTasks, hasMoreP
|
|
|
3972
3963
|
children: [
|
|
3973
3964
|
/* @__PURE__ */ jsx("div", {
|
|
3974
3965
|
className: "flex items-center justify-center w-5 h-5 text-surface-400 dark:text-surface-500 mb-3",
|
|
3975
|
-
children: /* @__PURE__ */ jsx(
|
|
3966
|
+
children: /* @__PURE__ */ jsx(CheckCircle2Icon, { className: "h-4 w-4" })
|
|
3976
3967
|
}),
|
|
3977
3968
|
/* @__PURE__ */ jsx(Typography, {
|
|
3978
3969
|
variant: "subtitle2",
|
|
@@ -4331,7 +4322,7 @@ function CalendarWidget({ loading, tasks, onOpenTask }) {
|
|
|
4331
4322
|
size: "smallest",
|
|
4332
4323
|
"aria-label": "Previous month",
|
|
4333
4324
|
onClick: goToPrevMonth,
|
|
4334
|
-
children: /* @__PURE__ */ jsx(
|
|
4325
|
+
children: /* @__PURE__ */ jsx(ChevronLeftIcon, { className: "h-4 w-4" })
|
|
4335
4326
|
}),
|
|
4336
4327
|
/* @__PURE__ */ jsxs(Typography, {
|
|
4337
4328
|
variant: "body2",
|
|
@@ -4346,7 +4337,7 @@ function CalendarWidget({ loading, tasks, onOpenTask }) {
|
|
|
4346
4337
|
size: "smallest",
|
|
4347
4338
|
"aria-label": "Next month",
|
|
4348
4339
|
onClick: goToNextMonth,
|
|
4349
|
-
children: /* @__PURE__ */ jsx(
|
|
4340
|
+
children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-4 w-4" })
|
|
4350
4341
|
})
|
|
4351
4342
|
]
|
|
4352
4343
|
}),
|
|
@@ -5167,7 +5158,7 @@ function CrmDashboardDemo() {
|
|
|
5167
5158
|
}), /* @__PURE__ */ jsxs(Typography, {
|
|
5168
5159
|
variant: "body2",
|
|
5169
5160
|
className: "font-medium mt-0.5 inline-flex items-center gap-1",
|
|
5170
|
-
children: [/* @__PURE__ */ jsx(
|
|
5161
|
+
children: [/* @__PURE__ */ jsx(CalendarIcon, { className: "h-3.5 w-3.5 text-surface-400" }), task.values.dueDate || "No due date"]
|
|
5171
5162
|
})] }), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(Typography, {
|
|
5172
5163
|
variant: "caption",
|
|
5173
5164
|
color: "secondary",
|
|
@@ -5294,13 +5285,13 @@ function CrmDashboardDemo() {
|
|
|
5294
5285
|
className: "space-y-2.5 py-3 border-y border-surface-200 dark:border-surface-700",
|
|
5295
5286
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
5296
5287
|
className: "flex items-center gap-2 text-surface-600 dark:text-surface-300",
|
|
5297
|
-
children: [/* @__PURE__ */ jsx(
|
|
5288
|
+
children: [/* @__PURE__ */ jsx(MailIcon, { className: "h-4 w-4 text-surface-400" }), /* @__PURE__ */ jsx(Typography, {
|
|
5298
5289
|
variant: "body2",
|
|
5299
5290
|
children: client.email
|
|
5300
5291
|
})]
|
|
5301
5292
|
}), /* @__PURE__ */ jsxs("div", {
|
|
5302
5293
|
className: "flex items-center gap-2 text-surface-600 dark:text-surface-300",
|
|
5303
|
-
children: [/* @__PURE__ */ jsx(
|
|
5294
|
+
children: [/* @__PURE__ */ jsx(PhoneIcon, { className: "h-4 w-4 text-surface-400" }), /* @__PURE__ */ jsx(Typography, {
|
|
5304
5295
|
variant: "body2",
|
|
5305
5296
|
children: client.phone
|
|
5306
5297
|
})]
|
|
@@ -5499,7 +5490,7 @@ function CrmDashboardDemo() {
|
|
|
5499
5490
|
}, 300);
|
|
5500
5491
|
},
|
|
5501
5492
|
disabled: loading,
|
|
5502
|
-
startIcon: /* @__PURE__ */ jsx(
|
|
5493
|
+
startIcon: /* @__PURE__ */ jsx(RefreshCwIcon, { className: cls("h-4 w-4", loading && "animate-spin") }),
|
|
5503
5494
|
children: "Refresh"
|
|
5504
5495
|
}), /* @__PURE__ */ jsx(Button, {
|
|
5505
5496
|
variant: "filled",
|
|
@@ -5585,7 +5576,7 @@ function CrmDashboardDemo() {
|
|
|
5585
5576
|
}), /* @__PURE__ */ jsx("button", {
|
|
5586
5577
|
onClick: () => setActiveSideEntity(null),
|
|
5587
5578
|
className: "p-1 rounded-md text-surface-400 hover:text-surface-700 hover:bg-surface-100 dark:hover:bg-surface-800 focus:outline-none",
|
|
5588
|
-
children: /* @__PURE__ */ jsx(
|
|
5579
|
+
children: /* @__PURE__ */ jsx(XIcon, { className: "h-4 w-4" })
|
|
5589
5580
|
})]
|
|
5590
5581
|
}), /* @__PURE__ */ jsxs("div", {
|
|
5591
5582
|
className: "flex-1 overflow-y-auto p-5 flex flex-col",
|
|
@@ -5604,7 +5595,7 @@ function CrmDashboardDemo() {
|
|
|
5604
5595
|
className: cls("absolute bottom-4 left-4 z-50 transition-all duration-300 transform", toastMessage ? "translate-y-0 opacity-100" : "translate-y-2 opacity-0 pointer-events-none"),
|
|
5605
5596
|
children: toastMessage && /* @__PURE__ */ jsxs("div", {
|
|
5606
5597
|
className: "px-4 py-3 bg-surface-900 dark:bg-surface-50 text-white dark:text-surface-900 text-xs font-medium rounded-lg shadow-lg flex items-center gap-2 border border-surface-800 dark:border-surface-200",
|
|
5607
|
-
children: [/* @__PURE__ */ jsx(
|
|
5598
|
+
children: [/* @__PURE__ */ jsx(CheckIcon, { className: "h-4 w-4 text-green-500" }), /* @__PURE__ */ jsx("span", { children: toastMessage })]
|
|
5608
5599
|
})
|
|
5609
5600
|
})
|
|
5610
5601
|
]
|
|
@@ -6014,14 +6005,14 @@ function CollectionTableDemo() {
|
|
|
6014
6005
|
asChild: true,
|
|
6015
6006
|
children: /* @__PURE__ */ jsx(IconButton, {
|
|
6016
6007
|
size: "smallest",
|
|
6017
|
-
children: /* @__PURE__ */ jsx(PencilIcon
|
|
6008
|
+
children: /* @__PURE__ */ jsx(PencilIcon, { size: iconSize.smallest })
|
|
6018
6009
|
})
|
|
6019
6010
|
}), /* @__PURE__ */ jsx(Tooltip, {
|
|
6020
6011
|
title: "Delete",
|
|
6021
6012
|
asChild: true,
|
|
6022
6013
|
children: /* @__PURE__ */ jsx(IconButton, {
|
|
6023
6014
|
size: "smallest",
|
|
6024
|
-
children: /* @__PURE__ */ jsx(Trash2Icon
|
|
6015
|
+
children: /* @__PURE__ */ jsx(Trash2Icon, { size: iconSize.smallest })
|
|
6025
6016
|
})
|
|
6026
6017
|
})]
|
|
6027
6018
|
})
|
|
@@ -6085,12 +6076,12 @@ function CardViewDemo() {
|
|
|
6085
6076
|
{
|
|
6086
6077
|
value: "sm",
|
|
6087
6078
|
label: "Small",
|
|
6088
|
-
icon: /* @__PURE__ */ jsx(LayoutGridIcon
|
|
6079
|
+
icon: /* @__PURE__ */ jsx(LayoutGridIcon, { size: 14 })
|
|
6089
6080
|
},
|
|
6090
6081
|
{
|
|
6091
6082
|
value: "md",
|
|
6092
6083
|
label: "Medium",
|
|
6093
|
-
icon: /* @__PURE__ */ jsx(ListIcon
|
|
6084
|
+
icon: /* @__PURE__ */ jsx(ListIcon, { size: 14 })
|
|
6094
6085
|
},
|
|
6095
6086
|
{
|
|
6096
6087
|
value: "lg",
|
|
@@ -6383,12 +6374,19 @@ function KanbanBoardDemo() {
|
|
|
6383
6374
|
* UIReferenceView — hidden debug route at /debug/ui
|
|
6384
6375
|
*
|
|
6385
6376
|
* This file is a STATIC reference of the real UI patterns used across the app.
|
|
6386
|
-
*
|
|
6387
|
-
* DO NOT add invented styles
|
|
6377
|
+
* Markup / styles are copied from source files where a section mirrors a real
|
|
6378
|
+
* screen. DO NOT add invented styles — copy from actual source files, or from
|
|
6379
|
+
* the components in @rebasepro/ui.
|
|
6380
|
+
*
|
|
6381
|
+
* Sections named after a component mirror that component. Sections named after
|
|
6382
|
+
* a pattern (e.g. "Management Screen", "Form Dialog") are illustrative
|
|
6383
|
+
* compositions of kit components and are not tied to a specific screen.
|
|
6384
|
+
*
|
|
6385
|
+
* Do not cite source line numbers here — they rot silently. Name the file only.
|
|
6388
6386
|
*
|
|
6389
6387
|
* Sources:
|
|
6390
6388
|
* DefaultDrawer.tsx, DefaultAppBar.tsx, DrawerNavigationItem.tsx,
|
|
6391
|
-
* DrawerNavigationGroup.tsx
|
|
6389
|
+
* DrawerNavigationGroup.tsx
|
|
6392
6390
|
*/
|
|
6393
6391
|
var SECTIONS = [
|
|
6394
6392
|
{
|
|
@@ -6438,12 +6436,12 @@ var SECTIONS = [
|
|
|
6438
6436
|
},
|
|
6439
6437
|
{
|
|
6440
6438
|
id: "users",
|
|
6441
|
-
label: "
|
|
6439
|
+
label: "Management",
|
|
6442
6440
|
icon: UserIcon
|
|
6443
6441
|
},
|
|
6444
6442
|
{
|
|
6445
6443
|
id: "user-dialog",
|
|
6446
|
-
label: "
|
|
6444
|
+
label: "Form Dialog",
|
|
6447
6445
|
icon: CircleUserIcon
|
|
6448
6446
|
},
|
|
6449
6447
|
{
|
|
@@ -7897,38 +7895,41 @@ function UIReferenceView() {
|
|
|
7897
7895
|
}),
|
|
7898
7896
|
/* @__PURE__ */ jsxs(SectionBlock, {
|
|
7899
7897
|
id: "users",
|
|
7900
|
-
title: "
|
|
7898
|
+
title: "Management Screen — Alert + Table + Chip",
|
|
7901
7899
|
children: [
|
|
7902
7900
|
/* @__PURE__ */ jsxs(Typography, {
|
|
7903
7901
|
variant: "body2",
|
|
7904
7902
|
color: "secondary",
|
|
7905
7903
|
className: "mb-4",
|
|
7906
7904
|
children: [
|
|
7907
|
-
"
|
|
7905
|
+
"Canonical layout for an admin management screen: an ",
|
|
7906
|
+
/* @__PURE__ */ jsx("code", {
|
|
7907
|
+
className: "font-mono text-xs",
|
|
7908
|
+
children: "Alert"
|
|
7909
|
+
}),
|
|
7910
|
+
" with an ",
|
|
7908
7911
|
/* @__PURE__ */ jsx("code", {
|
|
7909
7912
|
className: "font-mono text-xs",
|
|
7910
|
-
children: "
|
|
7913
|
+
children: "action"
|
|
7911
7914
|
}),
|
|
7912
|
-
"
|
|
7915
|
+
", a header row, and a plain ",
|
|
7913
7916
|
/* @__PURE__ */ jsx("code", {
|
|
7914
7917
|
className: "font-mono text-xs",
|
|
7915
|
-
children: "
|
|
7918
|
+
children: "Table"
|
|
7916
7919
|
}),
|
|
7917
|
-
"
|
|
7920
|
+
" with ",
|
|
7918
7921
|
/* @__PURE__ */ jsx("code", {
|
|
7919
7922
|
className: "font-mono text-xs",
|
|
7920
|
-
children: "
|
|
7923
|
+
children: "Chip"
|
|
7921
7924
|
}),
|
|
7922
|
-
"s."
|
|
7925
|
+
"s. Illustrative mock — not tied to a specific screen."
|
|
7923
7926
|
]
|
|
7924
7927
|
}),
|
|
7925
|
-
/* @__PURE__ */
|
|
7926
|
-
|
|
7927
|
-
|
|
7928
|
-
|
|
7929
|
-
|
|
7930
|
-
children: "No admin users exist. You can make yourself an admin."
|
|
7931
|
-
}) }), /* @__PURE__ */ jsx(Button, { children: "Make me admin" })]
|
|
7928
|
+
/* @__PURE__ */ jsx(Alert, {
|
|
7929
|
+
color: "warning",
|
|
7930
|
+
outerClassName: "mb-4",
|
|
7931
|
+
action: /* @__PURE__ */ jsx(Button, { children: "Make me admin" }),
|
|
7932
|
+
children: "No admin users exist. You can make yourself an admin."
|
|
7932
7933
|
}),
|
|
7933
7934
|
/* @__PURE__ */ jsxs("div", {
|
|
7934
7935
|
className: "flex items-center mt-12",
|
|
@@ -8023,33 +8024,28 @@ function UIReferenceView() {
|
|
|
8023
8024
|
}),
|
|
8024
8025
|
/* @__PURE__ */ jsxs(SectionBlock, {
|
|
8025
8026
|
id: "user-dialog",
|
|
8026
|
-
title: "
|
|
8027
|
+
title: "Form Dialog — grid + MultiSelect + LoadingButton",
|
|
8027
8028
|
children: [/* @__PURE__ */ jsxs(Typography, {
|
|
8028
8029
|
variant: "body2",
|
|
8029
8030
|
color: "secondary",
|
|
8030
8031
|
className: "mb-4",
|
|
8031
8032
|
children: [
|
|
8032
|
-
"
|
|
8033
|
-
/* @__PURE__ */ jsx("code", {
|
|
8034
|
-
className: "font-mono text-xs",
|
|
8035
|
-
children: "UserDetailsForm"
|
|
8036
|
-
}),
|
|
8037
|
-
": ",
|
|
8033
|
+
"Canonical form-in-a-card layout: ",
|
|
8038
8034
|
/* @__PURE__ */ jsx("code", {
|
|
8039
8035
|
className: "font-mono text-xs",
|
|
8040
8036
|
children: "grid grid-cols-12 gap-4"
|
|
8041
8037
|
}),
|
|
8042
|
-
", ",
|
|
8038
|
+
" for the fields, a ",
|
|
8043
8039
|
/* @__PURE__ */ jsx("code", {
|
|
8044
8040
|
className: "font-mono text-xs",
|
|
8045
8041
|
children: "MultiSelect"
|
|
8046
8042
|
}),
|
|
8047
|
-
"
|
|
8043
|
+
", and a ",
|
|
8048
8044
|
/* @__PURE__ */ jsx("code", {
|
|
8049
8045
|
className: "font-mono text-xs",
|
|
8050
8046
|
children: "LoadingButton"
|
|
8051
8047
|
}),
|
|
8052
|
-
" to submit."
|
|
8048
|
+
" to submit. Illustrative mock — not tied to a specific screen."
|
|
8053
8049
|
]
|
|
8054
8050
|
}), /* @__PURE__ */ jsxs("div", {
|
|
8055
8051
|
className: `rounded-lg border w-full max-w-xl ${defaultBorderMixin}`,
|
|
@@ -8924,6 +8920,23 @@ function UserDisplay({ user }) {
|
|
|
8924
8920
|
* near-black login card, so login inputs get an explicit border in dark mode.
|
|
8925
8921
|
*/
|
|
8926
8922
|
var loginFieldClasses = "w-full dark:border dark:border-surface-700/70 dark:hover:border-surface-600";
|
|
8923
|
+
/** One warning per provider per page load — this is a config hint, not a log stream. */
|
|
8924
|
+
var warnedProviders = /* @__PURE__ */ new Set();
|
|
8925
|
+
/**
|
|
8926
|
+
* An OAuth button needs a client id in the frontend *and* the provider
|
|
8927
|
+
* configured on the backend. Half a configuration renders nothing at all, with
|
|
8928
|
+
* no error anywhere — the button simply is not there, which reads as "the
|
|
8929
|
+
* feature broke" rather than "one env var is missing". Say which half is
|
|
8930
|
+
* missing instead.
|
|
8931
|
+
*/
|
|
8932
|
+
function warnAboutHalfConfiguredOAuth(provider, clientId, backendProviders) {
|
|
8933
|
+
const backendHasIt = backendProviders.includes(provider);
|
|
8934
|
+
if (Boolean(clientId) === backendHasIt) return;
|
|
8935
|
+
if (warnedProviders.has(provider)) return;
|
|
8936
|
+
warnedProviders.add(provider);
|
|
8937
|
+
const envVar = `${provider.toUpperCase()}_CLIENT_ID`;
|
|
8938
|
+
console.warn(clientId ? `[Rebase] ${provider} login is hidden: the login view has a client id, but the backend reports no "${provider}" provider. Set ${envVar} (and ${provider.toUpperCase()}_CLIENT_SECRET) on the server and restart it.` : `[Rebase] ${provider} login is hidden: the backend has a "${provider}" provider, but the login view was given no client id. Pass it to the login view (e.g. VITE_${envVar}) and restart the frontend so the new env var is picked up.`);
|
|
8939
|
+
}
|
|
8927
8940
|
/**
|
|
8928
8941
|
* Generic login view component that works with any AuthControllerExtended.
|
|
8929
8942
|
* Feature-detects capabilities to show/hide login methods.
|
|
@@ -8945,9 +8958,23 @@ function LoginView({ logo, authController, noUserComponent, disableSignupScreen
|
|
|
8945
8958
|
const caps = authController.capabilities ?? {};
|
|
8946
8959
|
const isBootstrapMode = needsSetup ?? ("needsSetup" in authController && !!authController.needsSetup) ?? false;
|
|
8947
8960
|
const canRegister = registrationEnabled ?? caps.registration ?? false;
|
|
8948
|
-
const
|
|
8949
|
-
const
|
|
8950
|
-
const
|
|
8961
|
+
const backendProviders = caps.enabledProviders ?? [];
|
|
8962
|
+
const hasGoogleLogin = Boolean(googleClientId) && backendProviders.includes("google");
|
|
8963
|
+
const hasGitHubLogin = githubClientId && backendProviders.includes("github");
|
|
8964
|
+
const hasLinkedinLogin = linkedinClientId && backendProviders.includes("linkedin");
|
|
8965
|
+
useEffect(() => {
|
|
8966
|
+
const timer = setTimeout(() => {
|
|
8967
|
+
warnAboutHalfConfiguredOAuth("google", googleClientId, backendProviders);
|
|
8968
|
+
warnAboutHalfConfiguredOAuth("github", githubClientId, backendProviders);
|
|
8969
|
+
warnAboutHalfConfiguredOAuth("linkedin", linkedinClientId, backendProviders);
|
|
8970
|
+
}, 3e3);
|
|
8971
|
+
return () => clearTimeout(timer);
|
|
8972
|
+
}, [
|
|
8973
|
+
googleClientId,
|
|
8974
|
+
githubClientId,
|
|
8975
|
+
linkedinClientId,
|
|
8976
|
+
backendProviders.join(",")
|
|
8977
|
+
]);
|
|
8951
8978
|
const hasPasswordReset = caps.passwordReset ?? !!authController.forgotPassword;
|
|
8952
8979
|
const showRegistration = !disableSignupScreen && canRegister;
|
|
8953
8980
|
useEffect(() => {
|
|
@@ -15793,7 +15820,7 @@ function RebaseInternal({ loading, children }) {
|
|
|
15793
15820
|
//#region src/core/RebaseRouter.tsx
|
|
15794
15821
|
function RebaseRouter({ children, basePath }) {
|
|
15795
15822
|
return /* @__PURE__ */ jsx(RouterProvider, { router: createBrowserRouter([{
|
|
15796
|
-
path: basePath ? `${removeInitialAndTrailingSlashes(basePath)}/*` : "/*",
|
|
15823
|
+
path: basePath ? `${removeInitialAndTrailingSlashes$1(basePath)}/*` : "/*",
|
|
15797
15824
|
element: children
|
|
15798
15825
|
}]) });
|
|
15799
15826
|
}
|
|
@@ -16974,6 +17001,657 @@ function useBridgeRegistration(key, value) {
|
|
|
16974
17001
|
]);
|
|
16975
17002
|
}
|
|
16976
17003
|
//#endregion
|
|
16977
|
-
|
|
17004
|
+
//#region src/collections/collection_view_config.ts
|
|
17005
|
+
function resolveDefaultSelectedView(defaultSelectedView, params) {
|
|
17006
|
+
if (!defaultSelectedView) return;
|
|
17007
|
+
else if (typeof defaultSelectedView === "string") return defaultSelectedView;
|
|
17008
|
+
else return defaultSelectedView(params);
|
|
17009
|
+
}
|
|
17010
|
+
function getLocalChangesBackup(collection) {
|
|
17011
|
+
if (!collection.localChangesBackup) return "manual_apply";
|
|
17012
|
+
return collection.localChangesBackup;
|
|
17013
|
+
}
|
|
17014
|
+
/**
|
|
17015
|
+
* Returns the primary keys for a entity collection by inspecting the properties
|
|
17016
|
+
* and finding any properties with `isId`.
|
|
17017
|
+
* Fallbacks to `["id"]` if no properties are marked as `isId: true`.
|
|
17018
|
+
* @param collection
|
|
17019
|
+
*/
|
|
17020
|
+
/**
|
|
17021
|
+
* A collection's child collections, as the panel's view model.
|
|
17022
|
+
*
|
|
17023
|
+
* `getSubcollections` in `@rebasepro/common` returns the contract type, so the
|
|
17024
|
+
* children of a resolved collection arrived un-flattened and reading
|
|
17025
|
+
* `child.icon` or `child.hideFromNavigation` failed. Resolving is not recursive
|
|
17026
|
+
* on purpose — children are fetched lazily through a thunk
|
|
17027
|
+
* (`childCollections`/`subcollections`), so walking the whole tree eagerly to
|
|
17028
|
+
* flatten it would defeat that.
|
|
17029
|
+
*/
|
|
17030
|
+
function getAdminSubcollections(collection) {
|
|
17031
|
+
return (getSubcollections(collection) ?? []).map(resolveAdminCollection);
|
|
17032
|
+
}
|
|
17033
|
+
//#endregion
|
|
17034
|
+
//#region src/collections/entity_image_preview.ts
|
|
17035
|
+
function getEntityImagePreviewPropertyKey(collection) {
|
|
17036
|
+
for (const key in collection.properties) {
|
|
17037
|
+
const property = collection.properties[key];
|
|
17038
|
+
if (property.type === "string" && property.storage?.acceptedFiles?.includes("image/*")) return key;
|
|
17039
|
+
}
|
|
17040
|
+
for (const key in collection.properties) {
|
|
17041
|
+
const property = collection.properties[key];
|
|
17042
|
+
if (property.type === "array" && !Array.isArray(property.of) && property.of?.type === "string" && property.of.storage?.acceptedFiles?.includes("image/*")) return key;
|
|
17043
|
+
}
|
|
17044
|
+
for (const key in collection.properties) {
|
|
17045
|
+
const property = collection.properties[key];
|
|
17046
|
+
if (property.type === "string" && property.admin?.urlPreview === "image") return key;
|
|
17047
|
+
}
|
|
17048
|
+
for (const key in collection.properties) {
|
|
17049
|
+
const property = collection.properties[key];
|
|
17050
|
+
if (property.type === "array" && property.of && !Array.isArray(property.of) && property.of.type === "string" && property.of.admin?.urlPreview === "image") return key;
|
|
17051
|
+
}
|
|
17052
|
+
for (const key in collection.properties) {
|
|
17053
|
+
const property = collection.properties[key];
|
|
17054
|
+
if (property.type === "string" && property.storage && !property.storage.acceptedFiles) return key;
|
|
17055
|
+
}
|
|
17056
|
+
for (const key in collection.properties) {
|
|
17057
|
+
const property = collection.properties[key];
|
|
17058
|
+
if (property.type === "array" && !Array.isArray(property.of) && property.of?.type === "string" && property.of.storage && !property.of.storage.acceptedFiles) return key;
|
|
17059
|
+
}
|
|
17060
|
+
}
|
|
17061
|
+
//#endregion
|
|
17062
|
+
//#region src/collections/filter-operator-resolution.ts
|
|
17063
|
+
/**
|
|
17064
|
+
* Default operators offered per property type, before engine capabilities and
|
|
17065
|
+
* per-property narrowing are applied. These mirror what the built-in filter
|
|
17066
|
+
* fields can render.
|
|
17067
|
+
*/
|
|
17068
|
+
var COMPARISON_OPS = [
|
|
17069
|
+
"==",
|
|
17070
|
+
"!=",
|
|
17071
|
+
">",
|
|
17072
|
+
">=",
|
|
17073
|
+
"<",
|
|
17074
|
+
"<="
|
|
17075
|
+
];
|
|
17076
|
+
var NULL_CHECK_OPS = ["is-null", "is-not-null"];
|
|
17077
|
+
var MEMBERSHIP_OPS = ["in", "not-in"];
|
|
17078
|
+
var PATTERN_OPS = [
|
|
17079
|
+
"like",
|
|
17080
|
+
"ilike",
|
|
17081
|
+
"not-like",
|
|
17082
|
+
"not-ilike"
|
|
17083
|
+
];
|
|
17084
|
+
var DEFAULT_OPS_BY_TYPE = {
|
|
17085
|
+
string: [
|
|
17086
|
+
...COMPARISON_OPS,
|
|
17087
|
+
...MEMBERSHIP_OPS,
|
|
17088
|
+
...PATTERN_OPS,
|
|
17089
|
+
...NULL_CHECK_OPS
|
|
17090
|
+
],
|
|
17091
|
+
number: [
|
|
17092
|
+
...COMPARISON_OPS,
|
|
17093
|
+
...MEMBERSHIP_OPS,
|
|
17094
|
+
...NULL_CHECK_OPS
|
|
17095
|
+
],
|
|
17096
|
+
date: [...COMPARISON_OPS, ...NULL_CHECK_OPS],
|
|
17097
|
+
boolean: [
|
|
17098
|
+
"==",
|
|
17099
|
+
"!=",
|
|
17100
|
+
...NULL_CHECK_OPS
|
|
17101
|
+
],
|
|
17102
|
+
reference: [
|
|
17103
|
+
"==",
|
|
17104
|
+
"!=",
|
|
17105
|
+
...MEMBERSHIP_OPS,
|
|
17106
|
+
...NULL_CHECK_OPS
|
|
17107
|
+
],
|
|
17108
|
+
relation: [
|
|
17109
|
+
"==",
|
|
17110
|
+
"!=",
|
|
17111
|
+
...MEMBERSHIP_OPS,
|
|
17112
|
+
...NULL_CHECK_OPS
|
|
17113
|
+
]
|
|
17114
|
+
};
|
|
17115
|
+
/** Operators offered when the property is an *array of* a filterable type. */
|
|
17116
|
+
var ARRAY_OPS = ["array-contains", "array-contains-any"];
|
|
17117
|
+
/**
|
|
17118
|
+
* Resolve which filter operators the UI should offer for a property.
|
|
17119
|
+
*
|
|
17120
|
+
* The result is the **intersection** of three sets:
|
|
17121
|
+
* 1. what the engine can execute — {@link DataSourceCapabilities.filterOperators}
|
|
17122
|
+
* (e.g. Firestore cannot run the LIKE family);
|
|
17123
|
+
* 2. what makes sense for the property type (e.g. no `>` on booleans);
|
|
17124
|
+
* 3. the developer's optional narrowing — `property.admin.filterOperators`.
|
|
17125
|
+
*
|
|
17126
|
+
* Returns an empty array when the property is not filterable (either by
|
|
17127
|
+
* type, or because the developer disabled it with `filterOperators: []`).
|
|
17128
|
+
*
|
|
17129
|
+
* @group Models
|
|
17130
|
+
*/
|
|
17131
|
+
function resolveFilterOperators({ property, isArray, engine }) {
|
|
17132
|
+
const typeDefaults = isArray ? ARRAY_OPS : DEFAULT_OPS_BY_TYPE[property.type] ?? [];
|
|
17133
|
+
if (typeDefaults.length === 0) return [];
|
|
17134
|
+
const engineOps = new Set(getDataSourceCapabilities(engine).filterOperators ?? ALL_WHERE_FILTER_OPS);
|
|
17135
|
+
const narrowing = property.admin?.filterOperators;
|
|
17136
|
+
const narrowingSet = narrowing !== void 0 ? new Set(narrowing) : void 0;
|
|
17137
|
+
return typeDefaults.filter((op) => engineOps.has(op) && (narrowingSet === void 0 || narrowingSet.has(op)));
|
|
17138
|
+
}
|
|
17139
|
+
//#endregion
|
|
17140
|
+
//#region src/collections/navigation_utils.ts
|
|
17141
|
+
function removeInitialAndTrailingSlashes(s) {
|
|
17142
|
+
return removeInitialSlash(removeTrailingSlash(s));
|
|
17143
|
+
}
|
|
17144
|
+
function removeInitialSlash(s) {
|
|
17145
|
+
if (s.startsWith("/")) return s.slice(1);
|
|
17146
|
+
else return s;
|
|
17147
|
+
}
|
|
17148
|
+
function removeTrailingSlash(s) {
|
|
17149
|
+
if (s.endsWith("/")) return s.slice(0, -1);
|
|
17150
|
+
else return s;
|
|
17151
|
+
}
|
|
17152
|
+
function addInitialSlash(s) {
|
|
17153
|
+
if (s.startsWith("/")) return s;
|
|
17154
|
+
else return `/${s}`;
|
|
17155
|
+
}
|
|
17156
|
+
function getLastSegment(path) {
|
|
17157
|
+
const cleanPath = removeInitialAndTrailingSlashes(path);
|
|
17158
|
+
if (cleanPath.includes("/")) {
|
|
17159
|
+
const segments = cleanPath.split("/");
|
|
17160
|
+
return segments[segments.length - 1];
|
|
17161
|
+
}
|
|
17162
|
+
return cleanPath;
|
|
17163
|
+
}
|
|
17164
|
+
function resolveCollectionPathIds(path, allCollections) {
|
|
17165
|
+
let remainingPath = removeInitialAndTrailingSlashes(path);
|
|
17166
|
+
if (!remainingPath) return "";
|
|
17167
|
+
let currentCollections = allCollections;
|
|
17168
|
+
const resolvedPathParts = [];
|
|
17169
|
+
while (remainingPath.length > 0) {
|
|
17170
|
+
if (!currentCollections || currentCollections.length === 0) {
|
|
17171
|
+
console.warn(`resolveCollectionPathIds: Path structure implies subcollections, but none found before segment starting with "${remainingPath}" in original path "${path}". Appending remaining original path.`);
|
|
17172
|
+
resolvedPathParts.push(remainingPath);
|
|
17173
|
+
remainingPath = "";
|
|
17174
|
+
break;
|
|
17175
|
+
}
|
|
17176
|
+
let foundMatch = false;
|
|
17177
|
+
const potentialMatches = currentCollections.flatMap((col) => [{
|
|
17178
|
+
col,
|
|
17179
|
+
match: col.slug
|
|
17180
|
+
}]).filter((p) => p.match && remainingPath.startsWith(p.match)).sort((a, b) => b.match.length - a.match.length);
|
|
17181
|
+
if (potentialMatches.length > 0) {
|
|
17182
|
+
const { col: foundCollection, match: matchString } = potentialMatches[0];
|
|
17183
|
+
resolvedPathParts.push(foundCollection.slug);
|
|
17184
|
+
remainingPath = removeInitialSlash(remainingPath.substring(matchString.length));
|
|
17185
|
+
if (remainingPath.length === 0) {
|
|
17186
|
+
foundMatch = true;
|
|
17187
|
+
break;
|
|
17188
|
+
}
|
|
17189
|
+
const idSeparatorIndex = remainingPath.indexOf("/");
|
|
17190
|
+
let entityId;
|
|
17191
|
+
if (idSeparatorIndex > -1) {
|
|
17192
|
+
entityId = remainingPath.substring(0, idSeparatorIndex);
|
|
17193
|
+
remainingPath = remainingPath.substring(idSeparatorIndex + 1);
|
|
17194
|
+
} else {
|
|
17195
|
+
entityId = remainingPath;
|
|
17196
|
+
remainingPath = "";
|
|
17197
|
+
console.warn(`resolveCollectionPathIds: Path seems to end with a entity ID "${entityId}" instead of a collection segment in original path "${path}". This might indicate an invalid input path.`);
|
|
17198
|
+
}
|
|
17199
|
+
resolvedPathParts.push(entityId);
|
|
17200
|
+
currentCollections = getSubcollections(foundCollection);
|
|
17201
|
+
foundMatch = true;
|
|
17202
|
+
if (!currentCollections && remainingPath.length > 0) {
|
|
17203
|
+
console.warn(`resolveCollectionPathIds: Path continues after entity ID "${entityId}", but no subcollections are defined for the preceding collection "${foundCollection.slug}" in path "${path}". Appending remaining original path.`);
|
|
17204
|
+
resolvedPathParts.push(remainingPath);
|
|
17205
|
+
remainingPath = "";
|
|
17206
|
+
break;
|
|
17207
|
+
}
|
|
17208
|
+
}
|
|
17209
|
+
if (!foundMatch) {
|
|
17210
|
+
console.warn(`resolveCollectionPathIds: Collection definition not found for segment starting with "${remainingPath}" in original path "${path}". Appending remaining original path.`);
|
|
17211
|
+
resolvedPathParts.push(remainingPath);
|
|
17212
|
+
remainingPath = "";
|
|
17213
|
+
break;
|
|
17214
|
+
}
|
|
17215
|
+
}
|
|
17216
|
+
return resolvedPathParts.join("/");
|
|
17217
|
+
}
|
|
17218
|
+
/**
|
|
17219
|
+
* Find the corresponding view at any depth for a given path.
|
|
17220
|
+
* Note that path or segments of the paths can be collection aliases.
|
|
17221
|
+
* @param slugOrPath
|
|
17222
|
+
* @param collections
|
|
17223
|
+
*/
|
|
17224
|
+
function getCollectionBySlugWithin(slugOrPath, collections) {
|
|
17225
|
+
const subpaths = removeInitialAndTrailingSlashes(slugOrPath).split("/");
|
|
17226
|
+
if (subpaths.length % 2 === 0) throw Error(`getCollectionBySlug: Collection paths must have an odd number of segments: ${slugOrPath}`);
|
|
17227
|
+
const subpathCombinations = getCollectionPathsCombinations(subpaths);
|
|
17228
|
+
let result;
|
|
17229
|
+
for (let i = 0; i < subpathCombinations.length; i++) {
|
|
17230
|
+
const subpathCombination = subpathCombinations[i];
|
|
17231
|
+
const navigationEntry = collections && collections.sort((a, b) => (a.slug ?? "").localeCompare(b.slug ?? "")).find((entry) => entry.slug === subpathCombination);
|
|
17232
|
+
if (navigationEntry) {
|
|
17233
|
+
if (subpathCombination === slugOrPath) result = navigationEntry;
|
|
17234
|
+
else if (getSubcollections(navigationEntry).length > 0) {
|
|
17235
|
+
const newPath = slugOrPath.replace(subpathCombination, "").split("/").slice(2).join("/");
|
|
17236
|
+
if (newPath.length > 0) result = getCollectionBySlugWithin(newPath, getSubcollections(navigationEntry));
|
|
17237
|
+
}
|
|
17238
|
+
}
|
|
17239
|
+
if (result) break;
|
|
17240
|
+
}
|
|
17241
|
+
return result;
|
|
17242
|
+
}
|
|
17243
|
+
/**
|
|
17244
|
+
* Get the subcollection combinations from a path:
|
|
17245
|
+
* "sites/es/locales" => ["sites/es/locales", "sites"]
|
|
17246
|
+
* @param subpaths
|
|
17247
|
+
*/
|
|
17248
|
+
function getCollectionPathsCombinations(subpaths) {
|
|
17249
|
+
const entries = subpaths.length > 0 && subpaths.length % 2 === 0 ? subpaths.splice(0, subpaths.length - 1) : subpaths;
|
|
17250
|
+
const length = entries.length;
|
|
17251
|
+
const result = [];
|
|
17252
|
+
for (let i = length; i > 0; i = i - 2) result.push(entries.slice(0, i).join("/"));
|
|
17253
|
+
return result;
|
|
17254
|
+
}
|
|
17255
|
+
//#endregion
|
|
17256
|
+
//#region src/collections/navigation_from_path.ts
|
|
17257
|
+
function getNavigationEntriesFromPath(props) {
|
|
17258
|
+
const { path, collections = [], currentFullPath } = props;
|
|
17259
|
+
const subpathCombinations = getCollectionPathsCombinations(removeInitialAndTrailingSlashes(path).split("/"));
|
|
17260
|
+
const result = [];
|
|
17261
|
+
for (let i = 0; i < subpathCombinations.length; i++) {
|
|
17262
|
+
const subpathCombination = subpathCombinations[i];
|
|
17263
|
+
const collection = collections && collections.find((entry) => entry.slug === subpathCombination);
|
|
17264
|
+
if (collection) {
|
|
17265
|
+
const collectionPath = currentFullPath && currentFullPath.length > 0 ? currentFullPath + "/" + collection.slug : collection.slug;
|
|
17266
|
+
result.push({
|
|
17267
|
+
type: "collection",
|
|
17268
|
+
id: collection.slug,
|
|
17269
|
+
slug: collectionPath,
|
|
17270
|
+
path: collectionPath,
|
|
17271
|
+
collection
|
|
17272
|
+
});
|
|
17273
|
+
const restOfThePath = removeInitialAndTrailingSlashes(removeInitialAndTrailingSlashes(path).replace(subpathCombination, ""));
|
|
17274
|
+
const nextSegments = restOfThePath.length > 0 ? restOfThePath.split("/") : [];
|
|
17275
|
+
if (nextSegments.length > 0) {
|
|
17276
|
+
const entityId = nextSegments[0];
|
|
17277
|
+
const path = collectionPath + "/" + entityId;
|
|
17278
|
+
result.push({
|
|
17279
|
+
type: "entity",
|
|
17280
|
+
entityId,
|
|
17281
|
+
slug: collectionPath,
|
|
17282
|
+
path,
|
|
17283
|
+
parentCollection: collection
|
|
17284
|
+
});
|
|
17285
|
+
if (nextSegments.length > 1) {
|
|
17286
|
+
const newPath = nextSegments.slice(1).join("/");
|
|
17287
|
+
if (!collection) throw Error("collection not found resolving path: " + collection);
|
|
17288
|
+
const entityViews = collection.entityViews;
|
|
17289
|
+
const customView = entityViews && entityViews.map((entry) => resolveEntityView(entry, props.contextEntityViews)).filter((v) => v != null).find((entry) => entry.key === newPath);
|
|
17290
|
+
const subcollections = getSubcollections(collection);
|
|
17291
|
+
if (customView) result.push({
|
|
17292
|
+
type: "custom_view",
|
|
17293
|
+
slug: collectionPath,
|
|
17294
|
+
entityId,
|
|
17295
|
+
path: path + "/" + customView.key,
|
|
17296
|
+
view: customView
|
|
17297
|
+
});
|
|
17298
|
+
else if (subcollections) result.push(...getNavigationEntriesFromPath({
|
|
17299
|
+
path: newPath,
|
|
17300
|
+
collections: subcollections,
|
|
17301
|
+
currentFullPath: path,
|
|
17302
|
+
contextEntityViews: props.contextEntityViews
|
|
17303
|
+
}));
|
|
17304
|
+
}
|
|
17305
|
+
}
|
|
17306
|
+
break;
|
|
17307
|
+
}
|
|
17308
|
+
}
|
|
17309
|
+
return result;
|
|
17310
|
+
}
|
|
17311
|
+
function resolveEntityView(entityView, contextEntityViews) {
|
|
17312
|
+
if (typeof entityView === "string") return contextEntityViews?.find((entry) => entry.key === entityView);
|
|
17313
|
+
else return entityView;
|
|
17314
|
+
}
|
|
17315
|
+
//#endregion
|
|
17316
|
+
//#region src/collections/parent_references_from_path.ts
|
|
17317
|
+
function getParentReferencesFromPath(props) {
|
|
17318
|
+
const { path, collections = [], currentFullPath } = props;
|
|
17319
|
+
const subpathCombinations = getCollectionPathsCombinations(removeInitialAndTrailingSlashes(path).split("/"));
|
|
17320
|
+
const result = [];
|
|
17321
|
+
for (let i = 0; i < subpathCombinations.length; i++) {
|
|
17322
|
+
const subpathCombination = subpathCombinations[i];
|
|
17323
|
+
const collection = collections && collections.find((entry) => entry.slug === subpathCombination);
|
|
17324
|
+
if (collection) {
|
|
17325
|
+
const collectionPath = currentFullPath && currentFullPath.length > 0 ? currentFullPath + "/" + collection.slug : collection.slug;
|
|
17326
|
+
const restOfThePath = removeInitialAndTrailingSlashes(removeInitialAndTrailingSlashes(path).replace(subpathCombination, ""));
|
|
17327
|
+
const nextSegments = restOfThePath.length > 0 ? restOfThePath.split("/") : [];
|
|
17328
|
+
if (nextSegments.length > 0) {
|
|
17329
|
+
const entityId = nextSegments[0];
|
|
17330
|
+
const path = collectionPath + "/" + entityId;
|
|
17331
|
+
result.push(new EntityReference({
|
|
17332
|
+
id: entityId,
|
|
17333
|
+
path: collectionPath
|
|
17334
|
+
}));
|
|
17335
|
+
if (nextSegments.length > 1) {
|
|
17336
|
+
const newPath = nextSegments.slice(1).join("/");
|
|
17337
|
+
if (!collection) throw Error("collection not found resolving path: " + collection);
|
|
17338
|
+
if (getSubcollections(collection).length > 0) result.push(...getParentReferencesFromPath({
|
|
17339
|
+
path: newPath,
|
|
17340
|
+
collections: getSubcollections(collection),
|
|
17341
|
+
currentFullPath: path
|
|
17342
|
+
}));
|
|
17343
|
+
}
|
|
17344
|
+
}
|
|
17345
|
+
break;
|
|
17346
|
+
}
|
|
17347
|
+
}
|
|
17348
|
+
return result;
|
|
17349
|
+
}
|
|
17350
|
+
//#endregion
|
|
17351
|
+
//#region src/collections/property_presentation.ts
|
|
17352
|
+
function isReadOnly(property) {
|
|
17353
|
+
if (property.admin?.readOnly) return true;
|
|
17354
|
+
if (property.type === "date") {
|
|
17355
|
+
if (property.autoValue) return true;
|
|
17356
|
+
}
|
|
17357
|
+
if (property.type === "reference") return !property.path && !("Field" in (property.admin || {}) && property.admin?.Field);
|
|
17358
|
+
return false;
|
|
17359
|
+
}
|
|
17360
|
+
function isHidden(property) {
|
|
17361
|
+
return typeof property.admin?.disabled === "object" && Boolean(property.admin?.disabled.hidden);
|
|
17362
|
+
}
|
|
17363
|
+
function applyPropertyConditions(property, context) {
|
|
17364
|
+
const { conditions } = property;
|
|
17365
|
+
if (!conditions) return property;
|
|
17366
|
+
const result = { ...property };
|
|
17367
|
+
if (conditions.disabled) {
|
|
17368
|
+
if (evaluateCondition(conditions.disabled, context)) {
|
|
17369
|
+
result.admin = result.admin || {};
|
|
17370
|
+
result.admin.disabled = {
|
|
17371
|
+
clearOnDisabled: conditions.clearOnDisabled ?? false,
|
|
17372
|
+
disabledMessage: conditions.disabledMessage,
|
|
17373
|
+
hidden: false
|
|
17374
|
+
};
|
|
17375
|
+
}
|
|
17376
|
+
}
|
|
17377
|
+
if (conditions.hidden) {
|
|
17378
|
+
if (evaluateCondition(conditions.hidden, context)) {
|
|
17379
|
+
result.admin = result.admin || {};
|
|
17380
|
+
result.admin.disabled = {
|
|
17381
|
+
...typeof result.admin?.disabled === "object" ? result.admin.disabled : {},
|
|
17382
|
+
hidden: true,
|
|
17383
|
+
clearOnDisabled: conditions.clearOnDisabled ?? false
|
|
17384
|
+
};
|
|
17385
|
+
}
|
|
17386
|
+
}
|
|
17387
|
+
if (conditions.readOnly) {
|
|
17388
|
+
if (evaluateCondition(conditions.readOnly, context)) {
|
|
17389
|
+
result.admin = result.admin || {};
|
|
17390
|
+
result.admin.readOnly = true;
|
|
17391
|
+
}
|
|
17392
|
+
}
|
|
17393
|
+
if (conditions.required !== void 0) {
|
|
17394
|
+
const isRequired = evaluateCondition(conditions.required, context);
|
|
17395
|
+
result.validation = {
|
|
17396
|
+
...result.validation,
|
|
17397
|
+
required: isRequired,
|
|
17398
|
+
requiredMessage: conditions.requiredMessage
|
|
17399
|
+
};
|
|
17400
|
+
}
|
|
17401
|
+
if (context.isNew && conditions.defaultValue !== void 0) result.defaultValue = evaluateCondition(conditions.defaultValue, context);
|
|
17402
|
+
if ("enum" in result && result.enum && (conditions.enumConditions || conditions.allowedEnumValues || conditions.excludedEnumValues)) result.enum = applyEnumConditions(result.enum, conditions, context);
|
|
17403
|
+
if (result.type === "reference") {
|
|
17404
|
+
if (conditions.referencePath) result.path = evaluateCondition(conditions.referencePath, context);
|
|
17405
|
+
if (conditions.referenceFilter) result.fixedFilter = evaluateCondition(conditions.referenceFilter, context);
|
|
17406
|
+
}
|
|
17407
|
+
if (result.type === "array") {
|
|
17408
|
+
if (conditions.canAddElements !== void 0) result.canAddElements = evaluateCondition(conditions.canAddElements, context);
|
|
17409
|
+
if (conditions.sortable !== void 0) result.sortable = evaluateCondition(conditions.sortable, context);
|
|
17410
|
+
}
|
|
17411
|
+
return result;
|
|
17412
|
+
}
|
|
17413
|
+
/**
|
|
17414
|
+
* Convert an object with numeric keys back to an array.
|
|
17415
|
+
* Firestore stores arrays as {"0": "a", "1": "b"} to avoid nested arrays.
|
|
17416
|
+
*/
|
|
17417
|
+
function objectToArray(obj) {
|
|
17418
|
+
if (Array.isArray(obj)) return obj.map(String);
|
|
17419
|
+
if (obj && typeof obj === "object") {
|
|
17420
|
+
const keys = Object.keys(obj);
|
|
17421
|
+
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);
|
|
17422
|
+
}
|
|
17423
|
+
return [];
|
|
17424
|
+
}
|
|
17425
|
+
/**
|
|
17426
|
+
* Apply enum-specific conditions to filter and modify enum values.
|
|
17427
|
+
*/
|
|
17428
|
+
function applyEnumConditions(enumValues, conditions, context) {
|
|
17429
|
+
let result = [...enumValues];
|
|
17430
|
+
if (conditions.allowedEnumValues) {
|
|
17431
|
+
const allowedArray = objectToArray(evaluateCondition(conditions.allowedEnumValues, context));
|
|
17432
|
+
if (allowedArray.length > 0) result = result.filter((ev) => allowedArray.includes(String(ev.id)));
|
|
17433
|
+
}
|
|
17434
|
+
if (conditions.excludedEnumValues) {
|
|
17435
|
+
const excludedArray = objectToArray(evaluateCondition(conditions.excludedEnumValues, context));
|
|
17436
|
+
if (excludedArray.length > 0) result = result.filter((ev) => !excludedArray.includes(String(ev.id)));
|
|
17437
|
+
}
|
|
17438
|
+
if (conditions.enumConditions) result = result.map((ev) => {
|
|
17439
|
+
const evConditions = conditions.enumConditions?.[ev.id];
|
|
17440
|
+
if (!evConditions) return ev;
|
|
17441
|
+
if (evConditions.hidden && evaluateCondition(evConditions.hidden, context)) return null;
|
|
17442
|
+
if (evConditions.disabled && evaluateCondition(evConditions.disabled, context)) return {
|
|
17443
|
+
...ev,
|
|
17444
|
+
disabled: true
|
|
17445
|
+
};
|
|
17446
|
+
return ev;
|
|
17447
|
+
}).filter((ev) => ev !== null);
|
|
17448
|
+
return result;
|
|
17449
|
+
}
|
|
17450
|
+
//#endregion
|
|
17451
|
+
//#region src/collections/title-property.ts
|
|
17452
|
+
/**
|
|
17453
|
+
* How good a property is as the human-readable title of an entity.
|
|
17454
|
+
* Higher wins; ties are broken by declaration order.
|
|
17455
|
+
* `DISQUALIFIED` means the property can never be a title.
|
|
17456
|
+
*/
|
|
17457
|
+
var SCORE = {
|
|
17458
|
+
DISQUALIFIED: -1,
|
|
17459
|
+
/**
|
|
17460
|
+
* Points at another entity. Only readable once the target resolves, and it
|
|
17461
|
+
* renders as the raw key until then — last resort, for collections (like
|
|
17462
|
+
* junction tables) that hold no text of their own.
|
|
17463
|
+
*/
|
|
17464
|
+
REFERENCE: 5,
|
|
17465
|
+
RELATION: 10,
|
|
17466
|
+
/** A user picker: resolves to a person's name, like a relation does */
|
|
17467
|
+
USER: 10,
|
|
17468
|
+
/** Long form text — readable, but a description, not a name */
|
|
17469
|
+
LONG_TEXT: 20,
|
|
17470
|
+
/** A closed set of values: shared by many rows, so it identifies nothing */
|
|
17471
|
+
ENUM: 30,
|
|
17472
|
+
/** Identifying, but PII and usually secondary to a name */
|
|
17473
|
+
EMAIL: 45,
|
|
17474
|
+
/** Any plain, short, free text field */
|
|
17475
|
+
PLAIN_TEXT: 60,
|
|
17476
|
+
/** Free text whose name says it holds the entity's label */
|
|
17477
|
+
NAMED: 100
|
|
17478
|
+
};
|
|
17479
|
+
/**
|
|
17480
|
+
* Keys whose name states outright that the property is the entity label.
|
|
17481
|
+
* This is a *bonus* on top of the structural rules — never a requirement, and
|
|
17482
|
+
* never the mechanism that keeps identifiers out of the title slot.
|
|
17483
|
+
*/
|
|
17484
|
+
var TITLE_LIKE_KEYS = new Set([
|
|
17485
|
+
"name",
|
|
17486
|
+
"fullname",
|
|
17487
|
+
"displayname",
|
|
17488
|
+
"title",
|
|
17489
|
+
"label",
|
|
17490
|
+
"heading",
|
|
17491
|
+
"subject",
|
|
17492
|
+
"username",
|
|
17493
|
+
"nickname"
|
|
17494
|
+
]);
|
|
17495
|
+
function normalizeKey(key) {
|
|
17496
|
+
return key.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
17497
|
+
}
|
|
17498
|
+
function isHidden$1(property) {
|
|
17499
|
+
return Boolean(property.admin?.hideFromCollection);
|
|
17500
|
+
}
|
|
17501
|
+
/**
|
|
17502
|
+
* File-storage backed content (single image, array of images, generic upload…).
|
|
17503
|
+
* Rendered by the dedicated image slot, so never a title.
|
|
17504
|
+
*/
|
|
17505
|
+
function isStorageProperty(property) {
|
|
17506
|
+
if (property.type === "string" && (property.storage || property.admin?.urlPreview === "image")) return true;
|
|
17507
|
+
if (property.type === "array" && property.of && !Array.isArray(property.of)) {
|
|
17508
|
+
const inner = property.of;
|
|
17509
|
+
if (inner.type === "string" && (inner.storage || inner.admin?.urlPreview === "image")) return true;
|
|
17510
|
+
}
|
|
17511
|
+
return false;
|
|
17512
|
+
}
|
|
17513
|
+
/**
|
|
17514
|
+
* Every column on this collection that stores a foreign key: the `localKey` of
|
|
17515
|
+
* each owning relation (declared inline on a property or in `relations[]`), the
|
|
17516
|
+
* source column of a junction, and the key a many-to-many joins on.
|
|
17517
|
+
*
|
|
17518
|
+
* These hold another entity's id, so they must never fill the title slot even
|
|
17519
|
+
* though they are declared as plain strings.
|
|
17520
|
+
*/
|
|
17521
|
+
function getForeignKeyColumns(collection) {
|
|
17522
|
+
const keys = /* @__PURE__ */ new Set();
|
|
17523
|
+
const addRelationKeys = (relation) => {
|
|
17524
|
+
if (relation.localKey) keys.add(relation.localKey);
|
|
17525
|
+
if (relation.through?.sourceColumn) keys.add(relation.through.sourceColumn);
|
|
17526
|
+
const firstStep = relation.joinPath?.[0];
|
|
17527
|
+
if (firstStep) {
|
|
17528
|
+
const from = firstStep.on?.from;
|
|
17529
|
+
for (const column of Array.isArray(from) ? from : [from]) if (column) keys.add(column);
|
|
17530
|
+
}
|
|
17531
|
+
};
|
|
17532
|
+
for (const relation of collection.relations ?? []) addRelationKeys(relation);
|
|
17533
|
+
for (const [key, propertyRaw] of Object.entries(collection.properties ?? {})) {
|
|
17534
|
+
const property = propertyRaw;
|
|
17535
|
+
if (!property || isPropertyBuilder(property) || property.type !== "relation") continue;
|
|
17536
|
+
addRelationKeys(property);
|
|
17537
|
+
if (property.relation) addRelationKeys(property.relation);
|
|
17538
|
+
if ((property.cardinality ?? "one") === "one" && (property.direction ?? "owning") === "owning") keys.add(generateForeignKeyName(property.relationName || key));
|
|
17539
|
+
}
|
|
17540
|
+
return keys;
|
|
17541
|
+
}
|
|
17542
|
+
/**
|
|
17543
|
+
* True when the property is declared to hold an opaque identifier rather than
|
|
17544
|
+
* something a person reads: a primary key, a foreign key, a UUID column, or a
|
|
17545
|
+
* picker bound to an auth user id. Decided from the property *schema*, never
|
|
17546
|
+
* from the key name.
|
|
17547
|
+
*/
|
|
17548
|
+
function isIdentifierProperty(property, key, idKeys, foreignKeys) {
|
|
17549
|
+
if (idKeys.has(key)) return true;
|
|
17550
|
+
if (foreignKeys.has(key)) return true;
|
|
17551
|
+
if ("isId" in property && property.isId) return true;
|
|
17552
|
+
if (property.type === "string" && property.columnType === "uuid") return true;
|
|
17553
|
+
return false;
|
|
17554
|
+
}
|
|
17555
|
+
function scoreTitleCandidate(property, key, idKeys, foreignKeys) {
|
|
17556
|
+
if (isHidden$1(property)) return SCORE.DISQUALIFIED;
|
|
17557
|
+
if (isIdentifierProperty(property, key, idKeys, foreignKeys)) return SCORE.DISQUALIFIED;
|
|
17558
|
+
if (isStorageProperty(property)) return SCORE.DISQUALIFIED;
|
|
17559
|
+
if (property.type === "relation") return property.cardinality === "many" || property.relation?.cardinality === "many" ? SCORE.DISQUALIFIED : SCORE.RELATION;
|
|
17560
|
+
if (property.type === "reference") return SCORE.REFERENCE;
|
|
17561
|
+
if (property.type !== "string") return SCORE.DISQUALIFIED;
|
|
17562
|
+
if (property.userSelect) return SCORE.USER;
|
|
17563
|
+
if (property.enum) return SCORE.ENUM;
|
|
17564
|
+
if (property.admin?.multiline || property.admin?.markdown) return SCORE.LONG_TEXT;
|
|
17565
|
+
if (property.email) return SCORE.EMAIL;
|
|
17566
|
+
if (TITLE_LIKE_KEYS.has(normalizeKey(key))) return SCORE.NAMED;
|
|
17567
|
+
return SCORE.PLAIN_TEXT;
|
|
17568
|
+
}
|
|
17569
|
+
/**
|
|
17570
|
+
* All properties that could serve as the entity title, best first.
|
|
17571
|
+
*
|
|
17572
|
+
* Candidates are ranked from the property *schema* — identifiers (primary
|
|
17573
|
+
* keys, foreign keys, UUID columns, user pickers), images and hidden fields are
|
|
17574
|
+
* excluded structurally, so a collection whose id column is called something
|
|
17575
|
+
* other than `id` is handled the same as one where it isn't.
|
|
17576
|
+
*
|
|
17577
|
+
* When the collection declares `propertiesOrder` the developer has already
|
|
17578
|
+
* stated what comes first, so qualifying candidates keep that order; otherwise
|
|
17579
|
+
* they are ranked (a name beats a description beats a relation).
|
|
17580
|
+
*
|
|
17581
|
+
* @group Collections
|
|
17582
|
+
*/
|
|
17583
|
+
function getTitlePropertyCandidates(collection) {
|
|
17584
|
+
if (!collection.properties) return [];
|
|
17585
|
+
if (collection.titleProperty && collection.properties[collection.titleProperty]) return [collection.titleProperty];
|
|
17586
|
+
const idKeys = new Set(getPrimaryKeys(collection));
|
|
17587
|
+
const foreignKeys = getForeignKeyColumns(collection);
|
|
17588
|
+
const explicitOrder = collection.propertiesOrder;
|
|
17589
|
+
const order = explicitOrder ?? Object.keys(collection.properties);
|
|
17590
|
+
const scored = [];
|
|
17591
|
+
order.forEach((key, index) => {
|
|
17592
|
+
const property = collection.properties[key];
|
|
17593
|
+
if (!property || isPropertyBuilder(property)) return;
|
|
17594
|
+
const score = scoreTitleCandidate(property, key, idKeys, foreignKeys);
|
|
17595
|
+
if (score === SCORE.DISQUALIFIED) return;
|
|
17596
|
+
scored.push({
|
|
17597
|
+
key,
|
|
17598
|
+
score,
|
|
17599
|
+
index
|
|
17600
|
+
});
|
|
17601
|
+
});
|
|
17602
|
+
if (!explicitOrder) scored.sort((a, b) => b.score - a.score || a.index - b.index);
|
|
17603
|
+
return scored.map((candidate) => candidate.key);
|
|
17604
|
+
}
|
|
17605
|
+
/**
|
|
17606
|
+
* The property that should fill the title slot for a collection, ignoring any
|
|
17607
|
+
* concrete values. Prefer {@link getTitlePropertyKeyForValues} when an entity
|
|
17608
|
+
* is at hand — it can skip candidates that happen to be empty or to hold an id.
|
|
17609
|
+
*
|
|
17610
|
+
* @group Collections
|
|
17611
|
+
*/
|
|
17612
|
+
function getTitlePropertyKey(collection) {
|
|
17613
|
+
return getTitlePropertyCandidates(collection)[0];
|
|
17614
|
+
}
|
|
17615
|
+
var UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
17616
|
+
var LONG_HEX_REGEX = /^[0-9a-f]{24,}$/i;
|
|
17617
|
+
var CUID_REGEX = /^c[a-z0-9]{20,}$/i;
|
|
17618
|
+
/**
|
|
17619
|
+
* True when a value reads as a machine identifier (UUID, ObjectId/long hex,
|
|
17620
|
+
* cuid) rather than as something worth showing to a person.
|
|
17621
|
+
*
|
|
17622
|
+
* @group Collections
|
|
17623
|
+
*/
|
|
17624
|
+
function looksLikeIdentifierValue(value) {
|
|
17625
|
+
if (typeof value !== "string") return false;
|
|
17626
|
+
const trimmed = value.trim();
|
|
17627
|
+
return UUID_REGEX.test(trimmed) || LONG_HEX_REGEX.test(trimmed) || CUID_REGEX.test(trimmed);
|
|
17628
|
+
}
|
|
17629
|
+
/**
|
|
17630
|
+
* The title property for a concrete entity: the best-ranked candidate that
|
|
17631
|
+
* actually carries a readable value. Candidates that are empty, that repeat the
|
|
17632
|
+
* entity id, or that hold an opaque identifier are skipped, so a free-text
|
|
17633
|
+
* column that happens to store UUIDs never ends up as the title.
|
|
17634
|
+
*
|
|
17635
|
+
* Returns the top-ranked candidate when none of them has a usable value, so
|
|
17636
|
+
* callers can still render a placeholder for that property.
|
|
17637
|
+
*
|
|
17638
|
+
* @group Collections
|
|
17639
|
+
*/
|
|
17640
|
+
function getTitlePropertyKeyForValues(collection, values, entityId) {
|
|
17641
|
+
const candidates = getTitlePropertyCandidates(collection);
|
|
17642
|
+
if (!values || candidates.length === 0) return candidates[0];
|
|
17643
|
+
for (const key of candidates) {
|
|
17644
|
+
const value = values[key];
|
|
17645
|
+
if (value === void 0 || value === null || value === "") continue;
|
|
17646
|
+
if (typeof value === "string") {
|
|
17647
|
+
if (looksLikeIdentifierValue(value)) continue;
|
|
17648
|
+
if (entityId !== void 0 && value === String(entityId)) continue;
|
|
17649
|
+
}
|
|
17650
|
+
return key;
|
|
17651
|
+
}
|
|
17652
|
+
return candidates[0];
|
|
17653
|
+
}
|
|
17654
|
+
//#endregion
|
|
17655
|
+
export { ADDITIONAL_TAB_WIDTH, AIIcon, AIModifiedIndicator, AdminModeControllerContext, AdminModeControllerProvider, AnalyticsContext, ApiConfigProvider, AuthApiError, AuthControllerContext, CONTAINER_FULL_WIDTH, CollectionComponentOverrideProvider, CollectionResolverRegistrationContext, CollectionScopeContext, CollectionScopeProvider, ComponentOverrideContext, ConfirmationDialog, CrmDashboardDemo, CustomizationControllerContext, 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, STUDIO_NAVIGATION_GROUPS, SchemaDriftBanner, SchemaDriftProvider, SnackbarProvider, StorageSourceContext, StorageSourcesContext, StudioBridgeContext, StudioBridgeProvider, StudioBridgeRegistryContext, StudioBridgeRegistryProvider, UIReferenceView, UIStyleGuide, UnsavedChangesDialog, UserConfigurationPersistenceContext, UserDisplay, UserSelectPopover, UserSettingsView, addInitialSlash, applyPropertyConditions, buildCollapsedDefaults, buildEnumLabel, clearAuthConfigCache, clearFetchCache, createAuthConfigCache, createFormexStub, deleteEntityWithCallbacks, en, es, fetchAuthConfig, flattenKeys, getAdminSubcollections, getCollectionBySlugWithin, getCollectionPathsCombinations, getColorScheme, getColumnKeysForProperty, getEntityFromCache, getEntityFromMemoryCache, getEntityImagePreviewPropertyKey, getEntityPreviewKeys, getEntityTitlePropertyKey, getFormFieldKeys, getIcon, getLastSegment, getLocalChangesBackup, getNavigationEntriesFromPath, getParentReferencesFromPath, getRelationIncludeParams, getRowHeight, getSubcollectionColumnId, getTitlePropertyCandidates, getTitlePropertyKey, getTitlePropertyKeyForValues, iconsSearch, isEnumValueDisabled, isHidden, isReadOnly, isSchemaDriftError, looksLikeIdentifierValue, populateFetchCache, removeEntityFromCache, removeEntityFromMemoryCache, removeInitialAndTrailingSlashes, removeInitialSlash, removeTrailingSlash, resolveCollectionPathIds, resolveComponentRef, resolveDefaultSelectedView, resolveFilterOperators, saveEntityToCache, saveEntityToMemoryCache, saveEntityWithCallbacks, useAdminModeController, useAnalyticsController, 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, useStudioCollectionRegistry, useStudioNavigationState, useStudioSidePanelController, useStudioUrlController, useTranslation, useUnsavedChangesDialog, useUserConfigurationPersistence };
|
|
16978
17656
|
|
|
16979
17657
|
//# sourceMappingURL=index.es.js.map
|