@timefoldai/viz-react 0.0.0-stage → 0.1.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 (289) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +240 -2
  3. package/dist/THIRD-PARTY-NOTICES.txt +99 -0
  4. package/dist/a11y/AccessibleTable.d.mts +42 -0
  5. package/dist/a11y/AccessibleTable.mjs +82 -0
  6. package/dist/a11y/activation.d.mts +4 -0
  7. package/dist/a11y/activation.mjs +0 -0
  8. package/dist/analytics/AnalyticsProvider.d.mts +16 -0
  9. package/dist/analytics/AnalyticsProvider.mjs +32 -0
  10. package/dist/assets/Inter-latin-ext.woff2 +0 -0
  11. package/dist/badge/Badge.css +122 -0
  12. package/dist/badge/Badge.d.mts +50 -0
  13. package/dist/badge/Badge.mjs +145 -0
  14. package/dist/badge/Badge.module.css.mjs +15 -0
  15. package/dist/badge/BadgeFacetGroup.d.mts +23 -0
  16. package/dist/badge/BadgeFacetGroup.mjs +220 -0
  17. package/dist/badge/BadgeGroup.d.mts +13 -0
  18. package/dist/badge/BadgeGroup.mjs +53 -0
  19. package/dist/badge/BadgeList.d.mts +14 -0
  20. package/dist/badge/BadgeList.mjs +15 -0
  21. package/dist/badge/badge-facet-fit.d.mts +18 -0
  22. package/dist/badge/badge-facet-fit.mjs +50 -0
  23. package/dist/badge/badge-item.d.mts +19 -0
  24. package/dist/badge/badge-item.mjs +23 -0
  25. package/dist/button/CopyButton.d.mts +12 -0
  26. package/dist/button/CopyButton.mjs +52 -0
  27. package/dist/button/ShowAllButton.d.mts +14 -0
  28. package/dist/button/ShowAllButton.mjs +61 -0
  29. package/dist/button/ShowMoreButton.d.mts +13 -0
  30. package/dist/button/ShowMoreButton.mjs +51 -0
  31. package/dist/button/SolveButton.d.mts +16 -0
  32. package/dist/button/SolveButton.mjs +56 -0
  33. package/dist/charts/BarChart.css +59 -0
  34. package/dist/charts/BarChart.d.mts +26 -0
  35. package/dist/charts/BarChart.mjs +167 -0
  36. package/dist/charts/BarChart.module.css.mjs +10 -0
  37. package/dist/charts/ChartGrid.d.mts +8 -0
  38. package/dist/charts/ChartGrid.mjs +47 -0
  39. package/dist/charts/DistributionChart.d.mts +60 -0
  40. package/dist/charts/DistributionChart.mjs +151 -0
  41. package/dist/code/CodeBlock.d.mts +13 -0
  42. package/dist/code/CodeBlock.mjs +71 -0
  43. package/dist/composition-bar/CompositionBar.d.mts +24 -0
  44. package/dist/composition-bar/CompositionBar.mjs +124 -0
  45. package/dist/composition-bar/composition-shares.d.mts +8 -0
  46. package/dist/composition-bar/composition-shares.mjs +30 -0
  47. package/dist/data-gate/DataGate.d.mts +34 -0
  48. package/dist/data-gate/DataGate.mjs +80 -0
  49. package/dist/date-scope/DateScope.d.mts +30 -0
  50. package/dist/date-scope/DateScope.mjs +285 -0
  51. package/dist/design-system/part-props.d.mts +39 -0
  52. package/dist/design-system/part-props.mjs +0 -0
  53. package/dist/detail-panel/DetailPanel.d.mts +22 -0
  54. package/dist/detail-panel/DetailPanel.mjs +80 -0
  55. package/dist/detail-panel/DetailPanelSection.d.mts +20 -0
  56. package/dist/detail-panel/DetailPanelSection.mjs +27 -0
  57. package/dist/detail-panel/micro-label.d.mts +7 -0
  58. package/dist/detail-panel/micro-label.mjs +9 -0
  59. package/dist/env.d.mts +2 -0
  60. package/dist/env.mjs +4 -0
  61. package/dist/export/ExportCsvButton.d.mts +19 -0
  62. package/dist/export/ExportCsvButton.mjs +73 -0
  63. package/dist/export/download-csv.d.mts +5 -0
  64. package/dist/export/download-csv.mjs +11 -0
  65. package/dist/export/download-file.d.mts +11 -0
  66. package/dist/export/download-file.mjs +32 -0
  67. package/dist/export/download-json.d.mts +2 -0
  68. package/dist/export/download-json.mjs +8 -0
  69. package/dist/filter/FilterGroup.d.mts +24 -0
  70. package/dist/filter/FilterGroup.mjs +71 -0
  71. package/dist/filter/FilterGroupTitle.d.mts +3 -0
  72. package/dist/filter/FilterGroupTitle.mjs +18 -0
  73. package/dist/filter/FilterItem.d.mts +17 -0
  74. package/dist/filter/FilterItem.mjs +94 -0
  75. package/dist/filter/FilterPanel.d.mts +22 -0
  76. package/dist/filter/FilterPanel.mjs +158 -0
  77. package/dist/filter/FilterToggleButton.d.mts +15 -0
  78. package/dist/filter/FilterToggleButton.mjs +30 -0
  79. package/dist/filter/date-range.d.mts +8 -0
  80. package/dist/filter/date-range.mjs +13 -0
  81. package/dist/filter/filter-facet.d.mts +7 -0
  82. package/dist/filter/filter-facet.mjs +0 -0
  83. package/dist/heatmap/Heatmap.css +138 -0
  84. package/dist/heatmap/Heatmap.d.mts +10 -0
  85. package/dist/heatmap/Heatmap.mjs +370 -0
  86. package/dist/heatmap/Heatmap.module.css.mjs +17 -0
  87. package/dist/heatmap/HeatmapCell.d.mts +25 -0
  88. package/dist/heatmap/HeatmapCell.mjs +124 -0
  89. package/dist/heatmap/heatmap-scale.d.mts +19 -0
  90. package/dist/heatmap/heatmap-scale.mjs +43 -0
  91. package/dist/heatmap/heatmap-types.d.mts +49 -0
  92. package/dist/heatmap/heatmap-types.mjs +0 -0
  93. package/dist/hooks/use-controllable-state.d.mts +9 -0
  94. package/dist/hooks/use-controllable-state.mjs +44 -0
  95. package/dist/hooks/use-debounced-value.d.mts +1 -0
  96. package/dist/hooks/use-debounced-value.mjs +27 -0
  97. package/dist/hooks/use-detail-panel-layout.d.mts +18 -0
  98. package/dist/hooks/use-detail-panel-layout.mjs +94 -0
  99. package/dist/hooks/use-hover-card.d.mts +47 -0
  100. package/dist/hooks/use-hover-card.mjs +190 -0
  101. package/dist/hooks/use-hover-focus-card.d.mts +38 -0
  102. package/dist/hooks/use-hover-focus-card.mjs +321 -0
  103. package/dist/hooks/use-hover-intent.d.mts +6 -0
  104. package/dist/hooks/use-hover-intent.mjs +55 -0
  105. package/dist/hooks/use-merged-ref.d.mts +2 -0
  106. package/dist/hooks/use-merged-ref.mjs +36 -0
  107. package/dist/hooks/use-tracked-anchor.d.mts +14 -0
  108. package/dist/hooks/use-tracked-anchor.mjs +42 -0
  109. package/dist/index.d.mts +97 -0
  110. package/dist/index.mjs +88 -0
  111. package/dist/input/MenuButton.d.mts +47 -0
  112. package/dist/input/MenuButton.mjs +152 -0
  113. package/dist/interval-strip/IntervalStrip.css +7 -0
  114. package/dist/interval-strip/IntervalStrip.d.mts +39 -0
  115. package/dist/interval-strip/IntervalStrip.mjs +233 -0
  116. package/dist/interval-strip/IntervalStrip.module.css.mjs +4 -0
  117. package/dist/interval-strip/IntervalStripAxis.d.mts +18 -0
  118. package/dist/interval-strip/IntervalStripAxis.mjs +73 -0
  119. package/dist/interval-strip/interval-fill.d.mts +2 -0
  120. package/dist/interval-strip/interval-fill.mjs +13 -0
  121. package/dist/interval-strip/interval-layout.d.mts +33 -0
  122. package/dist/interval-strip/interval-layout.mjs +79 -0
  123. package/dist/layout/AppShell.css +103 -0
  124. package/dist/layout/AppShell.d.mts +73 -0
  125. package/dist/layout/AppShell.mjs +397 -0
  126. package/dist/layout/AppShell.module.css.mjs +16 -0
  127. package/dist/layout/ColorSchemeMenu.d.mts +14 -0
  128. package/dist/layout/ColorSchemeMenu.mjs +92 -0
  129. package/dist/layout/DemoDataPicker.d.mts +17 -0
  130. package/dist/layout/DemoDataPicker.mjs +150 -0
  131. package/dist/layout/OverflowMenu.d.mts +11 -0
  132. package/dist/layout/OverflowMenu.mjs +94 -0
  133. package/dist/layout/SidebarLayout.css +70 -0
  134. package/dist/layout/SidebarLayout.d.mts +33 -0
  135. package/dist/layout/SidebarLayout.mjs +129 -0
  136. package/dist/layout/SidebarLayout.module.css.mjs +8 -0
  137. package/dist/layout/use-date-scope-day.d.mts +23 -0
  138. package/dist/layout/use-date-scope-day.mjs +63 -0
  139. package/dist/layout/use-fill-height.d.mts +7 -0
  140. package/dist/layout/use-fill-height.mjs +50 -0
  141. package/dist/layout/use-followed-state.d.mts +5 -0
  142. package/dist/layout/use-followed-state.mjs +75 -0
  143. package/dist/layout/use-page-route.d.mts +10 -0
  144. package/dist/layout/use-page-route.mjs +65 -0
  145. package/dist/legend/Legend.d.mts +54 -0
  146. package/dist/legend/Legend.mjs +132 -0
  147. package/dist/map/MapLayersControl.d.mts +11 -0
  148. package/dist/map/MapLayersControl.mjs +157 -0
  149. package/dist/map/MapLocator.css +9 -0
  150. package/dist/map/MapLocator.d.mts +18 -0
  151. package/dist/map/MapLocator.mjs +97 -0
  152. package/dist/map/MapLocator.module.css.mjs +4 -0
  153. package/dist/map/MapMarker.d.mts +29 -0
  154. package/dist/map/MapMarker.mjs +265 -0
  155. package/dist/map/MapStops.d.mts +19 -0
  156. package/dist/map/MapStops.mjs +355 -0
  157. package/dist/map/MapView.css +24 -0
  158. package/dist/map/MapView.d.mts +11 -0
  159. package/dist/map/MapView.mjs +141 -0
  160. package/dist/map/MapWebgl.d.mts +9 -0
  161. package/dist/map/MapWebgl.mjs +727 -0
  162. package/dist/map/area-layers.d.mts +33 -0
  163. package/dist/map/area-layers.mjs +96 -0
  164. package/dist/map/control-group.d.mts +6 -0
  165. package/dist/map/control-group.mjs +12 -0
  166. package/dist/map/for-each-chunk.d.mts +4 -0
  167. package/dist/map/for-each-chunk.mjs +14 -0
  168. package/dist/map/highlight.d.mts +30 -0
  169. package/dist/map/highlight.mjs +99 -0
  170. package/dist/map/locator-tile.d.mts +24 -0
  171. package/dist/map/locator-tile.mjs +41 -0
  172. package/dist/map/map-sites.d.mts +12 -0
  173. package/dist/map/map-sites.mjs +39 -0
  174. package/dist/map/map-style.d.mts +24 -0
  175. package/dist/map/map-style.mjs +79 -0
  176. package/dist/map/marker-geometry.d.mts +5 -0
  177. package/dist/map/marker-geometry.mjs +13 -0
  178. package/dist/map/marker-icon.d.mts +26 -0
  179. package/dist/map/marker-icon.mjs +223 -0
  180. package/dist/map/observe-color-scheme.d.mts +5 -0
  181. package/dist/map/observe-color-scheme.mjs +19 -0
  182. package/dist/map/popup-placement.d.mts +20 -0
  183. package/dist/map/popup-placement.mjs +20 -0
  184. package/dist/map/route-layers.d.mts +28 -0
  185. package/dist/map/route-layers.mjs +73 -0
  186. package/dist/map/types.d.mts +97 -0
  187. package/dist/map/types.mjs +0 -0
  188. package/dist/map/use-painted-color-scheme.d.mts +6 -0
  189. package/dist/map/use-painted-color-scheme.mjs +43 -0
  190. package/dist/map/use-resolved-colors.d.mts +5 -0
  191. package/dist/map/use-resolved-colors.mjs +63 -0
  192. package/dist/pagination/paginationLabels.d.mts +6 -0
  193. package/dist/pagination/paginationLabels.mjs +8 -0
  194. package/dist/popover/Popover.css +176 -0
  195. package/dist/popover/Popover.d.mts +239 -0
  196. package/dist/popover/Popover.mjs +672 -0
  197. package/dist/popover/Popover.module.css.mjs +18 -0
  198. package/dist/popover/PopoverFacts.d.mts +24 -0
  199. package/dist/popover/PopoverFacts.mjs +63 -0
  200. package/dist/readout/Readout.d.mts +15 -0
  201. package/dist/readout/Readout.mjs +53 -0
  202. package/dist/readout/TimeZoneReadout.d.mts +11 -0
  203. package/dist/readout/TimeZoneReadout.mjs +46 -0
  204. package/dist/score-box/ScoreBox.css +62 -0
  205. package/dist/score-box/ScoreBox.d.mts +12 -0
  206. package/dist/score-box/ScoreBox.mjs +143 -0
  207. package/dist/score-box/ScoreBox.module.css.mjs +15 -0
  208. package/dist/segment-bar/Segment.d.mts +23 -0
  209. package/dist/segment-bar/Segment.mjs +27 -0
  210. package/dist/segment-bar/SegmentBar.css +44 -0
  211. package/dist/segment-bar/SegmentBar.d.mts +35 -0
  212. package/dist/segment-bar/SegmentBar.mjs +57 -0
  213. package/dist/segment-bar/SegmentBar.module.css.mjs +9 -0
  214. package/dist/segment-bar/segment-box.d.mts +10 -0
  215. package/dist/segment-bar/segment-box.mjs +30 -0
  216. package/dist/stat/Stat.d.mts +25 -0
  217. package/dist/stat/Stat.mjs +36 -0
  218. package/dist/stat/StatTile.d.mts +18 -0
  219. package/dist/stat/StatTile.mjs +37 -0
  220. package/dist/styles.css +1 -0
  221. package/dist/swatch/Swatch.d.mts +8 -0
  222. package/dist/swatch/Swatch.mjs +30 -0
  223. package/dist/swatch/legend-swatch.d.mts +3 -0
  224. package/dist/swatch/legend-swatch.mjs +0 -0
  225. package/dist/tab-bar/FilteredTabBar.d.mts +32 -0
  226. package/dist/tab-bar/FilteredTabBar.mjs +181 -0
  227. package/dist/tab-bar/TabBar.d.mts +22 -0
  228. package/dist/tab-bar/TabBar.mjs +151 -0
  229. package/dist/tab-bar/TabPanel.d.mts +9 -0
  230. package/dist/tab-bar/TabPanel.mjs +55 -0
  231. package/dist/tab-bar/assert-named-value.d.mts +4 -0
  232. package/dist/tab-bar/assert-named-value.mjs +6 -0
  233. package/dist/table/DataTable.d.mts +31 -0
  234. package/dist/table/DataTable.mjs +43 -0
  235. package/dist/theme/use-color-scheme.d.mts +14 -0
  236. package/dist/theme/use-color-scheme.mjs +92 -0
  237. package/dist/theme.css +58 -0
  238. package/dist/timeline/Timeline.d.mts +54 -0
  239. package/dist/timeline/Timeline.mjs +220 -0
  240. package/dist/timeline/TimelineBand.d.mts +18 -0
  241. package/dist/timeline/TimelineBand.mjs +30 -0
  242. package/dist/timeline/TimelineGroup.d.mts +7 -0
  243. package/dist/timeline/TimelineGroup.mjs +50 -0
  244. package/dist/timeline/TimelineItem.d.mts +19 -0
  245. package/dist/timeline/TimelineItem.mjs +64 -0
  246. package/dist/timeline/TimelineItemChip.css +153 -0
  247. package/dist/timeline/TimelineItemChip.d.mts +23 -0
  248. package/dist/timeline/TimelineItemChip.mjs +74 -0
  249. package/dist/timeline/TimelineItemChip.module.css.mjs +15 -0
  250. package/dist/timeline/TimelineItemMark.css +38 -0
  251. package/dist/timeline/TimelineItemMark.d.mts +15 -0
  252. package/dist/timeline/TimelineItemMark.mjs +129 -0
  253. package/dist/timeline/TimelineItemMark.module.css.mjs +4 -0
  254. package/dist/timeline/TimelineRoot.d.mts +19 -0
  255. package/dist/timeline/TimelineRoot.mjs +742 -0
  256. package/dist/timeline/TimelineRowHeader.d.mts +23 -0
  257. package/dist/timeline/TimelineRowHeader.mjs +244 -0
  258. package/dist/timeline/TimelineZoomHint.d.mts +9 -0
  259. package/dist/timeline/TimelineZoomHint.mjs +32 -0
  260. package/dist/timeline/axis-label.d.mts +5 -0
  261. package/dist/timeline/axis-label.mjs +53 -0
  262. package/dist/timeline/batched-dataset-writer.d.mts +29 -0
  263. package/dist/timeline/batched-dataset-writer.mjs +58 -0
  264. package/dist/timeline/row-card-side.d.mts +7 -0
  265. package/dist/timeline/row-card-side.mjs +6 -0
  266. package/dist/timeline/timeline-a11y.d.mts +33 -0
  267. package/dist/timeline/timeline-a11y.mjs +96 -0
  268. package/dist/timeline/timeline-context.d.mts +33 -0
  269. package/dist/timeline/timeline-context.mjs +40 -0
  270. package/dist/timeline/timeline-types.d.mts +126 -0
  271. package/dist/timeline/timeline-types.mjs +0 -0
  272. package/dist/timeline/timeline-utils.d.mts +52 -0
  273. package/dist/timeline/timeline-utils.mjs +130 -0
  274. package/dist/timeline/zoom-modifier.d.mts +21 -0
  275. package/dist/timeline/zoom-modifier.mjs +25 -0
  276. package/dist/toast/ToastProvider.d.mts +33 -0
  277. package/dist/toast/ToastProvider.mjs +257 -0
  278. package/dist/toast/toast-context.d.mts +2 -0
  279. package/dist/toast/toast-context.mjs +5 -0
  280. package/dist/tokens.css +1 -0
  281. package/dist/tooltip/Tooltip.d.mts +17 -0
  282. package/dist/tooltip/Tooltip.mjs +41 -0
  283. package/dist/tooltip/hover-open-delay.d.mts +2 -0
  284. package/dist/tooltip/hover-open-delay.mjs +4 -0
  285. package/dist/tooltip/is-text-cut.d.mts +1 -0
  286. package/dist/tooltip/is-text-cut.mjs +5 -0
  287. package/dist/vendor/components.d.mts +664 -0
  288. package/dist/vendor/components.mjs +2060 -0
  289. package/package.json +61 -3
@@ -0,0 +1,397 @@
1
+ "use client";
2
+ import MenuButton from "../input/MenuButton.mjs";
3
+ import ScoreBox from "../score-box/ScoreBox.mjs";
4
+ import { assertNamedValue } from "../tab-bar/assert-named-value.mjs";
5
+ import ToastProvider, { useToast } from "../toast/ToastProvider.mjs";
6
+ import ColorSchemeMenu from "./ColorSchemeMenu.mjs";
7
+ import DemoDataPicker from "./DemoDataPicker.mjs";
8
+ import OverflowMenu from "./OverflowMenu.mjs";
9
+ import { usePageRoute } from "./use-page-route.mjs";
10
+ import AppShell_module_default from "./AppShell.module.css.mjs";
11
+ import { c } from "react/compiler-runtime";
12
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
13
+ import { Activity, startTransition, useEffect, useLayoutEffect, useRef, useState } from "react";
14
+ import { Button, TooltipProvider } from "../vendor/components.mjs";
15
+ import clsx$1 from "clsx";
16
+ import { title } from "radash";
17
+ // src/layout/AppShell.tsx
18
+ /**
19
+ * The application shell every app renders: a standalone toolbar (score, solve, demo data) above the active
20
+ * page when off the platform, with a menu that switches between the pages.
21
+ *
22
+ * @see https://www.w3.org/WAI/ARIA/apg/patterns/menu-button/
23
+ * @see https://www.w3.org/WAI/ARIA/apg/patterns/button/
24
+ * @category Layout
25
+ */
26
+ function AppShell(props) {
27
+ const { title, pages, toolbar = NO_TOOLBAR, onPlatform = false, errors = NO_ERRORS } = props;
28
+ const startPage = defaultPageValue(pages, props.defaultPage);
29
+ const [internalPage, internalNavigate] = usePageRoute(startPage);
30
+ const [activeKey, rawNavigate] = props.page === void 0 ? [internalPage, internalNavigate] : [props.page, props.onPageChange];
31
+ const navigate = (key) => startTransition(() => rawNavigate(key));
32
+ const currentPage = pages.find((p_0) => p_0.value === activeKey) || pages.find((p) => p.value === startPage) || null;
33
+ const contentSized = onPlatform;
34
+ const contentSizedVars = {};
35
+ if (contentSized) contentSizedVars["--viz-data-gate-height"] = "30rem";
36
+ return /* @__PURE__ */ jsx(ToastProvider, { children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [[...new Set(errors)].map((error) => error ? /* @__PURE__ */ jsx(LoadErrorToast, { error }, error) : null), /* @__PURE__ */ jsxs("div", {
37
+ className: clsx$1("flex flex-col", !contentSized && "min-h-dvh"),
38
+ "data-slot": "app-shell",
39
+ style: contentSizedVars,
40
+ children: [!onPlatform && /* @__PURE__ */ jsx(Header, {
41
+ title,
42
+ pages,
43
+ currentPage,
44
+ onNavigate: navigate,
45
+ toolbar
46
+ }), /* @__PURE__ */ jsx(Content, { children: /* @__PURE__ */ jsx(VisitedPages, {
47
+ pages,
48
+ currentKey: currentPage?.value
49
+ }) })]
50
+ })] }) });
51
+ }
52
+ const NO_TOOLBAR = {};
53
+ const NO_ERRORS = [];
54
+ function PageFrame(t0) {
55
+ const $ = c(2);
56
+ const { children } = t0;
57
+ let t1;
58
+ if ($[0] !== children) {
59
+ t1 = /* @__PURE__ */ jsx("div", {
60
+ "data-slot": "app-shell-page",
61
+ className: "flex grow flex-col",
62
+ children
63
+ });
64
+ $[0] = children;
65
+ $[1] = t1;
66
+ } else t1 = $[1];
67
+ return t1;
68
+ }
69
+ function Content(t0) {
70
+ const $ = c(2);
71
+ const { children } = t0;
72
+ let t1;
73
+ if ($[0] !== children) {
74
+ t1 = /* @__PURE__ */ jsx("main", {
75
+ className: "main-content flex grow flex-col px-(--main-padding-x) py-(--main-padding-y)",
76
+ children
77
+ });
78
+ $[0] = children;
79
+ $[1] = t1;
80
+ } else t1 = $[1];
81
+ return t1;
82
+ }
83
+ function defaultPageValue(pages, defaultPage) {
84
+ const values = pages.map((page) => page.value);
85
+ assertNamedValue(defaultPage, values, {
86
+ prop: "AppShell defaultPage",
87
+ noun: "page"
88
+ });
89
+ return defaultPage ?? values[0] ?? "";
90
+ }
91
+ function getAppShellPageLabel(page) {
92
+ return page.label ?? title(page.value);
93
+ }
94
+ const HEADER_DENSITIES = [
95
+ "full",
96
+ "compact",
97
+ "condensed",
98
+ "stacked",
99
+ "phone"
100
+ ];
101
+ function overflowsContentBox(bar) {
102
+ const contentRight = bar.getBoundingClientRect().right - parseFloat(getComputedStyle(bar).paddingRight);
103
+ return Array.from(bar.children).some((zone) => zone.getBoundingClientRect().right > contentRight + .5);
104
+ }
105
+ function fitDensity(bar) {
106
+ for (const density of HEADER_DENSITIES) {
107
+ bar.dataset.density = density;
108
+ if (!overflowsContentBox(bar)) return;
109
+ }
110
+ }
111
+ function useFittedDensity(barRef, hasPageSwitcher) {
112
+ const $ = c(5);
113
+ let t0;
114
+ if ($[0] !== barRef) {
115
+ t0 = () => {
116
+ const bar = barRef.current;
117
+ if (!bar) return;
118
+ let frame = 0;
119
+ const observer = new ResizeObserver(() => {
120
+ cancelAnimationFrame(frame);
121
+ frame = requestAnimationFrame(() => fitDensity(bar));
122
+ });
123
+ fitDensity(bar);
124
+ observer.observe(bar);
125
+ for (const zone of bar.children) observer.observe(zone);
126
+ return () => {
127
+ cancelAnimationFrame(frame);
128
+ observer.disconnect();
129
+ };
130
+ };
131
+ $[0] = barRef;
132
+ $[1] = t0;
133
+ } else t0 = $[1];
134
+ let t1;
135
+ if ($[2] !== barRef || $[3] !== hasPageSwitcher) {
136
+ t1 = [barRef, hasPageSwitcher];
137
+ $[2] = barRef;
138
+ $[3] = hasPageSwitcher;
139
+ $[4] = t1;
140
+ } else t1 = $[4];
141
+ useLayoutEffect(t0, t1);
142
+ }
143
+ function Header(t0) {
144
+ const $ = c(41);
145
+ const { title, pages, currentPage, onNavigate, toolbar: t1 } = t0;
146
+ const { logo, score, solve, demo, action } = t1;
147
+ const t2 = currentPage?.value;
148
+ let t3;
149
+ if ($[0] !== onNavigate || $[1] !== pages) {
150
+ let t4;
151
+ if ($[3] !== onNavigate) {
152
+ t4 = (page) => ({
153
+ value: page.value,
154
+ label: getAppShellPageLabel(page),
155
+ onSelect: () => {
156
+ onNavigate(page.value);
157
+ }
158
+ });
159
+ $[3] = onNavigate;
160
+ $[4] = t4;
161
+ } else t4 = $[4];
162
+ t3 = pages.map(t4);
163
+ $[0] = onNavigate;
164
+ $[1] = pages;
165
+ $[2] = t3;
166
+ } else t3 = $[2];
167
+ let t4;
168
+ if ($[5] !== t3) {
169
+ t4 = [{ options: t3 }];
170
+ $[5] = t3;
171
+ $[6] = t4;
172
+ } else t4 = $[6];
173
+ let t5;
174
+ if ($[7] !== t2 || $[8] !== t4) {
175
+ t5 = {
176
+ selectedValue: t2,
177
+ sections: t4
178
+ };
179
+ $[7] = t2;
180
+ $[8] = t4;
181
+ $[9] = t5;
182
+ } else t5 = $[9];
183
+ const pageMenu = t5;
184
+ const hasPageSwitcher = pages.length > 1;
185
+ const barRef = useRef(null);
186
+ useFittedDensity(barRef, hasPageSwitcher);
187
+ let t6;
188
+ if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
189
+ t6 = /* @__PURE__ */ jsxs("svg", {
190
+ className: AppShell_module_default["main-logo-word"],
191
+ viewBox: "0 0 478.51 100",
192
+ xmlns: "http://www.w3.org/2000/svg",
193
+ fill: "currentColor",
194
+ "aria-hidden": "true",
195
+ children: [
196
+ /* @__PURE__ */ jsx("path", { d: "m52 25v-25h-27v25h-15.9l-9.1 25h25v50h28.35c5.25 0 9.95-3.29 11.75-8.22l5.46-15.01s.64-1.76 2.52-1.76h39.62l9.1-25h-32.75c-5.25 0-9.95 3.29-11.75 8.22l-5.46 15.01s-.64 1.76-2.52 1.76h-17.33v-25h19.55c5.25 0 9.95-3.29 11.75-8.22l5.46-15.01s.64-1.76 2.52-1.76h44.62l9.11-25.01h-37.75c-5.25 0-9.95 3.29-11.75 8.22l-5.46 15.01s-.64 1.76-2.52 1.76h-35.53z" }),
197
+ /* @__PURE__ */ jsx("path", { d: "m214.81 66.3-2.12 5.83c-.63 1.72-2.26 2.86-4.09 2.86h-9.26c-2.4 0-4.34-1.94-4.34-4.34v-27.5h-6.49v-7.17h6.49v-11h10.71v11h7.85v7.17h-7.85v23.14h9.1z" }),
198
+ /* @__PURE__ */ jsx("path", { d: "m370.25 28.7h-7.39v7.3h7.39v7.17h-7.39v31.84h-10.71v-31.84h-6.49v-7.17h6.49v-11.66c0-2.4 1.94-4.34 4.34-4.34h16.93l-3.16 8.7z" }),
199
+ /* @__PURE__ */ jsx("path", { d: "m218.99 30v-10h10.71v10zm10.71 6v39h-10.71v-39z" }),
200
+ /* @__PURE__ */ jsx("path", { d: "m248.56 36v5.28h.15c1.41-2.01 3.1-3.57 5.09-4.68s4.26-1.66 6.83-1.66 4.72.48 6.75 1.43c2.04.96 3.58 2.64 4.64 5.05 1.16-1.71 2.73-3.22 4.72-4.53s4.34-1.96 7.05-1.96c2.06 0 3.97.25 5.73.76 1.76.5 3.27 1.31 4.53 2.41 1.26 1.11 2.24 2.55 2.94 4.34s1.06 3.94 1.06 6.45v26.1h-10.71v-22.1c0-1.31-.05-2.54-.15-3.7s-.38-2.16-.83-3.02c-.45-.85-1.12-1.53-2-2.04-.88-.5-2.08-.75-3.58-.75s-2.73.29-3.66.87-1.66 1.33-2.19 2.26-.88 1.99-1.06 3.17-.26 2.38-.26 3.58v21.73h-10.71v-21.88c0-1.16-.03-2.3-.08-3.43s-.26-2.17-.64-3.13c-.38-.95-1.01-1.72-1.89-2.3s-2.18-.87-3.89-.87c-.5 0-1.17.11-2 .34s-1.63.65-2.41 1.28-1.45 1.53-2 2.71-.83 2.73-.83 4.64v22.63h-10.71v-39h10.11z" }),
201
+ /* @__PURE__ */ jsx("path", { d: "m317.97 65.64c1.61 1.56 3.92 2.34 6.94 2.34 2.16 0 4.02-.54 5.58-1.62s2.51-2.22 2.87-3.43h9.43c-1.51 4.68-3.82 8.02-6.94 10.03s-6.89 3.02-11.32 3.02c-3.07 0-5.84-.49-8.3-1.47-2.47-.98-4.55-2.38-6.26-4.19s-3.03-3.97-3.96-6.49c-.93-2.51-1.4-5.28-1.4-8.3s.48-5.63 1.43-8.15c.95-2.51 2.31-4.69 4.07-6.53 1.76-1.83 3.86-3.28 6.3-4.34s5.14-1.59 8.11-1.59c3.32 0 6.21.64 8.68 1.92 2.46 1.28 4.49 3.01 6.07 5.17s2.73 4.63 3.43 7.39c.7 2.77.95 5.66.75 8.68h-28.14c.15 3.47 1.03 5.99 2.64 7.54zm12.11-20.52c-1.28-1.41-3.23-2.11-5.85-2.11-1.71 0-3.13.29-4.26.87s-2.04 1.3-2.72 2.15c-.68.86-1.16 1.76-1.43 2.72-.28.96-.44 1.81-.49 2.57h17.43c-.5-2.72-1.4-4.78-2.68-6.19z" }),
202
+ /* @__PURE__ */ jsx("path", { d: "m375.16 47.05c.95-2.54 2.31-4.7 4.07-6.49s3.87-3.17 6.34-4.15c2.46-.98 5.23-1.47 8.3-1.47s5.85.49 8.34 1.47 4.61 2.36 6.37 4.15 3.12 3.95 4.07 6.49 1.43 5.37 1.43 8.49-.48 5.94-1.43 8.45c-.96 2.51-2.31 4.66-4.07 6.45s-3.89 3.16-6.37 4.11c-2.49.96-5.27 1.43-8.34 1.43s-5.84-.48-8.3-1.43c-2.47-.95-4.58-2.33-6.34-4.11-1.76-1.79-3.12-3.94-4.07-6.45-.96-2.51-1.43-5.33-1.43-8.45s.48-5.95 1.43-8.49zm9.73 13.05c.3 1.48.82 2.82 1.55 4s1.7 2.13 2.9 2.83c1.21.7 2.72 1.06 4.53 1.06s3.33-.35 4.56-1.06c1.23-.7 2.21-1.65 2.94-2.83s1.24-2.51 1.55-4c.3-1.48.45-3 .45-4.57s-.15-3.09-.45-4.6-.82-2.84-1.55-4-1.71-2.1-2.94-2.83-2.75-1.09-4.56-1.09-3.32.37-4.53 1.09c-1.21.73-2.18 1.67-2.9 2.83-.73 1.16-1.25 2.49-1.55 4s-.45 3.04-.45 4.6.15 3.08.45 4.57z" }),
203
+ /* @__PURE__ */ jsx("path", { d: "m432.04 20v55h-10.71v-55z" }),
204
+ /* @__PURE__ */ jsx("path", { d: "m468.18 70.02c-1.26 2.11-2.9 3.63-4.94 4.56s-4.34 1.4-6.9 1.4c-2.92 0-5.48-.57-7.69-1.7s-4.04-2.66-5.47-4.6-2.52-4.16-3.24-6.68c-.73-2.51-1.09-5.13-1.09-7.85s.36-5.14 1.09-7.58 1.81-4.59 3.24-6.45 3.23-3.36 5.39-4.49 4.68-1.7 7.54-1.7c2.31 0 4.51.49 6.6 1.47s3.73 2.43 4.94 4.34h.15v-20.75h10.71v55h-10.18v-4.98h-.15zm-.45-19.28c-.3-1.48-.82-2.79-1.55-3.92s-1.67-2.05-2.83-2.75-2.62-1.06-4.38-1.06-3.24.35-4.45 1.06-2.18 1.63-2.9 2.79c-.73 1.16-1.26 2.48-1.58 3.96-.33 1.48-.49 3.03-.49 4.64 0 1.51.18 3.02.53 4.53s.92 2.86 1.7 4.04 1.76 2.14 2.94 2.87 2.6 1.09 4.26 1.09c1.76 0 3.23-.35 4.41-1.06 1.18-.7 2.12-1.65 2.83-2.83.7-1.18 1.21-2.53 1.51-4.04s.45-3.07.45-4.68-.15-3.16-.45-4.64z" })
205
+ ]
206
+ });
207
+ $[10] = t6;
208
+ } else t6 = $[10];
209
+ let t7;
210
+ if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
211
+ t7 = /* @__PURE__ */ jsxs("div", {
212
+ className: AppShell_module_default["main-logo"],
213
+ children: [t6, /* @__PURE__ */ jsx("svg", {
214
+ className: AppShell_module_default["main-logo-mark"],
215
+ viewBox: "0 0 145 100",
216
+ xmlns: "http://www.w3.org/2000/svg",
217
+ fill: "currentColor",
218
+ "aria-hidden": "true",
219
+ children: /* @__PURE__ */ jsx("path", { d: "m52 25v-25h-27v25h-15.9l-9.1 25h25v50h28.35c5.25 0 9.95-3.29 11.75-8.22l5.46-15.01s.64-1.76 2.52-1.76h39.62l9.1-25h-32.75c-5.25 0-9.95 3.29-11.75 8.22l-5.46 15.01s-.64 1.76-2.52 1.76h-17.33v-25h19.55c5.25 0 9.95-3.29 11.75-8.22l5.46-15.01s.64-1.76 2.52-1.76h44.62l9.11-25.01h-37.75c-5.25 0-9.95 3.29-11.75 8.22l-5.46 15.01s-.64 1.76-2.52 1.76h-35.53z" })
220
+ })]
221
+ });
222
+ $[11] = t7;
223
+ } else t7 = $[11];
224
+ let t8;
225
+ if ($[12] !== logo || $[13] !== title) {
226
+ t8 = logo && /* @__PURE__ */ jsx("img", {
227
+ src: logo,
228
+ alt: title
229
+ });
230
+ $[12] = logo;
231
+ $[13] = title;
232
+ $[14] = t8;
233
+ } else t8 = $[14];
234
+ const t9 = logo ? true : void 0;
235
+ let t10;
236
+ if ($[15] !== t9 || $[16] !== title) {
237
+ t10 = /* @__PURE__ */ jsx("span", {
238
+ "aria-hidden": t9,
239
+ "data-slot": "app-shell-nav-model-name",
240
+ className: AppShell_module_default["main-nav-model-name"],
241
+ children: title
242
+ });
243
+ $[15] = t9;
244
+ $[16] = title;
245
+ $[17] = t10;
246
+ } else t10 = $[17];
247
+ let t11;
248
+ if ($[18] !== t10 || $[19] !== t8) {
249
+ t11 = /* @__PURE__ */ jsxs("div", {
250
+ "data-slot": "app-shell-nav-model",
251
+ className: AppShell_module_default["main-nav-model"],
252
+ children: [t8, t10]
253
+ });
254
+ $[18] = t10;
255
+ $[19] = t8;
256
+ $[20] = t11;
257
+ } else t11 = $[20];
258
+ let t12;
259
+ if ($[21] !== currentPage || $[22] !== hasPageSwitcher || $[23] !== pageMenu) {
260
+ t12 = hasPageSwitcher && /* @__PURE__ */ jsx("div", {
261
+ className: AppShell_module_default["main-nav-view"],
262
+ children: /* @__PURE__ */ jsx(MenuButton, {
263
+ label: currentPage ? getAppShellPageLabel(currentPage) : "Select Page",
264
+ ...pageMenu
265
+ })
266
+ });
267
+ $[21] = currentPage;
268
+ $[22] = hasPageSwitcher;
269
+ $[23] = pageMenu;
270
+ $[24] = t12;
271
+ } else t12 = $[24];
272
+ let t13;
273
+ if ($[25] !== score) {
274
+ t13 = /* @__PURE__ */ jsx(ScoreBox, { score });
275
+ $[25] = score;
276
+ $[26] = t13;
277
+ } else t13 = $[26];
278
+ let t14;
279
+ if ($[27] !== action || $[28] !== demo || $[29] !== hasPageSwitcher || $[30] !== pageMenu) {
280
+ t14 = demo && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
281
+ className: AppShell_module_default["main-nav-data"],
282
+ children: /* @__PURE__ */ jsxs("div", {
283
+ className: "flex items-center gap-2",
284
+ children: [/* @__PURE__ */ jsx(DemoDataPicker, { ...demo }), action && /* @__PURE__ */ jsx(Button, {
285
+ variant: "soft",
286
+ leadingIcon: action.icon,
287
+ disabled: action.disabled,
288
+ onClick: action.onClick,
289
+ children: action.label
290
+ })]
291
+ })
292
+ }), /* @__PURE__ */ jsx(OverflowMenu, {
293
+ pageMenu: hasPageSwitcher ? pageMenu : void 0,
294
+ demo,
295
+ action
296
+ })] });
297
+ $[27] = action;
298
+ $[28] = demo;
299
+ $[29] = hasPageSwitcher;
300
+ $[30] = pageMenu;
301
+ $[31] = t14;
302
+ } else t14 = $[31];
303
+ let t15;
304
+ if ($[32] === Symbol.for("react.memo_cache_sentinel")) {
305
+ t15 = /* @__PURE__ */ jsx("div", {
306
+ className: AppShell_module_default["main-nav-theme"],
307
+ children: /* @__PURE__ */ jsx(ColorSchemeMenu, {})
308
+ });
309
+ $[32] = t15;
310
+ } else t15 = $[32];
311
+ let t16;
312
+ if ($[33] !== solve || $[34] !== t13 || $[35] !== t14) {
313
+ t16 = /* @__PURE__ */ jsxs("div", {
314
+ className: AppShell_module_default["main-nav-right"],
315
+ children: [
316
+ t13,
317
+ solve,
318
+ t14,
319
+ t15
320
+ ]
321
+ });
322
+ $[33] = solve;
323
+ $[34] = t13;
324
+ $[35] = t14;
325
+ $[36] = t16;
326
+ } else t16 = $[36];
327
+ let t17;
328
+ if ($[37] !== t11 || $[38] !== t12 || $[39] !== t16) {
329
+ t17 = /* @__PURE__ */ jsx("nav", { children: /* @__PURE__ */ jsxs("div", {
330
+ ref: barRef,
331
+ "data-slot": "app-shell-nav-content",
332
+ className: AppShell_module_default["main-nav-content"],
333
+ children: [
334
+ t7,
335
+ t11,
336
+ t12,
337
+ t16
338
+ ]
339
+ }) });
340
+ $[37] = t11;
341
+ $[38] = t12;
342
+ $[39] = t16;
343
+ $[40] = t17;
344
+ } else t17 = $[40];
345
+ return t17;
346
+ }
347
+ function LoadErrorToast(t0) {
348
+ const $ = c(4);
349
+ const { error } = t0;
350
+ const { show } = useToast();
351
+ let t1;
352
+ let t2;
353
+ if ($[0] !== error || $[1] !== show) {
354
+ t1 = () => {
355
+ show(error, { state: "negative" });
356
+ };
357
+ t2 = [error, show];
358
+ $[0] = error;
359
+ $[1] = show;
360
+ $[2] = t1;
361
+ $[3] = t2;
362
+ } else {
363
+ t1 = $[2];
364
+ t2 = $[3];
365
+ }
366
+ useEffect(t1, t2);
367
+ return null;
368
+ }
369
+ function VisitedPages(t0) {
370
+ const $ = c(7);
371
+ const { pages, currentKey } = t0;
372
+ const [visitedKeys, setVisitedKeys] = useState(_temp);
373
+ if (currentKey !== void 0 && !visitedKeys.has(currentKey)) setVisitedKeys(new Set(visitedKeys).add(currentKey));
374
+ let t1;
375
+ if ($[0] !== currentKey || $[1] !== pages || $[2] !== visitedKeys) {
376
+ let t2;
377
+ if ($[4] !== currentKey || $[5] !== visitedKeys) {
378
+ t2 = (page) => visitedKeys.has(page.value) ? /* @__PURE__ */ jsx(Activity, {
379
+ mode: page.value === currentKey ? "visible" : "hidden",
380
+ children: /* @__PURE__ */ jsx(PageFrame, { children: page.content })
381
+ }, page.value) : null;
382
+ $[4] = currentKey;
383
+ $[5] = visitedKeys;
384
+ $[6] = t2;
385
+ } else t2 = $[6];
386
+ t1 = pages.map(t2);
387
+ $[0] = currentKey;
388
+ $[1] = pages;
389
+ $[2] = visitedKeys;
390
+ $[3] = t1;
391
+ } else t1 = $[3];
392
+ return t1;
393
+ }
394
+ function _temp() {
395
+ return /* @__PURE__ */ new Set();
396
+ }
397
+ export { AppShell as default };
@@ -0,0 +1,16 @@
1
+ import './AppShell.css';
2
+ // src/layout/AppShell.module.css
3
+ var AppShell_module_default = {
4
+ "main-logo": "pYC0na_main-logo",
5
+ "main-logo-mark": "pYC0na_main-logo-mark",
6
+ "main-logo-word": "pYC0na_main-logo-word",
7
+ "main-nav-content": "pYC0na_main-nav-content",
8
+ "main-nav-data": "pYC0na_main-nav-data",
9
+ "main-nav-model": "pYC0na_main-nav-model",
10
+ "main-nav-model-name": "pYC0na_main-nav-model-name",
11
+ "main-nav-overflow": "pYC0na_main-nav-overflow",
12
+ "main-nav-right": "pYC0na_main-nav-right",
13
+ "main-nav-theme": "pYC0na_main-nav-theme",
14
+ "main-nav-view": "pYC0na_main-nav-view"
15
+ };
16
+ export { AppShell_module_default as default };
@@ -0,0 +1,14 @@
1
+ import { MenuButtonMenu } from "../input/MenuButton.mjs";
2
+ import { ColorSchemePreference } from "../theme/use-color-scheme.mjs";
3
+ /**
4
+ * The color-scheme options as a `MenuButton` menu, so the standalone toolbar
5
+ * offers exactly one route to the scheme at any width.
6
+ */
7
+ export declare function useColorSchemeMenu(): MenuButtonMenu & {
8
+ preference: ColorSchemePreference;
9
+ };
10
+ /**
11
+ * The standalone toolbar's color-scheme switch: an icon trigger, an icon and
12
+ * wording per mode, and a check on the active one.
13
+ */
14
+ export default function ColorSchemeMenu(): import("react").JSX.Element;
@@ -0,0 +1,92 @@
1
+ "use client";
2
+ import MenuButton from "../input/MenuButton.mjs";
3
+ import { useColorScheme } from "../theme/use-color-scheme.mjs";
4
+ import { c } from "react/compiler-runtime";
5
+ import { jsx } from "react/jsx-runtime";
6
+ import "../vendor/components.mjs";
7
+ import { TbDeviceDesktop, TbMoon, TbSun } from "react-icons/tb";
8
+ // src/layout/ColorSchemeMenu.tsx
9
+ const COLOR_SCHEMES = {
10
+ light: {
11
+ label: "Light mode",
12
+ icon: TbSun
13
+ },
14
+ dark: {
15
+ label: "Dark mode",
16
+ icon: TbMoon
17
+ },
18
+ system: {
19
+ label: "System default",
20
+ icon: TbDeviceDesktop
21
+ }
22
+ };
23
+ /**
24
+ * The color-scheme options as a `MenuButton` menu, so the standalone toolbar
25
+ * offers exactly one route to the scheme at any width.
26
+ */
27
+ function useColorSchemeMenu() {
28
+ const $ = c(6);
29
+ const { preference, setPreference } = useColorScheme();
30
+ let t0;
31
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
32
+ t0 = Object.keys(COLOR_SCHEMES);
33
+ $[0] = t0;
34
+ } else t0 = $[0];
35
+ let t1;
36
+ if ($[1] !== setPreference) {
37
+ t1 = [{ options: t0.map((value) => ({
38
+ value,
39
+ ...COLOR_SCHEMES[value],
40
+ onSelect: () => {
41
+ setPreference(value);
42
+ }
43
+ })) }];
44
+ $[1] = setPreference;
45
+ $[2] = t1;
46
+ } else t1 = $[2];
47
+ let t2;
48
+ if ($[3] !== preference || $[4] !== t1) {
49
+ t2 = {
50
+ preference,
51
+ selectedValue: preference,
52
+ sections: t1
53
+ };
54
+ $[3] = preference;
55
+ $[4] = t1;
56
+ $[5] = t2;
57
+ } else t2 = $[5];
58
+ return t2;
59
+ }
60
+ /**
61
+ * The standalone toolbar's color-scheme switch: an icon trigger, an icon and
62
+ * wording per mode, and a check on the active one.
63
+ */
64
+ function ColorSchemeMenu() {
65
+ const $ = c(6);
66
+ const t0 = useColorSchemeMenu();
67
+ let menu;
68
+ let preference;
69
+ if ($[0] !== t0) {
70
+ ({preference, ...menu} = t0);
71
+ $[0] = t0;
72
+ $[1] = menu;
73
+ $[2] = preference;
74
+ } else {
75
+ menu = $[1];
76
+ preference = $[2];
77
+ }
78
+ const t1 = COLOR_SCHEMES[preference];
79
+ let t2;
80
+ if ($[3] !== menu || $[4] !== t1.icon) {
81
+ t2 = /* @__PURE__ */ jsx(MenuButton, {
82
+ label: "Color scheme",
83
+ soloIcon: t1.icon,
84
+ ...menu
85
+ });
86
+ $[3] = menu;
87
+ $[4] = t1.icon;
88
+ $[5] = t2;
89
+ } else t2 = $[5];
90
+ return t2;
91
+ }
92
+ export { ColorSchemeMenu as default, useColorSchemeMenu };
@@ -0,0 +1,17 @@
1
+ import { MenuButtonMenu } from "../input/MenuButton.mjs";
2
+ import { AppShellDemoData } from "./AppShell.mjs";
3
+ /**
4
+ * The demo-data options as a `MenuButton` menu, with the hidden file input that
5
+ * its Import option opens. Render `fileInput` beside the menu.
6
+ */
7
+ export declare function useDemoDataMenu({ demoDataSets, importError, loadDataSet, importFile }: AppShellDemoData): {
8
+ menu: MenuButtonMenu;
9
+ fileInput: React.ReactElement;
10
+ };
11
+ /**
12
+ * Demo-data picker: dropdown of available demo datasets plus a file-import
13
+ * option. Presentational only — fetch/import/validation lives in `useDemoData`.
14
+ *
15
+ * @see https://www.w3.org/WAI/ARIA/apg/patterns/menu-button/
16
+ */
17
+ export default function DemoDataPicker(demo: AppShellDemoData): import("react").JSX.Element;
@@ -0,0 +1,150 @@
1
+ "use client";
2
+ import MenuButton from "../input/MenuButton.mjs";
3
+ import { useToast } from "../toast/ToastProvider.mjs";
4
+ import { c } from "react/compiler-runtime";
5
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
+ import { useEffect, useRef } from "react";
7
+ import { TbFileImport } from "react-icons/tb";
8
+ // src/layout/DemoDataPicker.tsx
9
+ /**
10
+ * The demo-data options as a `MenuButton` menu, with the hidden file input that
11
+ * its Import option opens. Render `fileInput` beside the menu.
12
+ */
13
+ function useDemoDataMenu(t0) {
14
+ const $ = c(15);
15
+ const { demoDataSets, importError, loadDataSet, importFile } = t0;
16
+ const fileInputRef = useRef(null);
17
+ let t1;
18
+ if ($[0] !== demoDataSets || $[1] !== importError || $[2] !== loadDataSet) {
19
+ t1 = demoDataSets ? demoDataSets.map((t2) => {
20
+ const { id } = t2;
21
+ return {
22
+ value: id,
23
+ label: id,
24
+ onSelect: () => {
25
+ loadDataSet(id);
26
+ }
27
+ };
28
+ }) : [{
29
+ value: "loading",
30
+ label: importError ? "Demo data unavailable" : "Loading…",
31
+ disabled: true
32
+ }];
33
+ $[0] = demoDataSets;
34
+ $[1] = importError;
35
+ $[2] = loadDataSet;
36
+ $[3] = t1;
37
+ } else t1 = $[3];
38
+ let t2;
39
+ if ($[4] !== t1) {
40
+ t2 = { options: t1 };
41
+ $[4] = t1;
42
+ $[5] = t2;
43
+ } else t2 = $[5];
44
+ let t3;
45
+ if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
46
+ t3 = { options: [{
47
+ value: "import",
48
+ label: "Import",
49
+ icon: TbFileImport,
50
+ onSelect: () => {
51
+ fileInputRef.current?.click();
52
+ }
53
+ }] };
54
+ $[6] = t3;
55
+ } else t3 = $[6];
56
+ let t4;
57
+ if ($[7] !== t2) {
58
+ t4 = { sections: [t2, t3] };
59
+ $[7] = t2;
60
+ $[8] = t4;
61
+ } else t4 = $[8];
62
+ let t5;
63
+ if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
64
+ t5 = { display: "none" };
65
+ $[9] = t5;
66
+ } else t5 = $[9];
67
+ let t6;
68
+ if ($[10] !== importFile) {
69
+ t6 = /* @__PURE__ */ jsx("input", {
70
+ ref: fileInputRef,
71
+ type: "file",
72
+ accept: "application/json,.json",
73
+ style: t5,
74
+ onChange: (e) => {
75
+ const file = e.target.files?.[0];
76
+ if (file) importFile(file);
77
+ e.target.value = "";
78
+ }
79
+ });
80
+ $[10] = importFile;
81
+ $[11] = t6;
82
+ } else t6 = $[11];
83
+ let t7;
84
+ if ($[12] !== t4 || $[13] !== t6) {
85
+ t7 = {
86
+ menu: t4,
87
+ fileInput: t6
88
+ };
89
+ $[12] = t4;
90
+ $[13] = t6;
91
+ $[14] = t7;
92
+ } else t7 = $[14];
93
+ return t7;
94
+ }
95
+ /**
96
+ * Demo-data picker: dropdown of available demo datasets plus a file-import
97
+ * option. Presentational only — fetch/import/validation lives in `useDemoData`.
98
+ *
99
+ * @see https://www.w3.org/WAI/ARIA/apg/patterns/menu-button/
100
+ */
101
+ function DemoDataPicker(demo) {
102
+ const $ = c(12);
103
+ const { menu, fileInput } = useDemoDataMenu(demo);
104
+ const { show } = useToast();
105
+ const { importError } = demo;
106
+ let t0;
107
+ let t1;
108
+ if ($[0] !== importError || $[1] !== show) {
109
+ t0 = () => {
110
+ if (importError) show(importError.message, { state: "negative" });
111
+ };
112
+ t1 = [importError, show];
113
+ $[0] = importError;
114
+ $[1] = show;
115
+ $[2] = t0;
116
+ $[3] = t1;
117
+ } else {
118
+ t0 = $[2];
119
+ t1 = $[3];
120
+ }
121
+ useEffect(t0, t1);
122
+ let t2;
123
+ if ($[4] !== demo.label) {
124
+ t2 = /* @__PURE__ */ jsx("span", {
125
+ className: "block max-w-40 truncate",
126
+ children: demo.label
127
+ });
128
+ $[4] = demo.label;
129
+ $[5] = t2;
130
+ } else t2 = $[5];
131
+ let t3;
132
+ if ($[6] !== menu || $[7] !== t2) {
133
+ t3 = /* @__PURE__ */ jsx(MenuButton, {
134
+ label: t2,
135
+ ...menu
136
+ });
137
+ $[6] = menu;
138
+ $[7] = t2;
139
+ $[8] = t3;
140
+ } else t3 = $[8];
141
+ let t4;
142
+ if ($[9] !== fileInput || $[10] !== t3) {
143
+ t4 = /* @__PURE__ */ jsxs(Fragment, { children: [fileInput, t3] });
144
+ $[9] = fileInput;
145
+ $[10] = t3;
146
+ $[11] = t4;
147
+ } else t4 = $[11];
148
+ return t4;
149
+ }
150
+ export { DemoDataPicker as default, useDemoDataMenu };
@@ -0,0 +1,11 @@
1
+ import { MenuButtonMenu } from "../input/MenuButton.mjs";
2
+ import { AppShellDemoData, AppShellToolbarAction } from "./AppShell.mjs";
3
+ /**
4
+ * Narrow-viewport overflow: folds the page switcher, the data picker and the
5
+ * colour-scheme switch into a single "more" menu, each as its own submenu.
6
+ */
7
+ export default function OverflowMenu({ pageMenu, demo, action }: {
8
+ pageMenu?: MenuButtonMenu;
9
+ demo: AppShellDemoData;
10
+ action?: AppShellToolbarAction;
11
+ }): import("react").JSX.Element;