@rinzai/zen 0.13.0 → 0.15.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 (172) hide show
  1. package/CHANGELOG.md +138 -0
  2. package/README.md +16 -1
  3. package/dist/carousel/index.d.ts.map +1 -1
  4. package/dist/carousel/index.js +5 -5
  5. package/dist/docs/README.md +205 -0
  6. package/dist/docs/accordion.md +122 -0
  7. package/dist/docs/alert.md +69 -0
  8. package/dist/docs/animated-number.md +105 -0
  9. package/dist/docs/avatar.md +91 -0
  10. package/dist/docs/backdrop.md +94 -0
  11. package/dist/docs/badge.md +37 -0
  12. package/dist/docs/breadcrumbs.md +44 -0
  13. package/dist/docs/button-group.md +76 -0
  14. package/dist/docs/button.md +131 -0
  15. package/dist/docs/calendar-heatmap.md +73 -0
  16. package/dist/docs/calendar.md +101 -0
  17. package/dist/docs/canvas.md +584 -0
  18. package/dist/docs/card.md +180 -0
  19. package/dist/docs/carousel.md +162 -0
  20. package/dist/docs/chart.md +325 -0
  21. package/dist/docs/checkbox.md +88 -0
  22. package/dist/docs/chip.md +52 -0
  23. package/dist/docs/code-block.md +116 -0
  24. package/dist/docs/code-input.md +52 -0
  25. package/dist/docs/collapse.md +46 -0
  26. package/dist/docs/color-picker.md +145 -0
  27. package/dist/docs/combobox.md +208 -0
  28. package/dist/docs/command-palette.md +65 -0
  29. package/dist/docs/date-picker.md +167 -0
  30. package/dist/docs/dialog.md +271 -0
  31. package/dist/docs/disclosure.md +88 -0
  32. package/dist/docs/editable-cell.md +90 -0
  33. package/dist/docs/empty-state.md +46 -0
  34. package/dist/docs/field.md +82 -0
  35. package/dist/docs/file-drop.md +44 -0
  36. package/dist/docs/filter-bar.md +66 -0
  37. package/dist/docs/header.md +51 -0
  38. package/dist/docs/hover-card.md +110 -0
  39. package/dist/docs/icon-picker.md +65 -0
  40. package/dist/docs/input-group.md +89 -0
  41. package/dist/docs/input.md +33 -0
  42. package/dist/docs/inset.md +57 -0
  43. package/dist/docs/kbd.md +34 -0
  44. package/dist/docs/keypad.md +51 -0
  45. package/dist/docs/load-more.md +66 -0
  46. package/dist/docs/locale-provider.md +99 -0
  47. package/dist/docs/marquee.md +86 -0
  48. package/dist/docs/menu.md +403 -0
  49. package/dist/docs/meter.md +102 -0
  50. package/dist/docs/money-input.md +169 -0
  51. package/dist/docs/month-picker.md +80 -0
  52. package/dist/docs/navigation-menu.md +157 -0
  53. package/dist/docs/number-field.md +129 -0
  54. package/dist/docs/page-header.md +44 -0
  55. package/dist/docs/page-transition.md +93 -0
  56. package/dist/docs/pagination.md +42 -0
  57. package/dist/docs/pills.md +85 -0
  58. package/dist/docs/player-bar.md +158 -0
  59. package/dist/docs/popover.md +200 -0
  60. package/dist/docs/progress-ring.md +70 -0
  61. package/dist/docs/radio-cards.md +82 -0
  62. package/dist/docs/radio-group.md +86 -0
  63. package/dist/docs/range-slider.md +64 -0
  64. package/dist/docs/repeat-picker.md +44 -0
  65. package/dist/docs/resizable.md +107 -0
  66. package/dist/docs/seek-bar.md +68 -0
  67. package/dist/docs/segmented.md +89 -0
  68. package/dist/docs/select.md +148 -0
  69. package/dist/docs/separator.md +76 -0
  70. package/dist/docs/side-nav.md +75 -0
  71. package/dist/docs/skeleton.md +89 -0
  72. package/dist/docs/slider.md +87 -0
  73. package/dist/docs/sortable.md +182 -0
  74. package/dist/docs/sparkline.md +56 -0
  75. package/dist/docs/spinner.md +69 -0
  76. package/dist/docs/status-pill.md +81 -0
  77. package/dist/docs/stepper.md +59 -0
  78. package/dist/docs/tab-bar.md +78 -0
  79. package/dist/docs/table-of-contents.md +43 -0
  80. package/dist/docs/table.md +714 -0
  81. package/dist/docs/tabs.md +140 -0
  82. package/dist/docs/tag-input.md +45 -0
  83. package/dist/docs/textarea.md +25 -0
  84. package/dist/docs/theme-toggle.md +85 -0
  85. package/dist/docs/theming.md +193 -0
  86. package/dist/docs/time-field.md +71 -0
  87. package/dist/docs/timeline.md +50 -0
  88. package/dist/docs/toast.md +53 -0
  89. package/dist/docs/toggle-group.md +83 -0
  90. package/dist/docs/toggle.md +38 -0
  91. package/dist/docs/toolbar.md +97 -0
  92. package/dist/docs/tooltip.md +60 -0
  93. package/dist/docs/tree.md +295 -0
  94. package/dist/docs/trend.md +50 -0
  95. package/dist/icons/arrow-path.d.ts +3 -0
  96. package/dist/icons/arrow-path.d.ts.map +1 -0
  97. package/dist/icons/arrows-right-left.d.ts +3 -0
  98. package/dist/icons/arrows-right-left.d.ts.map +1 -0
  99. package/dist/icons/backward.d.ts +3 -0
  100. package/dist/icons/backward.d.ts.map +1 -0
  101. package/dist/icons/forward.d.ts +3 -0
  102. package/dist/icons/forward.d.ts.map +1 -0
  103. package/dist/icons/heart-solid.d.ts +3 -0
  104. package/dist/icons/heart-solid.d.ts.map +1 -0
  105. package/dist/icons/heart.d.ts +3 -0
  106. package/dist/icons/heart.d.ts.map +1 -0
  107. package/dist/icons/musical-note.d.ts +3 -0
  108. package/dist/icons/musical-note.d.ts.map +1 -0
  109. package/dist/icons/pause.d.ts +3 -0
  110. package/dist/icons/pause.d.ts.map +1 -0
  111. package/dist/icons/play.d.ts +3 -0
  112. package/dist/icons/play.d.ts.map +1 -0
  113. package/dist/icons/queue-list.d.ts +3 -0
  114. package/dist/icons/queue-list.d.ts.map +1 -0
  115. package/dist/icons/speaker-wave.d.ts +3 -0
  116. package/dist/icons/speaker-wave.d.ts.map +1 -0
  117. package/dist/icons/speaker-x-mark.d.ts +3 -0
  118. package/dist/icons/speaker-x-mark.d.ts.map +1 -0
  119. package/dist/index.d.ts +8 -2
  120. package/dist/index.d.ts.map +1 -1
  121. package/dist/lib.js +80 -74
  122. package/dist/marquee/index.d.ts +15 -0
  123. package/dist/marquee/index.d.ts.map +1 -0
  124. package/dist/marquee/index.js +90 -0
  125. package/dist/menu/index.d.ts.map +1 -1
  126. package/dist/menu/index.js +7 -6
  127. package/dist/number-field/index.d.ts +18 -2
  128. package/dist/number-field/index.d.ts.map +1 -1
  129. package/dist/number-field/index.js +65 -51
  130. package/dist/player-bar/index.d.ts +11 -0
  131. package/dist/player-bar/index.d.ts.map +1 -0
  132. package/dist/player-bar/index.js +17 -0
  133. package/dist/radio-cards/index.d.ts +2 -1
  134. package/dist/radio-cards/index.d.ts.map +1 -1
  135. package/dist/radio-cards/index.js +3 -3
  136. package/dist/seek-bar/index.d.ts +24 -0
  137. package/dist/seek-bar/index.d.ts.map +1 -0
  138. package/dist/seek-bar/index.js +120 -0
  139. package/dist/segmented/index.d.ts +3 -2
  140. package/dist/segmented/index.d.ts.map +1 -1
  141. package/dist/segmented/index.js +19 -18
  142. package/dist/slider/index.d.ts +2 -1
  143. package/dist/slider/index.d.ts.map +1 -1
  144. package/dist/tab-bar/index.d.ts +4 -2
  145. package/dist/tab-bar/index.d.ts.map +1 -1
  146. package/dist/tab-bar/index.js +24 -19
  147. package/dist/textarea/index.d.ts +6 -2
  148. package/dist/textarea/index.d.ts.map +1 -1
  149. package/dist/textarea/index.js +2 -1
  150. package/dist/theme.css +40 -0
  151. package/dist/utils/duration.d.ts +3 -0
  152. package/dist/utils/duration.d.ts.map +1 -0
  153. package/dist/utils/duration.js +7 -0
  154. package/dist/utils/messages.d.ts +2 -0
  155. package/dist/utils/messages.d.ts.map +1 -1
  156. package/dist/utils/messages.js +3 -1
  157. package/dist/utils/slot.d.ts +5 -2
  158. package/dist/utils/slot.d.ts.map +1 -1
  159. package/dist/utils/slot.js +16 -11
  160. package/dist/utils/useAnchoredPopup.d.ts.map +1 -1
  161. package/dist/utils/useAnchoredPopup.js +3 -2
  162. package/dist/utils/useHeightVar.d.ts +7 -0
  163. package/dist/utils/useHeightVar.d.ts.map +1 -0
  164. package/dist/utils/useHeightVar.js +17 -0
  165. package/dist/utils/useMediaPlayer.d.ts +38 -0
  166. package/dist/utils/useMediaPlayer.d.ts.map +1 -0
  167. package/dist/utils/useMediaPlayer.js +91 -0
  168. package/dist/utils/useMediaSession.d.ts +24 -0
  169. package/dist/utils/useMediaSession.d.ts.map +1 -0
  170. package/dist/utils/useMediaSession.js +76 -0
  171. package/dist/zen.css +1 -1
  172. package/package.json +4 -2
package/dist/theme.css CHANGED
@@ -1592,3 +1592,43 @@ html.reduce-motion .rise-list > * {
1592
1592
  animation-iteration-count: 1 !important;
1593
1593
  transition-duration: 0.01ms !important;
1594
1594
  }
1595
+
1596
+ /*
1597
+ * Marquee: an ellipsis at rest. While it scrolls (data-moving, set with its
1598
+ * animation) the text is one box to slide, cut off by fades at both edges; the
1599
+ * start's fade grows in as the text leaves it.
1600
+ */
1601
+ @property --zen-marquee-fade-start {
1602
+ syntax: '<length>';
1603
+ inherits: false;
1604
+ initial-value: 0px;
1605
+ }
1606
+ .zen__marquee {
1607
+ display: block;
1608
+ min-width: 0;
1609
+ overflow: hidden;
1610
+ white-space: nowrap;
1611
+ text-overflow: ellipsis;
1612
+ }
1613
+ .zen__marquee[data-moving] {
1614
+ text-overflow: clip;
1615
+ mask-image: linear-gradient(
1616
+ to right,
1617
+ transparent,
1618
+ #000 var(--zen-marquee-fade-start),
1619
+ #000 calc(100% - 1rem),
1620
+ transparent
1621
+ );
1622
+ }
1623
+ .zen__marquee[data-moving]:dir(rtl) {
1624
+ mask-image: linear-gradient(
1625
+ to left,
1626
+ transparent,
1627
+ #000 var(--zen-marquee-fade-start),
1628
+ #000 calc(100% - 1rem),
1629
+ transparent
1630
+ );
1631
+ }
1632
+ .zen__marquee[data-moving] > .zen__marquee-content {
1633
+ display: inline-block;
1634
+ }
@@ -0,0 +1,3 @@
1
+ /** Seconds as a clock reads them: 3:07, or 1:02:07 from an hour up. */
2
+ export declare function formatDuration(seconds: number): string;
3
+ //# sourceMappingURL=duration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"duration.d.ts","sourceRoot":"","sources":["../../packages/utils/duration.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,UAM7C"}
@@ -0,0 +1,7 @@
1
+ //#region packages/utils/duration.ts
2
+ function e(e) {
3
+ let t = Math.floor(Math.max(e, 0)), n = Math.floor(t / 3600), r = Math.floor(t % 3600 / 60), i = String(t % 60).padStart(2, "0");
4
+ return n ? `${n}:${String(r).padStart(2, "0")}:${i}` : `${r}:${i}`;
5
+ }
6
+ //#endregion
7
+ export { e as formatDuration };
@@ -132,6 +132,8 @@ export declare const ENGLISH: {
132
132
  nextSlide: string;
133
133
  resize: string;
134
134
  notifications: string;
135
+ seek: string;
136
+ timeOf: (time: string, total: string) => string;
135
137
  };
136
138
  export type Messages = typeof ENGLISH;
137
139
  //# sourceMappingURL=messages.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../packages/utils/messages.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,OAAO;;;;;;mBAOD,MAAM;;;;;;;;;;;;;;gBAgBT,MAAM;;;;;;;;;;;;;gCAeU,MAAM;uBACf,MAAM;;;4CAKe,MAAM,cAAc,MAAM;;wBAG9C,MAAM;;4BAEF,MAAM;;;;;;;;;;;;;;;;;;+BAsBH,MAAM;;2BAEV,MAAM,SAAS,MAAM;;;;;;6BAMnB,MAAM;4BACP,MAAM,QAAQ,MAAM;uBACzB,MAAM,UAAU,MAAM;;;;;;aAQhC,MAAM;;;uBAGI,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,SAAS,MAAM;yBAC9C,MAAM,QAAQ,MAAM;qBACxB,MAAM,QAAQ,MAAM;mBACtB,MAAM;;oBAIL,MAAM;qBACL,MAAM,SAAS,MAAM;oBAEtB,MAAM,SAAS,MAAM;oBACrB,MAAM,SAAS,MAAM;oBACrB,MAAM,UAAU,MAAM;sBACpB,MAAM,SAAS,MAAM;wBACnB,MAAM,SAAS,MAAM,SAAS,MAAM;oBAGxC,MAAM,SAAS,MAAM,UAAU,MAAM;kBACvC,MAAM,KAAK,MAAM,KAAK,MAAM;sBACxB,MAAM;;;;2BAOD,MAAM;;;;uBAMV,MAAM;oBACT,MAAM,QAAQ,MAAM;;;;;;;;;;;;;;qBAgBnB,MAAM;;cAEb,MAAM;;;;;;iBAMH,MAAM,SAAS,MAAM;mBACnB,MAAM;;;;;CAKxB,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG,OAAO,OAAO,CAAC"}
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../packages/utils/messages.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,OAAO;;;;;;mBAOD,MAAM;;;;;;;;;;;;;;gBAgBT,MAAM;;;;;;;;;;;;;gCAeU,MAAM;uBACf,MAAM;;;4CAKe,MAAM,cAAc,MAAM;;wBAG9C,MAAM;;4BAEF,MAAM;;;;;;;;;;;;;;;;;;+BAsBH,MAAM;;2BAEV,MAAM,SAAS,MAAM;;;;;;6BAMnB,MAAM;4BACP,MAAM,QAAQ,MAAM;uBACzB,MAAM,UAAU,MAAM;;;;;;aAQhC,MAAM;;;uBAGI,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,SAAS,MAAM;yBAC9C,MAAM,QAAQ,MAAM;qBACxB,MAAM,QAAQ,MAAM;mBACtB,MAAM;;oBAIL,MAAM;qBACL,MAAM,SAAS,MAAM;oBAEtB,MAAM,SAAS,MAAM;oBACrB,MAAM,SAAS,MAAM;oBACrB,MAAM,UAAU,MAAM;sBACpB,MAAM,SAAS,MAAM;wBACnB,MAAM,SAAS,MAAM,SAAS,MAAM;oBAGxC,MAAM,SAAS,MAAM,UAAU,MAAM;kBACvC,MAAM,KAAK,MAAM,KAAK,MAAM;sBACxB,MAAM;;;;2BAOD,MAAM;;;;uBAMV,MAAM;oBACT,MAAM,QAAQ,MAAM;;;;;;;;;;;;;;qBAgBnB,MAAM;;cAEb,MAAM;;;;;;iBAMH,MAAM,SAAS,MAAM;mBACnB,MAAM;;;;;;mBAQN,MAAM,SAAS,MAAM;CACvC,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG,OAAO,OAAO,CAAC"}
@@ -127,7 +127,9 @@ var e = {
127
127
  previousSlide: "Previous slide",
128
128
  nextSlide: "Next slide",
129
129
  resize: "Resize",
130
- notifications: "Notifications (F8)"
130
+ notifications: "Notifications (F8)",
131
+ seek: "Seek",
132
+ timeOf: (e, t) => `${e} of ${t}`
131
133
  };
132
134
  //#endregion
133
135
  export { e as ENGLISH };
@@ -5,9 +5,12 @@ type Props = Record<string, unknown>;
5
5
  * props: a component's styles and attributes go onto the caller's own element,
6
6
  * such as a router's Link. Classes are combined, styles merged (the child's
7
7
  * win), event handlers both run (the child's first), and refs both receive the
8
- * element; other props from the component win.
8
+ * element; other props from the component win. `before` goes ahead of the
9
+ * child's own content (e.g. a component's icon), also when that content is a
10
+ * render function such as a router NavLink's.
9
11
  */
10
- export declare function Slot({ children, ...props }: ComponentProps<'a'> & {
12
+ export declare function Slot({ before, children, ...props }: ComponentProps<'a'> & {
13
+ before?: ReactNode;
11
14
  children?: ReactNode;
12
15
  }): ReactElement<Props, string | import('react').JSXElementConstructor<any>> | null;
13
16
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"slot.d.ts","sourceRoot":"","sources":["../../packages/utils/slot.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAgB,cAAc,EAAkB,YAAY,EAAE,SAAS,EAAO,MAAM,OAAO,CAAC;AAKnG,KAAK,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAErC;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,cAAc,CAAC,GAAG,CAAC,GAAG;IAAE,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,mFAoB1F"}
1
+ {"version":3,"file":"slot.d.ts","sourceRoot":"","sources":["../../packages/utils/slot.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAgB,cAAc,EAAkB,YAAY,EAAE,SAAS,EAAO,MAAM,OAAO,CAAC;AAKnG,KAAK,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAErC;;;;;;;;GAQG;AACH,wBAAgB,IAAI,CAAC,EACjB,MAAM,EACN,QAAQ,EACR,GAAG,KAAK,EACX,EAAE,cAAc,CAAC,GAAG,CAAC,GAAG;IAAE,MAAM,CAAC,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,mFAqCpE"}
@@ -2,20 +2,25 @@
2
2
  import { cx as e } from "./cx.js";
3
3
  import { mergeRefs as t } from "./refs.js";
4
4
  import { cloneElement as n, isValidElement as r } from "react";
5
+ import { Fragment as i, jsxs as a } from "react/jsx-runtime";
5
6
  //#region packages/utils/slot.tsx
6
- function i({ children: i, ...a }) {
7
- if (!r(i)) return null;
8
- let o = i, s = a, c = o.props, l = { ...s };
9
- for (let e of Object.keys(s)) {
10
- let t = s[e], n = c[e];
11
- /^on[A-Z]/.test(e) && typeof t == "function" && typeof n == "function" && (l[e] = (...e) => {
7
+ function o({ before: o, children: s, ...c }) {
8
+ if (!r(s)) return null;
9
+ let l = s, u = c, d = l.props, f = { ...u };
10
+ for (let e of Object.keys(u)) {
11
+ let t = u[e], n = d[e];
12
+ /^on[A-Z]/.test(e) && typeof t == "function" && typeof n == "function" && (f[e] = (...e) => {
12
13
  n(...e), t(...e);
13
14
  });
14
15
  }
15
- return l.className = e(s.className, c.className), (s.style || c.style) && (l.style = {
16
- ...s.style,
17
- ...c.style
18
- }), s.ref && c.ref && (l.ref = t(s.ref, c.ref)), n(o, l);
16
+ if (f.className = e(u.className, d.className), (u.style || d.style) && (f.style = {
17
+ ...u.style,
18
+ ...d.style
19
+ }), u.ref && d.ref && (f.ref = t(u.ref, d.ref)), o != null) {
20
+ let e = d.children;
21
+ f.children = typeof e == "function" ? ((...t) => /* @__PURE__ */ a(i, { children: [o, e(...t)] })) : /* @__PURE__ */ a(i, { children: [o, e] });
22
+ }
23
+ return n(l, f);
19
24
  }
20
25
  //#endregion
21
- export { i as Slot };
26
+ export { o as Slot };
@@ -1 +1 @@
1
- {"version":3,"file":"useAnchoredPopup.d.ts","sourceRoot":"","sources":["../../packages/utils/useAnchoredPopup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAmD,MAAM,OAAO,CAAC;AAElG;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,WAAW,GAAG,cAAc,EAAE,EACrE,KAAe,EACf,MAAU,EACV,UAAkB,EAClB,YAAY,GACf,GAAE,oBAAyB;;;oBAgBb,OAAO;;;eA6CkD,aAAa;;;;;;;;;;;;;EAJpF;AAED,gGAAgG;AAChG,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM;;WACoC,aAAa;EACpF;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CACzB,EAAE,EAAE,MAAM,EACV,EAAE,KAAe,EAAE,MAAU,EAAE,KAAK,EAAE,IAAc,EAAE,GAAE,aAAkB,GAC3E,aAAa,CAuBf;AAED,UAAU,aAAa;IACnB,KAAK,CAAC,EAAE,OAAO,GAAG,KAAK,GAAG,QAAQ,CAAC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;IAC7B,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;CAC7B;AAYD,8FAA8F;AAC9F,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,QAiCnE;AA6CD,MAAM,WAAW,oBAAoB;IACjC,sFAAsF;IACtF,KAAK,CAAC,EAAE,OAAO,GAAG,KAAK,GAAG,QAAQ,CAAC;IACnC,oCAAoC;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8DAA8D;IAC9D,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;CAC1C"}
1
+ {"version":3,"file":"useAnchoredPopup.d.ts","sourceRoot":"","sources":["../../packages/utils/useAnchoredPopup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAmD,MAAM,OAAO,CAAC;AAElG;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,WAAW,GAAG,cAAc,EAAE,EACrE,KAAe,EACf,MAAU,EACV,UAAkB,EAClB,YAAY,GACf,GAAE,oBAAyB;;;oBAgBb,OAAO;;;eA6CkD,aAAa;;;;;;;;;;;;;EAJpF;AAED,gGAAgG;AAChG,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM;;WACoC,aAAa;EACpF;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CACzB,EAAE,EAAE,MAAM,EACV,EAAE,KAAe,EAAE,MAAU,EAAE,KAAK,EAAE,IAAc,EAAE,GAAE,aAAkB,GAC3E,aAAa,CA4Bf;AAED,UAAU,aAAa;IACnB,KAAK,CAAC,EAAE,OAAO,GAAG,KAAK,GAAG,QAAQ,CAAC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;IAC7B,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;CAC7B;AAYD,8FAA8F;AAC9F,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,QAiCnE;AA6CD,MAAM,WAAW,oBAAoB;IACjC,sFAAsF;IACtF,KAAK,CAAC,EAAE,OAAO,GAAG,KAAK,GAAG,QAAQ,CAAC;IACnC,oCAAoC;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8DAA8D;IAC9D,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;CAC1C"}
@@ -54,12 +54,13 @@ function s(e, { align: t = "start", offset: n = 4, width: r, side: i = "below" }
54
54
  let a = i === "beside" ? "inline-end span-block-end" : {
55
55
  start: "block-end span-inline-end",
56
56
  end: "block-end span-inline-start",
57
- center: "block-end center"
57
+ center: "block-end span-all"
58
58
  }[t];
59
59
  return {
60
60
  positionAnchor: `--${e}`,
61
61
  positionArea: a,
62
- positionTryFallbacks: i === "beside" ? "flip-inline, flip-block, flip-block flip-inline" : "flip-block",
62
+ ...i !== "beside" && t === "center" && { justifySelf: "anchor-center" },
63
+ positionTryFallbacks: i === "beside" || t !== "center" ? "flip-inline, flip-block, flip-block flip-inline" : "flip-block",
63
64
  inset: "auto",
64
65
  ...r === "at-least" && {
65
66
  width: "max-content",
@@ -0,0 +1,7 @@
1
+ import { RefObject } from 'react';
2
+ /**
3
+ * Keeps a fixed bar's height in a CSS variable on its parent (0px while the bar
4
+ * is hidden), so the bars and the page beside it can stack on it and pad for it.
5
+ */
6
+ export declare function useHeightVar(ref: RefObject<HTMLElement | null>, name: `--${string}`): void;
7
+ //# sourceMappingURL=useHeightVar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHeightVar.d.ts","sourceRoot":"","sources":["../../packages/utils/useHeightVar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAmB,MAAM,OAAO,CAAC;AAEnD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,MAAM,EAAE,QAcnF"}
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ import { useLayoutEffect as e } from "react";
3
+ //#region packages/utils/useHeightVar.ts
4
+ function t(t, n) {
5
+ e(() => {
6
+ let e = t.current, r = e?.parentElement;
7
+ if (!e || !r) return;
8
+ let i = () => r.style.setProperty(n, `${e.offsetHeight}px`);
9
+ i();
10
+ let a = new ResizeObserver(i);
11
+ return a.observe(e), () => {
12
+ a.disconnect(), r.style.removeProperty(n);
13
+ };
14
+ }, [t, n]);
15
+ }
16
+ //#endregion
17
+ export { t as useHeightVar };
@@ -0,0 +1,38 @@
1
+ import { RefCallback } from 'react';
2
+ export interface MediaState {
3
+ /** Playing, or about to (not paused). */
4
+ playing: boolean;
5
+ /** Playing but stalled, waiting for data. */
6
+ waiting: boolean;
7
+ ended: boolean;
8
+ /** Seconds in. */
9
+ currentTime: number;
10
+ /** Seconds long; 0 until known, and for a live stream. */
11
+ duration: number;
12
+ /** Seconds loaded from the start of the stretch being played: how far it can play without waiting. */
13
+ buffered: number;
14
+ /** 0 to 1. */
15
+ volume: number;
16
+ muted: boolean;
17
+ playbackRate: number;
18
+ error: MediaError | null;
19
+ }
20
+ export interface MediaPlayer extends MediaState {
21
+ /** Rejects when the browser won't play yet (autoplay before any tap) or can't play the source. */
22
+ play: () => Promise<void>;
23
+ pause: () => void;
24
+ toggle: () => Promise<void>;
25
+ /** Jump to a time, in seconds. */
26
+ seek: (time: number) => void;
27
+ setVolume: (volume: number) => void;
28
+ setMuted: (muted: boolean) => void;
29
+ }
30
+ /**
31
+ * Plays audio or video through your own <audio> or <video> element, and keeps
32
+ * its state for the UI: playing, time, duration, buffered, volume. Returns the
33
+ * ref for the element, kept apart from the player so reading the player isn't
34
+ * reading a ref: `const [ref, player] = useMediaPlayer(); <audio ref={ref} />`.
35
+ * Pair it with SeekBar, and with useMediaSession for the lock screen and media keys.
36
+ */
37
+ export declare function useMediaPlayer(): [ref: RefCallback<HTMLMediaElement>, player: MediaPlayer];
38
+ //# sourceMappingURL=useMediaPlayer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMediaPlayer.d.ts","sourceRoot":"","sources":["../../packages/utils/useMediaPlayer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAA0C,MAAM,OAAO,CAAC;AAE5E,MAAM,WAAW,UAAU;IACvB,yCAAyC;IACzC,OAAO,EAAE,OAAO,CAAC;IACjB,6CAA6C;IAC7C,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,kBAAkB;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,0DAA0D;IAC1D,QAAQ,EAAE,MAAM,CAAC;IACjB,sGAAsG;IACtG,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;CAC5B;AAED,MAAM,WAAW,WAAY,SAAQ,UAAU;IAC3C,kGAAkG;IAClG,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,kCAAkC;IAClC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACtC;AAuDD;;;;;;GAMG;AACH,wBAAgB,cAAc,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,CA8C1F"}
@@ -0,0 +1,91 @@
1
+ "use client";
2
+ import { useCallback as e, useMemo as t, useRef as n, useState as r } from "react";
3
+ //#region packages/utils/useMediaPlayer.ts
4
+ var i = [
5
+ "play",
6
+ "pause",
7
+ "playing",
8
+ "waiting",
9
+ "ended",
10
+ "timeupdate",
11
+ "durationchange",
12
+ "loadedmetadata",
13
+ "progress",
14
+ "seeking",
15
+ "volumechange",
16
+ "ratechange",
17
+ "emptied",
18
+ "error"
19
+ ], a = {
20
+ playing: !1,
21
+ waiting: !1,
22
+ ended: !1,
23
+ currentTime: 0,
24
+ duration: 0,
25
+ buffered: 0,
26
+ volume: 1,
27
+ muted: !1,
28
+ playbackRate: 1,
29
+ error: null
30
+ };
31
+ function o(e) {
32
+ let t = e.currentTime, n = 0;
33
+ for (let r = 0; r < e.buffered.length; r++) e.buffered.start(r) <= t && t <= e.buffered.end(r) && (n = e.buffered.end(r));
34
+ return {
35
+ playing: !e.paused,
36
+ waiting: !e.paused && e.readyState < HTMLMediaElement.HAVE_FUTURE_DATA,
37
+ ended: e.ended,
38
+ currentTime: t,
39
+ duration: Number.isFinite(e.duration) ? e.duration : 0,
40
+ buffered: n,
41
+ volume: e.volume,
42
+ muted: e.muted,
43
+ playbackRate: e.playbackRate,
44
+ error: e.error
45
+ };
46
+ }
47
+ var s = (e, t) => Object.keys(e).every((n) => Object.is(e[n], t[n]));
48
+ function c() {
49
+ let [c, l] = r(a), u = n(null), d = e((e) => {
50
+ if (!e) return;
51
+ u.current = e;
52
+ let t = () => l((t) => s(t, o(e)) ? t : o(e));
53
+ t();
54
+ for (let n of i) e.addEventListener(n, t);
55
+ return () => {
56
+ for (let n of i) e.removeEventListener(n, t);
57
+ u.current === e && (u.current = null);
58
+ };
59
+ }, []), f = t(() => {
60
+ let e = async () => {
61
+ try {
62
+ await u.current?.play();
63
+ } catch (e) {
64
+ if (!(e instanceof DOMException && e.name === "AbortError")) throw e;
65
+ }
66
+ }, t = () => u.current?.pause();
67
+ return {
68
+ play: e,
69
+ pause: t,
70
+ toggle: () => u.current?.paused === !1 ? Promise.resolve(t()) : e(),
71
+ seek: (e) => {
72
+ let t = u.current;
73
+ if (!t) return;
74
+ let n = Number.isFinite(t.duration) ? t.duration : Infinity;
75
+ t.currentTime = Math.min(Math.max(e, 0), n);
76
+ },
77
+ setVolume: (e) => {
78
+ u.current && (u.current.volume = Math.min(Math.max(e, 0), 1));
79
+ },
80
+ setMuted: (e) => {
81
+ u.current && (u.current.muted = e);
82
+ }
83
+ };
84
+ }, []);
85
+ return [d, {
86
+ ...c,
87
+ ...f
88
+ }];
89
+ }
90
+ //#endregion
91
+ export { c as useMediaPlayer };
@@ -0,0 +1,24 @@
1
+ import { MediaPlayer } from './useMediaPlayer';
2
+ export interface MediaSessionOptions {
3
+ title?: string;
4
+ artist?: string;
5
+ album?: string;
6
+ /** Cover art, e.g. `[{ src: '/cover-512.jpg', sizes: '512x512', type: 'image/jpeg' }]`. */
7
+ artwork?: MediaImage[];
8
+ /** Shows a previous button on the lock screen and makes the key work. */
9
+ onPrevious?: () => void;
10
+ /** Shows a next button on the lock screen and makes the key work. */
11
+ onNext?: () => void;
12
+ /** Seconds the skip back and forward buttons move (default 10). */
13
+ seekOffset?: number;
14
+ }
15
+ /** What useMediaSession needs from a player: useMediaPlayer's, or your own. */
16
+ export type MediaSessionPlayer = Pick<MediaPlayer, 'playing' | 'currentTime' | 'duration' | 'playbackRate' | 'play' | 'pause' | 'seek'>;
17
+ /**
18
+ * Puts what's playing on the lock screen, the notification shade and the OS
19
+ * media controls (title, artist, cover, position), and makes play, pause,
20
+ * seek, previous, next and the keyboard's media keys control your player.
21
+ * Does nothing where the browser has no Media Session API.
22
+ */
23
+ export declare function useMediaSession(player: MediaSessionPlayer, options?: MediaSessionOptions): void;
24
+ //# sourceMappingURL=useMediaSession.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMediaSession.d.ts","sourceRoot":"","sources":["../../packages/utils/useMediaSession.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,MAAM,WAAW,mBAAmB;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2FAA2F;IAC3F,OAAO,CAAC,EAAE,UAAU,EAAE,CAAC;IACvB,yEAAyE;IACzE,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,mEAAmE;IACnE,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,+EAA+E;AAC/E,MAAM,MAAM,kBAAkB,GAAG,IAAI,CACjC,WAAW,EACX,SAAS,GAAG,aAAa,GAAG,UAAU,GAAG,cAAc,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CACtF,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,kBAAkB,EAAE,OAAO,GAAE,mBAAwB,QAuE5F"}
@@ -0,0 +1,76 @@
1
+ "use client";
2
+ import { useEffect as e, useLayoutEffect as t, useRef as n } from "react";
3
+ //#region packages/utils/useMediaSession.ts
4
+ function r(r, i = {}) {
5
+ let { title: a, artist: o, album: s, artwork: c, onPrevious: l, onNext: u } = i, d = n({
6
+ player: r,
7
+ options: i
8
+ });
9
+ t(() => {
10
+ d.current = {
11
+ player: r,
12
+ options: i
13
+ };
14
+ });
15
+ let f = typeof navigator < "u" && "mediaSession" in navigator, p = JSON.stringify(c ?? []);
16
+ e(() => {
17
+ if (f) return navigator.mediaSession.metadata = new MediaMetadata({
18
+ title: a,
19
+ artist: o,
20
+ album: s,
21
+ artwork: JSON.parse(p)
22
+ }), () => {
23
+ navigator.mediaSession.metadata = null;
24
+ };
25
+ }, [
26
+ f,
27
+ a,
28
+ o,
29
+ s,
30
+ p
31
+ ]), e(() => {
32
+ f && (navigator.mediaSession.playbackState = r.playing ? "playing" : "paused");
33
+ }, [f, r.playing]);
34
+ let { duration: m, currentTime: h, playbackRate: g } = r;
35
+ e(() => {
36
+ if (f) try {
37
+ m > 0 ? navigator.mediaSession.setPositionState({
38
+ duration: m,
39
+ position: Math.min(h, m),
40
+ playbackRate: g || 1
41
+ }) : navigator.mediaSession.setPositionState();
42
+ } catch {}
43
+ }, [
44
+ f,
45
+ m,
46
+ h,
47
+ g
48
+ ]);
49
+ let _ = !!l, v = !!u;
50
+ e(() => {
51
+ if (!f) return;
52
+ let e = () => d.current.options.seekOffset ?? 10, t = () => d.current.player, n = [
53
+ ["play", () => void t().play().catch(() => {})],
54
+ ["pause", () => t().pause()],
55
+ ["seekto", (e) => e.seekTime != null && t().seek(e.seekTime)],
56
+ ["seekbackward", (n) => t().seek(t().currentTime - (n.seekOffset ?? e()))],
57
+ ["seekforward", (n) => t().seek(t().currentTime + (n.seekOffset ?? e()))],
58
+ ["previoustrack", _ ? () => d.current.options.onPrevious?.() : null],
59
+ ["nexttrack", v ? () => d.current.options.onNext?.() : null]
60
+ ], r = (e, t) => {
61
+ try {
62
+ navigator.mediaSession.setActionHandler(e, t);
63
+ } catch {}
64
+ };
65
+ for (let [e, t] of n) r(e, t);
66
+ return () => {
67
+ for (let [e] of n) r(e, null);
68
+ };
69
+ }, [
70
+ f,
71
+ _,
72
+ v
73
+ ]);
74
+ }
75
+ //#endregion
76
+ export { r as useMediaSession };