@robert-stackflow/oneui 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (367) hide show
  1. package/README.md +45 -2
  2. package/assets/LUCIDE-LICENSE.txt +43 -0
  3. package/assets/character-metadata.json +1 -0
  4. package/assets/emoji.json +1 -0
  5. package/assets/icon-catalog.json +1 -0
  6. package/assets/symbols.json +1 -0
  7. package/components/Accessibility.module.css +8 -0
  8. package/components/Accordion.d.ts +7 -0
  9. package/components/Accordion.js +41 -0
  10. package/components/Accordion.module.css +38 -0
  11. package/components/Alert.d.ts +9 -0
  12. package/components/Alert.js +42 -0
  13. package/components/Alert.module.css +56 -0
  14. package/components/AppShell.d.ts +30 -0
  15. package/components/AppShell.js +152 -0
  16. package/components/AppShell.module.css +239 -0
  17. package/components/AppearanceSettings.d.ts +7 -0
  18. package/components/AppearanceSettings.js +201 -0
  19. package/components/AppearanceSettings.module.css +32 -0
  20. package/components/Avatar.d.ts +14 -0
  21. package/components/Avatar.js +69 -0
  22. package/components/Avatar.module.css +70 -0
  23. package/components/AvatarGroup.d.ts +15 -0
  24. package/components/AvatarGroup.js +115 -0
  25. package/components/AvatarGroup.module.css +54 -0
  26. package/components/Badge.d.ts +5 -0
  27. package/components/Badge.js +11 -0
  28. package/components/Badge.module.css +30 -0
  29. package/components/BlockedTab.d.ts +4 -0
  30. package/components/BlockedTab.js +10 -0
  31. package/components/Breadcrumb.d.ts +16 -0
  32. package/components/Breadcrumb.js +157 -0
  33. package/components/Breadcrumb.module.css +97 -0
  34. package/components/Button.d.ts +6 -0
  35. package/components/Button.js +29 -0
  36. package/components/Button.module.css +79 -0
  37. package/components/Calendar.d.ts +10 -0
  38. package/components/Calendar.js +260 -0
  39. package/components/Calendar.module.css +106 -0
  40. package/components/Card.d.ts +7 -0
  41. package/components/Card.js +19 -0
  42. package/components/Card.module.css +28 -0
  43. package/components/Cascader.d.ts +14 -0
  44. package/components/Cascader.js +296 -0
  45. package/components/CatalogIcon.d.ts +3 -0
  46. package/components/CatalogIcon.js +11 -0
  47. package/components/CharacterPicker.d.ts +15 -0
  48. package/components/CharacterPicker.js +200 -0
  49. package/components/Checkbox.d.ts +12 -0
  50. package/components/Checkbox.js +82 -0
  51. package/components/Checkbox.module.css +95 -0
  52. package/components/ColorField.d.ts +6 -0
  53. package/components/ColorField.js +61 -0
  54. package/components/ColorField.module.css +15 -0
  55. package/components/ColorPicker.d.ts +5 -0
  56. package/components/ColorPicker.js +188 -0
  57. package/components/ColorPicker.module.css +90 -0
  58. package/components/Combobox.d.ts +11 -0
  59. package/components/Combobox.js +252 -0
  60. package/components/Combobox.module.css +26 -0
  61. package/components/CommandPalette.d.ts +25 -0
  62. package/components/CommandPalette.js +269 -0
  63. package/components/CommandPalette.module.css +49 -0
  64. package/components/ContextMenu.d.ts +9 -0
  65. package/components/ContextMenu.js +363 -0
  66. package/components/ContextMenu.module.css +42 -0
  67. package/components/ContextMenuPanel.d.ts +22 -0
  68. package/components/ContextMenuPanel.js +155 -0
  69. package/components/ContributionCalendar.d.ts +18 -0
  70. package/components/ContributionCalendar.js +201 -0
  71. package/components/ContributionCalendar.module.css +114 -0
  72. package/components/ContributionCell.d.ts +11 -0
  73. package/components/ContributionCell.js +41 -0
  74. package/components/Control.module.css +73 -0
  75. package/components/DataTable.d.ts +49 -0
  76. package/components/DataTable.js +220 -0
  77. package/components/DataTable.module.css +112 -0
  78. package/components/DatePicker.d.ts +15 -0
  79. package/components/DatePicker.js +186 -0
  80. package/components/DatePicker.module.css +85 -0
  81. package/components/DateRangePicker.d.ts +9 -0
  82. package/components/DateRangePicker.js +168 -0
  83. package/components/Descriptions.d.ts +21 -0
  84. package/components/Descriptions.js +162 -0
  85. package/components/Descriptions.module.css +117 -0
  86. package/components/Dialog.d.ts +9 -0
  87. package/components/Dialog.js +112 -0
  88. package/components/Dialog.module.css +71 -0
  89. package/components/DisclosureChevron.d.ts +3 -0
  90. package/components/DisclosureChevron.js +17 -0
  91. package/components/DisclosureChevron.module.css +17 -0
  92. package/components/Divider.d.ts +5 -0
  93. package/components/Divider.js +24 -0
  94. package/components/Divider.module.css +19 -0
  95. package/components/Drawer.d.ts +18 -0
  96. package/components/Drawer.js +145 -0
  97. package/components/Drawer.module.css +109 -0
  98. package/components/EmojiPicker.d.ts +6 -0
  99. package/components/EmojiPicker.js +19 -0
  100. package/components/EmptyState.d.ts +8 -0
  101. package/components/EmptyState.js +20 -0
  102. package/components/EmptyState.module.css +30 -0
  103. package/components/FieldLabel.d.ts +8 -0
  104. package/components/FieldLabel.js +20 -0
  105. package/components/FieldMessages.d.ts +5 -0
  106. package/components/FieldMessages.js +15 -0
  107. package/components/FileDropOverlay.d.ts +5 -0
  108. package/components/FileDropOverlay.js +26 -0
  109. package/components/FileDropOverlay.module.css +55 -0
  110. package/components/FileDropZone.d.ts +15 -0
  111. package/components/FileDropZone.js +113 -0
  112. package/components/FileDropZone.module.css +6 -0
  113. package/components/FilePicker.d.ts +10 -0
  114. package/components/FilePicker.js +59 -0
  115. package/components/FileSelectionFeedback.d.ts +5 -0
  116. package/components/FileSelectionFeedback.js +23 -0
  117. package/components/FileSelectionFeedback.module.css +14 -0
  118. package/components/FileTree.d.ts +13 -0
  119. package/components/FileTree.js +125 -0
  120. package/components/FileTree.module.css +66 -0
  121. package/components/Form.d.ts +7 -0
  122. package/components/Form.js +26 -0
  123. package/components/Form.module.css +7 -0
  124. package/components/FormErrorSummary.d.ts +6 -0
  125. package/components/FormErrorSummary.js +27 -0
  126. package/components/FormErrorSummary.module.css +27 -0
  127. package/components/FormField.d.ts +9 -0
  128. package/components/FormField.js +59 -0
  129. package/components/FormField.module.css +85 -0
  130. package/components/FormGroup.d.ts +9 -0
  131. package/components/FormGroup.js +32 -0
  132. package/components/HierarchyPicker.module.css +146 -0
  133. package/components/IconButton.d.ts +7 -0
  134. package/components/IconButton.js +30 -0
  135. package/components/IconButton.module.css +39 -0
  136. package/components/IconPicker.d.ts +6 -0
  137. package/components/IconPicker.js +111 -0
  138. package/components/Indicator.d.ts +18 -0
  139. package/components/Indicator.js +97 -0
  140. package/components/Indicator.module.css +83 -0
  141. package/components/Input.d.ts +7 -0
  142. package/components/Input.js +29 -0
  143. package/components/Input.module.css +23 -0
  144. package/components/LoadingOverlay.d.ts +6 -0
  145. package/components/LoadingOverlay.js +16 -0
  146. package/components/LoadingOverlay.module.css +22 -0
  147. package/components/LoadingState.d.ts +5 -0
  148. package/components/LoadingState.js +29 -0
  149. package/components/LoadingState.module.css +14 -0
  150. package/components/Menu.d.ts +11 -0
  151. package/components/Menu.js +82 -0
  152. package/components/MenuItem.d.ts +14 -0
  153. package/components/MenuItem.js +49 -0
  154. package/components/MenuItem.module.css +163 -0
  155. package/components/MenuItemContent.d.ts +8 -0
  156. package/components/MenuItemContent.js +19 -0
  157. package/components/MultiSelect.d.ts +12 -0
  158. package/components/MultiSelect.js +161 -0
  159. package/components/MultiSelect.module.css +61 -0
  160. package/components/NumberInput.d.ts +12 -0
  161. package/components/NumberInput.js +113 -0
  162. package/components/NumberInput.module.css +33 -0
  163. package/components/Page.d.ts +7 -0
  164. package/components/Page.js +22 -0
  165. package/components/Page.module.css +44 -0
  166. package/components/Pagination.d.ts +11 -0
  167. package/components/Pagination.js +160 -0
  168. package/components/Pagination.module.css +70 -0
  169. package/components/PasswordField.d.ts +9 -0
  170. package/components/PasswordField.js +101 -0
  171. package/components/PasswordField.module.css +64 -0
  172. package/components/Picker.module.css +52 -0
  173. package/components/PinInput.d.ts +13 -0
  174. package/components/PinInput.js +172 -0
  175. package/components/PinInput.module.css +72 -0
  176. package/components/Placeholder.d.ts +31 -0
  177. package/components/Placeholder.js +36 -0
  178. package/components/Popconfirm.d.ts +17 -0
  179. package/components/Popconfirm.js +159 -0
  180. package/components/Popconfirm.module.css +49 -0
  181. package/components/Popover.d.ts +13 -0
  182. package/components/Popover.js +150 -0
  183. package/components/Popover.module.css +16 -0
  184. package/components/Progress.d.ts +5 -0
  185. package/components/Progress.js +31 -0
  186. package/components/Progress.module.css +33 -0
  187. package/components/RadioGroup.d.ts +15 -0
  188. package/components/RadioGroup.js +73 -0
  189. package/components/RadioGroup.module.css +87 -0
  190. package/components/RangeSlider.d.ts +22 -0
  191. package/components/RangeSlider.js +278 -0
  192. package/components/RangeSlider.module.css +141 -0
  193. package/components/ResizablePanel.d.ts +21 -0
  194. package/components/ResizablePanel.js +219 -0
  195. package/components/ResizablePanel.module.css +101 -0
  196. package/components/SearchField.d.ts +11 -0
  197. package/components/SearchField.js +66 -0
  198. package/components/SearchField.module.css +37 -0
  199. package/components/Section.d.ts +6 -0
  200. package/components/Section.js +18 -0
  201. package/components/Section.module.css +14 -0
  202. package/components/Segmented.d.ts +11 -0
  203. package/components/Segmented.js +77 -0
  204. package/components/Segmented.module.css +82 -0
  205. package/components/Select.d.ts +11 -0
  206. package/components/Select.js +171 -0
  207. package/components/Select.module.css +21 -0
  208. package/components/SelectOptionContent.d.ts +5 -0
  209. package/components/SelectOptionContent.js +20 -0
  210. package/components/SelectOptionContent.module.css +7 -0
  211. package/components/SelectTrigger.d.ts +5 -0
  212. package/components/SelectTrigger.js +32 -0
  213. package/components/SelectTrigger.module.css +24 -0
  214. package/components/SettingRow.d.ts +7 -0
  215. package/components/SettingRow.js +19 -0
  216. package/components/SettingRow.module.css +44 -0
  217. package/components/SettingsLayout.d.ts +9 -0
  218. package/components/SettingsLayout.js +45 -0
  219. package/components/SettingsLayout.module.css +48 -0
  220. package/components/ShortcutInput.d.ts +8 -0
  221. package/components/ShortcutInput.js +131 -0
  222. package/components/ShortcutInput.module.css +39 -0
  223. package/components/Skeleton.d.ts +5 -0
  224. package/components/Skeleton.js +19 -0
  225. package/components/Skeleton.module.css +27 -0
  226. package/components/SkeletonRows.d.ts +4 -0
  227. package/components/SkeletonRows.js +19 -0
  228. package/components/SkeletonRows.module.css +19 -0
  229. package/components/SkinTonePicker.d.ts +4 -0
  230. package/components/SkinTonePicker.js +43 -0
  231. package/components/SkinTonePicker.module.css +50 -0
  232. package/components/Slider.d.ts +10 -0
  233. package/components/Slider.js +40 -0
  234. package/components/Slider.module.css +19 -0
  235. package/components/Spinner.d.ts +6 -0
  236. package/components/Spinner.js +31 -0
  237. package/components/Spinner.module.css +57 -0
  238. package/components/SplitButton.d.ts +17 -0
  239. package/components/SplitButton.js +102 -0
  240. package/components/SplitButton.module.css +56 -0
  241. package/components/Statistic.d.ts +22 -0
  242. package/components/Statistic.js +102 -0
  243. package/components/Statistic.module.css +55 -0
  244. package/components/Steps.d.ts +19 -0
  245. package/components/Steps.js +102 -0
  246. package/components/Steps.module.css +176 -0
  247. package/components/Switch.d.ts +6 -0
  248. package/components/Switch.js +25 -0
  249. package/components/Switch.module.css +56 -0
  250. package/components/SymbolPicker.d.ts +6 -0
  251. package/components/SymbolPicker.js +18 -0
  252. package/components/Tab.module.css +145 -0
  253. package/components/TabList.d.ts +11 -0
  254. package/components/TabList.js +51 -0
  255. package/components/Table.d.ts +12 -0
  256. package/components/Table.js +20 -0
  257. package/components/Table.module.css +48 -0
  258. package/components/TableColumnFilter.d.ts +6 -0
  259. package/components/TableColumnFilter.js +76 -0
  260. package/components/TableColumnVisibility.d.ts +11 -0
  261. package/components/TableColumnVisibility.js +76 -0
  262. package/components/Tabs.d.ts +13 -0
  263. package/components/Tabs.js +49 -0
  264. package/components/Tabs.module.css +3 -0
  265. package/components/TagInput.d.ts +11 -0
  266. package/components/TagInput.js +154 -0
  267. package/components/TagInput.module.css +64 -0
  268. package/components/Textarea.d.ts +6 -0
  269. package/components/Textarea.js +24 -0
  270. package/components/Textarea.module.css +9 -0
  271. package/components/ThemePicker.d.ts +6 -0
  272. package/components/ThemePicker.js +78 -0
  273. package/components/ThemePicker.module.css +178 -0
  274. package/components/ThemeProvider.d.ts +11 -0
  275. package/components/ThemeProvider.js +80 -0
  276. package/components/ThemeStylePicker.d.ts +5 -0
  277. package/components/ThemeStylePicker.js +22 -0
  278. package/components/TimeColumns.d.ts +6 -0
  279. package/components/TimeColumns.js +55 -0
  280. package/components/TimeColumns.module.css +47 -0
  281. package/components/Timeline.d.ts +26 -0
  282. package/components/Timeline.js +131 -0
  283. package/components/Timeline.module.css +202 -0
  284. package/components/Toast.d.ts +6 -0
  285. package/components/Toast.js +181 -0
  286. package/components/Toast.module.css +175 -0
  287. package/components/ToastProvider.d.ts +35 -0
  288. package/components/ToastProvider.js +47 -0
  289. package/components/Tooltip.d.ts +10 -0
  290. package/components/Tooltip.js +169 -0
  291. package/components/Tooltip.module.css +53 -0
  292. package/components/TreeSelect.d.ts +23 -0
  293. package/components/TreeSelect.js +309 -0
  294. package/components/UIProvider.d.ts +10 -0
  295. package/components/UIProvider.js +20 -0
  296. package/components/UnderlinedTab.d.ts +2 -0
  297. package/components/UnderlinedTab.js +8 -0
  298. package/components/Upload.d.ts +22 -0
  299. package/components/Upload.js +165 -0
  300. package/components/Upload.module.css +36 -0
  301. package/components/UploadList.d.ts +9 -0
  302. package/components/UploadList.js +14 -0
  303. package/components/UploadList.module.css +130 -0
  304. package/components/UploadListItem.d.ts +13 -0
  305. package/components/UploadListItem.js +122 -0
  306. package/components/VirtualPickerList.d.ts +25 -0
  307. package/components/VirtualPickerList.js +269 -0
  308. package/components/VirtualPickerList.module.css +89 -0
  309. package/components/appearance.d.ts +19 -0
  310. package/components/appearance.js +60 -0
  311. package/components/characterCatalog.d.ts +9 -0
  312. package/components/characterCatalog.js +55 -0
  313. package/components/color.d.ts +7 -0
  314. package/components/color.js +18 -0
  315. package/components/contribution.d.ts +57 -0
  316. package/components/contribution.js +86 -0
  317. package/components/dateConstraints.d.ts +13 -0
  318. package/components/dateConstraints.js +44 -0
  319. package/components/field.d.ts +58 -0
  320. package/components/field.js +57 -0
  321. package/components/fileSelection.d.ts +21 -0
  322. package/components/fileSelection.js +43 -0
  323. package/components/hierarchy.d.ts +22 -0
  324. package/components/hierarchy.js +33 -0
  325. package/components/iconCatalog.d.ts +13 -0
  326. package/components/iconCatalog.js +80 -0
  327. package/components/index.d.ts +150 -0
  328. package/components/index.js +219 -0
  329. package/components/menuFocus.d.ts +7 -0
  330. package/components/menuFocus.js +21 -0
  331. package/components/menuPointer.d.ts +6 -0
  332. package/components/menuPointer.js +13 -0
  333. package/components/menuTypes.d.ts +24 -0
  334. package/components/menuTypes.js +0 -0
  335. package/components/motion.d.ts +9 -0
  336. package/components/motion.js +82 -0
  337. package/components/rangeMath.d.ts +12 -0
  338. package/components/rangeMath.js +30 -0
  339. package/components/surfacePortal.d.ts +13 -0
  340. package/components/surfacePortal.js +22 -0
  341. package/components/tooltipState.d.ts +5 -0
  342. package/components/tooltipState.js +48 -0
  343. package/components/types.d.ts +9 -0
  344. package/components/types.js +0 -0
  345. package/components/uploadTypes.d.ts +21 -0
  346. package/components/uploadTypes.js +0 -0
  347. package/components/useFormState.d.ts +51 -0
  348. package/components/useFormState.js +218 -0
  349. package/components/useHierarchy.d.ts +8 -0
  350. package/components/useHierarchy.js +80 -0
  351. package/components/useMenuLayers.d.ts +17 -0
  352. package/components/useMenuLayers.js +23 -0
  353. package/components/useModalScrollLock.d.ts +1 -0
  354. package/components/useModalScrollLock.js +18 -0
  355. package/components/usePopover.d.ts +8 -0
  356. package/components/usePopover.js +22 -0
  357. package/components/useTabIndicator.d.ts +12 -0
  358. package/components/useTabIndicator.js +63 -0
  359. package/components/useUploadQueue.d.ts +20 -0
  360. package/components/useUploadQueue.js +175 -0
  361. package/package.json +783 -3
  362. package/styles/base.css +189 -0
  363. package/styles/blue.css +254 -0
  364. package/styles/desktop.css +2 -0
  365. package/styles/minimal.css +337 -0
  366. package/styles/themes.css +2 -0
  367. package/styles/web.css +2 -0
@@ -0,0 +1,64 @@
1
+ .control {
2
+ composes: surface from "./Control.module.css";
3
+ display: flex;
4
+ align-items: center;
5
+ gap: 7px;
6
+ padding: 0 8px 0 10px;
7
+ }
8
+ .control input {
9
+ flex: 1;
10
+ min-width: 0;
11
+ width: 100%;
12
+ height: 100%;
13
+ padding: 0;
14
+ border: 0;
15
+ outline: 0;
16
+ background: transparent;
17
+ font-size: inherit;
18
+ }
19
+ .control button {
20
+ display: grid;
21
+ place-items: center;
22
+ flex-shrink: 0;
23
+ width: 26px;
24
+ height: 26px;
25
+ border: 0;
26
+ padding: 0;
27
+ border-radius: 5px;
28
+ background: transparent;
29
+ color: var(--muted);
30
+ }
31
+ .control button:hover {
32
+ background: var(--hover);
33
+ color: var(--fg);
34
+ }
35
+ .control svg {
36
+ width: 16px;
37
+ height: 16px;
38
+ }
39
+ .caps {
40
+ font-size: 11px;
41
+ color: var(--warning);
42
+ margin: 0;
43
+ }
44
+ .strength {
45
+ display: flex;
46
+ gap: 4px;
47
+ height: 4px;
48
+ }
49
+ .strength span {
50
+ height: 4px;
51
+ flex: 1;
52
+ border-radius: 3px;
53
+ background: var(--line);
54
+ }
55
+ .strength[data-strength="1"] [data-active="true"] {
56
+ background: var(--danger);
57
+ }
58
+ .strength[data-strength="2"] [data-active="true"] {
59
+ background: var(--warning);
60
+ }
61
+ .strength[data-strength="3"] [data-active="true"],
62
+ .strength[data-strength="4"] [data-active="true"] {
63
+ background: var(--success);
64
+ }
@@ -0,0 +1,52 @@
1
+ .panel {
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: 12px;
5
+ padding: 12px;
6
+ max-height: min(540px, 80vh);
7
+ }
8
+ .footer {
9
+ display: flex;
10
+ align-items: center;
11
+ color: var(--muted);
12
+ font-size: 12px;
13
+ min-height: 20px;
14
+ }
15
+ .preview {
16
+ display: grid;
17
+ place-items: center;
18
+ font-size: 16px;
19
+ line-height: 18px;
20
+ width: 18px;
21
+ flex-shrink: 0;
22
+ font-family: "Segoe UI Emoji", "Segoe UI Symbol", var(--ui-font);
23
+ }
24
+ .loading {
25
+ display: grid;
26
+ place-items: center;
27
+ height: 320px;
28
+ }
29
+ .variantPanel {
30
+ height: 320px;
31
+ overflow: auto;
32
+ }
33
+ .variantGrid {
34
+ display: grid;
35
+ grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
36
+ gap: 5px;
37
+ margin-top: 14px;
38
+ }
39
+ .cell {
40
+ display: grid;
41
+ place-items: center;
42
+ height: 38px;
43
+ padding: 0;
44
+ border: 1px solid transparent;
45
+ border-radius: 7px;
46
+ background: transparent;
47
+ font-size: 23px;
48
+ font-family: "Segoe UI Emoji", "Segoe UI Symbol", var(--ui-font);
49
+ }
50
+ .cell:hover {
51
+ background: var(--hover);
52
+ }
@@ -0,0 +1,13 @@
1
+ import { type ComponentPropsWithRef } from "react";
2
+ export declare function PinInput({ value, onChange, onComplete, length, format, mask, groups, label, error, hint, ref: forwardedRef, ...props }: Omit<ComponentPropsWithRef<"input">, "value" | "onChange" | "type" | "maxLength" | "pattern" | "size"> & {
3
+ value: string;
4
+ onChange(value: string): void;
5
+ onComplete?(value: string): void;
6
+ length?: number;
7
+ format?: "numeric" | "alphanumeric";
8
+ mask?: boolean;
9
+ groups?: number[];
10
+ label?: string;
11
+ error?: string;
12
+ hint?: string;
13
+ }): import("react").JSX.Element;
@@ -0,0 +1,172 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import {
3
+ useEffect,
4
+ useLayoutEffect,
5
+ useRef,
6
+ useState
7
+ } from "react";
8
+ import { FormField } from "./FormField.js";
9
+ import { useFieldControl } from "./field.js";
10
+ import s from "./PinInput.module.css";
11
+ function PinInput({
12
+ value,
13
+ onChange,
14
+ onComplete,
15
+ length = 6,
16
+ format = "numeric",
17
+ mask = false,
18
+ groups,
19
+ label,
20
+ error,
21
+ hint,
22
+ ref: forwardedRef,
23
+ ...props
24
+ }) {
25
+ const field = useFieldControl({ ...props, label, error, hint }), input = useRef(null), root = useRef(null), lastComplete = useRef(""), pendingCaret = useRef(void 0), [focused, setFocused] = useState(false), [active, setActive] = useState(0), size = Math.max(1, Math.min(16, Math.trunc(length) || 6));
26
+ useEffect(() => {
27
+ if (value.length < size) lastComplete.current = "";
28
+ }, [value, size]);
29
+ useLayoutEffect(() => {
30
+ if (pendingCaret.current === void 0) return;
31
+ const caret = Math.min(pendingCaret.current, value.length);
32
+ input.current?.setSelectionRange(caret, caret);
33
+ pendingCaret.current = void 0;
34
+ }, [value]);
35
+ const clean = (text) => (format === "numeric" ? text.replace(/[^0-9]/g, "") : text.replace(/[^a-z0-9]/gi, "")).slice(0, size);
36
+ const emit = (next, caret) => {
37
+ pendingCaret.current = caret;
38
+ onChange(next);
39
+ setActive(Math.min(caret, size - 1));
40
+ if (next === value) {
41
+ input.current?.setSelectionRange(
42
+ Math.min(caret, value.length),
43
+ Math.min(caret, value.length)
44
+ );
45
+ pendingCaret.current = void 0;
46
+ }
47
+ if (next.length === size && lastComplete.current !== next) {
48
+ lastComplete.current = next;
49
+ onComplete?.(next);
50
+ } else if (next.length < size) lastComplete.current = "";
51
+ };
52
+ const boundaries = /* @__PURE__ */ new Set();
53
+ let offset = 0;
54
+ for (const group of groups || [size]) {
55
+ offset += group;
56
+ boundaries.add(offset);
57
+ }
58
+ const control = /* @__PURE__ */ jsxs(
59
+ "div",
60
+ {
61
+ ref: root,
62
+ className: s.root,
63
+ "data-disabled": field.disabled,
64
+ onPointerDown: (event) => {
65
+ if (event.button !== 0 || field.disabled) return;
66
+ event.preventDefault();
67
+ input.current?.focus({ preventScroll: true });
68
+ const slots = [
69
+ ...root.current.querySelectorAll("[data-pin-slot]")
70
+ ];
71
+ let index = 0, distance = Infinity;
72
+ slots.forEach((slot, i) => {
73
+ const rect = slot.getBoundingClientRect(), d = (event.clientX - rect.left - rect.width / 2) ** 2 + (event.clientY - rect.top - rect.height / 2) ** 2;
74
+ if (d < distance) {
75
+ distance = d;
76
+ index = i;
77
+ }
78
+ });
79
+ const caret = Math.min(index < 0 ? size - 1 : index, value.length);
80
+ input.current?.setSelectionRange(
81
+ caret,
82
+ Math.min(caret + 1, value.length)
83
+ );
84
+ setActive(Math.min(caret, size - 1));
85
+ },
86
+ children: [
87
+ Array.from({ length: size }, (_, index) => /* @__PURE__ */ jsxs("span", { className: s.unit, "aria-hidden": "true", children: [
88
+ index > 0 && boundaries.has(index) && /* @__PURE__ */ jsx("span", { className: s.separator, children: "\u2013" }),
89
+ /* @__PURE__ */ jsxs(
90
+ "span",
91
+ {
92
+ "data-pin-slot": true,
93
+ className: s.slot,
94
+ "data-focus": focused && active === index,
95
+ "aria-invalid": field.invalid,
96
+ children: [
97
+ mask && value[index] ? "\u2022" : value[index],
98
+ focused && active === index && !value[index] && /* @__PURE__ */ jsx("i", { className: s.caret })
99
+ ]
100
+ }
101
+ )
102
+ ] }, index)),
103
+ /* @__PURE__ */ jsx(
104
+ "input",
105
+ {
106
+ ...props,
107
+ ref: (node) => {
108
+ input.current = node;
109
+ if (typeof forwardedRef === "function") forwardedRef(node);
110
+ else if (forwardedRef) forwardedRef.current = node;
111
+ },
112
+ id: field.id,
113
+ name: field.name,
114
+ className: s.input,
115
+ type: "text",
116
+ autoComplete: props.autoComplete || "one-time-code",
117
+ inputMode: format === "numeric" ? "numeric" : "text",
118
+ spellCheck: false,
119
+ required: field.required,
120
+ disabled: field.disabled,
121
+ readOnly: field.readOnly,
122
+ minLength: size,
123
+ maxLength: size,
124
+ pattern: format === "numeric" ? "[0-9]{" + size + "}" : "[a-zA-Z0-9]{" + size + "}",
125
+ value,
126
+ "aria-invalid": field.invalid,
127
+ "aria-describedby": field.descriptionId,
128
+ onFocus: (event) => {
129
+ setFocused(true);
130
+ setActive(
131
+ Math.min(event.currentTarget.selectionStart || 0, size - 1)
132
+ );
133
+ props.onFocus?.(event);
134
+ },
135
+ onBlur: (event) => {
136
+ setFocused(false);
137
+ props.onBlur?.(event);
138
+ },
139
+ onSelect: (event) => {
140
+ setActive(
141
+ Math.min(event.currentTarget.selectionStart || 0, size - 1)
142
+ );
143
+ props.onSelect?.(event);
144
+ },
145
+ onChange: (event) => {
146
+ if (!field.readOnly)
147
+ emit(clean(event.target.value), event.target.selectionStart || 0);
148
+ },
149
+ onPaste: (event) => {
150
+ props.onPaste?.(event);
151
+ if (event.defaultPrevented || field.readOnly) return;
152
+ event.preventDefault();
153
+ const text = clean(
154
+ event.clipboardData.getData("text/plain") || event.clipboardData.getData("text")
155
+ );
156
+ if (!text) return;
157
+ const start = event.currentTarget.selectionStart || 0, end = event.currentTarget.selectionEnd || start;
158
+ emit(
159
+ text.length === size ? text : clean(value.slice(0, start) + text + value.slice(end)),
160
+ text.length === size ? size : start + text.length
161
+ );
162
+ }
163
+ }
164
+ )
165
+ ]
166
+ }
167
+ );
168
+ return field.wrapped ? control : /* @__PURE__ */ jsx(FormField, { ...field, children: control });
169
+ }
170
+ export {
171
+ PinInput
172
+ };
@@ -0,0 +1,72 @@
1
+ .root {
2
+ position: relative;
3
+ display: inline-flex;
4
+ align-items: center;
5
+ gap: 7px;
6
+ align-self: flex-start;
7
+ max-width: 100%;
8
+ flex-wrap: wrap;
9
+ }
10
+ .unit {
11
+ display: inline-flex;
12
+ align-items: center;
13
+ gap: 10px;
14
+ }
15
+ .slot {
16
+ composes: surface from "./Control.module.css";
17
+ position: relative;
18
+ display: grid;
19
+ place-items: center;
20
+ width: 39px;
21
+ height: 44px;
22
+ font-size: 19px;
23
+ font-variant-numeric: tabular-nums;
24
+ pointer-events: none;
25
+ }
26
+ .separator {
27
+ color: var(--muted);
28
+ padding: 0 2px;
29
+ }
30
+ .input {
31
+ position: absolute;
32
+ inset: 0;
33
+ width: 100%;
34
+ height: 100%;
35
+ padding: 0;
36
+ border: 0;
37
+ outline: 0;
38
+ background: transparent !important;
39
+ color: transparent !important;
40
+ caret-color: transparent !important;
41
+ letter-spacing: 20px;
42
+ font-size: 19px;
43
+ box-shadow: none !important;
44
+ }
45
+ .input::selection {
46
+ background: transparent;
47
+ color: transparent;
48
+ }
49
+ .root[data-disabled="true"] .slot {
50
+ opacity: 0.45;
51
+ }
52
+ .caret {
53
+ position: absolute;
54
+ display: block;
55
+ height: 19px;
56
+ width: 1.5px;
57
+ background: var(--fg);
58
+ animation: pin-caret 1.1s step-end infinite;
59
+ }
60
+ @keyframes pin-caret {
61
+ 50% {
62
+ opacity: 0;
63
+ }
64
+ }
65
+
66
+ .input:focus,
67
+ .input:focus-visible {
68
+ outline: none !important;
69
+ outline-offset: 0 !important;
70
+ box-shadow: none !important;
71
+ border: 0 !important;
72
+ }
@@ -0,0 +1,31 @@
1
+ import type { ReactNode } from "react";
2
+ declare const presets: {
3
+ empty: {
4
+ icon: import("lucide-react").LucideIcon;
5
+ title: string;
6
+ };
7
+ search: {
8
+ icon: import("lucide-react").LucideIcon;
9
+ title: string;
10
+ };
11
+ error: {
12
+ icon: import("lucide-react").LucideIcon;
13
+ title: string;
14
+ };
15
+ offline: {
16
+ icon: import("lucide-react").LucideIcon;
17
+ title: string;
18
+ };
19
+ folder: {
20
+ icon: import("lucide-react").LucideIcon;
21
+ title: string;
22
+ };
23
+ };
24
+ export type PlaceholderVariant = keyof typeof presets;
25
+ export declare function Placeholder({ variant, title, description, children, }: {
26
+ variant?: PlaceholderVariant;
27
+ title?: string;
28
+ description?: string;
29
+ children?: ReactNode;
30
+ }): import("react").JSX.Element;
31
+ export {};
@@ -0,0 +1,36 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import {
3
+ Inbox,
4
+ Search,
5
+ TriangleAlert,
6
+ WifiOff,
7
+ FolderOpen
8
+ } from "lucide-react";
9
+ import { EmptyState } from "./EmptyState.js";
10
+ const presets = {
11
+ empty: { icon: Inbox, title: "\u6682\u65E0\u5185\u5BB9" },
12
+ search: { icon: Search, title: "\u6CA1\u6709\u5339\u914D\u7684\u7ED3\u679C" },
13
+ error: { icon: TriangleAlert, title: "\u5185\u5BB9\u52A0\u8F7D\u5931\u8D25" },
14
+ offline: { icon: WifiOff, title: "\u5F53\u524D\u5904\u4E8E\u79BB\u7EBF\u72B6\u6001" },
15
+ folder: { icon: FolderOpen, title: "\u6587\u4EF6\u5939\u4E3A\u7A7A" }
16
+ };
17
+ function Placeholder({
18
+ variant = "empty",
19
+ title,
20
+ description,
21
+ children
22
+ }) {
23
+ const preset = presets[variant], Icon = preset.icon;
24
+ return /* @__PURE__ */ jsx(
25
+ EmptyState,
26
+ {
27
+ icon: /* @__PURE__ */ jsx(Icon, {}),
28
+ title: title || preset.title,
29
+ description,
30
+ children
31
+ }
32
+ );
33
+ }
34
+ export {
35
+ Placeholder
36
+ };
@@ -0,0 +1,17 @@
1
+ import { type ComponentPropsWithRef, type ReactElement, type ReactNode } from "react";
2
+ export type PopconfirmProps = {
3
+ children: ReactElement<ComponentPropsWithRef<"button">>;
4
+ title: string;
5
+ description?: ReactNode;
6
+ onConfirm(signal: AbortSignal): void | Promise<void>;
7
+ onCancel?(): void;
8
+ open?: boolean;
9
+ defaultOpen?: boolean;
10
+ onOpenChange?(open: boolean): void;
11
+ disabled?: boolean;
12
+ confirmText?: string;
13
+ cancelText?: string;
14
+ tone?: "default" | "danger";
15
+ icon?: ReactNode | false;
16
+ };
17
+ export declare function Popconfirm({ children, title, description, onConfirm, onCancel, open: controlled, defaultOpen, onOpenChange, disabled, confirmText, cancelText, tone, icon, }: PopconfirmProps): import("react").JSX.Element;
@@ -0,0 +1,159 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import {
3
+ cloneElement,
4
+ useEffect,
5
+ useId,
6
+ useRef,
7
+ useState
8
+ } from "react";
9
+ import { CircleAlert } from "lucide-react";
10
+ import { Popover } from "./Popover.js";
11
+ import { Button } from "./Button.js";
12
+ import s from "./Popconfirm.module.css";
13
+ function Popconfirm({
14
+ children,
15
+ title,
16
+ description,
17
+ onConfirm,
18
+ onCancel,
19
+ open: controlled,
20
+ defaultOpen = false,
21
+ onOpenChange,
22
+ disabled = false,
23
+ confirmText = "\u786E\u8BA4",
24
+ cancelText = "\u53D6\u6D88",
25
+ tone = "default",
26
+ icon
27
+ }) {
28
+ const [localOpen, setLocalOpen] = useState(defaultOpen), [pending, setPending] = useState(false), [error, setError] = useState(""), anchor = useRef(null), session = useRef(null), alive = useRef(true), id = useId(), confirm = useRef(null);
29
+ const blocked = disabled || !!children.props.disabled, open = (controlled ?? localOpen) && !blocked;
30
+ const change = (next) => {
31
+ if (controlled === void 0) setLocalOpen(next);
32
+ onOpenChange?.(next);
33
+ };
34
+ const abort = () => {
35
+ session.current?.abort();
36
+ session.current = null;
37
+ setPending(false);
38
+ };
39
+ const close = (cancel = true, restoreFocus = true) => {
40
+ abort();
41
+ change(false);
42
+ setError("");
43
+ if (cancel) onCancel?.();
44
+ if (restoreFocus) anchor.current?.focus({ preventScroll: true });
45
+ };
46
+ useEffect(() => {
47
+ alive.current = true;
48
+ return () => {
49
+ alive.current = false;
50
+ session.current?.abort();
51
+ session.current = null;
52
+ };
53
+ }, []);
54
+ useEffect(() => {
55
+ if (!open) {
56
+ session.current?.abort();
57
+ session.current = null;
58
+ setPending(false);
59
+ setError("");
60
+ }
61
+ }, [open]);
62
+ useEffect(() => {
63
+ if (error && !pending) confirm.current?.focus({ preventScroll: true });
64
+ }, [error, pending]);
65
+ const submit = async () => {
66
+ if (session.current || !open) return;
67
+ const controller = new AbortController();
68
+ session.current = controller;
69
+ setPending(true);
70
+ setError("");
71
+ try {
72
+ await onConfirm(controller.signal);
73
+ if (!alive.current || controller.signal.aborted || session.current !== controller)
74
+ return;
75
+ session.current = null;
76
+ setPending(false);
77
+ change(false);
78
+ anchor.current?.focus({ preventScroll: true });
79
+ } catch (reason) {
80
+ if (!alive.current || controller.signal.aborted || session.current !== controller)
81
+ return;
82
+ session.current = null;
83
+ setPending(false);
84
+ setError(reason instanceof Error ? reason.message : "\u64CD\u4F5C\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\u3002");
85
+ confirm.current?.focus({ preventScroll: true });
86
+ }
87
+ };
88
+ const childRef = children.props.ref;
89
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
90
+ cloneElement(children, {
91
+ ref: (node) => {
92
+ anchor.current = node;
93
+ if (typeof childRef === "function") return childRef(node);
94
+ else if (childRef) childRef.current = node;
95
+ },
96
+ disabled: blocked,
97
+ "aria-haspopup": "dialog",
98
+ "aria-expanded": open,
99
+ "aria-controls": id,
100
+ onClick: (event) => {
101
+ children.props.onClick?.(event);
102
+ if (event.defaultPrevented || blocked) return;
103
+ if (open) close();
104
+ else {
105
+ setError("");
106
+ change(true);
107
+ }
108
+ }
109
+ }),
110
+ /* @__PURE__ */ jsx(
111
+ Popover,
112
+ {
113
+ anchor,
114
+ open,
115
+ onClose: () => close(true, false),
116
+ label: title,
117
+ role: "alertdialog",
118
+ id,
119
+ descriptionId: description ? id + "-description" : void 0,
120
+ width: 320,
121
+ children: /* @__PURE__ */ jsxs(
122
+ "div",
123
+ {
124
+ className: s.content,
125
+ "data-tone": tone,
126
+ "aria-busy": pending || void 0,
127
+ children: [
128
+ /* @__PURE__ */ jsxs("div", { className: s.copy, children: [
129
+ icon !== false && /* @__PURE__ */ jsx("span", { className: s.icon, "aria-hidden": "true", children: icon || /* @__PURE__ */ jsx(CircleAlert, {}) }),
130
+ /* @__PURE__ */ jsxs("div", { children: [
131
+ /* @__PURE__ */ jsx("div", { className: s.title, children: title }),
132
+ description && /* @__PURE__ */ jsx("div", { className: s.description, id: id + "-description", children: description })
133
+ ] })
134
+ ] }),
135
+ error && /* @__PURE__ */ jsx("div", { role: "alert", className: s.error, children: error }),
136
+ /* @__PURE__ */ jsxs("div", { className: s.actions, children: [
137
+ /* @__PURE__ */ jsx(Button, { size: "small", "data-autofocus": true, onClick: () => close(), children: pending ? "\u53D6\u6D88\u64CD\u4F5C" : cancelText }),
138
+ /* @__PURE__ */ jsx(
139
+ Button,
140
+ {
141
+ ref: confirm,
142
+ size: "small",
143
+ variant: tone === "danger" ? "danger" : "primary",
144
+ loading: pending,
145
+ onClick: () => void submit(),
146
+ children: confirmText
147
+ }
148
+ )
149
+ ] })
150
+ ]
151
+ }
152
+ )
153
+ }
154
+ )
155
+ ] });
156
+ }
157
+ export {
158
+ Popconfirm
159
+ };
@@ -0,0 +1,49 @@
1
+ .content {
2
+ padding: 12px;
3
+ }
4
+ .copy {
5
+ display: flex;
6
+ gap: 10px;
7
+ align-items: flex-start;
8
+ }
9
+ .copy > div {
10
+ min-width: 0;
11
+ }
12
+ .icon {
13
+ display: flex;
14
+ padding-top: 1px;
15
+ color: var(--warning);
16
+ }
17
+ .icon svg {
18
+ width: 18px;
19
+ height: 18px;
20
+ }
21
+ .content[data-tone="danger"] .icon {
22
+ color: var(--danger);
23
+ }
24
+ .title {
25
+ font-size: 13px;
26
+ font-weight: 600;
27
+ line-height: 20px;
28
+ overflow-wrap: anywhere;
29
+ }
30
+ .description {
31
+ margin-top: 5px;
32
+ font-size: 12px;
33
+ line-height: 1.65;
34
+ color: var(--muted);
35
+ overflow-wrap: anywhere;
36
+ }
37
+ .error {
38
+ margin-top: 10px;
39
+ color: var(--danger);
40
+ font-size: 12px;
41
+ line-height: 1.6;
42
+ overflow-wrap: anywhere;
43
+ }
44
+ .actions {
45
+ display: flex;
46
+ justify-content: flex-end;
47
+ gap: 8px;
48
+ margin-top: 16px;
49
+ }
@@ -0,0 +1,13 @@
1
+ import { type ReactNode, type RefObject } from "react";
2
+ export declare function Popover({ open: requestedOpen, onClose, anchor, children, width, label, role, id, onKeyDown, descriptionId, }: {
3
+ open: boolean;
4
+ onClose(): void;
5
+ anchor: RefObject<HTMLElement | null>;
6
+ children: ReactNode;
7
+ width?: number;
8
+ label: string;
9
+ role?: string;
10
+ id?: string;
11
+ onKeyDown?: React.KeyboardEventHandler<HTMLDivElement>;
12
+ descriptionId?: string;
13
+ }): import("react").ReactPortal;