@stackflow/plugin-basic-ui 1.7.0 → 1.8.1

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 (48) 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 +11 -15
  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.css.ts +0 -1
  34. package/src/components/AppBar.tsx +5 -5
  35. package/src/components/AppScreen.css.ts +7 -8
  36. package/src/components/AppScreen.tsx +2 -2
  37. package/src/components/BottomSheet.css.ts +0 -1
  38. package/src/components/BottomSheet.tsx +8 -5
  39. package/src/components/Modal.css.ts +0 -1
  40. package/src/components/Modal.tsx +8 -5
  41. package/src/hooks/index.ts +1 -0
  42. package/src/hooks/useStyleEffect.ts +1 -1
  43. package/src/hooks/useStyleEffectHide.ts +0 -2
  44. package/src/hooks/useStyleEffectOffset.ts +1 -5
  45. package/src/hooks/useStyleEffectSwipeBack.ts +1 -3
  46. package/src/hooks/useZIndexBase.ts +6 -0
  47. package/src/index.ts +1 -0
  48. package/src/utils/last.ts +1 -1
@@ -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`
@@ -38,7 +38,6 @@ export const appBar = recipe({
38
38
  {
39
39
  backgroundColor: globalVars.appBar.backgroundColor,
40
40
  zIndex: vars.zIndexes.appBar,
41
- willChange: "transform, opacity",
42
41
  transition: transitions(appBarCommonTransition),
43
42
  selectors: {
44
43
  [`${cupertino} &`]: {
@@ -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>
@@ -57,7 +57,6 @@ export const dim = style([
57
57
  {
58
58
  opacity: 0,
59
59
  zIndex: vars.zIndexes.dim,
60
- willChange: "opacity",
61
60
  selectors: {
62
61
  [`${android} &`]: {
63
62
  height: "10rem",
@@ -91,7 +90,6 @@ export const paper = recipe({
91
90
  display: "none",
92
91
  },
93
92
  zIndex: vars.zIndexes.paper,
94
- willChange: "transform",
95
93
  selectors: {
96
94
  [`${cupertino} &`]: {
97
95
  transform: "translate3d(100%, 0, 0)",
@@ -121,14 +119,15 @@ export const paper = recipe({
121
119
  true: [
122
120
  f.borderBox,
123
121
  {
124
- transition: `transform ${vars.transitionDuration}, opacity ${vars.transitionDuration}, padding-top ${globalVars.appBar.heightTransitionDuration}`,
125
- paddingTop: globalVars.appBar.height,
122
+ transition: `transform ${vars.transitionDuration}, opacity ${vars.transitionDuration}, margin-top ${globalVars.appBar.heightTransitionDuration}`,
123
+ marginTop: globalVars.appBar.height,
124
+ height: `calc(100% - ${globalVars.appBar.height})`,
126
125
  "@supports": {
127
- "(padding-top: constant(safe-area-inset-top))": {
128
- paddingTop: `calc(${globalVars.appBar.height} + max(${globalVars.appBar.minSafeAreaInsetTop}, constant(safe-area-inset-top)))`,
126
+ "(margin-top: constant(safe-area-inset-top))": {
127
+ marginTop: `calc(${globalVars.appBar.height} + max(${globalVars.appBar.minSafeAreaInsetTop}, constant(safe-area-inset-top)))`,
129
128
  },
130
- "(padding-top: env(safe-area-inset-top))": {
131
- paddingTop: `calc(${globalVars.appBar.height} + max(${globalVars.appBar.minSafeAreaInsetTop}, env(safe-area-inset-top)))`,
129
+ "(margin-top: env(safe-area-inset-top))": {
130
+ marginTop: `calc(${globalVars.appBar.height} + max(${globalVars.appBar.minSafeAreaInsetTop}, env(safe-area-inset-top)))`,
132
131
  },
133
132
  },
134
133
  },
@@ -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);
@@ -62,7 +62,6 @@ export const paper = style([
62
62
  backgroundColor: globalVars.backgroundColor,
63
63
  width: "100%",
64
64
  borderRadius: `${globalVars.bottomSheet.borderRadius} ${globalVars.bottomSheet.borderRadius} 0 0`,
65
- willChange: "transform, opacity",
66
65
  transform: "translate3d(0, 100%, 0)",
67
66
  opacity: 0,
68
67
  selectors: {
@@ -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 (
@@ -66,7 +66,6 @@ export const paper = style([
66
66
  boxShadow:
67
67
  "0px 0.625rem 2.375rem rgba(0, 0, 0, 0.15), 0px .5625rem 2.875rem rgba(0, 0, 0, 0.12), 0px .3125rem .9375rem rgba(0, 0, 0, 0.1)",
68
68
  borderRadius: globalVars.modal.borderRadius,
69
- willChange: "transform, opacity",
70
69
  transform: "scale(1.1)",
71
70
  opacity: 0,
72
71
  selectors: {
@@ -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];