@enigmax/primitives 0.25.0 → 0.27.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 (55) hide show
  1. package/dist/chunk-2RIO4VDV.js +121 -0
  2. package/dist/{chunk-DZMHY3SU.js → chunk-CPJJ3FPW.js} +17 -7
  3. package/dist/chunk-EYZ366LP.js +189 -0
  4. package/dist/chunk-HUUINHPR.js +135 -0
  5. package/dist/chunk-JLZDS6CV.js +177 -0
  6. package/dist/chunk-O2UJ5ZIX.js +387 -0
  7. package/dist/chunk-PVDU6AZU.js +953 -0
  8. package/dist/{chunk-Z3VDE7OA.js → chunk-YQV5XZIA.js} +2 -2
  9. package/dist/clipboard-menu-eemzEBqB.d.ts +93 -0
  10. package/dist/context-DR1dpO8b.d.ts +54 -0
  11. package/dist/{clipboard-menu-B_ouitfS.d.ts → context-menu-qqpGBkny.d.ts} +7 -91
  12. package/dist/index.d.ts +292 -2
  13. package/dist/index.js +5 -3
  14. package/dist/menu-52PXC5PL.js +33 -0
  15. package/dist/menu-YIGMPFUP.js +58 -0
  16. package/dist/next/index.d.ts +6 -2
  17. package/dist/next/index.js +12 -8
  18. package/dist/react/context-menu.d.ts +15 -55
  19. package/dist/react/context-menu.js +2 -2
  20. package/dist/react/image.d.ts +112 -0
  21. package/dist/react/image.js +3 -0
  22. package/dist/react/index.d.ts +6 -2
  23. package/dist/react/index.js +12 -8
  24. package/dist/react/input.js +1 -1
  25. package/dist/react/video.d.ts +126 -0
  26. package/dist/react/video.js +3 -0
  27. package/dist/react-router/index.d.ts +6 -2
  28. package/dist/react-router/index.js +12 -8
  29. package/dist/viewer-N5WLFB24.js +3 -0
  30. package/package.json +15 -2
  31. package/recipes/context-menu/styles.css +8 -1
  32. package/recipes/image/styles.css +182 -0
  33. package/recipes/video/styles.css +154 -0
  34. package/registry.json +486 -5
  35. package/src/core/context-menu.ts +22 -3
  36. package/src/core/image-viewer.ts +269 -0
  37. package/src/core/player.ts +345 -0
  38. package/src/index.ts +55 -0
  39. package/src/react/context-menu/root.tsx +27 -5
  40. package/src/react/context-menu/styles.ts +8 -1
  41. package/src/react/image/icons.tsx +59 -0
  42. package/src/react/image/index.tsx +185 -0
  43. package/src/react/image/menu.tsx +80 -0
  44. package/src/react/image/styles.ts +213 -0
  45. package/src/react/image/types.ts +116 -0
  46. package/src/react/image/viewer.tsx +571 -0
  47. package/src/react/index.ts +3 -0
  48. package/src/react/video/icons.tsx +135 -0
  49. package/src/react/video/index.tsx +731 -0
  50. package/src/react/video/menu.tsx +66 -0
  51. package/src/react/video/rail.tsx +99 -0
  52. package/src/react/video/styles.ts +161 -0
  53. package/src/react/video/types.ts +141 -0
  54. /package/dist/{chunk-3MGBZOAU.js → chunk-RMNXVWQ4.js} +0 -0
  55. /package/dist/{chunk-MSOCCQGH.js → chunk-T7I6WJSN.js} +0 -0
@@ -0,0 +1,116 @@
1
+ /**
2
+ * The prop shapes for `<Image>`, split from the component so the viewer's chunk can import
3
+ * them without pulling the component in - the same arrangement `<Input>` is in.
4
+ *
5
+ * WHAT IS ON BY DEFAULT is the whole design of this API: an image that opens and zooms, and
6
+ * nothing else. A gallery's arrows, its thumbnails, a menu and a discard action are each a
7
+ * decision about the page they sit in, so each is a prop you turn on rather than one you
8
+ * remember to turn off.
9
+ */
10
+
11
+ import type { ComponentPropsWithoutRef, ReactNode } from "react";
12
+ import type { ContextMenuNode } from "@/react/context-menu/context";
13
+
14
+ /** One image in a set: a URL, or the URL plus what is known about it. */
15
+ export type ImageSource = string | ImageItem;
16
+
17
+ export interface ImageItem {
18
+ src: string;
19
+ alt?: string;
20
+ /** A smaller file for the strip and for the frame while the full one loads. */
21
+ thumbnail?: string;
22
+ /** The URL to save, when the file to download is not the one being shown. */
23
+ download?: string;
24
+ /** Saved under this name instead of the one in the URL. */
25
+ filename?: string;
26
+ caption?: ReactNode;
27
+ }
28
+
29
+ export interface ZoomOptions {
30
+ /** How far out. 1 is the fitted image; below it the picture is smaller than its frame. */
31
+ min?: number;
32
+ max?: number;
33
+ /** Zoom on the wheel. On by default - it is the gesture every image viewer answers. */
34
+ wheel?: boolean;
35
+ /** A double press toggles between fitted and this. `false` leaves the gesture alone. */
36
+ doubleClick?: boolean;
37
+ }
38
+
39
+ export interface ImageMenuOptions {
40
+ /** The download row. On whenever the menu is. */
41
+ download?: boolean;
42
+ /** The row that opens the picture on its own, in another tab. On whenever the menu is. */
43
+ newTab?: boolean;
44
+ /** Rows of your own, after the built-in ones. */
45
+ items?: readonly ContextMenuNode[];
46
+ onSelect?: (id: string, item: ImageItem, index: number) => void;
47
+ }
48
+
49
+ /** Every string the viewer says, for a UI that is not in English. */
50
+ export interface ImageLabels {
51
+ open?: string;
52
+ close?: string;
53
+ zoomIn?: string;
54
+ zoomOut?: string;
55
+ reset?: string;
56
+ previous?: string;
57
+ next?: string;
58
+ menu?: string;
59
+ download?: string;
60
+ newTab?: string;
61
+ discard?: string;
62
+ thumbnails?: string;
63
+ /** The frame itself, announced as the dialog's name. Default "Image viewer". */
64
+ viewer?: string;
65
+ /** `{index}` and `{total}` are replaced. Default "{index} of {total}". */
66
+ counter?: string;
67
+ }
68
+
69
+ export interface ImageProps extends Omit<ComponentPropsWithoutRef<"img">, "children" | "onSelect"> {
70
+ src: string;
71
+ alt: string;
72
+ /**
73
+ * The set this image belongs to. Without it the viewer shows this one image; with it the
74
+ * arrows, the strip and the discard action have something to move through.
75
+ */
76
+ images?: readonly ImageSource[];
77
+ /** Where in `images` this one is. Found by `src` when it is left out. */
78
+ index?: number;
79
+ /** Click to see it larger. ON by default: it is what an image in a page is expected to do. */
80
+ lightbox?: boolean;
81
+ /** Zoom, with the wheel and the keyboard. ON by default. */
82
+ zoom?: boolean | ZoomOptions;
83
+ /**
84
+ * The picture flies out of the page into the viewer, and back into it on the way out. ON
85
+ * by default, and skipped anyway for a reader who has asked for less movement.
86
+ */
87
+ animate?: boolean;
88
+ /** Arrows, the counter, and Left/Right on the keyboard. Off by default. */
89
+ navigation?: boolean;
90
+ /** The strip of previews along the bottom. Off by default. */
91
+ thumbnails?: boolean;
92
+ /** The three dots, and what is under them. Off by default. */
93
+ menu?: boolean | ImageMenuOptions;
94
+ /**
95
+ * Take an image out of the set and move to the next one. Off by default, because it is
96
+ * destructive and only the caller knows whether it means anything on their page.
97
+ */
98
+ discardable?: boolean;
99
+ onDiscard?: (item: ImageItem, index: number) => void;
100
+ /** Whether the arrows and the strip wrap around at the ends. On by default. */
101
+ loop?: boolean;
102
+ /** The caption under the frame, when the item carries none of its own. */
103
+ caption?: ReactNode;
104
+ onOpenChange?: (open: boolean) => void;
105
+ onIndexChange?: (index: number, item: ImageItem) => void;
106
+ /** The viewer's stylesheet, injected once. There is no useful unstyled lightbox. */
107
+ styles?: boolean;
108
+ labels?: ImageLabels;
109
+ /** Props for the element wrapping the thumbnail - this is what you position. */
110
+ wrapperProps?: ComponentPropsWithoutRef<"span">;
111
+ }
112
+
113
+ /** A source in either spelling, as the one the viewer works in. */
114
+ export function toItem(source: ImageSource): ImageItem {
115
+ return typeof source === "string" ? { src: source } : source;
116
+ }