@firecms/core 3.0.0-canary.139 → 3.0.0-canary.140

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,10 +1,10 @@
1
1
  import React from "react";
2
2
  import { DraggableProvided } from "@hello-pangea/dnd";
3
- interface ArrayContainerProps<T> {
3
+ export interface ArrayContainerProps<T> {
4
4
  droppableId: string;
5
5
  value: T[];
6
6
  addLabel: string;
7
- buildEntry: (index: number, internalId: number) => React.ReactNode;
7
+ buildEntry: (index: number, internalId: number, isDragging: boolean) => React.ReactNode;
8
8
  disabled?: boolean;
9
9
  size?: "small" | "medium";
10
10
  onInternalIdAdded?: (id: number) => void;
@@ -23,7 +23,7 @@ type ArrayContainerItemProps = {
23
23
  internalId: number;
24
24
  size?: "small" | "medium";
25
25
  disabled: boolean;
26
- buildEntry: (index: number, internalId: number) => React.ReactNode;
26
+ buildEntry: (index: number, internalId: number, isDragging: boolean) => React.ReactNode;
27
27
  remove: (index: number) => void;
28
28
  copy: (index: number) => void;
29
29
  isDragging: boolean;
@@ -26,5 +26,5 @@ import { CMSType, PropertyFieldBindingProps } from "../types";
26
26
  * @group Form custom fields
27
27
  */
28
28
  export declare const PropertyFieldBinding: typeof PropertyFieldBindingInternal;
29
- declare function PropertyFieldBindingInternal<T extends CMSType = CMSType, M extends Record<string, any> = Record<string, any>>({ propertyKey, property, context, includeDescription, underlyingValueHasChanged, disabled, partOfArray, minimalistView, autoFocus, index, size }: PropertyFieldBindingProps<T, M>): ReactElement<PropertyFieldBindingProps<T, M>>;
29
+ declare function PropertyFieldBindingInternal<T extends CMSType = CMSType, M extends Record<string, any> = Record<string, any>>({ propertyKey, property, context, includeDescription, underlyingValueHasChanged, disabled: disabledProp, partOfArray, minimalistView, autoFocus, index, size }: PropertyFieldBindingProps<T, M>): ReactElement<PropertyFieldBindingProps<T, M>>;
30
30
  export {};
package/dist/index.es.js CHANGED
@@ -3598,7 +3598,7 @@ async function saveEntityWithCallbacks({
3598
3598
  } else {
3599
3599
  updatedValues = values;
3600
3600
  }
3601
- console.log("Saving entity", {
3601
+ console.debug("Saving entity", {
3602
3602
  entityId,
3603
3603
  updatedValues,
3604
3604
  collection
@@ -13529,7 +13529,7 @@ function ArrayContainerItem({
13529
13529
  "div",
13530
13530
  {
13531
13531
  className: "flex-grow w-[calc(100%-48px)] text-text-primary dark:text-text-primary-dark",
13532
- children: buildEntry(index, internalId)
13532
+ children: buildEntry(index, internalId, isDragging)
13533
13533
  }
13534
13534
  ),
13535
13535
  /* @__PURE__ */ jsx(
@@ -15113,7 +15113,7 @@ function PropertyFieldBindingInternal({
15113
15113
  context,
15114
15114
  includeDescription,
15115
15115
  underlyingValueHasChanged,
15116
- disabled,
15116
+ disabled: disabledProp,
15117
15117
  partOfArray,
15118
15118
  minimalistView,
15119
15119
  autoFocus,
@@ -15136,6 +15136,7 @@ function PropertyFieldBindingInternal({
15136
15136
  propertyConfigs: customizationController.propertyConfigs,
15137
15137
  index
15138
15138
  });
15139
+ const disabled = disabledProp || isReadOnly(resolvedProperty) || Boolean(resolvedProperty?.disabled);
15139
15140
  if (resolvedProperty === null || isHidden(resolvedProperty)) {
15140
15141
  return /* @__PURE__ */ jsx(Fragment, {});
15141
15142
  } else if (isReadOnly(resolvedProperty)) {
@@ -15344,9 +15345,10 @@ function MapFieldBinding({
15344
15345
  }
15345
15346
  const mapFormView = /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("div", { className: "py-1 flex flex-col space-y-2", children: Object.entries(mapProperties).filter(([_, property2]) => !isHidden(property2)).map(
15346
15347
  ([entryKey, childProperty], index) => {
15348
+ const thisDisabled = isReadOnly(childProperty) || Boolean(childProperty.disabled);
15347
15349
  const fieldBindingProps = {
15348
15350
  propertyKey: `${propertyKey}.${entryKey}`,
15349
- disabled,
15351
+ disabled: disabled || thisDisabled,
15350
15352
  property: childProperty,
15351
15353
  includeDescription,
15352
15354
  underlyingValueHasChanged,
@@ -16149,7 +16151,7 @@ function BlockFieldBinding({
16149
16151
  setValue
16150
16152
  });
16151
16153
  const [lastAddedId, setLastAddedId] = useState();
16152
- const buildEntry = useCallback((index, internalId) => {
16154
+ const buildEntry = useCallback((index, internalId, isDragging) => {
16153
16155
  return /* @__PURE__ */ jsx(
16154
16156
  BlockEntry,
16155
16157
  {
@@ -16162,7 +16164,7 @@ function BlockFieldBinding({
16162
16164
  autoFocus: internalId === lastAddedId,
16163
16165
  context
16164
16166
  },
16165
- `array_one_of_${index}`
16167
+ `array_one_of_${internalId}`
16166
16168
  );
16167
16169
  }, [context, lastAddedId, property.oneOf, propertyKey, value]);
16168
16170
  const title = /* @__PURE__ */ jsx(
@@ -16177,17 +16179,17 @@ function BlockFieldBinding({
16177
16179
  );
16178
16180
  const firstOneOfKey = Object.keys(property.oneOf.properties)[0];
16179
16181
  const body = /* @__PURE__ */ jsx(
16180
- FormikArrayContainer,
16182
+ ArrayContainer,
16181
16183
  {
16182
16184
  value,
16183
16185
  className: "flex flex-col gap-3",
16184
- name: propertyKey,
16186
+ droppableId: propertyKey,
16185
16187
  addLabel: property.name ? "Add entry to " + property.name : "Add entry",
16186
16188
  buildEntry,
16187
16189
  onInternalIdAdded: setLastAddedId,
16188
16190
  disabled: isSubmitting || Boolean(property.disabled),
16189
16191
  includeAddButton: !property.disabled,
16190
- setFieldValue,
16192
+ onValueChange: (value2) => setFieldValue(propertyKey, value2),
16191
16193
  newDefaultEntry: {
16192
16194
  [property.oneOf.typeField ?? DEFAULT_ONE_OF_TYPE]: firstOneOfKey,
16193
16195
  [property.oneOf.valueField ?? DEFAULT_ONE_OF_VALUE]: getDefaultValueFor(property.oneOf.properties[firstOneOfKey])
@@ -16490,9 +16492,10 @@ function ArrayCustomShapedFieldBinding({
16490
16492
  ] })
16491
16493
  ] });
16492
16494
  const body = resolvedProperties.map((childProperty, index) => {
16495
+ const thisDisabled = isReadOnly(childProperty) || Boolean(childProperty.disabled);
16493
16496
  const fieldProps = {
16494
16497
  propertyKey: `${propertyKey}[${index}]`,
16495
- disabled,
16498
+ disabled: disabled || thisDisabled,
16496
16499
  property: childProperty,
16497
16500
  includeDescription,
16498
16501
  underlyingValueHasChanged,
@@ -18026,7 +18029,7 @@ function EntityEditViewInner({
18026
18029
  children: pluginActions
18027
18030
  }
18028
18031
  ),
18029
- /* @__PURE__ */ jsx("div", { className: "h-full overflow-auto", children: /* @__PURE__ */ jsxs("div", { className: "pt-12 pb-16 pl-4 sm:px-8 md:px-10", children: [
18032
+ /* @__PURE__ */ jsxs("div", { className: "pt-12 pb-16 pl-4 sm:px-8 md:px-10", children: [
18030
18033
  /* @__PURE__ */ jsxs(
18031
18034
  "div",
18032
18035
  {
@@ -18074,7 +18077,7 @@ function EntityEditViewInner({
18074
18077
  ),
18075
18078
  /* @__PURE__ */ jsx("div", { className: "h-14" })
18076
18079
  ] })
18077
- ] }) })
18080
+ ] })
18078
18081
  ] });
18079
18082
  if (plugins) {
18080
18083
  plugins.forEach((plugin) => {
@@ -18143,11 +18146,11 @@ function EntityEditViewInner({
18143
18146
  if (entityId && onIdChange)
18144
18147
  onIdChange(entityId);
18145
18148
  }, [entityId, onIdChange]);
18146
- return /* @__PURE__ */ jsx(Formex, { value: formex, children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col h-full w-full transition-width duration-250 ease-in-out", children: [
18149
+ return /* @__PURE__ */ jsx(Formex, { value: formex, children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col h-full w-full", children: [
18147
18150
  /* @__PURE__ */ jsxs(
18148
18151
  "div",
18149
18152
  {
18150
- className: cls(defaultBorderMixin, "no-scrollbar border-b pl-2 pr-2 pt-1 flex items-end overflow-scroll bg-gray-50 dark:bg-gray-950"),
18153
+ className: cls(defaultBorderMixin, "no-scrollbar h-16 border-b pl-2 pr-2 pt-1 flex items-end overflow-scroll bg-gray-50 dark:bg-gray-950"),
18151
18154
  children: [
18152
18155
  /* @__PURE__ */ jsx(
18153
18156
  "div",