@geomak/ui 7.3.4 → 7.4.1

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.cjs CHANGED
@@ -4595,17 +4595,70 @@ function ScalableContainer({
4595
4595
  expandIcon,
4596
4596
  collapseIcon,
4597
4597
  togglePosition = "top-right",
4598
+ expandContainerRef,
4599
+ expandRatio = 5,
4598
4600
  className = ""
4599
4601
  }) {
4600
4602
  const containerRef = React30.useRef(null);
4601
4603
  const [internalScaled, setInternalScaled] = React30.useState(false);
4602
4604
  const isScaled = expanded ?? internalScaled;
4603
4605
  const reduced = framerMotion.useReducedMotion();
4606
+ const usePush = expandContainerRef != null;
4607
+ const grownRef = React30.useRef([]);
4608
+ const prevScaled = React30.useRef(isScaled);
4609
+ const growAncestors = () => {
4610
+ const bound = expandContainerRef?.current;
4611
+ if (!bound || !containerRef.current) return;
4612
+ const grown = [];
4613
+ let el = containerRef.current.parentElement;
4614
+ while (el && el !== bound && bound.contains(el)) {
4615
+ const parent = el.parentElement;
4616
+ if (parent && getComputedStyle(parent).display.includes("flex")) {
4617
+ grown.push({
4618
+ el,
4619
+ prev: {
4620
+ flexGrow: el.style.flexGrow,
4621
+ flexBasis: el.style.flexBasis,
4622
+ transition: el.style.transition
4623
+ }
4624
+ });
4625
+ const grow = `flex-grow ${reduced ? 0 : 0.32}s cubic-bezier(0.16, 1, 0.3, 1), flex-basis ${reduced ? 0 : 0.32}s cubic-bezier(0.16, 1, 0.3, 1)`;
4626
+ el.style.transition = el.style.transition ? `${el.style.transition}, ${grow}` : grow;
4627
+ el.style.flexBasis = "0%";
4628
+ el.style.flexGrow = String(expandRatio);
4629
+ }
4630
+ el = parent;
4631
+ }
4632
+ grownRef.current = grown;
4633
+ };
4634
+ const restoreAncestors = () => {
4635
+ for (const { el, prev } of grownRef.current) {
4636
+ el.style.flexGrow = prev.flexGrow;
4637
+ el.style.flexBasis = prev.flexBasis;
4638
+ window.setTimeout(() => {
4639
+ el.style.transition = prev.transition;
4640
+ }, reduced ? 0 : 360);
4641
+ }
4642
+ grownRef.current = [];
4643
+ };
4644
+ React30.useEffect(() => {
4645
+ if (!usePush || isScaled === prevScaled.current) return;
4646
+ prevScaled.current = isScaled;
4647
+ if (isScaled) growAncestors();
4648
+ else restoreAncestors();
4649
+ }, [isScaled, usePush]);
4650
+ React30.useEffect(() => () => {
4651
+ for (const { el, prev } of grownRef.current) {
4652
+ el.style.flexGrow = prev.flexGrow;
4653
+ el.style.flexBasis = prev.flexBasis;
4654
+ el.style.transition = prev.transition;
4655
+ }
4656
+ }, []);
4604
4657
  const onToggle = () => {
4605
4658
  const next = !isScaled;
4606
4659
  if (expanded === void 0) setInternalScaled(next);
4607
4660
  onExpandedChange?.(next);
4608
- if (next) {
4661
+ if (next && !usePush) {
4609
4662
  window.setTimeout(
4610
4663
  () => containerRef.current?.scrollIntoView({ behavior: "smooth", block: "nearest" }),
4611
4664
  reduced ? 0 : 340
@@ -4618,8 +4671,10 @@ function ScalableContainer({
4618
4671
  {
4619
4672
  ref: containerRef,
4620
4673
  animate: {
4621
- width: isScaled ? expandedWidth : width,
4622
- height: isScaled ? expandedHeight : height
4674
+ // Push mode keeps the container filling its (now growing)
4675
+ // wrapper the wrapper's flex-grow does the work.
4676
+ width: isScaled && !usePush ? expandedWidth : width,
4677
+ height: isScaled && !usePush ? expandedHeight : height
4623
4678
  },
4624
4679
  transition: reduced ? { duration: 0 } : {
4625
4680
  width: { type: "tween", duration: 0.32, ease: [0.16, 1, 0.3, 1] },
@@ -4653,7 +4708,7 @@ function ScalableContainer({
4653
4708
  children: isScaled ? collapseIcon ?? /* @__PURE__ */ jsxRuntime.jsx(CollapseIcon, {}) : expandIcon ?? /* @__PURE__ */ jsxRuntime.jsx(ExpandIcon, {})
4654
4709
  }
4655
4710
  ) }),
4656
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: wrapperClass, children })
4711
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: cx("h-full w-full", wrapperClass), children })
4657
4712
  ]
4658
4713
  }
4659
4714
  );