qstd 0.2.15 → 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;AA0TvC,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"}
@@ -2496,6 +2496,7 @@ function DrawerComponent(props) {
2496
2496
  const dragHandleRef = React12__namespace.default.useRef(null);
2497
2497
  const [isDesktop] = useMatchMedia(breakpoint);
2498
2498
  const closeFnRef = React12__namespace.default.useRef(null);
2499
+ const prevOpenRef = React12__namespace.default.useRef(null);
2499
2500
  const dragControls = framerMotion.useDragControls();
2500
2501
  const { open, setOpen } = useDrawer();
2501
2502
  const { onClose, ...rest } = props;
@@ -2505,7 +2506,10 @@ function DrawerComponent(props) {
2505
2506
  y.set(0);
2506
2507
  setOpen(true);
2507
2508
  };
2508
- const closeDrawer = () => setOpen(false);
2509
+ const closeDrawer = () => {
2510
+ y.stop();
2511
+ setOpen(false);
2512
+ };
2509
2513
  React12__namespace.default.useEffect(() => {
2510
2514
  closeFnRef.current = () => {
2511
2515
  closeDrawer();
@@ -2526,9 +2530,15 @@ function DrawerComponent(props) {
2526
2530
  );
2527
2531
  }
2528
2532
  };
2529
- React12__namespace.default.useEffect(() => {
2530
- if (props.open) openDrawer();
2531
- else closeFnRef.current?.();
2533
+ React12__namespace.default.useLayoutEffect(() => {
2534
+ const wasOpen = prevOpenRef.current;
2535
+ const isOpen = props.open;
2536
+ if (isOpen) {
2537
+ openDrawer();
2538
+ } else if (wasOpen === true) {
2539
+ closeFnRef.current?.();
2540
+ }
2541
+ prevOpenRef.current = isOpen;
2532
2542
  }, [props.open]);
2533
2543
  React12__namespace.default.useEffect(() => {
2534
2544
  const container = ref.current;
@@ -2553,6 +2563,7 @@ function DrawerComponent(props) {
2553
2563
  };
2554
2564
  }, [open, props.closeOnEsc]);
2555
2565
  React12__namespace.default.useEffect(() => {
2566
+ if (!props.open) return;
2556
2567
  const unsubscribeY = y.on("change", (latestY) => {
2557
2568
  if (latestY > 150) {
2558
2569
  console.log("[close] latestY > 150");
@@ -2561,8 +2572,9 @@ function DrawerComponent(props) {
2561
2572
  });
2562
2573
  return () => {
2563
2574
  unsubscribeY();
2575
+ y.stop();
2564
2576
  };
2565
- }, [y]);
2577
+ }, [y, props.open]);
2566
2578
  const onBackdropClick = () => {
2567
2579
  const outsideClickClose = props.outsideClickClose ?? true;
2568
2580
  if (!outsideClickClose) return;
@@ -2622,15 +2634,34 @@ function DrawerComponent(props) {
2622
2634
  bottom: 0,
2623
2635
  borderTopLeftRadius: 12,
2624
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.
2625
2640
  variants: {
2626
- initial: { height: 0, opacity: 0 },
2641
+ initial: {
2642
+ transform: "translateY(100%)",
2643
+ opacity: 0.5
2644
+ },
2627
2645
  animate: {
2628
- height: "auto",
2646
+ transform: "translateY(0%)",
2629
2647
  opacity: 1,
2630
- // transition: { type: "spring", damping: 26, stiffness: 300 },
2631
- transition: { type: "spring", duration: 0.3 }
2648
+ transition: {
2649
+ type: "spring",
2650
+ damping: 22,
2651
+ stiffness: 400,
2652
+ mass: 0.7
2653
+ }
2632
2654
  },
2633
- 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
+ }
2634
2665
  },
2635
2666
  drag: "y",
2636
2667
  style: { y },
@@ -2750,6 +2781,8 @@ function CloseBtn(props) {
2750
2781
  bg: { base: "neutral.200", _dark: "neutral.800" }
2751
2782
  },
2752
2783
  position: "absolute",
2784
+ flex: true,
2785
+ center: true,
2753
2786
  h: 32,
2754
2787
  w: 32,
2755
2788
  top: -2,
@@ -2757,17 +2790,7 @@ function CloseBtn(props) {
2757
2790
  borderRadius: 32,
2758
2791
  cursor: "pointer",
2759
2792
  ...rest,
2760
- children: /* @__PURE__ */ jsxRuntime.jsx(
2761
- Icon,
2762
- {
2763
- icon: "times",
2764
- placeC: true,
2765
- h: 16,
2766
- w: 16,
2767
- fontSize: 16,
2768
- color: "currentColor"
2769
- }
2770
- )
2793
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { icon: "times", fontSize: 16, lineHeight: 1, color: "currentColor" })
2771
2794
  }
2772
2795
  );
2773
2796
  } else if (children) {
@@ -2777,7 +2800,7 @@ function CloseBtn(props) {
2777
2800
  }
2778
2801
  }
2779
2802
  function Backdrop(props) {
2780
- const [allowOutsideClick, setAllowOutsideClick] = React12__namespace.default.useState(true);
2803
+ const allowOutsideClickRef = React12__namespace.default.useRef(true);
2781
2804
  const [isDesktop] = useMatchMedia(breakpoint);
2782
2805
  return /* @__PURE__ */ jsxRuntime.jsx(
2783
2806
  MotionDiv4,
@@ -2790,10 +2813,10 @@ function Backdrop(props) {
2790
2813
  animate: { opacity: 1, transition: { duration: 0.2 } },
2791
2814
  exit: { opacity: 0, transition: { duration: 0.3 } },
2792
2815
  onAnimationStart: () => {
2793
- setAllowOutsideClick(false);
2816
+ allowOutsideClickRef.current = false;
2794
2817
  },
2795
2818
  onAnimationComplete: () => {
2796
- setAllowOutsideClick(true);
2819
+ allowOutsideClickRef.current = true;
2797
2820
  },
2798
2821
  position: "fixed",
2799
2822
  top: 0,
@@ -2801,25 +2824,26 @@ function Backdrop(props) {
2801
2824
  height: "100%",
2802
2825
  width: "100%",
2803
2826
  ...isDesktop ? { placeI: true } : {},
2804
- onClick: () => allowOutsideClick ? props.onClick() : void 0,
2827
+ onClick: () => allowOutsideClickRef.current ? props.onClick() : void 0,
2805
2828
  children: props.children
2806
2829
  }
2807
2830
  );
2808
2831
  }
2809
- function useMatchMedia(queries, defaultValues = []) {
2810
- const initialValues = defaultValues.length ? defaultValues : Array(queries.length).fill(false);
2811
- const mediaQueryLists = queries.map((q) => window.matchMedia(q));
2812
- const getValue = () => {
2813
- const matchedQueries = mediaQueryLists.map((mql) => mql.matches);
2814
- return matchedQueries;
2815
- };
2816
- const [value, setValue] = React12__namespace.default.useState(getValue);
2832
+ function useMatchMedia(queries) {
2833
+ const [value, setValue] = React12__namespace.default.useState(() => {
2834
+ return queries.map((q) => window.matchMedia(q).matches);
2835
+ });
2817
2836
  React12__namespace.default.useLayoutEffect(() => {
2818
- const handler = () => setValue(getValue);
2819
- mediaQueryLists.forEach((mql) => mql.addListener(handler));
2820
- return () => mediaQueryLists.forEach((mql) => mql.removeListener(handler));
2821
- }, []);
2822
- if (typeof window === "undefined") return initialValues;
2837
+ const mediaQueryLists = queries.map((q) => window.matchMedia(q));
2838
+ const handler = () => {
2839
+ setValue(mediaQueryLists.map((mql) => mql.matches));
2840
+ };
2841
+ handler();
2842
+ mediaQueryLists.forEach((mql) => mql.addEventListener("change", handler));
2843
+ return () => mediaQueryLists.forEach(
2844
+ (mql) => mql.removeEventListener("change", handler)
2845
+ );
2846
+ }, [queries]);
2823
2847
  return value;
2824
2848
  }
2825
2849
  var MotionDiv5 = motionTags.div;
@@ -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
  }
@@ -2473,6 +2473,7 @@ function DrawerComponent(props) {
2473
2473
  const dragHandleRef = React12__default.useRef(null);
2474
2474
  const [isDesktop] = useMatchMedia(breakpoint);
2475
2475
  const closeFnRef = React12__default.useRef(null);
2476
+ const prevOpenRef = React12__default.useRef(null);
2476
2477
  const dragControls = useDragControls();
2477
2478
  const { open, setOpen } = useDrawer();
2478
2479
  const { onClose, ...rest } = props;
@@ -2482,7 +2483,10 @@ function DrawerComponent(props) {
2482
2483
  y.set(0);
2483
2484
  setOpen(true);
2484
2485
  };
2485
- const closeDrawer = () => setOpen(false);
2486
+ const closeDrawer = () => {
2487
+ y.stop();
2488
+ setOpen(false);
2489
+ };
2486
2490
  React12__default.useEffect(() => {
2487
2491
  closeFnRef.current = () => {
2488
2492
  closeDrawer();
@@ -2503,9 +2507,15 @@ function DrawerComponent(props) {
2503
2507
  );
2504
2508
  }
2505
2509
  };
2506
- React12__default.useEffect(() => {
2507
- if (props.open) openDrawer();
2508
- else closeFnRef.current?.();
2510
+ React12__default.useLayoutEffect(() => {
2511
+ const wasOpen = prevOpenRef.current;
2512
+ const isOpen = props.open;
2513
+ if (isOpen) {
2514
+ openDrawer();
2515
+ } else if (wasOpen === true) {
2516
+ closeFnRef.current?.();
2517
+ }
2518
+ prevOpenRef.current = isOpen;
2509
2519
  }, [props.open]);
2510
2520
  React12__default.useEffect(() => {
2511
2521
  const container = ref.current;
@@ -2530,6 +2540,7 @@ function DrawerComponent(props) {
2530
2540
  };
2531
2541
  }, [open, props.closeOnEsc]);
2532
2542
  React12__default.useEffect(() => {
2543
+ if (!props.open) return;
2533
2544
  const unsubscribeY = y.on("change", (latestY) => {
2534
2545
  if (latestY > 150) {
2535
2546
  console.log("[close] latestY > 150");
@@ -2538,8 +2549,9 @@ function DrawerComponent(props) {
2538
2549
  });
2539
2550
  return () => {
2540
2551
  unsubscribeY();
2552
+ y.stop();
2541
2553
  };
2542
- }, [y]);
2554
+ }, [y, props.open]);
2543
2555
  const onBackdropClick = () => {
2544
2556
  const outsideClickClose = props.outsideClickClose ?? true;
2545
2557
  if (!outsideClickClose) return;
@@ -2599,15 +2611,34 @@ function DrawerComponent(props) {
2599
2611
  bottom: 0,
2600
2612
  borderTopLeftRadius: 12,
2601
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.
2602
2617
  variants: {
2603
- initial: { height: 0, opacity: 0 },
2618
+ initial: {
2619
+ transform: "translateY(100%)",
2620
+ opacity: 0.5
2621
+ },
2604
2622
  animate: {
2605
- height: "auto",
2623
+ transform: "translateY(0%)",
2606
2624
  opacity: 1,
2607
- // transition: { type: "spring", damping: 26, stiffness: 300 },
2608
- transition: { type: "spring", duration: 0.3 }
2625
+ transition: {
2626
+ type: "spring",
2627
+ damping: 22,
2628
+ stiffness: 400,
2629
+ mass: 0.7
2630
+ }
2609
2631
  },
2610
- 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
+ }
2611
2642
  },
2612
2643
  drag: "y",
2613
2644
  style: { y },
@@ -2727,6 +2758,8 @@ function CloseBtn(props) {
2727
2758
  bg: { base: "neutral.200", _dark: "neutral.800" }
2728
2759
  },
2729
2760
  position: "absolute",
2761
+ flex: true,
2762
+ center: true,
2730
2763
  h: 32,
2731
2764
  w: 32,
2732
2765
  top: -2,
@@ -2734,17 +2767,7 @@ function CloseBtn(props) {
2734
2767
  borderRadius: 32,
2735
2768
  cursor: "pointer",
2736
2769
  ...rest,
2737
- children: /* @__PURE__ */ jsx(
2738
- Icon,
2739
- {
2740
- icon: "times",
2741
- placeC: true,
2742
- h: 16,
2743
- w: 16,
2744
- fontSize: 16,
2745
- color: "currentColor"
2746
- }
2747
- )
2770
+ children: /* @__PURE__ */ jsx(Icon, { icon: "times", fontSize: 16, lineHeight: 1, color: "currentColor" })
2748
2771
  }
2749
2772
  );
2750
2773
  } else if (children) {
@@ -2754,7 +2777,7 @@ function CloseBtn(props) {
2754
2777
  }
2755
2778
  }
2756
2779
  function Backdrop(props) {
2757
- const [allowOutsideClick, setAllowOutsideClick] = React12__default.useState(true);
2780
+ const allowOutsideClickRef = React12__default.useRef(true);
2758
2781
  const [isDesktop] = useMatchMedia(breakpoint);
2759
2782
  return /* @__PURE__ */ jsx(
2760
2783
  MotionDiv4,
@@ -2767,10 +2790,10 @@ function Backdrop(props) {
2767
2790
  animate: { opacity: 1, transition: { duration: 0.2 } },
2768
2791
  exit: { opacity: 0, transition: { duration: 0.3 } },
2769
2792
  onAnimationStart: () => {
2770
- setAllowOutsideClick(false);
2793
+ allowOutsideClickRef.current = false;
2771
2794
  },
2772
2795
  onAnimationComplete: () => {
2773
- setAllowOutsideClick(true);
2796
+ allowOutsideClickRef.current = true;
2774
2797
  },
2775
2798
  position: "fixed",
2776
2799
  top: 0,
@@ -2778,25 +2801,26 @@ function Backdrop(props) {
2778
2801
  height: "100%",
2779
2802
  width: "100%",
2780
2803
  ...isDesktop ? { placeI: true } : {},
2781
- onClick: () => allowOutsideClick ? props.onClick() : void 0,
2804
+ onClick: () => allowOutsideClickRef.current ? props.onClick() : void 0,
2782
2805
  children: props.children
2783
2806
  }
2784
2807
  );
2785
2808
  }
2786
- function useMatchMedia(queries, defaultValues = []) {
2787
- const initialValues = defaultValues.length ? defaultValues : Array(queries.length).fill(false);
2788
- const mediaQueryLists = queries.map((q) => window.matchMedia(q));
2789
- const getValue = () => {
2790
- const matchedQueries = mediaQueryLists.map((mql) => mql.matches);
2791
- return matchedQueries;
2792
- };
2793
- const [value, setValue] = React12__default.useState(getValue);
2809
+ function useMatchMedia(queries) {
2810
+ const [value, setValue] = React12__default.useState(() => {
2811
+ return queries.map((q) => window.matchMedia(q).matches);
2812
+ });
2794
2813
  React12__default.useLayoutEffect(() => {
2795
- const handler = () => setValue(getValue);
2796
- mediaQueryLists.forEach((mql) => mql.addListener(handler));
2797
- return () => mediaQueryLists.forEach((mql) => mql.removeListener(handler));
2798
- }, []);
2799
- if (typeof window === "undefined") return initialValues;
2814
+ const mediaQueryLists = queries.map((q) => window.matchMedia(q));
2815
+ const handler = () => {
2816
+ setValue(mediaQueryLists.map((mql) => mql.matches));
2817
+ };
2818
+ handler();
2819
+ mediaQueryLists.forEach((mql) => mql.addEventListener("change", handler));
2820
+ return () => mediaQueryLists.forEach(
2821
+ (mql) => mql.removeEventListener("change", handler)
2822
+ );
2823
+ }, [queries]);
2800
2824
  return value;
2801
2825
  }
2802
2826
  var MotionDiv5 = motionTags.div;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qstd",
3
- "version": "0.2.15",
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",