@jsb188/react 1.1.3 → 1.1.4

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsb188/react",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "Contains react (and DOM) related utils and hooks.",
5
5
  "license": "ISC",
6
6
  "author": "jsb188",
@@ -12,7 +12,7 @@
12
12
  "./types/PopOver.d": "./types/PopOver.d.ts"
13
13
  },
14
14
  "peerDependencies": {
15
- "@jsb188/app": "1.1.3",
15
+ "@jsb188/app": "1.1.4",
16
16
  "jotai": "^2.12.5",
17
17
  "react": "^19.1.0"
18
18
  },
@@ -227,7 +227,7 @@ export function mergeAuthToDefaultValues(
227
227
  authorization: auth.token,
228
228
  account: auth.account,
229
229
  primaryOrganizationId: auth.primaryOrganizationId || null,
230
- settings: authSettings || DEFAULT_APP_CONTEXT.settings,
230
+ settings: authSettings,
231
231
  hasPassword: auth.hasPassword,
232
232
  version: auth.version,
233
233
 
@@ -252,7 +252,7 @@ export function mergeAuthToDefaultValues(
252
252
  * App reducer
253
253
  */
254
254
 
255
- export const appReducer = (state: Partial<AppContextData>, action: AppContextAction) => {
255
+ export const appReducer = (state: AppContextData, action: AppContextAction) => {
256
256
  const { __type, data } = action;
257
257
 
258
258
  switch (__type) {
@@ -399,7 +399,7 @@ export function useCurrentAccount() {
399
399
  version,
400
400
 
401
401
  // Computed
402
- loggedIn: !!account?.id,
402
+ isLoggedIn: !!account?.id,
403
403
  hasName,
404
404
  fullName,
405
405
  displayName,
@@ -21,6 +21,7 @@ export interface ClientRectValues {
21
21
 
22
22
  export interface PONListSubtitleObj {
23
23
  __type: 'SUBTITLE';
24
+ hidden?: boolean;
24
25
  text: string;
25
26
  }
26
27
 
@@ -57,6 +58,7 @@ export interface POListItemObj {
57
58
 
58
59
  export interface POCheckListItemObj extends POListItemObj {
59
60
  __type: 'CHECK_LIST_ITEM';
61
+ hidden?: boolean;
60
62
  checked?: boolean;
61
63
  }
62
64
 
@@ -83,6 +85,7 @@ export interface PONavAvatarItemObj {
83
85
 
84
86
  export interface PODateRangeObj {
85
87
  __type: 'DATE_RANGE';
88
+ hidden?: boolean;
86
89
  }
87
90
 
88
91
  export type PONavItemObj = PONListSubtitleObj | POListBreakObj | POListItemObj | POCheckListItemObj | PONavAvatarItemObj | PODateRangeObj;
@@ -156,7 +159,7 @@ export interface UpdatePopOverParams {
156
159
  }
157
160
 
158
161
  export interface PopOverGlobalStateParams {
159
- action: 'ITEM' | 'MOUNT' | 'UNMOUNT';
162
+ action: 'ITEM' | 'SUBMIT' | 'MOUNT' | 'UNMOUNT';
160
163
  value: any;
161
164
  }
162
165
 
package/utils/hooks.ts CHANGED
@@ -194,52 +194,50 @@ export function arePropsEqualExceptChildren(pp: any, np: any) {
194
194
 
195
195
  type VisibilityValue = 0 | .5 | 1 | 2;
196
196
 
197
- export function useAnimationVisibility(
198
- props: any,
197
+ export function useAnimationVisibility<T>(
198
+ props: T,
199
199
  onHasProps?: (hasProps: boolean) => void,
200
200
  ): [
201
201
  any,
202
202
  VisibilityValue,
203
203
  (VisibilityValue: VisibilityValue) => void,
204
204
  ] {
205
- const [visible, setVisible] = useState(0 as VisibilityValue);
206
- const [persistedProps, setPersistedProps] = useState({});
205
+ const [visibility, setVisibility] = useState(0 as VisibilityValue);
206
+ const [persistedProps, setPersistedProps] = useState<T>(props as T);
207
207
  const hasData = !!props;
208
208
 
209
209
  useEffect(() => {
210
210
  if (props) {
211
- setPersistedProps({ ...props });
212
- }
213
- if (onHasProps) {
214
- onHasProps(hasData);
211
+ setPersistedProps(props);
215
212
  }
213
+ onHasProps?.(hasData);
216
214
  }, [props]);
217
215
 
218
216
  useEffect(() => {
219
- if (visible === 1) {
217
+ if (visibility === 1) {
220
218
  if (hasData) {
221
219
  const timer = setTimeout(() => {
222
- setVisible(2);
220
+ setVisibility(2);
223
221
  }, 100);
224
222
  return () => clearTimeout(timer);
225
223
  } else {
226
224
  const timer = setTimeout(() => {
227
- setVisible(0);
225
+ setVisibility(0);
228
226
  }, 300);
229
227
  return () => clearTimeout(timer);
230
228
  }
231
- } else if (visible === .5) {
229
+ } else if (visibility === .5) {
232
230
  // Use custom exit function if .5
233
231
  return;
234
232
  }
235
233
 
236
234
  const shouldBeValue = hasData ? 2 : 0;
237
- if (shouldBeValue !== visible) {
238
- setVisible(1);
235
+ if (shouldBeValue !== visibility) {
236
+ setVisibility(1);
239
237
  }
240
- }, [visible, hasData]);
238
+ }, [visibility, hasData]);
241
239
 
242
- return [persistedProps, visible, setVisible];
240
+ return [persistedProps, visibility, setVisibility];
243
241
  }
244
242
 
245
243
  /**