@firecms/core 3.0.0-canary.164 → 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;
@@ -6857,15 +6879,17 @@ const EntityCollectionRowActions = function EntityCollectionRowActions2({
6857
6879
  const hasCollapsedActions = actions.some((a) => a.collapsed || a.collapsed === void 0);
6858
6880
  const collapsedActions = actions.filter((a_0) => a_0.collapsed || a_0.collapsed === void 0);
6859
6881
  const uncollapsedActions = actions.filter((a_1) => a_1.collapsed === false);
6860
- return /* @__PURE__ */ jsxs("div", { className: cls("h-full flex items-center justify-center flex-col bg-surface-50 dark:bg-surface-900 bg-opacity-90 dark:bg-opacity-90 z-10", frozen ? "sticky left-0" : ""), style: {
6882
+ return /* @__PURE__ */ jsxs("div", { className: cls("h-full flex items-center justify-center flex-col bg-surface-50 dark:bg-surface-900 bg-opacity-90 dark:bg-opacity-90 z-10", frozen ? "sticky left-0" : ""), onClick: useCallback((event) => {
6883
+ event.stopPropagation();
6884
+ }, []), style: {
6861
6885
  width,
6862
6886
  position: frozen ? "sticky" : "initial",
6863
6887
  left: frozen ? 0 : "initial",
6864
6888
  contain: "strict"
6865
6889
  }, children: [
6866
6890
  (hasActions || selectionEnabled) && /* @__PURE__ */ jsxs("div", { className: "w-34 flex justify-center", children: [
6867
- uncollapsedActions.map((action, index) => /* @__PURE__ */ jsx(Tooltip, { title: action.name, asChild: true, children: /* @__PURE__ */ jsx(IconButton, { onClick: (event) => {
6868
- event.stopPropagation();
6891
+ uncollapsedActions.map((action, index) => /* @__PURE__ */ jsx(Tooltip, { title: action.name, asChild: true, children: /* @__PURE__ */ jsx(IconButton, { onClick: (event_0) => {
6892
+ event_0.stopPropagation();
6869
6893
  action.onClick({
6870
6894
  entity,
6871
6895
  fullPath,
@@ -6895,8 +6919,8 @@ const EntityCollectionRowActions = function EntityCollectionRowActions2({
6895
6919
  ] }, index_0)) }),
6896
6920
  selectionEnabled && /* @__PURE__ */ jsx(Tooltip, { title: `Select ${entity.id}`, children: /* @__PURE__ */ jsx(Checkbox, { size: largeLayout ? "medium" : "small", checked: Boolean(isSelected), onCheckedChange }) })
6897
6921
  ] }),
6898
- !hideId && size !== "xs" && /* @__PURE__ */ jsx("div", { className: "w-[138px] text-center overflow-hidden truncate font-mono text-xs text-text-secondary dark:text-text-secondary-dark max-w-full text-ellipsis px-2", onClick: (event_0) => {
6899
- event_0.stopPropagation();
6922
+ !hideId && size !== "xs" && /* @__PURE__ */ jsx("div", { className: "w-[138px] text-center overflow-hidden truncate font-mono text-xs text-text-secondary dark:text-text-secondary-dark max-w-full text-ellipsis px-2", onClick: (event_1) => {
6923
+ event_1.stopPropagation();
6900
6924
  }, children: entity ? entity.id : /* @__PURE__ */ jsx(Skeleton, {}) })
6901
6925
  ] });
6902
6926
  };
@@ -7105,7 +7129,7 @@ function getTablePropertyColumnWidth(property) {
7105
7129
  function getSubcollectionColumnId(collection) {
7106
7130
  return `subcollection:${collection.id ?? collection.path}`;
7107
7131
  }
7108
- const COLLECTION_GROUP_PARENT_ID$1 = "collectionGroupParent";
7132
+ const COLLECTION_GROUP_PARENT_ID = "collectionGroupParent";
7109
7133
  function useColumnIds(collection, includeSubcollections) {
7110
7134
  const $ = c(5);
7111
7135
  let t0;
@@ -7116,7 +7140,7 @@ function useColumnIds(collection, includeSubcollections) {
7116
7140
  propertyColumnConfigs = hideAndExpandKeys(collection, collection.propertiesOrder);
7117
7141
  if (collection.collectionGroup) {
7118
7142
  propertyColumnConfigs.push({
7119
- key: COLLECTION_GROUP_PARENT_ID$1,
7143
+ key: COLLECTION_GROUP_PARENT_ID,
7120
7144
  disabled: true
7121
7145
  });
7122
7146
  }
@@ -7171,7 +7195,7 @@ function hideAndExpandKeys(collection, keys) {
7171
7195
  }];
7172
7196
  }
7173
7197
  }
7174
- if (collection.collectionGroup && key === COLLECTION_GROUP_PARENT_ID$1) {
7198
+ if (collection.collectionGroup && key === COLLECTION_GROUP_PARENT_ID) {
7175
7199
  return [{
7176
7200
  key,
7177
7201
  disabled: true
@@ -7190,7 +7214,7 @@ function getDefaultColumnKeys(collection, includeSubCollections) {
7190
7214
  columnIds.push(...subCollectionIds.filter((subColId) => !columnIds.includes(subColId)));
7191
7215
  }
7192
7216
  if (collection.collectionGroup) {
7193
- columnIds.push(COLLECTION_GROUP_PARENT_ID$1);
7217
+ columnIds.push(COLLECTION_GROUP_PARENT_ID);
7194
7218
  }
7195
7219
  return hideAndExpandKeys(collection, columnIds);
7196
7220
  }
@@ -9468,6 +9492,7 @@ function getRecentIds(collectionId) {
9468
9492
  }
9469
9493
  const editEntityAction = {
9470
9494
  icon: /* @__PURE__ */ jsx(EditIcon, {}),
9495
+ key: "edit",
9471
9496
  name: "Edit",
9472
9497
  collapsed: false,
9473
9498
  onClick({
@@ -9500,6 +9525,7 @@ const editEntityAction = {
9500
9525
  const copyEntityAction = {
9501
9526
  icon: /* @__PURE__ */ jsx(FileCopyIcon, {}),
9502
9527
  name: "Copy",
9528
+ key: "copy",
9503
9529
  onClick({
9504
9530
  entity,
9505
9531
  collection,
@@ -9523,34 +9549,10 @@ const copyEntityAction = {
9523
9549
  return Promise.resolve(void 0);
9524
9550
  }
9525
9551
  };
9526
- const archiveEntityAction = {
9527
- icon: /* @__PURE__ */ jsx(ArchiveIcon, {}),
9528
- name: "Archive",
9529
- onClick({
9530
- entity,
9531
- collection,
9532
- context: {
9533
- dataSource
9534
- }
9535
- }) {
9536
- return Promise.resolve(void 0);
9537
- }
9538
- };
9539
- const openWebsiteAction = {
9540
- icon: /* @__PURE__ */ jsx(OpenInNewIcon, {}),
9541
- name: "See in website",
9542
- onClick({
9543
- entity,
9544
- collection,
9545
- context
9546
- }) {
9547
- window.open(`https://example.com/${entity.id}`, "_blank");
9548
- return Promise.resolve(void 0);
9549
- }
9550
- };
9551
9552
  const deleteEntityAction = {
9552
9553
  icon: /* @__PURE__ */ jsx(DeleteIcon, {}),
9553
9554
  name: "Delete",
9555
+ key: "delete",
9554
9556
  onClick({
9555
9557
  entity,
9556
9558
  fullPath,
@@ -11517,7 +11519,7 @@ function EntityEditViewInner({
11517
11519
  const actions = [];
11518
11520
  if (createEnabled) actions.push(copyEntityAction);
11519
11521
  if (deleteEnabled) actions.push(deleteEntityAction);
11520
- if (customEntityActions) actions.push(...customEntityActions);
11522
+ if (customEntityActions) return mergeEntityActions(actions, customEntityActions);
11521
11523
  return actions;
11522
11524
  }, [authController, inputCollection, path]);
11523
11525
  const modified = formex.dirty;
@@ -12125,7 +12127,6 @@ function EntityCollectionViewStartActions(t0) {
12125
12127
  }
12126
12128
  return t5;
12127
12129
  }
12128
- const COLLECTION_GROUP_PARENT_ID = "collectionGroupParent";
12129
12130
  const EntityCollectionView = React__default.memo(function EntityCollectionView2({
12130
12131
  fullPath: fullPathProp,
12131
12132
  parentCollectionIds,
@@ -12375,7 +12376,7 @@ const EntityCollectionView = React__default.memo(function EntityCollectionView2(
12375
12376
  const actions = [editEntityAction];
12376
12377
  if (createEnabled) actions.push(copyEntityAction);
12377
12378
  if (deleteEnabled) actions.push(deleteEntityAction);
12378
- if (customEntityActions) actions.push(...customEntityActions);
12379
+ if (customEntityActions) return mergeEntityActions(actions, customEntityActions);
12379
12380
  return actions;
12380
12381
  };
12381
12382
  const getIdColumnWidth = () => {
@@ -16015,7 +16016,7 @@ const PropertyPreview = React__default.memo(function PropertyPreview2(props) {
16015
16016
  propertyOrBuilder: inputProperty,
16016
16017
  propertyConfigs: customizationController.propertyConfigs
16017
16018
  });
16018
- if (value === void 0 || property === null) {
16019
+ if (property === null) {
16019
16020
  let t02;
16020
16021
  if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
16021
16022
  t02 = /* @__PURE__ */ jsx(EmptyValue, {});
@@ -16036,7 +16037,7 @@ const PropertyPreview = React__default.memo(function PropertyPreview2(props) {
16036
16037
  customProps: property.customProps
16037
16038
  });
16038
16039
  } else {
16039
- if (value === null) {
16040
+ if (value === void 0 || value === null) {
16040
16041
  let t02;
16041
16042
  if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
16042
16043
  t02 = /* @__PURE__ */ jsx(EmptyValue, {});
@@ -22533,6 +22534,7 @@ export {
22533
22534
  AuthControllerContext,
22534
22535
  BlockFieldBinding,
22535
22536
  BooleanPreview,
22537
+ COLLECTION_GROUP_PARENT_ID,
22536
22538
  COLLECTION_PATH_SEPARATOR,
22537
22539
  CircularProgressCenter,
22538
22540
  ConfirmationDialog,
@@ -22611,7 +22613,6 @@ export {
22611
22613
  VirtualTable,
22612
22614
  addInitialSlash,
22613
22615
  applyPermissionsFunctionIfEmpty,
22614
- archiveEntityAction,
22615
22616
  buildAdditionalFieldDelegate,
22616
22617
  buildCollection,
22617
22618
  buildEntityCallbacks,
@@ -22685,7 +22686,7 @@ export {
22685
22686
  makePropertiesNonEditable,
22686
22687
  mergeCollection,
22687
22688
  mergeDeep,
22688
- openWebsiteAction,
22689
+ mergeEntityActions,
22689
22690
  pick,
22690
22691
  plural,
22691
22692
  printChanged,