@firecms/core 3.0.0-canary.170 → 3.0.0-canary.172

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.
@@ -11,5 +11,5 @@ interface ReferenceFilterFieldProps {
11
11
  hidden: boolean;
12
12
  setHidden: (hidden: boolean) => void;
13
13
  }
14
- export declare function ReferenceFilterField({ name, value, setValue, isArray, path, title, includeId, previewProperties, setHidden }: ReferenceFilterFieldProps): import("react/jsx-runtime").JSX.Element;
14
+ export declare function ReferenceFilterField({ value, setValue, isArray, path, includeId, previewProperties, setHidden }: ReferenceFilterFieldProps): import("react/jsx-runtime").JSX.Element;
15
15
  export {};
package/dist/index.es.js CHANGED
@@ -8358,18 +8358,20 @@ const operationLabels$2 = {
8358
8358
  };
8359
8359
  const multipleSelectOperations$2 = ["array-contains-any", "in", "not-in"];
8360
8360
  function ReferenceFilterField({
8361
- name,
8362
8361
  value,
8363
8362
  setValue,
8364
8363
  isArray,
8365
8364
  path,
8366
- title,
8367
8365
  includeId = true,
8368
8366
  previewProperties,
8369
8367
  setHidden
8370
8368
  }) {
8371
8369
  const possibleOperations = isArray ? ["array-contains"] : ["==", "!=", ">", "<", ">=", "<="];
8372
- isArray ? possibleOperations.push("array-contains-any") : possibleOperations.push("in", "not-in");
8370
+ if (isArray) {
8371
+ possibleOperations.push("array-contains-any");
8372
+ } else {
8373
+ possibleOperations.push("in", "not-in");
8374
+ }
8373
8375
  const [fieldOperation, fieldValue] = value || [possibleOperations[0], void 0];
8374
8376
  const [operation, setOperation] = useState(fieldOperation);
8375
8377
  const [internalValue, setInternalValue] = useState(fieldValue);
@@ -8424,11 +8426,11 @@ function ReferenceFilterField({
8424
8426
  const buildEntry = (reference) => {
8425
8427
  return /* @__PURE__ */ jsx(ReferencePreview, { disabled: !path, previewProperties, size: "medium", onClick: doOpenDialog, reference, hover: true, includeId, includeEntityLink: false });
8426
8428
  };
8427
- return /* @__PURE__ */ jsxs("div", { className: "flex w-[440px] flex-row", children: [
8429
+ return /* @__PURE__ */ jsxs("div", { className: "flex w-[480px] flex-row", children: [
8428
8430
  /* @__PURE__ */ jsx("div", { className: "w-[140px]", children: /* @__PURE__ */ jsx(Select, { value: operation, size: "large", fullWidth: true, onValueChange: (value_0) => {
8429
8431
  updateFilter(value_0, internalValue);
8430
8432
  }, renderValue: (op_0) => operationLabels$2[op_0], children: possibleOperations.map((op_1) => /* @__PURE__ */ jsx(SelectItem, { value: op_1, children: operationLabels$2[op_1] }, op_1)) }) }),
8431
- /* @__PURE__ */ jsxs("div", { className: "flex-grow ml-2 h-full gap-2 flex flex-col", children: [
8433
+ /* @__PURE__ */ jsxs("div", { className: "flex-grow ml-2 h-full gap-2 flex flex-col w-[340px]", children: [
8432
8434
  internalValue && Array.isArray(internalValue) && /* @__PURE__ */ jsx("div", { children: internalValue.map((ref_0, index) => buildEntry(ref_0)) }),
8433
8435
  internalValue && !Array.isArray(internalValue) && /* @__PURE__ */ jsx("div", { children: buildEntry(internalValue) }),
8434
8436
  (!internalValue || Array.isArray(internalValue) && internalValue.length === 0) && /* @__PURE__ */ jsx(Button, { onClick: doOpenDialog, variant: "outlined", size: "large", className: "h-full w-full", children: multiple ? "Select references" : "Select reference" }),
@@ -9273,10 +9275,10 @@ function useDataSourceTableController({
9273
9275
  return initialSort;
9274
9276
  }, [initialSort, forceFilter]);
9275
9277
  const {
9276
- filterValues: initialFilteUrl,
9278
+ filterValues: initialFilterUrl,
9277
9279
  sortBy: initialSortUrl
9278
9280
  } = parseFilterAndSort(window.location.search);
9279
- const [filterValues_0, setFilterValues] = React__default.useState(forceFilter ?? initialFilteUrl ?? initialFilter ?? void 0);
9281
+ const [filterValues_0, setFilterValues] = React__default.useState(forceFilter ?? (updateUrl ? initialFilterUrl : void 0) ?? initialFilter ?? void 0);
9280
9282
  const [sortBy_0, setSortBy] = React__default.useState(initialSortUrl ?? initialSortInternal);
9281
9283
  useUpdateUrl(filterValues_0, sortBy_0, searchString, updateUrl);
9282
9284
  const collectionScroll = scrollRestoration?.getCollectionScroll(fullPath, filterValues_0);
@@ -9441,8 +9443,30 @@ function encodeFilterAndSort(filterValues, sortBy) {
9441
9443
  if (filterValues) {
9442
9444
  Object.entries(filterValues).forEach(([key, value]) => {
9443
9445
  if (value) {
9444
- entries[encodeURIComponent(`${key}_op`)] = encodeURIComponent(value[0]);
9445
- entries[encodeURIComponent(`${key}_value`)] = encodeURIComponent(value[1]);
9446
+ const [op, val] = value;
9447
+ let encodedValue = val;
9448
+ try {
9449
+ if (typeof val === "object") {
9450
+ if (val instanceof Date) {
9451
+ encodedValue = val.toISOString();
9452
+ } else if (Array.isArray(val)) {
9453
+ encodedValue = JSON.stringify(val, (key2, value2) => {
9454
+ if (value2 instanceof EntityReference) {
9455
+ return encodeRef(value2);
9456
+ }
9457
+ return value2;
9458
+ });
9459
+ } else if (val instanceof EntityReference) {
9460
+ encodedValue = encodeRef(val);
9461
+ }
9462
+ }
9463
+ } catch (e) {
9464
+ encodedValue = val;
9465
+ }
9466
+ if (encodedValue !== void 0) {
9467
+ entries[encodeURIComponent(`${key}_op`)] = encodeURIComponent(op);
9468
+ entries[encodeURIComponent(`${key}_value`)] = encodeURIComponent(encodedValue.toString());
9469
+ }
9446
9470
  }
9447
9471
  });
9448
9472
  }
@@ -9457,10 +9481,14 @@ function parseFilterAndSort(search) {
9457
9481
  let sortBy = void 0;
9458
9482
  entries.forEach((value, key) => {
9459
9483
  if (key === "__sort") {
9460
- sortBy = [value, entries.get("__sort_order")];
9484
+ sortBy = [decodeURIComponent(value), entries.get("__sort_order")];
9461
9485
  } else if (key.endsWith("_op")) {
9462
- const filterValue = entries.get(`${key.replace("_op", "_value")}`);
9463
- filterValues[key.replace("_op", "")] = [value, filterValue];
9486
+ const field = key.replace("_op", "");
9487
+ const filterOp = decodeURIComponent(value);
9488
+ const filterValStr = entries.get(`${field}_value`);
9489
+ if (filterValStr !== null) {
9490
+ filterValues[field] = [filterOp, decodeString(filterValStr)];
9491
+ }
9464
9492
  }
9465
9493
  });
9466
9494
  return {
@@ -9468,6 +9496,43 @@ function parseFilterAndSort(search) {
9468
9496
  sortBy
9469
9497
  };
9470
9498
  }
9499
+ function isDate(dateString) {
9500
+ const regexPattern = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;
9501
+ if (!regexPattern.test(dateString)) {
9502
+ return false;
9503
+ }
9504
+ const date = new Date(dateString);
9505
+ return date.toISOString() === dateString;
9506
+ }
9507
+ function encodeRef(val) {
9508
+ return `ref::${val.path}/${val.id}`;
9509
+ }
9510
+ function decodeString(val) {
9511
+ let parsedFilterVal = val;
9512
+ if (isDate(val)) {
9513
+ try {
9514
+ parsedFilterVal = new Date(val);
9515
+ } catch (e) {
9516
+ }
9517
+ }
9518
+ if (typeof parsedFilterVal === "string") {
9519
+ try {
9520
+ parsedFilterVal = JSON.parse(parsedFilterVal, (key, value) => {
9521
+ if (typeof value === "string" && value.startsWith("ref::")) {
9522
+ const [path, id] = value.substring(5).split("/");
9523
+ return new EntityReference(id, path);
9524
+ }
9525
+ return value;
9526
+ });
9527
+ } catch (e) {
9528
+ }
9529
+ }
9530
+ if (typeof parsedFilterVal === "string" && parsedFilterVal.startsWith("ref::")) {
9531
+ const [path, id] = parsedFilterVal.substring(5).split("/");
9532
+ return new EntityReference(id, path);
9533
+ }
9534
+ return parsedFilterVal;
9535
+ }
9471
9536
  function useSelectionController(onSelectionChange) {
9472
9537
  const [selectedEntities, setSelectedEntities] = useState([]);
9473
9538
  const toggleEntitySelection = useCallback((entity, newSelectedState) => {
@@ -10008,7 +10073,8 @@ function ReferenceSelectionTable({
10008
10073
  fullPath,
10009
10074
  collection,
10010
10075
  entitiesDisplayedFirst,
10011
- forceFilter
10076
+ forceFilter,
10077
+ updateUrl: false
10012
10078
  });
10013
10079
  const {
10014
10080
  textSearchLoading,
@@ -13705,7 +13771,7 @@ function ArrayContainer({
13705
13771
  return /* @__PURE__ */ jsx(Draggable, { draggableId: `array_field_${internalId_1}`, isDragDisabled: disabled, index: index_4, children: (provided_0, snapshot_0) => /* @__PURE__ */ jsx(ArrayContainerItem, { provided: provided_0, internalId: internalId_1, index: index_4, size, disabled, buildEntry, remove, copy, isDragging: snapshot_0.isDragging, storedProps: itemCustomPropsRef.current[internalId_1], updateItemCustomProps, addInIndex, includeAddButton }) }, `array_field_${internalId_1}`);
13706
13772
  }),
13707
13773
  droppableProvided.placeholder,
13708
- includeAddButton && /* @__PURE__ */ jsx("div", { className: "my-4 justify-center text-left", children: /* @__PURE__ */ jsx(Button, { variant: "text", size: size === "small" ? "small" : "medium", color: "primary", disabled: disabled || value.length >= max, startIcon: /* @__PURE__ */ jsx(AddIcon, {}), onClick: insertInEnd, children: addLabel ?? "Add" }) })
13774
+ includeAddButton && /* @__PURE__ */ jsx("div", { className: "my-4 justify-center text-left", children: /* @__PURE__ */ jsx(Button, { variant: "text", size: size === "small" ? "small" : "medium", color: "primary", disabled: disabled || value?.length >= max, startIcon: /* @__PURE__ */ jsx(AddIcon, {}), onClick: insertInEnd, children: addLabel ?? "Add" }) })
13709
13775
  ] }) }) });
13710
13776
  }
13711
13777
  function ArrayContainerItem(t0) {
@@ -22967,8 +23033,10 @@ function EntityFullScreenRoute({
22967
23033
  const collectionPath = navigation.resolveIdsFrom(isNew ? lastCollectionEntry.path : lastEntityEntry.path);
22968
23034
  return /* @__PURE__ */ jsxs(Fragment, { children: [
22969
23035
  /* @__PURE__ */ jsx(EntityEditView, { entityId: isNew ? void 0 : entityId, collection, layout: "full_screen", path: collectionPath, selectedTab: selectedTab ?? void 0, onValuesModified: (modified) => blocked.current = modified, onSaved: (params) => {
23036
+ console.log("EntityEditView Saved", params);
22970
23037
  updateUrl(params.entityId, params.selectedTab, true, params.path, isNew);
22971
23038
  }, onTabChange: (params_0) => {
23039
+ console.log("EntityEditView onTabChange", params_0);
22972
23040
  updateUrl(params_0.entityId, params_0.selectedTab, !isNew, params_0.path, isNew);
22973
23041
  setSelectedTab(params_0.selectedTab);
22974
23042
  }, parentCollectionIds }, collection.id + "_" + (isNew ? "new" : entityId)),