@rebasepro/cms 0.21.2-canary.g1ea48be → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{CollectionEditorDialog-B1mG1cfx.js → CollectionEditorDialog-DLHCka00.js} +103 -58
- package/dist/CollectionEditorDialog-DLHCka00.js.map +1 -0
- package/dist/{PropertyEditView-gKNUHxLY.js → PropertyEditView-_pu5hzZn.js} +53 -21
- package/dist/PropertyEditView-_pu5hzZn.js.map +1 -0
- package/dist/{RouterCollectionsStudioView-qgDWC6E2.js → RouterCollectionsStudioView-ChPNl_uU.js} +34 -10
- package/dist/RouterCollectionsStudioView-ChPNl_uU.js.map +1 -0
- package/dist/collection_editor/_cms_internals.d.ts +1 -0
- package/dist/collection_editor/relation_kinds.d.ts +11 -0
- package/dist/collection_editor/ui/collection_editor/CollectionStudioView.d.ts +8 -1
- package/dist/collection_editor_ui.js +4 -4
- package/dist/components/CollectionTableBinding/fields/CompactEntityCellField.d.ts +12 -13
- package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.d.ts +6 -3
- package/dist/components/CollectionTableBinding/fields/TableReferenceField.d.ts +8 -1
- package/dist/components/CollectionTableBinding/fields/TableRelationField.d.ts +8 -1
- package/dist/components/CollectionTableBinding/fields/TableRelationSelectorField.d.ts +13 -3
- package/dist/components/CollectionTableBinding/fields/VirtualTableSelect.d.ts +10 -0
- package/dist/components/CollectionTableBinding/fields/VirtualTableUserSelect.d.ts +10 -0
- package/dist/components/CollectionTableBinding/internal/EntityTableCell.d.ts +21 -0
- package/dist/components/CollectionTableBinding/internal/TableCellOpener.d.ts +45 -0
- package/dist/components/CollectionTableBinding/table_bindings.d.ts +24 -0
- package/dist/components/CollectionViewBinding/CollectionViewBinding.d.ts +7 -1
- package/dist/components/EntityPreviewBinding.d.ts +8 -1
- package/dist/components/EntityPreviewNesting.d.ts +15 -0
- package/dist/components/PickerTrigger.d.ts +17 -0
- package/dist/components/ReferenceTable/SelectionTableBinding.d.ts +12 -0
- package/dist/components/RelationSelector.d.ts +24 -7
- package/dist/components/UserSelector.d.ts +8 -1
- package/dist/data_export/export/additional_fields.d.ts +13 -0
- package/dist/data_export/export/export.d.ts +6 -0
- package/dist/data_import/utils/csv.d.ts +3 -2
- package/dist/data_import/utils/id_column.d.ts +16 -0
- package/dist/editor.js +1 -1
- package/dist/{export-DIyk1720.js → export-4bJWdlDK.js} +63 -209
- package/dist/export-4bJWdlDK.js.map +1 -0
- package/dist/form/form_utils.d.ts +13 -0
- package/dist/form/validation.d.ts +13 -0
- package/dist/{history-CrZEzQ5b.js → history-BElrZ5Rw.js} +2 -2
- package/dist/{history-CrZEzQ5b.js.map → history-BElrZ5Rw.js.map} +1 -1
- package/dist/hooks/useEntityDisplay.d.ts +4 -5
- package/dist/{import-ByaJMZuT.js → import-TCgkTVlS.js} +3 -4
- package/dist/import-TCgkTVlS.js.map +1 -0
- package/dist/index.js +16 -10
- package/dist/index.js.map +1 -1
- package/dist/preview/util.d.ts +25 -0
- package/dist/util/navigation_utils.d.ts +14 -2
- package/dist/util/view_mode.d.ts +12 -18
- package/dist/{util-DB31IoJE.js → util-CC0ozHoD.js} +35 -2
- package/dist/util-CC0ozHoD.js.map +1 -0
- package/dist/{util-qfCPxJzB.js → util-DybQBkug.js} +1482 -717
- package/dist/util-DybQBkug.js.map +1 -0
- package/package.json +9 -9
- package/dist/CollectionEditorDialog-B1mG1cfx.js.map +0 -1
- package/dist/PropertyEditView-gKNUHxLY.js.map +0 -1
- package/dist/RouterCollectionsStudioView-qgDWC6E2.js.map +0 -1
- package/dist/export-DIyk1720.js.map +0 -1
- package/dist/import-ByaJMZuT.js.map +0 -1
- package/dist/util-DB31IoJE.js.map +0 -1
- package/dist/util-qfCPxJzB.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
|
|
2
|
-
import {
|
|
2
|
+
import { $t as PropertyConfigBadge, A as getFieldId, E as DEFAULT_FIELD_CONFIGS, Qt as ArrayContainer, a as namespaceToPropertiesPath, ct as useSafeSnackbarController, g as toSerializableProperty, i as namespaceToPropertiesOrderPath, k as getFieldConfig, m as toSerializableCollectionConfig, n as getFullIdPath, r as idToPropertiesPath, t as getFullId, tn as FieldCaption, ur as useCollectionRegistryController } from "./util-DybQBkug.js";
|
|
3
3
|
import React, { createContext, useCallback, useContext, useDeferredValue, useEffect, useMemo, useRef, useState } from "react";
|
|
4
4
|
import { deepEqual } from "fast-equals";
|
|
5
5
|
import { AlertTriangleIcon, ArrowDownToLineIcon, ArrowUpToLineIcon, Badge, BooleanSwitchWithLabel, Button, Card, CheckSquareIcon, CircularProgress, DebouncedTextField, Dialog, DialogActions, DialogContent, DialogTitle, ErrorBoundary, ExpandablePanel, FileSearchIcon, FunctionSquareIcon, IconButton, InfoLabel, ListIcon, Menu, MenuItem, MinusCircleIcon, MoreVerticalIcon, MultiSelect, MultiSelectItem, Paper, PlusIcon, RefreshCcwIcon, Select, SelectItem, SettingsIcon, TextField, Tooltip, Trash2Icon, Typography, UploadCloudIcon, cls, defaultBorderMixin, iconSize } from "@rebasepro/ui";
|
|
@@ -1448,7 +1448,7 @@ var CommonPropertyFields = React.forwardRef(function CommonPropertyFields({ show
|
|
|
1448
1448
|
const name = "name";
|
|
1449
1449
|
const nameError = showErrors && getIn(errors, name);
|
|
1450
1450
|
const id = "id";
|
|
1451
|
-
const idError = showErrors && getIn(errors, id);
|
|
1451
|
+
const idError = (showErrors || Boolean(getIn(touched, id))) && getIn(errors, id);
|
|
1452
1452
|
const description = "description";
|
|
1453
1453
|
const descriptionError = showErrors && getIn(errors, description);
|
|
1454
1454
|
return /* @__PURE__ */ jsxs("div", {
|
|
@@ -2542,6 +2542,35 @@ var kindUsesLocalKey = (kind) => kind === "belongsTo";
|
|
|
2542
2542
|
var kindUsesForeignKeyOnTarget = (kind) => kind === "hasOne" || kind === "hasMany";
|
|
2543
2543
|
var kindUsesThrough = (kind) => kind === "manyToMany";
|
|
2544
2544
|
var kindUsesJoinPath = (kind) => kind === "via";
|
|
2545
|
+
/**
|
|
2546
|
+
* The link fields each kind owns — the only ones a relation of that kind may
|
|
2547
|
+
* carry. The same table the boot validator checks a relation against.
|
|
2548
|
+
*/
|
|
2549
|
+
var LINK_FIELDS_BY_KIND = {
|
|
2550
|
+
belongsTo: ["localKey"],
|
|
2551
|
+
hasOne: ["foreignKeyOnTarget", "sourceKey"],
|
|
2552
|
+
hasMany: ["foreignKeyOnTarget", "sourceKey"],
|
|
2553
|
+
manyToMany: ["through"],
|
|
2554
|
+
via: ["joinPath", "cardinality"]
|
|
2555
|
+
};
|
|
2556
|
+
var LINK_FIELDS = new Set(Object.values(LINK_FIELDS_BY_KIND).flat());
|
|
2557
|
+
/**
|
|
2558
|
+
* `relation` switched to `kind`, without the link fields its old kind owned.
|
|
2559
|
+
*
|
|
2560
|
+
* Switching kind in the property form used to set `kind` and nothing else, so
|
|
2561
|
+
* a junction table filled in before switching to "Belongs to" stayed on the
|
|
2562
|
+
* relation — `through` on a `belongsTo` — and a `localKey` rode along into a
|
|
2563
|
+
* `hasMany`. The boot validator refuses both, and every collection in the
|
|
2564
|
+
* directory stops loading. The name, the target and the referential actions
|
|
2565
|
+
* belong to every kind and are kept.
|
|
2566
|
+
*/
|
|
2567
|
+
function relationWithKind(relation, kind) {
|
|
2568
|
+
const owned = LINK_FIELDS_BY_KIND[kind];
|
|
2569
|
+
return {
|
|
2570
|
+
...Object.fromEntries(Object.entries(relation).filter(([key]) => !LINK_FIELDS.has(key) || owned.includes(key))),
|
|
2571
|
+
kind
|
|
2572
|
+
};
|
|
2573
|
+
}
|
|
2545
2574
|
//#endregion
|
|
2546
2575
|
//#region src/collection_editor/ui/collection_editor/properties/RelationPropertyField.tsx
|
|
2547
2576
|
var ON_ACTION_OPTIONS = [
|
|
@@ -2588,17 +2617,17 @@ function RelationPropertyField({ disabled, showErrors }) {
|
|
|
2588
2617
|
const showLocalKey = kindUsesLocalKey(kind);
|
|
2589
2618
|
const showForeignKey = kindUsesForeignKeyOnTarget(kind);
|
|
2590
2619
|
const showJoinPath = kindUsesJoinPath(kind);
|
|
2620
|
+
const setLinkField = useCallback((field, value) => setFieldValue(`relation.${field}`, value === "" ? void 0 : value), [setFieldValue]);
|
|
2591
2621
|
const updateThrough = useCallback((patch) => {
|
|
2592
|
-
const
|
|
2593
|
-
|
|
2594
|
-
sourceColumn: "",
|
|
2595
|
-
targetColumn: ""
|
|
2596
|
-
};
|
|
2597
|
-
setFieldValue("relation.through", {
|
|
2598
|
-
...currentThrough,
|
|
2622
|
+
const next = Object.fromEntries(Object.entries({
|
|
2623
|
+
...link.through ?? {},
|
|
2599
2624
|
...patch
|
|
2600
|
-
});
|
|
2625
|
+
}).filter(([, value]) => value !== "" && value !== void 0));
|
|
2626
|
+
setFieldValue("relation.through", Object.keys(next).length > 0 ? next : void 0);
|
|
2601
2627
|
}, [link.through, setFieldValue]);
|
|
2628
|
+
useEffect(() => {
|
|
2629
|
+
if (!values.relation?.kind) setFieldValue("relation.kind", "belongsTo");
|
|
2630
|
+
}, [values.relation?.kind, setFieldValue]);
|
|
2602
2631
|
useEffect(() => {
|
|
2603
2632
|
if (targetSlug && !relationName) setFieldValue("relation.relationName", targetSlug);
|
|
2604
2633
|
}, [
|
|
@@ -2641,7 +2670,7 @@ function RelationPropertyField({ disabled, showErrors }) {
|
|
|
2641
2670
|
className: "col-span-12",
|
|
2642
2671
|
children: [/* @__PURE__ */ jsx(Select, {
|
|
2643
2672
|
value: kind,
|
|
2644
|
-
onValueChange: (v) => setFieldValue("relation
|
|
2673
|
+
onValueChange: (v) => setFieldValue("relation", relationWithKind(link, v)),
|
|
2645
2674
|
label: "Kind",
|
|
2646
2675
|
disabled,
|
|
2647
2676
|
fullWidth: true,
|
|
@@ -2663,7 +2692,7 @@ function RelationPropertyField({ disabled, showErrors }) {
|
|
|
2663
2692
|
className: "col-span-12",
|
|
2664
2693
|
children: [/* @__PURE__ */ jsx(TextField, {
|
|
2665
2694
|
value: localKey,
|
|
2666
|
-
onChange: (e) =>
|
|
2695
|
+
onChange: (e) => setLinkField("localKey", e.target.value),
|
|
2667
2696
|
label: "Local key (foreign key column on this table)",
|
|
2668
2697
|
disabled,
|
|
2669
2698
|
placeholder: "e.g. author_id"
|
|
@@ -2674,7 +2703,7 @@ function RelationPropertyField({ disabled, showErrors }) {
|
|
|
2674
2703
|
children: [
|
|
2675
2704
|
/* @__PURE__ */ jsx(TextField, {
|
|
2676
2705
|
value: foreignKeyOnTarget,
|
|
2677
|
-
onChange: (e) =>
|
|
2706
|
+
onChange: (e) => setLinkField("foreignKeyOnTarget", e.target.value),
|
|
2678
2707
|
label: "Foreign key on target table",
|
|
2679
2708
|
disabled,
|
|
2680
2709
|
placeholder: "e.g. post_id"
|
|
@@ -2683,7 +2712,7 @@ function RelationPropertyField({ disabled, showErrors }) {
|
|
|
2683
2712
|
/* @__PURE__ */ jsx(TextField, {
|
|
2684
2713
|
className: "mt-4",
|
|
2685
2714
|
value: sourceKey,
|
|
2686
|
-
onChange: (e) =>
|
|
2715
|
+
onChange: (e) => setLinkField("sourceKey", e.target.value),
|
|
2687
2716
|
label: "Source key (optional)",
|
|
2688
2717
|
disabled,
|
|
2689
2718
|
placeholder: "defaults to this table's primary key"
|
|
@@ -2948,12 +2977,14 @@ function updatePropertyFromWidget(propertyData, selectedWidgetId, propertyConfig
|
|
|
2948
2977
|
propertyConfig: "date_time",
|
|
2949
2978
|
mode: "date_time"
|
|
2950
2979
|
});
|
|
2951
|
-
else if (selectedWidgetId === "relation")
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2980
|
+
else if (selectedWidgetId === "relation") {
|
|
2981
|
+
const { relationName: _misplaced, ...rest } = propertyData ?? {};
|
|
2982
|
+
updatedProperty = mergeDeep(rest, {
|
|
2983
|
+
type: "relation",
|
|
2984
|
+
propertyConfig: "relation",
|
|
2985
|
+
relation: { kind: propertyData?.relation?.kind ?? "belongsTo" }
|
|
2986
|
+
});
|
|
2987
|
+
} else if (selectedWidgetId === "repeat") updatedProperty = mergeDeep(propertyData, {
|
|
2957
2988
|
type: "array",
|
|
2958
2989
|
propertyConfig: "repeat"
|
|
2959
2990
|
});
|
|
@@ -3211,6 +3242,7 @@ var PropertyForm = React.memo(function PropertyForm(props) {
|
|
|
3211
3242
|
property
|
|
3212
3243
|
} : void 0);
|
|
3213
3244
|
const doOnPropertyChanged = ({ id, property }) => {
|
|
3245
|
+
if (includeIdAndName && id !== lastSubmittedProperty.current?.id && validateId(id, existingPropertyKeys)) return;
|
|
3214
3246
|
const params = {
|
|
3215
3247
|
id,
|
|
3216
3248
|
previousId: lastSubmittedProperty.current?.id,
|
|
@@ -3802,4 +3834,4 @@ function WidgetSelectViewItem({ onClick, initialProperty, propertyConfig, existi
|
|
|
3802
3834
|
//#endregion
|
|
3803
3835
|
export { updatePropertyFromWidget as a, useAIModifiedPaths as c, supportedFields as i, PropertyForm as n, PropertyTree as o, PropertyFormDialog as r, AIModifiedPathsProvider as s, PropertyEditView_exports as t };
|
|
3804
3836
|
|
|
3805
|
-
//# sourceMappingURL=PropertyEditView-
|
|
3837
|
+
//# sourceMappingURL=PropertyEditView-_pu5hzZn.js.map
|