@fluxus-ui/core 0.13.0 → 0.14.0

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/base.cjs CHANGED
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var base_exports = {};
22
22
  __export(base_exports, {
23
23
  MEASURE_EVENT: () => MEASURE_EVENT,
24
+ MOTION_ATTR: () => MOTION_ATTR,
24
25
  attachCombobox: () => attachCombobox,
25
26
  attachDatePicker: () => attachDatePicker,
26
27
  attachDialog: () => attachDialog,
@@ -28,6 +29,7 @@ __export(base_exports, {
28
29
  attachMenu: () => attachMenu,
29
30
  attachPending: () => attachPending,
30
31
  attachPress: () => attachPress,
32
+ attachSheet: () => attachSheet,
31
33
  attachSkeleton: () => attachSkeleton,
32
34
  attachSlider: () => attachSlider,
33
35
  attachSwitch: () => attachSwitch,
@@ -96,7 +98,9 @@ function resolveEasing(e, fallback = "decelerate") {
96
98
  return e in tokens.easing ? tokens.easing[e] : e;
97
99
  }
98
100
  var MEASURE_EVENT = "fluxus:measure";
101
+ var MOTION_ATTR = "data-fx-motion";
99
102
  function prefersReducedMotion() {
103
+ if (typeof document !== "undefined" && document.documentElement?.getAttribute(MOTION_ATTR) === "reduced") return true;
100
104
  return typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
101
105
  }
102
106
  function supportsWaapi(el) {
@@ -1619,15 +1623,28 @@ var revealEffect = Object.assign(
1619
1623
  { gap: 6 }
1620
1624
  );
1621
1625
 
1626
+ // src/sheet.ts
1627
+ var MARK = "--fx-css";
1628
+ var fromPackage = false;
1629
+ var packageCss = () => fromPackage || (fromPackage = typeof getComputedStyle === "function" && getComputedStyle(document.documentElement).getPropertyValue(MARK).trim() !== "");
1630
+ function ensureRule(rule) {
1631
+ if (typeof document === "undefined" || packageCss()) return;
1632
+ if (typeof CSSStyleSheet !== "function" || !("adoptedStyleSheets" in document)) return;
1633
+ try {
1634
+ const sheet = new CSSStyleSheet();
1635
+ sheet.replaceSync(rule);
1636
+ document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];
1637
+ } catch {
1638
+ }
1639
+ }
1640
+
1622
1641
  // src/toplayer.ts
1623
1642
  var TOP_ATTR = "data-fx-top";
1624
1643
  var ruled = false;
1625
1644
  var topRule = () => {
1626
1645
  if (ruled) return;
1627
1646
  ruled = true;
1628
- const rule = document.createElement("style");
1629
- rule.textContent = `@layer fx.reset{:where([${TOP_ATTR}]){inset:auto;margin:0;border:0;padding:0;overflow:visible;color:inherit;background:none}}`;
1630
- document.head.insertBefore(rule, document.head.firstChild);
1647
+ ensureRule(`@layer fx.reset{:where([${TOP_ATTR}]){inset:auto;margin:0;border:0;padding:0;overflow:visible;color:inherit;background:none}}`);
1631
1648
  };
1632
1649
  var lift = (panel, up) => {
1633
1650
  if (panel.matches(":popover-open") === up) return;
@@ -2098,6 +2115,7 @@ function attachSlider(input, options = {}) {
2098
2115
  }
2099
2116
 
2100
2117
  // src/datepicker.ts
2118
+ var attr = (text) => text.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;");
2101
2119
  var DAY = 864e5;
2102
2120
  var ms = (iso2) => Date.UTC(+iso2.slice(0, 4), +iso2.slice(5, 7) - 1, +iso2.slice(8, 10));
2103
2121
  var iso = (t) => new Date(t).toISOString().slice(0, 10);
@@ -2139,7 +2157,7 @@ function attachDatePicker(button, panel, options = {}) {
2139
2157
  panel.hidden = false;
2140
2158
  button.setAttribute("aria-haspopup", "dialog");
2141
2159
  button.setAttribute("aria-expanded", "false");
2142
- const nav = (to, label) => `<button type="button" class="fx-date__nav" data-to="${to}" aria-label="${label}">${chevron(to < 0 ? "M10 3.5 5.5 8l4.5 4.5" : "M6 3.5 10.5 8 6 12.5")}</button>`;
2160
+ const nav = (to, label) => `<button type="button" class="fx-date__nav" data-to="${to}" aria-label="${attr(label)}">${chevron(to < 0 ? "M10 3.5 5.5 8l4.5 4.5" : "M6 3.5 10.5 8 6 12.5")}</button>`;
2143
2161
  panel.innerHTML = `<div class="fx-date__head">${nav(-1, options.labels?.previous ?? "Previous month")}<span class="fx-date__month" id="${id}-month" aria-live="polite"></span>${nav(1, options.labels?.next ?? "Next month")}</div><div class="fx-date__row" aria-hidden="true">${[0, 1, 2, 3, 4, 5, 6].map((i) => `<span class="fx-date__dow">${shortDay.format(ms(add(startOf(today), i)))}</span>`).join("")}</div><div class="fx-date__body"></div>`;
2144
2162
  const monthEl = panel.querySelector(".fx-date__month");
2145
2163
  const body = panel.querySelector(".fx-date__body");
@@ -2178,7 +2196,7 @@ function attachDatePicker(button, panel, options = {}) {
2178
2196
  for (const d of days) {
2179
2197
  const on = week ? row === chosen : d === chosen;
2180
2198
  const marked = busy || marks.has(d);
2181
- html += `<span role="gridcell" aria-selected="${on}"><button type="button" class="fx-date__day" data-date="${d}" tabindex="${d === focus ? 0 : -1}" aria-label="${dayName.format(ms(d))}${marked && options.labels?.marked ? `, ${options.labels.marked}` : ""}"${marked ? " data-marked" : ""}${d === today ? ' aria-current="date"' : ""}${d.slice(0, 7) !== start.slice(0, 7) ? " data-outside" : ""}${out(d) ? ' aria-disabled="true"' : ""}>${+d.slice(8)}</button></span>`;
2199
+ html += `<span role="gridcell" aria-selected="${on}"><button type="button" class="fx-date__day" data-date="${d}" tabindex="${d === focus ? 0 : -1}" aria-label="${dayName.format(ms(d))}${marked && options.labels?.marked ? `, ${attr(options.labels.marked)}` : ""}"${marked ? " data-marked" : ""}${d === today ? ' aria-current="date"' : ""}${d.slice(0, 7) !== start.slice(0, 7) ? " data-outside" : ""}${out(d) ? ' aria-disabled="true"' : ""}>${+d.slice(8)}</button></span>`;
2182
2200
  }
2183
2201
  html += "</div>";
2184
2202
  }
@@ -2609,6 +2627,111 @@ function attachDialog(trigger, dialog, options = {}) {
2609
2627
  };
2610
2628
  }
2611
2629
 
2630
+ // src/side-sheet.ts
2631
+ function attachSheet(trigger, dialog, options = {}) {
2632
+ if (typeof dialog.showModal !== "function") throw new Error("attachSheet: it needs a <dialog> element");
2633
+ const closeOnBackdrop = options.closeOnBackdrop ?? true;
2634
+ const preset = typeof options.spring === "string" ? options.spring : "smooth";
2635
+ const custom = typeof options.spring === "object" ? options.spring : {};
2636
+ let isOpen = false;
2637
+ let motion = null;
2638
+ let shown = 0;
2639
+ let towardsEnd = true;
2640
+ trigger.setAttribute("aria-expanded", "false");
2641
+ if (!trigger.hasAttribute("aria-haspopup")) trigger.setAttribute("aria-haspopup", "dialog");
2642
+ dialog.dataset.fxSide = options.side ?? "end";
2643
+ const paint = (at) => {
2644
+ shown = at;
2645
+ dialog.style.translate = `${((1 - at) * 100 * (towardsEnd ? 1 : -1)).toFixed(2)}% 0`;
2646
+ dialog.style.setProperty("--fx-open", at.toFixed(3));
2647
+ };
2648
+ const rest = () => {
2649
+ dialog.style.removeProperty("translate");
2650
+ dialog.style.removeProperty("--fx-open");
2651
+ };
2652
+ const go = (to, done) => {
2653
+ if ((options.respectReducedMotion ?? true) && prefersReducedMotion()) {
2654
+ motion?.stop();
2655
+ paint(to);
2656
+ done?.();
2657
+ return;
2658
+ }
2659
+ if (motion && !motion.done) {
2660
+ motion.stop();
2661
+ }
2662
+ motion = spring({ ...custom, from: shown, to, velocity: motion?.velocity, preset, restDelta: 2e-3, onUpdate: paint, onRest: () => done?.() });
2663
+ };
2664
+ const open = () => {
2665
+ if (isOpen) return;
2666
+ isOpen = true;
2667
+ trigger.setAttribute("aria-expanded", "true");
2668
+ if (!dialog.open) {
2669
+ towardsEnd = dialog.dataset.fxSide === "end" !== (getComputedStyle(dialog).direction === "rtl");
2670
+ paint(0);
2671
+ dialog.showModal();
2672
+ }
2673
+ go(1, () => {
2674
+ if (isOpen) rest();
2675
+ });
2676
+ options.onOpenChange?.(true);
2677
+ };
2678
+ const close = () => {
2679
+ if (!isOpen) return;
2680
+ isOpen = false;
2681
+ trigger.setAttribute("aria-expanded", "false");
2682
+ go(0, () => {
2683
+ if (isOpen) return;
2684
+ if (dialog.open) dialog.close();
2685
+ rest();
2686
+ });
2687
+ options.onOpenChange?.(false);
2688
+ };
2689
+ const onTrigger = () => open();
2690
+ const onCancel = (e) => {
2691
+ e.preventDefault();
2692
+ close();
2693
+ };
2694
+ const onClick = (e) => {
2695
+ const target = e.target;
2696
+ if (target?.closest("[data-fx-close]")) {
2697
+ close();
2698
+ return;
2699
+ }
2700
+ if (!closeOnBackdrop || target !== dialog) return;
2701
+ const box = dialog.getBoundingClientRect();
2702
+ if (e.clientX < box.left || e.clientX > box.right || e.clientY < box.top || e.clientY > box.bottom) close();
2703
+ };
2704
+ const onClosed = () => {
2705
+ if (!isOpen) return;
2706
+ isOpen = false;
2707
+ motion?.stop();
2708
+ trigger.setAttribute("aria-expanded", "false");
2709
+ rest();
2710
+ options.onOpenChange?.(false);
2711
+ };
2712
+ trigger.addEventListener("click", onTrigger);
2713
+ dialog.addEventListener("cancel", onCancel);
2714
+ dialog.addEventListener("click", onClick);
2715
+ dialog.addEventListener("close", onClosed);
2716
+ return {
2717
+ get isOpen() {
2718
+ return isOpen;
2719
+ },
2720
+ open,
2721
+ close,
2722
+ destroy() {
2723
+ motion?.stop();
2724
+ trigger.removeEventListener("click", onTrigger);
2725
+ dialog.removeEventListener("cancel", onCancel);
2726
+ dialog.removeEventListener("click", onClick);
2727
+ dialog.removeEventListener("close", onClosed);
2728
+ rest();
2729
+ trigger.removeAttribute("aria-expanded");
2730
+ delete dialog.dataset.fxSide;
2731
+ }
2732
+ };
2733
+ }
2734
+
2612
2735
  // src/liquid.ts
2613
2736
  var SINK = 3;
2614
2737
  var lerp = (a, b, p) => a + (b - a) * p;
@@ -3153,6 +3276,7 @@ function layoutCellAttrs(cell) {
3153
3276
  // Annotate the CommonJS export names for ESM import in node:
3154
3277
  0 && (module.exports = {
3155
3278
  MEASURE_EVENT,
3279
+ MOTION_ATTR,
3156
3280
  attachCombobox,
3157
3281
  attachDatePicker,
3158
3282
  attachDialog,
@@ -3160,6 +3284,7 @@ function layoutCellAttrs(cell) {
3160
3284
  attachMenu,
3161
3285
  attachPending,
3162
3286
  attachPress,
3287
+ attachSheet,
3163
3288
  attachSkeleton,
3164
3289
  attachSlider,
3165
3290
  attachSwitch,
package/dist/base.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as SpringConfig, a as SpringPreset, E as EasingToken } from './cells-C1fRmU7p.cjs';
2
- export { C as CellLayoutHandle, b as CellLayoutOptions, M as MEASURE_EVENT, P as PlayOptions, p as prefersReducedMotion, r as resolveEasing, c as resolveSpring, s as supportsWaapi, t as tokens } from './cells-C1fRmU7p.cjs';
1
+ import { S as SpringConfig, a as SpringPreset, E as EasingToken } from './cells-_RHBATKa.cjs';
2
+ export { C as CellLayoutHandle, b as CellLayoutOptions, M as MEASURE_EVENT, c as MOTION_ATTR, P as PlayOptions, p as prefersReducedMotion, r as resolveEasing, d as resolveSpring, s as supportsWaapi, t as tokens } from './cells-_RHBATKa.cjs';
3
3
 
4
4
  /**
5
5
  * Fluxus spring engine.
@@ -524,6 +524,34 @@ interface DialogHandle {
524
524
  }
525
525
  declare function attachDialog(trigger: HTMLElement, dialog: HTMLDialogElement, options?: DialogOptions): DialogHandle;
526
526
 
527
+ /**
528
+ * Sheet — a panel that comes in from a side of the page (SPEC §14.50).
529
+ *
530
+ * A native `<dialog>`, as the dialog: the focus trap, Escape, the inert page and
531
+ * the top layer are the browser's. It slides in from its side on a spring and
532
+ * goes back the same way; `--fx-open` (0 → 1) goes with it for the backdrop.
533
+ * Only `translate` and that property are written, from the client.
534
+ */
535
+
536
+ interface SheetOptions {
537
+ /** Which side it comes from, in the direction of the text: 'end' (right in LTR) or 'start'. Default: 'end'. */
538
+ side?: 'start' | 'end';
539
+ /** Spring preset or config. Default: 'smooth'. */
540
+ spring?: SpringPreset | Partial<SpringConfig>;
541
+ /** Close on a click on the backdrop. Default: true. */
542
+ closeOnBackdrop?: boolean;
543
+ onOpenChange?: (open: boolean) => void;
544
+ /** Honor reduced motion (default: true). */
545
+ respectReducedMotion?: boolean;
546
+ }
547
+ interface SheetHandle {
548
+ readonly isOpen: boolean;
549
+ open(): void;
550
+ close(): void;
551
+ destroy(): void;
552
+ }
553
+ declare function attachSheet(trigger: HTMLElement, dialog: HTMLDialogElement, options?: SheetOptions): SheetHandle;
554
+
527
555
  /**
528
556
  * Tooltip — a short description that is born from what it explains.
529
557
  *
@@ -719,4 +747,4 @@ declare function layoutCellStyle(cell: LayoutCellDoc): Record<string, string>;
719
747
  /** Identity and provenance attributes for one cell. */
720
748
  declare function layoutCellAttrs(cell: LayoutCellDoc): Record<string, string>;
721
749
 
722
- export { type Bud, type BudOptions, type ClockOptions, type ComboboxHandle, type ComboboxOptions, type CounterHandle, type CounterOptions, type DatePickerHandle, type DatePickerOptions, type DialogHandle, type DialogOptions, EasingToken, type IndicatorHandle, type IndicatorOptions, type LayoutCellDoc, type LayoutDoc, type MenuHandle, type MenuOptions, type MenuPlacement, type MorphHandle, type MorphOptions, type PendingHandle, type PendingOptions, type PressHandle, type PressOptions, type SkeletonHandle, type SkeletonOptions, type SliderHandle, type SliderOptions, SpringConfig, type SpringHandle, type SpringOptions, SpringPreset, type StaggerOptions, type StaggerOutOptions, type SwapDirection, type SwapHandle, type SwapOptions, type SwitchHandle, type SwitchOptions, type TableSort, type TooltipEffect, type TooltipHandle, type TooltipOptions, type TooltipPlacement, attachCombobox, attachDatePicker, attachDialog, attachIndicator, attachMenu, attachPending, attachPress, attachSkeleton, attachSlider, attachSwitch, attachTooltip, budEffect, clock, createBud, createCounter, createMorph, createSwap, layoutCellAttrs, layoutCellStyle, layoutContainerStyle, nextSort, reorder, revealEffect, sortRows, spring, staggerIn, staggerOut };
750
+ export { type Bud, type BudOptions, type ClockOptions, type ComboboxHandle, type ComboboxOptions, type CounterHandle, type CounterOptions, type DatePickerHandle, type DatePickerOptions, type DialogHandle, type DialogOptions, EasingToken, type IndicatorHandle, type IndicatorOptions, type LayoutCellDoc, type LayoutDoc, type MenuHandle, type MenuOptions, type MenuPlacement, type MorphHandle, type MorphOptions, type PendingHandle, type PendingOptions, type PressHandle, type PressOptions, type SheetHandle, type SheetOptions, type SkeletonHandle, type SkeletonOptions, type SliderHandle, type SliderOptions, SpringConfig, type SpringHandle, type SpringOptions, SpringPreset, type StaggerOptions, type StaggerOutOptions, type SwapDirection, type SwapHandle, type SwapOptions, type SwitchHandle, type SwitchOptions, type TableSort, type TooltipEffect, type TooltipHandle, type TooltipOptions, type TooltipPlacement, attachCombobox, attachDatePicker, attachDialog, attachIndicator, attachMenu, attachPending, attachPress, attachSheet, attachSkeleton, attachSlider, attachSwitch, attachTooltip, budEffect, clock, createBud, createCounter, createMorph, createSwap, layoutCellAttrs, layoutCellStyle, layoutContainerStyle, nextSort, reorder, revealEffect, sortRows, spring, staggerIn, staggerOut };
package/dist/base.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as SpringConfig, a as SpringPreset, E as EasingToken } from './cells-C1fRmU7p.js';
2
- export { C as CellLayoutHandle, b as CellLayoutOptions, M as MEASURE_EVENT, P as PlayOptions, p as prefersReducedMotion, r as resolveEasing, c as resolveSpring, s as supportsWaapi, t as tokens } from './cells-C1fRmU7p.js';
1
+ import { S as SpringConfig, a as SpringPreset, E as EasingToken } from './cells-_RHBATKa.js';
2
+ export { C as CellLayoutHandle, b as CellLayoutOptions, M as MEASURE_EVENT, c as MOTION_ATTR, P as PlayOptions, p as prefersReducedMotion, r as resolveEasing, d as resolveSpring, s as supportsWaapi, t as tokens } from './cells-_RHBATKa.js';
3
3
 
4
4
  /**
5
5
  * Fluxus spring engine.
@@ -524,6 +524,34 @@ interface DialogHandle {
524
524
  }
525
525
  declare function attachDialog(trigger: HTMLElement, dialog: HTMLDialogElement, options?: DialogOptions): DialogHandle;
526
526
 
527
+ /**
528
+ * Sheet — a panel that comes in from a side of the page (SPEC §14.50).
529
+ *
530
+ * A native `<dialog>`, as the dialog: the focus trap, Escape, the inert page and
531
+ * the top layer are the browser's. It slides in from its side on a spring and
532
+ * goes back the same way; `--fx-open` (0 → 1) goes with it for the backdrop.
533
+ * Only `translate` and that property are written, from the client.
534
+ */
535
+
536
+ interface SheetOptions {
537
+ /** Which side it comes from, in the direction of the text: 'end' (right in LTR) or 'start'. Default: 'end'. */
538
+ side?: 'start' | 'end';
539
+ /** Spring preset or config. Default: 'smooth'. */
540
+ spring?: SpringPreset | Partial<SpringConfig>;
541
+ /** Close on a click on the backdrop. Default: true. */
542
+ closeOnBackdrop?: boolean;
543
+ onOpenChange?: (open: boolean) => void;
544
+ /** Honor reduced motion (default: true). */
545
+ respectReducedMotion?: boolean;
546
+ }
547
+ interface SheetHandle {
548
+ readonly isOpen: boolean;
549
+ open(): void;
550
+ close(): void;
551
+ destroy(): void;
552
+ }
553
+ declare function attachSheet(trigger: HTMLElement, dialog: HTMLDialogElement, options?: SheetOptions): SheetHandle;
554
+
527
555
  /**
528
556
  * Tooltip — a short description that is born from what it explains.
529
557
  *
@@ -719,4 +747,4 @@ declare function layoutCellStyle(cell: LayoutCellDoc): Record<string, string>;
719
747
  /** Identity and provenance attributes for one cell. */
720
748
  declare function layoutCellAttrs(cell: LayoutCellDoc): Record<string, string>;
721
749
 
722
- export { type Bud, type BudOptions, type ClockOptions, type ComboboxHandle, type ComboboxOptions, type CounterHandle, type CounterOptions, type DatePickerHandle, type DatePickerOptions, type DialogHandle, type DialogOptions, EasingToken, type IndicatorHandle, type IndicatorOptions, type LayoutCellDoc, type LayoutDoc, type MenuHandle, type MenuOptions, type MenuPlacement, type MorphHandle, type MorphOptions, type PendingHandle, type PendingOptions, type PressHandle, type PressOptions, type SkeletonHandle, type SkeletonOptions, type SliderHandle, type SliderOptions, SpringConfig, type SpringHandle, type SpringOptions, SpringPreset, type StaggerOptions, type StaggerOutOptions, type SwapDirection, type SwapHandle, type SwapOptions, type SwitchHandle, type SwitchOptions, type TableSort, type TooltipEffect, type TooltipHandle, type TooltipOptions, type TooltipPlacement, attachCombobox, attachDatePicker, attachDialog, attachIndicator, attachMenu, attachPending, attachPress, attachSkeleton, attachSlider, attachSwitch, attachTooltip, budEffect, clock, createBud, createCounter, createMorph, createSwap, layoutCellAttrs, layoutCellStyle, layoutContainerStyle, nextSort, reorder, revealEffect, sortRows, spring, staggerIn, staggerOut };
750
+ export { type Bud, type BudOptions, type ClockOptions, type ComboboxHandle, type ComboboxOptions, type CounterHandle, type CounterOptions, type DatePickerHandle, type DatePickerOptions, type DialogHandle, type DialogOptions, EasingToken, type IndicatorHandle, type IndicatorOptions, type LayoutCellDoc, type LayoutDoc, type MenuHandle, type MenuOptions, type MenuPlacement, type MorphHandle, type MorphOptions, type PendingHandle, type PendingOptions, type PressHandle, type PressOptions, type SheetHandle, type SheetOptions, type SkeletonHandle, type SkeletonOptions, type SliderHandle, type SliderOptions, SpringConfig, type SpringHandle, type SpringOptions, SpringPreset, type StaggerOptions, type StaggerOutOptions, type SwapDirection, type SwapHandle, type SwapOptions, type SwitchHandle, type SwitchOptions, type TableSort, type TooltipEffect, type TooltipHandle, type TooltipOptions, type TooltipPlacement, attachCombobox, attachDatePicker, attachDialog, attachIndicator, attachMenu, attachPending, attachPress, attachSheet, attachSkeleton, attachSlider, attachSwitch, attachTooltip, budEffect, clock, createBud, createCounter, createMorph, createSwap, layoutCellAttrs, layoutCellStyle, layoutContainerStyle, nextSort, reorder, revealEffect, sortRows, spring, staggerIn, staggerOut };
package/dist/base.js CHANGED
@@ -6,6 +6,7 @@ import {
6
6
  attachMenu,
7
7
  attachPending,
8
8
  attachPress,
9
+ attachSheet,
9
10
  attachSkeleton,
10
11
  attachSlider,
11
12
  attachSwitch,
@@ -24,9 +25,10 @@ import {
24
25
  sortRows,
25
26
  staggerIn,
26
27
  staggerOut
27
- } from "./chunk-O7KUU7VB.js";
28
+ } from "./chunk-P46FNWIK.js";
28
29
  import {
29
30
  MEASURE_EVENT,
31
+ MOTION_ATTR,
30
32
  clock,
31
33
  prefersReducedMotion,
32
34
  resolveEasing,
@@ -34,9 +36,10 @@ import {
34
36
  spring,
35
37
  supportsWaapi,
36
38
  tokens
37
- } from "./chunk-LCXYNLM7.js";
39
+ } from "./chunk-RMSWZ2JF.js";
38
40
  export {
39
41
  MEASURE_EVENT,
42
+ MOTION_ATTR,
40
43
  attachCombobox,
41
44
  attachDatePicker,
42
45
  attachDialog,
@@ -44,6 +47,7 @@ export {
44
47
  attachMenu,
45
48
  attachPending,
46
49
  attachPress,
50
+ attachSheet,
47
51
  attachSkeleton,
48
52
  attachSlider,
49
53
  attachSwitch,
@@ -50,7 +50,9 @@ declare function resolveEasing(e: EasingToken | string | undefined, fallback?: E
50
50
  * Whatever places itself by measuring gets to its place first.
51
51
  */
52
52
  declare const MEASURE_EVENT = "fluxus:measure";
53
- /** True when the user asked the OS for reduced motion. */
53
+ /** On <html>, `reduced`: the application asks for less motion (a choice of its user), as the OS can (SPEC §14.50). */
54
+ declare const MOTION_ATTR = "data-fx-motion";
55
+ /** True when the user asked the OS, or the application, for reduced motion. The attribute only reduces. */
54
56
  declare function prefersReducedMotion(): boolean;
55
57
  /**
56
58
  * True when the element supports the Web Animations API.
@@ -195,4 +197,4 @@ interface CellLayoutHandle {
195
197
  declare function layoutTransaction(mutate: () => void | Promise<void>, options?: PlayOptions): Promise<void>;
196
198
  declare function createCellLayout(container: HTMLElement, options?: CellLayoutOptions): CellLayoutHandle;
197
199
 
198
- export { type CellLayoutHandle as C, type EasingToken as E, MEASURE_EVENT as M, type PlayOptions as P, type SpringConfig as S, type SpringPreset as a, type CellLayoutOptions as b, resolveSpring as c, createCellLayout as d, layoutTransaction as l, prefersReducedMotion as p, resolveEasing as r, supportsWaapi as s, tokens as t };
200
+ export { type CellLayoutHandle as C, type EasingToken as E, MEASURE_EVENT as M, type PlayOptions as P, type SpringConfig as S, type SpringPreset as a, type CellLayoutOptions as b, MOTION_ATTR as c, resolveSpring as d, createCellLayout as e, layoutTransaction as l, prefersReducedMotion as p, resolveEasing as r, supportsWaapi as s, tokens as t };
@@ -50,7 +50,9 @@ declare function resolveEasing(e: EasingToken | string | undefined, fallback?: E
50
50
  * Whatever places itself by measuring gets to its place first.
51
51
  */
52
52
  declare const MEASURE_EVENT = "fluxus:measure";
53
- /** True when the user asked the OS for reduced motion. */
53
+ /** On <html>, `reduced`: the application asks for less motion (a choice of its user), as the OS can (SPEC §14.50). */
54
+ declare const MOTION_ATTR = "data-fx-motion";
55
+ /** True when the user asked the OS, or the application, for reduced motion. The attribute only reduces. */
54
56
  declare function prefersReducedMotion(): boolean;
55
57
  /**
56
58
  * True when the element supports the Web Animations API.
@@ -195,4 +197,4 @@ interface CellLayoutHandle {
195
197
  declare function layoutTransaction(mutate: () => void | Promise<void>, options?: PlayOptions): Promise<void>;
196
198
  declare function createCellLayout(container: HTMLElement, options?: CellLayoutOptions): CellLayoutHandle;
197
199
 
198
- export { type CellLayoutHandle as C, type EasingToken as E, MEASURE_EVENT as M, type PlayOptions as P, type SpringConfig as S, type SpringPreset as a, type CellLayoutOptions as b, resolveSpring as c, createCellLayout as d, layoutTransaction as l, prefersReducedMotion as p, resolveEasing as r, supportsWaapi as s, tokens as t };
200
+ export { type CellLayoutHandle as C, type EasingToken as E, MEASURE_EVENT as M, type PlayOptions as P, type SpringConfig as S, type SpringPreset as a, type CellLayoutOptions as b, MOTION_ATTR as c, resolveSpring as d, createCellLayout as e, layoutTransaction as l, prefersReducedMotion as p, resolveEasing as r, supportsWaapi as s, tokens as t };
package/dist/cells.cjs CHANGED
@@ -25,6 +25,21 @@ __export(cells_exports, {
25
25
  });
26
26
  module.exports = __toCommonJS(cells_exports);
27
27
 
28
+ // src/sheet.ts
29
+ var MARK = "--fx-css";
30
+ var fromPackage = false;
31
+ var packageCss = () => fromPackage || (fromPackage = typeof getComputedStyle === "function" && getComputedStyle(document.documentElement).getPropertyValue(MARK).trim() !== "");
32
+ function ensureRule(rule) {
33
+ if (typeof document === "undefined" || packageCss()) return;
34
+ if (typeof CSSStyleSheet !== "function" || !("adoptedStyleSheets" in document)) return;
35
+ try {
36
+ const sheet = new CSSStyleSheet();
37
+ sheet.replaceSync(rule);
38
+ document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];
39
+ } catch {
40
+ }
41
+ }
42
+
28
43
  // src/tokens.ts
29
44
  var tokens = {
30
45
  duration: {
@@ -61,7 +76,9 @@ function resolveSpring(s, fallback = "smooth") {
61
76
  return { ...tokens.spring[fallback], ...s };
62
77
  }
63
78
  var MEASURE_EVENT = "fluxus:measure";
79
+ var MOTION_ATTR = "data-fx-motion";
64
80
  function prefersReducedMotion() {
81
+ if (typeof document !== "undefined" && document.documentElement?.getAttribute(MOTION_ATTR) === "reduced") return true;
65
82
  return typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
66
83
  }
67
84
  function supportsWaapi(el) {
@@ -355,9 +372,7 @@ var unclipRuled = false;
355
372
  var unclipRule = () => {
356
373
  if (unclipRuled) return;
357
374
  unclipRuled = true;
358
- const rule = document.createElement("style");
359
- rule.textContent = `[${UNCLIP_ATTR}]{overflow:visible!important}`;
360
- document.head.appendChild(rule);
375
+ ensureRule(`[${UNCLIP_ATTR}]{overflow:visible!important}`);
361
376
  };
362
377
  var engines = /* @__PURE__ */ new Set();
363
378
  var stagings = 0;
package/dist/cells.d.cts CHANGED
@@ -1 +1 @@
1
- export { C as CellLayoutHandle, b as CellLayoutOptions, P as PlayOptions, d as createCellLayout, l as layoutTransaction } from './cells-C1fRmU7p.cjs';
1
+ export { C as CellLayoutHandle, b as CellLayoutOptions, P as PlayOptions, e as createCellLayout, l as layoutTransaction } from './cells-_RHBATKa.cjs';
package/dist/cells.d.ts CHANGED
@@ -1 +1 @@
1
- export { C as CellLayoutHandle, b as CellLayoutOptions, P as PlayOptions, d as createCellLayout, l as layoutTransaction } from './cells-C1fRmU7p.js';
1
+ export { C as CellLayoutHandle, b as CellLayoutOptions, P as PlayOptions, e as createCellLayout, l as layoutTransaction } from './cells-_RHBATKa.js';
package/dist/cells.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  createCellLayout,
3
3
  layoutTransaction
4
- } from "./chunk-JQ73ETUC.js";
5
- import "./chunk-LCXYNLM7.js";
4
+ } from "./chunk-L3APQ24V.js";
5
+ import "./chunk-RMSWZ2JF.js";
6
6
  export {
7
7
  createCellLayout,
8
8
  layoutTransaction
@@ -2,6 +2,7 @@ import {
2
2
  MEASURE_EVENT,
3
3
  clamp01,
4
4
  clock,
5
+ ensureRule,
5
6
  lerp,
6
7
  mix,
7
8
  move,
@@ -20,7 +21,7 @@ import {
20
21
  surface,
21
22
  tokens,
22
23
  unit
23
- } from "./chunk-LCXYNLM7.js";
24
+ } from "./chunk-RMSWZ2JF.js";
24
25
 
25
26
  // src/cells.ts
26
27
  var GHOST_ATTR = "data-fx-ghost";
@@ -32,9 +33,7 @@ var unclipRuled = false;
32
33
  var unclipRule = () => {
33
34
  if (unclipRuled) return;
34
35
  unclipRuled = true;
35
- const rule = document.createElement("style");
36
- rule.textContent = `[${UNCLIP_ATTR}]{overflow:visible!important}`;
37
- document.head.appendChild(rule);
36
+ ensureRule(`[${UNCLIP_ATTR}]{overflow:visible!important}`);
38
37
  };
39
38
  var engines = /* @__PURE__ */ new Set();
40
39
  var stagings = 0;
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  MEASURE_EVENT,
3
+ ensureRule,
3
4
  lerp,
4
5
  neckOf,
5
6
  neckPath,
@@ -11,7 +12,7 @@ import {
11
12
  spring,
12
13
  supportsWaapi,
13
14
  tokens
14
- } from "./chunk-LCXYNLM7.js";
15
+ } from "./chunk-RMSWZ2JF.js";
15
16
 
16
17
  // src/morph.ts
17
18
  function createMorph(el, options = {}) {
@@ -1385,9 +1386,7 @@ var ruled = false;
1385
1386
  var topRule = () => {
1386
1387
  if (ruled) return;
1387
1388
  ruled = true;
1388
- const rule = document.createElement("style");
1389
- rule.textContent = `@layer fx.reset{:where([${TOP_ATTR}]){inset:auto;margin:0;border:0;padding:0;overflow:visible;color:inherit;background:none}}`;
1390
- document.head.insertBefore(rule, document.head.firstChild);
1389
+ ensureRule(`@layer fx.reset{:where([${TOP_ATTR}]){inset:auto;margin:0;border:0;padding:0;overflow:visible;color:inherit;background:none}}`);
1391
1390
  };
1392
1391
  var lift = (panel, up) => {
1393
1392
  if (panel.matches(":popover-open") === up) return;
@@ -1858,6 +1857,7 @@ function attachSlider(input, options = {}) {
1858
1857
  }
1859
1858
 
1860
1859
  // src/datepicker.ts
1860
+ var attr = (text) => text.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;");
1861
1861
  var DAY = 864e5;
1862
1862
  var ms = (iso2) => Date.UTC(+iso2.slice(0, 4), +iso2.slice(5, 7) - 1, +iso2.slice(8, 10));
1863
1863
  var iso = (t) => new Date(t).toISOString().slice(0, 10);
@@ -1899,7 +1899,7 @@ function attachDatePicker(button, panel, options = {}) {
1899
1899
  panel.hidden = false;
1900
1900
  button.setAttribute("aria-haspopup", "dialog");
1901
1901
  button.setAttribute("aria-expanded", "false");
1902
- const nav = (to, label) => `<button type="button" class="fx-date__nav" data-to="${to}" aria-label="${label}">${chevron(to < 0 ? "M10 3.5 5.5 8l4.5 4.5" : "M6 3.5 10.5 8 6 12.5")}</button>`;
1902
+ const nav = (to, label) => `<button type="button" class="fx-date__nav" data-to="${to}" aria-label="${attr(label)}">${chevron(to < 0 ? "M10 3.5 5.5 8l4.5 4.5" : "M6 3.5 10.5 8 6 12.5")}</button>`;
1903
1903
  panel.innerHTML = `<div class="fx-date__head">${nav(-1, options.labels?.previous ?? "Previous month")}<span class="fx-date__month" id="${id}-month" aria-live="polite"></span>${nav(1, options.labels?.next ?? "Next month")}</div><div class="fx-date__row" aria-hidden="true">${[0, 1, 2, 3, 4, 5, 6].map((i) => `<span class="fx-date__dow">${shortDay.format(ms(add(startOf(today), i)))}</span>`).join("")}</div><div class="fx-date__body"></div>`;
1904
1904
  const monthEl = panel.querySelector(".fx-date__month");
1905
1905
  const body = panel.querySelector(".fx-date__body");
@@ -1938,7 +1938,7 @@ function attachDatePicker(button, panel, options = {}) {
1938
1938
  for (const d of days) {
1939
1939
  const on = week ? row === chosen : d === chosen;
1940
1940
  const marked = busy || marks.has(d);
1941
- html += `<span role="gridcell" aria-selected="${on}"><button type="button" class="fx-date__day" data-date="${d}" tabindex="${d === focus ? 0 : -1}" aria-label="${dayName.format(ms(d))}${marked && options.labels?.marked ? `, ${options.labels.marked}` : ""}"${marked ? " data-marked" : ""}${d === today ? ' aria-current="date"' : ""}${d.slice(0, 7) !== start.slice(0, 7) ? " data-outside" : ""}${out(d) ? ' aria-disabled="true"' : ""}>${+d.slice(8)}</button></span>`;
1941
+ html += `<span role="gridcell" aria-selected="${on}"><button type="button" class="fx-date__day" data-date="${d}" tabindex="${d === focus ? 0 : -1}" aria-label="${dayName.format(ms(d))}${marked && options.labels?.marked ? `, ${attr(options.labels.marked)}` : ""}"${marked ? " data-marked" : ""}${d === today ? ' aria-current="date"' : ""}${d.slice(0, 7) !== start.slice(0, 7) ? " data-outside" : ""}${out(d) ? ' aria-disabled="true"' : ""}>${+d.slice(8)}</button></span>`;
1942
1942
  }
1943
1943
  html += "</div>";
1944
1944
  }
@@ -2369,6 +2369,111 @@ function attachDialog(trigger, dialog, options = {}) {
2369
2369
  };
2370
2370
  }
2371
2371
 
2372
+ // src/side-sheet.ts
2373
+ function attachSheet(trigger, dialog, options = {}) {
2374
+ if (typeof dialog.showModal !== "function") throw new Error("attachSheet: it needs a <dialog> element");
2375
+ const closeOnBackdrop = options.closeOnBackdrop ?? true;
2376
+ const preset = typeof options.spring === "string" ? options.spring : "smooth";
2377
+ const custom = typeof options.spring === "object" ? options.spring : {};
2378
+ let isOpen = false;
2379
+ let motion = null;
2380
+ let shown = 0;
2381
+ let towardsEnd = true;
2382
+ trigger.setAttribute("aria-expanded", "false");
2383
+ if (!trigger.hasAttribute("aria-haspopup")) trigger.setAttribute("aria-haspopup", "dialog");
2384
+ dialog.dataset.fxSide = options.side ?? "end";
2385
+ const paint = (at) => {
2386
+ shown = at;
2387
+ dialog.style.translate = `${((1 - at) * 100 * (towardsEnd ? 1 : -1)).toFixed(2)}% 0`;
2388
+ dialog.style.setProperty("--fx-open", at.toFixed(3));
2389
+ };
2390
+ const rest = () => {
2391
+ dialog.style.removeProperty("translate");
2392
+ dialog.style.removeProperty("--fx-open");
2393
+ };
2394
+ const go = (to, done) => {
2395
+ if ((options.respectReducedMotion ?? true) && prefersReducedMotion()) {
2396
+ motion?.stop();
2397
+ paint(to);
2398
+ done?.();
2399
+ return;
2400
+ }
2401
+ if (motion && !motion.done) {
2402
+ motion.stop();
2403
+ }
2404
+ motion = spring({ ...custom, from: shown, to, velocity: motion?.velocity, preset, restDelta: 2e-3, onUpdate: paint, onRest: () => done?.() });
2405
+ };
2406
+ const open = () => {
2407
+ if (isOpen) return;
2408
+ isOpen = true;
2409
+ trigger.setAttribute("aria-expanded", "true");
2410
+ if (!dialog.open) {
2411
+ towardsEnd = dialog.dataset.fxSide === "end" !== (getComputedStyle(dialog).direction === "rtl");
2412
+ paint(0);
2413
+ dialog.showModal();
2414
+ }
2415
+ go(1, () => {
2416
+ if (isOpen) rest();
2417
+ });
2418
+ options.onOpenChange?.(true);
2419
+ };
2420
+ const close = () => {
2421
+ if (!isOpen) return;
2422
+ isOpen = false;
2423
+ trigger.setAttribute("aria-expanded", "false");
2424
+ go(0, () => {
2425
+ if (isOpen) return;
2426
+ if (dialog.open) dialog.close();
2427
+ rest();
2428
+ });
2429
+ options.onOpenChange?.(false);
2430
+ };
2431
+ const onTrigger = () => open();
2432
+ const onCancel = (e) => {
2433
+ e.preventDefault();
2434
+ close();
2435
+ };
2436
+ const onClick = (e) => {
2437
+ const target = e.target;
2438
+ if (target?.closest("[data-fx-close]")) {
2439
+ close();
2440
+ return;
2441
+ }
2442
+ if (!closeOnBackdrop || target !== dialog) return;
2443
+ const box = dialog.getBoundingClientRect();
2444
+ if (e.clientX < box.left || e.clientX > box.right || e.clientY < box.top || e.clientY > box.bottom) close();
2445
+ };
2446
+ const onClosed = () => {
2447
+ if (!isOpen) return;
2448
+ isOpen = false;
2449
+ motion?.stop();
2450
+ trigger.setAttribute("aria-expanded", "false");
2451
+ rest();
2452
+ options.onOpenChange?.(false);
2453
+ };
2454
+ trigger.addEventListener("click", onTrigger);
2455
+ dialog.addEventListener("cancel", onCancel);
2456
+ dialog.addEventListener("click", onClick);
2457
+ dialog.addEventListener("close", onClosed);
2458
+ return {
2459
+ get isOpen() {
2460
+ return isOpen;
2461
+ },
2462
+ open,
2463
+ close,
2464
+ destroy() {
2465
+ motion?.stop();
2466
+ trigger.removeEventListener("click", onTrigger);
2467
+ dialog.removeEventListener("cancel", onCancel);
2468
+ dialog.removeEventListener("click", onClick);
2469
+ dialog.removeEventListener("close", onClosed);
2470
+ rest();
2471
+ trigger.removeAttribute("aria-expanded");
2472
+ delete dialog.dataset.fxSide;
2473
+ }
2474
+ };
2475
+ }
2476
+
2372
2477
  // src/bud.ts
2373
2478
  var SVG = "http://www.w3.org/2000/svg";
2374
2479
  var DROP = 5;
@@ -2803,6 +2908,7 @@ export {
2803
2908
  sortRows,
2804
2909
  nextSort,
2805
2910
  attachDialog,
2911
+ attachSheet,
2806
2912
  createBud,
2807
2913
  budEffect,
2808
2914
  attachTooltip,
@@ -38,7 +38,9 @@ function resolveEasing(e, fallback = "decelerate") {
38
38
  return e in tokens.easing ? tokens.easing[e] : e;
39
39
  }
40
40
  var MEASURE_EVENT = "fluxus:measure";
41
+ var MOTION_ATTR = "data-fx-motion";
41
42
  function prefersReducedMotion() {
43
+ if (typeof document !== "undefined" && document.documentElement?.getAttribute(MOTION_ATTR) === "reduced") return true;
42
44
  return typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
43
45
  }
44
46
  function supportsWaapi(el) {
@@ -195,6 +197,21 @@ function clock(options) {
195
197
  };
196
198
  }
197
199
 
200
+ // src/sheet.ts
201
+ var MARK = "--fx-css";
202
+ var fromPackage = false;
203
+ var packageCss = () => fromPackage || (fromPackage = typeof getComputedStyle === "function" && getComputedStyle(document.documentElement).getPropertyValue(MARK).trim() !== "");
204
+ function ensureRule(rule) {
205
+ if (typeof document === "undefined" || packageCss()) return;
206
+ if (typeof CSSStyleSheet !== "function" || !("adoptedStyleSheets" in document)) return;
207
+ try {
208
+ const sheet = new CSSStyleSheet();
209
+ sheet.replaceSync(rule);
210
+ document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];
211
+ } catch {
212
+ }
213
+ }
214
+
198
215
  // src/liquid.ts
199
216
  var SINK = 3;
200
217
  var lerp = (a, b, p) => a + (b - a) * p;
@@ -327,10 +344,12 @@ export {
327
344
  resolveSpring,
328
345
  resolveEasing,
329
346
  MEASURE_EVENT,
347
+ MOTION_ATTR,
330
348
  prefersReducedMotion,
331
349
  supportsWaapi,
332
350
  spring,
333
351
  clock,
352
+ ensureRule,
334
353
  lerp,
335
354
  clamp01,
336
355
  smooth,
package/dist/index.cjs CHANGED
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
23
  MEASURE_EVENT: () => MEASURE_EVENT,
24
+ MOTION_ATTR: () => MOTION_ATTR,
24
25
  attachCombobox: () => attachCombobox,
25
26
  attachDatePicker: () => attachDatePicker,
26
27
  attachDialog: () => attachDialog,
@@ -28,6 +29,7 @@ __export(index_exports, {
28
29
  attachMenu: () => attachMenu,
29
30
  attachPending: () => attachPending,
30
31
  attachPress: () => attachPress,
32
+ attachSheet: () => attachSheet,
31
33
  attachSkeleton: () => attachSkeleton,
32
34
  attachSlider: () => attachSlider,
33
35
  attachSwitch: () => attachSwitch,
@@ -98,7 +100,9 @@ function resolveEasing(e, fallback = "decelerate") {
98
100
  return e in tokens.easing ? tokens.easing[e] : e;
99
101
  }
100
102
  var MEASURE_EVENT = "fluxus:measure";
103
+ var MOTION_ATTR = "data-fx-motion";
101
104
  function prefersReducedMotion() {
105
+ if (typeof document !== "undefined" && document.documentElement?.getAttribute(MOTION_ATTR) === "reduced") return true;
102
106
  return typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
103
107
  }
104
108
  function supportsWaapi(el) {
@@ -1621,15 +1625,28 @@ var revealEffect = Object.assign(
1621
1625
  { gap: 6 }
1622
1626
  );
1623
1627
 
1628
+ // src/sheet.ts
1629
+ var MARK = "--fx-css";
1630
+ var fromPackage = false;
1631
+ var packageCss = () => fromPackage || (fromPackage = typeof getComputedStyle === "function" && getComputedStyle(document.documentElement).getPropertyValue(MARK).trim() !== "");
1632
+ function ensureRule(rule) {
1633
+ if (typeof document === "undefined" || packageCss()) return;
1634
+ if (typeof CSSStyleSheet !== "function" || !("adoptedStyleSheets" in document)) return;
1635
+ try {
1636
+ const sheet = new CSSStyleSheet();
1637
+ sheet.replaceSync(rule);
1638
+ document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];
1639
+ } catch {
1640
+ }
1641
+ }
1642
+
1624
1643
  // src/toplayer.ts
1625
1644
  var TOP_ATTR = "data-fx-top";
1626
1645
  var ruled = false;
1627
1646
  var topRule = () => {
1628
1647
  if (ruled) return;
1629
1648
  ruled = true;
1630
- const rule = document.createElement("style");
1631
- rule.textContent = `@layer fx.reset{:where([${TOP_ATTR}]){inset:auto;margin:0;border:0;padding:0;overflow:visible;color:inherit;background:none}}`;
1632
- document.head.insertBefore(rule, document.head.firstChild);
1649
+ ensureRule(`@layer fx.reset{:where([${TOP_ATTR}]){inset:auto;margin:0;border:0;padding:0;overflow:visible;color:inherit;background:none}}`);
1633
1650
  };
1634
1651
  var lift = (panel, up) => {
1635
1652
  if (panel.matches(":popover-open") === up) return;
@@ -2100,6 +2117,7 @@ function attachSlider(input, options = {}) {
2100
2117
  }
2101
2118
 
2102
2119
  // src/datepicker.ts
2120
+ var attr = (text) => text.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;");
2103
2121
  var DAY = 864e5;
2104
2122
  var ms = (iso2) => Date.UTC(+iso2.slice(0, 4), +iso2.slice(5, 7) - 1, +iso2.slice(8, 10));
2105
2123
  var iso = (t) => new Date(t).toISOString().slice(0, 10);
@@ -2141,7 +2159,7 @@ function attachDatePicker(button, panel, options = {}) {
2141
2159
  panel.hidden = false;
2142
2160
  button.setAttribute("aria-haspopup", "dialog");
2143
2161
  button.setAttribute("aria-expanded", "false");
2144
- const nav = (to, label) => `<button type="button" class="fx-date__nav" data-to="${to}" aria-label="${label}">${chevron(to < 0 ? "M10 3.5 5.5 8l4.5 4.5" : "M6 3.5 10.5 8 6 12.5")}</button>`;
2162
+ const nav = (to, label) => `<button type="button" class="fx-date__nav" data-to="${to}" aria-label="${attr(label)}">${chevron(to < 0 ? "M10 3.5 5.5 8l4.5 4.5" : "M6 3.5 10.5 8 6 12.5")}</button>`;
2145
2163
  panel.innerHTML = `<div class="fx-date__head">${nav(-1, options.labels?.previous ?? "Previous month")}<span class="fx-date__month" id="${id}-month" aria-live="polite"></span>${nav(1, options.labels?.next ?? "Next month")}</div><div class="fx-date__row" aria-hidden="true">${[0, 1, 2, 3, 4, 5, 6].map((i) => `<span class="fx-date__dow">${shortDay.format(ms(add(startOf(today), i)))}</span>`).join("")}</div><div class="fx-date__body"></div>`;
2146
2164
  const monthEl = panel.querySelector(".fx-date__month");
2147
2165
  const body = panel.querySelector(".fx-date__body");
@@ -2180,7 +2198,7 @@ function attachDatePicker(button, panel, options = {}) {
2180
2198
  for (const d of days) {
2181
2199
  const on = week ? row === chosen : d === chosen;
2182
2200
  const marked = busy || marks.has(d);
2183
- html += `<span role="gridcell" aria-selected="${on}"><button type="button" class="fx-date__day" data-date="${d}" tabindex="${d === focus ? 0 : -1}" aria-label="${dayName.format(ms(d))}${marked && options.labels?.marked ? `, ${options.labels.marked}` : ""}"${marked ? " data-marked" : ""}${d === today ? ' aria-current="date"' : ""}${d.slice(0, 7) !== start.slice(0, 7) ? " data-outside" : ""}${out(d) ? ' aria-disabled="true"' : ""}>${+d.slice(8)}</button></span>`;
2201
+ html += `<span role="gridcell" aria-selected="${on}"><button type="button" class="fx-date__day" data-date="${d}" tabindex="${d === focus ? 0 : -1}" aria-label="${dayName.format(ms(d))}${marked && options.labels?.marked ? `, ${attr(options.labels.marked)}` : ""}"${marked ? " data-marked" : ""}${d === today ? ' aria-current="date"' : ""}${d.slice(0, 7) !== start.slice(0, 7) ? " data-outside" : ""}${out(d) ? ' aria-disabled="true"' : ""}>${+d.slice(8)}</button></span>`;
2184
2202
  }
2185
2203
  html += "</div>";
2186
2204
  }
@@ -2611,6 +2629,111 @@ function attachDialog(trigger, dialog, options = {}) {
2611
2629
  };
2612
2630
  }
2613
2631
 
2632
+ // src/side-sheet.ts
2633
+ function attachSheet(trigger, dialog, options = {}) {
2634
+ if (typeof dialog.showModal !== "function") throw new Error("attachSheet: it needs a <dialog> element");
2635
+ const closeOnBackdrop = options.closeOnBackdrop ?? true;
2636
+ const preset = typeof options.spring === "string" ? options.spring : "smooth";
2637
+ const custom = typeof options.spring === "object" ? options.spring : {};
2638
+ let isOpen = false;
2639
+ let motion = null;
2640
+ let shown = 0;
2641
+ let towardsEnd = true;
2642
+ trigger.setAttribute("aria-expanded", "false");
2643
+ if (!trigger.hasAttribute("aria-haspopup")) trigger.setAttribute("aria-haspopup", "dialog");
2644
+ dialog.dataset.fxSide = options.side ?? "end";
2645
+ const paint = (at) => {
2646
+ shown = at;
2647
+ dialog.style.translate = `${((1 - at) * 100 * (towardsEnd ? 1 : -1)).toFixed(2)}% 0`;
2648
+ dialog.style.setProperty("--fx-open", at.toFixed(3));
2649
+ };
2650
+ const rest = () => {
2651
+ dialog.style.removeProperty("translate");
2652
+ dialog.style.removeProperty("--fx-open");
2653
+ };
2654
+ const go = (to, done) => {
2655
+ if ((options.respectReducedMotion ?? true) && prefersReducedMotion()) {
2656
+ motion?.stop();
2657
+ paint(to);
2658
+ done?.();
2659
+ return;
2660
+ }
2661
+ if (motion && !motion.done) {
2662
+ motion.stop();
2663
+ }
2664
+ motion = spring({ ...custom, from: shown, to, velocity: motion?.velocity, preset, restDelta: 2e-3, onUpdate: paint, onRest: () => done?.() });
2665
+ };
2666
+ const open = () => {
2667
+ if (isOpen) return;
2668
+ isOpen = true;
2669
+ trigger.setAttribute("aria-expanded", "true");
2670
+ if (!dialog.open) {
2671
+ towardsEnd = dialog.dataset.fxSide === "end" !== (getComputedStyle(dialog).direction === "rtl");
2672
+ paint(0);
2673
+ dialog.showModal();
2674
+ }
2675
+ go(1, () => {
2676
+ if (isOpen) rest();
2677
+ });
2678
+ options.onOpenChange?.(true);
2679
+ };
2680
+ const close = () => {
2681
+ if (!isOpen) return;
2682
+ isOpen = false;
2683
+ trigger.setAttribute("aria-expanded", "false");
2684
+ go(0, () => {
2685
+ if (isOpen) return;
2686
+ if (dialog.open) dialog.close();
2687
+ rest();
2688
+ });
2689
+ options.onOpenChange?.(false);
2690
+ };
2691
+ const onTrigger = () => open();
2692
+ const onCancel = (e) => {
2693
+ e.preventDefault();
2694
+ close();
2695
+ };
2696
+ const onClick = (e) => {
2697
+ const target = e.target;
2698
+ if (target?.closest("[data-fx-close]")) {
2699
+ close();
2700
+ return;
2701
+ }
2702
+ if (!closeOnBackdrop || target !== dialog) return;
2703
+ const box = dialog.getBoundingClientRect();
2704
+ if (e.clientX < box.left || e.clientX > box.right || e.clientY < box.top || e.clientY > box.bottom) close();
2705
+ };
2706
+ const onClosed = () => {
2707
+ if (!isOpen) return;
2708
+ isOpen = false;
2709
+ motion?.stop();
2710
+ trigger.setAttribute("aria-expanded", "false");
2711
+ rest();
2712
+ options.onOpenChange?.(false);
2713
+ };
2714
+ trigger.addEventListener("click", onTrigger);
2715
+ dialog.addEventListener("cancel", onCancel);
2716
+ dialog.addEventListener("click", onClick);
2717
+ dialog.addEventListener("close", onClosed);
2718
+ return {
2719
+ get isOpen() {
2720
+ return isOpen;
2721
+ },
2722
+ open,
2723
+ close,
2724
+ destroy() {
2725
+ motion?.stop();
2726
+ trigger.removeEventListener("click", onTrigger);
2727
+ dialog.removeEventListener("cancel", onCancel);
2728
+ dialog.removeEventListener("click", onClick);
2729
+ dialog.removeEventListener("close", onClosed);
2730
+ rest();
2731
+ trigger.removeAttribute("aria-expanded");
2732
+ delete dialog.dataset.fxSide;
2733
+ }
2734
+ };
2735
+ }
2736
+
2614
2737
  // src/liquid.ts
2615
2738
  var SINK = 3;
2616
2739
  var lerp = (a, b, p) => a + (b - a) * p;
@@ -3163,9 +3286,7 @@ var unclipRuled = false;
3163
3286
  var unclipRule = () => {
3164
3287
  if (unclipRuled) return;
3165
3288
  unclipRuled = true;
3166
- const rule = document.createElement("style");
3167
- rule.textContent = `[${UNCLIP_ATTR}]{overflow:visible!important}`;
3168
- document.head.appendChild(rule);
3289
+ ensureRule(`[${UNCLIP_ATTR}]{overflow:visible!important}`);
3169
3290
  };
3170
3291
  var engines = /* @__PURE__ */ new Set();
3171
3292
  var stagings = 0;
@@ -5140,6 +5261,7 @@ ${el.getAttribute(partAttr) ?? ""}` : null,
5140
5261
  // Annotate the CommonJS export names for ESM import in node:
5141
5262
  0 && (module.exports = {
5142
5263
  MEASURE_EVENT,
5264
+ MOTION_ATTR,
5143
5265
  attachCombobox,
5144
5266
  attachDatePicker,
5145
5267
  attachDialog,
@@ -5147,6 +5269,7 @@ ${el.getAttribute(partAttr) ?? ""}` : null,
5147
5269
  attachMenu,
5148
5270
  attachPending,
5149
5271
  attachPress,
5272
+ attachSheet,
5150
5273
  attachSkeleton,
5151
5274
  attachSlider,
5152
5275
  attachSwitch,
package/dist/index.d.cts CHANGED
@@ -1,2 +1,2 @@
1
- export { C as CellLayoutHandle, b as CellLayoutOptions, E as EasingToken, M as MEASURE_EVENT, P as PlayOptions, S as SpringConfig, a as SpringPreset, d as createCellLayout, l as layoutTransaction, p as prefersReducedMotion, r as resolveEasing, c as resolveSpring, s as supportsWaapi, t as tokens } from './cells-C1fRmU7p.cjs';
2
- export { Bud, BudOptions, ClockOptions, ComboboxHandle, ComboboxOptions, CounterHandle, CounterOptions, DatePickerHandle, DatePickerOptions, DialogHandle, DialogOptions, IndicatorHandle, IndicatorOptions, LayoutCellDoc, LayoutDoc, MenuHandle, MenuOptions, MenuPlacement, MorphHandle, MorphOptions, PendingHandle, PendingOptions, PressHandle, PressOptions, SkeletonHandle, SkeletonOptions, SliderHandle, SliderOptions, SpringHandle, SpringOptions, StaggerOptions, StaggerOutOptions, SwapDirection, SwapHandle, SwapOptions, SwitchHandle, SwitchOptions, TableSort, TooltipEffect, TooltipHandle, TooltipOptions, TooltipPlacement, attachCombobox, attachDatePicker, attachDialog, attachIndicator, attachMenu, attachPending, attachPress, attachSkeleton, attachSlider, attachSwitch, attachTooltip, budEffect, clock, createBud, createCounter, createMorph, createSwap, layoutCellAttrs, layoutCellStyle, layoutContainerStyle, nextSort, reorder, revealEffect, sortRows, spring, staggerIn, staggerOut } from './base.cjs';
1
+ export { C as CellLayoutHandle, b as CellLayoutOptions, E as EasingToken, M as MEASURE_EVENT, c as MOTION_ATTR, P as PlayOptions, S as SpringConfig, a as SpringPreset, e as createCellLayout, l as layoutTransaction, p as prefersReducedMotion, r as resolveEasing, d as resolveSpring, s as supportsWaapi, t as tokens } from './cells-_RHBATKa.cjs';
2
+ export { Bud, BudOptions, ClockOptions, ComboboxHandle, ComboboxOptions, CounterHandle, CounterOptions, DatePickerHandle, DatePickerOptions, DialogHandle, DialogOptions, IndicatorHandle, IndicatorOptions, LayoutCellDoc, LayoutDoc, MenuHandle, MenuOptions, MenuPlacement, MorphHandle, MorphOptions, PendingHandle, PendingOptions, PressHandle, PressOptions, SheetHandle, SheetOptions, SkeletonHandle, SkeletonOptions, SliderHandle, SliderOptions, SpringHandle, SpringOptions, StaggerOptions, StaggerOutOptions, SwapDirection, SwapHandle, SwapOptions, SwitchHandle, SwitchOptions, TableSort, TooltipEffect, TooltipHandle, TooltipOptions, TooltipPlacement, attachCombobox, attachDatePicker, attachDialog, attachIndicator, attachMenu, attachPending, attachPress, attachSheet, attachSkeleton, attachSlider, attachSwitch, attachTooltip, budEffect, clock, createBud, createCounter, createMorph, createSwap, layoutCellAttrs, layoutCellStyle, layoutContainerStyle, nextSort, reorder, revealEffect, sortRows, spring, staggerIn, staggerOut } from './base.cjs';
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { C as CellLayoutHandle, b as CellLayoutOptions, E as EasingToken, M as MEASURE_EVENT, P as PlayOptions, S as SpringConfig, a as SpringPreset, d as createCellLayout, l as layoutTransaction, p as prefersReducedMotion, r as resolveEasing, c as resolveSpring, s as supportsWaapi, t as tokens } from './cells-C1fRmU7p.js';
2
- export { Bud, BudOptions, ClockOptions, ComboboxHandle, ComboboxOptions, CounterHandle, CounterOptions, DatePickerHandle, DatePickerOptions, DialogHandle, DialogOptions, IndicatorHandle, IndicatorOptions, LayoutCellDoc, LayoutDoc, MenuHandle, MenuOptions, MenuPlacement, MorphHandle, MorphOptions, PendingHandle, PendingOptions, PressHandle, PressOptions, SkeletonHandle, SkeletonOptions, SliderHandle, SliderOptions, SpringHandle, SpringOptions, StaggerOptions, StaggerOutOptions, SwapDirection, SwapHandle, SwapOptions, SwitchHandle, SwitchOptions, TableSort, TooltipEffect, TooltipHandle, TooltipOptions, TooltipPlacement, attachCombobox, attachDatePicker, attachDialog, attachIndicator, attachMenu, attachPending, attachPress, attachSkeleton, attachSlider, attachSwitch, attachTooltip, budEffect, clock, createBud, createCounter, createMorph, createSwap, layoutCellAttrs, layoutCellStyle, layoutContainerStyle, nextSort, reorder, revealEffect, sortRows, spring, staggerIn, staggerOut } from './base.js';
1
+ export { C as CellLayoutHandle, b as CellLayoutOptions, E as EasingToken, M as MEASURE_EVENT, c as MOTION_ATTR, P as PlayOptions, S as SpringConfig, a as SpringPreset, e as createCellLayout, l as layoutTransaction, p as prefersReducedMotion, r as resolveEasing, d as resolveSpring, s as supportsWaapi, t as tokens } from './cells-_RHBATKa.js';
2
+ export { Bud, BudOptions, ClockOptions, ComboboxHandle, ComboboxOptions, CounterHandle, CounterOptions, DatePickerHandle, DatePickerOptions, DialogHandle, DialogOptions, IndicatorHandle, IndicatorOptions, LayoutCellDoc, LayoutDoc, MenuHandle, MenuOptions, MenuPlacement, MorphHandle, MorphOptions, PendingHandle, PendingOptions, PressHandle, PressOptions, SheetHandle, SheetOptions, SkeletonHandle, SkeletonOptions, SliderHandle, SliderOptions, SpringHandle, SpringOptions, StaggerOptions, StaggerOutOptions, SwapDirection, SwapHandle, SwapOptions, SwitchHandle, SwitchOptions, TableSort, TooltipEffect, TooltipHandle, TooltipOptions, TooltipPlacement, attachCombobox, attachDatePicker, attachDialog, attachIndicator, attachMenu, attachPending, attachPress, attachSheet, attachSkeleton, attachSlider, attachSwitch, attachTooltip, budEffect, clock, createBud, createCounter, createMorph, createSwap, layoutCellAttrs, layoutCellStyle, layoutContainerStyle, nextSort, reorder, revealEffect, sortRows, spring, staggerIn, staggerOut } from './base.js';
package/dist/index.js CHANGED
@@ -6,6 +6,7 @@ import {
6
6
  attachMenu,
7
7
  attachPending,
8
8
  attachPress,
9
+ attachSheet,
9
10
  attachSkeleton,
10
11
  attachSlider,
11
12
  attachSwitch,
@@ -24,13 +25,14 @@ import {
24
25
  sortRows,
25
26
  staggerIn,
26
27
  staggerOut
27
- } from "./chunk-O7KUU7VB.js";
28
+ } from "./chunk-P46FNWIK.js";
28
29
  import {
29
30
  createCellLayout,
30
31
  layoutTransaction
31
- } from "./chunk-JQ73ETUC.js";
32
+ } from "./chunk-L3APQ24V.js";
32
33
  import {
33
34
  MEASURE_EVENT,
35
+ MOTION_ATTR,
34
36
  clock,
35
37
  prefersReducedMotion,
36
38
  resolveEasing,
@@ -38,9 +40,10 @@ import {
38
40
  spring,
39
41
  supportsWaapi,
40
42
  tokens
41
- } from "./chunk-LCXYNLM7.js";
43
+ } from "./chunk-RMSWZ2JF.js";
42
44
  export {
43
45
  MEASURE_EVENT,
46
+ MOTION_ATTR,
44
47
  attachCombobox,
45
48
  attachDatePicker,
46
49
  attachDialog,
@@ -48,6 +51,7 @@ export {
48
51
  attachMenu,
49
52
  attachPending,
50
53
  attachPress,
54
+ attachSheet,
51
55
  attachSkeleton,
52
56
  attachSlider,
53
57
  attachSwitch,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluxus-ui/core",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "description": "Fluent Motion / Dynamic UI primitives: layout morphing, staggered entrances, physical press feedback. Zero dependencies.",
5
5
  "license": "MIT",
6
6
  "author": "Jhony0709 (https://github.com/Jhony0709)",