@stackflow/plugin-basic-ui 0.14.1 → 0.14.2

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.
@@ -4,12 +4,12 @@ import { useActions, useActivity } from "@stackflow/react";
4
4
  import { assignInlineVars } from "@vanilla-extract/dynamic";
5
5
  import React, { useRef } from "react";
6
6
 
7
+ import { useGlobalOptions } from "../basicUIPlugin";
7
8
  import {
8
9
  useLazy,
9
10
  useStyleEffectHide,
10
11
  useStyleEffectOffset,
11
12
  useStyleEffectSwipeBack,
12
- useTheme,
13
13
  } from "../hooks";
14
14
  import type { GlobalVars } from "../theme.css";
15
15
  import { globalVars } from "../theme.css";
@@ -24,8 +24,13 @@ type AppScreenProps = Partial<
24
24
  appBar?: Omit<PropOf<typeof AppBar>, "theme" | "ref" | "key">;
25
25
  children: React.ReactNode;
26
26
  };
27
- const AppScreen: React.FC<AppScreenProps> = ({ appBar, children }) => {
28
- const theme = useTheme();
27
+ const AppScreen: React.FC<AppScreenProps> = ({
28
+ backgroundColor,
29
+ dimBackgroundColor,
30
+ appBar,
31
+ children,
32
+ }) => {
33
+ const { theme } = useGlobalOptions();
29
34
  const activity = useActivity();
30
35
  const { pop } = useActions();
31
36
 
@@ -72,6 +77,8 @@ const AppScreen: React.FC<AppScreenProps> = ({ appBar, children }) => {
72
77
  })}
73
78
  style={assignInlineVars(
74
79
  compactMap({
80
+ [globalVars.backgroundColor]: backgroundColor,
81
+ [globalVars.dimBackgroundColor]: dimBackgroundColor,
75
82
  [globalVars.appBar.height]: appBar?.height,
76
83
  [css.vars.zIndexes.dim]: `${zIndexDim}`,
77
84
  [css.vars.zIndexes.paper]: `${zIndexPaper}`,
@@ -14,12 +14,14 @@ type BottomSheetProps = Partial<
14
14
  Pick<GlobalVars, "backgroundColor" | "dimBackgroundColor">
15
15
  > &
16
16
  Partial<GlobalVars["bottomSheet"]> & {
17
+ onOutsideClick?: React.MouseEventHandler;
17
18
  children: React.ReactNode;
18
19
  };
19
20
  const BottomSheet: React.FC<BottomSheetProps> = ({
20
21
  borderRadius = "1rem",
21
22
  backgroundColor,
22
23
  dimBackgroundColor,
24
+ onOutsideClick,
23
25
  children,
24
26
  }) => {
25
27
  const activity = useActivity();
@@ -43,13 +45,19 @@ const BottomSheet: React.FC<BottomSheetProps> = ({
43
45
 
44
46
  const popLock = useRef(false);
45
47
 
46
- const onDimClick = () => {
48
+ const onDimClick: React.MouseEventHandler = (e) => {
49
+ onOutsideClick?.(e);
50
+
51
+ if (e.defaultPrevented) {
52
+ return;
53
+ }
54
+
47
55
  if (popLock.current) {
48
56
  return;
49
57
  }
58
+ popLock.current = true;
50
59
 
51
60
  pop();
52
- popLock.current = true;
53
61
  };
54
62
  const onPaperClick: React.MouseEventHandler = (e) => {
55
63
  e.stopPropagation();
@@ -14,12 +14,14 @@ type ModalProps = Partial<
14
14
  Pick<GlobalVars, "backgroundColor" | "dimBackgroundColor">
15
15
  > &
16
16
  Partial<GlobalVars["modal"]> & {
17
+ onOutsideClick?: React.MouseEventHandler;
17
18
  children: React.ReactNode;
18
19
  };
19
20
  const Modal: React.FC<ModalProps> = ({
20
21
  backgroundColor,
21
22
  dimBackgroundColor,
22
23
  borderRadius = "1rem",
24
+ onOutsideClick,
23
25
  children,
24
26
  }) => {
25
27
  const activity = useActivity();
@@ -43,13 +45,19 @@ const Modal: React.FC<ModalProps> = ({
43
45
 
44
46
  const popLock = useRef(false);
45
47
 
46
- const onDimClick = () => {
48
+ const onDimClick: React.MouseEventHandler = (e) => {
49
+ onOutsideClick?.(e);
50
+
51
+ if (e.defaultPrevented) {
52
+ return;
53
+ }
54
+
47
55
  if (popLock.current) {
48
56
  return;
49
57
  }
58
+ popLock.current = true;
50
59
 
51
60
  pop();
52
- popLock.current = true;
53
61
  };
54
62
  const onPaperClick: React.MouseEventHandler = (e) => {
55
63
  e.stopPropagation();
@@ -4,4 +4,3 @@ export * from "./useStyleEffect";
4
4
  export * from "./useStyleEffectHide";
5
5
  export * from "./useStyleEffectOffset";
6
6
  export * from "./useStyleEffectSwipeBack";
7
- export * from "./useTheme";
@@ -0,0 +1,5 @@
1
+ export type RecursivePartial<K> = {
2
+ [attr in keyof K]?: K[attr] extends object
3
+ ? RecursivePartial<K[attr]>
4
+ : K[attr];
5
+ };
@@ -4,4 +4,5 @@ export * from "./listenOnce";
4
4
  export * from "./listenResize";
5
5
  export * from "./noop";
6
6
  export * from "./PropOf";
7
+ export * from "./RecursivePartial";
7
8
  export * from "./requestNextFrame";
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- export declare const ThemeProvider: import("react").Provider<"android" | "cupertino">;
3
- export declare function useTheme(): "android" | "cupertino";
@@ -1,9 +0,0 @@
1
- import { createContext, useContext } from "react";
2
-
3
- const ThemeContext = createContext<"android" | "cupertino">("android");
4
-
5
- export const ThemeProvider = ThemeContext.Provider;
6
-
7
- export function useTheme() {
8
- return useContext(ThemeContext);
9
- }