@siiway/ui-react 0.0.0 → 0.2.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 (258) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +19 -1
  3. package/dist/components/AppShell.d.ts +29 -0
  4. package/dist/components/AppShell.d.ts.map +1 -0
  5. package/dist/components/AppShell.js +220 -0
  6. package/dist/components/AppShell.js.map +1 -0
  7. package/dist/components/AuthShell.d.ts +21 -0
  8. package/dist/components/AuthShell.d.ts.map +1 -0
  9. package/dist/components/AuthShell.js +53 -0
  10. package/dist/components/AuthShell.js.map +1 -0
  11. package/dist/components/BrandMark.d.ts +11 -0
  12. package/dist/components/BrandMark.d.ts.map +1 -0
  13. package/dist/components/BrandMark.js +11 -0
  14. package/dist/components/BrandMark.js.map +1 -0
  15. package/dist/components/ButtonLink.d.ts +11 -0
  16. package/dist/components/ButtonLink.d.ts.map +1 -0
  17. package/dist/components/ButtonLink.js +15 -0
  18. package/dist/components/ButtonLink.js.map +1 -0
  19. package/dist/components/CheckboxField.d.ts +15 -0
  20. package/dist/components/CheckboxField.d.ts.map +1 -0
  21. package/dist/components/CheckboxField.js +23 -0
  22. package/dist/components/CheckboxField.js.map +1 -0
  23. package/dist/components/ColorPickerInput.d.ts +17 -0
  24. package/dist/components/ColorPickerInput.d.ts.map +1 -0
  25. package/dist/components/ColorPickerInput.js +97 -0
  26. package/dist/components/ColorPickerInput.js.map +1 -0
  27. package/dist/components/CommandPalette.d.ts +65 -0
  28. package/dist/components/CommandPalette.d.ts.map +1 -0
  29. package/dist/components/CommandPalette.js +269 -0
  30. package/dist/components/CommandPalette.js.map +1 -0
  31. package/dist/components/CopyButton.d.ts +27 -0
  32. package/dist/components/CopyButton.d.ts.map +1 -0
  33. package/dist/components/CopyButton.js +20 -0
  34. package/dist/components/CopyButton.js.map +1 -0
  35. package/dist/components/CopyIdTrigger.d.ts +31 -0
  36. package/dist/components/CopyIdTrigger.d.ts.map +1 -0
  37. package/dist/components/CopyIdTrigger.js +72 -0
  38. package/dist/components/CopyIdTrigger.js.map +1 -0
  39. package/dist/components/DataList.d.ts +78 -0
  40. package/dist/components/DataList.d.ts.map +1 -0
  41. package/dist/components/DataList.js +150 -0
  42. package/dist/components/DataList.js.map +1 -0
  43. package/dist/components/DetailHeader.d.ts +26 -0
  44. package/dist/components/DetailHeader.d.ts.map +1 -0
  45. package/dist/components/DetailHeader.js +49 -0
  46. package/dist/components/DetailHeader.js.map +1 -0
  47. package/dist/components/DurationInput.d.ts +25 -0
  48. package/dist/components/DurationInput.d.ts.map +1 -0
  49. package/dist/components/DurationInput.js +83 -0
  50. package/dist/components/DurationInput.js.map +1 -0
  51. package/dist/components/EmptyState.d.ts +14 -0
  52. package/dist/components/EmptyState.d.ts.map +1 -0
  53. package/dist/components/EmptyState.js +41 -0
  54. package/dist/components/EmptyState.js.map +1 -0
  55. package/dist/components/FormPage.d.ts +22 -0
  56. package/dist/components/FormPage.d.ts.map +1 -0
  57. package/dist/components/FormPage.js +65 -0
  58. package/dist/components/FormPage.js.map +1 -0
  59. package/dist/components/GetStartedPanel.d.ts +16 -0
  60. package/dist/components/GetStartedPanel.d.ts.map +1 -0
  61. package/dist/components/GetStartedPanel.js +96 -0
  62. package/dist/components/GetStartedPanel.js.map +1 -0
  63. package/dist/components/LabeledLine.d.ts +12 -0
  64. package/dist/components/LabeledLine.d.ts.map +1 -0
  65. package/dist/components/LabeledLine.js +6 -0
  66. package/dist/components/LabeledLine.js.map +1 -0
  67. package/dist/components/ListSearch.d.ts +15 -0
  68. package/dist/components/ListSearch.d.ts.map +1 -0
  69. package/dist/components/ListSearch.js +23 -0
  70. package/dist/components/ListSearch.js.map +1 -0
  71. package/dist/components/LoadingBar.d.ts +8 -0
  72. package/dist/components/LoadingBar.d.ts.map +1 -0
  73. package/dist/components/LoadingBar.js +55 -0
  74. package/dist/components/LoadingBar.js.map +1 -0
  75. package/dist/components/LoadingPage.d.ts +6 -0
  76. package/dist/components/LoadingPage.d.ts.map +1 -0
  77. package/dist/components/LoadingPage.js +25 -0
  78. package/dist/components/LoadingPage.js.map +1 -0
  79. package/dist/components/MenuPanel.d.ts +34 -0
  80. package/dist/components/MenuPanel.d.ts.map +1 -0
  81. package/dist/components/MenuPanel.js +98 -0
  82. package/dist/components/MenuPanel.js.map +1 -0
  83. package/dist/components/Outline.d.ts +23 -0
  84. package/dist/components/Outline.d.ts.map +1 -0
  85. package/dist/components/Outline.js +150 -0
  86. package/dist/components/Outline.js.map +1 -0
  87. package/dist/components/Overview.d.ts +103 -0
  88. package/dist/components/Overview.d.ts.map +1 -0
  89. package/dist/components/Overview.js +286 -0
  90. package/dist/components/Overview.js.map +1 -0
  91. package/dist/components/PageHeader.d.ts +19 -0
  92. package/dist/components/PageHeader.d.ts.map +1 -0
  93. package/dist/components/PageHeader.js +41 -0
  94. package/dist/components/PageHeader.js.map +1 -0
  95. package/dist/components/Pagination.d.ts +19 -0
  96. package/dist/components/Pagination.d.ts.map +1 -0
  97. package/dist/components/Pagination.js +47 -0
  98. package/dist/components/Pagination.js.map +1 -0
  99. package/dist/components/PasswordInput.d.ts +3 -0
  100. package/dist/components/PasswordInput.d.ts.map +1 -0
  101. package/dist/components/PasswordInput.js +29 -0
  102. package/dist/components/PasswordInput.js.map +1 -0
  103. package/dist/components/PrevNext.d.ts +16 -0
  104. package/dist/components/PrevNext.d.ts.map +1 -0
  105. package/dist/components/PrevNext.js +61 -0
  106. package/dist/components/PrevNext.js.map +1 -0
  107. package/dist/components/SearchButton.d.ts +16 -0
  108. package/dist/components/SearchButton.d.ts.map +1 -0
  109. package/dist/components/SearchButton.js +63 -0
  110. package/dist/components/SearchButton.js.map +1 -0
  111. package/dist/components/SearchField.d.ts +10 -0
  112. package/dist/components/SearchField.d.ts.map +1 -0
  113. package/dist/components/SearchField.js +67 -0
  114. package/dist/components/SearchField.js.map +1 -0
  115. package/dist/components/Segmented.d.ts +28 -0
  116. package/dist/components/Segmented.d.ts.map +1 -0
  117. package/dist/components/Segmented.js +74 -0
  118. package/dist/components/Segmented.js.map +1 -0
  119. package/dist/components/Select.d.ts +22 -0
  120. package/dist/components/Select.d.ts.map +1 -0
  121. package/dist/components/Select.js +50 -0
  122. package/dist/components/Select.js.map +1 -0
  123. package/dist/components/Settings.d.ts +103 -0
  124. package/dist/components/Settings.d.ts.map +1 -0
  125. package/dist/components/Settings.js +246 -0
  126. package/dist/components/Settings.js.map +1 -0
  127. package/dist/components/SideNav.d.ts +47 -0
  128. package/dist/components/SideNav.d.ts.map +1 -0
  129. package/dist/components/SideNav.js +125 -0
  130. package/dist/components/SideNav.js.map +1 -0
  131. package/dist/components/Skeletons.d.ts +37 -0
  132. package/dist/components/Skeletons.d.ts.map +1 -0
  133. package/dist/components/Skeletons.js +109 -0
  134. package/dist/components/Skeletons.js.map +1 -0
  135. package/dist/components/StatusPage.d.ts +49 -0
  136. package/dist/components/StatusPage.d.ts.map +1 -0
  137. package/dist/components/StatusPage.js +110 -0
  138. package/dist/components/StatusPage.js.map +1 -0
  139. package/dist/components/ThemeMenu.d.ts +13 -0
  140. package/dist/components/ThemeMenu.d.ts.map +1 -0
  141. package/dist/components/ThemeMenu.js +18 -0
  142. package/dist/components/ThemeMenu.js.map +1 -0
  143. package/dist/components/ThemeSwitch.d.ts +17 -0
  144. package/dist/components/ThemeSwitch.d.ts.map +1 -0
  145. package/dist/components/ThemeSwitch.js +25 -0
  146. package/dist/components/ThemeSwitch.js.map +1 -0
  147. package/dist/components/TopBar.d.ts +49 -0
  148. package/dist/components/TopBar.d.ts.map +1 -0
  149. package/dist/components/TopBar.js +146 -0
  150. package/dist/components/TopBar.js.map +1 -0
  151. package/dist/components/ViewBanner.d.ts +17 -0
  152. package/dist/components/ViewBanner.d.ts.map +1 -0
  153. package/dist/components/ViewBanner.js +14 -0
  154. package/dist/components/ViewBanner.js.map +1 -0
  155. package/dist/hooks/platform.d.ts +7 -0
  156. package/dist/hooks/platform.d.ts.map +1 -0
  157. package/dist/hooks/platform.js +19 -0
  158. package/dist/hooks/platform.js.map +1 -0
  159. package/dist/hooks/useConfirm.d.ts +23 -0
  160. package/dist/hooks/useConfirm.d.ts.map +1 -0
  161. package/dist/hooks/useConfirm.js +55 -0
  162. package/dist/hooks/useConfirm.js.map +1 -0
  163. package/dist/hooks/useCopy.d.ts +12 -0
  164. package/dist/hooks/useCopy.d.ts.map +1 -0
  165. package/dist/hooks/useCopy.js +39 -0
  166. package/dist/hooks/useCopy.js.map +1 -0
  167. package/dist/hooks/useDebouncedSearch.d.ts +8 -0
  168. package/dist/hooks/useDebouncedSearch.d.ts.map +1 -0
  169. package/dist/hooks/useDebouncedSearch.js +19 -0
  170. package/dist/hooks/useDebouncedSearch.js.map +1 -0
  171. package/dist/hooks/usePageClamp.d.ts +4 -0
  172. package/dist/hooks/usePageClamp.d.ts.map +1 -0
  173. package/dist/hooks/usePageClamp.js +17 -0
  174. package/dist/hooks/usePageClamp.js.map +1 -0
  175. package/dist/hooks/useSearchShortcut.d.ts +8 -0
  176. package/dist/hooks/useSearchShortcut.d.ts.map +1 -0
  177. package/dist/hooks/useSearchShortcut.js +38 -0
  178. package/dist/hooks/useSearchShortcut.js.map +1 -0
  179. package/dist/hooks/useThemeMode.d.ts +29 -0
  180. package/dist/hooks/useThemeMode.d.ts.map +1 -0
  181. package/dist/hooks/useThemeMode.js +111 -0
  182. package/dist/hooks/useThemeMode.js.map +1 -0
  183. package/dist/hooks/useToastMessage.d.ts +22 -0
  184. package/dist/hooks/useToastMessage.d.ts.map +1 -0
  185. package/dist/hooks/useToastMessage.js +26 -0
  186. package/dist/hooks/useToastMessage.js.map +1 -0
  187. package/dist/index.d.ts +50 -0
  188. package/dist/index.d.ts.map +1 -0
  189. package/dist/index.js +60 -0
  190. package/dist/index.js.map +1 -0
  191. package/dist/provider/UiProvider.d.ts +60 -0
  192. package/dist/provider/UiProvider.d.ts.map +1 -0
  193. package/dist/provider/UiProvider.js +144 -0
  194. package/dist/provider/UiProvider.js.map +1 -0
  195. package/dist/provider/canvas.d.ts +7 -0
  196. package/dist/provider/canvas.d.ts.map +1 -0
  197. package/dist/provider/canvas.js +30 -0
  198. package/dist/provider/canvas.js.map +1 -0
  199. package/dist/provider/context.d.ts +69 -0
  200. package/dist/provider/context.d.ts.map +1 -0
  201. package/dist/provider/context.js +84 -0
  202. package/dist/provider/context.js.map +1 -0
  203. package/dist/theme/createTheme.d.ts +13 -0
  204. package/dist/theme/createTheme.d.ts.map +1 -0
  205. package/dist/theme/createTheme.js +18 -0
  206. package/dist/theme/createTheme.js.map +1 -0
  207. package/package.json +42 -2
  208. package/src/components/AppShell.tsx +337 -0
  209. package/src/components/AuthShell.tsx +104 -0
  210. package/src/components/BrandMark.tsx +28 -0
  211. package/src/components/ButtonLink.tsx +40 -0
  212. package/src/components/CheckboxField.tsx +50 -0
  213. package/src/components/ColorPickerInput.tsx +190 -0
  214. package/src/components/CommandPalette.tsx +479 -0
  215. package/src/components/CopyButton.tsx +76 -0
  216. package/src/components/CopyIdTrigger.tsx +127 -0
  217. package/src/components/DataList.tsx +332 -0
  218. package/src/components/DetailHeader.tsx +108 -0
  219. package/src/components/DurationInput.tsx +133 -0
  220. package/src/components/EmptyState.tsx +67 -0
  221. package/src/components/FormPage.tsx +109 -0
  222. package/src/components/GetStartedPanel.tsx +132 -0
  223. package/src/components/LabeledLine.tsx +28 -0
  224. package/src/components/ListSearch.tsx +64 -0
  225. package/src/components/LoadingBar.tsx +81 -0
  226. package/src/components/LoadingPage.tsx +41 -0
  227. package/src/components/MenuPanel.tsx +163 -0
  228. package/src/components/Outline.tsx +208 -0
  229. package/src/components/Overview.tsx +448 -0
  230. package/src/components/PageHeader.tsx +69 -0
  231. package/src/components/Pagination.tsx +105 -0
  232. package/src/components/PasswordInput.tsx +50 -0
  233. package/src/components/PrevNext.tsx +98 -0
  234. package/src/components/SearchButton.tsx +90 -0
  235. package/src/components/SearchField.tsx +97 -0
  236. package/src/components/Segmented.tsx +136 -0
  237. package/src/components/Select.tsx +110 -0
  238. package/src/components/Settings.tsx +432 -0
  239. package/src/components/SideNav.tsx +258 -0
  240. package/src/components/Skeletons.tsx +233 -0
  241. package/src/components/StatusPage.tsx +212 -0
  242. package/src/components/ThemeMenu.tsx +51 -0
  243. package/src/components/ThemeSwitch.tsx +49 -0
  244. package/src/components/TopBar.tsx +293 -0
  245. package/src/components/ViewBanner.tsx +51 -0
  246. package/src/hooks/platform.ts +22 -0
  247. package/src/hooks/useConfirm.tsx +97 -0
  248. package/src/hooks/useCopy.ts +39 -0
  249. package/src/hooks/useDebouncedSearch.ts +19 -0
  250. package/src/hooks/usePageClamp.ts +20 -0
  251. package/src/hooks/useSearchShortcut.ts +49 -0
  252. package/src/hooks/useThemeMode.ts +168 -0
  253. package/src/hooks/useToastMessage.ts +38 -0
  254. package/src/index.ts +156 -0
  255. package/src/provider/UiProvider.tsx +256 -0
  256. package/src/provider/canvas.ts +31 -0
  257. package/src/provider/context.tsx +145 -0
  258. package/src/theme/createTheme.ts +29 -0
package/dist/index.js ADDED
@@ -0,0 +1,60 @@
1
+ // Theme and provider
2
+ export { createTheme } from "./theme/createTheme.js";
3
+ export { UiProvider } from "./provider/UiProvider.js";
4
+ export { useCanvasClass } from "./provider/canvas.js";
5
+ export { DEFAULT_ROUTER, UiLink, useUiMatch, useUiNavigate, useUiPageTitle, useUiScheme, useUiThemeMode, useUiStrings, } from "./provider/context.js";
6
+ // Hooks
7
+ export { useConfirm } from "./hooks/useConfirm.js";
8
+ export { useCopy } from "./hooks/useCopy.js";
9
+ export { useDebouncedSearch } from "./hooks/useDebouncedSearch.js";
10
+ export { usePageClamp } from "./hooks/usePageClamp.js";
11
+ export { useSearchShortcut } from "./hooks/useSearchShortcut.js";
12
+ export { useThemeMode } from "./hooks/useThemeMode.js";
13
+ export { useToastMessage } from "./hooks/useToastMessage.js";
14
+ // Page structure
15
+ export { PageHeader } from "./components/PageHeader.js";
16
+ export { BackButton, DetailHeader } from "./components/DetailHeader.js";
17
+ export { FormPage } from "./components/FormPage.js";
18
+ export { StatusPage, } from "./components/StatusPage.js";
19
+ export { LoadingPage } from "./components/LoadingPage.js";
20
+ export { AuthShell } from "./components/AuthShell.js";
21
+ export { EmptyState } from "./components/EmptyState.js";
22
+ export { GetStartedPanel } from "./components/GetStartedPanel.js";
23
+ export { ViewBanner } from "./components/ViewBanner.js";
24
+ export { LabeledLine } from "./components/LabeledLine.js";
25
+ export { BrandMark } from "./components/BrandMark.js";
26
+ // Navigation
27
+ export { TOP_BAR_HEIGHT, TopBar, } from "./components/TopBar.js";
28
+ export { SideNav, } from "./components/SideNav.js";
29
+ export { Outline } from "./components/Outline.js";
30
+ export { PrevNext } from "./components/PrevNext.js";
31
+ export { LoadingBar } from "./components/LoadingBar.js";
32
+ export { AppShell, AppShellClose } from "./components/AppShell.js";
33
+ // Search
34
+ export { SearchField } from "./components/SearchField.js";
35
+ export { SearchButton } from "./components/SearchButton.js";
36
+ export { CommandPalette, } from "./components/CommandPalette.js";
37
+ // Settings
38
+ export { SaveFooter, SettingsBody, SettingsCard, SettingsEmpty, SettingsFooter, SettingsLinkRow, SettingsPage, SettingsRow, SettingsSubhead, SettingsTable, SettingsToast, } from "./components/Settings.js";
39
+ // Lists and data
40
+ export { DataList, DataListLink, DataListName, DataListRow, DataListSkeleton, } from "./components/DataList.js";
41
+ export { Pagination } from "./components/Pagination.js";
42
+ export { ListSearch } from "./components/ListSearch.js";
43
+ export { Callout, Callouts, ListColumn, ListGrid, ListRow, Metric, MetricGrid, MetricSuffix, SectionTitle, SummaryList, SummaryRow, } from "./components/Overview.js";
44
+ export { SkeletonSettingsCard, SkeletonSettingsPage, SkeletonStatCards, SkeletonTableBodyRows, SkeletonTableRows, } from "./components/Skeletons.js";
45
+ // Inputs
46
+ export { Segmented } from "./components/Segmented.js";
47
+ export { ThemeSwitch } from "./components/ThemeSwitch.js";
48
+ export { ThemeMenu } from "./components/ThemeMenu.js";
49
+ export { MenuPanel, MenuPanelButton, MenuPanelDivider, MenuPanelHeader, MenuPanelRow, } from "./components/MenuPanel.js";
50
+ export { Select } from "./components/Select.js";
51
+ export { CheckboxField } from "./components/CheckboxField.js";
52
+ export { PasswordInput } from "./components/PasswordInput.js";
53
+ export { DurationInput } from "./components/DurationInput.js";
54
+ export { ColorPickerInput } from "./components/ColorPickerInput.js";
55
+ // Copy
56
+ export { CopyButton } from "./components/CopyButton.js";
57
+ export { CopyIdText, CopyIdTrigger } from "./components/CopyIdTrigger.js";
58
+ // Re-exported from @siiway/ui-core for convenience
59
+ export { CANVAS, DEFAULT_ACCENT, SCHEME_COOKIE, THEME_STORAGE_KEY, resolveScheme, schemeBootScript, schemeCookie, schemeFromRequest, } from "@siiway/ui-core";
60
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qBAAqB;AACrB,OAAO,EAAE,WAAW,EAA2B,MAAM,wBAAwB,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAwB,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EACL,cAAc,EACd,MAAM,EACN,UAAU,EACV,aAAa,EACb,cAAc,EACd,WAAW,EACX,cAAc,EACd,YAAY,GAIb,MAAM,uBAAuB,CAAC;AAE/B,QAAQ;AACR,OAAO,EAAE,UAAU,EAAuB,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAE,OAAO,EAAkB,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAA8B,MAAM,8BAA8B,CAAC;AAC7F,OAAO,EAAE,YAAY,EAA8C,MAAM,yBAAyB,CAAC;AACnG,OAAO,EAAE,eAAe,EAAqB,MAAM,4BAA4B,CAAC;AAEhF,iBAAiB;AAC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,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,GAKlB,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,60 @@
1
+ import { type FluentProviderProps } from "@fluentui/react-components";
2
+ import { type Scheme, type UiStrings } from "@siiway/ui-core";
3
+ import { type ThemeModeOptions } from "../hooks/useThemeMode.js";
4
+ import { type PageTitleHandler, type UiRouter } from "./context.js";
5
+ export interface UiProviderProps extends Omit<FluentProviderProps, "theme"> {
6
+ /**
7
+ * The scheme to render in, when the app keeps the light/dark choice itself
8
+ * or draws a fixed one. Leave it out and the provider keeps the person's
9
+ * choice (`themeMode`), or a provider inside another follows the outer one.
10
+ */
11
+ scheme?: Scheme;
12
+ /**
13
+ * How the provider keeps the person's choice when it has no `scheme`:
14
+ * `useThemeMode`'s options (`storageKey`, `defaultMode`, `cookie`,
15
+ * `initialScheme`). `ThemeSwitch` and `ThemeMenu` show and change it, and
16
+ * `useUiThemeMode()` gives it to your own components.
17
+ */
18
+ themeMode?: ThemeModeOptions;
19
+ /**
20
+ * This provider is the page. It takes the canvas colour, removes the
21
+ * body's margin, and draws `<html>` in the scheme (`data-scheme`,
22
+ * `color-scheme`, the canvas background, `--siiway-canvas`) and each
23
+ * `<meta name="theme-color">` in the canvas, as `schemeBootScript` does
24
+ * before the app loads. Selected text takes a tint of the accent, and
25
+ * scrollbars are thin. Set it on the app's outermost provider only.
26
+ */
27
+ page?: boolean;
28
+ /**
29
+ * With `page`, for a page rendered once for everyone, such as a static
30
+ * site: it carries both schemes' colours, keyed on `<html data-scheme>`,
31
+ * so the scheme `schemeBootScript` picks shows before the app loads, not
32
+ * the one the page was rendered in. It adds about as much CSS again as the
33
+ * theme takes. Without `page` it does nothing.
34
+ */
35
+ bothSchemes?: boolean;
36
+ /** Brand colour; missing or invalid gives Fluent's blue. */
37
+ accent?: string | null;
38
+ /** BCP-47 tag for the library's own strings: `zh*` is Chinese, anything else English. */
39
+ locale?: string | null;
40
+ /** Replaces individual library strings. */
41
+ strings?: Partial<UiStrings>;
42
+ /**
43
+ * The app's router. Without one, links are `<a href>` and navigation
44
+ * reloads the page. Pass a stable object (define it at module level).
45
+ */
46
+ router?: UiRouter;
47
+ /**
48
+ * Called with a page's title when its PageHeader or DetailHeader mounts
49
+ * (`tabTitle`, or the title if it's plain text), and with null when the
50
+ * page goes, so the app can set the browser tab's title. Pass a stable
51
+ * function.
52
+ */
53
+ onPageTitle?: PageTitleHandler;
54
+ }
55
+ /**
56
+ * Fluent's provider with the SiiWay theme, plus the library's strings and
57
+ * router. Wrap the app in it once, where FluentProvider used to be.
58
+ */
59
+ export declare function UiProvider(props: UiProviderProps): import("react").JSX.Element;
60
+ //# sourceMappingURL=UiProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UiProvider.d.ts","sourceRoot":"","sources":["../../src/provider/UiProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,mBAAmB,EACzB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAuC,KAAK,MAAM,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEnG,OAAO,EAAgB,KAAK,gBAAgB,EAAuB,MAAM,0BAA0B,CAAC;AAEpG,OAAO,EAIL,KAAK,gBAAgB,EACrB,KAAK,QAAQ,EACd,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,mBAAmB,EAAE,OAAO,CAAC;IACzE;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,4DAA4D;IAC5D,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,yFAAyF;IACzF,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,2CAA2C;IAC3C,OAAO,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAC7B;;;OAGG;IACH,MAAM,CAAC,EAAE,QAAQ,CAAC;IAClB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,gBAAgB,CAAC;CAChC;AAsHD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,+BAQhD"}
@@ -0,0 +1,144 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { FluentProvider, createCSSRuleFromTheme, makeStaticStyles, mergeClasses, tokens, useIsomorphicLayoutEffect, } from "@fluentui/react-components";
3
+ import { CANVAS, DEFAULT_ACCENT, pickStrings } from "@siiway/ui-core";
4
+ import { useContext, useMemo, useSyncExternalStore } from "react";
5
+ import { useThemeMode } from "../hooks/useThemeMode.js";
6
+ import { createTheme } from "../theme/createTheme.js";
7
+ import { DEFAULT_ROUTER, NO_PROVIDER, UiContext, } from "./context.js";
8
+ // The look's rules for Fluent's own parts, wherever they render. Badges keep
9
+ // their label on one line: in a narrow flex row, CJK text otherwise wraps a
10
+ // character at a time. Surfaces that float (in a portal, outside the page's
11
+ // containers) get a hairline on top of their shadow, which barely shows on the
12
+ // dark canvas.
13
+ const useLookStyles = makeStaticStyles({
14
+ ".fui-Badge": { whiteSpace: "nowrap", flexShrink: "0" },
15
+ ".fui-DialogSurface, .fui-MenuPopover, .fui-PopoverSurface, .fui-Listbox": {
16
+ border: `1px solid ${tokens.colorNeutralStroke2}`,
17
+ },
18
+ });
19
+ function LookStyles() {
20
+ useLookStyles();
21
+ return null;
22
+ }
23
+ // Selected text takes a tint of the accent, and scrollbars are thin, with a
24
+ // neutral thumb on a clear track in either scheme.
25
+ const usePageStyles = makeStaticStyles({
26
+ body: { margin: "0" },
27
+ "::selection": {
28
+ backgroundColor: `color-mix(in srgb, var(--colorBrandBackground, ${DEFAULT_ACCENT}) 22%, transparent)`,
29
+ },
30
+ "::-webkit-scrollbar": { width: "8px", height: "8px" },
31
+ "::-webkit-scrollbar-track": { backgroundColor: "transparent" },
32
+ "::-webkit-scrollbar-thumb": {
33
+ backgroundColor: "rgba(0, 0, 0, 0.16)",
34
+ backgroundClip: "padding-box",
35
+ border: "2px solid transparent",
36
+ borderRadius: "4px",
37
+ },
38
+ "::-webkit-scrollbar-thumb:hover": { backgroundColor: "rgba(0, 0, 0, 0.32)" },
39
+ 'html[data-scheme="dark"] ::-webkit-scrollbar-thumb': {
40
+ backgroundColor: "rgba(255, 255, 255, 0.14)",
41
+ },
42
+ 'html[data-scheme="dark"] ::-webkit-scrollbar-thumb:hover': {
43
+ backgroundColor: "rgba(255, 255, 255, 0.28)",
44
+ },
45
+ });
46
+ const subscribeNothing = () => () => { };
47
+ // False while hydrating, true from the render after (and at once in a render
48
+ // that doesn't hydrate).
49
+ function useHydrated() {
50
+ return useSyncExternalStore(subscribeNothing, () => true, () => false);
51
+ }
52
+ // <html> in the page's scheme, for what lies outside the provider: the
53
+ // overscroll area, the scrollbars, form controls' native parts, the app's CSS
54
+ // (--siiway-canvas) and the browser's own bar (theme-color).
55
+ function PageScheme({ scheme, both }) {
56
+ usePageStyles();
57
+ // Hydrating a page with both schemes, `scheme` is the one the server drew,
58
+ // and <html> has the one the boot script picked, which the page shows. Left
59
+ // as it is until the render after, which brings the app's own scheme.
60
+ const hydrated = useHydrated();
61
+ const hold = both && !hydrated;
62
+ useIsomorphicLayoutEffect(() => {
63
+ if (hold)
64
+ return;
65
+ const root = document.documentElement;
66
+ const canvas = CANVAS[scheme];
67
+ root.setAttribute("data-scheme", scheme);
68
+ root.style.colorScheme = scheme;
69
+ root.style.backgroundColor = canvas;
70
+ root.style.setProperty("--siiway-canvas", canvas);
71
+ const metas = Array.from(document.querySelectorAll('meta[name="theme-color"]'));
72
+ const colors = metas.map((meta) => meta.content);
73
+ for (const meta of metas)
74
+ meta.content = canvas;
75
+ return () => {
76
+ root.removeAttribute("data-scheme");
77
+ root.style.removeProperty("color-scheme");
78
+ root.style.removeProperty("background-color");
79
+ root.style.removeProperty("--siiway-canvas");
80
+ metas.forEach((meta, i) => (meta.content = colors[i]));
81
+ };
82
+ }, [scheme, hold]);
83
+ return null;
84
+ }
85
+ // For bothSchemes: each scheme's tokens, keyed on <html data-scheme>, which the
86
+ // boot script sets before the page paints. They outrank FluentProvider's own
87
+ // rule for its class, and agree with it once the provider draws the page's
88
+ // scheme.
89
+ const BOTH_SCHEMES = "siiway-both-schemes";
90
+ // Through Griffel, as static styles: the renderer gives them its attributes
91
+ // (a CSP nonce) and, on the server, puts them in the head with the rest. One
92
+ // hook per accent, made once.
93
+ const bothSchemesStyles = new Map();
94
+ function BothSchemes({ accent }) {
95
+ const key = accent ?? "";
96
+ let useRules = bothSchemesStyles.get(key);
97
+ if (!useRules) {
98
+ useRules = makeStaticStyles(["light", "dark"].map((scheme) => createCSSRuleFromTheme(`html[data-scheme="${scheme}"] .${BOTH_SCHEMES}`, createTheme({ scheme, accent }))));
99
+ bothSchemesStyles.set(key, useRules);
100
+ }
101
+ useRules();
102
+ return null;
103
+ }
104
+ /**
105
+ * Fluent's provider with the SiiWay theme, plus the library's strings and
106
+ * router. Wrap the app in it once, where FluentProvider used to be.
107
+ */
108
+ export function UiProvider(props) {
109
+ const outer = useContext(UiContext);
110
+ const kept = outer.themeMode;
111
+ if (props.scheme !== undefined)
112
+ return _jsx(Provider, { ...props, scheme: props.scheme, kept: kept });
113
+ // Inside another provider: draw what it draws, whether it keeps the choice
114
+ // or was given a scheme.
115
+ if (outer !== NO_PROVIDER)
116
+ return _jsx(Provider, { ...props, scheme: outer.scheme, kept: kept });
117
+ return _jsx(KeepingProvider, { ...props });
118
+ }
119
+ // The outermost provider without a scheme keeps the person's choice.
120
+ function KeepingProvider({ themeMode, ...props }) {
121
+ const kept = useThemeMode(themeMode);
122
+ return _jsx(Provider, { ...props, scheme: kept.scheme, kept: kept });
123
+ }
124
+ function Provider({ scheme, kept, themeMode: _options, page, bothSchemes, accent, locale, strings, router, onPageTitle, children, ...rest }) {
125
+ const both = !!(page && bothSchemes);
126
+ const theme = useMemo(() => createTheme({ scheme, accent }), [scheme, accent]);
127
+ const resolved = useMemo(() => pickStrings(locale, strings), [locale, strings]);
128
+ const value = useMemo(() => ({
129
+ scheme,
130
+ strings: resolved,
131
+ router: router ?? DEFAULT_ROUTER,
132
+ onPageTitle: onPageTitle ?? null,
133
+ themeMode: kept,
134
+ bothSchemes: both,
135
+ }), [scheme, resolved, router, onPageTitle, kept, both]);
136
+ // Fluent paints its provider colorNeutralBackground1; the page is the canvas,
137
+ // with bothSchemes the one <html> has.
138
+ const canvas = both ? `var(--siiway-canvas, ${CANVAS[scheme]})` : CANVAS[scheme];
139
+ const style = page
140
+ ? { backgroundColor: canvas, ...rest.style }
141
+ : rest.style;
142
+ return (_jsxs(FluentProvider, { theme: theme, ...rest, className: both ? mergeClasses(BOTH_SCHEMES, rest.className) : rest.className, style: style, children: [_jsx(LookStyles, {}), both && _jsx(BothSchemes, { accent: accent }), page && _jsx(PageScheme, { scheme: scheme, both: both }), _jsx(UiContext.Provider, { value: value, children: children })] }));
143
+ }
144
+ //# sourceMappingURL=UiProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UiProvider.js","sourceRoot":"","sources":["../../src/provider/UiProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,gBAAgB,EAChB,YAAY,EACZ,MAAM,EACN,yBAAyB,GAE1B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,WAAW,EAA+B,MAAM,iBAAiB,CAAC;AACnG,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,oBAAoB,EAAsB,MAAM,OAAO,CAAC;AACtF,OAAO,EAAE,YAAY,EAA8C,MAAM,0BAA0B,CAAC;AACpG,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EACL,cAAc,EACd,WAAW,EACX,SAAS,GAGV,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AE,MAAM,IAAI,cAAc;QAChC,WAAW,EAAE,WAAW,IAAI,IAAI;QAChC,SAAS,EAAE,IAAI;QACf,WAAW,EAAE,IAAI;KAClB,CAAC,EACF,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,CACpD,CAAC;IACF,8EAA8E;IAC9E,uCAAuC;IACvC,MAAM,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,wBAAwB,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACjF,MAAM,KAAK,GAA8B,IAAI;QAC3C,CAAC,CAAC,EAAE,eAAe,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,EAAE;QAC5C,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;IACf,OAAO,CACL,MAAC,cAAc,IACb,KAAK,EAAE,KAAK,KACR,IAAI,EACR,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,EAC7E,KAAK,EAAE,KAAK,aAEZ,KAAC,UAAU,KAAG,EACb,IAAI,IAAI,KAAC,WAAW,IAAC,MAAM,EAAE,MAAM,GAAI,EACvC,IAAI,IAAI,KAAC,UAAU,IAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAI,EACnD,KAAC,SAAS,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAsB,IAClD,CAClB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * A class with the canvas colour, in the provider's scheme (or the page's,
3
+ * with `bothSchemes`), for parts of the page drawn on it that must be opaque:
4
+ * a sticky bar, a drawer, a full-page message.
5
+ */
6
+ export declare function useCanvasClass(): string;
7
+ //# sourceMappingURL=canvas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canvas.d.ts","sourceRoot":"","sources":["../../src/provider/canvas.ts"],"names":[],"mappings":"AAoBA;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAKvC"}
@@ -0,0 +1,30 @@
1
+ // Tokens have no canvas (it's darker than colorNeutralBackground1 in dark),
2
+ // so this picks CANVAS by the provider's scheme. Under a page provider with
3
+ // bothSchemes, whose colours follow <html data-scheme>, it reads the canvas
4
+ // there instead (--siiway-canvas, set by schemeBootScript before the page
5
+ // paints): the one the boot script picked, not the one the page was rendered
6
+ // in. Without bothSchemes the rest of the page is drawn in the rendered
7
+ // scheme until the app loads, so the canvas stays with it.
8
+ import { makeStyles } from "@fluentui/react-components";
9
+ import { CANVAS } from "@siiway/ui-core";
10
+ import { useContext } from "react";
11
+ import { UiContext } from "./context.js";
12
+ const useStyles = makeStyles({
13
+ light: { backgroundColor: CANVAS.light },
14
+ dark: { backgroundColor: CANVAS.dark },
15
+ pageLight: { backgroundColor: `var(--siiway-canvas, ${CANVAS.light})` },
16
+ pageDark: { backgroundColor: `var(--siiway-canvas, ${CANVAS.dark})` },
17
+ });
18
+ /**
19
+ * A class with the canvas colour, in the provider's scheme (or the page's,
20
+ * with `bothSchemes`), for parts of the page drawn on it that must be opaque:
21
+ * a sticky bar, a drawer, a full-page message.
22
+ */
23
+ export function useCanvasClass() {
24
+ const styles = useStyles();
25
+ const { scheme, bothSchemes } = useContext(UiContext);
26
+ if (!bothSchemes)
27
+ return styles[scheme];
28
+ return scheme === "dark" ? styles.pageDark : styles.pageLight;
29
+ }
30
+ //# sourceMappingURL=canvas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canvas.js","sourceRoot":"","sources":["../../src/provider/canvas.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,4EAA4E;AAC5E,4EAA4E;AAC5E,0EAA0E;AAC1E,6EAA6E;AAC7E,wEAAwE;AACxE,2DAA2D;AAE3D,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,SAAS,GAAG,UAAU,CAAC;IAC3B,KAAK,EAAE,EAAE,eAAe,EAAE,MAAM,CAAC,KAAK,EAAE;IACxC,IAAI,EAAE,EAAE,eAAe,EAAE,MAAM,CAAC,IAAI,EAAE;IACtC,SAAS,EAAE,EAAE,eAAe,EAAE,wBAAwB,MAAM,CAAC,KAAK,GAAG,EAAE;IACvE,QAAQ,EAAE,EAAE,eAAe,EAAE,wBAAwB,MAAM,CAAC,IAAI,GAAG,EAAE;CACtE,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,UAAU,cAAc;IAC5B,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;IACtD,IAAI,CAAC,WAAW;QAAE,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC;IACxC,OAAO,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC;AAChE,CAAC"}
@@ -0,0 +1,69 @@
1
+ import { type ComponentType, type MouseEventHandler, type ReactNode } from "react";
2
+ import { type Scheme, type UiStrings } from "@siiway/ui-core";
3
+ import type { ThemeModeState } from "../hooks/useThemeMode.js";
4
+ /** Props the library passes to the app's link component. */
5
+ export interface UiLinkProps {
6
+ /** An in-app path, e.g. `/apps/123`. */
7
+ to: string;
8
+ /** History state, for routers that keep it (React Router's `state`). */
9
+ state?: unknown;
10
+ className?: string;
11
+ onClick?: MouseEventHandler<HTMLAnchorElement>;
12
+ /** `"page"` on the link to the page the reader is on (SideNav, TopBar). */
13
+ "aria-current"?: "page";
14
+ children?: ReactNode;
15
+ }
16
+ /**
17
+ * How library components link, navigate and know the current page. React
18
+ * Router fits as is: `router={{ Link, useNavigate }}`, plus `useMatch`.
19
+ */
20
+ export interface UiRouter {
21
+ Link: ComponentType<UiLinkProps>;
22
+ /** A hook returning a navigate function. Called during render, like any hook. */
23
+ useNavigate: () => (to: string) => void;
24
+ /**
25
+ * A hook: whether the reader is on `to`, or on a page below it unless
26
+ * `end`. SideNav asks it for items without `active`. React Router:
27
+ * `(to, end) => useMatch({ path: to, end }) !== null`.
28
+ */
29
+ useMatch?: (to: string, end: boolean) => boolean;
30
+ }
31
+ /** Plain `<a href>` links and full page loads: for apps without a client router. */
32
+ export declare const DEFAULT_ROUTER: UiRouter;
33
+ /** Receives the page's title from its header, and null when the page goes. */
34
+ export type PageTitleHandler = (title: string | null) => void;
35
+ export interface UiContextValue {
36
+ scheme: Scheme;
37
+ strings: UiStrings;
38
+ router: UiRouter;
39
+ onPageTitle: PageTitleHandler | null;
40
+ /** The person's light/dark choice, when the page's provider keeps it. */
41
+ themeMode: ThemeModeState | null;
42
+ /** Under a page provider with `bothSchemes`: colours follow `<html data-scheme>`. */
43
+ bothSchemes: boolean;
44
+ }
45
+ export declare const NO_PROVIDER: UiContextValue;
46
+ export declare const UiContext: import("react").Context<UiContextValue>;
47
+ /** The library's own strings, in the locale given to `<UiProvider>`. */
48
+ export declare function useUiStrings(): UiStrings;
49
+ /** The scheme `<UiProvider>` renders in. */
50
+ export declare function useUiScheme(): Scheme;
51
+ /**
52
+ * The person's light/dark choice that `<UiProvider>` keeps when it has no
53
+ * `scheme`: `{ mode, setMode, scheme }`. Null when the app keeps it itself.
54
+ */
55
+ export declare function useUiThemeMode(): ThemeModeState | null;
56
+ /** A link through the app's router (React Router's `Link`, or `<a href>`). */
57
+ export declare function UiLink(props: UiLinkProps): import("react").JSX.Element;
58
+ /** A function that navigates to an in-app path. */
59
+ export declare function useUiNavigate(): (to: string) => void;
60
+ /**
61
+ * Whether the reader is on `to`, or on a page below it unless `end`, by the
62
+ * router's `useMatch`; false without one. Keep the same router: one that
63
+ * gains or loses `useMatch` changes the hooks this calls.
64
+ */
65
+ export declare function useUiMatch(to: string, end?: boolean): boolean;
66
+ /** The app's page-title handler, if it gave `<UiProvider onPageTitle>`. */
67
+ export declare function useUiPageTitle(): PageTitleHandler | null;
68
+ export declare function useTabTitle(title: ReactNode, tabTitle?: string): void;
69
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/provider/context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,EAAc,KAAK,MAAM,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE/D,4DAA4D;AAC5D,MAAM,WAAW,WAAW;IAC1B,wCAAwC;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,wEAAwE;IACxE,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;IAC/C,2EAA2E;IAC3E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IACjC,iFAAiF;IACjF,WAAW,EAAE,MAAM,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC;CAClD;AAUD,oFAAoF;AACpF,eAAO,MAAM,cAAc,EAAE,QAAiE,CAAC;AAE/F,8EAA8E;AAC9E,MAAM,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;AAE9D,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,SAAS,CAAC;IACnB,MAAM,EAAE,QAAQ,CAAC;IACjB,WAAW,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACrC,yEAAyE;IACzE,SAAS,EAAE,cAAc,GAAG,IAAI,CAAC;IACjC,qFAAqF;IACrF,WAAW,EAAE,OAAO,CAAC;CACtB;AAID,eAAO,MAAM,WAAW,EAAE,cAOzB,CAAC;AAEF,eAAO,MAAM,SAAS,yCAA6C,CAAC;AAEpE,wEAAwE;AACxE,wBAAgB,YAAY,IAAI,SAAS,CAExC;AAED,4CAA4C;AAC5C,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,cAAc,GAAG,IAAI,CAEtD;AAED,8EAA8E;AAC9E,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,+BAGxC;AAED,mDAAmD;AACnD,wBAAgB,aAAa,IAAI,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAEpD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,UAAQ,GAAG,OAAO,CAG3D;AAED,2EAA2E;AAC3E,wBAAgB,cAAc,IAAI,gBAAgB,GAAG,IAAI,CAExD;AAUD,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,MAAM,QAc9D"}
@@ -0,0 +1,84 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext, useEffect, } from "react";
3
+ import { UI_STRINGS } from "@siiway/ui-core";
4
+ function AnchorLink({ to, state: _state, ...rest }) {
5
+ return _jsx("a", { href: to, ...rest });
6
+ }
7
+ function useLocationNavigate() {
8
+ return (to) => window.location.assign(to);
9
+ }
10
+ /** Plain `<a href>` links and full page loads: for apps without a client router. */
11
+ export const DEFAULT_ROUTER = { Link: AnchorLink, useNavigate: useLocationNavigate };
12
+ // What components see outside any provider; UiProvider tells it apart from
13
+ // an outer provider's value by identity.
14
+ export const NO_PROVIDER = {
15
+ scheme: "light",
16
+ strings: UI_STRINGS.en,
17
+ router: DEFAULT_ROUTER,
18
+ onPageTitle: null,
19
+ themeMode: null,
20
+ bothSchemes: false,
21
+ };
22
+ export const UiContext = createContext(NO_PROVIDER);
23
+ /** The library's own strings, in the locale given to `<UiProvider>`. */
24
+ export function useUiStrings() {
25
+ return useContext(UiContext).strings;
26
+ }
27
+ /** The scheme `<UiProvider>` renders in. */
28
+ export function useUiScheme() {
29
+ return useContext(UiContext).scheme;
30
+ }
31
+ /**
32
+ * The person's light/dark choice that `<UiProvider>` keeps when it has no
33
+ * `scheme`: `{ mode, setMode, scheme }`. Null when the app keeps it itself.
34
+ */
35
+ export function useUiThemeMode() {
36
+ return useContext(UiContext).themeMode;
37
+ }
38
+ /** A link through the app's router (React Router's `Link`, or `<a href>`). */
39
+ export function UiLink(props) {
40
+ const { Link } = useContext(UiContext).router;
41
+ return _jsx(Link, { ...props });
42
+ }
43
+ /** A function that navigates to an in-app path. */
44
+ export function useUiNavigate() {
45
+ return useContext(UiContext).router.useNavigate();
46
+ }
47
+ /**
48
+ * Whether the reader is on `to`, or on a page below it unless `end`, by the
49
+ * router's `useMatch`; false without one. Keep the same router: one that
50
+ * gains or loses `useMatch` changes the hooks this calls.
51
+ */
52
+ export function useUiMatch(to, end = false) {
53
+ const { router } = useContext(UiContext);
54
+ return router.useMatch ? router.useMatch(to, end) : false;
55
+ }
56
+ /** The app's page-title handler, if it gave `<UiProvider onPageTitle>`. */
57
+ export function useUiPageTitle() {
58
+ return useContext(UiContext).onPageTitle;
59
+ }
60
+ // The header each handler last heard from. Only it clears the title, so a
61
+ // page that leaves after the next one came (in a route transition) doesn't
62
+ // clear the next one's.
63
+ const titleOwners = new WeakMap();
64
+ // Names the browser tab after a page header ("Security · Prism"): `tabTitle`,
65
+ // or the title when it's plain text; a rich or empty title (a name still
66
+ // loading, say) leaves the site name.
67
+ export function useTabTitle(title, tabTitle) {
68
+ const onPageTitle = useUiPageTitle();
69
+ const text = tabTitle ?? (typeof title === "string" ? title : null);
70
+ useEffect(() => {
71
+ if (!text || !onPageTitle)
72
+ return;
73
+ const owner = {};
74
+ titleOwners.set(onPageTitle, owner);
75
+ onPageTitle(text);
76
+ return () => {
77
+ if (titleOwners.get(onPageTitle) !== owner)
78
+ return;
79
+ titleOwners.delete(onPageTitle);
80
+ onPageTitle(null);
81
+ };
82
+ }, [text, onPageTitle]);
83
+ }
84
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/provider/context.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,aAAa,EACb,UAAU,EACV,SAAS,GAIV,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,UAAU,EAA+B,MAAM,iBAAiB,CAAC;AAgC1E,SAAS,UAAU,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAe;IAC7D,OAAO,YAAG,IAAI,EAAE,EAAE,KAAM,IAAI,GAAI,CAAC;AACnC,CAAC;AAED,SAAS,mBAAmB;IAC1B,OAAO,CAAC,EAAU,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AACpD,CAAC;AAED,oFAAoF;AACpF,MAAM,CAAC,MAAM,cAAc,GAAa,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,mBAAmB,EAAE,CAAC;AAgB/F,2EAA2E;AAC3E,yCAAyC;AACzC,MAAM,CAAC,MAAM,WAAW,GAAmB;IACzC,MAAM,EAAE,OAAO;IACf,OAAO,EAAE,UAAU,CAAC,EAAE;IACtB,MAA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B,MAAM,WAAW,GAAG,IAAI,OAAO,EAA4B,CAAC;AAE5D,8EAA8E;AAC9E,yEAAyE;AACzE,sCAAsC;AACtC,MAAM,UAAU,WAAW,CAAC,KAAgB,EAAE,QAAiB;IAC7D,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IACrC,MAAM,IAAI,GAAG,QAAQ,IAAI,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACpE,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,IAAI,IAAI,CAAC,WAAW;YAAE,OAAO;QAClC,MAAM,KAAK,GAAG,EAAE,CAAC;QACjB,WAAW,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QACpC,WAAW,CAAC,IAAI,CAAC,CAAC;QAClB,OAAO,GAAG,EAAE;YACV,IAAI,WAAW,CAAC,GAAG,CAAC,WAAW,CAAC,KAAK,KAAK;gBAAE,OAAO;YACnD,WAAW,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;YAChC,WAAW,CAAC,IAAI,CAAC,CAAC;QACpB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { type Theme } from "@fluentui/react-components";
2
+ import { type Scheme } from "@siiway/ui-core";
3
+ export interface CreateThemeOptions {
4
+ scheme: Scheme;
5
+ /** Brand colour, `#rgb` to `#rrggbbaa`. Missing or invalid gives Fluent's blue. */
6
+ accent?: string | null;
7
+ }
8
+ /**
9
+ * The SiiWay Fluent theme: Fluent's own theme for the accent's brand ramp,
10
+ * with the neutral greys, radii and shadows replaced.
11
+ */
12
+ export declare function createTheme({ scheme, accent }: CreateThemeOptions): Theme;
13
+ //# sourceMappingURL=createTheme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createTheme.d.ts","sourceRoot":"","sources":["../../src/theme/createTheme.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,KAAK,EACX,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAA6B,KAAK,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzE,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,mFAAmF;IACnF,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,kBAAkB,GAAG,KAAK,CASzE"}
@@ -0,0 +1,18 @@
1
+ import { createDarkTheme, createLightTheme, webDarkTheme, webLightTheme, } from "@fluentui/react-components";
2
+ import { brandRamp, themeOverrides } from "@siiway/ui-core";
3
+ /**
4
+ * The SiiWay Fluent theme: Fluent's own theme for the accent's brand ramp,
5
+ * with the neutral greys, radii and shadows replaced.
6
+ */
7
+ export function createTheme({ scheme, accent }) {
8
+ const brand = brandRamp(accent);
9
+ let base;
10
+ try {
11
+ base = scheme === "dark" ? createDarkTheme(brand) : createLightTheme(brand);
12
+ }
13
+ catch {
14
+ base = scheme === "dark" ? webDarkTheme : webLightTheme;
15
+ }
16
+ return { ...base, ...themeOverrides(scheme) };
17
+ }
18
+ //# sourceMappingURL=createTheme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createTheme.js","sourceRoot":"","sources":["../../src/theme/createTheme.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,aAAa,GAEd,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,cAAc,EAAe,MAAM,iBAAiB,CAAC;AAQzE;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,EAAE,MAAM,EAAE,MAAM,EAAsB;IAChE,MAAM,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;IAChC,IAAI,IAAW,CAAC;IAChB,IAAI,CAAC;QACH,IAAI,GAAG,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAC9E,CAAC;IAAC,MAAM,CAAC;QACP,IAAI,GAAG,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,aAAa,CAAC;IAC1D,CAAC;IACD,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;AAChD,CAAC"}
package/package.json CHANGED
@@ -1,11 +1,51 @@
1
1
  {
2
2
  "name": "@siiway/ui-react",
3
- "version": "0.0.0",
4
- "description": "Placeholder so npm trusted publishing can be set up. Use 0.1.0 or later.",
3
+ "version": "0.2.0",
4
+ "description": "SiiWay's Fluent UI v9 theme, provider and components for React.",
5
5
  "license": "MIT",
6
+ "homepage": "https://ui.siiway.org",
7
+ "type": "module",
8
+ "sideEffects": false,
6
9
  "repository": {
7
10
  "type": "git",
8
11
  "url": "git+https://github.com/siiway/ui.git",
9
12
  "directory": "packages/react"
13
+ },
14
+ "exports": {
15
+ ".": {
16
+ "types": "./dist/index.d.ts",
17
+ "default": "./dist/index.js"
18
+ },
19
+ "./package.json": "./package.json"
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "!dist/.tsbuildinfo",
24
+ "src",
25
+ "LICENSE",
26
+ "README.md"
27
+ ],
28
+ "scripts": {
29
+ "build": "tsc -b"
30
+ },
31
+ "dependencies": {
32
+ "@siiway/ui-core": "0.2.0"
33
+ },
34
+ "peerDependencies": {
35
+ "@fluentui/react-components": "^9.73.0",
36
+ "@fluentui/react-icons": "^2.0.300",
37
+ "react": "^18.3.0 || ^19.0.0",
38
+ "react-dom": "^18.3.0 || ^19.0.0"
39
+ },
40
+ "devDependencies": {
41
+ "@fluentui/react-components": "^9.75.0",
42
+ "@fluentui/react-icons": "^2.0.345",
43
+ "@types/react": "^19.3.0",
44
+ "@types/react-dom": "^19.3.0",
45
+ "react": "^19.3.1",
46
+ "react-dom": "^19.3.1"
47
+ },
48
+ "publishConfig": {
49
+ "access": "public"
10
50
  }
11
51
  }