@stackflow/plugin-basic-ui 1.3.4 → 1.4.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.
package/dist/index.mjs CHANGED
@@ -335,13 +335,28 @@ var OFFSET_PX_CUPERTINO = 80;
335
335
  function useStyleEffectOffset({
336
336
  refs,
337
337
  theme,
338
- hasEffect
338
+ activityEnterStyle,
339
+ hasEffect = false
339
340
  }) {
340
341
  useStyleEffect({
341
342
  styleName: "offset",
342
343
  refs,
343
344
  effect: hasEffect ? ({ activityTransitionState, refs: refs2 }) => {
344
- const transform = theme === "cupertino" ? `translate3d(-${OFFSET_PX_CUPERTINO / 16}rem, 0, 0)` : `translate3d(0, -${OFFSET_PX_ANDROID / 16}rem, 0)`;
345
+ let transform;
346
+ let opacity;
347
+ switch (theme) {
348
+ case "cupertino": {
349
+ transform = `translate3d(-${OFFSET_PX_CUPERTINO / 16}rem, 0, 0)`;
350
+ opacity = "1";
351
+ break;
352
+ }
353
+ case "android":
354
+ default: {
355
+ transform = activityEnterStyle === "slideInLeft" ? `translate3d(-50%, 0, 0)` : `translate3d(0, -${OFFSET_PX_ANDROID / 16}rem, 0)`;
356
+ opacity = activityEnterStyle === "slideInLeft" ? "0" : "1";
357
+ break;
358
+ }
359
+ }
345
360
  const cleanup = () => {
346
361
  requestNextFrame(() => {
347
362
  refs2.forEach((ref) => {
@@ -350,6 +365,7 @@ function useStyleEffectOffset({
350
365
  }
351
366
  const $el = ref.current;
352
367
  $el.style.transform = "";
368
+ $el.style.opacity = "";
353
369
  listenOnce($el, "transitionend", () => {
354
370
  $el.style.transition = "";
355
371
  });
@@ -365,6 +381,7 @@ function useStyleEffectOffset({
365
381
  }
366
382
  ref.current.style.transition = globalVars.computedTransitionDuration;
367
383
  ref.current.style.transform = transform;
384
+ ref.current.style.opacity = opacity;
368
385
  });
369
386
  switch (activityTransitionState) {
370
387
  case "enter-done":
@@ -395,10 +412,10 @@ function useStyleEffectOffset({
395
412
  import { createRuntimeFn as _7a4682 } from "@vanilla-extract/recipes/createRuntimeFn";
396
413
  var appScreen = _7a4682({ defaultClassName: "dhthxq4 dhthxq0 dhthxq1 dhthxq2 dhthxq3 dhthxqc", variantClassNames: { transitionState: { "enter-active": "_1dlf4349", "enter-done": "_1dlf434a", "exit-active": "_1dlf434b", "exit-done": "_1dlf434c" } }, defaultVariants: {}, compoundVariants: [] });
397
414
  var dim = "_1dlf434i dhthxq4 dhthxq0 dhthxq1 dhthxq2 dhthxq3 _1dlf4346 _1dlf4348";
398
- var edge = _7a4682({ defaultClassName: "_1dlf434m dhthxq4 dhthxq2 dhthxq3 dhthxq1", variantClassNames: { hasAppBar: { true: "_1dlf434n" } }, defaultVariants: {}, compoundVariants: [] });
415
+ var edge = _7a4682({ defaultClassName: "_1dlf434n dhthxq4 dhthxq2 dhthxq3 dhthxq1", variantClassNames: { hasAppBar: { true: "_1dlf434o" } }, defaultVariants: {}, compoundVariants: [] });
399
416
  var exitActive = "_1dlf434b";
400
417
  var exitDone = "_1dlf434c";
401
- var paper = _7a4682({ defaultClassName: "_1dlf434j dhthxq4 dhthxq0 dhthxq1 dhthxq2 dhthxq3 _1dlf4347 _1dlf4348", variantClassNames: { hasAppBar: { true: "_1dlf434k dhthxqg" }, presentModalFullScreen: { true: "_1dlf434l" } }, defaultVariants: {}, compoundVariants: [] });
418
+ var paper = _7a4682({ defaultClassName: "_1dlf434j dhthxq4 dhthxq0 dhthxq1 dhthxq2 dhthxq3 _1dlf4347 _1dlf4348", variantClassNames: { hasAppBar: { true: "_1dlf434k dhthxqg" }, modalPresentationStyle: { fullScreen: "_1dlf434l" }, activityEnterStyle: { slideInLeft: "_1dlf434m" } }, defaultVariants: {}, compoundVariants: [] });
402
419
  var vars = { transitionDuration: "var(--_1dlf4340)", zIndexes: { dim: "var(--_1dlf4341)", paper: "var(--_1dlf4342)", edge: "var(--_1dlf4343)", appBar: "var(--_1dlf4344)" }, appBar: { center: { mainWidth: "var(--_1dlf4345)" } } };
403
420
 
404
421
  // src/hooks/useStyleEffectSwipeBack.ts
@@ -581,30 +598,31 @@ import { forwardRef, useRef } from "react";
581
598
 
582
599
  // src/components/AppBar.css.ts
583
600
  import { createRuntimeFn as _7a4683 } from "@vanilla-extract/recipes/createRuntimeFn";
584
- var appBar = _7a4683({ defaultClassName: "_1yk3a452 dhthxq4 dhthxq0 dhthxqh _1dlf4347 _1yk3a451", variantClassNames: { border: { true: "_1yk3a453" }, presentModalFullScreen: { true: "_1yk3a454" } }, defaultVariants: {}, compoundVariants: [] });
585
- var backButton = "_1yk3a458 dhthxq9 dhthxq7 dhthxqb dhthxqf dhthxqi";
601
+ var appBar = _7a4683({ defaultClassName: "_1yk3a452 dhthxq4 dhthxq0 dhthxqh _1dlf4347 _1yk3a451", variantClassNames: { border: { true: "_1yk3a453" }, modalPresentationStyle: { fullScreen: "_1yk3a454" }, activityEnterStyle: { slideInLeft: "_1yk3a455" } }, defaultVariants: {}, compoundVariants: [] });
602
+ var backButton = "_1yk3a459 dhthxq9 dhthxq7 dhthxqb dhthxqf dhthxqi";
586
603
  var center = "dhthxq9 dhthxq7 dhthxq8 _1yk3a450";
587
- var centerMain = _7a4683({ defaultClassName: "_1yk3a45b", variantClassNames: { hasLeft: { true: "_1yk3a45c" } }, defaultVariants: {}, compoundVariants: [] });
588
- var centerMainEdge = "_1yk3a45d dhthxqi dhthxq4 dhthxq2 dhthxqf";
589
- var centerText = "_1yk3a45e dhthxqc dhthxqd dhthxq0";
590
- var closeButton = "_1yk3a458 dhthxq9 dhthxq7 dhthxqb dhthxqf dhthxqi";
591
- var container = "_1yk3a456 dhthxqa dhthxq7 _1yk3a451";
592
- var left = "_1yk3a457 dhthxq9 dhthxq7 dhthxq1 _1yk3a450";
593
- var right = "_1yk3a45f dhthxq9 dhthxq7 dhthxq1 dhthxq5 _1yk3a450";
594
- var safeArea = "_1yk3a455";
604
+ var centerMain = _7a4683({ defaultClassName: "_1yk3a45c", variantClassNames: { hasLeft: { true: "_1yk3a45d" } }, defaultVariants: {}, compoundVariants: [] });
605
+ var centerMainEdge = "_1yk3a45e dhthxqi dhthxq4 dhthxq2 dhthxqf";
606
+ var centerText = "_1yk3a45f dhthxqc dhthxqd dhthxq0";
607
+ var closeButton = "_1yk3a459 dhthxq9 dhthxq7 dhthxqb dhthxqf dhthxqi";
608
+ var container = "_1yk3a457 dhthxqa dhthxq7 _1yk3a451";
609
+ var left = "_1yk3a458 dhthxq9 dhthxq7 dhthxq1 _1yk3a450";
610
+ var right = "_1yk3a45g dhthxq9 dhthxq7 dhthxq1 dhthxq5 _1yk3a450";
611
+ var safeArea = "_1yk3a456";
595
612
 
596
613
  // src/components/AppBar.tsx
597
614
  import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
598
615
  var AppBar = forwardRef(
599
616
  ({
600
617
  title,
601
- appendLeft,
602
- appendRight,
618
+ renderLeft,
619
+ renderRight,
603
620
  backButton: backButton2,
604
621
  closeButton: closeButton2,
605
622
  closeButtonLocation = "left",
606
623
  border = true,
607
624
  modalPresentationStyle,
625
+ activityEnterStyle,
608
626
  iconColor,
609
627
  iconColorTransitionDuration,
610
628
  textColor,
@@ -631,7 +649,6 @@ var AppBar = forwardRef(
631
649
  innerRef: centerRef,
632
650
  enable: globalOptions.theme === "cupertino"
633
651
  });
634
- const presentModalFullScreen = modalPresentationStyle === "fullScreen";
635
652
  const onBackClick = (e) => {
636
653
  if (backButton2 && "onClick" in backButton2 && backButton2.onClick) {
637
654
  backButton2.onClick(e);
@@ -679,7 +696,7 @@ var AppBar = forwardRef(
679
696
  if (globalBackButton && "renderIcon" in globalBackButton && globalBackButton.renderIcon) {
680
697
  return globalBackButton.renderIcon();
681
698
  }
682
- if (presentModalFullScreen) {
699
+ if (modalPresentationStyle === "fullScreen") {
683
700
  return /* @__PURE__ */ jsx4(IconClose_default, {});
684
701
  }
685
702
  return /* @__PURE__ */ jsx4(IconBack_default, {});
@@ -728,14 +745,15 @@ var AppBar = forwardRef(
728
745
  }
729
746
  );
730
747
  };
731
- const hasLeft = !!(closeButtonLocation === "left" && closeButton2 || backButton2 || appendLeft);
748
+ const hasLeft = !!(closeButtonLocation === "left" && closeButton2 || backButton2 || renderLeft);
732
749
  return /* @__PURE__ */ jsxs2(
733
750
  "div",
734
751
  {
735
752
  ref,
736
753
  className: appBar({
737
754
  border,
738
- presentModalFullScreen
755
+ modalPresentationStyle,
756
+ activityEnterStyle
739
757
  }),
740
758
  style: assignInlineVars2(
741
759
  compactMap({
@@ -760,7 +778,7 @@ var AppBar = forwardRef(
760
778
  /* @__PURE__ */ jsxs2("div", { className: left, children: [
761
779
  closeButtonLocation === "left" && renderCloseButton(),
762
780
  renderBackButton(),
763
- appendLeft == null ? void 0 : appendLeft()
781
+ renderLeft == null ? void 0 : renderLeft()
764
782
  ] }),
765
783
  /* @__PURE__ */ jsx4("div", { ref: centerRef, className: center, children: /* @__PURE__ */ jsxs2(
766
784
  "div",
@@ -783,7 +801,7 @@ var AppBar = forwardRef(
783
801
  }
784
802
  ) }),
785
803
  /* @__PURE__ */ jsxs2("div", { className: right, children: [
786
- appendRight == null ? void 0 : appendRight(),
804
+ renderRight == null ? void 0 : renderRight(),
787
805
  closeButtonLocation === "right" && renderCloseButton()
788
806
  ] })
789
807
  ] })
@@ -806,7 +824,8 @@ var AppScreen = ({
806
824
  dimBackgroundColor,
807
825
  appBar: appBar2,
808
826
  preventSwipeBack,
809
- modalPresentationStyle,
827
+ CUPERTINO_ONLY_modalPresentationStyle,
828
+ ANDROID_ONLY_activityEnterStyle,
810
829
  children
811
830
  }) => {
812
831
  var _a, _b;
@@ -818,36 +837,55 @@ var AppScreen = ({
818
837
  const paperRef = useRef2(null);
819
838
  const edgeRef = useRef2(null);
820
839
  const appBarRef = useRef2(null);
821
- const presentModalFullScreen = modalPresentationStyle === "fullScreen";
822
- const swipeBackPrevented = preventSwipeBack || presentModalFullScreen;
840
+ const modalPresentationStyle = globalOptions.theme === "cupertino" ? CUPERTINO_ONLY_modalPresentationStyle : void 0;
841
+ const activityEnterStyle = globalOptions.theme === "android" ? ANDROID_ONLY_activityEnterStyle : void 0;
842
+ const swipeBackPrevented = preventSwipeBack || modalPresentationStyle === "fullScreen";
843
+ const hasAppBar = !!appBar2;
844
+ const zIndexBase = ((_a = activity == null ? void 0 : activity.zIndex) != null ? _a : 0) * 5;
845
+ let zIndexDim;
846
+ let zIndexPaper;
847
+ let zIndexEdge;
848
+ let zIndexAppBar;
849
+ switch (globalOptions.theme) {
850
+ case "cupertino": {
851
+ zIndexDim = zIndexBase + (modalPresentationStyle === "fullScreen" ? 2 : 0);
852
+ zIndexPaper = zIndexBase + (hasAppBar && modalPresentationStyle !== "fullScreen" ? 1 : 3);
853
+ zIndexEdge = zIndexBase + 4;
854
+ zIndexAppBar = zIndexBase + 7;
855
+ break;
856
+ }
857
+ case "android":
858
+ default: {
859
+ zIndexDim = zIndexBase;
860
+ zIndexPaper = zIndexBase + (activityEnterStyle === "slideInLeft" ? 1 : 3);
861
+ zIndexEdge = zIndexBase + 4;
862
+ zIndexAppBar = zIndexBase + (activityEnterStyle === "slideInLeft" ? 7 : 4);
863
+ break;
864
+ }
865
+ }
866
+ const transitionState = (_b = activity == null ? void 0 : activity.transitionState) != null ? _b : "enter-done";
867
+ const lazyTransitionState = useLazy(transitionState);
823
868
  useStyleEffectHide({
824
869
  refs: [appScreenRef],
825
870
  hasEffect: true
826
871
  });
827
872
  useStyleEffectOffset({
873
+ refs: globalOptions.theme === "cupertino" || activityEnterStyle === "slideInLeft" ? [paperRef] : [paperRef, appBarRef],
828
874
  theme: globalOptions.theme,
829
- refs: globalOptions.theme === "cupertino" ? [paperRef] : [paperRef, appBarRef],
830
- hasEffect: !presentModalFullScreen
875
+ activityEnterStyle,
876
+ hasEffect: modalPresentationStyle !== "fullScreen"
831
877
  });
832
878
  useStyleEffectSwipeBack({
833
- theme: globalOptions.theme,
834
879
  dimRef,
835
880
  edgeRef,
836
881
  paperRef,
837
- hasEffect: true,
882
+ theme: globalOptions.theme,
838
883
  prevented: swipeBackPrevented,
839
884
  onSwiped() {
840
885
  pop();
841
- }
886
+ },
887
+ hasEffect: true
842
888
  });
843
- const hasAppBar = !!appBar2;
844
- const zIndexBase = ((_a = activity == null ? void 0 : activity.zIndex) != null ? _a : 0) * 5;
845
- const zIndexDim = zIndexBase;
846
- const zIndexPaper = zIndexBase + (globalOptions.theme === "cupertino" && hasAppBar ? 1 : 3);
847
- const zIndexEdge = zIndexBase + 4;
848
- const zIndexAppBar = globalOptions.theme === "cupertino" ? zIndexBase + 7 : zIndexBase + 4;
849
- const transitionState = (_b = activity == null ? void 0 : activity.transitionState) != null ? _b : "enter-done";
850
- const lazyTransitionState = useLazy(transitionState);
851
889
  const onAppBarTopClick = (e) => {
852
890
  var _a2, _b2;
853
891
  (_a2 = appBar2 == null ? void 0 : appBar2.onTopClick) == null ? void 0 : _a2.call(appBar2, e);
@@ -893,13 +931,17 @@ var AppScreen = ({
893
931
  [vars.transitionDuration]: transitionState === "enter-active" || transitionState === "exit-active" ? globalVars.computedTransitionDuration : "0ms"
894
932
  })
895
933
  ),
934
+ "data-stackflow-component-name": "AppScreen",
935
+ "data-stackflow-activity-id": activity == null ? void 0 : activity.id,
936
+ "data-stackflow-activity-is-active": activity == null ? void 0 : activity.isActive,
896
937
  children: [
897
- /* @__PURE__ */ jsx5("div", { className: dim, ref: dimRef }),
938
+ activityEnterStyle !== "slideInLeft" && /* @__PURE__ */ jsx5("div", { className: dim, ref: dimRef }),
898
939
  appBar2 && /* @__PURE__ */ jsx5(
899
940
  AppBar_default,
900
941
  __spreadProps(__spreadValues({}, appBar2), {
901
942
  ref: appBarRef,
902
943
  modalPresentationStyle,
944
+ activityEnterStyle,
903
945
  onTopClick: onAppBarTopClick
904
946
  })
905
947
  ),
@@ -908,7 +950,8 @@ var AppScreen = ({
908
950
  {
909
951
  className: paper({
910
952
  hasAppBar,
911
- presentModalFullScreen
953
+ modalPresentationStyle,
954
+ activityEnterStyle
912
955
  }),
913
956
  ref: paperRef,
914
957
  children
@@ -998,6 +1041,9 @@ var BottomSheet = ({
998
1041
  [vars2.transitionDuration]: transitionState === "enter-active" || transitionState === "exit-active" ? globalVars.computedTransitionDuration : "0ms"
999
1042
  })
1000
1043
  ),
1044
+ "data-stackflow-component-name": "BottomSheet",
1045
+ "data-stackflow-activity-id": activity == null ? void 0 : activity.id,
1046
+ "data-stackflow-activity-is-active": activity == null ? void 0 : activity.isActive,
1001
1047
  children: /* @__PURE__ */ jsx6("div", { className: dim2, ref: paperRef, onClick: onDimClick, children: /* @__PURE__ */ jsx6("div", { className: paper2, onClick: onPaperClick, children }) })
1002
1048
  }
1003
1049
  );
@@ -1078,6 +1124,9 @@ var Modal = ({
1078
1124
  [vars3.transitionDuration]: transitionState === "enter-active" || transitionState === "exit-active" ? globalVars.computedTransitionDuration : "0ms"
1079
1125
  })
1080
1126
  ),
1127
+ "data-stackflow-component-name": "Modal",
1128
+ "data-stackflow-activity-id": activity == null ? void 0 : activity.id,
1129
+ "data-stackflow-activity-is-active": activity == null ? void 0 : activity.isActive,
1081
1130
  children: /* @__PURE__ */ jsx7("div", { className: dim3, ref: paperRef, onClick: onDimClick, children: /* @__PURE__ */ jsx7("div", { className: paper3, onClick: onPaperClick, children }) })
1082
1131
  }
1083
1132
  );