@seanyeh77/ui 0.43.1 → 0.45.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 (885) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -1
  3. package/dist/bundle.js +20 -20
  4. package/dist/components/AccentPicker/AccentPicker.d.ts +1 -0
  5. package/dist/components/AccentPicker/AccentPicker.js +92 -72
  6. package/dist/components/AccentPicker/AccentPicker.js.map +1 -1
  7. package/dist/components/ActionBar/ActionBar.d.ts +2 -0
  8. package/dist/components/ActionBar/ActionBar.js.map +1 -1
  9. package/dist/components/AiMark/AiMark.d.ts +1 -0
  10. package/dist/components/AiMark/AiMark.js.map +1 -1
  11. package/dist/components/Alert/Alert.d.ts +6 -3
  12. package/dist/components/Alert/Alert.js +18 -14
  13. package/dist/components/Alert/Alert.js.map +1 -1
  14. package/dist/components/AppShell/AppShell.d.ts +10 -4
  15. package/dist/components/AppShell/AppShell.js +30 -19
  16. package/dist/components/AppShell/AppShell.js.map +1 -1
  17. package/dist/components/Badge/Badge.d.ts +24 -7
  18. package/dist/components/Badge/Badge.js +78 -21
  19. package/dist/components/Badge/Badge.js.map +1 -1
  20. package/dist/components/BarChart/BarChart.d.ts +14 -1
  21. package/dist/components/BarChart/BarChart.js +88 -59
  22. package/dist/components/BarChart/BarChart.js.map +1 -1
  23. package/dist/components/Breadcrumb/Breadcrumb.d.ts +1 -0
  24. package/dist/components/Breadcrumb/Breadcrumb.js.map +1 -1
  25. package/dist/components/Button/Button.d.ts +4 -1
  26. package/dist/components/Button/Button.js +17 -3
  27. package/dist/components/Button/Button.js.map +1 -1
  28. package/dist/components/Calendar/Calendar.d.ts +11 -2
  29. package/dist/components/Calendar/Calendar.js +16 -5
  30. package/dist/components/Calendar/Calendar.js.map +1 -1
  31. package/dist/components/Card/Card.d.ts +1 -0
  32. package/dist/components/Card/Card.js.map +1 -1
  33. package/dist/components/Checkbox/Checkbox.d.ts +24 -8
  34. package/dist/components/Checkbox/Checkbox.js +22 -9
  35. package/dist/components/Checkbox/Checkbox.js.map +1 -1
  36. package/dist/components/CodeView/CodeView.d.ts +3 -0
  37. package/dist/components/CodeView/CodeView.js +6 -6
  38. package/dist/components/CodeView/CodeView.js.map +1 -1
  39. package/dist/components/CommandPalette/CommandPalette.d.ts +16 -4
  40. package/dist/components/CommandPalette/CommandPalette.js +38 -11
  41. package/dist/components/CommandPalette/CommandPalette.js.map +1 -1
  42. package/dist/components/ConsoleLayout/ConsoleLayout.d.ts +2 -3
  43. package/dist/components/ConsoleLayout/ConsoleLayout.js +4 -1
  44. package/dist/components/ConsoleLayout/ConsoleLayout.js.map +1 -1
  45. package/dist/components/DangerZone/DangerZone.d.ts +3 -2
  46. package/dist/components/DangerZone/DangerZone.js +3 -2
  47. package/dist/components/DangerZone/DangerZone.js.map +1 -1
  48. package/dist/components/DataTable/DataTable.d.ts +16 -4
  49. package/dist/components/DataTable/DataTable.js +346 -208
  50. package/dist/components/DataTable/DataTable.js.map +1 -1
  51. package/dist/components/DataTable/SortButton.js +48 -5
  52. package/dist/components/DataTable/SortButton.js.map +1 -1
  53. package/dist/components/DataTable/filters.js +2 -1
  54. package/dist/components/DataTable/filters.js.map +1 -1
  55. package/dist/components/DataTable/parts.js +1 -1
  56. package/dist/components/DataTable/parts.js.map +1 -1
  57. package/dist/components/DataTable/types.d.ts +10 -3
  58. package/dist/components/DatePicker/DatePicker.d.ts +9 -7
  59. package/dist/components/DatePicker/DatePicker.js +16 -6
  60. package/dist/components/DatePicker/DatePicker.js.map +1 -1
  61. package/dist/components/DateRangePicker/DateRangePicker.d.ts +12 -7
  62. package/dist/components/DateRangePicker/DateRangePicker.js +81 -45
  63. package/dist/components/DateRangePicker/DateRangePicker.js.map +1 -1
  64. package/dist/components/DetailList/DetailList.d.ts +2 -0
  65. package/dist/components/DetailList/DetailList.js.map +1 -1
  66. package/dist/components/Dialog/Dialog.d.ts +56 -20
  67. package/dist/components/Dialog/Dialog.js +46 -14
  68. package/dist/components/Dialog/Dialog.js.map +1 -1
  69. package/dist/components/Drawer/Drawer.d.ts +18 -5
  70. package/dist/components/Drawer/Drawer.js +87 -24
  71. package/dist/components/Drawer/Drawer.js.map +1 -1
  72. package/dist/components/EmptyState/EmptyState.d.ts +2 -2
  73. package/dist/components/EmptyState/EmptyState.js +3 -2
  74. package/dist/components/EmptyState/EmptyState.js.map +1 -1
  75. package/dist/components/ErrorPage/ErrorPage.d.ts +4 -0
  76. package/dist/components/ErrorPage/ErrorPage.js +2 -1
  77. package/dist/components/ErrorPage/ErrorPage.js.map +1 -1
  78. package/dist/components/EventTimeline/EventTimeline.d.ts +23 -5
  79. package/dist/components/EventTimeline/EventTimeline.js +64 -20
  80. package/dist/components/EventTimeline/EventTimeline.js.map +1 -1
  81. package/dist/components/FileUpload/FileUpload.d.ts +10 -2
  82. package/dist/components/FileUpload/FileUpload.js +5 -2
  83. package/dist/components/FileUpload/FileUpload.js.map +1 -1
  84. package/dist/components/FormGrid/FormGrid.d.ts +3 -1
  85. package/dist/components/FormGrid/FormGrid.js +5 -2
  86. package/dist/components/FormGrid/FormGrid.js.map +1 -1
  87. package/dist/components/Graph/Graph.d.ts +1 -0
  88. package/dist/components/Graph/Graph.js +8 -4
  89. package/dist/components/Graph/Graph.js.map +1 -1
  90. package/dist/components/Grid/Grid.d.ts +11 -4
  91. package/dist/components/Grid/Grid.js +14 -2
  92. package/dist/components/Grid/Grid.js.map +1 -1
  93. package/dist/components/IconButton/IconButton.d.ts +2 -1
  94. package/dist/components/IconButton/IconButton.js +10 -1
  95. package/dist/components/IconButton/IconButton.js.map +1 -1
  96. package/dist/components/InlineCode/InlineCode.d.ts +6 -0
  97. package/dist/components/InlineCode/InlineCode.js +10 -6
  98. package/dist/components/InlineCode/InlineCode.js.map +1 -1
  99. package/dist/components/KpiCard/KpiCard.d.ts +7 -3
  100. package/dist/components/KpiCard/KpiCard.js +40 -25
  101. package/dist/components/KpiCard/KpiCard.js.map +1 -1
  102. package/dist/components/LayerGraph/LayerGraph.d.ts +68 -23
  103. package/dist/components/LayerGraph/LayerGraph.js +178 -97
  104. package/dist/components/LayerGraph/LayerGraph.js.map +1 -1
  105. package/dist/components/LineChart/LineChart.d.ts +10 -3
  106. package/dist/components/LineChart/LineChart.js +55 -23
  107. package/dist/components/LineChart/LineChart.js.map +1 -1
  108. package/dist/components/Link/Link.d.ts +17 -0
  109. package/dist/components/Link/Link.js +47 -0
  110. package/dist/components/Link/Link.js.map +1 -0
  111. package/dist/components/LoadingBar/LoadingBar.d.ts +1 -0
  112. package/dist/components/LoadingBar/LoadingBar.js.map +1 -1
  113. package/dist/components/LoginCard/LoginCard.d.ts +9 -3
  114. package/dist/components/LoginCard/LoginCard.js +99 -78
  115. package/dist/components/LoginCard/LoginCard.js.map +1 -1
  116. package/dist/components/Markdown/Markdown.d.ts +1 -0
  117. package/dist/components/Markdown/Markdown.js +20 -2
  118. package/dist/components/Markdown/Markdown.js.map +1 -1
  119. package/dist/components/Menu/Menu.d.ts +4 -2
  120. package/dist/components/Menu/Menu.js +43 -33
  121. package/dist/components/Menu/Menu.js.map +1 -1
  122. package/dist/components/Meter/Meter.d.ts +4 -0
  123. package/dist/components/Meter/Meter.js.map +1 -1
  124. package/dist/components/MobileTabBar/MobileTabBar.d.ts +3 -0
  125. package/dist/components/MobileTabBar/MobileTabBar.js.map +1 -1
  126. package/dist/components/MultiSelect/MultiSelect.d.ts +7 -6
  127. package/dist/components/MultiSelect/MultiSelect.js +27 -9
  128. package/dist/components/MultiSelect/MultiSelect.js.map +1 -1
  129. package/dist/components/NotificationBell/NotificationBell.d.ts +4 -0
  130. package/dist/components/NotificationBell/NotificationBell.js +4 -3
  131. package/dist/components/NotificationBell/NotificationBell.js.map +1 -1
  132. package/dist/components/PageHeader/PageHeader.d.ts +34 -0
  133. package/dist/components/PageHeader/PageHeader.js +68 -0
  134. package/dist/components/PageHeader/PageHeader.js.map +1 -0
  135. package/dist/components/Popover/Popover.d.ts +11 -4
  136. package/dist/components/Popover/Popover.js +17 -7
  137. package/dist/components/Popover/Popover.js.map +1 -1
  138. package/dist/components/ProgressBar/ProgressBar.d.ts +2 -0
  139. package/dist/components/ProgressBar/ProgressBar.js.map +1 -1
  140. package/dist/components/ProgressRing/ProgressRing.d.ts +1 -0
  141. package/dist/components/ProgressRing/ProgressRing.js.map +1 -1
  142. package/dist/components/ProjectSwitcher/ProjectSwitcher.d.ts +5 -1
  143. package/dist/components/ProjectSwitcher/ProjectSwitcher.js +16 -3
  144. package/dist/components/ProjectSwitcher/ProjectSwitcher.js.map +1 -1
  145. package/dist/components/RadioGroup/RadioGroup.d.ts +22 -5
  146. package/dist/components/RadioGroup/RadioGroup.js +48 -47
  147. package/dist/components/RadioGroup/RadioGroup.js.map +1 -1
  148. package/dist/components/RelativeTime/RelativeTime.d.ts +10 -0
  149. package/dist/components/RelativeTime/RelativeTime.js +44 -0
  150. package/dist/components/RelativeTime/RelativeTime.js.map +1 -0
  151. package/dist/components/SearchField/SearchField.d.ts +2 -0
  152. package/dist/components/SearchField/SearchField.js.map +1 -1
  153. package/dist/components/Section/Section.d.ts +4 -0
  154. package/dist/components/Section/Section.js +8 -22
  155. package/dist/components/Section/Section.js.map +1 -1
  156. package/dist/components/SegmentedControl/SegmentedControl.d.ts +22 -9
  157. package/dist/components/SegmentedControl/SegmentedControl.js +20 -19
  158. package/dist/components/SegmentedControl/SegmentedControl.js.map +1 -1
  159. package/dist/components/Select/Select.d.ts +7 -11
  160. package/dist/components/Select/Select.js +7 -3
  161. package/dist/components/Select/Select.js.map +1 -1
  162. package/dist/components/SettingsLayout/SettingsLayout.d.ts +33 -4
  163. package/dist/components/SettingsLayout/SettingsLayout.js +62 -14
  164. package/dist/components/SettingsLayout/SettingsLayout.js.map +1 -1
  165. package/dist/components/SideNav/SideNav.d.ts +2 -0
  166. package/dist/components/SideNav/SideNav.js +3 -3
  167. package/dist/components/SideNav/SideNav.js.map +1 -1
  168. package/dist/components/SplitPane/SplitPane.d.ts +1 -0
  169. package/dist/components/SplitPane/SplitPane.js.map +1 -1
  170. package/dist/components/StatusBand/StatusBand.d.ts +1 -0
  171. package/dist/components/StatusBand/StatusBand.js.map +1 -1
  172. package/dist/components/Suggestion/Suggestion.d.ts +6 -0
  173. package/dist/components/Suggestion/Suggestion.js.map +1 -1
  174. package/dist/components/Switch/Switch.d.ts +13 -3
  175. package/dist/components/Switch/Switch.js +16 -7
  176. package/dist/components/Switch/Switch.js.map +1 -1
  177. package/dist/components/Tabs/Tabs.d.ts +8 -1
  178. package/dist/components/Tabs/Tabs.js +6 -3
  179. package/dist/components/Tabs/Tabs.js.map +1 -1
  180. package/dist/components/Tag/Tag.d.ts +15 -7
  181. package/dist/components/Tag/Tag.js +22 -10
  182. package/dist/components/Tag/Tag.js.map +1 -1
  183. package/dist/components/Term/Term.d.ts +8 -3
  184. package/dist/components/Term/Term.js +1 -1
  185. package/dist/components/Term/Term.js.map +1 -1
  186. package/dist/components/TextArea/TextArea.d.ts +6 -9
  187. package/dist/components/TextArea/TextArea.js +25 -12
  188. package/dist/components/TextArea/TextArea.js.map +1 -1
  189. package/dist/components/TextField/TextField.d.ts +8 -11
  190. package/dist/components/TextField/TextField.js +9 -7
  191. package/dist/components/TextField/TextField.js.map +1 -1
  192. package/dist/components/ThemePicker/ThemePicker.d.ts +1 -0
  193. package/dist/components/ThemePicker/ThemePicker.js +35 -34
  194. package/dist/components/ThemePicker/ThemePicker.js.map +1 -1
  195. package/dist/components/TimeControl/TimeControl.d.ts +1 -0
  196. package/dist/components/TimeControl/TimeControl.js.map +1 -1
  197. package/dist/components/Toast/Toast.d.ts +56 -3
  198. package/dist/components/Toast/Toast.js +191 -8
  199. package/dist/components/Toast/Toast.js.map +1 -1
  200. package/dist/components/TopBar/TopBar.d.ts +6 -2
  201. package/dist/components/TopBar/TopBar.js +7 -1
  202. package/dist/components/TopBar/TopBar.js.map +1 -1
  203. package/dist/components/Tour/Tour.d.ts +14 -3
  204. package/dist/components/Tour/Tour.js +26 -14
  205. package/dist/components/Tour/Tour.js.map +1 -1
  206. package/dist/components/TreeList/TreeList.d.ts +28 -4
  207. package/dist/components/TreeList/TreeList.js +32 -20
  208. package/dist/components/TreeList/TreeList.js.map +1 -1
  209. package/dist/components/Workbench/Workbench.d.ts +1 -0
  210. package/dist/components/Workbench/Workbench.js +24 -12
  211. package/dist/components/Workbench/Workbench.js.map +1 -1
  212. package/dist/components/ZoneMap/ZoneMap.d.ts +12 -2
  213. package/dist/components/ZoneMap/ZoneMap.js +13 -5
  214. package/dist/components/ZoneMap/ZoneMap.js.map +1 -1
  215. package/dist/components/useFormErrors/useFormErrors.d.ts +20 -0
  216. package/dist/components/useFormErrors/useFormErrors.js +55 -0
  217. package/dist/components/useFormErrors/useFormErrors.js.map +1 -0
  218. package/dist/css/AccentPicker.css +1 -0
  219. package/dist/css/Alert.css +8 -19
  220. package/dist/css/AppShell.css +1 -0
  221. package/dist/css/Badge.css +19 -45
  222. package/dist/css/BarChart.css +21 -3
  223. package/dist/css/Button.css +6 -1
  224. package/dist/css/Card.css +8 -8
  225. package/dist/css/Checkbox.css +20 -0
  226. package/dist/css/CodeView.css +3 -2
  227. package/dist/css/DangerZone.css +5 -3
  228. package/dist/css/DataTable.css +303 -69
  229. package/dist/css/DatePicker.css +1 -0
  230. package/dist/css/DateRangePicker.css +24 -2
  231. package/dist/css/Drawer.css +31 -0
  232. package/dist/css/EmptyState.css +1 -0
  233. package/dist/css/ErrorPage.css +4 -1
  234. package/dist/css/EventTimeline.css +34 -5
  235. package/dist/css/FileUpload.css +1 -0
  236. package/dist/css/FormGrid.css +12 -3
  237. package/dist/css/Graph.css +9 -1
  238. package/dist/css/Grid.css +8 -0
  239. package/dist/css/KpiCard.css +13 -1
  240. package/dist/css/LayerGraph.css +40 -15
  241. package/dist/css/Link.css +23 -0
  242. package/dist/css/LoginCard.css +17 -11
  243. package/dist/css/Markdown.css +31 -2
  244. package/dist/css/Menu.css +0 -2
  245. package/dist/css/Meter.css +16 -0
  246. package/dist/css/MultiSelect.css +1 -0
  247. package/dist/css/NotificationBell.css +1 -0
  248. package/dist/css/PageHeader.css +50 -0
  249. package/dist/css/ProgressBar.css +12 -0
  250. package/dist/css/ProjectSwitcher.css +25 -23
  251. package/dist/css/RelativeTime.css +2 -0
  252. package/dist/css/SegmentedControl.css +38 -10
  253. package/dist/css/Select.css +1 -0
  254. package/dist/css/SettingsLayout.css +29 -8
  255. package/dist/css/SideNav.css +4 -1
  256. package/dist/css/Skeleton.css +22 -1
  257. package/dist/css/Suggestion.css +1 -1
  258. package/dist/css/Switch.css +27 -0
  259. package/dist/css/Tabs.css +8 -7
  260. package/dist/css/Tag.css +19 -12
  261. package/dist/css/Term.css +1 -1
  262. package/dist/css/TextArea.css +1 -0
  263. package/dist/css/TextField.css +1 -0
  264. package/dist/css/Toast.css +101 -4
  265. package/dist/css/TopBar.css +21 -2
  266. package/dist/css/Tour.css +1 -1
  267. package/dist/css/TreeList.css +7 -3
  268. package/dist/css/Workbench.css +13 -1
  269. package/dist/css/ZoneMap.css +0 -1
  270. package/dist/css/base.css +45 -0
  271. package/dist/css/end.css +119 -5
  272. package/dist/deprecated.d.ts +3 -0
  273. package/dist/deprecated.js +13 -0
  274. package/dist/deprecated.js.map +1 -0
  275. package/dist/fonts.css +2 -7543
  276. package/dist/format.d.ts +3 -1
  277. package/dist/format.js +15 -5
  278. package/dist/format.js.map +1 -1
  279. package/dist/generated/themeDefaults.d.ts +8 -0
  280. package/dist/generated/themeDefaults.js +35 -0
  281. package/dist/generated/themeDefaults.js.map +1 -0
  282. package/dist/i18n.d.ts +7 -2
  283. package/dist/i18n.js +65 -10
  284. package/dist/i18n.js.map +1 -1
  285. package/dist/icons/Icon.d.ts +3 -1
  286. package/dist/icons/Icon.js.map +1 -1
  287. package/dist/index.d.ts +23 -14
  288. package/dist/index.js +14 -8
  289. package/dist/internal/Field.d.ts +19 -0
  290. package/dist/internal/Field.js +13 -6
  291. package/dist/internal/Field.js.map +1 -1
  292. package/dist/internal/FloatingPanel.js +2 -1
  293. package/dist/internal/FloatingPanel.js.map +1 -1
  294. package/dist/internal/chart.d.ts +4 -0
  295. package/dist/internal/chart.js +89 -19
  296. package/dist/internal/chart.js.map +1 -1
  297. package/dist/internal/codeSpans.js +20 -0
  298. package/dist/internal/codeSpans.js.map +1 -0
  299. package/dist/internal/dev.js +9 -4
  300. package/dist/internal/dev.js.map +1 -1
  301. package/dist/internal/focus.js +27 -3
  302. package/dist/internal/focus.js.map +1 -1
  303. package/dist/internal/focusMain.js +6 -2
  304. package/dist/internal/focusMain.js.map +1 -1
  305. package/dist/internal/open.d.ts +14 -0
  306. package/dist/internal/open.js +28 -0
  307. package/dist/internal/open.js.map +1 -0
  308. package/dist/internal/roving.js +37 -0
  309. package/dist/internal/roving.js.map +1 -0
  310. package/dist/internal/shell.js +12 -0
  311. package/dist/internal/shell.js.map +1 -0
  312. package/dist/internal/stored.js +89 -0
  313. package/dist/internal/stored.js.map +1 -0
  314. package/dist/internal/tableTools.js +46 -4
  315. package/dist/internal/tableTools.js.map +1 -1
  316. package/dist/internal/util.js +8 -17
  317. package/dist/internal/util.js.map +1 -1
  318. package/dist/locale.d.ts +17 -0
  319. package/dist/locale.js +29 -0
  320. package/dist/locale.js.map +1 -0
  321. package/dist/styles.css +1296 -400
  322. package/dist/theme.d.ts +23 -5
  323. package/dist/theme.js +85 -25
  324. package/dist/theme.js.map +1 -1
  325. package/dist/tokens.css +3 -0
  326. package/docs/AccentPicker.md +3 -1
  327. package/docs/Alert.md +4 -3
  328. package/docs/AppShell.md +11 -10
  329. package/docs/Badge.md +26 -16
  330. package/docs/BarChart.md +7 -4
  331. package/docs/Button.md +4 -5
  332. package/docs/Calendar.md +2 -2
  333. package/docs/Card.md +9 -8
  334. package/docs/Checkbox.md +4 -1
  335. package/docs/CodeView.md +30 -43
  336. package/docs/CommandPalette.md +3 -2
  337. package/docs/ConsoleLayout.md +5 -5
  338. package/docs/DangerZone.md +3 -2
  339. package/docs/DataColors.md +2 -2
  340. package/docs/DataTable.md +29 -141
  341. package/docs/DatePicker.md +1 -0
  342. package/docs/DateRangePicker.md +3 -0
  343. package/docs/DetailList.md +9 -9
  344. package/docs/Dialog.md +8 -4
  345. package/docs/Drawer.md +7 -4
  346. package/docs/ErrorPage.md +1 -1
  347. package/docs/EventTimeline.md +23 -12
  348. package/docs/FileUpload.md +1 -1
  349. package/docs/FormGrid.md +2 -1
  350. package/docs/Format.md +5 -3
  351. package/docs/Graph.md +1 -1
  352. package/docs/Grid.md +5 -1
  353. package/docs/KpiCard.md +6 -4
  354. package/docs/LayerGraph.md +18 -53
  355. package/docs/LineChart.md +5 -3
  356. package/docs/Link.md +22 -0
  357. package/docs/LoginCard.md +7 -3
  358. package/docs/Markdown.md +3 -13
  359. package/docs/Menu.md +2 -0
  360. package/docs/Meter.md +1 -0
  361. package/docs/MultiSelect.md +2 -1
  362. package/docs/NotificationBell.md +1 -0
  363. package/docs/PageHeader.md +34 -0
  364. package/docs/Popover.md +3 -1
  365. package/docs/ProgressBar.md +3 -1
  366. package/docs/ProjectSwitcher.md +14 -14
  367. package/docs/RadioGroup.md +2 -0
  368. package/docs/RelativeTime.md +23 -0
  369. package/docs/Section.md +1 -1
  370. package/docs/SegmentedControl.md +9 -6
  371. package/docs/Select.md +2 -1
  372. package/docs/SettingsLayout.md +19 -4
  373. package/docs/SideNav.md +1 -1
  374. package/docs/Skeleton.md +2 -1
  375. package/docs/Switch.md +3 -1
  376. package/docs/Tabs.md +4 -3
  377. package/docs/Tag.md +9 -7
  378. package/docs/Term.md +3 -3
  379. package/docs/TextArea.md +2 -1
  380. package/docs/TextField.md +5 -3
  381. package/docs/ThemePicker.md +3 -1
  382. package/docs/Toast.md +17 -5
  383. package/docs/TopBar.md +8 -5
  384. package/docs/Tour.md +3 -2
  385. package/docs/TreeList.md +10 -37
  386. package/docs/Workbench.md +1 -48
  387. package/docs/ZoneMap.md +5 -5
  388. package/docs/agents.md +82 -0
  389. package/docs/code.md +2 -2
  390. package/docs/components.json +314 -0
  391. package/docs/data.md +9 -18
  392. package/docs/forms.md +6 -5
  393. package/docs/guidelines.md +39 -31
  394. package/docs/icons.md +9 -0
  395. package/docs/layout.md +16 -20
  396. package/docs/motion.md +31 -56
  397. package/docs/theme.md +15 -18
  398. package/docs/useFormErrors.md +35 -0
  399. package/package.json +8 -7
  400. package/dist/bundle.js.map +0 -1
  401. package/dist/fonts/LICENSE-OFL.txt +0 -93
  402. package/dist/fonts/geist-mono-cyrillic-400-normal.woff2 +0 -0
  403. package/dist/fonts/geist-mono-cyrillic-500-normal.woff2 +0 -0
  404. package/dist/fonts/geist-mono-cyrillic-600-normal.woff2 +0 -0
  405. package/dist/fonts/geist-mono-cyrillic-700-normal.woff2 +0 -0
  406. package/dist/fonts/geist-mono-cyrillic-ext-400-normal.woff2 +0 -0
  407. package/dist/fonts/geist-mono-cyrillic-ext-500-normal.woff2 +0 -0
  408. package/dist/fonts/geist-mono-cyrillic-ext-600-normal.woff2 +0 -0
  409. package/dist/fonts/geist-mono-cyrillic-ext-700-normal.woff2 +0 -0
  410. package/dist/fonts/geist-mono-latin-400-normal.woff2 +0 -0
  411. package/dist/fonts/geist-mono-latin-500-normal.woff2 +0 -0
  412. package/dist/fonts/geist-mono-latin-600-normal.woff2 +0 -0
  413. package/dist/fonts/geist-mono-latin-700-normal.woff2 +0 -0
  414. package/dist/fonts/geist-mono-latin-ext-400-normal.woff2 +0 -0
  415. package/dist/fonts/geist-mono-latin-ext-500-normal.woff2 +0 -0
  416. package/dist/fonts/geist-mono-latin-ext-600-normal.woff2 +0 -0
  417. package/dist/fonts/geist-mono-latin-ext-700-normal.woff2 +0 -0
  418. package/dist/fonts/geist-mono-symbols2-400-normal.woff2 +0 -0
  419. package/dist/fonts/geist-mono-symbols2-500-normal.woff2 +0 -0
  420. package/dist/fonts/geist-mono-symbols2-600-normal.woff2 +0 -0
  421. package/dist/fonts/geist-mono-symbols2-700-normal.woff2 +0 -0
  422. package/dist/fonts/geist-mono-vietnamese-400-normal.woff2 +0 -0
  423. package/dist/fonts/geist-mono-vietnamese-500-normal.woff2 +0 -0
  424. package/dist/fonts/geist-mono-vietnamese-600-normal.woff2 +0 -0
  425. package/dist/fonts/geist-mono-vietnamese-700-normal.woff2 +0 -0
  426. package/dist/fonts/inter-cyrillic-400-normal.woff2 +0 -0
  427. package/dist/fonts/inter-cyrillic-500-normal.woff2 +0 -0
  428. package/dist/fonts/inter-cyrillic-600-normal.woff2 +0 -0
  429. package/dist/fonts/inter-cyrillic-700-normal.woff2 +0 -0
  430. package/dist/fonts/inter-cyrillic-ext-400-normal.woff2 +0 -0
  431. package/dist/fonts/inter-cyrillic-ext-500-normal.woff2 +0 -0
  432. package/dist/fonts/inter-cyrillic-ext-600-normal.woff2 +0 -0
  433. package/dist/fonts/inter-cyrillic-ext-700-normal.woff2 +0 -0
  434. package/dist/fonts/inter-greek-400-normal.woff2 +0 -0
  435. package/dist/fonts/inter-greek-500-normal.woff2 +0 -0
  436. package/dist/fonts/inter-greek-600-normal.woff2 +0 -0
  437. package/dist/fonts/inter-greek-700-normal.woff2 +0 -0
  438. package/dist/fonts/inter-greek-ext-400-normal.woff2 +0 -0
  439. package/dist/fonts/inter-greek-ext-500-normal.woff2 +0 -0
  440. package/dist/fonts/inter-greek-ext-600-normal.woff2 +0 -0
  441. package/dist/fonts/inter-greek-ext-700-normal.woff2 +0 -0
  442. package/dist/fonts/inter-latin-400-normal.woff2 +0 -0
  443. package/dist/fonts/inter-latin-500-normal.woff2 +0 -0
  444. package/dist/fonts/inter-latin-600-normal.woff2 +0 -0
  445. package/dist/fonts/inter-latin-700-normal.woff2 +0 -0
  446. package/dist/fonts/inter-latin-ext-400-normal.woff2 +0 -0
  447. package/dist/fonts/inter-latin-ext-500-normal.woff2 +0 -0
  448. package/dist/fonts/inter-latin-ext-600-normal.woff2 +0 -0
  449. package/dist/fonts/inter-latin-ext-700-normal.woff2 +0 -0
  450. package/dist/fonts/inter-vietnamese-400-normal.woff2 +0 -0
  451. package/dist/fonts/inter-vietnamese-500-normal.woff2 +0 -0
  452. package/dist/fonts/inter-vietnamese-600-normal.woff2 +0 -0
  453. package/dist/fonts/inter-vietnamese-700-normal.woff2 +0 -0
  454. package/dist/fonts/noto-sans-tc-0-400-normal.woff2 +0 -0
  455. package/dist/fonts/noto-sans-tc-0-500-normal.woff2 +0 -0
  456. package/dist/fonts/noto-sans-tc-0-600-normal.woff2 +0 -0
  457. package/dist/fonts/noto-sans-tc-0-700-normal.woff2 +0 -0
  458. package/dist/fonts/noto-sans-tc-1-400-normal.woff2 +0 -0
  459. package/dist/fonts/noto-sans-tc-1-500-normal.woff2 +0 -0
  460. package/dist/fonts/noto-sans-tc-1-600-normal.woff2 +0 -0
  461. package/dist/fonts/noto-sans-tc-1-700-normal.woff2 +0 -0
  462. package/dist/fonts/noto-sans-tc-10-400-normal.woff2 +0 -0
  463. package/dist/fonts/noto-sans-tc-10-500-normal.woff2 +0 -0
  464. package/dist/fonts/noto-sans-tc-10-600-normal.woff2 +0 -0
  465. package/dist/fonts/noto-sans-tc-10-700-normal.woff2 +0 -0
  466. package/dist/fonts/noto-sans-tc-101-400-normal.woff2 +0 -0
  467. package/dist/fonts/noto-sans-tc-101-500-normal.woff2 +0 -0
  468. package/dist/fonts/noto-sans-tc-101-600-normal.woff2 +0 -0
  469. package/dist/fonts/noto-sans-tc-101-700-normal.woff2 +0 -0
  470. package/dist/fonts/noto-sans-tc-102-400-normal.woff2 +0 -0
  471. package/dist/fonts/noto-sans-tc-102-500-normal.woff2 +0 -0
  472. package/dist/fonts/noto-sans-tc-102-600-normal.woff2 +0 -0
  473. package/dist/fonts/noto-sans-tc-102-700-normal.woff2 +0 -0
  474. package/dist/fonts/noto-sans-tc-103-400-normal.woff2 +0 -0
  475. package/dist/fonts/noto-sans-tc-103-500-normal.woff2 +0 -0
  476. package/dist/fonts/noto-sans-tc-103-600-normal.woff2 +0 -0
  477. package/dist/fonts/noto-sans-tc-103-700-normal.woff2 +0 -0
  478. package/dist/fonts/noto-sans-tc-104-400-normal.woff2 +0 -0
  479. package/dist/fonts/noto-sans-tc-104-500-normal.woff2 +0 -0
  480. package/dist/fonts/noto-sans-tc-104-600-normal.woff2 +0 -0
  481. package/dist/fonts/noto-sans-tc-104-700-normal.woff2 +0 -0
  482. package/dist/fonts/noto-sans-tc-105-400-normal.woff2 +0 -0
  483. package/dist/fonts/noto-sans-tc-105-500-normal.woff2 +0 -0
  484. package/dist/fonts/noto-sans-tc-105-600-normal.woff2 +0 -0
  485. package/dist/fonts/noto-sans-tc-105-700-normal.woff2 +0 -0
  486. package/dist/fonts/noto-sans-tc-106-400-normal.woff2 +0 -0
  487. package/dist/fonts/noto-sans-tc-106-500-normal.woff2 +0 -0
  488. package/dist/fonts/noto-sans-tc-106-600-normal.woff2 +0 -0
  489. package/dist/fonts/noto-sans-tc-106-700-normal.woff2 +0 -0
  490. package/dist/fonts/noto-sans-tc-107-400-normal.woff2 +0 -0
  491. package/dist/fonts/noto-sans-tc-107-500-normal.woff2 +0 -0
  492. package/dist/fonts/noto-sans-tc-107-600-normal.woff2 +0 -0
  493. package/dist/fonts/noto-sans-tc-107-700-normal.woff2 +0 -0
  494. package/dist/fonts/noto-sans-tc-108-400-normal.woff2 +0 -0
  495. package/dist/fonts/noto-sans-tc-108-500-normal.woff2 +0 -0
  496. package/dist/fonts/noto-sans-tc-108-600-normal.woff2 +0 -0
  497. package/dist/fonts/noto-sans-tc-108-700-normal.woff2 +0 -0
  498. package/dist/fonts/noto-sans-tc-109-400-normal.woff2 +0 -0
  499. package/dist/fonts/noto-sans-tc-109-500-normal.woff2 +0 -0
  500. package/dist/fonts/noto-sans-tc-109-600-normal.woff2 +0 -0
  501. package/dist/fonts/noto-sans-tc-109-700-normal.woff2 +0 -0
  502. package/dist/fonts/noto-sans-tc-11-400-normal.woff2 +0 -0
  503. package/dist/fonts/noto-sans-tc-11-500-normal.woff2 +0 -0
  504. package/dist/fonts/noto-sans-tc-11-600-normal.woff2 +0 -0
  505. package/dist/fonts/noto-sans-tc-11-700-normal.woff2 +0 -0
  506. package/dist/fonts/noto-sans-tc-110-400-normal.woff2 +0 -0
  507. package/dist/fonts/noto-sans-tc-110-500-normal.woff2 +0 -0
  508. package/dist/fonts/noto-sans-tc-110-600-normal.woff2 +0 -0
  509. package/dist/fonts/noto-sans-tc-110-700-normal.woff2 +0 -0
  510. package/dist/fonts/noto-sans-tc-111-400-normal.woff2 +0 -0
  511. package/dist/fonts/noto-sans-tc-111-500-normal.woff2 +0 -0
  512. package/dist/fonts/noto-sans-tc-111-600-normal.woff2 +0 -0
  513. package/dist/fonts/noto-sans-tc-111-700-normal.woff2 +0 -0
  514. package/dist/fonts/noto-sans-tc-112-400-normal.woff2 +0 -0
  515. package/dist/fonts/noto-sans-tc-112-500-normal.woff2 +0 -0
  516. package/dist/fonts/noto-sans-tc-112-600-normal.woff2 +0 -0
  517. package/dist/fonts/noto-sans-tc-112-700-normal.woff2 +0 -0
  518. package/dist/fonts/noto-sans-tc-113-400-normal.woff2 +0 -0
  519. package/dist/fonts/noto-sans-tc-113-500-normal.woff2 +0 -0
  520. package/dist/fonts/noto-sans-tc-113-600-normal.woff2 +0 -0
  521. package/dist/fonts/noto-sans-tc-113-700-normal.woff2 +0 -0
  522. package/dist/fonts/noto-sans-tc-114-400-normal.woff2 +0 -0
  523. package/dist/fonts/noto-sans-tc-114-500-normal.woff2 +0 -0
  524. package/dist/fonts/noto-sans-tc-114-600-normal.woff2 +0 -0
  525. package/dist/fonts/noto-sans-tc-114-700-normal.woff2 +0 -0
  526. package/dist/fonts/noto-sans-tc-115-400-normal.woff2 +0 -0
  527. package/dist/fonts/noto-sans-tc-115-500-normal.woff2 +0 -0
  528. package/dist/fonts/noto-sans-tc-115-600-normal.woff2 +0 -0
  529. package/dist/fonts/noto-sans-tc-115-700-normal.woff2 +0 -0
  530. package/dist/fonts/noto-sans-tc-116-400-normal.woff2 +0 -0
  531. package/dist/fonts/noto-sans-tc-116-500-normal.woff2 +0 -0
  532. package/dist/fonts/noto-sans-tc-116-600-normal.woff2 +0 -0
  533. package/dist/fonts/noto-sans-tc-116-700-normal.woff2 +0 -0
  534. package/dist/fonts/noto-sans-tc-117-400-normal.woff2 +0 -0
  535. package/dist/fonts/noto-sans-tc-117-500-normal.woff2 +0 -0
  536. package/dist/fonts/noto-sans-tc-117-600-normal.woff2 +0 -0
  537. package/dist/fonts/noto-sans-tc-117-700-normal.woff2 +0 -0
  538. package/dist/fonts/noto-sans-tc-118-400-normal.woff2 +0 -0
  539. package/dist/fonts/noto-sans-tc-118-500-normal.woff2 +0 -0
  540. package/dist/fonts/noto-sans-tc-118-600-normal.woff2 +0 -0
  541. package/dist/fonts/noto-sans-tc-118-700-normal.woff2 +0 -0
  542. package/dist/fonts/noto-sans-tc-119-400-normal.woff2 +0 -0
  543. package/dist/fonts/noto-sans-tc-119-500-normal.woff2 +0 -0
  544. package/dist/fonts/noto-sans-tc-119-600-normal.woff2 +0 -0
  545. package/dist/fonts/noto-sans-tc-119-700-normal.woff2 +0 -0
  546. package/dist/fonts/noto-sans-tc-12-400-normal.woff2 +0 -0
  547. package/dist/fonts/noto-sans-tc-12-500-normal.woff2 +0 -0
  548. package/dist/fonts/noto-sans-tc-12-600-normal.woff2 +0 -0
  549. package/dist/fonts/noto-sans-tc-12-700-normal.woff2 +0 -0
  550. package/dist/fonts/noto-sans-tc-120-400-normal.woff2 +0 -0
  551. package/dist/fonts/noto-sans-tc-120-500-normal.woff2 +0 -0
  552. package/dist/fonts/noto-sans-tc-120-600-normal.woff2 +0 -0
  553. package/dist/fonts/noto-sans-tc-120-700-normal.woff2 +0 -0
  554. package/dist/fonts/noto-sans-tc-121-400-normal.woff2 +0 -0
  555. package/dist/fonts/noto-sans-tc-121-500-normal.woff2 +0 -0
  556. package/dist/fonts/noto-sans-tc-121-600-normal.woff2 +0 -0
  557. package/dist/fonts/noto-sans-tc-121-700-normal.woff2 +0 -0
  558. package/dist/fonts/noto-sans-tc-122-400-normal.woff2 +0 -0
  559. package/dist/fonts/noto-sans-tc-122-500-normal.woff2 +0 -0
  560. package/dist/fonts/noto-sans-tc-122-600-normal.woff2 +0 -0
  561. package/dist/fonts/noto-sans-tc-122-700-normal.woff2 +0 -0
  562. package/dist/fonts/noto-sans-tc-123-400-normal.woff2 +0 -0
  563. package/dist/fonts/noto-sans-tc-123-500-normal.woff2 +0 -0
  564. package/dist/fonts/noto-sans-tc-123-600-normal.woff2 +0 -0
  565. package/dist/fonts/noto-sans-tc-123-700-normal.woff2 +0 -0
  566. package/dist/fonts/noto-sans-tc-2-400-normal.woff2 +0 -0
  567. package/dist/fonts/noto-sans-tc-2-500-normal.woff2 +0 -0
  568. package/dist/fonts/noto-sans-tc-2-600-normal.woff2 +0 -0
  569. package/dist/fonts/noto-sans-tc-2-700-normal.woff2 +0 -0
  570. package/dist/fonts/noto-sans-tc-23-400-normal.woff2 +0 -0
  571. package/dist/fonts/noto-sans-tc-23-500-normal.woff2 +0 -0
  572. package/dist/fonts/noto-sans-tc-23-600-normal.woff2 +0 -0
  573. package/dist/fonts/noto-sans-tc-23-700-normal.woff2 +0 -0
  574. package/dist/fonts/noto-sans-tc-24-400-normal.woff2 +0 -0
  575. package/dist/fonts/noto-sans-tc-24-500-normal.woff2 +0 -0
  576. package/dist/fonts/noto-sans-tc-24-600-normal.woff2 +0 -0
  577. package/dist/fonts/noto-sans-tc-24-700-normal.woff2 +0 -0
  578. package/dist/fonts/noto-sans-tc-25-400-normal.woff2 +0 -0
  579. package/dist/fonts/noto-sans-tc-25-500-normal.woff2 +0 -0
  580. package/dist/fonts/noto-sans-tc-25-600-normal.woff2 +0 -0
  581. package/dist/fonts/noto-sans-tc-25-700-normal.woff2 +0 -0
  582. package/dist/fonts/noto-sans-tc-26-400-normal.woff2 +0 -0
  583. package/dist/fonts/noto-sans-tc-26-500-normal.woff2 +0 -0
  584. package/dist/fonts/noto-sans-tc-26-600-normal.woff2 +0 -0
  585. package/dist/fonts/noto-sans-tc-26-700-normal.woff2 +0 -0
  586. package/dist/fonts/noto-sans-tc-27-400-normal.woff2 +0 -0
  587. package/dist/fonts/noto-sans-tc-27-500-normal.woff2 +0 -0
  588. package/dist/fonts/noto-sans-tc-27-600-normal.woff2 +0 -0
  589. package/dist/fonts/noto-sans-tc-27-700-normal.woff2 +0 -0
  590. package/dist/fonts/noto-sans-tc-28-400-normal.woff2 +0 -0
  591. package/dist/fonts/noto-sans-tc-28-500-normal.woff2 +0 -0
  592. package/dist/fonts/noto-sans-tc-28-600-normal.woff2 +0 -0
  593. package/dist/fonts/noto-sans-tc-28-700-normal.woff2 +0 -0
  594. package/dist/fonts/noto-sans-tc-29-400-normal.woff2 +0 -0
  595. package/dist/fonts/noto-sans-tc-29-500-normal.woff2 +0 -0
  596. package/dist/fonts/noto-sans-tc-29-600-normal.woff2 +0 -0
  597. package/dist/fonts/noto-sans-tc-29-700-normal.woff2 +0 -0
  598. package/dist/fonts/noto-sans-tc-30-400-normal.woff2 +0 -0
  599. package/dist/fonts/noto-sans-tc-30-500-normal.woff2 +0 -0
  600. package/dist/fonts/noto-sans-tc-30-600-normal.woff2 +0 -0
  601. package/dist/fonts/noto-sans-tc-30-700-normal.woff2 +0 -0
  602. package/dist/fonts/noto-sans-tc-31-400-normal.woff2 +0 -0
  603. package/dist/fonts/noto-sans-tc-31-500-normal.woff2 +0 -0
  604. package/dist/fonts/noto-sans-tc-31-600-normal.woff2 +0 -0
  605. package/dist/fonts/noto-sans-tc-31-700-normal.woff2 +0 -0
  606. package/dist/fonts/noto-sans-tc-32-400-normal.woff2 +0 -0
  607. package/dist/fonts/noto-sans-tc-32-500-normal.woff2 +0 -0
  608. package/dist/fonts/noto-sans-tc-32-600-normal.woff2 +0 -0
  609. package/dist/fonts/noto-sans-tc-32-700-normal.woff2 +0 -0
  610. package/dist/fonts/noto-sans-tc-33-400-normal.woff2 +0 -0
  611. package/dist/fonts/noto-sans-tc-33-500-normal.woff2 +0 -0
  612. package/dist/fonts/noto-sans-tc-33-600-normal.woff2 +0 -0
  613. package/dist/fonts/noto-sans-tc-33-700-normal.woff2 +0 -0
  614. package/dist/fonts/noto-sans-tc-34-400-normal.woff2 +0 -0
  615. package/dist/fonts/noto-sans-tc-34-500-normal.woff2 +0 -0
  616. package/dist/fonts/noto-sans-tc-34-600-normal.woff2 +0 -0
  617. package/dist/fonts/noto-sans-tc-34-700-normal.woff2 +0 -0
  618. package/dist/fonts/noto-sans-tc-35-400-normal.woff2 +0 -0
  619. package/dist/fonts/noto-sans-tc-35-500-normal.woff2 +0 -0
  620. package/dist/fonts/noto-sans-tc-35-600-normal.woff2 +0 -0
  621. package/dist/fonts/noto-sans-tc-35-700-normal.woff2 +0 -0
  622. package/dist/fonts/noto-sans-tc-36-400-normal.woff2 +0 -0
  623. package/dist/fonts/noto-sans-tc-36-500-normal.woff2 +0 -0
  624. package/dist/fonts/noto-sans-tc-36-600-normal.woff2 +0 -0
  625. package/dist/fonts/noto-sans-tc-36-700-normal.woff2 +0 -0
  626. package/dist/fonts/noto-sans-tc-37-400-normal.woff2 +0 -0
  627. package/dist/fonts/noto-sans-tc-37-500-normal.woff2 +0 -0
  628. package/dist/fonts/noto-sans-tc-37-600-normal.woff2 +0 -0
  629. package/dist/fonts/noto-sans-tc-37-700-normal.woff2 +0 -0
  630. package/dist/fonts/noto-sans-tc-38-400-normal.woff2 +0 -0
  631. package/dist/fonts/noto-sans-tc-38-500-normal.woff2 +0 -0
  632. package/dist/fonts/noto-sans-tc-38-600-normal.woff2 +0 -0
  633. package/dist/fonts/noto-sans-tc-38-700-normal.woff2 +0 -0
  634. package/dist/fonts/noto-sans-tc-39-400-normal.woff2 +0 -0
  635. package/dist/fonts/noto-sans-tc-39-500-normal.woff2 +0 -0
  636. package/dist/fonts/noto-sans-tc-39-600-normal.woff2 +0 -0
  637. package/dist/fonts/noto-sans-tc-39-700-normal.woff2 +0 -0
  638. package/dist/fonts/noto-sans-tc-4-400-normal.woff2 +0 -0
  639. package/dist/fonts/noto-sans-tc-4-500-normal.woff2 +0 -0
  640. package/dist/fonts/noto-sans-tc-4-600-normal.woff2 +0 -0
  641. package/dist/fonts/noto-sans-tc-4-700-normal.woff2 +0 -0
  642. package/dist/fonts/noto-sans-tc-40-400-normal.woff2 +0 -0
  643. package/dist/fonts/noto-sans-tc-40-500-normal.woff2 +0 -0
  644. package/dist/fonts/noto-sans-tc-40-600-normal.woff2 +0 -0
  645. package/dist/fonts/noto-sans-tc-40-700-normal.woff2 +0 -0
  646. package/dist/fonts/noto-sans-tc-41-400-normal.woff2 +0 -0
  647. package/dist/fonts/noto-sans-tc-41-500-normal.woff2 +0 -0
  648. package/dist/fonts/noto-sans-tc-41-600-normal.woff2 +0 -0
  649. package/dist/fonts/noto-sans-tc-41-700-normal.woff2 +0 -0
  650. package/dist/fonts/noto-sans-tc-42-400-normal.woff2 +0 -0
  651. package/dist/fonts/noto-sans-tc-42-500-normal.woff2 +0 -0
  652. package/dist/fonts/noto-sans-tc-42-600-normal.woff2 +0 -0
  653. package/dist/fonts/noto-sans-tc-42-700-normal.woff2 +0 -0
  654. package/dist/fonts/noto-sans-tc-43-400-normal.woff2 +0 -0
  655. package/dist/fonts/noto-sans-tc-43-500-normal.woff2 +0 -0
  656. package/dist/fonts/noto-sans-tc-43-600-normal.woff2 +0 -0
  657. package/dist/fonts/noto-sans-tc-43-700-normal.woff2 +0 -0
  658. package/dist/fonts/noto-sans-tc-44-400-normal.woff2 +0 -0
  659. package/dist/fonts/noto-sans-tc-44-500-normal.woff2 +0 -0
  660. package/dist/fonts/noto-sans-tc-44-600-normal.woff2 +0 -0
  661. package/dist/fonts/noto-sans-tc-44-700-normal.woff2 +0 -0
  662. package/dist/fonts/noto-sans-tc-45-400-normal.woff2 +0 -0
  663. package/dist/fonts/noto-sans-tc-45-500-normal.woff2 +0 -0
  664. package/dist/fonts/noto-sans-tc-45-600-normal.woff2 +0 -0
  665. package/dist/fonts/noto-sans-tc-45-700-normal.woff2 +0 -0
  666. package/dist/fonts/noto-sans-tc-46-400-normal.woff2 +0 -0
  667. package/dist/fonts/noto-sans-tc-46-500-normal.woff2 +0 -0
  668. package/dist/fonts/noto-sans-tc-46-600-normal.woff2 +0 -0
  669. package/dist/fonts/noto-sans-tc-46-700-normal.woff2 +0 -0
  670. package/dist/fonts/noto-sans-tc-47-400-normal.woff2 +0 -0
  671. package/dist/fonts/noto-sans-tc-47-500-normal.woff2 +0 -0
  672. package/dist/fonts/noto-sans-tc-47-600-normal.woff2 +0 -0
  673. package/dist/fonts/noto-sans-tc-47-700-normal.woff2 +0 -0
  674. package/dist/fonts/noto-sans-tc-48-400-normal.woff2 +0 -0
  675. package/dist/fonts/noto-sans-tc-48-500-normal.woff2 +0 -0
  676. package/dist/fonts/noto-sans-tc-48-600-normal.woff2 +0 -0
  677. package/dist/fonts/noto-sans-tc-48-700-normal.woff2 +0 -0
  678. package/dist/fonts/noto-sans-tc-49-400-normal.woff2 +0 -0
  679. package/dist/fonts/noto-sans-tc-49-500-normal.woff2 +0 -0
  680. package/dist/fonts/noto-sans-tc-49-600-normal.woff2 +0 -0
  681. package/dist/fonts/noto-sans-tc-49-700-normal.woff2 +0 -0
  682. package/dist/fonts/noto-sans-tc-50-400-normal.woff2 +0 -0
  683. package/dist/fonts/noto-sans-tc-50-500-normal.woff2 +0 -0
  684. package/dist/fonts/noto-sans-tc-50-600-normal.woff2 +0 -0
  685. package/dist/fonts/noto-sans-tc-50-700-normal.woff2 +0 -0
  686. package/dist/fonts/noto-sans-tc-51-400-normal.woff2 +0 -0
  687. package/dist/fonts/noto-sans-tc-51-500-normal.woff2 +0 -0
  688. package/dist/fonts/noto-sans-tc-51-600-normal.woff2 +0 -0
  689. package/dist/fonts/noto-sans-tc-51-700-normal.woff2 +0 -0
  690. package/dist/fonts/noto-sans-tc-52-400-normal.woff2 +0 -0
  691. package/dist/fonts/noto-sans-tc-52-500-normal.woff2 +0 -0
  692. package/dist/fonts/noto-sans-tc-52-600-normal.woff2 +0 -0
  693. package/dist/fonts/noto-sans-tc-52-700-normal.woff2 +0 -0
  694. package/dist/fonts/noto-sans-tc-53-400-normal.woff2 +0 -0
  695. package/dist/fonts/noto-sans-tc-53-500-normal.woff2 +0 -0
  696. package/dist/fonts/noto-sans-tc-53-600-normal.woff2 +0 -0
  697. package/dist/fonts/noto-sans-tc-53-700-normal.woff2 +0 -0
  698. package/dist/fonts/noto-sans-tc-54-400-normal.woff2 +0 -0
  699. package/dist/fonts/noto-sans-tc-54-500-normal.woff2 +0 -0
  700. package/dist/fonts/noto-sans-tc-54-600-normal.woff2 +0 -0
  701. package/dist/fonts/noto-sans-tc-54-700-normal.woff2 +0 -0
  702. package/dist/fonts/noto-sans-tc-55-400-normal.woff2 +0 -0
  703. package/dist/fonts/noto-sans-tc-55-500-normal.woff2 +0 -0
  704. package/dist/fonts/noto-sans-tc-55-600-normal.woff2 +0 -0
  705. package/dist/fonts/noto-sans-tc-55-700-normal.woff2 +0 -0
  706. package/dist/fonts/noto-sans-tc-56-400-normal.woff2 +0 -0
  707. package/dist/fonts/noto-sans-tc-56-500-normal.woff2 +0 -0
  708. package/dist/fonts/noto-sans-tc-56-600-normal.woff2 +0 -0
  709. package/dist/fonts/noto-sans-tc-56-700-normal.woff2 +0 -0
  710. package/dist/fonts/noto-sans-tc-57-400-normal.woff2 +0 -0
  711. package/dist/fonts/noto-sans-tc-57-500-normal.woff2 +0 -0
  712. package/dist/fonts/noto-sans-tc-57-600-normal.woff2 +0 -0
  713. package/dist/fonts/noto-sans-tc-57-700-normal.woff2 +0 -0
  714. package/dist/fonts/noto-sans-tc-58-400-normal.woff2 +0 -0
  715. package/dist/fonts/noto-sans-tc-58-500-normal.woff2 +0 -0
  716. package/dist/fonts/noto-sans-tc-58-600-normal.woff2 +0 -0
  717. package/dist/fonts/noto-sans-tc-58-700-normal.woff2 +0 -0
  718. package/dist/fonts/noto-sans-tc-59-400-normal.woff2 +0 -0
  719. package/dist/fonts/noto-sans-tc-59-500-normal.woff2 +0 -0
  720. package/dist/fonts/noto-sans-tc-59-600-normal.woff2 +0 -0
  721. package/dist/fonts/noto-sans-tc-59-700-normal.woff2 +0 -0
  722. package/dist/fonts/noto-sans-tc-60-400-normal.woff2 +0 -0
  723. package/dist/fonts/noto-sans-tc-60-500-normal.woff2 +0 -0
  724. package/dist/fonts/noto-sans-tc-60-600-normal.woff2 +0 -0
  725. package/dist/fonts/noto-sans-tc-60-700-normal.woff2 +0 -0
  726. package/dist/fonts/noto-sans-tc-61-400-normal.woff2 +0 -0
  727. package/dist/fonts/noto-sans-tc-61-500-normal.woff2 +0 -0
  728. package/dist/fonts/noto-sans-tc-61-600-normal.woff2 +0 -0
  729. package/dist/fonts/noto-sans-tc-61-700-normal.woff2 +0 -0
  730. package/dist/fonts/noto-sans-tc-62-400-normal.woff2 +0 -0
  731. package/dist/fonts/noto-sans-tc-62-500-normal.woff2 +0 -0
  732. package/dist/fonts/noto-sans-tc-62-600-normal.woff2 +0 -0
  733. package/dist/fonts/noto-sans-tc-62-700-normal.woff2 +0 -0
  734. package/dist/fonts/noto-sans-tc-63-400-normal.woff2 +0 -0
  735. package/dist/fonts/noto-sans-tc-63-500-normal.woff2 +0 -0
  736. package/dist/fonts/noto-sans-tc-63-600-normal.woff2 +0 -0
  737. package/dist/fonts/noto-sans-tc-63-700-normal.woff2 +0 -0
  738. package/dist/fonts/noto-sans-tc-64-400-normal.woff2 +0 -0
  739. package/dist/fonts/noto-sans-tc-64-500-normal.woff2 +0 -0
  740. package/dist/fonts/noto-sans-tc-64-600-normal.woff2 +0 -0
  741. package/dist/fonts/noto-sans-tc-64-700-normal.woff2 +0 -0
  742. package/dist/fonts/noto-sans-tc-65-400-normal.woff2 +0 -0
  743. package/dist/fonts/noto-sans-tc-65-500-normal.woff2 +0 -0
  744. package/dist/fonts/noto-sans-tc-65-600-normal.woff2 +0 -0
  745. package/dist/fonts/noto-sans-tc-65-700-normal.woff2 +0 -0
  746. package/dist/fonts/noto-sans-tc-66-400-normal.woff2 +0 -0
  747. package/dist/fonts/noto-sans-tc-66-500-normal.woff2 +0 -0
  748. package/dist/fonts/noto-sans-tc-66-600-normal.woff2 +0 -0
  749. package/dist/fonts/noto-sans-tc-66-700-normal.woff2 +0 -0
  750. package/dist/fonts/noto-sans-tc-67-400-normal.woff2 +0 -0
  751. package/dist/fonts/noto-sans-tc-67-500-normal.woff2 +0 -0
  752. package/dist/fonts/noto-sans-tc-67-600-normal.woff2 +0 -0
  753. package/dist/fonts/noto-sans-tc-67-700-normal.woff2 +0 -0
  754. package/dist/fonts/noto-sans-tc-68-400-normal.woff2 +0 -0
  755. package/dist/fonts/noto-sans-tc-68-500-normal.woff2 +0 -0
  756. package/dist/fonts/noto-sans-tc-68-600-normal.woff2 +0 -0
  757. package/dist/fonts/noto-sans-tc-68-700-normal.woff2 +0 -0
  758. package/dist/fonts/noto-sans-tc-69-400-normal.woff2 +0 -0
  759. package/dist/fonts/noto-sans-tc-69-500-normal.woff2 +0 -0
  760. package/dist/fonts/noto-sans-tc-69-600-normal.woff2 +0 -0
  761. package/dist/fonts/noto-sans-tc-69-700-normal.woff2 +0 -0
  762. package/dist/fonts/noto-sans-tc-70-400-normal.woff2 +0 -0
  763. package/dist/fonts/noto-sans-tc-70-500-normal.woff2 +0 -0
  764. package/dist/fonts/noto-sans-tc-70-600-normal.woff2 +0 -0
  765. package/dist/fonts/noto-sans-tc-70-700-normal.woff2 +0 -0
  766. package/dist/fonts/noto-sans-tc-71-400-normal.woff2 +0 -0
  767. package/dist/fonts/noto-sans-tc-71-500-normal.woff2 +0 -0
  768. package/dist/fonts/noto-sans-tc-71-600-normal.woff2 +0 -0
  769. package/dist/fonts/noto-sans-tc-71-700-normal.woff2 +0 -0
  770. package/dist/fonts/noto-sans-tc-72-400-normal.woff2 +0 -0
  771. package/dist/fonts/noto-sans-tc-72-500-normal.woff2 +0 -0
  772. package/dist/fonts/noto-sans-tc-72-600-normal.woff2 +0 -0
  773. package/dist/fonts/noto-sans-tc-72-700-normal.woff2 +0 -0
  774. package/dist/fonts/noto-sans-tc-73-400-normal.woff2 +0 -0
  775. package/dist/fonts/noto-sans-tc-73-500-normal.woff2 +0 -0
  776. package/dist/fonts/noto-sans-tc-73-600-normal.woff2 +0 -0
  777. package/dist/fonts/noto-sans-tc-73-700-normal.woff2 +0 -0
  778. package/dist/fonts/noto-sans-tc-74-400-normal.woff2 +0 -0
  779. package/dist/fonts/noto-sans-tc-74-500-normal.woff2 +0 -0
  780. package/dist/fonts/noto-sans-tc-74-600-normal.woff2 +0 -0
  781. package/dist/fonts/noto-sans-tc-74-700-normal.woff2 +0 -0
  782. package/dist/fonts/noto-sans-tc-75-400-normal.woff2 +0 -0
  783. package/dist/fonts/noto-sans-tc-75-500-normal.woff2 +0 -0
  784. package/dist/fonts/noto-sans-tc-75-600-normal.woff2 +0 -0
  785. package/dist/fonts/noto-sans-tc-75-700-normal.woff2 +0 -0
  786. package/dist/fonts/noto-sans-tc-76-400-normal.woff2 +0 -0
  787. package/dist/fonts/noto-sans-tc-76-500-normal.woff2 +0 -0
  788. package/dist/fonts/noto-sans-tc-76-600-normal.woff2 +0 -0
  789. package/dist/fonts/noto-sans-tc-76-700-normal.woff2 +0 -0
  790. package/dist/fonts/noto-sans-tc-77-400-normal.woff2 +0 -0
  791. package/dist/fonts/noto-sans-tc-77-500-normal.woff2 +0 -0
  792. package/dist/fonts/noto-sans-tc-77-600-normal.woff2 +0 -0
  793. package/dist/fonts/noto-sans-tc-77-700-normal.woff2 +0 -0
  794. package/dist/fonts/noto-sans-tc-78-400-normal.woff2 +0 -0
  795. package/dist/fonts/noto-sans-tc-78-500-normal.woff2 +0 -0
  796. package/dist/fonts/noto-sans-tc-78-600-normal.woff2 +0 -0
  797. package/dist/fonts/noto-sans-tc-78-700-normal.woff2 +0 -0
  798. package/dist/fonts/noto-sans-tc-79-400-normal.woff2 +0 -0
  799. package/dist/fonts/noto-sans-tc-79-500-normal.woff2 +0 -0
  800. package/dist/fonts/noto-sans-tc-79-600-normal.woff2 +0 -0
  801. package/dist/fonts/noto-sans-tc-79-700-normal.woff2 +0 -0
  802. package/dist/fonts/noto-sans-tc-80-400-normal.woff2 +0 -0
  803. package/dist/fonts/noto-sans-tc-80-500-normal.woff2 +0 -0
  804. package/dist/fonts/noto-sans-tc-80-600-normal.woff2 +0 -0
  805. package/dist/fonts/noto-sans-tc-80-700-normal.woff2 +0 -0
  806. package/dist/fonts/noto-sans-tc-81-400-normal.woff2 +0 -0
  807. package/dist/fonts/noto-sans-tc-81-500-normal.woff2 +0 -0
  808. package/dist/fonts/noto-sans-tc-81-600-normal.woff2 +0 -0
  809. package/dist/fonts/noto-sans-tc-81-700-normal.woff2 +0 -0
  810. package/dist/fonts/noto-sans-tc-82-400-normal.woff2 +0 -0
  811. package/dist/fonts/noto-sans-tc-82-500-normal.woff2 +0 -0
  812. package/dist/fonts/noto-sans-tc-82-600-normal.woff2 +0 -0
  813. package/dist/fonts/noto-sans-tc-82-700-normal.woff2 +0 -0
  814. package/dist/fonts/noto-sans-tc-83-400-normal.woff2 +0 -0
  815. package/dist/fonts/noto-sans-tc-83-500-normal.woff2 +0 -0
  816. package/dist/fonts/noto-sans-tc-83-600-normal.woff2 +0 -0
  817. package/dist/fonts/noto-sans-tc-83-700-normal.woff2 +0 -0
  818. package/dist/fonts/noto-sans-tc-84-400-normal.woff2 +0 -0
  819. package/dist/fonts/noto-sans-tc-84-500-normal.woff2 +0 -0
  820. package/dist/fonts/noto-sans-tc-84-600-normal.woff2 +0 -0
  821. package/dist/fonts/noto-sans-tc-84-700-normal.woff2 +0 -0
  822. package/dist/fonts/noto-sans-tc-85-400-normal.woff2 +0 -0
  823. package/dist/fonts/noto-sans-tc-85-500-normal.woff2 +0 -0
  824. package/dist/fonts/noto-sans-tc-85-600-normal.woff2 +0 -0
  825. package/dist/fonts/noto-sans-tc-85-700-normal.woff2 +0 -0
  826. package/dist/fonts/noto-sans-tc-86-400-normal.woff2 +0 -0
  827. package/dist/fonts/noto-sans-tc-86-500-normal.woff2 +0 -0
  828. package/dist/fonts/noto-sans-tc-86-600-normal.woff2 +0 -0
  829. package/dist/fonts/noto-sans-tc-86-700-normal.woff2 +0 -0
  830. package/dist/fonts/noto-sans-tc-87-400-normal.woff2 +0 -0
  831. package/dist/fonts/noto-sans-tc-87-500-normal.woff2 +0 -0
  832. package/dist/fonts/noto-sans-tc-87-600-normal.woff2 +0 -0
  833. package/dist/fonts/noto-sans-tc-87-700-normal.woff2 +0 -0
  834. package/dist/fonts/noto-sans-tc-88-400-normal.woff2 +0 -0
  835. package/dist/fonts/noto-sans-tc-88-500-normal.woff2 +0 -0
  836. package/dist/fonts/noto-sans-tc-88-600-normal.woff2 +0 -0
  837. package/dist/fonts/noto-sans-tc-88-700-normal.woff2 +0 -0
  838. package/dist/fonts/noto-sans-tc-89-400-normal.woff2 +0 -0
  839. package/dist/fonts/noto-sans-tc-89-500-normal.woff2 +0 -0
  840. package/dist/fonts/noto-sans-tc-89-600-normal.woff2 +0 -0
  841. package/dist/fonts/noto-sans-tc-89-700-normal.woff2 +0 -0
  842. package/dist/fonts/noto-sans-tc-90-400-normal.woff2 +0 -0
  843. package/dist/fonts/noto-sans-tc-90-500-normal.woff2 +0 -0
  844. package/dist/fonts/noto-sans-tc-90-600-normal.woff2 +0 -0
  845. package/dist/fonts/noto-sans-tc-90-700-normal.woff2 +0 -0
  846. package/dist/fonts/noto-sans-tc-91-400-normal.woff2 +0 -0
  847. package/dist/fonts/noto-sans-tc-91-500-normal.woff2 +0 -0
  848. package/dist/fonts/noto-sans-tc-91-600-normal.woff2 +0 -0
  849. package/dist/fonts/noto-sans-tc-91-700-normal.woff2 +0 -0
  850. package/dist/fonts/noto-sans-tc-92-400-normal.woff2 +0 -0
  851. package/dist/fonts/noto-sans-tc-92-500-normal.woff2 +0 -0
  852. package/dist/fonts/noto-sans-tc-92-600-normal.woff2 +0 -0
  853. package/dist/fonts/noto-sans-tc-92-700-normal.woff2 +0 -0
  854. package/dist/fonts/noto-sans-tc-93-400-normal.woff2 +0 -0
  855. package/dist/fonts/noto-sans-tc-93-500-normal.woff2 +0 -0
  856. package/dist/fonts/noto-sans-tc-93-600-normal.woff2 +0 -0
  857. package/dist/fonts/noto-sans-tc-93-700-normal.woff2 +0 -0
  858. package/dist/fonts/noto-sans-tc-94-400-normal.woff2 +0 -0
  859. package/dist/fonts/noto-sans-tc-94-500-normal.woff2 +0 -0
  860. package/dist/fonts/noto-sans-tc-94-600-normal.woff2 +0 -0
  861. package/dist/fonts/noto-sans-tc-94-700-normal.woff2 +0 -0
  862. package/dist/fonts/noto-sans-tc-95-400-normal.woff2 +0 -0
  863. package/dist/fonts/noto-sans-tc-95-500-normal.woff2 +0 -0
  864. package/dist/fonts/noto-sans-tc-95-600-normal.woff2 +0 -0
  865. package/dist/fonts/noto-sans-tc-95-700-normal.woff2 +0 -0
  866. package/dist/fonts/noto-sans-tc-96-400-normal.woff2 +0 -0
  867. package/dist/fonts/noto-sans-tc-96-500-normal.woff2 +0 -0
  868. package/dist/fonts/noto-sans-tc-96-600-normal.woff2 +0 -0
  869. package/dist/fonts/noto-sans-tc-96-700-normal.woff2 +0 -0
  870. package/dist/fonts/noto-sans-tc-cyrillic-400-normal.woff2 +0 -0
  871. package/dist/fonts/noto-sans-tc-cyrillic-500-normal.woff2 +0 -0
  872. package/dist/fonts/noto-sans-tc-cyrillic-600-normal.woff2 +0 -0
  873. package/dist/fonts/noto-sans-tc-cyrillic-700-normal.woff2 +0 -0
  874. package/dist/fonts/noto-sans-tc-latin-400-normal.woff2 +0 -0
  875. package/dist/fonts/noto-sans-tc-latin-500-normal.woff2 +0 -0
  876. package/dist/fonts/noto-sans-tc-latin-600-normal.woff2 +0 -0
  877. package/dist/fonts/noto-sans-tc-latin-700-normal.woff2 +0 -0
  878. package/dist/fonts/noto-sans-tc-latin-ext-400-normal.woff2 +0 -0
  879. package/dist/fonts/noto-sans-tc-latin-ext-500-normal.woff2 +0 -0
  880. package/dist/fonts/noto-sans-tc-latin-ext-600-normal.woff2 +0 -0
  881. package/dist/fonts/noto-sans-tc-latin-ext-700-normal.woff2 +0 -0
  882. package/dist/fonts/noto-sans-tc-vietnamese-400-normal.woff2 +0 -0
  883. package/dist/fonts/noto-sans-tc-vietnamese-500-normal.woff2 +0 -0
  884. package/dist/fonts/noto-sans-tc-vietnamese-600-normal.woff2 +0 -0
  885. package/dist/fonts/noto-sans-tc-vietnamese-700-normal.woff2 +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"Section.js","names":["phArrowsInLineVertical","phArrowsOutLineVertical","phCaretRight"],"sources":["../../../src/components/Section/Section.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Icon } from '../../icons/Icon';\nimport { tr } from '../../i18n';\nimport { cx } from '../../internal/util';\nimport { IconButton } from '../IconButton/IconButton';\nimport { includeIcons } from '../../icons/store';\nimport phArrowsInLineVertical from '../../icons/ph/arrows-in-line-vertical';\nimport phArrowsOutLineVertical from '../../icons/ph/arrows-out-line-vertical';\nimport phCaretRight from '../../icons/ph/caret-right';\n\nincludeIcons(phArrowsInLineVertical, phArrowsOutLineVertical, phCaretRight);\n\n/** What a SectionGroup shares with its sections: the last 「全部展開/全部收合」 and who is open. */\ninterface GroupCtx {\n /** Bumped on every 「全部展開/全部收合」, with the state it asked for. */\n all: { n: number; open: boolean };\n report: (key: string, open: boolean | null) => void;\n /** Some section is closed (or none reported yet): the toggle opens all; otherwise it closes all. */\n anyClosed: boolean;\n setAll: (open: boolean) => void;\n}\nconst Group = React.createContext<GroupCtx | null>(null);\n\n// SA: the open and close animation, the same as TreeList's children growing out of a folder.\nconst MOVE_MS = 260;\n\nconst reduced = () => typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;\n\nfunction readStored(key: string | undefined): boolean | undefined {\n if (!key) return undefined;\n try {\n const v = localStorage.getItem('ui-section:' + key);\n return v === '1' ? true : v === '0' ? false : undefined;\n } catch {\n return undefined;\n }\n}\nfunction writeStored(key: string | undefined, open: boolean) {\n if (!key) return;\n try {\n localStorage.setItem('ui-section:' + key, open ? '1' : '0');\n } catch {\n // Storage blocked or full: works the same, it only does not remember.\n }\n}\n\nexport interface SectionProps {\n /** The heading, 20 px bold (h4 size), above the 16 px content. */\n title: React.ReactNode;\n /** One line of key numbers right of the title, shown open or closed: 「29 個指令、4 個 namespace、3 個沒有逾時」.\n * Muted, cut with 「…」 when it does not fit. Part of the button: no links or buttons in it. */\n summary?: React.ReactNode;\n /** Uncontrolled: open at first. Default false. A stored state (storageKey) wins. */\n defaultOpen?: boolean;\n /** Controlled: open or closed; pair with onOpenChange. */\n open?: boolean;\n /** Called with the new state when the title is clicked, the address jumps here, or 「全部展開/全部收合」. */\n onOpenChange?: (open: boolean) => void;\n /** Anchor. When the address hash (or a link in the page) points at this id, the section opens and scrolls to its title. */\n id?: string;\n /** Closed: the content is not rendered at all. Default false: it stays in the page hidden, and the browser's find\n * (Ctrl+F) opens the section when it finds text in it. Set it on very long sections. */\n lazy?: boolean;\n /** Remembers open or closed in localStorage under this key. If storage fails it works the same, without remembering. */\n storageKey?: string;\n /** Controls right of the summary, such as a copy IconButton. Outside the title button: clicking them does not open\n * or close the section. */\n actions?: React.ReactNode;\n /** Heading level of the title. Default 3. The size stays 20 px whatever the level. */\n level?: 2 | 3 | 4 | 5 | 6;\n children?: React.ReactNode;\n className?: string;\n}\n\n/** A part of a page that can be closed: the title and a one-line summary stay visible. A line between sections;\n * the caret left of the title turns when it opens (260 ms, none with reduced motion). */\nexport function Section(p: SectionProps) {\n const group = React.useContext(Group);\n const uid = React.useId();\n const [own, setOwn] = React.useState(() => readStored(p.storageKey) ?? p.defaultOpen ?? false);\n const open = p.open ?? own;\n const set = React.useCallback(\n (v: boolean) => {\n if (p.open === undefined) setOwn(v);\n writeStored(p.storageKey, v);\n p.onOpenChange?.(v);\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [p.open, p.storageKey, p.onOpenChange],\n );\n const setRef = React.useRef(set);\n const openRef = React.useRef(open);\n React.useLayoutEffect(() => {\n setRef.current = set;\n openRef.current = open;\n });\n\n // Lazy content stays mounted until the closing animation ends, so it has something to shrink.\n const [prevOpen, setPrevOpen] = React.useState(open);\n const [linger, setLinger] = React.useState(false);\n if (prevOpen !== open) {\n setPrevOpen(open);\n setLinger(!open);\n }\n React.useEffect(() => {\n if (!linger) return;\n const t = window.setTimeout(() => setLinger(false), reduced() ? 0 : MOVE_MS);\n return () => window.clearTimeout(t);\n }, [linger]);\n\n // Not lazy: closed content is hidden=\"until-found\", so the browser's find still reaches it and opens the section.\n const inner = React.useRef<HTMLDivElement>(null);\n React.useEffect(() => {\n const el = inner.current;\n if (!el || p.lazy) return;\n if (open) {\n el.removeAttribute('hidden');\n return;\n }\n const t = window.setTimeout(() => el.setAttribute('hidden', 'until-found'), reduced() ? 0 : MOVE_MS);\n const found = () => setRef.current(true);\n el.addEventListener('beforematch', found);\n return () => {\n window.clearTimeout(t);\n el.removeEventListener('beforematch', found);\n };\n }, [open, p.lazy]);\n\n // The address points here: open and scroll to the title.\n const head = React.useRef<HTMLHeadingElement>(null);\n React.useEffect(() => {\n if (!p.id) return;\n const check = () => {\n if (decodeURIComponent(location.hash.slice(1)) !== p.id) return;\n if (!openRef.current) setRef.current(true);\n requestAnimationFrame(() => head.current?.scrollIntoView?.({ block: 'start', behavior: reduced() ? 'auto' : 'smooth' }));\n };\n check();\n window.addEventListener('hashchange', check);\n return () => window.removeEventListener('hashchange', check);\n }, [p.id]);\n\n // 「全部展開/全部收合」 from the group, and this section's state reported back to it.\n const seen = React.useRef(group?.all.n ?? 0);\n React.useEffect(() => {\n if (!group || group.all.n === seen.current) return;\n seen.current = group.all.n;\n if (group.all.open !== openRef.current) setRef.current(group.all.open);\n }, [group, group?.all.n, group?.all.open]);\n const report = group?.report;\n React.useEffect(() => {\n report?.(uid, open);\n }, [report, uid, open]);\n React.useEffect(() => () => report?.(uid, null), [report, uid]);\n\n const H = `h${p.level ?? 3}` as 'h3';\n const body = uid + '-body';\n const showContent = !p.lazy || open || linger;\n return (\n <section id={p.id} className={cx('ui-sec', open && 'is-open', p.className)}>\n <div className=\"ui-sec-row\">\n <H ref={head} className=\"ui-sec-h\">\n <button type=\"button\" className=\"ui-sec-btn\" aria-expanded={open} aria-controls={body} onClick={() => set(!open)}>\n <Icon name=\"caret-right\" size={18} className=\"ui-sec-caret\" />\n <span className=\"ui-sec-title\">{p.title}</span>\n {p.summary != null && p.summary !== false ? <span className=\"ui-sec-sum\">{p.summary}</span> : null}\n </button>\n </H>\n {p.actions ? <div className=\"ui-sec-actions\">{p.actions}</div> : null}\n </div>\n <div id={body} className=\"ui-sec-body\">\n <div ref={inner} className=\"ui-sec-in\">\n {showContent ? <div className=\"ui-sec-content\">{p.children}</div> : null}\n </div>\n </div>\n </section>\n );\n}\n\nexport interface SectionGroupProps {\n /** Sections. One icon button above them on the right opens them all, or closes them all once all are open\n * (「全部展開」「全部收合」 as its tooltip and name). */\n children?: React.ReactNode;\n /** More controls on the same row, left of the button. */\n actions?: React.ReactNode;\n /** false: no row above the sections; put <SectionGroupToggle /> where you want it, such as the card's title row next\n * to its other icon buttons. It must be inside the SectionGroup. Default true. */\n bar?: boolean;\n className?: string;\n}\n\n/** A run of Sections with one 「全部展開/全部收合」 icon button. */\nexport function SectionGroup({ children, actions, bar = true, className }: SectionGroupProps) {\n const [all, setAllState] = React.useState({ n: 0, open: false });\n const [states, setStates] = React.useState<Record<string, boolean>>({});\n const report = React.useCallback((key: string, open: boolean | null) => {\n setStates((s) => {\n if (open === null) return key in s ? Object.fromEntries(Object.entries(s).filter(([id]) => id !== key)) : s;\n return s[key] === open ? s : { ...s, [key]: open };\n });\n }, []);\n const setAll = React.useCallback((open: boolean) => setAllState((a) => ({ n: a.n + 1, open })), []);\n const vals = Object.values(states);\n const anyClosed = vals.length === 0 || vals.some((v) => !v);\n const ctx = React.useMemo(() => ({ all, report, anyClosed, setAll }), [all, report, anyClosed, setAll]);\n return (\n <Group.Provider value={ctx}>\n <div className={cx('ui-sec-group', className)}>\n {bar ? (\n <div className=\"ui-sec-bar\">\n {actions ?? null}\n <SectionGroupToggle />\n </div>\n ) : null}\n {children}\n </div>\n </Group.Provider>\n );\n}\n\nexport interface SectionGroupToggleProps {\n className?: string;\n}\n\n/** GB: the 「全部展開/全部收合」 icon button of the SectionGroup around it, for a place of your own (with bar={false}).\n * Opens every section while any is closed, else closes them all; its tooltip and name say which. */\nexport function SectionGroupToggle({ className }: SectionGroupToggleProps) {\n const g = React.useContext(Group);\n if (!g) return null;\n const open = g.anyClosed;\n return (\n <IconButton\n className={cx('ui-sec-toggle', className)}\n icon={open ? 'arrows-out-line-vertical' : 'arrows-in-line-vertical'}\n label={open ? tr('全部展開') : tr('全部收合')}\n onClick={() => g.setAll(open)}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;AAUA,aAAaA,iCAAwBC,kCAAyBC,mBAAY;AAW1E,MAAM,QAAQ,MAAM,cAA+B,IAAI;AAGvD,MAAM,UAAU;AAEhB,MAAM,gBAAgB,OAAO,eAAe,cAAc,WAAW,kCAAkC,CAAC,CAAC;AAEzG,SAAS,WAAW,KAA8C;CAChE,IAAI,CAAC,KAAK,OAAO,KAAA;CACjB,IAAI;EACF,MAAM,IAAI,aAAa,QAAQ,gBAAgB,GAAG;EAClD,OAAO,MAAM,MAAM,OAAO,MAAM,MAAM,QAAQ,KAAA;CAChD,QAAQ;EACN;CACF;AACF;AACA,SAAS,YAAY,KAAyB,MAAe;CAC3D,IAAI,CAAC,KAAK;CACV,IAAI;EACF,aAAa,QAAQ,gBAAgB,KAAK,OAAO,MAAM,GAAG;CAC5D,QAAQ,CAER;AACF;;;AAgCA,SAAgB,QAAQ,GAAiB;CACvC,MAAM,QAAQ,MAAM,WAAW,KAAK;CACpC,MAAM,MAAM,MAAM,MAAM;CACxB,MAAM,CAAC,KAAK,UAAU,MAAM,eAAe,WAAW,EAAE,UAAU,KAAK,EAAE,eAAe,KAAK;CAC7F,MAAM,OAAO,EAAE,QAAQ;CACvB,MAAM,MAAM,MAAM,aACf,MAAe;EACd,IAAI,EAAE,SAA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MAAM,MAAM,MAAM,eAAe;EAAE;EAAK;EAAQ;EAAW;CAAO,IAAI;EAAC;EAAK;EAAQ;EAAW;CAAM,CAAC;CACtG,OACE,oBAAC,MAAM,UAAP;EAAgB,OAAO;EACrB,UAAA,qBAAC,OAAD;GAAK,WAAW,GAAG,gBAAgB,SAAS;GAA5C,UAAA,CACG,MACC,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACG,WAAW,MACZ,oBAAC,oBAAD,CAAqB,CAAA,CAClB;GACH,CAAA,IAAA,MACH,QACE;;CACS,CAAA;AAEpB;;;AAQA,SAAgB,mBAAmB,EAAE,aAAsC;CACzE,MAAM,IAAI,MAAM,WAAW,KAAK;CAChC,IAAI,CAAC,GAAG,OAAO;CACf,MAAM,OAAO,EAAE;CACf,OACE,oBAAC,YAAD;EACE,WAAW,GAAG,iBAAiB,SAAS;EACxC,MAAM,OAAO,6BAA6B;EAC1C,OAAO,OAAO,GAAG,MAAM,IAAI,GAAG,MAAM;EACpC,eAAe,EAAE,OAAO,IAAI;CAC7B,CAAA;AAEL"}
1
+ {"version":3,"file":"Section.js","names":["phArrowsInLineVertical","phArrowsOutLineVertical","phCaretRight"],"sources":["../../../src/components/Section/Section.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Icon } from '../../icons/Icon';\nimport { tr } from '../../i18n';\nimport { cx } from '../../internal/util';\nimport { useStored } from '../../internal/stored';\nimport { IconButton } from '../IconButton/IconButton';\nimport { includeIcons } from '../../icons/store';\nimport phArrowsInLineVertical from '../../icons/ph/arrows-in-line-vertical';\nimport phArrowsOutLineVertical from '../../icons/ph/arrows-out-line-vertical';\nimport phCaretRight from '../../icons/ph/caret-right';\n\nincludeIcons(phArrowsInLineVertical, phArrowsOutLineVertical, phCaretRight);\n\n/** What a SectionGroup shares with its sections: the last 「全部展開/全部收合」 and who is open. */\ninterface GroupCtx {\n /** Bumped on every 「全部展開/全部收合」, with the state it asked for. */\n all: { n: number; open: boolean };\n report: (key: string, open: boolean | null) => void;\n /** Some section is closed (or none reported yet): the toggle opens all; otherwise it closes all. */\n anyClosed: boolean;\n setAll: (open: boolean) => void;\n}\nconst Group = React.createContext<GroupCtx | null>(null);\n\n// SA: the open and close animation, the same as TreeList's children growing out of a folder.\nconst MOVE_MS = 260;\n\nconst reduced = () => typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;\n\n// A stored open state: '1' or '0'; anything else gives the default.\nfunction parseOpen(raw: string): boolean {\n if (raw === '1' || raw === '0') return raw === '1';\n throw new Error('not a stored open state');\n}\nconst serializeOpen = (v: boolean) => (v ? '1' : '0');\n\nexport interface SectionProps {\n /** The heading, 20 px bold (h4 size), above the 16 px content. */\n title: React.ReactNode;\n /** One line of key numbers right of the title, shown open or closed: 「29 個指令、4 個 namespace、3 個沒有逾時」.\n * Muted, cut with 「…」 when it does not fit. Part of the button: no links or buttons in it. */\n summary?: React.ReactNode;\n /** Uncontrolled: open at first. Default false. A stored state (storageKey) wins. */\n defaultOpen?: boolean;\n /** Controlled: open or closed; pair with onOpenChange. */\n open?: boolean;\n /** Called with the new state when the title is clicked, the address jumps here, or 「全部展開/全部收合」. */\n onOpenChange?: (open: boolean) => void;\n /** Anchor. When the address hash (or a link in the page) points at this id, the section opens and scrolls to its title. */\n id?: string;\n /** Closed: the content is not rendered at all. Default false: it stays in the page hidden, and the browser's find\n * (Ctrl+F) opens the section when it finds text in it. Set it on very long sections. */\n lazy?: boolean;\n /** Remembers open or closed in localStorage under this key. If storage fails it works the same, without remembering. */\n storageKey?: string;\n /** Controls right of the summary, such as a copy IconButton. Outside the title button: clicking them does not open\n * or close the section. */\n actions?: React.ReactNode;\n /** Heading level of the title. Default 3. The size stays 20 px whatever the level. */\n level?: 2 | 3 | 4 | 5 | 6;\n /** The content shown while the section is open. */\n children?: React.ReactNode;\n /** Extra class on the root element. */\n className?: string;\n}\n\n/** A part of a page that can be closed: the title and a one-line summary stay visible. A line between sections;\n * the caret left of the title turns when it opens (260 ms, none with reduced motion). */\nexport function Section(p: SectionProps) {\n const group = React.useContext(Group);\n const uid = React.useId();\n // Closed or defaultOpen on the server and the first browser render, then the stored state (storageKey).\n const [own, setOwn] = useStored(p.storageKey ? 'ui-section:' + p.storageKey : undefined, parseOpen, p.defaultOpen ?? false, serializeOpen);\n const open = p.open ?? own;\n const set = React.useCallback(\n (v: boolean) => {\n // Stored even when controlled, so an uncontrolled use with the same key starts from it.\n setOwn(v);\n p.onOpenChange?.(v);\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [setOwn, p.onOpenChange],\n );\n const setRef = React.useRef(set);\n const openRef = React.useRef(open);\n React.useLayoutEffect(() => {\n setRef.current = set;\n openRef.current = open;\n });\n\n // Lazy content stays mounted until the closing animation ends, so it has something to shrink.\n const [prevOpen, setPrevOpen] = React.useState(open);\n const [linger, setLinger] = React.useState(false);\n if (prevOpen !== open) {\n setPrevOpen(open);\n setLinger(!open);\n }\n React.useEffect(() => {\n if (!linger) return;\n const t = window.setTimeout(() => setLinger(false), reduced() ? 0 : MOVE_MS);\n return () => window.clearTimeout(t);\n }, [linger]);\n\n // Not lazy: closed content is hidden=\"until-found\", so the browser's find still reaches it and opens the section.\n const inner = React.useRef<HTMLDivElement>(null);\n React.useEffect(() => {\n const el = inner.current;\n if (!el || p.lazy) return;\n if (open) {\n el.removeAttribute('hidden');\n return;\n }\n const t = window.setTimeout(() => el.setAttribute('hidden', 'until-found'), reduced() ? 0 : MOVE_MS);\n const found = () => setRef.current(true);\n el.addEventListener('beforematch', found);\n return () => {\n window.clearTimeout(t);\n el.removeEventListener('beforematch', found);\n };\n }, [open, p.lazy]);\n\n // The address points here: open and scroll to the title.\n const head = React.useRef<HTMLHeadingElement>(null);\n React.useEffect(() => {\n if (!p.id) return;\n const check = () => {\n if (decodeURIComponent(location.hash.slice(1)) !== p.id) return;\n if (!openRef.current) setRef.current(true);\n requestAnimationFrame(() => head.current?.scrollIntoView?.({ block: 'start', behavior: reduced() ? 'auto' : 'smooth' }));\n };\n check();\n window.addEventListener('hashchange', check);\n return () => window.removeEventListener('hashchange', check);\n }, [p.id]);\n\n // 「全部展開/全部收合」 from the group, and this section's state reported back to it.\n const seen = React.useRef(group?.all.n ?? 0);\n React.useEffect(() => {\n if (!group || group.all.n === seen.current) return;\n seen.current = group.all.n;\n if (group.all.open !== openRef.current) setRef.current(group.all.open);\n }, [group, group?.all.n, group?.all.open]);\n const report = group?.report;\n React.useEffect(() => {\n report?.(uid, open);\n }, [report, uid, open]);\n React.useEffect(() => () => report?.(uid, null), [report, uid]);\n\n const H = `h${p.level ?? 3}` as 'h3';\n const body = uid + '-body';\n const showContent = !p.lazy || open || linger;\n return (\n <section id={p.id} className={cx('ui-sec', open && 'is-open', p.className)}>\n <div className=\"ui-sec-row\">\n <H ref={head} className=\"ui-sec-h\">\n <button type=\"button\" className=\"ui-sec-btn\" aria-expanded={open} aria-controls={body} onClick={() => set(!open)}>\n <Icon name=\"caret-right\" size={18} className=\"ui-sec-caret\" />\n <span className=\"ui-sec-title\">{p.title}</span>\n {p.summary != null && p.summary !== false ? <span className=\"ui-sec-sum\">{p.summary}</span> : null}\n </button>\n </H>\n {p.actions ? <div className=\"ui-sec-actions\">{p.actions}</div> : null}\n </div>\n <div id={body} className=\"ui-sec-body\">\n <div ref={inner} className=\"ui-sec-in\">\n {showContent ? <div className=\"ui-sec-content\">{p.children}</div> : null}\n </div>\n </div>\n </section>\n );\n}\n\nexport interface SectionGroupProps {\n /** Sections. One icon button above them on the right opens them all, or closes them all once all are open\n * (「全部展開」「全部收合」 as its tooltip and name). */\n children?: React.ReactNode;\n /** More controls on the same row, left of the button. */\n actions?: React.ReactNode;\n /** false: no row above the sections; put <SectionGroupToggle /> where you want it, such as the card's title row next\n * to its other icon buttons. It must be inside the SectionGroup. Default true. */\n bar?: boolean;\n /** Extra class on the root element. */\n className?: string;\n}\n\n/** A run of Sections with one 「全部展開/全部收合」 icon button. */\nexport function SectionGroup({ children, actions, bar = true, className }: SectionGroupProps) {\n const [all, setAllState] = React.useState({ n: 0, open: false });\n const [states, setStates] = React.useState<Record<string, boolean>>({});\n const report = React.useCallback((key: string, open: boolean | null) => {\n setStates((s) => {\n if (open === null) return key in s ? Object.fromEntries(Object.entries(s).filter(([id]) => id !== key)) : s;\n return s[key] === open ? s : { ...s, [key]: open };\n });\n }, []);\n const setAll = React.useCallback((open: boolean) => setAllState((a) => ({ n: a.n + 1, open })), []);\n const vals = Object.values(states);\n const anyClosed = vals.length === 0 || vals.some((v) => !v);\n const ctx = React.useMemo(() => ({ all, report, anyClosed, setAll }), [all, report, anyClosed, setAll]);\n return (\n <Group.Provider value={ctx}>\n <div className={cx('ui-sec-group', className)}>\n {bar ? (\n <div className=\"ui-sec-bar\">\n {actions ?? null}\n <SectionGroupToggle />\n </div>\n ) : null}\n {children}\n </div>\n </Group.Provider>\n );\n}\n\nexport interface SectionGroupToggleProps {\n /** Extra class on the root element. */\n className?: string;\n}\n\n/** GB: the 「全部展開/全部收合」 icon button of the SectionGroup around it, for a place of your own (with bar={false}).\n * Opens every section while any is closed, else closes them all; its tooltip and name say which. */\nexport function SectionGroupToggle({ className }: SectionGroupToggleProps) {\n const g = React.useContext(Group);\n if (!g) return null;\n const open = g.anyClosed;\n return (\n <IconButton\n className={cx('ui-sec-toggle', className)}\n icon={open ? 'arrows-out-line-vertical' : 'arrows-in-line-vertical'}\n label={open ? tr('全部展開') : tr('全部收合')}\n onClick={() => g.setAll(open)}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAWA,aAAaA,iCAAwBC,kCAAyBC,mBAAY;AAW1E,MAAM,QAAQ,MAAM,cAA+B,IAAI;AAGvD,MAAM,UAAU;AAEhB,MAAM,gBAAgB,OAAO,eAAe,cAAc,WAAW,kCAAkC,CAAC,CAAC;AAGzG,SAAS,UAAU,KAAsB;CACvC,IAAI,QAAQ,OAAO,QAAQ,KAAK,OAAO,QAAQ;CAC/C,MAAM,IAAI,MAAM,yBAAyB;AAC3C;AACA,MAAM,iBAAiB,MAAg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AAG,CAAC,CAAC;CACL,MAAM,SAAS,MAAM,aAAa,SAAkB,aAAa,OAAO;EAAE,GAAG,EAAE,IAAI;EAAG;CAAK,EAAE,GAAG,CAAC,CAAC;CAClG,MAAM,OAAO,OAAO,OAAO,MAAM;CACjC,MAAM,YAAY,KAAK,WAAW,KAAK,KAAK,MAAM,MAAM,CAAC,CAAC;CAC1D,MAAM,MAAM,MAAM,eAAe;EAAE;EAAK;EAAQ;EAAW;CAAO,IAAI;EAAC;EAAK;EAAQ;EAAW;CAAM,CAAC;CACtG,OACE,oBAAC,MAAM,UAAP;EAAgB,OAAO;EACrB,UAAA,qBAAC,OAAD;GAAK,WAAW,GAAG,gBAAgB,SAAS;GAA5C,UAAA,CACG,MACC,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACG,WAAW,MACZ,oBAAC,oBAAD,CAAqB,CAAA,CAClB;GACH,CAAA,IAAA,MACH,QACE;;CACS,CAAA;AAEpB;;;AASA,SAAgB,mBAAmB,EAAE,aAAsC;CACzE,MAAM,IAAI,MAAM,WAAW,KAAK;CAChC,IAAI,CAAC,GAAG,OAAO;CACf,MAAM,OAAO,EAAE;CACf,OACE,oBAAC,YAAD;EACE,WAAW,GAAG,iBAAiB,SAAS;EACxC,MAAM,OAAO,6BAA6B;EAC1C,OAAO,OAAO,GAAG,MAAM,IAAI,GAAG,MAAM;EACpC,eAAe,EAAE,OAAO,IAAI;CAC7B,CAAA;AAEL"}
@@ -1,23 +1,36 @@
1
1
  import { IconSource } from "../../icons/Icon.js";
2
2
  import * as React from "react";
3
- export interface SegmentedItem<V extends string = string> {
4
- id: V;
3
+ export interface SegmentedOption<V extends string = string> {
4
+ /** What onChange receives. */
5
+ value: V;
5
6
  /** The words: shown, or with `iconOnly` the tooltip and what screen readers say. */
6
7
  label: string;
7
8
  /** Phosphor icon name or element; required with `iconOnly`. */
8
9
  icon?: IconSource;
9
10
  }
11
+ /** @deprecated use SegmentedOption ({ value, label, icon }). */
12
+ export interface SegmentedItem<V extends string = string> {
13
+ id: V;
14
+ label: string;
15
+ icon?: IconSource;
16
+ }
10
17
  export interface SegmentedControlProps<V extends string = string> {
11
- items: SegmentedItem<V>[];
18
+ /** The ways to show, 2 or 3, each { value, label, icon }. */
19
+ options?: SegmentedOption<V>[];
20
+ /** @deprecated use options ({ value, label, icon }); items ({ id, … }) still works for now. */
21
+ items?: SegmentedItem<V>[];
22
+ /** The chosen value. */
12
23
  value: V;
13
- onChange?: (id: V) => void;
24
+ /** Receives the chosen value. */
25
+ onChange?: (value: V) => void;
14
26
  /** What the choice is about, for screen readers, e.g. 「顯示方式」. */
15
27
  label: string;
16
- /** Icons only, 28 px each, the words in a tooltip; for a bar such as Workbench's mainBar. Default false. */
28
+ /** Icons only, the words in a tooltip; for a bar such as Workbench's mainBar. Default false. */
17
29
  iconOnly?: boolean;
30
+ /** Extra class on the root element. */
18
31
  className?: string;
19
32
  }
20
- /** A small switch between two or three ways of showing the same thing (預覽/原始碼), 28 px tall to sit in a toolbar
21
- * or Workbench's mainBar. The selected part is a raised white pill that slides; ← → move and pick. For views of
22
- * different content use Tabs. */
23
- export declare function SegmentedControl<V extends string = string>({ items, value, onChange, label, iconOnly, className }: SegmentedControlProps<V>): React.JSX.Element;
33
+ /** A small switch between two or three ways of showing the same thing (預覽/原始碼), 40 px tall like the other
34
+ * controls of a toolbar (28 px inside Workbench's 36 px mainBar). The selected part is a raised pill that slides;
35
+ * ← → move and pick. For views of different content use Tabs. */
36
+ export declare function SegmentedControl<V extends string = string>({ options, items: oldItems, value, onChange, label, iconOnly, className }: SegmentedControlProps<V>): React.JSX.Element;
@@ -1,19 +1,26 @@
1
1
  "use client";
2
2
  import { dropTransition } from "../../motion.js";
3
- import { browserKey, cx, resizeObserver } from "../../internal/util.js";
3
+ import { cx, resizeObserver } from "../../internal/util.js";
4
+ import { useRovingRadio } from "../../internal/roving.js";
4
5
  import { devWarn } from "../../internal/dev.js";
5
6
  import { IconOf } from "../../icons/Icon.js";
6
7
  import { Tooltip } from "../Tooltip/Tooltip.js";
7
8
  import * as React from "react";
8
9
  import { jsx, jsxs } from "react/jsx-runtime";
9
10
  // src/components/SegmentedControl/SegmentedControl.tsx
10
- /** A small switch between two or three ways of showing the same thing (預覽/原始碼), 28 px tall to sit in a toolbar
11
- * or Workbench's mainBar. The selected part is a raised white pill that slides; ← → move and pick. For views of
12
- * different content use Tabs. */
13
- function SegmentedControl({ items, value, onChange, label, iconOnly = false, className }) {
14
- devWarn(iconOnly && items.some((t) => !t.icon), "SegmentedControl", "iconOnly 需要每一項都有 icon;沒有圖示的那一項只剩空白。補上 icon,或拿掉 iconOnly 改顯示文字。");
11
+ /** A small switch between two or three ways of showing the same thing (預覽/原始碼), 40 px tall like the other
12
+ * controls of a toolbar (28 px inside Workbench's 36 px mainBar). The selected part is a raised pill that slides;
13
+ * ← → move and pick. For views of different content use Tabs. */
14
+ function SegmentedControl({ options, items: oldItems, value, onChange, label, iconOnly = false, className }) {
15
+ devWarn(!!oldItems, "SegmentedControl", "items is deprecated: pass options={[{ value, label, icon }]} (value in place of id).");
16
+ const items = options ?? (oldItems ?? []).map((t) => ({
17
+ value: t.id,
18
+ label: t.label,
19
+ icon: t.icon
20
+ }));
21
+ devWarn(() => iconOnly && items.some((t) => !t.icon), "SegmentedControl", "iconOnly needs an icon on every option; one without an icon shows nothing. Add icon, or drop iconOnly to show the words.");
15
22
  const refs = React.useRef([]);
16
- const idx = Math.max(0, items.findIndex((t) => t.id === value));
23
+ const idx = Math.max(0, items.findIndex((t) => t.value === value));
17
24
  const [box, setBox] = React.useState(null);
18
25
  const [forward, setForward] = React.useState(true);
19
26
  React.useLayoutEffect(() => {
@@ -31,8 +38,9 @@ function SegmentedControl({ items, value, onChange, label, iconOnly = false, cla
31
38
  const go = (i) => {
32
39
  if (i === idx || !items[i]) return;
33
40
  setForward(i > idx);
34
- onChange?.(items[i].id);
41
+ onChange?.(items[i].value);
35
42
  };
43
+ const roving = useRovingRadio(items.length, (i) => go(i));
36
44
  return /* @__PURE__ */ jsxs("div", {
37
45
  className: cx("ui-seg", iconOnly && "is-icons", className),
38
46
  role: "radiogroup",
@@ -49,6 +57,7 @@ function SegmentedControl({ items, value, onChange, label, iconOnly = false, cla
49
57
  const btn = /* @__PURE__ */ jsxs("button", {
50
58
  ref: (n) => {
51
59
  refs.current[i] = n;
60
+ roving.ref(i)(n);
52
61
  },
53
62
  type: "button",
54
63
  role: "radio",
@@ -57,27 +66,19 @@ function SegmentedControl({ items, value, onChange, label, iconOnly = false, cla
57
66
  tabIndex: i === idx ? 0 : -1,
58
67
  className: cx("ui-seg-item", i === idx && "is-selected"),
59
68
  onClick: () => go(i),
60
- onKeyDown: (e) => {
61
- if (browserKey(e)) return;
62
- const n = items.length;
63
- const to = e.key === "ArrowRight" || e.key === "ArrowDown" ? (i + 1) % n : e.key === "ArrowLeft" || e.key === "ArrowUp" ? (i - 1 + n) % n : -1;
64
- if (to < 0) return;
65
- e.preventDefault();
66
- refs.current[to]?.focus();
67
- go(to);
68
- },
69
+ onKeyDown: roving.onKeyDown(i),
69
70
  children: [t.icon ? /* @__PURE__ */ jsx(IconOf, {
70
71
  icon: t.icon,
71
72
  size: 16,
72
73
  filled: iconOnly && i === idx
73
74
  }) : null, iconOnly ? null : /* @__PURE__ */ jsx("span", { children: t.label })]
74
- }, t.id);
75
+ }, t.value);
75
76
  return iconOnly ? /* @__PURE__ */ jsx(Tooltip, {
76
77
  label: t.label,
77
78
  describe: false,
78
79
  side: "bottom",
79
80
  children: btn
80
- }, t.id) : btn;
81
+ }, t.value) : btn;
81
82
  })]
82
83
  });
83
84
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SegmentedControl.js","names":[],"sources":["../../../src/components/SegmentedControl/SegmentedControl.tsx"],"sourcesContent":["import * as React from 'react';\nimport { dropTransition } from '../../motion';\nimport { cx, browserKey, resizeObserver } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\nimport { IconOf, type IconSource } from '../../icons/Icon';\nimport { Tooltip } from '../Tooltip/Tooltip';\n\nexport interface SegmentedItem<V extends string = string> {\n id: V;\n /** The words: shown, or with `iconOnly` the tooltip and what screen readers say. */\n label: string;\n /** Phosphor icon name or element; required with `iconOnly`. */\n icon?: IconSource;\n}\n\nexport interface SegmentedControlProps<V extends string = string> {\n items: SegmentedItem<V>[];\n value: V;\n onChange?: (id: V) => void;\n /** What the choice is about, for screen readers, e.g. 「顯示方式」. */\n label: string;\n /** Icons only, 28 px each, the words in a tooltip; for a bar such as Workbench's mainBar. Default false. */\n iconOnly?: boolean;\n className?: string;\n}\n\n/** A small switch between two or three ways of showing the same thing (預覽/原始碼), 28 px tall to sit in a toolbar\n * or Workbench's mainBar. The selected part is a raised white pill that slides; ← → move and pick. For views of\n * different content use Tabs. */\nexport function SegmentedControl<V extends string = string>({ items, value, onChange, label, iconOnly = false, className }: SegmentedControlProps<V>) {\n devWarn(\n iconOnly && items.some((t) => !t.icon),\n 'SegmentedControl',\n 'iconOnly 需要每一項都有 icon;沒有圖示的那一項只剩空白。補上 icon,或拿掉 iconOnly 改顯示文字。',\n );\n const refs = React.useRef<(HTMLButtonElement | null)[]>([]);\n const idx = Math.max(\n 0,\n items.findIndex((t) => t.id === value),\n );\n const [box, setBox] = React.useState<{ left: number; width: number } | null>(null);\n const [forward, setForward] = React.useState(true);\n React.useLayoutEffect(() => {\n const el = refs.current[idx];\n if (!el) return;\n const measure = () => setBox({ left: el.offsetLeft, width: el.offsetWidth });\n measure();\n const ro = resizeObserver(measure);\n ro?.observe(el);\n return () => ro?.disconnect();\n }, [idx, items.length]);\n const go = (i: number) => {\n if (i === idx || !items[i]) return;\n setForward(i > idx);\n onChange?.(items[i].id);\n };\n return (\n <div className={cx('ui-seg', iconOnly && 'is-icons', className)} role=\"radiogroup\" aria-label={label}>\n {box ? (\n <span className=\"ui-seg-ind\" aria-hidden=\"true\" style={{ left: box.left, width: box.width, transition: dropTransition('left', 'width', forward) }} />\n ) : null}\n {items.map((t, i) => {\n const btn = (\n <button\n key={t.id}\n ref={(n) => {\n refs.current[i] = n;\n }}\n type=\"button\"\n role=\"radio\"\n aria-checked={i === idx}\n aria-label={iconOnly ? t.label : undefined}\n tabIndex={i === idx ? 0 : -1}\n className={cx('ui-seg-item', i === idx && 'is-selected')}\n onClick={() => go(i)}\n onKeyDown={(e) => {\n if (browserKey(e)) return;\n const n = items.length;\n const to = e.key === 'ArrowRight' || e.key === 'ArrowDown' ? (i + 1) % n : e.key === 'ArrowLeft' || e.key === 'ArrowUp' ? (i - 1 + n) % n : -1;\n if (to < 0) return;\n e.preventDefault();\n refs.current[to]?.focus();\n go(to);\n }}\n >\n {t.icon ? <IconOf icon={t.icon} size={16} filled={iconOnly && i === idx} /> : null}\n {iconOnly ? null : <span>{t.label}</span>}\n </button>\n );\n return iconOnly ? (\n <Tooltip key={t.id} label={t.label} describe={false} side=\"bottom\">\n {btn}\n </Tooltip>\n ) : (\n btn\n );\n })}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;AA6BA,SAAgB,iBAA4C,EAAE,OAAO,OAAO,UAAU,OAAO,WAAW,OAAO,aAAuC;CACpJ,QACE,YAAY,MAAM,MAAM,MAAM,CAAC,EAAE,IAAI,GACrC,oBACA,gEACF;CACA,MAAM,OAAO,MAAM,OAAqC,CAAC,CAAC;CAC1D,MAAM,MAAM,KAAK,IACf,GACA,MAAM,WAAW,MAAM,EAAE,OAAO,KAAK,CACvC;CACA,MAAM,CAAC,KAAK,UAAU,MAAM,SAAiD,IAAI;CACjF,MAAM,CAAC,SAAS,cAAc,MAAM,SAAS,IAAI;CACjD,MAAM,sBAAsB;EAC1B,MAAM,KAAK,KAAK,QAAQ;EACxB,IAAI,CAAC,IAAI;EACT,MAAM,gBAAgB,OAAO;GAAE,MAAM,GAAG;GAAY,OAAO,GAAG;EAAY,CAAC;EAC3E,QAAQ;EACR,MAAM,KAAK,eAAe,OAAO;EACjC,IAAI,QAAQ,EAAE;EACd,aAAa,IAAI,WAAW;CAC9B,GAAG,CAAC,KAAK,M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O,WACL,oBAAC,SAAD;IAAoB,OAAO,EAAE;IAAO,UAAU;IAAO,MAAK;IACvD,UAAA;GACM,GAFK,EAAE,EAEP,IAET;EAEJ,CAAC,CACE;;AAET"}
1
+ {"version":3,"file":"SegmentedControl.js","names":[],"sources":["../../../src/components/SegmentedControl/SegmentedControl.tsx"],"sourcesContent":["import * as React from 'react';\nimport { dropTransition } from '../../motion';\nimport { cx, resizeObserver } from '../../internal/util';\nimport { useRovingRadio } from '../../internal/roving';\nimport { devWarn } from '../../internal/dev';\nimport { IconOf, type IconSource } from '../../icons/Icon';\nimport { Tooltip } from '../Tooltip/Tooltip';\n\nexport interface SegmentedOption<V extends string = string> {\n /** What onChange receives. */\n value: V;\n /** The words: shown, or with `iconOnly` the tooltip and what screen readers say. */\n label: string;\n /** Phosphor icon name or element; required with `iconOnly`. */\n icon?: IconSource;\n}\n\n/** @deprecated use SegmentedOption ({ value, label, icon }). */\nexport interface SegmentedItem<V extends string = string> {\n id: V;\n label: string;\n icon?: IconSource;\n}\n\nexport interface SegmentedControlProps<V extends string = string> {\n /** The ways to show, 2 or 3, each { value, label, icon }. */\n options?: SegmentedOption<V>[];\n /** @deprecated use options ({ value, label, icon }); items ({ id, … }) still works for now. */\n items?: SegmentedItem<V>[];\n /** The chosen value. */\n value: V;\n /** Receives the chosen value. */\n onChange?: (value: V) => void;\n /** What the choice is about, for screen readers, e.g. 「顯示方式」. */\n label: string;\n /** Icons only, the words in a tooltip; for a bar such as Workbench's mainBar. Default false. */\n iconOnly?: boolean;\n /** Extra class on the root element. */\n className?: string;\n}\n\n/** A small switch between two or three ways of showing the same thing (預覽/原始碼), 40 px tall like the other\n * controls of a toolbar (28 px inside Workbench's 36 px mainBar). The selected part is a raised pill that slides;\n * ← → move and pick. For views of different content use Tabs. */\nexport function SegmentedControl<V extends string = string>({\n options,\n items: oldItems,\n value,\n onChange,\n label,\n iconOnly = false,\n className,\n}: SegmentedControlProps<V>) {\n devWarn(!!oldItems, 'SegmentedControl', 'items is deprecated: pass options={[{ value, label, icon }]} (value in place of id).');\n const items = options ?? (oldItems ?? []).map((t) => ({ value: t.id, label: t.label, icon: t.icon }));\n devWarn(\n () => iconOnly && items.some((t) => !t.icon),\n 'SegmentedControl',\n 'iconOnly needs an icon on every option; one without an icon shows nothing. Add icon, or drop iconOnly to show the words.',\n );\n const refs = React.useRef<(HTMLButtonElement | null)[]>([]);\n const idx = Math.max(\n 0,\n items.findIndex((t) => t.value === value),\n );\n const [box, setBox] = React.useState<{ left: number; width: number } | null>(null);\n const [forward, setForward] = React.useState(true);\n React.useLayoutEffect(() => {\n const el = refs.current[idx];\n if (!el) return;\n const measure = () => setBox({ left: el.offsetLeft, width: el.offsetWidth });\n measure();\n const ro = resizeObserver(measure);\n ro?.observe(el);\n return () => ro?.disconnect();\n }, [idx, items.length]);\n const go = (i: number) => {\n if (i === idx || !items[i]) return;\n setForward(i > idx);\n onChange?.(items[i].value);\n };\n const roving = useRovingRadio(items.length, (i) => go(i));\n return (\n <div className={cx('ui-seg', iconOnly && 'is-icons', className)} role=\"radiogroup\" aria-label={label}>\n {box ? (\n <span className=\"ui-seg-ind\" aria-hidden=\"true\" style={{ left: box.left, width: box.width, transition: dropTransition('left', 'width', forward) }} />\n ) : null}\n {items.map((t, i) => {\n const btn = (\n <button\n key={t.value}\n ref={(n) => {\n refs.current[i] = n;\n roving.ref(i)(n);\n }}\n type=\"button\"\n role=\"radio\"\n aria-checked={i === idx}\n aria-label={iconOnly ? t.label : undefined}\n tabIndex={i === idx ? 0 : -1}\n className={cx('ui-seg-item', i === idx && 'is-selected')}\n onClick={() => go(i)}\n onKeyDown={roving.onKeyDown(i)}\n >\n {t.icon ? <IconOf icon={t.icon} size={16} filled={iconOnly && i === idx} /> : null}\n {iconOnly ? null : <span>{t.label}</span>}\n </button>\n );\n return iconOnly ? (\n <Tooltip key={t.value} label={t.label} describe={false} side=\"bottom\">\n {btn}\n </Tooltip>\n ) : (\n btn\n );\n })}\n </div>\n );\n}\n"],"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OAAO,IAAI;IAAO,YAAY,eAAe,QAAQ,SAAS,OAAO;GAAE;EAAI,CAAA,IAClJ,MACH,MAAM,KAAK,GAAG,MAAM;GACnB,MAAM,MACJ,qBAAC,UAAD;IAEE,MAAM,MAAM;KACV,KAAK,QAAQ,KAAK;KAClB,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC;IACjB;IACA,MAAK;IACL,MAAK;IACL,gBAAc,MAAM;IACpB,cAAY,WAAW,EAAE,QAAQ,KAAA;IACjC,UAAU,MAAM,MAAM,IAAI;IAC1B,WAAW,GAAG,eAAe,MAAM,OAAO,aAAa;IACvD,eAAe,GAAG,CAAC;IACnB,WAAW,OAAO,UAAU,CAAC;IAb/B,UAAA,CAeG,EAAE,OAAO,oBAAC,QAAD;KAAQ,MAAM,EAAE;KAAM,MAAM;KAAI,QAAQ,YAAY,MAAM;IAAM,CAAA,IAAI,MAC7E,WAAW,OAAO,oBAAC,QAAD,EAAA,UAAO,EAAE,MAAY,CAAA,CAClC;GAhBD,GAAA,EAAE,KAgBD;GAEV,OAAO,WACL,oBAAC,SAAD;IAAuB,OAAO,EAAE;IAAO,UAAU;IAAO,MAAK;IAC1D,UAAA;GACM,GAFK,EAAE,KAEP,IAET;EAEJ,CAAC,CACE;;AAET"}
@@ -1,15 +1,18 @@
1
+ import { FieldProps } from "../../internal/Field.js";
1
2
  import * as React from "react";
2
3
  export interface SelectOption<V extends string = string> {
3
4
  value: V;
4
5
  label: string;
5
6
  disabled?: boolean;
6
7
  }
7
- export interface SelectProps<V extends string = string> {
8
- /** Shown above the trigger. Without it, pass aria-label. */
9
- label?: string;
8
+ export interface SelectProps<V extends string = string> extends FieldProps {
9
+ /** @deprecated pass label (with hideLabel to hide it). */
10
10
  'aria-label'?: string;
11
+ /** The chosen value, or null for none. */
11
12
  value?: V | null;
13
+ /** Receives the chosen value. */
12
14
  onChange?: (value: V) => void;
15
+ /** The options, each { value, label }. */
13
16
  options: SelectOption<V>[];
14
17
  /** A search box at the top of the list. Default: on when there are more than 8 options. */
15
18
  searchable?: boolean;
@@ -17,14 +20,7 @@ export interface SelectProps<V extends string = string> {
17
20
  placeholder?: string;
18
21
  /** Default 「搜尋」. */
19
22
  searchPlaceholder?: string;
20
- /** Red asterisk after the label. */
21
- required?: boolean;
22
- disabled?: boolean;
23
- /** The cause and the fix (「請選擇部門」). Red border, the warning icon and this line under the field, announced when it
24
- * appears. */
25
- error?: string;
26
- /** Form field name; the value is submitted with the form. */
27
- name?: string;
23
+ /** Extra class on the root element. */
28
24
  className?: string;
29
25
  }
30
26
  /** Pick one option from a list. Use it instead of a native <select>; a search box appears above 8 options. */
@@ -3,6 +3,7 @@ import { tr } from "../../i18n.js";
3
3
  import { Icon } from "../../icons/Icon.js";
4
4
  import { cx } from "../../internal/util.js";
5
5
  import { FieldErrorIcon, FieldLabel, FieldMessage } from "../../internal/Field.js";
6
+ import { devWarn } from "../../internal/dev.js";
6
7
  import { includeIcons } from "../../icons/store.js";
7
8
  import caret_down_default from "../../icons/ph/caret-down.js";
8
9
  import check_default from "../../icons/ph/check.js";
@@ -15,12 +16,14 @@ import { Select } from "@base-ui/react/select";
15
16
  includeIcons(caret_down_default, check_default, magnifying_glass_default);
16
17
  /** Pick one option from a list. Use it instead of a native <select>; a search box appears above 8 options. */
17
18
  function Select$1(props) {
18
- const { label, value, onChange, options, searchable = options.length > 8, placeholder, searchPlaceholder, required, disabled, error, name, className } = props;
19
+ const { label, hideLabel, hint, value, onChange, options, searchable = options.length > 8, placeholder, searchPlaceholder, required, disabled, error, name, className } = props;
19
20
  const labelId = React.useId();
20
21
  const current = options.find((o) => o.value === value) ?? null;
22
+ devWarn(!label, "Select", "label is required: pass label=\"…\" (and hideLabel to hide it from sight) instead of aria-label.");
21
23
  const head = label ? /* @__PURE__ */ jsx(FieldLabel, {
22
24
  id: labelId,
23
25
  required,
26
+ hidden: hideLabel,
24
27
  children: label
25
28
  }) : null;
26
29
  const trigger = /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -38,7 +41,8 @@ function Select$1(props) {
38
41
  const errId = labelId + "-err";
39
42
  const message = /* @__PURE__ */ jsx(FieldMessage, {
40
43
  id: errId,
41
- error
44
+ error,
45
+ hint
42
46
  });
43
47
  const optionBody = (o, on) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", { children: o.label }), on ? /* @__PURE__ */ jsx(Icon, {
44
48
  name: "check",
@@ -48,7 +52,7 @@ function Select$1(props) {
48
52
  "aria-labelledby": label ? labelId : void 0,
49
53
  "aria-label": label ? void 0 : props["aria-label"],
50
54
  "aria-invalid": error ? true : void 0,
51
- "aria-describedby": error ? errId : void 0
55
+ "aria-describedby": error || hint ? errId : void 0
52
56
  };
53
57
  const triggerClass = cx("ui-select-trigger", error && "is-invalid");
54
58
  if (searchable) return /* @__PURE__ */ jsxs("div", {
@@ -1 +1 @@
1
- {"version":3,"file":"Select.js","names":["phCaretDown","phCheck","phMagnifyingGlass","Select","BaseSelect"],"sources":["../../../src/components/Select/Select.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Select as BaseSelect } from '@base-ui/react/select';\nimport { Combobox } from '@base-ui/react/combobox';\nimport { tr } from '../../i18n';\nimport { Icon } from '../../icons/Icon';\nimport { cx } from '../../internal/util';\nimport { FieldErrorIcon, FieldLabel, FieldMessage } from '../../internal/Field';\nimport { includeIcons } from '../../icons/store';\nimport phCaretDown from '../../icons/ph/caret-down';\nimport phCheck from '../../icons/ph/check';\nimport phMagnifyingGlass from '../../icons/ph/magnifying-glass';\n\nincludeIcons(phCaretDown, phCheck, phMagnifyingGlass);\n\nexport interface SelectOption<V extends string = string> {\n value: V;\n label: string;\n disabled?: boolean;\n}\n\nexport interface SelectProps<V extends string = string> {\n /** Shown above the trigger. Without it, pass aria-label. */\n label?: string;\n 'aria-label'?: string;\n value?: V | null;\n onChange?: (value: V) => void;\n options: SelectOption<V>[];\n /** A search box at the top of the list. Default: on when there are more than 8 options. */\n searchable?: boolean;\n /** Default 「請選擇」. */\n placeholder?: string;\n /** Default 「搜尋」. */\n searchPlaceholder?: string;\n /** Red asterisk after the label. */\n required?: boolean;\n disabled?: boolean;\n /** The cause and the fix (「請選擇部門」). Red border, the warning icon and this line under the field, announced when it\n * appears. */\n error?: string;\n /** Form field name; the value is submitted with the form. */\n name?: string;\n className?: string;\n}\n\n/** Pick one option from a list. Use it instead of a native <select>; a search box appears above 8 options. */\nexport function Select<V extends string = string>(props: SelectProps<V>) {\n const {\n label,\n value,\n onChange,\n options,\n searchable = options.length > 8,\n placeholder,\n searchPlaceholder,\n required,\n disabled,\n error,\n name,\n className,\n } = props;\n const labelId = React.useId();\n const current = options.find((o) => o.value === value) ?? null;\n const head = label ? (\n <FieldLabel id={labelId} required={required}>\n {label}\n </FieldLabel>\n ) : null;\n const trigger = (\n <>\n <span className={cx(!current && 'is-placeholder')}>{current ? current.label : placeholder || tr('請選擇')}</span>\n {error ? <FieldErrorIcon inline /> : null}\n <Icon name=\"caret-down\" size={16} className=\"ui-select-chev\" />\n </>\n );\n const errId = labelId + '-err';\n const message = <FieldMessage id={errId} error={error} />;\n const optionBody = (o: SelectOption<V>, on: boolean) => (\n <>\n <span>{o.label}</span>\n {on ? <Icon name=\"check\" size={16} /> : null}\n </>\n );\n const labelling = {\n 'aria-labelledby': label ? labelId : undefined,\n 'aria-label': label ? undefined : props['aria-label'],\n 'aria-invalid': error ? true : undefined,\n 'aria-describedby': error ? errId : undefined,\n };\n const triggerClass = cx('ui-select-trigger', error && 'is-invalid');\n\n if (searchable) {\n return (\n <div className={cx('ui-select', className)}>\n {head}\n <Combobox.Root\n items={options}\n value={current}\n onValueChange={(o: SelectOption<V> | null) => o && onChange?.(o.value)}\n itemToStringLabel={(o: SelectOption<V>) => o.label}\n isItemEqualToValue={(a: SelectOption<V>, b: SelectOption<V>) => a.value === b.value}\n disabled={disabled}\n required={required}\n name={name}\n >\n <Combobox.Trigger className={triggerClass} {...labelling}>\n {trigger}\n </Combobox.Trigger>\n <Combobox.Portal>\n <Combobox.Positioner className=\"ui-select-positioner\" align=\"start\" sideOffset={6}>\n <Combobox.Popup className=\"ui-select-menu\" aria-label={label || props['aria-label']}>\n <div className=\"ui-select-search\">\n <Icon name=\"magnifying-glass\" size={14} />\n <Combobox.Input placeholder={searchPlaceholder || tr('搜尋')} aria-label={searchPlaceholder || tr('搜尋')} />\n </div>\n <Combobox.Empty className=\"ui-select-empty\">{tr('找不到符合的選項')}</Combobox.Empty>\n <Combobox.List>\n {(o: SelectOption<V>) => (\n <Combobox.Item key={o.value} value={o} disabled={o.disabled} className={cx('ui-select-opt', o.value === value && 'is-on')}>\n {optionBody(o, o.value === value)}\n </Combobox.Item>\n )}\n </Combobox.List>\n </Combobox.Popup>\n </Combobox.Positioner>\n </Combobox.Portal>\n </Combobox.Root>\n {message}\n </div>\n );\n }\n return (\n <div className={cx('ui-select', className)}>\n {head}\n <BaseSelect.Root\n items={options}\n value={value ?? null}\n onValueChange={(v) => v != null && onChange?.(v as V)}\n disabled={disabled}\n required={required}\n name={name}\n >\n <BaseSelect.Trigger className={triggerClass} {...labelling}>\n {trigger}\n </BaseSelect.Trigger>\n <BaseSelect.Portal>\n <BaseSelect.Positioner className=\"ui-select-positioner\" alignItemWithTrigger={false} align=\"start\" sideOffset={6}>\n <BaseSelect.Popup className=\"ui-select-menu\">\n <BaseSelect.List>\n {options.map((o) => (\n <BaseSelect.Item key={o.value} value={o.value} disabled={o.disabled} className={cx('ui-select-opt', o.value === value && 'is-on')}>\n {optionBody(o, o.value === value)}\n </BaseSelect.Item>\n ))}\n </BaseSelect.List>\n </BaseSelect.Popup>\n </BaseSelect.Positioner>\n </BaseSelect.Portal>\n </BaseSelect.Root>\n {message}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAYA,aAAaA,oBAAaC,eAASC,wBAAiB;;AAiCpD,SAAgBC,SAAkC,OAAuB;CACvE,MAAM,EACJ,OACA,OACA,UACA,SACA,aAAa,QAAQ,SAAS,GAC9B,aACA,mBACA,UACA,UACA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Y;KAC7G,UAAA,oBAACA,OAAW,OAAZ;MAAkB,WAAU;MAC1B,UAAA,oBAACA,OAAW,MAAZ,EAAA,UACG,QAAQ,KAAK,MACZ,oBAACA,OAAW,MAAZ;OAA+B,OAAO,EAAE;OAAO,UAAU,EAAE;OAAU,WAAW,GAAG,iBAAiB,EAAE,UAAU,SAAS,OAAO;OAC7H,UAAA,WAAW,GAAG,EAAE,UAAU,KAAK;MACjB,GAFK,EAAE,KAEP,CAClB,EACc,CAAA;KACD,CAAA;IACG,CAAA,EACN,CAAA,CACJ;;GAChB;EACE;;AAET"}
1
+ {"version":3,"file":"Select.js","names":["phCaretDown","phCheck","phMagnifyingGlass","Select","BaseSelect"],"sources":["../../../src/components/Select/Select.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Select as BaseSelect } from '@base-ui/react/select';\nimport { Combobox } from '@base-ui/react/combobox';\nimport { tr } from '../../i18n';\nimport { Icon } from '../../icons/Icon';\nimport { cx } from '../../internal/util';\nimport { FieldErrorIcon, FieldLabel, FieldMessage, type FieldProps } from '../../internal/Field';\nimport { devWarn } from '../../internal/dev';\nimport { includeIcons } from '../../icons/store';\nimport phCaretDown from '../../icons/ph/caret-down';\nimport phCheck from '../../icons/ph/check';\nimport phMagnifyingGlass from '../../icons/ph/magnifying-glass';\n\nincludeIcons(phCaretDown, phCheck, phMagnifyingGlass);\n\nexport interface SelectOption<V extends string = string> {\n value: V;\n label: string;\n disabled?: boolean;\n}\n\nexport interface SelectProps<V extends string = string> extends FieldProps {\n /** @deprecated pass label (with hideLabel to hide it). */\n 'aria-label'?: string;\n /** The chosen value, or null for none. */\n value?: V | null;\n /** Receives the chosen value. */\n onChange?: (value: V) => void;\n /** The options, each { value, label }. */\n options: SelectOption<V>[];\n /** A search box at the top of the list. Default: on when there are more than 8 options. */\n searchable?: boolean;\n /** Default 「請選擇」. */\n placeholder?: string;\n /** Default 「搜尋」. */\n searchPlaceholder?: string;\n /** Extra class on the root element. */\n className?: string;\n}\n\n/** Pick one option from a list. Use it instead of a native <select>; a search box appears above 8 options. */\nexport function Select<V extends string = string>(props: SelectProps<V>) {\n const {\n label,\n hideLabel,\n hint,\n value,\n onChange,\n options,\n searchable = options.length > 8,\n placeholder,\n searchPlaceholder,\n required,\n disabled,\n error,\n name,\n className,\n } = props;\n const labelId = React.useId();\n const current = options.find((o) => o.value === value) ?? null;\n devWarn(!label, 'Select', 'label is required: pass label=\"…\" (and hideLabel to hide it from sight) instead of aria-label.');\n const head = label ? (\n <FieldLabel id={labelId} required={required} hidden={hideLabel}>\n {label}\n </FieldLabel>\n ) : null;\n const trigger = (\n <>\n <span className={cx(!current && 'is-placeholder')}>{current ? current.label : placeholder || tr('請選擇')}</span>\n {error ? <FieldErrorIcon inline /> : null}\n <Icon name=\"caret-down\" size={16} className=\"ui-select-chev\" />\n </>\n );\n const errId = labelId + '-err';\n const message = <FieldMessage id={errId} error={error} hint={hint} />;\n const optionBody = (o: SelectOption<V>, on: boolean) => (\n <>\n <span>{o.label}</span>\n {on ? <Icon name=\"check\" size={16} /> : null}\n </>\n );\n const labelling = {\n 'aria-labelledby': label ? labelId : undefined,\n 'aria-label': label ? undefined : props['aria-label'],\n 'aria-invalid': error ? true : undefined,\n 'aria-describedby': error || hint ? errId : undefined,\n };\n const triggerClass = cx('ui-select-trigger', error && 'is-invalid');\n\n if (searchable) {\n return (\n <div className={cx('ui-select', className)}>\n {head}\n <Combobox.Root\n items={options}\n value={current}\n onValueChange={(o: SelectOption<V> | null) => o && onChange?.(o.value)}\n itemToStringLabel={(o: SelectOption<V>) => o.label}\n isItemEqualToValue={(a: SelectOption<V>, b: SelectOption<V>) => a.value === b.value}\n disabled={disabled}\n required={required}\n name={name}\n >\n <Combobox.Trigger className={triggerClass} {...labelling}>\n {trigger}\n </Combobox.Trigger>\n <Combobox.Portal>\n <Combobox.Positioner className=\"ui-select-positioner\" align=\"start\" sideOffset={6}>\n <Combobox.Popup className=\"ui-select-menu\" aria-label={label || props['aria-label']}>\n <div className=\"ui-select-search\">\n <Icon name=\"magnifying-glass\" size={14} />\n <Combobox.Input placeholder={searchPlaceholder || tr('搜尋')} aria-label={searchPlaceholder || tr('搜尋')} />\n </div>\n <Combobox.Empty className=\"ui-select-empty\">{tr('找不到符合的選項')}</Combobox.Empty>\n <Combobox.List>\n {(o: SelectOption<V>) => (\n <Combobox.Item key={o.value} value={o} disabled={o.disabled} className={cx('ui-select-opt', o.value === value && 'is-on')}>\n {optionBody(o, o.value === value)}\n </Combobox.Item>\n )}\n </Combobox.List>\n </Combobox.Popup>\n </Combobox.Positioner>\n </Combobox.Portal>\n </Combobox.Root>\n {message}\n </div>\n );\n }\n return (\n <div className={cx('ui-select', className)}>\n {head}\n <BaseSelect.Root\n items={options}\n value={value ?? null}\n onValueChange={(v) => v != null && onChange?.(v as V)}\n disabled={disabled}\n required={required}\n name={name}\n >\n <BaseSelect.Trigger className={triggerClass} {...labelling}>\n {trigger}\n </BaseSelect.Trigger>\n <BaseSelect.Portal>\n <BaseSelect.Positioner className=\"ui-select-positioner\" alignItemWithTrigger={false} align=\"start\" sideOffset={6}>\n <BaseSelect.Popup className=\"ui-select-menu\">\n <BaseSelect.List>\n {options.map((o) => (\n <BaseSelect.Item key={o.value} value={o.value} disabled={o.disabled} className={cx('ui-select-opt', o.value === value && 'is-on')}>\n {optionBody(o, o.value === value)}\n </BaseSelect.Item>\n ))}\n </BaseSelect.List>\n </BaseSelect.Popup>\n </BaseSelect.Positioner>\n </BaseSelect.Portal>\n </BaseSelect.Root>\n {message}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAaA,aAAaA,oBAAaC,eAASC,wBAAiB;;AA4BpD,SAAgBC,SAAkC,OAAuB;CACvE,MAAM,EACJ,OACA,WACA,MACA,OACA,UACA,SACA,aAAa,QAAQ,SAAS,GAC9B,aACA,mBACA,UACA,UACA,OACA,MACA,cACE;CACJ,MAAM,UAAU,MAAM,MAAM;CAC5B,MAAM,UAAU,QAAQ,MAAM,MAAM,EAAE,U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W,OAAZ;MAAkB,WAAU;MAC1B,UAAA,oBAACA,OAAW,MAAZ,EAAA,UACG,QAAQ,KAAK,MACZ,oBAACA,OAAW,MAAZ;OAA+B,OAAO,EAAE;OAAO,UAAU,EAAE;OAAU,WAAW,GAAG,iBAAiB,EAAE,UAAU,SAAS,OAAO;OAC7H,UAAA,WAAW,GAAG,EAAE,UAAU,KAAK;MACjB,GAFK,EAAE,KAEP,CAClB,EACc,CAAA;KACD,CAAA;IACG,CAAA,EACN,CAAA,CACJ;;GAChB;EACE;;AAET"}
@@ -1,27 +1,56 @@
1
1
  import * as React from "react";
2
2
  export interface SettingsCategory {
3
+ /** Also the URL hash of the category (#notifications): letters, digits and hyphens. */
3
4
  id: string;
5
+ /** The name in the category list, a noun: 「通知」. */
4
6
  label: string;
7
+ /** SettingsSections; a DangerZone goes last in the last category. */
5
8
  content: React.ReactNode;
6
9
  }
7
10
  export interface SettingsLayoutProps {
11
+ /** The page title. Inside AppShell leave it out and give AppShell title="設定": the title shows once. */
8
12
  title?: string;
13
+ /** The categories, in order. */
9
14
  categories: SettingsCategory[];
10
15
  /** Controlled category id. */
11
16
  value?: string;
17
+ /** Called with the category id when another category is chosen. */
12
18
  onChange?: (id: string) => void;
13
- /** Text of the 「已儲存」 toast; empty hides it. Changes save on their own, so there is no save button. */
19
+ /** Uncontrolled: keep the open category in the URL hash (#notifications), so a reload or a shared link opens it.
20
+ * Default true. */
21
+ urlSync?: boolean;
22
+ /** @deprecated call toast('已儲存', { id: 'saved' }) when a change is saved; AppShell shows it. Until removed: a
23
+ * non-empty text shows through toast(), an empty one closes it. */
14
24
  toast?: string;
25
+ /** Extra class on the root element. */
15
26
  className?: string;
16
27
  }
17
28
  /** A settings page: categories on the left, their sections on the right. Changes save at once. */
18
- export declare function SettingsLayout({ title, categories, value, onChange, toast, className }: SettingsLayoutProps): React.JSX.Element;
29
+ export declare function SettingsLayout({ title, categories, value, onChange, urlSync, toast, className }: SettingsLayoutProps): React.JSX.Element;
19
30
  export interface SettingsSectionProps {
31
+ /** The section's heading, 17 px like a Card title. */
20
32
  title?: string;
21
- /** One sentence under the title. */
33
+ /** One sentence under the title; `backticks` are code. */
22
34
  description?: string;
35
+ /** Fields and SettingsRows. */
23
36
  children?: React.ReactNode;
37
+ /** Extra class on the root element. */
24
38
  className?: string;
25
39
  }
26
40
  /** One group of settings with a heading. It is a card on its own; inside a Card it drops its shadow. */
27
- export declare function SettingsSection({ title, description, children, className }: SettingsSectionProps): React.JSX.Element;
41
+ export declare function SettingsSection({ title, description, children, className }: SettingsSectionProps): React.JSX.Element;
42
+ export interface SettingsRowProps {
43
+ /** What the setting does, a short noun phrase: 「部署失敗時寄 Email」. Also give it to the Switch's `label`. */
44
+ label: string;
45
+ /** One sentence under the label; `backticks` are code. */
46
+ description?: string;
47
+ /** The control at the right end: a Switch (or a Select). */
48
+ children: React.ReactElement<{
49
+ 'aria-describedby'?: string;
50
+ }>;
51
+ /** Extra class on the root element. */
52
+ className?: string;
53
+ }
54
+ /** One setting on one row: the label and a sentence on the left, the control on the right. The whole row is a
55
+ * `<label>`, so clicking the text toggles a Switch. */
56
+ export declare function SettingsRow({ label, description, children, className }: SettingsRowProps): React.JSX.Element;
@@ -1,15 +1,49 @@
1
1
  "use client";
2
2
  import { tr } from "../../i18n.js";
3
3
  import { cx } from "../../internal/util.js";
4
- import { Toast } from "../Toast/Toast.js";
4
+ import { devWarn } from "../../internal/dev.js";
5
+ import { ShellTitle } from "../../internal/shell.js";
6
+ import { announce } from "../../announce.js";
7
+ import { AutoToaster, toast } from "../Toast/Toast.js";
8
+ import { codeText } from "../InlineCode/InlineCode.js";
5
9
  import * as React from "react";
6
10
  import { jsx, jsxs } from "react/jsx-runtime";
7
11
  // src/components/SettingsLayout/SettingsLayout.tsx
8
12
  /** A settings page: categories on the left, their sections on the right. Changes save at once. */
9
- function SettingsLayout({ title, categories, value, onChange, toast, className }) {
10
- const [own, setOwn] = React.useState(value ?? categories[0]?.id);
13
+ function SettingsLayout({ title, categories, value, onChange, urlSync = true, toast: toast$1, className }) {
14
+ const shell = React.useContext(ShellTitle);
15
+ devWarn(toast$1 !== void 0, "SettingsLayout", "toast is deprecated: call toast('已儲存', { id: 'saved' }) from @seanyeh77/ui when a change is saved. AppShell shows it above the phone tab bar; outside AppShell put one <Toaster /> on the page.");
16
+ React.useEffect(() => {
17
+ if (toast$1 === void 0) return;
18
+ if (toast$1) toast(toast$1, { id: "ui-settings-saved" });
19
+ else toast.close("ui-settings-saved");
20
+ }, [toast$1]);
21
+ devWarn(title && shell.title, "SettingsLayout", "the page title shows twice: AppShell has `title` and SettingsLayout has `title`. Inside AppShell, give the title to AppShell only.");
22
+ const sync = urlSync && value === void 0;
23
+ const fromHash = () => {
24
+ if (!sync || typeof location === "undefined") return void 0;
25
+ const id = decodeURIComponent(location.hash.slice(1));
26
+ return categories.some((c) => c.id === id) ? id : void 0;
27
+ };
28
+ const [own, setOwn] = React.useState(() => fromHash() ?? value ?? categories[0]?.id);
11
29
  const active = value ?? own;
12
30
  const item = categories.find((c) => c.id === active) ?? categories[0];
31
+ React.useEffect(() => {
32
+ if (!sync) return;
33
+ const onHash = () => {
34
+ const id = fromHash();
35
+ if (id) setOwn(id);
36
+ };
37
+ window.addEventListener("hashchange", onHash);
38
+ return () => window.removeEventListener("hashchange", onHash);
39
+ }, [sync]);
40
+ const choose = (c) => {
41
+ if (c.id === item?.id) return;
42
+ setOwn(c.id);
43
+ if (sync) history.replaceState(history.state, "", location.pathname + location.search + "#" + encodeURIComponent(c.id));
44
+ announce(c.label);
45
+ onChange?.(c.id);
46
+ };
13
47
  return /* @__PURE__ */ jsxs("div", {
14
48
  className: cx("ui-settings", className),
15
49
  children: [
@@ -23,15 +57,12 @@ function SettingsLayout({ title, categories, value, onChange, toast, className }
23
57
  className: "ui-settings-nav",
24
58
  "aria-label": tr("設定分類"),
25
59
  children: categories.map((c) => {
26
- const on = c.id === active;
60
+ const on = c.id === item?.id;
27
61
  return /* @__PURE__ */ jsx("button", {
28
62
  type: "button",
29
63
  className: cx("ui-settings-cat", on && "is-on"),
30
64
  "aria-current": on ? "page" : void 0,
31
- onClick: () => {
32
- setOwn(c.id);
33
- onChange?.(c.id);
34
- },
65
+ onClick: () => choose(c),
35
66
  children: c.label
36
67
  }, c.id);
37
68
  })
@@ -40,10 +71,7 @@ function SettingsLayout({ title, categories, value, onChange, toast, className }
40
71
  children: item?.content
41
72
  })]
42
73
  }),
43
- toast ? /* @__PURE__ */ jsx("div", {
44
- className: "ui-settings-toast",
45
- children: /* @__PURE__ */ jsx(Toast, { children: toast })
46
- }) : null
74
+ toast$1 !== void 0 ? /* @__PURE__ */ jsx(AutoToaster, {}) : null
47
75
  ]
48
76
  });
49
77
  }
@@ -58,12 +86,32 @@ function SettingsSection({ title, description, children, className }) {
58
86
  }) : null,
59
87
  description ? /* @__PURE__ */ jsx("p", {
60
88
  className: "ui-settings-desc",
61
- children: description
89
+ children: codeText(description)
62
90
  }) : null,
63
91
  children
64
92
  ]
65
93
  });
66
94
  }
67
- export { SettingsLayout, SettingsSection };
95
+ /** One setting on one row: the label and a sentence on the left, the control on the right. The whole row is a
96
+ * `<label>`, so clicking the text toggles a Switch. */
97
+ function SettingsRow({ label, description, children, className }) {
98
+ const id = React.useId();
99
+ const control = description && React.isValidElement(children) ? React.cloneElement(children, { "aria-describedby": id }) : children;
100
+ return /* @__PURE__ */ jsxs("label", {
101
+ className: cx("ui-settings-row", className),
102
+ children: [/* @__PURE__ */ jsxs("span", {
103
+ className: "ui-settings-rowtext",
104
+ children: [/* @__PURE__ */ jsx("span", {
105
+ className: "ui-settings-rowlabel",
106
+ children: label
107
+ }), description ? /* @__PURE__ */ jsx("span", {
108
+ id,
109
+ className: "ui-settings-rowdesc",
110
+ children: codeText(description)
111
+ }) : null]
112
+ }), control]
113
+ });
114
+ }
115
+ export { SettingsLayout, SettingsRow, SettingsSection };
68
116
 
69
117
  //# sourceMappingURL=SettingsLayout.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SettingsLayout.js","names":[],"sources":["../../../src/components/SettingsLayout/SettingsLayout.tsx"],"sourcesContent":["import * as React from 'react';\nimport { tr } from '../../i18n';\nimport { cx } from '../../internal/util';\nimport { Toast } from '../Toast/Toast';\n\nexport interface SettingsCategory {\n id: string;\n label: string;\n content: React.ReactNode;\n}\n\nexport interface SettingsLayoutProps {\n title?: string;\n categories: SettingsCategory[];\n /** Controlled category id. */\n value?: string;\n onChange?: (id: string) => void;\n /** Text of the 「已儲存」 toast; empty hides it. Changes save on their own, so there is no save button. */\n toast?: string;\n className?: string;\n}\n\n/** A settings page: categories on the left, their sections on the right. Changes save at once. */\nexport function SettingsLayout({ title, categories, value, onChange, toast, className }: SettingsLayoutProps) {\n const [own, setOwn] = React.useState(value ?? categories[0]?.id);\n const active = value ?? own;\n const item = categories.find((c) => c.id === active) ?? categories[0];\n return (\n <div className={cx('ui-settings', className)}>\n {title ? <h1 className=\"ui-settings-title\">{title}</h1> : null}\n <div className=\"ui-settings-body\">\n <nav className=\"ui-settings-nav\" aria-label={tr('設定分類')}>\n {categories.map((c) => {\n const on = c.id === active;\n return (\n <button\n key={c.id}\n type=\"button\"\n className={cx('ui-settings-cat', on && 'is-on')}\n aria-current={on ? 'page' : undefined}\n onClick={() => {\n setOwn(c.id);\n onChange?.(c.id);\n }}\n >\n {c.label}\n </button>\n );\n })}\n </nav>\n <div className=\"ui-settings-content\">{item?.content}</div>\n </div>\n {toast ? (\n <div className=\"ui-settings-toast\">\n <Toast>{toast}</Toast>\n </div>\n ) : null}\n </div>\n );\n}\n\nexport interface SettingsSectionProps {\n title?: string;\n /** One sentence under the title. */\n description?: string;\n children?: React.ReactNode;\n className?: string;\n}\n\n/** One group of settings with a heading. It is a card on its own; inside a Card it drops its shadow. */\nexport function SettingsSection({ title, description, children, className }: SettingsSectionProps) {\n return (\n <section className={cx('ui-settings-section', className)}>\n {title ? <h2 className=\"ui-settings-h\">{title}</h2> : null}\n {description ? <p className=\"ui-settings-desc\">{description}</p> : null}\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AA,IAAI;GAClE;EACM;;AAEb"}
1
+ {"version":3,"file":"SettingsLayout.js","names":["toast"],"sources":["../../../src/components/SettingsLayout/SettingsLayout.tsx"],"sourcesContent":["import * as React from 'react';\nimport { tr } from '../../i18n';\nimport { cx } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\nimport { ShellTitle } from '../../internal/shell';\nimport { announce } from '../../announce';\nimport { AutoToaster, toast as showToast } from '../Toast/Toast';\nimport { codeText } from '../InlineCode/InlineCode';\n\nexport interface SettingsCategory {\n /** Also the URL hash of the category (#notifications): letters, digits and hyphens. */\n id: string;\n /** The name in the category list, a noun: 「通知」. */\n label: string;\n /** SettingsSections; a DangerZone goes last in the last category. */\n content: React.ReactNode;\n}\n\nexport interface SettingsLayoutProps {\n /** The page title. Inside AppShell leave it out and give AppShell title=\"設定\": the title shows once. */\n title?: string;\n /** The categories, in order. */\n categories: SettingsCategory[];\n /** Controlled category id. */\n value?: string;\n /** Called with the category id when another category is chosen. */\n onChange?: (id: string) => void;\n /** Uncontrolled: keep the open category in the URL hash (#notifications), so a reload or a shared link opens it.\n * Default true. */\n urlSync?: boolean;\n /** @deprecated call toast('已儲存', { id: 'saved' }) when a change is saved; AppShell shows it. Until removed: a\n * non-empty text shows through toast(), an empty one closes it. */\n toast?: string;\n /** Extra class on the root element. */\n className?: string;\n}\n\n/** A settings page: categories on the left, their sections on the right. Changes save at once. */\nexport function SettingsLayout({ title, categories, value, onChange, urlSync = true, toast, className }: SettingsLayoutProps) {\n const shell = React.useContext(ShellTitle);\n devWarn(\n toast !== undefined,\n 'SettingsLayout',\n \"toast is deprecated: call toast('已儲存', { id: 'saved' }) from @seanyeh77/ui when a change is saved. AppShell shows it above the phone tab bar; outside AppShell put one <Toaster /> on the page.\",\n );\n // The old prop, through the toast system: one toast that restarts when the text changes, closed when it is emptied.\n React.useEffect(() => {\n if (toast === undefined) return;\n if (toast) showToast(toast, { id: 'ui-settings-saved' });\n else showToast.close('ui-settings-saved');\n }, [toast]);\n devWarn(\n title && shell.title,\n 'SettingsLayout',\n 'the page title shows twice: AppShell has `title` and SettingsLayout has `title`. Inside AppShell, give the title to AppShell only.',\n );\n const sync = urlSync && value === undefined;\n const fromHash = () => {\n if (!sync || typeof location === 'undefined') return undefined;\n const id = decodeURIComponent(location.hash.slice(1));\n return categories.some((c) => c.id === id) ? id : undefined;\n };\n const [own, setOwn] = React.useState<string | undefined>(() => fromHash() ?? value ?? categories[0]?.id);\n const active = value ?? own;\n const item = categories.find((c) => c.id === active) ?? categories[0];\n // A link or the back button that changes the hash opens that category.\n React.useEffect(() => {\n if (!sync) return;\n const onHash = () => {\n const id = fromHash();\n if (id) setOwn(id);\n };\n window.addEventListener('hashchange', onHash);\n return () => window.removeEventListener('hashchange', onHash);\n // eslint-disable-next-line react-hooks/exhaustive-deps -- categories are read when the hash changes\n }, [sync]);\n const choose = (c: SettingsCategory) => {\n if (c.id === item?.id) return;\n setOwn(c.id);\n if (sync) history.replaceState(history.state, '', location.pathname + location.search + '#' + encodeURIComponent(c.id));\n announce(c.label);\n onChange?.(c.id);\n };\n return (\n <div className={cx('ui-settings', className)}>\n {title ? <h1 className=\"ui-settings-title\">{title}</h1> : null}\n <div className=\"ui-settings-body\">\n <nav className=\"ui-settings-nav\" aria-label={tr('設定分類')}>\n {categories.map((c) => {\n const on = c.id === item?.id;\n return (\n <button\n key={c.id}\n type=\"button\"\n className={cx('ui-settings-cat', on && 'is-on')}\n aria-current={on ? 'page' : undefined}\n onClick={() => choose(c)}\n >\n {c.label}\n </button>\n );\n })}\n </nav>\n <div className=\"ui-settings-content\">{item?.content}</div>\n </div>\n {toast !== undefined ? <AutoToaster /> : null}\n </div>\n );\n}\n\nexport interface SettingsSectionProps {\n /** The section's heading, 17 px like a Card title. */\n title?: string;\n /** One sentence under the title; `backticks` are code. */\n description?: string;\n /** Fields and SettingsRows. */\n children?: React.ReactNode;\n /** Extra class on the root element. */\n className?: string;\n}\n\n/** One group of settings with a heading. It is a card on its own; inside a Card it drops its shadow. */\nexport function SettingsSection({ title, description, children, className }: SettingsSectionProps) {\n return (\n <section className={cx('ui-settings-section', className)}>\n {title ? <h2 className=\"ui-settings-h\">{title}</h2> : null}\n {description ? <p className=\"ui-settings-desc\">{codeText(description)}</p> : null}\n {children}\n </section>\n );\n}\n\nexport interface SettingsRowProps {\n /** What the setting does, a short noun phrase: 「部署失敗時寄 Email」. Also give it to the Switch's `label`. */\n label: string;\n /** One sentence under the label; `backticks` are code. */\n description?: string;\n /** The control at the right end: a Switch (or a Select). */\n children: React.ReactElement<{ 'aria-describedby'?: string }>;\n /** Extra class on the root element. */\n className?: string;\n}\n\n/** One setting on one row: the label and a sentence on the left, the control on the right. The whole row is a\n * `<label>`, so clicking the text toggles a Switch. */\nexport function SettingsRow({ label, description, children, className }: SettingsRowProps) {\n const id = React.useId();\n const control = description && React.isValidElement(children) ? React.cloneElement(children, { 'aria-describedby': id }) : children;\n return (\n <label className={cx('ui-settings-row', className)}>\n <span className=\"ui-settings-rowtext\">\n <span className=\"ui-settings-rowlabel\">{label}</span>\n {description ? (\n <span id={id} className=\"ui-settings-rowdesc\">\n {codeText(description)}\n </span>\n ) : null}\n </span>\n {control}\n </label>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAsCA,SAAgB,eAAe,EAAE,OAAO,YAAY,OAAO,UAAU,UAAU,MAAM,OAAA,SAAO,aAAkC;CAC5H,MAAM,QAAQ,MAAM,WAAW,UAAU;CACzC,QACEA,YAAU,KAAA,GACV,kBACA,iMACF;CAEA,MAAM,gBAAgB;EACpB,IAAIA,YAAU,KAAA,GAAW;EACzB,IAAIA,SAAO,MAAUA,SAAO,EAAE,IAAI,oBAAoB,CAAC;OAClD,MAAU,MAAM,mBAAmB;CAC1C,GAAG,CAACA,OAAK,CAAC;CACV,QACE,SAAS,MAAM,OACf,kBACA,oIACF;CACA,MAAM,OAAO,WAAW,UAAU,KAAA;CAClC,MAAM,iBAAiB;EACrB,IAAI,CAAC,QAAQ,OAAO,aAAa,aAAa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EAAE;MACG,GAPD,EAAE,EAOD;KAEZ,CAAC;IACE,CAAA,GACL,oBAAC,OAAD;KAAK,WAAU;KAAuB,UAAA,MAAM;IAAa,CAAA,CACtD;;GACJA,YAAU,KAAA,IAAY,oBAAC,aAAD,CAAc,CAAA,IAAI;EACtC;;AAET;;AAcA,SAAgB,gBAAgB,EAAE,OAAO,aAAa,UAAU,aAAmC;CACjG,OACE,qBAAC,WAAD;EAAS,WAAW,GAAG,uBAAuB,SAAS;EAAvD,UAAA;GACG,QAAQ,oBAAC,MAAD;IAAI,WAAU;IAAiB,UAAA;GAAU,CAAA,IAAI;GACrD,cAAc,oBAAC,KAAD;IAAG,WAAU;IAAoB,UAAA,SAAS,WAAW;GAAK,CAAA,IAAI;GAC5E;EACM;;AAEb;;;AAeA,SAAgB,YAAY,EAAE,OAAO,aAAa,UAAU,aAA+B;CACzF,MAAM,KAAK,MAAM,MAAM;CACvB,MAAM,UAAU,eAAe,MAAM,eAAe,QAAQ,IAAI,MAAM,aAAa,UAAU,EAAE,oBAAoB,GAAG,CAAC,IAAI;CAC3H,OACE,qBAAC,SAAD;EAAO,WAAW,GAAG,mBAAmB,SAAS;EAAjD,UAAA,CACE,qBAAC,QAAD;GAAM,WAAU;GAAhB,UAAA,CACE,oBAAC,QAAD;IAAM,WAAU;IAAwB,UAAA;GAAY,CAAA,GACnD,cACC,oBAAC,QAAD;IAAU;IAAI,WAAU;IACrB,UAAA,SAAS,WAAW;GACjB,CAAA,IACJ,IACA;EACL,CAAA,GAAA,OACI;;AAEX"}
@@ -27,6 +27,7 @@ export interface SideNavProps {
27
27
  sections: NavSection[];
28
28
  /** Id of the current page. */
29
29
  value: string;
30
+ /** Called with the id of the item the person picks. */
30
31
  onChange?: (id: string) => void;
31
32
  /** 72 px with icons only, labels as tooltips. */
32
33
  collapsed?: boolean;
@@ -42,6 +43,7 @@ export interface SideNavProps {
42
43
  brand?: React.ReactNode | NavBrand;
43
44
  /** Default 「主要導覽」. */
44
45
  label?: string;
46
+ /** Extra class on the root element. */
45
47
  className?: string;
46
48
  }
47
49
  /** The 240 px dashboard sidebar (72 px collapsed). The selection bar moves like a droplet. */