@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,41 @@
1
+ import { useEffect } from '@lynx-js/react';
2
+ import { SyncedInput } from "./SyncedInput.jsx";
3
+ function numericValue(value, fallback) {
4
+ const parsed = Number(value);
5
+ return value !== '' && Number.isFinite(parsed) ? parsed : fallback;
6
+ }
7
+ export function NumberStepper({ value, onChange, onBlur, min = 0, max = Number.MAX_SAFE_INTEGER, step = 1, disabled = false }) {
8
+ const precision = (String(step).split('.')[1] ?? '').length;
9
+ useEffect(() => {
10
+ if (value === '')
11
+ onChange(min.toFixed(precision));
12
+ }, []);
13
+ const current = numericValue(value, min);
14
+ const decreaseDisabled = disabled || current <= min;
15
+ const increaseDisabled = disabled || current >= max;
16
+ const update = (next) => {
17
+ const factor = 10 ** precision;
18
+ const bounded = Math.min(max, Math.max(min, next));
19
+ onChange((Math.round(bounded * factor) / factor).toFixed(precision));
20
+ };
21
+ const normalize = () => {
22
+ update(numericValue(value, min));
23
+ onBlur?.();
24
+ };
25
+ return <view className={`number-stepper ${disabled ? 'number-stepper-disabled' : ''}`}>
26
+ <view className={`number-stepper-button ${decreaseDisabled ? 'number-stepper-button-disabled' : ''}`} bindtap={() => { if (!decreaseDisabled)
27
+ update(current - step); }}><text>−</text></view>
28
+ <SyncedInput className="number-stepper-input" value={value} maxlength={precision ? undefined : String(Math.max(Math.abs(min), Math.abs(max))).length} onInput={next => {
29
+ if (disabled)
30
+ return;
31
+ if (!precision) {
32
+ onChange(next.replace(/[^0-9]/g, ''));
33
+ return;
34
+ }
35
+ if (/^-?\d*(\.\d*)?$/.test(next))
36
+ onChange(next);
37
+ }} onBlur={normalize}/>
38
+ <view className={`number-stepper-button ${increaseDisabled ? 'number-stepper-button-disabled' : ''}`} bindtap={() => { if (!increaseDisabled)
39
+ update(current + step); }}><text>+</text></view>
40
+ </view>;
41
+ }
@@ -0,0 +1,16 @@
1
+ import type { ReactNode } from '@lynx-js/react';
2
+ import type { CSSProperties } from '@lynx-js/types';
3
+ import type { TransitionProps } from "./Transition.jsx";
4
+ export type LayerLifecycle = Pick<TransitionProps, 'onBeforeEnter' | 'onEnter' | 'onAfterEnter' | 'onBeforeLeave' | 'onLeave' | 'onAfterLeave'>;
5
+ export type OverlayProps = LayerLifecycle & {
6
+ show?: boolean;
7
+ duration?: TransitionProps['duration'];
8
+ lockScroll?: boolean;
9
+ zIndex?: number;
10
+ rootPortal?: boolean;
11
+ children?: ReactNode;
12
+ className?: string;
13
+ style?: CSSProperties;
14
+ onTap?: () => void;
15
+ };
16
+ export declare function Overlay({ show, duration, lockScroll, zIndex, rootPortal, children, className, style, onTap, ...lifecycle }: OverlayProps): import("@lynx-js/react").JSX.Element;
@@ -0,0 +1,12 @@
1
+ import { RootPortal } from "./RootPortal.jsx";
2
+ import { Transition } from "./Transition.jsx";
3
+ export function Overlay({ show = false, duration = 300, lockScroll = true, zIndex = 10, rootPortal = false, children, className = '', style, onTap, ...lifecycle }) {
4
+ const layer = <Transition {...lifecycle} show={show} duration={duration} name="fade" lazyRender destroy={false} interactiveDuringLeave className={`ui-overlay ${className}`} style={{ zIndex, ...style }} onTap={() => {
5
+ 'background only';
6
+ if (show)
7
+ onTap?.();
8
+ }}>
9
+ <view className="ui-overlay-content" event-through={false} consume-slide-event={lockScroll ? [[-180, 180]] : undefined} catchtouchmove={lockScroll ? () => { } : undefined}>{children}</view>
10
+ </Transition>;
11
+ return rootPortal ? <RootPortal>{layer}</RootPortal> : layer;
12
+ }
@@ -0,0 +1,13 @@
1
+ import { type FeedListRef } from '@lynx-js/lynx-ui';
2
+ import type { ReactElement, ReactNode, RefObject } from '@lynx-js/react';
3
+ /** The platform refresh element owns pull distance, threshold, pinning and rebound. */
4
+ export declare function PagedList({ listId, listRef, refreshing, onRefresh, onLoadMore, onLayoutComplete, footer, children }: {
5
+ listId: string;
6
+ listRef: RefObject<FeedListRef | null>;
7
+ refreshing: boolean;
8
+ onRefresh: () => void;
9
+ onLoadMore: () => void;
10
+ onLayoutComplete?: () => void;
11
+ footer: ReactElement | null;
12
+ children: ReactNode;
13
+ }): import("@lynx-js/react").JSX.Element;
@@ -0,0 +1,36 @@
1
+ import { FeedList } from '@lynx-js/lynx-ui';
2
+ import { useEffect, useMemo, useRef } from '@lynx-js/react';
3
+ const REFRESH_SPINNER_URL = 'https://lf-lynx.tiktok-cdns.com/obj/lynx-artifacts-oss-sg/plugin/static/loading.gif';
4
+ /** The platform refresh element owns pull distance, threshold, pinning and rebound. */
5
+ export function PagedList({ listId, listRef, refreshing, onRefresh, onLoadMore, onLayoutComplete, footer, children }) {
6
+ const pending = useRef(false);
7
+ const refreshHeader = useMemo(() => <view className="native-refresh-header">
8
+ <image className="native-refresh-spinner" src={REFRESH_SPINNER_URL} mode="aspectFit"/>
9
+ <text className="native-refresh-label">正在刷新</text>
10
+ </view>, []);
11
+ useEffect(() => {
12
+ // Initial data loading is not a refresh gesture. Only finish a refresh
13
+ // after onStartRefresh has actually fired, matching the official demo.
14
+ if (!refreshing && pending.current) {
15
+ pending.current = false;
16
+ listRef.current?.finishRefresh();
17
+ }
18
+ }, [refreshing, listRef]);
19
+ return <view className="data-list-body" flatten={false}>
20
+ <FeedList listId={listId} ref={listRef} listType="single" spanCount={1} scrollOrientation="vertical" useRefactorList={true} bounces={true} style={{ width: '100%', height: '100%' }} refreshOptions={{
21
+ enableRefresh: true,
22
+ mode: 'native',
23
+ headerContent: refreshHeader,
24
+ onStartRefresh: () => {
25
+ if (pending.current)
26
+ return;
27
+ pending.current = true;
28
+ if (!refreshing)
29
+ onRefresh();
30
+ },
31
+ }} onLayoutComplete={onLayoutComplete} onScrollToLower={onLoadMore}>
32
+ {children}
33
+ {footer}
34
+ </FeedList>
35
+ </view>;
36
+ }
@@ -0,0 +1,29 @@
1
+ import type { ReactNode } from '@lynx-js/react';
2
+ export type PaginationRenderState = {
3
+ value: number;
4
+ totalPage: number;
5
+ total?: number;
6
+ pageSize: number;
7
+ prev: () => void;
8
+ next: () => void;
9
+ };
10
+ export type PaginationProps = {
11
+ value?: number;
12
+ defaultValue?: number;
13
+ onChange?: (value: number) => void;
14
+ total?: number;
15
+ totalPage?: number;
16
+ pageSize?: number;
17
+ prevText?: string;
18
+ nextText?: string;
19
+ showIcon?: boolean;
20
+ showMessage?: boolean;
21
+ hideIfOnePage?: boolean;
22
+ buttonVariant?: 'text' | 'plain' | 'dashed' | 'base';
23
+ renderPrev?: (state: PaginationRenderState) => ReactNode;
24
+ renderNext?: (state: PaginationRenderState) => ReactNode;
25
+ renderSize?: (state: PaginationRenderState) => ReactNode;
26
+ renderMessage?: (state: PaginationRenderState) => ReactNode;
27
+ className?: string;
28
+ };
29
+ export declare function Pagination({ value, defaultValue, onChange, total, totalPage, pageSize, prevText, nextText, showIcon, showMessage, hideIfOnePage, buttonVariant, renderPrev, renderNext, renderSize, renderMessage, className }: PaginationProps): import("@lynx-js/react").JSX.Element | null;
@@ -0,0 +1,33 @@
1
+ import { useState } from '@lynx-js/react';
2
+ import { Button } from "./Button.jsx";
3
+ import { paginationState } from './paginationModel.js';
4
+ export function Pagination({ value, defaultValue = 1, onChange, total, totalPage, pageSize = 10, prevText = '上一页', nextText = '下一页', showIcon = false, showMessage = false, hideIfOnePage = true, buttonVariant = 'text', renderPrev, renderNext, renderSize, renderMessage, className = '' }) {
5
+ const [inner, setInner] = useState(defaultValue);
6
+ const state = paginationState(value ?? inner, total, totalPage, pageSize);
7
+ const change = (next) => {
8
+ 'background only';
9
+ if (next < 1 || next > state.pages || next === state.page)
10
+ return;
11
+ if (value === undefined)
12
+ setInner(next);
13
+ onChange?.(next);
14
+ };
15
+ const renderState = { value: state.page, totalPage: state.pages, total: state.total, pageSize: state.pageSize, prev: () => {
16
+ 'background only';
17
+ change(state.page - 1);
18
+ }, next: () => {
19
+ 'background only';
20
+ change(state.page + 1);
21
+ } };
22
+ if (hideIfOnePage && state.pages === 1)
23
+ return null;
24
+ const variant = buttonVariant === 'base' ? 'solid' : buttonVariant;
25
+ return <view className={`ui-pagination ${className}`}>
26
+ <view className="ui-pagination-content">
27
+ {renderPrev ? renderPrev(renderState) : <Button size="small" tone="info" variant={variant} className={`ui-pagination-nav ${showIcon ? 'ui-pagination-icon-nav' : ''}`} label={showIcon ? undefined : prevText} icon={showIcon ? <view className="ui-pagination-arrow ui-pagination-arrow-left"><view /></view> : undefined} accessibilityLabel={prevText} disabled={state.page <= 1} onTap={renderState.prev}/>}
28
+ <view className="ui-pagination-size">{renderSize ? renderSize(renderState) : <><text className="ui-pagination-current">{state.page}</text><text className="ui-pagination-separator">/</text><text className="ui-pagination-total">{state.pages}</text></>}</view>
29
+ {renderNext ? renderNext(renderState) : <Button size="small" tone="primary" variant={variant} className={`ui-pagination-nav ${showIcon ? 'ui-pagination-icon-nav' : ''}`} label={showIcon ? undefined : nextText} icon={showIcon ? <view className="ui-pagination-arrow ui-pagination-arrow-right"><view /></view> : undefined} accessibilityLabel={nextText} disabled={state.page >= state.pages} onTap={renderState.next}/>}
30
+ </view>
31
+ {showMessage ? renderMessage ? renderMessage(renderState) : <text className="ui-pagination-message">{`当前页:${state.page},${state.total !== undefined ? `当前数据:${state.total}条,` : ''}分页大小:${state.pageSize}`}</text> : null}
32
+ </view>;
33
+ }
@@ -0,0 +1,16 @@
1
+ import type { CSSProperties, CommonEvent } from '@lynx-js/types';
2
+ export type PasswordInputProps = {
3
+ value?: string;
4
+ mask?: boolean;
5
+ info?: string;
6
+ errorInfo?: string;
7
+ gutter?: number | string;
8
+ length?: number;
9
+ focused?: boolean;
10
+ disabled?: boolean;
11
+ onFocus?: (event: CommonEvent) => void;
12
+ className?: string;
13
+ style?: CSSProperties;
14
+ };
15
+ /** Display only: pair with a controlled Keyboard to handle input. */
16
+ export declare function PasswordInput({ value, mask, info, errorInfo, gutter, length, focused, disabled: disabledProp, onFocus, className, style }: PasswordInputProps): import("@lynx-js/react").JSX.Element;
@@ -0,0 +1,20 @@
1
+ import { useContext } from '@lynx-js/react';
2
+ import { FormFieldContext } from './formContext.js';
3
+ import { passwordGutter, passwordLength } from './passwordInputModel.js';
4
+ /** Display only: pair with a controlled Keyboard to handle input. */
5
+ export function PasswordInput({ value = '', mask = true, info = '', errorInfo = '', gutter = 0, length = 6, focused = true, disabled: disabledProp, onFocus, className = '', style }) {
6
+ const field = useContext(FormFieldContext), disabled = disabledProp ?? field?.disabled ?? false;
7
+ const count = passwordLength(length), gap = passwordGutter(gutter), characters = Array.from(value).slice(0, count);
8
+ return <view className={`ui-password-input ${disabled ? 'ui-password-input-disabled' : ''} ${className}`} style={style}>
9
+ <view className="ui-password-input-security" accessibility-element accessibility-traits={disabled ? 'none' : 'button'} accessibility-label={`${mask ? '密码' : '验证码'},已输入${characters.length}位,共${count}位${mask || !characters.length ? '' : `,${characters.join('')}`}${disabled ? ',已禁用' : ''}`} bindtap={(event) => {
10
+ 'background only';
11
+ if (!disabled)
12
+ onFocus?.(event);
13
+ }}>
14
+ {Array.from({ length: count }, (_, index) => <view key={index} className={`ui-password-input-item ${gap.spaced ? '' : 'ui-password-input-bordered'} ${index === 0 ? 'ui-password-input-first' : ''} ${index === count - 1 ? 'ui-password-input-last' : ''}`} style={index > 0 && gap.spaced ? { marginLeft: gap.value } : undefined}>
15
+ {focused && !disabled && index === characters.length ? <view className="ui-password-input-cursor"/> : characters[index] ? mask ? <view className="ui-password-input-dot"/> : <text className="ui-password-input-value">{characters[index]}</text> : null}
16
+ </view>)}
17
+ </view>
18
+ {errorInfo || info ? <text className={`ui-password-input-info ${errorInfo ? 'ui-password-input-error' : ''}`} accessibility-element accessibility-label={errorInfo || info}>{errorInfo || info}</text> : null}
19
+ </view>;
20
+ }
@@ -0,0 +1,61 @@
1
+ import type { ReactNode } from '@lynx-js/react';
2
+ import type { PickerViewProps } from "./PickerView.jsx";
3
+ import type { PickerChange, PickerValue } from './pickerModel.js';
4
+ export { PickerView } from "./PickerView.jsx";
5
+ export type { PickerViewProps, PickerViewRef } from "./PickerView.jsx";
6
+ export { pickerColumns, pickerSelection } from './pickerModel.js';
7
+ export type { PickerChange, PickerValue, PickerOption, PickerColumnItem, PickerColumns, PickerFieldNames } from './pickerModel.js';
8
+ export type PickerProps = PickerViewProps & {
9
+ visible?: boolean;
10
+ onVisibleChange?: (visible: boolean) => void;
11
+ title?: ReactNode;
12
+ confirmButtonText?: string;
13
+ cancelButtonText?: string;
14
+ beforeConfirm?: (value: PickerValue[]) => boolean | Promise<boolean>;
15
+ onConfirm?: (event: PickerChange) => void;
16
+ onCancel?: () => void;
17
+ onClose?: () => void;
18
+ onOpen?: () => void;
19
+ closeOnClickModal?: boolean;
20
+ safeAreaInsetBottom?: boolean;
21
+ viewClassName?: string;
22
+ zIndex?: number;
23
+ rootPortal?: boolean;
24
+ safeAreaBottom?: number;
25
+ };
26
+ export type PickerRef = {
27
+ open: () => void;
28
+ close: () => void;
29
+ };
30
+ export declare const Picker: (props: import("./pickerModel.js").PickerFieldNames & {
31
+ value?: readonly PickerValue[];
32
+ columns: import("./pickerModel.js").PickerColumns;
33
+ cascade?: boolean;
34
+ itemHeight?: number;
35
+ visibleItemCount?: number;
36
+ immediateChange?: boolean;
37
+ disabled?: boolean;
38
+ loading?: boolean;
39
+ onChange?: (event: PickerChange) => void;
40
+ onPickStart?: () => void;
41
+ onPickEnd?: () => void;
42
+ className?: string;
43
+ style?: import("@lynx-js/types").CSSProperties;
44
+ } & {
45
+ visible?: boolean;
46
+ onVisibleChange?: (visible: boolean) => void;
47
+ title?: ReactNode;
48
+ confirmButtonText?: string;
49
+ cancelButtonText?: string;
50
+ beforeConfirm?: (value: PickerValue[]) => boolean | Promise<boolean>;
51
+ onConfirm?: (event: PickerChange) => void;
52
+ onCancel?: () => void;
53
+ onClose?: () => void;
54
+ onOpen?: () => void;
55
+ closeOnClickModal?: boolean;
56
+ safeAreaInsetBottom?: boolean;
57
+ viewClassName?: string;
58
+ zIndex?: number;
59
+ rootPortal?: boolean;
60
+ safeAreaBottom?: number;
61
+ } & import("react").RefAttributes<PickerRef>) => React.ReactElement | null;
@@ -0,0 +1,80 @@
1
+ import { forwardRef, useContext, useEffect, useImperativeHandle, useMemo, useRef, useState } from '@lynx-js/react';
2
+ import { Popup } from "./Popup.jsx";
3
+ import { FormFieldContext } from './formContext.js';
4
+ import { Loading } from "./Loading.jsx";
5
+ import { PickerView } from "./PickerView.jsx";
6
+ import { pickerSelection } from './pickerModel.js';
7
+ export { PickerView } from "./PickerView.jsx";
8
+ export { pickerColumns, pickerSelection } from './pickerModel.js';
9
+ export const Picker = forwardRef(function Picker({ visible, onVisibleChange, title = '', confirmButtonText = '完成', cancelButtonText = '取消', beforeConfirm, onConfirm, onCancel, onClose, onOpen, closeOnClickModal = true, safeAreaInsetBottom = true, viewClassName, zIndex = 100, rootPortal = false, safeAreaBottom = 0, ...props }, ref) {
10
+ const field = useContext(FormFieldContext), disabled = props.disabled ?? field?.disabled ?? false;
11
+ const [innerVisible, setInnerVisible] = useState(false), show = visible ?? innerVisible;
12
+ const [draft, setDraft] = useState([]), [busy, setBusy] = useState(false);
13
+ const sequence = useRef(0), pending = useRef(false), view = useRef(null), openCallback = useRef(onOpen);
14
+ openCallback.current = onOpen;
15
+ const snapshot = useMemo(() => ({ show, value: props.value, columns: props.columns, cascade: props.cascade, valueKey: props.valueKey, labelKey: props.labelKey, childrenKey: props.childrenKey, disabled, loading: props.loading }), [show, props.value, props.columns, props.cascade, props.valueKey, props.labelKey, props.childrenKey, disabled, props.loading]);
16
+ const latest = useRef(snapshot);
17
+ latest.current = snapshot;
18
+ useEffect(() => { sequence.current++; pending.current = false; setBusy(false); if (show)
19
+ setDraft(pickerSelection(props).value); }, [snapshot]);
20
+ useEffect(() => { if (show)
21
+ openCallback.current?.(); }, [show]);
22
+ useEffect(() => () => { sequence.current++; }, []);
23
+ const changeVisible = (next) => {
24
+ 'background only';
25
+ if (visible === undefined)
26
+ setInnerVisible(next);
27
+ onVisibleChange?.(next);
28
+ };
29
+ const close = () => {
30
+ 'background only';
31
+ sequence.current++;
32
+ pending.current = false;
33
+ setBusy(false);
34
+ if (show) {
35
+ changeVisible(false);
36
+ onClose?.();
37
+ }
38
+ };
39
+ const cancel = () => {
40
+ 'background only';
41
+ if (!show)
42
+ return;
43
+ onCancel?.();
44
+ close();
45
+ };
46
+ useImperativeHandle(ref, () => ({ open: () => {
47
+ 'background only';
48
+ if (!disabled && !show)
49
+ changeVisible(true);
50
+ }, close }), [show, disabled, visible, onVisibleChange, onClose]);
51
+ const confirm = async () => {
52
+ 'background only';
53
+ if (!show || pending.current || disabled || props.loading)
54
+ return;
55
+ const selected = view.current?.getSelected() ?? pickerSelection({ ...props, value: draft }), ticket = ++sequence.current, source = latest.current;
56
+ pending.current = true;
57
+ setBusy(true);
58
+ try {
59
+ if (!await (beforeConfirm?.(selected.value) ?? true) || ticket !== sequence.current || source !== latest.current)
60
+ return;
61
+ props.onChange?.(selected);
62
+ onConfirm?.(selected);
63
+ close();
64
+ }
65
+ catch { /* Rejection preserves the draft so the user can try again. */ }
66
+ finally {
67
+ if (ticket === sequence.current) {
68
+ pending.current = false;
69
+ setBusy(false);
70
+ }
71
+ }
72
+ };
73
+ return <Popup show={show} onClose={cancel} closeOnClickModal={closeOnClickModal} position="bottom" zIndex={zIndex} rootPortal={rootPortal} safeAreaInsetBottom={safeAreaInsetBottom} safeAreaBottom={safeAreaBottom} round className="ui-picker">
74
+ <view className="ui-picker-toolbar"><text className="ui-picker-cancel" bindtap={cancel}>{cancelButtonText}</text><view className="ui-picker-title">{typeof title === 'string' ? <text>{title}</text> : title}</view><view className="ui-picker-confirm" accessibility-element accessibility-label={confirmButtonText} bindtap={() => void confirm()}>{busy ? <Loading size={16}/> : <text>{confirmButtonText}</text>}</view></view>
75
+ <PickerView {...props} ref={view} className={[props.className, viewClassName].filter(Boolean).join(' ')} value={draft} disabled={disabled || busy} onChange={event => {
76
+ 'background only';
77
+ setDraft(event.value);
78
+ }}/>
79
+ </Popup>;
80
+ });
@@ -0,0 +1,43 @@
1
+ import type { CSSProperties } from '@lynx-js/types';
2
+ import type { PickerChange, PickerColumns, PickerFieldNames, PickerOption, PickerValue } from './pickerModel.js';
3
+ export type PickerViewProps = PickerFieldNames & {
4
+ value?: readonly PickerValue[];
5
+ columns: PickerColumns;
6
+ cascade?: boolean;
7
+ itemHeight?: number;
8
+ visibleItemCount?: number;
9
+ immediateChange?: boolean;
10
+ disabled?: boolean;
11
+ loading?: boolean;
12
+ onChange?: (event: PickerChange) => void;
13
+ onPickStart?: () => void;
14
+ onPickEnd?: () => void;
15
+ className?: string;
16
+ style?: CSSProperties;
17
+ };
18
+ export type PickerViewRef = {
19
+ getSelected: () => PickerChange;
20
+ getSelectedOptions: () => PickerOption[];
21
+ getSelectedValues: () => PickerValue[];
22
+ getSelectedLabels: () => string[];
23
+ getSelectedIndex: () => number[];
24
+ getColumnsData: () => readonly (readonly PickerOption[])[];
25
+ getColumnData: (index: number) => readonly PickerOption[];
26
+ getColumnIndex: (index: number) => number;
27
+ resetColumns: (columns: PickerColumns) => void;
28
+ };
29
+ export declare const PickerView: (props: PickerFieldNames & {
30
+ value?: readonly PickerValue[];
31
+ columns: PickerColumns;
32
+ cascade?: boolean;
33
+ itemHeight?: number;
34
+ visibleItemCount?: number;
35
+ immediateChange?: boolean;
36
+ disabled?: boolean;
37
+ loading?: boolean;
38
+ onChange?: (event: PickerChange) => void;
39
+ onPickStart?: () => void;
40
+ onPickEnd?: () => void;
41
+ className?: string;
42
+ style?: CSSProperties;
43
+ } & import("react").RefAttributes<PickerViewRef>) => React.ReactElement | null;
@@ -0,0 +1,142 @@
1
+ import { forwardRef, useContext, useEffect, useImperativeHandle, useMemo, useRef, useState } from '@lynx-js/react';
2
+ import { Loading } from "./Loading.jsx";
3
+ import { FormFieldContext } from './formContext.js';
4
+ import { nearestPickerIndex, normalizePickerColumns, resolvePickerColumns, pickerSelection } from './pickerModel.js';
5
+ const Column = forwardRef(function Column({ items, index, row, count, disabled, immediate, onSelect, onStart, onEnd }, handle) {
6
+ const node = useRef(null), timer = useRef(), offset = useRef(Math.max(0, index) * row);
7
+ const dragging = useRef(false), moving = useRef(false), target = useRef(null), selected = useRef(index);
8
+ const scrollTo = (next, smooth) => {
9
+ 'background only';
10
+ target.current = next * row;
11
+ offset.current = next * row;
12
+ node.current?.invoke({ method: 'scrollTo', params: { offset: next * row, smooth } }).exec();
13
+ };
14
+ useEffect(() => {
15
+ clearTimeout(timer.current);
16
+ dragging.current = false;
17
+ moving.current = false;
18
+ selected.current = index;
19
+ scrollTo(Math.max(0, index), false);
20
+ return () => clearTimeout(timer.current);
21
+ }, [items, row, disabled]);
22
+ useEffect(() => { if (selected.current !== index) {
23
+ selected.current = index;
24
+ scrollTo(Math.max(0, index), false);
25
+ } }, [index]);
26
+ useImperativeHandle(handle, () => ({ getIndex: () => nearestPickerIndex(items, offset.current / row) }), [items, row]);
27
+ const end = () => {
28
+ 'background only';
29
+ if (moving.current) {
30
+ moving.current = false;
31
+ onEnd?.();
32
+ }
33
+ };
34
+ const settle = (smooth = true) => {
35
+ 'background only';
36
+ clearTimeout(timer.current);
37
+ if (disabled)
38
+ return;
39
+ const next = nearestPickerIndex(items, offset.current / row);
40
+ if (next >= 0) {
41
+ scrollTo(next, smooth);
42
+ if (selected.current !== next) {
43
+ selected.current = next;
44
+ onSelect(next);
45
+ }
46
+ }
47
+ end();
48
+ };
49
+ return <scroll-view ref={node} className="ui-picker-column" scroll-orientation="vertical" scroll-bar-enable={false} enable-scroll={!disabled} bounces={false} enable-nested-scroll force-can-scroll initial-scroll-offset={Math.max(0, index) * row} bindtouchstart={() => {
50
+ 'background only';
51
+ if (disabled)
52
+ return;
53
+ clearTimeout(timer.current);
54
+ target.current = null;
55
+ dragging.current = true;
56
+ }} bindtouchend={() => {
57
+ 'background only';
58
+ dragging.current = false;
59
+ if (immediate)
60
+ settle(false);
61
+ else
62
+ timer.current = setTimeout(() => settle(), 160);
63
+ }} bindtouchcancel={() => {
64
+ 'background only';
65
+ dragging.current = false;
66
+ settle(false);
67
+ }} bindscroll={event => {
68
+ 'background only';
69
+ if (disabled)
70
+ return;
71
+ offset.current = event.detail.scrollTop;
72
+ if (target.current !== null) {
73
+ if (Math.abs(offset.current - target.current) < .5)
74
+ target.current = null;
75
+ return;
76
+ }
77
+ if (!moving.current) {
78
+ moving.current = true;
79
+ onStart?.();
80
+ }
81
+ clearTimeout(timer.current);
82
+ if (!dragging.current)
83
+ timer.current = setTimeout(() => settle(), 160);
84
+ }} bindscrollend={() => {
85
+ 'background only';
86
+ if (target.current !== null) {
87
+ target.current = null;
88
+ return;
89
+ }
90
+ if (!dragging.current)
91
+ settle();
92
+ }}>
93
+ <view style={{ paddingTop: `${(count - 1) * row / 2}px`, paddingBottom: `${(count - 1) * row / 2}px` }}>
94
+ {items.map((item, i) => <view key={`${typeof item.value}:${item.value}:${i}`} className={`ui-picker-option ${i === index ? 'ui-picker-option-selected' : ''} ${item.disabled ? 'ui-picker-option-disabled' : ''}`} style={{ height: `${row}px` }} bindtap={() => {
95
+ 'background only';
96
+ if (disabled || item.disabled)
97
+ return;
98
+ clearTimeout(timer.current);
99
+ selected.current = i;
100
+ scrollTo(i, true);
101
+ if (i !== index)
102
+ onSelect(i);
103
+ end();
104
+ }}><text text-maxline="1">{item.label}</text></view>)}
105
+ </view>
106
+ </scroll-view>;
107
+ });
108
+ export const PickerView = forwardRef(function PickerView({ value, columns, cascade = false, itemHeight = 44, visibleItemCount = 6, valueKey, labelKey, childrenKey, immediateChange = false, disabled: disabledProp, loading = false, onChange, onPickStart, onPickEnd, className = '', style }, ref) {
109
+ const field = useContext(FormFieldContext), disabled = disabledProp ?? field?.disabled ?? false;
110
+ const [inner, setInner] = useState([]), [override, setOverride] = useState();
111
+ const columnRefs = useRef([]), current = value ?? inner, source = override?.source === columns ? override.columns : columns;
112
+ const row = Number.isFinite(itemHeight) ? Math.max(1, itemHeight) : 44, count = Number.isFinite(visibleItemCount) ? Math.max(1, Math.trunc(visibleItemCount)) : 6;
113
+ const model = useMemo(() => ({ columns: source, value: current, cascade, valueKey, labelKey, childrenKey }), [source, current, cascade, valueKey, labelKey, childrenKey]);
114
+ const selection = useMemo(() => pickerSelection(model), [model]);
115
+ const normalized = useMemo(() => normalizePickerColumns(source, { valueKey, labelKey, childrenKey }), [source, valueKey, labelKey, childrenKey]);
116
+ const data = useMemo(() => resolvePickerColumns(normalized, current, cascade), [normalized, current, cascade]);
117
+ const read = () => {
118
+ const values = data.flatMap((items, index) => {
119
+ const item = items[columnRefs.current[index]?.getIndex() ?? selection.selectedIndexes[index]];
120
+ return item ? [item.value] : [];
121
+ });
122
+ return pickerSelection({ ...model, value: values });
123
+ };
124
+ useImperativeHandle(ref, () => ({ getSelected: read, getSelectedOptions: () => read().selectedOptions, getSelectedValues: () => read().value, getSelectedLabels: () => read().selectedLabels, getSelectedIndex: () => read().selectedIndexes, getColumnsData: () => data, getColumnData: index => data[index] ?? [], getColumnIndex: index => read().selectedIndexes[index] ?? -1, resetColumns: next => setOverride({ source: columns, columns: next }) }), [model, selection, data, columns]);
125
+ const padding = (count - 1) * row / 2;
126
+ return <view className={`ui-picker-view ${className}`} style={{ height: `${row * count}px`, ...style }}>
127
+ <view className="ui-picker-indicator" style={{ top: `${padding}px`, height: `${row}px` }} pointer-events="none"/>
128
+ <view className="ui-picker-columns">{data.map((items, column) => <Column key={column} ref={node => { columnRefs.current[column] = node; }} items={items} index={selection.selectedIndexes[column] ?? -1} row={row} count={count} disabled={disabled || loading} immediate={immediateChange} onStart={onPickStart} onEnd={onPickEnd} onSelect={index => {
129
+ 'background only';
130
+ const next = [...selection.value];
131
+ next[column] = items[index].value;
132
+ if (cascade)
133
+ next.splice(column + 1);
134
+ const result = pickerSelection({ ...model, value: next }, data.length === 1 ? index : column);
135
+ if (value === undefined)
136
+ setInner(result.value);
137
+ onChange?.(result);
138
+ }}/>)}</view>
139
+ <view className="ui-picker-fade ui-picker-fade-top" style={{ height: `${padding}px` }} pointer-events="none"/><view className="ui-picker-fade ui-picker-fade-bottom" style={{ height: `${padding}px` }} pointer-events="none"/>
140
+ {loading ? <view className="ui-picker-view-loading"><Loading /></view> : null}
141
+ </view>;
142
+ });
@@ -0,0 +1,23 @@
1
+ import type { AnchoredBubbleProps, BubbleRef } from "./AnchoredBubble.jsx";
2
+ export type PopoverRef = BubbleRef;
3
+ export type PopoverMenuItem = {
4
+ content: string;
5
+ iconClass?: string;
6
+ [key: string]: unknown;
7
+ };
8
+ export type PopoverProps = Omit<AnchoredBubbleProps, 'kind'> & {
9
+ content?: string | readonly PopoverMenuItem[];
10
+ mode?: 'normal' | 'menu';
11
+ onMenuClick?: (event: {
12
+ item: PopoverMenuItem;
13
+ index: number;
14
+ }) => void;
15
+ };
16
+ export declare const Popover: (props: Omit<AnchoredBubbleProps, "kind"> & {
17
+ content?: string | readonly PopoverMenuItem[];
18
+ mode?: "normal" | "menu";
19
+ onMenuClick?: (event: {
20
+ item: PopoverMenuItem;
21
+ index: number;
22
+ }) => void;
23
+ } & import("react").RefAttributes<BubbleRef>) => React.ReactElement | null;
@@ -0,0 +1,35 @@
1
+ import { forwardRef, useImperativeHandle, useRef } from '@lynx-js/react';
2
+ import { AnchoredBubble } from "./AnchoredBubble.jsx";
3
+ import { Icon } from "./Icon.jsx";
4
+ export const Popover = forwardRef(function Popover({ content = '', contentNode, mode = 'normal', onMenuClick, onOpen, onClose, disabled, ...props }, ref) {
5
+ const bubble = useRef(null);
6
+ const visible = useRef(false);
7
+ useImperativeHandle(ref, () => ({ open: () => {
8
+ 'background only';
9
+ bubble.current?.open();
10
+ }, close: () => {
11
+ 'background only';
12
+ bubble.current?.close();
13
+ }, updatePosition: () => {
14
+ 'background only';
15
+ bubble.current?.updatePosition();
16
+ } }), []);
17
+ const items = Array.isArray(content) ? content : [];
18
+ const body = contentNode ?? (mode === 'menu' ? <view className="ui-popover-menu">{items.map((item, index) => <view key={index} className="ui-popover-menu-item" accessibility-element accessibility-traits="button" accessibility-label={item.content} catchtap={() => {
19
+ 'background only';
20
+ if (disabled || !visible.current)
21
+ return;
22
+ visible.current = false;
23
+ bubble.current?.close();
24
+ onMenuClick?.({ item, index });
25
+ }}>{index ? <view className="ui-popover-menu-line"/> : null}{item.iconClass ? <view className="ui-popover-menu-icon"><Icon name={item.iconClass} size={14}/></view> : null}<text className="ui-popover-menu-text">{item.content}</text></view>)}</view> : <text className="ui-bubble-text">{typeof content === 'string' ? content : ''}</text>);
26
+ return <AnchoredBubble {...props} disabled={disabled} ref={bubble} kind="popover" contentNode={body} onOpen={() => {
27
+ 'background only';
28
+ visible.current = true;
29
+ onOpen?.();
30
+ }} onClose={() => {
31
+ 'background only';
32
+ visible.current = false;
33
+ onClose?.();
34
+ }}/>;
35
+ });
@@ -0,0 +1,30 @@
1
+ import type { ReactNode } from '@lynx-js/react';
2
+ import type { CSSProperties } from '@lynx-js/types';
3
+ import type { LayerLifecycle } from "./Overlay.jsx";
4
+ import type { TransitionName } from "./Transition.jsx";
5
+ export type PopupPosition = 'center' | 'top' | 'right' | 'bottom' | 'left';
6
+ export type PopupCloseReason = 'modal' | 'close';
7
+ export type PopupProps = LayerLifecycle & {
8
+ show?: boolean;
9
+ onChange?: (show: boolean) => void;
10
+ onClose?: (reason: PopupCloseReason) => void;
11
+ onClickModal?: () => void;
12
+ position?: PopupPosition;
13
+ transition?: TransitionName | readonly TransitionName[];
14
+ duration?: number | boolean;
15
+ closable?: boolean;
16
+ closeOnClickModal?: boolean;
17
+ modal?: boolean;
18
+ modalStyle?: CSSProperties;
19
+ zIndex?: number;
20
+ lazyRender?: boolean;
21
+ lockScroll?: boolean;
22
+ rootPortal?: boolean;
23
+ round?: boolean;
24
+ safeAreaInsetBottom?: boolean;
25
+ safeAreaBottom?: number;
26
+ className?: string;
27
+ style?: CSSProperties;
28
+ children?: ReactNode;
29
+ };
30
+ export declare function Popup({ show, onChange, onClose, onClickModal, position, transition, duration, closable, closeOnClickModal, modal, modalStyle, zIndex, lazyRender, lockScroll, rootPortal, round, safeAreaInsetBottom, safeAreaBottom, className, style, children, ...lifecycle }: PopupProps): import("@lynx-js/react").JSX.Element;