@enigmax/primitives 0.26.0 → 0.28.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 (58) hide show
  1. package/dist/{chunk-VKL3DEIQ.js → chunk-6WIGVIQF.js} +58 -37
  2. package/dist/{chunk-ISXB5RUH.js → chunk-CB7K6VW4.js} +10 -3
  3. package/dist/{chunk-QIIV2QSV.js → chunk-HUUINHPR.js} +28 -1
  4. package/dist/{chunk-4SZ5N7BA.js → chunk-IQMHDRJF.js} +2 -2
  5. package/dist/{chunk-RUEQ3TGP.js → chunk-JLZDS6CV.js} +23 -1
  6. package/dist/{chunk-JJVZYW5C.js → chunk-JPBVKXOL.js} +10 -3
  7. package/dist/{chunk-DZMHY3SU.js → chunk-RRPWJAIJ.js} +41 -17
  8. package/dist/chunk-RXEO4WPI.js +111 -0
  9. package/dist/{chunk-RMNXVWQ4.js → chunk-YHH5U2NW.js} +1 -1
  10. package/dist/{chunk-Z3VDE7OA.js → chunk-YQV5XZIA.js} +2 -2
  11. package/dist/{clipboard-menu-BvXJCSFN.d.ts → clipboard-menu-eemzEBqB.d.ts} +1 -1
  12. package/dist/{color-T63FLJNH.js → color-WBNVPFT5.js} +157 -158
  13. package/dist/{context-BfjYGPnH.d.ts → context-DR1dpO8b.d.ts} +1 -1
  14. package/dist/{context-menu-D3FtTn7v.d.ts → context-menu-qqpGBkny.d.ts} +6 -0
  15. package/dist/index.d.ts +29 -3
  16. package/dist/index.js +3 -3
  17. package/dist/{menu-PNQRTRNV.js → menu-5JZMGNOT.js} +3 -2
  18. package/dist/{menu-MSQSE6U5.js → menu-O3G4LM5O.js} +9 -4
  19. package/dist/next/index.d.ts +3 -3
  20. package/dist/next/index.js +8 -7
  21. package/dist/react/context-menu.d.ts +13 -7
  22. package/dist/react/context-menu.js +3 -2
  23. package/dist/react/image.d.ts +5 -2
  24. package/dist/react/image.js +1 -1
  25. package/dist/react/index.d.ts +3 -3
  26. package/dist/react/index.js +8 -7
  27. package/dist/react/input.js +1 -1
  28. package/dist/react/select.d.ts +6 -1
  29. package/dist/react/select.js +2 -1
  30. package/dist/react/video.d.ts +9 -3
  31. package/dist/react/video.js +2 -2
  32. package/dist/react-router/index.d.ts +3 -3
  33. package/dist/react-router/index.js +8 -7
  34. package/dist/viewer-C323RYNZ.js +3 -0
  35. package/package.json +1 -1
  36. package/recipes/color/styles.css +12 -7
  37. package/recipes/context-menu/styles.css +15 -1
  38. package/recipes/select/styles.css +24 -7
  39. package/registry.json +119 -10
  40. package/src/core/context-menu.ts +22 -3
  41. package/src/core/floating.ts +71 -0
  42. package/src/core/image-viewer.ts +47 -0
  43. package/src/core/player.ts +42 -0
  44. package/src/index.ts +3 -0
  45. package/src/react/context-menu/root.tsx +57 -20
  46. package/src/react/context-menu/styles.ts +15 -1
  47. package/src/react/floating.ts +185 -0
  48. package/src/react/image/icons.tsx +4 -0
  49. package/src/react/image/menu.tsx +5 -1
  50. package/src/react/image/types.ts +3 -0
  51. package/src/react/input/color-styles.ts +12 -7
  52. package/src/react/input/color.tsx +30 -27
  53. package/src/react/select/context.ts +5 -0
  54. package/src/react/select/root.tsx +33 -21
  55. package/src/react/select/styles.ts +24 -7
  56. package/src/react/video/index.tsx +8 -1
  57. package/src/react/video/types.ts +7 -1
  58. package/dist/viewer-73LSE6RR.js +0 -3
@@ -1,5 +1,7 @@
1
1
  import { parseColor, rgbToHsv, colorEquals, hsvToRgb, formatColor, toHex } from './chunk-S2FPN5ID.js';
2
2
  import { writeValue, ColorSwatch } from './chunk-KVLSOQTI.js';
3
+ import { useFloating, tabOut } from './chunk-RXEO4WPI.js';
4
+ import { createPortal } from 'react-dom';
3
5
  import { useLayoutEffect, useRef, useState, useMemo, useEffect, useCallback } from 'react';
4
6
  import { jsx, jsxs } from 'react/jsx-runtime';
5
7
 
@@ -23,6 +25,11 @@ var COLOR_STYLES = `
23
25
  on, which is why only one colour is a property. */
24
26
  --enigma-color-checker: rgba(255, 255, 255, 0.22);
25
27
  --enigma-color-checker-size: 0.5rem;
28
+
29
+ /* The layer every portaled popup shares, declared with the same value by the select and
30
+ the context menu: above the lightbox (9999), because a popup is opened FROM whatever
31
+ is on top. Not in the light-scheme block, or half the readers get no z-index. */
32
+ --enigma-floating-z: 10000;
26
33
  }
27
34
 
28
35
  @media (prefers-color-scheme: light) {
@@ -39,9 +46,7 @@ var COLOR_STYLES = `
39
46
  }
40
47
  }
41
48
 
42
- /* The anchor the panel hangs from. Inline so it sits in the field's own row, and the
43
- positioning context so the panel needs no portal and no scroll listener: it moves with
44
- the field because it is INSIDE it. */
49
+ /* The anchor the panel is placed against. Inline so it sits in the field's own row. */
45
50
  [data-enigma-color] { position: relative; display: inline-flex; flex: none; }
46
51
 
47
52
  [data-enigma-color-swatch] {
@@ -65,8 +70,13 @@ var COLOR_STYLES = `
65
70
  rather than the last good colour: a stale swatch says the value is fine when it is not. */
66
71
  [data-enigma-color-swatch][data-invalid] [data-enigma-color-fill] { background: none; }
67
72
 
73
+ /* Portaled and placed in viewport coordinates against the swatch (see react/floating.ts),
74
+ so a dialog or a card with overflow: hidden cannot cut it off. left, top, max-height and
75
+ data-side are written by the placement: below, flipped above when there is more room
76
+ there, and capped to the room it has - scrolling inside rather than off the screen. */
68
77
  [data-enigma-color-panel] {
69
- position: absolute; z-index: 60; top: calc(100% + 0.375rem); left: 0;
78
+ position: fixed; z-index: var(--enigma-floating-z);
79
+ overflow-y: auto; overscroll-behavior: contain;
70
80
  display: grid; gap: 0.625rem;
71
81
  box-sizing: border-box; width: var(--enigma-color-panel-width); padding: 0.625rem;
72
82
  color: var(--enigma-color-text); background: var(--enigma-color-panel-bg);
@@ -74,9 +84,6 @@ var COLOR_STYLES = `
74
84
  border-radius: var(--enigma-color-panel-radius);
75
85
  box-shadow: var(--enigma-color-panel-shadow);
76
86
  }
77
- /* Flipped when the field sits near the bottom of the window. Without it the panel opens off
78
- the screen and the controls are unreachable, which is the same defect the select fixes. */
79
- [data-enigma-color-panel][data-side="top"] { top: auto; bottom: calc(100% + 0.375rem); }
80
87
 
81
88
  [data-enigma-color-area] {
82
89
  position: relative; height: var(--enigma-color-area-height);
@@ -164,6 +171,7 @@ var COLOR_STYLES = `
164
171
  var INITIAL = { h: 0, s: 0, v: 0, a: 1 };
165
172
  var STEP = { fine: 0.01, coarse: 0.1, hue: 1, hueCoarse: 10 };
166
173
  var MARGIN = 12;
174
+ var GAP = 6;
167
175
  var FORMATS = ["hex", "rgb", "hsl"];
168
176
  var FORMAT_LABELS = { hex: "HEX", rgb: "RGB", hsl: "HSL" };
169
177
  var injected = false;
@@ -200,7 +208,6 @@ function ColorExtras({
200
208
  const swatchRef = useRef(null);
201
209
  const areaRef = useRef(null);
202
210
  const [open, setOpen] = useState(openOnMount && !locked);
203
- const [side, setSide] = useState(placement === "top" ? "top" : "bottom");
204
211
  const parsed = useMemo(() => parseColor(value), [value]);
205
212
  const [hsv, setHsv] = useState(() => parsed ? rgbToHsv(parsed) : INITIAL);
206
213
  useEffect(() => {
@@ -230,22 +237,14 @@ function ColorExtras({
230
237
  setOpenState(false);
231
238
  if (focusSwatch) swatchRef.current?.focus();
232
239
  }, [setOpenState]);
233
- const place = useCallback(() => {
234
- if (placement !== "auto") return setSide(placement);
235
- const anchor = anchorRef.current?.getBoundingClientRect();
236
- const panel = panelRef.current?.getBoundingClientRect();
237
- if (!anchor || !panel) return;
238
- const below = window.innerHeight - anchor.bottom;
239
- setSide(below < panel.height + MARGIN && anchor.top > below ? "top" : "bottom");
240
- }, [placement]);
241
- useLayoutEffect(() => {
242
- if (!open) return;
243
- place();
244
- }, [open, place]);
240
+ const showing = open && !locked;
241
+ const container = useFloating({ open: showing, anchorRef, panelRef, gap: GAP, margin: MARGIN, side: placement });
242
+ useEffect(() => {
243
+ if (showing && container) areaRef.current?.focus();
244
+ }, [showing, container]);
245
245
  useEffect(() => {
246
246
  if (!open) return;
247
- areaRef.current?.focus();
248
- const inside = (target) => Boolean(anchorRef.current?.contains(target));
247
+ const inside = (target) => Boolean(anchorRef.current?.contains(target) || panelRef.current?.contains(target));
249
248
  const onPointerDown = (event) => {
250
249
  if (!inside(event.target)) setOpenState(false);
251
250
  };
@@ -253,16 +252,13 @@ function ColorExtras({
253
252
  if (event.target === document.body || inside(event.target)) return;
254
253
  setOpenState(false);
255
254
  };
256
- const onResize = () => place();
257
255
  document.addEventListener("pointerdown", onPointerDown, true);
258
256
  document.addEventListener("focusin", onFocusIn, true);
259
- window.addEventListener("resize", onResize);
260
257
  return () => {
261
258
  document.removeEventListener("pointerdown", onPointerDown, true);
262
259
  document.removeEventListener("focusin", onFocusIn, true);
263
- window.removeEventListener("resize", onResize);
264
260
  };
265
- }, [open, place, setOpenState]);
261
+ }, [open, setOpenState]);
266
262
  const track = useCallback((event, onMove) => {
267
263
  if (event.button !== 0) return;
268
264
  const element = event.currentTarget;
@@ -354,149 +350,152 @@ function ColorExtras({
354
350
  locked,
355
351
  label: text.open ?? "Pick a colour",
356
352
  onPress: () => open ? close(true) : setOpenState(true),
357
- children: open && !locked && /* @__PURE__ */ jsxs(
358
- "div",
359
- {
360
- ref: panelRef,
361
- "data-enigma-color-panel": "",
362
- "data-side": side,
363
- role: "dialog",
364
- "aria-label": text.panel ?? "Colour picker",
365
- style: panelStyle,
366
- onKeyDown: (event) => {
367
- if (event.key !== "Escape") return;
368
- event.stopPropagation();
369
- close(true);
370
- },
371
- children: [
372
- /* @__PURE__ */ jsx(
373
- "div",
374
- {
375
- ref: areaRef,
376
- "data-enigma-color-area": "",
377
- role: "slider",
378
- tabIndex: 0,
379
- "aria-label": text.area ?? "Saturation and brightness",
380
- "aria-valuemin": 0,
381
- "aria-valuemax": 100,
382
- "aria-valuenow": Math.round(hsv.s * 100),
383
- "aria-valuetext": `${Math.round(hsv.s * 100)}% saturation, ${Math.round(hsv.v * 100)}% brightness, ${valueText}`,
384
- onKeyDown: areaKeys,
385
- onPointerDown: (event) => track(event, (x, y) => commit({ ...hsv, s: x, v: 1 - y })),
386
- children: /* @__PURE__ */ jsx("span", { "data-enigma-color-thumb": "", style: { left: `${hsv.s * 100}%`, top: `${(1 - hsv.v) * 100}%` } })
387
- }
388
- ),
389
- /* @__PURE__ */ jsxs("div", { "data-enigma-color-controls": "", children: [
390
- /* @__PURE__ */ jsx("span", { "data-enigma-color-preview": "", "data-enigma-color-checkers": "", children: /* @__PURE__ */ jsx("span", { "data-enigma-color-fill": "", style: { background: css } }) }),
391
- dropper && /* @__PURE__ */ jsx(
392
- "button",
353
+ children: showing && container && createPortal(
354
+ /* @__PURE__ */ jsxs(
355
+ "div",
356
+ {
357
+ ref: panelRef,
358
+ "data-enigma-color-panel": "",
359
+ role: "dialog",
360
+ "aria-label": text.panel ?? "Colour picker",
361
+ style: panelStyle,
362
+ onKeyDown: (event) => {
363
+ if (tabOut(event, panelRef.current, swatchRef.current)) return;
364
+ if (event.key !== "Escape") return;
365
+ event.stopPropagation();
366
+ close(true);
367
+ },
368
+ children: [
369
+ /* @__PURE__ */ jsx(
370
+ "div",
393
371
  {
394
- type: "button",
395
- "data-enigma-color-eyedropper": "",
396
- "aria-label": text.eyedropper ?? "Pick a colour from the screen",
397
- title: text.eyedropper ?? "Pick a colour from the screen",
398
- onClick: () => {
399
- void pick();
400
- },
401
- children: /* @__PURE__ */ jsx(EyedropperIcon, {})
372
+ ref: areaRef,
373
+ "data-enigma-color-area": "",
374
+ role: "slider",
375
+ tabIndex: 0,
376
+ "aria-label": text.area ?? "Saturation and brightness",
377
+ "aria-valuemin": 0,
378
+ "aria-valuemax": 100,
379
+ "aria-valuenow": Math.round(hsv.s * 100),
380
+ "aria-valuetext": `${Math.round(hsv.s * 100)}% saturation, ${Math.round(hsv.v * 100)}% brightness, ${valueText}`,
381
+ onKeyDown: areaKeys,
382
+ onPointerDown: (event) => track(event, (x, y) => commit({ ...hsv, s: x, v: 1 - y })),
383
+ children: /* @__PURE__ */ jsx("span", { "data-enigma-color-thumb": "", style: { left: `${hsv.s * 100}%`, top: `${(1 - hsv.v) * 100}%` } })
402
384
  }
403
385
  ),
404
- /* @__PURE__ */ jsxs("div", { "data-enigma-color-rails": "", children: [
386
+ /* @__PURE__ */ jsxs("div", { "data-enigma-color-controls": "", children: [
387
+ /* @__PURE__ */ jsx("span", { "data-enigma-color-preview": "", "data-enigma-color-checkers": "", children: /* @__PURE__ */ jsx("span", { "data-enigma-color-fill": "", style: { background: css } }) }),
388
+ dropper && /* @__PURE__ */ jsx(
389
+ "button",
390
+ {
391
+ type: "button",
392
+ "data-enigma-color-eyedropper": "",
393
+ "aria-label": text.eyedropper ?? "Pick a colour from the screen",
394
+ title: text.eyedropper ?? "Pick a colour from the screen",
395
+ onClick: () => {
396
+ void pick();
397
+ },
398
+ children: /* @__PURE__ */ jsx(EyedropperIcon, {})
399
+ }
400
+ ),
401
+ /* @__PURE__ */ jsxs("div", { "data-enigma-color-rails": "", children: [
402
+ /* @__PURE__ */ jsx(
403
+ "div",
404
+ {
405
+ "data-enigma-color-rail": "hue",
406
+ role: "slider",
407
+ tabIndex: 0,
408
+ "aria-label": text.hue ?? "Hue",
409
+ "aria-valuemin": 0,
410
+ "aria-valuemax": 360,
411
+ "aria-valuenow": Math.round(hsv.h),
412
+ "aria-valuetext": `${Math.round(hsv.h)} degrees`,
413
+ onKeyDown: (event) => railKeys(event, "hue"),
414
+ onPointerDown: (event) => track(event, (x) => commit({ ...hsv, h: x * 360 })),
415
+ children: /* @__PURE__ */ jsx("span", { "data-enigma-color-thumb": "", style: { left: `${hsv.h / 360 * 100}%` } })
416
+ }
417
+ ),
418
+ alpha && /* @__PURE__ */ jsxs(
419
+ "div",
420
+ {
421
+ "data-enigma-color-rail": "alpha",
422
+ "data-enigma-color-checkers": "",
423
+ role: "slider",
424
+ tabIndex: 0,
425
+ "aria-label": text.alpha ?? "Opacity",
426
+ "aria-valuemin": 0,
427
+ "aria-valuemax": 100,
428
+ "aria-valuenow": Math.round(hsv.a * 100),
429
+ "aria-valuetext": `${Math.round(hsv.a * 100)}% opacity`,
430
+ onKeyDown: (event) => railKeys(event, "alpha"),
431
+ onPointerDown: (event) => track(event, (x) => commit({ ...hsv, a: x })),
432
+ children: [
433
+ /* @__PURE__ */ jsx("span", { "data-enigma-color-gradient": "" }),
434
+ /* @__PURE__ */ jsx("span", { "data-enigma-color-thumb": "", style: { left: `${hsv.a * 100}%` } })
435
+ ]
436
+ }
437
+ )
438
+ ] })
439
+ ] }),
440
+ /* @__PURE__ */ jsxs("div", { "data-enigma-color-value": "", children: [
405
441
  /* @__PURE__ */ jsx(
406
- "div",
442
+ "button",
407
443
  {
408
- "data-enigma-color-rail": "hue",
409
- role: "slider",
410
- tabIndex: 0,
411
- "aria-label": text.hue ?? "Hue",
412
- "aria-valuemin": 0,
413
- "aria-valuemax": 360,
414
- "aria-valuenow": Math.round(hsv.h),
415
- "aria-valuetext": `${Math.round(hsv.h)} degrees`,
416
- onKeyDown: (event) => railKeys(event, "hue"),
417
- onPointerDown: (event) => track(event, (x) => commit({ ...hsv, h: x * 360 })),
418
- children: /* @__PURE__ */ jsx("span", { "data-enigma-color-thumb": "", style: { left: `${hsv.h / 360 * 100}%` } })
444
+ type: "button",
445
+ "data-enigma-color-format": "",
446
+ "aria-label": `${text.formatAs ?? "Show as"} ${FORMAT_LABELS[nextFormat]}`,
447
+ title: `${text.formatAs ?? "Show as"} ${FORMAT_LABELS[nextFormat]}`,
448
+ onClick: () => {
449
+ setShown(nextFormat);
450
+ setDraft(null);
451
+ },
452
+ children: FORMAT_LABELS[shown]
419
453
  }
420
454
  ),
421
- alpha && /* @__PURE__ */ jsxs(
422
- "div",
455
+ /* @__PURE__ */ jsx(
456
+ "input",
423
457
  {
424
- "data-enigma-color-rail": "alpha",
425
- "data-enigma-color-checkers": "",
426
- role: "slider",
427
- tabIndex: 0,
428
- "aria-label": text.alpha ?? "Opacity",
429
- "aria-valuemin": 0,
430
- "aria-valuemax": 100,
431
- "aria-valuenow": Math.round(hsv.a * 100),
432
- "aria-valuetext": `${Math.round(hsv.a * 100)}% opacity`,
433
- onKeyDown: (event) => railKeys(event, "alpha"),
434
- onPointerDown: (event) => track(event, (x) => commit({ ...hsv, a: x })),
435
- children: [
436
- /* @__PURE__ */ jsx("span", { "data-enigma-color-gradient": "" }),
437
- /* @__PURE__ */ jsx("span", { "data-enigma-color-thumb": "", style: { left: `${hsv.a * 100}%` } })
438
- ]
458
+ type: "text",
459
+ "data-enigma-color-input": "",
460
+ value: draft ?? readout,
461
+ "aria-label": text.value ?? "Colour value",
462
+ spellCheck: false,
463
+ autoComplete: "off",
464
+ autoCorrect: "off",
465
+ autoCapitalize: "off",
466
+ onChange: (event) => typed(event.target.value),
467
+ onBlur: () => setDraft(null),
468
+ onKeyDown: (event) => {
469
+ if (event.key !== "Enter") return;
470
+ event.preventDefault();
471
+ setDraft(null);
472
+ }
439
473
  }
440
474
  )
441
- ] })
442
- ] }),
443
- /* @__PURE__ */ jsxs("div", { "data-enigma-color-value": "", children: [
444
- /* @__PURE__ */ jsx(
445
- "button",
446
- {
447
- type: "button",
448
- "data-enigma-color-format": "",
449
- "aria-label": `${text.formatAs ?? "Show as"} ${FORMAT_LABELS[nextFormat]}`,
450
- title: `${text.formatAs ?? "Show as"} ${FORMAT_LABELS[nextFormat]}`,
451
- onClick: () => {
452
- setShown(nextFormat);
453
- setDraft(null);
475
+ ] }),
476
+ swatches && swatches.length > 0 && /* @__PURE__ */ jsx("div", { "data-enigma-color-swatches": "", role: "group", "aria-label": text.swatches ?? "Preset colours", children: swatches.map((preset) => {
477
+ const colour = parseColor(preset);
478
+ return /* @__PURE__ */ jsx(
479
+ "button",
480
+ {
481
+ type: "button",
482
+ "data-enigma-color-preset": "",
483
+ "data-enigma-color-checkers": "",
484
+ style: { background: preset },
485
+ "aria-label": preset,
486
+ title: preset,
487
+ "aria-pressed": colourEqualsPreset(colour, css),
488
+ onClick: () => {
489
+ if (colour) commit(rgbToHsv(alpha ? colour : { ...colour, a: 1 }, hsv.h));
490
+ }
454
491
  },
455
- children: FORMAT_LABELS[shown]
456
- }
457
- ),
458
- /* @__PURE__ */ jsx(
459
- "input",
460
- {
461
- type: "text",
462
- "data-enigma-color-input": "",
463
- value: draft ?? readout,
464
- "aria-label": text.value ?? "Colour value",
465
- spellCheck: false,
466
- autoComplete: "off",
467
- autoCorrect: "off",
468
- autoCapitalize: "off",
469
- onChange: (event) => typed(event.target.value),
470
- onBlur: () => setDraft(null),
471
- onKeyDown: (event) => {
472
- if (event.key !== "Enter") return;
473
- event.preventDefault();
474
- setDraft(null);
475
- }
476
- }
477
- )
478
- ] }),
479
- swatches && swatches.length > 0 && /* @__PURE__ */ jsx("div", { "data-enigma-color-swatches": "", role: "group", "aria-label": text.swatches ?? "Preset colours", children: swatches.map((preset) => {
480
- const colour = parseColor(preset);
481
- return /* @__PURE__ */ jsx(
482
- "button",
483
- {
484
- type: "button",
485
- "data-enigma-color-preset": "",
486
- "data-enigma-color-checkers": "",
487
- style: { background: preset },
488
- "aria-label": preset,
489
- title: preset,
490
- "aria-pressed": colourEqualsPreset(colour, css),
491
- onClick: () => {
492
- if (colour) commit(rgbToHsv(alpha ? colour : { ...colour, a: 1 }, hsv.h));
493
- }
494
- },
495
- preset
496
- );
497
- }) })
498
- ]
499
- }
492
+ preset
493
+ );
494
+ }) })
495
+ ]
496
+ }
497
+ ),
498
+ container
500
499
  )
501
500
  }
502
501
  );
@@ -1,5 +1,5 @@
1
1
  import { ReactNode, RefObject } from 'react';
2
- import { a as ContextMenuAction, b as ContextMenuEntry, c as ContextMenuInstance, j as ContextMenuState, h as ContextMenuPoint } from './context-menu-D3FtTn7v.js';
2
+ import { a as ContextMenuAction, b as ContextMenuEntry, c as ContextMenuInstance, j as ContextMenuState, h as ContextMenuPoint } from './context-menu-qqpGBkny.js';
3
3
 
4
4
  /**
5
5
  * One row, as React draws it. The core carries `icon` as `unknown` because it cannot know
@@ -126,6 +126,12 @@ interface ContextMenuOptions {
126
126
  /** A row was invoked. The menu has already closed unless the row keeps it open. */
127
127
  onSelect?: (item: ContextMenuAction, path: string[]) => void;
128
128
  onOpenChange?: (open: boolean) => void;
129
+ /**
130
+ * Whether the ROOT level draws a filter. `"auto"` (the default) grows one from
131
+ * `SEARCHABLE_FROM` rows; `true` puts one there whatever the count, which is what a menu
132
+ * filling itself from somewhere wants; `false` never does.
133
+ */
134
+ searchable?: boolean | "auto";
129
135
  }
130
136
  interface ContextMenuInstance {
131
137
  readonly state: ContextMenuState;
package/dist/index.d.ts CHANGED
@@ -9,8 +9,8 @@ export { R as RelativeTimeFormat, a as RelativeTimeOptions, b as RelativeTimePre
9
9
  export { F as FLAG_CDN, a as FLAG_RATIO, b as FlagConfig, c as FlagFormat, d as FlagOptions, e as FlagShape, f as FlagSource, g as FlagView, h as configureFlags, i as flagAttributes, j as flagConfig, k as flagName, l as flagSrc, m as flagView, n as normalizeFlagCode, r as resetFlagConfig } from './flags-BQU1V9rE.js';
10
10
  export { P as PaletteKey, a as PositionedRow, R as RecentEntry, b as RecentStore, c as RecentStoreOptions, d as RowGroup, e as createRecentStore, g as groupRows, i as isPaletteShortcut, m as moveActive, r as recentKey, s as shortcutLabel } from './palette-D7iuQh_T.js';
11
11
  export { S as SELECT_SEARCH_KEYS, a as SelectInstance, b as SelectMoveKey, c as SelectOption, d as SelectOptions, e as SelectState, f as createSelect } from './select-ClSy-J1f.js';
12
- export { C as CONTEXT_MENU_SEARCH_KEYS, a as ContextMenuAction, b as ContextMenuEntry, c as ContextMenuInstance, d as ContextMenuLabel, e as ContextMenuLevel, f as ContextMenuMoveKey, g as ContextMenuOptions, h as ContextMenuPoint, i as ContextMenuSeparator, j as ContextMenuState, k as createContextMenu, l as isAction } from './context-menu-D3FtTn7v.js';
13
- export { C as CLIPBOARD_PREFIX, a as ClipboardAction, b as ClipboardMenuLabels, c as ClipboardMenuOptions, d as ClipboardTarget, e as clipboardAction, f as clipboardEntries, g as clipboardHasText, i as inspectClipboardTarget, p as performClipboardAction } from './clipboard-menu-BvXJCSFN.js';
12
+ export { C as CONTEXT_MENU_SEARCH_KEYS, a as ContextMenuAction, b as ContextMenuEntry, c as ContextMenuInstance, d as ContextMenuLabel, e as ContextMenuLevel, f as ContextMenuMoveKey, g as ContextMenuOptions, h as ContextMenuPoint, i as ContextMenuSeparator, j as ContextMenuState, k as createContextMenu, l as isAction } from './context-menu-qqpGBkny.js';
13
+ export { C as CLIPBOARD_PREFIX, a as ClipboardAction, b as ClipboardMenuLabels, c as ClipboardMenuOptions, d as ClipboardTarget, e as clipboardAction, f as clipboardEntries, g as clipboardHasText, i as inspectClipboardTarget, p as performClipboardAction } from './clipboard-menu-eemzEBqB.js';
14
14
  export { D as DEFAULT_SELECTION_SHORTCUTS, S as SelectionClickModifiers, a as SelectionCommand, b as SelectionCommandEvent, c as SelectionCommandName, d as SelectionInstance, e as SelectionOptions, f as SelectionShortcuts, g as SelectionState, h as createSelection } from './selection-B_pmzHpy.js';
15
15
  export { S as Shortcut, a as ShortcutEvent, b as ShortcutSpec, T as TYPEAHEAD_MS, c as TypeaheadState, d as TypeaheadStep, i as isApplePlatform, m as matchesShortcut, p as parseShortcut, s as shortcutList, e as shortcutText, f as shortcutTokens, t as typeaheadStep } from './keys-D2zJs1uB.js';
16
16
 
@@ -140,6 +140,23 @@ declare function filenameFrom(url: string, fallback?: string): string;
140
140
  * when that is refused (no CORS header) - a tab is still better than nothing happening.
141
141
  */
142
142
  declare function downloadFile(url: string, filename?: string): Promise<void>;
143
+ /**
144
+ * A `data:` URL as the bytes it stands for.
145
+ *
146
+ * Synchronous on purpose: it is used to open a tab, and a window opened after an `await` is a
147
+ * popup with no gesture behind it, which the browser blocks.
148
+ */
149
+ declare function dataUrlToBlob(url: string): Blob;
150
+ /**
151
+ * The picture on its own, in another tab.
152
+ *
153
+ * Chromium refuses a top-level navigation to a `data:` URL - it was a phishing vector - so a
154
+ * row that just called `window.open` on one did nothing at all, silently, which is how it
155
+ * shipped. Those are handed over as a blob instead; everything else opens as it is.
156
+ *
157
+ * `noopener` on both: the new tab must not get a handle on the page that opened it.
158
+ */
159
+ declare function openInNewTab(url: string): void;
143
160
  /** How long the picture takes to fly, when the stylesheet does not say otherwise. */
144
161
  declare const FLIGHT_MS = 300;
145
162
  /**
@@ -249,6 +266,15 @@ declare function toggleFullscreen(container: HTMLElement, video: HTMLVideoElemen
249
266
  /** Picture in picture, where the browser has it. Firefox has its own button and no API. */
250
267
  declare function supportsPip(): boolean;
251
268
  declare function togglePip(video: HTMLVideoElement): Promise<void>;
269
+ /**
270
+ * The type a URL's extension implies, or undefined.
271
+ *
272
+ * Read from the PATH, so a query string or a fragment cannot be mistaken for one -
273
+ * `/clip.mp4?token=...` is still an mp4, and `/download?file=x.webm` is not a webm, because
274
+ * the extension has to be on the path's last segment. A `blob:` or `data:` URL has no
275
+ * extension to read and gets nothing, which is the right answer: the browser sniffs.
276
+ */
277
+ declare function sourceType(url: string): string | undefined;
252
278
  /** One subtitle track, as the menu lists it. */
253
279
  interface CaptionTrack {
254
280
  /** Where it sits in the element's own `textTracks`, which is what turns it on. */
@@ -303,4 +329,4 @@ declare function watchRemote(video: HTMLVideoElement, onChange: (state: RemoteSt
303
329
  */
304
330
  declare function promptRemote(video: HTMLVideoElement): Promise<void>;
305
331
 
306
- export { type Box, type CaptionTrack, FLIGHT_MS, IDENTITY, INPUT_ICON_PATHS, type PlayerCommand, type RemoteState, SEEK_JUMP, SEEK_STEP, SPEEDS, type Transform, VOLUME_STEP, ZOOM_DOUBLE, ZOOM_LIMITS, ZOOM_STEP, type ZoomLimits, activeCaption, bufferedAhead, captionTracks, clampPan, clampScale, commandFor, downloadFile, filenameFrom, fittedSize, flightFrom, flightMs, formatTime, fractionAt, fullscreenElement, iconMarkup, isTypingTarget, nextIndex, nextSpeed, pinchDistance, prefersReducedMotion, progress, promptRemote, showCaption, supportsPip, supportsRemote, toggleFullscreen, togglePip, watchRemote, wheelFactor, zoomAt };
332
+ export { type Box, type CaptionTrack, FLIGHT_MS, IDENTITY, INPUT_ICON_PATHS, type PlayerCommand, type RemoteState, SEEK_JUMP, SEEK_STEP, SPEEDS, type Transform, VOLUME_STEP, ZOOM_DOUBLE, ZOOM_LIMITS, ZOOM_STEP, type ZoomLimits, activeCaption, bufferedAhead, captionTracks, clampPan, clampScale, commandFor, dataUrlToBlob, downloadFile, filenameFrom, fittedSize, flightFrom, flightMs, formatTime, fractionAt, fullscreenElement, iconMarkup, isTypingTarget, nextIndex, nextSpeed, openInNewTab, pinchDistance, prefersReducedMotion, progress, promptRemote, showCaption, sourceType, supportsPip, supportsRemote, toggleFullscreen, togglePip, watchRemote, wheelFactor, zoomAt };
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
- export { FLIGHT_MS, IDENTITY, ZOOM_DOUBLE, ZOOM_LIMITS, ZOOM_STEP, clampPan, clampScale, downloadFile, filenameFrom, fittedSize, flightFrom, flightMs, nextIndex, pinchDistance, prefersReducedMotion, wheelFactor, zoomAt } from './chunk-QIIV2QSV.js';
1
+ export { FLIGHT_MS, IDENTITY, ZOOM_DOUBLE, ZOOM_LIMITS, ZOOM_STEP, clampPan, clampScale, dataUrlToBlob, downloadFile, filenameFrom, fittedSize, flightFrom, flightMs, nextIndex, openInNewTab, pinchDistance, prefersReducedMotion, wheelFactor, zoomAt } from './chunk-HUUINHPR.js';
2
2
  export { createInput } from './chunk-KJINGUQN.js';
3
3
  export { colorEquals, formatColor, hslToRgb, hsvToRgb, parseColor, rgbToHsl, rgbToHsv, toHex } from './chunk-S2FPN5ID.js';
4
4
  export { SERVER_NETWORK_STATE, createNetworkMonitor } from './chunk-2QFTRNAZ.js';
5
5
  export { ensureZone, normalizeDate, parseDuration, relativeTimeAttributes, relativeTimeView } from './chunk-IXVMRVD4.js';
6
6
  export { estimatePasswordStrength, generatePassword } from './chunk-HC2ME5PU.js';
7
- export { CLIPBOARD_PREFIX, CONTEXT_MENU_SEARCH_KEYS, clipboardAction, clipboardEntries, clipboardHasText, createContextMenu, inspectClipboardTarget, isAction, performClipboardAction } from './chunk-Z3VDE7OA.js';
7
+ export { CLIPBOARD_PREFIX, CONTEXT_MENU_SEARCH_KEYS, clipboardAction, clipboardEntries, clipboardHasText, createContextMenu, inspectClipboardTarget, isAction, performClipboardAction } from './chunk-YQV5XZIA.js';
8
8
  export { DEFAULT_SELECTION_SHORTCUTS, createSelection } from './chunk-WSQC3PCC.js';
9
- export { SEEK_JUMP, SEEK_STEP, SPEEDS, VOLUME_STEP, activeCaption, bufferedAhead, captionTracks, commandFor, formatTime, fractionAt, fullscreenElement, isTypingTarget, nextSpeed, progress, promptRemote, showCaption, supportsPip, supportsRemote, toggleFullscreen, togglePip, watchRemote } from './chunk-RUEQ3TGP.js';
9
+ export { SEEK_JUMP, SEEK_STEP, SPEEDS, VOLUME_STEP, activeCaption, bufferedAhead, captionTracks, commandFor, formatTime, fractionAt, fullscreenElement, isTypingTarget, nextSpeed, progress, promptRemote, showCaption, sourceType, supportsPip, supportsRemote, toggleFullscreen, togglePip, watchRemote } from './chunk-JLZDS6CV.js';
10
10
  export { createButton } from './chunk-MMQPZGSU.js';
11
11
  export { FLAG_CDN, FLAG_RATIO, configureFlags, flagAttributes, flagConfig, flagName, flagSrc, flagView, normalizeFlagCode, resetFlagConfig } from './chunk-LMZJBOZG.js';
12
12
  export { createNotifications } from './chunk-SNYUBXWQ.js';
@@ -1,5 +1,6 @@
1
- import { ContextMenu, useContextMenuContext } from './chunk-DZMHY3SU.js';
2
- import './chunk-Z3VDE7OA.js';
1
+ import { ContextMenu, useContextMenuContext } from './chunk-RRPWJAIJ.js';
2
+ import './chunk-YQV5XZIA.js';
3
+ import './chunk-RXEO4WPI.js';
3
4
  import './chunk-4VUHQFAT.js';
4
5
  import './chunk-HS3X3XCW.js';
5
6
  import './chunk-4ZPMP47J.js';
@@ -1,8 +1,9 @@
1
- import { Download, MenuButton } from './chunk-ISXB5RUH.js';
2
- import { downloadFile } from './chunk-QIIV2QSV.js';
3
- import { ContextMenu, useContextMenuContext } from './chunk-DZMHY3SU.js';
1
+ import { Download, NewTab, MenuButton } from './chunk-CB7K6VW4.js';
2
+ import { downloadFile, openInNewTab } from './chunk-HUUINHPR.js';
3
+ import { ContextMenu, useContextMenuContext } from './chunk-RRPWJAIJ.js';
4
4
  import './chunk-EYZ366LP.js';
5
- import './chunk-Z3VDE7OA.js';
5
+ import './chunk-YQV5XZIA.js';
6
+ import './chunk-RXEO4WPI.js';
6
7
  import './chunk-4VUHQFAT.js';
7
8
  import './chunk-HS3X3XCW.js';
8
9
  import './chunk-4ZPMP47J.js';
@@ -14,6 +15,9 @@ function ImageMenu({ item, index, options, labels }) {
14
15
  if (options.download !== false) {
15
16
  rows.push({ id: "download", label: labels.download ?? "Download", icon: /* @__PURE__ */ jsx(Download, {}) });
16
17
  }
18
+ if (options.newTab !== false) {
19
+ rows.push({ id: "new-tab", label: labels.newTab ?? "Open in a new tab", icon: /* @__PURE__ */ jsx(NewTab, {}) });
20
+ }
17
21
  if (options.items?.length) {
18
22
  if (rows.length > 0) rows.push({ type: "separator" });
19
23
  rows.push(...options.items);
@@ -25,6 +29,7 @@ function ImageMenu({ item, index, options, labels }) {
25
29
  clipboard: false,
26
30
  onSelect: (row) => {
27
31
  if (row.id === "download") void downloadFile(item.download ?? item.src, item.filename);
32
+ if (row.id === "new-tab") openInNewTab(item.src);
28
33
  options.onSelect?.(row.id, item, index);
29
34
  },
30
35
  children: [
@@ -24,14 +24,14 @@ export { R as RecentEntry, b as RecentStore, e as createRecentStore, g as groupR
24
24
  export { Select, SelectContent, SelectContextValue, SelectItem, SelectList, SelectMultipleProps, SelectOptionRow, SelectProps, SelectRoot, SelectRootProps, SelectSearch, SelectSingleProps, SelectTrigger, SelectValue, useSelectContext } from '../react/select.js';
25
25
  export { a as SelectInstance, c as SelectOption, d as SelectOptions, e as SelectState, f as createSelect } from '../select-ClSy-J1f.js';
26
26
  export { ContextMenu, ContextMenuContent, ContextMenuContentProps, ContextMenuList, ContextMenuPanel, ContextMenuProps, ContextMenuRoot, ContextMenuRootProps, ContextMenuRow, ContextMenuSearch, ContextMenuTrigger, ContextMenuTriggerProps } from '../react/context-menu.js';
27
- export { C as CLIPBOARD_PREFIX, a as ClipboardAction, b as ClipboardMenuLabels, c as ClipboardMenuOptions, d as ClipboardTarget, e as clipboardAction, f as clipboardEntries, g as clipboardHasText, i as inspectClipboardTarget, p as performClipboardAction } from '../clipboard-menu-BvXJCSFN.js';
28
- export { a as ContextMenuAction, b as ContextMenuEntry, c as ContextMenuInstance, g as ContextMenuOptions, j as ContextMenuState, k as createContextMenu, l as isAction } from '../context-menu-D3FtTn7v.js';
27
+ export { C as CLIPBOARD_PREFIX, a as ClipboardAction, b as ClipboardMenuLabels, c as ClipboardMenuOptions, d as ClipboardTarget, e as clipboardAction, f as clipboardEntries, g as clipboardHasText, i as inspectClipboardTarget, p as performClipboardAction } from '../clipboard-menu-eemzEBqB.js';
28
+ export { a as ContextMenuAction, b as ContextMenuEntry, c as ContextMenuInstance, g as ContextMenuOptions, j as ContextMenuState, k as createContextMenu, l as isAction } from '../context-menu-qqpGBkny.js';
29
29
  export { MarqueeRect, SelectionList, SelectionListProps, SelectionRenderer, SelectionRowRender, UseSelectionOptions, UseSelectionResult, useSelection } from '../react/selection.js';
30
30
  export { D as DEFAULT_SELECTION_SHORTCUTS, a as SelectionCommand, b as SelectionCommandEvent, c as SelectionCommandName, d as SelectionInstance, e as SelectionOptions, f as SelectionShortcuts, g as SelectionState, h as createSelection } from '../selection-B_pmzHpy.js';
31
31
  export { S as Shortcut, b as ShortcutSpec, i as isApplePlatform, m as matchesShortcut, p as parseShortcut, e as shortcutText, f as shortcutTokens } from '../keys-D2zJs1uB.js';
32
32
  export { Image, ImageItem, ImageLabels, ImageMenuOptions, ImageProps, ImageSource, ZoomOptions } from '../react/image.js';
33
33
  export { Video, VideoControls, VideoLabels, VideoProps, VideoSource, VideoTrack } from '../react/video.js';
34
- export { C as ContextMenuContextValue, a as ContextMenuItem, b as ContextMenuNode, u as useContextMenuContext } from '../context-BfjYGPnH.js';
34
+ export { C as ContextMenuContextValue, a as ContextMenuItem, b as ContextMenuNode, u as useContextMenuContext } from '../context-DR1dpO8b.js';
35
35
 
36
36
  /**
37
37
  * The Next.js entry. Same components, wired to `next/link`.
@@ -4,11 +4,11 @@ export { useSearch } from '../chunk-45UHLZYT.js';
4
4
  export { useNetworkState } from '../chunk-S653GLSF.js';
5
5
  export { RelativeTime } from '../chunk-OCMI7R6H.js';
6
6
  export { PasswordStrength } from '../chunk-XQHCZAPJ.js';
7
- export { ContextMenu, ContextMenuContent, ContextMenuList, ContextMenuPanel, ContextMenuRoot, ContextMenuRow, ContextMenuSearch, ContextMenuTrigger, useContextMenuContext } from '../chunk-DZMHY3SU.js';
7
+ export { ContextMenu, ContextMenuContent, ContextMenuList, ContextMenuPanel, ContextMenuRoot, ContextMenuRow, ContextMenuSearch, ContextMenuTrigger, useContextMenuContext } from '../chunk-RRPWJAIJ.js';
8
8
  export { SelectionList, useSelection } from '../chunk-N6PDHMAX.js';
9
- export { Image } from '../chunk-4SZ5N7BA.js';
9
+ export { Image } from '../chunk-IQMHDRJF.js';
10
10
  import '../chunk-EYZ366LP.js';
11
- export { Video } from '../chunk-JJVZYW5C.js';
11
+ export { Video } from '../chunk-JPBVKXOL.js';
12
12
  import { Button } from '../chunk-6BGBYUSZ.js';
13
13
  export { getLinkComponent, setLinkComponent, useButton } from '../chunk-6BGBYUSZ.js';
14
14
  export { Flag } from '../chunk-NPHRS2Q7.js';
@@ -20,18 +20,19 @@ export { colorEquals, formatColor, hslToRgb, hsvToRgb, parseColor, rgbToHsl, rgb
20
20
  import '../chunk-2QFTRNAZ.js';
21
21
  import '../chunk-IXVMRVD4.js';
22
22
  export { estimatePasswordStrength, generatePassword } from '../chunk-HC2ME5PU.js';
23
- export { CLIPBOARD_PREFIX, clipboardAction, clipboardEntries, clipboardHasText, createContextMenu, inspectClipboardTarget, isAction, performClipboardAction } from '../chunk-Z3VDE7OA.js';
23
+ export { CLIPBOARD_PREFIX, clipboardAction, clipboardEntries, clipboardHasText, createContextMenu, inspectClipboardTarget, isAction, performClipboardAction } from '../chunk-YQV5XZIA.js';
24
24
  export { DEFAULT_SELECTION_SHORTCUTS, createSelection } from '../chunk-WSQC3PCC.js';
25
- import '../chunk-RUEQ3TGP.js';
25
+ import '../chunk-JLZDS6CV.js';
26
26
  import '../chunk-MMQPZGSU.js';
27
27
  export { configureFlags, flagAttributes, flagName, flagSrc, flagView, normalizeFlagCode } from '../chunk-LMZJBOZG.js';
28
28
  import '../chunk-SNYUBXWQ.js';
29
29
  import '../chunk-UOSSNUSC.js';
30
- export { Input } from '../chunk-RMNXVWQ4.js';
30
+ export { Input } from '../chunk-YHH5U2NW.js';
31
31
  import '../chunk-KVLSOQTI.js';
32
32
  import '../chunk-F25CGNQC.js';
33
33
  export { PaletteContent, PaletteField, PaletteFooter, PaletteItem, PaletteList, PaletteRoot, PaletteTrigger, SearchPalette, usePaletteContext } from '../chunk-FGBIZDV2.js';
34
- export { Select, SelectContent, SelectList, SelectOptionRow, SelectRoot, SelectSearch, SelectTrigger, SelectValue, useSelectContext } from '../chunk-VKL3DEIQ.js';
34
+ export { Select, SelectContent, SelectList, SelectOptionRow, SelectRoot, SelectSearch, SelectTrigger, SelectValue, useSelectContext } from '../chunk-6WIGVIQF.js';
35
+ import '../chunk-RXEO4WPI.js';
35
36
  export { createSelect } from '../chunk-NONGREXC.js';
36
37
  export { isApplePlatform, matchesShortcut, parseShortcut, shortcutText, shortcutTokens } from '../chunk-4VUHQFAT.js';
37
38
  export { Slot, mergeSlotProps } from '../chunk-HS3X3XCW.js';