@plexui/vue 0.41.1 → 0.42.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.
Files changed (87) hide show
  1. package/dist/es/components/Accordion/Accordion.js +18 -0
  2. package/dist/es/components/Accordion/Accordion.js.map +1 -1
  3. package/dist/es/components/Button/NavigationButton.js +13 -2
  4. package/dist/es/components/Button/NavigationButton.js.map +1 -1
  5. package/dist/es/components/Dialog/Dialog.js +47 -3
  6. package/dist/es/components/Dialog/Dialog.js.map +1 -1
  7. package/dist/es/components/Dialog/sheetDrag.js +45 -12
  8. package/dist/es/components/Dialog/sheetDrag.js.map +1 -1
  9. package/dist/es/components/Field/Field.js +32 -3
  10. package/dist/es/components/Field/Field.js.map +1 -1
  11. package/dist/es/components/Icon/svg/Array.js +4 -4
  12. package/dist/es/components/Icon/svg/Array.js.map +1 -1
  13. package/dist/es/components/Icon/svg/Boolean.js +4 -4
  14. package/dist/es/components/Icon/svg/Boolean.js.map +1 -1
  15. package/dist/es/components/Icon/svg/Clipboard.js +4 -4
  16. package/dist/es/components/Icon/svg/Clipboard.js.map +1 -1
  17. package/dist/es/components/Icon/svg/Comment.js +4 -4
  18. package/dist/es/components/Icon/svg/Comment.js.map +1 -1
  19. package/dist/es/components/Icon/svg/Error.js +4 -4
  20. package/dist/es/components/Icon/svg/Error.js.map +1 -1
  21. package/dist/es/components/Icon/svg/Function.js +4 -4
  22. package/dist/es/components/Icon/svg/Function.js.map +1 -1
  23. package/dist/es/components/Icon/svg/Number.js +4 -4
  24. package/dist/es/components/Icon/svg/Number.js.map +1 -1
  25. package/dist/es/components/Icon/svg/Object.js +4 -4
  26. package/dist/es/components/Icon/svg/Object.js.map +1 -1
  27. package/dist/es/components/Icon/svg/Report.js +4 -4
  28. package/dist/es/components/Icon/svg/Report.js.map +1 -1
  29. package/dist/es/components/Icon/svg/Storage.js +4 -4
  30. package/dist/es/components/Icon/svg/Storage.js.map +1 -1
  31. package/dist/es/components/Icon/svg/String.js +4 -4
  32. package/dist/es/components/Icon/svg/String.js.map +1 -1
  33. package/dist/es/components/Icon/svg/Text.js +4 -4
  34. package/dist/es/components/Icon/svg/Text.js.map +1 -1
  35. package/dist/es/components/Menu/Menu.js +29 -2
  36. package/dist/es/components/Menu/Menu.js.map +1 -1
  37. package/dist/es/components/PlexUIProvider/PlexUIProvider.js +43 -3
  38. package/dist/es/components/PlexUIProvider/PlexUIProvider.js.map +1 -1
  39. package/dist/es/components/PlexUIProvider/androidRipple.js +98 -0
  40. package/dist/es/components/PlexUIProvider/androidRipple.js.map +1 -0
  41. package/dist/es/components/PlexUIProvider/index.js.map +1 -1
  42. package/dist/es/components/Select/Select.js +364 -22
  43. package/dist/es/components/Select/Select.js.map +1 -1
  44. package/dist/es/components/Sidebar/Sidebar.js +8 -1
  45. package/dist/es/components/Sidebar/Sidebar.js.map +1 -1
  46. package/dist/es/components/Sidebar/index.js +1 -1
  47. package/dist/es/components/Sidebar/index.js.map +1 -1
  48. package/dist/es/components/Toolbar/Toolbar.js +276 -17
  49. package/dist/es/components/Toolbar/Toolbar.js.map +1 -1
  50. package/dist/es/components/Toolbar/index.js.map +1 -1
  51. package/dist/es/lib/accordionMotion.js +144 -0
  52. package/dist/es/lib/accordionMotion.js.map +1 -0
  53. package/dist/es/lib/fieldRow.js +54 -0
  54. package/dist/es/lib/fieldRow.js.map +1 -1
  55. package/dist/es/lib/presentMotion.js +151 -0
  56. package/dist/es/lib/presentMotion.js.map +1 -0
  57. package/dist/types/components/Button/NavigationButton.d.ts +30 -1
  58. package/dist/types/components/ContextMenu/ContextMenu.d.ts +8 -8
  59. package/dist/types/components/Field/Field.d.ts +12 -2
  60. package/dist/types/components/FloatingLabelSelect/FloatingLabelSelect.d.ts +1 -1
  61. package/dist/types/components/Icon/svg/Array.d.ts +2 -2
  62. package/dist/types/components/Icon/svg/Boolean.d.ts +2 -2
  63. package/dist/types/components/Icon/svg/Clipboard.d.ts +2 -2
  64. package/dist/types/components/Icon/svg/Comment.d.ts +2 -2
  65. package/dist/types/components/Icon/svg/Error.d.ts +2 -2
  66. package/dist/types/components/Icon/svg/Function.d.ts +2 -2
  67. package/dist/types/components/Icon/svg/Number.d.ts +2 -2
  68. package/dist/types/components/Icon/svg/Object.d.ts +2 -2
  69. package/dist/types/components/Icon/svg/Report.d.ts +2 -2
  70. package/dist/types/components/Icon/svg/Storage.d.ts +2 -2
  71. package/dist/types/components/Icon/svg/String.d.ts +2 -2
  72. package/dist/types/components/Icon/svg/Text.d.ts +2 -2
  73. package/dist/types/components/PlexUIProvider/PlexUIProvider.d.ts +20 -3
  74. package/dist/types/components/PlexUIProvider/androidRipple.d.ts +9 -0
  75. package/dist/types/components/PlexUIProvider/index.d.ts +1 -1
  76. package/dist/types/components/Select/Select.d.ts +51 -0
  77. package/dist/types/components/Sidebar/Sidebar.d.ts +20 -0
  78. package/dist/types/components/Sidebar/index.d.ts +2 -2
  79. package/dist/types/components/Sidebar/useSidebarContext.d.ts +1 -1
  80. package/dist/types/components/TabBar/TabBar.d.ts +4 -4
  81. package/dist/types/components/Toast/Toaster.d.ts +1 -1
  82. package/dist/types/components/Toolbar/Toolbar.d.ts +49 -12
  83. package/dist/types/components/Toolbar/index.d.ts +1 -1
  84. package/dist/types/lib/accordionMotion.d.ts +20 -0
  85. package/dist/types/lib/fieldRow.d.ts +12 -0
  86. package/dist/types/lib/presentMotion.d.ts +46 -0
  87. package/package.json +2 -2
@@ -0,0 +1,144 @@
1
+ /**
2
+ * An Accordion item opens and closes as an iOS 27.2 DisclosureGroup: the panel takes its height at once, its content
3
+ * shows through a clip that grows down from the trigger (the CSS keyframes of the panel), and what follows the item
4
+ * slides down into place, or up when it closes, by a transform. The page lays out once per toggle, not once a frame.
5
+ *
6
+ * The panel's `data-state` changing (or an open panel being inserted, as `asChild` does) is the toggle: a
7
+ * MutationObserver sees it after the framework has updated the DOM and before the frame paints, so the panel's height
8
+ * is known and what follows can be moved back to where it was, then let go. Each move is added to what the element
9
+ * already does (`composite: "add"`), so one item closing while another opens, a nested item inside a moving one, or a
10
+ * quick second toggle all sum to where the layout puts things. Time and curve are the panel's
11
+ * `--accordion-motion-duration` and `--accordion-motion-easing`, which its keyframes use too. With reduced motion,
12
+ * or a zero duration, nothing moves.
13
+ */
14
+ const toMilliseconds = (value) => {
15
+ const number = parseFloat(value);
16
+ if (!Number.isFinite(number))
17
+ return 0;
18
+ return value.trim().endsWith("ms") ? number : number * 1000;
19
+ };
20
+ /** The elements that follow an item, up to the outermost Accordion it is in: what moves when its panel resizes. */
21
+ const followersOf = (item, rootClass) => {
22
+ let top = item.closest(`.${rootClass}`);
23
+ while (top?.parentElement?.closest(`.${rootClass}`))
24
+ top = top.parentElement.closest(`.${rootClass}`);
25
+ const followers = [];
26
+ for (let node = item; node && node !== top; node = node.parentElement) {
27
+ for (let sibling = node.nextElementSibling; sibling; sibling = sibling.nextElementSibling) {
28
+ if (sibling instanceof HTMLElement)
29
+ followers.push(sibling);
30
+ }
31
+ }
32
+ return followers;
33
+ };
34
+ export function attachAccordionMotion(root, classes) {
35
+ if (typeof MutationObserver === "undefined" || typeof window === "undefined")
36
+ return () => { };
37
+ const all = new Set();
38
+ const closing = new Map();
39
+ const stopAll = () => {
40
+ for (const entry of [...closing.values()])
41
+ entry.release(true);
42
+ for (const animation of [...all])
43
+ animation.cancel();
44
+ all.clear();
45
+ };
46
+ const track = (animation) => {
47
+ all.add(animation);
48
+ const forget = () => all.delete(animation);
49
+ animation.addEventListener("finish", forget);
50
+ animation.addEventListener("cancel", forget);
51
+ return animation;
52
+ };
53
+ const toggle = (panel, opening) => {
54
+ const item = panel.parentElement;
55
+ if (!item?.classList.contains(classes.item) || typeof item.animate !== "function")
56
+ return;
57
+ // Opened again while it closes: its moves turn back to where they started, and nothing else is needed, as the
58
+ // panel never left the layout
59
+ const pending = closing.get(panel);
60
+ if (pending) {
61
+ if (opening) {
62
+ pending.release(false);
63
+ for (const animation of pending.animations) {
64
+ animation.reverse();
65
+ animation.addEventListener("finish", () => animation.cancel());
66
+ }
67
+ return;
68
+ }
69
+ pending.release(true);
70
+ }
71
+ const height = panel.getBoundingClientRect().height;
72
+ const style = getComputedStyle(panel);
73
+ const duration = toMilliseconds(style.getPropertyValue("--accordion-motion-duration"));
74
+ const easing = style.getPropertyValue("--accordion-motion-easing").trim() || "ease";
75
+ if (!height || !duration)
76
+ return;
77
+ const shift = { transform: `translateY(${-height}px)` };
78
+ const animations = followersOf(item, classes.root).map((follower) => track(follower.animate(opening ? [shift, { transform: "none" }] : [{ transform: "none" }, shift], {
79
+ duration,
80
+ easing,
81
+ composite: "add",
82
+ // Closing, what follows holds its place over the closed panel until the panel leaves the layout
83
+ fill: opening ? "none" : "forwards",
84
+ })));
85
+ if (opening || animations.length === 0)
86
+ return;
87
+ // The panel hides when its closing keyframes end; then what follows lets go of the shift, which the layout
88
+ // now gives it. A timer covers a panel whose animation never ends (removed, or its keyframes overridden).
89
+ let timer = 0;
90
+ const onEnd = (event) => {
91
+ if (event.target === panel)
92
+ entry.release(true);
93
+ };
94
+ const entry = {
95
+ animations,
96
+ release: (cancel) => {
97
+ window.clearTimeout(timer);
98
+ panel.removeEventListener("animationend", onEnd);
99
+ if (closing.get(panel) === entry)
100
+ closing.delete(panel);
101
+ if (cancel)
102
+ for (const animation of animations)
103
+ animation.cancel();
104
+ },
105
+ };
106
+ panel.addEventListener("animationend", onEnd);
107
+ timer = window.setTimeout(() => entry.release(true), duration + 100);
108
+ closing.set(panel, entry);
109
+ };
110
+ const isOwnPanel = (node) => node instanceof HTMLElement &&
111
+ node.classList.contains(classes.content) &&
112
+ node.closest(`.${classes.root}`) === root;
113
+ const observer = new MutationObserver((records) => {
114
+ if (window.matchMedia?.("(prefers-reduced-motion: reduce)").matches) {
115
+ stopAll();
116
+ return;
117
+ }
118
+ for (const record of records) {
119
+ if (record.type === "attributes") {
120
+ const panel = record.target;
121
+ if (isOwnPanel(panel) && record.oldValue !== panel.dataset.state)
122
+ toggle(panel, panel.dataset.state === "open");
123
+ continue;
124
+ }
125
+ // A panel rendered only while open (`asChild`) arrives open
126
+ for (const node of record.addedNodes) {
127
+ if (isOwnPanel(node) && node.dataset.state === "open")
128
+ toggle(node, true);
129
+ }
130
+ }
131
+ });
132
+ observer.observe(root, {
133
+ subtree: true,
134
+ childList: true,
135
+ attributes: true,
136
+ attributeFilter: ["data-state"],
137
+ attributeOldValue: true,
138
+ });
139
+ return () => {
140
+ observer.disconnect();
141
+ stopAll();
142
+ };
143
+ }
144
+ //# sourceMappingURL=accordionMotion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accordionMotion.js","sourceRoot":"","sources":["../../../src/lib/accordionMotion.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,MAAM,cAAc,GAAG,CAAC,KAAa,EAAE,EAAE;IACvC,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,CAAC,CAAA;IAChC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,CAAC,CAAA;IACtC,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,GAAG,IAAI,CAAA;AAC7D,CAAC,CAAA;AAED,mHAAmH;AACnH,MAAM,WAAW,GAAG,CAAC,IAAiB,EAAE,SAAiB,EAAE,EAAE;IAC3D,IAAI,GAAG,GAAuB,IAAI,CAAC,OAAO,CAAc,IAAI,SAAS,EAAE,CAAC,CAAA;IACxE,OAAO,GAAG,EAAE,aAAa,EAAE,OAAO,CAAC,IAAI,SAAS,EAAE,CAAC;QAAE,GAAG,GAAG,GAAG,CAAC,aAAa,CAAC,OAAO,CAAc,IAAI,SAAS,EAAE,CAAC,CAAA;IAClH,MAAM,SAAS,GAAkB,EAAE,CAAA;IACnC,KAAK,IAAI,IAAI,GAAmB,IAAI,EAAE,IAAI,IAAI,IAAI,KAAK,GAAG,EAAE,IAAI,GAAG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AO,CAAC,IAAI,EAAE;QACrB,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,IAAI;QACf,UAAU,EAAE,IAAI;QAChB,eAAe,EAAE,CAAC,YAAY,CAAC;QAC/B,iBAAiB,EAAE,IAAI;KACxB,CAAC,CAAA;IAEF,OAAO,GAAG,EAAE;QACV,QAAQ,CAAC,UAAU,EAAE,CAAA;QACrB,OAAO,EAAE,CAAA;IACX,CAAC,CAAA;AACH,CAAC","sourcesContent":["/**\n * An Accordion item opens and closes as an iOS 27.2 DisclosureGroup: the panel takes its height at once, its content\n * shows through a clip that grows down from the trigger (the CSS keyframes of the panel), and what follows the item\n * slides down into place, or up when it closes, by a transform. The page lays out once per toggle, not once a frame.\n *\n * The panel's `data-state` changing (or an open panel being inserted, as `asChild` does) is the toggle: a\n * MutationObserver sees it after the framework has updated the DOM and before the frame paints, so the panel's height\n * is known and what follows can be moved back to where it was, then let go. Each move is added to what the element\n * already does (`composite: \"add\"`), so one item closing while another opens, a nested item inside a moving one, or a\n * quick second toggle all sum to where the layout puts things. Time and curve are the panel's\n * `--accordion-motion-duration` and `--accordion-motion-easing`, which its keyframes use too. With reduced motion,\n * or a zero duration, nothing moves.\n */\n\ntype Classes = { root: string; item: string; content: string }\n\nconst toMilliseconds = (value: string) => {\n const number = parseFloat(value)\n if (!Number.isFinite(number)) return 0\n return value.trim().endsWith(\"ms\") ? number : number * 1000\n}\n\n/** The elements that follow an item, up to the outermost Accordion it is in: what moves when its panel resizes. */\nconst followersOf = (item: HTMLElement, rootClass: string) => {\n let top: HTMLElement | null = item.closest<HTMLElement>(`.${rootClass}`)\n while (top?.parentElement?.closest(`.${rootClass}`)) top = top.parentElement.closest<HTMLElement>(`.${rootClass}`)\n const followers: HTMLElement[] = []\n for (let node: Element | null = item; node && node !== top; node = node.parentElement) {\n for (let sibling = node.nextElementSibling; sibling; sibling = sibling.nextElementSibling) {\n if (sibling instanceof HTMLElement) followers.push(sibling)\n }\n }\n return followers\n}\n\n/** A closing panel's moves, held until the panel leaves the layout. */\ntype Closing = { animations: Animation[]; release: (cancel: boolean) => void }\n\nexport function attachAccordionMotion(root: HTMLElement, classes: Classes): () => void {\n if (typeof MutationObserver === \"undefined\" || typeof window === \"undefined\") return () => {}\n const all = new Set<Animation>()\n const closing = new Map<HTMLElement, Closing>()\n\n const stopAll = () => {\n for (const entry of [...closing.values()]) entry.release(true)\n for (const animation of [...all]) animation.cancel()\n all.clear()\n }\n\n const track = (animation: Animation) => {\n all.add(animation)\n const forget = () => all.delete(animation)\n animation.addEventListener(\"finish\", forget)\n animation.addEventListener(\"cancel\", forget)\n return animation\n }\n\n const toggle = (panel: HTMLElement, opening: boolean) => {\n const item = panel.parentElement\n if (!item?.classList.contains(classes.item) || typeof item.animate !== \"function\") return\n\n // Opened again while it closes: its moves turn back to where they started, and nothing else is needed, as the\n // panel never left the layout\n const pending = closing.get(panel)\n if (pending) {\n if (opening) {\n pending.release(false)\n for (const animation of pending.animations) {\n animation.reverse()\n animation.addEventListener(\"finish\", () => animation.cancel())\n }\n return\n }\n pending.release(true)\n }\n\n const height = panel.getBoundingClientRect().height\n const style = getComputedStyle(panel)\n const duration = toMilliseconds(style.getPropertyValue(\"--accordion-motion-duration\"))\n const easing = style.getPropertyValue(\"--accordion-motion-easing\").trim() || \"ease\"\n if (!height || !duration) return\n\n const shift = { transform: `translateY(${-height}px)` }\n const animations = followersOf(item, classes.root).map((follower) =>\n track(\n follower.animate(opening ? [shift, { transform: \"none\" }] : [{ transform: \"none\" }, shift], {\n duration,\n easing,\n composite: \"add\",\n // Closing, what follows holds its place over the closed panel until the panel leaves the layout\n fill: opening ? \"none\" : \"forwards\",\n }),\n ),\n )\n if (opening || animations.length === 0) return\n\n // The panel hides when its closing keyframes end; then what follows lets go of the shift, which the layout\n // now gives it. A timer covers a panel whose animation never ends (removed, or its keyframes overridden).\n let timer = 0\n const onEnd = (event: AnimationEvent) => {\n if (event.target === panel) entry.release(true)\n }\n const entry: Closing = {\n animations,\n release: (cancel) => {\n window.clearTimeout(timer)\n panel.removeEventListener(\"animationend\", onEnd)\n if (closing.get(panel) === entry) closing.delete(panel)\n if (cancel) for (const animation of animations) animation.cancel()\n },\n }\n panel.addEventListener(\"animationend\", onEnd)\n timer = window.setTimeout(() => entry.release(true), duration + 100)\n closing.set(panel, entry)\n }\n\n const isOwnPanel = (node: Node): node is HTMLElement =>\n node instanceof HTMLElement &&\n node.classList.contains(classes.content) &&\n node.closest(`.${classes.root}`) === root\n\n const observer = new MutationObserver((records) => {\n if (window.matchMedia?.(\"(prefers-reduced-motion: reduce)\").matches) {\n stopAll()\n return\n }\n for (const record of records) {\n if (record.type === \"attributes\") {\n const panel = record.target\n if (isOwnPanel(panel) && record.oldValue !== panel.dataset.state) toggle(panel, panel.dataset.state === \"open\")\n continue\n }\n // A panel rendered only while open (`asChild`) arrives open\n for (const node of record.addedNodes) {\n if (isOwnPanel(node) && node.dataset.state === \"open\") toggle(node, true)\n }\n }\n })\n observer.observe(root, {\n subtree: true,\n childList: true,\n attributes: true,\n attributeFilter: [\"data-state\"],\n attributeOldValue: true,\n })\n\n return () => {\n observer.disconnect()\n stopAll()\n }\n}\n"]}
@@ -25,4 +25,58 @@ export const useFieldRowPill = (pill) => {
25
25
  const inRow = useFieldRow();
26
26
  return computed(() => pill() ?? inRow.value);
27
27
  };
28
+ const ANDROID_LOOK = '[data-platform="android"]';
29
+ const BLANK = " ";
30
+ /**
31
+ * In the Plex Android look a text field under its label (a vertical `Field row` with the label shown) is a field of
32
+ * an input card: the label stands in the field while it is empty, which the styles tell by `:placeholder-shown`. That
33
+ * needs a placeholder, so there a field without one gets a blank one; elsewhere (iOS, the desktop) nothing is added.
34
+ * `start` gives it and follows the platform and the field's own placeholder, `sync` checks again after a render,
35
+ * `stop` takes it back.
36
+ */
37
+ export function blankPlaceholder(controlId) {
38
+ let given = null;
39
+ let observer = null;
40
+ const release = () => {
41
+ if (given?.getAttribute("placeholder") === BLANK)
42
+ given.removeAttribute("placeholder");
43
+ given = null;
44
+ };
45
+ let watched = null;
46
+ const sync = () => {
47
+ if (typeof document === "undefined")
48
+ return;
49
+ const control = document.getElementById(controlId());
50
+ // Watch only this field's own placeholder (and, from `start`, the root's platform), never the whole document
51
+ if (observer && control && control !== watched) {
52
+ observer.observe(control, { attributes: true, attributeFilter: ["placeholder"] });
53
+ watched = control;
54
+ }
55
+ const input = (control instanceof HTMLInputElement || control instanceof HTMLTextAreaElement) &&
56
+ control.matches('[data-slot="input"] > input, [data-slot="textarea"] > textarea') &&
57
+ control.closest(ANDROID_LOOK)
58
+ ? control
59
+ : null;
60
+ if (given && given !== input)
61
+ release();
62
+ if (input && !input.hasAttribute("placeholder")) {
63
+ input.setAttribute("placeholder", BLANK);
64
+ given = input;
65
+ }
66
+ };
67
+ const start = () => {
68
+ if (!observer && typeof MutationObserver !== "undefined" && typeof document !== "undefined") {
69
+ observer = new MutationObserver(sync);
70
+ observer.observe(document.documentElement, { attributes: true, attributeFilter: ["data-platform"] });
71
+ }
72
+ sync();
73
+ };
74
+ const stop = () => {
75
+ observer?.disconnect();
76
+ observer = null;
77
+ watched = null;
78
+ release();
79
+ };
80
+ return { start, sync, stop };
81
+ }
28
82
  //# sourceMappingURL=fieldRow.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fieldRow.js","sourceRoot":"","sources":["../../../src/lib/fieldRow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAuC,MAAM,KAAK,CAAA;AAEpF,+CAA+C;AAE/C;;;;GAIG;AACH,MAAM,WAAW,GAAuC,MAAM,CAAC,gBAAgB,CAAC,CAAA;AAEhF,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAoB,EAAE,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAA;AAE9F,gDAAgD;AAChD,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,EAAE;IAC9B,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,CAAA;IACvC,OAAO,QAAQ,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,KAAK,IAAI,KAAK,CAAC,CAAA;AAC9C,CAAC,CAAA;AAED,8EAA8E;AAC9E,MAAM,eAAe,GAAuC,MAAM,CAAC,oBAAoB,CAAC,CAAA;AAExF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,OAAsB,EAAE,EAAE,CAAC,OAAO,CAAC,eAAe,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAA;AAE1G,oFAAoF;AACpF,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE;IAClC,MAAM,OAAO,GAAG,MAAM,CAAC,eAAe,EAAE,IAAI,CAAC,CAAA;IAC7C,OAAO,QAAQ,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,KAAK,IAAI,KAAK,CAAC,CAAA;AAChD,CAAC,CAAA;AAED,8DAA8D;AAC9D,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAA+B,EAAE,EAAE;IACjE,MAAM,KAAK,GAAG,WAAW,EAAE,CAAA;IAC3B,OAAO,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,CAAC,KAAK,CAAC,CAAA;AAC9C,CAAC,CAAA","sourcesContent":["import { computed, inject, provide, type ComputedRef, type InjectionKey } from \"vue\"\n\n// Vue port of packages/ui/src/lib/fieldRow.ts.\n\n/**\n * True in a `Field row` whose control ends the row. It stands there beside\n * buttons and tags, so it takes their shape; a field with its label above stays\n * rounded.\n */\nconst FieldRowKey: InjectionKey<ComputedRef<boolean>> = Symbol(\"PlexUIFieldRow\")\n\nexport const provideFieldRow = (inRow: () => boolean) => provide(FieldRowKey, computed(inRow))\n\n/** True when the control ends a `Field row`. */\nexport const useFieldRow = () => {\n const inRow = inject(FieldRowKey, null)\n return computed(() => inRow?.value ?? false)\n}\n\n/** True in a `FieldGroup columns`, where every value starts at one column. */\nconst FieldColumnsKey: InjectionKey<ComputedRef<boolean>> = Symbol(\"PlexUIFieldColumns\")\n\nexport const provideFieldColumns = (columns: () => boolean) => provide(FieldColumnsKey, computed(columns))\n\n/** True when the control's value starts at the column of a `FieldGroup columns`. */\nexport const useFieldColumns = () => {\n const columns = inject(FieldColumnsKey, null)\n return computed(() => columns?.value ?? false)\n}\n\n/** The control's own `pill`, or else the shape of its row. */\nexport const useFieldRowPill = (pill: () => boolean | undefined) => {\n const inRow = useFieldRow()\n return computed(() => pill() ?? inRow.value)\n}\n"]}
1
+ {"version":3,"file":"fieldRow.js","sourceRoot":"","sources":["../../../src/lib/fieldRow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAuC,MAAM,KAAK,CAAA;AAEpF,+CAA+C;AAE/C;;;;GAIG;AACH,MAAM,WAAW,GAAuC,MAAM,CAAC,gBAAgB,CAAC,CAAA;AAEhF,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAoB,EAAE,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAA;AAE9F,gDAAgD;AAChD,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,EAAE;IAC9B,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,CAAA;IACvC,OAAO,QAAQ,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,KAAK,IAAI,KAAK,CAAC,CAAA;AAC9C,CAAC,CAAA;AAED,8EAA8E;AAC9E,MAAM,eAAe,GAAuC,MAAM,CAAC,oBAAoB,CAAC,CAAA;AAExF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,OAAsB,EAAE,EAAE,CAAC,OAAO,CAAC,eAAe,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAA;AAE1G,oFAAoF;AACpF,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE;IAClC,MAAM,OAAO,G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AAM,KAAK,GACT,CAAC,OAAO,YAAY,gBAAgB,IAAI,OAAO,YAAY,mBAAmB,CAAC;YAC/E,OAAO,CAAC,OAAO,CAAC,gEAAgE,CAAC;YACjF,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC;YAC3B,CAAC,CAAC,OAAO;YACT,CAAC,CAAC,IAAI,CAAA;QACV,IAAI,KAAK,IAAI,KAAK,KAAK,KAAK;YAAE,OAAO,EAAE,CAAA;QACvC,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,aAAa,CAAC,EAAE,CAAC;YAChD,KAAK,CAAC,YAAY,CAAC,aAAa,EAAE,KAAK,CAAC,CAAA;YACxC,KAAK,GAAG,KAAK,CAAA;QACf,CAAC;IACH,CAAC,CAAA;IACD,MAAM,KAAK,GAAG,GAAG,EAAE;QACjB,IAAI,CAAC,QAAQ,IAAI,OAAO,gBAAgB,KAAK,WAAW,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE,CAAC;YAC5F,QAAQ,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAA;YACrC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,eAAe,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC,eAAe,CAAC,EAAE,CAAC,CAAA;QACtG,CAAC;QACD,IAAI,EAAE,CAAA;IACR,CAAC,CAAA;IACD,MAAM,IAAI,GAAG,GAAG,EAAE;QAChB,QAAQ,EAAE,UAAU,EAAE,CAAA;QACtB,QAAQ,GAAG,IAAI,CAAA;QACf,OAAO,GAAG,IAAI,CAAA;QACd,OAAO,EAAE,CAAA;IACX,CAAC,CAAA;IACD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;AAC9B,CAAC","sourcesContent":["import { computed, inject, provide, type ComputedRef, type InjectionKey } from \"vue\"\n\n// Vue port of packages/ui/src/lib/fieldRow.ts.\n\n/**\n * True in a `Field row` whose control ends the row. It stands there beside\n * buttons and tags, so it takes their shape; a field with its label above stays\n * rounded.\n */\nconst FieldRowKey: InjectionKey<ComputedRef<boolean>> = Symbol(\"PlexUIFieldRow\")\n\nexport const provideFieldRow = (inRow: () => boolean) => provide(FieldRowKey, computed(inRow))\n\n/** True when the control ends a `Field row`. */\nexport const useFieldRow = () => {\n const inRow = inject(FieldRowKey, null)\n return computed(() => inRow?.value ?? false)\n}\n\n/** True in a `FieldGroup columns`, where every value starts at one column. */\nconst FieldColumnsKey: InjectionKey<ComputedRef<boolean>> = Symbol(\"PlexUIFieldColumns\")\n\nexport const provideFieldColumns = (columns: () => boolean) => provide(FieldColumnsKey, computed(columns))\n\n/** True when the control's value starts at the column of a `FieldGroup columns`. */\nexport const useFieldColumns = () => {\n const columns = inject(FieldColumnsKey, null)\n return computed(() => columns?.value ?? false)\n}\n\n/** The control's own `pill`, or else the shape of its row. */\nexport const useFieldRowPill = (pill: () => boolean | undefined) => {\n const inRow = useFieldRow()\n return computed(() => pill() ?? inRow.value)\n}\n\nconst ANDROID_LOOK = '[data-platform=\"android\"]'\nconst BLANK = \" \"\n\n/**\n * In the Plex Android look a text field under its label (a vertical `Field row` with the label shown) is a field of\n * an input card: the label stands in the field while it is empty, which the styles tell by `:placeholder-shown`. That\n * needs a placeholder, so there a field without one gets a blank one; elsewhere (iOS, the desktop) nothing is added.\n * `start` gives it and follows the platform and the field's own placeholder, `sync` checks again after a render,\n * `stop` takes it back.\n */\nexport function blankPlaceholder(controlId: () => string) {\n let given: HTMLInputElement | HTMLTextAreaElement | null = null\n let observer: MutationObserver | null = null\n const release = () => {\n if (given?.getAttribute(\"placeholder\") === BLANK) given.removeAttribute(\"placeholder\")\n given = null\n }\n let watched: Element | null = null\n const sync = () => {\n if (typeof document === \"undefined\") return\n const control = document.getElementById(controlId())\n // Watch only this field's own placeholder (and, from `start`, the root's platform), never the whole document\n if (observer && control && control !== watched) {\n observer.observe(control, { attributes: true, attributeFilter: [\"placeholder\"] })\n watched = control\n }\n const input =\n (control instanceof HTMLInputElement || control instanceof HTMLTextAreaElement) &&\n control.matches('[data-slot=\"input\"] > input, [data-slot=\"textarea\"] > textarea') &&\n control.closest(ANDROID_LOOK)\n ? control\n : null\n if (given && given !== input) release()\n if (input && !input.hasAttribute(\"placeholder\")) {\n input.setAttribute(\"placeholder\", BLANK)\n given = input\n }\n }\n const start = () => {\n if (!observer && typeof MutationObserver !== \"undefined\" && typeof document !== \"undefined\") {\n observer = new MutationObserver(sync)\n observer.observe(document.documentElement, { attributes: true, attributeFilter: [\"data-platform\"] })\n }\n sync()\n }\n const stop = () => {\n observer?.disconnect()\n observer = null\n watched = null\n release()\n }\n return { start, sync, stop }\n}\n"]}
@@ -0,0 +1,151 @@
1
+ /**
2
+ * How a phone overlay comes and goes as on iOS 27.2: a sheet grows out of the button that opened it and shrinks back
3
+ * into it as it closes, on SwiftUI's spring(duration: 0.33, bounce: 0.2); a sheet the finger lets go of carries on at
4
+ * the finger's speed, to its rest or off the screen. The CSS springs (--spring-sheet, --spring-menu) are these springs
5
+ * sampled; a released sheet needs one that starts at the finger's speed, which only a runtime sample has.
6
+ */
7
+ export const SHEET_SPRING = { duration: 0.33, bounce: 0.2 };
8
+ /** A released sheet does not overshoot: past its rest it would lift off the bottom of the screen. */
9
+ export const SHEET_RELEASE_SPRING = { duration: 0.33, bounce: 0 };
10
+ export const MENU_SPRING = { duration: 0.21, bounce: 0.2 };
11
+ /** The time these springs take to settle within 0.001, as --spring-sheet-duration and --spring-menu-duration. */
12
+ export const SHEET_SPRING_MS = 495;
13
+ export const MENU_SPRING_MS = 325;
14
+ /** The longest a sheet takes to leave: back into its button, or off the screen from a finger's release. */
15
+ export const SHEET_EXIT_MS = 500;
16
+ const STEP = 1 / 2000;
17
+ const SAMPLE = 1 / 120;
18
+ const LONGEST = 2;
19
+ /**
20
+ * A spring as a CSS easing and the time it takes to settle. `velocity` is the start speed in units of the whole move
21
+ * per second: a finger at 1 px/ms with 200 px left to go is 5. `stopAtEnd` keeps it from passing its end, as a sheet
22
+ * let go of toward its rest must not lift off the bottom of the screen however fast it comes.
23
+ */
24
+ export function springEasing({ duration, bounce }, velocity = 0, stopAtEnd = false) {
25
+ const stiffness = (2 * Math.PI / duration) ** 2;
26
+ const damping = (4 * Math.PI * (1 - bounce)) / duration;
27
+ let x = 0;
28
+ let v = velocity;
29
+ let t = 0;
30
+ let settled = 0;
31
+ const samples = [[0, 0]];
32
+ let nextSample = SAMPLE;
33
+ while (t < LONGEST) {
34
+ v += (-stiffness * (x - 1) - damping * v) * STEP;
35
+ x += v * STEP;
36
+ t += STEP;
37
+ if (stopAtEnd && x >= 1) {
38
+ x = 1;
39
+ v = 0;
40
+ }
41
+ if (Math.abs(x - 1) > 0.001 || Math.abs(v) > 0.01)
42
+ settled = t;
43
+ if (t >= nextSample) {
44
+ samples.push([t, x]);
45
+ nextSample += SAMPLE;
46
+ }
47
+ if (t - settled > 0.3)
48
+ break;
49
+ }
50
+ const total = Math.max(settled, SAMPLE);
51
+ const points = samples.filter(([time]) => time < total).map(([time, value]) => {
52
+ const share = `${Math.round((time / total) * 1000) / 10}%`;
53
+ return `${Math.round(value * 1000) / 1000} ${share}`;
54
+ });
55
+ points[0] = "0";
56
+ return { easing: `linear(${[...points, "1"].join(", ")})`, ms: Math.round(total * 1000) };
57
+ }
58
+ // The control last pressed, by a finger, a pointer or a key: the button a sheet opened from. A menu item is no source:
59
+ // its menu closes as the sheet comes, so the sheet slides up as one from a menu does on iOS.
60
+ const PRESSABLE = "button, a[href], [role='button'], [role='tab'], summary";
61
+ let lastPress = null;
62
+ const watched = new WeakSet();
63
+ const remember = (event) => {
64
+ if (event instanceof KeyboardEvent && event.key !== "Enter" && event.key !== " ")
65
+ return;
66
+ const target = event.target;
67
+ const element = target instanceof Element ? target.closest(PRESSABLE) : null;
68
+ lastPress = element && !element.closest("[role='menu'], [role='listbox']") ? { element, time: event.timeStamp } : null;
69
+ };
70
+ /** Starts noting what each press lands on, once per document. */
71
+ export function watchPresentationSources(doc) {
72
+ if (!doc || watched.has(doc))
73
+ return;
74
+ watched.add(doc);
75
+ doc.addEventListener("pointerdown", remember, { capture: true, passive: true });
76
+ doc.addEventListener("keydown", remember, { capture: true, passive: true });
77
+ }
78
+ /** The control pressed just now, which an overlay opening now opens from, if any. */
79
+ export function presentationSource(doc) {
80
+ if (!doc || !lastPress)
81
+ return null;
82
+ const view = doc.defaultView;
83
+ const recent = view && view.performance.now() - lastPress.time < 1000;
84
+ return recent && lastPress.element.isConnected && lastPress.element.ownerDocument === doc ? lastPress.element : null;
85
+ }
86
+ const toPixels = (value, size) => {
87
+ if (!value)
88
+ return size / 2;
89
+ const number = Number.parseFloat(value);
90
+ if (!Number.isFinite(number))
91
+ return size / 2;
92
+ return value.endsWith("%") ? (number / 100) * size : number;
93
+ };
94
+ /**
95
+ * The transform that lays the panel, at its rest, over the source: the panel grows out of it from there. Null when
96
+ * the source is gone, has no size, lies off the screen or inside the panel: the panel then comes as it would alone.
97
+ */
98
+ export function sourceTransform(panel, source) {
99
+ if (!source?.isConnected || panel.contains(source))
100
+ return null;
101
+ const view = panel.ownerDocument.defaultView;
102
+ if (!view)
103
+ return null;
104
+ const from = source.getBoundingClientRect();
105
+ if (!from.width || !from.height)
106
+ return null;
107
+ if (from.bottom <= 0 || from.right <= 0 || from.top >= view.innerHeight || from.left >= view.innerWidth)
108
+ return null;
109
+ // The rest is the panel without the transform of its entrance, its exit or a drag, nor of one under way: its layout
110
+ // box, which transforms leave alone, inside its offset parent (the dialog's layer, which nothing transforms).
111
+ const parent = panel.offsetParent instanceof view.HTMLElement ? panel.offsetParent : null;
112
+ const base = parent?.getBoundingClientRect();
113
+ const to = base
114
+ ? new view.DOMRect(base.left + parent.clientLeft + panel.offsetLeft, base.top + parent.clientTop + panel.offsetTop, panel.offsetWidth, panel.offsetHeight)
115
+ : panel.getBoundingClientRect();
116
+ const [originX, originY] = view.getComputedStyle(panel).transformOrigin.split(" ");
117
+ if (!to.width || !to.height)
118
+ return null;
119
+ const ox = to.left + toPixels(originX, to.width);
120
+ const oy = to.top + toPixels(originY, to.height);
121
+ const sx = from.width / to.width;
122
+ const sy = from.height / to.height;
123
+ const tx = from.left - ox - sx * (to.left - ox);
124
+ const ty = from.top - oy - sy * (to.top - oy);
125
+ const round = (value) => Math.round(value * 1000) / 1000;
126
+ return `translate(${round(tx)}px, ${round(ty)}px) scale(${round(sx)}, ${round(sy)})`;
127
+ }
128
+ /**
129
+ * A phone menu covers its button, its corner on the button's (menuTriggerCover.ts), and grows from its transform
130
+ * origin, which Radix puts at that corner: the scale that makes it the button's size there is all it takes. Sizes are
131
+ * the boxes' own, so this holds before the menu is placed.
132
+ */
133
+ export function sourceScale(panel, source) {
134
+ if (!source?.isConnected || panel.contains(source))
135
+ return null;
136
+ if (!panel.offsetWidth || !panel.offsetHeight || !source.offsetWidth || !source.offsetHeight)
137
+ return null;
138
+ const round = (value) => Math.round(value * 1000) / 1000;
139
+ return `scale(${round(source.offsetWidth / panel.offsetWidth)}, ${round(source.offsetHeight / panel.offsetHeight)})`;
140
+ }
141
+ /** Whether a phone overlay may grow out of its button: not with reduced motion, nor in the Plex Android look. */
142
+ export function growsFromButton(element) {
143
+ const doc = element?.ownerDocument ?? (typeof document === "undefined" ? undefined : document);
144
+ const view = doc?.defaultView;
145
+ if (!doc || !view)
146
+ return false;
147
+ if (view.matchMedia?.("(prefers-reduced-motion: reduce)").matches)
148
+ return false;
149
+ return !(element ?? doc.documentElement).closest("[data-platform='android']");
150
+ }
151
+ //# sourceMappingURL=presentMotion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presentMotion.js","sourceRoot":"","sources":["../../../src/lib/presentMotion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,MAAM,CAAC,MAAM,YAAY,GAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAA;AACnE,qGAAqG;AACrG,MAAM,CAAC,MAAM,oBAAoB,GAAW,EAAE,QAAQ,EAAE,IAAI,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AG,KAAK,CAAC,YAAY,CAAC,GAAG,CAAA;AACtH,CAAC;AAED,iHAAiH;AACjH,MAAM,UAAU,eAAe,CAAC,OAAmC;IACjE,MAAM,GAAG,GAAG,OAAO,EAAE,aAAa,IAAI,CAAC,OAAO,QAAQ,KAAK,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAA;IAC9F,MAAM,IAAI,GAAG,GAAG,EAAE,WAAW,CAAA;IAC7B,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI;QAAE,OAAO,KAAK,CAAA;IAC/B,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC,kCAAkC,CAAC,CAAC,OAAO;QAAE,OAAO,KAAK,CAAA;IAC/E,OAAO,CAAC,CAAC,OAAO,IAAI,GAAG,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,2BAA2B,CAAC,CAAA;AAC/E,CAAC","sourcesContent":["/**\n * How a phone overlay comes and goes as on iOS 27.2: a sheet grows out of the button that opened it and shrinks back\n * into it as it closes, on SwiftUI's spring(duration: 0.33, bounce: 0.2); a sheet the finger lets go of carries on at\n * the finger's speed, to its rest or off the screen. The CSS springs (--spring-sheet, --spring-menu) are these springs\n * sampled; a released sheet needs one that starts at the finger's speed, which only a runtime sample has.\n */\n\n/** SwiftUI's spring(duration:bounce:) with mass 1 */\nexport type Spring = { duration: number; bounce: number }\n\nexport const SHEET_SPRING: Spring = { duration: 0.33, bounce: 0.2 }\n/** A released sheet does not overshoot: past its rest it would lift off the bottom of the screen. */\nexport const SHEET_RELEASE_SPRING: Spring = { duration: 0.33, bounce: 0 }\nexport const MENU_SPRING: Spring = { duration: 0.21, bounce: 0.2 }\n/** The time these springs take to settle within 0.001, as --spring-sheet-duration and --spring-menu-duration. */\nexport const SHEET_SPRING_MS = 495\nexport const MENU_SPRING_MS = 325\n/** The longest a sheet takes to leave: back into its button, or off the screen from a finger's release. */\nexport const SHEET_EXIT_MS = 500\n\nconst STEP = 1 / 2000\nconst SAMPLE = 1 / 120\nconst LONGEST = 2\n\n/**\n * A spring as a CSS easing and the time it takes to settle. `velocity` is the start speed in units of the whole move\n * per second: a finger at 1 px/ms with 200 px left to go is 5. `stopAtEnd` keeps it from passing its end, as a sheet\n * let go of toward its rest must not lift off the bottom of the screen however fast it comes.\n */\nexport function springEasing(\n { duration, bounce }: Spring,\n velocity = 0,\n stopAtEnd = false,\n): { easing: string; ms: number } {\n const stiffness = (2 * Math.PI / duration) ** 2\n const damping = (4 * Math.PI * (1 - bounce)) / duration\n let x = 0\n let v = velocity\n let t = 0\n let settled = 0\n const samples: [number, number][] = [[0, 0]]\n let nextSample = SAMPLE\n while (t < LONGEST) {\n v += (-stiffness * (x - 1) - damping * v) * STEP\n x += v * STEP\n t += STEP\n if (stopAtEnd && x >= 1) {\n x = 1\n v = 0\n }\n if (Math.abs(x - 1) > 0.001 || Math.abs(v) > 0.01) settled = t\n if (t >= nextSample) {\n samples.push([t, x])\n nextSample += SAMPLE\n }\n if (t - settled > 0.3) break\n }\n const total = Math.max(settled, SAMPLE)\n const points = samples.filter(([time]) => time < total).map(([time, value]) => {\n const share = `${Math.round((time / total) * 1000) / 10}%`\n return `${Math.round(value * 1000) / 1000} ${share}`\n })\n points[0] = \"0\"\n return { easing: `linear(${[...points, \"1\"].join(\", \")})`, ms: Math.round(total * 1000) }\n}\n\n// The control last pressed, by a finger, a pointer or a key: the button a sheet opened from. A menu item is no source:\n// its menu closes as the sheet comes, so the sheet slides up as one from a menu does on iOS.\nconst PRESSABLE = \"button, a[href], [role='button'], [role='tab'], summary\"\nlet lastPress: { element: Element; time: number } | null = null\nconst watched = new WeakSet<Document>()\n\nconst remember = (event: Event) => {\n if (event instanceof KeyboardEvent && event.key !== \"Enter\" && event.key !== \" \") return\n const target = event.target\n const element = target instanceof Element ? target.closest(PRESSABLE) : null\n lastPress = element && !element.closest(\"[role='menu'], [role='listbox']\") ? { element, time: event.timeStamp } : null\n}\n\n/** Starts noting what each press lands on, once per document. */\nexport function watchPresentationSources(doc: Document | undefined) {\n if (!doc || watched.has(doc)) return\n watched.add(doc)\n doc.addEventListener(\"pointerdown\", remember, { capture: true, passive: true })\n doc.addEventListener(\"keydown\", remember, { capture: true, passive: true })\n}\n\n/** The control pressed just now, which an overlay opening now opens from, if any. */\nexport function presentationSource(doc: Document | undefined): Element | null {\n if (!doc || !lastPress) return null\n const view = doc.defaultView\n const recent = view && view.performance.now() - lastPress.time < 1000\n return recent && lastPress.element.isConnected && lastPress.element.ownerDocument === doc ? lastPress.element : null\n}\n\nconst toPixels = (value: string | undefined, size: number) => {\n if (!value) return size / 2\n const number = Number.parseFloat(value)\n if (!Number.isFinite(number)) return size / 2\n return value.endsWith(\"%\") ? (number / 100) * size : number\n}\n\n/**\n * The transform that lays the panel, at its rest, over the source: the panel grows out of it from there. Null when\n * the source is gone, has no size, lies off the screen or inside the panel: the panel then comes as it would alone.\n */\nexport function sourceTransform(panel: HTMLElement, source: Element | null): string | null {\n if (!source?.isConnected || panel.contains(source)) return null\n const view = panel.ownerDocument.defaultView\n if (!view) return null\n const from = source.getBoundingClientRect()\n if (!from.width || !from.height) return null\n if (from.bottom <= 0 || from.right <= 0 || from.top >= view.innerHeight || from.left >= view.innerWidth) return null\n // The rest is the panel without the transform of its entrance, its exit or a drag, nor of one under way: its layout\n // box, which transforms leave alone, inside its offset parent (the dialog's layer, which nothing transforms).\n const parent = panel.offsetParent instanceof view.HTMLElement ? panel.offsetParent : null\n const base = parent?.getBoundingClientRect()\n const to = base\n ? new view.DOMRect(\n base.left + parent!.clientLeft + panel.offsetLeft,\n base.top + parent!.clientTop + panel.offsetTop,\n panel.offsetWidth,\n panel.offsetHeight,\n )\n : panel.getBoundingClientRect()\n const [originX, originY] = view.getComputedStyle(panel).transformOrigin.split(\" \")\n if (!to.width || !to.height) return null\n const ox = to.left + toPixels(originX, to.width)\n const oy = to.top + toPixels(originY, to.height)\n const sx = from.width / to.width\n const sy = from.height / to.height\n const tx = from.left - ox - sx * (to.left - ox)\n const ty = from.top - oy - sy * (to.top - oy)\n const round = (value: number) => Math.round(value * 1000) / 1000\n return `translate(${round(tx)}px, ${round(ty)}px) scale(${round(sx)}, ${round(sy)})`\n}\n\n/**\n * A phone menu covers its button, its corner on the button's (menuTriggerCover.ts), and grows from its transform\n * origin, which Radix puts at that corner: the scale that makes it the button's size there is all it takes. Sizes are\n * the boxes' own, so this holds before the menu is placed.\n */\nexport function sourceScale(panel: HTMLElement, source: HTMLElement | null): string | null {\n if (!source?.isConnected || panel.contains(source)) return null\n if (!panel.offsetWidth || !panel.offsetHeight || !source.offsetWidth || !source.offsetHeight) return null\n const round = (value: number) => Math.round(value * 1000) / 1000\n return `scale(${round(source.offsetWidth / panel.offsetWidth)}, ${round(source.offsetHeight / panel.offsetHeight)})`\n}\n\n/** Whether a phone overlay may grow out of its button: not with reduced motion, nor in the Plex Android look. */\nexport function growsFromButton(element: Element | null | undefined): boolean {\n const doc = element?.ownerDocument ?? (typeof document === \"undefined\" ? undefined : document)\n const view = doc?.defaultView\n if (!doc || !view) return false\n if (view.matchMedia?.(\"(prefers-reduced-motion: reduce)\").matches) return false\n return !(element ?? doc.documentElement).closest(\"[data-platform='android']\")\n}\n"]}
@@ -6,6 +6,16 @@ declare const NavigationButtonComponent: import("vue").DefineComponent<import("v
6
6
  type: PropType<NavigationAction>;
7
7
  required: true;
8
8
  };
9
+ /**
10
+ * The text of confirm where it is drawn as a text pill (the Plex Android look's top bar): a short word, one or
11
+ * two at most (Done, Save, Apply). The accessible name stays in `aria-label`, which falls back to it. iOS draws
12
+ * confirm as a check circle and shows no text, nor do back and close.
13
+ * @default "Done"
14
+ */
15
+ label: {
16
+ type: StringConstructor;
17
+ default: undefined;
18
+ };
9
19
  }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
10
20
  [key: string]: any;
11
21
  }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
@@ -13,10 +23,29 @@ declare const NavigationButtonComponent: import("vue").DefineComponent<import("v
13
23
  type: PropType<NavigationAction>;
14
24
  required: true;
15
25
  };
16
- }>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
26
+ /**
27
+ * The text of confirm where it is drawn as a text pill (the Plex Android look's top bar): a short word, one or
28
+ * two at most (Done, Save, Apply). The accessible name stays in `aria-label`, which falls back to it. iOS draws
29
+ * confirm as a check circle and shows no text, nor do back and close.
30
+ * @default "Done"
31
+ */
32
+ label: {
33
+ type: StringConstructor;
34
+ default: undefined;
35
+ };
36
+ }>> & Readonly<{}>, {
37
+ label: string;
38
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
17
39
  export type NavigationButtonProps = Omit<ButtonProps, "children" | "uniform" | "pill" | "iconSize"> & {
18
40
  /** Visual role only; the caller owns navigation, dismissal and submission. */
19
41
  action: NavigationAction;
42
+ /**
43
+ * The text of confirm where it is drawn as a text pill (the Plex Android look's top bar): a short word, one or two
44
+ * at most (Done, Save, Apply). The accessible name stays in `aria-label`, which falls back to it. iOS draws confirm
45
+ * as a check circle and shows no text, nor do back and close.
46
+ * @default "Done"
47
+ */
48
+ label?: string;
20
49
  };
21
50
  /** Every native/Button prop reaches the same button; refs retain the Button instance's $el. */
22
51
  export declare const NavigationButton: typeof NavigationButtonComponent & {
@@ -107,9 +107,9 @@ export declare const ContextMenuTrigger: import("vue").DefineComponent<import("v
107
107
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
108
108
  declare const ContextMenuContentComponent: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
109
109
  /** Defines the `width` property of the content */
110
- width: (StringConstructor | NumberConstructor)[];
110
+ width: (NumberConstructor | StringConstructor)[];
111
111
  /** Defines the `min-width` property of the content, in pixels. */
112
- minWidth: (StringConstructor | NumberConstructor)[];
112
+ minWidth: (NumberConstructor | StringConstructor)[];
113
113
  /** Defines the `max-height` property of the content, in pixels. */
114
114
  maxHeight: NumberConstructor;
115
115
  /** Rounder list with fully rounded rows. */
@@ -123,9 +123,9 @@ declare const ContextMenuContentComponent: import("vue").DefineComponent<import(
123
123
  [key: string]: any;
124
124
  }>[], {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
125
125
  /** Defines the `width` property of the content */
126
- width: (StringConstructor | NumberConstructor)[];
126
+ width: (NumberConstructor | StringConstructor)[];
127
127
  /** Defines the `min-width` property of the content, in pixels. */
128
- minWidth: (StringConstructor | NumberConstructor)[];
128
+ minWidth: (NumberConstructor | StringConstructor)[];
129
129
  /** Defines the `max-height` property of the content, in pixels. */
130
130
  maxHeight: NumberConstructor;
131
131
  /** Rounder list with fully rounded rows. */
@@ -143,9 +143,9 @@ export type ContextMenuContentProps = InstanceType<typeof ContextMenuContentComp
143
143
  /** The menu (React `ContextMenu.Content`); its items are `MenuItem`, `MenuSeparator` and the other Menu items. */
144
144
  export declare const ContextMenuContent: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
145
145
  /** Defines the `width` property of the content */
146
- width: (StringConstructor | NumberConstructor)[];
146
+ width: (NumberConstructor | StringConstructor)[];
147
147
  /** Defines the `min-width` property of the content, in pixels. */
148
- minWidth: (StringConstructor | NumberConstructor)[];
148
+ minWidth: (NumberConstructor | StringConstructor)[];
149
149
  /** Defines the `max-height` property of the content, in pixels. */
150
150
  maxHeight: NumberConstructor;
151
151
  /** Rounder list with fully rounded rows. */
@@ -159,9 +159,9 @@ export declare const ContextMenuContent: import("vue").DefineComponent<import("v
159
159
  [key: string]: any;
160
160
  }>[], {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
161
161
  /** Defines the `width` property of the content */
162
- width: (StringConstructor | NumberConstructor)[];
162
+ width: (NumberConstructor | StringConstructor)[];
163
163
  /** Defines the `min-width` property of the content, in pixels. */
164
- minWidth: (StringConstructor | NumberConstructor)[];
164
+ minWidth: (NumberConstructor | StringConstructor)[];
165
165
  /** Defines the `max-height` property of the content, in pixels. */
166
166
  maxHeight: NumberConstructor;
167
167
  /** Rounder list with fully rounded rows. */
@@ -37,7 +37,12 @@ declare const FieldComponent: import("vue").DefineComponent<import("vue").Extrac
37
37
  type: BooleanConstructor;
38
38
  default: boolean;
39
39
  };
40
- /** Layout direction of label and control. @default "horizontal" on a `row` with a visible label, else "vertical" */
40
+ /**
41
+ * Layout direction of label and control. In the Plex Android look a vertical `row` whose control is
42
+ * an Input or a Textarea is a field of an input card: the label stands in the empty field as its hint and floats
43
+ * over the value once the field has the focus or a value, with a line under the field.
44
+ * @default "horizontal" on a `row` with a visible label, else "vertical"
45
+ */
41
46
  orientation: PropType<"vertical" | "horizontal">;
42
47
  /** One line of a FieldGroup. Its non-interactive area focuses the text editor or activates the choice control or popup trigger. @default false */
43
48
  row: {
@@ -83,7 +88,12 @@ declare const FieldComponent: import("vue").DefineComponent<import("vue").Extrac
83
88
  type: BooleanConstructor;
84
89
  default: boolean;
85
90
  };
86
- /** Layout direction of label and control. @default "horizontal" on a `row` with a visible label, else "vertical" */
91
+ /**
92
+ * Layout direction of label and control. In the Plex Android look a vertical `row` whose control is
93
+ * an Input or a Textarea is a field of an input card: the label stands in the empty field as its hint and floats
94
+ * over the value once the field has the focus or a value, with a line under the field.
95
+ * @default "horizontal" on a `row` with a visible label, else "vertical"
96
+ */
87
97
  orientation: PropType<"vertical" | "horizontal">;
88
98
  /** One line of a FieldGroup. Its non-interactive area focuses the text editor or activates the choice control or popup trigger. @default false */
89
99
  row: {
@@ -99,8 +99,8 @@ export declare const FloatingLabelSelect: import("vue").DefineComponent<import("
99
99
  };
100
100
  }>> & Readonly<{}>, {
101
101
  invalid: boolean;
102
- disabled: boolean;
103
102
  open: boolean;
103
+ disabled: boolean;
104
104
  pill: boolean;
105
105
  selected: boolean;
106
106
  labelPlacement: "inside" | "border";
@@ -1,3 +1,3 @@
1
1
  import { type FunctionalComponent, type SVGAttributes } from "vue";
2
- declare const Array: FunctionalComponent<SVGAttributes>;
3
- export default Array;
2
+ declare const ArrayIcon: FunctionalComponent<SVGAttributes>;
3
+ export default ArrayIcon;
@@ -1,3 +1,3 @@
1
1
  import { type FunctionalComponent, type SVGAttributes } from "vue";
2
- declare const Boolean: FunctionalComponent<SVGAttributes>;
3
- export default Boolean;
2
+ declare const BooleanIcon: FunctionalComponent<SVGAttributes>;
3
+ export default BooleanIcon;
@@ -1,3 +1,3 @@
1
1
  import { type FunctionalComponent, type SVGAttributes } from "vue";
2
- declare const Clipboard: FunctionalComponent<SVGAttributes>;
3
- export default Clipboard;
2
+ declare const ClipboardIcon: FunctionalComponent<SVGAttributes>;
3
+ export default ClipboardIcon;
@@ -1,3 +1,3 @@
1
1
  import { type FunctionalComponent, type SVGAttributes } from "vue";
2
- declare const Comment: FunctionalComponent<SVGAttributes>;
3
- export default Comment;
2
+ declare const CommentIcon: FunctionalComponent<SVGAttributes>;
3
+ export default CommentIcon;
@@ -1,3 +1,3 @@
1
1
  import { type FunctionalComponent, type SVGAttributes } from "vue";
2
- declare const Error: FunctionalComponent<SVGAttributes>;
3
- export default Error;
2
+ declare const ErrorIcon: FunctionalComponent<SVGAttributes>;
3
+ export default ErrorIcon;
@@ -1,3 +1,3 @@
1
1
  import { type FunctionalComponent, type SVGAttributes } from "vue";
2
- declare const Function: FunctionalComponent<SVGAttributes>;
3
- export default Function;
2
+ declare const FunctionIcon: FunctionalComponent<SVGAttributes>;
3
+ export default FunctionIcon;
@@ -1,3 +1,3 @@
1
1
  import { type FunctionalComponent, type SVGAttributes } from "vue";
2
- declare const Number: FunctionalComponent<SVGAttributes>;
3
- export default Number;
2
+ declare const NumberIcon: FunctionalComponent<SVGAttributes>;
3
+ export default NumberIcon;
@@ -1,3 +1,3 @@
1
1
  import { type FunctionalComponent, type SVGAttributes } from "vue";
2
- declare const Object: FunctionalComponent<SVGAttributes>;
3
- export default Object;
2
+ declare const ObjectIcon: FunctionalComponent<SVGAttributes>;
3
+ export default ObjectIcon;