@robert-stackflow/oneui 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (380) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +72 -2
  3. package/assets/LUCIDE-LICENSE.txt +43 -0
  4. package/assets/character-metadata.json +1 -0
  5. package/assets/emoji.json +1 -0
  6. package/assets/icon-catalog.json +1 -0
  7. package/assets/symbols.json +1 -0
  8. package/components/Accessibility.module.css +8 -0
  9. package/components/Accordion.d.ts +7 -0
  10. package/components/Accordion.js +41 -0
  11. package/components/Accordion.module.css +38 -0
  12. package/components/Alert.d.ts +9 -0
  13. package/components/Alert.js +42 -0
  14. package/components/Alert.module.css +56 -0
  15. package/components/AppShell.d.ts +30 -0
  16. package/components/AppShell.js +152 -0
  17. package/components/AppShell.module.css +239 -0
  18. package/components/AppearanceSettings.d.ts +7 -0
  19. package/components/AppearanceSettings.js +201 -0
  20. package/components/AppearanceSettings.module.css +32 -0
  21. package/components/Avatar.d.ts +14 -0
  22. package/components/Avatar.js +69 -0
  23. package/components/Avatar.module.css +70 -0
  24. package/components/AvatarGroup.d.ts +15 -0
  25. package/components/AvatarGroup.js +115 -0
  26. package/components/AvatarGroup.module.css +54 -0
  27. package/components/Badge.d.ts +5 -0
  28. package/components/Badge.js +11 -0
  29. package/components/Badge.module.css +30 -0
  30. package/components/BlockedTab.d.ts +4 -0
  31. package/components/BlockedTab.js +10 -0
  32. package/components/Breadcrumb.d.ts +16 -0
  33. package/components/Breadcrumb.js +157 -0
  34. package/components/Breadcrumb.module.css +97 -0
  35. package/components/Button.d.ts +13 -0
  36. package/components/Button.js +52 -0
  37. package/components/Button.module.css +88 -0
  38. package/components/Calendar.d.ts +10 -0
  39. package/components/Calendar.js +260 -0
  40. package/components/Calendar.module.css +106 -0
  41. package/components/Card.d.ts +8 -0
  42. package/components/Card.js +29 -0
  43. package/components/Card.module.css +47 -0
  44. package/components/Cascader.d.ts +14 -0
  45. package/components/Cascader.js +296 -0
  46. package/components/CatalogIcon.d.ts +3 -0
  47. package/components/CatalogIcon.js +11 -0
  48. package/components/CharacterPicker.d.ts +15 -0
  49. package/components/CharacterPicker.js +200 -0
  50. package/components/Checkbox.d.ts +12 -0
  51. package/components/Checkbox.js +82 -0
  52. package/components/Checkbox.module.css +95 -0
  53. package/components/ColorField.d.ts +6 -0
  54. package/components/ColorField.js +61 -0
  55. package/components/ColorField.module.css +15 -0
  56. package/components/ColorPicker.d.ts +5 -0
  57. package/components/ColorPicker.js +188 -0
  58. package/components/ColorPicker.module.css +90 -0
  59. package/components/Combobox.d.ts +13 -0
  60. package/components/Combobox.js +338 -0
  61. package/components/Combobox.module.css +24 -0
  62. package/components/CommandPalette.d.ts +25 -0
  63. package/components/CommandPalette.js +269 -0
  64. package/components/CommandPalette.module.css +49 -0
  65. package/components/ContextMenu.d.ts +9 -0
  66. package/components/ContextMenu.js +363 -0
  67. package/components/ContextMenu.module.css +42 -0
  68. package/components/ContextMenuPanel.d.ts +22 -0
  69. package/components/ContextMenuPanel.js +155 -0
  70. package/components/ContributionCalendar.d.ts +18 -0
  71. package/components/ContributionCalendar.js +201 -0
  72. package/components/ContributionCalendar.module.css +114 -0
  73. package/components/ContributionCell.d.ts +11 -0
  74. package/components/ContributionCell.js +41 -0
  75. package/components/Control.module.css +86 -0
  76. package/components/DataTable.d.ts +49 -0
  77. package/components/DataTable.js +220 -0
  78. package/components/DataTable.module.css +112 -0
  79. package/components/DatePicker.d.ts +15 -0
  80. package/components/DatePicker.js +186 -0
  81. package/components/DatePicker.module.css +85 -0
  82. package/components/DateRangePicker.d.ts +9 -0
  83. package/components/DateRangePicker.js +168 -0
  84. package/components/Descriptions.d.ts +21 -0
  85. package/components/Descriptions.js +162 -0
  86. package/components/Descriptions.module.css +117 -0
  87. package/components/Dialog.d.ts +14 -0
  88. package/components/Dialog.js +125 -0
  89. package/components/Dialog.module.css +88 -0
  90. package/components/DialogVariants.d.ts +27 -0
  91. package/components/DialogVariants.js +161 -0
  92. package/components/DialogVariants.module.css +29 -0
  93. package/components/DisclosureChevron.d.ts +3 -0
  94. package/components/DisclosureChevron.js +17 -0
  95. package/components/DisclosureChevron.module.css +17 -0
  96. package/components/Divider.d.ts +5 -0
  97. package/components/Divider.js +24 -0
  98. package/components/Divider.module.css +19 -0
  99. package/components/Drawer.d.ts +18 -0
  100. package/components/Drawer.js +145 -0
  101. package/components/Drawer.module.css +109 -0
  102. package/components/EmojiPicker.d.ts +6 -0
  103. package/components/EmojiPicker.js +19 -0
  104. package/components/EmptyState.d.ts +8 -0
  105. package/components/EmptyState.js +20 -0
  106. package/components/EmptyState.module.css +30 -0
  107. package/components/FieldLabel.d.ts +8 -0
  108. package/components/FieldLabel.js +20 -0
  109. package/components/FieldMessages.d.ts +5 -0
  110. package/components/FieldMessages.js +15 -0
  111. package/components/FileDropOverlay.d.ts +5 -0
  112. package/components/FileDropOverlay.js +26 -0
  113. package/components/FileDropOverlay.module.css +55 -0
  114. package/components/FileDropZone.d.ts +15 -0
  115. package/components/FileDropZone.js +113 -0
  116. package/components/FileDropZone.module.css +6 -0
  117. package/components/FilePicker.d.ts +10 -0
  118. package/components/FilePicker.js +59 -0
  119. package/components/FileSelectionFeedback.d.ts +5 -0
  120. package/components/FileSelectionFeedback.js +23 -0
  121. package/components/FileSelectionFeedback.module.css +14 -0
  122. package/components/FileTree.d.ts +13 -0
  123. package/components/FileTree.js +125 -0
  124. package/components/FileTree.module.css +66 -0
  125. package/components/Form.d.ts +7 -0
  126. package/components/Form.js +26 -0
  127. package/components/Form.module.css +7 -0
  128. package/components/FormErrorSummary.d.ts +6 -0
  129. package/components/FormErrorSummary.js +27 -0
  130. package/components/FormErrorSummary.module.css +27 -0
  131. package/components/FormField.d.ts +9 -0
  132. package/components/FormField.js +59 -0
  133. package/components/FormField.module.css +85 -0
  134. package/components/FormGroup.d.ts +9 -0
  135. package/components/FormGroup.js +32 -0
  136. package/components/HierarchyPicker.module.css +181 -0
  137. package/components/IconButton.d.ts +7 -0
  138. package/components/IconButton.js +30 -0
  139. package/components/IconButton.module.css +42 -0
  140. package/components/IconPicker.d.ts +6 -0
  141. package/components/IconPicker.js +111 -0
  142. package/components/Indicator.d.ts +18 -0
  143. package/components/Indicator.js +97 -0
  144. package/components/Indicator.module.css +83 -0
  145. package/components/Input.d.ts +8 -0
  146. package/components/Input.js +37 -0
  147. package/components/Input.module.css +40 -0
  148. package/components/LoadingOverlay.d.ts +6 -0
  149. package/components/LoadingOverlay.js +16 -0
  150. package/components/LoadingOverlay.module.css +22 -0
  151. package/components/LoadingState.d.ts +7 -0
  152. package/components/LoadingState.js +40 -0
  153. package/components/LoadingState.module.css +17 -0
  154. package/components/Menu.d.ts +11 -0
  155. package/components/Menu.js +82 -0
  156. package/components/MenuItem.d.ts +15 -0
  157. package/components/MenuItem.js +51 -0
  158. package/components/MenuItem.module.css +172 -0
  159. package/components/MenuItemContent.d.ts +8 -0
  160. package/components/MenuItemContent.js +19 -0
  161. package/components/MultiSelect.d.ts +13 -0
  162. package/components/MultiSelect.js +225 -0
  163. package/components/MultiSelect.module.css +99 -0
  164. package/components/NumberInput.d.ts +12 -0
  165. package/components/NumberInput.js +114 -0
  166. package/components/NumberInput.module.css +33 -0
  167. package/components/OptionList.module.css +12 -0
  168. package/components/Page.d.ts +7 -0
  169. package/components/Page.js +22 -0
  170. package/components/Page.module.css +44 -0
  171. package/components/Pagination.d.ts +11 -0
  172. package/components/Pagination.js +160 -0
  173. package/components/Pagination.module.css +70 -0
  174. package/components/PasswordField.d.ts +9 -0
  175. package/components/PasswordField.js +102 -0
  176. package/components/PasswordField.module.css +64 -0
  177. package/components/Picker.module.css +52 -0
  178. package/components/PinInput.d.ts +13 -0
  179. package/components/PinInput.js +173 -0
  180. package/components/PinInput.module.css +72 -0
  181. package/components/Placeholder.d.ts +31 -0
  182. package/components/Placeholder.js +36 -0
  183. package/components/Popconfirm.d.ts +17 -0
  184. package/components/Popconfirm.js +159 -0
  185. package/components/Popconfirm.module.css +49 -0
  186. package/components/Popover.d.ts +16 -0
  187. package/components/Popover.js +156 -0
  188. package/components/Popover.module.css +19 -0
  189. package/components/Progress.d.ts +5 -0
  190. package/components/Progress.js +31 -0
  191. package/components/Progress.module.css +33 -0
  192. package/components/RadioGroup.d.ts +15 -0
  193. package/components/RadioGroup.js +73 -0
  194. package/components/RadioGroup.module.css +87 -0
  195. package/components/RangeSlider.d.ts +22 -0
  196. package/components/RangeSlider.js +278 -0
  197. package/components/RangeSlider.module.css +141 -0
  198. package/components/ResizablePanel.d.ts +21 -0
  199. package/components/ResizablePanel.js +219 -0
  200. package/components/ResizablePanel.module.css +101 -0
  201. package/components/SearchField.d.ts +11 -0
  202. package/components/SearchField.js +67 -0
  203. package/components/SearchField.module.css +37 -0
  204. package/components/Section.d.ts +6 -0
  205. package/components/Section.js +18 -0
  206. package/components/Section.module.css +14 -0
  207. package/components/Segmented.d.ts +11 -0
  208. package/components/Segmented.js +77 -0
  209. package/components/Segmented.module.css +82 -0
  210. package/components/Select.d.ts +11 -0
  211. package/components/Select.js +172 -0
  212. package/components/Select.module.css +24 -0
  213. package/components/SelectOptionContent.d.ts +5 -0
  214. package/components/SelectOptionContent.js +20 -0
  215. package/components/SelectOptionContent.module.css +7 -0
  216. package/components/SelectTrigger.d.ts +5 -0
  217. package/components/SelectTrigger.js +32 -0
  218. package/components/SelectTrigger.module.css +24 -0
  219. package/components/SelectionTag.d.ts +8 -0
  220. package/components/SelectionTag.js +39 -0
  221. package/components/SettingRow.d.ts +7 -0
  222. package/components/SettingRow.js +19 -0
  223. package/components/SettingRow.module.css +44 -0
  224. package/components/SettingsLayout.d.ts +11 -0
  225. package/components/SettingsLayout.js +61 -0
  226. package/components/SettingsLayout.module.css +68 -0
  227. package/components/ShortcutInput.d.ts +8 -0
  228. package/components/ShortcutInput.js +131 -0
  229. package/components/ShortcutInput.module.css +39 -0
  230. package/components/Skeleton.d.ts +5 -0
  231. package/components/Skeleton.js +19 -0
  232. package/components/Skeleton.module.css +27 -0
  233. package/components/SkeletonRows.d.ts +4 -0
  234. package/components/SkeletonRows.js +19 -0
  235. package/components/SkeletonRows.module.css +19 -0
  236. package/components/SkinTonePicker.d.ts +4 -0
  237. package/components/SkinTonePicker.js +43 -0
  238. package/components/SkinTonePicker.module.css +50 -0
  239. package/components/Slider.d.ts +10 -0
  240. package/components/Slider.js +40 -0
  241. package/components/Slider.module.css +19 -0
  242. package/components/Spinner.d.ts +6 -0
  243. package/components/Spinner.js +31 -0
  244. package/components/Spinner.module.css +57 -0
  245. package/components/SplitButton.d.ts +17 -0
  246. package/components/SplitButton.js +102 -0
  247. package/components/SplitButton.module.css +56 -0
  248. package/components/Statistic.d.ts +22 -0
  249. package/components/Statistic.js +102 -0
  250. package/components/Statistic.module.css +55 -0
  251. package/components/Steps.d.ts +19 -0
  252. package/components/Steps.js +102 -0
  253. package/components/Steps.module.css +176 -0
  254. package/components/Switch.d.ts +6 -0
  255. package/components/Switch.js +25 -0
  256. package/components/Switch.module.css +59 -0
  257. package/components/SymbolPicker.d.ts +6 -0
  258. package/components/SymbolPicker.js +18 -0
  259. package/components/Tab.module.css +145 -0
  260. package/components/TabList.d.ts +11 -0
  261. package/components/TabList.js +51 -0
  262. package/components/Table.d.ts +16 -0
  263. package/components/Table.js +30 -0
  264. package/components/Table.module.css +48 -0
  265. package/components/TableColumnFilter.d.ts +6 -0
  266. package/components/TableColumnFilter.js +76 -0
  267. package/components/TableColumnVisibility.d.ts +11 -0
  268. package/components/TableColumnVisibility.js +76 -0
  269. package/components/Tabs.d.ts +13 -0
  270. package/components/Tabs.js +49 -0
  271. package/components/Tabs.module.css +3 -0
  272. package/components/TagInput.d.ts +11 -0
  273. package/components/TagInput.js +142 -0
  274. package/components/TagInput.module.css +64 -0
  275. package/components/Textarea.d.ts +6 -0
  276. package/components/Textarea.js +24 -0
  277. package/components/Textarea.module.css +9 -0
  278. package/components/ThemePicker.d.ts +6 -0
  279. package/components/ThemePicker.js +78 -0
  280. package/components/ThemePicker.module.css +178 -0
  281. package/components/ThemeProvider.d.ts +11 -0
  282. package/components/ThemeProvider.js +94 -0
  283. package/components/ThemeStylePicker.d.ts +5 -0
  284. package/components/ThemeStylePicker.js +22 -0
  285. package/components/TimeColumns.d.ts +6 -0
  286. package/components/TimeColumns.js +55 -0
  287. package/components/TimeColumns.module.css +47 -0
  288. package/components/Timeline.d.ts +26 -0
  289. package/components/Timeline.js +131 -0
  290. package/components/Timeline.module.css +202 -0
  291. package/components/Toast.d.ts +6 -0
  292. package/components/Toast.js +181 -0
  293. package/components/Toast.module.css +175 -0
  294. package/components/ToastProvider.d.ts +35 -0
  295. package/components/ToastProvider.js +47 -0
  296. package/components/Tooltip.d.ts +10 -0
  297. package/components/Tooltip.js +169 -0
  298. package/components/Tooltip.module.css +53 -0
  299. package/components/TreeGuides.d.ts +9 -0
  300. package/components/TreeGuides.js +39 -0
  301. package/components/TreeGuides.module.css +45 -0
  302. package/components/TreeSelect.d.ts +26 -0
  303. package/components/TreeSelect.js +337 -0
  304. package/components/TreeTable.d.ts +15 -0
  305. package/components/TreeTable.js +151 -0
  306. package/components/TreeTable.module.css +53 -0
  307. package/components/UIProvider.d.ts +10 -0
  308. package/components/UIProvider.js +20 -0
  309. package/components/UnderlinedTab.d.ts +2 -0
  310. package/components/UnderlinedTab.js +8 -0
  311. package/components/Upload.d.ts +22 -0
  312. package/components/Upload.js +165 -0
  313. package/components/Upload.module.css +36 -0
  314. package/components/UploadList.d.ts +9 -0
  315. package/components/UploadList.js +14 -0
  316. package/components/UploadList.module.css +130 -0
  317. package/components/UploadListItem.d.ts +13 -0
  318. package/components/UploadListItem.js +122 -0
  319. package/components/VirtualPickerList.d.ts +25 -0
  320. package/components/VirtualPickerList.js +269 -0
  321. package/components/VirtualPickerList.module.css +93 -0
  322. package/components/appearance.d.ts +20 -0
  323. package/components/appearance.js +69 -0
  324. package/components/characterCatalog.d.ts +9 -0
  325. package/components/characterCatalog.js +55 -0
  326. package/components/color.d.ts +7 -0
  327. package/components/color.js +18 -0
  328. package/components/contribution.d.ts +57 -0
  329. package/components/contribution.js +86 -0
  330. package/components/dateConstraints.d.ts +13 -0
  331. package/components/dateConstraints.js +44 -0
  332. package/components/field.d.ts +58 -0
  333. package/components/field.js +57 -0
  334. package/components/fileSelection.d.ts +21 -0
  335. package/components/fileSelection.js +43 -0
  336. package/components/hierarchy.d.ts +23 -0
  337. package/components/hierarchy.js +33 -0
  338. package/components/iconCatalog.d.ts +13 -0
  339. package/components/iconCatalog.js +80 -0
  340. package/components/index.d.ts +152 -0
  341. package/components/index.js +225 -0
  342. package/components/menuFocus.d.ts +7 -0
  343. package/components/menuFocus.js +21 -0
  344. package/components/menuPointer.d.ts +6 -0
  345. package/components/menuPointer.js +13 -0
  346. package/components/menuTypes.d.ts +24 -0
  347. package/components/menuTypes.js +0 -0
  348. package/components/motion.d.ts +9 -0
  349. package/components/motion.js +82 -0
  350. package/components/rangeMath.d.ts +12 -0
  351. package/components/rangeMath.js +30 -0
  352. package/components/surfacePortal.d.ts +13 -0
  353. package/components/surfacePortal.js +22 -0
  354. package/components/tooltipState.d.ts +5 -0
  355. package/components/tooltipState.js +48 -0
  356. package/components/types.d.ts +9 -0
  357. package/components/types.js +0 -0
  358. package/components/uploadTypes.d.ts +21 -0
  359. package/components/uploadTypes.js +0 -0
  360. package/components/useFormState.d.ts +51 -0
  361. package/components/useFormState.js +218 -0
  362. package/components/useHierarchy.d.ts +8 -0
  363. package/components/useHierarchy.js +80 -0
  364. package/components/useMenuLayers.d.ts +17 -0
  365. package/components/useMenuLayers.js +23 -0
  366. package/components/useModalScrollLock.d.ts +1 -0
  367. package/components/useModalScrollLock.js +18 -0
  368. package/components/usePopover.d.ts +8 -0
  369. package/components/usePopover.js +22 -0
  370. package/components/useTabIndicator.d.ts +12 -0
  371. package/components/useTabIndicator.js +63 -0
  372. package/components/useUploadQueue.d.ts +20 -0
  373. package/components/useUploadQueue.js +175 -0
  374. package/package.json +810 -3
  375. package/styles/base.css +206 -0
  376. package/styles/blue.css +268 -0
  377. package/styles/desktop.css +2 -0
  378. package/styles/minimal.css +337 -0
  379. package/styles/themes.css +2 -0
  380. package/styles/web.css +2 -0
@@ -0,0 +1,157 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { moveMenuFocus } from "./menuFocus.js";
3
+ import {
4
+ useEffect,
5
+ useId,
6
+ useRef
7
+ } from "react";
8
+ import { ChevronRight, Ellipsis } from "lucide-react";
9
+ import { MenuItem } from "./MenuItem.js";
10
+ import { Popover } from "./Popover.js";
11
+ import { usePopover } from "./usePopover.js";
12
+ import s from "./Breadcrumb.module.css";
13
+ function Breadcrumb({
14
+ items,
15
+ onNavigate,
16
+ maxItems = 0,
17
+ label = "\u9762\u5305\u5C51",
18
+ className = ""
19
+ }) {
20
+ const pop = usePopover(), id = useId(), menu = useRef(null);
21
+ const limit = Number.isFinite(maxItems) && maxItems > 0 ? Math.max(3, Math.floor(maxItems)) : 0;
22
+ const hidden = limit && items.length > limit ? items.slice(1, -(limit - 2)) : [];
23
+ const visible = hidden.length ? [items[0], null, ...items.slice(-(limit - 2))] : items;
24
+ const hasIcons = hidden.some((item) => !!item.icon);
25
+ const firstAction = hidden.find(
26
+ (item) => !item.disabled && (item.href || onNavigate)
27
+ )?.value;
28
+ useEffect(() => pop.close(), [items, limit, pop.close]);
29
+ const navigate = (event, item) => {
30
+ if (item.disabled) {
31
+ event.preventDefault();
32
+ return;
33
+ }
34
+ if (item.href && (event.ctrlKey || event.metaKey || event.shiftKey || event.altKey))
35
+ return;
36
+ if (pop.open) {
37
+ pop.closeAndFocus();
38
+ }
39
+ if (onNavigate) {
40
+ event.preventDefault();
41
+ onNavigate(item.value);
42
+ }
43
+ pop.close();
44
+ };
45
+ return /* @__PURE__ */ jsxs("nav", { "aria-label": label, className: `${s.breadcrumb} ${className}`, children: [
46
+ /* @__PURE__ */ jsx("ol", { children: visible.map((item, index) => {
47
+ const current = !!item && item === items.at(-1);
48
+ return /* @__PURE__ */ jsxs("li", { children: [
49
+ index > 0 && /* @__PURE__ */ jsx(ChevronRight, { className: s.separator, "aria-hidden": "true" }),
50
+ !item ? /* @__PURE__ */ jsx(
51
+ "button",
52
+ {
53
+ type: "button",
54
+ ref: pop.anchor,
55
+ className: s.crumb,
56
+ "aria-label": "\u5C55\u5F00\u8DEF\u5F84",
57
+ "aria-haspopup": "menu",
58
+ "aria-expanded": pop.open,
59
+ "aria-controls": id,
60
+ onClick: pop.toggle,
61
+ onKeyDown: (event) => {
62
+ if (event.key === "ArrowDown") {
63
+ event.preventDefault();
64
+ if (!pop.open) pop.toggle();
65
+ }
66
+ },
67
+ children: /* @__PURE__ */ jsx(Ellipsis, {})
68
+ }
69
+ ) : current || item.disabled || !item.href && !onNavigate ? /* @__PURE__ */ jsxs(
70
+ "span",
71
+ {
72
+ className: s.crumb,
73
+ "aria-current": current ? "page" : void 0,
74
+ "aria-disabled": item.disabled || void 0,
75
+ children: [
76
+ item.icon && /* @__PURE__ */ jsx("span", { className: s.icon, "aria-hidden": "true", children: item.icon }),
77
+ /* @__PURE__ */ jsx("span", { className: s.text, children: item.label })
78
+ ]
79
+ }
80
+ ) : item.href ? /* @__PURE__ */ jsxs(
81
+ "a",
82
+ {
83
+ className: s.crumb,
84
+ href: item.href,
85
+ onClick: (event) => navigate(event, item),
86
+ children: [
87
+ item.icon && /* @__PURE__ */ jsx("span", { className: s.icon, "aria-hidden": "true", children: item.icon }),
88
+ /* @__PURE__ */ jsx("span", { className: s.text, children: item.label })
89
+ ]
90
+ }
91
+ ) : /* @__PURE__ */ jsxs(
92
+ "button",
93
+ {
94
+ type: "button",
95
+ className: s.crumb,
96
+ onClick: (event) => navigate(event, item),
97
+ children: [
98
+ item.icon && /* @__PURE__ */ jsx("span", { className: s.icon, "aria-hidden": "true", children: item.icon }),
99
+ /* @__PURE__ */ jsx("span", { className: s.text, children: item.label })
100
+ ]
101
+ }
102
+ )
103
+ ] }, item?.value ?? `${id}-overflow`);
104
+ }) }),
105
+ /* @__PURE__ */ jsx(
106
+ Popover,
107
+ {
108
+ anchor: pop.anchor,
109
+ open: pop.open && hidden.length > 0,
110
+ onClose: pop.close,
111
+ id,
112
+ role: "menu",
113
+ label: `${label}\u5B8C\u6574\u8DEF\u5F84`,
114
+ width: 250,
115
+ onKeyDown: (event) => moveMenuFocus(event, menu.current),
116
+ children: /* @__PURE__ */ jsx("div", { ref: menu, className: s.menu, children: hidden.map(
117
+ (item) => item.href && !item.disabled ? /* @__PURE__ */ jsx(
118
+ "a",
119
+ {
120
+ href: item.href,
121
+ role: "menuitem",
122
+ "data-autofocus": item.value === firstAction ? "" : void 0,
123
+ className: s.menuLink,
124
+ onClick: (event) => navigate(event, item),
125
+ children: /* @__PURE__ */ jsx(
126
+ MenuItem,
127
+ {
128
+ as: "div",
129
+ role: "none",
130
+ label: item.label,
131
+ icon: item.icon,
132
+ reserveIcon: hasIcons
133
+ }
134
+ )
135
+ },
136
+ item.value
137
+ ) : /* @__PURE__ */ jsx(
138
+ MenuItem,
139
+ {
140
+ role: "menuitem",
141
+ "data-autofocus": item.value === firstAction ? "" : void 0,
142
+ label: item.label,
143
+ icon: item.icon,
144
+ reserveIcon: hasIcons,
145
+ disabled: item.disabled || !onNavigate,
146
+ onClick: (event) => navigate(event, item)
147
+ },
148
+ item.value
149
+ )
150
+ ) })
151
+ }
152
+ )
153
+ ] });
154
+ }
155
+ export {
156
+ Breadcrumb
157
+ };
@@ -0,0 +1,97 @@
1
+ .breadcrumb {
2
+ min-width: 0;
3
+ max-width: 100%;
4
+ }
5
+ .breadcrumb ol {
6
+ display: flex;
7
+ align-items: center;
8
+ flex-wrap: wrap;
9
+ gap: 2px;
10
+ list-style: none;
11
+ margin: 0;
12
+ padding: 0;
13
+ min-width: 0;
14
+ }
15
+ .breadcrumb li {
16
+ display: flex;
17
+ align-items: center;
18
+ gap: 2px;
19
+ min-width: 0;
20
+ max-width: 100%;
21
+ }
22
+ .crumb {
23
+ display: inline-flex;
24
+ align-items: center;
25
+ gap: 6px;
26
+ min-width: 0;
27
+ max-width: min(240px, 100%);
28
+ min-height: var(--control-small);
29
+ padding: 4px 6px;
30
+ border: 0;
31
+ border-radius: max(4px, calc(var(--radius) - 3px));
32
+ font-size: 12px;
33
+ line-height: 20px;
34
+ color: var(--muted);
35
+ background: transparent;
36
+ text-decoration: none;
37
+ transition:
38
+ background var(--motion-hover),
39
+ color var(--motion-hover);
40
+ }
41
+ .crumb:is(a, button):hover {
42
+ color: var(--fg);
43
+ background: var(--hover);
44
+ }
45
+ .crumb[aria-expanded="true"] {
46
+ color: var(--fg);
47
+ background: var(--selected);
48
+ }
49
+ .crumb[aria-current="page"] {
50
+ color: var(--fg);
51
+ }
52
+ .crumb[aria-disabled="true"] {
53
+ opacity: 0.42;
54
+ }
55
+ .crumb:focus-visible {
56
+ outline-offset: 1px;
57
+ }
58
+ .text {
59
+ min-width: 0;
60
+ overflow: hidden;
61
+ text-overflow: ellipsis;
62
+ white-space: nowrap;
63
+ }
64
+ .icon {
65
+ display: inline-flex;
66
+ flex: none;
67
+ align-items: center;
68
+ }
69
+ .icon > svg,
70
+ .crumb > svg {
71
+ width: 14px;
72
+ height: 14px;
73
+ }
74
+ .separator {
75
+ width: 13px;
76
+ height: 13px;
77
+ color: var(--muted);
78
+ opacity: 0.6;
79
+ }
80
+ .menu {
81
+ display: flex;
82
+ flex-direction: column;
83
+ gap: var(--menu-item-spacing);
84
+ }
85
+ .menuLink {
86
+ display: block;
87
+ border-radius: max(4px, calc(var(--radius) - 3px));
88
+ color: inherit;
89
+ text-decoration: none;
90
+ }
91
+ .menuLink:focus-visible {
92
+ outline: none;
93
+ }
94
+ .menuLink:focus-visible [data-menu-item] {
95
+ background: var(--hover);
96
+ box-shadow: inset 0 0 0 1px var(--accent);
97
+ }
@@ -0,0 +1,13 @@
1
+ import type { ComponentPropsWithRef } from "react";
2
+ type ButtonProps = {
3
+ variant?: "primary" | "secondary" | "ghost" | "danger";
4
+ size?: "normal" | "small";
5
+ loading?: boolean;
6
+ } & ((ComponentPropsWithRef<"button"> & {
7
+ href?: never;
8
+ }) | (ComponentPropsWithRef<"a"> & {
9
+ href: string;
10
+ disabled?: boolean;
11
+ }));
12
+ export declare function Button({ variant, size, loading, children, className, ...props }: ButtonProps): import("react").JSX.Element;
13
+ export {};
@@ -0,0 +1,52 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { Spinner } from "./Spinner.js";
3
+ import s from "./Button.module.css";
4
+ function Button({
5
+ variant = "secondary",
6
+ size = "normal",
7
+ loading,
8
+ children,
9
+ className = "",
10
+ ...props
11
+ }) {
12
+ const content = /* @__PURE__ */ jsxs(Fragment, { children: [
13
+ /* @__PURE__ */ jsx("span", { className: s.content, style: { opacity: loading ? 0 : 1 }, children }),
14
+ loading && /* @__PURE__ */ jsx("span", { className: s.loader, children: /* @__PURE__ */ jsx(Spinner, { decorative: true }) })
15
+ ] });
16
+ const classes = `${s.button} ${s[variant]} ${size === "small" ? s.small : ""} ${className}`;
17
+ if (typeof props.href === "string") {
18
+ const { disabled, onClick, ...link } = props;
19
+ const blocked = disabled || loading;
20
+ return /* @__PURE__ */ jsx(
21
+ "a",
22
+ {
23
+ ...link,
24
+ className: classes,
25
+ "aria-disabled": blocked || void 0,
26
+ "aria-busy": loading || void 0,
27
+ tabIndex: blocked ? -1 : link.tabIndex,
28
+ onClick: (event) => {
29
+ if (blocked) {
30
+ event.preventDefault();
31
+ event.stopPropagation();
32
+ } else onClick?.(event);
33
+ },
34
+ children: content
35
+ }
36
+ );
37
+ }
38
+ return /* @__PURE__ */ jsx(
39
+ "button",
40
+ {
41
+ type: "button",
42
+ ...props,
43
+ disabled: props.disabled || loading,
44
+ "aria-busy": loading || void 0,
45
+ className: classes,
46
+ children: content
47
+ }
48
+ );
49
+ }
50
+ export {
51
+ Button
52
+ };
@@ -0,0 +1,88 @@
1
+ .button {
2
+ display: inline-flex;
3
+ align-items: center;
4
+ justify-content: center;
5
+ gap: 7px;
6
+ min-height: var(--control-height);
7
+ padding: 6px 13px;
8
+ border: 1px solid var(--line);
9
+ border-radius: calc(var(--radius) - 3px);
10
+ background: var(--surface);
11
+ white-space: nowrap;
12
+ transition:
13
+ background var(--motion-hover),
14
+ transform var(--motion-hover),
15
+ border-color var(--motion-hover);
16
+ font-size: 12px;
17
+ text-decoration: none;
18
+ color: var(--fg);
19
+ }
20
+ .button[aria-disabled="true"] {
21
+ opacity: 0.5;
22
+ cursor: not-allowed;
23
+ }
24
+ .button:hover:not(:disabled):not([aria-disabled="true"]) {
25
+ background: var(--hover);
26
+ border-color: color-mix(in srgb, var(--fg) 18%, var(--surface));
27
+ }
28
+ .button:active:not(:disabled):not([aria-disabled="true"]) {
29
+ transform: translateY(1px);
30
+ }
31
+ .primary {
32
+ background: var(--accent-fill, var(--accent));
33
+ border-color: var(--accent-fill, var(--accent));
34
+ color: var(--on-accent-fill, var(--on-accent));
35
+ }
36
+ .primary:hover:not(:disabled):not([aria-disabled="true"]) {
37
+ background: var(
38
+ --accent-fill-hover,
39
+ color-mix(in srgb, var(--accent) 86%, var(--surface))
40
+ );
41
+ border-color: transparent;
42
+ }
43
+ .secondary {
44
+ box-shadow: 0 1px 1px #00000003;
45
+ }
46
+ .ghost {
47
+ background: transparent;
48
+ border-color: transparent;
49
+ box-shadow: none;
50
+ }
51
+ .danger {
52
+ color: var(--danger);
53
+ background: color-mix(in srgb, var(--danger) 5%, var(--surface));
54
+ }
55
+ .small {
56
+ min-height: var(--control-small);
57
+ padding: 4px 9px;
58
+ font-size: 11px;
59
+ }
60
+ .spin {
61
+ animation: spin 1s linear infinite;
62
+ }
63
+
64
+ .button {
65
+ position: relative;
66
+ }
67
+ .content {
68
+ display: inline-flex;
69
+ align-items: center;
70
+ justify-content: center;
71
+ gap: 7px;
72
+ }
73
+ .loader {
74
+ position: absolute;
75
+ inset: 0;
76
+ display: grid;
77
+ place-items: center;
78
+ }
79
+ .button[aria-busy="true"] {
80
+ opacity: 0.8;
81
+ cursor: wait;
82
+ }
83
+
84
+ .content > svg {
85
+ width: var(--button-icon-size, 16px);
86
+ height: var(--button-icon-size, 16px);
87
+ flex-shrink: 0;
88
+ }
@@ -0,0 +1,10 @@
1
+ import { type DateConstraints, type DateRange } from "./dateConstraints";
2
+ export { dateKey, readDate } from "./dateConstraints";
3
+ export type CalendarProps = DateConstraints & {
4
+ value: string;
5
+ onChange(value: string): void;
6
+ range?: DateRange;
7
+ preview?: string;
8
+ onHover?(value: string): void;
9
+ };
10
+ export declare function Calendar({ value, onChange, range, preview, onHover, minDate, maxDate, disabledDate, }: CalendarProps): import("react").JSX.Element;
@@ -0,0 +1,260 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useLayoutEffect, useRef, useState } from "react";
3
+ import { ChevronLeft, ChevronRight } from "lucide-react";
4
+ import { IconButton } from "./IconButton.js";
5
+ import {
6
+ boundedDate,
7
+ calendarDate,
8
+ dateKey,
9
+ isDateAllowed,
10
+ parseDate,
11
+ readDate
12
+ } from "./dateConstraints.js";
13
+ import s from "./Calendar.module.css";
14
+ import { dateKey as dateKey2, readDate as readDate2 } from "./dateConstraints.js";
15
+ function Calendar({
16
+ value,
17
+ onChange,
18
+ range,
19
+ preview,
20
+ onHover,
21
+ minDate,
22
+ maxDate,
23
+ disabledDate
24
+ }) {
25
+ const constraints = { minDate, maxDate, disabledDate };
26
+ const [month, setMonth] = useState(
27
+ () => readDate(boundedDate(value, constraints))
28
+ ), [view, setView] = useState("days"), [focused, setFocused] = useState(value);
29
+ const grid = useRef(null), choices = useRef(null), pending = useRef(null), pendingView = useRef(false);
30
+ const year = month.getFullYear(), index = month.getMonth(), start = (calendarDate(year, index).getDay() + 6) % 7, base = Math.floor(year / 12) * 12, today = dateKey(/* @__PURE__ */ new Date());
31
+ const allowed = (key) => isDateAllowed(key, constraints);
32
+ const monthAllowed = (y, m) => y >= 1 && y <= 9999 && !(minDate && parseDate(minDate) && dateKey(calendarDate(y, m + 1, 0)) < minDate) && !(maxDate && parseDate(maxDate) && dateKey(calendarDate(y, m)) > maxDate);
33
+ const periodAllowed = (amount) => {
34
+ if (view === "days") {
35
+ const next = calendarDate(year, index + amount);
36
+ return monthAllowed(next.getFullYear(), next.getMonth());
37
+ }
38
+ const first = view === "years" ? base + amount * 12 : year + amount, last = view === "years" ? first + 11 : first;
39
+ return last >= 1 && first <= 9999 && !(minDate && parseDate(minDate) && last < Number(minDate.slice(0, 4))) && !(maxDate && parseDate(maxDate) && first > Number(maxDate.slice(0, 4)));
40
+ };
41
+ const move = (amount) => setMonth(
42
+ calendarDate(
43
+ year + (view === "years" ? amount * 12 : view === "months" ? amount : 0),
44
+ index + (view === "days" ? amount : 0)
45
+ )
46
+ );
47
+ const cells = Array.from({ length: 42 }, (_, i) => {
48
+ const date = calendarDate(year, index, i - start + 1);
49
+ return { date, key: dateKey(date) };
50
+ });
51
+ const tabStop = cells.find((c) => c.key === focused && allowed(c.key))?.key || cells.find((c) => c.key === value && allowed(c.key))?.key || cells.find((c) => c.date.getMonth() === index && allowed(c.key))?.key || cells.find((c) => allowed(c.key))?.key;
52
+ const openView = (next) => {
53
+ pendingView.current = true;
54
+ setView(next);
55
+ };
56
+ useEffect(() => {
57
+ const next = boundedDate(dateKey(month), { minDate, maxDate });
58
+ if (next.slice(0, 7) !== dateKey(month).slice(0, 7))
59
+ setMonth(readDate(next));
60
+ }, [minDate, maxDate]);
61
+ useLayoutEffect(() => {
62
+ if (pending.current && view === "days") {
63
+ grid.current?.querySelector(`[data-date="${pending.current}"]`)?.focus({ preventScroll: true });
64
+ pending.current = null;
65
+ } else if (pendingView.current) {
66
+ pendingView.current = false;
67
+ const node = choices.current;
68
+ const target = view === "days" ? grid.current?.querySelector(
69
+ `[data-date="${tabStop}"]`
70
+ ) : node?.querySelector(
71
+ 'button[aria-pressed="true"]:not(:disabled)'
72
+ ) || node?.querySelector("button:not(:disabled)");
73
+ target?.focus({ preventScroll: true });
74
+ }
75
+ }, [month, view, focused]);
76
+ const rangeEnd = range?.[1] || preview || "", rangeStart = range?.[0] || "", low = rangeStart && rangeEnd ? rangeStart < rangeEnd ? rangeStart : rangeEnd : "", high = rangeStart && rangeEnd ? rangeStart > rangeEnd ? rangeStart : rangeEnd : "";
77
+ return /* @__PURE__ */ jsxs("div", { className: s.calendar, children: [
78
+ /* @__PURE__ */ jsxs("header", { children: [
79
+ /* @__PURE__ */ jsx(
80
+ IconButton,
81
+ {
82
+ label: view === "days" ? "\u4E0A\u4E2A\u6708" : view === "months" ? "\u4E0A\u4E00\u5E74" : "\u524D\u5341\u4E8C\u5E74",
83
+ disabled: !periodAllowed(-1),
84
+ onClick: () => move(-1),
85
+ children: /* @__PURE__ */ jsx(ChevronLeft, {})
86
+ }
87
+ ),
88
+ /* @__PURE__ */ jsx("span", { className: s.heading, children: view === "years" ? /* @__PURE__ */ jsxs("span", { "aria-live": "polite", children: [
89
+ base,
90
+ " \u2014 ",
91
+ base + 11
92
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
93
+ /* @__PURE__ */ jsxs(
94
+ "button",
95
+ {
96
+ type: "button",
97
+ "aria-label": "\u9009\u62E9\u5E74\u4EFD",
98
+ onClick: () => openView("years"),
99
+ children: [
100
+ year,
101
+ " \u5E74"
102
+ ]
103
+ }
104
+ ),
105
+ /* @__PURE__ */ jsxs(
106
+ "button",
107
+ {
108
+ type: "button",
109
+ "aria-label": "\u9009\u62E9\u6708\u4EFD",
110
+ onClick: () => openView(view === "months" ? "days" : "months"),
111
+ children: [
112
+ index + 1,
113
+ " \u6708"
114
+ ]
115
+ }
116
+ )
117
+ ] }) }),
118
+ /* @__PURE__ */ jsx(
119
+ IconButton,
120
+ {
121
+ label: view === "days" ? "\u4E0B\u4E2A\u6708" : view === "months" ? "\u4E0B\u4E00\u5E74" : "\u540E\u5341\u4E8C\u5E74",
122
+ disabled: !periodAllowed(1),
123
+ onClick: () => move(1),
124
+ children: /* @__PURE__ */ jsx(ChevronRight, {})
125
+ }
126
+ )
127
+ ] }),
128
+ /* @__PURE__ */ jsx("div", { className: s.area, children: view === "days" ? /* @__PURE__ */ jsxs(Fragment, { children: [
129
+ /* @__PURE__ */ jsx("div", { className: s.week, children: ["\u4E00", "\u4E8C", "\u4E09", "\u56DB", "\u4E94", "\u516D", "\u65E5"].map((day) => /* @__PURE__ */ jsx("span", { children: day }, day)) }),
130
+ /* @__PURE__ */ jsx(
131
+ "div",
132
+ {
133
+ ref: grid,
134
+ className: s.days,
135
+ "data-calendar-days": true,
136
+ onPointerLeave: () => onHover?.(""),
137
+ children: cells.map(({ date, key }) => {
138
+ const enabled = allowed(key), selected = range ? key === rangeStart || key === range[1] : key === value;
139
+ return /* @__PURE__ */ jsx(
140
+ "button",
141
+ {
142
+ type: "button",
143
+ "data-date": key,
144
+ "data-autofocus": key === tabStop || void 0,
145
+ "data-outside": date.getMonth() !== index,
146
+ "data-in-range": !!low && key > low && key < high,
147
+ "data-range-edge": !!range && selected,
148
+ "data-preview": !!range && !range[1] && !!preview,
149
+ "aria-label": key,
150
+ "aria-pressed": selected,
151
+ "aria-current": key === today ? "date" : void 0,
152
+ disabled: !enabled,
153
+ tabIndex: key === tabStop ? 0 : -1,
154
+ onFocus: () => {
155
+ setFocused(key);
156
+ onHover?.(key);
157
+ },
158
+ onPointerEnter: () => {
159
+ if (enabled) onHover?.(key);
160
+ },
161
+ onClick: () => {
162
+ if (!enabled) return;
163
+ setMonth(
164
+ calendarDate(date.getFullYear(), date.getMonth())
165
+ );
166
+ setFocused(key);
167
+ onChange(key);
168
+ },
169
+ onKeyDown: (event) => {
170
+ const deltas = {
171
+ ArrowLeft: -1,
172
+ ArrowRight: 1,
173
+ ArrowUp: -7,
174
+ ArrowDown: 7,
175
+ Home: -((date.getDay() + 6) % 7),
176
+ End: 6 - (date.getDay() + 6) % 7
177
+ };
178
+ if (!(event.key in deltas) && event.key !== "PageUp" && event.key !== "PageDown")
179
+ return;
180
+ event.preventDefault();
181
+ let next = new Date(date), direction = event.key === "Home" ? 1 : event.key === "End" ? -1 : event.key === "ArrowLeft" || event.key === "ArrowUp" || event.key === "PageUp" ? -1 : 1;
182
+ if (event.key.startsWith("Page")) {
183
+ const target = calendarDate(
184
+ date.getFullYear(),
185
+ date.getMonth() + direction
186
+ );
187
+ next = calendarDate(
188
+ target.getFullYear(),
189
+ target.getMonth(),
190
+ Math.min(
191
+ date.getDate(),
192
+ calendarDate(
193
+ target.getFullYear(),
194
+ target.getMonth() + 1,
195
+ 0
196
+ ).getDate()
197
+ )
198
+ );
199
+ } else next.setDate(next.getDate() + deltas[event.key]);
200
+ if (!parseDate(dateKey(next))) return;
201
+ const bounded = boundedDate(dateKey(next), constraints);
202
+ if (bounded !== dateKey(next)) {
203
+ direction = bounded > dateKey(next) ? 1 : -1;
204
+ next = readDate(bounded);
205
+ }
206
+ for (let i = 0; i < 366; i++) {
207
+ const candidate = dateKey(next);
208
+ if (minDate && parseDate(minDate) && candidate < minDate || maxDate && parseDate(maxDate) && candidate > maxDate || !parseDate(candidate))
209
+ return;
210
+ if (allowed(candidate)) {
211
+ pending.current = candidate;
212
+ setFocused(candidate);
213
+ setMonth(
214
+ calendarDate(next.getFullYear(), next.getMonth())
215
+ );
216
+ return;
217
+ }
218
+ next.setDate(next.getDate() + direction);
219
+ }
220
+ },
221
+ children: date.getDate()
222
+ },
223
+ key
224
+ );
225
+ })
226
+ }
227
+ )
228
+ ] }) : /* @__PURE__ */ jsx("div", { ref: choices, className: s.choices, children: Array.from({ length: 12 }, (_, i) => {
229
+ const choice = view === "years" ? base + i : i, enabled = view === "years" ? Array.from(
230
+ { length: 12 },
231
+ (_2, m) => monthAllowed(choice, m)
232
+ ).some(Boolean) : monthAllowed(year, choice);
233
+ return /* @__PURE__ */ jsx(
234
+ "button",
235
+ {
236
+ type: "button",
237
+ "aria-label": view === "years" ? choice + " \u5E74" : choice + 1 + " \u6708",
238
+ "aria-pressed": choice === (view === "years" ? year : index),
239
+ disabled: !enabled,
240
+ onClick: () => {
241
+ setMonth(
242
+ calendarDate(
243
+ view === "years" ? choice : year,
244
+ view === "months" ? choice : index
245
+ )
246
+ );
247
+ openView(view === "years" ? "months" : "days");
248
+ },
249
+ children: view === "years" ? choice : choice + 1 + " \u6708"
250
+ },
251
+ choice
252
+ );
253
+ }) }) })
254
+ ] });
255
+ }
256
+ export {
257
+ Calendar,
258
+ dateKey2 as dateKey,
259
+ readDate2 as readDate
260
+ };