hys-ui 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/README.md +68 -73
- package/dist/components/HysAnimatedNumber/HysAnimatedNumber.vue.js +5 -41
- package/dist/components/HysAnimatedNumber/HysAnimatedNumber2.vue.js +146 -2
- package/dist/components/HysButton/HysButton.vue.js +2 -2
- package/dist/components/HysButton/HysButton2.vue.js +227 -60
- package/dist/components/HysButtonGroup/HysButtonGroup.vue.js +7 -0
- package/dist/components/HysButtonGroup/HysButtonGroup2.vue.js +51 -0
- package/dist/components/HysMention/HysMention.vue.js +1 -1
- package/dist/components/HysMention/HysMention2.vue.js +1092 -154
- package/dist/components/HysModal/HysModal.vue.js +3 -3
- package/dist/components/HysModal/HysModal2.vue.js +81 -80
- package/dist/components/HysPagination/HysPagination.vue.js +2 -2
- package/dist/components/HysPagination/HysPagination2.vue.js +243 -180
- package/dist/components/HysSearch/HysSearch.vue.js +5 -82
- package/dist/components/HysSearch/HysSearch2.vue.js +176 -2
- package/dist/components/HysSelect/HysSelect.vue.js +2 -2
- package/dist/components/HysSelect/HysSelect2.vue.js +472 -443
- package/dist/components/HysSplitPane/HysSplitPane.vue.js +315 -58
- package/dist/components/HysSplitPane/HysSplitPane3.vue.js +5 -0
- package/dist/components/HysTable/HysTable.vue.js +2 -2
- package/dist/components/HysTable/HysTable2.vue.js +1418 -1150
- package/dist/components/HysTour/HysTour.vue.js +291 -67
- package/dist/components/HysTour/HysTour3.vue.js +5 -0
- package/dist/composables/buttonGroup.js +12 -0
- package/dist/composables/floatingPosition.js +18 -0
- package/dist/composables/mentionDocument.js +79 -0
- package/dist/composables/mentionEditor.js +58 -0
- package/dist/composables/selectOptions.js +44 -38
- package/dist/composables/splitPaneSizes.js +58 -0
- package/dist/composables/table.js +128 -105
- package/dist/composables/useDialog.js +50 -50
- package/dist/composables/useFloating.js +107 -103
- package/dist/composables/useMentionCaret.js +81 -0
- package/dist/composables/useMentionList.js +81 -0
- package/dist/composables/useMentionModel.js +90 -0
- package/dist/composables/useMentionOptions.js +421 -0
- package/dist/composables/useSplitPaneDrag.js +52 -0
- package/dist/composables/useSplitPaneStorage.js +38 -0
- package/dist/composables/useTable.js +344 -312
- package/dist/composables/useTableSticky.js +79 -0
- package/dist/composables/useTourLayout.js +129 -0
- package/dist/config.js +11 -11
- package/dist/index.js +175 -156
- package/dist/internal/MultiSplitPane.vue.js +305 -0
- package/dist/internal/MultiSplitPane2.vue.js +4 -0
- package/dist/style.css +1 -1
- package/dist/types/components/HysAnimatedNumber/HysAnimatedNumber.vue.d.ts +61 -7
- package/dist/types/components/HysAutocomplete/HysAutocomplete.vue.d.ts +1 -1
- package/dist/types/components/HysButton/HysButton.vue.d.ts +82 -22
- package/dist/types/components/HysButtonGroup/HysButtonGroup.vue.d.ts +30 -0
- package/dist/types/components/HysCascader/HysCascaderColumn.vue.d.ts +2 -2
- package/dist/types/components/HysColorPicker/HysColorPicker.vue.d.ts +2 -2
- package/dist/types/components/HysContextMenu/HysMenuPanel.vue.d.ts +2 -2
- package/dist/types/components/HysDatePicker/HysDatePickerControl.vue.d.ts +2 -2
- package/dist/types/components/HysDrawer/HysDrawer.vue.d.ts +1 -1
- package/dist/types/components/HysMention/HysMention.vue.d.ts +91 -40
- package/dist/types/components/HysModal/HysModal.vue.d.ts +1 -1
- package/dist/types/components/HysNumberInput/HysNumberInput.vue.d.ts +2 -2
- package/dist/types/components/HysPagination/HysPagination.vue.d.ts +55 -4
- package/dist/types/components/HysRating/HysRating.vue.d.ts +1 -1
- package/dist/types/components/HysSearch/HysSearch.vue.d.ts +45 -7
- package/dist/types/components/HysSelect/HysSelect.vue.d.ts +6 -1
- package/dist/types/components/HysSplitPane/HysSplitPane.vue.d.ts +125 -14
- package/dist/types/components/HysSteps/HysSteps.vue.d.ts +1 -1
- package/dist/types/components/HysTable/HysTable.vue.d.ts +1740 -3
- package/dist/types/components/HysTour/HysTour.vue.d.ts +46 -9
- package/dist/types/composables/buttonGroup.d.ts +9 -0
- package/dist/types/composables/floatingPosition.d.ts +14 -0
- package/dist/types/composables/mention.d.ts +284 -0
- package/dist/types/composables/mentionDocument.d.ts +15 -0
- package/dist/types/composables/mentionEditor.d.ts +7 -0
- package/dist/types/composables/modal.d.ts +2 -0
- package/dist/types/composables/selectOptions.d.ts +5 -0
- package/dist/types/composables/splitPaneSizes.d.ts +11 -0
- package/dist/types/composables/table.d.ts +116 -6
- package/dist/types/composables/tour.d.ts +68 -0
- package/dist/types/composables/useFloating.d.ts +1 -1
- package/dist/types/composables/useMentionCaret.d.ts +6 -0
- package/dist/types/composables/useMentionList.d.ts +23 -0
- package/dist/types/composables/useMentionModel.d.ts +14 -0
- package/dist/types/composables/useMentionOptions.d.ts +26 -0
- package/dist/types/composables/useSplitPaneDrag.d.ts +14 -0
- package/dist/types/composables/useSplitPaneStorage.d.ts +4 -0
- package/dist/types/composables/useTable.d.ts +7 -3
- package/dist/types/composables/useTableSticky.d.ts +22 -0
- package/dist/types/composables/useTourLayout.d.ts +33 -0
- package/dist/types/config.d.ts +1 -0
- package/dist/types/index.d.ts +36 -1
- package/dist/types/internal/MultiSplitPane.vue.d.ts +54 -0
- package/package.json +3 -2
- package/dist/components/HysSplitPane/HysSplitPane2.vue.js +0 -4
- package/dist/components/HysTour/HysTour2.vue.js +0 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
- 示例站点为新增能力补充交互示例,API 参考补全参数、事件、插槽和实例方法的具体说明。
|
|
6
|
+
|
|
7
|
+
- Button 增加石板灰、钴蓝、靛蓝、紫罗兰、湖青、青绿、翡翠绿、青柠、琥珀、柑橘、朱红、玫红十二种内置配色,支持深浅色和原有文字、链接及朴素样式。悬停只变更视觉样式,按钮位置保持稳定。
|
|
8
|
+
|
|
9
|
+
- Button 支持可取消的异步操作、延迟加载、按下状态、自定义根标签与键盘激活、两字中文间距、危险色与透明描边组合及文字底色。新增 ButtonGroup 统一按钮的方向、尺寸和状态。
|
|
10
|
+
- Search 增加独立搜索按钮、确认提交模式、非受控初值、清空策略及原生输入属性。
|
|
11
|
+
- Select 支持值与标签模型、远程标签回显、首选高亮值和动态清空值。多选批量事件使用同一模型格式。
|
|
12
|
+
|
|
13
|
+
- Tour 支持定位到元素、选择器和目标函数,增加跟随滚动的高亮遮罩、目标点击策略、非模态引导、逐步外观、自定义内容与导航、挂载与层级配置。
|
|
14
|
+
- SplitPane 增加两侧独立的像素或百分比约束、折叠和恢复、延迟拖动提交、拖动预览事件及非受控比例。
|
|
15
|
+
- SplitPane 支持按标识管理任意数量的面板、按分隔条调整相邻尺寸、受控尺寸集合和面板插槽。未设置尺寸的面板自动分配可用空间。
|
|
16
|
+
- SplitPane 更新细线、抓手和方向箭头,增加可配置分隔条尺寸、键盘折叠、双击操作、非受控布局记忆和按标识调整面板尺寸。
|
|
17
|
+
|
|
18
|
+
- Mention 支持独立触发规则、模糊和拼音搜索、多源分页与缓存、推荐和最近记录、分组虚拟候选、富文本实体、程序化编辑、序列化、撤销重做、权限校验、表单及浮层定制。
|
|
19
|
+
- AnimatedNumber 支持精确十进制字符串、统计标题与前后缀、自定义数值格式和截止时间倒计时。
|
|
20
|
+
- Table 增加外部容器粘性表头和同步滚动条、列级受控排序和筛选、自定义表格结构与表头合并。支持下一次排序提示、自定义批量选择和统一单元格文本转换。
|
|
21
|
+
- Table 支持分页布局、默认分页值、自定义分页器与服务端总页数,以及固定汇总、当前页汇总和自定义汇总行。新增横向最小宽度、列标题渲染和溢出提示样式配置。
|
|
22
|
+
- Pagination 支持非受控初始值、总页数、单页隐藏、控件布局和尺寸,以及总数、按钮内容和跳转插槽。受控模式按已生效的页大小调整页码。
|
|
23
|
+
|
|
3
24
|
## 0.3.0
|
|
4
25
|
|
|
5
26
|
- DataGrid 支持受控查询、远程加载取消与重试、单选和多选、选择保留、自定义列字段与汇总,以及按行键滚动定位。树形行事件返回原始记录,列宽拖动按帧预览并在释放时保存,支持键盘调整和取消。TypeScript 模板引用可使用 `HysDataGridInstance`。
|
package/README.md
CHANGED
|
@@ -1,110 +1,105 @@
|
|
|
1
1
|
# HYS UI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
HYS UI 是面向管理后台和业务应用的 Vue 3 组件库。用它搭建筛选表单、数据列表和项目排期界面。组件支持按需导入、TypeScript 类型提示和主题定制。
|
|
4
4
|
|
|
5
|
-
[在线文档与交互示例](https://lampo1024.github.io/hys-ui/)
|
|
5
|
+
[在线文档与交互示例](https://lampo1024.github.io/hys-ui/) · [npm](https://www.npmjs.com/package/hys-ui) · [更新记录](https://github.com/lampo1024/hys-ui/blob/main/packages/ui/CHANGELOG.md)
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## 按场景找组件
|
|
8
|
+
|
|
9
|
+
每个组件的文档都可以直接试用。展开示例即可复制 Vue 源码,属性、事件和插槽见该页的 API 参考。
|
|
10
|
+
|
|
11
|
+
| 场景 | 可以做什么 | 在线示例 |
|
|
12
|
+
| --- | --- | --- |
|
|
13
|
+
| 表单与输入 | 配置字段联动、异步校验、远程搜索和多选。 | [表单](https://lampo1024.github.io/hys-ui/components/hys-form/) · [下拉选择](https://lampo1024.github.io/hys-ui/components/hys-select/) · [自动补全](https://lampo1024.github.io/hys-ui/components/hys-autocomplete/) |
|
|
14
|
+
| 层级与批量选择 | 按层级挑选分类,在两侧列表之间批量移动成员。 | [树形选择](https://lampo1024.github.io/hys-ui/components/hys-tree-select/) · [穿梭框](https://lampo1024.github.io/hys-ui/components/hys-transfer/) |
|
|
15
|
+
| 日期与排期 | 按日期或周筛选,拖动甘特任务、连接前置依赖、查看排期冲突。 | [日期选择](https://lampo1024.github.io/hys-ui/components/hys-date-picker/) · [日期范围](https://lampo1024.github.io/hys-ui/components/hys-date-range-picker/) · [甘特图](https://lampo1024.github.io/hys-ui/components/hys-gantt/) |
|
|
16
|
+
| 弹层与反馈 | 在对话框中编辑长表单,用抽屉查看详情,用轻提示反馈操作结果。 | [对话框](https://lampo1024.github.io/hys-ui/components/hys-modal/) · [抽屉](https://lampo1024.github.io/hys-ui/components/hys-drawer/) · [轻提示](https://lampo1024.github.io/hys-ui/components/hys-toast/) |
|
|
17
|
+
| 文件与进度 | 选择文件、控制上传队列,显示进度、失败和重试状态。 | [文件上传](https://lampo1024.github.io/hys-ui/components/hys-upload/) · [进度条](https://lampo1024.github.io/hys-ui/components/hys-progress/) |
|
|
18
|
+
|
|
19
|
+
### 三种表格怎么选
|
|
20
|
+
|
|
21
|
+
- **`HysTable`** 适合常规列表和树形数据。支持固定列、展开行、合并单元格、表尾汇总和分页。[表格示例](https://lampo1024.github.io/hys-ui/components/hys-table/)
|
|
22
|
+
- **`HysDataGrid`** 适合让用户自行筛选和整理数据。支持按列搜索、拖拽调整列顺序、列显隐、分组、CSV 导出和服务端查询。[高级表格示例](https://lampo1024.github.io/hys-ui/components/hys-data-grid/)
|
|
23
|
+
- **`HysVirtualTable`** 适合需要连续滚动的大数据列表。按视口渲染行,也可开启列虚拟化。支持固定行列和滚动加载。[虚拟表格示例](https://lampo1024.github.io/hys-ui/components/hys-virtual-table/)
|
|
24
|
+
|
|
25
|
+
例如,任务管理页可以用日期范围和多选下拉框筛选任务,用高级表格展示结果,用对话框编辑记录。需要调整计划时,可以在甘特图里拖动任务、查看前置依赖和撤销排期修改。
|
|
26
|
+
|
|
27
|
+
## 快速开始
|
|
28
|
+
|
|
29
|
+
适用于 Vue 3.5+ 浏览器应用。通过 ESM 命名导入使用组件,无需全局注册或安装 Vue Router。
|
|
8
30
|
|
|
9
31
|
```bash
|
|
10
32
|
npm install hys-ui
|
|
11
33
|
```
|
|
12
34
|
|
|
35
|
+
把下面的任务状态选择示例放到任意 Vue 页面即可运行。项目中可以把 `hys-ui/style.css` 移到应用入口统一导入。
|
|
36
|
+
|
|
13
37
|
```vue
|
|
14
38
|
<script setup lang="ts">
|
|
15
|
-
import {
|
|
39
|
+
import { ref } from 'vue'
|
|
40
|
+
import { HysSelect } from 'hys-ui'
|
|
16
41
|
import 'hys-ui/style.css'
|
|
42
|
+
|
|
43
|
+
const status = ref('all')
|
|
44
|
+
const options = [
|
|
45
|
+
{ label: '全部状态', value: 'all' },
|
|
46
|
+
{ label: '待办', value: 'todo' },
|
|
47
|
+
{ label: '进行中', value: 'in-progress' },
|
|
48
|
+
{ label: '已完成', value: 'done' },
|
|
49
|
+
]
|
|
17
50
|
</script>
|
|
18
51
|
|
|
19
52
|
<template>
|
|
20
|
-
<
|
|
53
|
+
<HysSelect v-model="status" :options="options" aria-label="任务状态" />
|
|
54
|
+
<p>当前状态值:{{ status }}</p>
|
|
21
55
|
</template>
|
|
22
56
|
```
|
|
23
57
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
## 主题和动效
|
|
27
|
-
|
|
28
|
-
在根组件 setup 中调用,参数可以是响应式 ref 或 getter。配置会传递给子组件与 Teleport 浮层。
|
|
29
|
-
|
|
30
|
-
```ts
|
|
31
|
-
import { ref } from 'vue'
|
|
32
|
-
import { provideHysConfig, type HysTheme } from 'hys-ui'
|
|
33
|
-
|
|
34
|
-
const theme = ref<HysTheme>('blue')
|
|
35
|
-
provideHysConfig({ theme, motion: 'subtle' })
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
主题支持 `blue / dark / green / purple / orange / forest`,动效支持 `full / subtle / off`,系统减少动态效果设置优先。组件库不会写入浏览器存储或修改全局页面主题。
|
|
39
|
-
|
|
40
|
-
可以使用 `--hys-ui-primary`、`--hys-ui-surface`、`--hys-ui-text`、`--hys-ui-border`、`--hys-ui-font-family` 等公开变量覆盖组件外观。组件类名与变量采用独立前缀,没有 body/html 全局重置。
|
|
58
|
+
## 用轻提示反馈操作结果
|
|
41
59
|
|
|
42
|
-
|
|
43
|
-
浮层组件统一通过 `popupTransition` 设置展开与收起动效:`scale`(默认柔和缩放)、`fade`(淡入淡出)、`slide`(轻移)、`slide-fade`(轻移缩放)、`none`(关闭)。`popupTransitionDuration` 设置时长,默认 160ms,设为 0 立即切换。该配置适用于选择、日期、自动补全、提及、颜色、提示、菜单,以及表格、树形、头像组、日历事件和甘特图关系等浮层。Modal、Drawer 和 Toast 保留各自的动画配置。
|
|
60
|
+
在组件的 `<script setup>` 里调用 `useHysToast()`,即可在保存、上传等操作后显示提示。下面用定时器模拟上传,完成后更新同一条消息。
|
|
44
61
|
|
|
45
62
|
```vue
|
|
46
|
-
<
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
:popup-transition-duration="200"
|
|
51
|
-
/>
|
|
52
|
-
```
|
|
63
|
+
<script setup lang="ts">
|
|
64
|
+
import { ref } from 'vue'
|
|
65
|
+
import { HysButton, useHysToast } from 'hys-ui'
|
|
66
|
+
import 'hys-ui/style.css'
|
|
53
67
|
|
|
54
|
-
|
|
68
|
+
const toast = useHysToast()
|
|
69
|
+
const uploading = ref(false)
|
|
55
70
|
|
|
56
|
-
|
|
71
|
+
async function simulateUpload() {
|
|
72
|
+
uploading.value = true
|
|
73
|
+
const message = toast.loading('正在上传…')
|
|
57
74
|
|
|
58
|
-
|
|
59
|
-
npm install
|
|
60
|
-
npm run dev:docs
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
访问 http://127.0.0.1:5174。每个组件有独立路由、运行场景、源码、API 与说明,页面状态通过 KeepAlive 保留。API 从源码生成。
|
|
75
|
+
await new Promise(resolve => setTimeout(resolve, 700))
|
|
64
76
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
77
|
+
message.update({ type: 'success', message: '上传完成', duration: 2000 })
|
|
78
|
+
uploading.value = false
|
|
79
|
+
}
|
|
80
|
+
</script>
|
|
69
81
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
npm test
|
|
74
|
-
npm run check:contracts
|
|
75
|
-
npm run check:release
|
|
82
|
+
<template>
|
|
83
|
+
<HysButton :loading="uploading" @click="simulateUpload">模拟上传</HysButton>
|
|
84
|
+
</template>
|
|
76
85
|
```
|
|
77
86
|
|
|
78
|
-
|
|
87
|
+
轻提示默认在顶部居中。可设置显示位置、停留时长和队列上限,也可以合并重复消息。[轻提示 API 与示例](https://lampo1024.github.io/hys-ui/components/hys-toast/)
|
|
79
88
|
|
|
80
|
-
##
|
|
89
|
+
## 主题与动效
|
|
81
90
|
|
|
82
|
-
|
|
91
|
+
在根组件的 `<script setup>` 中调用 `provideHysConfig`,下级组件及其浮层会继承配置。主题支持响应式切换。
|
|
83
92
|
|
|
84
93
|
```ts
|
|
85
|
-
import {
|
|
86
|
-
|
|
87
|
-
// 在组件 setup 中使用
|
|
88
|
-
const toast = useHysToast({ maxCount: 5 })
|
|
89
|
-
toast.success('保存成功')
|
|
90
|
-
const task = toast.loading('正在上传…')
|
|
91
|
-
task.update({ type: 'success', message: '上传完成', duration: 2000 })
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
## 发布
|
|
95
|
-
|
|
96
|
-
根工作区和文档应用为私有,npm 包名为 `hys-ui`,版本 `0.3.0`,MIT 公开发布。
|
|
94
|
+
import { ref } from 'vue'
|
|
95
|
+
import { provideHysConfig, type HysTheme } from 'hys-ui'
|
|
97
96
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
npm login --registry=https://registry.npmjs.org/
|
|
101
|
-
npm run release:ui
|
|
97
|
+
const theme = ref<HysTheme>('blue')
|
|
98
|
+
provideHysConfig({ theme, motion: 'subtle' })
|
|
102
99
|
```
|
|
103
100
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
后续版本按语义化版本发布,并更新 CHANGELOG。暂不承诺 SSR/Nuxt 支持。
|
|
101
|
+
内置主题有 `blue`、`dark`、`green`、`purple`、`orange` 和 `forest`。可用 `--hys-ui-primary`、`--hys-ui-surface` 等 CSS 变量调整外观。动效可设为 `full`、`subtle` 或 `off`,并遵循系统的减少动态效果设置。支持浮层动效的组件还可以单独设置 `popup-transition` 和 `popup-transition-duration`。
|
|
107
102
|
|
|
108
|
-
##
|
|
103
|
+
## 源码与问题反馈
|
|
109
104
|
|
|
110
|
-
[MIT](LICENSE)
|
|
105
|
+
[GitHub 仓库](https://github.com/lampo1024/hys-ui) · [提交问题](https://github.com/lampo1024/hys-ui/issues) · [MIT 许可证](https://github.com/lampo1024/hys-ui/blob/main/LICENSE)
|
|
@@ -1,43 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
const
|
|
5
|
-
__name: "HysAnimatedNumber",
|
|
6
|
-
props: {
|
|
7
|
-
value: {},
|
|
8
|
-
duration: { default: 650 },
|
|
9
|
-
decimals: { default: 0 }
|
|
10
|
-
},
|
|
11
|
-
setup(o) {
|
|
12
|
-
const l = H(), { effectiveMotion: u } = R(), t = o, n = b(Number.isFinite(t.value) ? t.value : 0);
|
|
13
|
-
let a = 0, r = !0;
|
|
14
|
-
function i(e) {
|
|
15
|
-
return Number.isFinite(e) ? e : 0;
|
|
16
|
-
}
|
|
17
|
-
function f(e) {
|
|
18
|
-
if (e = i(e), cancelAnimationFrame(a), u.value === "off" || !Number.isFinite(t.duration) || t.duration <= 0) {
|
|
19
|
-
n.value = e;
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
const s = n.value, v = performance.now(), h = Math.max(1, t.duration);
|
|
23
|
-
function m(p) {
|
|
24
|
-
const c = Math.min(1, (p - v) / h), F = 1 - Math.pow(1 - c, 3);
|
|
25
|
-
n.value = s + (e - s) * F, c < 1 && (a = requestAnimationFrame(m));
|
|
26
|
-
}
|
|
27
|
-
a = requestAnimationFrame(m);
|
|
28
|
-
}
|
|
29
|
-
return M(() => [t.value, t.duration, u.value], ([e]) => {
|
|
30
|
-
r ? f(e) : n.value = i(e);
|
|
31
|
-
}), x(() => {
|
|
32
|
-
r = !1, cancelAnimationFrame(a);
|
|
33
|
-
}), y(() => {
|
|
34
|
-
r = !0, n.value = i(t.value);
|
|
35
|
-
}), N(() => cancelAnimationFrame(a)), (e, d) => (w(), B("span", k(q(l), {
|
|
36
|
-
class: "hys-ui-motion-number",
|
|
37
|
-
"aria-label": String(i(o.value))
|
|
38
|
-
}), D(n.value.toFixed(Number.isFinite(o.decimals) ? Math.max(0, Math.min(5, Math.floor(o.decimals))) : 0)), 17, S));
|
|
39
|
-
}
|
|
40
|
-
});
|
|
1
|
+
import o from "./HysAnimatedNumber2.vue.js";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import t from "../../_virtual/_plugin-vue_export-helper.js";
|
|
4
|
+
const a = /* @__PURE__ */ t(o, [["__scopeId", "data-v-11d35ec9"]]);
|
|
41
5
|
export {
|
|
42
|
-
|
|
6
|
+
a as default
|
|
43
7
|
};
|
|
@@ -1,4 +1,148 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { defineComponent as Z, useSlots as _, ref as G, watch as E, computed as c, onMounted as ee, onActivated as te, onDeactivated as ne, onBeforeUnmount as ae, openBlock as m, createElementBlock as v, mergeProps as ie, unref as b, renderSlot as x, createTextVNode as M, toDisplayString as N, createCommentVNode as V, createElementVNode as oe, normalizeStyle as re, normalizeProps as $, guardReactiveProps as C, createBlock as se, Fragment as ue } from "vue";
|
|
2
|
+
import { useHysRootAttrs as le } from "../../config.js";
|
|
3
|
+
import { useMotion as ce } from "../../motion/useMotion.js";
|
|
4
|
+
import { decimal as me, decimalText as I, decimalRound as de } from "../../composables/numberInput.js";
|
|
5
|
+
const fe = {
|
|
6
|
+
key: 0,
|
|
7
|
+
class: "hys-ui-motion-number-title"
|
|
8
|
+
}, ve = ["role"], pe = {
|
|
9
|
+
key: 0,
|
|
10
|
+
class: "hys-ui-motion-number-affix"
|
|
11
|
+
}, he = {
|
|
12
|
+
key: 1,
|
|
13
|
+
class: "hys-ui-motion-number-affix"
|
|
14
|
+
}, xe = /* @__PURE__ */ Z({
|
|
15
|
+
__name: "HysAnimatedNumber",
|
|
16
|
+
props: {
|
|
17
|
+
value: { default: 0 },
|
|
18
|
+
duration: { default: 650 },
|
|
19
|
+
decimals: {},
|
|
20
|
+
precision: {},
|
|
21
|
+
groupSeparator: {},
|
|
22
|
+
decimalSeparator: { default: "." },
|
|
23
|
+
title: {},
|
|
24
|
+
prefix: {},
|
|
25
|
+
suffix: {},
|
|
26
|
+
valueStyle: { type: [Boolean, null, String, Object, Array] },
|
|
27
|
+
formatter: {},
|
|
28
|
+
deadline: {},
|
|
29
|
+
format: { default: "HH:mm:ss" }
|
|
30
|
+
},
|
|
31
|
+
emits: ["change", "finish"],
|
|
32
|
+
setup(r, { expose: L, emit: U }) {
|
|
33
|
+
const t = r, j = U, A = _(), X = le(), { effectiveMotion: P } = ce(), F = (e) => typeof e == "number" && !Number.isFinite(e) ? 0 : e, s = G(F(t.value));
|
|
34
|
+
let p = 0, d = !1;
|
|
35
|
+
function q() {
|
|
36
|
+
if (cancelAnimationFrame(p), !d) return;
|
|
37
|
+
const e = F(t.value), n = s.value, u = t.duration;
|
|
38
|
+
if (typeof e != "number" || typeof n != "number" || n === e || t.deadline !== void 0 || P.value === "off" || !Number.isFinite(u) || u <= 0) {
|
|
39
|
+
s.value = e;
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const a = performance.now(), o = (l) => {
|
|
43
|
+
const R = Math.max(0, Math.min(1, (l - a) / u)), W = 1 - (1 - R) ** 3;
|
|
44
|
+
s.value = R === 1 ? e : n * (1 - W) + e * W, R < 1 && (p = requestAnimationFrame(o));
|
|
45
|
+
};
|
|
46
|
+
p = requestAnimationFrame(o);
|
|
47
|
+
}
|
|
48
|
+
E([() => t.value, () => t.duration, P], q);
|
|
49
|
+
const f = c(() => {
|
|
50
|
+
const e = t.deadline instanceof Date ? t.deadline.getTime() : t.deadline;
|
|
51
|
+
return e !== void 0 && Number.isFinite(e) ? e : void 0;
|
|
52
|
+
}), w = () => f.value === void 0 ? 0 : Math.max(
|
|
53
|
+
0,
|
|
54
|
+
Math.min(Number.MAX_SAFE_INTEGER, f.value - Date.now())
|
|
55
|
+
), i = G(w()), D = c(
|
|
56
|
+
() => t.format.match(/\[[^\]]*\]|SSS|DD?|HH?|mm?|ss?|[\s\S]/g) ?? []
|
|
57
|
+
), h = c(() => D.value.includes("SSS"));
|
|
58
|
+
let H, T, k;
|
|
59
|
+
function y() {
|
|
60
|
+
if (clearTimeout(H), !d || f.value === void 0) return;
|
|
61
|
+
const e = f.value;
|
|
62
|
+
if (i.value = w(), i.value !== k && (k = i.value, j("change", i.value)), i.value === 0) {
|
|
63
|
+
T !== e && (T = e, j("finish"));
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const n = h.value ? 16 : 1e3;
|
|
67
|
+
H = setTimeout(
|
|
68
|
+
y,
|
|
69
|
+
h.value ? n : i.value % n || n
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
E(f, () => {
|
|
73
|
+
T = void 0, k = void 0, i.value = w(), q(), y();
|
|
74
|
+
}), E(h, y);
|
|
75
|
+
function z() {
|
|
76
|
+
d || (d = !0, s.value = F(t.value), y());
|
|
77
|
+
}
|
|
78
|
+
function O() {
|
|
79
|
+
d = !1, clearTimeout(H), cancelAnimationFrame(p);
|
|
80
|
+
}
|
|
81
|
+
ee(z), te(z), ne(O), ae(O);
|
|
82
|
+
const J = c(() => {
|
|
83
|
+
const e = t.precision ?? t.decimals;
|
|
84
|
+
return e === void 0 && typeof s.value == "string" ? void 0 : e !== void 0 && Number.isFinite(e) ? Math.max(0, Math.min(20, Math.floor(e))) : 0;
|
|
85
|
+
});
|
|
86
|
+
function K() {
|
|
87
|
+
const e = me(s.value);
|
|
88
|
+
if (!e) return String(s.value);
|
|
89
|
+
const n = J.value, u = n === void 0 ? I(e) : I(de(e, n), n), [a, o] = u.split("."), l = t.groupSeparator ? a.replace(/\B(?=(\d{3})+(?!\d))/g, () => t.groupSeparator) : a;
|
|
90
|
+
return o === void 0 ? l : l + t.decimalSeparator + o;
|
|
91
|
+
}
|
|
92
|
+
function Q() {
|
|
93
|
+
let e = h.value ? Math.floor(i.value) : Math.ceil(i.value / 1e3) * 1e3;
|
|
94
|
+
const n = { D: 864e5, H: 36e5, m: 6e4, s: 1e3, S: 1 }, u = /* @__PURE__ */ new Map();
|
|
95
|
+
for (const [a, o] of Object.entries(n))
|
|
96
|
+
D.value.some(
|
|
97
|
+
(l) => l[0] === a && /^(D{1,2}|H{1,2}|m{1,2}|s{1,2}|SSS)$/.test(l)
|
|
98
|
+
) && (u.set(a, Math.floor(e / o)), e %= o);
|
|
99
|
+
return D.value.map((a) => {
|
|
100
|
+
if (a.startsWith("[") && a.endsWith("]"))
|
|
101
|
+
return a.slice(1, -1);
|
|
102
|
+
const o = u.get(a[0]);
|
|
103
|
+
return o === void 0 ? a : String(o).padStart(a.length, "0");
|
|
104
|
+
}).join("");
|
|
105
|
+
}
|
|
106
|
+
const S = c(() => t.deadline !== void 0), B = c(
|
|
107
|
+
() => S.value ? Q() : K()
|
|
108
|
+
), g = c(() => ({
|
|
109
|
+
value: S.value ? i.value : s.value,
|
|
110
|
+
displayValue: B.value,
|
|
111
|
+
remaining: S.value ? i.value : void 0
|
|
112
|
+
})), Y = ({ value: e }) => e;
|
|
113
|
+
return L({ displayValue: B, remaining: i }), (e, n) => (m(), v("span", ie(b(X), { class: "hys-ui-motion-number" }), [
|
|
114
|
+
r.title || b(A).title ? (m(), v("span", fe, [
|
|
115
|
+
x(e.$slots, "title", {}, () => [
|
|
116
|
+
M(N(r.title), 1)
|
|
117
|
+
], !0)
|
|
118
|
+
])) : V("", !0),
|
|
119
|
+
oe("span", {
|
|
120
|
+
class: "hys-ui-motion-number-value",
|
|
121
|
+
style: re(r.valueStyle),
|
|
122
|
+
role: S.value ? "timer" : void 0
|
|
123
|
+
}, [
|
|
124
|
+
r.prefix || b(A).prefix ? (m(), v("span", pe, [
|
|
125
|
+
x(e.$slots, "prefix", $(C(g.value)), () => [
|
|
126
|
+
M(N(r.prefix), 1)
|
|
127
|
+
], !0)
|
|
128
|
+
])) : V("", !0),
|
|
129
|
+
x(e.$slots, "formatter", $(C(g.value)), () => [
|
|
130
|
+
r.formatter ? (m(), se(Y, {
|
|
131
|
+
key: 0,
|
|
132
|
+
value: r.formatter(g.value)
|
|
133
|
+
}, null, 8, ["value"])) : (m(), v(ue, { key: 1 }, [
|
|
134
|
+
M(N(B.value), 1)
|
|
135
|
+
], 64))
|
|
136
|
+
], !0),
|
|
137
|
+
r.suffix || b(A).suffix ? (m(), v("span", he, [
|
|
138
|
+
x(e.$slots, "suffix", $(C(g.value)), () => [
|
|
139
|
+
M(N(r.suffix), 1)
|
|
140
|
+
], !0)
|
|
141
|
+
])) : V("", !0)
|
|
142
|
+
], 12, ve)
|
|
143
|
+
], 16));
|
|
144
|
+
}
|
|
145
|
+
});
|
|
2
146
|
export {
|
|
3
|
-
|
|
147
|
+
xe as default
|
|
4
148
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import o from "./HysButton2.vue.js";
|
|
2
2
|
/* empty css */
|
|
3
3
|
import t from "../../_virtual/_plugin-vue_export-helper.js";
|
|
4
|
-
const
|
|
4
|
+
const p = /* @__PURE__ */ t(o, [["__scopeId", "data-v-f242e243"]]);
|
|
5
5
|
export {
|
|
6
|
-
|
|
6
|
+
p as default
|
|
7
7
|
};
|