plass-ui 1.3.0 → 1.4.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 (340) hide show
  1. package/CHANGELOG.md +590 -0
  2. package/README.md +1 -1
  3. package/dist/components/alert/PlAlert.js +1 -1
  4. package/dist/components/anchor/PlAnchor.d.ts +72 -0
  5. package/dist/components/anchor/PlAnchor.js +1 -0
  6. package/dist/components/anchor/index.d.ts +2 -0
  7. package/dist/components/anchor/index.js +1 -0
  8. package/dist/components/animate-appear/PlAnimateAppear.d.ts +10 -0
  9. package/dist/components/animate-appear/PlAnimateAppear.js +1 -1
  10. package/dist/components/animate-blink/PlAnimateBlink.d.ts +2 -2
  11. package/dist/components/animate-blink/PlAnimateBlink.js +1 -1
  12. package/dist/components/animate-counter/PlAnimateCounter.d.ts +83 -0
  13. package/dist/components/animate-counter/PlAnimateCounter.js +1 -0
  14. package/dist/components/animate-counter/index.d.ts +2 -0
  15. package/dist/components/animate-counter/index.js +1 -0
  16. package/dist/components/animate-fade/PlAnimateFade.d.ts +2 -2
  17. package/dist/components/animate-fade/PlAnimateFade.js +1 -1
  18. package/dist/components/animate-float/PlAnimateFloat.d.ts +51 -0
  19. package/dist/components/animate-float/PlAnimateFloat.js +1 -0
  20. package/dist/components/animate-float/index.d.ts +2 -0
  21. package/dist/components/animate-float/index.js +1 -0
  22. package/dist/components/animate-grow/PlAnimateGrow.d.ts +2 -2
  23. package/dist/components/animate-grow/PlAnimateGrow.js +1 -1
  24. package/dist/components/animate-reveal/PlAnimateReveal.d.ts +51 -0
  25. package/dist/components/animate-reveal/PlAnimateReveal.js +1 -0
  26. package/dist/components/animate-reveal/index.d.ts +2 -0
  27. package/dist/components/animate-reveal/index.js +1 -0
  28. package/dist/components/animate-rotate/PlAnimateRotate.d.ts +2 -2
  29. package/dist/components/animate-rotate/PlAnimateRotate.js +1 -1
  30. package/dist/components/animate-scramble/PlAnimateScramble.d.ts +75 -0
  31. package/dist/components/animate-scramble/PlAnimateScramble.js +1 -0
  32. package/dist/components/animate-scramble/index.d.ts +2 -0
  33. package/dist/components/animate-scramble/index.js +1 -0
  34. package/dist/components/animate-shake/PlAnimateShake.d.ts +57 -0
  35. package/dist/components/animate-shake/PlAnimateShake.js +1 -0
  36. package/dist/components/animate-shake/index.d.ts +2 -0
  37. package/dist/components/animate-shake/index.js +1 -0
  38. package/dist/components/animate-slide/PlAnimateSlide.d.ts +2 -2
  39. package/dist/components/animate-slide/PlAnimateSlide.js +1 -1
  40. package/dist/components/animate-split/PlAnimateSplit.d.ts +54 -0
  41. package/dist/components/animate-split/PlAnimateSplit.js +1 -0
  42. package/dist/components/animate-split/index.d.ts +2 -0
  43. package/dist/components/animate-split/index.js +1 -0
  44. package/dist/components/animate-zoom/PlAnimateZoom.d.ts +2 -2
  45. package/dist/components/animate-zoom/PlAnimateZoom.js +1 -1
  46. package/dist/components/app-logo/PlAppLogo.d.ts +78 -0
  47. package/dist/components/app-logo/PlAppLogo.js +1 -0
  48. package/dist/components/app-logo/index.d.ts +2 -0
  49. package/dist/components/app-logo/index.js +1 -0
  50. package/dist/components/area-chart/PlAreaChart.d.ts +54 -0
  51. package/dist/components/area-chart/PlAreaChart.js +1 -0
  52. package/dist/components/area-chart/index.d.ts +2 -0
  53. package/dist/components/area-chart/index.js +1 -0
  54. package/dist/components/avatar/PlAvatar.js +1 -1
  55. package/dist/components/back-top/PlBackTop.js +1 -1
  56. package/dist/components/bar-chart/PlBarChart.d.ts +63 -0
  57. package/dist/components/bar-chart/PlBarChart.js +1 -0
  58. package/dist/components/bar-chart/index.d.ts +2 -0
  59. package/dist/components/bar-chart/index.js +1 -0
  60. package/dist/components/breadcrumb/PlBreadcrumb.js +1 -1
  61. package/dist/components/button-group/PlButtonGroup.js +1 -1
  62. package/dist/components/carousel/PlCarousel.js +1 -1
  63. package/dist/components/chat-bubble/PlChatBubble.js +1 -1
  64. package/dist/components/checkbox/PlCheckbox.js +1 -1
  65. package/dist/components/chip/PlChip.js +1 -1
  66. package/dist/components/code-block/PlCodeBlock.d.ts +175 -0
  67. package/dist/components/code-block/PlCodeBlock.js +1 -0
  68. package/dist/components/code-block/index.d.ts +2 -0
  69. package/dist/components/code-block/index.js +1 -0
  70. package/dist/components/combobox/PlCombobox.d.ts +1 -1
  71. package/dist/components/combobox/PlCombobox.js +1 -1
  72. package/dist/components/command-palette/PlCommandPalette.d.ts +1 -1
  73. package/dist/components/command-palette/PlCommandPalette.js +1 -1
  74. package/dist/components/container/PlContainer.d.ts +22 -6
  75. package/dist/components/container/PlContainer.js +1 -1
  76. package/dist/components/data-list/PlDataList.d.ts +74 -0
  77. package/dist/components/data-list/PlDataList.js +1 -0
  78. package/dist/components/data-list/index.d.ts +2 -0
  79. package/dist/components/data-list/index.js +1 -0
  80. package/dist/components/data-table/PlDataTable.d.ts +202 -0
  81. package/dist/components/data-table/PlDataTable.js +1 -0
  82. package/dist/components/data-table/index.d.ts +2 -0
  83. package/dist/components/data-table/index.js +1 -0
  84. package/dist/components/drawer/PlDrawer.d.ts +1 -1
  85. package/dist/components/drawer/PlDrawer.js +1 -1
  86. package/dist/components/flex/PlFlex.d.ts +83 -0
  87. package/dist/components/flex/PlFlex.js +1 -0
  88. package/dist/components/flex/index.d.ts +2 -0
  89. package/dist/components/flex/index.js +1 -0
  90. package/dist/components/floating-action-button/PlFloatingActionButton.d.ts +81 -0
  91. package/dist/components/floating-action-button/PlFloatingActionButton.js +1 -0
  92. package/dist/components/floating-action-button/index.d.ts +2 -0
  93. package/dist/components/floating-action-button/index.js +1 -0
  94. package/dist/components/footer/PlFooter.d.ts +4 -3
  95. package/dist/components/footer/PlFooter.js +1 -1
  96. package/dist/components/gallery/PlGallery.d.ts +154 -0
  97. package/dist/components/gallery/PlGallery.js +1 -0
  98. package/dist/components/gallery/PlGalleryViewer.d.ts +31 -0
  99. package/dist/components/gallery/PlGalleryViewer.js +1 -0
  100. package/dist/components/gallery/index.d.ts +2 -0
  101. package/dist/components/gallery/index.js +1 -0
  102. package/dist/components/gauge-chart/PlGaugeChart.d.ts +64 -0
  103. package/dist/components/gauge-chart/PlGaugeChart.js +1 -0
  104. package/dist/components/gauge-chart/index.d.ts +2 -0
  105. package/dist/components/gauge-chart/index.js +1 -0
  106. package/dist/components/grid/PlGrid.js +1 -1
  107. package/dist/components/grid/PlGridItem.js +1 -1
  108. package/dist/components/header/PlHeader.d.ts +4 -3
  109. package/dist/components/header/PlHeader.js +1 -1
  110. package/dist/components/heatmap-chart/PlHeatmapChart.d.ts +69 -0
  111. package/dist/components/heatmap-chart/PlHeatmapChart.js +1 -0
  112. package/dist/components/heatmap-chart/index.d.ts +2 -0
  113. package/dist/components/heatmap-chart/index.js +1 -0
  114. package/dist/components/hover-card/PlHoverCard.d.ts +94 -0
  115. package/dist/components/hover-card/PlHoverCard.js +1 -0
  116. package/dist/components/hover-card/index.d.ts +2 -0
  117. package/dist/components/hover-card/index.js +1 -0
  118. package/dist/components/how-to-steps/PlHowToSteps.d.ts +87 -0
  119. package/dist/components/how-to-steps/PlHowToSteps.js +1 -0
  120. package/dist/components/how-to-steps/index.d.ts +2 -0
  121. package/dist/components/how-to-steps/index.js +1 -0
  122. package/dist/components/image/PlImage.js +1 -1
  123. package/dist/components/line-chart/PlLineChart.d.ts +74 -0
  124. package/dist/components/line-chart/PlLineChart.js +1 -0
  125. package/dist/components/line-chart/index.d.ts +2 -0
  126. package/dist/components/line-chart/index.js +1 -0
  127. package/dist/components/meter/PlMeter.d.ts +83 -0
  128. package/dist/components/meter/PlMeter.js +1 -0
  129. package/dist/components/meter/index.d.ts +2 -0
  130. package/dist/components/meter/index.js +1 -0
  131. package/dist/components/mockup/PlMockup.d.ts +146 -0
  132. package/dist/components/mockup/PlMockup.js +1 -0
  133. package/dist/components/mockup/index.d.ts +2 -0
  134. package/dist/components/mockup/index.js +1 -0
  135. package/dist/components/modal/PlModal.d.ts +1 -1
  136. package/dist/components/modal/PlModal.js +1 -1
  137. package/dist/components/number-field/PlNumberField.d.ts +1 -1
  138. package/dist/components/number-field/PlNumberField.js +1 -1
  139. package/dist/components/overlay/PlOverlay.d.ts +1 -1
  140. package/dist/components/overlay/PlOverlay.js +1 -1
  141. package/dist/components/page-layout/PlPageLayout.js +1 -1
  142. package/dist/components/pagination/PlPagination.js +1 -1
  143. package/dist/components/panes/PlPanes.d.ts +2 -2
  144. package/dist/components/panes/PlPanes.js +1 -1
  145. package/dist/components/pie-chart/PlPieChart.d.ts +58 -0
  146. package/dist/components/pie-chart/PlPieChart.js +1 -0
  147. package/dist/components/pie-chart/index.d.ts +2 -0
  148. package/dist/components/pie-chart/index.js +1 -0
  149. package/dist/components/popconfirm/PlPopconfirm.d.ts +1 -1
  150. package/dist/components/popconfirm/PlPopconfirm.js +1 -1
  151. package/dist/components/popover/PlPopover.d.ts +1 -1
  152. package/dist/components/popover/PlPopover.js +1 -1
  153. package/dist/components/portal/PlPortal.d.ts +78 -0
  154. package/dist/components/portal/PlPortal.js +1 -0
  155. package/dist/components/portal/index.d.ts +2 -0
  156. package/dist/components/portal/index.js +1 -0
  157. package/dist/components/radio-group/PlRadioGroup.js +1 -1
  158. package/dist/components/rating/PlRating.js +1 -1
  159. package/dist/components/scatter-chart/PlScatterChart.d.ts +46 -0
  160. package/dist/components/scatter-chart/PlScatterChart.js +1 -0
  161. package/dist/components/scatter-chart/index.d.ts +2 -0
  162. package/dist/components/scatter-chart/index.js +1 -0
  163. package/dist/components/scroll-area/PlScrollArea.d.ts +98 -0
  164. package/dist/components/scroll-area/PlScrollArea.js +1 -0
  165. package/dist/components/scroll-area/index.d.ts +2 -0
  166. package/dist/components/scroll-area/index.js +1 -0
  167. package/dist/components/scroll-zone/PlScrollZone.d.ts +9 -5
  168. package/dist/components/scroll-zone/PlScrollZone.js +1 -1
  169. package/dist/components/select/PlSelect.js +1 -1
  170. package/dist/components/show/PlShow.d.ts +60 -0
  171. package/dist/components/show/PlShow.js +1 -0
  172. package/dist/components/show/index.d.ts +2 -0
  173. package/dist/components/show/index.js +1 -0
  174. package/dist/components/sidebar/PlSidebar.js +1 -1
  175. package/dist/components/slider/PlSlider.js +1 -1
  176. package/dist/components/sparkline/PlSparkline.d.ts +68 -0
  177. package/dist/components/sparkline/PlSparkline.js +1 -0
  178. package/dist/components/sparkline/index.d.ts +2 -0
  179. package/dist/components/sparkline/index.js +1 -0
  180. package/dist/components/spoiler/PlSpoiler.d.ts +8 -0
  181. package/dist/components/spoiler/PlSpoiler.js +1 -1
  182. package/dist/components/stack/PlStack.d.ts +114 -0
  183. package/dist/components/stack/PlStack.js +1 -0
  184. package/dist/components/stack/index.d.ts +2 -0
  185. package/dist/components/stack/index.js +1 -0
  186. package/dist/components/stepper/PlStepper.d.ts +2 -2
  187. package/dist/components/stepper/PlStepper.js +1 -1
  188. package/dist/components/table/PlTable.js +1 -1
  189. package/dist/components/tabs/PlTabs.d.ts +2 -2
  190. package/dist/components/tabs/PlTabs.js +1 -1
  191. package/dist/components/text-link/PlTextLink.js +1 -1
  192. package/dist/components/timeline/PlTimeline.d.ts +2 -2
  193. package/dist/components/timeline/PlTimeline.js +1 -1
  194. package/dist/components/timeline-chart/PlTimelineChart.d.ts +44 -0
  195. package/dist/components/timeline-chart/PlTimelineChart.js +1 -0
  196. package/dist/components/timeline-chart/index.d.ts +2 -0
  197. package/dist/components/timeline-chart/index.js +1 -0
  198. package/dist/components/toast/PlToast.d.ts +1 -1
  199. package/dist/components/toast/PlToast.js +1 -1
  200. package/dist/components/toggle/PlToggle.js +1 -1
  201. package/dist/components/toggle/PlToggleGroup.js +1 -1
  202. package/dist/components/tour/PlTour.d.ts +134 -0
  203. package/dist/components/tour/PlTour.js +1 -0
  204. package/dist/components/tour/index.d.ts +2 -0
  205. package/dist/components/tour/index.js +1 -0
  206. package/dist/components/transfer/PlTransfer.js +1 -1
  207. package/dist/components/tree/PlTree.js +1 -1
  208. package/dist/components/tree-select/PlTreeSelect.d.ts +99 -0
  209. package/dist/components/tree-select/PlTreeSelect.js +1 -0
  210. package/dist/components/tree-select/index.d.ts +2 -0
  211. package/dist/components/tree-select/index.js +1 -0
  212. package/dist/components/window-pane/PlWindowPane.d.ts +179 -0
  213. package/dist/components/window-pane/PlWindowPane.js +1 -0
  214. package/dist/components/window-pane/index.d.ts +2 -0
  215. package/dist/components/window-pane/index.js +1 -0
  216. package/dist/css/anchor.css +2 -0
  217. package/dist/css/animate-counter.css +2 -0
  218. package/dist/css/animate-float.css +2 -0
  219. package/dist/css/animate-reveal.css +2 -0
  220. package/dist/css/animate-scramble.css +2 -0
  221. package/dist/css/animate-shake.css +2 -0
  222. package/dist/css/animate-split.css +2 -0
  223. package/dist/css/app-logo.css +2 -0
  224. package/dist/css/area-chart.css +2 -0
  225. package/dist/css/bar-chart.css +2 -0
  226. package/dist/css/code-block.css +2 -0
  227. package/dist/css/data-list.css +2 -0
  228. package/dist/css/data-table.css +2 -0
  229. package/dist/css/flex.css +2 -0
  230. package/dist/css/floating-action-button.css +2 -0
  231. package/dist/css/gallery.css +2 -0
  232. package/dist/css/gauge-chart.css +2 -0
  233. package/dist/css/heatmap-chart.css +2 -0
  234. package/dist/css/hover-card.css +2 -0
  235. package/dist/css/how-to-steps.css +2 -0
  236. package/dist/css/line-chart.css +2 -0
  237. package/dist/css/meter.css +2 -0
  238. package/dist/css/mockup.css +2 -0
  239. package/dist/css/pie-chart.css +2 -0
  240. package/dist/css/portal.css +2 -0
  241. package/dist/css/scatter-chart.css +2 -0
  242. package/dist/css/scroll-area.css +2 -0
  243. package/dist/css/show.css +2 -0
  244. package/dist/css/sparkline.css +2 -0
  245. package/dist/css/stack.css +2 -0
  246. package/dist/css/timeline-chart.css +2 -0
  247. package/dist/css/tour.css +2 -0
  248. package/dist/css/tree-select.css +2 -0
  249. package/dist/css/window-pane.css +2 -0
  250. package/dist/hooks/index.d.ts +6 -0
  251. package/dist/hooks/index.js +1 -1
  252. package/dist/hooks/usePlBreakpoint.d.ts +3 -0
  253. package/dist/hooks/usePlBreakpoint.js +1 -1
  254. package/dist/hooks/usePlDisclosure.d.ts +44 -0
  255. package/dist/hooks/usePlDisclosure.js +1 -0
  256. package/dist/hooks/usePlElementSize.d.ts +31 -0
  257. package/dist/hooks/usePlElementSize.js +1 -0
  258. package/dist/hooks/usePlOnScreen.d.ts +50 -0
  259. package/dist/hooks/usePlOnScreen.js +1 -0
  260. package/dist/index.d.ts +34 -1
  261. package/dist/index.js +1 -1
  262. package/dist/internal/animate.d.ts +91 -5
  263. package/dist/internal/animate.js +1 -1
  264. package/dist/internal/breakpoints.d.ts +31 -0
  265. package/dist/internal/breakpoints.js +1 -0
  266. package/dist/internal/button-group.d.ts +29 -2
  267. package/dist/internal/button-group.js +2 -2
  268. package/dist/internal/calendar.d.ts +11 -36
  269. package/dist/internal/calendar.js +1 -1
  270. package/dist/internal/chart-frame.d.ts +458 -0
  271. package/dist/internal/chart-frame.js +1 -0
  272. package/dist/internal/chart-line.d.ts +44 -0
  273. package/dist/internal/chart-line.js +1 -0
  274. package/dist/internal/chart.d.ts +473 -0
  275. package/dist/internal/chart.js +1 -0
  276. package/dist/internal/data-table.d.ts +69 -0
  277. package/dist/internal/data-table.js +1 -0
  278. package/dist/internal/defaults.d.ts +8 -3
  279. package/dist/internal/drag.d.ts +49 -0
  280. package/dist/internal/drag.js +1 -0
  281. package/dist/internal/format.d.ts +2 -0
  282. package/dist/internal/format.js +1 -1
  283. package/dist/internal/gallery.d.ts +34 -0
  284. package/dist/internal/gallery.js +1 -0
  285. package/dist/internal/grid.d.ts +6 -27
  286. package/dist/internal/grid.js +1 -1
  287. package/dist/internal/highlight.d.ts +98 -0
  288. package/dist/internal/highlight.js +1 -0
  289. package/dist/internal/icons.d.ts +10 -0
  290. package/dist/internal/icons.js +1 -1
  291. package/dist/internal/labels.d.ts +138 -0
  292. package/dist/internal/labels.js +1 -0
  293. package/dist/internal/mockup.d.ts +193 -0
  294. package/dist/internal/mockup.js +1 -0
  295. package/dist/internal/page-layout.js +1 -1
  296. package/dist/internal/progress.d.ts +6 -0
  297. package/dist/internal/responsive.d.ts +108 -0
  298. package/dist/internal/responsive.js +1 -0
  299. package/dist/internal/scramble.d.ts +31 -0
  300. package/dist/internal/scramble.js +1 -0
  301. package/dist/internal/styles.d.ts +15 -0
  302. package/dist/internal/styles.js +1 -1
  303. package/dist/internal/table.d.ts +86 -0
  304. package/dist/internal/table.js +1 -0
  305. package/dist/internal/threshold.d.ts +19 -0
  306. package/dist/internal/threshold.js +1 -0
  307. package/dist/internal/tour.d.ts +42 -0
  308. package/dist/internal/tour.js +1 -0
  309. package/dist/internal/window.d.ts +201 -0
  310. package/dist/internal/window.js +1 -0
  311. package/dist/locales/de.d.ts +3 -0
  312. package/dist/locales/de.js +1 -0
  313. package/dist/locales/en.d.ts +2 -0
  314. package/dist/locales/en.js +1 -0
  315. package/dist/locales/es.d.ts +3 -0
  316. package/dist/locales/es.js +1 -0
  317. package/dist/locales/fr.d.ts +3 -0
  318. package/dist/locales/fr.js +1 -0
  319. package/dist/locales/index.d.ts +33 -0
  320. package/dist/locales/index.js +1 -0
  321. package/dist/locales/ja.d.ts +3 -0
  322. package/dist/locales/ja.js +1 -0
  323. package/dist/locales/ko.d.ts +3 -0
  324. package/dist/locales/ko.js +1 -0
  325. package/dist/locales/zh-Hans.d.ts +3 -0
  326. package/dist/locales/zh-Hans.js +1 -0
  327. package/dist/provider/index.d.ts +1 -0
  328. package/dist/provider/index.js +1 -1
  329. package/dist/styles.css +1 -1
  330. package/dist/tailwind.css +1104 -19
  331. package/dist/tokens.css +1104 -19
  332. package/dist/types.d.ts +381 -2
  333. package/package.json +14 -4
  334. package/dist/components/avatar-group/PlAvatarGroup.d.ts +0 -47
  335. package/dist/components/avatar-group/PlAvatarGroup.js +0 -1
  336. package/dist/components/avatar-group/index.d.ts +0 -2
  337. package/dist/components/avatar-group/index.js +0 -1
  338. package/dist/css/avatar-group.css +0 -2
  339. package/dist/internal/avatar-group.d.ts +0 -25
  340. package/dist/internal/avatar-group.js +0 -2
@@ -0,0 +1,179 @@
1
+ import * as React from 'react';
2
+ import { useRender } from '@base-ui/react/use-render';
3
+ import type { PlWindowControl, PlWindowOffset, PlWindowOs } from '../../internal/window.js';
4
+ import type { PlassColor, PlassElevation, PlassSize } from '../../types.js';
5
+ export type { PlWindowControl, PlWindowOffset, PlWindowOs } from '../../internal/window.js';
6
+ /** The three CSS positions a window can be laid out with. */
7
+ export type PlWindowPanePosition = 'static' | 'absolute' | 'fixed';
8
+ /** What a resize reports: the window's size in pixels. */
9
+ export interface PlWindowPaneSize {
10
+ width: number;
11
+ height: number;
12
+ }
13
+ export interface PlWindowPaneProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'color' | 'title' | 'onResize'> {
14
+ /**
15
+ * Whose window this is a picture of. Decides where the controls sit, how they
16
+ * are drawn, how tall the title bar is and how its corners are cut.
17
+ * @default 'macos'
18
+ */
19
+ os?: PlWindowOs;
20
+ /** The window's name, in the title bar. Also what names the window itself. */
21
+ title?: React.ReactNode;
22
+ /** A glyph beside the title — the app's mark. */
23
+ icon?: React.ReactNode;
24
+ /** Anything else the title bar carries, set beside the controls. */
25
+ actions?: React.ReactNode;
26
+ /**
27
+ * Which of the three buttons the title bar has. `true` is all of them,
28
+ * `false` is none, and an array is exactly the ones named — a window that can
29
+ * be closed but not minimized is `['close']`.
30
+ *
31
+ * The order is the system's rather than the array's: macOS puts close first
32
+ * and Windows puts it last, and that is not something a caller should have to
33
+ * remember.
34
+ * @default true
35
+ */
36
+ controls?: boolean | readonly PlWindowControl[];
37
+ /**
38
+ * The scale of the chrome — the title bar's height, its buttons and its type.
39
+ * It does not touch the content, which is the caller's and is laid out at its
40
+ * own scale, exactly as it would be on a desktop where the title bar does not
41
+ * grow with the document.
42
+ * @default 'md'
43
+ */
44
+ size?: PlassSize;
45
+ /** The colour family the focus rings and an `accent` title bar take. @default 'primary' */
46
+ color?: PlassColor;
47
+ /**
48
+ * Dyes the title bar with the colour family, the way Windows offers to. Off,
49
+ * the bar is the neutral shade the system draws by default.
50
+ * @default false
51
+ */
52
+ accent?: boolean;
53
+ /**
54
+ * How much of what is behind the window shows through its chrome, from `0` to
55
+ * `1`. It applies to the title bar, the body's own fill and the border —
56
+ * never to the content on it, which stays exactly as legible as it was.
57
+ *
58
+ * Anything above `0` also turns the acrylic on, so the page underneath is
59
+ * blurred rather than merely visible. `1` is a window that is nothing but its
60
+ * edge and its chrome.
61
+ * @default 0
62
+ */
63
+ transparency?: number;
64
+ /**
65
+ * Whether this is the window in front.
66
+ *
67
+ * Left out, the window works it out for itself: it is in front until another
68
+ * `PlWindowPane` on the page is pressed or takes the focus, exactly as windows on
69
+ * a desktop behave. A click on the page *around* the windows changes nothing
70
+ * — a paragraph is not a desktop.
71
+ *
72
+ * Pass it to drive that yourself, which is what a caller keeping its own
73
+ * z-order wants.
74
+ *
75
+ * What being in front looks like is the system's: coloured traffic lights on
76
+ * macOS against grey ones, an accent title bar and an accent border on
77
+ * Windows 10, a tinted header bar on GNOME — and, on all four, a window one
78
+ * step further off the page than the ones behind it.
79
+ */
80
+ active?: boolean;
81
+ /**
82
+ * The shadow around the window. `2` here, against the `0` everything else
83
+ * defaults to, for the reason `PlPill`'s is `2`: a window is by definition not
84
+ * part of the page it is on.
85
+ * @default 2
86
+ */
87
+ elevation?: PlassElevation;
88
+ /**
89
+ * How the window is laid out. `static` leaves it in the flow (as a
90
+ * relatively positioned box, so `offset` can move it without disturbing
91
+ * anything around it); `absolute` pins it inside the nearest positioned
92
+ * ancestor, which is what a desktop full of windows wants; `fixed` pins it to
93
+ * the viewport.
94
+ * @default 'static'
95
+ */
96
+ position?: PlWindowPanePosition;
97
+ /** Lets the title bar be dragged. @default false */
98
+ draggable?: boolean;
99
+ /** Lets the edges and corners be dragged. @default false */
100
+ resizable?: boolean;
101
+ /** The window's width — a number in pixels or any CSS length. */
102
+ width?: number | string;
103
+ /** And its height. Left out, the window is as tall as what is in it. */
104
+ height?: number | string;
105
+ /** How small it may be dragged, in pixels. @default 180 */
106
+ minWidth?: number;
107
+ /** The same downward. Defaults to the title bar's own height. */
108
+ minHeight?: number;
109
+ /** How far it has been dragged from where the layout put it. */
110
+ offset?: PlWindowOffset;
111
+ /** Where an uncontrolled window starts. @default { x: 0, y: 0 } */
112
+ defaultOffset?: PlWindowOffset;
113
+ onOffsetChange?: (offset: PlWindowOffset) => void;
114
+ /** Fires with the window's size, in pixels, while an edge is dragged. */
115
+ onResize?: (size: PlWindowPaneSize) => void;
116
+ /** Whether the window is on screen at all. Closing it renders nothing. */
117
+ open?: boolean;
118
+ /** @default true */
119
+ defaultOpen?: boolean;
120
+ onOpenChange?: (open: boolean) => void;
121
+ /**
122
+ * Whether the window is rolled up to its title bar. This is what minimizing
123
+ * means for a window that is part of a page rather than of a desktop: there
124
+ * is no dock for it to go to, so it stays where it is with nothing under the
125
+ * bar.
126
+ */
127
+ minimized?: boolean;
128
+ /** @default false */
129
+ defaultMinimized?: boolean;
130
+ onMinimizedChange?: (minimized: boolean) => void;
131
+ /**
132
+ * Whether the window fills whatever is holding it. Its corners go square
133
+ * while it does, as they do on every system.
134
+ */
135
+ maximized?: boolean;
136
+ /** @default false */
137
+ defaultMaximized?: boolean;
138
+ onMaximizedChange?: (maximized: boolean) => void;
139
+ /** Whether content taller than the window scrolls. @default true */
140
+ scroll?: boolean;
141
+ /**
142
+ * Overrides the buttons' own names.
143
+ *
144
+ * There is no `locale` here: the words come from `PlassProvider`'s `labels`,
145
+ * which is where every other component in the library gets its own, and these
146
+ * four are the narrower override for one window.
147
+ */
148
+ minimizeLabel?: string;
149
+ maximizeLabel?: string;
150
+ restoreLabel?: string;
151
+ closeLabel?: string;
152
+ resizeLabel?: string;
153
+ /** Renders something other than a `<div>`: `render={<section />}`. */
154
+ render?: useRender.RenderProp;
155
+ /** What is in the window. */
156
+ children?: React.ReactNode;
157
+ }
158
+ /**
159
+ * A window, drawn the way one of four systems draws it, with anything at all
160
+ * inside it.
161
+ *
162
+ * It is not a real window and does not pretend to be one: there is no desktop,
163
+ * no z-order and no dock. What it is is a *frame that behaves* — the title bar
164
+ * drags, the corners resize, the three buttons are real buttons with real names
165
+ * — so a screenshot of an app, a demo of a feature or a piece of a landing page
166
+ * can be shown as the thing it will be rather than as a picture of it.
167
+ *
168
+ * Nothing here is transformed. A dragged window moves on `left` and `top` and a
169
+ * resized one changes `width` and `height`, which is what keeps the text inside
170
+ * it at whole pixels through both gestures — a `translate()` would resample
171
+ * every glyph in the window for the length of the drag, which is exactly what
172
+ * the house rule against transforming a surface exists to prevent.
173
+ *
174
+ * `minimize` rolls the window up to its title bar rather than sending it
175
+ * anywhere, because a page has nowhere to send it to. `maximize` fills whatever
176
+ * is holding the window, which is the container for `position="absolute"` and
177
+ * the viewport for `fixed`.
178
+ */
179
+ export declare const PlWindowPane: React.ForwardRefExoticComponent<PlWindowPaneProps & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1 @@
1
+ "use client";import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import*as i from"react";import{useRender as o}from"@base-ui/react/use-render";import{beginPointerDrag as r}from"../../internal/drag.js";import{useLabels as s}from"../../internal/labels.js";import{cx as a,glassClasses as l,hasContent as d,iconClasses as c}from"../../internal/styles.js";import{PlWindowControls as u,orderControls as m,windowChrome as h,windowMetrics as g,windowSlots as f}from"../../internal/window.js";import{useDefaults as w}from"../../internal/defaults.js";function useLatched(e,t,n){const[o,r]=i.useState(t),s=void 0!==e;return[s?e:o,i.useCallback(e=>{s||r(e),n?.(e)},[s,n])]}const p=[{edge:"n",className:"inset-x-3 top-0 h-1.5 cursor-ns-resize"},{edge:"s",className:"inset-x-3 bottom-0 h-1.5 cursor-ns-resize"},{edge:"w",className:"inset-y-3 left-0 w-1.5 cursor-ew-resize"},{edge:"e",className:"inset-y-3 right-0 w-1.5 cursor-ew-resize"},{edge:"nw",className:"top-0 left-0 size-3 cursor-nwse-resize"},{edge:"ne",className:"top-0 right-0 size-3 cursor-nesw-resize"},{edge:"sw",className:"bottom-0 left-0 size-3 cursor-nesw-resize"},{edge:"se",className:"right-0 bottom-0 size-3 cursor-nwse-resize"}];export const PlWindowPane=/* @__PURE__ */i.forwardRef(function PlWindowPane(b,v){const{os:x="macos",title:z,icon:y,actions:N,controls:M=!0,size:C,color:E,accent:L=!1,transparency:S=0,active:k,elevation:R=2,position:j="static",draggable:I=!1,resizable:T=!1,width:D,height:P,minWidth:B=180,minHeight:W,offset:A,defaultOffset:H,onOffsetChange:O,onResize:X,open:$,defaultOpen:G=!0,onOpenChange:F,minimized:U,defaultMinimized:Y=!1,onMinimizedChange:_,maximized:q,defaultMaximized:K=!1,onMaximizedChange:J,scroll:Q=!0,minimizeLabel:V,maximizeLabel:Z,restoreLabel:ee,closeLabel:te,resizeLabel:ne,render:ie,className:oe,style:re,children:se,...ae}=b,le=w(),de=C??le.size??"md",ce=E??le.color??"primary",ue=s(),me=h(x),he=g(x,de),ge=i.useId(),[fe,we]=useLatched($,G,F),[pe,be]=useLatched(U,Y,_),[ve,xe]=useLatched(q,K,J),[ze,ye]=useLatched(A,H??{x:0,y:0},O),[Ne,Me]=i.useState(null),[Ce,Ee]=i.useState(!0),Le=k??Ce,[Se,ke]=i.useState(null),[Re,je]=i.useState(null),[Ie,Te]=i.useState(!1),[De,Pe]=i.useState(!1),[Be,We]=i.useState(fe);Be!==fe&&(We(fe),Pe(!fe)),i.useEffect(()=>{if(!De)return;const e=window.setTimeout(()=>Pe(!1),260);return()=>window.clearTimeout(e)},[De]);const Ae=i.useRef(null),He=i.useCallback(e=>{Ae.current=e,"function"==typeof v?v(e):v&&(v.current=e)},[v]);i.useEffect(()=>{if(void 0!==k)return;const e=Ae.current;if(!e)return;const notice=t=>{const n=t.target;if(!(n instanceof Node))return;if(e.contains(n))return void Ee(!0);const i=n instanceof Element?n:n.parentElement;i?.closest(".plass-window")&&Ee(!1)};return document.addEventListener("pointerdown",notice,!0),document.addEventListener("focusin",notice,!0),()=>{document.removeEventListener("pointerdown",notice,!0),document.removeEventListener("focusin",notice,!0)}},[k]);const Oe=i.useRef(null);function beginGesture(e,t){if(0!==e.button)return;Oe.current?.();const n=e.currentTarget,i=e.clientX,o=e.clientY;Te(!0);const finish=()=>{Oe.current=null,Te(!1)},s=r({target:n,pointerId:e.pointerId,onMove:e=>t(e.clientX-i,e.clientY-o),onEnd:finish});Oe.current=()=>{s(),finish()}}i.useEffect(()=>()=>Oe.current?.(),[]);const Xe={width:Math.max(0,B),height:Math.max(he.bar,W??he.bar)};function resizeTo(e){Me(e),X?.(e)}const $e=m(x,!0===M?["minimize","maximize","close"]:!1===M?[]:M),Ge=$e.includes("maximize");i.useEffect(()=>{if(pe||null===Re)return;const e=window.setTimeout(()=>je(null),400);return()=>window.clearTimeout(e)},[pe,Re]);const Fe={minimize:V??ue.minimize,maximize:Z??ue.maximize,restore:ee??ue.restore,close:te??ue.close},Ue=e(u,{os:x,metrics:he,controls:$e,maximized:ve,active:Le,labels:Fe,onCommand:function command(e){"close"===e?we(!1):"minimize"===e?function rollUp(e){const t=Ae.current,n=t?.firstElementChild;if(t&&n instanceof HTMLElement&&ke(n.offsetHeight+(t.offsetHeight-t.clientHeight)),e&&void 0===(Ne?.height??P)&&t)return je(t.getBoundingClientRect().height),void requestAnimationFrame(()=>be(!0));be(e)}(!pe):xe(!ve)}}),Ye=d(z)?e("span",{id:ge,className:"min-w-0 truncate",children:z}):null,_e=d(y)?e("span",{className:"flex shrink-0 items-center",children:y}):null,qe=t("div",{className:a("relative flex shrink-0 items-center select-none",c,I&&!ve?"cursor-grab active:cursor-grabbing":""),style:{height:he.bar,textShadow:"var(--p-window-bar-shadow)",fontWeight:he.weight,paddingInlineStart:he.padX,paddingInlineEnd:he.padEnd,gap:Math.round(.7*he.title),fontSize:he.title,backgroundColor:"var(--p-window-bar)",backgroundImage:"var(--p-window-bar-image)",color:"var(--p-window-bar-fg)",borderBlockEnd:me.rule?"1px solid var(--p-window-line)":void 0},onPointerDown:function beginDrag(e){if(!I||ve)return;const t={...ze};beginGesture(e,(e,n)=>ye({x:t.x+e,y:t.y+n}))},onDoubleClick:Ge?()=>xe(!ve):void 0,children:["start"===me.controlsSide?Ue:null,"center"===me.titleAlign?e("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 flex items-center justify-center",style:{paddingInline:he.controlsWidth($e.length)+2*he.padX},children:t("span",{className:"flex min-w-0 items-center",style:{gap:Math.round(.5*he.title)},children:[_e,Ye]})}):t(n,{children:[_e,Ye]}),e("span",{className:"flex-1"}),d(N)?e("span",{className:"flex shrink-0 items-center",style:{gap:Math.round(.5*he.title)},onPointerDown:e=>e.stopPropagation(),children:N}):null,"end"===me.controlsSide?Ue:null]}),Ke=ve?{left:0,top:0,width:"100%",height:"100%"}:{left:ze.x,top:ze.y,width:Ne?.width??D,height:pe?Se??he.bar:Ne?.height??P??Re??void 0},Je=o({render:ie,ref:He,props:{role:"group","aria-labelledby":Ye?ge:void 0,className:a("plass-window relative flex min-w-0 flex-col overflow-hidden",S>0?l:"",me.glass&&0===S?"[backdrop-filter:var(--plass-blur)]":"","[transition-property:left,top,width,height,opacity,box-shadow,background-color,border-color,border-radius]","[transition-duration:var(--plass-duration-slow)]","[transition-timing-function:var(--plass-ease)]","motion-reduce:[transition-duration:0ms]","data-[gesture]:[transition-property:none]",oe),"data-gesture":Ie?"":void 0,inert:!fe||void 0,style:{opacity:fe?void 0:0,...f({os:x,color:ce,accent:L,transparency:S,active:Le,elevation:R}),position:"static"===j?"relative":j,...Ke,borderRadius:ve?0:`${he.radius}px ${he.radius}px ${he.radiusBottom}px ${he.radiusBottom}px`,borderStyle:"solid",borderWidth:he.frame,borderColor:"var(--p-window-line)",backgroundColor:"var(--p-window-band)",boxShadow:"var(--p-window-shadow), var(--plass-gloss-glass)",...re},children:t(n,{children:[qe,e("div",{className:a("min-h-0 flex-1",Q?"overflow-auto":"overflow-hidden"),style:{backgroundColor:"var(--p-window-body)",marginInline:he.band.side,marginBottom:he.band.bottom,boxShadow:he.band.side>0?"inset 0 0 0 1px rgb(0 0 0 / 0.12)":void 0},inert:pe,children:se}),!T||ve||pe?null:p.map(t=>{const n="se"===t.edge;return e("div",{role:n?"button":void 0,tabIndex:n?0:void 0,"aria-label":n?ne??ue.resizeWindow:void 0,"aria-hidden":n?void 0:"true",className:a("absolute z-10 touch-none",t.className,n?"focus-visible:[outline:2px_solid_var(--p-ring)] focus-visible:[outline-offset:-2px]":""),onPointerDown:e=>function beginResize(e,t){const n=Ae.current;if(!n||ve)return;const i=n.getBoundingClientRect(),o={width:i.width,height:i.height,x:ze.x,y:ze.y},r=e.includes("e"),s=e.includes("w"),a=e.includes("n"),l=e.includes("s");beginGesture(t,(e,t)=>{let{width:n,height:i}=o,{x:d,y:c}=o;r&&(n=Math.max(Xe.width,o.width+e)),l&&(i=Math.max(Xe.height,o.height+t)),s&&(n=Math.max(Xe.width,o.width-e),d=o.x+(o.width-n)),a&&(i=Math.max(Xe.height,o.height-t),c=o.y+(o.height-i)),resizeTo({width:n,height:i}),(s||a)&&ye({x:d,y:c})})}(t.edge,e),onKeyDown:n?e=>{const t={ArrowRight:[16,0],ArrowLeft:[-16,0],ArrowDown:[0,16],ArrowUp:[0,-16]}[e.key];t&&(e.preventDefault(),function nudge(e,t){const n=Ae.current;if(!n)return;const i=n.getBoundingClientRect();resizeTo({width:Math.max(Xe.width,i.width+e),height:Math.max(Xe.height,i.height+t)})}(t[0],t[1]))}:void 0},t.edge)})]}),...ae}});return fe||De?Je:null});
@@ -0,0 +1,2 @@
1
+ export { PlWindowPane } from './PlWindowPane.js';
2
+ export type { PlWindowControl, PlWindowOffset, PlWindowOs, PlWindowPanePosition, PlWindowPaneProps, PlWindowPaneSize } from './PlWindowPane.js';
@@ -0,0 +1 @@
1
+ export{PlWindowPane}from"./PlWindowPane.js";
@@ -0,0 +1,2 @@
1
+ /* Scan manifest for <anchor>. Needs `plass-ui/css/base.css` first. */
2
+ @source '../components/anchor';
@@ -0,0 +1,2 @@
1
+ /* Scan manifest for <animate-counter>. Needs `plass-ui/css/base.css` first. */
2
+ @source '../components/animate-counter';
@@ -0,0 +1,2 @@
1
+ /* Scan manifest for <animate-float>. Needs `plass-ui/css/base.css` first. */
2
+ @source '../components/animate-float';
@@ -0,0 +1,2 @@
1
+ /* Scan manifest for <animate-reveal>. Needs `plass-ui/css/base.css` first. */
2
+ @source '../components/animate-reveal';
@@ -0,0 +1,2 @@
1
+ /* Scan manifest for <animate-scramble>. Needs `plass-ui/css/base.css` first. */
2
+ @source '../components/animate-scramble';
@@ -0,0 +1,2 @@
1
+ /* Scan manifest for <animate-shake>. Needs `plass-ui/css/base.css` first. */
2
+ @source '../components/animate-shake';
@@ -0,0 +1,2 @@
1
+ /* Scan manifest for <animate-split>. Needs `plass-ui/css/base.css` first. */
2
+ @source '../components/animate-split';
@@ -0,0 +1,2 @@
1
+ /* Scan manifest for <app-logo>. Needs `plass-ui/css/base.css` first. */
2
+ @source '../components/app-logo';
@@ -0,0 +1,2 @@
1
+ /* Scan manifest for <area-chart>. Needs `plass-ui/css/base.css` first. */
2
+ @source '../components/area-chart';
@@ -0,0 +1,2 @@
1
+ /* Scan manifest for <bar-chart>. Needs `plass-ui/css/base.css` first. */
2
+ @source '../components/bar-chart';
@@ -0,0 +1,2 @@
1
+ /* Scan manifest for <code-block>. Needs `plass-ui/css/base.css` first. */
2
+ @source '../components/code-block';
@@ -0,0 +1,2 @@
1
+ /* Scan manifest for <data-list>. Needs `plass-ui/css/base.css` first. */
2
+ @source '../components/data-list';
@@ -0,0 +1,2 @@
1
+ /* Scan manifest for <data-table>. Needs `plass-ui/css/base.css` first. */
2
+ @source '../components/data-table';
@@ -0,0 +1,2 @@
1
+ /* Scan manifest for <flex>. Needs `plass-ui/css/base.css` first. */
2
+ @source '../components/flex';
@@ -0,0 +1,2 @@
1
+ /* Scan manifest for <floating-action-button>. Needs `plass-ui/css/base.css` first. */
2
+ @source '../components/floating-action-button';
@@ -0,0 +1,2 @@
1
+ /* Scan manifest for <gallery>. Needs `plass-ui/css/base.css` first. */
2
+ @source '../components/gallery';
@@ -0,0 +1,2 @@
1
+ /* Scan manifest for <gauge-chart>. Needs `plass-ui/css/base.css` first. */
2
+ @source '../components/gauge-chart';
@@ -0,0 +1,2 @@
1
+ /* Scan manifest for <heatmap-chart>. Needs `plass-ui/css/base.css` first. */
2
+ @source '../components/heatmap-chart';
@@ -0,0 +1,2 @@
1
+ /* Scan manifest for <hover-card>. Needs `plass-ui/css/base.css` first. */
2
+ @source '../components/hover-card';
@@ -0,0 +1,2 @@
1
+ /* Scan manifest for <how-to-steps>. Needs `plass-ui/css/base.css` first. */
2
+ @source '../components/how-to-steps';
@@ -0,0 +1,2 @@
1
+ /* Scan manifest for <line-chart>. Needs `plass-ui/css/base.css` first. */
2
+ @source '../components/line-chart';
@@ -0,0 +1,2 @@
1
+ /* Scan manifest for <meter>. Needs `plass-ui/css/base.css` first. */
2
+ @source '../components/meter';
@@ -0,0 +1,2 @@
1
+ /* Scan manifest for <mockup>. Needs `plass-ui/css/base.css` first. */
2
+ @source '../components/mockup';
@@ -0,0 +1,2 @@
1
+ /* Scan manifest for <pie-chart>. Needs `plass-ui/css/base.css` first. */
2
+ @source '../components/pie-chart';
@@ -0,0 +1,2 @@
1
+ /* Scan manifest for <portal>. Needs `plass-ui/css/base.css` first. */
2
+ @source '../components/portal';
@@ -0,0 +1,2 @@
1
+ /* Scan manifest for <scatter-chart>. Needs `plass-ui/css/base.css` first. */
2
+ @source '../components/scatter-chart';
@@ -0,0 +1,2 @@
1
+ /* Scan manifest for <scroll-area>. Needs `plass-ui/css/base.css` first. */
2
+ @source '../components/scroll-area';
@@ -0,0 +1,2 @@
1
+ /* Scan manifest for <show>. Needs `plass-ui/css/base.css` first. */
2
+ @source '../components/show';
@@ -0,0 +1,2 @@
1
+ /* Scan manifest for <sparkline>. Needs `plass-ui/css/base.css` first. */
2
+ @source '../components/sparkline';
@@ -0,0 +1,2 @@
1
+ /* Scan manifest for <stack>. Needs `plass-ui/css/base.css` first. */
2
+ @source '../components/stack';
@@ -0,0 +1,2 @@
1
+ /* Scan manifest for <timeline-chart>. Needs `plass-ui/css/base.css` first. */
2
+ @source '../components/timeline-chart';
@@ -0,0 +1,2 @@
1
+ /* Scan manifest for <tour>. Needs `plass-ui/css/base.css` first. */
2
+ @source '../components/tour';
@@ -0,0 +1,2 @@
1
+ /* Scan manifest for <tree-select>. Needs `plass-ui/css/base.css` first. */
2
+ @source '../components/tree-select';
@@ -0,0 +1,2 @@
1
+ /* Scan manifest for <window-pane>. Needs `plass-ui/css/base.css` first. */
2
+ @source '../components/window-pane';
@@ -1,7 +1,13 @@
1
1
  export { usePlBreakpoint, usePlBreakpointValue } from './usePlBreakpoint.js';
2
2
  export { usePlColorScheme } from './usePlColorScheme.js';
3
3
  export type { PlColorScheme, PlColorSchemeOptions, PlColorSchemeResult, PlResolvedColorScheme } from './usePlColorScheme.js';
4
+ export { usePlDisclosure } from './usePlDisclosure.js';
5
+ export type { PlDisclosureResult } from './usePlDisclosure.js';
6
+ export { usePlElementSize } from './usePlElementSize.js';
7
+ export type { PlElementSize } from './usePlElementSize.js';
4
8
  export { usePlHotKeys } from './usePlHotKeys.js';
5
9
  export type { PlHotKeysOptions, PlHotKeysTarget } from './usePlHotKeys.js';
6
10
  export { usePlMediaQuery } from './usePlMediaQuery.js';
11
+ export { usePlOnScreen } from './usePlOnScreen.js';
12
+ export type { PlOnScreenOptions } from './usePlOnScreen.js';
7
13
  export { usePlReducedMotion } from './usePlReducedMotion.js';
@@ -1 +1 @@
1
- export{usePlBreakpoint,usePlBreakpointValue}from"./usePlBreakpoint.js";export{usePlColorScheme}from"./usePlColorScheme.js";export{usePlHotKeys}from"./usePlHotKeys.js";export{usePlMediaQuery}from"./usePlMediaQuery.js";export{usePlReducedMotion}from"./usePlReducedMotion.js";
1
+ export{usePlBreakpoint,usePlBreakpointValue}from"./usePlBreakpoint.js";export{usePlColorScheme}from"./usePlColorScheme.js";export{usePlDisclosure}from"./usePlDisclosure.js";export{usePlElementSize}from"./usePlElementSize.js";export{usePlHotKeys}from"./usePlHotKeys.js";export{usePlMediaQuery}from"./usePlMediaQuery.js";export{usePlOnScreen}from"./usePlOnScreen.js";export{usePlReducedMotion}from"./usePlReducedMotion.js";
@@ -9,6 +9,9 @@ import type { PlassBreakpoint, PlassResponsive } from '../types.js';
9
9
  * `md` here switches with the `md:` utilities beside it rather than a few
10
10
  * pixels away from them.
11
11
  *
12
+ * The widths come off the document — see `internal/breakpoints.ts` — so a
13
+ * project that moves a breakpoint in its Tailwind theme moves this too.
14
+ *
12
15
  * **`xs` is the server's answer**, and the first one a browser renders. See
13
16
  * `usePlMediaQuery` for what follows from that.
14
17
  */
@@ -1 +1 @@
1
- "use client";import{breakpointMap as e,breakpoints as t}from"../internal/grid.js";import{useMediaQuery as r}from"../internal/media.js";export function usePlBreakpoint(){const e=r("(width >= 40rem)"),t=r("(width >= 48rem)"),i=r("(width >= 64rem)");return r("(width >= 80rem)")?"xl":i?"lg":t?"md":e?"sm":"xs"}export function usePlBreakpointValue(r){const i=usePlBreakpoint(),n=e(r);for(let e=t.indexOf(i);e>=0;e-=1){const r=n[t[e]];if(void 0!==r)return r}}
1
+ "use client";import{fromQuery as e}from"../internal/breakpoints.js";import{resolveAt as r}from"../internal/responsive.js";import{useMediaQuery as n}from"../internal/media.js";export function usePlBreakpoint(){const r=n(e("sm")),t=n(e("md")),o=n(e("lg"));return n(e("xl"))?"xl":o?"lg":t?"md":r?"sm":"xs"}export function usePlBreakpointValue(e){return r(e,usePlBreakpoint())}
@@ -0,0 +1,44 @@
1
+ /** What a caller gets back: the answer, and the four ways to change it. */
2
+ export interface PlDisclosureResult {
3
+ /** Whether the thing is open. */
4
+ open: boolean;
5
+ /** Opens it. */
6
+ onOpen: () => void;
7
+ /** Closes it. */
8
+ onClose: () => void;
9
+ /** Turns it round. */
10
+ onToggle: () => void;
11
+ /** Sets it to a value, for the caller who already has one. */
12
+ setOpen: (open: boolean) => void;
13
+ }
14
+ /**
15
+ * One boolean and the four callbacks that change it.
16
+ *
17
+ * The smallest hook in the library and the one that saves the most typing: a
18
+ * dialog, a drawer, a popover and a menu each need exactly this, and written by
19
+ * hand it is a `useState` plus three arrow functions **that are new on every
20
+ * render**. That last part is the reason it is worth a hook rather than a
21
+ * snippet — an inline `() => setOpen(false)` handed to a memoised trigger
22
+ * defeats the memo, and every one of the callbacks here is stable for the life
23
+ * of the component.
24
+ *
25
+ * The names are the props they are handed to. `onOpenChange` is the one shape
26
+ * every openable component in this library takes, and `setOpen` fits it
27
+ * exactly, so the ordinary use is a spread:
28
+ *
29
+ * ```tsx
30
+ * const dialog = usePlDisclosure();
31
+ *
32
+ * <PlButton onClick={dialog.onOpen}>Delete</PlButton>
33
+ * <PlModal open={dialog.open} onOpenChange={dialog.setOpen} title="Delete this?">
34
+ * <PlButton onClick={dialog.onClose}>Cancel</PlButton>
35
+ * </PlModal>
36
+ * ```
37
+ *
38
+ * It holds no DOM, watches nothing and has no effect in it, so it costs the
39
+ * same on a server as it does in a browser.
40
+ *
41
+ * @example
42
+ * const drawer = usePlDisclosure(true);
43
+ */
44
+ export declare function usePlDisclosure(initial?: boolean): PlDisclosureResult;
@@ -0,0 +1 @@
1
+ "use client";import*as e from"react";export function usePlDisclosure(o=!1){const[s,l]=e.useState(o),n=e.useCallback(()=>l(!0),[]),t=e.useCallback(()=>l(!1),[]),u=e.useCallback(()=>l(e=>!e),[]);return e.useMemo(()=>({open:s,onOpen:n,onClose:t,onToggle:u,setOpen:l}),[s,n,t,u])}
@@ -0,0 +1,31 @@
1
+ import * as React from 'react';
2
+ /** The box an element is laid out at, in pixels. */
3
+ export interface PlElementSize {
4
+ width: number;
5
+ height: number;
6
+ }
7
+ /**
8
+ * How big an element is, kept up to date as it changes.
9
+ *
10
+ * A `ResizeObserver` and the two things a hook has to add. The first is
11
+ * **when**: the size is read in a layout effect as well as from the observer,
12
+ * because an observer's first callback arrives after a frame has been painted
13
+ * and a component that laid itself out from `0 × 0` for one frame flashes.
14
+ *
15
+ * The second is what it reports: the **content box**, the room actually left
16
+ * inside the element once its own padding has been taken off. A hand-written
17
+ * version nearly always reports `getBoundingClientRect` or `borderBoxSize`
18
+ * instead, which is a different number — and the wrong one for the question
19
+ * that made somebody measure the element.
20
+ *
21
+ * `null` until there is an element to measure, which is the honest answer on a
22
+ * server and on the first render: guessing `0` there would let a caller divide
23
+ * by it.
24
+ *
25
+ * @example
26
+ * const box = React.useRef<HTMLDivElement>(null);
27
+ * const size = usePlElementSize(box);
28
+ *
29
+ * <div ref={box}>{size ? `${Math.round(size.width)}px` : null}</div>
30
+ */
31
+ export declare function usePlElementSize(target: React.RefObject<HTMLElement | null>): PlElementSize | null;
@@ -0,0 +1 @@
1
+ "use client";import*as t from"react";export function usePlElementSize(e){const[n,i]=t.useState(null);return t.useLayoutEffect(()=>{const t=e.current;if(!t)return;const read=()=>{const e=function contentBoxOf(t){const e=getComputedStyle(t),n=parseFloat(e.paddingInlineStart)+parseFloat(e.paddingInlineEnd),i=parseFloat(e.paddingBlockStart)+parseFloat(e.paddingBlockEnd);return{width:Math.max(0,t.clientWidth-n),height:Math.max(0,t.clientHeight-i)}}(t);i(t=>t?.width===e.width&&t.height===e.height?t:e)};if(read(),"undefined"==typeof ResizeObserver)return;const n=new ResizeObserver(read);return n.observe(t),()=>n.disconnect()},[e]),n}
@@ -0,0 +1,50 @@
1
+ import * as React from 'react';
2
+ export interface PlOnScreenOptions {
3
+ /**
4
+ * How much of the element has to be showing before it counts, from `0` to
5
+ * `1`.
6
+ * @default 0
7
+ */
8
+ threshold?: number;
9
+ /**
10
+ * How far outside the viewport still counts, as a CSS margin — `'200px'`
11
+ * starts a fetch a screen early.
12
+ */
13
+ rootMargin?: string;
14
+ /**
15
+ * What it is measured against. The viewport when it is not given; a scrolling
16
+ * panel otherwise.
17
+ */
18
+ root?: React.RefObject<Element | null>;
19
+ /**
20
+ * Stops watching the first time it appears.
21
+ *
22
+ * On by default, because the question a caller almost always has is "has this
23
+ * been seen yet" rather than "is it on screen right now" — a lazily loaded
24
+ * picture, a section that animates once, a page that fetches the next batch.
25
+ * Turn it off for the answer that keeps changing.
26
+ * @default true
27
+ */
28
+ once?: boolean;
29
+ }
30
+ /**
31
+ * Whether an element is on screen.
32
+ *
33
+ * An `IntersectionObserver` with the three things a hook has to decide, and
34
+ * the interesting one is `once`. It is **on** by default: the question a caller
35
+ * almost always has is "has this been seen yet", not "is it on screen right
36
+ * now", and a hook that kept answering the second one would re-render a page of
37
+ * lazily loaded pictures every time the reader scrolled past any of them.
38
+ *
39
+ * `false` on a server and on the first render, which is the safe answer for
40
+ * both of the things this is used for: nothing is fetched that did not need to
41
+ * be, and nothing is played before a reader could see it.
42
+ *
43
+ * A browser with no observer is told **yes** rather than no. There is no way to
44
+ * find out, and a picture that never loads is worse than one that loads early.
45
+ *
46
+ * @example
47
+ * const section = React.useRef<HTMLDivElement>(null);
48
+ * const seen = usePlOnScreen(section, { rootMargin: '200px' });
49
+ */
50
+ export declare function usePlOnScreen(target: React.RefObject<Element | null>, { threshold, rootMargin, root, once }?: PlOnScreenOptions): boolean;
@@ -0,0 +1 @@
1
+ "use client";import*as e from"react";export function usePlOnScreen(r,{threshold:t=0,rootMargin:n,root:o,once:s=!0}={}){const[c,i]=e.useState(!1);return e.useEffect(()=>{const e=r.current;if(!e)return;if("undefined"==typeof IntersectionObserver)return void i(!0);const c=new IntersectionObserver(([e])=>{e.isIntersecting?(i(!0),s&&c.disconnect()):s||i(!1)},{threshold:t,rootMargin:n,root:o?.current??null});return c.observe(e),()=>c.disconnect()},[r,t,n,o,s]),c}