@rebasepro/core 0.2.4 → 0.2.5

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.
@@ -92,10 +92,18 @@ export interface LoginViewProps {
92
92
  * If not set, derived from `authController.capabilities.registration`.
93
93
  */
94
94
  registrationEnabled?: boolean;
95
+ /**
96
+ * Pre-fill the email field (e.g. for demo or testing environments).
97
+ */
98
+ defaultEmail?: string;
99
+ /**
100
+ * Pre-fill the password field (e.g. for demo or testing environments).
101
+ */
102
+ defaultPassword?: string;
95
103
  }
96
104
  /**
97
105
  * Generic login view component that works with any AuthControllerExtended.
98
106
  * Feature-detects capabilities to show/hide login methods.
99
107
  * @group Core
100
108
  */
101
- export declare function LoginView({ logo, authController, noUserComponent, disableSignupScreen, disabled, notAllowedError, googleClientId, githubClientId, linkedinClientId, title, subtitle, needsSetup, registrationEnabled, additionalComponent }: LoginViewProps): import("react/jsx-runtime").JSX.Element;
109
+ export declare function LoginView({ logo, authController, noUserComponent, disableSignupScreen, disabled, notAllowedError, googleClientId, githubClientId, linkedinClientId, title, subtitle, needsSetup, registrationEnabled, additionalComponent, defaultEmail, defaultPassword }: LoginViewProps): import("react/jsx-runtime").JSX.Element;
@@ -16,6 +16,14 @@ export interface CollectionFetchProps<M extends Record<string, any>> {
16
16
  * Number of entities to fetch
17
17
  */
18
18
  itemCount?: number;
19
+ /**
20
+ * Number of items to skip
21
+ */
22
+ offset?: number;
23
+ /**
24
+ * Page number (1-indexed), alternative to offset
25
+ */
26
+ page?: number;
19
27
  /**
20
28
  * Filter the fetched data by the property
21
29
  */
@@ -37,6 +45,7 @@ export interface CollectionFetchResult<M extends Record<string, any>> {
37
45
  dataLoading: boolean;
38
46
  noMoreToLoad: boolean;
39
47
  dataLoadingError?: Error;
48
+ totalCount?: number;
40
49
  }
41
50
  /**
42
51
  * This hook is used to fetch collections using a given collection
@@ -45,7 +54,9 @@ export interface CollectionFetchResult<M extends Record<string, any>> {
45
54
  * @param filterValues
46
55
  * @param sortBy
47
56
  * @param itemCount
57
+ * @param offset
58
+ * @param page
48
59
  * @param searchString
49
60
  * @group Hooks and utilities
50
61
  */
51
- export declare function useCollectionFetch<M extends Record<string, any>, USER extends User>({ path, collection, filterValues, sortBy, itemCount, searchString }: CollectionFetchProps<M>): CollectionFetchResult<M>;
62
+ export declare function useCollectionFetch<M extends Record<string, any>, USER extends User>({ path, collection, filterValues, sortBy, itemCount, offset, page, searchString }: CollectionFetchProps<M>): CollectionFetchResult<M>;
package/dist/index.es.js CHANGED
@@ -268,13 +268,15 @@ const useData = () => {
268
268
  return useContext(RebaseDataContext);
269
269
  };
270
270
  function useCollectionFetch(t0) {
271
- const $ = c(25);
271
+ const $ = c(30);
272
272
  const {
273
273
  path,
274
274
  collection,
275
275
  filterValues,
276
276
  sortBy,
277
277
  itemCount,
278
+ offset,
279
+ page,
278
280
  searchString
279
281
  } = t0;
280
282
  const dataClient = useData();
@@ -318,8 +320,9 @@ function useCollectionFetch(t0) {
318
320
  const [dataLoading, setDataLoading] = useState(false);
319
321
  const [dataLoadingError, setDataLoadingError] = useState();
320
322
  const [noMoreToLoad, setNoMoreToLoad] = useState(false);
323
+ const [totalCount, setTotalCount] = useState();
321
324
  let t3;
322
- if ($[3] !== collection.properties || $[4] !== dataClient || $[5] !== itemCount || $[6] !== orderByParams || $[7] !== path || $[8] !== searchString || $[9] !== whereParams) {
325
+ if ($[3] !== collection.properties || $[4] !== dataClient || $[5] !== itemCount || $[6] !== offset || $[7] !== orderByParams || $[8] !== page || $[9] !== path || $[10] !== searchString || $[11] !== whereParams) {
323
326
  t3 = () => {
324
327
  setDataLoading(true);
325
328
  const onEntitiesUpdate = async (res) => {
@@ -328,12 +331,14 @@ function useCollectionFetch(t0) {
328
331
  setDataLoadingError(void 0);
329
332
  setData(entities.map(_temp$7));
330
333
  setNoMoreToLoad(!res.meta.hasMore);
334
+ setTotalCount(res.meta.total);
331
335
  };
332
336
  const onError = (error) => {
333
337
  console.error("ERROR", error);
334
338
  setDataLoading(false);
335
339
  setData([]);
336
340
  setDataLoadingError(error);
341
+ setTotalCount(void 0);
337
342
  };
338
343
  const accessor = dataClient.collection(path);
339
344
  const hasRelations = collection.properties && Object.values(collection.properties).some(_temp2$4);
@@ -342,6 +347,8 @@ function useCollectionFetch(t0) {
342
347
  return accessor.listen({
343
348
  where: whereParams,
344
349
  limit: itemCount,
350
+ offset,
351
+ page,
345
352
  orderBy: orderByParams,
346
353
  searchString,
347
354
  include: includeParams
@@ -353,6 +360,8 @@ function useCollectionFetch(t0) {
353
360
  accessor.find({
354
361
  where: whereParams,
355
362
  limit: itemCount,
363
+ offset,
364
+ page,
356
365
  orderBy: orderByParams,
357
366
  searchString,
358
367
  include: includeParams
@@ -366,46 +375,52 @@ function useCollectionFetch(t0) {
366
375
  $[3] = collection.properties;
367
376
  $[4] = dataClient;
368
377
  $[5] = itemCount;
369
- $[6] = orderByParams;
370
- $[7] = path;
371
- $[8] = searchString;
372
- $[9] = whereParams;
373
- $[10] = t3;
378
+ $[6] = offset;
379
+ $[7] = orderByParams;
380
+ $[8] = page;
381
+ $[9] = path;
382
+ $[10] = searchString;
383
+ $[11] = whereParams;
384
+ $[12] = t3;
374
385
  } else {
375
- t3 = $[10];
386
+ t3 = $[12];
376
387
  }
377
388
  let t4;
378
- if ($[11] !== collection || $[12] !== currentSort || $[13] !== dataClient || $[14] !== filterValues || $[15] !== itemCount || $[16] !== path || $[17] !== searchString || $[18] !== sortByProperty) {
379
- t4 = [path, itemCount, currentSort, sortByProperty, filterValues, searchString, dataClient, collection];
380
- $[11] = collection;
381
- $[12] = currentSort;
382
- $[13] = dataClient;
383
- $[14] = filterValues;
384
- $[15] = itemCount;
385
- $[16] = path;
386
- $[17] = searchString;
387
- $[18] = sortByProperty;
388
- $[19] = t4;
389
- } else {
390
- t4 = $[19];
389
+ if ($[13] !== collection || $[14] !== currentSort || $[15] !== dataClient || $[16] !== filterValues || $[17] !== itemCount || $[18] !== offset || $[19] !== page || $[20] !== path || $[21] !== searchString || $[22] !== sortByProperty) {
390
+ t4 = [path, itemCount, offset, page, currentSort, sortByProperty, filterValues, searchString, dataClient, collection];
391
+ $[13] = collection;
392
+ $[14] = currentSort;
393
+ $[15] = dataClient;
394
+ $[16] = filterValues;
395
+ $[17] = itemCount;
396
+ $[18] = offset;
397
+ $[19] = page;
398
+ $[20] = path;
399
+ $[21] = searchString;
400
+ $[22] = sortByProperty;
401
+ $[23] = t4;
402
+ } else {
403
+ t4 = $[23];
391
404
  }
392
405
  useEffect(t3, t4);
393
406
  let t5;
394
407
  let t6;
395
- if ($[20] !== data || $[21] !== dataLoading || $[22] !== dataLoadingError || $[23] !== noMoreToLoad) {
408
+ if ($[24] !== data || $[25] !== dataLoading || $[26] !== dataLoadingError || $[27] !== noMoreToLoad || $[28] !== totalCount) {
396
409
  t6 = {
397
410
  data,
398
411
  dataLoading,
399
412
  dataLoadingError,
400
- noMoreToLoad
413
+ noMoreToLoad,
414
+ totalCount
401
415
  };
402
- $[20] = data;
403
- $[21] = dataLoading;
404
- $[22] = dataLoadingError;
405
- $[23] = noMoreToLoad;
406
- $[24] = t6;
416
+ $[24] = data;
417
+ $[25] = dataLoading;
418
+ $[26] = dataLoadingError;
419
+ $[27] = noMoreToLoad;
420
+ $[28] = totalCount;
421
+ $[29] = t6;
407
422
  } else {
408
- t6 = $[24];
423
+ t6 = $[29];
409
424
  }
410
425
  t5 = t6;
411
426
  return t5;
@@ -883,7 +898,7 @@ function useUserSelector({
883
898
  };
884
899
  }, []);
885
900
  const getUser = useCallback((uid) => {
886
- return userManagement?.getUser(uid) ?? null;
901
+ return userManagement?.getUser?.(uid) ?? null;
887
902
  }, [userManagement]);
888
903
  return useMemo(() => ({
889
904
  items,
@@ -6355,7 +6370,7 @@ function UserDisplay(t0) {
6355
6370
  return t8;
6356
6371
  }
6357
6372
  function LoginView(t0) {
6358
- const $ = c(107);
6373
+ const $ = c(111);
6359
6374
  const {
6360
6375
  logo,
6361
6376
  authController,
@@ -6370,7 +6385,9 @@ function LoginView(t0) {
6370
6385
  subtitle,
6371
6386
  needsSetup,
6372
6387
  registrationEnabled,
6373
- additionalComponent
6388
+ additionalComponent,
6389
+ defaultEmail,
6390
+ defaultPassword
6374
6391
  } = t0;
6375
6392
  const disableSignupScreen = t1 === void 0 ? false : t1;
6376
6393
  const disabled = t2 === void 0 ? false : t2;
@@ -6747,17 +6764,19 @@ function LoginView(t0) {
6747
6764
  t36 = $[69];
6748
6765
  }
6749
6766
  let t37;
6750
- if ($[70] !== authController || $[71] !== isBootstrapMode || $[72] !== noUserComponent) {
6751
- t37 = isBootstrapMode && !authController.user && /* @__PURE__ */ jsx(LoginForm, { authController, registrationMode: true, onClose: _temp, onForgotPassword: _temp2, noUserComponent, disableSignupScreen: false, bootstrapMode: true });
6767
+ if ($[70] !== authController || $[71] !== defaultEmail || $[72] !== defaultPassword || $[73] !== isBootstrapMode || $[74] !== noUserComponent) {
6768
+ t37 = isBootstrapMode && !authController.user && /* @__PURE__ */ jsx(LoginForm, { authController, registrationMode: true, onClose: _temp, onForgotPassword: _temp2, noUserComponent, disableSignupScreen: false, bootstrapMode: true, defaultEmail, defaultPassword });
6752
6769
  $[70] = authController;
6753
- $[71] = isBootstrapMode;
6754
- $[72] = noUserComponent;
6755
- $[73] = t37;
6770
+ $[71] = defaultEmail;
6771
+ $[72] = defaultPassword;
6772
+ $[73] = isBootstrapMode;
6773
+ $[74] = noUserComponent;
6774
+ $[75] = t37;
6756
6775
  } else {
6757
- t37 = $[73];
6776
+ t37 = $[75];
6758
6777
  }
6759
6778
  let t38;
6760
- if ($[74] !== authController || $[75] !== disableSignupScreen || $[76] !== disabled || $[77] !== githubClientId || $[78] !== googleClientId || $[79] !== hasGitHubLogin || $[80] !== hasGoogleLogin || $[81] !== hasLinkedinLogin || $[82] !== hasPasswordReset || $[83] !== isBootstrapMode || $[84] !== linkedinClientId || $[85] !== mode || $[86] !== noUserComponent || $[87] !== showRegistration || $[88] !== subtitle || $[89] !== title) {
6779
+ if ($[76] !== authController || $[77] !== defaultEmail || $[78] !== defaultPassword || $[79] !== disableSignupScreen || $[80] !== disabled || $[81] !== githubClientId || $[82] !== googleClientId || $[83] !== hasGitHubLogin || $[84] !== hasGoogleLogin || $[85] !== hasLinkedinLogin || $[86] !== hasPasswordReset || $[87] !== isBootstrapMode || $[88] !== linkedinClientId || $[89] !== mode || $[90] !== noUserComponent || $[91] !== showRegistration || $[92] !== subtitle || $[93] !== title) {
6761
6780
  t38 = !isBootstrapMode && /* @__PURE__ */ jsxs(Fragment, { children: [
6762
6781
  mode === "buttons" && /* @__PURE__ */ jsxs("div", { className: "w-full flex flex-col gap-3 mt-2", children: [
6763
6782
  (title || subtitle) && /* @__PURE__ */ jsxs("div", { className: "text-center mb-2", children: [
@@ -6774,53 +6793,55 @@ function LoginView(t0) {
6774
6793
  /* @__PURE__ */ jsx("button", { type: "button", className: "font-semibold hover:underline cursor-pointer text-primary-600 dark:text-primary-400", onClick: () => switchMode("register"), children: "Create one" })
6775
6794
  ] }) })
6776
6795
  ] }),
6777
- mode === "login" && /* @__PURE__ */ jsx(LoginForm, { authController, registrationMode: false, onClose: () => switchMode("buttons"), onForgotPassword: hasPasswordReset ? () => switchMode("forgot") : void 0, noUserComponent, disableSignupScreen, switchToRegister: showRegistration ? () => switchMode("register") : void 0 }),
6778
- mode === "register" && /* @__PURE__ */ jsx(LoginForm, { authController, registrationMode: true, onClose: () => switchMode("buttons"), onForgotPassword: hasPasswordReset ? () => switchMode("forgot") : void 0, noUserComponent, disableSignupScreen, switchToLogin: () => switchMode("login") }),
6796
+ mode === "login" && /* @__PURE__ */ jsx(LoginForm, { authController, registrationMode: false, onClose: () => switchMode("buttons"), onForgotPassword: hasPasswordReset ? () => switchMode("forgot") : void 0, noUserComponent, disableSignupScreen, switchToRegister: showRegistration ? () => switchMode("register") : void 0, defaultEmail, defaultPassword }),
6797
+ mode === "register" && /* @__PURE__ */ jsx(LoginForm, { authController, registrationMode: true, onClose: () => switchMode("buttons"), onForgotPassword: hasPasswordReset ? () => switchMode("forgot") : void 0, noUserComponent, disableSignupScreen, switchToLogin: () => switchMode("login"), defaultEmail, defaultPassword }),
6779
6798
  mode === "forgot" && authController.forgotPassword && /* @__PURE__ */ jsx(ForgotPasswordForm, { authController, onClose: () => switchMode("login") })
6780
6799
  ] });
6781
- $[74] = authController;
6782
- $[75] = disableSignupScreen;
6783
- $[76] = disabled;
6784
- $[77] = githubClientId;
6785
- $[78] = googleClientId;
6786
- $[79] = hasGitHubLogin;
6787
- $[80] = hasGoogleLogin;
6788
- $[81] = hasLinkedinLogin;
6789
- $[82] = hasPasswordReset;
6790
- $[83] = isBootstrapMode;
6791
- $[84] = linkedinClientId;
6792
- $[85] = mode;
6793
- $[86] = noUserComponent;
6794
- $[87] = showRegistration;
6795
- $[88] = subtitle;
6796
- $[89] = title;
6797
- $[90] = t38;
6798
- } else {
6799
- t38 = $[90];
6800
+ $[76] = authController;
6801
+ $[77] = defaultEmail;
6802
+ $[78] = defaultPassword;
6803
+ $[79] = disableSignupScreen;
6804
+ $[80] = disabled;
6805
+ $[81] = githubClientId;
6806
+ $[82] = googleClientId;
6807
+ $[83] = hasGitHubLogin;
6808
+ $[84] = hasGoogleLogin;
6809
+ $[85] = hasLinkedinLogin;
6810
+ $[86] = hasPasswordReset;
6811
+ $[87] = isBootstrapMode;
6812
+ $[88] = linkedinClientId;
6813
+ $[89] = mode;
6814
+ $[90] = noUserComponent;
6815
+ $[91] = showRegistration;
6816
+ $[92] = subtitle;
6817
+ $[93] = title;
6818
+ $[94] = t38;
6819
+ } else {
6820
+ t38 = $[94];
6800
6821
  }
6801
6822
  let t39;
6802
- if ($[91] !== t36 || $[92] !== t37 || $[93] !== t38) {
6823
+ if ($[95] !== t36 || $[96] !== t37 || $[97] !== t38) {
6803
6824
  t39 = /* @__PURE__ */ jsxs("div", { className: t36, children: [
6804
6825
  t37,
6805
6826
  t38
6806
6827
  ] });
6807
- $[91] = t36;
6808
- $[92] = t37;
6809
- $[93] = t38;
6810
- $[94] = t39;
6828
+ $[95] = t36;
6829
+ $[96] = t37;
6830
+ $[97] = t38;
6831
+ $[98] = t39;
6811
6832
  } else {
6812
- t39 = $[94];
6833
+ t39 = $[98];
6813
6834
  }
6814
6835
  let t40;
6815
- if ($[95] !== additionalComponent) {
6836
+ if ($[99] !== additionalComponent) {
6816
6837
  t40 = additionalComponent && /* @__PURE__ */ jsx("div", { className: "w-full", children: additionalComponent });
6817
- $[95] = additionalComponent;
6818
- $[96] = t40;
6838
+ $[99] = additionalComponent;
6839
+ $[100] = t40;
6819
6840
  } else {
6820
- t40 = $[96];
6841
+ t40 = $[100];
6821
6842
  }
6822
6843
  let t41;
6823
- if ($[97] !== t32 || $[98] !== t33 || $[99] !== t34 || $[100] !== t39 || $[101] !== t40) {
6844
+ if ($[101] !== t32 || $[102] !== t33 || $[103] !== t34 || $[104] !== t39 || $[105] !== t40) {
6824
6845
  t41 = /* @__PURE__ */ jsxs("div", { className: "relative flex flex-col items-center w-[440px] max-w-full p-8 sm:p-10 bg-white/70 dark:bg-surface-900/60 backdrop-blur-xl border border-surface-200/50 dark:border-surface-800/50 rounded-2xl shadow-2xl z-10 transition-all duration-300 hover:shadow-primary-500/5", children: [
6825
6846
  t32,
6826
6847
  t33,
@@ -6828,29 +6849,29 @@ function LoginView(t0) {
6828
6849
  t39,
6829
6850
  t40
6830
6851
  ] });
6831
- $[97] = t32;
6832
- $[98] = t33;
6833
- $[99] = t34;
6834
- $[100] = t39;
6835
- $[101] = t40;
6836
- $[102] = t41;
6852
+ $[101] = t32;
6853
+ $[102] = t33;
6854
+ $[103] = t34;
6855
+ $[104] = t39;
6856
+ $[105] = t40;
6857
+ $[106] = t41;
6837
6858
  } else {
6838
- t41 = $[102];
6859
+ t41 = $[106];
6839
6860
  }
6840
6861
  let t42;
6841
- if ($[103] !== t14 || $[104] !== t31 || $[105] !== t41) {
6862
+ if ($[107] !== t14 || $[108] !== t31 || $[109] !== t41) {
6842
6863
  t42 = /* @__PURE__ */ jsxs("div", { className: t14, children: [
6843
6864
  t15,
6844
6865
  t16,
6845
6866
  t31,
6846
6867
  t41
6847
6868
  ] });
6848
- $[103] = t14;
6849
- $[104] = t31;
6850
- $[105] = t41;
6851
- $[106] = t42;
6869
+ $[107] = t14;
6870
+ $[108] = t31;
6871
+ $[109] = t41;
6872
+ $[110] = t42;
6852
6873
  } else {
6853
- t42 = $[106];
6874
+ t42 = $[110];
6854
6875
  }
6855
6876
  return t42;
6856
6877
  }
@@ -7114,12 +7135,14 @@ function LoginForm(t0) {
7114
7135
  noUserComponent,
7115
7136
  bootstrapMode: t1,
7116
7137
  switchToRegister,
7117
- switchToLogin
7138
+ switchToLogin,
7139
+ defaultEmail,
7140
+ defaultPassword
7118
7141
  } = t0;
7119
7142
  const bootstrapMode = t1 === void 0 ? false : t1;
7120
7143
  const passwordRef = useRef(null);
7121
- const [email, setEmail] = useState();
7122
- const [password, setPassword] = useState();
7144
+ const [email, setEmail] = useState(defaultEmail);
7145
+ const [password, setPassword] = useState(defaultPassword);
7123
7146
  const [displayName, setDisplayName] = useState();
7124
7147
  let t2;
7125
7148
  let t3;
@@ -14614,6 +14637,10 @@ function isRelationProperty(property) {
14614
14637
  }
14615
14638
  return false;
14616
14639
  }
14640
+ function isHiddenProperty(property) {
14641
+ if (!property) return false;
14642
+ return Boolean(property.ui?.hideFromCollection);
14643
+ }
14617
14644
  function getEntityPreviewKeys(authController, targetCollection, fields, previewProperties, limit = 3) {
14618
14645
  const allProperties = Object.keys(targetCollection.properties);
14619
14646
  let listProperties = previewProperties?.filter((p) => allProperties.includes(p));
@@ -14630,7 +14657,7 @@ function getEntityPreviewKeys(authController, targetCollection, fields, previewP
14630
14657
  return !isIdProp && key !== "id";
14631
14658
  }).filter((key) => {
14632
14659
  const property = targetCollection.properties[key];
14633
- return property && !isPropertyBuilder(property) && !isReferenceProperty(property) && !isRelationProperty(property);
14660
+ return property && !isPropertyBuilder(property) && !isReferenceProperty(property) && !isRelationProperty(property) && !isHiddenProperty(property);
14634
14661
  }).slice(0, limit);
14635
14662
  }
14636
14663
  }
@@ -14644,6 +14671,9 @@ function getEntityTitlePropertyKey(collection, propertyConfigs) {
14644
14671
  const property = collection.properties[key];
14645
14672
  if (property && !isPropertyBuilder(property)) {
14646
14673
  const prop = property;
14674
+ if (isHiddenProperty(prop)) {
14675
+ continue;
14676
+ }
14647
14677
  if (prop.type === "string" && !prop.ui?.multiline && !prop.ui?.markdown && !prop.storage && !prop.isId) {
14648
14678
  if (!firstStringCandidate) {
14649
14679
  firstStringCandidate = key;