@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,151 @@
|
|
|
1
|
+
import { bem } from "../../shared/bem.js";
|
|
2
|
+
import { calcTextareaHeight } from "./utils.js";
|
|
3
|
+
import { computed, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, mergeModels, normalizeClass, openBlock, ref, toDisplayString, unref, useModel, vModelText, watch, withDirectives, withModifiers } from "vue";
|
|
4
|
+
import { FORM_EMPTY_CONTENT, injectFormContext } from "@veltra/utils";
|
|
5
|
+
import { useFocus, useFormFallbackProps } from "@veltra/compositions";
|
|
6
|
+
import { Close } from "@veltra/icons/normal";
|
|
7
|
+
// src/components/textarea/textarea.vue
|
|
8
|
+
const _hoisted_1 = [
|
|
9
|
+
"placeholder",
|
|
10
|
+
"maxlength",
|
|
11
|
+
"rows",
|
|
12
|
+
"cols",
|
|
13
|
+
"disabled",
|
|
14
|
+
"readonly"
|
|
15
|
+
];
|
|
16
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
17
|
+
name: "UTextarea",
|
|
18
|
+
__name: "textarea",
|
|
19
|
+
props: /*@__PURE__*/ mergeModels({
|
|
20
|
+
modelValue: {},
|
|
21
|
+
height: {},
|
|
22
|
+
placeholder: { default: "请输入" },
|
|
23
|
+
disabled: {
|
|
24
|
+
type: Boolean,
|
|
25
|
+
default: void 0
|
|
26
|
+
},
|
|
27
|
+
readonly: {
|
|
28
|
+
type: Boolean,
|
|
29
|
+
default: void 0
|
|
30
|
+
},
|
|
31
|
+
resize: {
|
|
32
|
+
type: Boolean,
|
|
33
|
+
default: true
|
|
34
|
+
},
|
|
35
|
+
rows: {},
|
|
36
|
+
cols: {},
|
|
37
|
+
maxlength: {},
|
|
38
|
+
showCount: { type: Boolean },
|
|
39
|
+
clearable: {
|
|
40
|
+
type: Boolean,
|
|
41
|
+
default: true
|
|
42
|
+
},
|
|
43
|
+
nativeReadonly: { type: Boolean },
|
|
44
|
+
autosize: {
|
|
45
|
+
type: Boolean,
|
|
46
|
+
default: false
|
|
47
|
+
},
|
|
48
|
+
tips: {},
|
|
49
|
+
span: {},
|
|
50
|
+
label: {},
|
|
51
|
+
field: {},
|
|
52
|
+
rules: {},
|
|
53
|
+
size: {}
|
|
54
|
+
}, {
|
|
55
|
+
"modelValue": {},
|
|
56
|
+
"modelModifiers": {}
|
|
57
|
+
}),
|
|
58
|
+
emits: /*@__PURE__*/ mergeModels([
|
|
59
|
+
"update:modelValue",
|
|
60
|
+
"change",
|
|
61
|
+
"focus",
|
|
62
|
+
"blur",
|
|
63
|
+
"clear"
|
|
64
|
+
], ["update:modelValue"]),
|
|
65
|
+
setup(__props, { emit: __emit }) {
|
|
66
|
+
const props = __props;
|
|
67
|
+
const cls = bem("textarea");
|
|
68
|
+
const { formProps } = injectFormContext();
|
|
69
|
+
const { size, disabled, readonly } = useFormFallbackProps([formProps ?? {}, props], {
|
|
70
|
+
size: "default",
|
|
71
|
+
disabled: false,
|
|
72
|
+
readonly: false
|
|
73
|
+
});
|
|
74
|
+
const emit = __emit;
|
|
75
|
+
const textareaRef = ref(null);
|
|
76
|
+
const model = useModel(__props, "modelValue");
|
|
77
|
+
const { focus, handleBlur, handleFocus } = useFocus((focused) => {
|
|
78
|
+
focused ? emit("focus") : emit("blur");
|
|
79
|
+
});
|
|
80
|
+
const textareaClass = computed(() => {
|
|
81
|
+
return [
|
|
82
|
+
cls.b,
|
|
83
|
+
cls.m(size.value),
|
|
84
|
+
bem.is("resize-none", !props.resize),
|
|
85
|
+
bem.is("disabled", disabled.value),
|
|
86
|
+
bem.is("readonly", readonly.value),
|
|
87
|
+
bem.is("focus", focus.value),
|
|
88
|
+
cls.m("more")
|
|
89
|
+
];
|
|
90
|
+
});
|
|
91
|
+
const handleInput = (e) => {
|
|
92
|
+
const value = e.target.value;
|
|
93
|
+
if (value.length > props.maxlength) {
|
|
94
|
+
const truncatedValue = value.slice(0, props.maxlength);
|
|
95
|
+
emit("update:modelValue", truncatedValue);
|
|
96
|
+
} else emit("update:modelValue", value);
|
|
97
|
+
};
|
|
98
|
+
const handleClear = () => {
|
|
99
|
+
model.value = "";
|
|
100
|
+
emit("clear");
|
|
101
|
+
};
|
|
102
|
+
const handleChange = (e) => {
|
|
103
|
+
emit("change", e.target.value);
|
|
104
|
+
};
|
|
105
|
+
watch([model, textareaRef], ([model, textareaRef]) => {
|
|
106
|
+
if (!textareaRef) return;
|
|
107
|
+
if (!props.autosize) return;
|
|
108
|
+
calcTextareaHeight(textareaRef);
|
|
109
|
+
}, { immediate: true });
|
|
110
|
+
return (_ctx, _cache) => {
|
|
111
|
+
return !unref(readonly) ? (openBlock(), createElementBlock("div", {
|
|
112
|
+
key: 0,
|
|
113
|
+
class: normalizeClass(textareaClass.value)
|
|
114
|
+
}, [
|
|
115
|
+
withDirectives(createElementVNode("textarea", {
|
|
116
|
+
class: normalizeClass(unref(cls).e("native")),
|
|
117
|
+
placeholder: __props.placeholder,
|
|
118
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => model.value = $event),
|
|
119
|
+
maxlength: __props.maxlength,
|
|
120
|
+
rows: __props.rows,
|
|
121
|
+
cols: __props.cols,
|
|
122
|
+
onInput: handleInput,
|
|
123
|
+
onFocus: _cache[1] || (_cache[1] = (...args) => unref(handleFocus) && unref(handleFocus)(...args)),
|
|
124
|
+
onBlur: _cache[2] || (_cache[2] = (...args) => unref(handleBlur) && unref(handleBlur)(...args)),
|
|
125
|
+
onChange: handleChange,
|
|
126
|
+
disabled: unref(disabled),
|
|
127
|
+
readonly: __props.nativeReadonly,
|
|
128
|
+
ref_key: "textareaRef",
|
|
129
|
+
ref: textareaRef
|
|
130
|
+
}, null, 42, _hoisted_1), [[vModelText, model.value]]),
|
|
131
|
+
props.maxlength && props.showCount ? (openBlock(), createElementBlock("span", {
|
|
132
|
+
key: 0,
|
|
133
|
+
class: normalizeClass(unref(cls).m("count"))
|
|
134
|
+
}, toDisplayString(model.value?.length ?? 0) + "/" + toDisplayString(props.maxlength), 3)) : createCommentVNode("v-if", true),
|
|
135
|
+
props.clearable && model.value && !unref(disabled) ? (openBlock(), createElementBlock("button", {
|
|
136
|
+
key: 1,
|
|
137
|
+
class: normalizeClass(unref(cls).m("clear")),
|
|
138
|
+
type: "button",
|
|
139
|
+
"aria-label": "清空",
|
|
140
|
+
onClick: withModifiers(handleClear, ["stop"])
|
|
141
|
+
}, [createVNode(unref(Close))], 2)) : createCommentVNode("v-if", true)
|
|
142
|
+
], 2)) : (openBlock(), createElementBlock("span", {
|
|
143
|
+
key: 1,
|
|
144
|
+
class: normalizeClass(unref(cls).m("readonly"))
|
|
145
|
+
}, toDisplayString(model.value || unref(FORM_EMPTY_CONTENT)), 3));
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
export { _sfc_main as default };
|
|
150
|
+
|
|
151
|
+
//# sourceMappingURL=textarea.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textarea.js","names":["_useModel","_unref","_openBlock","_createElementBlock","_normalizeClass","_withDirectives","_createElementVNode","_vModelText","_toDisplayString","_createCommentVNode","_withModifiers","_createVNode"],"sources":["../../../src/components/textarea/textarea.vue"],"sourcesContent":["<template>\n <div v-if=\"!readonly\" :class=\"textareaClass\">\n <textarea\n :class=\"cls.e('native')\"\n :placeholder=\"placeholder\"\n v-model=\"model\"\n :maxlength=\"maxlength\"\n :rows=\"rows\"\n :cols=\"cols\"\n @input=\"handleInput\"\n @focus=\"handleFocus\"\n @blur=\"handleBlur\"\n @change=\"handleChange\"\n :disabled=\"disabled\"\n :readonly=\"nativeReadonly\"\n ref=\"textareaRef\"\n />\n <span v-if=\"props.maxlength && props.showCount\" :class=\"cls.m('count')\">\n {{ model?.length ?? 0 }}/{{ props.maxlength }}\n </span>\n <button\n v-if=\"props.clearable && model && !disabled\"\n :class=\"cls.m('clear')\"\n type=\"button\"\n aria-label=\"清空\"\n @click.stop=\"handleClear\"\n >\n <Close />\n </button>\n </div>\n\n <span v-else :class=\"cls.m('readonly')\">\n {{ model || FORM_EMPTY_CONTENT }}\n </span>\n</template>\n\n<script lang=\"ts\" setup>\nimport { useFocus, useFormFallbackProps } from '@veltra/compositions'\nimport { Close } from '@veltra/icons/normal'\nimport { FORM_EMPTY_CONTENT, injectFormContext } from '@veltra/utils'\nimport type { ComponentSize } from '@veltra/utils'\nimport { computed, ref, watch } from 'vue'\n\nimport { bem } from '../../shared/bem'\nimport type { TextareaEmits, TextareaProps } from '../../types/textarea'\nimport { calcTextareaHeight } from './utils'\n\ndefineOptions({ name: 'UTextarea' })\n\nconst props = withDefaults(defineProps<TextareaProps>(), {\n placeholder: '请输入',\n resize: true,\n clearable: true,\n disabled: undefined,\n readonly: undefined,\n autosize: false\n})\n\nconst cls = bem('textarea')\n\nconst { formProps } = injectFormContext()\n\nconst { size, disabled, readonly } = useFormFallbackProps([formProps ?? {}, props], {\n size: 'default' as ComponentSize,\n disabled: false,\n readonly: false\n})\n\nconst emit = defineEmits<TextareaEmits>()\n\nconst textareaRef = ref<HTMLTextAreaElement | null>(null)\n\nconst model = defineModel<string>()\n\nconst { focus, handleBlur, handleFocus } = useFocus((focused) => {\n focused ? emit('focus') : emit('blur')\n})\n\nconst textareaClass = computed(() => {\n return [\n cls.b,\n cls.m(size.value),\n bem.is('resize-none', !props.resize),\n bem.is('disabled', disabled.value),\n bem.is('readonly', readonly.value),\n bem.is('focus', focus.value),\n cls.m('more')\n ]\n})\n\nconst handleInput = (e: Event) => {\n const value = (e.target as HTMLTextAreaElement).value\n if (value.length > props.maxlength!) {\n // 如果输入的字符数超过了最大长度,截取字符串到最大长度\n const truncatedValue = value.slice(0, props.maxlength)\n emit('update:modelValue', truncatedValue)\n } else {\n // 如果没有超过最大长度,则正常更新模型值\n emit('update:modelValue', value)\n }\n}\n\nconst handleClear = () => {\n model.value = ''\n emit('clear')\n}\n\nconst handleChange = (e: Event) => {\n emit('change', (e.target as HTMLTextAreaElement).value)\n}\n\nwatch(\n [model, textareaRef],\n ([model, textareaRef]) => {\n if (!textareaRef) return\n if (!props.autosize) return\n calcTextareaHeight(textareaRef)\n },\n { immediate: true }\n)\n</script>\n"],"mappings":"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"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { nextTick } from "vue";
|
|
2
|
+
import { setStyles } from "@veltra/utils";
|
|
3
|
+
// src/components/textarea/utils.ts
|
|
4
|
+
function calcTextareaHeight(el) {
|
|
5
|
+
setStyles(el, { height: "auto" });
|
|
6
|
+
nextTick(() => {
|
|
7
|
+
const { scrollHeight } = el;
|
|
8
|
+
setStyles(el, {
|
|
9
|
+
overflow: "hidden",
|
|
10
|
+
height: scrollHeight + "px"
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
export { calcTextareaHeight };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../../../src/components/textarea/utils.ts"],"sourcesContent":["import { setStyles } from '@veltra/utils'\nimport { nextTick } from 'vue'\n\nexport function calcTextareaHeight(el: HTMLTextAreaElement): void {\n setStyles(el, { height: 'auto' })\n nextTick(() => {\n const { scrollHeight } = el\n\n setStyles(el, { overflow: 'hidden', height: scrollHeight + 'px' })\n })\n}\n"],"mappings":";;;AAGA,SAAgB,mBAAmB,IAA+B;CAChE,UAAU,IAAI,EAAE,QAAQ,OAAO,CAAC;CAChC,eAAe;EACb,MAAM,EAAE,iBAAiB;EAEzB,UAAU,IAAI;GAAE,UAAU;GAAU,QAAQ,eAAe;EAAK,CAAC;CACnE,CAAC;AACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1,206 @@
|
|
|
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-time-picker {
|
|
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-time-picker--small {
|
|
44
|
+
min-height: max(var(--um-control-height-small, 32px), var(--um-touch-target, 44px));
|
|
45
|
+
}
|
|
46
|
+
.um-time-picker--default {
|
|
47
|
+
min-height: max(var(--um-control-height-default, 40px), var(--um-touch-target, 44px));
|
|
48
|
+
}
|
|
49
|
+
.um-time-picker--large {
|
|
50
|
+
min-height: max(var(--um-control-height-large, 48px), var(--um-touch-target, 44px));
|
|
51
|
+
}
|
|
52
|
+
.um-time-picker:active {
|
|
53
|
+
border-color: var(--u-color-primary);
|
|
54
|
+
}
|
|
55
|
+
.um-time-picker:focus-visible {
|
|
56
|
+
box-shadow: var(--u-focus-ring);
|
|
57
|
+
}
|
|
58
|
+
.um-time-picker.is-active {
|
|
59
|
+
border-color: var(--u-color-primary);
|
|
60
|
+
}
|
|
61
|
+
.um-time-picker.is-disabled {
|
|
62
|
+
cursor: not-allowed;
|
|
63
|
+
color: var(--u-text-color-disabled);
|
|
64
|
+
background-color: var(--u-bg-color-middle);
|
|
65
|
+
}
|
|
66
|
+
.um-time-picker__value {
|
|
67
|
+
flex: 1;
|
|
68
|
+
min-width: 0;
|
|
69
|
+
overflow: hidden;
|
|
70
|
+
text-overflow: ellipsis;
|
|
71
|
+
white-space: nowrap;
|
|
72
|
+
}
|
|
73
|
+
.um-time-picker__value.is-placeholder {
|
|
74
|
+
color: var(--u-text-color-placeholder);
|
|
75
|
+
}
|
|
76
|
+
.um-time-picker__icons {
|
|
77
|
+
display: inline-flex;
|
|
78
|
+
align-items: center;
|
|
79
|
+
align-self: stretch;
|
|
80
|
+
flex-shrink: 0;
|
|
81
|
+
}
|
|
82
|
+
.um-time-picker__clear {
|
|
83
|
+
display: inline-flex;
|
|
84
|
+
align-items: center;
|
|
85
|
+
justify-content: center;
|
|
86
|
+
min-width: var(--um-touch-target, 44px);
|
|
87
|
+
min-height: var(--um-touch-target, 44px);
|
|
88
|
+
margin: calc(-1 * var(--um-spacing-sm, 8px)) calc(-1 * var(--um-spacing-sm, 8px)) calc(-1 * var(--um-spacing-sm, 8px)) 0;
|
|
89
|
+
padding: 0;
|
|
90
|
+
border: none;
|
|
91
|
+
background: none;
|
|
92
|
+
font-size: var(--um-font-size-main, 16px);
|
|
93
|
+
color: var(--u-text-color-second);
|
|
94
|
+
cursor: pointer;
|
|
95
|
+
}
|
|
96
|
+
.um-time-picker__clear svg {
|
|
97
|
+
width: 1em;
|
|
98
|
+
height: 1em;
|
|
99
|
+
}
|
|
100
|
+
.um-time-picker__clear:active {
|
|
101
|
+
color: var(--u-text-color-title);
|
|
102
|
+
}
|
|
103
|
+
.um-time-picker__icon {
|
|
104
|
+
display: inline-flex;
|
|
105
|
+
align-items: center;
|
|
106
|
+
color: var(--u-text-color-second);
|
|
107
|
+
font-size: var(--um-font-size-main, 16px);
|
|
108
|
+
}
|
|
109
|
+
.um-time-picker__icon svg {
|
|
110
|
+
width: 1em;
|
|
111
|
+
height: 1em;
|
|
112
|
+
}
|
|
113
|
+
.um-time-picker__cancel {
|
|
114
|
+
display: inline-flex;
|
|
115
|
+
align-items: center;
|
|
116
|
+
min-height: var(--um-touch-target, 44px);
|
|
117
|
+
padding: 0 var(--um-spacing-sm, 8px);
|
|
118
|
+
border: none;
|
|
119
|
+
background: none;
|
|
120
|
+
font-size: var(--um-font-size-main, 16px);
|
|
121
|
+
color: var(--u-text-color-second);
|
|
122
|
+
cursor: pointer;
|
|
123
|
+
}
|
|
124
|
+
.um-time-picker__cancel:active {
|
|
125
|
+
color: var(--u-text-color-title);
|
|
126
|
+
}
|
|
127
|
+
.um-time-picker__title {
|
|
128
|
+
flex: 1;
|
|
129
|
+
min-width: 0;
|
|
130
|
+
text-align: center;
|
|
131
|
+
font-size: var(--um-font-size-title, 18px);
|
|
132
|
+
font-weight: 600;
|
|
133
|
+
color: var(--u-text-color-title);
|
|
134
|
+
overflow: hidden;
|
|
135
|
+
text-overflow: ellipsis;
|
|
136
|
+
white-space: nowrap;
|
|
137
|
+
}
|
|
138
|
+
.um-time-picker__confirm {
|
|
139
|
+
display: inline-flex;
|
|
140
|
+
align-items: center;
|
|
141
|
+
min-height: var(--um-touch-target, 44px);
|
|
142
|
+
padding: 0 var(--um-spacing-sm, 8px);
|
|
143
|
+
border: none;
|
|
144
|
+
background: none;
|
|
145
|
+
font-size: var(--um-font-size-main, 16px);
|
|
146
|
+
font-weight: 600;
|
|
147
|
+
color: var(--u-color-primary);
|
|
148
|
+
cursor: pointer;
|
|
149
|
+
}
|
|
150
|
+
.um-time-picker__confirm:active {
|
|
151
|
+
opacity: 0.7;
|
|
152
|
+
}
|
|
153
|
+
.um-time-picker__wheel {
|
|
154
|
+
position: relative;
|
|
155
|
+
display: flex;
|
|
156
|
+
gap: var(--um-spacing-sm, 8px);
|
|
157
|
+
}
|
|
158
|
+
.um-time-picker__highlight {
|
|
159
|
+
position: absolute;
|
|
160
|
+
top: calc(50% - 22px);
|
|
161
|
+
left: 0;
|
|
162
|
+
right: 0;
|
|
163
|
+
height: 44px;
|
|
164
|
+
border-radius: var(--um-control-radius-default, 6px);
|
|
165
|
+
background-color: var(--u-color-primary-light-9);
|
|
166
|
+
pointer-events: none;
|
|
167
|
+
}
|
|
168
|
+
.um-time-picker__column {
|
|
169
|
+
position: relative;
|
|
170
|
+
z-index: 1;
|
|
171
|
+
flex: 1;
|
|
172
|
+
min-width: 0;
|
|
173
|
+
height: 220px;
|
|
174
|
+
overflow-y: auto;
|
|
175
|
+
scroll-snap-type: y mandatory;
|
|
176
|
+
-webkit-overflow-scrolling: touch;
|
|
177
|
+
overscroll-behavior: contain;
|
|
178
|
+
scrollbar-width: none;
|
|
179
|
+
}
|
|
180
|
+
.um-time-picker__column::-webkit-scrollbar {
|
|
181
|
+
display: none;
|
|
182
|
+
}
|
|
183
|
+
.um-time-picker__spacer {
|
|
184
|
+
height: 88px;
|
|
185
|
+
}
|
|
186
|
+
.um-time-picker__item {
|
|
187
|
+
display: flex;
|
|
188
|
+
align-items: center;
|
|
189
|
+
justify-content: center;
|
|
190
|
+
height: 44px;
|
|
191
|
+
scroll-snap-align: center;
|
|
192
|
+
color: var(--u-text-color-main);
|
|
193
|
+
font-size: var(--um-font-size-title, 18px);
|
|
194
|
+
font-variant-numeric: tabular-nums;
|
|
195
|
+
user-select: none;
|
|
196
|
+
cursor: pointer;
|
|
197
|
+
-webkit-tap-highlight-color: transparent;
|
|
198
|
+
}
|
|
199
|
+
.um-time-picker__item.is-selected {
|
|
200
|
+
color: var(--u-text-color-title);
|
|
201
|
+
font-weight: 600;
|
|
202
|
+
}
|
|
203
|
+
.um-time-picker__item.is-disabled {
|
|
204
|
+
color: var(--u-text-color-disabled);
|
|
205
|
+
cursor: not-allowed;
|
|
206
|
+
}
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import { bem } from "../../shared/bem.js";
|
|
2
|
+
import _sfc_main$1 from "../_internal/bottom-sheet/bottom-sheet.js";
|
|
3
|
+
import { Fragment, computed, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, mergeProps, nextTick, normalizeClass, onBeforeUnmount, openBlock, renderList, shallowRef, toDisplayString, unref, watch, withCtx, withModifiers } from "vue";
|
|
4
|
+
import { FORM_EMPTY_CONTENT, injectFormContext } from "@veltra/utils";
|
|
5
|
+
import { Dater, date } from "@cat-kit/core";
|
|
6
|
+
import { useFormFallbackProps } from "@veltra/compositions";
|
|
7
|
+
import { Close, Time } from "@veltra/icons/normal";
|
|
8
|
+
// src/components/time-picker/time-picker.vue
|
|
9
|
+
const _hoisted_1 = ["aria-expanded"];
|
|
10
|
+
const _hoisted_2 = ["aria-label", "onScrollPassive"];
|
|
11
|
+
const _hoisted_3 = ["aria-selected", "onClick"];
|
|
12
|
+
const ITEM_HEIGHT = 44;
|
|
13
|
+
/** 面板打开期间的暂存时间:确定时落盘,取消时丢弃 */
|
|
14
|
+
const SCROLL_SETTLE_DELAY = 100;
|
|
15
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
16
|
+
name: "UTimePicker",
|
|
17
|
+
inheritAttrs: false,
|
|
18
|
+
__name: "time-picker",
|
|
19
|
+
props: {
|
|
20
|
+
modelValue: {},
|
|
21
|
+
placeholder: { default: "选择时间" },
|
|
22
|
+
format: {},
|
|
23
|
+
valueFormat: {},
|
|
24
|
+
dataType: { default: "string" },
|
|
25
|
+
disabledHours: {},
|
|
26
|
+
disabledMinutes: {},
|
|
27
|
+
disabledSeconds: {},
|
|
28
|
+
clearable: {
|
|
29
|
+
type: Boolean,
|
|
30
|
+
default: true
|
|
31
|
+
},
|
|
32
|
+
tips: {},
|
|
33
|
+
span: {},
|
|
34
|
+
label: {},
|
|
35
|
+
field: {},
|
|
36
|
+
disabled: {
|
|
37
|
+
type: Boolean,
|
|
38
|
+
default: void 0
|
|
39
|
+
},
|
|
40
|
+
readonly: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
default: void 0
|
|
43
|
+
},
|
|
44
|
+
rules: {},
|
|
45
|
+
size: {}
|
|
46
|
+
},
|
|
47
|
+
emits: ["update:modelValue", "change"],
|
|
48
|
+
setup(__props, { emit: __emit }) {
|
|
49
|
+
const props = __props;
|
|
50
|
+
const emit = __emit;
|
|
51
|
+
const cls = bem("time-picker");
|
|
52
|
+
const { formProps } = injectFormContext();
|
|
53
|
+
const { size, disabled, readonly } = useFormFallbackProps([formProps ?? {}, props], {
|
|
54
|
+
size: "default",
|
|
55
|
+
disabled: false,
|
|
56
|
+
readonly: false
|
|
57
|
+
});
|
|
58
|
+
const formatStr = computed(() => props.format ?? "HH:mm:ss");
|
|
59
|
+
const currentTime = shallowRef();
|
|
60
|
+
const sheetVisible = shallowRef(false);
|
|
61
|
+
function parseModelValue(val) {
|
|
62
|
+
if (val == null || val === "") return void 0;
|
|
63
|
+
if (val instanceof Date || typeof val === "number") {
|
|
64
|
+
const d = date(val);
|
|
65
|
+
return isNaN(d.timestamp) ? void 0 : d;
|
|
66
|
+
}
|
|
67
|
+
const parsed = Dater.parse(val, props.valueFormat ?? formatStr.value);
|
|
68
|
+
if (!isNaN(parsed.timestamp)) return parsed;
|
|
69
|
+
const fallback = date(val);
|
|
70
|
+
return isNaN(fallback.timestamp) ? void 0 : fallback;
|
|
71
|
+
}
|
|
72
|
+
watch(() => props.modelValue, (modelValue) => {
|
|
73
|
+
currentTime.value = parseModelValue(modelValue);
|
|
74
|
+
}, { immediate: true });
|
|
75
|
+
const displayedValue = computed(() => currentTime.value?.format(formatStr.value) ?? "");
|
|
76
|
+
/** 移动端无 hover:有值且可清除即展示清除按钮 */
|
|
77
|
+
const showClear = computed(() => props.clearable && !disabled.value && !!displayedValue.value);
|
|
78
|
+
function formatModelValue(d) {
|
|
79
|
+
if (props.dataType === "date") return d.raw;
|
|
80
|
+
if (props.dataType === "timestamp") return d.timestamp;
|
|
81
|
+
return d.format(props.valueFormat ?? formatStr.value);
|
|
82
|
+
}
|
|
83
|
+
const unitLabels = {
|
|
84
|
+
hours: "时",
|
|
85
|
+
minutes: "分",
|
|
86
|
+
seconds: "秒"
|
|
87
|
+
};
|
|
88
|
+
/** 滚轮行高(CSS px),列高固定 5 行 */
|
|
89
|
+
const staged = shallowRef({
|
|
90
|
+
hours: 0,
|
|
91
|
+
minutes: 0,
|
|
92
|
+
seconds: 0
|
|
93
|
+
});
|
|
94
|
+
function buildValues(count, disabled) {
|
|
95
|
+
return Array.from({ length: count }, (_, value) => ({
|
|
96
|
+
value,
|
|
97
|
+
disabled: disabled.has(value)
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
const columns = computed(() => {
|
|
101
|
+
const { hours, minutes } = staged.value;
|
|
102
|
+
const disabledHours = new Set(props.disabledHours?.() ?? []);
|
|
103
|
+
const disabledMinutes = new Set(props.disabledMinutes?.(hours) ?? []);
|
|
104
|
+
const disabledSeconds = new Set(props.disabledSeconds?.(hours, minutes) ?? []);
|
|
105
|
+
return [
|
|
106
|
+
{
|
|
107
|
+
name: "hours",
|
|
108
|
+
values: buildValues(24, disabledHours)
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
name: "minutes",
|
|
112
|
+
values: buildValues(60, disabledMinutes)
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: "seconds",
|
|
116
|
+
values: buildValues(60, disabledSeconds)
|
|
117
|
+
}
|
|
118
|
+
];
|
|
119
|
+
});
|
|
120
|
+
const columnEls = /* @__PURE__ */ new Map();
|
|
121
|
+
/** v-for 函数 ref:按列名登记滚轮列元素 */
|
|
122
|
+
function setColumnRef(name) {
|
|
123
|
+
return (el) => {
|
|
124
|
+
if (el instanceof HTMLElement) columnEls.set(name, el);
|
|
125
|
+
else columnEls.delete(name);
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/** 行索引即滚动位置 / 行高(上下补位等高,首行居中时 scrollTop 为 0) */
|
|
129
|
+
function scrollToValue(name, value, smooth = false) {
|
|
130
|
+
columnEls.get(name)?.scrollTo({
|
|
131
|
+
top: value * ITEM_HEIGHT,
|
|
132
|
+
behavior: smooth ? "smooth" : "auto"
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
const scrollTimers = /* @__PURE__ */ new Map();
|
|
136
|
+
onBeforeUnmount(() => {
|
|
137
|
+
for (const timer of scrollTimers.values()) clearTimeout(timer);
|
|
138
|
+
});
|
|
139
|
+
/** 滚动停稳后把视口中心的值落为暂存;停在禁用项则回弹到当前暂存值 */
|
|
140
|
+
function handleScroll(name) {
|
|
141
|
+
clearTimeout(scrollTimers.get(name));
|
|
142
|
+
scrollTimers.set(name, setTimeout(() => {
|
|
143
|
+
const el = columnEls.get(name);
|
|
144
|
+
if (!el) return;
|
|
145
|
+
const item = columns.value.find((col) => col.name === name).values[Math.round(el.scrollTop / ITEM_HEIGHT)];
|
|
146
|
+
if (!item || item.disabled) {
|
|
147
|
+
scrollToValue(name, staged.value[name], true);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
staged.value = {
|
|
151
|
+
...staged.value,
|
|
152
|
+
[name]: item.value
|
|
153
|
+
};
|
|
154
|
+
}, SCROLL_SETTLE_DELAY));
|
|
155
|
+
}
|
|
156
|
+
/** 点击选项:落暂存并平滑滚动到中心 */
|
|
157
|
+
function handleSelect(name, item) {
|
|
158
|
+
if (item.disabled) return;
|
|
159
|
+
staged.value = {
|
|
160
|
+
...staged.value,
|
|
161
|
+
[name]: item.value
|
|
162
|
+
};
|
|
163
|
+
scrollToValue(name, item.value, true);
|
|
164
|
+
}
|
|
165
|
+
watch(sheetVisible, (visible) => {
|
|
166
|
+
if (!visible) return;
|
|
167
|
+
const t = currentTime.value;
|
|
168
|
+
staged.value = t ? {
|
|
169
|
+
hours: t.hours,
|
|
170
|
+
minutes: t.minutes,
|
|
171
|
+
seconds: t.seconds
|
|
172
|
+
} : {
|
|
173
|
+
hours: 0,
|
|
174
|
+
minutes: 0,
|
|
175
|
+
seconds: 0
|
|
176
|
+
};
|
|
177
|
+
nextTick(() => {
|
|
178
|
+
for (const col of columns.value) scrollToValue(col.name, staged.value[col.name]);
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
const pad = (value) => `${value}`.padStart(2, "0");
|
|
182
|
+
function handleTriggerClick() {
|
|
183
|
+
if (disabled.value) return;
|
|
184
|
+
sheetVisible.value = true;
|
|
185
|
+
}
|
|
186
|
+
/** 确定:暂存落盘并通知父级(无值时以今天 00:00:00 为基底,与 desktop 一致) */
|
|
187
|
+
function handleConfirm() {
|
|
188
|
+
const next = (currentTime.value ?? date().setHours(0).setMinutes(0).setSeconds(0)).clone().setHours(staged.value.hours).setMinutes(staged.value.minutes).setSeconds(staged.value.seconds);
|
|
189
|
+
currentTime.value = next;
|
|
190
|
+
emit("update:modelValue", formatModelValue(next));
|
|
191
|
+
emit("change", next.raw);
|
|
192
|
+
sheetVisible.value = false;
|
|
193
|
+
}
|
|
194
|
+
function handleClear() {
|
|
195
|
+
currentTime.value = void 0;
|
|
196
|
+
emit("update:modelValue", void 0);
|
|
197
|
+
emit("change", void 0);
|
|
198
|
+
}
|
|
199
|
+
return (_ctx, _cache) => {
|
|
200
|
+
return openBlock(), createElementBlock(Fragment, null, [
|
|
201
|
+
createCommentVNode(" 只读态:纯展示 "),
|
|
202
|
+
unref(readonly) ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createTextVNode(toDisplayString(displayedValue.value || unref(FORM_EMPTY_CONTENT)), 1)], 64)) : (openBlock(), createElementBlock("div", mergeProps({ key: 1 }, _ctx.$attrs, {
|
|
203
|
+
class: [
|
|
204
|
+
unref(cls).b,
|
|
205
|
+
unref(cls).m(unref(size)),
|
|
206
|
+
unref(bem).is("disabled", unref(disabled)),
|
|
207
|
+
unref(bem).is("active", sheetVisible.value)
|
|
208
|
+
],
|
|
209
|
+
"aria-expanded": sheetVisible.value,
|
|
210
|
+
"aria-haspopup": "dialog",
|
|
211
|
+
onClick: handleTriggerClick
|
|
212
|
+
}), [createElementVNode("span", { class: normalizeClass([unref(cls).e("value"), unref(bem).is("placeholder", !displayedValue.value)]) }, toDisplayString(displayedValue.value || __props.placeholder), 3), createElementVNode("span", { class: normalizeClass(unref(cls).e("icons")) }, [showClear.value ? (openBlock(), createElementBlock("button", {
|
|
213
|
+
key: 0,
|
|
214
|
+
class: normalizeClass(unref(cls).e("clear")),
|
|
215
|
+
type: "button",
|
|
216
|
+
"aria-label": "清除",
|
|
217
|
+
onClick: withModifiers(handleClear, ["stop"])
|
|
218
|
+
}, [createVNode(unref(Close))], 2)) : (openBlock(), createElementBlock("span", {
|
|
219
|
+
key: 1,
|
|
220
|
+
class: normalizeClass(unref(cls).e("icon")),
|
|
221
|
+
"aria-hidden": "true"
|
|
222
|
+
}, [createVNode(unref(Time))], 2))], 2)], 16, _hoisted_1)),
|
|
223
|
+
createCommentVNode(" 底部滚轮面板(复用 BottomSheet 弹层基座,内部实现不进公开导出):取消/确定,滚动结果暂存至确认 "),
|
|
224
|
+
createVNode(unref(_sfc_main$1), {
|
|
225
|
+
visible: sheetVisible.value,
|
|
226
|
+
"onUpdate:visible": _cache[1] || (_cache[1] = ($event) => sheetVisible.value = $event)
|
|
227
|
+
}, {
|
|
228
|
+
header: withCtx(() => [
|
|
229
|
+
createElementVNode("button", {
|
|
230
|
+
class: normalizeClass(unref(cls).e("cancel")),
|
|
231
|
+
type: "button",
|
|
232
|
+
onClick: _cache[0] || (_cache[0] = ($event) => sheetVisible.value = false)
|
|
233
|
+
}, "取消", 2),
|
|
234
|
+
createElementVNode("span", { class: normalizeClass(unref(cls).e("title")) }, toDisplayString(__props.placeholder), 3),
|
|
235
|
+
createElementVNode("button", {
|
|
236
|
+
class: normalizeClass(unref(cls).e("confirm")),
|
|
237
|
+
type: "button",
|
|
238
|
+
onClick: handleConfirm
|
|
239
|
+
}, "确定", 2)
|
|
240
|
+
]),
|
|
241
|
+
default: withCtx(() => [createElementVNode("div", { class: normalizeClass(unref(cls).e("wheel")) }, [(openBlock(true), createElementBlock(Fragment, null, renderList(columns.value, (col) => {
|
|
242
|
+
return openBlock(), createElementBlock("div", {
|
|
243
|
+
key: col.name,
|
|
244
|
+
ref_for: true,
|
|
245
|
+
ref: setColumnRef(col.name),
|
|
246
|
+
class: normalizeClass(unref(cls).e("column")),
|
|
247
|
+
role: "listbox",
|
|
248
|
+
"aria-label": unitLabels[col.name],
|
|
249
|
+
onScrollPassive: ($event) => handleScroll(col.name)
|
|
250
|
+
}, [
|
|
251
|
+
createElementVNode("div", {
|
|
252
|
+
class: normalizeClass(unref(cls).e("spacer")),
|
|
253
|
+
"aria-hidden": "true"
|
|
254
|
+
}, null, 2),
|
|
255
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(col.values, (item) => {
|
|
256
|
+
return openBlock(), createElementBlock("div", {
|
|
257
|
+
key: item.value,
|
|
258
|
+
class: normalizeClass([
|
|
259
|
+
unref(cls).e("item"),
|
|
260
|
+
unref(bem).is("selected", staged.value[col.name] === item.value),
|
|
261
|
+
unref(bem).is("disabled", item.disabled)
|
|
262
|
+
]),
|
|
263
|
+
role: "option",
|
|
264
|
+
"aria-selected": staged.value[col.name] === item.value,
|
|
265
|
+
onClick: ($event) => handleSelect(col.name, item)
|
|
266
|
+
}, toDisplayString(pad(item.value)), 11, _hoisted_3);
|
|
267
|
+
}), 128)),
|
|
268
|
+
createElementVNode("div", {
|
|
269
|
+
class: normalizeClass(unref(cls).e("spacer")),
|
|
270
|
+
"aria-hidden": "true"
|
|
271
|
+
}, null, 2)
|
|
272
|
+
], 42, _hoisted_2);
|
|
273
|
+
}), 128)), createElementVNode("div", {
|
|
274
|
+
class: normalizeClass(unref(cls).e("highlight")),
|
|
275
|
+
"aria-hidden": "true"
|
|
276
|
+
}, null, 2)], 2)]),
|
|
277
|
+
_: 1
|
|
278
|
+
}, 8, ["visible"])
|
|
279
|
+
], 64);
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
export { _sfc_main as default };
|
|
284
|
+
|
|
285
|
+
//# sourceMappingURL=time-picker.js.map
|