@stackflow/plugin-basic-ui 1.7.0 → 1.8.0

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.
Files changed (45) hide show
  1. package/dist/assets/IconBack.d.ts +0 -1
  2. package/dist/assets/IconClose.d.ts +0 -1
  3. package/dist/basicUIPlugin.css.d.ts +32 -6
  4. package/dist/basicUIPlugin.d.ts +1 -2
  5. package/dist/components/AppBar.css.d.ts +2 -2
  6. package/dist/components/AppBar.d.ts +17 -18
  7. package/dist/components/AppScreen.css.d.ts +19 -18
  8. package/dist/components/AppScreen.d.ts +2 -3
  9. package/dist/components/BottomSheet.css.d.ts +6 -6
  10. package/dist/components/BottomSheet.d.ts +1 -2
  11. package/dist/components/Modal.css.d.ts +6 -6
  12. package/dist/components/Modal.d.ts +1 -2
  13. package/dist/hooks/index.d.ts +1 -0
  14. package/dist/hooks/useMaxWidth.d.ts +0 -1
  15. package/dist/hooks/useStyleEffect.d.ts +1 -2
  16. package/dist/hooks/useStyleEffectHide.d.ts +0 -1
  17. package/dist/hooks/useStyleEffectOffset.d.ts +0 -1
  18. package/dist/hooks/useStyleEffectSwipeBack.d.ts +0 -1
  19. package/dist/hooks/useZIndexBase.d.ts +1 -0
  20. package/dist/index.css +9 -8
  21. package/dist/index.css.map +3 -3
  22. package/dist/index.d.ts +1 -0
  23. package/dist/index.js +25 -19
  24. package/dist/index.js.map +4 -4
  25. package/dist/index.mjs +25 -19
  26. package/dist/index.mjs.map +4 -4
  27. package/dist/utils/PropOf.d.ts +1 -2
  28. package/dist/utils/RecursivePartial.d.ts +1 -1
  29. package/dist/utils/last.d.ts +1 -1
  30. package/package.json +12 -25
  31. package/src/basicUIPlugin.css.ts +32 -32
  32. package/src/basicUIPlugin.tsx +2 -2
  33. package/src/components/AppBar.tsx +5 -5
  34. package/src/components/AppScreen.css.ts +7 -6
  35. package/src/components/AppScreen.tsx +2 -2
  36. package/src/components/BottomSheet.tsx +8 -5
  37. package/src/components/Modal.tsx +8 -5
  38. package/src/hooks/index.ts +1 -0
  39. package/src/hooks/useStyleEffect.ts +1 -1
  40. package/src/hooks/useStyleEffectHide.ts +0 -2
  41. package/src/hooks/useStyleEffectOffset.ts +1 -5
  42. package/src/hooks/useStyleEffectSwipeBack.ts +1 -3
  43. package/src/hooks/useZIndexBase.ts +6 -0
  44. package/src/index.ts +1 -0
  45. package/src/utils/last.ts +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackflow/plugin-basic-ui",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/daangn/stackflow.git",
@@ -32,33 +32,20 @@
32
32
  "typecheck": "tsc --noEmit"
33
33
  },
34
34
  "dependencies": {
35
- "@vanilla-extract/css": "^1.7.2",
36
- "@vanilla-extract/dynamic": "^2.0.2",
37
- "@vanilla-extract/private": "^1.0.3",
38
- "@vanilla-extract/recipes": "^0.2.5",
39
- "ts-pattern": "^4.0.5"
35
+ "@vanilla-extract/css": "^1.15.3",
36
+ "@vanilla-extract/dynamic": "^2.1.1",
37
+ "@vanilla-extract/private": "^1.0.5",
38
+ "@vanilla-extract/recipes": "^0.5.3"
40
39
  },
41
40
  "devDependencies": {
42
- "@stackflow/core": "^1.0.10",
43
- "@stackflow/esbuild-config": "^1.0.1",
44
- "@stackflow/eslint-config": "^1.0.2",
45
- "@stackflow/react": "^1.1.8",
46
- "@types/react": "^18.0.10",
47
- "@typescript-eslint/eslint-plugin": "^5.32.0",
48
- "@typescript-eslint/parser": "^5.20.0",
49
- "esbuild": "^0.14.51",
50
- "eslint": "^8.13.0",
51
- "eslint-config-airbnb": "^19.0.4",
52
- "eslint-config-prettier": "^8.5.0",
53
- "eslint-plugin-import": "^2.26.0",
54
- "eslint-plugin-json-format": "^2.0.1",
55
- "eslint-plugin-jsx-a11y": "^6.5.1",
56
- "eslint-plugin-react": "^7.29.4",
57
- "eslint-plugin-react-hooks": "^4.4.0",
58
- "eslint-plugin-simple-import-sort": "^7.0.0",
59
- "react": "^18.1.0",
41
+ "@stackflow/core": "^1.0.12",
42
+ "@stackflow/esbuild-config": "^1.0.2",
43
+ "@stackflow/react": "^1.1.10",
44
+ "@types/react": "^18.3.3",
45
+ "esbuild": "^0.23.0",
46
+ "react": "^18.3.1",
60
47
  "rimraf": "^3.0.2",
61
- "typescript": "^4.7.4"
48
+ "typescript": "^5.5.3"
62
49
  },
63
50
  "peerDependencies": {
64
51
  "@stackflow/core": "^1",
@@ -3,44 +3,44 @@ import {
3
3
  createGlobalThemeContract,
4
4
  createTheme,
5
5
  } from "@vanilla-extract/css";
6
- import type { MapLeafNodes } from "@vanilla-extract/private";
7
6
  import { recipe } from "@vanilla-extract/recipes";
8
7
 
9
- export const globalVars = createGlobalThemeContract(
10
- {
11
- backgroundColor: "background-color",
12
- dimBackgroundColor: "dim-background-color",
13
- transitionDuration: "transition-duration",
14
- computedTransitionDuration: "computed-transition-duration",
15
- appBar: {
16
- borderColor: "app-bar-border-color",
17
- borderColorTransitionDuration: "app-bar-border-color-transition-duration",
18
- borderSize: "app-bar-border-size",
19
- height: "app-bar-height",
20
- heightTransitionDuration: "app-bar-height-transition-duration",
21
- minHeight: "app-bar-min-height",
22
- iconColor: "app-bar-icon-color",
23
- iconColorTransitionDuration: "app-bar-icon-color-transition-duration",
24
- textColor: "app-bar-text-color",
25
- textColorTransitionDuration: "app-bar-text-color-transition-duration",
26
- backgroundColor: "app-bar-background-color",
27
- backgroundColorTransitionDuration:
28
- "app-bar-background-color-transition-duration",
29
- overflow: "app-bar-overflow",
30
- minSafeAreaInsetTop: "app-bar-min-safe-area-inset-top",
31
- },
32
- bottomSheet: {
33
- borderRadius: "bottom-sheet-border-radius",
34
- },
35
- modal: {
36
- borderRadius: "bottom-sheet-border-radius",
37
- },
8
+ const GLOBAL_VARS = {
9
+ backgroundColor: "background-color",
10
+ dimBackgroundColor: "dim-background-color",
11
+ transitionDuration: "transition-duration",
12
+ computedTransitionDuration: "computed-transition-duration",
13
+ appBar: {
14
+ borderColor: "app-bar-border-color",
15
+ borderColorTransitionDuration: "app-bar-border-color-transition-duration",
16
+ borderSize: "app-bar-border-size",
17
+ height: "app-bar-height",
18
+ heightTransitionDuration: "app-bar-height-transition-duration",
19
+ minHeight: "app-bar-min-height",
20
+ iconColor: "app-bar-icon-color",
21
+ iconColorTransitionDuration: "app-bar-icon-color-transition-duration",
22
+ textColor: "app-bar-text-color",
23
+ textColorTransitionDuration: "app-bar-text-color-transition-duration",
24
+ backgroundColor: "app-bar-background-color",
25
+ backgroundColorTransitionDuration:
26
+ "app-bar-background-color-transition-duration",
27
+ overflow: "app-bar-overflow",
28
+ minSafeAreaInsetTop: "app-bar-min-safe-area-inset-top",
29
+ },
30
+ bottomSheet: {
31
+ borderRadius: "bottom-sheet-border-radius",
32
+ },
33
+ modal: {
34
+ borderRadius: "bottom-sheet-border-radius",
38
35
  },
36
+ };
37
+
38
+ export const globalVars = createGlobalThemeContract(
39
+ GLOBAL_VARS,
39
40
  (value) => `stackflow-plugin-basic-ui-${value}`,
40
41
  );
41
42
 
42
- type InferVars<T> = T extends MapLeafNodes<infer U, any> ? U : never;
43
- export type GlobalVars = InferVars<typeof globalVars>;
43
+ export type GlobalVars = typeof GLOBAL_VARS;
44
44
 
45
45
  const androidValues: GlobalVars = {
46
46
  backgroundColor: "#fff",
@@ -69,8 +69,8 @@ export const basicUIPlugin: (
69
69
  compactMap({
70
70
  [css.globalVars.backgroundColor]: _options.backgroundColor,
71
71
  [css.globalVars.dimBackgroundColor]: _options.dimBackgroundColor,
72
- [css.globalVars
73
- .transitionDuration]: `${stack.transitionDuration}ms`,
72
+ [css.globalVars.transitionDuration]:
73
+ `${stack.transitionDuration}ms`,
74
74
  [css.globalVars.computedTransitionDuration]:
75
75
  stack.globalTransitionState === "loading"
76
76
  ? `${stack.transitionDuration}ms`
@@ -120,6 +120,7 @@ const AppBar = forwardRef<HTMLDivElement, AppBarProps>(
120
120
  return (
121
121
  <button
122
122
  type="button"
123
+ aria-label="Go Back"
123
124
  className={css.backButton}
124
125
  onClick={onBackClick}
125
126
  >
@@ -147,8 +148,8 @@ const AppBar = forwardRef<HTMLDivElement, AppBarProps>(
147
148
  backButton && "ariaLabel" in backButton
148
149
  ? backButton.ariaLabel
149
150
  : globalBackButton && "ariaLabel" in globalBackButton
150
- ? globalBackButton.ariaLabel
151
- : undefined
151
+ ? globalBackButton.ariaLabel
152
+ : undefined
152
153
  }
153
154
  onClick={onBackClick}
154
155
  >
@@ -230,8 +231,8 @@ const AppBar = forwardRef<HTMLDivElement, AppBarProps>(
230
231
  closeButton && "ariaLabel" in closeButton
231
232
  ? closeButton.ariaLabel
232
233
  : globalCloseButton && "ariaLabel" in globalCloseButton
233
- ? globalCloseButton.ariaLabel
234
- : undefined
234
+ ? globalCloseButton.ariaLabel
235
+ : undefined
235
236
  }
236
237
  onClick={onCloseClick}
237
238
  >
@@ -316,7 +317,6 @@ const AppBar = forwardRef<HTMLDivElement, AppBarProps>(
316
317
  <button
317
318
  className={css.centerMainEdge}
318
319
  type="button"
319
- aria-hidden="true"
320
320
  onClick={onTopClick}
321
321
  />
322
322
  </div>
@@ -121,14 +121,15 @@ export const paper = recipe({
121
121
  true: [
122
122
  f.borderBox,
123
123
  {
124
- transition: `transform ${vars.transitionDuration}, opacity ${vars.transitionDuration}, padding-top ${globalVars.appBar.heightTransitionDuration}`,
125
- paddingTop: globalVars.appBar.height,
124
+ transition: `transform ${vars.transitionDuration}, opacity ${vars.transitionDuration}, margin-top ${globalVars.appBar.heightTransitionDuration}`,
125
+ marginTop: globalVars.appBar.height,
126
+ height: `calc(100% - ${globalVars.appBar.height})`,
126
127
  "@supports": {
127
- "(padding-top: constant(safe-area-inset-top))": {
128
- paddingTop: `calc(${globalVars.appBar.height} + max(${globalVars.appBar.minSafeAreaInsetTop}, constant(safe-area-inset-top)))`,
128
+ "(margin-top: constant(safe-area-inset-top))": {
129
+ marginTop: `calc(${globalVars.appBar.height} + max(${globalVars.appBar.minSafeAreaInsetTop}, constant(safe-area-inset-top)))`,
129
130
  },
130
- "(padding-top: env(safe-area-inset-top))": {
131
- paddingTop: `calc(${globalVars.appBar.height} + max(${globalVars.appBar.minSafeAreaInsetTop}, env(safe-area-inset-top)))`,
131
+ "(margin-top: env(safe-area-inset-top))": {
132
+ marginTop: `calc(${globalVars.appBar.height} + max(${globalVars.appBar.minSafeAreaInsetTop}, env(safe-area-inset-top)))`,
132
133
  },
133
134
  },
134
135
  },
@@ -12,6 +12,7 @@ import {
12
12
  useStyleEffectHide,
13
13
  useStyleEffectOffset,
14
14
  useStyleEffectSwipeBack,
15
+ useZIndexBase,
15
16
  } from "../hooks";
16
17
  import type { PropOf } from "../utils";
17
18
  import { compactMap } from "../utils";
@@ -74,7 +75,7 @@ const AppScreen: React.FC<AppScreenProps> = ({
74
75
 
75
76
  const hasAppBar = !!appBar;
76
77
 
77
- const zIndexBase = (activity?.zIndex ?? 0) * 5;
78
+ const zIndexBase = useZIndexBase();
78
79
 
79
80
  let zIndexDim: number;
80
81
  let zIndexPaper: number;
@@ -92,7 +93,6 @@ const AppScreen: React.FC<AppScreenProps> = ({
92
93
  zIndexAppBar = zIndexBase + 7;
93
94
  break;
94
95
  }
95
- case "android":
96
96
  default: {
97
97
  zIndexDim = zIndexBase;
98
98
  zIndexPaper = zIndexBase + (activityEnterStyle === "slideInLeft" ? 1 : 3);
@@ -1,12 +1,15 @@
1
- /* eslint-disable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */
2
-
3
1
  import { useActions } from "@stackflow/react";
4
2
  import { assignInlineVars } from "@vanilla-extract/dynamic";
5
3
  import { useRef } from "react";
6
4
 
7
5
  import type { GlobalVars } from "../basicUIPlugin.css";
8
6
  import { globalVars } from "../basicUIPlugin.css";
9
- import { useLazy, useNullableActivity, useStyleEffect } from "../hooks";
7
+ import {
8
+ useLazy,
9
+ useNullableActivity,
10
+ useStyleEffect,
11
+ useZIndexBase,
12
+ } from "../hooks";
10
13
  import { compactMap } from "../utils";
11
14
  import * as css from "./BottomSheet.css";
12
15
 
@@ -65,8 +68,8 @@ const BottomSheet: React.FC<BottomSheetProps> = ({
65
68
  e.stopPropagation();
66
69
  };
67
70
 
68
- const zIndexBase = (activity?.zIndex ?? 0) * 5 + 3;
69
- const zIndexPaper = (activity?.zIndex ?? 0) * 5 + 4;
71
+ const zIndexBase = useZIndexBase() + 3;
72
+ const zIndexPaper = useZIndexBase() + 4;
70
73
  const transitionState = activity?.transitionState ?? "enter-done";
71
74
 
72
75
  return (
@@ -1,12 +1,15 @@
1
- /* eslint-disable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */
2
-
3
1
  import { useActions } from "@stackflow/react";
4
2
  import { assignInlineVars } from "@vanilla-extract/dynamic";
5
3
  import { useRef } from "react";
6
4
 
7
5
  import type { GlobalVars } from "../basicUIPlugin.css";
8
6
  import { globalVars } from "../basicUIPlugin.css";
9
- import { useLazy, useNullableActivity, useStyleEffect } from "../hooks";
7
+ import {
8
+ useLazy,
9
+ useNullableActivity,
10
+ useStyleEffect,
11
+ useZIndexBase,
12
+ } from "../hooks";
10
13
  import { compactMap } from "../utils";
11
14
  import * as css from "./Modal.css";
12
15
 
@@ -63,8 +66,8 @@ const Modal: React.FC<ModalProps> = ({
63
66
  e.stopPropagation();
64
67
  };
65
68
 
66
- const zIndexBase = (activity?.zIndex ?? 0) * 5 + 3;
67
- const zIndexPaper = (activity?.zIndex ?? 0) * 5 + 4;
69
+ const zIndexBase = useZIndexBase() + 3;
70
+ const zIndexPaper = useZIndexBase() + 4;
68
71
  const transitionState = activity?.transitionState ?? "enter-done";
69
72
 
70
73
  return (
@@ -6,3 +6,4 @@ export * from "./useStyleEffect";
6
6
  export * from "./useStyleEffectHide";
7
7
  export * from "./useStyleEffectOffset";
8
8
  export * from "./useStyleEffectSwipeBack";
9
+ export * from "./useZIndexBase";
@@ -25,7 +25,7 @@ export function useStyleEffect<T extends HTMLElement>({
25
25
  effect?: (params: {
26
26
  activityTransitionState: ActivityTransitionState;
27
27
  refs: Array<React.RefObject<T>>;
28
- }) => (() => void) | void;
28
+ }) => (() => void) | undefined;
29
29
  effectDeps?: any[];
30
30
  }) {
31
31
  const activity = useNullableActivity();
@@ -1,5 +1,3 @@
1
- /* eslint-disable no-param-reassign */
2
-
3
1
  import { noop } from "../utils";
4
2
  import { useStyleEffect } from "./useStyleEffect";
5
3
 
@@ -1,5 +1,3 @@
1
- /* eslint-disable no-param-reassign */
2
-
3
1
  import { globalVars } from "../basicUIPlugin.css";
4
2
  import { listenOnce, noop, requestNextFrame } from "../utils";
5
3
  import { useStyleEffect } from "./useStyleEffect";
@@ -32,11 +30,10 @@ export function useStyleEffectOffset({
32
30
  opacity = "1";
33
31
  break;
34
32
  }
35
- case "android":
36
33
  default: {
37
34
  transform =
38
35
  activityEnterStyle === "slideInLeft"
39
- ? `translate3d(-50%, 0, 0)`
36
+ ? "translate3d(-50%, 0, 0)"
40
37
  : `translate3d(0, -${OFFSET_PX_ANDROID / 16}rem, 0)`;
41
38
  opacity = activityEnterStyle === "slideInLeft" ? "0" : "1";
42
39
  break;
@@ -81,7 +78,6 @@ export function useStyleEffectOffset({
81
78
  return () => {
82
79
  cleanup();
83
80
  };
84
- case "enter-active":
85
81
  default:
86
82
  return noop;
87
83
  }
@@ -1,5 +1,3 @@
1
- /* eslint-disable no-param-reassign */
2
-
3
1
  import { globalVars } from "../basicUIPlugin.css";
4
2
  import * as appScreenCss from "../components/AppScreen.css";
5
3
  import { listenOnce, noop } from "../utils";
@@ -175,7 +173,7 @@ export function useStyleEffectSwipeBack({
175
173
  const { activeElement } = document as any;
176
174
 
177
175
  activeElement?.blur?.();
178
- // eslint-disable-next-line no-multi-assign
176
+
179
177
  x0 = x = e.touches[0].clientX;
180
178
  t0 = Date.now();
181
179
 
@@ -0,0 +1,6 @@
1
+ import { useNullableActivity } from "./useNullableActivity";
2
+
3
+ export function useZIndexBase() {
4
+ const activity = useNullableActivity();
5
+ return (activity?.zIndex ?? 0) * 5;
6
+ }
package/src/index.ts CHANGED
@@ -15,3 +15,4 @@ export {
15
15
  export { vars as bottomSheetVars } from "./components/BottomSheet.css";
16
16
  export { default as Modal, ModalProps } from "./components/Modal";
17
17
  export { vars as modalVars } from "./components/Modal.css";
18
+ export { useStyleEffect, useZIndexBase } from "./hooks";
package/src/utils/last.ts CHANGED
@@ -1 +1 @@
1
- export const last = <T extends unknown>(arr: T[]) => arr[arr.length - 1];
1
+ export const last = <T>(arr: T[]) => arr[arr.length - 1];