@justanarthur/modo-ui-notch 0.3.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/blocks/activities/agenda/examples.mdx +8 -0
  2. package/blocks/activities/agenda/index.tsx +164 -16
  3. package/blocks/activities/clock/examples.mdx +16 -0
  4. package/blocks/activities/clock/index.tsx +357 -59
  5. package/blocks/activities/now-playing/examples.mdx +8 -0
  6. package/blocks/activities/now-playing/index.tsx +140 -54
  7. package/blocks/activities/weather/examples.mdx +9 -1
  8. package/blocks/activities/weather/index.tsx +241 -12
  9. package/blocks/app/expanded-island/index.tsx +3 -1
  10. package/blocks/app/settings-window/examples.mdx +8 -0
  11. package/blocks/app/settings-window/index.tsx +8 -3
  12. package/blocks/system/clipboard/examples.mdx +8 -0
  13. package/blocks/system/clipboard/index.tsx +262 -52
  14. package/blocks/system/recent-files/examples.mdx +14 -0
  15. package/blocks/system/recent-files/index.tsx +110 -25
  16. package/blocks/system/system-stats/examples.mdx +8 -0
  17. package/blocks/system/system-stats/index.tsx +211 -4
  18. package/components/island/widget/index.tsx +38 -4
  19. package/dist/blocks/activities/agenda/index.d.ts +2 -1
  20. package/dist/blocks/activities/agenda/index.js +2 -2
  21. package/dist/blocks/activities/clock/index.d.ts +2 -1
  22. package/dist/blocks/activities/clock/index.js +2 -2
  23. package/dist/blocks/activities/now-playing/index.d.ts +2 -1
  24. package/dist/blocks/activities/now-playing/index.js +2 -2
  25. package/dist/blocks/activities/weather/index.d.ts +2 -1
  26. package/dist/blocks/activities/weather/index.js +2 -2
  27. package/dist/blocks/app/expanded-island/index.d.ts +1 -1
  28. package/dist/blocks/app/expanded-island/index.js +1 -1
  29. package/dist/blocks/app/settings-window/index.d.ts +1 -1
  30. package/dist/blocks/app/settings-window/index.js +1 -1
  31. package/dist/blocks/system/clipboard/index.d.ts +2 -1
  32. package/dist/blocks/system/clipboard/index.js +2 -2
  33. package/dist/blocks/system/recent-files/index.d.ts +2 -1
  34. package/dist/blocks/system/recent-files/index.js +2 -2
  35. package/dist/blocks/system/system-stats/index.d.ts +2 -1
  36. package/dist/blocks/system/system-stats/index.js +2 -2
  37. package/dist/components/island/widget/index.d.ts +2 -2
  38. package/dist/components/island/widget/index.js +3 -1
  39. package/dist/index.d.ts +11 -11
  40. package/dist/index.js +12 -10
  41. package/dist/shared/{chunk-2m5dz8nf.d.ts → chunk-0ym9mcqc.d.ts} +6 -2
  42. package/dist/shared/{chunk-7fvnrtz4.d.ts → chunk-1v35ck2y.d.ts} +12 -2
  43. package/dist/shared/{chunk-wkg17nxs.d.ts → chunk-2bqmmfg9.d.ts} +13 -2
  44. package/dist/shared/{chunk-mt0k6v8x.js → chunk-2nxwdn5s.js} +147 -39
  45. package/dist/shared/{chunk-pfhy5e4q.d.ts → chunk-6tnq6p89.d.ts} +2 -0
  46. package/dist/shared/{chunk-bvtyjcce.d.ts → chunk-72s4sqwh.d.ts} +16 -1
  47. package/dist/shared/{chunk-t0hcxh89.d.ts → chunk-9b8b7fw6.d.ts} +12 -0
  48. package/dist/shared/{chunk-xq5hc5gv.js → chunk-a059ccj0.js} +177 -66
  49. package/dist/shared/{chunk-qdzemt2v.js → chunk-cry81asr.js} +401 -89
  50. package/dist/shared/{chunk-da177e8r.d.ts → chunk-fr9jf804.d.ts} +16 -1
  51. package/dist/shared/{chunk-9c7ewvkk.js → chunk-kbk4bp6p.js} +162 -19
  52. package/dist/shared/{chunk-3thgcfcq.d.ts → chunk-kv0w8vhq.d.ts} +18 -1
  53. package/dist/shared/{chunk-416tsgbc.d.ts → chunk-nqjermbr.d.ts} +25 -3
  54. package/dist/shared/chunk-p3nezxvx.js +481 -0
  55. package/dist/shared/{chunk-2818esrq.d.ts → chunk-sen170mz.d.ts} +10 -1
  56. package/dist/shared/{chunk-9m0xbg5v.js → chunk-wayv5rhr.js} +1 -1
  57. package/dist/shared/{chunk-ym0xbses.js → chunk-ygnrrqta.js} +274 -18
  58. package/dist/shared/{chunk-j77cx8dp.js → chunk-yw478nmj.js} +325 -58
  59. package/dist/shared/{chunk-cc9nwbtf.js → chunk-z3tj1ydg.js} +3 -0
  60. package/dist/shared/{chunk-x7f3g82r.js → chunk-zxsw11dr.js} +14 -4
  61. package/dist/styles.css +61 -1
  62. package/mock/clipboard.tsx +34 -0
  63. package/mock/clock.tsx +3 -3
  64. package/mock/data.ts +48 -0
  65. package/mock/files.tsx +14 -1
  66. package/mock/island-content.tsx +47 -15
  67. package/mock/system.ts +3 -0
  68. package/mock/weather.tsx +42 -12
  69. package/package.json +2 -2
  70. package/dist/shared/chunk-s2jeqqan.js +0 -243
@@ -5,7 +5,7 @@ import {
5
5
  } from "./chunk-ndf79pv5.js";
6
6
  import {
7
7
  widget_default
8
- } from "./chunk-x7f3g82r.js";
8
+ } from "./chunk-zxsw11dr.js";
9
9
  import {
10
10
  MINUTE2,
11
11
  useEdgeClock2
@@ -13,11 +13,13 @@ import {
13
13
 
14
14
  // blocks/activities/weather/index.tsx
15
15
  import Button from "@justanarthur/modo-ui/components/actions/button";
16
+ import Sparkline from "@justanarthur/modo-ui/components/data-display/sparkline";
16
17
  import { useSize } from "@justanarthur/modo-ui/lib/size-context";
17
18
  import { SURFACE_BG } from "@justanarthur/modo-ui/lib/surface-classes";
18
19
  import { useLift } from "@justanarthur/modo-ui/lib/surface-context";
19
20
  import { cn } from "@justanarthur/modo-ui/lib/utils";
20
21
  import Skeleton from "@justanarthur/modo-ui/primitives/content/skeleton";
22
+ import ScrollArea from "@justanarthur/modo-ui/primitives/layout/scroll-area";
21
23
  import {
22
24
  ArrowDown,
23
25
  ArrowUp,
@@ -38,6 +40,9 @@ import {
38
40
  Moon,
39
41
  RotateCw,
40
42
  Sun,
43
+ Sunrise,
44
+ Sunset,
45
+ Thermometer,
41
46
  Umbrella,
42
47
  WifiOff,
43
48
  Wind
@@ -88,8 +93,11 @@ var HUE = {
88
93
  };
89
94
  var HERO_GLYPH = { default: 30, compact: 24 };
90
95
  var STRIP_GLYPH = { default: 16, compact: 14 };
96
+ var SHEET_GLYPH = { default: 44, compact: 36 };
91
97
  var WET = 30;
92
98
  var HOURS = 6;
99
+ var DAY_HOURS = 24;
100
+ var WEEK = 7;
93
101
  function conditionFromCode2(code) {
94
102
  if (code === 0)
95
103
  return "clear";
@@ -129,6 +137,18 @@ var degrees = (celsius, unit) => Math.round(unit === "fahrenheit" ? celsius * 9
129
137
  var temp = (celsius, unit) => `${degrees(celsius, unit)}°`;
130
138
  var speed = (kmh, unit) => unit === "fahrenheit" ? `${Math.round(kmh / 1.609)} mph` : `${Math.round(kmh)} km/h`;
131
139
  var hourOf = (ms, locale) => new Date(ms).toLocaleTimeString(locale, { hour: "numeric" });
140
+ var clockOf = (ms, locale) => new Date(ms).toLocaleTimeString(locale, { hour: "numeric", minute: "2-digit" });
141
+ function uvLevel(uv) {
142
+ if (uv < 3)
143
+ return "Low";
144
+ if (uv < 6)
145
+ return "Moderate";
146
+ if (uv < 8)
147
+ return "High";
148
+ if (uv < 11)
149
+ return "Very high";
150
+ return "Extreme";
151
+ }
132
152
  function ago(ms) {
133
153
  const minutes = Math.floor(ms / MINUTE2);
134
154
  if (minutes < 1)
@@ -218,6 +238,122 @@ function Tomorrow({ day, unit }) {
218
238
  })
219
239
  });
220
240
  }
241
+ function HourStrip({ hours, unit, locale }) {
242
+ const size = useSize();
243
+ const temperatures = hours.map((hour) => hour.temperature);
244
+ const low = Math.min(...temperatures);
245
+ const wet = hours.some((hour) => (hour.precipitation ?? 0) >= WET);
246
+ return /* @__PURE__ */ jsx(ScrollArea, {
247
+ orientation: "horizontal",
248
+ viewportClassName: "scroll-fade-x",
249
+ children: /* @__PURE__ */ jsxs("div", {
250
+ className: "flex w-max flex-col gap-1.5 pb-3 tabular-nums",
251
+ children: [
252
+ /* @__PURE__ */ jsx("div", {
253
+ className: "flex",
254
+ children: hours.map((hour, i) => /* @__PURE__ */ jsxs("div", {
255
+ className: "flex w-12 shrink-0 flex-col items-center gap-1.5",
256
+ children: [
257
+ /* @__PURE__ */ jsx("span", {
258
+ className: "whitespace-nowrap text-caption text-muted-foreground",
259
+ children: i === 0 ? "Now" : hourOf(hour.time, locale)
260
+ }),
261
+ /* @__PURE__ */ jsx(Glyph, {
262
+ condition: hour.condition,
263
+ isDay: hour.isDay,
264
+ size: STRIP_GLYPH[size.variant],
265
+ className: hueFor(hour.condition, hour.isDay)
266
+ })
267
+ ]
268
+ }, hour.time))
269
+ }),
270
+ /* @__PURE__ */ jsx("div", {
271
+ className: "px-6",
272
+ children: /* @__PURE__ */ jsx(Sparkline, {
273
+ values: temperatures.map((value) => value - low),
274
+ max: Math.max(...temperatures) - low,
275
+ label: `Temperature over the next ${hours.length} hours`,
276
+ tone: "muted"
277
+ })
278
+ }),
279
+ /* @__PURE__ */ jsx("div", {
280
+ className: "flex",
281
+ children: hours.map((hour) => /* @__PURE__ */ jsxs("div", {
282
+ className: "flex w-12 shrink-0 flex-col items-center gap-0.5",
283
+ children: [
284
+ /* @__PURE__ */ jsx("span", {
285
+ className: "text-body text-foreground",
286
+ children: temp(hour.temperature, unit)
287
+ }),
288
+ wet && /* @__PURE__ */ jsx("span", {
289
+ className: "h-4 text-caption text-status-info",
290
+ children: (hour.precipitation ?? 0) >= WET && `${hour.precipitation}%`
291
+ })
292
+ ]
293
+ }, hour.time))
294
+ })
295
+ ]
296
+ })
297
+ });
298
+ }
299
+ function Week({ days, unit, locale }) {
300
+ const low = Math.min(...days.map((day) => day.low));
301
+ const span = Math.max(...days.map((day) => day.high)) - low || 1;
302
+ return days.map((day, i) => /* @__PURE__ */ jsxs("div", {
303
+ className: "flex h-8 min-w-0 items-center gap-3 text-body tabular-nums",
304
+ children: [
305
+ /* @__PURE__ */ jsx("span", {
306
+ className: "w-12 shrink-0 truncate text-foreground",
307
+ children: i === 0 ? "Today" : new Date(day.date).toLocaleDateString(locale, { weekday: "short" })
308
+ }),
309
+ /* @__PURE__ */ jsx(Glyph, {
310
+ condition: day.condition,
311
+ size: 16,
312
+ className: hueFor(day.condition)
313
+ }),
314
+ /* @__PURE__ */ jsx("span", {
315
+ className: "w-9 shrink-0 text-caption text-status-info",
316
+ children: (day.precipitation ?? 0) >= WET && `${day.precipitation}%`
317
+ }),
318
+ /* @__PURE__ */ jsx("span", {
319
+ className: "w-8 shrink-0 text-right text-muted-foreground",
320
+ children: temp(day.low, unit)
321
+ }),
322
+ /* @__PURE__ */ jsx("span", {
323
+ className: "relative h-1 min-w-12 flex-1 rounded-full bg-active",
324
+ children: /* @__PURE__ */ jsx("span", {
325
+ className: "absolute inset-y-0 rounded-full bg-foreground",
326
+ style: { left: `${(day.low - low) / span * 100}%`, width: `${(day.high - day.low) / span * 100}%` }
327
+ })
328
+ }),
329
+ /* @__PURE__ */ jsx("span", {
330
+ className: "w-8 shrink-0 text-foreground",
331
+ children: temp(day.high, unit)
332
+ })
333
+ ]
334
+ }, day.date));
335
+ }
336
+ function Detail({ icon: Icon, label, children }) {
337
+ return /* @__PURE__ */ jsxs("div", {
338
+ className: "flex h-8 min-w-0 items-center gap-2 text-body",
339
+ children: [
340
+ /* @__PURE__ */ jsx(Icon, {
341
+ "aria-hidden": true,
342
+ size: 14,
343
+ strokeWidth: 1.5,
344
+ className: "shrink-0 text-muted-foreground"
345
+ }),
346
+ /* @__PURE__ */ jsx("span", {
347
+ className: "min-w-0 flex-1 truncate text-muted-foreground",
348
+ children: label
349
+ }),
350
+ /* @__PURE__ */ jsx("span", {
351
+ className: "shrink-0 whitespace-nowrap tabular-nums text-foreground",
352
+ children
353
+ })
354
+ ]
355
+ });
356
+ }
221
357
  function Loading({ location, className }) {
222
358
  return /* @__PURE__ */ jsx(widget_default, {
223
359
  className,
@@ -335,6 +471,7 @@ var Weather2 = Object.assign(function Weather({
335
471
  onRefresh,
336
472
  onRequestAccess,
337
473
  onOpenSettings,
474
+ layout = "fit",
338
475
  className
339
476
  }) {
340
477
  const size = useSize();
@@ -399,6 +536,141 @@ var Weather2 = Object.assign(function Weather({
399
536
  const freshness = status === "offline" ? `Offline · ${fresh}` : status === "error" ? `Not updated · ${fresh}` : fresh;
400
537
  const feels = current.apparent !== undefined && `Feels like ${temp(current.apparent, unit)}`;
401
538
  const soon = rain && `${LABEL[rain.condition]} around ${hourOf(rain.time, locale)}`;
539
+ const header = /* @__PURE__ */ jsx(widget_default.Header, {
540
+ icon: MapPin,
541
+ trailing: /* @__PURE__ */ jsxs(Fragment, {
542
+ children: [
543
+ /* @__PURE__ */ jsx("span", {
544
+ className: "whitespace-nowrap pr-1 text-caption",
545
+ children: freshness
546
+ }),
547
+ onRefresh && /* @__PURE__ */ jsx(widget_default.Action, {
548
+ icon: RotateCw,
549
+ label: "Refresh",
550
+ onClick: onRefresh
551
+ })
552
+ ]
553
+ }),
554
+ children: location ?? "Current location"
555
+ });
556
+ if (layout === "tall") {
557
+ const week = days.slice(0, WEEK);
558
+ return /* @__PURE__ */ jsxs(widget_default.Sheet, {
559
+ className,
560
+ children: [
561
+ /* @__PURE__ */ jsxs("div", {
562
+ className: "flex min-w-0 flex-col gap-2",
563
+ children: [
564
+ header,
565
+ /* @__PURE__ */ jsxs("div", {
566
+ className: "flex min-w-0 items-center gap-5",
567
+ children: [
568
+ /* @__PURE__ */ jsxs("div", {
569
+ className: "flex shrink-0 items-center gap-3",
570
+ children: [
571
+ /* @__PURE__ */ jsx(Glyph, {
572
+ condition: current.condition,
573
+ isDay: current.isDay,
574
+ size: SHEET_GLYPH[size.variant],
575
+ className: hueFor(current.condition, current.isDay)
576
+ }),
577
+ /* @__PURE__ */ jsx(widget_default.Figure, {
578
+ value: degrees(current.temperature, unit),
579
+ unit: unit === "fahrenheit" ? "°F" : "°C"
580
+ })
581
+ ]
582
+ }),
583
+ /* @__PURE__ */ jsxs("div", {
584
+ className: "flex min-w-0 flex-1 flex-col gap-0.5",
585
+ children: [
586
+ /* @__PURE__ */ jsx(widget_default.Title, {
587
+ children: LABEL[current.condition]
588
+ }),
589
+ today && /* @__PURE__ */ jsx(widget_default.Subtitle, {
590
+ children: [`H ${temp(today.high, unit)}`, `L ${temp(today.low, unit)}`, soon].filter(Boolean).join(" · ")
591
+ })
592
+ ]
593
+ })
594
+ ]
595
+ })
596
+ ]
597
+ }),
598
+ ahead.length > 1 && /* @__PURE__ */ jsx(widget_default.Section, {
599
+ label: "Next 24 hours",
600
+ children: /* @__PURE__ */ jsx(HourStrip, {
601
+ hours: ahead.slice(0, DAY_HOURS),
602
+ unit,
603
+ locale
604
+ })
605
+ }),
606
+ /* @__PURE__ */ jsxs("div", {
607
+ className: "flex min-w-0 items-start gap-5",
608
+ children: [
609
+ week.length > 0 && /* @__PURE__ */ jsx(widget_default.Section, {
610
+ label: `${week.length}-day forecast`,
611
+ className: "flex-1",
612
+ children: /* @__PURE__ */ jsx(Week, {
613
+ days: week,
614
+ unit,
615
+ locale
616
+ })
617
+ }),
618
+ /* @__PURE__ */ jsxs(widget_default.Section, {
619
+ label: "Details",
620
+ className: "w-[38%] shrink-0 border-l border-border pl-5",
621
+ children: [
622
+ current.apparent !== undefined && /* @__PURE__ */ jsx(Detail, {
623
+ icon: Thermometer,
624
+ label: "Feels like",
625
+ children: temp(current.apparent, unit)
626
+ }),
627
+ today?.precipitation !== undefined && /* @__PURE__ */ jsxs(Detail, {
628
+ icon: Umbrella,
629
+ label: "Chance of rain",
630
+ children: [
631
+ today.precipitation,
632
+ "%"
633
+ ]
634
+ }),
635
+ current.wind !== undefined && /* @__PURE__ */ jsx(Detail, {
636
+ icon: Wind,
637
+ label: "Wind",
638
+ children: speed(current.wind, unit)
639
+ }),
640
+ current.humidity !== undefined && /* @__PURE__ */ jsxs(Detail, {
641
+ icon: Droplets,
642
+ label: "Humidity",
643
+ children: [
644
+ Math.round(current.humidity),
645
+ "%"
646
+ ]
647
+ }),
648
+ current.uv !== undefined && /* @__PURE__ */ jsxs(Detail, {
649
+ icon: Sun,
650
+ label: "UV index",
651
+ children: [
652
+ Math.round(current.uv),
653
+ " · ",
654
+ uvLevel(current.uv)
655
+ ]
656
+ }),
657
+ today?.sunrise !== undefined && /* @__PURE__ */ jsx(Detail, {
658
+ icon: Sunrise,
659
+ label: "Sunrise",
660
+ children: clockOf(today.sunrise, locale)
661
+ }),
662
+ today?.sunset !== undefined && /* @__PURE__ */ jsx(Detail, {
663
+ icon: Sunset,
664
+ label: "Sunset",
665
+ children: clockOf(today.sunset, locale)
666
+ })
667
+ ]
668
+ })
669
+ ]
670
+ })
671
+ ]
672
+ });
673
+ }
402
674
  return /* @__PURE__ */ jsxs(widget_default, {
403
675
  className,
404
676
  aside: ahead.length > 0 && /* @__PURE__ */ jsxs(Fragment, {
@@ -421,23 +693,7 @@ var Weather2 = Object.assign(function Weather({
421
693
  ]
422
694
  }),
423
695
  children: [
424
- /* @__PURE__ */ jsx(widget_default.Header, {
425
- icon: MapPin,
426
- trailing: /* @__PURE__ */ jsxs(Fragment, {
427
- children: [
428
- /* @__PURE__ */ jsx("span", {
429
- className: "whitespace-nowrap pr-1 text-caption",
430
- children: freshness
431
- }),
432
- onRefresh && /* @__PURE__ */ jsx(widget_default.Action, {
433
- icon: RotateCw,
434
- label: "Refresh",
435
- onClick: onRefresh
436
- })
437
- ]
438
- }),
439
- children: location ?? "Current location"
440
- }),
696
+ header,
441
697
  /* @__PURE__ */ jsxs("div", {
442
698
  className: "flex min-w-0 items-center gap-2.5",
443
699
  children: [