@rebasepro/core 0.2.5 → 0.4.0
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/common/types.d.ts +3 -3
- package/dist/index.es.js +42 -36
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +42 -36
- package/dist/index.umd.js.map +1 -1
- package/package.json +6 -6
- package/src/components/common/types.tsx +3 -3
- package/src/components/common/useDataTableController.tsx +47 -35
- package/src/hooks/useResolvedComponent.tsx +3 -3
- package/src/locales/en.ts +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Property } from "@rebasepro/types";
|
|
1
|
+
import type { Property, Entity } from "@rebasepro/types";
|
|
2
2
|
import { CollectionSize, SelectedCellProps } from "@rebasepro/types";
|
|
3
3
|
export type EntityCollectionTableController<M extends Record<string, unknown>> = {
|
|
4
4
|
/**
|
|
@@ -26,7 +26,7 @@ export type EntityCollectionTableController<M extends Record<string, unknown>> =
|
|
|
26
26
|
* Callback used when the value of a cell has changed.
|
|
27
27
|
* @param params
|
|
28
28
|
*/
|
|
29
|
-
onValueChange?: (params: OnCellValueChangeParams<unknown, M
|
|
29
|
+
onValueChange?: (params: OnCellValueChangeParams<unknown, Entity<M>>) => void;
|
|
30
30
|
/**
|
|
31
31
|
* Size of the elements in the collection
|
|
32
32
|
*/
|
|
@@ -56,7 +56,7 @@ export type UniqueFieldValidator = (props: {
|
|
|
56
56
|
* Callback when a cell has changed in a table
|
|
57
57
|
* @group Collection components
|
|
58
58
|
*/
|
|
59
|
-
export type OnCellValueChange<T, M extends Record<string, unknown>> = (params: OnCellValueChangeParams<T, M
|
|
59
|
+
export type OnCellValueChange<T, M extends Record<string, unknown>> = (params: OnCellValueChangeParams<T, Entity<M>>) => Promise<void> | void;
|
|
60
60
|
/**
|
|
61
61
|
* @group Collection components
|
|
62
62
|
*/
|
package/dist/index.es.js
CHANGED
|
@@ -2644,15 +2644,18 @@ function useDataTableController({
|
|
|
2644
2644
|
if (filterValues_0) {
|
|
2645
2645
|
Object.entries(filterValues_0).forEach(([key, value]) => {
|
|
2646
2646
|
if (value && Array.isArray(value)) {
|
|
2647
|
-
const [
|
|
2648
|
-
const
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
stringVal
|
|
2652
|
-
|
|
2653
|
-
|
|
2647
|
+
const conditions = Array.isArray(value[0]) ? value : [value];
|
|
2648
|
+
const [op, val] = conditions[0] || [];
|
|
2649
|
+
if (op) {
|
|
2650
|
+
const postgrestOp = op === "==" ? "eq" : op === "!=" ? "neq" : op === ">" ? "gt" : op === ">=" ? "gte" : op === "<" ? "lt" : op === "<=" ? "lte" : op === "in" ? "in" : op === "not-in" ? "nin" : op === "array-contains" ? "cs" : op === "array-contains-any" ? "csa" : "eq";
|
|
2651
|
+
let stringVal;
|
|
2652
|
+
if (Array.isArray(val)) {
|
|
2653
|
+
stringVal = `(${val.join(",")})`;
|
|
2654
|
+
} else {
|
|
2655
|
+
stringVal = String(val);
|
|
2656
|
+
}
|
|
2657
|
+
whereMap[key] = `${postgrestOp}.${stringVal}`;
|
|
2654
2658
|
}
|
|
2655
|
-
whereMap[key] = `${postgrestOp}.${stringVal}`;
|
|
2656
2659
|
}
|
|
2657
2660
|
});
|
|
2658
2661
|
}
|
|
@@ -2754,34 +2757,37 @@ function encodeFilterAndSort(filterValues, sortBy) {
|
|
|
2754
2757
|
if (filterValues) {
|
|
2755
2758
|
Object.entries(filterValues).forEach(([key, value]) => {
|
|
2756
2759
|
if (value) {
|
|
2757
|
-
const [
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2760
|
+
const conditions = Array.isArray(value[0]) ? value : [value];
|
|
2761
|
+
const [op, val] = conditions[0] || [];
|
|
2762
|
+
if (op) {
|
|
2763
|
+
let encodedValue = val;
|
|
2764
|
+
try {
|
|
2765
|
+
if (typeof val === "object") {
|
|
2766
|
+
if (val instanceof Date) {
|
|
2767
|
+
encodedValue = val.toISOString();
|
|
2768
|
+
} else if (Array.isArray(val)) {
|
|
2769
|
+
encodedValue = JSON.stringify(val, (k, v) => {
|
|
2770
|
+
if (v instanceof EntityRelation) {
|
|
2771
|
+
return encodeRelation(v);
|
|
2772
|
+
}
|
|
2773
|
+
if (v instanceof EntityReference) {
|
|
2774
|
+
return encodeReference(v);
|
|
2775
|
+
}
|
|
2776
|
+
return v;
|
|
2777
|
+
});
|
|
2778
|
+
} else if (val instanceof EntityRelation) {
|
|
2779
|
+
encodedValue = encodeRelation(val);
|
|
2780
|
+
} else if (val instanceof EntityReference) {
|
|
2781
|
+
encodedValue = encodeReference(val);
|
|
2782
|
+
}
|
|
2777
2783
|
}
|
|
2784
|
+
} catch (e) {
|
|
2785
|
+
encodedValue = val;
|
|
2786
|
+
}
|
|
2787
|
+
if (encodedValue !== void 0) {
|
|
2788
|
+
entries[encodeURIComponent(`${key}_op`)] = encodeURIComponent(op);
|
|
2789
|
+
entries[encodeURIComponent(`${key}_value`)] = encodedValue ? encodeURIComponent(String(encodedValue)) : "null";
|
|
2778
2790
|
}
|
|
2779
|
-
} catch (e) {
|
|
2780
|
-
encodedValue = val;
|
|
2781
|
-
}
|
|
2782
|
-
if (encodedValue !== void 0) {
|
|
2783
|
-
entries[encodeURIComponent(`${key}_op`)] = encodeURIComponent(op);
|
|
2784
|
-
entries[encodeURIComponent(`${key}_value`)] = encodedValue ? encodeURIComponent(String(encodedValue)) : "null";
|
|
2785
2791
|
}
|
|
2786
2792
|
}
|
|
2787
2793
|
});
|
|
@@ -8089,14 +8095,14 @@ const en = {
|
|
|
8089
8095
|
data_imported_successfully: "Data imported successfully",
|
|
8090
8096
|
export: "Export",
|
|
8091
8097
|
export_data: "Export data",
|
|
8092
|
-
download_table_csv: "Download the
|
|
8098
|
+
download_table_csv: "Download the content of this table as a CSV",
|
|
8093
8099
|
csv: "CSV",
|
|
8094
8100
|
json: "JSON",
|
|
8095
8101
|
dates_as_timestamps: "Dates as timestamps",
|
|
8096
8102
|
dates_as_strings: "Dates as strings",
|
|
8097
8103
|
flatten_arrays: "Flatten arrays",
|
|
8098
8104
|
download: "Download",
|
|
8099
|
-
large_number_of_documents: "This
|
|
8105
|
+
large_number_of_documents: "This collection has a large number of documents ({{count}}).",
|
|
8100
8106
|
include_undefined_values: "Include undefined values",
|
|
8101
8107
|
submit: "Submit",
|
|
8102
8108
|
no_filterable_properties: "No filterable properties available",
|