@justanarthur/modo-ui-notch 0.2.0 → 0.3.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 (148) hide show
  1. package/README.md +11 -11
  2. package/blocks/activities/agenda/examples.mdx +21 -5
  3. package/blocks/activities/agenda/index.tsx +291 -182
  4. package/blocks/activities/clock/examples.mdx +73 -0
  5. package/blocks/activities/clock/index.tsx +619 -0
  6. package/blocks/activities/now-playing/examples.mdx +32 -13
  7. package/blocks/activities/now-playing/index.tsx +319 -126
  8. package/blocks/activities/weather/examples.mdx +115 -0
  9. package/blocks/activities/weather/index.tsx +634 -0
  10. package/blocks/app/expanded-island/examples.mdx +8 -7
  11. package/blocks/app/expanded-island/index.tsx +19 -3
  12. package/blocks/app/settings-window/examples.mdx +6 -2
  13. package/blocks/app/settings-window/index.tsx +25 -7
  14. package/blocks/system/clipboard/examples.mdx +83 -0
  15. package/blocks/system/clipboard/index.tsx +563 -0
  16. package/blocks/system/recent-files/examples.mdx +66 -0
  17. package/blocks/system/recent-files/index.tsx +542 -0
  18. package/blocks/system/system-stats/examples.mdx +38 -9
  19. package/blocks/system/system-stats/index.tsx +241 -107
  20. package/components/indicators/media-scrubber/examples.mdx +8 -0
  21. package/components/indicators/media-scrubber/index.tsx +37 -13
  22. package/components/island/island/examples.mdx +4 -4
  23. package/components/island/island/index.tsx +2 -2
  24. package/components/island/island-flash/examples.mdx +15 -18
  25. package/components/island/island-flash/index.tsx +4 -4
  26. package/components/island/island-tabs/examples.mdx +5 -5
  27. package/components/island/widget/examples.mdx +76 -0
  28. package/components/island/widget/index.tsx +431 -0
  29. package/dist/blocks/activities/agenda/index.d.ts +1 -1
  30. package/dist/blocks/activities/agenda/index.js +3 -3
  31. package/dist/blocks/activities/clock/index.d.ts +2 -0
  32. package/dist/blocks/activities/clock/index.js +25 -0
  33. package/dist/blocks/activities/now-playing/index.d.ts +3 -2
  34. package/dist/blocks/activities/now-playing/index.js +5 -3
  35. package/dist/blocks/activities/weather/index.d.ts +2 -0
  36. package/dist/blocks/activities/weather/index.js +21 -0
  37. package/dist/blocks/app/expanded-island/index.d.ts +1 -1
  38. package/dist/blocks/app/expanded-island/index.js +4 -3
  39. package/dist/blocks/app/settings-window/index.d.ts +1 -1
  40. package/dist/blocks/app/settings-window/index.js +1 -1
  41. package/dist/blocks/system/clipboard/index.d.ts +2 -0
  42. package/dist/blocks/system/clipboard/index.js +17 -0
  43. package/dist/blocks/system/recent-files/index.d.ts +2 -0
  44. package/dist/blocks/system/recent-files/index.js +19 -0
  45. package/dist/blocks/system/system-stats/index.d.ts +2 -2
  46. package/dist/blocks/system/system-stats/index.js +4 -1
  47. package/dist/components/indicators/media-scrubber/index.d.ts +1 -1
  48. package/dist/components/indicators/media-scrubber/index.js +1 -1
  49. package/dist/components/island/island/index.d.ts +1 -1
  50. package/dist/components/island/island/index.js +2 -2
  51. package/dist/components/island/island-flash/index.d.ts +1 -1
  52. package/dist/components/island/island-flash/index.js +1 -1
  53. package/dist/components/island/island-tabs/index.js +2 -2
  54. package/dist/components/island/widget/index.d.ts +2 -0
  55. package/dist/components/island/widget/index.js +30 -0
  56. package/dist/index.d.ts +15 -15
  57. package/dist/index.js +102 -58
  58. package/dist/lib/artwork.d.ts +2 -0
  59. package/dist/lib/artwork.js +8 -0
  60. package/dist/lib/geometry.js +1 -1
  61. package/dist/shared/chunk-2818esrq.d.ts +140 -0
  62. package/dist/shared/{chunk-yngkkxz2.d.ts → chunk-2m5dz8nf.d.ts} +4 -4
  63. package/dist/shared/chunk-3thgcfcq.d.ts +151 -0
  64. package/dist/shared/chunk-416tsgbc.d.ts +175 -0
  65. package/dist/shared/{chunk-zvh0d3qb.js → chunk-61t2dfte.js} +1 -1
  66. package/dist/shared/chunk-7fvnrtz4.d.ts +105 -0
  67. package/dist/shared/{chunk-hpsabfsd.d.ts → chunk-81fpptwp.d.ts} +1 -1
  68. package/dist/shared/chunk-9c7ewvkk.js +381 -0
  69. package/dist/shared/{chunk-mp1nx0ez.js → chunk-9m0xbg5v.js} +14 -3
  70. package/dist/shared/{chunk-wwjxs75m.js → chunk-9xtcv3sy.js} +26 -12
  71. package/dist/shared/chunk-bvtyjcce.d.ts +123 -0
  72. package/dist/shared/{chunk-s33y1pcq.js → chunk-cc9nwbtf.js} +20 -10
  73. package/dist/shared/chunk-da177e8r.d.ts +114 -0
  74. package/dist/shared/{chunk-6c1jbefs.d.ts → chunk-fexwzycv.d.ts} +3 -3
  75. package/dist/shared/chunk-gejenfap.d.ts +25 -0
  76. package/dist/shared/{chunk-rr5e0g15.d.ts → chunk-j755a1a5.d.ts} +7 -1
  77. package/dist/shared/chunk-j77cx8dp.js +498 -0
  78. package/dist/shared/chunk-mt0k6v8x.js +474 -0
  79. package/dist/shared/{chunk-78w7qwp0.js → chunk-ndf79pv5.js} +1 -1
  80. package/dist/shared/{chunk-9nhpg9t8.d.ts → chunk-pfhy5e4q.d.ts} +7 -1
  81. package/dist/shared/chunk-qdzemt2v.js +477 -0
  82. package/dist/shared/{chunk-rpfwv3pz.js → chunk-r471sknr.js} +1 -1
  83. package/dist/shared/chunk-s2jeqqan.js +243 -0
  84. package/dist/shared/chunk-t0hcxh89.d.ts +124 -0
  85. package/dist/shared/chunk-w5h6ay93.js +72 -0
  86. package/dist/shared/chunk-wkg17nxs.d.ts +101 -0
  87. package/dist/shared/chunk-x7f3g82r.js +285 -0
  88. package/dist/shared/chunk-xq5hc5gv.js +333 -0
  89. package/dist/shared/{chunk-sbnrhy5m.js → chunk-y0188bbn.js} +2 -2
  90. package/dist/shared/chunk-ym0xbses.js +518 -0
  91. package/dist/styles.css +97 -55
  92. package/index.ts +7 -6
  93. package/lib/artwork.ts +112 -0
  94. package/lib/geometry.ts +1 -1
  95. package/mock/activities.tsx +9 -32
  96. package/mock/artwork.tsx +13 -1
  97. package/mock/clipboard.tsx +79 -0
  98. package/mock/clock.tsx +77 -0
  99. package/mock/data.ts +30 -44
  100. package/mock/files.tsx +70 -0
  101. package/mock/island-content.tsx +43 -118
  102. package/mock/screen.tsx +76 -0
  103. package/mock/settings.tsx +370 -91
  104. package/mock/system.ts +46 -0
  105. package/mock/weather.tsx +105 -0
  106. package/package.json +7 -2
  107. package/blocks/activities/shelf/examples.mdx +0 -33
  108. package/blocks/activities/shelf/index.tsx +0 -289
  109. package/blocks/activities/timer/examples.mdx +0 -52
  110. package/blocks/activities/timer/index.tsx +0 -292
  111. package/blocks/system/controls/examples.mdx +0 -34
  112. package/blocks/system/controls/index.tsx +0 -167
  113. package/blocks/system/devices/examples.mdx +0 -25
  114. package/blocks/system/devices/index.tsx +0 -172
  115. package/blocks/system/power-alert/examples.mdx +0 -32
  116. package/blocks/system/power-alert/index.tsx +0 -89
  117. package/components/indicators/battery-glyph/examples.mdx +0 -22
  118. package/components/indicators/battery-glyph/index.tsx +0 -91
  119. package/dist/blocks/activities/shelf/index.d.ts +0 -2
  120. package/dist/blocks/activities/shelf/index.js +0 -14
  121. package/dist/blocks/activities/timer/index.d.ts +0 -2
  122. package/dist/blocks/activities/timer/index.js +0 -19
  123. package/dist/blocks/system/controls/index.d.ts +0 -2
  124. package/dist/blocks/system/controls/index.js +0 -10
  125. package/dist/blocks/system/devices/index.d.ts +0 -2
  126. package/dist/blocks/system/devices/index.js +0 -12
  127. package/dist/blocks/system/power-alert/index.d.ts +0 -2
  128. package/dist/blocks/system/power-alert/index.js +0 -9
  129. package/dist/components/indicators/battery-glyph/index.d.ts +0 -2
  130. package/dist/components/indicators/battery-glyph/index.js +0 -9
  131. package/dist/shared/chunk-2qpcsv5h.d.ts +0 -45
  132. package/dist/shared/chunk-45gytfr1.d.ts +0 -84
  133. package/dist/shared/chunk-50ffk4r7.d.ts +0 -69
  134. package/dist/shared/chunk-5w0yck07.d.ts +0 -32
  135. package/dist/shared/chunk-7hr53mby.js +0 -116
  136. package/dist/shared/chunk-b8jb1w72.js +0 -145
  137. package/dist/shared/chunk-cpewy6yg.js +0 -178
  138. package/dist/shared/chunk-e3e4s4ds.d.ts +0 -77
  139. package/dist/shared/chunk-enm6td0p.js +0 -280
  140. package/dist/shared/chunk-fvedaas2.d.ts +0 -33
  141. package/dist/shared/chunk-gex38j8x.d.ts +0 -82
  142. package/dist/shared/chunk-hwtxpzg0.js +0 -69
  143. package/dist/shared/chunk-phb53x1f.js +0 -252
  144. package/dist/shared/chunk-r8esmjfs.d.ts +0 -42
  145. package/dist/shared/chunk-rcp1g9ca.js +0 -70
  146. package/dist/shared/chunk-rx9sphz2.js +0 -266
  147. package/dist/shared/chunk-xdeek16r.d.ts +0 -58
  148. package/dist/shared/chunk-xkzjk1tq.js +0 -206
@@ -0,0 +1,114 @@
1
+ import { SizeVariant } from "@justanarthur/modo-ui/lib/size-context";
2
+ import { ReactNode } from "react";
3
+ import { JSX as JSX_1kxb } from "react";
4
+ type ClipboardClipKind2 = "text" | "link" | "image" | "color" | "file";
5
+ interface ClipboardClip2 {
6
+ /** What tells it apart. */
7
+ id: string;
8
+ /** What was copied: it picks the glyph and how the clip previews. */
9
+ kind: ClipboardClipKind2;
10
+ /** The clip as text: the text, the URL, the color as copied (`#5B8DEF`), the file's or image's name. */
11
+ content: string;
12
+ /** One line more: a link's page title, an image's size, a color in another notation, a file's size. */
13
+ detail?: string;
14
+ /** A picture: an image's thumbnail or a link's favicon, as a URL or any element. */
15
+ preview?: string | ReactNode;
16
+ /** A color clip's paint, any CSS color; defaults to `content`. */
17
+ color?: string;
18
+ /** The app it was copied from. */
19
+ app?: string;
20
+ /** When it was copied, in epoch ms. */
21
+ copiedAt: number;
22
+ }
23
+ interface ClipboardHistoryProps2 {
24
+ /** The clips, in any order: pinned ones list first, the rest newest first. */
25
+ clips: ClipboardClip2[];
26
+ /** The selected clip's id, shown as the hero (controlled). */
27
+ value?: string;
28
+ /** The selected clip at first (uncontrolled). Defaults to the first in the list. */
29
+ defaultValue?: string;
30
+ /** Called with a clip's id when it is picked, by a press or the arrow keys. */
31
+ onValueChange?: (id: string) => void;
32
+ /** The pinned clips' ids (controlled). */
33
+ pinned?: string[];
34
+ /** The pinned clips at first (uncontrolled). Defaults to `[]`. */
35
+ defaultPinned?: string[];
36
+ /** Called with the new ids when a clip is pinned or unpinned. */
37
+ onPinnedChange?: (pinned: string[]) => void;
38
+ /** The search (controlled): clips whose text, detail or app hold it stay. */
39
+ query?: string;
40
+ /** The search at first (uncontrolled). Defaults to `''`. */
41
+ defaultQuery?: string;
42
+ /** Called with the search as it is typed. */
43
+ onQueryChange?: (query: string) => void;
44
+ /** Copying is not recorded (controlled). */
45
+ paused?: boolean;
46
+ /** Copying is not recorded at first (uncontrolled). Defaults to `false`. */
47
+ defaultPaused?: boolean;
48
+ /** Called with the new state when pause or resume is pressed. */
49
+ onPausedChange?: (paused: boolean) => void;
50
+ /** The frontmost app, when it is one whose copies are never kept (a password manager): a chip says so. */
51
+ ignoredApp?: string;
52
+ /** Called by Copy, a row's double-click or Enter, with the clip to put back on the clipboard. */
53
+ onCopy?: (clip: ClipboardClip2) => void;
54
+ /** Called by Delete with the clip to drop from the history. */
55
+ onDelete?: (clip: ClipboardClip2) => void;
56
+ /** The moment the times are read at, in epoch ms. Defaults to now, re-read on each minute. */
57
+ now?: number;
58
+ /** Step on the size ladder. Omitted, it follows the surrounding SizeProvider. */
59
+ size?: SizeVariant;
60
+ /** Classes for the root, which fills its container. */
61
+ className?: string;
62
+ }
63
+ type Element_12xgc = JSX_1kxb["Element"];
64
+ /** The compact island's left wing: the clipboard glyph. */
65
+ declare function ClipboardHistoryLeading2(): Element_12xgc;
66
+ /** The compact island's right wing: how many clips came in since the island was last open. */
67
+ declare function ClipboardHistoryTrailing2({ count }: {
68
+ count: number;
69
+ }): Element_12xgc;
70
+ interface CopiedProps {
71
+ /** The clip that was copied. */
72
+ clip: ClipboardClip2;
73
+ /** Called by Pin; without it the button hides. */
74
+ onPin?: (clip: ClipboardClip2) => void;
75
+ }
76
+ /** The island's flash when something is copied: the clip's picture or glyph, `Copied`, its preview and Pin. */
77
+ declare function ClipboardHistoryCopied2({ clip, onPin }: CopiedProps): Element_12xgc;
78
+ /**
79
+ * A notch app's clipboard history: the latest clip as the hero, the ones
80
+ * before it beside it, pinned ones on top.
81
+ *
82
+ * The hero is the selected clip, the newest until another is picked, shown
83
+ * as what it is: text over two lines, a link as its domain with the page's
84
+ * title, an image as its thumbnail, a color as a swatch with its value, a
85
+ * file as a tile with its name and size. The context line says where it was
86
+ * copied and how long ago; under the hero, its length or a link's path,
87
+ * Pin, Delete and Copy.
88
+ *
89
+ * Beside it, past a hairline, a search over the history and the clips
90
+ * themselves: pinned ones first, then the rest newest first, each a row of
91
+ * its swatch, thumbnail or glyph, its text and how long ago. Three show at
92
+ * a time, around the selected one, with a count of the rest. The arrow keys
93
+ * move the selection from anywhere in the widget (the search included),
94
+ * Enter copies it, and a double-click copies a row. The selection, the pins
95
+ * and the search each work both ways (`value`, `pinned`, `query`, with
96
+ * their `default…` and `on…Change`).
97
+ *
98
+ * Recording pauses from the context line (`paused`), and an app whose
99
+ * copies are never kept, such as a password manager, shows as a chip
100
+ * (`ignoredApp`). With no clips it says what will show up here, or that
101
+ * the history is paused.
102
+ *
103
+ * `ClipboardHistory.Leading` and `ClipboardHistory.Trailing` show the
104
+ * glyph and the count of new clips in the compact island's wings, and
105
+ * `ClipboardHistory.Copied` is the flash when something is copied.
106
+ *
107
+ * @example {@include ./examples.mdx}
108
+ */
109
+ declare const ClipboardHistory2: (({ clips, value: valueProp, defaultValue, onValueChange, pinned: pinnedProp, defaultPinned, onPinnedChange, query: queryProp, defaultQuery, onQueryChange, paused: pausedProp, defaultPaused, onPausedChange, ignoredApp, onCopy, onDelete, now: nowProp, size, className }: ClipboardHistoryProps2) => Element_12xgc) & {
110
+ Leading: typeof ClipboardHistoryLeading2;
111
+ Trailing: typeof ClipboardHistoryTrailing2;
112
+ Copied: typeof ClipboardHistoryCopied2;
113
+ };
114
+ export { ClipboardClipKind2, ClipboardClip2, ClipboardHistoryProps2, ClipboardHistoryLeading2, ClipboardHistoryTrailing2, ClipboardHistoryCopied2, ClipboardHistory2 };
@@ -10,9 +10,9 @@ interface IslandFlashProps2 {
10
10
  icon?: ReactNode;
11
11
  /** The hue of the icon and the `value`. Defaults to `'default'`. */
12
12
  tone?: IslandFlashTone2;
13
- /** A figure at the end, in the tone's hue: `82%`, a level. */
13
+ /** A figure at the end, in the tone's hue: `15 min`, a level. */
14
14
  value?: ReactNode;
15
- /** Content after it, such as a BatteryGlyph or an Equalizer. */
15
+ /** Content after it, such as an Equalizer. */
16
16
  trailing?: ReactNode;
17
17
  /** One control at the far end, such as a ghost Button. */
18
18
  action?: ReactNode;
@@ -27,7 +27,7 @@ type Element_12xgc = JSX_1kxb["Element"];
27
27
  * It lays out one row the height of the island's flash: the icon in a fixed
28
28
  * square, the title and caption truncating beside it, then the `value`, any
29
29
  * `trailing` glyph and an `action`. The icon and the value take the tone's
30
- * status hue (a charge in success, a low battery in warning); everything else
30
+ * status hue (a focus round done in success, rain coming in warning); everything else
31
31
  * keeps the two text colors. Pass it as the Island's `flash`.
32
32
  *
33
33
  * @example {@include ./examples.mdx}
@@ -0,0 +1,25 @@
1
+ import { ReactNode } from "react";
2
+ /** A track's picture: an image URL or any element; `null` when the track has none, `undefined` while it isn't known yet. */
3
+ type Artwork2 = string | ReactNode;
4
+ /** What the artwork tile shows: a picture, or the placeholder (`art: null`), under an `id` that changes only when the picture does. */
5
+ interface ShownArtwork2 {
6
+ id: string;
7
+ art: Artwork2 | null;
8
+ }
9
+ /**
10
+ * The artwork to show for the track `trackKey` names, held across updates.
11
+ *
12
+ * A URL is decoded before it replaces what's shown, so the swap is never to
13
+ * a blank. An update without artwork (`undefined`, or `null` for the same
14
+ * track) keeps the last good picture. A new track with `null`, or a URL that
15
+ * fails to load for a new track, shows the placeholder.
16
+ */
17
+ declare function useStableArtwork2(artwork: Artwork2 | null | undefined, trackKey: string): ShownArtwork2;
18
+ /**
19
+ * The color an image URL leans to, as `rgb(…)`: its pixels averaged, the
20
+ * vivid ones weighted up, so a mostly grey cover still lends its accent.
21
+ * Read once per URL; `undefined` until then, or when the image can't be
22
+ * read (a cross-origin image without CORS).
23
+ */
24
+ declare function useArtworkTint2(src?: string): string | undefined;
25
+ export { Artwork2, ShownArtwork2, useStableArtwork2, useArtworkTint2 };
@@ -15,6 +15,8 @@ interface MediaScrubberProps2 {
15
15
  label?: string;
16
16
  /** No seeking. Defaults to `false`. */
17
17
  disabled?: boolean;
18
+ /** At rest a thin line of progress; the scrubber fades in on hover and focus, and always shows on touch. Defaults to `false`. */
19
+ quiet?: boolean;
18
20
  /** Classes for the row. */
19
21
  className?: string;
20
22
  }
@@ -29,7 +31,11 @@ type Element_12xgc = JSX_1kxb["Element"];
29
31
  * press ends, and playback runs on from the seek until the player reports
30
32
  * its next `position`, so the thumb never jumps back to the stale one.
31
33
  *
34
+ * `quiet` is the player's form: at rest a thin line of progress, so the
35
+ * track reads before the control; the scrubber fades in on hover or focus,
36
+ * and always shows on touch.
37
+ *
32
38
  * @example {@include ./examples.mdx}
33
39
  */
34
- declare function MediaScrubber2({ position, duration, playing, onSeek, size, label, disabled, className }: MediaScrubberProps2): Element_12xgc;
40
+ declare function MediaScrubber2({ position, duration, playing, onSeek, size, label, disabled, quiet, className }: MediaScrubberProps2): Element_12xgc;
35
41
  export { MediaScrubberProps2, MediaScrubber2 };
@@ -0,0 +1,498 @@
1
+ "use client";
2
+
3
+ import {
4
+ IslandFlash2
5
+ } from "./chunk-ndf79pv5.js";
6
+ import {
7
+ widget_default
8
+ } from "./chunk-x7f3g82r.js";
9
+ import {
10
+ MINUTE2,
11
+ useEdgeClock2
12
+ } from "./chunk-gb56m10p.js";
13
+
14
+ // blocks/system/clipboard/index.tsx
15
+ import Button from "@justanarthur/modo-ui/components/actions/button";
16
+ import Input from "@justanarthur/modo-ui/components/inputs/input";
17
+ import { SURFACE_BG } from "@justanarthur/modo-ui/lib/surface-classes";
18
+ import { useLift } from "@justanarthur/modo-ui/lib/surface-context";
19
+ import { useControllableState } from "@justanarthur/modo-ui/lib/use-controllable-state";
20
+ import { cn } from "@justanarthur/modo-ui/lib/utils";
21
+ import FluidHover from "@justanarthur/modo-ui/primitives/systems/fluid-hover";
22
+ import { ClipboardList, Copy, File, Image, Link2, Palette, Pause, Pin, Play, Search, Trash2, Type } from "lucide-react";
23
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
24
+ /*!
25
+ * Local addition: a notch app's clipboard history, the latest clip as the
26
+ * hero and the ones before it beside it, pinned ones on top. Presentational:
27
+ * the clips and what to do with them come in as props.
28
+ */
29
+ var ROWS = 3;
30
+ var KIND_ICON = {
31
+ text: Type,
32
+ link: Link2,
33
+ image: Image,
34
+ color: Palette,
35
+ file: File
36
+ };
37
+ var KIND_LABEL = {
38
+ text: "Text",
39
+ link: "Link",
40
+ image: "Image",
41
+ color: "Color",
42
+ file: "File"
43
+ };
44
+ function ago(ms) {
45
+ const minutes = Math.floor(ms / MINUTE2);
46
+ if (minutes < 1)
47
+ return "just now";
48
+ if (minutes < 60)
49
+ return `${minutes} min ago`;
50
+ if (minutes < 24 * 60)
51
+ return `${Math.floor(minutes / 60)} h ago`;
52
+ return `${Math.floor(minutes / (24 * 60))} d ago`;
53
+ }
54
+ function short(ms) {
55
+ const minutes = Math.floor(ms / MINUTE2);
56
+ if (minutes < 1)
57
+ return "now";
58
+ if (minutes < 60)
59
+ return `${minutes}m`;
60
+ if (minutes < 24 * 60)
61
+ return `${Math.floor(minutes / 60)}h`;
62
+ return `${Math.floor(minutes / (24 * 60))}d`;
63
+ }
64
+ function domain(url) {
65
+ try {
66
+ return new URL(url).hostname.replace(/^www\./, "");
67
+ } catch {
68
+ return url;
69
+ }
70
+ }
71
+ function path(url) {
72
+ try {
73
+ const { pathname, search } = new URL(url);
74
+ return `${pathname}${search}`.replace(/^\/$/, "");
75
+ } catch {
76
+ return "";
77
+ }
78
+ }
79
+ var paint = (clip) => clip.color ?? clip.content;
80
+ function Picture({ preview, className }) {
81
+ return /* @__PURE__ */ jsxs("span", {
82
+ className: cn("relative block shrink-0 overflow-hidden", className),
83
+ children: [
84
+ typeof preview === "string" ? /* @__PURE__ */ jsx("img", {
85
+ alt: "",
86
+ src: preview,
87
+ draggable: false,
88
+ className: "size-full object-cover"
89
+ }) : preview,
90
+ /* @__PURE__ */ jsx("span", {
91
+ "aria-hidden": true,
92
+ className: "pointer-events-none absolute inset-0 rounded-[inherit] ring-1 ring-border ring-inset"
93
+ })
94
+ ]
95
+ });
96
+ }
97
+ function Mark({ clip }) {
98
+ if (clip.kind === "color")
99
+ return /* @__PURE__ */ jsx("span", {
100
+ "aria-hidden": true,
101
+ className: "size-3.5 shrink-0 rounded-full",
102
+ style: { backgroundColor: paint(clip) }
103
+ });
104
+ if (clip.preview != null)
105
+ return /* @__PURE__ */ jsx(Picture, {
106
+ preview: clip.preview,
107
+ className: "size-4 rounded-sm"
108
+ });
109
+ const Icon = KIND_ICON[clip.kind];
110
+ return /* @__PURE__ */ jsx(Icon, {
111
+ size: 14,
112
+ strokeWidth: 1.5,
113
+ className: "shrink-0 text-muted-foreground"
114
+ });
115
+ }
116
+ var hasMedia = (clip) => clip.kind === "image" || clip.kind === "color" || clip.kind === "file";
117
+ function Media({ clip }) {
118
+ const level = useLift(1);
119
+ if (clip.kind === "image" && clip.preview != null)
120
+ return /* @__PURE__ */ jsx(Picture, {
121
+ preview: clip.preview,
122
+ className: "h-24 w-36 rounded-xl"
123
+ });
124
+ if (clip.kind === "color")
125
+ return /* @__PURE__ */ jsx("span", {
126
+ "aria-hidden": true,
127
+ className: "size-24 shrink-0 rounded-xl ring-1 ring-border ring-inset",
128
+ style: { backgroundColor: paint(clip) }
129
+ });
130
+ if (clip.kind === "file" || clip.kind === "image")
131
+ return /* @__PURE__ */ jsx("span", {
132
+ className: cn("flex size-24 items-center justify-center rounded-xl text-muted-foreground", SURFACE_BG[level]),
133
+ children: clip.kind === "file" ? /* @__PURE__ */ jsx(File, {
134
+ size: 28,
135
+ strokeWidth: 1.25
136
+ }) : /* @__PURE__ */ jsx(Image, {
137
+ size: 28,
138
+ strokeWidth: 1.25
139
+ })
140
+ });
141
+ return null;
142
+ }
143
+ function Body({ clip }) {
144
+ if (clip.kind === "text")
145
+ return /* @__PURE__ */ jsx("p", {
146
+ className: "line-clamp-2 min-w-0 text-title weight-medium break-words text-foreground",
147
+ children: clip.content
148
+ });
149
+ if (clip.kind === "link")
150
+ return /* @__PURE__ */ jsxs("div", {
151
+ className: "flex min-w-0 flex-col gap-0.5",
152
+ children: [
153
+ /* @__PURE__ */ jsx(widget_default.Title, {
154
+ leading: clip.preview != null && /* @__PURE__ */ jsx(Picture, {
155
+ preview: clip.preview,
156
+ className: "size-4 rounded-sm"
157
+ }),
158
+ children: domain(clip.content)
159
+ }),
160
+ clip.detail && /* @__PURE__ */ jsx(widget_default.Subtitle, {
161
+ children: clip.detail
162
+ })
163
+ ]
164
+ });
165
+ return /* @__PURE__ */ jsxs("div", {
166
+ className: "flex min-w-0 flex-col gap-0.5",
167
+ children: [
168
+ /* @__PURE__ */ jsx(widget_default.Title, {
169
+ className: cn(clip.kind === "color" && "font-mono"),
170
+ children: clip.content
171
+ }),
172
+ clip.detail && /* @__PURE__ */ jsx(widget_default.Subtitle, {
173
+ children: clip.detail
174
+ })
175
+ ]
176
+ });
177
+ }
178
+ function fact(clip) {
179
+ if (clip.kind === "text")
180
+ return `${clip.content.length} characters`;
181
+ if (clip.kind === "link")
182
+ return path(clip.content);
183
+ return;
184
+ }
185
+ function Hero({ clip, pinned, onPin, onCopy, onDelete }) {
186
+ const line = fact(clip);
187
+ return /* @__PURE__ */ jsxs("div", {
188
+ className: "flex min-w-0 flex-col gap-2",
189
+ children: [
190
+ /* @__PURE__ */ jsx(Body, {
191
+ clip
192
+ }),
193
+ /* @__PURE__ */ jsxs("div", {
194
+ className: "flex min-w-0 items-center justify-between gap-3",
195
+ children: [
196
+ /* @__PURE__ */ jsx(widget_default.Meta, {
197
+ children: line && /* @__PURE__ */ jsx(widget_default.MetaItem, {
198
+ icon: KIND_ICON[clip.kind],
199
+ children: line
200
+ })
201
+ }),
202
+ /* @__PURE__ */ jsxs("div", {
203
+ className: "-mr-1 flex shrink-0 items-center gap-0.5",
204
+ children: [
205
+ /* @__PURE__ */ jsx(widget_default.Action, {
206
+ icon: Pin,
207
+ label: pinned ? "Unpin" : "Pin",
208
+ pressed: pinned,
209
+ onClick: onPin
210
+ }),
211
+ onDelete && /* @__PURE__ */ jsx(widget_default.Action, {
212
+ icon: Trash2,
213
+ label: "Delete",
214
+ onClick: () => onDelete(clip)
215
+ }),
216
+ /* @__PURE__ */ jsx(Button, {
217
+ variant: "primary",
218
+ size: "compact",
219
+ leadingIcon: Copy,
220
+ className: "ml-1.5",
221
+ onClick: () => onCopy?.(clip),
222
+ children: "Copy"
223
+ })
224
+ ]
225
+ })
226
+ ]
227
+ })
228
+ ]
229
+ });
230
+ }
231
+ function List({ order, selected, pinned, now, searching, onPick, onCopy }) {
232
+ const level = useLift(1);
233
+ if (!order.length)
234
+ return /* @__PURE__ */ jsx("span", {
235
+ className: "flex h-7 items-center text-body text-muted-foreground",
236
+ children: "No clips match"
237
+ });
238
+ const start = Math.max(0, Math.min(selected - ROWS + 1, order.length - ROWS));
239
+ const shown = order.slice(start, start + ROWS);
240
+ const more = order.length - start - shown.length;
241
+ const groups = [
242
+ { label: "Pinned", clips: shown.filter((clip) => pinned.includes(clip.id)) },
243
+ { label: searching ? "Matches" : "Recent", clips: shown.filter((clip) => !pinned.includes(clip.id)) }
244
+ ].filter((group) => group.clips.length);
245
+ return /* @__PURE__ */ jsx(FluidHover, {
246
+ className: "-mx-2 flex flex-col gap-0",
247
+ role: "listbox",
248
+ "aria-label": "Clipboard history",
249
+ children: groups.map((group, g) => /* @__PURE__ */ jsxs("div", {
250
+ role: "presentation",
251
+ className: "flex min-w-0 flex-col",
252
+ children: [
253
+ /* @__PURE__ */ jsxs("div", {
254
+ className: "flex h-6 items-center justify-between px-2 text-caption text-muted-foreground",
255
+ children: [
256
+ /* @__PURE__ */ jsx("span", {
257
+ children: group.label
258
+ }),
259
+ g === groups.length - 1 && more > 0 && /* @__PURE__ */ jsxs("span", {
260
+ className: "tabular-nums",
261
+ children: [
262
+ more,
263
+ " more"
264
+ ]
265
+ })
266
+ ]
267
+ }),
268
+ group.clips.map((clip) => {
269
+ const index = order.indexOf(clip);
270
+ const current = index === selected;
271
+ return /* @__PURE__ */ jsx(FluidHover.Item, {
272
+ index: index - start,
273
+ role: "option",
274
+ "aria-selected": current,
275
+ tabIndex: -1,
276
+ className: cn("h-7 px-2", current && SURFACE_BG[level]),
277
+ onClick: () => onPick(clip.id),
278
+ onDoubleClick: () => onCopy?.(clip),
279
+ children: /* @__PURE__ */ jsx(widget_default.Row, {
280
+ className: "w-full",
281
+ trailing: /* @__PURE__ */ jsxs(Fragment, {
282
+ children: [
283
+ pinned.includes(clip.id) && /* @__PURE__ */ jsx(Pin, {
284
+ size: 11,
285
+ strokeWidth: 1.5,
286
+ "aria-label": "Pinned"
287
+ }),
288
+ /* @__PURE__ */ jsx("span", {
289
+ className: "w-6 text-right tabular-nums",
290
+ children: short(now - clip.copiedAt)
291
+ })
292
+ ]
293
+ }),
294
+ children: /* @__PURE__ */ jsxs("span", {
295
+ className: "flex min-w-0 items-center gap-2",
296
+ children: [
297
+ /* @__PURE__ */ jsx(Mark, {
298
+ clip
299
+ }),
300
+ /* @__PURE__ */ jsx("span", {
301
+ className: "min-w-0 truncate",
302
+ children: clip.kind === "link" ? domain(clip.content) : clip.content
303
+ })
304
+ ]
305
+ })
306
+ })
307
+ }, clip.id);
308
+ })
309
+ ]
310
+ }, group.label))
311
+ });
312
+ }
313
+ function ClipboardHistoryLeading2() {
314
+ return /* @__PURE__ */ jsx(ClipboardList, {
315
+ size: 16,
316
+ strokeWidth: 1.5,
317
+ className: "text-foreground"
318
+ });
319
+ }
320
+ function ClipboardHistoryTrailing2({ count }) {
321
+ return /* @__PURE__ */ jsxs("span", {
322
+ className: "text-caption weight-semibold tabular-nums text-foreground",
323
+ children: [
324
+ count,
325
+ /* @__PURE__ */ jsx("span", {
326
+ className: "sr-only",
327
+ children: " new clips"
328
+ })
329
+ ]
330
+ });
331
+ }
332
+ function ClipboardHistoryCopied2({ clip, onPin }) {
333
+ const level = useLift(1);
334
+ const Icon = KIND_ICON[clip.kind];
335
+ const tile = clip.kind === "color" ? /* @__PURE__ */ jsx("span", {
336
+ "aria-hidden": true,
337
+ className: "size-9 rounded-lg ring-1 ring-border ring-inset",
338
+ style: { backgroundColor: paint(clip) }
339
+ }) : clip.kind === "image" && clip.preview != null ? /* @__PURE__ */ jsx(Picture, {
340
+ preview: clip.preview,
341
+ className: "size-9 rounded-lg"
342
+ }) : /* @__PURE__ */ jsx("span", {
343
+ className: cn("flex size-9 items-center justify-center rounded-lg text-muted-foreground", SURFACE_BG[level]),
344
+ children: /* @__PURE__ */ jsx(Icon, {
345
+ size: 16,
346
+ strokeWidth: 1.5
347
+ })
348
+ });
349
+ return /* @__PURE__ */ jsx(IslandFlash2, {
350
+ icon: tile,
351
+ title: `Copied ${KIND_LABEL[clip.kind].toLowerCase()}`,
352
+ caption: clip.kind === "link" ? domain(clip.content) : clip.content,
353
+ action: onPin && /* @__PURE__ */ jsx(Button, {
354
+ variant: "secondary",
355
+ size: "compact",
356
+ leadingIcon: Pin,
357
+ onClick: () => onPin(clip),
358
+ children: "Pin"
359
+ })
360
+ });
361
+ }
362
+ var ClipboardHistory2 = Object.assign(function ClipboardHistory({
363
+ clips,
364
+ value: valueProp,
365
+ defaultValue,
366
+ onValueChange,
367
+ pinned: pinnedProp,
368
+ defaultPinned = [],
369
+ onPinnedChange,
370
+ query: queryProp,
371
+ defaultQuery = "",
372
+ onQueryChange,
373
+ paused: pausedProp,
374
+ defaultPaused = false,
375
+ onPausedChange,
376
+ ignoredApp,
377
+ onCopy,
378
+ onDelete,
379
+ now: nowProp,
380
+ size,
381
+ className
382
+ }) {
383
+ const ticking = useEdgeClock2(0, nowProp === undefined, MINUTE2);
384
+ const now = nowProp ?? ticking;
385
+ const [value, setValue] = useControllableState(valueProp, defaultValue, onValueChange);
386
+ const [pinned, setPinned] = useControllableState(pinnedProp, defaultPinned, onPinnedChange);
387
+ const [query, setQuery] = useControllableState(queryProp, defaultQuery, onQueryChange);
388
+ const [paused, setPaused] = useControllableState(pausedProp, defaultPaused, onPausedChange);
389
+ const resume = /* @__PURE__ */ jsx(widget_default.Action, {
390
+ icon: paused ? Play : Pause,
391
+ label: paused ? "Resume history" : "Pause history",
392
+ onClick: () => setPaused(!paused)
393
+ });
394
+ if (!clips.length)
395
+ return /* @__PURE__ */ jsx(widget_default.Message, {
396
+ icon: paused ? Pause : ClipboardList,
397
+ title: paused ? "Clipboard history is paused" : "Copy something",
398
+ description: paused ? "Nothing you copy is kept until you resume." : "Text, links, images and colors you copy show up here, newest first.",
399
+ actions: paused && /* @__PURE__ */ jsx(Button, {
400
+ variant: "secondary",
401
+ size: "compact",
402
+ leadingIcon: Play,
403
+ onClick: () => setPaused(false),
404
+ children: "Resume"
405
+ }),
406
+ className
407
+ });
408
+ const needle = query.trim().toLowerCase();
409
+ const matches = needle ? clips.filter((clip) => [clip.content, clip.detail, clip.app].some((s) => s?.toLowerCase().includes(needle))) : clips;
410
+ const newest = [...matches].sort((a, b) => b.copiedAt - a.copiedAt);
411
+ const order = [
412
+ ...newest.filter((clip) => pinned.includes(clip.id)),
413
+ ...newest.filter((clip) => !pinned.includes(clip.id))
414
+ ];
415
+ const found = order.findIndex((clip) => clip.id === value);
416
+ const selected = found < 0 ? Math.max(0, order.indexOf(newest[0])) : found;
417
+ const hero = order[selected] ?? clips[0];
418
+ const heroPinned = pinned.includes(hero.id);
419
+ const onKeyDown = (event) => {
420
+ const step = event.key === "ArrowDown" ? 1 : event.key === "ArrowUp" ? -1 : 0;
421
+ if (step) {
422
+ event.preventDefault();
423
+ const next = order[Math.max(0, Math.min(order.length - 1, selected + step))];
424
+ if (next)
425
+ setValue(next.id);
426
+ return;
427
+ }
428
+ if (event.key === "Enter" && order[selected]) {
429
+ event.preventDefault();
430
+ onCopy?.(order[selected]);
431
+ }
432
+ };
433
+ return /* @__PURE__ */ jsx("div", {
434
+ className: cn("flex min-h-0 flex-col", className),
435
+ onKeyDown,
436
+ children: /* @__PURE__ */ jsxs(widget_default, {
437
+ size,
438
+ className: "flex-1",
439
+ aside: /* @__PURE__ */ jsxs("div", {
440
+ className: "flex min-w-0 flex-col gap-1",
441
+ children: [
442
+ /* @__PURE__ */ jsx(Input, {
443
+ size: "compact",
444
+ icon: Search,
445
+ placeholder: "Search clips",
446
+ "aria-label": "Search clips",
447
+ value: query,
448
+ onValueChange: setQuery
449
+ }),
450
+ /* @__PURE__ */ jsx(List, {
451
+ order,
452
+ selected,
453
+ pinned,
454
+ now,
455
+ searching: !!needle,
456
+ onPick: setValue,
457
+ onCopy
458
+ })
459
+ ]
460
+ }),
461
+ media: hasMedia(hero) && /* @__PURE__ */ jsx(Media, {
462
+ clip: hero
463
+ }),
464
+ children: [
465
+ /* @__PURE__ */ jsx(widget_default.Header, {
466
+ icon: KIND_ICON[hero.kind],
467
+ trailing: /* @__PURE__ */ jsxs(Fragment, {
468
+ children: [
469
+ paused ? /* @__PURE__ */ jsx(widget_default.Chip, {
470
+ children: "Paused"
471
+ }) : ignoredApp && /* @__PURE__ */ jsxs(widget_default.Chip, {
472
+ children: [
473
+ "Ignoring ",
474
+ ignoredApp
475
+ ]
476
+ }),
477
+ resume
478
+ ]
479
+ }),
480
+ children: [hero.app ?? KIND_LABEL[hero.kind], ago(now - hero.copiedAt)].join(" · ")
481
+ }),
482
+ /* @__PURE__ */ jsx(Hero, {
483
+ clip: hero,
484
+ pinned: heroPinned,
485
+ onPin: () => setPinned(heroPinned ? pinned.filter((id) => id !== hero.id) : [...pinned, hero.id]),
486
+ onCopy,
487
+ onDelete
488
+ })
489
+ ]
490
+ })
491
+ });
492
+ }, {
493
+ Leading: ClipboardHistoryLeading2,
494
+ Trailing: ClipboardHistoryTrailing2,
495
+ Copied: ClipboardHistoryCopied2
496
+ });
497
+ var clipboard_default = ClipboardHistory2;
498
+ export { ClipboardHistoryLeading2, ClipboardHistoryTrailing2, ClipboardHistoryCopied2, ClipboardHistory2, clipboard_default };