@daisu-ui/ui 0.0.0-stage → 0.1.0-beta.4

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 (402) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/LICENSE +21 -0
  3. package/README.md +179 -2
  4. package/THIRD_PARTY_NOTICES.md +19 -0
  5. package/dist/ActionSheet.d.ts +45 -0
  6. package/dist/ActionSheet.jsx +37 -0
  7. package/dist/AnchoredBubble.d.ts +36 -0
  8. package/dist/AnchoredBubble.jsx +120 -0
  9. package/dist/Avatar.d.ts +35 -0
  10. package/dist/Avatar.jsx +29 -0
  11. package/dist/Backtop.d.ts +22 -0
  12. package/dist/Backtop.jsx +18 -0
  13. package/dist/Badge.d.ts +19 -0
  14. package/dist/Badge.jsx +11 -0
  15. package/dist/BarCode.d.ts +20 -0
  16. package/dist/BarCode.jsx +38 -0
  17. package/dist/Button.d.ts +21 -0
  18. package/dist/Button.jsx +19 -0
  19. package/dist/Calendar.d.ts +90 -0
  20. package/dist/Calendar.jsx +164 -0
  21. package/dist/CalendarView.d.ts +51 -0
  22. package/dist/CalendarView.jsx +136 -0
  23. package/dist/Card.d.ts +21 -0
  24. package/dist/Card.jsx +21 -0
  25. package/dist/Cascader.d.ts +75 -0
  26. package/dist/Cascader.jsx +212 -0
  27. package/dist/Cell.d.ts +34 -0
  28. package/dist/Cell.jsx +37 -0
  29. package/dist/Checkbox.d.ts +50 -0
  30. package/dist/Checkbox.jsx +74 -0
  31. package/dist/Circle.d.ts +19 -0
  32. package/dist/Circle.jsx +35 -0
  33. package/dist/Collapse.d.ts +31 -0
  34. package/dist/Collapse.jsx +61 -0
  35. package/dist/ConfigProvider.d.ts +15 -0
  36. package/dist/ConfigProvider.jsx +20 -0
  37. package/dist/CountDown.d.ts +20 -0
  38. package/dist/CountDown.jsx +15 -0
  39. package/dist/CountTo.d.ts +28 -0
  40. package/dist/CountTo.jsx +27 -0
  41. package/dist/Curtain.d.ts +29 -0
  42. package/dist/Curtain.jsx +51 -0
  43. package/dist/DatetimePicker.d.ts +46 -0
  44. package/dist/DatetimePicker.jsx +138 -0
  45. package/dist/DatetimePickerView.d.ts +38 -0
  46. package/dist/DatetimePickerView.jsx +36 -0
  47. package/dist/Dialog.d.ts +64 -0
  48. package/dist/Dialog.jsx +105 -0
  49. package/dist/Divider.d.ts +16 -0
  50. package/dist/Divider.jsx +9 -0
  51. package/dist/DropMenu.d.ts +55 -0
  52. package/dist/DropMenu.jsx +210 -0
  53. package/dist/Empty.d.ts +14 -0
  54. package/dist/Empty.jsx +14 -0
  55. package/dist/EmptyState.d.ts +6 -0
  56. package/dist/EmptyState.jsx +9 -0
  57. package/dist/Fab.d.ts +30 -0
  58. package/dist/Fab.jsx +127 -0
  59. package/dist/FloatingPanel.d.ts +21 -0
  60. package/dist/FloatingPanel.jsx +102 -0
  61. package/dist/Form.d.ts +63 -0
  62. package/dist/Form.jsx +108 -0
  63. package/dist/FormFieldRow.d.ts +56 -0
  64. package/dist/FormFieldRow.jsx +63 -0
  65. package/dist/Gap.d.ts +10 -0
  66. package/dist/Gap.jsx +14 -0
  67. package/dist/Grid.d.ts +47 -0
  68. package/dist/Grid.jsx +31 -0
  69. package/dist/Icon.d.ts +11 -0
  70. package/dist/Icon.jsx +12 -0
  71. package/dist/ImagePreview.d.ts +62 -0
  72. package/dist/ImagePreview.jsx +78 -0
  73. package/dist/Img.d.ts +28 -0
  74. package/dist/Img.jsx +59 -0
  75. package/dist/ImgCropper.d.ts +74 -0
  76. package/dist/ImgCropper.jsx +114 -0
  77. package/dist/IndexBar.d.ts +36 -0
  78. package/dist/IndexBar.jsx +149 -0
  79. package/dist/Input.d.ts +11 -0
  80. package/dist/Input.jsx +3 -0
  81. package/dist/InputNumber.d.ts +32 -0
  82. package/dist/InputNumber.jsx +165 -0
  83. package/dist/Keyboard.d.ts +37 -0
  84. package/dist/Keyboard.jsx +130 -0
  85. package/dist/Layout.d.ts +31 -0
  86. package/dist/Layout.jsx +14 -0
  87. package/dist/Loading.d.ts +18 -0
  88. package/dist/Loading.jsx +15 -0
  89. package/dist/Loadmore.d.ts +18 -0
  90. package/dist/Loadmore.jsx +16 -0
  91. package/dist/Navbar.d.ts +35 -0
  92. package/dist/Navbar.jsx +50 -0
  93. package/dist/NoticeBar.d.ts +30 -0
  94. package/dist/NoticeBar.jsx +86 -0
  95. package/dist/Notify.d.ts +34 -0
  96. package/dist/Notify.jsx +52 -0
  97. package/dist/NumberStepper.d.ts +11 -0
  98. package/dist/NumberStepper.jsx +41 -0
  99. package/dist/Overlay.d.ts +16 -0
  100. package/dist/Overlay.jsx +12 -0
  101. package/dist/PagedList.d.ts +13 -0
  102. package/dist/PagedList.jsx +36 -0
  103. package/dist/Pagination.d.ts +29 -0
  104. package/dist/Pagination.jsx +33 -0
  105. package/dist/PasswordInput.d.ts +16 -0
  106. package/dist/PasswordInput.jsx +20 -0
  107. package/dist/Picker.d.ts +61 -0
  108. package/dist/Picker.jsx +80 -0
  109. package/dist/PickerView.d.ts +43 -0
  110. package/dist/PickerView.jsx +142 -0
  111. package/dist/Popover.d.ts +23 -0
  112. package/dist/Popover.jsx +35 -0
  113. package/dist/Popup.d.ts +30 -0
  114. package/dist/Popup.jsx +32 -0
  115. package/dist/Progress.d.ts +17 -0
  116. package/dist/Progress.jsx +45 -0
  117. package/dist/QrCode.d.ts +46 -0
  118. package/dist/QrCode.jsx +67 -0
  119. package/dist/Radio.d.ts +21 -0
  120. package/dist/Radio.jsx +34 -0
  121. package/dist/Rate.d.ts +25 -0
  122. package/dist/Rate.jsx +39 -0
  123. package/dist/Resize.d.ts +17 -0
  124. package/dist/Resize.jsx +17 -0
  125. package/dist/RichText.d.ts +133 -0
  126. package/dist/RichText.jsx +288 -0
  127. package/dist/RootPortal.d.ts +11 -0
  128. package/dist/RootPortal.jsx +19 -0
  129. package/dist/Search.d.ts +39 -0
  130. package/dist/Search.jsx +94 -0
  131. package/dist/Segmented.d.ts +18 -0
  132. package/dist/Segmented.jsx +35 -0
  133. package/dist/SelectPicker.d.ts +54 -0
  134. package/dist/SelectPicker.jsx +136 -0
  135. package/dist/Sidebar.d.ts +34 -0
  136. package/dist/Sidebar.jsx +43 -0
  137. package/dist/Signature.d.ts +46 -0
  138. package/dist/Signature.jsx +203 -0
  139. package/dist/Skeleton.d.ts +27 -0
  140. package/dist/Skeleton.jsx +29 -0
  141. package/dist/SlideVerify.d.ts +27 -0
  142. package/dist/SlideVerify.jsx +138 -0
  143. package/dist/Slider.d.ts +21 -0
  144. package/dist/Slider.jsx +131 -0
  145. package/dist/SortButton.d.ts +16 -0
  146. package/dist/SortButton.jsx +19 -0
  147. package/dist/Steps.d.ts +23 -0
  148. package/dist/Steps.jsx +25 -0
  149. package/dist/Sticky.d.ts +17 -0
  150. package/dist/Sticky.jsx +69 -0
  151. package/dist/SwipeAction.d.ts +27 -0
  152. package/dist/SwipeAction.jsx +187 -0
  153. package/dist/Swiper.d.ts +54 -0
  154. package/dist/Swiper.jsx +94 -0
  155. package/dist/SwiperNav.d.ts +18 -0
  156. package/dist/SwiperNav.jsx +10 -0
  157. package/dist/Switch.d.ts +31 -0
  158. package/dist/Switch.jsx +46 -0
  159. package/dist/SyncedInput.d.ts +12 -0
  160. package/dist/SyncedInput.jsx +18 -0
  161. package/dist/SyncedTextarea.d.ts +11 -0
  162. package/dist/SyncedTextarea.jsx +18 -0
  163. package/dist/Tabbar.d.ts +37 -0
  164. package/dist/Tabbar.jsx +46 -0
  165. package/dist/Table.d.ts +51 -0
  166. package/dist/Table.jsx +125 -0
  167. package/dist/Tabs.d.ts +65 -0
  168. package/dist/Tabs.jsx +132 -0
  169. package/dist/Tag.d.ts +33 -0
  170. package/dist/Tag.jsx +63 -0
  171. package/dist/Text.d.ts +19 -0
  172. package/dist/Text.jsx +7 -0
  173. package/dist/TextField.d.ts +89 -0
  174. package/dist/TextField.jsx +149 -0
  175. package/dist/Textarea.d.ts +22 -0
  176. package/dist/Textarea.jsx +3 -0
  177. package/dist/Toast.d.ts +36 -0
  178. package/dist/Toast.jsx +30 -0
  179. package/dist/Tooltip.d.ts +8 -0
  180. package/dist/Tooltip.jsx +5 -0
  181. package/dist/Tour.d.ts +85 -0
  182. package/dist/Tour.jsx +150 -0
  183. package/dist/Transition.d.ts +32 -0
  184. package/dist/Transition.jsx +43 -0
  185. package/dist/Upload.d.ts +64 -0
  186. package/dist/Upload.jsx +163 -0
  187. package/dist/VideoPreview.d.ts +47 -0
  188. package/dist/VideoPreview.jsx +59 -0
  189. package/dist/Watermark.d.ts +36 -0
  190. package/dist/Watermark.jsx +18 -0
  191. package/dist/action-sheet.css +19 -0
  192. package/dist/avatar.css +23 -0
  193. package/dist/avatarModel.d.ts +8 -0
  194. package/dist/avatarModel.js +17 -0
  195. package/dist/backtop.css +6 -0
  196. package/dist/badge.css +15 -0
  197. package/dist/badgeModel.d.ts +2 -0
  198. package/dist/badgeModel.js +18 -0
  199. package/dist/bar-code.css +5 -0
  200. package/dist/barCodeModel.d.ts +80 -0
  201. package/dist/barCodeModel.js +99 -0
  202. package/dist/brand/logo.svg +8 -0
  203. package/dist/bubble.css +14 -0
  204. package/dist/bubblePosition.d.ts +19 -0
  205. package/dist/bubblePosition.js +41 -0
  206. package/dist/button.css +56 -0
  207. package/dist/calendar.css +56 -0
  208. package/dist/calendarModel.d.ts +62 -0
  209. package/dist/calendarModel.js +141 -0
  210. package/dist/card.css +8 -0
  211. package/dist/cascader.css +16 -0
  212. package/dist/cascaderModel.d.ts +21 -0
  213. package/dist/cascaderModel.js +32 -0
  214. package/dist/cell.css +41 -0
  215. package/dist/choice.css +27 -0
  216. package/dist/choice.d.ts +28 -0
  217. package/dist/choice.jsx +16 -0
  218. package/dist/circle.css +4 -0
  219. package/dist/circleModel.d.ts +15 -0
  220. package/dist/circleModel.js +31 -0
  221. package/dist/config-provider.css +2 -0
  222. package/dist/configContext.d.ts +23 -0
  223. package/dist/configContext.js +24 -0
  224. package/dist/configTheme.d.ts +3 -0
  225. package/dist/configTheme.js +22 -0
  226. package/dist/count-down.css +2 -0
  227. package/dist/count-to.css +8 -0
  228. package/dist/countDownModel.d.ts +11 -0
  229. package/dist/countDownModel.js +7 -0
  230. package/dist/countToModel.d.ts +3 -0
  231. package/dist/countToModel.js +3 -0
  232. package/dist/curtain.css +10 -0
  233. package/dist/datetime-picker.css +11 -0
  234. package/dist/datetimePickerModel.d.ts +47 -0
  235. package/dist/datetimePickerModel.js +128 -0
  236. package/dist/dialog.css +23 -0
  237. package/dist/divider.css +14 -0
  238. package/dist/drop-menu.css +28 -0
  239. package/dist/empty.css +7 -0
  240. package/dist/fab.css +23 -0
  241. package/dist/fabModel.d.ts +26 -0
  242. package/dist/fabModel.js +16 -0
  243. package/dist/floating-panel.css +6 -0
  244. package/dist/floatingPanelModel.d.ts +3 -0
  245. package/dist/floatingPanelModel.js +10 -0
  246. package/dist/form.css +10 -0
  247. package/dist/formContext.d.ts +7 -0
  248. package/dist/formContext.js +2 -0
  249. package/dist/formModel.d.ts +38 -0
  250. package/dist/formModel.js +16 -0
  251. package/dist/gap.css +1 -0
  252. package/dist/grid.css +17 -0
  253. package/dist/icon.css +8 -0
  254. package/dist/icons/LICENSE.tabler +21 -0
  255. package/dist/icons/paths.d.ts +309 -0
  256. package/dist/icons/paths.js +310 -0
  257. package/dist/icons/render.d.ts +2 -0
  258. package/dist/icons/render.js +5 -0
  259. package/dist/image-preview.css +8 -0
  260. package/dist/img-cropper.css +1 -0
  261. package/dist/img.css +5 -0
  262. package/dist/imgCropperModel.d.ts +55 -0
  263. package/dist/imgCropperModel.js +41 -0
  264. package/dist/imgModel.d.ts +13 -0
  265. package/dist/imgModel.js +22 -0
  266. package/dist/index-bar.css +12 -0
  267. package/dist/index.d.ts +200 -0
  268. package/dist/index.js +99 -0
  269. package/dist/indexBarModel.d.ts +19 -0
  270. package/dist/indexBarModel.js +37 -0
  271. package/dist/input-number.css +24 -0
  272. package/dist/inputNumberModel.d.ts +23 -0
  273. package/dist/inputNumberModel.js +40 -0
  274. package/dist/keyboard.css +26 -0
  275. package/dist/keyboardModel.d.ts +11 -0
  276. package/dist/keyboardModel.js +34 -0
  277. package/dist/layout.css +2 -0
  278. package/dist/legacy/RadioGroup.d.ts +13 -0
  279. package/dist/legacy/RadioGroup.jsx +13 -0
  280. package/dist/legacy-controls.css +87 -0
  281. package/dist/loading.css +31 -0
  282. package/dist/loadingModel.d.ts +2 -0
  283. package/dist/loadingModel.js +21 -0
  284. package/dist/loadmore.css +5 -0
  285. package/dist/navbar.css +16 -0
  286. package/dist/notice-bar.css +19 -0
  287. package/dist/notify.css +14 -0
  288. package/dist/overlay.css +2 -0
  289. package/dist/pagination.css +12 -0
  290. package/dist/paginationModel.d.ts +6 -0
  291. package/dist/paginationModel.js +7 -0
  292. package/dist/password-input.css +14 -0
  293. package/dist/passwordInputModel.d.ts +6 -0
  294. package/dist/passwordInputModel.js +11 -0
  295. package/dist/picker.css +42 -0
  296. package/dist/pickerModel.d.ts +32 -0
  297. package/dist/pickerModel.js +49 -0
  298. package/dist/popover.css +5 -0
  299. package/dist/popup.css +17 -0
  300. package/dist/progress.css +16 -0
  301. package/dist/progressModel.d.ts +12 -0
  302. package/dist/progressModel.js +19 -0
  303. package/dist/qr-code.css +4 -0
  304. package/dist/qrCodeModel.d.ts +36 -0
  305. package/dist/qrCodeModel.js +61 -0
  306. package/dist/rate.css +20 -0
  307. package/dist/rateModel.d.ts +4 -0
  308. package/dist/rateModel.js +38 -0
  309. package/dist/resize.css +2 -0
  310. package/dist/rich-text.css +19 -0
  311. package/dist/richTextMedia.d.ts +28 -0
  312. package/dist/richTextMedia.js +3 -0
  313. package/dist/richTextModel.d.ts +52 -0
  314. package/dist/richTextModel.js +195 -0
  315. package/dist/root-portal.css +1 -0
  316. package/dist/router/RouterView.d.ts +21 -0
  317. package/dist/router/RouterView.jsx +120 -0
  318. package/dist/router/core.d.ts +85 -0
  319. package/dist/router/core.js +255 -0
  320. package/dist/router/hooks.d.ts +17 -0
  321. package/dist/router/hooks.jsx +71 -0
  322. package/dist/router/index.d.ts +5 -0
  323. package/dist/router/index.js +3 -0
  324. package/dist/router/location.d.ts +8 -0
  325. package/dist/router/location.js +46 -0
  326. package/dist/router/router.css +7 -0
  327. package/dist/router/runtime.d.ts +1 -0
  328. package/dist/router/runtime.js +25 -0
  329. package/dist/search.css +23 -0
  330. package/dist/segmented.css +19 -0
  331. package/dist/segmentedModel.d.ts +10 -0
  332. package/dist/segmentedModel.js +8 -0
  333. package/dist/sidebar.css +18 -0
  334. package/dist/sidebarModel.d.ts +8 -0
  335. package/dist/sidebarModel.js +27 -0
  336. package/dist/signature.css +5 -0
  337. package/dist/signatureModel.d.ts +23 -0
  338. package/dist/signatureModel.js +80 -0
  339. package/dist/skeleton.css +16 -0
  340. package/dist/slide-verify.css +7 -0
  341. package/dist/slider.css +49 -0
  342. package/dist/sliderModel.d.ts +10 -0
  343. package/dist/sliderModel.js +27 -0
  344. package/dist/sort-button.css +12 -0
  345. package/dist/steps.css +35 -0
  346. package/dist/sticky.css +7 -0
  347. package/dist/styles.css +136 -0
  348. package/dist/styles.d.ts +1 -0
  349. package/dist/swipe-action.css +6 -0
  350. package/dist/swiper.css +27 -0
  351. package/dist/swiperAnimation.d.ts +3 -0
  352. package/dist/swiperAnimation.js +6 -0
  353. package/dist/swiperModel.d.ts +2 -0
  354. package/dist/swiperModel.js +3 -0
  355. package/dist/switch.css +12 -0
  356. package/dist/tabbar.css +17 -0
  357. package/dist/tabbarModel.d.ts +8 -0
  358. package/dist/tabbarModel.js +27 -0
  359. package/dist/table.css +21 -0
  360. package/dist/tableModel.d.ts +10 -0
  361. package/dist/tableModel.js +17 -0
  362. package/dist/tabs.css +31 -0
  363. package/dist/tabsModel.d.ts +7 -0
  364. package/dist/tabsModel.js +14 -0
  365. package/dist/tag.css +66 -0
  366. package/dist/text-field.css +15 -0
  367. package/dist/text.css +7 -0
  368. package/dist/textModel.d.ts +3 -0
  369. package/dist/textModel.js +24 -0
  370. package/dist/toast.css +13 -0
  371. package/dist/tokens.d.ts +34 -0
  372. package/dist/tokens.js +10 -0
  373. package/dist/tour.css +8 -0
  374. package/dist/transition.css +12 -0
  375. package/dist/upload.css +11 -0
  376. package/dist/useCountDown.d.ts +14 -0
  377. package/dist/useCountDown.js +73 -0
  378. package/dist/useDialog.d.ts +9 -0
  379. package/dist/useDialog.js +33 -0
  380. package/dist/useImagePreview.d.ts +7 -0
  381. package/dist/useImagePreview.js +17 -0
  382. package/dist/useNotify.d.ts +9 -0
  383. package/dist/useNotify.js +26 -0
  384. package/dist/usePressState.d.ts +6 -0
  385. package/dist/usePressState.js +17 -0
  386. package/dist/useToast.d.ts +11 -0
  387. package/dist/useToast.js +23 -0
  388. package/dist/useVideoPreview.d.ts +7 -0
  389. package/dist/useVideoPreview.js +17 -0
  390. package/dist/utils.d.ts +4 -0
  391. package/dist/utils.js +4 -0
  392. package/dist/video-preview.css +7 -0
  393. package/dist/watermark.css +6 -0
  394. package/dist/web/imgCropperElement.d.ts +2 -0
  395. package/dist/web/imgCropperElement.js +309 -0
  396. package/dist/web/index.d.ts +6 -0
  397. package/dist/web/index.js +6 -0
  398. package/dist/web/qrCodeExportElement.d.ts +4 -0
  399. package/dist/web/qrCodeExportElement.js +70 -0
  400. package/dist/web/richTextMediaElement.d.ts +2 -0
  401. package/dist/web/richTextMediaElement.js +276 -0
  402. package/package.json +98 -4
@@ -0,0 +1,37 @@
1
+ import type { ReactNode } from '@lynx-js/react';
2
+ import type { CSSProperties } from '@lynx-js/types';
3
+ import type { CarKeyboardLang, KeyboardMode } from './keyboardModel.js';
4
+ export type { CarKeyboardLang, KeyboardMode } from './keyboardModel.js';
5
+ export type KeyboardProps = {
6
+ visible?: boolean;
7
+ onVisibleChange?: (visible: boolean) => void;
8
+ value?: string;
9
+ defaultValue?: string;
10
+ onChange?: (value: string) => void;
11
+ mode?: KeyboardMode;
12
+ title?: ReactNode;
13
+ extraKey?: string | readonly string[];
14
+ maxlength?: number;
15
+ showDeleteKey?: boolean;
16
+ deleteText?: string;
17
+ closeText?: string;
18
+ closeButtonLoading?: boolean;
19
+ randomKeyOrder?: boolean;
20
+ carLang?: CarKeyboardLang;
21
+ onCarLangChange?: (lang: CarKeyboardLang) => void;
22
+ autoSwitchLang?: boolean;
23
+ modal?: boolean;
24
+ hideOnClickOutside?: boolean;
25
+ lockScroll?: boolean;
26
+ safeAreaInsetBottom?: boolean;
27
+ safeAreaBottom?: number;
28
+ zIndex?: number;
29
+ rootPortal?: boolean;
30
+ disabled?: boolean;
31
+ onInput?: (key: string) => void;
32
+ onDelete?: () => void;
33
+ onClose?: () => void;
34
+ className?: string;
35
+ style?: CSSProperties;
36
+ };
37
+ export declare function Keyboard({ visible, onVisibleChange, value, defaultValue, onChange, mode, title, extraKey, maxlength, showDeleteKey, deleteText, closeText, closeButtonLoading, randomKeyOrder, carLang, onCarLangChange, autoSwitchLang, modal, hideOnClickOutside, lockScroll, safeAreaInsetBottom, safeAreaBottom, zIndex, rootPortal, disabled: disabledProp, onInput, onDelete, onClose, className, style }: KeyboardProps): import("@lynx-js/react").JSX.Element;
@@ -0,0 +1,130 @@
1
+ import { useContext, useEffect, useRef, useState } from '@lynx-js/react';
2
+ import { Popup } from "./Popup.jsx";
3
+ import { Icon } from "./Icon.jsx";
4
+ import { Loading } from "./Loading.jsx";
5
+ import { FormFieldContext } from './formContext.js';
6
+ import { keyboardAppend, keyboardDigits, keyboardKeys, shuffleKeyboardDigits } from './keyboardModel.js';
7
+ function Key({ item, car = false, large = false, loading = false, disabled, onPress }) {
8
+ const [pressed, setPressed] = useState(false);
9
+ const touch = useRef(), cancelled = useRef(false);
10
+ useEffect(() => { if (disabled) {
11
+ setPressed(false);
12
+ touch.current = undefined;
13
+ } }, [disabled]);
14
+ const release = () => {
15
+ 'background only';
16
+ setPressed(false);
17
+ touch.current = undefined;
18
+ };
19
+ return <view className={`ui-keyboard-key-wrap ${item.wider ? 'ui-keyboard-key-wider' : ''} ${car ? 'ui-keyboard-key-car-wrap' : ''} ${large ? 'ui-keyboard-key-large-wrap' : ''}`}>
20
+ <view className={`ui-keyboard-key ui-keyboard-key-${item.type ?? 'input'} ${car ? 'ui-keyboard-key-car' : ''} ${large ? 'ui-keyboard-key-large' : ''} ${pressed ? 'ui-keyboard-key-pressed' : ''}`} accessibility-element={item.type !== 'blank'} accessibility-traits="button" accessibility-label={item.type === 'delete' ? item.text || '删除' : item.type === 'extra' && !item.text ? '收起键盘' : item.text} bindtouchstart={(event) => {
21
+ 'background only';
22
+ cancelled.current = false;
23
+ const point = event.touches[0];
24
+ if (!disabled && point) {
25
+ touch.current = { x: point.clientX, y: point.clientY };
26
+ setPressed(true);
27
+ }
28
+ }} bindtouchmove={(event) => {
29
+ 'background only';
30
+ const start = touch.current, point = event.touches[0];
31
+ if (start && point && Math.max(Math.abs(point.clientX - start.x), Math.abs(point.clientY - start.y)) > 6) {
32
+ cancelled.current = true;
33
+ release();
34
+ }
35
+ }} bindtouchend={release} bindtouchcancel={() => {
36
+ 'background only';
37
+ cancelled.current = true;
38
+ release();
39
+ }} bindmousedown={() => {
40
+ 'background only';
41
+ cancelled.current = false;
42
+ if (!disabled)
43
+ setPressed(true);
44
+ }} bindmouseleave={release} global-bindmouseup={pressed ? release : undefined} catchtap={() => {
45
+ 'background only';
46
+ release();
47
+ if (!disabled && !cancelled.current && item.type !== 'blank')
48
+ onPress(item);
49
+ }}>
50
+ {loading ? <Loading size={20} color="#fff"/> : item.type === 'delete' && !item.text ? <Icon name="del" size={22}/> : item.type === 'extra' && !item.text ? <Icon name="keyboard" size={22}/> : <text>{item.text}</text>}
51
+ </view>
52
+ </view>;
53
+ }
54
+ export function Keyboard({ visible = false, onVisibleChange, value, defaultValue = '', onChange, mode = 'default', title, extraKey, maxlength = Infinity, showDeleteKey = true, deleteText = '', closeText = '', closeButtonLoading = false, randomKeyOrder = false, carLang, onCarLangChange, autoSwitchLang = false, modal = false, hideOnClickOutside = true, lockScroll = true, safeAreaInsetBottom = true, safeAreaBottom = 0, zIndex = 100, rootPortal = false, disabled: disabledProp, onInput, onDelete, onClose, className = '', style }) {
55
+ const field = useContext(FormFieldContext), disabled = disabledProp ?? field?.disabled ?? false;
56
+ const [inner, setInner] = useState(defaultValue), [language, setLanguage] = useState('zh'), [digits, setDigits] = useState(keyboardDigits);
57
+ const current = value ?? inner, lang = carLang ?? language, latest = useRef(current);
58
+ latest.current = current;
59
+ // Randomness belongs on the background thread, once per opening/configuration.
60
+ useEffect(() => { if (visible)
61
+ setDigits(randomKeyOrder ? shuffleKeyboardDigits() : keyboardDigits); }, [visible, randomKeyOrder]);
62
+ const changeLanguage = (next) => {
63
+ 'background only';
64
+ if (carLang === undefined)
65
+ setLanguage(next);
66
+ onCarLangChange?.(next);
67
+ };
68
+ const close = () => {
69
+ 'background only';
70
+ if (!visible)
71
+ return;
72
+ onVisibleChange?.(false);
73
+ onClose?.();
74
+ };
75
+ const commit = (next) => {
76
+ 'background only';
77
+ if (value === undefined) {
78
+ latest.current = next;
79
+ setInner(next);
80
+ }
81
+ onChange?.(next);
82
+ };
83
+ const press = (item) => {
84
+ 'background only';
85
+ if (!visible || disabled)
86
+ return;
87
+ if (item.type === 'close') {
88
+ if (!closeButtonLoading)
89
+ close();
90
+ return;
91
+ }
92
+ if (item.type === 'extra') {
93
+ if (!item.text) {
94
+ close();
95
+ return;
96
+ }
97
+ if (mode === 'car' && (item.text === 'ABC' || item.text === '省份')) {
98
+ changeLanguage(lang === 'zh' ? 'en' : 'zh');
99
+ return;
100
+ }
101
+ }
102
+ if (item.type === 'delete') {
103
+ const next = Array.from(latest.current).slice(0, -1).join('');
104
+ onDelete?.();
105
+ commit(next);
106
+ if (mode === 'car' && carLang === undefined && autoSwitchLang && !next)
107
+ changeLanguage('zh');
108
+ return;
109
+ }
110
+ const next = keyboardAppend(latest.current, item.text, maxlength);
111
+ if (next === latest.current)
112
+ return;
113
+ onInput?.(item.text);
114
+ commit(next);
115
+ if (mode === 'car' && carLang === undefined && autoSwitchLang && Array.from(next).length === 1)
116
+ changeLanguage('en');
117
+ };
118
+ const headerClose = !!closeText && mode !== 'custom', header = title !== undefined && title !== '' || headerClose;
119
+ const safe = safeAreaInsetBottom && Number.isFinite(safeAreaBottom) ? Math.max(0, safeAreaBottom) : 0;
120
+ const keys = keyboardKeys(mode, digits, extraKey, showDeleteKey, deleteText, lang);
121
+ return <Popup show={visible} onChange={onVisibleChange} onClose={onClose} position="bottom" zIndex={zIndex} modal={hideOnClickOutside} modalStyle={modal ? undefined : { backgroundColor: 'transparent' }} lockScroll={lockScroll} rootPortal={rootPortal} className="ui-keyboard-popup">
122
+ <view className={`ui-keyboard ${disabled ? 'ui-keyboard-disabled' : ''} ${className}`} style={{ paddingBottom: `${safe}px`, ...style }}>
123
+ {header ? <view className="ui-keyboard-header"><view className="ui-keyboard-title">{typeof title === 'string' ? <text>{title}</text> : title}</view>{headerClose ? <view className="ui-keyboard-close" catchtap={close}><text>{closeText}</text></view> : null}</view> : null}
124
+ <view className={`ui-keyboard-body ${header ? 'ui-keyboard-body-with-header' : ''}`}>
125
+ <view className={`ui-keyboard-keys ${mode === 'car' ? 'ui-keyboard-car-keys' : ''}`}>{keys.map((item, index) => <Key key={`${item.type ?? 'input'}-${item.text}-${index}`} item={item} car={mode === 'car'} disabled={disabled || !visible} onPress={press}/>)}</view>
126
+ {mode === 'custom' ? <view className="ui-keyboard-sidebar">{showDeleteKey ? <Key item={{ text: deleteText, type: 'delete' }} large disabled={disabled || !visible} onPress={press}/> : null}<Key item={{ text: closeText, type: 'close' }} large loading={closeButtonLoading} disabled={disabled || !visible || closeButtonLoading} onPress={press}/></view> : null}
127
+ </view>
128
+ </view>
129
+ </Popup>;
130
+ }
@@ -0,0 +1,31 @@
1
+ import type { ReactNode } from '@lynx-js/react';
2
+ declare const justifyValues: {
3
+ readonly start: "flex-start";
4
+ readonly center: "center";
5
+ readonly end: "flex-end";
6
+ readonly 'space-between': "space-between";
7
+ readonly 'space-around': "space-around";
8
+ readonly 'space-evenly': "space-evenly";
9
+ };
10
+ declare const alignValues: {
11
+ readonly top: "flex-start";
12
+ readonly middle: "center";
13
+ readonly bottom: "flex-end";
14
+ };
15
+ export type RowProps = {
16
+ gutter?: number;
17
+ justify?: keyof typeof justifyValues;
18
+ align?: keyof typeof alignValues;
19
+ className?: string;
20
+ children?: ReactNode;
21
+ };
22
+ export type ColProps = {
23
+ span?: number;
24
+ offset?: number;
25
+ className?: string;
26
+ children?: ReactNode;
27
+ };
28
+ /** A 24-column layout. Each nested Row owns its gutter independently. */
29
+ export declare function Row({ gutter, justify, align, className, children }: RowProps): import("@lynx-js/react").JSX.Element;
30
+ export declare function Col({ span, offset, className, children }: ColProps): import("@lynx-js/react").JSX.Element;
31
+ export {};
@@ -0,0 +1,14 @@
1
+ import { createContext, useContext } from '@lynx-js/react';
2
+ const GutterContext = createContext(0);
3
+ const justifyValues = { start: 'flex-start', center: 'center', end: 'flex-end', 'space-between': 'space-between', 'space-around': 'space-around', 'space-evenly': 'space-evenly' };
4
+ const alignValues = { top: 'flex-start', middle: 'center', bottom: 'flex-end' };
5
+ /** A 24-column layout. Each nested Row owns its gutter independently. */
6
+ export function Row({ gutter = 0, justify = 'start', align = 'top', className = '', children }) {
7
+ const spacing = Number.isFinite(gutter) ? Math.max(0, gutter) : 0;
8
+ return <GutterContext.Provider value={spacing}><view className={`ui-row ${className}`} style={{ marginLeft: `${-spacing / 2}px`, marginRight: `${-spacing / 2}px`, justifyContent: justifyValues[justify], alignItems: alignValues[align] }}>{children}</view></GutterContext.Provider>;
9
+ }
10
+ export function Col({ span = 24, offset = 0, className = '', children }) {
11
+ const gutter = useContext(GutterContext);
12
+ const columns = (value, fallback) => Number.isFinite(value) ? Math.max(0, Math.min(24, value)) : fallback;
13
+ return <view className={`ui-col ${className}`} style={{ width: `${columns(span, 24) / 24 * 100}%`, marginLeft: `${columns(offset, 0) / 24 * 100}%`, paddingLeft: `${gutter / 2}px`, paddingRight: `${gutter / 2}px` }}>{children}</view>;
14
+ }
@@ -0,0 +1,18 @@
1
+ import type { ReactNode } from '@lynx-js/react';
2
+ import type { CSSProperties } from '@lynx-js/types';
3
+ export type LoadingSize = 'small' | 'medium' | 'large' | (string & {}) | number;
4
+ export type LoadingType = 'circular' | 'spinner' | 'dots' | 'wave';
5
+ export type LoadingProps = {
6
+ type?: LoadingType;
7
+ color?: string;
8
+ size?: LoadingSize;
9
+ text?: string;
10
+ /** Legacy label keeps its horizontal layout unless direction is specified. */
11
+ label?: string;
12
+ children?: ReactNode;
13
+ direction?: 'vertical' | 'horizontal';
14
+ className?: string;
15
+ spinnerClassName?: string;
16
+ style?: CSSProperties;
17
+ };
18
+ export declare function Loading({ type, color, size, text, label, children, direction, className, spinnerClassName, style }: LoadingProps): import("@lynx-js/react").JSX.Element;
@@ -0,0 +1,15 @@
1
+ import { useMemo } from '@lynx-js/react';
2
+ import { circularLoadingSvg, loadingDimension } from './loadingModel.js';
3
+ export function Loading({ type = 'circular', color = '#1c64fd', size = 28, text, label, children, direction = label !== undefined ? 'horizontal' : 'vertical', className = '', spinnerClassName = '', style }) {
4
+ const dimension = loadingDimension(size);
5
+ const content = children ?? text ?? label;
6
+ const svg = useMemo(() => type === 'circular' ? circularLoadingSvg(color) : '', [type, color]);
7
+ return <view className={`ui-loading ui-loading-${direction} ${label !== undefined ? 'ui-loading-legacy-label' : ''} ${className}`} style={{ color, ...style }} accessibility-element accessibility-label={typeof content === 'string' ? content : '加载中'}>
8
+ <view className={`ui-loading-spinner ui-loading-spinner-${type} ${spinnerClassName}`} style={{ width: dimension, height: dimension }}>
9
+ {type === 'circular' ? <svg className="ui-loading-circle" content={svg}/> : <view className={`ui-loading-inner ui-loading-inner-${type}`}>
10
+ {type === 'spinner' ? Array.from({ length: 12 }, (_, index) => <view key={index} className="ui-loading-spoke" style={{ transform: `rotate(${60 - index * 30}deg)`, opacity: 1 - index / 16 }}><view className="ui-loading-spoke-tip" style={{ backgroundColor: color }}/></view>) : type === 'dots' ? Array.from({ length: 3 }, (_, index) => <view key={index} className="ui-loading-dot" style={{ backgroundColor: color, transform: `rotate(${60 - index * 30}deg)`, animationDelay: `${800 * index / 3}ms` }}/>) : Array.from({ length: 4 }, (_, index) => <view key={index} className={`ui-loading-wave-bar ui-loading-wave-bar-${index + 1}`}><view className="ui-loading-wave-inner" style={{ backgroundColor: color }}/></view>)}
11
+ </view>}
12
+ </view>
13
+ {content !== undefined && content !== null && content !== '' && content !== false ? typeof content === 'string' || typeof content === 'number' ? <text className="ui-loading-label">{content}</text> : <view className="ui-loading-label ui-loading-custom-text">{content}</view> : null}
14
+ </view>;
15
+ }
@@ -0,0 +1,18 @@
1
+ import type { ReactNode } from '@lynx-js/react';
2
+ import type { CSSProperties } from '@lynx-js/types';
3
+ import type { LoadingProps } from "./Loading.jsx";
4
+ export type LoadmoreState = 'loading' | 'finished' | 'error';
5
+ export type LoadmoreProps = {
6
+ state?: LoadmoreState;
7
+ loadingText?: string;
8
+ finishedText?: string;
9
+ errorText?: string;
10
+ loadingProps?: LoadingProps;
11
+ loading?: ReactNode;
12
+ finished?: ReactNode;
13
+ error?: ReactNode;
14
+ onReload?: () => void;
15
+ className?: string;
16
+ style?: CSSProperties;
17
+ };
18
+ export declare function Loadmore({ state, loadingText, finishedText, errorText, loadingProps, loading, finished, error, onReload, className, style }: LoadmoreProps): import("@lynx-js/react").JSX.Element;
@@ -0,0 +1,16 @@
1
+ import { Divider } from "./Divider.jsx";
2
+ import { Icon } from "./Icon.jsx";
3
+ import { Loading } from "./Loading.jsx";
4
+ function contentNode(content) {
5
+ return typeof content === 'string' || typeof content === 'number' ? <text className="ui-loadmore-text">{content}</text> : content;
6
+ }
7
+ export function Loadmore({ state, loadingText = '正在努力加载中...', finishedText = '已加载完毕', errorText = '加载失败', loadingProps, loading, finished, error, onReload, className = '', style }) {
8
+ const retry = () => {
9
+ 'background only';
10
+ if (state === 'error')
11
+ onReload?.();
12
+ };
13
+ return <view className={`ui-loadmore ${state ? `ui-loadmore-${state}` : ''} ${className}`} style={style} bindtap={retry} accessibility-element accessibility-traits={state === 'error' ? 'button' : 'text'} accessibility-label={state === 'error' ? `${errorText},点击重试` : state === 'loading' ? loadingText : state === 'finished' ? finishedText : undefined}>
14
+ {state === 'loading' ? loading !== undefined ? contentNode(loading) : <><Loading {...loadingProps} className={`ui-loadmore-loading ${loadingProps?.className || ''}`}/><text className="ui-loadmore-text">{loadingText}</text></> : state === 'finished' ? finished !== undefined ? contentNode(finished) : <Divider className="ui-loadmore-divider" label={finishedText}/> : state === 'error' ? error !== undefined ? contentNode(error) : <><text className="ui-loadmore-text">{errorText}</text><text className="ui-loadmore-retry">点击重试</text><Icon name="refresh" size={16} color="#1c64fd"/></> : null}
15
+ </view>;
16
+ }
@@ -0,0 +1,35 @@
1
+ import type { ReactNode } from '@lynx-js/react';
2
+ export type NavbarProps = {
3
+ title?: ReactNode;
4
+ variant?: 'business' | 'standard';
5
+ onBack?: () => void;
6
+ rightLabel?: string;
7
+ onRight?: () => void;
8
+ rightDisabled?: boolean;
9
+ rightContent?: ReactNode;
10
+ statusBarHeight?: number;
11
+ leftText?: string;
12
+ rightText?: string;
13
+ leftArrow?: boolean;
14
+ bordered?: boolean;
15
+ fixed?: boolean;
16
+ placeholder?: boolean;
17
+ zIndex?: number;
18
+ safeAreaInsetTop?: boolean;
19
+ leftDisabled?: boolean;
20
+ left?: ReactNode;
21
+ right?: ReactNode;
22
+ capsule?: ReactNode;
23
+ className?: string;
24
+ onLeftTap?: () => void;
25
+ onRightTap?: () => void;
26
+ };
27
+ /** Existing callers retain the original business appearance and callbacks. */
28
+ export declare function Navbar({ title, variant, onBack, rightLabel, onRight, rightDisabled, rightContent, statusBarHeight, leftText, rightText, leftArrow, bordered, fixed, placeholder, zIndex, safeAreaInsetTop, leftDisabled, left, right, capsule, className, onLeftTap, onRightTap }: NavbarProps): import("@lynx-js/react").JSX.Element;
29
+ export type NavbarCapsuleProps = {
30
+ onBack?: () => void;
31
+ onBackHome?: () => void;
32
+ disabled?: boolean;
33
+ className?: string;
34
+ };
35
+ export declare function NavbarCapsule({ onBack, onBackHome, disabled, className }: NavbarCapsuleProps): import("@lynx-js/react").JSX.Element;
@@ -0,0 +1,50 @@
1
+ import { Icon } from "./Icon.jsx";
2
+ /** Existing callers retain the original business appearance and callbacks. */
3
+ export function Navbar({ title = '', variant = 'business', onBack, rightLabel, onRight, rightDisabled = false, rightContent, statusBarHeight = 0, leftText = '', rightText, leftArrow, bordered = false, fixed = false, placeholder = false, zIndex = 10, safeAreaInsetTop, leftDisabled = false, left, right, capsule, className = '', onLeftTap, onRightTap }) {
4
+ const standard = variant === 'standard';
5
+ const topInset = (safeAreaInsetTop ?? !standard) && Number.isFinite(statusBarHeight) ? Math.max(0, statusBarHeight) : 0;
6
+ const height = (standard ? 44 : 56) + topInset;
7
+ const label = rightText ?? rightLabel;
8
+ const rightNode = right ?? rightContent;
9
+ const handleLeft = () => {
10
+ 'background only';
11
+ if (!leftDisabled)
12
+ (onLeftTap ?? onBack)?.();
13
+ };
14
+ const handleRight = () => {
15
+ 'background only';
16
+ if (!rightDisabled)
17
+ (onRightTap ?? onRight)?.();
18
+ };
19
+ return <>
20
+ {fixed && placeholder ? <view className="ui-navbar-placeholder" style={{ height: `${height}px` }}/> : null}
21
+ <view className={`${standard ? 'ui-navbar' : 'navbar'} ${bordered ? 'ui-navbar-bordered' : ''} ${className}`} flatten={false} style={{ height: `${height}px`, ...(standard ? { paddingTop: `${topInset}px`, zIndex } : {}), ...(fixed ? { position: 'fixed', top: '0px', left: '0px', width: '100%', zIndex } : {}) }}>
22
+ <view className={standard ? 'ui-navbar-content' : 'navbar-content'} style={standard ? undefined : { top: `${topInset}px` }}>
23
+ <view className={standard ? 'ui-navbar-title' : 'nav-center'}>{typeof title === 'string' || typeof title === 'number' ? <text className={standard ? '' : 'nav-title'} text-maxline="1" text-overflow="ellipsis">{title}</text> : title}</view>
24
+ {capsule != null ? <view className={standard ? 'ui-navbar-capsule-slot' : 'nav-action nav-left'}>{capsule}</view> : <view className={`${standard ? 'ui-navbar-action ui-navbar-left' : 'nav-action nav-left'} ${leftDisabled ? 'ui-navbar-disabled' : ''}`} bindtap={handleLeft} accessibility-element accessibility-traits="button" accessibility-label={leftText || '返回'}>
25
+ {left ?? <>{(leftArrow ?? !standard) ? standard ? <Icon name="left" size={24}/> : <view className="nav-back-circle nav-circle-button"><view className="nav-back-icon"/></view> : null}{leftText ? <text>{leftText}</text> : null}</>}
26
+ </view>}
27
+ {standard ? rightNode != null || label ? <view className={`ui-navbar-action ui-navbar-right ${rightDisabled ? 'ui-navbar-disabled' : ''}`} bindtap={handleRight} accessibility-element accessibility-traits="button" accessibility-label={label || '右侧操作'}>{rightNode ?? <text>{label}</text>}</view> : null : <view className="nav-action nav-right">
28
+ {rightNode ?? (label ? <view className={`nav-right-button ${rightDisabled ? 'nav-right-button-disabled' : ''}`} bindtap={handleRight}><text className={`nav-right-button-label ${rightDisabled ? 'nav-right-button-label-disabled' : ''}`}>{label}</text></view> : null)}
29
+ </view>}
30
+ </view>
31
+ </view>
32
+ </>;
33
+ }
34
+ export function NavbarCapsule({ onBack, onBackHome, disabled = false, className = '' }) {
35
+ return <view className={`ui-navbar-capsule ${disabled ? 'ui-navbar-disabled' : ''} ${className}`} catchtap={() => {
36
+ 'background only';
37
+ }}>
38
+ <view className="ui-navbar-capsule-button" accessibility-element accessibility-traits="button" accessibility-label="返回上级" bindtap={() => {
39
+ 'background only';
40
+ if (!disabled)
41
+ onBack?.();
42
+ }}><Icon name="left" size={18}/></view>
43
+ <view className="ui-navbar-capsule-divider"/>
44
+ <view className="ui-navbar-capsule-button" accessibility-element accessibility-traits="button" accessibility-label="返回首页" bindtap={() => {
45
+ 'background only';
46
+ if (!disabled)
47
+ onBackHome?.();
48
+ }}><Icon name="home" size={18}/></view>
49
+ </view>;
50
+ }
@@ -0,0 +1,30 @@
1
+ import type { ReactNode } from '@lynx-js/react';
2
+ import type { CSSProperties } from '@lynx-js/types';
3
+ export type NoticeBarClick = {
4
+ index: number;
5
+ text: string;
6
+ };
7
+ export type NoticeBarRef = {
8
+ reset: () => void;
9
+ };
10
+ export type NoticeBarProps = {
11
+ text?: string | readonly string[];
12
+ type?: 'warning' | 'info' | 'danger';
13
+ scrollable?: boolean;
14
+ delay?: number;
15
+ speed?: number;
16
+ closable?: boolean;
17
+ wrapable?: boolean;
18
+ direction?: 'horizontal' | 'vertical';
19
+ prefix?: ReactNode;
20
+ suffix?: ReactNode;
21
+ color?: string;
22
+ backgroundColor?: string;
23
+ children?: ReactNode;
24
+ onClose?: () => void;
25
+ onNext?: (index: number) => void;
26
+ onClick?: (event: NoticeBarClick) => void;
27
+ className?: string;
28
+ style?: CSSProperties;
29
+ };
30
+ export declare const NoticeBar: (props: NoticeBarProps & import("react").RefAttributes<NoticeBarRef>) => React.ReactElement | null;
@@ -0,0 +1,86 @@
1
+ import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from '@lynx-js/react';
2
+ import { Icon } from "./Icon.jsx";
3
+ import { useConfigProvider } from './configContext.js';
4
+ const colors = { warning: ['#f57f00', '#ffa94d'], danger: ['#f14646', '#ff6b6b'], info: ['#1c64fd', '#5b90ff'] };
5
+ export const NoticeBar = forwardRef(function NoticeBar({ text = '', type = 'warning', scrollable = true, delay = 1, speed = 50, closable = false, wrapable = false, direction = 'horizontal', prefix, suffix, color, backgroundColor, children, onClose, onNext, onClick, className = '', style }, ref) {
6
+ const [closed, setClosed] = useState(false), [revision, setRevision] = useState(0), closedRef = useRef(false);
7
+ const config = useConfigProvider(), foreground = color ?? colors[type][config.theme === 'dark' ? 1 : 0];
8
+ useImperativeHandle(ref, () => ({ reset() {
9
+ 'background only';
10
+ setRevision(value => value + 1);
11
+ } }), []);
12
+ const close = () => {
13
+ 'background only';
14
+ if (closedRef.current)
15
+ return;
16
+ closedRef.current = true;
17
+ setClosed(true);
18
+ onClose?.();
19
+ };
20
+ const items = Array.isArray(text) ? [...text] : [text];
21
+ const durationSpeed = Number.isFinite(speed) && speed > 0 ? speed : 50, wait = Number.isFinite(delay) ? Math.max(0, delay) : 1;
22
+ const multiLine = direction === 'horizontal' && !scrollable && wrapable;
23
+ if (closed)
24
+ return null;
25
+ return <view className={`ui-notice-bar ui-notice-bar-${type} ${multiLine ? 'ui-notice-bar-wrap' : ''} ${className}`} style={{ color: foreground, backgroundColor, ...style }}>
26
+ {prefix !== undefined && prefix !== null && prefix !== false ? <view className="ui-notice-bar-prefix">{typeof prefix === 'string' ? <Icon name={prefix} size={20} color={foreground}/> : prefix}</view> : null}
27
+ <NoticeContent key={JSON.stringify([items, scrollable, direction, multiLine, durationSpeed, wait, revision])} items={items} scrollable={scrollable} multiLine={multiLine} direction={direction} speed={durationSpeed} delay={wait} onNext={onNext} onClick={onClick}>{children}</NoticeContent>
28
+ {suffix !== undefined && suffix !== null ? <view className="ui-notice-bar-suffix">{typeof suffix === 'string' || typeof suffix === 'number' ? <text>{suffix}</text> : suffix}</view> : closable ? <view className="ui-notice-bar-suffix ui-notice-bar-close" catchtap={close} accessibility-element accessibility-traits="button" accessibility-label="关闭通知栏"><Icon name="close" size={20} color={foreground}/></view> : null}
29
+ </view>;
30
+ });
31
+ function NoticeContent({ items, scrollable, multiLine, direction, speed, delay, onNext, onClick, children }) {
32
+ const [index, setIndex] = useState(0), [cycle, setCycle] = useState(0), [wrapWidth, setWrapWidth] = useState(0);
33
+ const [measure, setMeasure] = useState({ index: 0, width: 0 }), [lineHeight, setLineHeight] = useState(20);
34
+ const [motion, setMotion] = useState({ offset: 0, duration: 0, delay: 0 });
35
+ const callbacks = useRef({ onNext, onClick });
36
+ callbacks.current = { onNext, onClick };
37
+ const vertical = direction === 'vertical', moving = items.length > 0 && (vertical ? items.length > 1 : scrollable), outside = cycle > 0;
38
+ const current = items[index] ?? '';
39
+ useEffect(() => {
40
+ if (!moving || wrapWidth <= 0 || (!vertical && (measure.index !== index || measure.width <= 0)))
41
+ return;
42
+ let cancelled = false, completion;
43
+ const start = vertical ? -lineHeight * index : outside ? wrapWidth + 1 : 0;
44
+ const end = vertical ? -lineHeight * (index + 1) : -measure.width;
45
+ const duration = Math.max(1, Math.abs(end - start) / speed * 1000);
46
+ setMotion({ offset: start, duration: 0, delay: 0 });
47
+ const frame = setTimeout(() => {
48
+ if (cancelled)
49
+ return;
50
+ setMotion({ offset: end, duration, delay: delay * 1000 });
51
+ completion = setTimeout(() => {
52
+ if (cancelled)
53
+ return;
54
+ const next = (index + 1) % items.length;
55
+ setMotion({ offset: vertical ? -lineHeight * next : wrapWidth + 1, duration: 0, delay: 0 });
56
+ setIndex(next);
57
+ setCycle(value => value + 1);
58
+ callbacks.current.onNext?.(next);
59
+ }, duration + delay * 1000);
60
+ }, 32);
61
+ return () => { cancelled = true; clearTimeout(frame); clearTimeout(completion); };
62
+ }, [moving, vertical, index, cycle, wrapWidth, measure.index, measure.width, lineHeight, speed, delay, children]);
63
+ const click = () => {
64
+ 'background only';
65
+ callbacks.current.onClick?.({ index, text: current });
66
+ };
67
+ const label = (value, key) => <text key={key} className="ui-notice-bar-label" text-maxline={multiLine ? undefined : '1'} text-overflow={moving && !vertical ? 'clip' : 'ellipsis'} bindlayoutchange={vertical && key === 0 ? event => {
68
+ 'background only';
69
+ if (event.detail.height > 0)
70
+ setLineHeight(event.detail.height);
71
+ } : undefined}>{value}</text>;
72
+ return <view className={`ui-notice-bar-viewport ${multiLine ? 'ui-notice-bar-viewport-wrap' : ''}`} flatten={false} bindlayoutchange={event => {
73
+ 'background only';
74
+ if (event.detail.width > 0)
75
+ setWrapWidth(event.detail.width);
76
+ }}>
77
+ <view key={index} accessibility-element accessibility-label={current} className={`ui-notice-bar-content ${moving && !vertical ? 'ui-notice-bar-marquee' : ''} ${vertical ? 'ui-notice-bar-vertical' : ''}`} flatten={false} style={moving ? { transform: `${vertical ? 'translateY' : 'translateX'}(${motion.offset}px)`, transitionProperty: 'transform', transitionDuration: `${motion.duration}ms`, transitionDelay: `${motion.delay}ms`, transitionTimingFunction: 'linear' } : undefined} bindlayoutchange={!vertical ? event => {
78
+ 'background only';
79
+ const width = event.detail.width;
80
+ if (Number.isFinite(width) && width > 0)
81
+ setMeasure(previous => previous.index === index && previous.width === width ? previous : { index, width });
82
+ } : undefined} bindtap={click}>
83
+ {vertical ? [...items, ...(items.length > 1 ? [items[0]] : [])].map((item, key) => label(item, key)) : children === undefined ? label(current) : typeof children === 'string' || typeof children === 'number' ? <text className="ui-notice-bar-label" text-maxline={multiLine ? undefined : '1'} text-overflow="ellipsis">{children}</text> : children}
84
+ </view>
85
+ </view>;
86
+ }
@@ -0,0 +1,34 @@
1
+ import type { ReactNode } from '@lynx-js/react';
2
+ import type { CSSProperties, TouchEvent } from '@lynx-js/types';
3
+ export type NotifyType = 'primary' | 'success' | 'warning' | 'danger';
4
+ export type NotifyPosition = 'top' | 'bottom';
5
+ export type NotifyVariant = 'filled' | 'floating';
6
+ export type NotifyOptions = {
7
+ type?: NotifyType;
8
+ message?: string | number;
9
+ duration?: number;
10
+ position?: NotifyPosition;
11
+ color?: string;
12
+ background?: string;
13
+ zIndex?: number;
14
+ safeHeight?: number | string;
15
+ safeAreaBottom?: number;
16
+ rootPortal?: boolean;
17
+ closable?: boolean;
18
+ variant?: NotifyVariant;
19
+ className?: string;
20
+ style?: CSSProperties;
21
+ onClick?: (event: TouchEvent) => void;
22
+ onOpened?: () => void;
23
+ onClosed?: () => void;
24
+ };
25
+ export type NotifyProps = NotifyOptions & {
26
+ visible?: boolean;
27
+ onChange?: (visible: boolean) => void;
28
+ requestKey?: number;
29
+ options?: NotifyOptions;
30
+ children?: ReactNode;
31
+ prefix?: ReactNode;
32
+ renderClose?: (close: () => void) => ReactNode;
33
+ };
34
+ export declare function Notify({ visible, onChange, requestKey, options, children, prefix, renderClose, ...defaults }: NotifyProps): import("@lynx-js/react").JSX.Element;
@@ -0,0 +1,52 @@
1
+ import { useEffect, useRef } from '@lynx-js/react';
2
+ import { Icon } from "./Icon.jsx";
3
+ import { RootPortal } from "./RootPortal.jsx";
4
+ import { Transition } from "./Transition.jsx";
5
+ import { useConfigProvider } from './configContext.js';
6
+ function safeLength(value) {
7
+ if (typeof value === 'number')
8
+ return `${Number.isFinite(value) ? Math.max(0, value) : 0}px`;
9
+ const text = value.trim();
10
+ if (/^-?\d+(\.\d+)?$/.test(text))
11
+ return `${Math.max(0, Number(text))}px`;
12
+ const rpx = /^(-?\d+(\.\d+)?)rpx$/.exec(text);
13
+ return rpx ? `${Math.max(0, Number(rpx[1])) / 7.5}vw` : text || '0px';
14
+ }
15
+ const icons = { primary: 'info-circle-fill', success: 'check-circle-fill', danger: 'close-circle-fill', warning: 'exclamation-circle-fill' };
16
+ const palette = { primary: ['#1c64fd', '#5b90ff'], success: ['#12b886', '#20c997'], danger: ['#f14646', '#ff6b6b'], warning: ['#f57f00', '#ffa94d'] };
17
+ export function Notify({ visible = false, onChange, requestKey = 0, options, children, prefix, renderClose, ...defaults }) {
18
+ const { type = 'danger', message = '', duration = 3000, position = 'top', color, background, zIndex = 99, safeHeight = 0, safeAreaBottom = 0, rootPortal = false, closable = false, variant = 'filled', className = '', style, onClick, onOpened, onClosed } = { ...defaults, ...options };
19
+ const config = useConfigProvider(), callbacks = useRef({ onChange, onClick, onOpened, onClosed }), closing = useRef(false);
20
+ callbacks.current = { onChange, onClick, onOpened, onClosed };
21
+ const close = () => {
22
+ 'background only';
23
+ if (!visible || closing.current)
24
+ return;
25
+ closing.current = true;
26
+ callbacks.current.onChange?.(false);
27
+ };
28
+ useEffect(() => {
29
+ closing.current = false;
30
+ if (!visible || !Number.isFinite(duration) || duration <= 0)
31
+ return;
32
+ const timer = setTimeout(close, duration);
33
+ return () => clearTimeout(timer);
34
+ }, [visible, requestKey, duration]);
35
+ const statusColor = config.tokens[`--cso-ui-${type}`] ?? palette[type][config.theme === 'dark' ? 1 : 0];
36
+ const foreground = color ?? (variant === 'floating' ? config.tokens['--cso-ui-text'] ?? (config.theme === 'dark' ? '#f7f8fa' : '#1d1f29') : statusColor);
37
+ const floating = variant === 'floating';
38
+ const layer = <view className={`ui-notify-anchor ui-notify-anchor-${position} ${floating ? 'ui-notify-anchor-floating' : ''}`} style={{ zIndex, ...(position === 'top' ? { top: safeLength(safeHeight) } : { bottom: `${Number.isFinite(safeAreaBottom) ? Math.max(0, safeAreaBottom) : 0}px` }) }} event-through>
39
+ <Transition show={visible} name={position === 'top' ? 'slide-down' : 'slide-up'} duration={300} lazyRender destroy={false} className={`ui-notify ui-notify-${type} ${floating ? 'ui-notify-floating' : ''} ${className}`} style={{ color, backgroundColor: background, ...style }} onAfterEnter={() => callbacks.current.onOpened?.()} onAfterLeave={() => callbacks.current.onClosed?.()}>
40
+ <view className="ui-notify-body" bindtap={event => {
41
+ 'background only';
42
+ if (visible && !closing.current)
43
+ callbacks.current.onClick?.(event);
44
+ }} accessibility-element={children === undefined || typeof children === 'string'} accessibility-label={children === undefined ? String(message) : typeof children === 'string' ? children : undefined}>
45
+ {prefix === null ? null : <view className="ui-notify-prefix">{prefix ?? <Icon name={icons[type]} size={18} color={color ?? statusColor}/>}</view>}
46
+ <view className="ui-notify-content">{children ?? <text className="ui-notify-message" text-maxline="1" text-overflow="ellipsis">{String(message)}</text>}</view>
47
+ {closable ? <view className="ui-notify-close" catchtap={close} accessibility-element accessibility-traits="button" accessibility-label="关闭通知">{renderClose ? renderClose(close) : <Icon name="close" size={18} color={foreground}/>}</view> : null}
48
+ </view>
49
+ </Transition>
50
+ </view>;
51
+ return rootPortal ? <RootPortal>{layer}</RootPortal> : layer;
52
+ }
@@ -0,0 +1,11 @@
1
+ type NumberStepperProps = {
2
+ value: string;
3
+ onChange: (value: string) => void;
4
+ onBlur?: () => void;
5
+ min?: number;
6
+ max?: number;
7
+ step?: number;
8
+ disabled?: boolean;
9
+ };
10
+ export declare function NumberStepper({ value, onChange, onBlur, min, max, step, disabled }: NumberStepperProps): import("@lynx-js/react").JSX.Element;
11
+ export {};