@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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rebasepro/core",
3
3
  "type": "module",
4
- "version": "0.2.4",
4
+ "version": "0.2.5",
5
5
  "description": "Rebase core — framework-agnostic runtime for data-driven admin panels",
6
6
  "funding": {
7
7
  "url": "https://github.com/sponsors/rebaseco"
@@ -53,11 +53,11 @@
53
53
  "notistack": "^3.0.2",
54
54
  "react-compiler-runtime": "1.0.0",
55
55
  "react-i18next": "^14.1.3",
56
- "@rebasepro/common": "0.2.4",
57
- "@rebasepro/types": "0.2.4",
58
- "@rebasepro/formex": "0.2.4",
59
- "@rebasepro/utils": "0.2.4",
60
- "@rebasepro/ui": "0.2.4"
56
+ "@rebasepro/common": "0.2.5",
57
+ "@rebasepro/formex": "0.2.5",
58
+ "@rebasepro/types": "0.2.5",
59
+ "@rebasepro/ui": "0.2.5",
60
+ "@rebasepro/utils": "0.2.5"
61
61
  },
62
62
  "peerDependencies": {
63
63
  "react": ">=19.0.0",
@@ -126,6 +126,16 @@ export interface LoginViewProps {
126
126
  * If not set, derived from `authController.capabilities.registration`.
127
127
  */
128
128
  registrationEnabled?: boolean;
129
+
130
+ /**
131
+ * Pre-fill the email field (e.g. for demo or testing environments).
132
+ */
133
+ defaultEmail?: string;
134
+
135
+ /**
136
+ * Pre-fill the password field (e.g. for demo or testing environments).
137
+ */
138
+ defaultPassword?: string;
129
139
  }
130
140
 
131
141
  type AuthMode = "buttons" | "login" | "register" | "forgot";
@@ -149,7 +159,9 @@ export function LoginView({
149
159
  subtitle,
150
160
  needsSetup,
151
161
  registrationEnabled,
152
- additionalComponent
162
+ additionalComponent,
163
+ defaultEmail,
164
+ defaultPassword
153
165
  }: LoginViewProps) {
154
166
 
155
167
  const modeState = useModeController();
@@ -301,6 +313,8 @@ export function LoginView({
301
313
  noUserComponent={noUserComponent}
302
314
  disableSignupScreen={false}
303
315
  bootstrapMode={true}
316
+ defaultEmail={defaultEmail}
317
+ defaultPassword={defaultPassword}
304
318
  />
305
319
  )}
306
320
 
@@ -376,6 +390,8 @@ export function LoginView({
376
390
  noUserComponent={noUserComponent}
377
391
  disableSignupScreen={disableSignupScreen}
378
392
  switchToRegister={showRegistration ? () => switchMode("register") : undefined}
393
+ defaultEmail={defaultEmail}
394
+ defaultPassword={defaultPassword}
379
395
  />
380
396
  )}
381
397
 
@@ -389,6 +405,8 @@ export function LoginView({
389
405
  noUserComponent={noUserComponent}
390
406
  disableSignupScreen={disableSignupScreen}
391
407
  switchToLogin={() => switchMode("login")}
408
+ defaultEmail={defaultEmail}
409
+ defaultPassword={defaultPassword}
392
410
  />
393
411
  )}
394
412
 
@@ -576,7 +594,9 @@ function LoginForm({
576
594
  disableSignupScreen,
577
595
  bootstrapMode = false,
578
596
  switchToRegister,
579
- switchToLogin
597
+ switchToLogin,
598
+ defaultEmail,
599
+ defaultPassword
580
600
  }: {
581
601
  onClose: () => void,
582
602
  onForgotPassword?: () => void,
@@ -586,12 +606,14 @@ function LoginForm({
586
606
  disableSignupScreen: boolean,
587
607
  bootstrapMode?: boolean,
588
608
  switchToRegister?: () => void,
589
- switchToLogin?: () => void
609
+ switchToLogin?: () => void,
610
+ defaultEmail?: string,
611
+ defaultPassword?: string
590
612
  }) {
591
613
  const passwordRef = useRef<HTMLInputElement | null>(null);
592
614
 
593
- const [email, setEmail] = useState<string>();
594
- const [password, setPassword] = useState<string>();
615
+ const [email, setEmail] = useState<string | undefined>(defaultEmail);
616
+ const [password, setPassword] = useState<string | undefined>(defaultPassword);
595
617
  const [displayName, setDisplayName] = useState<string>();
596
618
 
597
619
  useEffect(() => {
@@ -22,6 +22,16 @@ export interface CollectionFetchProps<M extends Record<string, any>> {
22
22
  */
23
23
  itemCount?: number;
24
24
 
25
+ /**
26
+ * Number of items to skip
27
+ */
28
+ offset?: number;
29
+
30
+ /**
31
+ * Page number (1-indexed), alternative to offset
32
+ */
33
+ page?: number;
34
+
25
35
  /**
26
36
  * Filter the fetched data by the property
27
37
  */
@@ -46,6 +56,7 @@ export interface CollectionFetchResult<M extends Record<string, any>> {
46
56
  dataLoading: boolean;
47
57
  noMoreToLoad: boolean;
48
58
  dataLoadingError?: Error;
59
+ totalCount?: number;
49
60
  }
50
61
 
51
62
  /**
@@ -55,6 +66,8 @@ export interface CollectionFetchResult<M extends Record<string, any>> {
55
66
  * @param filterValues
56
67
  * @param sortBy
57
68
  * @param itemCount
69
+ * @param offset
70
+ * @param page
58
71
  * @param searchString
59
72
  * @group Hooks and utilities
60
73
  */
@@ -65,6 +78,8 @@ export function useCollectionFetch<M extends Record<string, any>, USER extends U
65
78
  filterValues,
66
79
  sortBy,
67
80
  itemCount,
81
+ offset,
82
+ page,
68
83
  searchString
69
84
  }: CollectionFetchProps<M>): CollectionFetchResult<M> {
70
85
  const dataClient = useData();
@@ -99,12 +114,13 @@ export function useCollectionFetch<M extends Record<string, any>, USER extends U
99
114
  const [dataLoading, setDataLoading] = useState<boolean>(false);
100
115
  const [dataLoadingError, setDataLoadingError] = useState<Error | undefined>();
101
116
  const [noMoreToLoad, setNoMoreToLoad] = useState<boolean>(false);
117
+ const [totalCount, setTotalCount] = useState<number | undefined>();
102
118
 
103
119
  useEffect(() => {
104
120
 
105
121
  setDataLoading(true);
106
122
 
107
- const onEntitiesUpdate = async (res: { data: Entity<M>[], meta: { hasMore: boolean } }) => {
123
+ const onEntitiesUpdate = async (res: { data: Entity<M>[], meta: { hasMore: boolean; total?: number } }) => {
108
124
  const entities = res.data;
109
125
  setDataLoading(false);
110
126
  setDataLoadingError(undefined);
@@ -112,6 +128,7 @@ export function useCollectionFetch<M extends Record<string, any>, USER extends U
112
128
  ...e
113
129
  })));
114
130
  setNoMoreToLoad(!res.meta.hasMore);
131
+ setTotalCount(res.meta.total);
115
132
  };
116
133
 
117
134
  const onError = (error: Error) => {
@@ -119,6 +136,7 @@ export function useCollectionFetch<M extends Record<string, any>, USER extends U
119
136
  setDataLoading(false);
120
137
  setData([]);
121
138
  setDataLoadingError(error);
139
+ setTotalCount(undefined);
122
140
  };
123
141
 
124
142
  const accessor = dataClient.collection(path);
@@ -133,6 +151,8 @@ export function useCollectionFetch<M extends Record<string, any>, USER extends U
133
151
  return accessor.listen({
134
152
  where: whereParams,
135
153
  limit: itemCount,
154
+ offset,
155
+ page,
136
156
  orderBy: orderByParams,
137
157
  searchString,
138
158
  include: includeParams
@@ -141,6 +161,8 @@ export function useCollectionFetch<M extends Record<string, any>, USER extends U
141
161
  accessor.find({
142
162
  where: whereParams,
143
163
  limit: itemCount,
164
+ offset,
165
+ page,
144
166
  orderBy: orderByParams,
145
167
  searchString,
146
168
  include: includeParams
@@ -150,13 +172,14 @@ export function useCollectionFetch<M extends Record<string, any>, USER extends U
150
172
  return () => {
151
173
  };
152
174
  }
153
- }, [path, itemCount, currentSort, sortByProperty, filterValues, searchString, dataClient, collection]);
175
+ }, [path, itemCount, offset, page, currentSort, sortByProperty, filterValues, searchString, dataClient, collection]);
154
176
 
155
177
  return useMemo(() => ({
156
178
  data,
157
179
  dataLoading,
158
180
  dataLoadingError,
159
- noMoreToLoad
160
- }), [data, dataLoading, dataLoadingError, noMoreToLoad]);
181
+ noMoreToLoad,
182
+ totalCount
183
+ }), [data, dataLoading, dataLoadingError, noMoreToLoad, totalCount]);
161
184
 
162
185
  }
@@ -142,7 +142,7 @@ export function useUserSelector(
142
142
  }, []);
143
143
 
144
144
  const getUser = useCallback((uid: string): User | null => {
145
- return userManagement?.getUser(uid) ?? null;
145
+ return userManagement?.getUser?.(uid) ?? null;
146
146
  }, [userManagement]);
147
147
 
148
148
  return useMemo(() => ({
@@ -22,6 +22,11 @@ function isRelationProperty(property: Property) {
22
22
  return false;
23
23
  }
24
24
 
25
+ function isHiddenProperty(property: Property | undefined): boolean {
26
+ if (!property) return false;
27
+ return Boolean(property.ui?.hideFromCollection);
28
+ }
29
+
25
30
  export function getEntityPreviewKeys(
26
31
  authController: AuthController,
27
32
  targetCollection: EntityCollection<any>,
@@ -45,7 +50,7 @@ export function getEntityPreviewKeys(
45
50
  })
46
51
  .filter(key => {
47
52
  const property = targetCollection.properties[key];
48
- return property && !isPropertyBuilder(property) && !isReferenceProperty(property) && !isRelationProperty(property);
53
+ return property && !isPropertyBuilder(property) && !isReferenceProperty(property) && !isRelationProperty(property) && !isHiddenProperty(property);
49
54
  }).slice(0, limit);
50
55
  }
51
56
  }
@@ -62,6 +67,9 @@ export function getEntityTitlePropertyKey<M extends Record<string, any>>(collect
62
67
  const property = collection.properties[key];
63
68
  if (property && !isPropertyBuilder(property)) {
64
69
  const prop = property as Property;
70
+ if (isHiddenProperty(prop)) {
71
+ continue;
72
+ }
65
73
  if (prop.type === "string" && !prop.ui?.multiline && !prop.ui?.markdown && !prop.storage && !prop.isId) {
66
74
  if (!firstStringCandidate) {
67
75
  firstStringCandidate = key;