@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,57 @@
1
+ export type ContributionDay = {
2
+ date: string;
3
+ count: number;
4
+ level?: 0 | 1 | 2 | 3 | 4;
5
+ };
6
+ export declare const calendarKey: (date: Date) => string;
7
+ export declare function parseCalendarDay(key: string): Date | undefined;
8
+ export declare function buildContributionCalendar({ data, year, startDate, endDate, weekStartsOn, today, allowFuture, thresholds, }: {
9
+ data: ContributionDay[];
10
+ year: number;
11
+ startDate?: string;
12
+ endDate?: string;
13
+ weekStartsOn?: 0 | 1;
14
+ today: string;
15
+ allowFuture?: boolean;
16
+ thresholds?: [number, number, number, number];
17
+ }): {
18
+ valid: false;
19
+ cells: never[];
20
+ dates: never[];
21
+ weeks: number;
22
+ total: number;
23
+ months: never[];
24
+ } | {
25
+ valid: true;
26
+ cells: {
27
+ date: string;
28
+ outside: boolean;
29
+ count: number;
30
+ level: number;
31
+ future: boolean;
32
+ missing: boolean;
33
+ index: number;
34
+ row: number;
35
+ column: number;
36
+ }[];
37
+ dates: {
38
+ date: string;
39
+ outside: boolean;
40
+ count: number;
41
+ level: number;
42
+ future: boolean;
43
+ missing: boolean;
44
+ index: number;
45
+ row: number;
46
+ column: number;
47
+ }[];
48
+ weeks: number;
49
+ total: number;
50
+ months: {
51
+ key: string;
52
+ column: number;
53
+ month: number;
54
+ year: number;
55
+ }[];
56
+ };
57
+ export type ContributionCellData = ReturnType<typeof buildContributionCalendar>["cells"][number];
@@ -0,0 +1,86 @@
1
+ const calendarKey = (date) => date.toISOString().slice(0, 10);
2
+ function parseCalendarDay(key) {
3
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(key)) return void 0;
4
+ const date = /* @__PURE__ */ new Date(key + "T00:00:00Z");
5
+ return Number.isFinite(date.getTime()) && calendarKey(date) === key ? date : void 0;
6
+ }
7
+ function buildContributionCalendar({
8
+ data,
9
+ year,
10
+ startDate,
11
+ endDate,
12
+ weekStartsOn = 1,
13
+ today,
14
+ allowFuture = false,
15
+ thresholds
16
+ }) {
17
+ const start = parseCalendarDay(startDate || year + "-01-01"), end = parseCalendarDay(endDate || year + "-12-31");
18
+ if (!start || !end || end < start || end.getTime() - start.getTime() > 366 * 864e5 * 5)
19
+ return {
20
+ valid: false,
21
+ cells: [],
22
+ dates: [],
23
+ weeks: 0,
24
+ total: 0,
25
+ months: []
26
+ };
27
+ const entries = /* @__PURE__ */ new Map();
28
+ for (const day of data) {
29
+ if (!parseCalendarDay(day.date)) continue;
30
+ const old = entries.get(day.date);
31
+ entries.set(day.date, {
32
+ ...day,
33
+ count: Math.max(0, Number.isFinite(day.count) ? day.count : 0) + (old?.count || 0)
34
+ });
35
+ }
36
+ const leading = (start.getUTCDay() - weekStartsOn + 7) % 7, days = Math.round((end.getTime() - start.getTime()) / 864e5) + 1, weeks = Math.ceil((leading + days) / 7), first = start.getTime() - leading * 864e5, max = Math.max(
37
+ 1,
38
+ ...[...entries.values()].filter(
39
+ (day) => day.date >= calendarKey(start) && day.date <= calendarKey(end)
40
+ ).map((day) => day.count)
41
+ );
42
+ const cells = Array.from({ length: weeks * 7 }, (_, index) => {
43
+ const date = new Date(first + index * 864e5), key = calendarKey(date), outside = date < start || date > end, entry = entries.get(key), future = !allowFuture && key > today, count = future ? 0 : entry?.count || 0;
44
+ let level = count ? Math.min(4, Math.ceil(count / max * 4)) : 0;
45
+ if (entry?.level !== void 0)
46
+ level = Math.max(0, Math.min(4, entry.level));
47
+ if (thresholds)
48
+ level = count ? thresholds.filter((threshold) => count >= threshold).length : 0;
49
+ if (future) level = 0;
50
+ return {
51
+ date: key,
52
+ outside,
53
+ count,
54
+ level,
55
+ future,
56
+ missing: !entry,
57
+ index,
58
+ row: index % 7,
59
+ column: Math.floor(index / 7)
60
+ };
61
+ });
62
+ const dates = cells.filter((day) => !day.outside), months = [];
63
+ for (const day of dates) {
64
+ const month = day.date.slice(0, 7);
65
+ if (months.at(-1)?.key !== month)
66
+ months.push({
67
+ key: month,
68
+ column: day.column,
69
+ month: Number(month.slice(5)),
70
+ year: Number(month.slice(0, 4))
71
+ });
72
+ }
73
+ return {
74
+ valid: true,
75
+ cells,
76
+ dates,
77
+ weeks,
78
+ total: dates.reduce((n, day) => n + day.count, 0),
79
+ months
80
+ };
81
+ }
82
+ export {
83
+ buildContributionCalendar,
84
+ calendarKey,
85
+ parseCalendarDay
86
+ };
@@ -0,0 +1,13 @@
1
+ export type DateRange = [string, string];
2
+ export type DateConstraints = {
3
+ minDate?: string;
4
+ maxDate?: string;
5
+ disabledDate?(date: string): boolean;
6
+ };
7
+ export declare const dateKey: (date: Date) => string;
8
+ export declare function calendarDate(year: number, month: number, day?: number): Date;
9
+ export declare function parseDate(value: string): Date | null;
10
+ export declare const readDate: (value: string) => Date;
11
+ export declare function isDateAllowed(value: string, { minDate, maxDate, disabledDate }?: DateConstraints): boolean;
12
+ export declare function boundedDate(value: string, { minDate, maxDate }?: DateConstraints): string;
13
+ export declare function isRangeAllowed(range: DateRange, constraints: DateConstraints): boolean;
@@ -0,0 +1,44 @@
1
+ const dateKey = (date) => `${String(date.getFullYear()).padStart(4, "0")}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
2
+ function calendarDate(year, month, day = 1) {
3
+ const date = /* @__PURE__ */ new Date(0);
4
+ date.setHours(12, 0, 0, 0);
5
+ date.setFullYear(year, month, day);
6
+ return date;
7
+ }
8
+ function parseDate(value) {
9
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(value) || value.slice(0, 4) === "0000")
10
+ return null;
11
+ const [year, month, day] = value.split("-").map(Number), date = calendarDate(year, month - 1, day);
12
+ return dateKey(date) === value ? date : null;
13
+ }
14
+ const readDate = (value) => parseDate(value.slice(0, 10)) || /* @__PURE__ */ new Date();
15
+ function isDateAllowed(value, { minDate, maxDate, disabledDate } = {}) {
16
+ return !!parseDate(value) && !(minDate && parseDate(minDate) && value < minDate) && !(maxDate && parseDate(maxDate) && value > maxDate) && !disabledDate?.(value);
17
+ }
18
+ function boundedDate(value, { minDate, maxDate } = {}) {
19
+ let next = parseDate(value) ? value : dateKey(/* @__PURE__ */ new Date());
20
+ if (minDate && parseDate(minDate) && next < minDate) next = minDate;
21
+ if (maxDate && parseDate(maxDate) && next > maxDate) next = maxDate;
22
+ return next;
23
+ }
24
+ function isRangeAllowed(range, constraints) {
25
+ const [start, end] = range;
26
+ if (start > end || !isDateAllowed(start, constraints) || !isDateAllowed(end, constraints))
27
+ return false;
28
+ if (!constraints.disabledDate) return true;
29
+ const cursor = parseDate(start);
30
+ while (dateKey(cursor) < end) {
31
+ cursor.setDate(cursor.getDate() + 1);
32
+ if (!isDateAllowed(dateKey(cursor), constraints)) return false;
33
+ }
34
+ return true;
35
+ }
36
+ export {
37
+ boundedDate,
38
+ calendarDate,
39
+ dateKey,
40
+ isDateAllowed,
41
+ isRangeAllowed,
42
+ parseDate,
43
+ readDate
44
+ };
@@ -0,0 +1,58 @@
1
+ import type { AriaAttributes } from "react";
2
+ export type FieldOptions = {
3
+ id?: string;
4
+ name?: string;
5
+ label?: string;
6
+ required?: boolean;
7
+ disabled?: boolean;
8
+ readOnly?: boolean;
9
+ error?: string;
10
+ hint?: string;
11
+ "aria-describedby"?: string;
12
+ "aria-invalid"?: AriaAttributes["aria-invalid"];
13
+ };
14
+ export type FieldState = {
15
+ id: string;
16
+ name?: string;
17
+ label: string;
18
+ required: boolean;
19
+ disabled: boolean;
20
+ readOnly: boolean;
21
+ error?: string;
22
+ hint?: string;
23
+ descriptionId?: string;
24
+ invalid: AriaAttributes["aria-invalid"];
25
+ };
26
+ export declare const FieldContext: import("react").Context<FieldState | null>;
27
+ export declare function fieldInputProps(field: FieldState): {
28
+ id: string;
29
+ name: string | undefined;
30
+ required: boolean;
31
+ disabled: boolean;
32
+ readOnly: boolean;
33
+ "aria-invalid": "false" | "grammar" | "spelling" | "true" | boolean | undefined;
34
+ "aria-describedby": string | undefined;
35
+ };
36
+ export declare function fieldTriggerProps(field: FieldState): {
37
+ id: string;
38
+ disabled: boolean;
39
+ "aria-label": string;
40
+ "aria-required": true | undefined;
41
+ "aria-readonly": true | undefined;
42
+ "aria-invalid": "false" | "grammar" | "spelling" | "true" | boolean | undefined;
43
+ "aria-describedby": string | undefined;
44
+ };
45
+ export declare const joinIds: (...values: (string | undefined)[]) => string | undefined;
46
+ export declare function useFieldControl(options: FieldOptions): {
47
+ id: string;
48
+ name: string | undefined;
49
+ label: string;
50
+ required: boolean;
51
+ disabled: boolean;
52
+ readOnly: boolean;
53
+ error: string | undefined;
54
+ hint: string | undefined;
55
+ descriptionId: string | undefined;
56
+ invalid: "false" | "grammar" | "spelling" | "true" | boolean;
57
+ wrapped: boolean;
58
+ };
@@ -0,0 +1,57 @@
1
+ import { createContext, useContext, useId } from "react";
2
+ const FieldContext = createContext(null);
3
+ function fieldInputProps(field) {
4
+ return {
5
+ id: field.id,
6
+ name: field.name,
7
+ required: field.required,
8
+ disabled: field.disabled,
9
+ readOnly: field.readOnly,
10
+ "aria-invalid": field.invalid,
11
+ "aria-describedby": field.descriptionId
12
+ };
13
+ }
14
+ function fieldTriggerProps(field) {
15
+ return {
16
+ id: field.id,
17
+ disabled: field.disabled,
18
+ "aria-label": field.label,
19
+ "aria-required": field.required || void 0,
20
+ "aria-readonly": field.readOnly || void 0,
21
+ "aria-invalid": field.invalid,
22
+ "aria-describedby": field.descriptionId
23
+ };
24
+ }
25
+ const joinIds = (...values) => [
26
+ ...new Set(
27
+ values.flatMap((value) => value?.split(/\s+/).filter(Boolean) || [])
28
+ )
29
+ ].join(" ") || void 0;
30
+ function useFieldControl(options) {
31
+ const inherited = useContext(FieldContext), generated = useId(), id = options.id || inherited?.id || generated, error = options.error ?? inherited?.error, hint = options.hint ?? inherited?.hint;
32
+ return {
33
+ id,
34
+ name: options.name ?? inherited?.name,
35
+ label: options.label ?? inherited?.label ?? "",
36
+ required: options.required ?? inherited?.required ?? false,
37
+ disabled: options.disabled ?? inherited?.disabled ?? false,
38
+ readOnly: options.readOnly ?? inherited?.readOnly ?? false,
39
+ error,
40
+ hint,
41
+ descriptionId: joinIds(
42
+ inherited?.descriptionId,
43
+ options["aria-describedby"],
44
+ hint ? id + "-hint" : void 0,
45
+ error ? id + "-error" : void 0
46
+ ),
47
+ invalid: error ? true : options["aria-invalid"] ?? inherited?.invalid ?? false,
48
+ wrapped: !!inherited
49
+ };
50
+ }
51
+ export {
52
+ FieldContext,
53
+ fieldInputProps,
54
+ fieldTriggerProps,
55
+ joinIds,
56
+ useFieldControl
57
+ };
@@ -0,0 +1,21 @@
1
+ export type FileConstraints = {
2
+ accept?: string;
3
+ maxSize?: number;
4
+ maxFiles?: number;
5
+ selectedCount?: number;
6
+ multiple?: boolean;
7
+ };
8
+ export type FileRejection = {
9
+ file: File;
10
+ code: "type" | "size" | "count";
11
+ message: string;
12
+ };
13
+ export type FileSelectionResult = {
14
+ accepted: File[];
15
+ rejected: FileRejection[];
16
+ };
17
+ export declare function formatFileSize(bytes: number): string;
18
+ export declare function validateFiles(files: readonly File[], { accept, maxSize, maxFiles, selectedCount, multiple, }?: FileConstraints): {
19
+ accepted: File[];
20
+ rejected: FileRejection[];
21
+ };
@@ -0,0 +1,43 @@
1
+ function formatFileSize(bytes) {
2
+ const unit = bytes >= 1024 * 1024 ? "MB" : bytes >= 1024 ? "KB" : "B", divisor = unit === "MB" ? 1024 * 1024 : unit === "KB" ? 1024 : 1;
3
+ return `${Math.round(bytes / divisor * 100) / 100} ${unit}`;
4
+ }
5
+ function validateFiles(files, {
6
+ accept,
7
+ maxSize,
8
+ maxFiles,
9
+ selectedCount = 0,
10
+ multiple = true
11
+ } = {}) {
12
+ const rules = (accept || "").split(",").map((rule) => rule.trim().toLowerCase()).filter(Boolean);
13
+ const size = maxSize === void 0 || !Number.isFinite(maxSize) ? Infinity : Math.max(0, maxSize);
14
+ const limit = maxFiles === void 0 || !Number.isFinite(maxFiles) ? Infinity : Math.max(0, Math.floor(maxFiles));
15
+ const existing = Number.isFinite(selectedCount) ? Math.max(0, Math.floor(selectedCount)) : 0, slots = Math.max(0, Math.min(limit, multiple ? Infinity : 1) - existing);
16
+ const accepted = [], rejected = [];
17
+ for (const file of files) {
18
+ const name = file.name.toLowerCase(), type = file.type.toLowerCase();
19
+ const matches = !rules.length || rules.some(
20
+ (rule) => rule === "*" || rule === "*/*" || (rule.startsWith(".") ? name.endsWith(rule) : rule.endsWith("/*") ? type.startsWith(rule.slice(0, -1)) : type === rule)
21
+ );
22
+ if (!matches)
23
+ rejected.push({ file, code: "type", message: "\u6587\u4EF6\u7C7B\u578B\u4E0D\u53D7\u652F\u6301" });
24
+ else if (file.size > size)
25
+ rejected.push({
26
+ file,
27
+ code: "size",
28
+ message: `\u6587\u4EF6\u4E0D\u80FD\u8D85\u8FC7 ${formatFileSize(size)}`
29
+ });
30
+ else if (accepted.length >= slots)
31
+ rejected.push({
32
+ file,
33
+ code: "count",
34
+ message: `\u6700\u591A\u9009\u62E9 ${Math.min(limit, multiple ? Infinity : 1)} \u4E2A\u6587\u4EF6`
35
+ });
36
+ else accepted.push(file);
37
+ }
38
+ return { accepted, rejected };
39
+ }
40
+ export {
41
+ formatFileSize,
42
+ validateFiles
43
+ };
@@ -0,0 +1,23 @@
1
+ import type { ReactNode } from "react";
2
+ export type HierarchyOption = {
3
+ value: string;
4
+ label: string;
5
+ icon?: ReactNode;
6
+ count?: number;
7
+ keywords?: string[];
8
+ children?: HierarchyOption[];
9
+ disabled?: boolean;
10
+ selectable?: boolean;
11
+ isLeaf?: boolean;
12
+ };
13
+ export type HierarchyLoader = (node: HierarchyOption, signal: AbortSignal) => Promise<HierarchyOption[]>;
14
+ export type HierarchyEntry = {
15
+ node: HierarchyOption;
16
+ path: HierarchyOption[];
17
+ disabled: boolean;
18
+ parent?: string;
19
+ branch: boolean;
20
+ };
21
+ export declare function indexHierarchy(options: HierarchyOption[], children: (node: HierarchyOption) => HierarchyOption[] | undefined, lazy?: boolean): Map<string, HierarchyEntry>;
22
+ export declare function hierarchyMatches(entry: HierarchyEntry, query: string): boolean;
23
+ export declare function hierarchyLeaves(entry: HierarchyEntry, entries: Map<string, HierarchyEntry>): string[];
@@ -0,0 +1,33 @@
1
+ function indexHierarchy(options, children, lazy = false) {
2
+ const entries = /* @__PURE__ */ new Map();
3
+ const walk = (nodes, path, disabled) => {
4
+ for (const node of nodes) {
5
+ if (entries.has(node.value)) continue;
6
+ const next = [...path, node], nested = children(node);
7
+ entries.set(node.value, {
8
+ node,
9
+ path: next,
10
+ disabled: disabled || !!node.disabled,
11
+ parent: path.at(-1)?.value,
12
+ branch: !!nested?.length || node.isLeaf === false && nested === void 0 && lazy
13
+ });
14
+ if (nested?.length) walk(nested, next, disabled || !!node.disabled);
15
+ }
16
+ };
17
+ walk(options, [], false);
18
+ return entries;
19
+ }
20
+ function hierarchyMatches(entry, query) {
21
+ const text = entry.path.flatMap((node) => [node.label, node.value, ...node.keywords || []]).join(" ").normalize("NFKC").toLocaleLowerCase();
22
+ return query.normalize("NFKC").toLocaleLowerCase().trim().split(/\s+/).every((word) => text.includes(word));
23
+ }
24
+ function hierarchyLeaves(entry, entries) {
25
+ return [...entries.values()].filter(
26
+ (item) => !item.disabled && !item.branch && item.node.selectable !== false && item.path.some((node) => node.value === entry.node.value)
27
+ ).map((item) => item.node.value);
28
+ }
29
+ export {
30
+ hierarchyLeaves,
31
+ hierarchyMatches,
32
+ indexHierarchy
33
+ };
@@ -0,0 +1,13 @@
1
+ import type { LucideIconData } from "lucide-react";
2
+ export type CatalogEntry = LucideIconData & {
3
+ name: string;
4
+ aliases: string[];
5
+ categories: string[];
6
+ };
7
+ export declare function loadCatalog(): Promise<CatalogEntry[]>;
8
+ export declare function useIconCatalog(enabled?: boolean): {
9
+ items: CatalogEntry[] | undefined;
10
+ error: boolean;
11
+ retry: () => void;
12
+ };
13
+ export declare const iconCategories: Record<string, string>;
@@ -0,0 +1,80 @@
1
+ import { useEffect, useState } from "react";
2
+ const url = new URL("../assets/icon-catalog.json", import.meta.url).href;
3
+ let cache;
4
+ let pending;
5
+ function loadCatalog() {
6
+ return pending ||= fetch(url).then((r) => {
7
+ if (!r.ok) throw Error("\u56FE\u6807\u52A0\u8F7D\u5931\u8D25");
8
+ return r.json();
9
+ }).then((data) => cache = data).catch((e) => {
10
+ pending = void 0;
11
+ throw e;
12
+ });
13
+ }
14
+ function useIconCatalog(enabled = true) {
15
+ const [items, setItems] = useState(cache), [error, setError] = useState(false), [revision, setRevision] = useState(0);
16
+ useEffect(() => {
17
+ if (!enabled) return;
18
+ let alive = true;
19
+ setError(false);
20
+ loadCatalog().then((data) => {
21
+ if (alive) setItems(data);
22
+ }).catch(() => {
23
+ if (alive) setError(true);
24
+ });
25
+ return () => {
26
+ alive = false;
27
+ };
28
+ }, [enabled, revision]);
29
+ return { items, error, retry: () => setRevision((x) => x + 1) };
30
+ }
31
+ const iconCategories = {
32
+ accessibility: "\u65E0\u969C\u788D",
33
+ account: "\u8D26\u6237",
34
+ animals: "\u52A8\u7269",
35
+ arrows: "\u7BAD\u5934",
36
+ buildings: "\u5EFA\u7B51",
37
+ charts: "\u56FE\u8868",
38
+ communication: "\u901A\u4FE1",
39
+ connectivity: "\u8FDE\u63A5",
40
+ cursors: "\u5149\u6807",
41
+ design: "\u8BBE\u8BA1",
42
+ development: "\u5F00\u53D1",
43
+ devices: "\u8BBE\u5907",
44
+ emoji: "\u8868\u60C5",
45
+ files: "\u6587\u4EF6",
46
+ finance: "\u91D1\u878D",
47
+ "food-beverage": "\u9910\u996E",
48
+ gaming: "\u6E38\u620F",
49
+ home: "\u5BB6\u5C45",
50
+ layout: "\u5E03\u5C40",
51
+ mail: "\u90AE\u4EF6",
52
+ math: "\u6570\u5B66",
53
+ medical: "\u533B\u7597",
54
+ multimedia: "\u591A\u5A92\u4F53",
55
+ nature: "\u81EA\u7136",
56
+ navigation: "\u5BFC\u822A",
57
+ notifications: "\u901A\u77E5",
58
+ people: "\u4EBA\u7269",
59
+ photography: "\u6444\u5F71",
60
+ science: "\u79D1\u5B66",
61
+ seasons: "\u5B63\u8282",
62
+ security: "\u5B89\u5168",
63
+ shapes: "\u5F62\u72B6",
64
+ shopping: "\u8D2D\u7269",
65
+ social: "\u793E\u4EA4",
66
+ sports: "\u8FD0\u52A8",
67
+ sustainability: "\u53EF\u6301\u7EED",
68
+ text: "\u6587\u672C",
69
+ time: "\u65F6\u95F4",
70
+ tools: "\u5DE5\u5177",
71
+ transportation: "\u4EA4\u901A",
72
+ travel: "\u65C5\u884C",
73
+ weather: "\u5929\u6C14",
74
+ uncategorized: "\u5176\u4ED6"
75
+ };
76
+ export {
77
+ iconCategories,
78
+ loadCatalog,
79
+ useIconCatalog
80
+ };