@plexui/vue 0.41.0 → 0.42.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.
Files changed (50) 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/Markdown/Markdown.js +10 -1
  12. package/dist/es/components/Markdown/Markdown.js.map +1 -1
  13. package/dist/es/components/Markdown/directives.js +52 -11
  14. package/dist/es/components/Markdown/directives.js.map +1 -1
  15. package/dist/es/components/Menu/Menu.js +29 -2
  16. package/dist/es/components/Menu/Menu.js.map +1 -1
  17. package/dist/es/components/PlexUIProvider/PlexUIProvider.js +43 -3
  18. package/dist/es/components/PlexUIProvider/PlexUIProvider.js.map +1 -1
  19. package/dist/es/components/PlexUIProvider/androidRipple.js +98 -0
  20. package/dist/es/components/PlexUIProvider/androidRipple.js.map +1 -0
  21. package/dist/es/components/PlexUIProvider/index.js.map +1 -1
  22. package/dist/es/components/Select/Select.js +364 -22
  23. package/dist/es/components/Select/Select.js.map +1 -1
  24. package/dist/es/components/Toolbar/Toolbar.js +276 -17
  25. package/dist/es/components/Toolbar/Toolbar.js.map +1 -1
  26. package/dist/es/components/Toolbar/index.js.map +1 -1
  27. package/dist/es/lib/accordionMotion.js +144 -0
  28. package/dist/es/lib/accordionMotion.js.map +1 -0
  29. package/dist/es/lib/fieldRow.js +54 -0
  30. package/dist/es/lib/fieldRow.js.map +1 -1
  31. package/dist/es/lib/presentMotion.js +151 -0
  32. package/dist/es/lib/presentMotion.js.map +1 -0
  33. package/dist/types/components/Button/NavigationButton.d.ts +30 -1
  34. package/dist/types/components/ContextMenu/ContextMenu.d.ts +8 -8
  35. package/dist/types/components/Field/Field.d.ts +12 -2
  36. package/dist/types/components/FloatingLabelSelect/FloatingLabelSelect.d.ts +1 -1
  37. package/dist/types/components/Markdown/directives.d.ts +11 -2
  38. package/dist/types/components/PlexUIProvider/PlexUIProvider.d.ts +20 -3
  39. package/dist/types/components/PlexUIProvider/androidRipple.d.ts +9 -0
  40. package/dist/types/components/PlexUIProvider/index.d.ts +1 -1
  41. package/dist/types/components/Select/Select.d.ts +51 -0
  42. package/dist/types/components/Sidebar/useSidebarContext.d.ts +1 -1
  43. package/dist/types/components/TabBar/TabBar.d.ts +4 -4
  44. package/dist/types/components/Toast/Toaster.d.ts +1 -1
  45. package/dist/types/components/Toolbar/Toolbar.d.ts +49 -12
  46. package/dist/types/components/Toolbar/index.d.ts +1 -1
  47. package/dist/types/lib/accordionMotion.d.ts +20 -0
  48. package/dist/types/lib/fieldRow.d.ts +12 -0
  49. package/dist/types/lib/presentMotion.d.ts +46 -0
  50. package/package.json +2 -2
@@ -1,6 +1,8 @@
1
1
  import { isPhoneLayout } from "../../lib/phoneLayout.js";
2
+ import { SHEET_EXIT_MS, SHEET_RELEASE_SPRING, springEasing } from "../../lib/presentMotion.js";
2
3
  // A bottom sheet follows the finger. A drag from its top 44px moves it 1:1, never up. Past 30% of its
3
- // height, or at 0.5px/ms, it closes; otherwise it returns. Buttons in that strip keep their press.
4
+ // height, or at 0.5px/ms, it closes; otherwise it returns. Either way it goes on at the finger's speed, on a spring
5
+ // that starts at it, as a sheet let go of does on iOS. Buttons in that strip keep their press.
4
6
  // As on iOS, a pull down that starts anywhere else moves the sheet too once the content under the finger is at
5
7
  // its top: the first move decides, down and mostly vertical with every scroller under the finger at its top
6
8
  // takes the sheet; up, sideways, a move another handler took, a field, a control that pans by itself or a
@@ -21,6 +23,11 @@ const EXITING = "[data-exiting], [data-exiting-active]";
21
23
  // A sheet at its full height says so: a sheet under it then steps back, as one presented from a sheet does on iOS.
22
24
  // A shorter sheet leaves the one under it in place, as a medium detent does.
23
25
  const FULL = "data-sheet-full";
26
+ // A sheet that grew out of its button would shrink back into it; one let go of leaves down instead (Dialog sets it).
27
+ const PRESENTED_FROM = "data-presented-from";
28
+ const EXIT_DURATION = "--dialog-exit-duration";
29
+ const EXIT_EASING = "--dialog-exit-easing";
30
+ const reducedMotion = (view) => Boolean(view.matchMedia?.("(prefers-reduced-motion: reduce)").matches);
24
31
  const watchFullHeight = (panel, view) => {
25
32
  if (!view.ResizeObserver)
26
33
  return () => { };
@@ -68,20 +75,27 @@ export const attachSheetDrag = (panel, close) => {
68
75
  stopSettling();
69
76
  clearInline();
70
77
  panel.style.removeProperty(DRAG_TRANSFORM);
78
+ panel.style.removeProperty(EXIT_DURATION);
79
+ panel.style.removeProperty(EXIT_EASING);
71
80
  };
72
81
  const onSettled = (event) => {
73
82
  if (event.target === panel && event.propertyName === "transform")
74
83
  clear();
75
84
  };
76
- const returnToRest = () => {
85
+ // `from` is where the sheet is let go of, `velocity` the finger's speed down in px/ms: the sheet starts back at it.
86
+ const returnToRest = (from = 0, velocity = 0) => {
77
87
  stopSettling();
78
- if (view.matchMedia?.("(prefers-reduced-motion: reduce)").matches) {
88
+ if (reducedMotion(view)) {
79
89
  clear();
80
90
  return;
81
91
  }
82
- panel.style.transition = "transform var(--motion-enter) var(--cubic-enter)";
92
+ // Back up is the way to rest: a finger still going down starts it the other way.
93
+ const spring = springEasing(SHEET_RELEASE_SPRING, from > 0 ? (-velocity * 1000) / from : 0, true);
94
+ panel.style.transition = `transform ${spring.ms}ms ${spring.easing}`;
83
95
  panel.style.transform = "";
84
96
  panel.style.removeProperty(DRAG_TRANSFORM);
97
+ panel.style.removeProperty(EXIT_DURATION);
98
+ panel.style.removeProperty(EXIT_EASING);
85
99
  const durationText = view.getComputedStyle(panel).transitionDuration;
86
100
  const duration = Number.parseFloat(durationText) * (durationText.endsWith("ms") ? 1 : 1000);
87
101
  if (duration === 0) {
@@ -170,29 +184,48 @@ export const attachSheetDrag = (panel, close) => {
170
184
  if (fromContent && travelled > DECIDE && event.cancelable)
171
185
  event.preventDefault();
172
186
  fromContent = false;
173
- // A finger that rested before lifting is no flick.
174
- const flick = speed > CLOSE_SPEED && event.timeStamp - lastTime < REST;
187
+ // A finger that rested before lifting is no flick, and gives the sheet no speed.
188
+ const moving = event.timeStamp - lastTime < REST;
189
+ const velocity = moving ? speed : 0;
190
+ const flick = speed > CLOSE_SPEED && moving;
175
191
  startY = null;
176
192
  if (travelled <= 0) {
177
193
  clear();
178
194
  return;
179
195
  }
180
- if (travelled > panel.getBoundingClientRect().height * CLOSE_SHARE || flick) {
196
+ const height = panel.getBoundingClientRect().height;
197
+ if (travelled > height * CLOSE_SHARE || flick) {
181
198
  // The normal/exit-start CSS states retain this exact release position.
182
199
  // No inline transform or transition may mask the active CSS exit.
183
200
  panel.style.setProperty(DRAG_TRANSFORM, `translateY(${travelled}px)`);
184
201
  clearInline();
202
+ // The rest of the way down goes on at the finger's speed, within the time the dialog gives its exit
203
+ const presentedFrom = panel.hasAttribute(PRESENTED_FROM);
204
+ panel.removeAttribute(PRESENTED_FROM);
205
+ if (!reducedMotion(view)) {
206
+ const left = Math.max(1, height - travelled);
207
+ const spring = springEasing(SHEET_RELEASE_SPRING, (Math.max(0, velocity) * 1000) / left, true);
208
+ panel.style.setProperty(EXIT_DURATION, `${Math.min(spring.ms, SHEET_EXIT_MS)}ms`);
209
+ panel.style.setProperty(EXIT_EASING, spring.easing);
210
+ }
185
211
  // An owner can veto close. Register before close, which can detach us.
186
212
  settleTimer = view.setTimeout(() => {
187
213
  settleTimer = undefined;
188
- if (panel.isConnected && !panel.closest(EXITING))
189
- returnToRest();
214
+ if (!panel.isConnected || panel.closest(EXITING))
215
+ return;
216
+ // An owner that kept the dialog open without saying so: it still goes back into its button later
217
+ if (presentedFrom)
218
+ panel.setAttribute(PRESENTED_FROM, "");
219
+ returnToRest(travelled, velocity);
190
220
  }, SETTLE);
191
- if (close(event) === false)
192
- returnToRest();
221
+ if (close(event) === false) {
222
+ if (presentedFrom)
223
+ panel.setAttribute(PRESENTED_FROM, "");
224
+ returnToRest(travelled, velocity);
225
+ }
193
226
  return;
194
227
  }
195
- returnToRest();
228
+ returnToRest(travelled, velocity);
196
229
  };
197
230
  const onCancel = () => {
198
231
  startY = null;
@@ -1 +1 @@
1
- {"version":3,"file":"sheetDrag.js","sourceRoot":"","sources":["../../../../src/components/Dialog/sheetDrag.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAExD,sGAAsG;AACtG,mGAAmG;AACnG,+GAA+G;AAC/G,4GAA4G;AAC5G,0GAA0G;AAC1G,sFAAsF;AACtF,MAAM,IAAI,GAAG,EAAE,CAAA;AACf,MAAM,WAAW,GAAG,GAAG,CAAA;AACvB,MAAM,WAAW,GAAG,GAAG,CAAA;AACvB,MAAM,IAAI,GAAG,GAAG,CAAA;AAChB,MAAM,MAAM,GAAG,GAAG,CAAA;AAClB,MAAM,WAAW,GAAG,qDAAqD,CAAA;AACzE,MAAM,QAAQ,GAAG,4FAA4F,CAAA;AAC7G,6GAA6G;AAC7G,MAAM,MAAM,GAAG,CAAC,CAAA;AAChB,yFAAyF;AACzF,MAAM,IAAI,GAAG,GAAG,CAAA;AAChB,MAAM,cAAc,GAAG,+BAA+B,CAAA;AACtD,MAAM,OAAO,GAAG,uCAAuC,CAAA;AACvD,mHAAmH;AACnH,6EAA6E;AAC7E,MAAM,IAAI,GAAG,iBAAiB,CAAA;AAE9B,MAAM,eAAe,GAAG,CAAC,KAAkB,EAAE,IAAgC,EAAE,EAAE;IAC/E,IAAI,CAAC,IAAI,CAAC,cAAc;QAAE,OAAO,GAAG,EAAE,GAAE,CAAC,CAAA;IACzC,MAAM,MAAM,GAAG,GAAG,EAAE;QAClB,MAAM,GAAG,GAA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,EAAE;QACV,WAAW,EAAE,CAAA;QACb,aAAa,EAAE,UAAU,EAAE,CAAA;QAC3B,KAAK,CAAC,mBAAmB,CAAC,YAAY,EAAE,OAAO,CAAC,CAAA;QAChD,KAAK,CAAC,mBAAmB,CAAC,WAAW,EAAE,MAAM,CAAC,CAAA;QAC9C,KAAK,CAAC,mBAAmB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAA;QAC5C,KAAK,CAAC,mBAAmB,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAA;QAClD,MAAM,GAAG,IAAI,CAAA;QACb,OAAO,GAAG,IAAI,CAAA;QACd,KAAK,EAAE,CAAA;IACT,CAAC,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { isPhoneLayout } from \"../../lib/phoneLayout.js\"\n\n// A bottom sheet follows the finger. A drag from its top 44px moves it 1:1, never up. Past 30% of its\n// height, or at 0.5px/ms, it closes; otherwise it returns. Buttons in that strip keep their press.\n// As on iOS, a pull down that starts anywhere else moves the sheet too once the content under the finger is at\n// its top: the first move decides, down and mostly vertical with every scroller under the finger at its top\n// takes the sheet; up, sideways, a move another handler took, a field, a control that pans by itself or a\n// finger that rested first (a hold: Sortable, a context menu) stays with the content.\nconst GRIP = 44\nconst CLOSE_SHARE = 0.3\nconst CLOSE_SPEED = 0.5\nconst REST = 100\nconst SETTLE = 400\nconst INTERACTIVE = \"a, button, input, select, textarea, [role='button']\"\nconst EDITABLE = \"input, textarea, select, [contenteditable]:not([contenteditable='false']), [role='slider']\"\n// The move that settles which way the finger goes, under the browser's own slop so it can still be cancelled\nconst DECIDE = 4\n// A finger that rests this long holds (a Sortable row, a context menu) rather than pulls\nconst HOLD = 200\nconst DRAG_TRANSFORM = \"--dialog-panel-drag-transform\"\nconst EXITING = \"[data-exiting], [data-exiting-active]\"\n// A sheet at its full height says so: a sheet under it then steps back, as one presented from a sheet does on iOS.\n// A shorter sheet leaves the one under it in place, as a medium detent does.\nconst FULL = \"data-sheet-full\"\n\nconst watchFullHeight = (panel: HTMLElement, view: Window & typeof globalThis) => {\n if (!view.ResizeObserver) return () => {}\n const update = () => {\n const max = Number.parseFloat(view.getComputedStyle(panel).maxHeight)\n const full = Number.isFinite(max) && panel.offsetHeight >= max - 1\n if (full !== panel.hasAttribute(FULL)) panel.toggleAttribute(FULL, full)\n }\n const observer = new view.ResizeObserver(update)\n // Its height with the border, as `offsetHeight` reads it\n observer.observe(panel, { box: \"border-box\" })\n update()\n return () => {\n observer.disconnect()\n panel.removeAttribute(FULL)\n }\n}\n\n/** `close` returns false when the owner keeps the dialog open: the sheet then returns at once. */\nexport const attachSheetDrag = (panel: HTMLElement, close: (event: TouchEvent) => boolean | void) => {\n const view = panel.ownerDocument.defaultView\n if (!view) return () => {}\n const unwatchFull = watchFullHeight(panel, view)\n let startY: number | null = null\n // A touch in the content that may become a pull, until its first move says which way it goes\n let pending: { x: number; y: number; time: number; target: Element } | null = null\n // The pull began in the content: its release must not press what lies under the finger\n let fromContent = false\n let lastY = 0\n let lastTime = 0\n let speed = 0\n let settleTimer: number | undefined\n\n const stopSettling = () => {\n if (settleTimer !== undefined) view.clearTimeout(settleTimer)\n settleTimer = undefined\n panel.removeEventListener(\"transitionend\", onSettled)\n }\n const clearInline = () => {\n panel.style.transition = \"\"\n panel.style.transform = \"\"\n }\n const clear = () => {\n stopSettling()\n clearInline()\n panel.style.removeProperty(DRAG_TRANSFORM)\n }\n const onSettled = (event: TransitionEvent) => {\n if (event.target === panel && event.propertyName === \"transform\") clear()\n }\n const returnToRest = () => {\n stopSettling()\n if (view.matchMedia?.(\"(prefers-reduced-motion: reduce)\").matches) {\n clear()\n return\n }\n panel.style.transition = \"transform var(--motion-enter) var(--cubic-enter)\"\n panel.style.transform = \"\"\n panel.style.removeProperty(DRAG_TRANSFORM)\n const durationText = view.getComputedStyle(panel).transitionDuration\n const duration = Number.parseFloat(durationText) * (durationText.endsWith(\"ms\") ? 1 : 1000)\n if (duration === 0) {\n clear()\n return\n }\n panel.addEventListener(\"transitionend\", onSettled)\n // A theme can lengthen the token or remove the transition altogether.\n // This cleanup must not cut a valid longer transition at the veto timeout.\n settleTimer = view.setTimeout(clear, Math.max(SETTLE, Number.isFinite(duration) ? duration : 0))\n }\n\n const begin = (clientY: number, time: number) => {\n stopSettling()\n startY = clientY\n lastY = clientY\n lastTime = time\n speed = 0\n }\n\n // Every element from the target up to the panel: one that can scroll up, or pans by itself, keeps the move.\n const contentTakes = (target: Element) => {\n for (let element: Element | null = target; element; element = element.parentElement) {\n if (element.scrollTop > 0) return true\n const touchAction = view.getComputedStyle(element).touchAction\n if (touchAction && touchAction !== \"auto\" && touchAction !== \"manipulation\" && !touchAction.includes(\"pan-y\")) return true\n if (element === panel) break\n }\n return false\n }\n\n const onStart = (event: TouchEvent) => {\n pending = null\n fromContent = false\n const phone = isPhoneLayout(panel)\n if (event.touches.length !== 1 || !phone || panel.closest(EXITING)) return\n const { clientX, clientY } = event.touches[0]\n const target = event.target instanceof view.Element ? event.target : null\n if (clientY - panel.getBoundingClientRect().top <= GRIP) {\n if (target?.closest(INTERACTIVE)) return\n begin(clientY, event.timeStamp)\n return\n }\n if (!target || target.closest(EDITABLE)) return\n pending = { x: clientX, y: clientY, time: event.timeStamp, target }\n }\n\n // The first move of a touch in the content: a pull down from the top takes the sheet from here on.\n const decide = (event: TouchEvent, touch: Touch) => {\n const start = pending!\n const dx = touch.clientX - start.x\n const dy = touch.clientY - start.y\n if (Math.max(Math.abs(dx), Math.abs(dy)) < DECIDE) return\n pending = null\n if (event.defaultPrevented || !event.cancelable || event.timeStamp - start.time > HOLD) return\n if (dy <= 0 || Math.abs(dx) > dy || contentTakes(start.target)) return\n fromContent = true\n begin(start.y, start.time)\n }\n\n const onMove = (event: TouchEvent) => {\n const touch = event.touches[0]\n if (startY === null && pending && touch) decide(event, touch)\n if (startY === null || !touch) return\n event.preventDefault()\n const { clientY } = touch\n speed = (clientY - lastY) / Math.max(1, event.timeStamp - lastTime)\n lastY = clientY\n lastTime = event.timeStamp\n panel.style.transition = \"none\"\n panel.style.transform = `translateY(${Math.max(0, clientY - startY)}px)`\n }\n\n const onEnd = (event: TouchEvent) => {\n pending = null\n if (startY === null) return\n const travelled = lastY - startY\n // A pull from the content ends where it lifted, not in a press of the row under it. A finger that barely\n // moved keeps its tap.\n if (fromContent && travelled > DECIDE && event.cancelable) event.preventDefault()\n fromContent = false\n // A finger that rested before lifting is no flick.\n const flick = speed > CLOSE_SPEED && event.timeStamp - lastTime < REST\n startY = null\n if (travelled <= 0) {\n clear()\n return\n }\n if (travelled > panel.getBoundingClientRect().height * CLOSE_SHARE || flick) {\n // The normal/exit-start CSS states retain this exact release position.\n // No inline transform or transition may mask the active CSS exit.\n panel.style.setProperty(DRAG_TRANSFORM, `translateY(${travelled}px)`)\n clearInline()\n // An owner can veto close. Register before close, which can detach us.\n settleTimer = view.setTimeout(() => {\n settleTimer = undefined\n if (panel.isConnected && !panel.closest(EXITING)) returnToRest()\n }, SETTLE)\n if (close(event) === false) returnToRest()\n return\n }\n returnToRest()\n }\n\n const onCancel = () => {\n startY = null\n pending = null\n fromContent = false\n clear()\n }\n\n // A retained panel can reopen before its exit completes. Its new entrance\n // must return to rest, not finish at the old gesture's release offset.\n const dialog = panel.closest(\"[data-plex-dialog]\")\n const stateObserver = dialog ? new view.MutationObserver((records) => {\n if (panel.style.getPropertyValue(DRAG_TRANSFORM) &&\n dialog.getAttribute(\"data-state\") === \"open\" &&\n records.some((record) => record.oldValue === \"closed\")) clear()\n }) : undefined\n stateObserver?.observe(dialog ?? panel, {\n attributes: true, attributeFilter: [\"data-state\"], attributeOldValue: true,\n })\n\n panel.addEventListener(\"touchstart\", onStart, { passive: true })\n panel.addEventListener(\"touchmove\", onMove, { passive: false })\n panel.addEventListener(\"touchend\", onEnd)\n panel.addEventListener(\"touchcancel\", onCancel)\n\n return () => {\n unwatchFull()\n stateObserver?.disconnect()\n panel.removeEventListener(\"touchstart\", onStart)\n panel.removeEventListener(\"touchmove\", onMove)\n panel.removeEventListener(\"touchend\", onEnd)\n panel.removeEventListener(\"touchcancel\", onCancel)\n startY = null\n pending = null\n clear()\n }\n}\n"]}
1
+ {"version":3,"file":"sheetDrag.js","sourceRoot":"","sources":["../../../../src/components/Dialog/sheetDrag.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACxD,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAE9F,sGAAsG;AACtG,oHAAoH;AACpH,+FAA+F;AAC/F,+GAA+G;AAC/G,4GAA4G;AAC5G,0GAA0G;AAC1G,sFAAsF;AACtF,MAAM,IAAI,GAAG,EAAE,CAAA;AACf,MAAM,WAAW,GAAG,GAAG,CAAA;AACvB,MAAM,WAAW,GAAG,GAAG,CAAA;AACvB,MAAM,IAAI,GAAG,GAAG,CAAA;AAChB,MAAM,MAAM,GAAG,GAAG,CAAA;AAClB,MAAM,WAAW,GAAG,qDAAqD,CAAA;AACzE,MAAM,QAAQ,GAAG,4FAA4F,CAAA;AAC7G,6GAA6G;AAC7G,MAAM,MAAM,GAAG,CAAC,CAAA;AAChB,yFAAyF;AACzF,MAAM,IAAI,GAAG,GAAG,CAAA;AAChB,MAAM,cAAc,GAAG,+BAA+B,CAAA;AACtD,MAAM,OAAO,GAAG,uCAAuC,CAAA;AACvD,mHAAmH;AACnH,6EAA6E;AAC7E,MAAM,IAAI,GAAG,iBAAiB,CAAA;AAC9B,qHAAqH;AACrH,MAAM,cAAc,GAAG,qBAAqB,CAAA;AAC5C,MAAM,aAAa,GAAG,wBAAwB,CAAA;AAC9C,MAAM,WAAW,GAAG,sBAAsB,CAAA;AAE1C,MAAM,aAAa,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,kCAAkC,CAAC,CAAC,OAAO,CAAC,CAAA;AAE9G,MAAM,eAAe,GAAG,CAAC,KAAkB,EAAE,IAAgC,EAAE,E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rE,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IACd,aAAa,EAAE,OAAO,CAAC,MAAM,IAAI,KAAK,EAAE;QACtC,UAAU,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC,YAAY,CAAC,EAAE,iBAAiB,EAAE,IAAI;KAC3E,CAAC,CAAA;IAEF,KAAK,CAAC,gBAAgB,CAAC,YAAY,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAA;IAChE,KAAK,CAAC,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAA;IAC/D,KAAK,CAAC,gBAAgB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAA;IACzC,KAAK,CAAC,gBAAgB,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAA;IAE/C,OAAO,GAAG,EAAE;QACV,WAAW,EAAE,CAAA;QACb,aAAa,EAAE,UAAU,EAAE,CAAA;QAC3B,KAAK,CAAC,mBAAmB,CAAC,YAAY,EAAE,OAAO,CAAC,CAAA;QAChD,KAAK,CAAC,mBAAmB,CAAC,WAAW,EAAE,MAAM,CAAC,CAAA;QAC9C,KAAK,CAAC,mBAAmB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAA;QAC5C,KAAK,CAAC,mBAAmB,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAA;QAClD,MAAM,GAAG,IAAI,CAAA;QACb,OAAO,GAAG,IAAI,CAAA;QACd,KAAK,EAAE,CAAA;IACT,CAAC,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { isPhoneLayout } from \"../../lib/phoneLayout.js\"\nimport { SHEET_EXIT_MS, SHEET_RELEASE_SPRING, springEasing } from \"../../lib/presentMotion.js\"\n\n// A bottom sheet follows the finger. A drag from its top 44px moves it 1:1, never up. Past 30% of its\n// height, or at 0.5px/ms, it closes; otherwise it returns. Either way it goes on at the finger's speed, on a spring\n// that starts at it, as a sheet let go of does on iOS. Buttons in that strip keep their press.\n// As on iOS, a pull down that starts anywhere else moves the sheet too once the content under the finger is at\n// its top: the first move decides, down and mostly vertical with every scroller under the finger at its top\n// takes the sheet; up, sideways, a move another handler took, a field, a control that pans by itself or a\n// finger that rested first (a hold: Sortable, a context menu) stays with the content.\nconst GRIP = 44\nconst CLOSE_SHARE = 0.3\nconst CLOSE_SPEED = 0.5\nconst REST = 100\nconst SETTLE = 400\nconst INTERACTIVE = \"a, button, input, select, textarea, [role='button']\"\nconst EDITABLE = \"input, textarea, select, [contenteditable]:not([contenteditable='false']), [role='slider']\"\n// The move that settles which way the finger goes, under the browser's own slop so it can still be cancelled\nconst DECIDE = 4\n// A finger that rests this long holds (a Sortable row, a context menu) rather than pulls\nconst HOLD = 200\nconst DRAG_TRANSFORM = \"--dialog-panel-drag-transform\"\nconst EXITING = \"[data-exiting], [data-exiting-active]\"\n// A sheet at its full height says so: a sheet under it then steps back, as one presented from a sheet does on iOS.\n// A shorter sheet leaves the one under it in place, as a medium detent does.\nconst FULL = \"data-sheet-full\"\n// A sheet that grew out of its button would shrink back into it; one let go of leaves down instead (Dialog sets it).\nconst PRESENTED_FROM = \"data-presented-from\"\nconst EXIT_DURATION = \"--dialog-exit-duration\"\nconst EXIT_EASING = \"--dialog-exit-easing\"\n\nconst reducedMotion = (view: Window) => Boolean(view.matchMedia?.(\"(prefers-reduced-motion: reduce)\").matches)\n\nconst watchFullHeight = (panel: HTMLElement, view: Window & typeof globalThis) => {\n if (!view.ResizeObserver) return () => {}\n const update = () => {\n const max = Number.parseFloat(view.getComputedStyle(panel).maxHeight)\n const full = Number.isFinite(max) && panel.offsetHeight >= max - 1\n if (full !== panel.hasAttribute(FULL)) panel.toggleAttribute(FULL, full)\n }\n const observer = new view.ResizeObserver(update)\n // Its height with the border, as `offsetHeight` reads it\n observer.observe(panel, { box: \"border-box\" })\n update()\n return () => {\n observer.disconnect()\n panel.removeAttribute(FULL)\n }\n}\n\n/** `close` returns false when the owner keeps the dialog open: the sheet then returns at once. */\nexport const attachSheetDrag = (panel: HTMLElement, close: (event: TouchEvent) => boolean | void) => {\n const view = panel.ownerDocument.defaultView\n if (!view) return () => {}\n const unwatchFull = watchFullHeight(panel, view)\n let startY: number | null = null\n // A touch in the content that may become a pull, until its first move says which way it goes\n let pending: { x: number; y: number; time: number; target: Element } | null = null\n // The pull began in the content: its release must not press what lies under the finger\n let fromContent = false\n let lastY = 0\n let lastTime = 0\n let speed = 0\n let settleTimer: number | undefined\n\n const stopSettling = () => {\n if (settleTimer !== undefined) view.clearTimeout(settleTimer)\n settleTimer = undefined\n panel.removeEventListener(\"transitionend\", onSettled)\n }\n const clearInline = () => {\n panel.style.transition = \"\"\n panel.style.transform = \"\"\n }\n const clear = () => {\n stopSettling()\n clearInline()\n panel.style.removeProperty(DRAG_TRANSFORM)\n panel.style.removeProperty(EXIT_DURATION)\n panel.style.removeProperty(EXIT_EASING)\n }\n const onSettled = (event: TransitionEvent) => {\n if (event.target === panel && event.propertyName === \"transform\") clear()\n }\n // `from` is where the sheet is let go of, `velocity` the finger's speed down in px/ms: the sheet starts back at it.\n const returnToRest = (from = 0, velocity = 0) => {\n stopSettling()\n if (reducedMotion(view)) {\n clear()\n return\n }\n // Back up is the way to rest: a finger still going down starts it the other way.\n const spring = springEasing(SHEET_RELEASE_SPRING, from > 0 ? (-velocity * 1000) / from : 0, true)\n panel.style.transition = `transform ${spring.ms}ms ${spring.easing}`\n panel.style.transform = \"\"\n panel.style.removeProperty(DRAG_TRANSFORM)\n panel.style.removeProperty(EXIT_DURATION)\n panel.style.removeProperty(EXIT_EASING)\n const durationText = view.getComputedStyle(panel).transitionDuration\n const duration = Number.parseFloat(durationText) * (durationText.endsWith(\"ms\") ? 1 : 1000)\n if (duration === 0) {\n clear()\n return\n }\n panel.addEventListener(\"transitionend\", onSettled)\n // A theme can lengthen the token or remove the transition altogether.\n // This cleanup must not cut a valid longer transition at the veto timeout.\n settleTimer = view.setTimeout(clear, Math.max(SETTLE, Number.isFinite(duration) ? duration : 0))\n }\n\n const begin = (clientY: number, time: number) => {\n stopSettling()\n startY = clientY\n lastY = clientY\n lastTime = time\n speed = 0\n }\n\n // Every element from the target up to the panel: one that can scroll up, or pans by itself, keeps the move.\n const contentTakes = (target: Element) => {\n for (let element: Element | null = target; element; element = element.parentElement) {\n if (element.scrollTop > 0) return true\n const touchAction = view.getComputedStyle(element).touchAction\n if (touchAction && touchAction !== \"auto\" && touchAction !== \"manipulation\" && !touchAction.includes(\"pan-y\")) return true\n if (element === panel) break\n }\n return false\n }\n\n const onStart = (event: TouchEvent) => {\n pending = null\n fromContent = false\n const phone = isPhoneLayout(panel)\n if (event.touches.length !== 1 || !phone || panel.closest(EXITING)) return\n const { clientX, clientY } = event.touches[0]\n const target = event.target instanceof view.Element ? event.target : null\n if (clientY - panel.getBoundingClientRect().top <= GRIP) {\n if (target?.closest(INTERACTIVE)) return\n begin(clientY, event.timeStamp)\n return\n }\n if (!target || target.closest(EDITABLE)) return\n pending = { x: clientX, y: clientY, time: event.timeStamp, target }\n }\n\n // The first move of a touch in the content: a pull down from the top takes the sheet from here on.\n const decide = (event: TouchEvent, touch: Touch) => {\n const start = pending!\n const dx = touch.clientX - start.x\n const dy = touch.clientY - start.y\n if (Math.max(Math.abs(dx), Math.abs(dy)) < DECIDE) return\n pending = null\n if (event.defaultPrevented || !event.cancelable || event.timeStamp - start.time > HOLD) return\n if (dy <= 0 || Math.abs(dx) > dy || contentTakes(start.target)) return\n fromContent = true\n begin(start.y, start.time)\n }\n\n const onMove = (event: TouchEvent) => {\n const touch = event.touches[0]\n if (startY === null && pending && touch) decide(event, touch)\n if (startY === null || !touch) return\n event.preventDefault()\n const { clientY } = touch\n speed = (clientY - lastY) / Math.max(1, event.timeStamp - lastTime)\n lastY = clientY\n lastTime = event.timeStamp\n panel.style.transition = \"none\"\n panel.style.transform = `translateY(${Math.max(0, clientY - startY)}px)`\n }\n\n const onEnd = (event: TouchEvent) => {\n pending = null\n if (startY === null) return\n const travelled = lastY - startY\n // A pull from the content ends where it lifted, not in a press of the row under it. A finger that barely\n // moved keeps its tap.\n if (fromContent && travelled > DECIDE && event.cancelable) event.preventDefault()\n fromContent = false\n // A finger that rested before lifting is no flick, and gives the sheet no speed.\n const moving = event.timeStamp - lastTime < REST\n const velocity = moving ? speed : 0\n const flick = speed > CLOSE_SPEED && moving\n startY = null\n if (travelled <= 0) {\n clear()\n return\n }\n const height = panel.getBoundingClientRect().height\n if (travelled > height * CLOSE_SHARE || flick) {\n // The normal/exit-start CSS states retain this exact release position.\n // No inline transform or transition may mask the active CSS exit.\n panel.style.setProperty(DRAG_TRANSFORM, `translateY(${travelled}px)`)\n clearInline()\n // The rest of the way down goes on at the finger's speed, within the time the dialog gives its exit\n const presentedFrom = panel.hasAttribute(PRESENTED_FROM)\n panel.removeAttribute(PRESENTED_FROM)\n if (!reducedMotion(view)) {\n const left = Math.max(1, height - travelled)\n const spring = springEasing(SHEET_RELEASE_SPRING, (Math.max(0, velocity) * 1000) / left, true)\n panel.style.setProperty(EXIT_DURATION, `${Math.min(spring.ms, SHEET_EXIT_MS)}ms`)\n panel.style.setProperty(EXIT_EASING, spring.easing)\n }\n // An owner can veto close. Register before close, which can detach us.\n settleTimer = view.setTimeout(() => {\n settleTimer = undefined\n if (!panel.isConnected || panel.closest(EXITING)) return\n // An owner that kept the dialog open without saying so: it still goes back into its button later\n if (presentedFrom) panel.setAttribute(PRESENTED_FROM, \"\")\n returnToRest(travelled, velocity)\n }, SETTLE)\n if (close(event) === false) {\n if (presentedFrom) panel.setAttribute(PRESENTED_FROM, \"\")\n returnToRest(travelled, velocity)\n }\n return\n }\n returnToRest(travelled, velocity)\n }\n\n const onCancel = () => {\n startY = null\n pending = null\n fromContent = false\n clear()\n }\n\n // A retained panel can reopen before its exit completes. Its new entrance\n // must return to rest, not finish at the old gesture's release offset.\n const dialog = panel.closest(\"[data-plex-dialog]\")\n const stateObserver = dialog ? new view.MutationObserver((records) => {\n if (panel.style.getPropertyValue(DRAG_TRANSFORM) &&\n dialog.getAttribute(\"data-state\") === \"open\" &&\n records.some((record) => record.oldValue === \"closed\")) clear()\n }) : undefined\n stateObserver?.observe(dialog ?? panel, {\n attributes: true, attributeFilter: [\"data-state\"], attributeOldValue: true,\n })\n\n panel.addEventListener(\"touchstart\", onStart, { passive: true })\n panel.addEventListener(\"touchmove\", onMove, { passive: false })\n panel.addEventListener(\"touchend\", onEnd)\n panel.addEventListener(\"touchcancel\", onCancel)\n\n return () => {\n unwatchFull()\n stateObserver?.disconnect()\n panel.removeEventListener(\"touchstart\", onStart)\n panel.removeEventListener(\"touchmove\", onMove)\n panel.removeEventListener(\"touchend\", onEnd)\n panel.removeEventListener(\"touchcancel\", onCancel)\n startY = null\n pending = null\n clear()\n }\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import clsx, {} from "clsx";
2
- import { Comment, Fragment, Static, Text, camelize, cloneVNode, defineComponent, h, isVNode, mergeProps, useId, } from "vue";
2
+ import { Comment, Fragment, Static, Text, camelize, cloneVNode, defineComponent, h, isVNode, mergeProps, onBeforeUnmount, onMounted, onUpdated, useId, } from "vue";
3
3
  import { FieldError } from "../FieldError/index.js";
4
- import { provideFieldRow } from "../../lib/fieldRow.js";
4
+ import { blankPlaceholder, provideFieldRow } from "../../lib/fieldRow.js";
5
5
  import { hasContent } from "../../lib/slotContent.js";
6
6
  import s from "@plexui/styles/components/Field/Field.module.css";
7
7
  // Vue port of packages/ui/src/components/Field/Field.tsx.
@@ -152,7 +152,12 @@ const FieldComponent = defineComponent({
152
152
  size: String,
153
153
  /** Shows a required asterisk after the label. Visual only: no `required` attribute. @default false */
154
154
  required: { type: Boolean, default: false },
155
- /** Layout direction of label and control. @default "horizontal" on a `row` with a visible label, else "vertical" */
155
+ /**
156
+ * Layout direction of label and control. In the Plex Android look a vertical `row` whose control is
157
+ * an Input or a Textarea is a field of an input card: the label stands in the empty field as its hint and floats
158
+ * over the value once the field has the focus or a value, with a line under the field.
159
+ * @default "horizontal" on a `row` with a visible label, else "vertical"
160
+ */
156
161
  orientation: String,
157
162
  /** One line of a FieldGroup. Its non-interactive area focuses the text editor or activates the choice control or popup trigger. @default false */
158
163
  row: { type: Boolean, default: false },
@@ -168,6 +173,28 @@ const FieldComponent = defineComponent({
168
173
  const generatedId = useId();
169
174
  let forwardingRowClick = false;
170
175
  provideFieldRow(() => !!props.row && (props.orientation ?? (props.hideLabel ? "vertical" : "horizontal")) === "horizontal");
176
+ // In the Plex Android look a text field under its shown label floats the label in its place while it is empty
177
+ let blankControlId = "";
178
+ let blankActive = false;
179
+ let blank = null;
180
+ const syncBlank = () => {
181
+ if (blankActive && !blank) {
182
+ blank = blankPlaceholder(() => blankControlId);
183
+ blank.start();
184
+ }
185
+ else if (!blankActive && blank) {
186
+ blank.stop();
187
+ blank = null;
188
+ }
189
+ else
190
+ blank?.sync();
191
+ };
192
+ onMounted(syncBlank);
193
+ onUpdated(syncBlank);
194
+ onBeforeUnmount(() => {
195
+ blank?.stop();
196
+ blank = null;
197
+ });
171
198
  return () => {
172
199
  const { required, row, opticallyAlign } = props;
173
200
  const orientation = props.orientation ?? (row && !props.hideLabel ? "horizontal" : "vertical");
@@ -203,6 +230,8 @@ const FieldComponent = defineComponent({
203
230
  resolvedChildren = child ? [cloneWithFieldProps(child, { ...fieldChildProps, id: controlId }, labelId)] : nodes;
204
231
  }
205
232
  const size = props.size ?? (CONTROL_SIZES.has(childSize) ? childSize : "md");
233
+ blankControlId = controlId;
234
+ blankActive = !!row && orientation === "vertical" && !props.hideLabel;
206
235
  const icon = row && slots.icon ? slots.icon() : null;
207
236
  const labelAction = slots.labelAction ? slots.labelAction() : props.labelAction;
208
237
  const hasLabelAction = slots.labelAction ? hasContent(labelAction) : !!labelAction;
@@ -1 +1 @@
1
- {"version":3,"file":"Field.js","sourceRoot":"","sources":["../../../../src/components/Field/Field.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,EAAE,EAAmB,MAAM,MAAM,CAAA;AAC5C,OAAO,EACL,OAAO,E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AC,CAAC,CAAC,IAAI;iBAC3G,CAAC;gBACF,CAAC,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE;oBAC7B,CAAC,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,gBAAgB,CAAC;oBAChD,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,YAA0B,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI;iBACrF,CAAC;gBACF,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI;aAC7E,CACF,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAOF,mFAAmF;AACnF,MAAM,CAAC,MAAM,KAAK,GAAG,cAA4E,CAAA","sourcesContent":["import clsx, { type ClassValue } from \"clsx\"\nimport {\n Comment,\n Fragment,\n Static,\n Text,\n camelize,\n cloneVNode,\n defineComponent,\n h,\n isVNode,\n mergeProps,\n useId,\n type PropType,\n type SlotsType,\n type VNode,\n type VNodeArrayChildren,\n type VNodeChild,\n} from \"vue\"\nimport type { ControlSize } from \"@plexui/styles/types\"\nimport { FieldError } from \"../FieldError/index.js\"\nimport { provideFieldRow } from \"../../lib/fieldRow.js\"\nimport { hasContent } from \"../../lib/slotContent.js\"\nimport s from \"@plexui/styles/components/Field/Field.module.css\"\n\n// Vue port of packages/ui/src/components/Field/Field.tsx.\n//\n// - `label`, `description` and `errorMessage` take a string prop or a slot of\n// the same name (the slot wins), like React's ReactNode props.\n// - Children: React accepts an element, which Field clones with the field\n// props, or a render prop `(fieldProps) => ReactNode`, which it leaves alone.\n// Both are the default slot here, which receives the field props:\n// - a slot that reads them (`v-slot=\"fieldProps\"` + `v-bind=\"fieldProps\"`,\n// `v-slot=\"{ id }\"`, `(fieldProps) => h(...)`) is the render prop: its\n// content renders as it is.\n// - a slot that does not read them and holds exactly one element or\n// component gets it cloned like React's `cloneElement`: `opticallyAlign`\n// replaces the child's own, the child's own `id` stays and the label's\n// `for` follows it, `aria-describedby` is joined after the child's own\n// ids, and an explicit `aria-invalid` on the child wins. Template\n// comments do not count as children (JSX comments); the\n// placeholder of a `v-if` that renders nothing does, like `{false}` in a\n// React children array, so `<A v-if=\"x\" /><Input />` is not cloned.\n// - anything else (text, several roots, a `v-for` list) renders as it is,\n// like a React child that is not a single element.\n// - content a wrapper forwards with `<slot />` counts as its own roots, as\n// React's `children` passed on to Field are the elements themselves.\n// - As in React only `class` reaches the root element; other attributes are\n// dropped. On a `row` they all reach it, as React's rest props do.\n\n// What a row's press can reach: a form control, a popup trigger, a choice\nconst ROW_CONTROL = 'input:not([type=\"hidden\"]):not([aria-hidden=\"true\"]), textarea, select, button, [role=\"button\"], [role=\"switch\"], [role=\"checkbox\"], [role=\"radio\"], [role=\"combobox\"]'\n\n/** The one control inside a wrapper that took the Field's id; a control nested in another (a clear button in a\n * trigger) counts as part of it. */\nfunction soleRowControl(wrapper: HTMLElement): HTMLElement | null {\n const found = Array.from(wrapper.querySelectorAll<HTMLElement>(ROW_CONTROL))\n const outer = found.filter((element) => !found.some((other) => other !== element && other.contains(element)))\n return outer.length === 1 ? outer[0] : null\n}\n\nexport type FieldChildProps = {\n id: string\n /** The label's id. Bind it to a control that the label's `for` cannot name, such as a Select trigger. */\n \"aria-labelledby\"?: string\n \"aria-describedby\"?: string\n \"aria-invalid\"?: boolean\n opticallyAlign?: \"start\" | \"end\"\n}\n\ntype Props = Record<string, unknown>\n\nconst CONTROL_SIZES: ReadonlySet<unknown> = new Set([\"3xs\", \"2xs\", \"xs\", \"sm\", \"md\", \"lg\", \"xl\", \"2xl\", \"3xl\"])\n\n/** The slot props, recording whether the slot read them (the render-prop form). */\nconst trackUse = (target: FieldChildProps) => {\n const state = { used: false }\n const proxy = new Proxy(target, {\n get(object, key, receiver) {\n state.used = true\n return Reflect.get(object, key, receiver)\n },\n has(object, key) {\n state.used = true\n return Reflect.has(object, key)\n },\n ownKeys(object) {\n state.used = true\n return Reflect.ownKeys(object)\n },\n getOwnPropertyDescriptor(object, key) {\n state.used = true\n return Reflect.getOwnPropertyDescriptor(object, key)\n },\n })\n return { proxy, state }\n}\n\n/** Like React's `isValidElement` for a slot root: an element or a component. */\nconst isElementVNode = (node: VNode) => {\n const { type } = node\n if (type === Fragment || type === Text || type === Comment || type === Static) return false\n if (typeof type === \"object\" && type !== null && (\"__isTeleport\" in type || \"__isSuspense\" in type)) return false\n return true\n}\n\n/**\n * Template comments (`<!-- note -->`) are no children, like JSX comments.\n * The empty placeholder of a `v-if` that renders nothing (or of a `false`\n * child) still counts, like `{false}` in a React children array.\n */\nconst isTemplateComment = (node: VNodeArrayChildren[number]) =>\n isVNode(node) && node.type === Comment && !!node.children && node.children !== \"v-if\"\n\n/**\n * Unwraps content forwarded through a wrapper's `<slot />`: the fragment\n * `renderSlot` creates, keyed `_<slot name>`.\n */\nconst unwrapForwardedSlots = (nodes: VNodeArrayChildren): VNodeArrayChildren =>\n nodes.flatMap((node) =>\n isVNode(node) &&\n node.type === Fragment &&\n typeof node.key === \"string\" &&\n node.key.startsWith(\"_\") &&\n Array.isArray(node.children)\n ? unwrapForwardedSlots(node.children)\n : [node],\n )\n\n/** The one element a non-render-prop slot holds, if it holds exactly one. */\nconst singleElement = (nodes: VNodeArrayChildren): VNode | undefined => {\n const roots = unwrapForwardedSlots(nodes).filter((node) => !isTemplateComment(node))\n if (roots.length !== 1) return undefined\n const [root] = roots\n return isVNode(root) && isElementVNode(root) ? root : undefined\n}\n\n/** A child prop under its attribute name or its camelCase prop name. */\nconst childProp = (props: Props, name: string) => props[name] ?? props[camelize(name)]\n\n/**\n * `cloneElement(child, fieldProps)` with React Field's merging rules. A child\n * without its own name (`aria-label`, `aria-labelledby`, `label`, a `#label`\n * slot) is also labelled by the field's label, which names triggers `for`\n * cannot reach.\n */\nconst cloneWithFieldProps = (child: VNode, fieldChildProps: FieldChildProps, labelId: string): VNode => {\n const own: Props = { ...(child.props ?? {}) }\n const childDescribedBy = childProp(own, \"aria-describedby\") as string | undefined\n const childInvalid = childProp(own, \"aria-invalid\")\n const childSlots = child.children\n const childNamed =\n childProp(own, \"aria-label\") != null ||\n childProp(own, \"aria-labelledby\") != null ||\n own.label != null ||\n (childSlots != null && typeof childSlots === \"object\" && !Array.isArray(childSlots) && \"label\" in childSlots)\n\n const overrides: Props = {\n ...fieldChildProps,\n // Merge with the child's own associations instead of overwriting them\n \"aria-describedby\": [childDescribedBy, fieldChildProps[\"aria-describedby\"]].filter(Boolean).join(\" \") || undefined,\n \"aria-invalid\": childInvalid ?? fieldChildProps[\"aria-invalid\"],\n ...(!childNamed && { \"aria-labelledby\": labelId }),\n }\n\n // One spelling per prop, so the field's value is the one that applies\n for (const key of Object.keys(overrides)) {\n for (const spelling of [key, camelize(key), key.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)]) {\n delete own[spelling]\n }\n }\n\n return cloneVNode({ ...child, props: own } as VNode, overrides)\n}\n\nconst FieldComponent = defineComponent({\n name: \"Field\",\n inheritAttrs: false,\n props: {\n /** Label text for the field (or the `label` slot) */\n label: String,\n /**\n * Hides the label from view; it still names the control. On a `row` the value or placeholder\n * then starts at the row's edge, as an iOS cell that shows only its value, so the row is\n * vertical unless `orientation` says otherwise. @default false\n */\n hideLabel: { type: Boolean, default: false },\n /** Helper text below the label, linked via `aria-describedby` (or the `description` slot) */\n description: String,\n /**\n * Error message below the control (or the `errorMessage` slot). When set,\n * the control gets `aria-invalid=\"true\"`. Rendered with FieldError.\n */\n errorMessage: String,\n /** Content at the end of the label row, such as a link that acts on the field (or the `labelAction` slot) */\n labelAction: String,\n /** Font size of the label, to match the control's size. @default the child control's `size`, else \"md\" */\n size: String as PropType<ControlSize>,\n /** Shows a required asterisk after the label. Visual only: no `required` attribute. @default false */\n required: { type: Boolean, default: false },\n /** Layout direction of label and control. @default \"horizontal\" on a `row` with a visible label, else \"vertical\" */\n orientation: String as PropType<\"vertical\" | \"horizontal\">,\n /** One line of a FieldGroup. Its non-interactive area focuses the text editor or activates the choice control or popup trigger. @default false */\n row: { type: Boolean, default: false },\n /** On a `row`, the control takes the rest of the line after the label. @default false */\n fill: { type: Boolean, default: false },\n /** Overrides the generated id set on the control and the label's `for`. A child's own `id` wins over both. */\n id: String,\n /** Optically aligns the control's text with surrounding content; passed to the control. */\n opticallyAlign: String as PropType<\"start\" | \"end\">,\n },\n slots: Object as SlotsType<{\n /** The control. Read the props to render them yourself (React's render prop). */\n default?: (fieldProps: FieldChildProps) => VNodeChild\n label?: () => VNodeChild\n labelAction?: () => VNodeChild\n /** On a `row`, a control at the end of the row, such as a button that adds to a list on a `fill` row. On a row whose\n * control is a radio (an info button after a network or a VPN) the radio's mark leads in the icon column. */\n action?: () => VNodeChild\n /** On a `row`, a symbol or an app's picture before the label, as an iOS cell's image (React's `icon`). */\n icon?: () => VNodeChild\n description?: () => VNodeChild\n errorMessage?: () => VNodeChild\n }>,\n setup(props, { attrs, slots }) {\n const generatedId = useId()\n let forwardingRowClick = false\n\n provideFieldRow(() => !!props.row && (props.orientation ?? (props.hideLabel ? \"vertical\" : \"horizontal\")) === \"horizontal\")\n\n return () => {\n const { required, row, opticallyAlign } = props\n const orientation = props.orientation ?? (row && !props.hideLabel ? \"horizontal\" : \"vertical\")\n const fieldId = props.id || `field-${generatedId}`\n const labelId = `${fieldId}-label`\n\n const description = slots.description ? slots.description() : props.description\n const hasDescription = slots.description ? hasContent(description as VNodeArrayChildren) : !!description\n const errorMessage = slots.errorMessage ? slots.errorMessage() : props.errorMessage\n const hasError = slots.errorMessage ? hasContent(errorMessage as VNodeArrayChildren) : !!errorMessage\n\n const descriptionId = hasDescription ? `${fieldId}-description` : undefined\n const errorId = hasError ? `${fieldId}-error` : undefined\n\n // Build aria-describedby from description + error IDs\n const ariaDescribedBy = [descriptionId, errorId].filter(Boolean).join(\" \") || undefined\n const invalid = hasError\n\n // Props to inject into the child control\n const fieldChildProps: FieldChildProps = {\n \"id\": fieldId,\n \"aria-describedby\": ariaDescribedBy,\n \"aria-invalid\": invalid || undefined,\n ...(opticallyAlign && { opticallyAlign }),\n }\n\n // Resolve the children\n let resolvedChildren: VNodeArrayChildren | undefined\n let childSize: unknown\n // The control's id, which the label's `for` has to match\n let controlId = fieldId\n if (slots.default) {\n const { proxy, state } = trackUse({ ...fieldChildProps, \"aria-labelledby\": labelId })\n const nodes = slots.default(proxy) as VNodeArrayChildren\n const child = state.used ? undefined : singleElement(nodes)\n childSize = child?.props?.size\n controlId = (child?.props?.id as string | undefined) || fieldId\n resolvedChildren = child ? [cloneWithFieldProps(child, { ...fieldChildProps, id: controlId }, labelId)] : nodes\n }\n const size = props.size ?? (CONTROL_SIZES.has(childSize) ? (childSize as ControlSize) : \"md\")\n\n const icon = row && slots.icon ? slots.icon() : null\n const labelAction = slots.labelAction ? slots.labelAction() : props.labelAction\n const hasLabelAction = slots.labelAction ? hasContent(labelAction as VNodeArrayChildren) : !!labelAction\n const labelElement = h(\"label\", { class: s.Label, id: labelId, for: controlId }, [\n slots.label ? slots.label() : props.label,\n required ? h(\"span\", { \"class\": s.RequiredIndicator, \"aria-hidden\": \"true\" }, \"*\") : null,\n ])\n\n return h(\n \"div\",\n mergeProps({\n ...(row && { ...attrs, onClick: undefined }),\n \"class\": clsx(s.Field, attrs.class as ClassValue),\n \"data-slot\": \"field\",\n \"data-size\": size,\n \"data-orientation\": orientation,\n \"data-optically-align\": opticallyAlign,\n \"data-row\": row ? \"\" : undefined,\n \"data-fill\": props.fill ? \"\" : undefined,\n \"data-label-hidden\": props.hideLabel ? \"\" : undefined,\n }, row ? {\n onClick: (event: MouseEvent) => {\n if (forwardingRowClick) return\n for (const handler of Array.isArray(attrs.onClick) ? attrs.onClick : [attrs.onClick]) {\n if (typeof handler === \"function\") handler(event)\n }\n if (event.defaultPrevented) return\n const target = event.target\n const root = event.currentTarget\n // The linked control keeps its state and keyboard behavior. Nested\n // actions, including a Select's clear button, keep their own click.\n if (!(target instanceof Element) || !(root instanceof HTMLElement) ||\n target.closest(\"[data-row]\") !== root ||\n target.closest('button, a, input, select, textarea, [role=\"button\"], [role=\"link\"], [contenteditable]:not([contenteditable=\"false\"])')) return\n const linkedControl = root.ownerDocument.getElementById(controlId)\n if (!linkedControl || linkedControl.closest(\"[data-row]\") !== root) return\n // Select's linked form proxy is inside its popup trigger. An\n // ordinary input never delegates to a sibling Unit popup.\n const direct = linkedControl.matches('input[aria-hidden=\"true\"]')\n ? linkedControl.closest<HTMLElement>(':is(button, [role=\"button\"])[aria-haspopup]:not([aria-haspopup=\"false\"])') ?? linkedControl\n : linkedControl\n // A product's own wrapper may take the id (a row component around a Select): the row then reaches the one\n // control inside it, as an iOS cell does; with two controls, or none, the press stays on the row.\n const control = direct === linkedControl && !linkedControl.matches(ROW_CONTROL) ? soleRowControl(linkedControl) : direct\n // A control of a row nested in the wrapper belongs to that row\n if (!control || control.closest(\"[data-row]\") !== root) return\n if (control.matches(':disabled, [disabled], [data-disabled], [aria-disabled=\"true\"], [data-loading], [aria-busy=\"true\"]')) return\n const label = target.closest(\"label\")\n // Native label activation stays native; span popup triggers need\n // forwarding from the Field's own label as well as its whitespace.\n if (label && (label.htmlFor !== linkedControl.id || label.control === linkedControl)) return\n // The row is the hit area for its plain editor. Focus only: a synthetic\n // click would also run input actions or disturb native text selection.\n if (control.matches('textarea, input:not([type]), input[type=\"text\"], input[type=\"email\"], input[type=\"password\"], input[type=\"search\"], input[type=\"tel\"], input[type=\"url\"], input[type=\"number\"]') &&\n !control.matches('[hidden], [aria-hidden=\"true\"]')) {\n control.focus({ preventScroll: true })\n return\n }\n if (!control.matches('button[role=\"radio\"], button[role=\"checkbox\"], button[role=\"switch\"], input[type=\"radio\"], input[type=\"checkbox\"], :is(button, [role=\"button\"])[aria-haspopup]:not([aria-haspopup=\"false\"])')) return\n forwardingRowClick = true\n try {\n control.focus({ preventScroll: true })\n control.click()\n } finally {\n // Form controls can bubble their hidden input click after the render flush.\n queueMicrotask(() => { forwardingRowClick = false })\n }\n },\n } : {}),\n [\n icon && hasContent(icon as VNodeArrayChildren) ? h(\"div\", { class: s.Icon, \"aria-hidden\": \"true\" }, [icon as VNodeChild]) : null,\n h(\"div\", { class: s.LabelGroup }, [\n hasLabelAction\n ? h(\"div\", { class: s.LabelRow }, [labelElement, h(\"div\", { class: s.LabelAction }, [labelAction as VNodeChild])])\n : labelElement,\n hasDescription ? h(\"div\", { class: s.Description, id: descriptionId }, [description as VNodeChild]) : null,\n ]),\n h(\"div\", { class: s.Content }, [\n h(\"div\", { class: s.Control }, resolvedChildren),\n hasError ? h(FieldError, { id: errorId }, () => [errorMessage as VNodeChild]) : null,\n ]),\n row && slots.action ? h(\"div\", { class: s.Action }, [slots.action()]) : null,\n ],\n )\n }\n },\n})\n\ntype FieldOwnProps = InstanceType<typeof FieldComponent>[\"$props\"]\n\n/** Field props; `class` reaches the root element. */\nexport type FieldProps = FieldOwnProps & { class?: ClassValue }\n\n/** Form field wrapper with label, description, error and accessibility linking. */\nexport const Field = FieldComponent as typeof FieldComponent & { new (): { $props: FieldProps } }\n"]}
1
+ {"version":3,"file":"Field.js","sourceRoot":"","sources":["../../../../src/components/Field/Field.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,EAAE,EAAmB,MAAM,MAAM,CAAA;AAC5C,OAAO,EACL,OAAO,EACP,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,eAAe,EACf,CAAC,EACD,OAAO,EACP,UAAU,EACV,eAAe,EACf,SAAS,EACT,SAAS,EACT,KAAK,GAMN,MAAM,KAAK,CAAA;AAEZ,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAA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,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAOF,mFAAmF;AACnF,MAAM,CAAC,MAAM,KAAK,GAAG,cAA4E,CAAA","sourcesContent":["import clsx, { type ClassValue } from \"clsx\"\nimport {\n Comment,\n Fragment,\n Static,\n Text,\n camelize,\n cloneVNode,\n defineComponent,\n h,\n isVNode,\n mergeProps,\n onBeforeUnmount,\n onMounted,\n onUpdated,\n useId,\n type PropType,\n type SlotsType,\n type VNode,\n type VNodeArrayChildren,\n type VNodeChild,\n} from \"vue\"\nimport type { ControlSize } from \"@plexui/styles/types\"\nimport { FieldError } from \"../FieldError/index.js\"\nimport { blankPlaceholder, provideFieldRow } from \"../../lib/fieldRow.js\"\nimport { hasContent } from \"../../lib/slotContent.js\"\nimport s from \"@plexui/styles/components/Field/Field.module.css\"\n\n// Vue port of packages/ui/src/components/Field/Field.tsx.\n//\n// - `label`, `description` and `errorMessage` take a string prop or a slot of\n// the same name (the slot wins), like React's ReactNode props.\n// - Children: React accepts an element, which Field clones with the field\n// props, or a render prop `(fieldProps) => ReactNode`, which it leaves alone.\n// Both are the default slot here, which receives the field props:\n// - a slot that reads them (`v-slot=\"fieldProps\"` + `v-bind=\"fieldProps\"`,\n// `v-slot=\"{ id }\"`, `(fieldProps) => h(...)`) is the render prop: its\n// content renders as it is.\n// - a slot that does not read them and holds exactly one element or\n// component gets it cloned like React's `cloneElement`: `opticallyAlign`\n// replaces the child's own, the child's own `id` stays and the label's\n// `for` follows it, `aria-describedby` is joined after the child's own\n// ids, and an explicit `aria-invalid` on the child wins. Template\n// comments do not count as children (JSX comments); the\n// placeholder of a `v-if` that renders nothing does, like `{false}` in a\n// React children array, so `<A v-if=\"x\" /><Input />` is not cloned.\n// - anything else (text, several roots, a `v-for` list) renders as it is,\n// like a React child that is not a single element.\n// - content a wrapper forwards with `<slot />` counts as its own roots, as\n// React's `children` passed on to Field are the elements themselves.\n// - As in React only `class` reaches the root element; other attributes are\n// dropped. On a `row` they all reach it, as React's rest props do.\n\n// What a row's press can reach: a form control, a popup trigger, a choice\nconst ROW_CONTROL = 'input:not([type=\"hidden\"]):not([aria-hidden=\"true\"]), textarea, select, button, [role=\"button\"], [role=\"switch\"], [role=\"checkbox\"], [role=\"radio\"], [role=\"combobox\"]'\n\n/** The one control inside a wrapper that took the Field's id; a control nested in another (a clear button in a\n * trigger) counts as part of it. */\nfunction soleRowControl(wrapper: HTMLElement): HTMLElement | null {\n const found = Array.from(wrapper.querySelectorAll<HTMLElement>(ROW_CONTROL))\n const outer = found.filter((element) => !found.some((other) => other !== element && other.contains(element)))\n return outer.length === 1 ? outer[0] : null\n}\n\nexport type FieldChildProps = {\n id: string\n /** The label's id. Bind it to a control that the label's `for` cannot name, such as a Select trigger. */\n \"aria-labelledby\"?: string\n \"aria-describedby\"?: string\n \"aria-invalid\"?: boolean\n opticallyAlign?: \"start\" | \"end\"\n}\n\ntype Props = Record<string, unknown>\n\nconst CONTROL_SIZES: ReadonlySet<unknown> = new Set([\"3xs\", \"2xs\", \"xs\", \"sm\", \"md\", \"lg\", \"xl\", \"2xl\", \"3xl\"])\n\n/** The slot props, recording whether the slot read them (the render-prop form). */\nconst trackUse = (target: FieldChildProps) => {\n const state = { used: false }\n const proxy = new Proxy(target, {\n get(object, key, receiver) {\n state.used = true\n return Reflect.get(object, key, receiver)\n },\n has(object, key) {\n state.used = true\n return Reflect.has(object, key)\n },\n ownKeys(object) {\n state.used = true\n return Reflect.ownKeys(object)\n },\n getOwnPropertyDescriptor(object, key) {\n state.used = true\n return Reflect.getOwnPropertyDescriptor(object, key)\n },\n })\n return { proxy, state }\n}\n\n/** Like React's `isValidElement` for a slot root: an element or a component. */\nconst isElementVNode = (node: VNode) => {\n const { type } = node\n if (type === Fragment || type === Text || type === Comment || type === Static) return false\n if (typeof type === \"object\" && type !== null && (\"__isTeleport\" in type || \"__isSuspense\" in type)) return false\n return true\n}\n\n/**\n * Template comments (`<!-- note -->`) are no children, like JSX comments.\n * The empty placeholder of a `v-if` that renders nothing (or of a `false`\n * child) still counts, like `{false}` in a React children array.\n */\nconst isTemplateComment = (node: VNodeArrayChildren[number]) =>\n isVNode(node) && node.type === Comment && !!node.children && node.children !== \"v-if\"\n\n/**\n * Unwraps content forwarded through a wrapper's `<slot />`: the fragment\n * `renderSlot` creates, keyed `_<slot name>`.\n */\nconst unwrapForwardedSlots = (nodes: VNodeArrayChildren): VNodeArrayChildren =>\n nodes.flatMap((node) =>\n isVNode(node) &&\n node.type === Fragment &&\n typeof node.key === \"string\" &&\n node.key.startsWith(\"_\") &&\n Array.isArray(node.children)\n ? unwrapForwardedSlots(node.children)\n : [node],\n )\n\n/** The one element a non-render-prop slot holds, if it holds exactly one. */\nconst singleElement = (nodes: VNodeArrayChildren): VNode | undefined => {\n const roots = unwrapForwardedSlots(nodes).filter((node) => !isTemplateComment(node))\n if (roots.length !== 1) return undefined\n const [root] = roots\n return isVNode(root) && isElementVNode(root) ? root : undefined\n}\n\n/** A child prop under its attribute name or its camelCase prop name. */\nconst childProp = (props: Props, name: string) => props[name] ?? props[camelize(name)]\n\n/**\n * `cloneElement(child, fieldProps)` with React Field's merging rules. A child\n * without its own name (`aria-label`, `aria-labelledby`, `label`, a `#label`\n * slot) is also labelled by the field's label, which names triggers `for`\n * cannot reach.\n */\nconst cloneWithFieldProps = (child: VNode, fieldChildProps: FieldChildProps, labelId: string): VNode => {\n const own: Props = { ...(child.props ?? {}) }\n const childDescribedBy = childProp(own, \"aria-describedby\") as string | undefined\n const childInvalid = childProp(own, \"aria-invalid\")\n const childSlots = child.children\n const childNamed =\n childProp(own, \"aria-label\") != null ||\n childProp(own, \"aria-labelledby\") != null ||\n own.label != null ||\n (childSlots != null && typeof childSlots === \"object\" && !Array.isArray(childSlots) && \"label\" in childSlots)\n\n const overrides: Props = {\n ...fieldChildProps,\n // Merge with the child's own associations instead of overwriting them\n \"aria-describedby\": [childDescribedBy, fieldChildProps[\"aria-describedby\"]].filter(Boolean).join(\" \") || undefined,\n \"aria-invalid\": childInvalid ?? fieldChildProps[\"aria-invalid\"],\n ...(!childNamed && { \"aria-labelledby\": labelId }),\n }\n\n // One spelling per prop, so the field's value is the one that applies\n for (const key of Object.keys(overrides)) {\n for (const spelling of [key, camelize(key), key.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)]) {\n delete own[spelling]\n }\n }\n\n return cloneVNode({ ...child, props: own } as VNode, overrides)\n}\n\nconst FieldComponent = defineComponent({\n name: \"Field\",\n inheritAttrs: false,\n props: {\n /** Label text for the field (or the `label` slot) */\n label: String,\n /**\n * Hides the label from view; it still names the control. On a `row` the value or placeholder\n * then starts at the row's edge, as an iOS cell that shows only its value, so the row is\n * vertical unless `orientation` says otherwise. @default false\n */\n hideLabel: { type: Boolean, default: false },\n /** Helper text below the label, linked via `aria-describedby` (or the `description` slot) */\n description: String,\n /**\n * Error message below the control (or the `errorMessage` slot). When set,\n * the control gets `aria-invalid=\"true\"`. Rendered with FieldError.\n */\n errorMessage: String,\n /** Content at the end of the label row, such as a link that acts on the field (or the `labelAction` slot) */\n labelAction: String,\n /** Font size of the label, to match the control's size. @default the child control's `size`, else \"md\" */\n size: String as PropType<ControlSize>,\n /** Shows a required asterisk after the label. Visual only: no `required` attribute. @default false */\n required: { type: Boolean, default: false },\n /**\n * Layout direction of label and control. In the Plex Android look a vertical `row` whose control is\n * an Input or a Textarea is a field of an input card: the label stands in the empty field as its hint and floats\n * over the value once the field has the focus or a value, with a line under the field.\n * @default \"horizontal\" on a `row` with a visible label, else \"vertical\"\n */\n orientation: String as PropType<\"vertical\" | \"horizontal\">,\n /** One line of a FieldGroup. Its non-interactive area focuses the text editor or activates the choice control or popup trigger. @default false */\n row: { type: Boolean, default: false },\n /** On a `row`, the control takes the rest of the line after the label. @default false */\n fill: { type: Boolean, default: false },\n /** Overrides the generated id set on the control and the label's `for`. A child's own `id` wins over both. */\n id: String,\n /** Optically aligns the control's text with surrounding content; passed to the control. */\n opticallyAlign: String as PropType<\"start\" | \"end\">,\n },\n slots: Object as SlotsType<{\n /** The control. Read the props to render them yourself (React's render prop). */\n default?: (fieldProps: FieldChildProps) => VNodeChild\n label?: () => VNodeChild\n labelAction?: () => VNodeChild\n /** On a `row`, a control at the end of the row, such as a button that adds to a list on a `fill` row. On a row whose\n * control is a radio (an info button after a network or a VPN) the radio's mark leads in the icon column. */\n action?: () => VNodeChild\n /** On a `row`, a symbol or an app's picture before the label, as an iOS cell's image (React's `icon`). */\n icon?: () => VNodeChild\n description?: () => VNodeChild\n errorMessage?: () => VNodeChild\n }>,\n setup(props, { attrs, slots }) {\n const generatedId = useId()\n let forwardingRowClick = false\n\n provideFieldRow(() => !!props.row && (props.orientation ?? (props.hideLabel ? \"vertical\" : \"horizontal\")) === \"horizontal\")\n\n // In the Plex Android look a text field under its shown label floats the label in its place while it is empty\n let blankControlId = \"\"\n let blankActive = false\n let blank: ReturnType<typeof blankPlaceholder> | null = null\n const syncBlank = () => {\n if (blankActive && !blank) {\n blank = blankPlaceholder(() => blankControlId)\n blank.start()\n } else if (!blankActive && blank) {\n blank.stop()\n blank = null\n } else blank?.sync()\n }\n onMounted(syncBlank)\n onUpdated(syncBlank)\n onBeforeUnmount(() => {\n blank?.stop()\n blank = null\n })\n\n return () => {\n const { required, row, opticallyAlign } = props\n const orientation = props.orientation ?? (row && !props.hideLabel ? \"horizontal\" : \"vertical\")\n const fieldId = props.id || `field-${generatedId}`\n const labelId = `${fieldId}-label`\n\n const description = slots.description ? slots.description() : props.description\n const hasDescription = slots.description ? hasContent(description as VNodeArrayChildren) : !!description\n const errorMessage = slots.errorMessage ? slots.errorMessage() : props.errorMessage\n const hasError = slots.errorMessage ? hasContent(errorMessage as VNodeArrayChildren) : !!errorMessage\n\n const descriptionId = hasDescription ? `${fieldId}-description` : undefined\n const errorId = hasError ? `${fieldId}-error` : undefined\n\n // Build aria-describedby from description + error IDs\n const ariaDescribedBy = [descriptionId, errorId].filter(Boolean).join(\" \") || undefined\n const invalid = hasError\n\n // Props to inject into the child control\n const fieldChildProps: FieldChildProps = {\n \"id\": fieldId,\n \"aria-describedby\": ariaDescribedBy,\n \"aria-invalid\": invalid || undefined,\n ...(opticallyAlign && { opticallyAlign }),\n }\n\n // Resolve the children\n let resolvedChildren: VNodeArrayChildren | undefined\n let childSize: unknown\n // The control's id, which the label's `for` has to match\n let controlId = fieldId\n if (slots.default) {\n const { proxy, state } = trackUse({ ...fieldChildProps, \"aria-labelledby\": labelId })\n const nodes = slots.default(proxy) as VNodeArrayChildren\n const child = state.used ? undefined : singleElement(nodes)\n childSize = child?.props?.size\n controlId = (child?.props?.id as string | undefined) || fieldId\n resolvedChildren = child ? [cloneWithFieldProps(child, { ...fieldChildProps, id: controlId }, labelId)] : nodes\n }\n const size = props.size ?? (CONTROL_SIZES.has(childSize) ? (childSize as ControlSize) : \"md\")\n blankControlId = controlId\n blankActive = !!row && orientation === \"vertical\" && !props.hideLabel\n\n const icon = row && slots.icon ? slots.icon() : null\n const labelAction = slots.labelAction ? slots.labelAction() : props.labelAction\n const hasLabelAction = slots.labelAction ? hasContent(labelAction as VNodeArrayChildren) : !!labelAction\n const labelElement = h(\"label\", { class: s.Label, id: labelId, for: controlId }, [\n slots.label ? slots.label() : props.label,\n required ? h(\"span\", { \"class\": s.RequiredIndicator, \"aria-hidden\": \"true\" }, \"*\") : null,\n ])\n\n return h(\n \"div\",\n mergeProps({\n ...(row && { ...attrs, onClick: undefined }),\n \"class\": clsx(s.Field, attrs.class as ClassValue),\n \"data-slot\": \"field\",\n \"data-size\": size,\n \"data-orientation\": orientation,\n \"data-optically-align\": opticallyAlign,\n \"data-row\": row ? \"\" : undefined,\n \"data-fill\": props.fill ? \"\" : undefined,\n \"data-label-hidden\": props.hideLabel ? \"\" : undefined,\n }, row ? {\n onClick: (event: MouseEvent) => {\n if (forwardingRowClick) return\n for (const handler of Array.isArray(attrs.onClick) ? attrs.onClick : [attrs.onClick]) {\n if (typeof handler === \"function\") handler(event)\n }\n if (event.defaultPrevented) return\n const target = event.target\n const root = event.currentTarget\n // The linked control keeps its state and keyboard behavior. Nested\n // actions, including a Select's clear button, keep their own click.\n if (!(target instanceof Element) || !(root instanceof HTMLElement) ||\n target.closest(\"[data-row]\") !== root ||\n target.closest('button, a, input, select, textarea, [role=\"button\"], [role=\"link\"], [contenteditable]:not([contenteditable=\"false\"])')) return\n const linkedControl = root.ownerDocument.getElementById(controlId)\n if (!linkedControl || linkedControl.closest(\"[data-row]\") !== root) return\n // Select's linked form proxy is inside its popup trigger. An\n // ordinary input never delegates to a sibling Unit popup.\n const direct = linkedControl.matches('input[aria-hidden=\"true\"]')\n ? linkedControl.closest<HTMLElement>(':is(button, [role=\"button\"])[aria-haspopup]:not([aria-haspopup=\"false\"])') ?? linkedControl\n : linkedControl\n // A product's own wrapper may take the id (a row component around a Select): the row then reaches the one\n // control inside it, as an iOS cell does; with two controls, or none, the press stays on the row.\n const control = direct === linkedControl && !linkedControl.matches(ROW_CONTROL) ? soleRowControl(linkedControl) : direct\n // A control of a row nested in the wrapper belongs to that row\n if (!control || control.closest(\"[data-row]\") !== root) return\n if (control.matches(':disabled, [disabled], [data-disabled], [aria-disabled=\"true\"], [data-loading], [aria-busy=\"true\"]')) return\n const label = target.closest(\"label\")\n // Native label activation stays native; span popup triggers need\n // forwarding from the Field's own label as well as its whitespace.\n if (label && (label.htmlFor !== linkedControl.id || label.control === linkedControl)) return\n // The row is the hit area for its plain editor. Focus only: a synthetic\n // click would also run input actions or disturb native text selection.\n if (control.matches('textarea, input:not([type]), input[type=\"text\"], input[type=\"email\"], input[type=\"password\"], input[type=\"search\"], input[type=\"tel\"], input[type=\"url\"], input[type=\"number\"]') &&\n !control.matches('[hidden], [aria-hidden=\"true\"]')) {\n control.focus({ preventScroll: true })\n return\n }\n if (!control.matches('button[role=\"radio\"], button[role=\"checkbox\"], button[role=\"switch\"], input[type=\"radio\"], input[type=\"checkbox\"], :is(button, [role=\"button\"])[aria-haspopup]:not([aria-haspopup=\"false\"])')) return\n forwardingRowClick = true\n try {\n control.focus({ preventScroll: true })\n control.click()\n } finally {\n // Form controls can bubble their hidden input click after the render flush.\n queueMicrotask(() => { forwardingRowClick = false })\n }\n },\n } : {}),\n [\n icon && hasContent(icon as VNodeArrayChildren) ? h(\"div\", { class: s.Icon, \"aria-hidden\": \"true\" }, [icon as VNodeChild]) : null,\n h(\"div\", { class: s.LabelGroup }, [\n hasLabelAction\n ? h(\"div\", { class: s.LabelRow }, [labelElement, h(\"div\", { class: s.LabelAction }, [labelAction as VNodeChild])])\n : labelElement,\n hasDescription ? h(\"div\", { class: s.Description, id: descriptionId }, [description as VNodeChild]) : null,\n ]),\n h(\"div\", { class: s.Content }, [\n h(\"div\", { class: s.Control }, resolvedChildren),\n hasError ? h(FieldError, { id: errorId }, () => [errorMessage as VNodeChild]) : null,\n ]),\n row && slots.action ? h(\"div\", { class: s.Action }, [slots.action()]) : null,\n ],\n )\n }\n },\n})\n\ntype FieldOwnProps = InstanceType<typeof FieldComponent>[\"$props\"]\n\n/** Field props; `class` reaches the root element. */\nexport type FieldProps = FieldOwnProps & { class?: ClassValue }\n\n/** Form field wrapper with label, description, error and accessibility linking. */\nexport const Field = FieldComponent as typeof FieldComponent & { new (): { $props: FieldProps } }\n"]}
@@ -135,7 +135,16 @@ export const Markdown = defineComponent({
135
135
  const mergedRemarkPlugins = computed(() => {
136
136
  const baseRemarkPlugins = [
137
137
  remarkDirective,
138
- markdownRemarkDirective,
138
+ // The directives this Markdown renders as elements: its own and the components' tags
139
+ [
140
+ markdownRemarkDirective,
141
+ {
142
+ names: [
143
+ ...(props.directives?.map((directive) => directive.directiveName) ?? []),
144
+ ...Object.keys(props.components ?? {}),
145
+ ],
146
+ },
147
+ ],
139
148
  ...mathPlugins.value.remarkPlugins,
140
149
  ];
141
150
  if (props.breakNewLines) {
@@ -1 +1 @@
1
- {"version":3,"file":"Markdown.js","sourceRoot":"","sources":["../../../../src/components/Markdown/Markdown.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,eAAe,CAAA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CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC,CAAA;YAEhE,MAAM,cAAc,GAAuB;gBACzC,GAAG,iBAAiB;gBACpB,GAAG,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC,iCAAiC,CAAC,CAAC,CAAC,IAAI,CAAC;gBAC3E,GAAG,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,kCAAkC,CAAC;gBACzE,GAAG,KAAK,CAAC,UAAU;aACpB,CAAA;YACD,MAAM,UAAU,GACd,KAAK,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,GAAG,EAAE,SAAS,EAAE,EAAE;gBAC1C,GAAG,CAAC,SAAS,CAAC,aAAa,CAAC,GAAG,SAAS,CAAC,MAAM,CAAA;gBAC/C,OAAO,GAAG,CAAA;YACZ,CAAC,EAAE,cAAc,CAAC,IAAI,cAAc,CAAA;YAEtC,OAAO,cAAc,CAAC;gBACpB,QAAQ,EAAE,MAAM;gBAChB,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,eAAe,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;gBAC3D,aAAa,EAAE,mBAAmB,CAAC,KAAK;gBACxC,aAAa,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,aAAa,IAAI,EAAE,CAAC,EAAE,GAAG,WAAW,CAAC,KAAK,CAAC,aAAa,CAAC;gBACnF,UAAU;gBACV,eAAe,EAAE,KAAK,CAAC,eAAe;gBACtC,kBAAkB,EAAE,KAAK,CAAC,kBAAkB;gBAC5C,QAAQ,EAAE,KAAK,CAAC,QAAQ;gBACxB,YAAY,EAAE,KAAK,CAAC,YAAY;aACjC,CAAC,CAAA;QACJ,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA","sourcesContent":["import type { PluggableList } from \"unified\"\nimport remarkBreaks from \"remark-breaks\"\nimport remarkDirective from \"remark-directive\"\nimport remarkGfm from \"remark-gfm\"\nimport { Text, computed, defineComponent, h, isVNode, normalizeClass, type Component, type PropType } from \"vue\"\nimport { CodeBlock, CodeBlockBase, CodeBlockBaseCode, getSlotText } from \"../CodeBlock/CodeBlock.js\"\nimport { CollapsibleCodeBlock } from \"../CodeBlock/CollapsibleCodeBlock.js\"\nimport { TextLink } from \"../TextLink/index.js\"\nimport { markdownRemarkDirective, type MarkdownDirective } from \"./directives.js\"\nimport { renderMarkdown, sanitizeUrl, type MarkdownComponents } from \"./pipeline.js\"\nimport { defaultUrlTransform, type UrlTransform } from \"./urlTransform.js\"\nimport { useMathPlugins } from \"./useMathPlugins.js\"\nimport { useParseMarkdownPre } from \"./useParseMarkdownPre.js\"\nimport s from \"@plexui/styles/components/Markdown/Markdown.module.css\"\n\n// Vue port of packages/ui/src/components/Markdown/Markdown.tsx. React's\n// react-markdown is replaced by the same unified pipeline rendered through\n// Vue's JSX runtime (./pipeline.ts), so the elements, attributes and keys\n// match. The markdown is the text of the default slot (interpolate a string,\n// `{{ md }}`, so its newlines are kept) or, when the slot is empty, the\n// `source` prop.\n\nconst supportsLookbehind = (() => {\n try {\n new RegExp(\"(?<=a)b\")\n return true\n } catch {\n return false\n }\n})()\n\n/**\n * A component that renders one markdown element: it gets the hast `node`\n * prop, the element's attributes (`class`, `href`, ...) and its content as\n * the default slot. A tag name (`\"span\"`) works too.\n */\nexport type MarkdownComponent = Component | string\n\n// Every markdown component gets the hast element as `node`; declaring it\n// keeps it off the DOM\nconst nodeProps = { node: Object as PropType<Record<string, unknown>> }\n\nconst Pre = defineComponent({\n name: \"MarkdownPre\",\n inheritAttrs: false,\n props: nodeProps,\n setup(_props, { slots, attrs }) {\n return () => {\n const { code, language } = useParseMarkdownPre(slots.default?.())\n return h(CodeBlock, { language, class: attrs.class, code })\n }\n },\n})\n\nconst InlineCode = defineComponent({\n name: \"MarkdownInlineCode\",\n inheritAttrs: false,\n props: nodeProps,\n setup(_props, { slots, attrs }) {\n return () => h(\"code\", { class: [s.InlineCode, attrs.class] }, slots.default?.())\n },\n})\n\nconst Anchor = defineComponent({\n name: \"MarkdownAnchor\",\n inheritAttrs: false,\n props: nodeProps,\n setup(_props, { slots, attrs }) {\n // React DOM sanitizes the href TextLink renders; Vue does not, so it happens here\n return () =>\n h(\n TextLink,\n { as: \"a\", ...attrs, ...(typeof attrs.href === \"string\" ? { href: sanitizeUrl(attrs.href) } : null) },\n { default: () => slots.default?.() },\n )\n },\n})\n\n// Sourced from common markdown implementations\nconst TableCell = defineComponent({\n name: \"MarkdownTableCell\",\n props: nodeProps,\n setup(_props, { slots }) {\n return () =>\n h(\n \"td\",\n null,\n (slots.default?.() ?? []).map((child) =>\n // Markdown does not support <br> tags in tables without parsing raw\n // HTML (which may not be safe), so we need to manually handle them\n isVNode(child) && child.type === Text && child.children === \"<br>\" ? h(\"br\") : child,\n ),\n )\n },\n})\n\nconst COMMON_COMPONENTS: MarkdownComponents = {\n code: InlineCode,\n pre: Pre,\n a: Anchor,\n td: TableCell,\n}\n\nconst NonCopyableCodeBlock = defineComponent({\n name: \"MarkdownNonCopyableCodeBlock\",\n inheritAttrs: false,\n props: nodeProps,\n setup(_props, { slots, attrs }) {\n return () => {\n const { code, language } = useParseMarkdownPre(slots.default?.())\n return h(CodeBlockBase, { class: attrs.class }, { default: () => [h(CodeBlockBaseCode, { language, code })] })\n }\n },\n})\n\nconst NON_COPYABLE_CODE_BLOCK_COMPONENTS: MarkdownComponents = {\n pre: NonCopyableCodeBlock,\n}\n\nconst CollapsiblePre = defineComponent({\n name: \"MarkdownCollapsiblePre\",\n inheritAttrs: false,\n props: nodeProps,\n setup(_props, { slots, attrs }) {\n return () => {\n const { code, language } = useParseMarkdownPre(slots.default?.())\n return h(CollapsibleCodeBlock, { language, class: attrs.class, code })\n }\n },\n})\n\nconst COLLAPSIBLE_CODE_BLOCK_COMPONENTS: MarkdownComponents = {\n pre: CollapsiblePre,\n}\n\n/** Renders markdown: GFM, directives, optional LaTeX, Plex code blocks and links. */\nexport const Markdown = defineComponent({\n name: \"Markdown\",\n // Like React, only `class` reaches the DOM (on the wrapping div)\n inheritAttrs: false,\n props: {\n /** Markdown source, used when the default slot is empty */\n source: String,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n directives: Array as PropType<MarkdownDirective<any>[]>,\n /** Determines if remark-math plugins should be loaded for rendering LaTeX. @default false */\n includeMath: { type: Boolean, default: false },\n /** Determines whether single newlines should insert <br> tags. @default false */\n breakNewLines: { type: Boolean, default: false },\n /** Tag name → component overrides, applied over the built-in ones */\n components: Object as PropType<Record<string, MarkdownComponent>>,\n remarkPlugins: Array as PropType<PluggableList>,\n rehypePlugins: Array as PropType<PluggableList>,\n allowedElements: Array as PropType<ReadonlyArray<string>>,\n disallowedElements: Array as PropType<ReadonlyArray<string>>,\n /** Rewrites URLs; the default drops unsafe protocols (`javascript:`), keeps `tel:` and `sms:` */\n urlTransform: { type: Function as PropType<UrlTransform | null>, default: defaultUrlTransform },\n skipHtml: { type: Boolean, default: false },\n /** @default true */\n copyableCodeBlocks: { type: Boolean, default: true },\n /** Determines if code blocks should use the collapsible view with \"View Code\" button. @default true */\n collapsibleCodeBlocks: { type: Boolean, default: true },\n },\n setup(props, { slots, attrs }) {\n const mathPlugins = useMathPlugins(() => props.includeMath)\n\n const mergedRemarkPlugins = computed(() => {\n const baseRemarkPlugins: PluggableList = [\n remarkDirective,\n markdownRemarkDirective,\n ...mathPlugins.value.remarkPlugins,\n ]\n\n if (props.breakNewLines) {\n baseRemarkPlugins.push(remarkBreaks)\n }\n\n // remark-gfm requires lookbehind support, which will throw in <= Safari 16.4\n // with no easily available polyfill.\n if (supportsLookbehind) {\n // Do not treat single tilde as strikethrough to allow for more\n // conversational use cases such as \"~$20-$30\"\n baseRemarkPlugins.push([remarkGfm, { singleTilde: false }])\n }\n\n return [...baseRemarkPlugins, ...(props.remarkPlugins ?? [])]\n })\n\n return () => {\n const slotText = getSlotText(slots.default?.())\n const source = slotText !== \"\" ? slotText : (props.source ?? \"\")\n\n const baseComponents: MarkdownComponents = {\n ...COMMON_COMPONENTS,\n ...(props.collapsibleCodeBlocks ? COLLAPSIBLE_CODE_BLOCK_COMPONENTS : null),\n ...(props.copyableCodeBlocks ? null : NON_COPYABLE_CODE_BLOCK_COMPONENTS),\n ...props.components,\n }\n const components =\n props.directives?.reduce((acc, directive) => {\n acc[directive.directiveName] = directive.render\n return acc\n }, baseComponents) ?? baseComponents\n\n return renderMarkdown({\n children: source,\n className: normalizeClass([s.MarkdownContent, attrs.class]),\n remarkPlugins: mergedRemarkPlugins.value,\n rehypePlugins: [...(props.rehypePlugins ?? []), ...mathPlugins.value.rehypePlugins],\n components,\n allowedElements: props.allowedElements,\n disallowedElements: props.disallowedElements,\n skipHtml: props.skipHtml,\n urlTransform: props.urlTransform,\n })\n }\n },\n})\n\nexport type MarkdownProps = InstanceType<typeof Markdown>[\"$props\"]\n"]}
1
+ {"version":3,"file":"Markdown.js","sourceRoot":"","sources":["../../../../src/components/Markdown/Markdown.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,eAAe,CAAA;AACxC,OAAO,eAAe,MAAM,kBAAkB,CAAA;AAC9C,OAAO,SAAS,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC,EAAE,OAAO,EAAE,cAAc,EAAiC,MAAM,KAAK,CAAA;AAChH,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AACpG,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAA;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,uBAAuB,EAA0B,MAAM,iBAAiB,CAAA;AACjF,OAAO,EAAE,cAAc,EAAE,WAAW,EAA2B,MAAM,eAAe,CAAA;AACpF,OAAO,EAAE,mBAAmB,EAAqB,MAAM,mBAAmB,CAAA;AAC1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,CAAC,CAAC,kCAAkC,CAAC;gBACzE,GAAG,KAAK,CAAC,UAAU;aACpB,CAAA;YACD,MAAM,UAAU,GACd,KAAK,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,GAAG,EAAE,SAAS,EAAE,EAAE;gBAC1C,GAAG,CAAC,SAAS,CAAC,aAAa,CAAC,GAAG,SAAS,CAAC,MAAM,CAAA;gBAC/C,OAAO,GAAG,CAAA;YACZ,CAAC,EAAE,cAAc,CAAC,IAAI,cAAc,CAAA;YAEtC,OAAO,cAAc,CAAC;gBACpB,QAAQ,EAAE,MAAM;gBAChB,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,eAAe,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;gBAC3D,aAAa,EAAE,mBAAmB,CAAC,KAAK;gBACxC,aAAa,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,aAAa,IAAI,EAAE,CAAC,EAAE,GAAG,WAAW,CAAC,KAAK,CAAC,aAAa,CAAC;gBACnF,UAAU;gBACV,eAAe,EAAE,KAAK,CAAC,eAAe;gBACtC,kBAAkB,EAAE,KAAK,CAAC,kBAAkB;gBAC5C,QAAQ,EAAE,KAAK,CAAC,QAAQ;gBACxB,YAAY,EAAE,KAAK,CAAC,YAAY;aACjC,CAAC,CAAA;QACJ,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA","sourcesContent":["import type { PluggableList } from \"unified\"\nimport remarkBreaks from \"remark-breaks\"\nimport remarkDirective from \"remark-directive\"\nimport remarkGfm from \"remark-gfm\"\nimport { Text, computed, defineComponent, h, isVNode, normalizeClass, type Component, type PropType } from \"vue\"\nimport { CodeBlock, CodeBlockBase, CodeBlockBaseCode, getSlotText } from \"../CodeBlock/CodeBlock.js\"\nimport { CollapsibleCodeBlock } from \"../CodeBlock/CollapsibleCodeBlock.js\"\nimport { TextLink } from \"../TextLink/index.js\"\nimport { markdownRemarkDirective, type MarkdownDirective } from \"./directives.js\"\nimport { renderMarkdown, sanitizeUrl, type MarkdownComponents } from \"./pipeline.js\"\nimport { defaultUrlTransform, type UrlTransform } from \"./urlTransform.js\"\nimport { useMathPlugins } from \"./useMathPlugins.js\"\nimport { useParseMarkdownPre } from \"./useParseMarkdownPre.js\"\nimport s from \"@plexui/styles/components/Markdown/Markdown.module.css\"\n\n// Vue port of packages/ui/src/components/Markdown/Markdown.tsx. React's\n// react-markdown is replaced by the same unified pipeline rendered through\n// Vue's JSX runtime (./pipeline.ts), so the elements, attributes and keys\n// match. The markdown is the text of the default slot (interpolate a string,\n// `{{ md }}`, so its newlines are kept) or, when the slot is empty, the\n// `source` prop.\n\nconst supportsLookbehind = (() => {\n try {\n new RegExp(\"(?<=a)b\")\n return true\n } catch {\n return false\n }\n})()\n\n/**\n * A component that renders one markdown element: it gets the hast `node`\n * prop, the element's attributes (`class`, `href`, ...) and its content as\n * the default slot. A tag name (`\"span\"`) works too.\n */\nexport type MarkdownComponent = Component | string\n\n// Every markdown component gets the hast element as `node`; declaring it\n// keeps it off the DOM\nconst nodeProps = { node: Object as PropType<Record<string, unknown>> }\n\nconst Pre = defineComponent({\n name: \"MarkdownPre\",\n inheritAttrs: false,\n props: nodeProps,\n setup(_props, { slots, attrs }) {\n return () => {\n const { code, language } = useParseMarkdownPre(slots.default?.())\n return h(CodeBlock, { language, class: attrs.class, code })\n }\n },\n})\n\nconst InlineCode = defineComponent({\n name: \"MarkdownInlineCode\",\n inheritAttrs: false,\n props: nodeProps,\n setup(_props, { slots, attrs }) {\n return () => h(\"code\", { class: [s.InlineCode, attrs.class] }, slots.default?.())\n },\n})\n\nconst Anchor = defineComponent({\n name: \"MarkdownAnchor\",\n inheritAttrs: false,\n props: nodeProps,\n setup(_props, { slots, attrs }) {\n // React DOM sanitizes the href TextLink renders; Vue does not, so it happens here\n return () =>\n h(\n TextLink,\n { as: \"a\", ...attrs, ...(typeof attrs.href === \"string\" ? { href: sanitizeUrl(attrs.href) } : null) },\n { default: () => slots.default?.() },\n )\n },\n})\n\n// Sourced from common markdown implementations\nconst TableCell = defineComponent({\n name: \"MarkdownTableCell\",\n props: nodeProps,\n setup(_props, { slots }) {\n return () =>\n h(\n \"td\",\n null,\n (slots.default?.() ?? []).map((child) =>\n // Markdown does not support <br> tags in tables without parsing raw\n // HTML (which may not be safe), so we need to manually handle them\n isVNode(child) && child.type === Text && child.children === \"<br>\" ? h(\"br\") : child,\n ),\n )\n },\n})\n\nconst COMMON_COMPONENTS: MarkdownComponents = {\n code: InlineCode,\n pre: Pre,\n a: Anchor,\n td: TableCell,\n}\n\nconst NonCopyableCodeBlock = defineComponent({\n name: \"MarkdownNonCopyableCodeBlock\",\n inheritAttrs: false,\n props: nodeProps,\n setup(_props, { slots, attrs }) {\n return () => {\n const { code, language } = useParseMarkdownPre(slots.default?.())\n return h(CodeBlockBase, { class: attrs.class }, { default: () => [h(CodeBlockBaseCode, { language, code })] })\n }\n },\n})\n\nconst NON_COPYABLE_CODE_BLOCK_COMPONENTS: MarkdownComponents = {\n pre: NonCopyableCodeBlock,\n}\n\nconst CollapsiblePre = defineComponent({\n name: \"MarkdownCollapsiblePre\",\n inheritAttrs: false,\n props: nodeProps,\n setup(_props, { slots, attrs }) {\n return () => {\n const { code, language } = useParseMarkdownPre(slots.default?.())\n return h(CollapsibleCodeBlock, { language, class: attrs.class, code })\n }\n },\n})\n\nconst COLLAPSIBLE_CODE_BLOCK_COMPONENTS: MarkdownComponents = {\n pre: CollapsiblePre,\n}\n\n/** Renders markdown: GFM, directives, optional LaTeX, Plex code blocks and links. */\nexport const Markdown = defineComponent({\n name: \"Markdown\",\n // Like React, only `class` reaches the DOM (on the wrapping div)\n inheritAttrs: false,\n props: {\n /** Markdown source, used when the default slot is empty */\n source: String,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n directives: Array as PropType<MarkdownDirective<any>[]>,\n /** Determines if remark-math plugins should be loaded for rendering LaTeX. @default false */\n includeMath: { type: Boolean, default: false },\n /** Determines whether single newlines should insert <br> tags. @default false */\n breakNewLines: { type: Boolean, default: false },\n /** Tag name → component overrides, applied over the built-in ones */\n components: Object as PropType<Record<string, MarkdownComponent>>,\n remarkPlugins: Array as PropType<PluggableList>,\n rehypePlugins: Array as PropType<PluggableList>,\n allowedElements: Array as PropType<ReadonlyArray<string>>,\n disallowedElements: Array as PropType<ReadonlyArray<string>>,\n /** Rewrites URLs; the default drops unsafe protocols (`javascript:`), keeps `tel:` and `sms:` */\n urlTransform: { type: Function as PropType<UrlTransform | null>, default: defaultUrlTransform },\n skipHtml: { type: Boolean, default: false },\n /** @default true */\n copyableCodeBlocks: { type: Boolean, default: true },\n /** Determines if code blocks should use the collapsible view with \"View Code\" button. @default true */\n collapsibleCodeBlocks: { type: Boolean, default: true },\n },\n setup(props, { slots, attrs }) {\n const mathPlugins = useMathPlugins(() => props.includeMath)\n\n const mergedRemarkPlugins = computed(() => {\n const baseRemarkPlugins: PluggableList = [\n remarkDirective,\n // The directives this Markdown renders as elements: its own and the components' tags\n [\n markdownRemarkDirective,\n {\n names: [\n ...(props.directives?.map((directive) => directive.directiveName) ?? []),\n ...Object.keys(props.components ?? {}),\n ],\n },\n ],\n ...mathPlugins.value.remarkPlugins,\n ]\n\n if (props.breakNewLines) {\n baseRemarkPlugins.push(remarkBreaks)\n }\n\n // remark-gfm requires lookbehind support, which will throw in <= Safari 16.4\n // with no easily available polyfill.\n if (supportsLookbehind) {\n // Do not treat single tilde as strikethrough to allow for more\n // conversational use cases such as \"~$20-$30\"\n baseRemarkPlugins.push([remarkGfm, { singleTilde: false }])\n }\n\n return [...baseRemarkPlugins, ...(props.remarkPlugins ?? [])]\n })\n\n return () => {\n const slotText = getSlotText(slots.default?.())\n const source = slotText !== \"\" ? slotText : (props.source ?? \"\")\n\n const baseComponents: MarkdownComponents = {\n ...COMMON_COMPONENTS,\n ...(props.collapsibleCodeBlocks ? COLLAPSIBLE_CODE_BLOCK_COMPONENTS : null),\n ...(props.copyableCodeBlocks ? null : NON_COPYABLE_CODE_BLOCK_COMPONENTS),\n ...props.components,\n }\n const components =\n props.directives?.reduce((acc, directive) => {\n acc[directive.directiveName] = directive.render\n return acc\n }, baseComponents) ?? baseComponents\n\n return renderMarkdown({\n children: source,\n className: normalizeClass([s.MarkdownContent, attrs.class]),\n remarkPlugins: mergedRemarkPlugins.value,\n rehypePlugins: [...(props.rehypePlugins ?? []), ...mathPlugins.value.rehypePlugins],\n components,\n allowedElements: props.allowedElements,\n disallowedElements: props.disallowedElements,\n skipHtml: props.skipHtml,\n urlTransform: props.urlTransform,\n })\n }\n },\n})\n\nexport type MarkdownProps = InstanceType<typeof Markdown>[\"$props\"]\n"]}
@@ -1,5 +1,5 @@
1
1
  import { Comment, Text, isVNode } from "vue";
2
- import { visit } from "unist-util-visit";
2
+ import { SKIP, visit } from "unist-util-visit";
3
3
  import { createId } from "../../lib/ids.js";
4
4
  import { decodeBase64, encodeBase64 } from "../../lib/safeBase64.js";
5
5
  /**
@@ -43,17 +43,58 @@ export function createMarkdownDirective({ render, name, mode, }) {
43
43
  directive.render = renderDirective;
44
44
  return directive;
45
45
  }
46
- /** React's `reactMarkdownRemarkDirective`: directives become elements named after them. */
47
- export function markdownRemarkDirective() {
46
+ /**
47
+ * A directive's attribute reaches its element only as a plain HTML attribute: a lowercase name (`title`, `data-*`,
48
+ * `aria-*`), so never a DOM property such as `innerHTML` or React's `dangerouslySetInnerHTML`; never an event handler,
49
+ * an inline style, a frame's document or `is`.
50
+ */
51
+ const ATTRIBUTE_NAME = /^[a-z][a-z0-9-]*$/;
52
+ const UNSAFE_ATTRIBUTE = /^(?:on|style$|srcdoc$|formaction$|is$)/;
53
+ /** The attributes that load or open a URL: one with a protocol other than Markdown's safe ones is dropped. */
54
+ const URL_ATTRIBUTES = new Set(["href", "src", "action", "cite", "poster", "background", "ping", "data", "codebase"]);
55
+ const SAFE_PROTOCOL = /^(?:https?|ircs?|mailto|xmpp|tel|sms)$/i;
56
+ /** react-markdown's `defaultUrlTransform` test, with `tel:` and `sms:` as the Markdown's own transform. */
57
+ const isSafeUrl = (value) => {
58
+ const colon = value.indexOf(":");
59
+ const firstOf = (char) => value.indexOf(char);
60
+ return (colon === -1 ||
61
+ [firstOf("/"), firstOf("?"), firstOf("#")].some((index) => index !== -1 && colon > index) ||
62
+ SAFE_PROTOCOL.test(value.slice(0, colon).trim()));
63
+ };
64
+ const safeAttributes = (attributes) => Object.fromEntries(Object.entries(attributes ?? {}).filter(([key, value]) => ATTRIBUTE_NAME.test(key) &&
65
+ !UNSAFE_ATTRIBUTE.test(key) &&
66
+ !(URL_ATTRIBUTES.has(key) && !isSafeUrl(String(value ?? "")))));
67
+ /**
68
+ * Directives become elements only when the Markdown knows them: a `directives` entry or a `components` key, with
69
+ * their attributes minus event handlers, `style` and `srcdoc`. Any other directive stays what was written: an inline
70
+ * or leaf one its source text, a container one its content in a plain `div`. Text from elsewhere (a server, a user)
71
+ * can't make an element of its choosing with attributes of its choosing.
72
+ */
73
+ export function markdownRemarkDirective(options = {}) {
74
+ const names = new Set(options.names ?? []);
48
75
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
49
- return (tree) => {
50
- visit(tree, ["textDirective", "leafDirective", "containerDirective"], (node) => {
51
- node.data = {
52
- hName: node.name,
53
- hProperties: node.attributes,
54
- ...node.data,
55
- };
56
- return node;
76
+ return (tree, file) => {
77
+ const source = file?.value == null ? "" : String(file.value);
78
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
79
+ visit(tree, ["textDirective", "leafDirective", "containerDirective"], (node, index, parent) => {
80
+ if (names.has(node.name)) {
81
+ node.data = { hName: node.name, hProperties: safeAttributes(node.attributes), ...node.data };
82
+ return;
83
+ }
84
+ if (node.type === "containerDirective") {
85
+ node.data = { hName: "div", hProperties: {}, ...node.data };
86
+ return;
87
+ }
88
+ if (!parent || typeof index !== "number")
89
+ return;
90
+ const start = node.position?.start?.offset;
91
+ const end = node.position?.end?.offset;
92
+ const value = typeof start === "number" && typeof end === "number" && end <= source.length
93
+ ? source.slice(start, end)
94
+ : `${node.type === "leafDirective" ? "::" : ":"}${node.name}`;
95
+ const text = { type: "text", value };
96
+ parent.children[index] = node.type === "leafDirective" ? { type: "paragraph", children: [text] } : text;
97
+ return SKIP;
57
98
  });
58
99
  };
59
100
  }