@eldrajs/ui 0.3.4 → 0.3.6

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.js CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as parseLocaleNumber, A as focusInvalid, At as joinIds, B as FIELD_CLEAR_BUTTON_BOX, C as topLayerDialog, Ct as FORM_LAYOUT_KEY, D as normalizeText, Dt as ELDRA_SCOPE_KEY, E as matchRange, Et as useControllableModel, F as defaultCharacterMeaning, G as createNumberFormat, H as FIELD_LIVE, I as stripMask, J as defaultUnitFormat, K as currencyFractionDigits, L as CurrencyInput_default, M as filterNumericBeforeInput, N as Input_default, O as useListbox, Ot as provideEldraScope, P as applyMask, Q as localeSeparators, R as UnitInput_default, S as useOverlay, St as ICON_STROKE_WIDTH$4, T as useFloating, Tt as mergeClass, U as FIELD_SEARCH_APPEARANCE, V as FIELD_DISABLED, W as FIELD_SIZE, X as formatNumber, Y as formatCurrency, Z as formatUnit, _ as optionCursor, _t as FIELD_KEY, a as claimShortcut, at as provideEldraUiCurrency, b as MultiSelect_default, bt as Icon_default, c as SearchResultsPanel_default, ct as useEldraUiLocale, d as INPUT, dt as tagPadding, et as useSlotPresence, f as PLAIN_BOX_ONLY, ft as CheckboxGroup_default, g as labelRecipe, gt as FieldError_default, h as dotRecipe, ht as RequiredMark_default, i as SearchBar_default, it as LOCALE_KEY, j as Switch_default, jt as useUiId, k as FormLayout_default, kt as useEldraScope, l as RadioGroup_default, lt as TAG_FILL, m as PLAIN_OPTION, mt as VisuallyHidden_default, n as Textarea_default, nt as CURRENCY_KEY, o as ownsShortcut, ot as provideEldraUiLocale, p as PLAIN_COLUMNS, pt as Checkbox_default, q as currencySymbol, r as Select_default, rt as DEFAULT_UI_LOCALE, s as releaseShortcut, st as useEldraUiCurrency, t as VariantPicker_default, tt as useHeadingTag, u as HINT, ut as TAG_SHAPE, v as radioRecipe, vt as Button_default, w as useTeleportTarget, wt as FORM_SUBMITTING_KEY, x as usePopover, xt as ICON_SIZE_CLASS, y as QuantityStepper_default, yt as Spinner_default, z as FIELD_BASE } from "./VariantPicker-BjM-PmXb.js";
1
+ import { $ as parseLocaleNumber, A as focusInvalid, At as joinIds, B as FIELD_CLEAR_BUTTON_BOX, C as topLayerDialog, Ct as FORM_LAYOUT_KEY, D as normalizeText, Dt as ELDRA_SCOPE_KEY, E as matchRange, Et as useControllableModel, F as defaultCharacterMeaning, G as createNumberFormat, H as FIELD_LIVE, I as stripMask, J as defaultUnitFormat, K as currencyFractionDigits, L as CurrencyInput_default, M as filterNumericBeforeInput, N as Input_default, O as useListbox, Ot as provideEldraScope, P as applyMask, Q as localeSeparators, R as UnitInput_default, S as useOverlay, St as ICON_STROKE_WIDTH$4, T as useFloating, Tt as mergeClass, U as FIELD_SEARCH_APPEARANCE, V as FIELD_DISABLED, W as FIELD_SIZE, X as formatNumber, Y as formatCurrency, Z as formatUnit, _ as optionCursor, _t as FIELD_KEY, a as claimShortcut, at as provideEldraUiCurrency, b as MultiSelect_default, bt as Icon_default, c as SearchResultsPanel_default, ct as useEldraUiLocale, d as INPUT, dt as tagPadding, et as useSlotPresence, f as PLAIN_BOX_ONLY, ft as CheckboxGroup_default, g as labelRecipe, gt as FieldError_default, h as dotRecipe, ht as RequiredMark_default, i as SearchBar_default, it as LOCALE_KEY, j as Switch_default, jt as useUiId, k as FormLayout_default, kt as useEldraScope, l as RadioGroup_default, lt as TAG_FILL, m as PLAIN_OPTION, mt as VisuallyHidden_default, n as Textarea_default, nt as CURRENCY_KEY, o as ownsShortcut, ot as provideEldraUiLocale, p as PLAIN_COLUMNS, pt as Checkbox_default, q as currencySymbol, r as Select_default, rt as DEFAULT_UI_LOCALE, s as releaseShortcut, st as useEldraUiCurrency, t as VariantPicker_default, tt as useHeadingTag, u as HINT, ut as TAG_SHAPE, v as radioRecipe, vt as Button_default, w as useTeleportTarget, wt as FORM_SUBMITTING_KEY, x as usePopover, xt as ICON_SIZE_CLASS, y as QuantityStepper_default, yt as Spinner_default, z as FIELD_BASE } from "./VariantPicker-BB-2Cj32.js";
2
2
  import { i as enUS, n as provideEldraUiMessages, r as useMessages, t as MESSAGES_KEY } from "./useMessages-B5nzZghs.js";
3
3
  import { Comment, Fragment, Teleport, Text, Transition, cloneVNode, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createTextVNode, createVNode, defineComponent, guardReactiveProps, h, inject, isRef, mergeProps, nextTick, normalizeClass, normalizeProps, normalizeStyle, onBeforeUnmount, onMounted, onServerPrefetch, onUnmounted, onUpdated, openBlock, provide, reactive, ref, renderList, renderSlot, resolveDynamicComponent, shallowRef, toDisplayString, toRef, toValue, unref, useAttrs, useId, useSlots, useTemplateRef, vModelText, vShow, watch, withCtx, withDirectives, withKeys, withModifiers } from "vue";
4
4
  import { dateTimeFormat } from "@eldrajs/sdk/format/date";
@@ -4584,17 +4584,249 @@ var Dialog_default = /* @__PURE__ */ defineComponent({
4584
4584
  };
4585
4585
  }
4586
4586
  });
4587
+ // src/components/drawer/useDrawerDrag.ts
4588
+ /**
4589
+ * Drag-to-dismiss for `Drawer`: a side drawer swiped toward its own edge, and a `mobileSheet`
4590
+ * drawer pulled down below the 48rem viewport edge. The panel follows the pointer one to one, the
4591
+ * backdrop fades with the distance (`--eldra-drawer-drag`, read by `eldra-drawer-motion`), and on
4592
+ * release the drawer closes past a third of its size or on a quick flick, else springs back.
4593
+ *
4594
+ * Nothing moves until the pointer has travelled the dead zone along the closing direction and
4595
+ * more along it than across it: 24px for a side swipe (`--eldra-drawer-swipe-threshold`), so a
4596
+ * stray mouse movement or a scroll never drags the drawer, and 4px on a sheet's handle and header,
4597
+ * which exist to be grabbed. The panel then starts from 0, not from the dead zone.
4598
+ *
4599
+ * Where a drag may start: never on a control (a button, link, field, or anything editable) or
4600
+ * inside something that scrolls sideways. A mouse or pen drags a side drawer by its header only,
4601
+ * so selecting text in the body still works; a finger may swipe it from anywhere. A sheet is
4602
+ * dragged by its handle and header, and by its body when the body is scrolled to the top and the
4603
+ * finger moves down, the way a native sheet hands a scroll over to the sheet.
4604
+ */
4605
+ var INTERACTIVE = "button, a[href], input, textarea, select, label, summary, [contenteditable]:not([contenteditable=\"false\"]), [role=\"slider\"], [role=\"button\"], [role=\"link\"], [role=\"tab\"], [role=\"option\"]";
4606
+ /** A third of the panel, or a flick at least this fast toward the edge, closes the drawer. */
4607
+ var DISMISS_FRACTION = .35;
4608
+ var FLICK_SPEED = .45;
4609
+ var SHEET_THRESHOLD = 4;
4610
+ var SIDE_THRESHOLD = 24;
4611
+ function isSheetViewport() {
4612
+ return typeof window !== "undefined" && window.matchMedia("(width < 48rem)").matches;
4613
+ }
4614
+ function scrollsSideways(target, stop) {
4615
+ for (let el = target; el && el !== stop; el = el.parentElement) {
4616
+ const style = getComputedStyle(el);
4617
+ if (/(auto|scroll)/.test(style.overflowX) && el.scrollWidth > el.clientWidth) return true;
4618
+ }
4619
+ return false;
4620
+ }
4621
+ function useDrawerDrag(options) {
4622
+ let gesture = null;
4623
+ let pointerId = null;
4624
+ let suppressClick = false;
4625
+ function thresholdFor(axis) {
4626
+ if (axis === "y") return SHEET_THRESHOLD;
4627
+ const raw = options.dialog.value ? getComputedStyle(options.dialog.value).getPropertyValue("--eldra-drawer-swipe-threshold") : "";
4628
+ const value = parseFloat(raw);
4629
+ return Number.isFinite(value) ? value : SIDE_THRESHOLD;
4630
+ }
4631
+ function begin(x, y, axis) {
4632
+ const panel = options.panel.value;
4633
+ if (!panel) return;
4634
+ const rect = panel.getBoundingClientRect();
4635
+ gesture = {
4636
+ axis,
4637
+ dir: axis === "y" || options.side() === "right" ? 1 : -1,
4638
+ threshold: thresholdFor(axis),
4639
+ startX: x,
4640
+ startY: y,
4641
+ origin: 0,
4642
+ engaged: false,
4643
+ size: axis === "x" ? rect.width : rect.height,
4644
+ position: 0,
4645
+ samples: []
4646
+ };
4647
+ }
4648
+ /** Feeds a pointer position; returns whether the drag is engaged (the panel is following). */
4649
+ function track(x, y) {
4650
+ const g = gesture;
4651
+ if (!g) return false;
4652
+ const along = (g.axis === "x" ? x - g.startX : y - g.startY) * g.dir;
4653
+ const across = Math.abs(g.axis === "x" ? y - g.startY : x - g.startX);
4654
+ if (!g.engaged) {
4655
+ if (Math.abs(along) < g.threshold && across < g.threshold) return false;
4656
+ if (along < g.threshold || across > along) {
4657
+ gesture = null;
4658
+ return false;
4659
+ }
4660
+ g.engaged = true;
4661
+ g.origin = along;
4662
+ options.dialog.value?.setAttribute("data-dragging", "");
4663
+ window.getSelection?.()?.removeAllRanges();
4664
+ }
4665
+ g.position = Math.max(along - g.origin, 0);
4666
+ const now = performance.now();
4667
+ g.samples.push({
4668
+ t: now,
4669
+ p: g.position
4670
+ });
4671
+ while (g.samples.length > 2 && now - g.samples[0].t > 100) g.samples.shift();
4672
+ paint(g);
4673
+ return true;
4674
+ }
4675
+ function paint(g) {
4676
+ const panel = options.panel.value;
4677
+ const dialog = options.dialog.value;
4678
+ if (!panel || !dialog) return;
4679
+ const offset = g.position * g.dir;
4680
+ panel.style.translate = g.axis === "x" ? `${offset}px 0` : `0 ${offset}px`;
4681
+ const progress = Math.min(Math.max(g.position / g.size, 0), 1);
4682
+ dialog.style.setProperty("--eldra-drawer-drag", progress.toFixed(4));
4683
+ }
4684
+ function release() {
4685
+ const g = gesture;
4686
+ gesture = null;
4687
+ if (!g?.engaged) return;
4688
+ suppressClick = true;
4689
+ setTimeout(() => suppressClick = false, 0);
4690
+ const first = g.samples[0];
4691
+ const last = g.samples[g.samples.length - 1];
4692
+ const velocity = !(last ? performance.now() - last.t > 80 : true) && first && last && last.t > first.t ? (last.p - first.p) / (last.t - first.t) : 0;
4693
+ const dismissed = g.position > g.size * DISMISS_FRACTION || velocity > FLICK_SPEED && g.position > 8;
4694
+ const dialog = options.dialog.value;
4695
+ const panel = options.panel.value;
4696
+ if (dialog && dismissed) {
4697
+ const remaining = Math.max(g.size - g.position, 0);
4698
+ const duration = Math.round(Math.min(Math.max(remaining / Math.max(velocity, 1.2), 140), 320));
4699
+ dialog.style.setProperty("--eldra-drawer-exit-duration", `${duration}ms`);
4700
+ dialog.style.setProperty("--eldra-drawer-from-opacity", "1");
4701
+ if (g.axis === "x") {
4702
+ dialog.style.setProperty("--eldra-drawer-axis-x", "0");
4703
+ dialog.style.setProperty("--eldra-drawer-away-x", String(g.dir));
4704
+ }
4705
+ }
4706
+ dialog?.removeAttribute("data-dragging");
4707
+ dialog?.style.removeProperty("--eldra-drawer-drag");
4708
+ if (panel) panel.style.translate = "";
4709
+ if (dismissed) options.dismiss();
4710
+ }
4711
+ /** Clears what a swipe-dismiss left on the root, so the next opening enters the usual way. */
4712
+ function reset() {
4713
+ const dialog = options.dialog.value;
4714
+ if (!dialog) return;
4715
+ for (const name of [
4716
+ "--eldra-drawer-exit-duration",
4717
+ "--eldra-drawer-from-opacity",
4718
+ "--eldra-drawer-axis-x",
4719
+ "--eldra-drawer-away-x",
4720
+ "--eldra-drawer-drag"
4721
+ ]) dialog.style.removeProperty(name);
4722
+ dialog.removeAttribute("data-dragging");
4723
+ if (options.panel.value) options.panel.value.style.translate = "";
4724
+ }
4725
+ function onPointerDown(event) {
4726
+ if (!options.enabled() || gesture || event.button !== 0 || !event.isPrimary) return;
4727
+ const panel = options.panel.value;
4728
+ const target = event.target;
4729
+ if (!panel || !target || target.closest(INTERACTIVE)) return;
4730
+ const sheet = options.sheet() && isSheetViewport();
4731
+ const grip = target.closest("[data-part=\"handle\"], [data-part=\"header\"]");
4732
+ if (sheet) {
4733
+ if (!grip) return;
4734
+ } else {
4735
+ if (event.pointerType !== "touch" && !grip) return;
4736
+ if (scrollsSideways(target, panel)) return;
4737
+ }
4738
+ begin(event.clientX, event.clientY, sheet ? "y" : "x");
4739
+ pointerId = event.pointerId;
4740
+ window.addEventListener("pointermove", onPointerMove);
4741
+ window.addEventListener("pointerup", onPointerEnd);
4742
+ window.addEventListener("pointercancel", onPointerCancel);
4743
+ }
4744
+ function onPointerMove(event) {
4745
+ if (event.pointerId !== pointerId) return;
4746
+ if (track(event.clientX, event.clientY)) event.preventDefault();
4747
+ }
4748
+ function stopPointer() {
4749
+ pointerId = null;
4750
+ window.removeEventListener("pointermove", onPointerMove);
4751
+ window.removeEventListener("pointerup", onPointerEnd);
4752
+ window.removeEventListener("pointercancel", onPointerCancel);
4753
+ }
4754
+ function onPointerEnd(event) {
4755
+ if (event.pointerId !== pointerId) return;
4756
+ stopPointer();
4757
+ release();
4758
+ }
4759
+ /** The browser took the gesture over (a scroll): put the panel back. */
4760
+ function onPointerCancel(event) {
4761
+ if (event.pointerId !== pointerId) return;
4762
+ stopPointer();
4763
+ if (gesture?.engaged) gesture.position = 0;
4764
+ release();
4765
+ }
4766
+ /** A drag that ended over the panel must not also click what it ended on. */
4767
+ function onClickCapture(event) {
4768
+ if (!suppressClick) return;
4769
+ suppressClick = false;
4770
+ event.preventDefault();
4771
+ event.stopPropagation();
4772
+ }
4773
+ let touchId = null;
4774
+ function onTouchStart(event) {
4775
+ const body = options.body.value;
4776
+ if (!options.enabled() || !options.sheet() || !isSheetViewport() || gesture || !body) return;
4777
+ const touch = event.changedTouches[0];
4778
+ const target = event.target;
4779
+ if (!touch || event.touches.length > 1 || !target || target.closest(INTERACTIVE)) return;
4780
+ if (body.scrollTop > 0) return;
4781
+ touchId = touch.identifier;
4782
+ begin(touch.clientX, touch.clientY, "y");
4783
+ }
4784
+ function onTouchMove(event) {
4785
+ if (touchId === null) return;
4786
+ const touch = [...event.changedTouches].find((t) => t.identifier === touchId);
4787
+ if (!touch) return;
4788
+ if ((options.body.value?.scrollTop ?? 0) > 0 && !gesture?.engaged) {
4789
+ touchId = null;
4790
+ gesture = null;
4791
+ return;
4792
+ }
4793
+ if (track(touch.clientX, touch.clientY)) event.preventDefault();
4794
+ else if (!gesture) touchId = null;
4795
+ }
4796
+ function onTouchEnd(event) {
4797
+ if (touchId === null) return;
4798
+ if (![...event.changedTouches].some((t) => t.identifier === touchId)) return;
4799
+ touchId = null;
4800
+ release();
4801
+ }
4802
+ onMounted(() => options.dialog.value?.addEventListener("click", onClickCapture, true));
4803
+ onBeforeUnmount(() => {
4804
+ options.dialog.value?.removeEventListener("click", onClickCapture, true);
4805
+ stopPointer();
4806
+ });
4807
+ return {
4808
+ onPointerDown,
4809
+ onTouchStart,
4810
+ onTouchMove,
4811
+ onTouchEnd,
4812
+ reset
4813
+ };
4814
+ }
4587
4815
  // src/components/drawer/Drawer.vue?vue&type=script&setup=true&lang.ts
4588
4816
  var _hoisted_1$37 = [
4589
4817
  "data-eldra-scope",
4590
4818
  "aria-labelledby",
4591
- "aria-label"
4819
+ "aria-label",
4820
+ "data-side"
4592
4821
  ];
4593
4822
  var _hoisted_2$30 = ["data-eldra-slot"];
4594
4823
  var _hoisted_3$22 = ["data-eldra-scope", "id"];
4595
4824
  var _hoisted_4$14 = ["aria-label"];
4596
4825
  var _hoisted_5$10 = ["data-eldra-slot"];
4597
4826
  var _hoisted_6$6 = ["data-eldra-slot"];
4827
+ var handleBarClass = "eldra:block eldra:h-1 eldra:w-9 eldra:rounded-full eldra:bg-[var(--eldra-drawer-handle-color,var(--eldra-color-border-strong))]";
4828
+ /** `--eldra-drawer-width` from the `width` prop, left unset so the utility's own literal default
4829
+ * (28rem) applies when the prop is omitted. */
4598
4830
  var titleAreaClass = "eldra:min-w-0 eldra:flex-1";
4599
4831
  // src/components/drawer/Drawer.vue
4600
4832
  var Drawer_default = /* @__PURE__ */ defineComponent({
@@ -4609,6 +4841,14 @@ var Drawer_default = /* @__PURE__ */ defineComponent({
4609
4841
  ariaLabel: { default: void 0 },
4610
4842
  count: { default: void 0 },
4611
4843
  width: { default: void 0 },
4844
+ mobileSheet: {
4845
+ type: Boolean,
4846
+ default: false
4847
+ },
4848
+ swipe: {
4849
+ type: Boolean,
4850
+ default: true
4851
+ },
4612
4852
  messages: { default: void 0 },
4613
4853
  classes: { default: void 0 }
4614
4854
  },
@@ -4643,6 +4883,8 @@ var Drawer_default = /* @__PURE__ */ defineComponent({
4643
4883
  * every stateful component in this package uses. */
4644
4884
  const model = useControllableModel(props, emit, () => false);
4645
4885
  const dialogEl = ref(null);
4886
+ const panelEl = ref(null);
4887
+ const bodyEl = ref(null);
4646
4888
  const closeButtonEl = ref(null);
4647
4889
  const titleId = useUiId("drawer-title");
4648
4890
  const { close, isTop } = useDialog({
@@ -4660,6 +4902,18 @@ var Drawer_default = /* @__PURE__ */ defineComponent({
4660
4902
  }),
4661
4903
  onCancel: () => emit("cancel")
4662
4904
  });
4905
+ const drag = useDrawerDrag({
4906
+ dialog: dialogEl,
4907
+ panel: panelEl,
4908
+ body: bodyEl,
4909
+ side: () => props.side,
4910
+ sheet: () => props.mobileSheet,
4911
+ enabled: () => props.swipe,
4912
+ dismiss: () => close("swipe")
4913
+ });
4914
+ watch(model, (open) => {
4915
+ if (open) drag.reset();
4916
+ });
4663
4917
  /** The one place the public `close` event is emitted, for every closing route at once — see
4664
4918
  * `Dialog.vue`'s own comment on this exact pattern, including the `"programmatic"` reason a plain
4665
4919
  * external close (a parent setting `modelValue` to `false` directly) now reads. */
@@ -4691,10 +4945,11 @@ var Drawer_default = /* @__PURE__ */ defineComponent({
4691
4945
  * child panel to `side` — `justify-end`/`justify-start`, not a per-side inset, so the same panel
4692
4946
  * markup works for both without swapping which physical side it reads its position from.
4693
4947
  *
4694
- * The slide-in animation lives here, not on the panel (see `tailwind.css`'s own comment on
4695
- * `eldra-drawer-in-right`/`-left` for why): translating this full-viewport-width transparent box
4696
- * moves its panel child fully off-screen and back regardless of the panel's own width, while the
4697
- * `::backdrop` — a sibling box, not a descendant — is untouched and simply stays in place.
4948
+ * The motion is `eldra-drawer-motion` (see its comment in `utilities.css`): the panel slides a
4949
+ * short way in from its edge and fades, the backdrop fades, and closing plays the same in reverse.
4950
+ * It moves the panel, never this root, so a fixed descendant keeps the viewport as its containing
4951
+ * block. With `mobileSheet`, below 48rem the root becomes a column that sets the panel on the
4952
+ * bottom edge and `eldra-drawer-sheet` turns the slide into a rise from below.
4698
4953
  *
4699
4954
  * `hidden open:flex`, not a bare `flex` (fix, from the operator's own finding — see `Dialog`'s
4700
4955
  * own rootClass comment for the full mechanism): a bare `flex` here is exactly what left a closed
@@ -4705,8 +4960,8 @@ var Drawer_default = /* @__PURE__ */ defineComponent({
4705
4960
  const rootClass = computed(() => [
4706
4961
  "eldra:fixed eldra:inset-0 eldra:m-0 eldra:hidden eldra:open:flex eldra:h-auto eldra:max-h-none eldra:w-full eldra:max-w-none eldra:border-0 eldra:bg-transparent eldra:p-0 eldra:text-text",
4707
4962
  props.side === "left" ? "eldra:justify-start" : "eldra:justify-end",
4708
- "eldra:backdrop:bg-overlay eldra:focus:outline-none",
4709
- props.side === "left" ? "eldra:animate-eldra-drawer-in-left eldra:motion-reduce:animate-eldra-dialog-in-reduced" : "eldra:animate-eldra-drawer-in-right eldra:motion-reduce:animate-eldra-dialog-in-reduced"
4963
+ "eldra:overflow-clip eldra:backdrop:bg-overlay eldra:focus:outline-none eldra:eldra-drawer-motion",
4964
+ props.mobileSheet && "eldra:eldra-drawer-sheet eldra:max-md:flex-col eldra:max-md:justify-end"
4710
4965
  ]);
4711
4966
  /**
4712
4967
  * The visible sheet (spec "Drawer" → Sizes): full viewport height pinned to its edge, the width
@@ -4720,14 +4975,22 @@ var Drawer_default = /* @__PURE__ */ defineComponent({
4720
4975
  "eldra:flex eldra:h-full eldra:max-h-full eldra:min-w-0 eldra:flex-col eldra:bg-background eldra:text-text eldra:shadow-md",
4721
4976
  "eldra:eldra-drawer-width",
4722
4977
  props.side === "left" ? "eldra:border-r eldra:border-border eldra:max-md:border-r-0" : "eldra:border-l eldra:border-border eldra:max-md:border-l-0",
4978
+ props.mobileSheet && "eldra:max-md:h-auto eldra:max-md:eldra-drawer-sheet-height eldra:max-md:border-t eldra:max-md:rounded-t-[var(--eldra-drawer-sheet-radius,var(--eldra-radius-xl))]",
4979
+ props.swipe && (props.mobileSheet ? "eldra:md:touch-pan-y eldra:md:touch-pinch-zoom" : "eldra:touch-pan-y eldra:touch-pinch-zoom"),
4723
4980
  props.classes?.panel
4724
4981
  ]);
4725
- /** `--eldra-drawer-width` from the `width` prop, left unset so the utility's own literal default
4726
- * (28rem) applies when the prop is omitted. */
4982
+ /**
4983
+ * The sheet's grab handle: a short bar centred above the header, below 48rem only. Decorative to
4984
+ * assistive technology (the close button and `Esc` close it); its row, with the header below it,
4985
+ * is where the sheet is dragged, so neither lets the browser take the touch for a scroll.
4986
+ */
4987
+ const handleClass = computed(() => ["eldra:flex eldra:shrink-0 eldra:cursor-grab eldra:touch-none eldra:justify-center eldra:pt-2 eldra:pb-1 eldra:md:hidden", props.classes?.handle]);
4727
4988
  const panelStyle = computed(() => props.width === void 0 ? void 0 : { "--eldra-drawer-width": props.width });
4728
4989
  const headerClass = computed(() => [
4729
4990
  "eldra:flex eldra:shrink-0 eldra:items-center eldra:gap-4 eldra:border-b eldra:border-border",
4730
4991
  "eldra:eldra-drawer-header-height eldra:eldra-drawer-gutter eldra:eldra-drawer-header-top eldra:eldra-drawer-header-bottom",
4992
+ props.mobileSheet && "eldra:max-md:min-h-0 eldra:max-md:pt-1 eldra:max-md:touch-none",
4993
+ props.swipe && "eldra:select-none",
4731
4994
  props.classes?.header
4732
4995
  ]);
4733
4996
  /** A plain layout spacer, not a named part: `flex-1` so it claims every pixel the title does not
@@ -4769,12 +5032,22 @@ var Drawer_default = /* @__PURE__ */ defineComponent({
4769
5032
  class: normalizeClass(rootClass.value),
4770
5033
  "aria-labelledby": __props.title ? unref(titleId) : void 0,
4771
5034
  "aria-label": !__props.title ? __props.ariaLabel : void 0,
5035
+ "data-side": __props.side,
4772
5036
  onClose: onNativeClose
4773
5037
  }, [createElementVNode("div", {
5038
+ ref_key: "panelEl",
5039
+ ref: panelEl,
4774
5040
  "data-part": "panel",
4775
5041
  class: normalizeClass(panelClass.value),
4776
- style: normalizeStyle(panelStyle.value)
5042
+ style: normalizeStyle(panelStyle.value),
5043
+ onPointerdown: _cache[4] || (_cache[4] = (...args) => unref(drag).onPointerDown && unref(drag).onPointerDown(...args))
4777
5044
  }, [
5045
+ __props.mobileSheet ? (openBlock(), createElementBlock("div", {
5046
+ key: 0,
5047
+ "data-part": "handle",
5048
+ "aria-hidden": "true",
5049
+ class: normalizeClass(handleClass.value)
5050
+ }, [createElementVNode("span", { class: normalizeClass(handleBarClass) })], 2)) : createCommentVNode("", true),
4778
5051
  createElementVNode("div", {
4779
5052
  "data-part": "header",
4780
5053
  class: normalizeClass(headerClass.value)
@@ -4799,7 +5072,7 @@ var Drawer_default = /* @__PURE__ */ defineComponent({
4799
5072
  class: normalizeClass(closeClass.value),
4800
5073
  "aria-label": closeLabel.value,
4801
5074
  onClick: onCloseClick
4802
- }, [..._cache[0] || (_cache[0] = [createElementVNode("svg", {
5075
+ }, [..._cache[5] || (_cache[5] = [createElementVNode("svg", {
4803
5076
  class: "eldra:size-4",
4804
5077
  viewBox: "0 0 24 24",
4805
5078
  fill: "none",
@@ -4811,17 +5084,23 @@ var Drawer_default = /* @__PURE__ */ defineComponent({
4811
5084
  focusable: "false"
4812
5085
  }, [createElementVNode("path", { d: "M18 6l-12 12" }), createElementVNode("path", { d: "M6 6l12 12" })], -1)])], 10, _hoisted_4$14)], 2),
4813
5086
  createElementVNode("div", {
5087
+ ref_key: "bodyEl",
5088
+ ref: bodyEl,
4814
5089
  "data-eldra-slot": unref(eldra).slotHost("default"),
4815
5090
  "data-part": "body",
4816
- class: normalizeClass(bodyClass.value)
4817
- }, [renderSlot(_ctx.$slots, "default")], 10, _hoisted_5$10),
5091
+ class: normalizeClass(bodyClass.value),
5092
+ onTouchstart: _cache[0] || (_cache[0] = (...args) => unref(drag).onTouchStart && unref(drag).onTouchStart(...args)),
5093
+ onTouchmove: _cache[1] || (_cache[1] = (...args) => unref(drag).onTouchMove && unref(drag).onTouchMove(...args)),
5094
+ onTouchend: _cache[2] || (_cache[2] = (...args) => unref(drag).onTouchEnd && unref(drag).onTouchEnd(...args)),
5095
+ onTouchcancel: _cache[3] || (_cache[3] = (...args) => unref(drag).onTouchEnd && unref(drag).onTouchEnd(...args))
5096
+ }, [renderSlot(_ctx.$slots, "default")], 42, _hoisted_5$10),
4818
5097
  unref(slots).footer ? (openBlock(), createElementBlock("div", {
4819
- key: 0,
5098
+ key: 1,
4820
5099
  "data-eldra-slot": unref(eldra).slotHost("footer"),
4821
5100
  "data-part": "footer",
4822
5101
  class: normalizeClass(footerClass.value)
4823
5102
  }, [renderSlot(_ctx.$slots, "footer")], 10, _hoisted_6$6)) : createCommentVNode("", true)
4824
- ], 6)], 42, _hoisted_1$37);
5103
+ ], 38)], 42, _hoisted_1$37);
4825
5104
  };
4826
5105
  }
4827
5106
  });
@@ -5413,13 +5692,6 @@ var FieldWrapper_default = /* @__PURE__ */ defineComponent({
5413
5692
  * apart later. It carries no `data-part`, because it is not one of the spec's parts.
5414
5693
  */
5415
5694
  const LabelAndControl = (_props, { slots: own }) => isInline.value ? h("div", { class: GROUP_INLINE }, own.default?.()) : own.default?.() ?? [];
5416
- const controlEl = ref(null);
5417
- function onFramePress(event) {
5418
- const root = event.currentTarget;
5419
- const target = event.target;
5420
- const isInlineBox = target.parentElement === root && !target.hasAttribute("data-part");
5421
- if (target === root || target === controlEl.value || isInlineBox) event.preventDefault();
5422
- }
5423
5695
  /** In an inline row the error and the foot take a full-width row of their own, below the button. */
5424
5696
  const labelClass = computed(() => mergeClass([LABEL_TYPE, "eldra:mb-0.5"], props.classes?.label));
5425
5697
  const legendClass = computed(() => [
@@ -5458,7 +5730,7 @@ var FieldWrapper_default = /* @__PURE__ */ defineComponent({
5458
5730
  tabindex: __props.group ? -1 : void 0,
5459
5731
  "aria-describedby": __props.group ? describedBy.value : void 0,
5460
5732
  "aria-invalid": __props.group && hasError.value ? "true" : void 0
5461
- }, forwardedAttrs.value, { onMousedown: onFramePress }), {
5733
+ }, forwardedAttrs.value), {
5462
5734
  default: withCtx(() => [
5463
5735
  createVNode(LabelAndControl, null, {
5464
5736
  default: withCtx(() => [hasLabel.value ? (openBlock(), createBlock(resolveDynamicComponent(__props.group ? "legend" : "label"), {
@@ -5490,8 +5762,6 @@ var FieldWrapper_default = /* @__PURE__ */ defineComponent({
5490
5762
  "data-part",
5491
5763
  "class"
5492
5764
  ])) : createCommentVNode("", true), createElementVNode("div", {
5493
- ref_key: "controlEl",
5494
- ref: controlEl,
5495
5765
  "data-eldra-slot": unref(eldra).slotHost("default"),
5496
5766
  "data-part": "control",
5497
5767
  class: normalizeClass(controlClass.value)