@firecms/core 3.0.0-canary.170 → 3.0.0-canary.171
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/components/SelectableTable/filters/ReferenceFilterField.d.ts +1 -1
- package/dist/index.es.js +80 -14
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +80 -14
- package/dist/index.umd.js.map +1 -1
- package/package.json +5 -5
- package/src/components/ArrayContainer.tsx +1 -1
- package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +2 -1
- package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +7 -7
- package/src/components/common/useDataSourceTableController.tsx +83 -8
package/dist/index.umd.js
CHANGED
|
@@ -8360,18 +8360,20 @@
|
|
|
8360
8360
|
};
|
|
8361
8361
|
const multipleSelectOperations$2 = ["array-contains-any", "in", "not-in"];
|
|
8362
8362
|
function ReferenceFilterField({
|
|
8363
|
-
name,
|
|
8364
8363
|
value,
|
|
8365
8364
|
setValue,
|
|
8366
8365
|
isArray,
|
|
8367
8366
|
path,
|
|
8368
|
-
title,
|
|
8369
8367
|
includeId = true,
|
|
8370
8368
|
previewProperties,
|
|
8371
8369
|
setHidden
|
|
8372
8370
|
}) {
|
|
8373
8371
|
const possibleOperations = isArray ? ["array-contains"] : ["==", "!=", ">", "<", ">=", "<="];
|
|
8374
|
-
|
|
8372
|
+
if (isArray) {
|
|
8373
|
+
possibleOperations.push("array-contains-any");
|
|
8374
|
+
} else {
|
|
8375
|
+
possibleOperations.push("in", "not-in");
|
|
8376
|
+
}
|
|
8375
8377
|
const [fieldOperation, fieldValue] = value || [possibleOperations[0], void 0];
|
|
8376
8378
|
const [operation, setOperation] = React.useState(fieldOperation);
|
|
8377
8379
|
const [internalValue, setInternalValue] = React.useState(fieldValue);
|
|
@@ -8426,11 +8428,11 @@
|
|
|
8426
8428
|
const buildEntry = (reference) => {
|
|
8427
8429
|
return /* @__PURE__ */ jsxRuntime.jsx(ReferencePreview, { disabled: !path, previewProperties, size: "medium", onClick: doOpenDialog, reference, hover: true, includeId, includeEntityLink: false });
|
|
8428
8430
|
};
|
|
8429
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-[
|
|
8431
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-[480px] flex-row", children: [
|
|
8430
8432
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-[140px]", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select, { value: operation, size: "large", fullWidth: true, onValueChange: (value_0) => {
|
|
8431
8433
|
updateFilter(value_0, internalValue);
|
|
8432
8434
|
}, renderValue: (op_0) => operationLabels$2[op_0], children: possibleOperations.map((op_1) => /* @__PURE__ */ jsxRuntime.jsx(ui.SelectItem, { value: op_1, children: operationLabels$2[op_1] }, op_1)) }) }),
|
|
8433
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-grow ml-2 h-full gap-2 flex flex-col", children: [
|
|
8435
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-grow ml-2 h-full gap-2 flex flex-col w-[340px]", children: [
|
|
8434
8436
|
internalValue && Array.isArray(internalValue) && /* @__PURE__ */ jsxRuntime.jsx("div", { children: internalValue.map((ref_0, index) => buildEntry(ref_0)) }),
|
|
8435
8437
|
internalValue && !Array.isArray(internalValue) && /* @__PURE__ */ jsxRuntime.jsx("div", { children: buildEntry(internalValue) }),
|
|
8436
8438
|
(!internalValue || Array.isArray(internalValue) && internalValue.length === 0) && /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { onClick: doOpenDialog, variant: "outlined", size: "large", className: "h-full w-full", children: multiple ? "Select references" : "Select reference" }),
|
|
@@ -9275,10 +9277,10 @@
|
|
|
9275
9277
|
return initialSort;
|
|
9276
9278
|
}, [initialSort, forceFilter]);
|
|
9277
9279
|
const {
|
|
9278
|
-
filterValues:
|
|
9280
|
+
filterValues: initialFilterUrl,
|
|
9279
9281
|
sortBy: initialSortUrl
|
|
9280
9282
|
} = parseFilterAndSort(window.location.search);
|
|
9281
|
-
const [filterValues_0, setFilterValues] = React.useState(forceFilter ??
|
|
9283
|
+
const [filterValues_0, setFilterValues] = React.useState(forceFilter ?? (updateUrl ? initialFilterUrl : void 0) ?? initialFilter ?? void 0);
|
|
9282
9284
|
const [sortBy_0, setSortBy] = React.useState(initialSortUrl ?? initialSortInternal);
|
|
9283
9285
|
useUpdateUrl(filterValues_0, sortBy_0, searchString, updateUrl);
|
|
9284
9286
|
const collectionScroll = scrollRestoration?.getCollectionScroll(fullPath, filterValues_0);
|
|
@@ -9443,8 +9445,30 @@
|
|
|
9443
9445
|
if (filterValues) {
|
|
9444
9446
|
Object.entries(filterValues).forEach(([key, value]) => {
|
|
9445
9447
|
if (value) {
|
|
9446
|
-
|
|
9447
|
-
|
|
9448
|
+
const [op, val] = value;
|
|
9449
|
+
let encodedValue = val;
|
|
9450
|
+
try {
|
|
9451
|
+
if (typeof val === "object") {
|
|
9452
|
+
if (val instanceof Date) {
|
|
9453
|
+
encodedValue = val.toISOString();
|
|
9454
|
+
} else if (Array.isArray(val)) {
|
|
9455
|
+
encodedValue = JSON.stringify(val, (key2, value2) => {
|
|
9456
|
+
if (value2 instanceof EntityReference) {
|
|
9457
|
+
return encodeRef(value2);
|
|
9458
|
+
}
|
|
9459
|
+
return value2;
|
|
9460
|
+
});
|
|
9461
|
+
} else if (val instanceof EntityReference) {
|
|
9462
|
+
encodedValue = encodeRef(val);
|
|
9463
|
+
}
|
|
9464
|
+
}
|
|
9465
|
+
} catch (e) {
|
|
9466
|
+
encodedValue = val;
|
|
9467
|
+
}
|
|
9468
|
+
if (encodedValue !== void 0) {
|
|
9469
|
+
entries[encodeURIComponent(`${key}_op`)] = encodeURIComponent(op);
|
|
9470
|
+
entries[encodeURIComponent(`${key}_value`)] = encodeURIComponent(encodedValue.toString());
|
|
9471
|
+
}
|
|
9448
9472
|
}
|
|
9449
9473
|
});
|
|
9450
9474
|
}
|
|
@@ -9459,10 +9483,14 @@
|
|
|
9459
9483
|
let sortBy = void 0;
|
|
9460
9484
|
entries.forEach((value, key) => {
|
|
9461
9485
|
if (key === "__sort") {
|
|
9462
|
-
sortBy = [value, entries.get("__sort_order")];
|
|
9486
|
+
sortBy = [decodeURIComponent(value), entries.get("__sort_order")];
|
|
9463
9487
|
} else if (key.endsWith("_op")) {
|
|
9464
|
-
const
|
|
9465
|
-
|
|
9488
|
+
const field = key.replace("_op", "");
|
|
9489
|
+
const filterOp = decodeURIComponent(value);
|
|
9490
|
+
const filterValStr = entries.get(`${field}_value`);
|
|
9491
|
+
if (filterValStr !== null) {
|
|
9492
|
+
filterValues[field] = [filterOp, decodeString(filterValStr)];
|
|
9493
|
+
}
|
|
9466
9494
|
}
|
|
9467
9495
|
});
|
|
9468
9496
|
return {
|
|
@@ -9470,6 +9498,43 @@
|
|
|
9470
9498
|
sortBy
|
|
9471
9499
|
};
|
|
9472
9500
|
}
|
|
9501
|
+
function isDate(dateString) {
|
|
9502
|
+
const regexPattern = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;
|
|
9503
|
+
if (!regexPattern.test(dateString)) {
|
|
9504
|
+
return false;
|
|
9505
|
+
}
|
|
9506
|
+
const date = new Date(dateString);
|
|
9507
|
+
return date.toISOString() === dateString;
|
|
9508
|
+
}
|
|
9509
|
+
function encodeRef(val) {
|
|
9510
|
+
return `ref::${val.path}/${val.id}`;
|
|
9511
|
+
}
|
|
9512
|
+
function decodeString(val) {
|
|
9513
|
+
let parsedFilterVal = val;
|
|
9514
|
+
if (isDate(val)) {
|
|
9515
|
+
try {
|
|
9516
|
+
parsedFilterVal = new Date(val);
|
|
9517
|
+
} catch (e) {
|
|
9518
|
+
}
|
|
9519
|
+
}
|
|
9520
|
+
if (typeof parsedFilterVal === "string") {
|
|
9521
|
+
try {
|
|
9522
|
+
parsedFilterVal = JSON.parse(parsedFilterVal, (key, value) => {
|
|
9523
|
+
if (typeof value === "string" && value.startsWith("ref::")) {
|
|
9524
|
+
const [path, id] = value.substring(5).split("/");
|
|
9525
|
+
return new EntityReference(id, path);
|
|
9526
|
+
}
|
|
9527
|
+
return value;
|
|
9528
|
+
});
|
|
9529
|
+
} catch (e) {
|
|
9530
|
+
}
|
|
9531
|
+
}
|
|
9532
|
+
if (typeof parsedFilterVal === "string" && parsedFilterVal.startsWith("ref::")) {
|
|
9533
|
+
const [path, id] = parsedFilterVal.substring(5).split("/");
|
|
9534
|
+
return new EntityReference(id, path);
|
|
9535
|
+
}
|
|
9536
|
+
return parsedFilterVal;
|
|
9537
|
+
}
|
|
9473
9538
|
function useSelectionController(onSelectionChange) {
|
|
9474
9539
|
const [selectedEntities, setSelectedEntities] = React.useState([]);
|
|
9475
9540
|
const toggleEntitySelection = React.useCallback((entity, newSelectedState) => {
|
|
@@ -10010,7 +10075,8 @@
|
|
|
10010
10075
|
fullPath,
|
|
10011
10076
|
collection,
|
|
10012
10077
|
entitiesDisplayedFirst,
|
|
10013
|
-
forceFilter
|
|
10078
|
+
forceFilter,
|
|
10079
|
+
updateUrl: false
|
|
10014
10080
|
});
|
|
10015
10081
|
const {
|
|
10016
10082
|
textSearchLoading,
|
|
@@ -13707,7 +13773,7 @@
|
|
|
13707
13773
|
return /* @__PURE__ */ jsxRuntime.jsx(dnd.Draggable, { draggableId: `array_field_${internalId_1}`, isDragDisabled: disabled, index: index_4, children: (provided_0, snapshot_0) => /* @__PURE__ */ jsxRuntime.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}`);
|
|
13708
13774
|
}),
|
|
13709
13775
|
droppableProvided.placeholder,
|
|
13710
|
-
includeAddButton && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "my-4 justify-center text-left", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "text", size: size === "small" ? "small" : "medium", color: "primary", disabled: disabled || value
|
|
13776
|
+
includeAddButton && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "my-4 justify-center text-left", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "text", size: size === "small" ? "small" : "medium", color: "primary", disabled: disabled || value?.length >= max, startIcon: /* @__PURE__ */ jsxRuntime.jsx(ui.AddIcon, {}), onClick: insertInEnd, children: addLabel ?? "Add" }) })
|
|
13711
13777
|
] }) }) });
|
|
13712
13778
|
}
|
|
13713
13779
|
function ArrayContainerItem(t0) {
|