@firecms/core 3.0.0-canary.165 → 3.0.0-canary.166

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.
@@ -1,6 +1,4 @@
1
1
  import { EntityAction } from "../../types";
2
2
  export declare const editEntityAction: EntityAction;
3
3
  export declare const copyEntityAction: EntityAction;
4
- export declare const archiveEntityAction: EntityAction;
5
- export declare const openWebsiteAction: EntityAction;
6
4
  export declare const deleteEntityAction: EntityAction;
@@ -1,5 +1,6 @@
1
1
  import { EntityCollection, ResolvedEntityCollection, ResolvedProperty } from "../../types";
2
2
  import { PropertyColumnConfig } from "../EntityCollectionTable/EntityCollectionTableProps";
3
+ export declare const COLLECTION_GROUP_PARENT_ID = "collectionGroupParent";
3
4
  export declare function useColumnIds<M extends Record<string, any>>(collection: ResolvedEntityCollection<M>, includeSubcollections: boolean): PropertyColumnConfig[];
4
5
  export declare function getColumnKeysForProperty(property: ResolvedProperty, key: string, disabled?: boolean): PropertyColumnConfig[];
5
6
  export declare function getFormFieldKeys(collection: EntityCollection): string[];
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, { forwardRef, useState, useRef, useEffect, useContext, useCallback, useMemo, createRef, createContext, useLayoutEffect, createElement } from "react";
5
- import { getColorSchemeForSeed, CHIP_COLORS, Tooltip, IconButton, InfoIcon, Typography, ContentCopyIcon, CircleIcon, FunctionsIcon, iconKeys, coolIconKeys, Icon, ErrorIcon, cls, defaultBorderMixin, OpenInNewIcon, TextareaAutosize, focusedDisabled, MultiSelect, MultiSelectItem, Select, SelectItem, BooleanSwitch, DateTimeField, Skeleton, paperMixin, EditIcon, KeyboardTabIcon, DoNotDisturbOnIcon, Menu, MoreVertIcon, MenuItem, Checkbox, CircularProgress, SearchBar, Badge, ArrowUpwardIcon, Popover, FilterListIcon, Button, CenteredView, AssignmentIcon, Label, CloseIcon, TextField, BooleanSwitchWithLabel, useOutsideAlerter, Dialog, DialogTitle, DialogContent, DialogActions, FileCopyIcon, ArchiveIcon, DeleteIcon, AddIcon, ExpandablePanel, Markdown, ArrowForwardIcon, Card, cardMixin, cardClickableMixin, StarIcon, Chip, Collapse, Container, NotesIcon, Tab, Tabs, Alert, FilterListOffIcon, SearchIcon, LoadingButton, Avatar, DarkModeIcon, LightModeIcon, LogoutIcon, HandleIcon, RemoveIcon, KeyboardArrowUpIcon, KeyboardArrowDownIcon, debounce, DescriptionIcon, fieldBackgroundMixin, fieldBackgroundHoverMixin, fieldBackgroundDisabledMixin, ArrowDropDownIcon, ShortTextIcon, SubjectIcon, FormatQuoteIcon, HttpIcon, MailIcon, FlagIcon, ListIcon, ListAltIcon, NumbersIcon, FormatListNumberedIcon, UploadFileIcon, DriveFolderUploadIcon, LinkIcon, AddLinkIcon, ScheduleIcon, BallotIcon, RepeatIcon, ViewStreamIcon, Sheet, MenuIcon, ChevronLeftIcon } from "@firecms/ui";
5
+ import { getColorSchemeForSeed, CHIP_COLORS, Tooltip, IconButton, InfoIcon, Typography, ContentCopyIcon, CircleIcon, FunctionsIcon, iconKeys, coolIconKeys, Icon, ErrorIcon, cls, defaultBorderMixin, OpenInNewIcon, TextareaAutosize, focusedDisabled, MultiSelect, MultiSelectItem, Select, SelectItem, BooleanSwitch, DateTimeField, Skeleton, paperMixin, EditIcon, KeyboardTabIcon, DoNotDisturbOnIcon, Menu, MoreVertIcon, MenuItem, Checkbox, CircularProgress, SearchBar, Badge, ArrowUpwardIcon, Popover, FilterListIcon, Button, CenteredView, AssignmentIcon, Label, CloseIcon, TextField, BooleanSwitchWithLabel, useOutsideAlerter, Dialog, DialogTitle, DialogContent, DialogActions, FileCopyIcon, DeleteIcon, AddIcon, ExpandablePanel, Markdown, ArrowForwardIcon, Card, cardMixin, cardClickableMixin, StarIcon, Chip, Collapse, Container, NotesIcon, Tab, Tabs, Alert, FilterListOffIcon, SearchIcon, LoadingButton, Avatar, DarkModeIcon, LightModeIcon, LogoutIcon, HandleIcon, RemoveIcon, KeyboardArrowUpIcon, KeyboardArrowDownIcon, debounce, DescriptionIcon, fieldBackgroundMixin, fieldBackgroundHoverMixin, fieldBackgroundDisabledMixin, ArrowDropDownIcon, ShortTextIcon, SubjectIcon, FormatQuoteIcon, HttpIcon, MailIcon, FlagIcon, ListIcon, ListAltIcon, NumbersIcon, FormatListNumberedIcon, UploadFileIcon, DriveFolderUploadIcon, LinkIcon, AddLinkIcon, ScheduleIcon, BallotIcon, RepeatIcon, ViewStreamIcon, Sheet, 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 { useFormex, setIn, getIn, useCreateFormex, Formex, Field } from "@firecms/formex";
@@ -874,6 +874,28 @@ function isValidRegExp(input) {
874
874
  const simpleRegexp = input.match(/((?![*+?])(?:[^\r\n[/\\]|\\.|\[(?:[^\r\n\]\\]|\\.)*])+)/);
875
875
  return !!simpleRegexp;
876
876
  }
877
+ const reservedKeys = ["edit", "copy", "delete"];
878
+ function mergeEntityActions(currentActions, newActions) {
879
+ const updatedActions = [];
880
+ currentActions.forEach((action) => {
881
+ const newAction = newActions.find((a) => a.key === action.key);
882
+ if (newAction) {
883
+ const mergedAction = {
884
+ ...action,
885
+ ...newAction
886
+ };
887
+ updatedActions.push(mergedAction);
888
+ } else {
889
+ updatedActions.push(action);
890
+ }
891
+ });
892
+ newActions.forEach((action) => {
893
+ if (!currentActions.find((a) => a.key === action.key) && (!action.key || !reservedKeys.includes(action.key))) {
894
+ updatedActions.push(action);
895
+ }
896
+ });
897
+ return updatedActions;
898
+ }
877
899
  function useDebouncedCallback(value, callback, immediate, t0) {
878
900
  const $ = c(9);
879
901
  const timeoutMs = t0 === void 0 ? 300 : t0;
@@ -7107,7 +7129,7 @@ function getTablePropertyColumnWidth(property) {
7107
7129
  function getSubcollectionColumnId(collection) {
7108
7130
  return `subcollection:${collection.id ?? collection.path}`;
7109
7131
  }
7110
- const COLLECTION_GROUP_PARENT_ID$1 = "collectionGroupParent";
7132
+ const COLLECTION_GROUP_PARENT_ID = "collectionGroupParent";
7111
7133
  function useColumnIds(collection, includeSubcollections) {
7112
7134
  const $ = c(5);
7113
7135
  let t0;
@@ -7118,7 +7140,7 @@ function useColumnIds(collection, includeSubcollections) {
7118
7140
  propertyColumnConfigs = hideAndExpandKeys(collection, collection.propertiesOrder);
7119
7141
  if (collection.collectionGroup) {
7120
7142
  propertyColumnConfigs.push({
7121
- key: COLLECTION_GROUP_PARENT_ID$1,
7143
+ key: COLLECTION_GROUP_PARENT_ID,
7122
7144
  disabled: true
7123
7145
  });
7124
7146
  }
@@ -7173,7 +7195,7 @@ function hideAndExpandKeys(collection, keys) {
7173
7195
  }];
7174
7196
  }
7175
7197
  }
7176
- if (collection.collectionGroup && key === COLLECTION_GROUP_PARENT_ID$1) {
7198
+ if (collection.collectionGroup && key === COLLECTION_GROUP_PARENT_ID) {
7177
7199
  return [{
7178
7200
  key,
7179
7201
  disabled: true
@@ -7192,7 +7214,7 @@ function getDefaultColumnKeys(collection, includeSubCollections) {
7192
7214
  columnIds.push(...subCollectionIds.filter((subColId) => !columnIds.includes(subColId)));
7193
7215
  }
7194
7216
  if (collection.collectionGroup) {
7195
- columnIds.push(COLLECTION_GROUP_PARENT_ID$1);
7217
+ columnIds.push(COLLECTION_GROUP_PARENT_ID);
7196
7218
  }
7197
7219
  return hideAndExpandKeys(collection, columnIds);
7198
7220
  }
@@ -9470,6 +9492,7 @@ function getRecentIds(collectionId) {
9470
9492
  }
9471
9493
  const editEntityAction = {
9472
9494
  icon: /* @__PURE__ */ jsx(EditIcon, {}),
9495
+ key: "edit",
9473
9496
  name: "Edit",
9474
9497
  collapsed: false,
9475
9498
  onClick({
@@ -9502,6 +9525,7 @@ const editEntityAction = {
9502
9525
  const copyEntityAction = {
9503
9526
  icon: /* @__PURE__ */ jsx(FileCopyIcon, {}),
9504
9527
  name: "Copy",
9528
+ key: "copy",
9505
9529
  onClick({
9506
9530
  entity,
9507
9531
  collection,
@@ -9525,34 +9549,10 @@ const copyEntityAction = {
9525
9549
  return Promise.resolve(void 0);
9526
9550
  }
9527
9551
  };
9528
- const archiveEntityAction = {
9529
- icon: /* @__PURE__ */ jsx(ArchiveIcon, {}),
9530
- name: "Archive",
9531
- onClick({
9532
- entity,
9533
- collection,
9534
- context: {
9535
- dataSource
9536
- }
9537
- }) {
9538
- return Promise.resolve(void 0);
9539
- }
9540
- };
9541
- const openWebsiteAction = {
9542
- icon: /* @__PURE__ */ jsx(OpenInNewIcon, {}),
9543
- name: "See in website",
9544
- onClick({
9545
- entity,
9546
- collection,
9547
- context
9548
- }) {
9549
- window.open(`https://example.com/${entity.id}`, "_blank");
9550
- return Promise.resolve(void 0);
9551
- }
9552
- };
9553
9552
  const deleteEntityAction = {
9554
9553
  icon: /* @__PURE__ */ jsx(DeleteIcon, {}),
9555
9554
  name: "Delete",
9555
+ key: "delete",
9556
9556
  onClick({
9557
9557
  entity,
9558
9558
  fullPath,
@@ -11519,7 +11519,7 @@ function EntityEditViewInner({
11519
11519
  const actions = [];
11520
11520
  if (createEnabled) actions.push(copyEntityAction);
11521
11521
  if (deleteEnabled) actions.push(deleteEntityAction);
11522
- if (customEntityActions) actions.push(...customEntityActions);
11522
+ if (customEntityActions) return mergeEntityActions(actions, customEntityActions);
11523
11523
  return actions;
11524
11524
  }, [authController, inputCollection, path]);
11525
11525
  const modified = formex.dirty;
@@ -12127,7 +12127,6 @@ function EntityCollectionViewStartActions(t0) {
12127
12127
  }
12128
12128
  return t5;
12129
12129
  }
12130
- const COLLECTION_GROUP_PARENT_ID = "collectionGroupParent";
12131
12130
  const EntityCollectionView = React__default.memo(function EntityCollectionView2({
12132
12131
  fullPath: fullPathProp,
12133
12132
  parentCollectionIds,
@@ -12377,7 +12376,7 @@ const EntityCollectionView = React__default.memo(function EntityCollectionView2(
12377
12376
  const actions = [editEntityAction];
12378
12377
  if (createEnabled) actions.push(copyEntityAction);
12379
12378
  if (deleteEnabled) actions.push(deleteEntityAction);
12380
- if (customEntityActions) actions.push(...customEntityActions);
12379
+ if (customEntityActions) return mergeEntityActions(actions, customEntityActions);
12381
12380
  return actions;
12382
12381
  };
12383
12382
  const getIdColumnWidth = () => {
@@ -16017,7 +16016,7 @@ const PropertyPreview = React__default.memo(function PropertyPreview2(props) {
16017
16016
  propertyOrBuilder: inputProperty,
16018
16017
  propertyConfigs: customizationController.propertyConfigs
16019
16018
  });
16020
- if (value === void 0 || property === null) {
16019
+ if (property === null) {
16021
16020
  let t02;
16022
16021
  if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
16023
16022
  t02 = /* @__PURE__ */ jsx(EmptyValue, {});
@@ -16038,7 +16037,7 @@ const PropertyPreview = React__default.memo(function PropertyPreview2(props) {
16038
16037
  customProps: property.customProps
16039
16038
  });
16040
16039
  } else {
16041
- if (value === null) {
16040
+ if (value === void 0 || value === null) {
16042
16041
  let t02;
16043
16042
  if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
16044
16043
  t02 = /* @__PURE__ */ jsx(EmptyValue, {});
@@ -22535,6 +22534,7 @@ export {
22535
22534
  AuthControllerContext,
22536
22535
  BlockFieldBinding,
22537
22536
  BooleanPreview,
22537
+ COLLECTION_GROUP_PARENT_ID,
22538
22538
  COLLECTION_PATH_SEPARATOR,
22539
22539
  CircularProgressCenter,
22540
22540
  ConfirmationDialog,
@@ -22613,7 +22613,6 @@ export {
22613
22613
  VirtualTable,
22614
22614
  addInitialSlash,
22615
22615
  applyPermissionsFunctionIfEmpty,
22616
- archiveEntityAction,
22617
22616
  buildAdditionalFieldDelegate,
22618
22617
  buildCollection,
22619
22618
  buildEntityCallbacks,
@@ -22687,7 +22686,7 @@ export {
22687
22686
  makePropertiesNonEditable,
22688
22687
  mergeCollection,
22689
22688
  mergeDeep,
22690
- openWebsiteAction,
22689
+ mergeEntityActions,
22691
22690
  pick,
22692
22691
  plural,
22693
22692
  printChanged,