@veltra/mobile 1.1.0 → 1.1.2
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/dist/components/_internal/bottom-sheet/bottom-sheet.js +68 -0
- package/dist/components/_internal/bottom-sheet/bottom-sheet.js.map +1 -0
- package/dist/components/_internal/bottom-sheet/style.d.ts +1 -0
- package/dist/components/_internal/bottom-sheet/style.js +1 -0
- package/dist/components/_internal/bottom-sheet/style2.css +121 -0
- package/dist/components/_internal/overlay-container.js +16 -0
- package/dist/components/_internal/overlay-container.js.map +1 -0
- package/dist/components/avatar/avatar.js +47 -0
- package/dist/components/avatar/avatar.js.map +1 -0
- package/dist/components/avatar/style.d.ts +1 -0
- package/dist/components/avatar/style.js +1 -0
- package/dist/components/avatar/style2.css +68 -0
- package/dist/components/badge/badge.js +66 -0
- package/dist/components/badge/badge.js.map +1 -0
- package/dist/components/badge/style.d.ts +1 -0
- package/dist/components/badge/style.js +1 -0
- package/dist/components/badge/style2.css +94 -0
- package/dist/components/button/button.js +88 -0
- package/dist/components/button/button.js.map +1 -0
- package/dist/components/button/style.d.ts +1 -0
- package/dist/components/button/style.js +1 -0
- package/dist/components/button/style2.css +515 -0
- package/dist/components/card/card.js +31 -0
- package/dist/components/card/card.js.map +1 -0
- package/dist/components/card/style.d.ts +1 -0
- package/dist/components/card/style.js +1 -0
- package/dist/components/card/style2.css +49 -0
- package/dist/components/cascade/cascade.js +539 -0
- package/dist/components/cascade/cascade.js.map +1 -0
- package/dist/components/cascade/node.js +19 -0
- package/dist/components/cascade/node.js.map +1 -0
- package/dist/components/cascade/style.d.ts +1 -0
- package/dist/components/cascade/style.js +2 -0
- package/dist/components/cascade/style2.css +378 -0
- package/dist/components/check-tag/check-tag.js +40 -0
- package/dist/components/check-tag/check-tag.js.map +1 -0
- package/dist/components/check-tag/style.d.ts +1 -0
- package/dist/components/check-tag/style.js +1 -0
- package/dist/components/check-tag/style2.css +60 -0
- package/dist/components/checkbox/checkbox.js +86 -0
- package/dist/components/checkbox/checkbox.js.map +1 -0
- package/dist/components/checkbox/style.d.ts +1 -0
- package/dist/components/checkbox/style.js +2 -0
- package/dist/components/checkbox/style2.css +143 -0
- package/dist/components/checkbox-group/checkbox-group.js +109 -0
- package/dist/components/checkbox-group/checkbox-group.js.map +1 -0
- package/dist/components/checkbox-group/style.d.ts +1 -0
- package/dist/components/checkbox-group/style.js +2 -0
- package/dist/components/checkbox-group/style2.css +73 -0
- package/dist/components/collapse/collapse-item.js +116 -0
- package/dist/components/collapse/collapse-item.js.map +1 -0
- package/dist/components/collapse/collapse.js +94 -0
- package/dist/components/collapse/collapse.js.map +1 -0
- package/dist/components/collapse/di.js +6 -0
- package/dist/components/collapse/di.js.map +1 -0
- package/dist/components/collapse/style.d.ts +1 -0
- package/dist/components/collapse/style.js +1 -0
- package/dist/components/collapse/style2.css +164 -0
- package/dist/components/date-picker/date-picker.js +303 -0
- package/dist/components/date-picker/date-picker.js.map +1 -0
- package/dist/components/date-picker/style.d.ts +1 -0
- package/dist/components/date-picker/style.js +2 -0
- package/dist/components/date-picker/style2.css +221 -0
- package/dist/components/descriptions/descriptions-item.js +15 -0
- package/dist/components/descriptions/descriptions-item.js.map +1 -0
- package/dist/components/descriptions/descriptions.js +56 -0
- package/dist/components/descriptions/descriptions.js.map +1 -0
- package/dist/components/descriptions/style.d.ts +1 -0
- package/dist/components/descriptions/style.js +1 -0
- package/dist/components/descriptions/style2.css +112 -0
- package/dist/components/dialog/dialog.js +157 -0
- package/dist/components/dialog/dialog.js.map +1 -0
- package/dist/components/dialog/style.d.ts +2 -0
- package/dist/components/dialog/style.js +4 -0
- package/dist/components/dialog/style2.css +162 -0
- package/dist/components/divider/divider.js +40 -0
- package/dist/components/divider/divider.js.map +1 -0
- package/dist/components/divider/style.d.ts +1 -0
- package/dist/components/divider/style.js +1 -0
- package/dist/components/divider/style2.css +77 -0
- package/dist/components/drawer/drawer.js +173 -0
- package/dist/components/drawer/drawer.js.map +1 -0
- package/dist/components/drawer/style.d.ts +1 -0
- package/dist/components/drawer/style.js +2 -0
- package/dist/components/drawer/style2.css +251 -0
- package/dist/components/empty/empty.js +25 -0
- package/dist/components/empty/empty.js.map +1 -0
- package/dist/components/empty/style.d.ts +1 -0
- package/dist/components/empty/style.js +1 -0
- package/dist/components/empty/style2.css +50 -0
- package/dist/components/form/form.js +112 -0
- package/dist/components/form/form.js.map +1 -0
- package/dist/components/form/is-field-modified.js +11 -0
- package/dist/components/form/is-field-modified.js.map +1 -0
- package/dist/components/form/style.d.ts +1 -0
- package/dist/components/form/style.js +2 -0
- package/dist/components/form/style2.css +69 -0
- package/dist/components/form/use-form-fields.js +81 -0
- package/dist/components/form/use-form-fields.js.map +1 -0
- package/dist/components/form/use-node-interceptor.js +78 -0
- package/dist/components/form/use-node-interceptor.js.map +1 -0
- package/dist/components/form-item/form-item.js +127 -0
- package/dist/components/form-item/form-item.js.map +1 -0
- package/dist/components/form-item/helper.js +10 -0
- package/dist/components/form-item/helper.js.map +1 -0
- package/dist/components/form-item/style.d.ts +1 -0
- package/dist/components/form-item/style.js +1 -0
- package/dist/components/form-item/style2.css +108 -0
- package/dist/components/form-item/validate.js +96 -0
- package/dist/components/form-item/validate.js.map +1 -0
- package/dist/components/icon/icon.js +25 -0
- package/dist/components/icon/icon.js.map +1 -0
- package/dist/components/icon/style.d.ts +1 -0
- package/dist/components/icon/style.js +1 -0
- package/dist/components/icon/style2.css +58 -0
- package/dist/components/input/input.js +184 -0
- package/dist/components/input/input.js.map +1 -0
- package/dist/components/input/style.d.ts +1 -0
- package/dist/components/input/style.js +1 -0
- package/dist/components/input/style2.css +142 -0
- package/dist/components/list/list-item.js +18 -0
- package/dist/components/list/list-item.js.map +1 -0
- package/dist/components/list/list.js +27 -0
- package/dist/components/list/list.js.map +1 -0
- package/dist/components/list/style.d.ts +1 -0
- package/dist/components/list/style.js +1 -0
- package/dist/components/list/style2.css +58 -0
- package/dist/components/loading/directive.d.ts +3 -0
- package/dist/components/loading/directive.js +28 -0
- package/dist/components/loading/directive.js.map +1 -0
- package/dist/components/loading/index.d.ts +3 -0
- package/dist/components/loading/loading.js +31 -0
- package/dist/components/loading/loading.js.map +1 -0
- package/dist/components/loading/style.d.ts +1 -0
- package/dist/components/loading/style.js +2 -0
- package/dist/components/loading/style2.css +144 -0
- package/dist/components/message/helper.js +22 -0
- package/dist/components/message/helper.js.map +1 -0
- package/dist/components/message/index.d.ts +3 -0
- package/dist/components/message/message-box.js +37 -0
- package/dist/components/message/message-box.js.map +1 -0
- package/dist/components/message/message.d.ts +4 -0
- package/dist/components/message/message.js +63 -0
- package/dist/components/message/message.js.map +1 -0
- package/dist/components/message/message2.js +107 -0
- package/dist/components/message/message2.js.map +1 -0
- package/dist/components/message/style.d.ts +1 -0
- package/dist/components/message/style.js +1 -0
- package/dist/components/message/style2.css +148 -0
- package/dist/components/message-confirm/index.d.ts +3 -0
- package/dist/components/message-confirm/message-confirm-box.js +38 -0
- package/dist/components/message-confirm/message-confirm-box.js.map +1 -0
- package/dist/components/message-confirm/message-confirm.d.ts +4 -0
- package/dist/components/message-confirm/message-confirm.js +62 -0
- package/dist/components/message-confirm/message-confirm.js.map +1 -0
- package/dist/components/message-confirm/message-confirm2.js +118 -0
- package/dist/components/message-confirm/message-confirm2.js.map +1 -0
- package/dist/components/message-confirm/style.d.ts +1 -0
- package/dist/components/message-confirm/style.js +1 -0
- package/dist/components/message-confirm/style2.css +135 -0
- package/dist/components/multi-select/multi-select.js +368 -0
- package/dist/components/multi-select/multi-select.js.map +1 -0
- package/dist/components/multi-select/style.d.ts +1 -0
- package/dist/components/multi-select/style.js +2 -0
- package/dist/components/multi-select/style2.css +340 -0
- package/dist/components/number-input/number-input.js +366 -0
- package/dist/components/number-input/number-input.js.map +1 -0
- package/dist/components/number-input/style.d.ts +1 -0
- package/dist/components/number-input/style.js +2 -0
- package/dist/components/number-input/style2.css +117 -0
- package/dist/components/password-input/password-input.js +141 -0
- package/dist/components/password-input/password-input.js.map +1 -0
- package/dist/components/password-input/style.d.ts +1 -0
- package/dist/components/password-input/style.js +2 -0
- package/dist/components/password-input/style2.css +54 -0
- package/dist/components/progress/progress.js +83 -0
- package/dist/components/progress/progress.js.map +1 -0
- package/dist/components/progress/style.d.ts +1 -0
- package/dist/components/progress/style.js +1 -0
- package/dist/components/progress/style2.css +113 -0
- package/dist/components/radio/radio.js +68 -0
- package/dist/components/radio/radio.js.map +1 -0
- package/dist/components/radio/style.d.ts +1 -0
- package/dist/components/radio/style.js +1 -0
- package/dist/components/radio/style2.css +130 -0
- package/dist/components/radio-group/radio-group.js +83 -0
- package/dist/components/radio-group/radio-group.js.map +1 -0
- package/dist/components/radio-group/style.d.ts +1 -0
- package/dist/components/radio-group/style.js +2 -0
- package/dist/components/radio-group/style2.css +41 -0
- package/dist/components/segment/segment.js +143 -0
- package/dist/components/segment/segment.js.map +1 -0
- package/dist/components/segment/style.d.ts +1 -0
- package/dist/components/segment/style.js +1 -0
- package/dist/components/segment/style2.css +145 -0
- package/dist/components/select/select.js +254 -0
- package/dist/components/select/select.js.map +1 -0
- package/dist/components/select/style.d.ts +1 -0
- package/dist/components/select/style.js +2 -0
- package/dist/components/select/style2.css +219 -0
- package/dist/components/select/use-options.js +140 -0
- package/dist/components/select/use-options.js.map +1 -0
- package/dist/components/skeleton/skeleton.js +73 -0
- package/dist/components/skeleton/skeleton.js.map +1 -0
- package/dist/components/skeleton/style.d.ts +1 -0
- package/dist/components/skeleton/style.js +1 -0
- package/dist/components/skeleton/style2.css +95 -0
- package/dist/components/space/space.js +46 -0
- package/dist/components/space/space.js.map +1 -0
- package/dist/components/space/style.d.ts +1 -0
- package/dist/components/space/style.js +1 -0
- package/dist/components/space/style2.css +52 -0
- package/dist/components/steps/steps.js +98 -0
- package/dist/components/steps/steps.js.map +1 -0
- package/dist/components/steps/style.d.ts +1 -0
- package/dist/components/steps/style.js +1 -0
- package/dist/components/steps/style2.css +238 -0
- package/dist/components/switch/style.d.ts +1 -0
- package/dist/components/switch/style.js +1 -0
- package/dist/components/switch/style2.css +141 -0
- package/dist/components/switch/switch.js +82 -0
- package/dist/components/switch/switch.js.map +1 -0
- package/dist/components/tabs/style.d.ts +1 -0
- package/dist/components/tabs/style.js +1 -0
- package/dist/components/tabs/style2.css +243 -0
- package/dist/components/tabs/tabs.js +131 -0
- package/dist/components/tabs/tabs.js.map +1 -0
- package/dist/components/tag/style.d.ts +1 -0
- package/dist/components/tag/style.js +1 -0
- package/dist/components/tag/style2.css +200 -0
- package/dist/components/tag/tag.js +51 -0
- package/dist/components/tag/tag.js.map +1 -0
- package/dist/components/text/style.d.ts +1 -0
- package/dist/components/text/style.js +1 -0
- package/dist/components/text/style2.css +67 -0
- package/dist/components/text/text.js +54 -0
- package/dist/components/text/text.js.map +1 -0
- package/dist/components/textarea/style.d.ts +1 -0
- package/dist/components/textarea/style.js +1 -0
- package/dist/components/textarea/style2.css +141 -0
- package/dist/components/textarea/textarea.js +151 -0
- package/dist/components/textarea/textarea.js.map +1 -0
- package/dist/components/textarea/utils.js +16 -0
- package/dist/components/textarea/utils.js.map +1 -0
- package/dist/components/time-picker/style.d.ts +1 -0
- package/dist/components/time-picker/style.js +2 -0
- package/dist/components/time-picker/style2.css +206 -0
- package/dist/components/time-picker/time-picker.js +285 -0
- package/dist/components/time-picker/time-picker.js.map +1 -0
- package/dist/components/timeline/style.d.ts +1 -0
- package/dist/components/timeline/style.js +1 -0
- package/dist/components/timeline/style2.css +101 -0
- package/dist/components/timeline/timeline-item.js +31 -0
- package/dist/components/timeline/timeline-item.js.map +1 -0
- package/dist/components/timeline/timeline.js +16 -0
- package/dist/components/timeline/timeline.js.map +1 -0
- package/dist/components/uploader/style.d.ts +1 -0
- package/dist/components/uploader/style.js +1 -0
- package/dist/components/uploader/style2.css +218 -0
- package/dist/components/uploader/uploader.js +303 -0
- package/dist/components/uploader/uploader.js.map +1 -0
- package/dist/index.d.ts +97 -0
- package/dist/index.js +52 -0
- package/dist/shared/bem.js +13 -0
- package/dist/shared/bem.js.map +1 -0
- package/dist/shared/use-scroll-lock.d.ts +9 -0
- package/dist/shared/use-scroll-lock.js +93 -0
- package/dist/shared/use-scroll-lock.js.map +1 -0
- package/dist/shared/use-touch-gesture.d.ts +61 -0
- package/dist/shared/use-touch-gesture.js +91 -0
- package/dist/shared/use-touch-gesture.js.map +1 -0
- package/dist/types/avatar.d.ts +26 -0
- package/dist/types/badge.d.ts +25 -0
- package/dist/types/button.d.ts +44 -0
- package/dist/types/card.d.ts +12 -0
- package/dist/types/cascade.d.ts +77 -0
- package/dist/types/check-tag.d.ts +18 -0
- package/dist/types/checkbox-group.d.ts +19 -0
- package/dist/types/checkbox.d.ts +14 -0
- package/dist/types/collapse.d.ts +66 -0
- package/dist/types/date-picker.d.ts +35 -0
- package/dist/types/descriptions.d.ts +20 -0
- package/dist/types/dialog.d.ts +49 -0
- package/dist/types/divider.d.ts +12 -0
- package/dist/types/drawer.d.ts +32 -0
- package/dist/types/empty.d.ts +15 -0
- package/dist/types/form-item.d.ts +20 -0
- package/dist/types/form.d.ts +51 -0
- package/dist/types/icon.d.ts +9 -0
- package/dist/types/input.d.ts +48 -0
- package/dist/types/list.d.ts +10 -0
- package/dist/types/loading.d.ts +16 -0
- package/dist/types/message-confirm.d.ts +65 -0
- package/dist/types/message.d.ts +64 -0
- package/dist/types/multi-select.d.ts +35 -0
- package/dist/types/number-input.d.ts +30 -0
- package/dist/types/password-input.d.ts +15 -0
- package/dist/types/progress.d.ts +19 -0
- package/dist/types/radio-group.d.ts +32 -0
- package/dist/types/radio.d.ts +17 -0
- package/dist/types/segment.d.ts +38 -0
- package/dist/types/select.d.ts +62 -0
- package/dist/types/skeleton.d.ts +22 -0
- package/dist/types/space.d.ts +18 -0
- package/dist/types/steps.d.ts +61 -0
- package/dist/types/switch.d.ts +16 -0
- package/dist/types/tabs.d.ts +59 -0
- package/dist/types/tag.d.ts +18 -0
- package/dist/types/text.d.ts +26 -0
- package/dist/types/textarea.d.ts +70 -0
- package/dist/types/time-picker.d.ts +36 -0
- package/dist/types/timeline.d.ts +14 -0
- package/dist/types/uploader.d.ts +47 -0
- package/package.json +1 -1
- package/src/components/descriptions/descriptions.vue +12 -3
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
@charset "UTF-8";
|
|
2
|
+
/** flex布局 */
|
|
3
|
+
/**
|
|
4
|
+
* 设置css变量
|
|
5
|
+
* 参数1:变量前缀
|
|
6
|
+
* 参数2: 一个由值组成的列表或者由key, value组成的map
|
|
7
|
+
* css-var(height, (
|
|
8
|
+
* large: 40px
|
|
9
|
+
* default: 32px
|
|
10
|
+
* small: 24px
|
|
11
|
+
* ))
|
|
12
|
+
* 生成的css变量:
|
|
13
|
+
* --u-height-large: 40px;
|
|
14
|
+
* --u-height-default: 32px;
|
|
15
|
+
* --u-height-small: 24px;
|
|
16
|
+
*/
|
|
17
|
+
/** 暗色:`UITheme.render()` 按主题系列写入 html[data-theme] */
|
|
18
|
+
/**
|
|
19
|
+
* 移动端密度 token 层(`--um-*` 前缀,纯 SCSS,不经运行时注入)
|
|
20
|
+
*
|
|
21
|
+
* - 值表是编译期回退值的单一来源:组件样式一律经 `use-var()` 取密度值,
|
|
22
|
+
* 产出 `var(--um-<name>, 回退值)`,宿主可在任意层级用 `--um-*` 覆盖
|
|
23
|
+
* - 配色、圆角、阴影等观感 token 仍走 `@veltra/styles` 的 `--u-*` 预设体系
|
|
24
|
+
* - 本模块只提供值与函数,不产出任何 CSS;组件 SCSS 以
|
|
25
|
+
* `@use '../../styles/tokens' as t;` 引用(下划线 partial,禁止单独编译)
|
|
26
|
+
*/
|
|
27
|
+
.um-multi-select {
|
|
28
|
+
display: flex;
|
|
29
|
+
align-items: center;
|
|
30
|
+
width: 100%;
|
|
31
|
+
box-sizing: border-box;
|
|
32
|
+
gap: var(--um-spacing-sm, 8px);
|
|
33
|
+
padding: 0 var(--um-spacing-md, 12px);
|
|
34
|
+
border: var(--u-border);
|
|
35
|
+
border-radius: var(--um-control-radius-default, 6px);
|
|
36
|
+
background-color: var(--u-bg-color-top);
|
|
37
|
+
color: var(--u-text-color-main);
|
|
38
|
+
font-size: var(--um-font-size-main, 16px);
|
|
39
|
+
cursor: pointer;
|
|
40
|
+
-webkit-tap-highlight-color: transparent;
|
|
41
|
+
transition: border-color var(--u-transition-fast) var(--u-transition-ease), box-shadow var(--u-transition-fast) var(--u-transition-ease);
|
|
42
|
+
}
|
|
43
|
+
.um-multi-select--small {
|
|
44
|
+
min-height: max(var(--um-control-height-small, 32px), var(--um-touch-target, 44px));
|
|
45
|
+
}
|
|
46
|
+
.um-multi-select--default {
|
|
47
|
+
min-height: max(var(--um-control-height-default, 40px), var(--um-touch-target, 44px));
|
|
48
|
+
}
|
|
49
|
+
.um-multi-select--large {
|
|
50
|
+
min-height: max(var(--um-control-height-large, 48px), var(--um-touch-target, 44px));
|
|
51
|
+
}
|
|
52
|
+
.um-multi-select:active {
|
|
53
|
+
border-color: var(--u-color-primary);
|
|
54
|
+
}
|
|
55
|
+
.um-multi-select:focus-visible {
|
|
56
|
+
box-shadow: var(--u-focus-ring);
|
|
57
|
+
}
|
|
58
|
+
.um-multi-select.is-active {
|
|
59
|
+
border-color: var(--u-color-primary);
|
|
60
|
+
}
|
|
61
|
+
.um-multi-select.is-active .um-multi-select__arrow {
|
|
62
|
+
transform: rotate(180deg);
|
|
63
|
+
}
|
|
64
|
+
.um-multi-select.is-disabled {
|
|
65
|
+
cursor: not-allowed;
|
|
66
|
+
color: var(--u-text-color-disabled);
|
|
67
|
+
background-color: var(--u-bg-color-middle);
|
|
68
|
+
}
|
|
69
|
+
.um-multi-select.is-disabled .um-multi-select__arrow {
|
|
70
|
+
color: var(--u-text-color-disabled);
|
|
71
|
+
}
|
|
72
|
+
.um-multi-select__value {
|
|
73
|
+
flex: 1;
|
|
74
|
+
min-width: 0;
|
|
75
|
+
overflow: hidden;
|
|
76
|
+
text-overflow: ellipsis;
|
|
77
|
+
white-space: nowrap;
|
|
78
|
+
}
|
|
79
|
+
.um-multi-select__value.is-placeholder {
|
|
80
|
+
color: var(--u-text-color-placeholder);
|
|
81
|
+
}
|
|
82
|
+
.um-multi-select__tags {
|
|
83
|
+
flex: 1;
|
|
84
|
+
min-width: 0;
|
|
85
|
+
display: flex;
|
|
86
|
+
flex-wrap: nowrap;
|
|
87
|
+
align-items: center;
|
|
88
|
+
gap: var(--um-spacing-xs, 4px);
|
|
89
|
+
overflow: hidden;
|
|
90
|
+
}
|
|
91
|
+
.um-multi-select.is-readonly {
|
|
92
|
+
padding-block: var(--um-spacing-xs, 4px);
|
|
93
|
+
}
|
|
94
|
+
.um-multi-select.is-readonly .um-multi-select__tags {
|
|
95
|
+
flex-wrap: wrap;
|
|
96
|
+
overflow: visible;
|
|
97
|
+
}
|
|
98
|
+
.um-multi-select__tag {
|
|
99
|
+
display: inline-flex;
|
|
100
|
+
align-items: center;
|
|
101
|
+
min-width: 0;
|
|
102
|
+
box-sizing: border-box;
|
|
103
|
+
padding: var(--um-spacing-xs, 4px) var(--um-spacing-sm, 8px);
|
|
104
|
+
border-radius: var(--um-control-radius-small, 4px);
|
|
105
|
+
background-color: var(--u-bg-color-middle);
|
|
106
|
+
color: var(--u-text-color-main);
|
|
107
|
+
font-size: var(--um-font-size-secondary, 14px);
|
|
108
|
+
}
|
|
109
|
+
.um-multi-select__tag.is-rest {
|
|
110
|
+
flex-shrink: 0;
|
|
111
|
+
color: var(--u-text-color-second);
|
|
112
|
+
background-color: var(--u-bg-color-middle);
|
|
113
|
+
}
|
|
114
|
+
.um-multi-select__tag-label {
|
|
115
|
+
min-width: 0;
|
|
116
|
+
overflow: hidden;
|
|
117
|
+
text-overflow: ellipsis;
|
|
118
|
+
white-space: nowrap;
|
|
119
|
+
}
|
|
120
|
+
.um-multi-select__tag-close {
|
|
121
|
+
position: relative;
|
|
122
|
+
display: inline-flex;
|
|
123
|
+
align-items: center;
|
|
124
|
+
justify-content: center;
|
|
125
|
+
flex-shrink: 0;
|
|
126
|
+
width: 20px;
|
|
127
|
+
height: 20px;
|
|
128
|
+
margin-left: var(--um-spacing-xs, 4px);
|
|
129
|
+
margin-right: calc(-1 * var(--um-spacing-xs, 4px));
|
|
130
|
+
border: none;
|
|
131
|
+
background: none;
|
|
132
|
+
padding: 0;
|
|
133
|
+
font-size: var(--um-font-size-auxiliary, 12px);
|
|
134
|
+
color: var(--u-text-color-second);
|
|
135
|
+
cursor: pointer;
|
|
136
|
+
}
|
|
137
|
+
.um-multi-select__tag-close::before {
|
|
138
|
+
content: "";
|
|
139
|
+
position: absolute;
|
|
140
|
+
inset: -12px;
|
|
141
|
+
}
|
|
142
|
+
.um-multi-select__tag-close svg {
|
|
143
|
+
width: 1em;
|
|
144
|
+
height: 1em;
|
|
145
|
+
}
|
|
146
|
+
.um-multi-select__tag-close:active {
|
|
147
|
+
color: var(--u-text-color-title);
|
|
148
|
+
}
|
|
149
|
+
.um-multi-select__icons {
|
|
150
|
+
display: inline-flex;
|
|
151
|
+
align-items: center;
|
|
152
|
+
align-self: stretch;
|
|
153
|
+
flex-shrink: 0;
|
|
154
|
+
}
|
|
155
|
+
.um-multi-select__clear {
|
|
156
|
+
display: inline-flex;
|
|
157
|
+
align-items: center;
|
|
158
|
+
justify-content: center;
|
|
159
|
+
min-width: var(--um-touch-target, 44px);
|
|
160
|
+
min-height: var(--um-touch-target, 44px);
|
|
161
|
+
margin: calc(-1 * var(--um-spacing-sm, 8px)) calc(-1 * var(--um-spacing-sm, 8px)) calc(-1 * var(--um-spacing-sm, 8px)) 0;
|
|
162
|
+
padding: 0;
|
|
163
|
+
border: none;
|
|
164
|
+
background: none;
|
|
165
|
+
font-size: var(--um-font-size-main, 16px);
|
|
166
|
+
color: var(--u-text-color-second);
|
|
167
|
+
cursor: pointer;
|
|
168
|
+
}
|
|
169
|
+
.um-multi-select__clear svg {
|
|
170
|
+
width: 1em;
|
|
171
|
+
height: 1em;
|
|
172
|
+
}
|
|
173
|
+
.um-multi-select__clear:active {
|
|
174
|
+
color: var(--u-text-color-title);
|
|
175
|
+
}
|
|
176
|
+
.um-multi-select__arrow {
|
|
177
|
+
display: inline-flex;
|
|
178
|
+
align-items: center;
|
|
179
|
+
justify-content: center;
|
|
180
|
+
align-self: stretch;
|
|
181
|
+
min-width: var(--um-touch-target, 44px);
|
|
182
|
+
color: var(--u-text-color-second);
|
|
183
|
+
font-size: var(--um-font-size-secondary, 14px);
|
|
184
|
+
transition: transform var(--u-transition-fast) var(--u-transition-ease);
|
|
185
|
+
}
|
|
186
|
+
.um-multi-select__arrow svg {
|
|
187
|
+
width: 1em;
|
|
188
|
+
height: 1em;
|
|
189
|
+
}
|
|
190
|
+
.um-multi-select__cancel, .um-multi-select__confirm {
|
|
191
|
+
flex-shrink: 0;
|
|
192
|
+
min-width: var(--um-touch-target, 44px);
|
|
193
|
+
min-height: var(--um-touch-target, 44px);
|
|
194
|
+
margin: calc(-1 * var(--um-spacing-sm, 8px)) 0;
|
|
195
|
+
padding: 0;
|
|
196
|
+
border: none;
|
|
197
|
+
background: none;
|
|
198
|
+
font-size: var(--um-font-size-main, 16px);
|
|
199
|
+
cursor: pointer;
|
|
200
|
+
-webkit-tap-highlight-color: transparent;
|
|
201
|
+
}
|
|
202
|
+
.um-multi-select__cancel {
|
|
203
|
+
margin-left: calc(-1 * var(--um-spacing-sm, 8px));
|
|
204
|
+
color: var(--u-text-color-second);
|
|
205
|
+
}
|
|
206
|
+
.um-multi-select__confirm {
|
|
207
|
+
margin-right: calc(-1 * var(--um-spacing-sm, 8px));
|
|
208
|
+
font-weight: 600;
|
|
209
|
+
color: var(--u-color-primary);
|
|
210
|
+
}
|
|
211
|
+
.um-multi-select__confirm:disabled {
|
|
212
|
+
color: var(--u-text-color-disabled);
|
|
213
|
+
}
|
|
214
|
+
.um-multi-select__title {
|
|
215
|
+
flex: 1;
|
|
216
|
+
min-width: 0;
|
|
217
|
+
font-size: var(--um-font-size-title, 18px);
|
|
218
|
+
font-weight: 600;
|
|
219
|
+
color: var(--u-text-color-title);
|
|
220
|
+
text-align: center;
|
|
221
|
+
overflow: hidden;
|
|
222
|
+
text-overflow: ellipsis;
|
|
223
|
+
white-space: nowrap;
|
|
224
|
+
}
|
|
225
|
+
.um-multi-select__search {
|
|
226
|
+
padding: var(--um-spacing-sm, 8px) 0;
|
|
227
|
+
}
|
|
228
|
+
.um-multi-select__search-input {
|
|
229
|
+
width: 100%;
|
|
230
|
+
box-sizing: border-box;
|
|
231
|
+
min-height: var(--um-touch-target, 44px);
|
|
232
|
+
padding: 0 var(--um-spacing-md, 12px);
|
|
233
|
+
border: var(--u-border);
|
|
234
|
+
border-radius: var(--um-control-radius-default, 6px);
|
|
235
|
+
background-color: var(--u-bg-color-middle);
|
|
236
|
+
color: var(--u-text-color-main);
|
|
237
|
+
font-size: var(--um-font-size-main, 16px);
|
|
238
|
+
outline: none;
|
|
239
|
+
-webkit-appearance: none;
|
|
240
|
+
}
|
|
241
|
+
.um-multi-select__search-input::placeholder {
|
|
242
|
+
color: var(--u-text-color-placeholder);
|
|
243
|
+
}
|
|
244
|
+
.um-multi-select__search-input:focus {
|
|
245
|
+
border-color: var(--u-color-primary);
|
|
246
|
+
}
|
|
247
|
+
.um-multi-select__content-header {
|
|
248
|
+
display: flex;
|
|
249
|
+
align-items: center;
|
|
250
|
+
justify-content: space-between;
|
|
251
|
+
padding: var(--um-spacing-sm, 8px) 0;
|
|
252
|
+
}
|
|
253
|
+
.um-multi-select__check-all {
|
|
254
|
+
display: inline-flex;
|
|
255
|
+
align-items: center;
|
|
256
|
+
gap: var(--um-spacing-sm, 8px);
|
|
257
|
+
min-height: var(--um-touch-target, 44px);
|
|
258
|
+
padding: 0;
|
|
259
|
+
border: none;
|
|
260
|
+
background: none;
|
|
261
|
+
color: var(--u-text-color-main);
|
|
262
|
+
font-size: var(--um-font-size-main, 16px);
|
|
263
|
+
cursor: pointer;
|
|
264
|
+
-webkit-tap-highlight-color: transparent;
|
|
265
|
+
}
|
|
266
|
+
.um-multi-select__check-all.is-disabled {
|
|
267
|
+
cursor: not-allowed;
|
|
268
|
+
color: var(--u-text-color-disabled);
|
|
269
|
+
}
|
|
270
|
+
.um-multi-select__count {
|
|
271
|
+
color: var(--u-text-color-second);
|
|
272
|
+
font-size: var(--um-font-size-auxiliary, 12px);
|
|
273
|
+
}
|
|
274
|
+
.um-multi-select__options {
|
|
275
|
+
list-style: none;
|
|
276
|
+
margin: 0;
|
|
277
|
+
padding: 0;
|
|
278
|
+
display: flex;
|
|
279
|
+
flex-direction: column;
|
|
280
|
+
gap: var(--um-spacing-xs, 4px);
|
|
281
|
+
}
|
|
282
|
+
.um-multi-select__option {
|
|
283
|
+
display: flex;
|
|
284
|
+
align-items: center;
|
|
285
|
+
min-height: var(--um-touch-target, 44px);
|
|
286
|
+
gap: var(--um-spacing-md, 12px);
|
|
287
|
+
padding: 0 var(--um-spacing-md, 12px);
|
|
288
|
+
border-radius: var(--um-control-radius-default, 6px);
|
|
289
|
+
color: var(--u-text-color-main);
|
|
290
|
+
user-select: none;
|
|
291
|
+
cursor: pointer;
|
|
292
|
+
}
|
|
293
|
+
.um-multi-select__option:active {
|
|
294
|
+
background-color: var(--u-bg-color-hover);
|
|
295
|
+
}
|
|
296
|
+
.um-multi-select__option.is-disabled {
|
|
297
|
+
cursor: not-allowed;
|
|
298
|
+
color: var(--u-text-color-disabled);
|
|
299
|
+
}
|
|
300
|
+
.um-multi-select__option.is-disabled:active {
|
|
301
|
+
background-color: transparent;
|
|
302
|
+
}
|
|
303
|
+
.um-multi-select__option-label {
|
|
304
|
+
flex: 1;
|
|
305
|
+
min-width: 0;
|
|
306
|
+
overflow: hidden;
|
|
307
|
+
text-overflow: ellipsis;
|
|
308
|
+
white-space: nowrap;
|
|
309
|
+
}
|
|
310
|
+
.um-multi-select__checkbox {
|
|
311
|
+
display: inline-flex;
|
|
312
|
+
align-items: center;
|
|
313
|
+
justify-content: center;
|
|
314
|
+
flex-shrink: 0;
|
|
315
|
+
width: 20px;
|
|
316
|
+
height: 20px;
|
|
317
|
+
border: 1px solid var(--u-border-color);
|
|
318
|
+
border-radius: var(--um-control-radius-small, 4px);
|
|
319
|
+
color: var(--u-text-color-white);
|
|
320
|
+
font-size: var(--um-font-size-secondary, 14px);
|
|
321
|
+
transition: background-color var(--u-transition-fast) var(--u-transition-ease), border-color var(--u-transition-fast) var(--u-transition-ease);
|
|
322
|
+
}
|
|
323
|
+
.um-multi-select__checkbox svg {
|
|
324
|
+
width: 1em;
|
|
325
|
+
height: 1em;
|
|
326
|
+
}
|
|
327
|
+
.um-multi-select__checkbox.is-checked {
|
|
328
|
+
border-color: var(--u-color-primary);
|
|
329
|
+
background-color: var(--u-color-primary);
|
|
330
|
+
}
|
|
331
|
+
.um-multi-select__empty {
|
|
332
|
+
padding: var(--um-spacing-lg, 16px) 0;
|
|
333
|
+
text-align: center;
|
|
334
|
+
color: var(--u-text-color-second);
|
|
335
|
+
}
|
|
336
|
+
.um-multi-select__loading {
|
|
337
|
+
padding: var(--um-spacing-lg, 16px) 0;
|
|
338
|
+
text-align: center;
|
|
339
|
+
color: var(--u-text-color-second);
|
|
340
|
+
}
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
import { bem } from "../../shared/bem.js";
|
|
2
|
+
import _sfc_main$1 from "../input/input.js";
|
|
3
|
+
import { Fragment, computed, createCommentVNode, createElementBlock, createElementVNode, createSlots, createTextVNode, createVNode, defineComponent, mergeModels, mergeProps, normalizeClass, openBlock, renderSlot, shallowRef, toDisplayString, unref, useAttrs, useModel, useSlots, watch, withCtx, withModifiers } from "vue";
|
|
4
|
+
import { FORM_EMPTY_CONTENT, Tween, injectFormContext } from "@veltra/utils";
|
|
5
|
+
import { $n, isUndef, n, o } from "@cat-kit/core";
|
|
6
|
+
import { useFormFallbackProps } from "@veltra/compositions";
|
|
7
|
+
import { Close, Minus, Plus } from "@veltra/icons/normal";
|
|
8
|
+
// src/components/number-input/number-input.vue
|
|
9
|
+
const _hoisted_1 = ["disabled"];
|
|
10
|
+
const _hoisted_2 = ["disabled"];
|
|
11
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
12
|
+
name: "UNumberInput",
|
|
13
|
+
inheritAttrs: false,
|
|
14
|
+
__name: "number-input",
|
|
15
|
+
props: /*@__PURE__*/ mergeModels({
|
|
16
|
+
modelValue: {},
|
|
17
|
+
currency: { type: Boolean },
|
|
18
|
+
precision: {},
|
|
19
|
+
minPrecision: {},
|
|
20
|
+
maxPrecision: {},
|
|
21
|
+
step: { type: [Boolean, Number] },
|
|
22
|
+
max: {},
|
|
23
|
+
min: {},
|
|
24
|
+
multiple: {},
|
|
25
|
+
placeholder: { default: "请输入" },
|
|
26
|
+
prefix: {},
|
|
27
|
+
suffix: {},
|
|
28
|
+
clearable: {
|
|
29
|
+
type: Boolean,
|
|
30
|
+
default: true
|
|
31
|
+
},
|
|
32
|
+
nativeReadonly: { type: Boolean },
|
|
33
|
+
pattern: {},
|
|
34
|
+
tips: {},
|
|
35
|
+
span: {},
|
|
36
|
+
label: {},
|
|
37
|
+
field: {},
|
|
38
|
+
disabled: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
default: void 0
|
|
41
|
+
},
|
|
42
|
+
readonly: {
|
|
43
|
+
type: Boolean,
|
|
44
|
+
default: void 0
|
|
45
|
+
},
|
|
46
|
+
rules: {},
|
|
47
|
+
size: {}
|
|
48
|
+
}, {
|
|
49
|
+
"modelValue": {},
|
|
50
|
+
"modelModifiers": {}
|
|
51
|
+
}),
|
|
52
|
+
emits: /*@__PURE__*/ mergeModels([
|
|
53
|
+
"update:modelValue",
|
|
54
|
+
"change",
|
|
55
|
+
"clear"
|
|
56
|
+
], ["update:modelValue"]),
|
|
57
|
+
setup(__props, { emit: __emit }) {
|
|
58
|
+
const props = __props;
|
|
59
|
+
const emit = __emit;
|
|
60
|
+
const slots = useSlots();
|
|
61
|
+
const { formProps } = injectFormContext();
|
|
62
|
+
const { size, disabled, readonly } = useFormFallbackProps([formProps ?? {}, props], {
|
|
63
|
+
size: "default",
|
|
64
|
+
disabled: false,
|
|
65
|
+
readonly: false
|
|
66
|
+
});
|
|
67
|
+
const attrs = useAttrs();
|
|
68
|
+
const inputProps = computed(() => ({
|
|
69
|
+
...attrs,
|
|
70
|
+
...o(props).pick([
|
|
71
|
+
"disabled",
|
|
72
|
+
"placeholder",
|
|
73
|
+
"size",
|
|
74
|
+
"prefix"
|
|
75
|
+
])
|
|
76
|
+
}));
|
|
77
|
+
const inputRef = shallowRef();
|
|
78
|
+
const inputDom = computed(() => inputRef.value?.el);
|
|
79
|
+
const cls = bem("number-input");
|
|
80
|
+
const className = computed(() => {
|
|
81
|
+
return [cls.b, cls.m(size.value)];
|
|
82
|
+
});
|
|
83
|
+
/** 实际值 */
|
|
84
|
+
const model = useModel(__props, "modelValue");
|
|
85
|
+
const displayed = shallowRef("");
|
|
86
|
+
const focused = shallowRef(false);
|
|
87
|
+
const generateDisplayed = computed(() => {
|
|
88
|
+
if (!displayed.value) return "";
|
|
89
|
+
return `${props.prefix ?? ""}${displayed.value}${props.suffix ?? ""}`;
|
|
90
|
+
});
|
|
91
|
+
const showStep = computed(() => props.step !== void 0 && props.step !== false);
|
|
92
|
+
const hasCustomSuffix = computed(() => !!props.suffix || !!slots.suffix);
|
|
93
|
+
const hasSuffix = computed(() => props.clearable || hasCustomSuffix.value);
|
|
94
|
+
const showClear = computed(() => {
|
|
95
|
+
return props.clearable && !disabled.value && displayed.value !== "";
|
|
96
|
+
});
|
|
97
|
+
/** 步长 */
|
|
98
|
+
const stepVal = computed(() => {
|
|
99
|
+
const { step } = props;
|
|
100
|
+
if (step === void 0) return 1;
|
|
101
|
+
return typeof step === "boolean" ? 1 : step;
|
|
102
|
+
});
|
|
103
|
+
/** 是否可增 */
|
|
104
|
+
const increasable = computed(() => {
|
|
105
|
+
const { max, multiple } = props;
|
|
106
|
+
if (isUndef(max) || isUndef(model.value)) return true;
|
|
107
|
+
return (multiple ? $n.div(model.value, multiple) : model.value) < max;
|
|
108
|
+
});
|
|
109
|
+
/** 是否可减 */
|
|
110
|
+
const reducible = computed(() => {
|
|
111
|
+
const { min, multiple } = props;
|
|
112
|
+
if (isUndef(min) || isUndef(model.value)) return true;
|
|
113
|
+
return (multiple ? $n.div(model.value, multiple) : model.value) > min;
|
|
114
|
+
});
|
|
115
|
+
const defaultMaxPrecision = computed(() => {
|
|
116
|
+
const { multiple } = props;
|
|
117
|
+
const rawValue = multiple && model.value !== void 0 ? $n.div(model.value, multiple) : model.value;
|
|
118
|
+
return Math.max(String(rawValue).split(".")[1]?.length ?? 0, String(stepVal.value).split(".")[1]?.length ?? 0);
|
|
119
|
+
});
|
|
120
|
+
/**
|
|
121
|
+
* 获取展示值
|
|
122
|
+
* @param num 实际值
|
|
123
|
+
*/
|
|
124
|
+
function getDisplayed(num) {
|
|
125
|
+
if (!num && num !== 0) return "";
|
|
126
|
+
const { currency, precision, minPrecision, maxPrecision = defaultMaxPrecision.value, multiple } = props;
|
|
127
|
+
const displayValue = multiple ? $n.div(num, multiple) : num;
|
|
128
|
+
return currency ? n(displayValue).currency("CNY", {
|
|
129
|
+
precision,
|
|
130
|
+
minPrecision,
|
|
131
|
+
maxPrecision
|
|
132
|
+
}) : n(displayValue).fixed(precision ?? {
|
|
133
|
+
minPrecision,
|
|
134
|
+
maxPrecision
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
watch([
|
|
138
|
+
model,
|
|
139
|
+
focused,
|
|
140
|
+
() => props.currency
|
|
141
|
+
], ([modelValue, inputFocused]) => {
|
|
142
|
+
if (inputFocused) return;
|
|
143
|
+
displayed.value = getDisplayed(modelValue);
|
|
144
|
+
}, { immediate: true });
|
|
145
|
+
/**
|
|
146
|
+
* 解析展示值
|
|
147
|
+
* @param str 展示值
|
|
148
|
+
*/
|
|
149
|
+
function parseDisplayed(str) {
|
|
150
|
+
if (!str) return void 0;
|
|
151
|
+
const number = +str.replace(/,/g, "");
|
|
152
|
+
const { multiple } = props;
|
|
153
|
+
let result;
|
|
154
|
+
if (isNaN(number)) {
|
|
155
|
+
if (model.value === void 0) return void 0;
|
|
156
|
+
result = multiple ? $n.div(model.value, multiple) : model.value;
|
|
157
|
+
} else result = number;
|
|
158
|
+
if (result === void 0) return void 0;
|
|
159
|
+
const { precision, maxPrecision, minPrecision } = props;
|
|
160
|
+
const fixedResult = +n(result).fixed(precision ?? {
|
|
161
|
+
minPrecision,
|
|
162
|
+
maxPrecision
|
|
163
|
+
});
|
|
164
|
+
return multiple ? $n.mul(fixedResult, multiple) : fixedResult;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* 获取有效值
|
|
168
|
+
* @param val 值
|
|
169
|
+
*/
|
|
170
|
+
function getValidValue(val) {
|
|
171
|
+
if (val === void 0) return val;
|
|
172
|
+
const { min, max, multiple } = props;
|
|
173
|
+
if (multiple) {
|
|
174
|
+
const rawVal = $n.div(val, multiple);
|
|
175
|
+
let validRawVal = rawVal;
|
|
176
|
+
if (min !== void 0 && rawVal < min) validRawVal = min;
|
|
177
|
+
if (max !== void 0 && rawVal > max) validRawVal = max;
|
|
178
|
+
return $n.mul(validRawVal, multiple);
|
|
179
|
+
}
|
|
180
|
+
if (min !== void 0 && val < min) return min;
|
|
181
|
+
if (max !== void 0 && val > max) return max;
|
|
182
|
+
return val;
|
|
183
|
+
}
|
|
184
|
+
function handleUpdateModelValue(input) {
|
|
185
|
+
const newVal = parseDisplayed(input);
|
|
186
|
+
model.value = getValidValue(newVal);
|
|
187
|
+
displayed.value = input;
|
|
188
|
+
}
|
|
189
|
+
function handleClear() {
|
|
190
|
+
if (!showClear.value) return;
|
|
191
|
+
model.value = void 0;
|
|
192
|
+
displayed.value = "";
|
|
193
|
+
emit("clear");
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* 处理输入值变化的函数, 该函数仅在输入框失去焦点时触发,
|
|
197
|
+
* 主要用于在输入非数字的情况下的修正处理
|
|
198
|
+
*/
|
|
199
|
+
function handleChange() {
|
|
200
|
+
emit("change", model.value);
|
|
201
|
+
}
|
|
202
|
+
const tween = new Tween({ n: model.value ?? 0 }, {
|
|
203
|
+
onUpdate(state) {
|
|
204
|
+
const _rawInput = inputDom.value;
|
|
205
|
+
if (!_rawInput) return;
|
|
206
|
+
const { multiple } = props;
|
|
207
|
+
_rawInput.value = getDisplayed(multiple ? $n.mul(state.n, multiple) : state.n);
|
|
208
|
+
},
|
|
209
|
+
onComplete() {
|
|
210
|
+
const _rawInput = inputDom.value;
|
|
211
|
+
if (!_rawInput) return;
|
|
212
|
+
_rawInput.value = getDisplayed(model.value);
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
/**
|
|
216
|
+
* 步进后更新输入框的展示值
|
|
217
|
+
* 步长为 1 时直接展示目标值, 不播放数字滚动动画
|
|
218
|
+
* @param rawFrom 步进前的原始值(存在倍数时为除以倍数后的值)
|
|
219
|
+
* @param rawTarget 步进后的原始值(存在倍数时为除以倍数后的值)
|
|
220
|
+
*/
|
|
221
|
+
function updateStepDisplay(rawFrom, rawTarget) {
|
|
222
|
+
tween.state.n = rawFrom;
|
|
223
|
+
if (stepVal.value === 1) {
|
|
224
|
+
tween.state.n = rawTarget;
|
|
225
|
+
const _rawInput = inputDom.value;
|
|
226
|
+
if (!_rawInput) return;
|
|
227
|
+
const { multiple } = props;
|
|
228
|
+
_rawInput.value = getDisplayed(multiple ? $n.mul(rawTarget, multiple) : rawTarget);
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
tween.to({ n: rawTarget });
|
|
232
|
+
}
|
|
233
|
+
/** 增 */
|
|
234
|
+
function increase() {
|
|
235
|
+
if (disabled.value) return;
|
|
236
|
+
const { multiple } = props;
|
|
237
|
+
const val = model.value ?? 0;
|
|
238
|
+
if (multiple) {
|
|
239
|
+
const rawVal = $n.div(val, multiple);
|
|
240
|
+
const newRawVal = $n.plus(rawVal, stepVal.value);
|
|
241
|
+
const target = getValidValue($n.mul(newRawVal, multiple));
|
|
242
|
+
model.value = target;
|
|
243
|
+
updateStepDisplay($n.div(val, multiple), $n.div(target, multiple));
|
|
244
|
+
} else {
|
|
245
|
+
const target = getValidValue($n.plus(val, stepVal.value));
|
|
246
|
+
model.value = target;
|
|
247
|
+
updateStepDisplay(val, target);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
/** 减 */
|
|
251
|
+
function decrease() {
|
|
252
|
+
if (disabled.value) return;
|
|
253
|
+
const { multiple } = props;
|
|
254
|
+
const val = model.value ?? 0;
|
|
255
|
+
if (multiple) {
|
|
256
|
+
const rawVal = $n.div(val, multiple);
|
|
257
|
+
const newRawVal = $n.minus(rawVal, stepVal.value);
|
|
258
|
+
const target = getValidValue($n.mul(newRawVal, multiple));
|
|
259
|
+
model.value = target;
|
|
260
|
+
updateStepDisplay($n.div(val, multiple), $n.div(target, multiple));
|
|
261
|
+
} else {
|
|
262
|
+
const target = getValidValue($n.minus(val, stepVal.value));
|
|
263
|
+
model.value = target;
|
|
264
|
+
updateStepDisplay(val, target);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
function handleKeydown(e) {
|
|
268
|
+
if (!props.step) return;
|
|
269
|
+
if (e.key === "ArrowUp") {
|
|
270
|
+
e.preventDefault();
|
|
271
|
+
return increase();
|
|
272
|
+
}
|
|
273
|
+
if (e.key === "ArrowDown") {
|
|
274
|
+
e.preventDefault();
|
|
275
|
+
return decrease();
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
function handleFocus() {
|
|
279
|
+
focused.value = true;
|
|
280
|
+
if (model.value === void 0) return;
|
|
281
|
+
const { precision, maxPrecision, minPrecision, multiple } = props;
|
|
282
|
+
if (multiple) {
|
|
283
|
+
const rawVal = $n.div(model.value, multiple);
|
|
284
|
+
const fixedRawVal = +n(rawVal).fixed(precision ?? {
|
|
285
|
+
maxPrecision,
|
|
286
|
+
minPrecision
|
|
287
|
+
});
|
|
288
|
+
model.value = $n.mul(fixedRawVal, multiple);
|
|
289
|
+
} else model.value = +n(model.value).fixed(precision ?? {
|
|
290
|
+
maxPrecision,
|
|
291
|
+
minPrecision
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
function handleBlur() {
|
|
295
|
+
focused.value = false;
|
|
296
|
+
model.value = props.modelValue;
|
|
297
|
+
}
|
|
298
|
+
return (_ctx, _cache) => {
|
|
299
|
+
return !unref(readonly) ? (openBlock(), createElementBlock("div", {
|
|
300
|
+
key: 0,
|
|
301
|
+
class: normalizeClass(className.value)
|
|
302
|
+
}, [
|
|
303
|
+
createVNode(unref(_sfc_main$1), mergeProps({
|
|
304
|
+
ref_key: "inputRef",
|
|
305
|
+
ref: inputRef,
|
|
306
|
+
class: unref(cls).e("field"),
|
|
307
|
+
"model-value": displayed.value
|
|
308
|
+
}, inputProps.value, {
|
|
309
|
+
inputmode: "decimal",
|
|
310
|
+
"onUpdate:modelValue": handleUpdateModelValue,
|
|
311
|
+
onChange: handleChange,
|
|
312
|
+
onKeydown: withModifiers(handleKeydown, ["stop"]),
|
|
313
|
+
onFocus: handleFocus,
|
|
314
|
+
onBlur: handleBlur,
|
|
315
|
+
size: unref(size),
|
|
316
|
+
readonly: unref(readonly),
|
|
317
|
+
disabled: unref(disabled),
|
|
318
|
+
clearable: false
|
|
319
|
+
}), createSlots({ _: 2 }, [hasSuffix.value ? {
|
|
320
|
+
name: "suffix",
|
|
321
|
+
fn: withCtx(() => [createElementVNode("span", { class: normalizeClass(unref(cls).e("suffix")) }, [props.clearable ? (openBlock(), createElementBlock("button", {
|
|
322
|
+
key: 0,
|
|
323
|
+
class: normalizeClass([unref(cls).e("clear"), unref(bem).is("hidden", !showClear.value)]),
|
|
324
|
+
type: "button",
|
|
325
|
+
"aria-label": "清除",
|
|
326
|
+
onClick: withModifiers(handleClear, ["stop"])
|
|
327
|
+
}, [createVNode(unref(Close))], 2)) : createCommentVNode("v-if", true), hasCustomSuffix.value ? (openBlock(), createElementBlock("span", {
|
|
328
|
+
key: 1,
|
|
329
|
+
class: normalizeClass(unref(cls).e("suffix-content"))
|
|
330
|
+
}, [createTextVNode(toDisplayString(__props.suffix) + " ", 1), renderSlot(_ctx.$slots, "suffix")], 2)) : createCommentVNode("v-if", true)], 2)]),
|
|
331
|
+
key: "0"
|
|
332
|
+
} : void 0, slots.prefix ? {
|
|
333
|
+
name: "prefix",
|
|
334
|
+
fn: withCtx(() => [renderSlot(_ctx.$slots, "prefix")]),
|
|
335
|
+
key: "1"
|
|
336
|
+
} : void 0]), 1040, [
|
|
337
|
+
"class",
|
|
338
|
+
"model-value",
|
|
339
|
+
"size",
|
|
340
|
+
"readonly",
|
|
341
|
+
"disabled"
|
|
342
|
+
]),
|
|
343
|
+
createCommentVNode(" 步进按钮外置在输入框右侧,保证 44×44 触控热区(移动端形态) "),
|
|
344
|
+
showStep.value ? (openBlock(), createElementBlock("div", {
|
|
345
|
+
key: 0,
|
|
346
|
+
class: normalizeClass(unref(cls).e("step"))
|
|
347
|
+
}, [createElementVNode("button", {
|
|
348
|
+
type: "button",
|
|
349
|
+
"aria-label": "减少",
|
|
350
|
+
class: normalizeClass(unref(bem).is("disabled", unref(disabled) || !reducible.value)),
|
|
351
|
+
disabled: unref(disabled) || !reducible.value,
|
|
352
|
+
onClick: decrease
|
|
353
|
+
}, [createVNode(unref(Minus))], 10, _hoisted_1), createElementVNode("button", {
|
|
354
|
+
type: "button",
|
|
355
|
+
"aria-label": "增加",
|
|
356
|
+
class: normalizeClass(unref(bem).is("disabled", unref(disabled) || !increasable.value)),
|
|
357
|
+
disabled: unref(disabled) || !increasable.value,
|
|
358
|
+
onClick: increase
|
|
359
|
+
}, [createVNode(unref(Plus))], 10, _hoisted_2)], 2)) : createCommentVNode("v-if", true)
|
|
360
|
+
], 2)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createTextVNode(toDisplayString(generateDisplayed.value || unref(FORM_EMPTY_CONTENT)), 1)], 64));
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
});
|
|
364
|
+
export { _sfc_main as default };
|
|
365
|
+
|
|
366
|
+
//# sourceMappingURL=number-input.js.map
|