qstd 0.2.16 → 0.2.17

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.
@@ -1 +1 @@
1
- {"version":3,"file":"drawer.d.ts","sourceRoot":"","sources":["../../src/block/drawer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAY1B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAE9B,QAAA,MAAM,SAAS,sKAAoB,CAAC;AACpC,QAAA,MAAM,SAAS,4KAAuB,CAAC;AAuUvC,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC,gBAAgB,2CAMxD;AAID,wBAAgB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,SAAS,CAAC,2CAYrE;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,SAAS,CAAC,uDAuDrE"}
1
+ {"version":3,"file":"drawer.d.ts","sourceRoot":"","sources":["../../src/block/drawer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAY1B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAE9B,QAAA,MAAM,SAAS,sKAAoB,CAAC;AACpC,QAAA,MAAM,SAAS,4KAAuB,CAAC;AAmWvC,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC,gBAAgB,2CAMxD;AAID,wBAAgB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,SAAS,CAAC,2CAYrE;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,SAAS,CAAC,uDAkDrE"}
@@ -2506,7 +2506,10 @@ function DrawerComponent(props) {
2506
2506
  y.set(0);
2507
2507
  setOpen(true);
2508
2508
  };
2509
- const closeDrawer = () => setOpen(false);
2509
+ const closeDrawer = () => {
2510
+ y.stop();
2511
+ setOpen(false);
2512
+ };
2510
2513
  React12__namespace.default.useEffect(() => {
2511
2514
  closeFnRef.current = () => {
2512
2515
  closeDrawer();
@@ -2527,7 +2530,7 @@ function DrawerComponent(props) {
2527
2530
  );
2528
2531
  }
2529
2532
  };
2530
- React12__namespace.default.useEffect(() => {
2533
+ React12__namespace.default.useLayoutEffect(() => {
2531
2534
  const wasOpen = prevOpenRef.current;
2532
2535
  const isOpen = props.open;
2533
2536
  if (isOpen) {
@@ -2560,6 +2563,7 @@ function DrawerComponent(props) {
2560
2563
  };
2561
2564
  }, [open, props.closeOnEsc]);
2562
2565
  React12__namespace.default.useEffect(() => {
2566
+ if (!props.open) return;
2563
2567
  const unsubscribeY = y.on("change", (latestY) => {
2564
2568
  if (latestY > 150) {
2565
2569
  console.log("[close] latestY > 150");
@@ -2568,8 +2572,9 @@ function DrawerComponent(props) {
2568
2572
  });
2569
2573
  return () => {
2570
2574
  unsubscribeY();
2575
+ y.stop();
2571
2576
  };
2572
- }, [y]);
2577
+ }, [y, props.open]);
2573
2578
  const onBackdropClick = () => {
2574
2579
  const outsideClickClose = props.outsideClickClose ?? true;
2575
2580
  if (!outsideClickClose) return;
@@ -2629,15 +2634,34 @@ function DrawerComponent(props) {
2629
2634
  bottom: 0,
2630
2635
  borderTopLeftRadius: 12,
2631
2636
  borderTopRightRadius: 12,
2637
+ overflow: "hidden",
2638
+ // Note: Can't use framer-motion's `y` prop because it conflicts
2639
+ // with the drag motion value. Use CSS transform instead.
2632
2640
  variants: {
2633
- initial: { height: 0, opacity: 0 },
2641
+ initial: {
2642
+ transform: "translateY(100%)",
2643
+ opacity: 0.5
2644
+ },
2634
2645
  animate: {
2635
- height: "auto",
2646
+ transform: "translateY(0%)",
2636
2647
  opacity: 1,
2637
- // transition: { type: "spring", damping: 26, stiffness: 300 },
2638
- transition: { type: "spring", duration: 0.3 }
2648
+ transition: {
2649
+ type: "spring",
2650
+ damping: 22,
2651
+ stiffness: 400,
2652
+ mass: 0.7
2653
+ }
2639
2654
  },
2640
- exit: { height: 0, opacity: 0 }
2655
+ exit: {
2656
+ transform: "translateY(100%)",
2657
+ opacity: 0,
2658
+ transition: {
2659
+ type: "tween",
2660
+ duration: 0.2,
2661
+ ease: [0.4, 0, 1, 1]
2662
+ // ease-in for quick exit
2663
+ }
2664
+ }
2641
2665
  },
2642
2666
  drag: "y",
2643
2667
  style: { y },
@@ -2757,6 +2781,8 @@ function CloseBtn(props) {
2757
2781
  bg: { base: "neutral.200", _dark: "neutral.800" }
2758
2782
  },
2759
2783
  position: "absolute",
2784
+ flex: true,
2785
+ center: true,
2760
2786
  h: 32,
2761
2787
  w: 32,
2762
2788
  top: -2,
@@ -2764,17 +2790,7 @@ function CloseBtn(props) {
2764
2790
  borderRadius: 32,
2765
2791
  cursor: "pointer",
2766
2792
  ...rest,
2767
- children: /* @__PURE__ */ jsxRuntime.jsx(
2768
- Icon,
2769
- {
2770
- icon: "times",
2771
- placeC: true,
2772
- h: 16,
2773
- w: 16,
2774
- fontSize: 16,
2775
- color: "currentColor"
2776
- }
2777
- )
2793
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { icon: "times", fontSize: 16, lineHeight: 1, color: "currentColor" })
2778
2794
  }
2779
2795
  );
2780
2796
  } else if (children) {
@@ -2784,7 +2800,7 @@ function CloseBtn(props) {
2784
2800
  }
2785
2801
  }
2786
2802
  function Backdrop(props) {
2787
- const [allowOutsideClick, setAllowOutsideClick] = React12__namespace.default.useState(true);
2803
+ const allowOutsideClickRef = React12__namespace.default.useRef(true);
2788
2804
  const [isDesktop] = useMatchMedia(breakpoint);
2789
2805
  return /* @__PURE__ */ jsxRuntime.jsx(
2790
2806
  MotionDiv4,
@@ -2797,10 +2813,10 @@ function Backdrop(props) {
2797
2813
  animate: { opacity: 1, transition: { duration: 0.2 } },
2798
2814
  exit: { opacity: 0, transition: { duration: 0.3 } },
2799
2815
  onAnimationStart: () => {
2800
- setAllowOutsideClick(false);
2816
+ allowOutsideClickRef.current = false;
2801
2817
  },
2802
2818
  onAnimationComplete: () => {
2803
- setAllowOutsideClick(true);
2819
+ allowOutsideClickRef.current = true;
2804
2820
  },
2805
2821
  position: "fixed",
2806
2822
  top: 0,
@@ -2808,13 +2824,12 @@ function Backdrop(props) {
2808
2824
  height: "100%",
2809
2825
  width: "100%",
2810
2826
  ...isDesktop ? { placeI: true } : {},
2811
- onClick: () => allowOutsideClick ? props.onClick() : void 0,
2827
+ onClick: () => allowOutsideClickRef.current ? props.onClick() : void 0,
2812
2828
  children: props.children
2813
2829
  }
2814
2830
  );
2815
2831
  }
2816
- function useMatchMedia(queries, defaultValues = []) {
2817
- defaultValues.length ? defaultValues : Array(queries.length).fill(false);
2832
+ function useMatchMedia(queries) {
2818
2833
  const [value, setValue] = React12__namespace.default.useState(() => {
2819
2834
  return queries.map((q) => window.matchMedia(q).matches);
2820
2835
  });
@@ -871,6 +871,9 @@
871
871
  .rounded_12 {
872
872
  border-radius: 12px;
873
873
  }
874
+ .ov_hidden {
875
+ overflow: hidden;
876
+ }
874
877
  .rounded_20 {
875
878
  border-radius: 20px;
876
879
  }
@@ -886,9 +889,6 @@
886
889
  .rounded_50\% {
887
890
  border-radius: 50%;
888
891
  }
889
- .ov_hidden {
890
- overflow: hidden;
891
- }
892
892
  .trs_200ms_cubic-bezier\(0\,_0\,_0\.2\,_1\)_0ms\,_\.2s_color_ease-in-out\,_\.2s_background_ease-in-out {
893
893
  transition:
894
894
  200ms cubic-bezier(0, 0, 0.2, 1) 0ms,
@@ -1030,12 +1030,16 @@
1030
1030
  .pos_absolute {
1031
1031
  position: absolute;
1032
1032
  }
1033
- .place-c_true {
1033
+ .center_true {
1034
1034
  place-content: center;
1035
+ place-items: center;
1035
1036
  }
1036
1037
  .fs_16 {
1037
1038
  font-size: 16px;
1038
1039
  }
1040
+ .lh_1 {
1041
+ line-height: 1;
1042
+ }
1039
1043
  .c_currentColor {
1040
1044
  color: currentColor;
1041
1045
  }
@@ -1268,12 +1272,6 @@
1268
1272
  .right_3 {
1269
1273
  right: var(--spacing-3);
1270
1274
  }
1271
- .h_16 {
1272
- height: 16px;
1273
- }
1274
- .w_16 {
1275
- width: 16px;
1276
- }
1277
1275
  .w_12px {
1278
1276
  width: 12px;
1279
1277
  }
@@ -2483,7 +2483,10 @@ function DrawerComponent(props) {
2483
2483
  y.set(0);
2484
2484
  setOpen(true);
2485
2485
  };
2486
- const closeDrawer = () => setOpen(false);
2486
+ const closeDrawer = () => {
2487
+ y.stop();
2488
+ setOpen(false);
2489
+ };
2487
2490
  React12__default.useEffect(() => {
2488
2491
  closeFnRef.current = () => {
2489
2492
  closeDrawer();
@@ -2504,7 +2507,7 @@ function DrawerComponent(props) {
2504
2507
  );
2505
2508
  }
2506
2509
  };
2507
- React12__default.useEffect(() => {
2510
+ React12__default.useLayoutEffect(() => {
2508
2511
  const wasOpen = prevOpenRef.current;
2509
2512
  const isOpen = props.open;
2510
2513
  if (isOpen) {
@@ -2537,6 +2540,7 @@ function DrawerComponent(props) {
2537
2540
  };
2538
2541
  }, [open, props.closeOnEsc]);
2539
2542
  React12__default.useEffect(() => {
2543
+ if (!props.open) return;
2540
2544
  const unsubscribeY = y.on("change", (latestY) => {
2541
2545
  if (latestY > 150) {
2542
2546
  console.log("[close] latestY > 150");
@@ -2545,8 +2549,9 @@ function DrawerComponent(props) {
2545
2549
  });
2546
2550
  return () => {
2547
2551
  unsubscribeY();
2552
+ y.stop();
2548
2553
  };
2549
- }, [y]);
2554
+ }, [y, props.open]);
2550
2555
  const onBackdropClick = () => {
2551
2556
  const outsideClickClose = props.outsideClickClose ?? true;
2552
2557
  if (!outsideClickClose) return;
@@ -2606,15 +2611,34 @@ function DrawerComponent(props) {
2606
2611
  bottom: 0,
2607
2612
  borderTopLeftRadius: 12,
2608
2613
  borderTopRightRadius: 12,
2614
+ overflow: "hidden",
2615
+ // Note: Can't use framer-motion's `y` prop because it conflicts
2616
+ // with the drag motion value. Use CSS transform instead.
2609
2617
  variants: {
2610
- initial: { height: 0, opacity: 0 },
2618
+ initial: {
2619
+ transform: "translateY(100%)",
2620
+ opacity: 0.5
2621
+ },
2611
2622
  animate: {
2612
- height: "auto",
2623
+ transform: "translateY(0%)",
2613
2624
  opacity: 1,
2614
- // transition: { type: "spring", damping: 26, stiffness: 300 },
2615
- transition: { type: "spring", duration: 0.3 }
2625
+ transition: {
2626
+ type: "spring",
2627
+ damping: 22,
2628
+ stiffness: 400,
2629
+ mass: 0.7
2630
+ }
2616
2631
  },
2617
- exit: { height: 0, opacity: 0 }
2632
+ exit: {
2633
+ transform: "translateY(100%)",
2634
+ opacity: 0,
2635
+ transition: {
2636
+ type: "tween",
2637
+ duration: 0.2,
2638
+ ease: [0.4, 0, 1, 1]
2639
+ // ease-in for quick exit
2640
+ }
2641
+ }
2618
2642
  },
2619
2643
  drag: "y",
2620
2644
  style: { y },
@@ -2734,6 +2758,8 @@ function CloseBtn(props) {
2734
2758
  bg: { base: "neutral.200", _dark: "neutral.800" }
2735
2759
  },
2736
2760
  position: "absolute",
2761
+ flex: true,
2762
+ center: true,
2737
2763
  h: 32,
2738
2764
  w: 32,
2739
2765
  top: -2,
@@ -2741,17 +2767,7 @@ function CloseBtn(props) {
2741
2767
  borderRadius: 32,
2742
2768
  cursor: "pointer",
2743
2769
  ...rest,
2744
- children: /* @__PURE__ */ jsx(
2745
- Icon,
2746
- {
2747
- icon: "times",
2748
- placeC: true,
2749
- h: 16,
2750
- w: 16,
2751
- fontSize: 16,
2752
- color: "currentColor"
2753
- }
2754
- )
2770
+ children: /* @__PURE__ */ jsx(Icon, { icon: "times", fontSize: 16, lineHeight: 1, color: "currentColor" })
2755
2771
  }
2756
2772
  );
2757
2773
  } else if (children) {
@@ -2761,7 +2777,7 @@ function CloseBtn(props) {
2761
2777
  }
2762
2778
  }
2763
2779
  function Backdrop(props) {
2764
- const [allowOutsideClick, setAllowOutsideClick] = React12__default.useState(true);
2780
+ const allowOutsideClickRef = React12__default.useRef(true);
2765
2781
  const [isDesktop] = useMatchMedia(breakpoint);
2766
2782
  return /* @__PURE__ */ jsx(
2767
2783
  MotionDiv4,
@@ -2774,10 +2790,10 @@ function Backdrop(props) {
2774
2790
  animate: { opacity: 1, transition: { duration: 0.2 } },
2775
2791
  exit: { opacity: 0, transition: { duration: 0.3 } },
2776
2792
  onAnimationStart: () => {
2777
- setAllowOutsideClick(false);
2793
+ allowOutsideClickRef.current = false;
2778
2794
  },
2779
2795
  onAnimationComplete: () => {
2780
- setAllowOutsideClick(true);
2796
+ allowOutsideClickRef.current = true;
2781
2797
  },
2782
2798
  position: "fixed",
2783
2799
  top: 0,
@@ -2785,13 +2801,12 @@ function Backdrop(props) {
2785
2801
  height: "100%",
2786
2802
  width: "100%",
2787
2803
  ...isDesktop ? { placeI: true } : {},
2788
- onClick: () => allowOutsideClick ? props.onClick() : void 0,
2804
+ onClick: () => allowOutsideClickRef.current ? props.onClick() : void 0,
2789
2805
  children: props.children
2790
2806
  }
2791
2807
  );
2792
2808
  }
2793
- function useMatchMedia(queries, defaultValues = []) {
2794
- defaultValues.length ? defaultValues : Array(queries.length).fill(false);
2809
+ function useMatchMedia(queries) {
2795
2810
  const [value, setValue] = React12__default.useState(() => {
2796
2811
  return queries.map((q) => window.matchMedia(q).matches);
2797
2812
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qstd",
3
- "version": "0.2.16",
3
+ "version": "0.2.17",
4
4
  "description": "Standard Block component and utilities library with Panda CSS",
5
5
  "author": "malin1",
6
6
  "license": "MIT",