qstd 0.2.15 → 0.2.16

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;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"}
@@ -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;
@@ -2527,8 +2528,14 @@ function DrawerComponent(props) {
2527
2528
  }
2528
2529
  };
2529
2530
  React12__namespace.default.useEffect(() => {
2530
- if (props.open) openDrawer();
2531
- else closeFnRef.current?.();
2531
+ const wasOpen = prevOpenRef.current;
2532
+ const isOpen = props.open;
2533
+ if (isOpen) {
2534
+ openDrawer();
2535
+ } else if (wasOpen === true) {
2536
+ closeFnRef.current?.();
2537
+ }
2538
+ prevOpenRef.current = isOpen;
2532
2539
  }, [props.open]);
2533
2540
  React12__namespace.default.useEffect(() => {
2534
2541
  const container = ref.current;
@@ -2807,19 +2814,21 @@ function Backdrop(props) {
2807
2814
  );
2808
2815
  }
2809
2816
  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);
2817
+ defaultValues.length ? defaultValues : Array(queries.length).fill(false);
2818
+ const [value, setValue] = React12__namespace.default.useState(() => {
2819
+ return queries.map((q) => window.matchMedia(q).matches);
2820
+ });
2817
2821
  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;
2822
+ const mediaQueryLists = queries.map((q) => window.matchMedia(q));
2823
+ const handler = () => {
2824
+ setValue(mediaQueryLists.map((mql) => mql.matches));
2825
+ };
2826
+ handler();
2827
+ mediaQueryLists.forEach((mql) => mql.addEventListener("change", handler));
2828
+ return () => mediaQueryLists.forEach(
2829
+ (mql) => mql.removeEventListener("change", handler)
2830
+ );
2831
+ }, [queries]);
2823
2832
  return value;
2824
2833
  }
2825
2834
  var MotionDiv5 = motionTags.div;
@@ -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;
@@ -2504,8 +2505,14 @@ function DrawerComponent(props) {
2504
2505
  }
2505
2506
  };
2506
2507
  React12__default.useEffect(() => {
2507
- if (props.open) openDrawer();
2508
- else closeFnRef.current?.();
2508
+ const wasOpen = prevOpenRef.current;
2509
+ const isOpen = props.open;
2510
+ if (isOpen) {
2511
+ openDrawer();
2512
+ } else if (wasOpen === true) {
2513
+ closeFnRef.current?.();
2514
+ }
2515
+ prevOpenRef.current = isOpen;
2509
2516
  }, [props.open]);
2510
2517
  React12__default.useEffect(() => {
2511
2518
  const container = ref.current;
@@ -2784,19 +2791,21 @@ function Backdrop(props) {
2784
2791
  );
2785
2792
  }
2786
2793
  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);
2794
+ defaultValues.length ? defaultValues : Array(queries.length).fill(false);
2795
+ const [value, setValue] = React12__default.useState(() => {
2796
+ return queries.map((q) => window.matchMedia(q).matches);
2797
+ });
2794
2798
  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;
2799
+ const mediaQueryLists = queries.map((q) => window.matchMedia(q));
2800
+ const handler = () => {
2801
+ setValue(mediaQueryLists.map((mql) => mql.matches));
2802
+ };
2803
+ handler();
2804
+ mediaQueryLists.forEach((mql) => mql.addEventListener("change", handler));
2805
+ return () => mediaQueryLists.forEach(
2806
+ (mql) => mql.removeEventListener("change", handler)
2807
+ );
2808
+ }, [queries]);
2800
2809
  return value;
2801
2810
  }
2802
2811
  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.16",
4
4
  "description": "Standard Block component and utilities library with Panda CSS",
5
5
  "author": "malin1",
6
6
  "license": "MIT",