@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.
- package/CHANGELOG.md +67 -0
- package/LICENSE +21 -0
- package/README.md +179 -2
- package/THIRD_PARTY_NOTICES.md +19 -0
- package/dist/ActionSheet.d.ts +45 -0
- package/dist/ActionSheet.jsx +37 -0
- package/dist/AnchoredBubble.d.ts +36 -0
- package/dist/AnchoredBubble.jsx +120 -0
- package/dist/Avatar.d.ts +35 -0
- package/dist/Avatar.jsx +29 -0
- package/dist/Backtop.d.ts +22 -0
- package/dist/Backtop.jsx +18 -0
- package/dist/Badge.d.ts +19 -0
- package/dist/Badge.jsx +11 -0
- package/dist/BarCode.d.ts +20 -0
- package/dist/BarCode.jsx +38 -0
- package/dist/Button.d.ts +21 -0
- package/dist/Button.jsx +19 -0
- package/dist/Calendar.d.ts +90 -0
- package/dist/Calendar.jsx +164 -0
- package/dist/CalendarView.d.ts +51 -0
- package/dist/CalendarView.jsx +136 -0
- package/dist/Card.d.ts +21 -0
- package/dist/Card.jsx +21 -0
- package/dist/Cascader.d.ts +75 -0
- package/dist/Cascader.jsx +212 -0
- package/dist/Cell.d.ts +34 -0
- package/dist/Cell.jsx +37 -0
- package/dist/Checkbox.d.ts +50 -0
- package/dist/Checkbox.jsx +74 -0
- package/dist/Circle.d.ts +19 -0
- package/dist/Circle.jsx +35 -0
- package/dist/Collapse.d.ts +31 -0
- package/dist/Collapse.jsx +61 -0
- package/dist/ConfigProvider.d.ts +15 -0
- package/dist/ConfigProvider.jsx +20 -0
- package/dist/CountDown.d.ts +20 -0
- package/dist/CountDown.jsx +15 -0
- package/dist/CountTo.d.ts +28 -0
- package/dist/CountTo.jsx +27 -0
- package/dist/Curtain.d.ts +29 -0
- package/dist/Curtain.jsx +51 -0
- package/dist/DatetimePicker.d.ts +46 -0
- package/dist/DatetimePicker.jsx +138 -0
- package/dist/DatetimePickerView.d.ts +38 -0
- package/dist/DatetimePickerView.jsx +36 -0
- package/dist/Dialog.d.ts +64 -0
- package/dist/Dialog.jsx +105 -0
- package/dist/Divider.d.ts +16 -0
- package/dist/Divider.jsx +9 -0
- package/dist/DropMenu.d.ts +55 -0
- package/dist/DropMenu.jsx +210 -0
- package/dist/Empty.d.ts +14 -0
- package/dist/Empty.jsx +14 -0
- package/dist/EmptyState.d.ts +6 -0
- package/dist/EmptyState.jsx +9 -0
- package/dist/Fab.d.ts +30 -0
- package/dist/Fab.jsx +127 -0
- package/dist/FloatingPanel.d.ts +21 -0
- package/dist/FloatingPanel.jsx +102 -0
- package/dist/Form.d.ts +63 -0
- package/dist/Form.jsx +108 -0
- package/dist/FormFieldRow.d.ts +56 -0
- package/dist/FormFieldRow.jsx +63 -0
- package/dist/Gap.d.ts +10 -0
- package/dist/Gap.jsx +14 -0
- package/dist/Grid.d.ts +47 -0
- package/dist/Grid.jsx +31 -0
- package/dist/Icon.d.ts +11 -0
- package/dist/Icon.jsx +12 -0
- package/dist/ImagePreview.d.ts +62 -0
- package/dist/ImagePreview.jsx +78 -0
- package/dist/Img.d.ts +28 -0
- package/dist/Img.jsx +59 -0
- package/dist/ImgCropper.d.ts +74 -0
- package/dist/ImgCropper.jsx +114 -0
- package/dist/IndexBar.d.ts +36 -0
- package/dist/IndexBar.jsx +149 -0
- package/dist/Input.d.ts +11 -0
- package/dist/Input.jsx +3 -0
- package/dist/InputNumber.d.ts +32 -0
- package/dist/InputNumber.jsx +165 -0
- package/dist/Keyboard.d.ts +37 -0
- package/dist/Keyboard.jsx +130 -0
- package/dist/Layout.d.ts +31 -0
- package/dist/Layout.jsx +14 -0
- package/dist/Loading.d.ts +18 -0
- package/dist/Loading.jsx +15 -0
- package/dist/Loadmore.d.ts +18 -0
- package/dist/Loadmore.jsx +16 -0
- package/dist/Navbar.d.ts +35 -0
- package/dist/Navbar.jsx +50 -0
- package/dist/NoticeBar.d.ts +30 -0
- package/dist/NoticeBar.jsx +86 -0
- package/dist/Notify.d.ts +34 -0
- package/dist/Notify.jsx +52 -0
- package/dist/NumberStepper.d.ts +11 -0
- package/dist/NumberStepper.jsx +41 -0
- package/dist/Overlay.d.ts +16 -0
- package/dist/Overlay.jsx +12 -0
- package/dist/PagedList.d.ts +13 -0
- package/dist/PagedList.jsx +36 -0
- package/dist/Pagination.d.ts +29 -0
- package/dist/Pagination.jsx +33 -0
- package/dist/PasswordInput.d.ts +16 -0
- package/dist/PasswordInput.jsx +20 -0
- package/dist/Picker.d.ts +61 -0
- package/dist/Picker.jsx +80 -0
- package/dist/PickerView.d.ts +43 -0
- package/dist/PickerView.jsx +142 -0
- package/dist/Popover.d.ts +23 -0
- package/dist/Popover.jsx +35 -0
- package/dist/Popup.d.ts +30 -0
- package/dist/Popup.jsx +32 -0
- package/dist/Progress.d.ts +17 -0
- package/dist/Progress.jsx +45 -0
- package/dist/QrCode.d.ts +46 -0
- package/dist/QrCode.jsx +67 -0
- package/dist/Radio.d.ts +21 -0
- package/dist/Radio.jsx +34 -0
- package/dist/Rate.d.ts +25 -0
- package/dist/Rate.jsx +39 -0
- package/dist/Resize.d.ts +17 -0
- package/dist/Resize.jsx +17 -0
- package/dist/RichText.d.ts +133 -0
- package/dist/RichText.jsx +288 -0
- package/dist/RootPortal.d.ts +11 -0
- package/dist/RootPortal.jsx +19 -0
- package/dist/Search.d.ts +39 -0
- package/dist/Search.jsx +94 -0
- package/dist/Segmented.d.ts +18 -0
- package/dist/Segmented.jsx +35 -0
- package/dist/SelectPicker.d.ts +54 -0
- package/dist/SelectPicker.jsx +136 -0
- package/dist/Sidebar.d.ts +34 -0
- package/dist/Sidebar.jsx +43 -0
- package/dist/Signature.d.ts +46 -0
- package/dist/Signature.jsx +203 -0
- package/dist/Skeleton.d.ts +27 -0
- package/dist/Skeleton.jsx +29 -0
- package/dist/SlideVerify.d.ts +27 -0
- package/dist/SlideVerify.jsx +138 -0
- package/dist/Slider.d.ts +21 -0
- package/dist/Slider.jsx +131 -0
- package/dist/SortButton.d.ts +16 -0
- package/dist/SortButton.jsx +19 -0
- package/dist/Steps.d.ts +23 -0
- package/dist/Steps.jsx +25 -0
- package/dist/Sticky.d.ts +17 -0
- package/dist/Sticky.jsx +69 -0
- package/dist/SwipeAction.d.ts +27 -0
- package/dist/SwipeAction.jsx +187 -0
- package/dist/Swiper.d.ts +54 -0
- package/dist/Swiper.jsx +94 -0
- package/dist/SwiperNav.d.ts +18 -0
- package/dist/SwiperNav.jsx +10 -0
- package/dist/Switch.d.ts +31 -0
- package/dist/Switch.jsx +46 -0
- package/dist/SyncedInput.d.ts +12 -0
- package/dist/SyncedInput.jsx +18 -0
- package/dist/SyncedTextarea.d.ts +11 -0
- package/dist/SyncedTextarea.jsx +18 -0
- package/dist/Tabbar.d.ts +37 -0
- package/dist/Tabbar.jsx +46 -0
- package/dist/Table.d.ts +51 -0
- package/dist/Table.jsx +125 -0
- package/dist/Tabs.d.ts +65 -0
- package/dist/Tabs.jsx +132 -0
- package/dist/Tag.d.ts +33 -0
- package/dist/Tag.jsx +63 -0
- package/dist/Text.d.ts +19 -0
- package/dist/Text.jsx +7 -0
- package/dist/TextField.d.ts +89 -0
- package/dist/TextField.jsx +149 -0
- package/dist/Textarea.d.ts +22 -0
- package/dist/Textarea.jsx +3 -0
- package/dist/Toast.d.ts +36 -0
- package/dist/Toast.jsx +30 -0
- package/dist/Tooltip.d.ts +8 -0
- package/dist/Tooltip.jsx +5 -0
- package/dist/Tour.d.ts +85 -0
- package/dist/Tour.jsx +150 -0
- package/dist/Transition.d.ts +32 -0
- package/dist/Transition.jsx +43 -0
- package/dist/Upload.d.ts +64 -0
- package/dist/Upload.jsx +163 -0
- package/dist/VideoPreview.d.ts +47 -0
- package/dist/VideoPreview.jsx +59 -0
- package/dist/Watermark.d.ts +36 -0
- package/dist/Watermark.jsx +18 -0
- package/dist/action-sheet.css +19 -0
- package/dist/avatar.css +23 -0
- package/dist/avatarModel.d.ts +8 -0
- package/dist/avatarModel.js +17 -0
- package/dist/backtop.css +6 -0
- package/dist/badge.css +15 -0
- package/dist/badgeModel.d.ts +2 -0
- package/dist/badgeModel.js +18 -0
- package/dist/bar-code.css +5 -0
- package/dist/barCodeModel.d.ts +80 -0
- package/dist/barCodeModel.js +99 -0
- package/dist/brand/logo.svg +8 -0
- package/dist/bubble.css +14 -0
- package/dist/bubblePosition.d.ts +19 -0
- package/dist/bubblePosition.js +41 -0
- package/dist/button.css +56 -0
- package/dist/calendar.css +56 -0
- package/dist/calendarModel.d.ts +62 -0
- package/dist/calendarModel.js +141 -0
- package/dist/card.css +8 -0
- package/dist/cascader.css +16 -0
- package/dist/cascaderModel.d.ts +21 -0
- package/dist/cascaderModel.js +32 -0
- package/dist/cell.css +41 -0
- package/dist/choice.css +27 -0
- package/dist/choice.d.ts +28 -0
- package/dist/choice.jsx +16 -0
- package/dist/circle.css +4 -0
- package/dist/circleModel.d.ts +15 -0
- package/dist/circleModel.js +31 -0
- package/dist/config-provider.css +2 -0
- package/dist/configContext.d.ts +23 -0
- package/dist/configContext.js +24 -0
- package/dist/configTheme.d.ts +3 -0
- package/dist/configTheme.js +22 -0
- package/dist/count-down.css +2 -0
- package/dist/count-to.css +8 -0
- package/dist/countDownModel.d.ts +11 -0
- package/dist/countDownModel.js +7 -0
- package/dist/countToModel.d.ts +3 -0
- package/dist/countToModel.js +3 -0
- package/dist/curtain.css +10 -0
- package/dist/datetime-picker.css +11 -0
- package/dist/datetimePickerModel.d.ts +47 -0
- package/dist/datetimePickerModel.js +128 -0
- package/dist/dialog.css +23 -0
- package/dist/divider.css +14 -0
- package/dist/drop-menu.css +28 -0
- package/dist/empty.css +7 -0
- package/dist/fab.css +23 -0
- package/dist/fabModel.d.ts +26 -0
- package/dist/fabModel.js +16 -0
- package/dist/floating-panel.css +6 -0
- package/dist/floatingPanelModel.d.ts +3 -0
- package/dist/floatingPanelModel.js +10 -0
- package/dist/form.css +10 -0
- package/dist/formContext.d.ts +7 -0
- package/dist/formContext.js +2 -0
- package/dist/formModel.d.ts +38 -0
- package/dist/formModel.js +16 -0
- package/dist/gap.css +1 -0
- package/dist/grid.css +17 -0
- package/dist/icon.css +8 -0
- package/dist/icons/LICENSE.tabler +21 -0
- package/dist/icons/paths.d.ts +309 -0
- package/dist/icons/paths.js +310 -0
- package/dist/icons/render.d.ts +2 -0
- package/dist/icons/render.js +5 -0
- package/dist/image-preview.css +8 -0
- package/dist/img-cropper.css +1 -0
- package/dist/img.css +5 -0
- package/dist/imgCropperModel.d.ts +55 -0
- package/dist/imgCropperModel.js +41 -0
- package/dist/imgModel.d.ts +13 -0
- package/dist/imgModel.js +22 -0
- package/dist/index-bar.css +12 -0
- package/dist/index.d.ts +200 -0
- package/dist/index.js +99 -0
- package/dist/indexBarModel.d.ts +19 -0
- package/dist/indexBarModel.js +37 -0
- package/dist/input-number.css +24 -0
- package/dist/inputNumberModel.d.ts +23 -0
- package/dist/inputNumberModel.js +40 -0
- package/dist/keyboard.css +26 -0
- package/dist/keyboardModel.d.ts +11 -0
- package/dist/keyboardModel.js +34 -0
- package/dist/layout.css +2 -0
- package/dist/legacy/RadioGroup.d.ts +13 -0
- package/dist/legacy/RadioGroup.jsx +13 -0
- package/dist/legacy-controls.css +87 -0
- package/dist/loading.css +31 -0
- package/dist/loadingModel.d.ts +2 -0
- package/dist/loadingModel.js +21 -0
- package/dist/loadmore.css +5 -0
- package/dist/navbar.css +16 -0
- package/dist/notice-bar.css +19 -0
- package/dist/notify.css +14 -0
- package/dist/overlay.css +2 -0
- package/dist/pagination.css +12 -0
- package/dist/paginationModel.d.ts +6 -0
- package/dist/paginationModel.js +7 -0
- package/dist/password-input.css +14 -0
- package/dist/passwordInputModel.d.ts +6 -0
- package/dist/passwordInputModel.js +11 -0
- package/dist/picker.css +42 -0
- package/dist/pickerModel.d.ts +32 -0
- package/dist/pickerModel.js +49 -0
- package/dist/popover.css +5 -0
- package/dist/popup.css +17 -0
- package/dist/progress.css +16 -0
- package/dist/progressModel.d.ts +12 -0
- package/dist/progressModel.js +19 -0
- package/dist/qr-code.css +4 -0
- package/dist/qrCodeModel.d.ts +36 -0
- package/dist/qrCodeModel.js +61 -0
- package/dist/rate.css +20 -0
- package/dist/rateModel.d.ts +4 -0
- package/dist/rateModel.js +38 -0
- package/dist/resize.css +2 -0
- package/dist/rich-text.css +19 -0
- package/dist/richTextMedia.d.ts +28 -0
- package/dist/richTextMedia.js +3 -0
- package/dist/richTextModel.d.ts +52 -0
- package/dist/richTextModel.js +195 -0
- package/dist/root-portal.css +1 -0
- package/dist/router/RouterView.d.ts +21 -0
- package/dist/router/RouterView.jsx +120 -0
- package/dist/router/core.d.ts +85 -0
- package/dist/router/core.js +255 -0
- package/dist/router/hooks.d.ts +17 -0
- package/dist/router/hooks.jsx +71 -0
- package/dist/router/index.d.ts +5 -0
- package/dist/router/index.js +3 -0
- package/dist/router/location.d.ts +8 -0
- package/dist/router/location.js +46 -0
- package/dist/router/router.css +7 -0
- package/dist/router/runtime.d.ts +1 -0
- package/dist/router/runtime.js +25 -0
- package/dist/search.css +23 -0
- package/dist/segmented.css +19 -0
- package/dist/segmentedModel.d.ts +10 -0
- package/dist/segmentedModel.js +8 -0
- package/dist/sidebar.css +18 -0
- package/dist/sidebarModel.d.ts +8 -0
- package/dist/sidebarModel.js +27 -0
- package/dist/signature.css +5 -0
- package/dist/signatureModel.d.ts +23 -0
- package/dist/signatureModel.js +80 -0
- package/dist/skeleton.css +16 -0
- package/dist/slide-verify.css +7 -0
- package/dist/slider.css +49 -0
- package/dist/sliderModel.d.ts +10 -0
- package/dist/sliderModel.js +27 -0
- package/dist/sort-button.css +12 -0
- package/dist/steps.css +35 -0
- package/dist/sticky.css +7 -0
- package/dist/styles.css +136 -0
- package/dist/styles.d.ts +1 -0
- package/dist/swipe-action.css +6 -0
- package/dist/swiper.css +27 -0
- package/dist/swiperAnimation.d.ts +3 -0
- package/dist/swiperAnimation.js +6 -0
- package/dist/swiperModel.d.ts +2 -0
- package/dist/swiperModel.js +3 -0
- package/dist/switch.css +12 -0
- package/dist/tabbar.css +17 -0
- package/dist/tabbarModel.d.ts +8 -0
- package/dist/tabbarModel.js +27 -0
- package/dist/table.css +21 -0
- package/dist/tableModel.d.ts +10 -0
- package/dist/tableModel.js +17 -0
- package/dist/tabs.css +31 -0
- package/dist/tabsModel.d.ts +7 -0
- package/dist/tabsModel.js +14 -0
- package/dist/tag.css +66 -0
- package/dist/text-field.css +15 -0
- package/dist/text.css +7 -0
- package/dist/textModel.d.ts +3 -0
- package/dist/textModel.js +24 -0
- package/dist/toast.css +13 -0
- package/dist/tokens.d.ts +34 -0
- package/dist/tokens.js +10 -0
- package/dist/tour.css +8 -0
- package/dist/transition.css +12 -0
- package/dist/upload.css +11 -0
- package/dist/useCountDown.d.ts +14 -0
- package/dist/useCountDown.js +73 -0
- package/dist/useDialog.d.ts +9 -0
- package/dist/useDialog.js +33 -0
- package/dist/useImagePreview.d.ts +7 -0
- package/dist/useImagePreview.js +17 -0
- package/dist/useNotify.d.ts +9 -0
- package/dist/useNotify.js +26 -0
- package/dist/usePressState.d.ts +6 -0
- package/dist/usePressState.js +17 -0
- package/dist/useToast.d.ts +11 -0
- package/dist/useToast.js +23 -0
- package/dist/useVideoPreview.d.ts +7 -0
- package/dist/useVideoPreview.js +17 -0
- package/dist/utils.d.ts +4 -0
- package/dist/utils.js +4 -0
- package/dist/video-preview.css +7 -0
- package/dist/watermark.css +6 -0
- package/dist/web/imgCropperElement.d.ts +2 -0
- package/dist/web/imgCropperElement.js +309 -0
- package/dist/web/index.d.ts +6 -0
- package/dist/web/index.js +6 -0
- package/dist/web/qrCodeExportElement.d.ts +4 -0
- package/dist/web/qrCodeExportElement.js +70 -0
- package/dist/web/richTextMediaElement.d.ts +2 -0
- package/dist/web/richTextMediaElement.js +276 -0
- package/package.json +98 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# 更新日志
|
|
2
|
+
|
|
3
|
+
记录 Daisu UI 的版本变化。npm 组件包名为 `@daisu-ui/ui`,GitLab 保留源码与 Git 安装产物。
|
|
4
|
+
|
|
5
|
+
## 0.1.0-beta.4
|
|
6
|
+
|
|
7
|
+
2026-11-25 · npm 页面说明
|
|
8
|
+
|
|
9
|
+
- 重新编排 npm README:品牌标志与徽章、特性、组件分类、安装、快速上手和主题配置。
|
|
10
|
+
- 提供自包含的使用说明,不依赖公开文档站或 Demo 地址。
|
|
11
|
+
- 随 UI 产物提供品牌 SVG,确保 npm 页面 Logo 使用公开 CDN 地址。
|
|
12
|
+
- UI 组件 API 保持不变。
|
|
13
|
+
|
|
14
|
+
## 0.1.0-beta.3
|
|
15
|
+
|
|
16
|
+
2026-11-25 · npm 首次发布
|
|
17
|
+
|
|
18
|
+
- npm 包名统一为 `@daisu-ui/ui`,同步组件示例、公开入口与消费校验。
|
|
19
|
+
- npm 仅包含 UI 库的 ESM、保留 JSX 的组件、声明、样式和许可证;不包含 Demo、文档应用或 MCP。
|
|
20
|
+
- 建立 `developer` 开发、`main` 稳定源码、`npm-dist` 产物分支,发布前核对源码已合并到远端 `main`。
|
|
21
|
+
- 增加 npm 产物校验、beta/latest 发布命令及 README 的完整发布操作示例。
|
|
22
|
+
|
|
23
|
+
## 0.1.0-beta.2
|
|
24
|
+
|
|
25
|
+
2026-11-25 · Git 发布
|
|
26
|
+
|
|
27
|
+
- 通过受保护的源码版本 Tag 自动执行测试、类型检查、Demo/文档构建和独立组件包校验。
|
|
28
|
+
- 自动生成 `npm-dist` 发布分支及 `npm-v*` 安装标签,产物保留 JSX、类型声明和自动样式加载。
|
|
29
|
+
- 提供本地 Docker Runner 配置和一键 Git 发布命令,无需发布到 npmjs。
|
|
30
|
+
|
|
31
|
+
## 0.1.0-beta.1
|
|
32
|
+
|
|
33
|
+
2026-11-25 · 开发中
|
|
34
|
+
|
|
35
|
+
- 增加随仓库使用的本地 stdio MCP 文档服务,提供组件、API、Demo、主题变量、全文搜索与更新记录查询;补充通用 JSON、Cursor、VS Code 和 Codex 配置及真实客户端集成测试。
|
|
36
|
+
- 文档站增加分组指南、设计系统与 AI 导航,统一左侧目录和顶部菜单,提供 AI 总览、文档搜索及版本更新定位,支持键盘、触屏与明暗主题。
|
|
37
|
+
- 清理组件注释、使用指南、示例内容及远程资源引用。
|
|
38
|
+
- 内置图标切换至 Tabler Icons 3.53.0,保留现有 305 个图标名称。
|
|
39
|
+
- 演示插画、视频与旋律使用本仓库生成的本地资源,水印使用 Daisu UI 标志。
|
|
40
|
+
|
|
41
|
+
## 0.1.0-beta.0
|
|
42
|
+
|
|
43
|
+
2026-11-25 · 开发中
|
|
44
|
+
|
|
45
|
+
### 新增
|
|
46
|
+
|
|
47
|
+
- 将应用内通用 UI 提取为独立 ReactLynx npm 包。
|
|
48
|
+
- 提供保留 JSX 的 ESM、TypeScript 声明和完整组件样式。
|
|
49
|
+
- 从组件入口自动加载样式,支持生产构建 tree shaking,无需单独导入 CSS。
|
|
50
|
+
- 提供独立 router、router/runtime 与 utils 入口。
|
|
51
|
+
- 提供独立交互 Demo 与 Web 组件文档站,包含使用示例、API 表格和本页目录。
|
|
52
|
+
- 提供站内源码查看器,支持高亮、复制与源码链接直接访问。
|
|
53
|
+
- 增加更新日志页面及组件分类导航。
|
|
54
|
+
|
|
55
|
+
### 优化
|
|
56
|
+
|
|
57
|
+
- 统一组件文档的说明、代码和交互预览布局。
|
|
58
|
+
- 文档构建同步生成最新组件库与 Demo,避免预览使用旧产物。
|
|
59
|
+
|
|
60
|
+
### 修复
|
|
61
|
+
|
|
62
|
+
- 修复文档底部源码链接触发下载的问题,改为站内查看。
|
|
63
|
+
|
|
64
|
+
### 版本说明
|
|
65
|
+
|
|
66
|
+
- 业务组件及 Flutter 宿主适配由应用维护。
|
|
67
|
+
- 首个 beta,原生平台完整回归待完成。
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Daisu UI contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,180 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://cdn.jsdelivr.net/npm/@daisu-ui/ui@beta/dist/brand/logo.svg" width="120" height="120" alt="Daisu UI 袋鼠 UI Logo" />
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
<h1 align="center">Daisu UI · 袋鼠 UI</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">面向 ReactLynx 的移动端组件库</p>
|
|
8
|
+
<p align="center">原生元素 · TypeScript · 主题定制 · 深色模式</p>
|
|
9
|
+
|
|
10
|
+
<p align="center">
|
|
11
|
+
<a href="https://www.npmjs.com/package/@daisu-ui/ui"><img src="https://img.shields.io/npm/v/@daisu-ui/ui/beta?style=flat-square&logo=npm&color=FF6A00" alt="npm beta version" /></a>
|
|
12
|
+
<a href="https://www.npmjs.com/package/@daisu-ui/ui"><img src="https://img.shields.io/npm/dm/@daisu-ui/ui?style=flat-square&logo=npm&color=FF6A00" alt="npm downloads" /></a>
|
|
13
|
+
<a href="https://opensource.org/license/mit"><img src="https://img.shields.io/badge/license-MIT-FF6A00?style=flat-square" alt="MIT license" /></a>
|
|
14
|
+
<a href="https://lynxjs.org/"><img src="https://img.shields.io/badge/Lynx-%E2%89%A5%204.2-FF6A00?style=flat-square" alt="Lynx 4.2 or later" /></a>
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
## ✨ 特性
|
|
18
|
+
|
|
19
|
+
- **丰富的移动端组件**:覆盖基础布局、表单输入、数据展示、导航、反馈和媒体交互。
|
|
20
|
+
- **ReactLynx 原生元素**:基于 `@lynx-js/react` 与 `@lynx-js/lynx-ui`,保留 React 的组件开发方式。
|
|
21
|
+
- **完整的 TypeScript 类型**:提供组件 Props、事件、Ref 与独立入口的类型声明。
|
|
22
|
+
- **主题定制**:通过 `ConfigProvider` 和 CSS 变量统一外观,支持浅色、深色主题。
|
|
23
|
+
- **开箱即用的样式**:导入组件时自动加载 CSS,无需单独引入样式文件。
|
|
24
|
+
- **独立路由入口**:提供路由视图、导航 hooks 与宿主历史适配接口。
|
|
25
|
+
- **宿主能力可扩展**:上传、媒体和页面历史通过适配接口接入应用。
|
|
26
|
+
|
|
27
|
+
## 📦 安装
|
|
28
|
+
|
|
29
|
+
当前为 beta 版本,建议显式安装 `beta` 渠道:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# npm
|
|
33
|
+
npm install @daisu-ui/ui@beta
|
|
34
|
+
|
|
35
|
+
# pnpm
|
|
36
|
+
pnpm add @daisu-ui/ui@beta
|
|
37
|
+
|
|
38
|
+
# yarn
|
|
39
|
+
yarn add @daisu-ui/ui@beta
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
需要锁定版本时:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npm install @daisu-ui/ui@0.1.0-beta.4
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
本包包含 UI 库的 ESM、保留 JSX 的组件、类型声明、CSS 和许可证。Demo、文档应用和 CLI 不随组件包发布。
|
|
49
|
+
|
|
50
|
+
## 🚀 快速上手
|
|
51
|
+
|
|
52
|
+
在已经配置 ReactLynx 的项目中,从公开入口导入组件:
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
import { root } from '@lynx-js/react';
|
|
56
|
+
import { Button, ConfigProvider, RootPortalHost } from '@daisu-ui/ui';
|
|
57
|
+
|
|
58
|
+
function App() {
|
|
59
|
+
return (
|
|
60
|
+
<ConfigProvider theme="light">
|
|
61
|
+
<RootPortalHost>
|
|
62
|
+
<Button
|
|
63
|
+
label="开始使用 Daisu UI"
|
|
64
|
+
onTap={() => {
|
|
65
|
+
'background only';
|
|
66
|
+
console.log('Hello Daisu UI');
|
|
67
|
+
}}
|
|
68
|
+
/>
|
|
69
|
+
</RootPortalHost>
|
|
70
|
+
</ConfigProvider>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
root.render(<App />);
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
组件入口自动加载样式。`RootPortalHost` 为弹窗、Toast 等浮层提供挂载位置,在应用根部配置一次,并放在同一个 `ConfigProvider` 内。
|
|
78
|
+
|
|
79
|
+
### 环境要求
|
|
80
|
+
|
|
81
|
+
| 依赖 | 版本 |
|
|
82
|
+
| --- | --- |
|
|
83
|
+
| Lynx 原生引擎 | 4.2 或更高 |
|
|
84
|
+
| `@lynx-js/react` | `^0.126.2` |
|
|
85
|
+
| `@lynx-js/types` | `^4.2.1` |
|
|
86
|
+
| `@types/react` | `^18.3.0` |
|
|
87
|
+
|
|
88
|
+
使用 Rspeedy 的 `pluginReactLynx({ engineVersion: '4.2' })` 构建。组件包保留 JSX,由消费项目的 ReactLynx 编译器完成转换。
|
|
89
|
+
|
|
90
|
+
如果构建插件仍内置 `@lynx-js/tasm@0.0.49`,需要在项目根 `package.json` 配置支持 Lynx 4.2 的编译器并重新安装依赖:
|
|
91
|
+
|
|
92
|
+
```json
|
|
93
|
+
{
|
|
94
|
+
"overrides": {
|
|
95
|
+
"@lynx-js/tasm": "0.0.53"
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
编译目标不会升级宿主引擎;宿主集成方须同步满足引擎版本要求。
|
|
101
|
+
|
|
102
|
+
## 🧩 组件一览
|
|
103
|
+
|
|
104
|
+
| 分类 | 部分组件 |
|
|
105
|
+
| --- | --- |
|
|
106
|
+
| 基础与布局 | Button、Text、Icon、Row / Col、Grid、Cell、Card |
|
|
107
|
+
| 表单与选择 | Input、Textarea、Form、Checkbox、Radio、Switch、Picker、Calendar、Upload |
|
|
108
|
+
| 数据展示 | Avatar、Badge、Tag、Table、Progress、Skeleton、CountDown、Swiper |
|
|
109
|
+
| 操作反馈 | Popup、Dialog、Toast、Notify、ActionSheet、Popover、Tooltip |
|
|
110
|
+
| 导航与滚动 | Navbar、Tabbar、Tabs、Sidebar、IndexBar、PagedList、Backtop |
|
|
111
|
+
| 媒体与工具 | Img、ImagePreview、RichText、VideoPreview、ImgCropper、QrCode、Signature |
|
|
112
|
+
|
|
113
|
+
组件、hooks 和类型统一从 `@daisu-ui/ui` 导入,按实际场景组合使用。
|
|
114
|
+
|
|
115
|
+
## 🎨 主题定制
|
|
116
|
+
|
|
117
|
+
通过 `ConfigProvider` 统一设置主题:
|
|
118
|
+
|
|
119
|
+
```tsx
|
|
120
|
+
import { Button, ConfigProvider } from '@daisu-ui/ui';
|
|
121
|
+
|
|
122
|
+
export function DarkExample() {
|
|
123
|
+
return (
|
|
124
|
+
<ConfigProvider theme="dark">
|
|
125
|
+
<Button label="深色模式" />
|
|
126
|
+
</ConfigProvider>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
主题变量与组件属性均有 TypeScript 声明。需要自定义品牌色、间距或圆角时,可使用 `ConfigProvider` 的主题配置及 CSS 变量。
|
|
132
|
+
|
|
133
|
+
## 🔌 公开入口
|
|
134
|
+
|
|
135
|
+
| 入口 | 用途 |
|
|
136
|
+
| --- | --- |
|
|
137
|
+
| `@daisu-ui/ui` | 组件、hooks、类型与主题 tokens |
|
|
138
|
+
| `@daisu-ui/ui/router` | 路由视图、路由 hooks 与宿主历史适配 |
|
|
139
|
+
| `@daisu-ui/ui/router/runtime` | 路由运行环境初始化 |
|
|
140
|
+
| `@daisu-ui/ui/router/location` | 无渲染依赖的地址编解码与历史类型 |
|
|
141
|
+
| `@daisu-ui/ui/utils` | 日期、轮播和按压状态等辅助 API |
|
|
142
|
+
| `@daisu-ui/ui/web` | 浏览器媒体、裁剪及二维码导出后端注册 |
|
|
143
|
+
| `@daisu-ui/ui/styles.css` | 兼容的独立样式入口,常规使用无需手动导入 |
|
|
144
|
+
|
|
145
|
+
### 浏览器媒体能力
|
|
146
|
+
|
|
147
|
+
在浏览器宿主挂载 `<lynx-view>` 前注册 Web 后端:
|
|
148
|
+
|
|
149
|
+
```ts
|
|
150
|
+
import { registerDaisuWebComponents } from '@daisu-ui/ui/web';
|
|
151
|
+
|
|
152
|
+
registerDaisuWebComponents();
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
`RichText`、`VideoPreview` 使用 `mediaMode="browser"`,`ImgCropper` 使用 `mode="browser"`。浏览器后端提供 HTML5 音视频播放、图片裁剪和二维码 PNG 导出;原生宿主需要实现对应适配。
|
|
156
|
+
|
|
157
|
+
### 路由接入
|
|
158
|
+
|
|
159
|
+
使用路由时,在加载路由逻辑前初始化运行环境:
|
|
160
|
+
|
|
161
|
+
```ts
|
|
162
|
+
import '@daisu-ui/ui/router/runtime';
|
|
163
|
+
import { RouterView, createRouter } from '@daisu-ui/ui/router';
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
使用 TanStack 路由树 API 时,在应用中直接声明 `@tanstack/react-router@1.170.46`,并将 `react`、`react/jsx-runtime`、`react/jsx-dev-runtime` 分别映射到 ReactLynx 对应的兼容入口。
|
|
167
|
+
|
|
168
|
+
## 📱 平台与宿主
|
|
169
|
+
|
|
170
|
+
Daisu UI 的原生引擎目标为 Lynx 4.2,浏览器使用 Lynx Web。布局、手势、性能和原生能力需要在目标设备验收,当前 beta 尚未完成 Android / iOS 全部组件的完整真机回归。
|
|
171
|
+
|
|
172
|
+
上传通过 `UploadAdapter` 接入选图、上传和预览;路由通过 `RouterHistoryAdapter` 接入页面历史。网络请求、鉴权与业务会话由使用方应用负责。
|
|
173
|
+
|
|
174
|
+
## 🤝 参与开发
|
|
175
|
+
|
|
176
|
+
源码维护在 [Daisu UI GitLab 仓库](https://git.zilueit.com/daisu-ui/daisu-ui),需要仓库访问权限。开发约定、发布操作与变更记录在仓库维护,组件版本变化也可查看安装包内的 `CHANGELOG.md`。
|
|
177
|
+
|
|
178
|
+
## 📄 开源协议
|
|
179
|
+
|
|
180
|
+
[MIT](https://opensource.org/license/mit)。第三方版权与改编说明见包内 `THIRD_PARTY_NOTICES.md`,Tabler 图标许可见 `dist/icons/LICENSE.tabler`。
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
## Tabler Icons
|
|
4
|
+
|
|
5
|
+
The bundled SVG glyphs are generated from Tabler Icons 3.53.0, licensed under MIT. Copyright (c) 2020-2026 Paweł Kuna. The complete license is distributed as `dist/icons/LICENSE.tabler`. Public icon names are mapped to bundled glyphs in the source catalog; generation uses `npm run icons:generate`.
|
|
6
|
+
|
|
7
|
+
Upstream: https://github.com/tabler/tabler-icons
|
|
8
|
+
|
|
9
|
+
## Lynx UI
|
|
10
|
+
|
|
11
|
+
本库通过 npm 依赖使用官方 `@lynx-js/lynx-ui` 的 List、FeedList 和 Swiper 等组件。项目:https://github.com/lynx-family/lynx-ui ,许可证为 Apache-2.0,其声明由对应依赖包提供。
|
|
12
|
+
|
|
13
|
+
## Other runtime dependencies
|
|
14
|
+
|
|
15
|
+
TanStack Router、abort-controller、fflate、htmlparser2、JsBarcode、qrcode-generator 和 url-search-params-polyfill 均通过 npm 依赖分发,各自版权与许可证以对应安装包中的声明为准。
|
|
16
|
+
|
|
17
|
+
## Demo assets
|
|
18
|
+
|
|
19
|
+
The local illustration, video and melody assets are generated from the original SVG scenes and synthesis commands in this repository. They are maintained with the Demo and are not included in the published component package.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { ReactNode } from '@lynx-js/react';
|
|
2
|
+
import type { CSSProperties } from '@lynx-js/types';
|
|
3
|
+
import type { PopupProps } from "./Popup.jsx";
|
|
4
|
+
import type { IconName } from './icons/paths.js';
|
|
5
|
+
export type ActionSheetAction = {
|
|
6
|
+
name?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
color?: string;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
loading?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export type ActionSheetPanel = {
|
|
13
|
+
icon?: IconName | ReactNode;
|
|
14
|
+
image?: string;
|
|
15
|
+
title: string;
|
|
16
|
+
color?: string;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
};
|
|
19
|
+
export type ActionSheetSelection = {
|
|
20
|
+
item: ActionSheetAction;
|
|
21
|
+
index: number;
|
|
22
|
+
} | {
|
|
23
|
+
item: ActionSheetPanel;
|
|
24
|
+
index: number;
|
|
25
|
+
} | {
|
|
26
|
+
item: ActionSheetPanel;
|
|
27
|
+
rowIndex: number;
|
|
28
|
+
colIndex: number;
|
|
29
|
+
};
|
|
30
|
+
export type ActionSheetProps = Pick<PopupProps, 'show' | 'onChange' | 'closeOnClickModal' | 'onClickModal' | 'duration' | 'zIndex' | 'lazyRender' | 'safeAreaInsetBottom' | 'safeAreaBottom' | 'rootPortal' | 'onEnter' | 'onAfterEnter' | 'onLeave' | 'onAfterLeave'> & {
|
|
31
|
+
actions?: readonly ActionSheetAction[];
|
|
32
|
+
panels?: readonly ActionSheetPanel[] | readonly (readonly ActionSheetPanel[])[];
|
|
33
|
+
title?: string;
|
|
34
|
+
cancelText?: string;
|
|
35
|
+
closeOnClickAction?: boolean;
|
|
36
|
+
onClose?: () => void;
|
|
37
|
+
onCancel?: () => void;
|
|
38
|
+
onSelect?: (selection: ActionSheetSelection) => void;
|
|
39
|
+
children?: ReactNode;
|
|
40
|
+
renderClose?: (close: () => void) => ReactNode;
|
|
41
|
+
titleClassName?: string;
|
|
42
|
+
className?: string;
|
|
43
|
+
style?: CSSProperties;
|
|
44
|
+
};
|
|
45
|
+
export declare function ActionSheet({ actions, panels, title, cancelText, closeOnClickAction, onClose, onCancel, onSelect, children, renderClose, titleClassName, className, style, duration, safeAreaInsetBottom, onChange, show, ...popup }: ActionSheetProps): import("@lynx-js/react").JSX.Element;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Popup } from "./Popup.jsx";
|
|
2
|
+
import { Icon } from "./Icon.jsx";
|
|
3
|
+
import { Loading } from "./Loading.jsx";
|
|
4
|
+
export function ActionSheet({ actions = [], panels = [], title, cancelText, closeOnClickAction = true, onClose, onCancel, onSelect, children, renderClose, titleClassName = '', className = '', style, duration = 200, safeAreaInsetBottom = true, onChange, show = false, ...popup }) {
|
|
5
|
+
const close = () => {
|
|
6
|
+
'background only';
|
|
7
|
+
if (!show)
|
|
8
|
+
return;
|
|
9
|
+
onChange?.(false);
|
|
10
|
+
onClose?.();
|
|
11
|
+
};
|
|
12
|
+
const select = (selection) => {
|
|
13
|
+
'background only';
|
|
14
|
+
if (!show || selection.item.disabled || ('loading' in selection.item && selection.item.loading))
|
|
15
|
+
return;
|
|
16
|
+
onSelect?.(selection);
|
|
17
|
+
if (closeOnClickAction)
|
|
18
|
+
close();
|
|
19
|
+
};
|
|
20
|
+
const multiple = panels.length > 0 && Array.isArray(panels[0]);
|
|
21
|
+
const rows = (multiple ? panels : [panels]);
|
|
22
|
+
return <Popup {...popup} show={show} duration={duration} position="bottom" round lockScroll={false} onChange={close} safeAreaInsetBottom={safeAreaInsetBottom} className={`ui-action-sheet ${className}`} style={style}>
|
|
23
|
+
{title ? <view className={`ui-action-sheet-header ${titleClassName}`}><text className="ui-action-sheet-title">{title}</text><view className="ui-action-sheet-close" catchtap={close} accessibility-element accessibility-traits="button" accessibility-label="关闭动作面板">{renderClose ? renderClose(close) : <Icon name="close" size={24}/>}</view></view> : null}
|
|
24
|
+
{children ?? (panels.length ? <view className="ui-action-sheet-panels">{rows.map((row, rowIndex) => <scroll-view key={rowIndex} className="ui-action-sheet-panel-scroll" scroll-orientation="horizontal" scroll-x><view className="ui-action-sheet-panel-row">{row.map((item, colIndex) => <view key={colIndex} className={`ui-action-sheet-panel ${item.disabled ? 'ui-action-sheet-disabled' : ''}`} bindtap={() => select(multiple ? { item, rowIndex, colIndex } : { item, index: colIndex })} accessibility-element accessibility-traits="button" accessibility-label={item.title}>
|
|
25
|
+
<view className="ui-action-sheet-panel-icon">{item.image ? <image src={item.image} mode="aspectFit" className="ui-action-sheet-panel-image"/> : typeof item.icon === 'string' ? <Icon name={item.icon} size={24} color={item.color}/> : item.icon}</view><text className="ui-action-sheet-panel-title">{item.title}</text>
|
|
26
|
+
</view>)}</view></scroll-view>)}</view> : <view>{actions.map((item, index) => <view key={index} className={`ui-action-sheet-action ${item.disabled ? 'ui-action-sheet-disabled' : ''}`} bindtap={() => select({ item, index })} accessibility-element accessibility-traits="button" accessibility-label={item.name ?? '加载中'}>
|
|
27
|
+
{index ? <view className="ui-action-sheet-line"/> : null}{item.loading ? <Loading size={28}/> : <><text className="ui-action-sheet-name" style={item.color ? { color: item.color } : undefined}>{item.name}</text>{item.description ? <text className="ui-action-sheet-description">{item.description}</text> : null}</>}
|
|
28
|
+
</view>)}</view>)}
|
|
29
|
+
{cancelText ? <view className="ui-action-sheet-cancel-wrap"><view className="ui-action-sheet-cancel" bindtap={() => {
|
|
30
|
+
'background only';
|
|
31
|
+
if (!show)
|
|
32
|
+
return;
|
|
33
|
+
onCancel?.();
|
|
34
|
+
close();
|
|
35
|
+
}}><text>{cancelText}</text></view></view> : null}
|
|
36
|
+
</Popup>;
|
|
37
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ReactNode } from '@lynx-js/react';
|
|
2
|
+
import type { CSSProperties } from '@lynx-js/types';
|
|
3
|
+
import type { BubbleOffset, BubblePlacement } from './bubblePosition.js';
|
|
4
|
+
export type BubbleRef = {
|
|
5
|
+
open: () => void;
|
|
6
|
+
close: () => void;
|
|
7
|
+
updatePosition: () => void;
|
|
8
|
+
};
|
|
9
|
+
export type AnchoredBubbleProps = {
|
|
10
|
+
show?: boolean;
|
|
11
|
+
defaultShow?: boolean;
|
|
12
|
+
onShowChange?: (show: boolean) => void;
|
|
13
|
+
onChange?: (event: {
|
|
14
|
+
show: boolean;
|
|
15
|
+
}) => void;
|
|
16
|
+
onOpen?: () => void;
|
|
17
|
+
onClose?: () => void;
|
|
18
|
+
placement?: BubblePlacement;
|
|
19
|
+
offset?: BubbleOffset;
|
|
20
|
+
visibleArrow?: boolean;
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
showClose?: boolean;
|
|
23
|
+
duration?: number;
|
|
24
|
+
zIndex?: number;
|
|
25
|
+
rootPortal?: boolean;
|
|
26
|
+
className?: string;
|
|
27
|
+
style?: CSSProperties;
|
|
28
|
+
arrowClassName?: string;
|
|
29
|
+
popClassName?: string;
|
|
30
|
+
popStyle?: CSSProperties;
|
|
31
|
+
children?: ReactNode;
|
|
32
|
+
contentNode?: ReactNode;
|
|
33
|
+
kind: 'tooltip' | 'popover';
|
|
34
|
+
};
|
|
35
|
+
/** Shared geometry and interaction for the public Tooltip and Popover. */
|
|
36
|
+
export declare const AnchoredBubble: (props: AnchoredBubbleProps & import("react").RefAttributes<BubbleRef>) => React.ReactElement | null;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from '@lynx-js/react';
|
|
2
|
+
import { Icon } from "./Icon.jsx";
|
|
3
|
+
import { RootPortal } from "./RootPortal.jsx";
|
|
4
|
+
import { Transition } from "./Transition.jsx";
|
|
5
|
+
import { bubblePosition } from './bubblePosition.js';
|
|
6
|
+
function measure(node) {
|
|
7
|
+
'background only';
|
|
8
|
+
return new Promise(resolve => {
|
|
9
|
+
if (!node) {
|
|
10
|
+
resolve(undefined);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
node.invoke({ method: 'boundingClientRect', params: { androidEnableTransformProps: true, iosEnableTransformProps: true }, success: (value) => {
|
|
14
|
+
'background only';
|
|
15
|
+
const rect = value;
|
|
16
|
+
resolve(rect && [rect.left, rect.top, rect.width, rect.height].every(Number.isFinite) ? rect : undefined);
|
|
17
|
+
}, fail: () => resolve(undefined) }).exec();
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/** Shared geometry and interaction for the public Tooltip and Popover. */
|
|
21
|
+
export const AnchoredBubble = forwardRef(function AnchoredBubble({ show, defaultShow = false, onShowChange, onChange, onOpen, onClose, placement = 'bottom', offset = 0, visibleArrow = true, disabled = false, showClose = false, duration = 200, zIndex = 20, rootPortal = false, className = '', style, arrowClassName = '', popClassName = '', popStyle, children, contentNode, kind }, ref) {
|
|
22
|
+
const [inner, setInner] = useState(defaultShow);
|
|
23
|
+
const requested = (show ?? inner) && !disabled;
|
|
24
|
+
const [position, setPosition] = useState();
|
|
25
|
+
const [targetRect, setTargetRect] = useState();
|
|
26
|
+
const [contentWidth, setContentWidth] = useState(0);
|
|
27
|
+
const repositionTimer = useRef();
|
|
28
|
+
const target = useRef(null);
|
|
29
|
+
const content = useRef(null);
|
|
30
|
+
const viewport = useRef(null);
|
|
31
|
+
const sequence = useRef(0);
|
|
32
|
+
const live = useRef({ requested, disabled, placement, offset, visibleArrow, rootPortal });
|
|
33
|
+
live.current = { requested, disabled, placement, offset, visibleArrow, rootPortal };
|
|
34
|
+
const callbacks = useRef({ onOpen, onClose });
|
|
35
|
+
callbacks.current = { onOpen, onClose };
|
|
36
|
+
const previous = useRef(false);
|
|
37
|
+
const size = useRef({ width: 0, height: 0 });
|
|
38
|
+
const calculatePosition = () => {
|
|
39
|
+
'background only';
|
|
40
|
+
if (!live.current.requested)
|
|
41
|
+
return;
|
|
42
|
+
const token = ++sequence.current;
|
|
43
|
+
void Promise.all([measure(target.current), measure(content.current), measure(viewport.current)]).then(([trigger, box, bounds]) => {
|
|
44
|
+
'background only';
|
|
45
|
+
if (token !== sequence.current || !live.current.requested || !trigger || !box || !bounds || box.width <= 0 || box.height <= 0 || bounds.width <= 0 || bounds.height <= 0)
|
|
46
|
+
return;
|
|
47
|
+
const state = live.current;
|
|
48
|
+
setTargetRect(trigger);
|
|
49
|
+
setContentWidth(box.width);
|
|
50
|
+
setPosition(bubblePosition(trigger, box, bounds, state.placement, state.offset, state.visibleArrow));
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
const calculateRef = useRef(calculatePosition);
|
|
54
|
+
calculateRef.current = calculatePosition;
|
|
55
|
+
const updatePosition = () => {
|
|
56
|
+
'background only';
|
|
57
|
+
if (!live.current.requested)
|
|
58
|
+
return;
|
|
59
|
+
setPosition(undefined);
|
|
60
|
+
clearTimeout(repositionTimer.current);
|
|
61
|
+
repositionTimer.current = setTimeout(() => calculateRef.current(), 32);
|
|
62
|
+
};
|
|
63
|
+
const updateRef = useRef(updatePosition);
|
|
64
|
+
updateRef.current = updatePosition;
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
if (requested) {
|
|
67
|
+
setPosition(undefined);
|
|
68
|
+
const timer = setTimeout(() => calculateRef.current(), 40);
|
|
69
|
+
if (!previous.current)
|
|
70
|
+
callbacks.current.onOpen?.();
|
|
71
|
+
previous.current = true;
|
|
72
|
+
return () => { clearTimeout(timer); sequence.current++; };
|
|
73
|
+
}
|
|
74
|
+
sequence.current++;
|
|
75
|
+
if (previous.current)
|
|
76
|
+
callbacks.current.onClose?.();
|
|
77
|
+
previous.current = false;
|
|
78
|
+
}, [requested]);
|
|
79
|
+
const offsetKey = JSON.stringify(offset);
|
|
80
|
+
useEffect(() => { if (requested)
|
|
81
|
+
updatePosition(); }, [placement, offsetKey, visibleArrow, rootPortal]);
|
|
82
|
+
useEffect(() => () => { sequence.current++; clearTimeout(repositionTimer.current); }, []);
|
|
83
|
+
const request = (next) => {
|
|
84
|
+
'background only';
|
|
85
|
+
if (next && disabled || next === requested)
|
|
86
|
+
return;
|
|
87
|
+
if (show === undefined)
|
|
88
|
+
setInner(next);
|
|
89
|
+
onShowChange?.(next);
|
|
90
|
+
onChange?.({ show: next });
|
|
91
|
+
};
|
|
92
|
+
useImperativeHandle(ref, () => ({ open: () => {
|
|
93
|
+
'background only';
|
|
94
|
+
request(true);
|
|
95
|
+
}, close: () => {
|
|
96
|
+
'background only';
|
|
97
|
+
request(false);
|
|
98
|
+
}, updatePosition }), [show, requested, disabled, onShowChange, onChange]);
|
|
99
|
+
const layer = <view className={`ui-bubble-anchor ui-${kind}-anchor`} style={{ position: rootPortal || !position ? 'fixed' : 'absolute', width: position ? `${contentWidth}px` : undefined, left: `${position ? position.x - (rootPortal ? 0 : targetRect?.left ?? 0) : 0}px`, top: `${position ? position.y - (rootPortal ? 0 : targetRect?.top ?? 0) : 0}px`, zIndex, visibility: position ? 'visible' : 'hidden' }}>
|
|
100
|
+
<Transition show={requested} name="fade" duration={duration} destroy={false} interactiveDuringLeave className={`ui-bubble-panel ui-${kind}-panel ${popClassName}`} style={popStyle}>
|
|
101
|
+
<view ref={content} className={`ui-bubble-body ${showClose ? 'ui-bubble-closable' : ''}`} flatten={false} catchtap={() => { }} bindlayoutchange={event => {
|
|
102
|
+
'background only';
|
|
103
|
+
const { width, height } = event.detail;
|
|
104
|
+
if (width === size.current.width && height === size.current.height)
|
|
105
|
+
return;
|
|
106
|
+
size.current = { width, height };
|
|
107
|
+
calculateRef.current();
|
|
108
|
+
}}>
|
|
109
|
+
{visibleArrow && position ? <view className={`ui-bubble-arrow ui-bubble-arrow-${position.side} ${arrowClassName}`} style={position.side === 'top' || position.side === 'bottom' ? { left: `${position.arrow - 8}px` } : { top: `${position.arrow - 8}px` }}/> : null}
|
|
110
|
+
{contentNode}
|
|
111
|
+
{showClose ? <view className="ui-bubble-close" catchtap={() => request(false)} accessibility-element accessibility-traits="button" accessibility-label="关闭提示"><Icon name="close" size={12}/></view> : null}
|
|
112
|
+
</view>
|
|
113
|
+
</Transition>
|
|
114
|
+
</view>;
|
|
115
|
+
return <view className={`ui-bubble ui-${kind} ${className}`} style={style}>
|
|
116
|
+
<view ref={viewport} className="ui-bubble-viewport" flatten={false} bindlayoutchange={() => updateRef.current()}/>
|
|
117
|
+
<view ref={target} className={`ui-bubble-target ui-${kind}-target`} flatten={false} catchtap={() => request(!requested)} bindlayoutchange={() => updateRef.current()}>{children}</view>
|
|
118
|
+
{rootPortal ? <RootPortal>{layer}</RootPortal> : layer}
|
|
119
|
+
</view>;
|
|
120
|
+
});
|
package/dist/Avatar.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ReactNode } from '@lynx-js/react';
|
|
2
|
+
import type { BaseEvent, CSSProperties, ImageErrorEvent } from '@lynx-js/types';
|
|
3
|
+
import type { AvatarSize } from './avatarModel.js';
|
|
4
|
+
export type AvatarProps = {
|
|
5
|
+
src?: string;
|
|
6
|
+
text?: string;
|
|
7
|
+
icon?: string;
|
|
8
|
+
size?: AvatarSize;
|
|
9
|
+
shape?: 'round' | 'square';
|
|
10
|
+
bgColor?: string;
|
|
11
|
+
color?: string;
|
|
12
|
+
alt?: string;
|
|
13
|
+
mode?: 'scaleToFill' | 'aspectFit' | 'aspectFill' | 'center';
|
|
14
|
+
onTap?: () => void;
|
|
15
|
+
onError?: (event: BaseEvent<'error', ImageErrorEvent>) => void;
|
|
16
|
+
children?: ReactNode;
|
|
17
|
+
className?: string;
|
|
18
|
+
style?: CSSProperties;
|
|
19
|
+
};
|
|
20
|
+
export declare function Avatar({ src, text, icon, size, shape, bgColor, color, alt, mode, onTap, onError, children, className, style }: AvatarProps): import("@lynx-js/react").JSX.Element;
|
|
21
|
+
export type AvatarGroupItem = AvatarProps & {
|
|
22
|
+
key?: string | number;
|
|
23
|
+
};
|
|
24
|
+
export type AvatarGroupProps = {
|
|
25
|
+
items: readonly AvatarGroupItem[];
|
|
26
|
+
maxCount?: number;
|
|
27
|
+
cascading?: 'left-up' | 'right-up';
|
|
28
|
+
size?: AvatarSize;
|
|
29
|
+
shape?: 'round' | 'square';
|
|
30
|
+
collapseAvatar?: string;
|
|
31
|
+
vertical?: boolean;
|
|
32
|
+
className?: string;
|
|
33
|
+
style?: CSSProperties;
|
|
34
|
+
};
|
|
35
|
+
export declare function AvatarGroup({ items, maxCount, cascading, size, shape, collapseAvatar, vertical, className, style }: AvatarGroupProps): import("@lynx-js/react").JSX.Element;
|
package/dist/Avatar.jsx
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useState } from '@lynx-js/react';
|
|
2
|
+
import { Icon } from "./Icon.jsx";
|
|
3
|
+
import { avatarMetrics, avatarVisibleCount } from './avatarModel.js';
|
|
4
|
+
function AvatarImage({ src, mode, fallback, onError }) {
|
|
5
|
+
const [failed, setFailed] = useState(false);
|
|
6
|
+
return failed ? fallback : <image className="ui-avatar-image" src={src} mode={mode} binderror={event => {
|
|
7
|
+
'background only';
|
|
8
|
+
setFailed(true);
|
|
9
|
+
onError?.(event);
|
|
10
|
+
}}/>;
|
|
11
|
+
}
|
|
12
|
+
export function Avatar({ src = '', text = '', icon = '', size = 'normal', shape = 'round', bgColor, color, alt = '', mode = 'aspectFill', onTap, onError, children, className = '', style }) {
|
|
13
|
+
const metrics = avatarMetrics(size);
|
|
14
|
+
const foreground = color || (bgColor ? '#fff' : undefined);
|
|
15
|
+
const fallback = alt || text ? <text className="ui-avatar-text" style={{ fontSize: metrics.font, lineHeight: metrics.line, color: foreground }} text-maxline="1" text-overflow="ellipsis">{alt || text}</text> : icon ? <view className="ui-avatar-icon" style={{ width: metrics.font, height: metrics.font }}>{foreground ? <Icon name={icon} color={foreground}/> : <><Icon name={icon} color="#868a9c" className="ui-avatar-icon-light"/><Icon name={icon} color="#f7f8fa" className="ui-avatar-icon-dark"/></>}</view> : null;
|
|
16
|
+
const content = text ? <text className="ui-avatar-text" style={{ fontSize: metrics.font, lineHeight: metrics.line, color: foreground }} text-maxline="1" text-overflow="ellipsis">{text}</text> : fallback;
|
|
17
|
+
return <view className={`ui-avatar ui-avatar-${shape} ${className}`} style={{ width: metrics.dimension, height: metrics.dimension, backgroundColor: bgColor, ...style }} bindtap={onTap} accessibility-element={!!onTap || !!alt} accessibility-traits={onTap ? 'button' : 'image'} accessibility-label={alt || text || '头像'}>
|
|
18
|
+
{children !== undefined && children !== null && children !== false ? typeof children === 'string' || typeof children === 'number' ? <text className="ui-avatar-text" style={{ fontSize: metrics.font, lineHeight: metrics.line, color: foreground }}>{children}</text> : children : src ? <AvatarImage key={src} src={src} mode={mode} fallback={fallback} onError={onError}/> : content}
|
|
19
|
+
</view>;
|
|
20
|
+
}
|
|
21
|
+
export function AvatarGroup({ items, maxCount, cascading = 'left-up', size = 'normal', shape = 'round', collapseAvatar, vertical = false, className = '', style }) {
|
|
22
|
+
const count = avatarVisibleCount(items.length, maxCount);
|
|
23
|
+
const overflow = items.length - count;
|
|
24
|
+
const metrics = avatarMetrics(size);
|
|
25
|
+
const visible = [...items.slice(0, count), ...(overflow ? [{ key: '__collapse__', text: collapseAvatar || `+${overflow}`, className: 'ui-avatar-collapse' }] : [])];
|
|
26
|
+
return <view className={`ui-avatar-group ${vertical ? 'ui-avatar-group-vertical' : ''} ${className}`} style={style}>
|
|
27
|
+
{visible.map(({ key, style: itemStyle, className: itemClass = '', ...item }, index) => <Avatar key={index === count ? 'collapse' : `avatar:${typeof key}:${key ?? index}`} {...item} size={size} shape={shape} className={`ui-avatar-group-item ${itemClass}`} style={{ ...itemStyle, ...(index ? vertical ? { marginTop: metrics.overlap } : { marginLeft: metrics.overlap } : {}), zIndex: cascading === 'left-up' ? index + 1 : count - index }}/>)}
|
|
28
|
+
</view>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ReactNode } from '@lynx-js/react';
|
|
2
|
+
import type { CSSProperties } from '@lynx-js/types';
|
|
3
|
+
export type BacktopRequest = {
|
|
4
|
+
duration: number;
|
|
5
|
+
};
|
|
6
|
+
export type BacktopProps = {
|
|
7
|
+
scrollTop: number;
|
|
8
|
+
onBacktop: (request: BacktopRequest) => void;
|
|
9
|
+
top?: number;
|
|
10
|
+
duration?: number;
|
|
11
|
+
zIndex?: number;
|
|
12
|
+
bottom?: number;
|
|
13
|
+
right?: number;
|
|
14
|
+
shape?: 'circle' | 'square';
|
|
15
|
+
text?: string;
|
|
16
|
+
iconStyle?: CSSProperties;
|
|
17
|
+
children?: ReactNode;
|
|
18
|
+
className?: string;
|
|
19
|
+
style?: CSSProperties;
|
|
20
|
+
};
|
|
21
|
+
/** Scrolling belongs to the caller's scroll-view/List/host, never the global page. */
|
|
22
|
+
export declare function Backtop({ scrollTop, onBacktop, top, duration, zIndex, bottom, right, shape, text, iconStyle, children, className, style }: BacktopProps): import("@lynx-js/react").JSX.Element;
|
package/dist/Backtop.jsx
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Icon } from "./Icon.jsx";
|
|
2
|
+
import { Transition } from "./Transition.jsx";
|
|
3
|
+
/** Scrolling belongs to the caller's scroll-view/List/host, never the global page. */
|
|
4
|
+
export function Backtop({ scrollTop, onBacktop, top = 300, duration = 100, zIndex = 10, bottom = 100, right = 20, shape = 'circle', text, iconStyle, children, className = '', style }) {
|
|
5
|
+
const visible = Number.isFinite(scrollTop) && scrollTop > top;
|
|
6
|
+
const activate = () => {
|
|
7
|
+
'background only';
|
|
8
|
+
if (visible)
|
|
9
|
+
onBacktop({ duration: Number.isFinite(duration) ? Math.max(0, duration) : 100 });
|
|
10
|
+
};
|
|
11
|
+
return <view className="ui-backtop-position" style={{ bottom: `${bottom}px`, right: `${right}px`, zIndex }}>
|
|
12
|
+
<Transition show={visible} name="fade" lazyRender>
|
|
13
|
+
<view className={`ui-backtop ui-backtop-${shape} ${className}`} style={style} bindtap={activate} accessibility-element accessibility-traits="button" accessibility-label={text || '回到顶部'}>
|
|
14
|
+
{children ?? <view className="ui-backtop-content"><view style={iconStyle}><Icon name="to-top" size={20} color={typeof iconStyle?.color === 'string' ? iconStyle.color : undefined}/></view>{text ? <text className="ui-backtop-text" style={{ color: style?.color }}>{text}</text> : null}</view>}
|
|
15
|
+
</view>
|
|
16
|
+
</Transition>
|
|
17
|
+
</view>;
|
|
18
|
+
}
|