@apliteni/apliteni-ui 0.124.0 → 0.124.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apliteni/apliteni-ui",
3
- "version": "0.124.0",
3
+ "version": "0.124.1",
4
4
  "workspaces": [
5
5
  "react"
6
6
  ],
@@ -637,7 +637,10 @@ function ddSizeHeight(dd, panel) {
637
637
  /** Fit a panel again where it now is, whichever placement it uses. */
638
638
  function ddPlace(dd) {
639
639
  const panel = dd.__ddPanel || ddPanelOf(dd);
640
- if (dd.__ddPanel) positionPortalPanel(dd, dd.__ddPanel);
640
+ if (dd.__ddPanel) {
641
+ ddResolveDirection(dd, panel);
642
+ positionPortalPanel(dd, panel);
643
+ }
641
644
  else ddFitViewport(dd, ddPanelOf(dd));
642
645
  ddSizeHeight(dd, panel);
643
646
  }
@@ -700,16 +703,36 @@ function ddCancelClose(dd, panel) {
700
703
  else panel?.classList?.remove('is-closing');
701
704
  }
702
705
 
703
- // `auto` is the only direction the wiring decides; `up` and the default are the
704
- // panel's own class, set once at render. Flip only when below is too tight AND
705
- // above is roomier, so a panel that fits nowhere still opens the way it says.
706
+ // Keep the configured side separate from the side resolved for this opening.
706
707
  function ddResolveDirection(dd, panel) {
707
- if (dd.getAttribute('data-dropdown-direction') !== 'auto') return;
708
+ const auto = dd.getAttribute('data-dropdown-direction') === 'auto';
709
+ if (!auto && !dd.__ddPanel) return;
708
710
  const trigger = dd.querySelector('[data-dropdown-trigger]');
709
711
  if (!trigger || typeof trigger.getBoundingClientRect !== 'function') return;
710
712
  const t = trigger.getBoundingClientRect();
711
713
  const below = ddViewOf(panel).innerHeight - t.bottom;
712
- panel.classList.toggle('is-up', below < panel.offsetHeight + ddGap(panel) && t.top > below);
714
+ if (auto) {
715
+ ddSetUp(panel, below < panel.offsetHeight + ddGap(panel) && t.top > below);
716
+ return;
717
+ }
718
+ const up = dd.__ddPreferredUp;
719
+ const room = (up ? t.top : below) - ddGap(panel);
720
+ const opposite = (up ? below : t.top) - ddGap(panel);
721
+ // Short content or a smaller consumer cap needs less than the usual floor.
722
+ const needed = Math.min(ddMin(panel), panel.offsetHeight);
723
+ ddSetUp(panel, room < needed && opposite > room ? !up : up);
724
+ }
725
+
726
+ /* Change the side without a transition: the shut panel's transform would otherwise
727
+ * be running when `is-open` arrives, and the open would retarget it from the wrong
728
+ * side. */
729
+ function ddSetUp(panel, up) {
730
+ if (panel.classList.contains('is-up') === up) return;
731
+ const held = panel.style.transition;
732
+ panel.style.transition = 'none';
733
+ panel.classList.toggle('is-up', up);
734
+ ddViewOf(panel).getComputedStyle(panel).transform;
735
+ panel.style.transition = held;
713
736
  }
714
737
 
715
738
  /** The shift a panel is already carrying, the one ddFitViewport() wrote. Taken
@@ -1057,6 +1080,7 @@ export function wireDropdown(root = document) {
1057
1080
  sweepOrphanPanels(host);
1058
1081
  panel.setAttribute('data-dropdown-portal', '');
1059
1082
  panel.__ddOwner = dd;
1083
+ dd.__ddPreferredUp = panel.classList.contains('is-up');
1060
1084
  dd.__ddPanel = panel;
1061
1085
  host.appendChild(panel);
1062
1086
  if (dd.classList.contains('open')) {
@@ -209,7 +209,7 @@
209
209
  src/styles/dropdown.css:271 `.ui-dropdown__item:hover`.
210
210
  why: docs/foundations.md#elevation */
211
211
  .vopt:hover { outline: 1px solid var(--control-edge); outline-offset: -1px; background: var(--surface); /* code-bg: inherit — control paint; the containing surface is the ground, for a chip and for a band alike. */ }
212
- /* The row is a keyboard stop: src/components/dropdown.js:1141
212
+ /* The row is a keyboard stop: src/components/dropdown.js:1165
213
213
  `items[next < 0 ? 0 : next]?.focus()` moves focus onto a `[data-dd-item]` with
214
214
  the arrow keys, and this is one. It takes the ring on its own 10px radius, the
215
215
  same way `.amenu a` above does. #482 */