@rebasepro/core 0.0.1-canary.bbcb8b4 → 0.0.1-canary.c53f5db
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/useDataTableController.d.ts +3 -3
- package/dist/hooks/data/useRelationSelector.d.ts +2 -2
- package/dist/index.es.js +41 -18
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +41 -18
- package/dist/index.umd.js.map +1 -1
- package/package.json +7 -7
- package/src/components/common/useDataTableController.tsx +15 -15
- package/src/hooks/data/useRelationSelector.tsx +6 -6
- package/src/hooks/useStudioBridge.tsx +2 -1
- package/src/locales/de.ts +3 -0
- package/src/locales/en.ts +5 -0
- package/src/locales/es.ts +3 -0
- package/src/locales/fr.ts +3 -0
- package/src/locales/hi.ts +3 -0
- package/src/locales/it.ts +3 -0
- package/src/locales/pt.ts +3 -0
|
@@ -20,7 +20,7 @@ export type DataTableControllerProps<M extends Record<string, any> = any> = {
|
|
|
20
20
|
/**
|
|
21
21
|
* Force filter to be applied to the table.
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
fixedFilter?: FilterValues<string>;
|
|
24
24
|
scrollRestoration?: ScrollRestorationController;
|
|
25
25
|
/**
|
|
26
26
|
* When set to true the filters and sort will be updated in the URL
|
|
@@ -39,7 +39,7 @@ export type DataTableControllerProps<M extends Record<string, any> = any> = {
|
|
|
39
39
|
* @param scrollRestoration
|
|
40
40
|
* @param entitiesDisplayedFirst
|
|
41
41
|
* @param lastDeleteTimestamp
|
|
42
|
-
* @param
|
|
42
|
+
* @param fixedFilterFromProps
|
|
43
43
|
* @param updateUrl
|
|
44
44
|
*/
|
|
45
|
-
export declare function useDataTableController<M extends Record<string, any> = any, USER extends User = User>({ path, collection, scrollRestoration, entitiesDisplayedFirst, lastDeleteTimestamp: _lastDeleteTimestamp,
|
|
45
|
+
export declare function useDataTableController<M extends Record<string, any> = any, USER extends User = User>({ path, collection, scrollRestoration, entitiesDisplayedFirst, lastDeleteTimestamp: _lastDeleteTimestamp, fixedFilter: fixedFilterFromProps, updateUrl }: DataTableControllerProps<M>): EntityTableController<M>;
|
|
@@ -19,7 +19,7 @@ export interface UseRelationSelectorProps<M extends Record<string, any> = any> {
|
|
|
19
19
|
/**
|
|
20
20
|
* Force filter to be applied to the relation search
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
fixedFilter?: FilterValues<string>;
|
|
23
23
|
/**
|
|
24
24
|
* Page size for pagination
|
|
25
25
|
*/
|
|
@@ -49,4 +49,4 @@ export interface RelationSelectorController {
|
|
|
49
49
|
/**
|
|
50
50
|
* Hook to manage relation selection with data fetching from Rebase data source
|
|
51
51
|
*/
|
|
52
|
-
export declare function useRelationSelector<M extends Record<string, any> = any>({ path, collection,
|
|
52
|
+
export declare function useRelationSelector<M extends Record<string, any> = any>({ path, collection, fixedFilter, pageSize, getLabelFromEntity, getDescriptionFromEntity, descriptionProperty }: UseRelationSelectorProps<M>): RelationSelectorController;
|
package/dist/index.es.js
CHANGED
|
@@ -581,7 +581,7 @@ const DEFAULT_PAGE_SIZE$2 = 10;
|
|
|
581
581
|
function useRelationSelector({
|
|
582
582
|
path,
|
|
583
583
|
collection,
|
|
584
|
-
|
|
584
|
+
fixedFilter,
|
|
585
585
|
pageSize = DEFAULT_PAGE_SIZE$2,
|
|
586
586
|
getLabelFromEntity,
|
|
587
587
|
getDescriptionFromEntity,
|
|
@@ -642,8 +642,8 @@ function useRelationSelector({
|
|
|
642
642
|
setError(void 0);
|
|
643
643
|
setLoading(true);
|
|
644
644
|
const whereMap = {};
|
|
645
|
-
if (
|
|
646
|
-
Object.entries(
|
|
645
|
+
if (fixedFilter) {
|
|
646
|
+
Object.entries(fixedFilter).forEach(([key, value]) => {
|
|
647
647
|
if (value && Array.isArray(value)) {
|
|
648
648
|
const [op, val] = value;
|
|
649
649
|
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";
|
|
@@ -690,7 +690,7 @@ function useRelationSelector({
|
|
|
690
690
|
};
|
|
691
691
|
}
|
|
692
692
|
unsubscribeRef.current = unsubscribe || null;
|
|
693
|
-
}, [dataClient, path,
|
|
693
|
+
}, [dataClient, path, fixedFilter, limit, currentSearch, entityToRelationItem, cleanupSubscription, setLoading]);
|
|
694
694
|
const search = useCallback((searchString) => {
|
|
695
695
|
if (searchTimeoutRef.current) {
|
|
696
696
|
clearTimeout(searchTimeoutRef.current);
|
|
@@ -2468,17 +2468,17 @@ function useDataTableController({
|
|
|
2468
2468
|
scrollRestoration,
|
|
2469
2469
|
entitiesDisplayedFirst,
|
|
2470
2470
|
lastDeleteTimestamp: _lastDeleteTimestamp,
|
|
2471
|
-
|
|
2471
|
+
fixedFilter: fixedFilterFromProps,
|
|
2472
2472
|
updateUrl
|
|
2473
2473
|
}) {
|
|
2474
2474
|
const {
|
|
2475
|
-
|
|
2475
|
+
defaultFilter,
|
|
2476
2476
|
sort,
|
|
2477
|
-
|
|
2477
|
+
fixedFilter: fixedFilterFromCollection
|
|
2478
2478
|
} = collection;
|
|
2479
2479
|
const [popupCell, setPopupCell] = React.useState(void 0);
|
|
2480
2480
|
const dataClient = useData();
|
|
2481
|
-
const
|
|
2481
|
+
const fixedFilter = fixedFilterFromProps ?? fixedFilterFromCollection;
|
|
2482
2482
|
const paginationEnabled = collection.pagination === void 0 || Boolean(collection.pagination);
|
|
2483
2483
|
const pageSize = typeof collection.pagination === "number" ? collection.pagination : DEFAULT_PAGE_SIZE;
|
|
2484
2484
|
const [searchString, setSearchString] = React.useState();
|
|
@@ -2486,18 +2486,18 @@ function useDataTableController({
|
|
|
2486
2486
|
return true;
|
|
2487
2487
|
}, []);
|
|
2488
2488
|
const sortInternal = useMemo(() => {
|
|
2489
|
-
if (sort &&
|
|
2489
|
+
if (sort && fixedFilter && !checkFilterCombination(fixedFilter, sort)) {
|
|
2490
2490
|
console.warn("Initial sort is not compatible with the force filter. Ignoring initial sort");
|
|
2491
2491
|
return void 0;
|
|
2492
2492
|
}
|
|
2493
2493
|
return sort;
|
|
2494
|
-
}, [sort,
|
|
2494
|
+
}, [sort, fixedFilter]);
|
|
2495
2495
|
const location = useLocation();
|
|
2496
2496
|
const {
|
|
2497
2497
|
filterValues: filterUrl,
|
|
2498
2498
|
sortBy: sortUrl
|
|
2499
2499
|
} = parseFilterAndSort(location.search);
|
|
2500
|
-
const [filterValues_0, setFilterValues] = React.useState(
|
|
2500
|
+
const [filterValues_0, setFilterValues] = React.useState(fixedFilter ?? (updateUrl ? filterUrl : void 0) ?? defaultFilter ?? void 0);
|
|
2501
2501
|
const [sortBy_0, setSortBy] = React.useState((updateUrl ? sortUrl : void 0) ?? sortInternal);
|
|
2502
2502
|
const initialSearchRef = React.useRef(location.search);
|
|
2503
2503
|
useEffect(() => {
|
|
@@ -2511,15 +2511,15 @@ function useDataTableController({
|
|
|
2511
2511
|
filterValues: urlFilterValues,
|
|
2512
2512
|
sortBy: urlSortBy
|
|
2513
2513
|
} = parseFilterAndSort(location.search);
|
|
2514
|
-
if (!
|
|
2514
|
+
if (!fixedFilter) {
|
|
2515
2515
|
setFilterValues(urlFilterValues);
|
|
2516
2516
|
}
|
|
2517
|
-
if (urlSortBy &&
|
|
2517
|
+
if (urlSortBy && fixedFilter && !checkFilterCombination(fixedFilter, urlSortBy)) {
|
|
2518
2518
|
console.warn("URL sort is not compatible with the force filter.");
|
|
2519
2519
|
} else {
|
|
2520
2520
|
setSortBy(urlSortBy);
|
|
2521
2521
|
}
|
|
2522
|
-
}, [location.search, updateUrl,
|
|
2522
|
+
}, [location.search, updateUrl, fixedFilter, checkFilterCombination]);
|
|
2523
2523
|
useUpdateUrl(filterValues_0, sortBy_0, searchString, updateUrl);
|
|
2524
2524
|
const collectionScroll = scrollRestoration?.getCollectionScroll(path, filterValues_0);
|
|
2525
2525
|
const initialItemCount = collectionScroll?.data.length ?? pageSize;
|
|
@@ -2553,9 +2553,9 @@ function useDataTableController({
|
|
|
2553
2553
|
const [dataLoading, setDataLoading] = useState(false);
|
|
2554
2554
|
const [dataLoadingError, setDataLoadingError] = useState();
|
|
2555
2555
|
const [noMoreToLoad, setNoMoreToLoad] = useState(false);
|
|
2556
|
-
const clearFilter = useCallback(() => setFilterValues(
|
|
2556
|
+
const clearFilter = useCallback(() => setFilterValues(fixedFilter ?? void 0), [fixedFilter]);
|
|
2557
2557
|
const updateFilterValues = useCallback((updatedFilter) => {
|
|
2558
|
-
if (
|
|
2558
|
+
if (fixedFilter) {
|
|
2559
2559
|
console.warn("Filter is not compatible with the force filter. Ignoring filter");
|
|
2560
2560
|
return;
|
|
2561
2561
|
}
|
|
@@ -2564,7 +2564,7 @@ function useDataTableController({
|
|
|
2564
2564
|
} else {
|
|
2565
2565
|
setFilterValues(updatedFilter);
|
|
2566
2566
|
}
|
|
2567
|
-
}, [
|
|
2567
|
+
}, [fixedFilter]);
|
|
2568
2568
|
useEffect(() => {
|
|
2569
2569
|
setDataLoading(true);
|
|
2570
2570
|
const onEntitiesUpdate = async (entities) => {
|
|
@@ -7784,6 +7784,10 @@ const en = {
|
|
|
7784
7784
|
reset_password: "Reset Password",
|
|
7785
7785
|
reset_password_success: "Password reset successfully",
|
|
7786
7786
|
reset_password_confirmation: "Are you sure you want to reset this user's password?",
|
|
7787
|
+
/** Permission-denied empty states */
|
|
7788
|
+
no_permission_to_view_users: "You don't have permission to view users",
|
|
7789
|
+
no_permission_to_view_roles: "You don't have permission to view roles",
|
|
7790
|
+
no_permission_description: "Contact an administrator if you need access to this section.",
|
|
7787
7791
|
error_resetting_password: "Error resetting password",
|
|
7788
7792
|
/** Editor table-bubble */
|
|
7789
7793
|
add_row_before: "Add row before",
|
|
@@ -8328,6 +8332,9 @@ const es = {
|
|
|
8328
8332
|
delete_user_confirmation: "¿Estás seguro de que quieres eliminar a este usuario?",
|
|
8329
8333
|
create_your_users_and_roles: "Crea tus usuarios y roles",
|
|
8330
8334
|
no_users_or_roles_defined: "No tienes usuarios ni roles. Puedes crear los roles por defecto y añadirte a ti mismo como administrador.",
|
|
8335
|
+
no_permission_to_view_users: "No tienes permisos para ver los usuarios",
|
|
8336
|
+
no_permission_to_view_roles: "No tienes permisos para ver los roles",
|
|
8337
|
+
no_permission_description: "Contacta a un administrador si necesitas acceso a esta sección.",
|
|
8331
8338
|
save_before_changing_schema: "Debes guardar el documento antes de cambiar el esquema",
|
|
8332
8339
|
edit_schema_for_this_form: "Editar esquema para este formulario",
|
|
8333
8340
|
no_permissions_to_edit_collection: "No tienes permisos para editar esta colección",
|
|
@@ -9172,6 +9179,9 @@ const de = {
|
|
|
9172
9179
|
delete_user_confirmation: "Sind Sie sicher, dass Sie diesen Benutzer löschen möchten?",
|
|
9173
9180
|
create_your_users_and_roles: "Erstellen Sie Ihre Benutzer und Rollen",
|
|
9174
9181
|
no_users_or_roles_defined: "Sie haben keine Benutzer oder Rollen definiert. Sie können Standardrollen erstellen und den aktuellen Benutzer als Administrator hinzufügen.",
|
|
9182
|
+
no_permission_to_view_users: "Sie haben keine Berechtigung, Benutzer anzuzeigen",
|
|
9183
|
+
no_permission_to_view_roles: "Sie haben keine Berechtigung, Rollen anzuzeigen",
|
|
9184
|
+
no_permission_description: "Wenden Sie sich an einen Administrator, wenn Sie Zugang zu diesem Bereich benötigen.",
|
|
9175
9185
|
save_before_changing_schema: "Sie müssen das Dokument speichern, bevor Sie das Schema ändern können",
|
|
9176
9186
|
edit_schema_for_this_form: "Schema für dieses Formular bearbeiten",
|
|
9177
9187
|
no_permissions_to_edit_collection: "Sie haben keine Berechtigung, diese Sammlung zu bearbeiten",
|
|
@@ -10013,6 +10023,9 @@ const fr = {
|
|
|
10013
10023
|
delete_user_confirmation: "Êtes-vous sûr de vouloir supprimer cet utilisateur ?",
|
|
10014
10024
|
create_your_users_and_roles: "Créez vos utilisateurs et rôles",
|
|
10015
10025
|
no_users_or_roles_defined: "Vous n'avez défini aucun utilisateur ni rôle. Vous pouvez créer les rôles par défaut et ajouter l'utilisateur actuel en tant qu'administrateur.",
|
|
10026
|
+
no_permission_to_view_users: "Vous n'avez pas la permission de voir les utilisateurs",
|
|
10027
|
+
no_permission_to_view_roles: "Vous n'avez pas la permission de voir les rôles",
|
|
10028
|
+
no_permission_description: "Contactez un administrateur si vous avez besoin d'accéder à cette section.",
|
|
10016
10029
|
save_before_changing_schema: "Vous devez enregistrer le document avant de modifier le schéma",
|
|
10017
10030
|
edit_schema_for_this_form: "Modifier le schéma de ce formulaire",
|
|
10018
10031
|
no_permissions_to_edit_collection: "Vous n'avez pas l'autorisation de modifier cette collection",
|
|
@@ -10854,6 +10867,9 @@ const it = {
|
|
|
10854
10867
|
delete_user_confirmation: "Sei sicuro di voler eliminare questo utente?",
|
|
10855
10868
|
create_your_users_and_roles: "Crea i tuoi utenti e ruoli",
|
|
10856
10869
|
no_users_or_roles_defined: "Non hai definito né utenti né ruoli. Puoi creare ruoli predefiniti e aggiungere l'utente corrente come amministratore.",
|
|
10870
|
+
no_permission_to_view_users: "Non hai i permessi per visualizzare gli utenti",
|
|
10871
|
+
no_permission_to_view_roles: "Non hai i permessi per visualizzare i ruoli",
|
|
10872
|
+
no_permission_description: "Contatta un amministratore se hai bisogno di accedere a questa sezione.",
|
|
10857
10873
|
save_before_changing_schema: "Devi salvare il documento prima di modificare lo schema",
|
|
10858
10874
|
edit_schema_for_this_form: "Modifica lo schema per questo modulo",
|
|
10859
10875
|
no_permissions_to_edit_collection: "Non hai i permessi per modificare questa collezione",
|
|
@@ -11695,6 +11711,9 @@ const hi = {
|
|
|
11695
11711
|
delete_user_confirmation: "क्या आप वाकई इस उपयोगकर्ता को हटाना चाहते हैं?",
|
|
11696
11712
|
create_your_users_and_roles: "अपने उपयोगकर्ता और भूमिकाएँ बनाएँ",
|
|
11697
11713
|
no_users_or_roles_defined: "आपके पास कोई उपयोगकर्ता या भूमिका परिभाषित नहीं है। आप डिफ़ॉल्ट भूमिकाएँ बना सकते हैं और वर्तमान उपयोगकर्ता को एडमिन के रूप में जोड़ सकते हैं।",
|
|
11714
|
+
no_permission_to_view_users: "आपको उपयोगकर्ताओं को देखने की अनुमति नहीं है",
|
|
11715
|
+
no_permission_to_view_roles: "आपको भूमिकाओं को देखने की अनुमति नहीं है",
|
|
11716
|
+
no_permission_description: "यदि आपको इस अनुभाग तक पहुँच की आवश्यकता है तो किसी व्यवस्थापक से संपर्क करें।",
|
|
11698
11717
|
save_before_changing_schema: "स्कीमा बदलने से पहले आपको दस्तावेज़ सहेजना होगा",
|
|
11699
11718
|
edit_schema_for_this_form: "इस फॉर्म के लिए स्कीमा संपादित करें",
|
|
11700
11719
|
no_permissions_to_edit_collection: "आपके पास इस संग्रह को संपादित करने की अनुमति नहीं है",
|
|
@@ -12536,6 +12555,9 @@ const pt = {
|
|
|
12536
12555
|
delete_user_confirmation: "Tem a certeza de que quer eliminar este utilizador?",
|
|
12537
12556
|
create_your_users_and_roles: "Crie os seus utilizadores e funções",
|
|
12538
12557
|
no_users_or_roles_defined: "Não tem utilizadores ou funções definidas. Pode criar funções predefinidas e adicionar o utilizador atual como administrador.",
|
|
12558
|
+
no_permission_to_view_users: "Não tem permissão para ver os utilizadores",
|
|
12559
|
+
no_permission_to_view_roles: "Não tem permissão para ver as funções",
|
|
12560
|
+
no_permission_description: "Contacte um administrador se precisar de acesso a esta secção.",
|
|
12539
12561
|
save_before_changing_schema: "Precisa de guardar o documento antes de alterar o esquema",
|
|
12540
12562
|
edit_schema_for_this_form: "Editar esquema para este formulário",
|
|
12541
12563
|
no_permissions_to_edit_collection: "Não tem permissões para editar esta coleção",
|
|
@@ -14469,7 +14491,8 @@ const NOOP_COLLECTION_REGISTRY = {
|
|
|
14469
14491
|
getCollection: () => void 0,
|
|
14470
14492
|
getRawCollection: () => void 0,
|
|
14471
14493
|
getParentReferencesFromPath: () => [],
|
|
14472
|
-
|
|
14494
|
+
getParentCollectionSlugs: () => [],
|
|
14495
|
+
getParentEntityIds: () => [],
|
|
14473
14496
|
convertIdsToPaths: () => [],
|
|
14474
14497
|
initialised: false
|
|
14475
14498
|
};
|