@adecore/ui 0.14.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 (318) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +83 -0
  3. package/dist/AccentSwatches.d.ts +15 -0
  4. package/dist/AccentSwatches.js +21 -0
  5. package/dist/Banner.d.ts +12 -0
  6. package/dist/Banner.js +18 -0
  7. package/dist/Button.d.ts +9 -0
  8. package/dist/Button.js +28 -0
  9. package/dist/ButtonGroup.d.ts +3 -0
  10. package/dist/ButtonGroup.js +11 -0
  11. package/dist/Checkbox.d.ts +11 -0
  12. package/dist/Checkbox.js +9 -0
  13. package/dist/ChoiceCards.d.ts +23 -0
  14. package/dist/ChoiceCards.js +21 -0
  15. package/dist/CloseButton.d.ts +15 -0
  16. package/dist/CloseButton.js +11 -0
  17. package/dist/ColorSwatch.d.ts +14 -0
  18. package/dist/ColorSwatch.js +28 -0
  19. package/dist/ColumnResizeHandle.d.ts +9 -0
  20. package/dist/ColumnResizeHandle.js +12 -0
  21. package/dist/DisabledReason.d.ts +6 -0
  22. package/dist/DisabledReason.js +8 -0
  23. package/dist/DockShell.d.ts +9 -0
  24. package/dist/DockShell.js +49 -0
  25. package/dist/EmptyState.d.ts +16 -0
  26. package/dist/EmptyState.js +11 -0
  27. package/dist/ErrorBoundary.d.ts +24 -0
  28. package/dist/ErrorBoundary.js +47 -0
  29. package/dist/Field.d.ts +17 -0
  30. package/dist/Field.js +48 -0
  31. package/dist/FileIcon.d.ts +8 -0
  32. package/dist/FileIcon.js +15 -0
  33. package/dist/Icon.d.ts +9 -0
  34. package/dist/Icon.js +12 -0
  35. package/dist/IconButton.d.ts +23 -0
  36. package/dist/IconButton.js +25 -0
  37. package/dist/IconPicker.d.ts +17 -0
  38. package/dist/IconPicker.js +93 -0
  39. package/dist/Input.d.ts +14 -0
  40. package/dist/Input.js +25 -0
  41. package/dist/Kbd.d.ts +23 -0
  42. package/dist/Kbd.js +20 -0
  43. package/dist/ListRow.d.ts +10 -0
  44. package/dist/ListRow.js +20 -0
  45. package/dist/Meter.d.ts +12 -0
  46. package/dist/Meter.js +7 -0
  47. package/dist/PanelEmpty.d.ts +16 -0
  48. package/dist/PanelEmpty.js +7 -0
  49. package/dist/PanelHeader.d.ts +6 -0
  50. package/dist/PanelHeader.js +20 -0
  51. package/dist/Pill.d.ts +27 -0
  52. package/dist/Pill.js +25 -0
  53. package/dist/ProjectSwitcher.d.ts +30 -0
  54. package/dist/ProjectSwitcher.js +18 -0
  55. package/dist/PromptDialog.d.ts +40 -0
  56. package/dist/PromptDialog.js +47 -0
  57. package/dist/SectionLabel.d.ts +3 -0
  58. package/dist/SectionLabel.js +16 -0
  59. package/dist/SegmentBar.d.ts +18 -0
  60. package/dist/SegmentBar.js +44 -0
  61. package/dist/Segmented.d.ts +17 -0
  62. package/dist/Segmented.js +7 -0
  63. package/dist/Select.d.ts +27 -0
  64. package/dist/Select.js +34 -0
  65. package/dist/Separator.d.ts +7 -0
  66. package/dist/Separator.js +8 -0
  67. package/dist/ShortcutHints.d.ts +1 -0
  68. package/dist/ShortcutHints.js +94 -0
  69. package/dist/Skeleton.d.ts +6 -0
  70. package/dist/Skeleton.js +6 -0
  71. package/dist/SlidingColumn.d.ts +19 -0
  72. package/dist/SlidingColumn.js +41 -0
  73. package/dist/Spinner.d.ts +6 -0
  74. package/dist/Spinner.js +7 -0
  75. package/dist/Stepper.d.ts +14 -0
  76. package/dist/Stepper.js +18 -0
  77. package/dist/Surface.d.ts +3 -0
  78. package/dist/Surface.js +16 -0
  79. package/dist/Switch.d.ts +10 -0
  80. package/dist/Switch.js +7 -0
  81. package/dist/TextMenu.d.ts +5 -0
  82. package/dist/TextMenu.js +31 -0
  83. package/dist/Tile.d.ts +11 -0
  84. package/dist/Tile.js +10 -0
  85. package/dist/Toasts.d.ts +9 -0
  86. package/dist/Toasts.js +58 -0
  87. package/dist/Tooltip.d.ts +16 -0
  88. package/dist/Tooltip.js +21 -0
  89. package/dist/UIProvider.d.ts +9 -0
  90. package/dist/UIProvider.js +26 -0
  91. package/dist/Waveform.d.ts +16 -0
  92. package/dist/Waveform.js +123 -0
  93. package/dist/Wipe.d.ts +12 -0
  94. package/dist/Wipe.js +47 -0
  95. package/dist/ZoomControls.d.ts +30 -0
  96. package/dist/ZoomControls.js +16 -0
  97. package/dist/class-name.d.ts +2 -0
  98. package/dist/class-name.js +3 -0
  99. package/dist/clipboard.d.ts +2 -0
  100. package/dist/clipboard.js +16 -0
  101. package/dist/context-menu/index.parts.d.ts +1 -0
  102. package/dist/context-menu/index.parts.js +2 -0
  103. package/dist/dialog/index.parts.d.ts +1 -0
  104. package/dist/dialog/index.parts.js +1 -0
  105. package/dist/dialog/parts.d.ts +36 -0
  106. package/dist/dialog/parts.js +55 -0
  107. package/dist/dialog-layer.d.ts +1 -0
  108. package/dist/dialog-layer.js +27 -0
  109. package/dist/error-boundary.d.ts +4 -0
  110. package/dist/error-boundary.js +34 -0
  111. package/dist/error-message.d.ts +1 -0
  112. package/dist/error-message.js +4 -0
  113. package/dist/field-context.d.ts +7 -0
  114. package/dist/field-context.js +4 -0
  115. package/dist/file-icon.d.ts +4 -0
  116. package/dist/file-icon.js +46 -0
  117. package/dist/floating.d.ts +5 -0
  118. package/dist/floating.js +6 -0
  119. package/dist/format/datetime.d.ts +11 -0
  120. package/dist/format/datetime.js +50 -0
  121. package/dist/format/duration.d.ts +5 -0
  122. package/dist/format/duration.js +76 -0
  123. package/dist/format/index.d.ts +6 -0
  124. package/dist/format/index.js +7 -0
  125. package/dist/format/locale.d.ts +17 -0
  126. package/dist/format/locale.js +105 -0
  127. package/dist/format/number.d.ts +8 -0
  128. package/dist/format/number.js +72 -0
  129. package/dist/format/regions.d.ts +6 -0
  130. package/dist/format/regions.js +15 -0
  131. package/dist/format/time-zone.d.ts +1 -0
  132. package/dist/format/time-zone.js +2 -0
  133. package/dist/icon-button-size.d.ts +3 -0
  134. package/dist/icon-button-size.js +3 -0
  135. package/dist/icon-picker.d.ts +23 -0
  136. package/dist/icon-picker.js +80 -0
  137. package/dist/index.d.ts +74 -0
  138. package/dist/index.js +74 -0
  139. package/dist/lazy.d.ts +12 -0
  140. package/dist/lazy.js +104 -0
  141. package/dist/locales/en.json +59 -0
  142. package/dist/locales/nl.json +59 -0
  143. package/dist/locales.d.ts +4 -0
  144. package/dist/locales.js +17 -0
  145. package/dist/menu/index.parts.d.ts +1 -0
  146. package/dist/menu/index.parts.js +1 -0
  147. package/dist/menu/parts.d.ts +67 -0
  148. package/dist/menu/parts.js +113 -0
  149. package/dist/merge-refs.d.ts +2 -0
  150. package/dist/merge-refs.js +11 -0
  151. package/dist/modality.d.ts +1 -0
  152. package/dist/modality.js +29 -0
  153. package/dist/platform.d.ts +2 -0
  154. package/dist/platform.js +9 -0
  155. package/dist/popover/index.parts.d.ts +1 -0
  156. package/dist/popover/index.parts.js +1 -0
  157. package/dist/popover/parts.d.ts +26 -0
  158. package/dist/popover/parts.js +28 -0
  159. package/dist/prefetch.d.ts +21 -0
  160. package/dist/prefetch.js +99 -0
  161. package/dist/preview-card/index.parts.d.ts +1 -0
  162. package/dist/preview-card/index.parts.js +1 -0
  163. package/dist/project-switcher-row.d.ts +6 -0
  164. package/dist/project-switcher-row.js +16 -0
  165. package/dist/selection.d.ts +2 -0
  166. package/dist/selection.js +22 -0
  167. package/dist/seti-icons.d.ts +5 -0
  168. package/dist/seti-icons.js +445 -0
  169. package/dist/settings/ConfirmDialog.d.ts +9 -0
  170. package/dist/settings/ConfirmDialog.js +9 -0
  171. package/dist/settings/DetailHeader.d.ts +10 -0
  172. package/dist/settings/DetailHeader.js +6 -0
  173. package/dist/settings/MasterDetail.d.ts +24 -0
  174. package/dist/settings/MasterDetail.js +16 -0
  175. package/dist/settings/SettingsDialog.d.ts +46 -0
  176. package/dist/settings/SettingsDialog.js +96 -0
  177. package/dist/settings/SettingsRow.d.ts +22 -0
  178. package/dist/settings/SettingsRow.js +30 -0
  179. package/dist/settings/SettingsSection.d.ts +14 -0
  180. package/dist/settings/SettingsSection.js +8 -0
  181. package/dist/settings/index.d.ts +7 -0
  182. package/dist/settings/index.js +8 -0
  183. package/dist/settings/target.d.ts +7 -0
  184. package/dist/settings/target.js +3 -0
  185. package/dist/shortcut-hints.d.ts +38 -0
  186. package/dist/shortcut-hints.js +81 -0
  187. package/dist/shortcut.d.ts +32 -0
  188. package/dist/shortcut.js +137 -0
  189. package/dist/testing/dedupe.d.ts +1 -0
  190. package/dist/testing/dedupe.js +73 -0
  191. package/dist/testing/fake-source.d.ts +8 -0
  192. package/dist/testing/fake-source.js +15 -0
  193. package/dist/testing/index.d.ts +1 -0
  194. package/dist/testing/index.js +2 -0
  195. package/dist/theme.css +562 -0
  196. package/dist/toast-store.d.ts +38 -0
  197. package/dist/toast-store.js +61 -0
  198. package/dist/useAsyncAction.d.ts +8 -0
  199. package/dist/useAsyncAction.js +23 -0
  200. package/dist/useColumnResize.d.ts +14 -0
  201. package/dist/useColumnResize.js +49 -0
  202. package/dist/useContentSize.d.ts +5 -0
  203. package/dist/useContentSize.js +21 -0
  204. package/dist/useMeasuredWidth.d.ts +1 -0
  205. package/dist/useMeasuredWidth.js +6 -0
  206. package/dist/useNow.d.ts +3 -0
  207. package/dist/useNow.js +41 -0
  208. package/dist/wipe-split.d.ts +7 -0
  209. package/dist/wipe-split.js +20 -0
  210. package/dist/zoom.d.ts +3 -0
  211. package/dist/zoom.js +6 -0
  212. package/package.json +92 -0
  213. package/src/AccentSwatches.tsx +73 -0
  214. package/src/Banner.tsx +43 -0
  215. package/src/Button.tsx +55 -0
  216. package/src/ButtonGroup.tsx +14 -0
  217. package/src/Checkbox.tsx +44 -0
  218. package/src/ChoiceCards.tsx +108 -0
  219. package/src/CloseButton.tsx +21 -0
  220. package/src/ColorSwatch.tsx +41 -0
  221. package/src/ColumnResizeHandle.tsx +23 -0
  222. package/src/DisabledReason.tsx +23 -0
  223. package/src/DockShell.tsx +76 -0
  224. package/src/EmptyState.tsx +48 -0
  225. package/src/ErrorBoundary.tsx +116 -0
  226. package/src/Field.tsx +116 -0
  227. package/src/FileIcon.tsx +27 -0
  228. package/src/Icon.tsx +22 -0
  229. package/src/IconButton.tsx +84 -0
  230. package/src/IconPicker.tsx +257 -0
  231. package/src/Input.tsx +78 -0
  232. package/src/Kbd.tsx +67 -0
  233. package/src/ListRow.tsx +26 -0
  234. package/src/Meter.tsx +41 -0
  235. package/src/PanelEmpty.tsx +37 -0
  236. package/src/PanelHeader.tsx +31 -0
  237. package/src/Pill.tsx +61 -0
  238. package/src/ProjectSwitcher.tsx +127 -0
  239. package/src/PromptDialog.tsx +168 -0
  240. package/src/SectionLabel.tsx +20 -0
  241. package/src/SegmentBar.tsx +128 -0
  242. package/src/Segmented.tsx +51 -0
  243. package/src/Select.tsx +135 -0
  244. package/src/Separator.tsx +15 -0
  245. package/src/ShortcutHints.tsx +118 -0
  246. package/src/Skeleton.tsx +13 -0
  247. package/src/SlidingColumn.tsx +91 -0
  248. package/src/Spinner.tsx +32 -0
  249. package/src/Stepper.tsx +67 -0
  250. package/src/Surface.tsx +20 -0
  251. package/src/Switch.tsx +32 -0
  252. package/src/TextMenu.tsx +59 -0
  253. package/src/Tile.tsx +49 -0
  254. package/src/Toasts.tsx +151 -0
  255. package/src/Tooltip.tsx +70 -0
  256. package/src/UIProvider.tsx +41 -0
  257. package/src/Waveform.tsx +199 -0
  258. package/src/Wipe.tsx +99 -0
  259. package/src/ZoomControls.tsx +99 -0
  260. package/src/class-name.ts +8 -0
  261. package/src/clipboard.ts +17 -0
  262. package/src/context-menu/index.parts.ts +21 -0
  263. package/src/dialog/index.parts.ts +10 -0
  264. package/src/dialog/parts.tsx +112 -0
  265. package/src/dialog-layer.ts +31 -0
  266. package/src/error-boundary.ts +40 -0
  267. package/src/error-message.ts +5 -0
  268. package/src/field-context.ts +12 -0
  269. package/src/file-icon.ts +52 -0
  270. package/src/floating.ts +9 -0
  271. package/src/format/datetime.ts +63 -0
  272. package/src/format/duration.ts +83 -0
  273. package/src/format/index.ts +20 -0
  274. package/src/format/locale.ts +153 -0
  275. package/src/format/number.ts +87 -0
  276. package/src/format/regions.ts +20 -0
  277. package/src/format/time-zone.ts +2 -0
  278. package/src/icon-button-size.ts +6 -0
  279. package/src/icon-picker.ts +112 -0
  280. package/src/index.ts +103 -0
  281. package/src/lazy.tsx +124 -0
  282. package/src/locales/en.json +59 -0
  283. package/src/locales/nl.json +59 -0
  284. package/src/locales.ts +21 -0
  285. package/src/menu/index.parts.ts +20 -0
  286. package/src/menu/parts.tsx +296 -0
  287. package/src/merge-refs.ts +14 -0
  288. package/src/modality.ts +37 -0
  289. package/src/platform.ts +10 -0
  290. package/src/popover/index.parts.ts +8 -0
  291. package/src/popover/parts.tsx +119 -0
  292. package/src/prefetch.ts +113 -0
  293. package/src/preview-card/index.parts.ts +1 -0
  294. package/src/project-switcher-row.tsx +51 -0
  295. package/src/selection.ts +24 -0
  296. package/src/seti-icons.ts +451 -0
  297. package/src/settings/ConfirmDialog.tsx +30 -0
  298. package/src/settings/DetailHeader.tsx +25 -0
  299. package/src/settings/MasterDetail.tsx +67 -0
  300. package/src/settings/SettingsDialog.tsx +342 -0
  301. package/src/settings/SettingsRow.tsx +89 -0
  302. package/src/settings/SettingsSection.tsx +46 -0
  303. package/src/settings/index.ts +16 -0
  304. package/src/settings/target.ts +12 -0
  305. package/src/shortcut-hints.ts +117 -0
  306. package/src/shortcut.ts +170 -0
  307. package/src/testing/dedupe.ts +93 -0
  308. package/src/testing/fake-source.ts +21 -0
  309. package/src/testing/index.ts +3 -0
  310. package/src/theme.css +562 -0
  311. package/src/toast-store.ts +120 -0
  312. package/src/useAsyncAction.ts +32 -0
  313. package/src/useColumnResize.ts +75 -0
  314. package/src/useContentSize.ts +27 -0
  315. package/src/useMeasuredWidth.ts +7 -0
  316. package/src/useNow.ts +49 -0
  317. package/src/wipe-split.ts +24 -0
  318. package/src/zoom.ts +9 -0
@@ -0,0 +1,29 @@
1
+ let current = null;
2
+ let started = false;
3
+ const set = (modality) => {
4
+ if (current === modality) {
5
+ return;
6
+ }
7
+ current = modality;
8
+ document.documentElement.dataset.modality = modality;
9
+ };
10
+ /* Which device the app was last driven with, on the root element as `data-modality`. A ring that
11
+ only belongs to keyboard navigation cannot ask `:focus-visible` alone. Focus that a script moves
12
+ (Base UI does that for the hovered menu item) keeps matching it while the browser's own keyboard
13
+ flag is up, which a single keystroke anywhere, a terminal included, leaves on. Once per page;
14
+ `UIProvider` starts it, and a second call does nothing. */
15
+ export function startInputModality() {
16
+ if (started) {
17
+ return;
18
+ }
19
+ started = true;
20
+ set('pointer');
21
+ window.addEventListener('keydown', (event) => {
22
+ // A modifier on its own is half of a shift-click as often as it is a keystroke.
23
+ if (event.key !== 'Shift' && event.key !== 'Control' && event.key !== 'Alt' && event.key !== 'Meta') {
24
+ set('keyboard');
25
+ }
26
+ }, { capture: true });
27
+ window.addEventListener('pointerdown', () => set('pointer'), { capture: true, passive: true });
28
+ window.addEventListener('pointermove', () => set('pointer'), { capture: true, passive: true });
29
+ }
@@ -0,0 +1,2 @@
1
+ export declare const isApplePlatform: () => boolean;
2
+ export declare const applePlatformFrom: (platform: string | undefined) => boolean;
@@ -0,0 +1,9 @@
1
+ /* True on macOS and iOS, where a shortcut is written with ⌘ instead of Ctrl. The keyboard in question is the one in front of this page. */
2
+ export const isApplePlatform = () => {
3
+ if (typeof navigator === 'undefined') {
4
+ return false;
5
+ }
6
+ const hints = navigator.userAgentData;
7
+ return applePlatformFrom(hints?.platform || navigator.platform);
8
+ };
9
+ export const applePlatformFrom = (platform) => /mac|iphone|ipad/i.test(platform ?? '');
@@ -0,0 +1 @@
1
+ export { PopoverClose as Close, PopoverDescription as Description, PopoverPopup as Popup, PopoverRoot as Root, PopoverTitle as Title, PopoverTrigger as Trigger } from './parts.tsx';
@@ -0,0 +1 @@
1
+ export { PopoverClose as Close, PopoverDescription as Description, PopoverPopup as Popup, PopoverRoot as Root, PopoverTitle as Title, PopoverTrigger as Trigger } from './parts.js';
@@ -0,0 +1,26 @@
1
+ import type { ComponentProps } from 'react';
2
+ import { Popover as BasePopover } from '@base-ui-components/react/popover';
3
+ import { PreviewCard as BasePreviewCard } from '@base-ui-components/react/preview-card';
4
+ declare const POPUP_VARIANT: {
5
+ readonly menu: 'menu-popup';
6
+ readonly picker: 'picker-popup';
7
+ readonly plain: '';
8
+ };
9
+ export type PopupVariant = keyof typeof POPUP_VARIANT;
10
+ type Placement = Pick<ComponentProps<typeof BasePopover.Positioner>, 'side' | 'align' | 'sideOffset' | 'alignOffset' | 'collisionPadding' | 'collisionBoundary' | 'collisionAvoidance' | 'anchor' | 'sticky' | 'positionMethod'>;
11
+ export declare const PopoverRoot: typeof BasePopover.Root;
12
+ export declare const PopoverTrigger: BasePopover.Trigger;
13
+ export declare const PopoverClose: import("react").ForwardRefExoticComponent<import("@base-ui-components/react/popover").PopoverCloseProps & import("react").RefAttributes<HTMLButtonElement>>;
14
+ export declare const PopoverTitle: import("react").ForwardRefExoticComponent<import("@base-ui-components/react/popover").PopoverTitleProps & import("react").RefAttributes<HTMLHeadingElement>>;
15
+ export declare const PopoverDescription: import("react").ForwardRefExoticComponent<import("@base-ui-components/react/popover").PopoverDescriptionProps & import("react").RefAttributes<HTMLParagraphElement>>;
16
+ export type PopoverPopupProps = ComponentProps<typeof BasePopover.Popup> & Placement & {
17
+ variant?: PopupVariant;
18
+ };
19
+ export declare function PopoverPopup({ variant, side, align, sideOffset, alignOffset, collisionPadding, collisionBoundary, collisionAvoidance, anchor, sticky, positionMethod, className, ...props }: PopoverPopupProps): import("react").JSX.Element;
20
+ export declare const PreviewCardRoot: typeof BasePreviewCard.Root;
21
+ export declare const PreviewCardTrigger: import("react").ForwardRefExoticComponent<import("@base-ui-components/react/preview-card").PreviewCardTriggerProps & import("react").RefAttributes<HTMLAnchorElement>>;
22
+ export type PreviewCardPopupProps = ComponentProps<typeof BasePreviewCard.Popup> & Placement & {
23
+ variant?: PopupVariant;
24
+ };
25
+ export declare function PreviewCardPopup({ variant, side, align, sideOffset, alignOffset, collisionPadding, collisionBoundary, collisionAvoidance, anchor, sticky, positionMethod, className, ...props }: PreviewCardPopupProps): import("react").JSX.Element;
26
+ export {};
@@ -0,0 +1,28 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Popover as BasePopover } from '@base-ui-components/react/popover';
3
+ import { PreviewCard as BasePreviewCard } from '@base-ui-components/react/preview-card';
4
+ import { withClass } from '../class-name.js';
5
+ /*
6
+ * The surface a popup is drawn on. `menu` is the padded card menus use, `picker` a card whose
7
+ * content runs to its edges (a search field on top of a list), and `plain` leaves the surface to the caller.
8
+ */
9
+ const POPUP_VARIANT = {
10
+ menu: 'menu-popup',
11
+ picker: 'picker-popup',
12
+ plain: ''
13
+ };
14
+ export const PopoverRoot = BasePopover.Root;
15
+ export const PopoverTrigger = BasePopover.Trigger;
16
+ export const PopoverClose = BasePopover.Close;
17
+ export const PopoverTitle = BasePopover.Title;
18
+ export const PopoverDescription = BasePopover.Description;
19
+ /* The portal, the positioner and the popup of a popover: under its trigger and lined up with its start unless it says otherwise. */
20
+ export function PopoverPopup({ variant = 'menu', side = 'bottom', align = 'start', sideOffset = 8, alignOffset, collisionPadding, collisionBoundary, collisionAvoidance, anchor, sticky, positionMethod, className, ...props }) {
21
+ return (_jsx(BasePopover.Portal, { children: _jsx(BasePopover.Positioner, { className: "popup-positioner", side: side, align: align, sideOffset: sideOffset, alignOffset: alignOffset, collisionPadding: collisionPadding, collisionBoundary: collisionBoundary, collisionAvoidance: collisionAvoidance, anchor: anchor, sticky: sticky, positionMethod: positionMethod, children: _jsx(BasePopover.Popup, { className: withClass(POPUP_VARIANT[variant], className), ...props }) }) }));
22
+ }
23
+ export const PreviewCardRoot = BasePreviewCard.Root;
24
+ export const PreviewCardTrigger = BasePreviewCard.Trigger;
25
+ /* A card that opens while the pointer rests on its trigger, drawn like a popover. */
26
+ export function PreviewCardPopup({ variant = 'menu', side = 'bottom', align = 'start', sideOffset = 8, alignOffset, collisionPadding, collisionBoundary, collisionAvoidance, anchor, sticky, positionMethod, className, ...props }) {
27
+ return (_jsx(BasePreviewCard.Portal, { children: _jsx(BasePreviewCard.Positioner, { className: "z-(--z-popup)", side: side, align: align, sideOffset: sideOffset, alignOffset: alignOffset, collisionPadding: collisionPadding, collisionBoundary: collisionBoundary, collisionAvoidance: collisionAvoidance, anchor: anchor, sticky: sticky, positionMethod: positionMethod, children: _jsx(BasePreviewCard.Popup, { className: withClass(POPUP_VARIANT[variant], className), ...props }) }) }));
28
+ }
@@ -0,0 +1,21 @@
1
+ export type Loader = () => Promise<unknown>;
2
+ export type WhenIdle = (run: () => void) => void;
3
+ export declare class Prefetcher {
4
+ private readonly registered;
5
+ private readonly queued;
6
+ private readonly queue;
7
+ private everythingOn;
8
+ private running;
9
+ private loading;
10
+ private readonly whenIdle;
11
+ private readonly allowed;
12
+ constructor(whenIdle: WhenIdle, allowed?: () => boolean);
13
+ get busy(): boolean;
14
+ register(load: Loader): void;
15
+ prefetch(load: Loader): Promise<void>;
16
+ prefetchEverything(): Promise<void>;
17
+ private enqueue;
18
+ private drain;
19
+ private loadQueue;
20
+ }
21
+ export declare const prefetcher: Prefetcher;
@@ -0,0 +1,99 @@
1
+ /*
2
+ * Loads lazy modules ahead of their first opening, one per idle moment and never two at once, so
3
+ * the first open resolves from the module cache. A loader registered while everything is on
4
+ * joins the end, which is how a lazy surface inside another lazy one gets its turn.
5
+ */
6
+ export class Prefetcher {
7
+ registered = [];
8
+ queued = new Set();
9
+ queue = [];
10
+ everythingOn = false;
11
+ running = null;
12
+ loading = false;
13
+ whenIdle;
14
+ /* Asked on every start, since a person can turn data saving on while the page runs. */
15
+ allowed;
16
+ constructor(whenIdle, allowed = () => true) {
17
+ this.whenIdle = whenIdle;
18
+ this.allowed = allowed;
19
+ }
20
+ /* True while a prefetch waits on its chunk, so a failure it causes is not taken for a person's. */
21
+ get busy() {
22
+ return this.loading;
23
+ }
24
+ register(load) {
25
+ this.registered.push(load);
26
+ if (this.everythingOn) {
27
+ this.enqueue(load);
28
+ }
29
+ }
30
+ /* Loads this one module, ahead of whatever is registered. */
31
+ prefetch(load) {
32
+ if (!this.allowed()) {
33
+ return Promise.resolve();
34
+ }
35
+ this.enqueue(load);
36
+ return this.drain();
37
+ }
38
+ /* Loads every registered module, and every one registered from now on. */
39
+ prefetchEverything() {
40
+ if (!this.allowed()) {
41
+ return Promise.resolve();
42
+ }
43
+ this.everythingOn = true;
44
+ for (const load of this.registered) {
45
+ this.enqueue(load);
46
+ }
47
+ return this.drain();
48
+ }
49
+ enqueue(load) {
50
+ if (this.queued.has(load)) {
51
+ return;
52
+ }
53
+ this.queued.add(load);
54
+ this.queue.push(load);
55
+ void this.drain();
56
+ }
57
+ drain() {
58
+ // Never on an empty queue: `loadQueue` would clear `running` before it is even set.
59
+ if (this.running === null && this.queue.length > 0) {
60
+ this.running = this.loadQueue();
61
+ }
62
+ return this.running ?? Promise.resolve();
63
+ }
64
+ async loadQueue() {
65
+ try {
66
+ for (let load = this.queue.shift(); load; load = this.queue.shift()) {
67
+ await new Promise((resolve) => this.whenIdle(resolve));
68
+ this.loading = true;
69
+ try {
70
+ await load();
71
+ }
72
+ catch {
73
+ // A later open tries again; a chunk a deploy removed is the app's to answer, and `busy` tells it this was only a prefetch.
74
+ }
75
+ finally {
76
+ this.loading = false;
77
+ }
78
+ }
79
+ }
80
+ finally {
81
+ this.running = null;
82
+ }
83
+ }
84
+ }
85
+ /* Safari has no idle callback; the timeout at least lets the frame that asked finish first. */
86
+ const FALLBACK_DELAY_MS = 50;
87
+ /* A canvas that keeps drawing (a blinking cursor, a stream) may never leave an idle moment, and a prefetch that never runs helps nobody. */
88
+ const IDLE_TIMEOUT_MS = 2000;
89
+ const whenIdle = (run) => {
90
+ if (typeof requestIdleCallback === 'function') {
91
+ requestIdleCallback(() => run(), { timeout: IDLE_TIMEOUT_MS });
92
+ return;
93
+ }
94
+ setTimeout(run, FALLBACK_DELAY_MS);
95
+ };
96
+ /* Not in every DOM typing yet, and only Chromium reports it. */
97
+ const savesData = () => navigator.connection?.saveData === true;
98
+ /* The one every `lazyNamed` and `lazyDialog` registers with. */
99
+ export const prefetcher = /* @__PURE__ */ new Prefetcher(whenIdle, () => !savesData());
@@ -0,0 +1 @@
1
+ export { PreviewCardPopup as Popup, PreviewCardRoot as Root, PreviewCardTrigger as Trigger } from '../popover/parts.tsx';
@@ -0,0 +1 @@
1
+ export { PreviewCardPopup as Popup, PreviewCardRoot as Root, PreviewCardTrigger as Trigger } from '../popover/parts.js';
@@ -0,0 +1,6 @@
1
+ import type { MouseEvent } from 'react';
2
+ import type { ProjectSwitcherItem } from './ProjectSwitcher.tsx';
3
+ export declare function ProjectSwitcherRow<Item extends ProjectSwitcherItem>({ project, onSelect }: {
4
+ project: Item;
5
+ onSelect(project: Item, event: MouseEvent<HTMLElement>): void;
6
+ }): import("react").JSX.Element;
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import clsx from 'clsx';
3
+ import { useTranslation } from 'react-i18next';
4
+ import { MoreHorizontal } from 'lucide-react';
5
+ import * as Menu from './menu/index.parts.js';
6
+ import { Tooltip } from './Tooltip.js';
7
+ export function ProjectSwitcherRow({ project, onSelect }) {
8
+ const { t } = useTranslation('ui');
9
+ const hasActions = Boolean(project.actions);
10
+ const item = (_jsxs(Menu.Item, { className: clsx('min-w-0', project.muted && 'opacity-50'), disabled: project.disabled, label: project.name, onClick: (event) => onSelect(project, event), children: [project.icon, _jsx("span", { className: "min-w-0 truncate", children: project.name }), project.hint && _jsx("span", { className: "ml-auto truncate pl-3 text-xs text-text-faint", children: project.hint })] }));
11
+ const row = project.description ? (_jsx(Tooltip, { label: project.description, side: "right", sideOffset: hasActions ? 41 : undefined, children: item })) : (item);
12
+ if (!hasActions) {
13
+ return row;
14
+ }
15
+ return (_jsxs(Menu.Row, { "aria-label": project.name, children: [row, _jsxs(Menu.SubmenuRoot, { children: [_jsx(Menu.RowSubmenuTrigger, { icon: MoreHorizontal, label: t('projectSwitcher.actionsFor', { name: project.name }) }), _jsx(Menu.Popup, { className: "min-w-52", children: project.actions })] })] }));
16
+ }
@@ -0,0 +1,2 @@
1
+ export declare const selectionWithin: (element: HTMLElement | null) => string;
2
+ export declare const selectAllWithin: (element: HTMLElement | null) => void;
@@ -0,0 +1,22 @@
1
+ /*
2
+ * The text selection, as a context menu has to read it. The app has one selection at a time and a
3
+ * menu belongs to the surface the click landed on, so both of these are scoped to an element.
4
+ * A selection somewhere else is no selection this menu can copy.
5
+ */
6
+ export const selectionWithin = (element) => {
7
+ const selection = window.getSelection();
8
+ if (!element || !selection || selection.isCollapsed || selection.rangeCount === 0) {
9
+ return '';
10
+ }
11
+ return element.contains(selection.getRangeAt(0).commonAncestorContainer) ? selection.toString() : '';
12
+ };
13
+ export const selectAllWithin = (element) => {
14
+ const selection = window.getSelection();
15
+ if (!element || !selection) {
16
+ return;
17
+ }
18
+ const range = document.createRange();
19
+ range.selectNodeContents(element);
20
+ selection.removeAllRanges();
21
+ selection.addRange(range);
22
+ };