@firecms/core 3.0.0-canary.210 → 3.0.0-canary.211
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/components/EntityJsonPreview.d.ts +3 -0
- package/dist/core/EntityEditView.d.ts +3 -1
- package/dist/index.es.js +105 -7
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +105 -8
- package/dist/index.umd.js.map +1 -1
- package/package.json +6 -5
- package/src/components/EntityJsonPreview.tsx +66 -0
- package/src/core/EntityEditView.tsx +30 -7
- package/src/internal/useBuildSideEntityController.tsx +2 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Entity, EntityCollection, EntityStatus, User } from "../types";
|
|
3
3
|
import { EntityFormProps } from "../form";
|
|
4
|
+
export declare const MAIN_TAB_VALUE = "__main_##Q$SC^#S6";
|
|
5
|
+
export declare const JSON_TAB_VALUE = "__json";
|
|
4
6
|
export type OnUpdateParams = {
|
|
5
7
|
entity: Entity<any>;
|
|
6
8
|
status: EntityStatus;
|
|
@@ -35,7 +37,7 @@ export interface EntityEditViewProps<M extends Record<string, any>> {
|
|
|
35
37
|
* an entity is opened.
|
|
36
38
|
*/
|
|
37
39
|
export declare function EntityEditView<M extends Record<string, any>, USER extends User>({ entityId, ...props }: EntityEditViewProps<M>): import("react/jsx-runtime").JSX.Element;
|
|
38
|
-
export declare function EntityEditViewInner<M extends Record<string, any>>({ path, entityId, selectedTab: selectedTabProp, collection, parentCollectionIds, onValuesModified, onSaved, onTabChange, entity, cachedDirtyValues, dataLoading, layout, barActions, status, setStatus, formProps
|
|
40
|
+
export declare function EntityEditViewInner<M extends Record<string, any>>({ path, entityId, selectedTab: selectedTabProp, collection, parentCollectionIds, onValuesModified, onSaved, onTabChange, entity, cachedDirtyValues, dataLoading, layout, barActions, status, setStatus, formProps }: EntityEditViewProps<M> & {
|
|
39
41
|
entity?: Entity<M>;
|
|
40
42
|
cachedDirtyValues?: Partial<M>;
|
|
41
43
|
dataLoading: boolean;
|
package/dist/index.es.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
|
2
2
|
import { c } from "react-compiler-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import React__default, { useRef, useEffect, useContext, useCallback, useMemo, useState, createElement, createRef, createContext, forwardRef, useLayoutEffect, useDeferredValue } from "react";
|
|
5
|
-
import { getColorSchemeForSeed, CHIP_COLORS, Tooltip, ErrorIcon, Typography, CircleIcon, FunctionsIcon, iconKeys, coolIconKeys, Icon, IconButton, ContentCopyIcon, OpenInNewIcon, DescriptionIcon, cls, Skeleton, Chip, defaultBorderMixin, KeyboardTabIcon, Checkbox, Markdown, TextareaAutosize, focusedDisabled, MultiSelect, MultiSelectItem, Select, SelectItem, BooleanSwitch, DateTimeField, paperMixin, EditIcon, DoNotDisturbOnIcon, Menu, MoreVertIcon, MenuItem, CircularProgress, SearchBar, Badge, ArrowUpwardIcon, Popover, FilterListIcon, Button, CenteredView, AssignmentIcon, Label, CloseIcon, TextField, BooleanSwitchWithLabel, useOutsideAlerter, Dialog, DialogTitle, DialogContent, DialogActions, FileCopyIcon, DeleteIcon, AddIcon, ExpandablePanel, ArrowForwardIcon, Card, cardMixin, cardClickableMixin, StarIcon, Collapse, Container, FilterListOffIcon, SearchIcon, LoadingButton, Avatar, DarkModeIcon, LightModeIcon, BrightnessMediumIcon, LogoutIcon, HandleIcon, RemoveIcon, KeyboardArrowUpIcon, KeyboardArrowDownIcon, debounce, Alert, CheckIcon, NotesIcon, InfoIcon, fieldBackgroundMixin, fieldBackgroundDisabledMixin, fieldBackgroundHoverMixin, ArrowDropDownIcon, ShortTextIcon, SubjectIcon, FormatQuoteIcon, HttpIcon, MailIcon, FlagIcon, ListIcon, ListAltIcon, NumbersIcon, FormatListNumberedIcon, UploadFileIcon, DriveFolderUploadIcon, LinkIcon, AddLinkIcon, ScheduleIcon, BallotIcon, RepeatIcon, ViewStreamIcon, Sheet, Tab, Tabs, OpenInFullIcon, MenuIcon, ChevronLeftIcon } from "@firecms/ui";
|
|
5
|
+
import { getColorSchemeForSeed, CHIP_COLORS, Tooltip, ErrorIcon, Typography, CircleIcon, FunctionsIcon, iconKeys, coolIconKeys, Icon, IconButton, ContentCopyIcon, OpenInNewIcon, DescriptionIcon, cls, Skeleton, Chip, defaultBorderMixin, KeyboardTabIcon, Checkbox, Markdown, TextareaAutosize, focusedDisabled, MultiSelect, MultiSelectItem, Select, SelectItem, BooleanSwitch, DateTimeField, paperMixin, EditIcon, DoNotDisturbOnIcon, Menu, MoreVertIcon, MenuItem, CircularProgress, SearchBar, Badge, ArrowUpwardIcon, Popover, FilterListIcon, Button, CenteredView, AssignmentIcon, Label, CloseIcon, TextField, BooleanSwitchWithLabel, useOutsideAlerter, Dialog, DialogTitle, DialogContent, DialogActions, FileCopyIcon, DeleteIcon, AddIcon, ExpandablePanel, ArrowForwardIcon, Card, cardMixin, cardClickableMixin, StarIcon, Collapse, Container, FilterListOffIcon, SearchIcon, LoadingButton, Avatar, DarkModeIcon, LightModeIcon, BrightnessMediumIcon, LogoutIcon, HandleIcon, RemoveIcon, KeyboardArrowUpIcon, KeyboardArrowDownIcon, debounce, Alert, CheckIcon, NotesIcon, InfoIcon, fieldBackgroundMixin, fieldBackgroundDisabledMixin, fieldBackgroundHoverMixin, ArrowDropDownIcon, ShortTextIcon, SubjectIcon, FormatQuoteIcon, HttpIcon, MailIcon, FlagIcon, ListIcon, ListAltIcon, NumbersIcon, FormatListNumberedIcon, UploadFileIcon, DriveFolderUploadIcon, LinkIcon, AddLinkIcon, ScheduleIcon, BallotIcon, RepeatIcon, ViewStreamIcon, Sheet, Tab, Tabs, CodeIcon, OpenInFullIcon, MenuIcon, ChevronLeftIcon } from "@firecms/ui";
|
|
6
6
|
import { SnackbarProvider as SnackbarProvider$1, useSnackbar } from "notistack";
|
|
7
7
|
import hash from "object-hash";
|
|
8
8
|
import { useCreateFormex, Formex, setIn, useFormex, getIn, Field } from "@firecms/formex";
|
|
@@ -13,6 +13,7 @@ import * as locales from "date-fns/locale";
|
|
|
13
13
|
import useMeasure from "react-use-measure";
|
|
14
14
|
import * as yup from "yup";
|
|
15
15
|
import { FixedSizeList } from "react-window";
|
|
16
|
+
import { themes, Highlight } from "prism-react-renderer";
|
|
16
17
|
import { useDropzone } from "react-dropzone";
|
|
17
18
|
import { DragDropContext, Droppable, Draggable } from "@hello-pangea/dnd";
|
|
18
19
|
import Resizer from "react-image-file-resizer";
|
|
@@ -21529,7 +21530,99 @@ function buildSideActions({
|
|
|
21529
21530
|
savingError && /* @__PURE__ */ jsx("div", { className: "text-right", children: /* @__PURE__ */ jsx(Typography, { color: "error", children: savingError.message }) })
|
|
21530
21531
|
] });
|
|
21531
21532
|
}
|
|
21532
|
-
|
|
21533
|
+
function EntityJsonPreview(t0) {
|
|
21534
|
+
const $ = c(9);
|
|
21535
|
+
const {
|
|
21536
|
+
values
|
|
21537
|
+
} = t0;
|
|
21538
|
+
let t1;
|
|
21539
|
+
if ($[0] !== values) {
|
|
21540
|
+
t1 = JSON.stringify(values, null, " ");
|
|
21541
|
+
$[0] = values;
|
|
21542
|
+
$[1] = t1;
|
|
21543
|
+
} else {
|
|
21544
|
+
t1 = $[1];
|
|
21545
|
+
}
|
|
21546
|
+
const code = t1;
|
|
21547
|
+
const {
|
|
21548
|
+
mode
|
|
21549
|
+
} = useModeController();
|
|
21550
|
+
const preRef = useRef(null);
|
|
21551
|
+
let t2;
|
|
21552
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
21553
|
+
t2 = (e) => {
|
|
21554
|
+
if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "a") {
|
|
21555
|
+
if (preRef.current) {
|
|
21556
|
+
e.preventDefault();
|
|
21557
|
+
e.stopPropagation();
|
|
21558
|
+
const selection = window.getSelection();
|
|
21559
|
+
const range = document.createRange();
|
|
21560
|
+
range.selectNodeContents(preRef.current);
|
|
21561
|
+
if (selection) {
|
|
21562
|
+
selection.removeAllRanges();
|
|
21563
|
+
selection.addRange(range);
|
|
21564
|
+
}
|
|
21565
|
+
}
|
|
21566
|
+
}
|
|
21567
|
+
};
|
|
21568
|
+
$[2] = t2;
|
|
21569
|
+
} else {
|
|
21570
|
+
t2 = $[2];
|
|
21571
|
+
}
|
|
21572
|
+
const handleGlobalKeyDown = t2;
|
|
21573
|
+
let t3;
|
|
21574
|
+
let t4;
|
|
21575
|
+
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
21576
|
+
t3 = () => {
|
|
21577
|
+
document.addEventListener("keydown", handleGlobalKeyDown);
|
|
21578
|
+
return () => {
|
|
21579
|
+
document.removeEventListener("keydown", handleGlobalKeyDown);
|
|
21580
|
+
};
|
|
21581
|
+
};
|
|
21582
|
+
t4 = [handleGlobalKeyDown];
|
|
21583
|
+
$[3] = t3;
|
|
21584
|
+
$[4] = t4;
|
|
21585
|
+
} else {
|
|
21586
|
+
t3 = $[3];
|
|
21587
|
+
t4 = $[4];
|
|
21588
|
+
}
|
|
21589
|
+
useEffect(t3, t4);
|
|
21590
|
+
const t5 = mode === "dark" ? themes.vsDark : themes.vsLight;
|
|
21591
|
+
let t6;
|
|
21592
|
+
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
21593
|
+
t6 = (t72) => {
|
|
21594
|
+
const {
|
|
21595
|
+
style,
|
|
21596
|
+
tokens,
|
|
21597
|
+
getLineProps,
|
|
21598
|
+
getTokenProps
|
|
21599
|
+
} = t72;
|
|
21600
|
+
return /* @__PURE__ */ jsx("pre", { ref: preRef, style: {
|
|
21601
|
+
...style,
|
|
21602
|
+
background: "inherit"
|
|
21603
|
+
}, className: "container mx-auto p-8 rounded text-sm", children: tokens.map((line, i) => /* @__PURE__ */ jsx("div", { ...getLineProps({
|
|
21604
|
+
line
|
|
21605
|
+
}), className: "text-wrap", children: line.map((token, key) => /* @__PURE__ */ jsx("span", { ...getTokenProps({
|
|
21606
|
+
token
|
|
21607
|
+
}), className: "word-break" }, key)) }, i)) });
|
|
21608
|
+
};
|
|
21609
|
+
$[5] = t6;
|
|
21610
|
+
} else {
|
|
21611
|
+
t6 = $[5];
|
|
21612
|
+
}
|
|
21613
|
+
let t7;
|
|
21614
|
+
if ($[6] !== code || $[7] !== t5) {
|
|
21615
|
+
t7 = /* @__PURE__ */ jsx(Highlight, { theme: t5, code, language: "json", children: t6 });
|
|
21616
|
+
$[6] = code;
|
|
21617
|
+
$[7] = t5;
|
|
21618
|
+
$[8] = t7;
|
|
21619
|
+
} else {
|
|
21620
|
+
t7 = $[8];
|
|
21621
|
+
}
|
|
21622
|
+
return t7;
|
|
21623
|
+
}
|
|
21624
|
+
const MAIN_TAB_VALUE = "__main_##Q$SC^#S6";
|
|
21625
|
+
const JSON_TAB_VALUE = "__json";
|
|
21533
21626
|
function EntityEditView(t0) {
|
|
21534
21627
|
const $ = c(28);
|
|
21535
21628
|
let entityId;
|
|
@@ -21691,7 +21784,8 @@ function EntityEditViewInner({
|
|
|
21691
21784
|
const subcollectionsCount = subcollections?.length ?? 0;
|
|
21692
21785
|
const customViews = collection.entityViews;
|
|
21693
21786
|
const customViewsCount = customViews?.length ?? 0;
|
|
21694
|
-
const
|
|
21787
|
+
const includeJsonView = true;
|
|
21788
|
+
const hasAdditionalViews = customViewsCount > 0 || subcollectionsCount > 0 || includeJsonView;
|
|
21695
21789
|
const {
|
|
21696
21790
|
resolvedEntityViews,
|
|
21697
21791
|
selectedEntityView,
|
|
@@ -21711,6 +21805,9 @@ function EntityEditViewInner({
|
|
|
21711
21805
|
}), role: "tabpanel", children: /* @__PURE__ */ jsx(ErrorBoundary, { children: formContext && /* @__PURE__ */ jsx(Builder, { collection, entity: usedEntity, modifiedValues: formContext.formex.values ?? usedEntity?.values, formContext }) }) }, `custom_view_${customView.key}`);
|
|
21712
21806
|
}).filter(Boolean);
|
|
21713
21807
|
const globalLoading = dataLoading && !usedEntity;
|
|
21808
|
+
const jsonView = /* @__PURE__ */ jsx("div", { className: cls("relative flex-1 h-full overflow-auto w-full", {
|
|
21809
|
+
"hidden": selectedTab !== JSON_TAB_VALUE
|
|
21810
|
+
}), role: "tabpanel", children: /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsx(EntityJsonPreview, { values: formContext?.values ?? {} }) }) }, "json_view");
|
|
21714
21811
|
const subCollectionsViews = subcollections && subcollections.map((subcollection) => {
|
|
21715
21812
|
const subcollectionId = subcollection.id ?? subcollection.path;
|
|
21716
21813
|
const fullPath = usedEntity ? `${path}/${usedEntity?.id}/${removeInitialAndTrailingSlashes(subcollectionId)}` : void 0;
|
|
@@ -21750,21 +21847,22 @@ function EntityEditViewInner({
|
|
|
21750
21847
|
}, Builder: selectedSecondaryForm?.Builder });
|
|
21751
21848
|
const subcollectionTabs = subcollections && subcollections.map((subcollection_0) => /* @__PURE__ */ jsx(Tab, { className: "text-sm min-w-[120px]", value: subcollection_0.id, children: subcollection_0.name }, `entity_detail_collection_tab_${subcollection_0.name}`));
|
|
21752
21849
|
const customViewTabs = resolvedEntityViews.map((view) => /* @__PURE__ */ jsx(Tab, { className: "text-sm min-w-[120px]", value: view.key, children: view.name }, `entity_detail_collection_tab_${view.name}`));
|
|
21753
|
-
const shouldShowTopBar = Boolean(barActions) || hasAdditionalViews;
|
|
21754
21850
|
let result = /* @__PURE__ */ jsxs("div", { className: "relative flex flex-col h-full w-full bg-white dark:bg-surface-900", children: [
|
|
21755
|
-
|
|
21851
|
+
/* @__PURE__ */ jsxs("div", { className: cls("h-14 flex overflow-visible overflow-x-scroll w-full no-scrollbar h-14 border-b pl-2 pr-2 pt-1 flex items-end bg-surface-50 dark:bg-surface-900", defaultBorderMixin), children: [
|
|
21756
21852
|
barActions,
|
|
21757
21853
|
/* @__PURE__ */ jsx("div", { className: "flex-grow" }),
|
|
21758
21854
|
globalLoading && /* @__PURE__ */ jsx("div", { className: "self-center", children: /* @__PURE__ */ jsx(CircularProgress, { size: "small" }) }),
|
|
21759
|
-
|
|
21855
|
+
/* @__PURE__ */ jsxs(Tabs, { value: selectedTab, onValueChange: (value_0) => {
|
|
21760
21856
|
onSideTabClick(value_0);
|
|
21761
21857
|
}, children: [
|
|
21858
|
+
/* @__PURE__ */ jsx(Tab, { disabled: !hasAdditionalViews, value: JSON_TAB_VALUE, innerClassName: "block", className: "text-sm", children: /* @__PURE__ */ jsx(CodeIcon, { size: "small" }) }),
|
|
21762
21859
|
/* @__PURE__ */ jsx(Tab, { disabled: !hasAdditionalViews, value: MAIN_TAB_VALUE, className: "text-sm min-w-[120px]", children: collection.singularName ?? collection.name }),
|
|
21763
21860
|
customViewTabs,
|
|
21764
21861
|
subcollectionTabs
|
|
21765
21862
|
] })
|
|
21766
21863
|
] }),
|
|
21767
21864
|
globalLoading ? /* @__PURE__ */ jsx("div", { className: "w-full pt-12 pb-16 px-4 sm:px-8 md:px-10", children: /* @__PURE__ */ jsx(CircularProgressCenter, {}) }) : entityView,
|
|
21865
|
+
jsonView,
|
|
21768
21866
|
customViewsView,
|
|
21769
21867
|
subCollectionsViews
|
|
21770
21868
|
] });
|
|
@@ -21880,7 +21978,7 @@ function getEntityViewWidth(props, small, customizationController) {
|
|
|
21880
21978
|
const {
|
|
21881
21979
|
selectedSecondaryForm
|
|
21882
21980
|
} = resolvedSelectedEntityView(props.collection?.entityViews, customizationController, props.selectedTab);
|
|
21883
|
-
const shouldUseSmallLayout = !props.selectedTab || Boolean(selectedSecondaryForm);
|
|
21981
|
+
const shouldUseSmallLayout = !props.selectedTab || props.selectedTab === JSON_TAB_VALUE || Boolean(selectedSecondaryForm);
|
|
21884
21982
|
let resolvedWidth;
|
|
21885
21983
|
if (props.width) {
|
|
21886
21984
|
resolvedWidth = typeof props.width === "number" ? `${props.width}px` : props.width;
|