qstd 0.2.16 → 0.2.18

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 (127) hide show
  1. package/dist/block/drawer.d.ts.map +1 -1
  2. package/dist/block/test-types.d.ts.map +1 -1
  3. package/dist/react/index.cjs +40 -25
  4. package/dist/react/index.css +20 -10
  5. package/dist/react/index.js +40 -25
  6. package/package.json +22 -20
  7. package/styled-system/css/conditions.mjs +36 -0
  8. package/styled-system/css/css.d.ts +22 -0
  9. package/styled-system/css/css.mjs +45 -0
  10. package/styled-system/css/cva.d.ts +6 -0
  11. package/styled-system/css/cva.mjs +87 -0
  12. package/styled-system/css/cx.d.ts +5 -0
  13. package/styled-system/css/cx.mjs +15 -0
  14. package/styled-system/css/index.d.ts +5 -0
  15. package/styled-system/css/index.mjs +4 -0
  16. package/styled-system/css/sva.d.ts +4 -0
  17. package/styled-system/css/sva.mjs +46 -0
  18. package/styled-system/helpers.mjs +328 -0
  19. package/styled-system/jsx/aspect-ratio.d.ts +10 -0
  20. package/styled-system/jsx/aspect-ratio.mjs +14 -0
  21. package/styled-system/jsx/bleed.d.ts +10 -0
  22. package/styled-system/jsx/bleed.mjs +14 -0
  23. package/styled-system/jsx/box.d.ts +10 -0
  24. package/styled-system/jsx/box.mjs +14 -0
  25. package/styled-system/jsx/center.d.ts +10 -0
  26. package/styled-system/jsx/center.mjs +14 -0
  27. package/styled-system/jsx/circle.d.ts +10 -0
  28. package/styled-system/jsx/circle.mjs +14 -0
  29. package/styled-system/jsx/container.d.ts +10 -0
  30. package/styled-system/jsx/container.mjs +14 -0
  31. package/styled-system/jsx/cq.d.ts +10 -0
  32. package/styled-system/jsx/cq.mjs +14 -0
  33. package/styled-system/jsx/create-style-context.d.ts +54 -0
  34. package/styled-system/jsx/create-style-context.mjs +98 -0
  35. package/styled-system/jsx/divider.d.ts +10 -0
  36. package/styled-system/jsx/divider.mjs +14 -0
  37. package/styled-system/jsx/factory-helper.mjs +22 -0
  38. package/styled-system/jsx/factory.d.ts +3 -0
  39. package/styled-system/jsx/factory.mjs +89 -0
  40. package/styled-system/jsx/flex.d.ts +10 -0
  41. package/styled-system/jsx/flex.mjs +14 -0
  42. package/styled-system/jsx/float.d.ts +10 -0
  43. package/styled-system/jsx/float.mjs +14 -0
  44. package/styled-system/jsx/grid-item.d.ts +10 -0
  45. package/styled-system/jsx/grid-item.mjs +14 -0
  46. package/styled-system/jsx/grid.d.ts +10 -0
  47. package/styled-system/jsx/grid.mjs +14 -0
  48. package/styled-system/jsx/hstack.d.ts +10 -0
  49. package/styled-system/jsx/hstack.mjs +14 -0
  50. package/styled-system/jsx/index.d.ts +25 -0
  51. package/styled-system/jsx/index.mjs +23 -0
  52. package/styled-system/jsx/is-valid-prop.d.ts +11 -0
  53. package/styled-system/jsx/is-valid-prop.mjs +17 -0
  54. package/styled-system/jsx/link-overlay.d.ts +10 -0
  55. package/styled-system/jsx/link-overlay.mjs +14 -0
  56. package/styled-system/jsx/spacer.d.ts +10 -0
  57. package/styled-system/jsx/spacer.mjs +14 -0
  58. package/styled-system/jsx/square.d.ts +10 -0
  59. package/styled-system/jsx/square.mjs +14 -0
  60. package/styled-system/jsx/stack.d.ts +10 -0
  61. package/styled-system/jsx/stack.mjs +14 -0
  62. package/styled-system/jsx/visually-hidden.d.ts +10 -0
  63. package/styled-system/jsx/visually-hidden.mjs +14 -0
  64. package/styled-system/jsx/vstack.d.ts +10 -0
  65. package/styled-system/jsx/vstack.mjs +14 -0
  66. package/styled-system/jsx/wrap.d.ts +10 -0
  67. package/styled-system/jsx/wrap.mjs +14 -0
  68. package/styled-system/patterns/aspect-ratio.d.ts +20 -0
  69. package/styled-system/patterns/aspect-ratio.mjs +38 -0
  70. package/styled-system/patterns/bleed.d.ts +21 -0
  71. package/styled-system/patterns/bleed.mjs +24 -0
  72. package/styled-system/patterns/box.d.ts +20 -0
  73. package/styled-system/patterns/box.mjs +15 -0
  74. package/styled-system/patterns/center.d.ts +20 -0
  75. package/styled-system/patterns/center.mjs +21 -0
  76. package/styled-system/patterns/circle.d.ts +20 -0
  77. package/styled-system/patterns/circle.mjs +25 -0
  78. package/styled-system/patterns/container.d.ts +20 -0
  79. package/styled-system/patterns/container.mjs +21 -0
  80. package/styled-system/patterns/cq.d.ts +21 -0
  81. package/styled-system/patterns/cq.mjs +21 -0
  82. package/styled-system/patterns/divider.d.ts +22 -0
  83. package/styled-system/patterns/divider.mjs +25 -0
  84. package/styled-system/patterns/flex.d.ts +26 -0
  85. package/styled-system/patterns/flex.mjs +26 -0
  86. package/styled-system/patterns/float.d.ts +23 -0
  87. package/styled-system/patterns/float.mjs +52 -0
  88. package/styled-system/patterns/grid-item.d.ts +25 -0
  89. package/styled-system/patterns/grid-item.mjs +25 -0
  90. package/styled-system/patterns/grid.d.ts +24 -0
  91. package/styled-system/patterns/grid.mjs +27 -0
  92. package/styled-system/patterns/hstack.d.ts +21 -0
  93. package/styled-system/patterns/hstack.mjs +24 -0
  94. package/styled-system/patterns/index.d.ts +21 -0
  95. package/styled-system/patterns/index.mjs +20 -0
  96. package/styled-system/patterns/link-overlay.d.ts +20 -0
  97. package/styled-system/patterns/link-overlay.mjs +24 -0
  98. package/styled-system/patterns/spacer.d.ts +20 -0
  99. package/styled-system/patterns/spacer.mjs +21 -0
  100. package/styled-system/patterns/square.d.ts +20 -0
  101. package/styled-system/patterns/square.mjs +24 -0
  102. package/styled-system/patterns/stack.d.ts +23 -0
  103. package/styled-system/patterns/stack.mjs +24 -0
  104. package/styled-system/patterns/visually-hidden.d.ts +20 -0
  105. package/styled-system/patterns/visually-hidden.mjs +18 -0
  106. package/styled-system/patterns/vstack.d.ts +21 -0
  107. package/styled-system/patterns/vstack.mjs +24 -0
  108. package/styled-system/patterns/wrap.d.ts +24 -0
  109. package/styled-system/patterns/wrap.mjs +25 -0
  110. package/styled-system/styles.css +1749 -0
  111. package/styled-system/tokens/index.d.ts +9 -0
  112. package/styled-system/tokens/index.mjs +1976 -0
  113. package/styled-system/tokens/tokens.d.ts +60 -0
  114. package/styled-system/types/composition.d.ts +224 -0
  115. package/styled-system/types/conditions.d.ts +348 -0
  116. package/styled-system/types/csstype.d.ts +21298 -0
  117. package/styled-system/types/global.d.ts +20 -0
  118. package/styled-system/types/index.d.ts +8 -0
  119. package/styled-system/types/jsx.d.ts +67 -0
  120. package/styled-system/types/parts.d.ts +8 -0
  121. package/styled-system/types/pattern.d.ts +78 -0
  122. package/styled-system/types/prop-type.d.ts +277 -0
  123. package/styled-system/types/recipe.d.ts +181 -0
  124. package/styled-system/types/selectors.d.ts +59 -0
  125. package/styled-system/types/static-css.d.ts +56 -0
  126. package/styled-system/types/style-props.d.ts +7639 -0
  127. package/styled-system/types/system-types.d.ts +269 -0
@@ -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"}
@@ -1 +1 @@
1
- {"version":3,"file":"test-types.d.ts","sourceRoot":"","sources":["../../src/block/test-types.tsx"],"names":[],"mappings":"AAOA,QAAA,MAAM,eAAe,+CA2IpB,CAAC;AAGF,QAAA,MAAM,cAAc,YAMnB,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,CAAC"}
1
+ {"version":3,"file":"test-types.d.ts","sourceRoot":"","sources":["../../src/block/test-types.tsx"],"names":[],"mappings":"AAOA,QAAA,MAAM,eAAe,+CA2IpB,CAAC;AAeF,QAAA,MAAM,cAAc,YAMnB,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,CAAC"}
@@ -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
  });
@@ -838,6 +838,9 @@
838
838
  .bg_white {
839
839
  background: var(--colors-white);
840
840
  }
841
+ .bg_red\.500 {
842
+ background: var(--colors-red-500);
843
+ }
841
844
  .bg_rgba\(20\,20\,20\,0\.95\) {
842
845
  background: rgba(20, 20, 20, 0.95);
843
846
  }
@@ -871,6 +874,9 @@
871
874
  .rounded_12 {
872
875
  border-radius: 12px;
873
876
  }
877
+ .ov_hidden {
878
+ overflow: hidden;
879
+ }
874
880
  .rounded_20 {
875
881
  border-radius: 20px;
876
882
  }
@@ -886,9 +892,6 @@
886
892
  .rounded_50\% {
887
893
  border-radius: 50%;
888
894
  }
889
- .ov_hidden {
890
- overflow: hidden;
891
- }
892
895
  .trs_200ms_cubic-bezier\(0\,_0\,_0\.2\,_1\)_0ms\,_\.2s_color_ease-in-out\,_\.2s_background_ease-in-out {
893
896
  transition:
894
897
  200ms cubic-bezier(0, 0, 0.2, 1) 0ms,
@@ -943,6 +946,9 @@
943
946
  .trs_background-color_0\.2s_ease-in-out {
944
947
  transition: background-color 0.2s ease-in-out;
945
948
  }
949
+ .py_3 {
950
+ padding-block: var(--spacing-3);
951
+ }
946
952
  .px_10px {
947
953
  padding-inline: 10px;
948
954
  }
@@ -1030,12 +1036,16 @@
1030
1036
  .pos_absolute {
1031
1037
  position: absolute;
1032
1038
  }
1033
- .place-c_true {
1039
+ .center_true {
1034
1040
  place-content: center;
1041
+ place-items: center;
1035
1042
  }
1036
1043
  .fs_16 {
1037
1044
  font-size: 16px;
1038
1045
  }
1046
+ .lh_1 {
1047
+ line-height: 1;
1048
+ }
1039
1049
  .c_currentColor {
1040
1050
  color: currentColor;
1041
1051
  }
@@ -1268,12 +1278,6 @@
1268
1278
  .right_3 {
1269
1279
  right: var(--spacing-3);
1270
1280
  }
1271
- .h_16 {
1272
- height: 16px;
1273
- }
1274
- .w_16 {
1275
- width: 16px;
1276
- }
1277
1281
  .w_12px {
1278
1282
  width: 12px;
1279
1283
  }
@@ -1343,6 +1347,12 @@
1343
1347
  .h_fit-content {
1344
1348
  height: fit-content;
1345
1349
  }
1350
+ .mr_2 {
1351
+ margin-right: var(--spacing-2);
1352
+ }
1353
+ .h_true {
1354
+ height: 100%;
1355
+ }
1346
1356
  .top_1 {
1347
1357
  top: var(--spacing-1);
1348
1358
  }
@@ -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.18",
4
4
  "description": "Standard Block component and utilities library with Panda CSS",
5
5
  "author": "malin1",
6
6
  "license": "MIT",
@@ -34,6 +34,7 @@
34
34
  },
35
35
  "files": [
36
36
  "dist",
37
+ "styled-system",
37
38
  "panda.config.ts",
38
39
  "README.md",
39
40
  "CHANGELOG.md"
@@ -41,6 +42,24 @@
41
42
  "sideEffects": [
42
43
  "dist/react/index.css"
43
44
  ],
45
+ "scripts": {
46
+ "build": "panda codegen && panda cssgen && tsup && tsc -p tsconfig.build.json && node scripts/inject-css-import.js",
47
+ "build:js": "tsup",
48
+ "build:types": "tsc -p tsconfig.build.json",
49
+ "dev": "tsup --watch",
50
+ "prepublishOnly": "pnpm build",
51
+ "prepare:local": "pnpm build && cd playground && pnpm prepare",
52
+ "test": "vitest run",
53
+ "test:watch": "vitest",
54
+ "test:all": "pnpx tsx tests/test-all.ts",
55
+ "test:block": "node tests/test-block.tsx",
56
+ "test:playground": "node tests/playground-e2e.mjs",
57
+ "typecheck": "tsc --noEmit",
58
+ "typecheck:perf": "tsc --noEmit --extendedDiagnostics",
59
+ "typecheck:trace": "tsc --noEmit --generateTrace ./performance/ts-trace",
60
+ "analyze:tsserver": "bash performance/analyze-tsserver.sh",
61
+ "lint": "eslint ."
62
+ },
44
63
  "peerDependencies": {
45
64
  "react": "^18.0.0 || ^19.0.0",
46
65
  "react-dom": "^18.0.0 || ^19.0.0"
@@ -96,22 +115,5 @@
96
115
  "bugs": {
97
116
  "url": "https://github.com/55cancri/qstd/issues"
98
117
  },
99
- "homepage": "https://github.com/55cancri/qstd#readme",
100
- "scripts": {
101
- "build": "panda codegen && panda cssgen && tsup && tsc -p tsconfig.build.json && node scripts/inject-css-import.js",
102
- "build:js": "tsup",
103
- "build:types": "tsc -p tsconfig.build.json",
104
- "dev": "tsup --watch",
105
- "prepare:local": "pnpm build && cd playground && pnpm prepare",
106
- "test": "vitest run",
107
- "test:watch": "vitest",
108
- "test:all": "pnpx tsx tests/test-all.ts",
109
- "test:block": "node tests/test-block.tsx",
110
- "test:playground": "node tests/playground-e2e.mjs",
111
- "typecheck": "tsc --noEmit",
112
- "typecheck:perf": "tsc --noEmit --extendedDiagnostics",
113
- "typecheck:trace": "tsc --noEmit --generateTrace ./performance/ts-trace",
114
- "analyze:tsserver": "bash performance/analyze-tsserver.sh",
115
- "lint": "eslint ."
116
- }
117
- }
118
+ "homepage": "https://github.com/55cancri/qstd#readme"
119
+ }
@@ -0,0 +1,36 @@
1
+ import { withoutSpace } from '../helpers.mjs';
2
+
3
+ const conditionsStr = "_hover,_focus,_focusWithin,_focusVisible,_disabled,_active,_visited,_target,_readOnly,_readWrite,_empty,_checked,_enabled,_expanded,_highlighted,_complete,_incomplete,_dragging,_before,_after,_firstLetter,_firstLine,_marker,_selection,_file,_backdrop,_first,_last,_only,_even,_odd,_firstOfType,_lastOfType,_onlyOfType,_peerFocus,_peerHover,_peerActive,_peerFocusWithin,_peerFocusVisible,_peerDisabled,_peerChecked,_peerInvalid,_peerExpanded,_peerPlaceholderShown,_groupFocus,_groupHover,_groupActive,_groupFocusWithin,_groupFocusVisible,_groupDisabled,_groupChecked,_groupExpanded,_groupInvalid,_indeterminate,_required,_valid,_invalid,_autofill,_inRange,_outOfRange,_placeholder,_placeholderShown,_pressed,_selected,_grabbed,_underValue,_overValue,_atValue,_default,_optional,_open,_closed,_fullscreen,_loading,_hidden,_current,_currentPage,_currentStep,_today,_unavailable,_rangeStart,_rangeEnd,_now,_topmost,_motionReduce,_motionSafe,_print,_landscape,_portrait,_dark,_light,_osDark,_osLight,_highContrast,_lessContrast,_moreContrast,_ltr,_rtl,_scrollbar,_scrollbarThumb,_scrollbarTrack,_horizontal,_vertical,_icon,_starting,_noscript,_invertedColors,_activeMouse,_activeKeyboard,_checkbox,_radioLabel,_radioDisabled,_radioSelected,_radioCircleOuter,_radioCircleInner,_radioFocusRing,_path,_svg,xs,xsOnly,xsDown,sm,smOnly,smDown,md,mdOnly,mdDown,lg,lgOnly,lgDown,xl,xlOnly,xlDown,2xl,2xlOnly,2xlDown,xsToSm,xsToMd,xsToLg,xsToXl,xsTo2xl,smToMd,smToLg,smToXl,smTo2xl,mdToLg,mdToXl,mdTo2xl,lgToXl,lgTo2xl,xlTo2xl,@/xs,@/sm,@/md,@/lg,@/xl,@/2xl,@/3xl,@/4xl,@/5xl,@/6xl,@/7xl,@/8xl,base"
4
+ const conditions = new Set(conditionsStr.split(','))
5
+
6
+ const conditionRegex = /^@|&|&$/
7
+
8
+ export function isCondition(value){
9
+ return conditions.has(value) || conditionRegex.test(value)
10
+ }
11
+
12
+ const underscoreRegex = /^_/
13
+ const conditionsSelectorRegex = /&|@/
14
+
15
+ export function finalizeConditions(paths){
16
+ return paths.map((path) => {
17
+ if (conditions.has(path)){
18
+ return path.replace(underscoreRegex, '')
19
+ }
20
+
21
+ if (conditionsSelectorRegex.test(path)){
22
+ return `[${withoutSpace(path.trim())}]`
23
+ }
24
+
25
+ return path
26
+ })}
27
+
28
+ export function sortConditions(paths){
29
+ return paths.sort((a, b) => {
30
+ const aa = isCondition(a)
31
+ const bb = isCondition(b)
32
+ if (aa && !bb) return 1
33
+ if (!aa && bb) return -1
34
+ return 0
35
+ })
36
+ }
@@ -0,0 +1,22 @@
1
+ /* eslint-disable */
2
+ import type { SystemStyleObject } from '../types/index';
3
+
4
+ type Styles = SystemStyleObject | undefined | null | false
5
+
6
+ interface CssRawFunction {
7
+ (styles: Styles): SystemStyleObject
8
+ (styles: Styles[]): SystemStyleObject
9
+ (...styles: Array<Styles | Styles[]>): SystemStyleObject
10
+ (styles: Styles): SystemStyleObject
11
+ }
12
+
13
+ interface CssFunction {
14
+ (styles: Styles): string
15
+ (styles: Styles[]): string
16
+ (...styles: Array<Styles | Styles[]>): string
17
+ (styles: Styles): string
18
+
19
+ raw: CssRawFunction
20
+ }
21
+
22
+ export declare const css: CssFunction;
@@ -0,0 +1,45 @@
1
+ import { createCss, createMergeCss, hypenateProperty, withoutSpace } from '../helpers.mjs';
2
+ import { sortConditions, finalizeConditions } from './conditions.mjs';
3
+
4
+ const utilities = "aspectRatio:asp/ar,boxDecorationBreak:bx-db,zIndex:z,boxSizing:bx-s,objectPosition:obj-p,objectFit:obj-f,overscrollBehavior:ovs-b,overscrollBehaviorX:ovs-bx,overscrollBehaviorY:ovs-by,position:pos/1,top:top,left:left,inset:inset,insetInline:inset-x/insetX,insetBlock:inset-y/insetY,insetBlockEnd:inset-be,insetBlockStart:inset-bs,insetInlineEnd:inset-e/insetEnd/end,insetInlineStart:inset-s/insetStart/start,right:right,bottom:bottom,float:float,visibility:vis,display:d,hideFrom:hide,hideBelow:show,flexBasis:flex-b,flex:flex,flexDirection:flex-d/flexDir,flexGrow:flex-g,flexShrink:flex-sh,gridTemplateColumns:grid-tc,gridTemplateRows:grid-tr,gridColumn:grid-c,gridRow:grid-r,gridColumnStart:grid-cs/colStart,gridColumnEnd:grid-ce/colEnd,gridAutoFlow:grid-af,gridAutoColumns:grid-ac/autoCols,gridAutoRows:grid-ar,gap:gap,gridGap:grid-g,gridRowGap:grid-rg,gridColumnGap:grid-cg,rowGap:rg/rowG,columnGap:cg/colG,justifyContent:jc,alignContent:ac,alignItems:ai,alignSelf:as,padding:p/1,paddingLeft:pl/1,paddingRight:pr/1,paddingTop:pt/1,paddingBottom:pb/1,paddingBlock:py/1/paddingY,paddingBlockEnd:pbe,paddingBlockStart:pbs,paddingInline:px/paddingX/1,paddingInlineEnd:pe/1/paddingEnd,paddingInlineStart:ps/1/paddingStart,marginLeft:ml/1,marginRight:mr/1,marginTop:mt/1,marginBottom:mb/1,margin:m/1,marginBlock:my/1/marginY,marginBlockEnd:mbe,marginBlockStart:mbs,marginInline:mx/1/marginX,marginInlineEnd:me/1/marginEnd,marginInlineStart:ms/1/marginStart,spaceX:sx,spaceY:sy,outlineWidth:ring-w/ringWidth,outlineColor:ring-c/ringColor,outline:ring/1,outlineOffset:ring-o/ringOffset,focusRing:focus-ring,focusVisibleRing:focus-v-ring,focusRingColor:focus-ring-c,focusRingOffset:focus-ring-o,focusRingWidth:focus-ring-w,focusRingStyle:focus-ring-s,divideX:dvd-x,divideY:dvd-y,divideColor:dvd-c,divideStyle:dvd-s,width:w/1,inlineSize:w-is,minWidth:min-w/minW,minInlineSize:min-w-is,maxWidth:max-w/maxW,maxInlineSize:max-w-is,height:h/1,blockSize:h-bs,minHeight:min-h/minH,minBlockSize:min-h-bs,maxHeight:max-h/maxH,maxBlockSize:max-b,boxSize:size,color:c,fontFamily:ff,fontSize:fs,fontSizeAdjust:fs-a,fontPalette:fp,fontKerning:fk,fontFeatureSettings:ff-s,fontWeight:fw,fontSmoothing:fsmt,fontVariant:fv,fontVariantAlternates:fv-alt,fontVariantCaps:fv-caps,fontVariationSettings:fv-s,fontVariantNumeric:fv-num,letterSpacing:ls,lineHeight:lh,textAlign:ta,textDecoration:td,textDecorationColor:td-c,textEmphasisColor:te-c,textDecorationStyle:td-s,textDecorationThickness:td-t,textUnderlineOffset:tu-o,textTransform:tt,textIndent:ti,textShadow:tsh,textShadowColor:tsh-c/textShadowColor,textOverflow:tov,verticalAlign:va,wordBreak:wb,textWrap:tw,truncate:trunc,lineClamp:lc,listStyleType:li-t,listStylePosition:li-pos,listStyleImage:li-img,listStyle:li-s,backgroundPosition:bg-p/bgPosition,backgroundPositionX:bg-p-x/bgPositionX,backgroundPositionY:bg-p-y/bgPositionY,backgroundAttachment:bg-a/bgAttachment,backgroundClip:bg-cp/bgClip,background:bg/1,backgroundColor:bg-c/bgColor,backgroundOrigin:bg-o/bgOrigin,backgroundImage:bg-i/bgImage,backgroundRepeat:bg-r/bgRepeat,backgroundBlendMode:bg-bm/bgBlendMode,backgroundSize:bg-s/bgSize,backgroundGradient:bg-grad/bgGradient,backgroundLinear:bg-linear/bgLinear,backgroundRadial:bg-radial/bgRadial,backgroundConic:bg-conic/bgConic,textGradient:txt-grad,gradientFromPosition:grad-from-pos,gradientToPosition:grad-to-pos,gradientFrom:grad-from,gradientTo:grad-to,gradientVia:grad-via,gradientViaPosition:grad-via-pos,borderRadius:rounded/br,borderTopLeftRadius:bdr-tl/roundedTopLeft,borderTopRightRadius:bdr-tr/roundedTopRight,borderBottomRightRadius:bdr-br/roundedBottomRight,borderBottomLeftRadius:bdr-bl/roundedBottomLeft,borderTopRadius:bdr-t/roundedTop,borderRightRadius:bdr-r/roundedRight,borderBottomRadius:bdr-b/roundedBottom,borderLeftRadius:bdr-l/roundedLeft,borderStartStartRadius:bdr-ss/roundedStartStart,borderStartEndRadius:bdr-se/roundedStartEnd,borderStartRadius:bdr-s/roundedStart,borderEndStartRadius:bdr-es/roundedEndStart,borderEndEndRadius:bdr-ee/roundedEndEnd,borderEndRadius:bdr-e/roundedEnd,border:bd,borderWidth:bd-w,borderTopWidth:bd-t-w,borderLeftWidth:bd-l-w,borderRightWidth:bd-r-w,borderBottomWidth:bd-b-w,borderBlockStartWidth:bd-bs-w,borderBlockEndWidth:bd-be-w,borderColor:bd-c,borderInline:bd-x/borderX,borderInlineWidth:bd-x-w/borderXWidth,borderInlineColor:bd-x-c/borderXColor,borderBlock:bd-y/borderY,borderBlockWidth:bd-y-w/borderYWidth,borderBlockColor:bd-y-c/borderYColor,borderLeft:bd-l,borderLeftColor:bd-l-c,borderInlineStart:bd-s/borderStart,borderInlineStartWidth:bd-s-w/borderStartWidth,borderInlineStartColor:bd-s-c/borderStartColor,borderRight:bd-r,borderRightColor:bd-r-c,borderInlineEnd:bd-e/borderEnd,borderInlineEndWidth:bd-e-w/borderEndWidth,borderInlineEndColor:bd-e-c/borderEndColor,borderTop:bd-t,borderTopColor:bd-t-c,borderBottom:bd-b,borderBottomColor:bd-b-c,borderBlockEnd:bd-be,borderBlockEndColor:bd-be-c,borderBlockStart:bd-bs,borderBlockStartColor:bd-bs-c,opacity:op,boxShadow:bx-sh/shadow,boxShadowColor:bx-sh-c/shadowColor,mixBlendMode:mix-bm,filter:filter,brightness:brightness,contrast:contrast,grayscale:grayscale,hueRotate:hue-rotate,invert:invert,saturate:saturate,sepia:sepia,dropShadow:drop-shadow,blur:blur,backdropFilter:bkdp,backdropBlur:bkdp-blur,backdropBrightness:bkdp-brightness,backdropContrast:bkdp-contrast,backdropGrayscale:bkdp-grayscale,backdropHueRotate:bkdp-hue-rotate,backdropInvert:bkdp-invert,backdropOpacity:bkdp-opacity,backdropSaturate:bkdp-saturate,backdropSepia:bkdp-sepia,borderCollapse:bd-cl,borderSpacing:bd-sp,borderSpacingX:bd-sx,borderSpacingY:bd-sy,tableLayout:tbl,transitionTimingFunction:trs-tmf,transitionDelay:trs-dly,transitionDuration:trs-dur,transitionProperty:trs-prop,transition:trs,animation:anim,animationName:anim-n,animationTimingFunction:anim-tmf,animationDuration:anim-dur,animationDelay:anim-dly,animationPlayState:anim-ps,animationComposition:anim-comp,animationFillMode:anim-fm,animationDirection:anim-dir,animationIterationCount:anim-ic,animationRange:anim-r,animationState:anim-s,animationRangeStart:anim-rs,animationRangeEnd:anim-re,animationTimeline:anim-tl,transformOrigin:trf-o,transformBox:trf-b,transformStyle:trf-s,transform:trf,rotate:rotate,rotateX:rotate-x,rotateY:rotate-y,rotateZ:rotate-z,scale:scale,scaleX:scale-x,scaleY:scale-y,translate:translate,translateX:translate-x/x,translateY:translate-y/y,translateZ:translate-z/z,accentColor:ac-c,caretColor:ca-c,scrollBehavior:scr-bhv,scrollbar:scr-bar,scrollbarColor:scr-bar-c,scrollbarGutter:scr-bar-g,scrollbarWidth:scr-bar-w,scrollMargin:scr-m,scrollMarginLeft:scr-ml,scrollMarginRight:scr-mr,scrollMarginTop:scr-mt,scrollMarginBottom:scr-mb,scrollMarginBlock:scr-my/scrollMarginY,scrollMarginBlockEnd:scr-mbe,scrollMarginBlockStart:scr-mbt,scrollMarginInline:scr-mx/scrollMarginX,scrollMarginInlineEnd:scr-me,scrollMarginInlineStart:scr-ms,scrollPadding:scr-p,scrollPaddingBlock:scr-py/scrollPaddingY,scrollPaddingBlockStart:scr-pbs,scrollPaddingBlockEnd:scr-pbe,scrollPaddingInline:scr-px/scrollPaddingX,scrollPaddingInlineEnd:scr-pe,scrollPaddingInlineStart:scr-ps,scrollPaddingLeft:scr-pl,scrollPaddingRight:scr-pr,scrollPaddingTop:scr-pt,scrollPaddingBottom:scr-pb,scrollSnapAlign:scr-sa,scrollSnapStop:scrs-s,scrollSnapType:scrs-t,scrollSnapStrictness:scrs-strt,scrollSnapMargin:scrs-m,scrollSnapMarginTop:scrs-mt,scrollSnapMarginBottom:scrs-mb,scrollSnapMarginLeft:scrs-ml,scrollSnapMarginRight:scrs-mr,scrollSnapCoordinate:scrs-c,scrollSnapDestination:scrs-d,scrollSnapPointsX:scrs-px,scrollSnapPointsY:scrs-py,scrollSnapTypeX:scrs-tx,scrollSnapTypeY:scrs-ty,scrollTimeline:scrtl,scrollTimelineAxis:scrtl-a,scrollTimelineName:scrtl-n,touchAction:tch-a,userSelect:us,overflow:ov,overflowWrap:ov-wrap,overflowX:ov-x,overflowY:ov-y,overflowAnchor:ov-a,overflowBlock:ov-b,overflowInline:ov-i,overflowClipBox:ovcp-bx,overflowClipMargin:ovcp-m,overscrollBehaviorBlock:ovs-bb,overscrollBehaviorInline:ovs-bi,fill:fill,stroke:stk,strokeWidth:stk-w,strokeDasharray:stk-dsh,strokeDashoffset:stk-do,strokeLinecap:stk-lc,strokeLinejoin:stk-lj,strokeMiterlimit:stk-ml,strokeOpacity:stk-op,srOnly:sr,debug:debug,appearance:ap,backfaceVisibility:bfv,clipPath:cp-path,hyphens:hy,mask:msk,maskImage:msk-i,maskSize:msk-s,textSizeAdjust:txt-adj,container:cq,containerName:cq-n,containerType:cq-t,cursor:cursor,gridRowStart:rowStart/1,gridRowEnd:rowEnd/1,textStyle:textStyle"
5
+
6
+ const classNameByProp = new Map()
7
+ const shorthands = new Map()
8
+ utilities.split(',').forEach((utility) => {
9
+ const [prop, meta] = utility.split(':')
10
+ const [className, ...shorthandList] = meta.split('/')
11
+ classNameByProp.set(prop, className)
12
+ if (shorthandList.length) {
13
+ shorthandList.forEach((shorthand) => {
14
+ shorthands.set(shorthand === '1' ? className : shorthand, prop)
15
+ })
16
+ }
17
+ })
18
+
19
+ const resolveShorthand = (prop) => shorthands.get(prop) || prop
20
+
21
+ const context = {
22
+
23
+ conditions: {
24
+ shift: sortConditions,
25
+ finalize: finalizeConditions,
26
+ breakpoints: { keys: ["base","xs","sm","md","lg","xl","2xl"] }
27
+ },
28
+ utility: {
29
+
30
+ transform: (prop, value) => {
31
+ const key = resolveShorthand(prop)
32
+ const propKey = classNameByProp.get(key) || hypenateProperty(key)
33
+ return { className: `${propKey}_${withoutSpace(value)}` }
34
+ },
35
+ hasShorthand: true,
36
+ toHash: (path, hashFn) => hashFn(path.join(":")),
37
+ resolveShorthand: resolveShorthand,
38
+ }
39
+ }
40
+
41
+ const cssFn = createCss(context)
42
+ export const css = (...styles) => cssFn(mergeCss(...styles))
43
+ css.raw = (...styles) => mergeCss(...styles)
44
+
45
+ export const { mergeCss, assignCss } = createMergeCss(context)
@@ -0,0 +1,6 @@
1
+ /* eslint-disable */
2
+ import type { RecipeCreatorFn } from '../types/recipe';
3
+
4
+ export declare const cva: RecipeCreatorFn
5
+
6
+ export type { RecipeVariant, RecipeVariantProps } from '../types/recipe';
@@ -0,0 +1,87 @@
1
+ import { compact, mergeProps, memo, splitProps, uniq } from '../helpers.mjs';
2
+ import { css, mergeCss } from './css.mjs';
3
+
4
+ const defaults = (conf) => ({
5
+ base: {},
6
+ variants: {},
7
+ defaultVariants: {},
8
+ compoundVariants: [],
9
+ ...conf,
10
+ })
11
+
12
+ export function cva(config) {
13
+ const { base, variants, defaultVariants, compoundVariants } = defaults(config)
14
+ const getVariantProps = (variants) => ({ ...defaultVariants, ...compact(variants) })
15
+
16
+ function resolve(props = {}) {
17
+ const computedVariants = getVariantProps(props)
18
+ let variantCss = { ...base }
19
+ for (const [key, value] of Object.entries(computedVariants)) {
20
+ if (variants[key]?.[value]) {
21
+ variantCss = mergeCss(variantCss, variants[key][value])
22
+ }
23
+ }
24
+ const compoundVariantCss = getCompoundVariantCss(compoundVariants, computedVariants)
25
+ return mergeCss(variantCss, compoundVariantCss)
26
+ }
27
+
28
+ function merge(__cva) {
29
+ const override = defaults(__cva.config)
30
+ const variantKeys = uniq(__cva.variantKeys, Object.keys(variants))
31
+ return cva({
32
+ base: mergeCss(base, override.base),
33
+ variants: Object.fromEntries(
34
+ variantKeys.map((key) => [key, mergeCss(variants[key], override.variants[key])]),
35
+ ),
36
+ defaultVariants: mergeProps(defaultVariants, override.defaultVariants),
37
+ compoundVariants: [...compoundVariants, ...override.compoundVariants],
38
+ })
39
+ }
40
+
41
+ function cvaFn(props) {
42
+ return css(resolve(props))
43
+ }
44
+
45
+ const variantKeys = Object.keys(variants)
46
+
47
+ function splitVariantProps(props) {
48
+ return splitProps(props, variantKeys)
49
+ }
50
+
51
+ const variantMap = Object.fromEntries(Object.entries(variants).map(([key, value]) => [key, Object.keys(value)]))
52
+
53
+ return Object.assign(memo(cvaFn), {
54
+ __cva__: true,
55
+ variantMap,
56
+ variantKeys,
57
+ raw: resolve,
58
+ config,
59
+ merge,
60
+ splitVariantProps,
61
+ getVariantProps
62
+ })
63
+ }
64
+
65
+ export function getCompoundVariantCss(compoundVariants, variantMap) {
66
+ let result = {}
67
+ compoundVariants.forEach((compoundVariant) => {
68
+ const isMatching = Object.entries(compoundVariant).every(([key, value]) => {
69
+ if (key === 'css') return true
70
+
71
+ const values = Array.isArray(value) ? value : [value]
72
+ return values.some((value) => variantMap[key] === value)
73
+ })
74
+
75
+ if (isMatching) {
76
+ result = mergeCss(result, compoundVariant.css)
77
+ }
78
+ })
79
+
80
+ return result
81
+ }
82
+
83
+ export function assertCompoundVariant(name, compoundVariants, variants, prop) {
84
+ if (compoundVariants.length > 0 && typeof variants?.[prop] === 'object') {
85
+ throw new Error(`[recipe:${name}:${prop}] Conditions are not supported when using compound variants.`)
86
+ }
87
+ }
@@ -0,0 +1,5 @@
1
+ /* eslint-disable */
2
+ type Argument = string | boolean | null | undefined
3
+
4
+ /** Conditionally join classNames into a single string */
5
+ export declare function cx(...args: Argument[]): string