@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/index.umd.js CHANGED
@@ -1,6 +1,6 @@
1
1
  (function(global, factory) {
2
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react/jsx-runtime"), require("react-compiler-runtime"), require("react"), require("@firecms/ui"), require("notistack"), require("object-hash"), require("@firecms/formex"), require("react-fast-compare"), require("react-router-dom"), require("date-fns"), require("date-fns/locale"), require("react-use-measure"), require("yup"), require("react-window"), require("react-dropzone"), require("@hello-pangea/dnd"), require("react-image-file-resizer"), require("fuse.js"), require("@firecms/editor"), require("@radix-ui/react-portal"), require("react-router")) : typeof define === "function" && define.amd ? define(["exports", "react/jsx-runtime", "react-compiler-runtime", "react", "@firecms/ui", "notistack", "object-hash", "@firecms/formex", "react-fast-compare", "react-router-dom", "date-fns", "date-fns/locale", "react-use-measure", "yup", "react-window", "react-dropzone", "@hello-pangea/dnd", "react-image-file-resizer", "fuse.js", "@firecms/editor", "@radix-ui/react-portal", "react-router"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["FireCMS Core"] = {}, global.jsxRuntime, global.reactCompilerRuntime, global.React, global.ui, global.notistack, global.hash, global.formex, global.equal, global.reactRouterDom, global.dateFns, global.locales, global.useMeasure, global.yup, global.reactWindow, global.reactDropzone, global.dnd, global.Resizer, global.Fuse, global.editor, global.Portal, global.reactRouter));
3
- })(this, function(exports2, jsxRuntime, reactCompilerRuntime, React, ui, notistack, hash, formex, equal, reactRouterDom, dateFns, locales, useMeasure, yup, reactWindow, reactDropzone, dnd, Resizer, Fuse, editor, Portal, reactRouter) {
2
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react/jsx-runtime"), require("react-compiler-runtime"), require("react"), require("@firecms/ui"), require("notistack"), require("object-hash"), require("@firecms/formex"), require("react-fast-compare"), require("react-router-dom"), require("date-fns"), require("date-fns/locale"), require("react-use-measure"), require("yup"), require("react-window"), require("prism-react-renderer"), require("react-dropzone"), require("@hello-pangea/dnd"), require("react-image-file-resizer"), require("fuse.js"), require("@firecms/editor"), require("@radix-ui/react-portal"), require("react-router")) : typeof define === "function" && define.amd ? define(["exports", "react/jsx-runtime", "react-compiler-runtime", "react", "@firecms/ui", "notistack", "object-hash", "@firecms/formex", "react-fast-compare", "react-router-dom", "date-fns", "date-fns/locale", "react-use-measure", "yup", "react-window", "prism-react-renderer", "react-dropzone", "@hello-pangea/dnd", "react-image-file-resizer", "fuse.js", "@firecms/editor", "@radix-ui/react-portal", "react-router"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["FireCMS Core"] = {}, global.jsxRuntime, global.reactCompilerRuntime, global.React, global.ui, global.notistack, global.hash, global.formex, global.equal, global.reactRouterDom, global.dateFns, global.locales, global.useMeasure, global.yup, global.reactWindow, global.prismReactRenderer, global.reactDropzone, global.dnd, global.Resizer, global.Fuse, global.editor, global.Portal, global.reactRouter));
3
+ })(this, function(exports2, jsxRuntime, reactCompilerRuntime, React, ui, notistack, hash, formex, equal, reactRouterDom, dateFns, locales, useMeasure, yup, reactWindow, prismReactRenderer, reactDropzone, dnd, Resizer, Fuse, editor, Portal, reactRouter) {
4
4
  "use strict";
5
5
  function _interopNamespaceDefault(e) {
6
6
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
@@ -21531,7 +21531,99 @@
21531
21531
  savingError && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-right", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Typography, { color: "error", children: savingError.message }) })
21532
21532
  ] });
21533
21533
  }
21534
- const MAIN_TAB_VALUE = "main_##Q$SC^#S6";
21534
+ function EntityJsonPreview(t0) {
21535
+ const $ = reactCompilerRuntime.c(9);
21536
+ const {
21537
+ values
21538
+ } = t0;
21539
+ let t1;
21540
+ if ($[0] !== values) {
21541
+ t1 = JSON.stringify(values, null, " ");
21542
+ $[0] = values;
21543
+ $[1] = t1;
21544
+ } else {
21545
+ t1 = $[1];
21546
+ }
21547
+ const code = t1;
21548
+ const {
21549
+ mode
21550
+ } = useModeController();
21551
+ const preRef = React.useRef(null);
21552
+ let t2;
21553
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
21554
+ t2 = (e) => {
21555
+ if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "a") {
21556
+ if (preRef.current) {
21557
+ e.preventDefault();
21558
+ e.stopPropagation();
21559
+ const selection = window.getSelection();
21560
+ const range = document.createRange();
21561
+ range.selectNodeContents(preRef.current);
21562
+ if (selection) {
21563
+ selection.removeAllRanges();
21564
+ selection.addRange(range);
21565
+ }
21566
+ }
21567
+ }
21568
+ };
21569
+ $[2] = t2;
21570
+ } else {
21571
+ t2 = $[2];
21572
+ }
21573
+ const handleGlobalKeyDown = t2;
21574
+ let t3;
21575
+ let t4;
21576
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
21577
+ t3 = () => {
21578
+ document.addEventListener("keydown", handleGlobalKeyDown);
21579
+ return () => {
21580
+ document.removeEventListener("keydown", handleGlobalKeyDown);
21581
+ };
21582
+ };
21583
+ t4 = [handleGlobalKeyDown];
21584
+ $[3] = t3;
21585
+ $[4] = t4;
21586
+ } else {
21587
+ t3 = $[3];
21588
+ t4 = $[4];
21589
+ }
21590
+ React.useEffect(t3, t4);
21591
+ const t5 = mode === "dark" ? prismReactRenderer.themes.vsDark : prismReactRenderer.themes.vsLight;
21592
+ let t6;
21593
+ if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
21594
+ t6 = (t72) => {
21595
+ const {
21596
+ style,
21597
+ tokens,
21598
+ getLineProps,
21599
+ getTokenProps
21600
+ } = t72;
21601
+ return /* @__PURE__ */ jsxRuntime.jsx("pre", { ref: preRef, style: {
21602
+ ...style,
21603
+ background: "inherit"
21604
+ }, className: "container mx-auto p-8 rounded text-sm", children: tokens.map((line, i) => /* @__PURE__ */ jsxRuntime.jsx("div", { ...getLineProps({
21605
+ line
21606
+ }), className: "text-wrap", children: line.map((token, key) => /* @__PURE__ */ jsxRuntime.jsx("span", { ...getTokenProps({
21607
+ token
21608
+ }), className: "word-break" }, key)) }, i)) });
21609
+ };
21610
+ $[5] = t6;
21611
+ } else {
21612
+ t6 = $[5];
21613
+ }
21614
+ let t7;
21615
+ if ($[6] !== code || $[7] !== t5) {
21616
+ t7 = /* @__PURE__ */ jsxRuntime.jsx(prismReactRenderer.Highlight, { theme: t5, code, language: "json", children: t6 });
21617
+ $[6] = code;
21618
+ $[7] = t5;
21619
+ $[8] = t7;
21620
+ } else {
21621
+ t7 = $[8];
21622
+ }
21623
+ return t7;
21624
+ }
21625
+ const MAIN_TAB_VALUE = "__main_##Q$SC^#S6";
21626
+ const JSON_TAB_VALUE = "__json";
21535
21627
  function EntityEditView(t0) {
21536
21628
  const $ = reactCompilerRuntime.c(28);
21537
21629
  let entityId;
@@ -21693,7 +21785,8 @@
21693
21785
  const subcollectionsCount = subcollections?.length ?? 0;
21694
21786
  const customViews = collection.entityViews;
21695
21787
  const customViewsCount = customViews?.length ?? 0;
21696
- const hasAdditionalViews = customViewsCount > 0 || subcollectionsCount > 0;
21788
+ const includeJsonView = true;
21789
+ const hasAdditionalViews = customViewsCount > 0 || subcollectionsCount > 0 || includeJsonView;
21697
21790
  const {
21698
21791
  resolvedEntityViews,
21699
21792
  selectedEntityView,
@@ -21713,6 +21806,9 @@
21713
21806
  }), role: "tabpanel", children: /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundary, { children: formContext && /* @__PURE__ */ jsxRuntime.jsx(Builder, { collection, entity: usedEntity, modifiedValues: formContext.formex.values ?? usedEntity?.values, formContext }) }) }, `custom_view_${customView.key}`);
21714
21807
  }).filter(Boolean);
21715
21808
  const globalLoading = dataLoading && !usedEntity;
21809
+ const jsonView = /* @__PURE__ */ jsxRuntime.jsx("div", { className: ui.cls("relative flex-1 h-full overflow-auto w-full", {
21810
+ "hidden": selectedTab !== JSON_TAB_VALUE
21811
+ }), role: "tabpanel", children: /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundary, { children: /* @__PURE__ */ jsxRuntime.jsx(EntityJsonPreview, { values: formContext?.values ?? {} }) }) }, "json_view");
21716
21812
  const subCollectionsViews = subcollections && subcollections.map((subcollection) => {
21717
21813
  const subcollectionId = subcollection.id ?? subcollection.path;
21718
21814
  const fullPath = usedEntity ? `${path}/${usedEntity?.id}/${removeInitialAndTrailingSlashes(subcollectionId)}` : void 0;
@@ -21752,21 +21848,22 @@
21752
21848
  }, Builder: selectedSecondaryForm?.Builder });
21753
21849
  const subcollectionTabs = subcollections && subcollections.map((subcollection_0) => /* @__PURE__ */ jsxRuntime.jsx(ui.Tab, { className: "text-sm min-w-[120px]", value: subcollection_0.id, children: subcollection_0.name }, `entity_detail_collection_tab_${subcollection_0.name}`));
21754
21850
  const customViewTabs = resolvedEntityViews.map((view) => /* @__PURE__ */ jsxRuntime.jsx(ui.Tab, { className: "text-sm min-w-[120px]", value: view.key, children: view.name }, `entity_detail_collection_tab_${view.name}`));
21755
- const shouldShowTopBar = Boolean(barActions) || hasAdditionalViews;
21756
21851
  let result = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative flex flex-col h-full w-full bg-white dark:bg-surface-900", children: [
21757
- shouldShowTopBar && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ui.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", ui.defaultBorderMixin), children: [
21852
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ui.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", ui.defaultBorderMixin), children: [
21758
21853
  barActions,
21759
21854
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-grow" }),
21760
21855
  globalLoading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "self-center", children: /* @__PURE__ */ jsxRuntime.jsx(ui.CircularProgress, { size: "small" }) }),
21761
- hasAdditionalViews && /* @__PURE__ */ jsxRuntime.jsxs(ui.Tabs, { value: selectedTab, onValueChange: (value_0) => {
21856
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Tabs, { value: selectedTab, onValueChange: (value_0) => {
21762
21857
  onSideTabClick(value_0);
21763
21858
  }, children: [
21859
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Tab, { disabled: !hasAdditionalViews, value: JSON_TAB_VALUE, innerClassName: "block", className: "text-sm", children: /* @__PURE__ */ jsxRuntime.jsx(ui.CodeIcon, { size: "small" }) }),
21764
21860
  /* @__PURE__ */ jsxRuntime.jsx(ui.Tab, { disabled: !hasAdditionalViews, value: MAIN_TAB_VALUE, className: "text-sm min-w-[120px]", children: collection.singularName ?? collection.name }),
21765
21861
  customViewTabs,
21766
21862
  subcollectionTabs
21767
21863
  ] })
21768
21864
  ] }),
21769
21865
  globalLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full pt-12 pb-16 px-4 sm:px-8 md:px-10", children: /* @__PURE__ */ jsxRuntime.jsx(CircularProgressCenter, {}) }) : entityView,
21866
+ jsonView,
21770
21867
  customViewsView,
21771
21868
  subCollectionsViews
21772
21869
  ] });
@@ -21882,7 +21979,7 @@
21882
21979
  const {
21883
21980
  selectedSecondaryForm
21884
21981
  } = resolvedSelectedEntityView(props.collection?.entityViews, customizationController, props.selectedTab);
21885
- const shouldUseSmallLayout = !props.selectedTab || Boolean(selectedSecondaryForm);
21982
+ const shouldUseSmallLayout = !props.selectedTab || props.selectedTab === JSON_TAB_VALUE || Boolean(selectedSecondaryForm);
21886
21983
  let resolvedWidth;
21887
21984
  if (props.width) {
21888
21985
  resolvedWidth = typeof props.width === "number" ? `${props.width}px` : props.width;