@firecms/collection_editor 3.0.0-canary.264 → 3.0.0-canary.266

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.es.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import { c } from "react-compiler-runtime";
3
- import { toSnakeCase, singular, IconForView, FieldCaption, SearchIconsView, ArrayContainer, serializeRegExp, useSnackbarController, resolveEnumValues, isPropertyBuilder, useCustomizationController, getFieldConfig, ErrorBoundary, PropertyConfigBadge, unslugify, useNavigationController, mergeDeep, DEFAULT_FIELD_CONFIGS, getFieldId, isValidRegExp, ConfirmationDialog, isEmptyObject, useLargeLayout, makePropertiesEditable, resolveEntityView, useAuthController, useSelectionController, CircularProgressCenter, EntityCollectionTable, slugify, resolveEntityAction, randomString, removeUndefined, ErrorView, removeInitialAndTrailingSlashes, getDefaultPropertiesOrder, joinCollectionLists } from "@firecms/core";
3
+ import { toSnakeCase, singular, IconForView, FieldCaption, SearchIconsView, ArrayContainer, serializeRegExp, useSnackbarController, resolveEnumValues, isPropertyBuilder, useCustomizationController, getFieldConfig, ErrorBoundary, PropertyConfigBadge, unslugify, useNavigationController, mergeDeep, DEFAULT_FIELD_CONFIGS, getFieldId, ConfirmationDialog, isValidRegExp, isEmptyObject, useLargeLayout, makePropertiesEditable, resolveEntityView, useAuthController, useSelectionController, CircularProgressCenter, EntityCollectionTable, slugify, resolveEntityAction, randomString, removeUndefined, ErrorView, removeInitialAndTrailingSlashes, getDefaultPropertiesOrder, joinCollectionLists } from "@firecms/core";
4
4
  import * as React from "react";
5
5
  import React__default, { useContext, useState, useEffect, useMemo, useRef, useDeferredValue } from "react";
6
6
  import equal from "react-fast-compare";
7
- import { cls, Typography, VerticalSplitIcon, Tooltip, Card, SquareIcon, useAutoComplete, Chip, SelectItem, IconButton, TextField, DebouncedTextField, BooleanSwitchWithLabel, SettingsIcon, CloseIcon, Select, ExpandablePanel, Dialog, Container, Badge, AutorenewIcon, ListIcon, Button, CircularProgress, Paper, DialogTitle, DialogContent, DialogActions, RuleIcon, MultiSelectItem, CloudUploadIcon, MultiSelect, cardMixin, cardClickableMixin, cardSelectedMixin, FunctionsIcon, DoNotDisturbOnIcon, DragHandleIcon, defaultBorderMixin, RemoveIcon, AddIcon, SelectGroup, DeleteIcon, InfoLabel, fieldBackgroundMixin, fieldBackgroundDisabledMixin, fieldBackgroundHoverMixin, WarningIcon, ContentCopyIcon, CodeIcon, Table, TableBody, TableRow, TableCell, Alert, Icon, coolIconKeys, Tabs, Tab, ArrowBackIcon, LoadingButton, CheckIcon, Menu, MoreVertIcon, MenuItem, UndoIcon, SaveIcon } from "@firecms/ui";
7
+ import { cls, Typography, VerticalSplitIcon, Tooltip, Card, SquareIcon, useAutoComplete, Chip, SelectItem, IconButton, TextField, DebouncedTextField, BooleanSwitchWithLabel, SettingsIcon, CloseIcon, Select, ExpandablePanel, Dialog, Container, Badge, AutorenewIcon, ListIcon, Button, CircularProgress, Paper, DialogTitle, DialogContent, DialogActions, RuleIcon, MultiSelectItem, CloudUploadIcon, MultiSelect, cardMixin, cardClickableMixin, cardSelectedMixin, FunctionsIcon, DoNotDisturbOnIcon, DragHandleIcon, defaultBorderMixin, RemoveIcon, AddIcon, SelectGroup, DeleteIcon, InfoLabel, fieldBackgroundMixin, fieldBackgroundDisabledMixin, fieldBackgroundHoverMixin, WarningIcon, ContentCopyIcon, CodeIcon, Table, TableBody, TableRow, TableCell, Alert, Icon, coolIconKeys, Tabs, Tab, ArrowBackIcon, LoadingButton, CheckIcon, Menu, MenuItem, MoreVertIcon, UndoIcon, SaveIcon } from "@firecms/ui";
8
8
  import * as Yup from "yup";
9
9
  import { useFormex, getIn, Field, useCreateFormex, Formex, clone } from "@firecms/formex";
10
10
  import { extractEnumFromValues, buildPropertyFromData, buildEntityPropertiesFromData } from "@firecms/schema_inference";
@@ -14,7 +14,7 @@ import { restrictToVerticalAxis } from "@dnd-kit/modifiers";
14
14
  import { CSS } from "@dnd-kit/utilities";
15
15
  import JSON5 from "json5";
16
16
  import { Highlight, themes } from "prism-react-renderer";
17
- import { ImportFileUpload, getInferenceType, ImportNewPropertyFieldPreview, DataNewPropertiesMapping, convertDataToEntity, useImportConfig, ImportSaveInProgress } from "@firecms/data_import_export";
17
+ import { ImportFileUpload, getInferenceType, ImportNewPropertyFieldPreview, DataNewPropertiesMapping, convertDataToEntity, useImportConfig, ImportSaveInProgress } from "@firecms/data_import";
18
18
  import { useNavigate } from "react-router";
19
19
  const YupSchema = Yup.object().shape({
20
20
  id: Yup.string().required("Required"),
@@ -4443,7 +4443,7 @@ function ReferencePropertyField(t0) {
4443
4443
  return t4;
4444
4444
  }
4445
4445
  function CollectionsSelect(t0) {
4446
- const $ = c(25);
4446
+ const $ = c(29);
4447
4447
  let disabled;
4448
4448
  let error;
4449
4449
  let handleChange;
@@ -4495,12 +4495,21 @@ function CollectionsSelect(t0) {
4495
4495
  }
4496
4496
  const collections = t1;
4497
4497
  let t2;
4498
- if ($[10] !== collections || $[11] !== disabled || $[12] !== error || $[13] !== handleChange || $[14] !== pathPath || $[15] !== props || $[16] !== value) {
4499
- const groups = Array.from(new Set(Object.values(collections).map(_temp$9).filter(Boolean)).values());
4498
+ if ($[10] !== collections) {
4499
+ t2 = Array.from(new Set(Object.values(collections).map(_temp$9).filter(Boolean)).values());
4500
+ $[10] = collections;
4501
+ $[11] = t2;
4502
+ } else {
4503
+ t2 = $[11];
4504
+ }
4505
+ const groups = t2;
4506
+ let t3;
4507
+ if ($[12] !== collections || $[13] !== disabled || $[14] !== error || $[15] !== groups || $[16] !== handleChange || $[17] !== pathPath || $[18] !== props || $[19] !== value) {
4500
4508
  const ungroupedCollections = collections.filter(_temp2$6);
4501
- let t32;
4502
- if ($[18] !== collections) {
4503
- t32 = (selected) => {
4509
+ const t42 = Boolean(error);
4510
+ let t52;
4511
+ if ($[21] !== collections) {
4512
+ t52 = (selected) => {
4504
4513
  const selectedCollection = collections.find((collection) => collection.id === selected || collection.path === selected);
4505
4514
  if (!selectedCollection) {
4506
4515
  return null;
@@ -4510,56 +4519,58 @@ function CollectionsSelect(t0) {
4510
4519
  /* @__PURE__ */ jsx(Typography, { variant: "subtitle2", className: "font-medium ml-4", children: selectedCollection?.name.toUpperCase() })
4511
4520
  ] });
4512
4521
  };
4513
- $[18] = collections;
4514
- $[19] = t32;
4522
+ $[21] = collections;
4523
+ $[22] = t52;
4515
4524
  } else {
4516
- t32 = $[19];
4525
+ t52 = $[22];
4517
4526
  }
4518
- let t42;
4519
- if ($[20] !== collections) {
4520
- t42 = (group) => /* @__PURE__ */ jsx(SelectGroup, { label: group || "Views", children: collections.filter((collection_0) => collection_0.group === group).map((collection_1) => /* @__PURE__ */ jsx(SelectItem, { value: collection_1.id ?? collection_1.path, children: /* @__PURE__ */ jsxs("div", { className: "flex flex-row", children: [
4527
+ let t6;
4528
+ if ($[23] !== collections || $[24] !== groups) {
4529
+ t6 = groups.flatMap((group) => /* @__PURE__ */ jsx(SelectGroup, { label: group || "Views", children: collections.filter((collection_0) => collection_0.group === group).map((collection_1) => /* @__PURE__ */ jsx(SelectItem, { value: collection_1.id ?? collection_1.path, children: /* @__PURE__ */ jsxs("div", { className: "flex flex-row", children: [
4521
4530
  /* @__PURE__ */ jsx(IconForView, { collectionOrView: collection_1 }),
4522
4531
  /* @__PURE__ */ jsx(Typography, { variant: "subtitle2", className: "font-medium ml-4", children: collection_1?.name.toUpperCase() })
4523
- ] }) }, `${collection_1.id ?? collection_1.path}-${group}`)) }, `group_${group}`);
4524
- $[20] = collections;
4525
- $[21] = t42;
4532
+ ] }) }, `${collection_1.id ?? collection_1.path}-${group}`)) }, `group_${group}`));
4533
+ $[23] = collections;
4534
+ $[24] = groups;
4535
+ $[25] = t6;
4526
4536
  } else {
4527
- t42 = $[21];
4537
+ t6 = $[25];
4528
4538
  }
4529
- t2 = /* @__PURE__ */ jsxs(Select, { error: Boolean(error), disabled, value: value ?? "", position: "item-aligned", name: pathPath, size: "large", fullWidth: true, onChange: handleChange, label: "Target collection", renderValue: t32, ...props, children: [
4530
- groups.flatMap(t42),
4539
+ t3 = /* @__PURE__ */ jsxs(Select, { error: t42, disabled, value: value ?? "", position: "item-aligned", name: pathPath, size: "large", fullWidth: true, onChange: handleChange, label: "Target collection", renderValue: t52, ...props, children: [
4540
+ t6,
4531
4541
  ungroupedCollections && /* @__PURE__ */ jsx(SelectGroup, { label: "Views", children: ungroupedCollections.map(_temp3$3) })
4532
4542
  ] });
4533
- $[10] = collections;
4534
- $[11] = disabled;
4535
- $[12] = error;
4536
- $[13] = handleChange;
4537
- $[14] = pathPath;
4538
- $[15] = props;
4539
- $[16] = value;
4540
- $[17] = t2;
4543
+ $[12] = collections;
4544
+ $[13] = disabled;
4545
+ $[14] = error;
4546
+ $[15] = groups;
4547
+ $[16] = handleChange;
4548
+ $[17] = pathPath;
4549
+ $[18] = props;
4550
+ $[19] = value;
4551
+ $[20] = t3;
4541
4552
  } else {
4542
- t2 = $[17];
4553
+ t3 = $[20];
4543
4554
  }
4544
- let t3;
4545
- if ($[22] === Symbol.for("react.memo_cache_sentinel")) {
4546
- t3 = /* @__PURE__ */ jsx(FieldCaption, { children: "You can only edit the reference collection upon field creation." });
4547
- $[22] = t3;
4555
+ let t4;
4556
+ if ($[26] === Symbol.for("react.memo_cache_sentinel")) {
4557
+ t4 = /* @__PURE__ */ jsx(FieldCaption, { children: "You can only edit the reference collection upon field creation." });
4558
+ $[26] = t4;
4548
4559
  } else {
4549
- t3 = $[22];
4560
+ t4 = $[26];
4550
4561
  }
4551
- let t4;
4552
- if ($[23] !== t2) {
4553
- t4 = /* @__PURE__ */ jsxs(Fragment, { children: [
4554
- t2,
4555
- t3
4562
+ let t5;
4563
+ if ($[27] !== t3) {
4564
+ t5 = /* @__PURE__ */ jsxs(Fragment, { children: [
4565
+ t3,
4566
+ t4
4556
4567
  ] });
4557
- $[23] = t2;
4558
- $[24] = t4;
4568
+ $[27] = t3;
4569
+ $[28] = t5;
4559
4570
  } else {
4560
- t4 = $[24];
4571
+ t5 = $[28];
4561
4572
  }
4562
- return t4;
4573
+ return t5;
4563
4574
  }
4564
4575
  function _temp3$3(collection_2) {
4565
4576
  return /* @__PURE__ */ jsx(SelectItem, { value: collection_2.id ?? collection_2.path, children: /* @__PURE__ */ jsxs("div", { className: "flex flex-row", children: [
@@ -8659,8 +8670,10 @@ function CollectionEditorImportMapping(t0) {
8659
8670
  editable: true
8660
8671
  };
8661
8672
  if (propertyPath_0) {
8662
- {
8673
+ if (inferredNewProperty) {
8663
8674
  setFieldValue(propertyPath_0, inferredNewProperty, false);
8675
+ } else {
8676
+ setFieldValue(propertyPath_0, property_1, false);
8664
8677
  }
8665
8678
  setFieldTouched(propertyPath_0, true, false);
8666
8679
  }