@manohub/ui 1.1.2 → 1.1.3
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/README.md +2 -2
- package/dist/components/code-block/index.js +7 -2
- package/dist/components/date-picker/calendar.d.ts +78 -0
- package/dist/components/date-picker/calendar.js +91 -0
- package/dist/components/date-picker/date-panel.d.ts +312 -0
- package/dist/components/date-picker/date-panel.js +265 -0
- package/dist/components/date-picker/date-time-row.d.ts +84 -0
- package/dist/components/date-picker/date-time-row.js +105 -0
- package/dist/components/date-picker/index.d.ts +863 -0
- package/dist/components/date-picker/index.js +549 -0
- package/dist/components/date-picker/panel.d.ts +73 -0
- package/dist/components/date-picker/panel.js +53 -0
- package/dist/components/date-picker/shared.d.ts +37 -0
- package/dist/components/date-picker/shared.js +20 -0
- package/dist/components/date-picker/trigger.d.ts +147 -0
- package/dist/components/date-picker/trigger.js +107 -0
- package/dist/components/input/composition.d.ts +25 -0
- package/dist/components/input/composition.js +31 -0
- package/dist/components/input/index.d.ts +5 -5
- package/dist/components/input/index.js +91 -12
- package/dist/components/search/index.d.ts +1 -1
- package/dist/components/select/index.d.ts +5 -2
- package/dist/components/select/select-panel.d.ts +3 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -0
- package/dist/styles/components/date-picker.css +278 -0
- package/dist/styles/components/date-picker.tokens.css +14 -0
- package/dist/styles/components/select.css +3 -33
- package/dist/styles/components/select.tokens.css +0 -1
- package/dist/styles/index.css +2 -0
- package/dist/utils/state-illustration.d.ts +1 -14
- package/dist/utils/state-illustration.js +81 -69
- package/package.json +2 -2
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 日期族的**共用原子**(内件,不对外导出):面板 id、原生 popover 开合、触发器键盘契约。
|
|
3
|
+
*
|
|
4
|
+
* 与选择器族那份(`components/select/select-shared.ts`)**各留一份是有意的**:拆目录后两族的面、类名与
|
|
5
|
+
* 面板结构都独立(选择器面板有搜索行与选项列表,日期面板是日历 / 月份网格 / 时间行),真正共用的只剩
|
|
6
|
+
* 「原生 popover 那几行 API」——为这几行维持一条跨目录的内件依赖,不如各写一份。族**内部**三件
|
|
7
|
+
* (单日 / 区间 / 日期时间)才是真共用:同目录、同一份面、同一个面板壳。
|
|
8
|
+
*/
|
|
9
|
+
import type { Ref } from 'vue';
|
|
10
|
+
/** 生成全页唯一的面板 id(随机段与全库其它随机 id 同法) */
|
|
11
|
+
export declare const createPanelId: () => string;
|
|
12
|
+
/**
|
|
13
|
+
* 开 / 收面板 —— 调**原生** `showPopover()` / `hidePopover()`,不是自建浮层逻辑(开合、Esc、点外部关闭、
|
|
14
|
+
* 顶层渲染全归浏览器与 `styles/operations/popup.css`)。先探存在性再调用:jsdom 至今没实现这套 API,
|
|
15
|
+
* 直接 `?.()` 会在测试里抛「不是函数」。
|
|
16
|
+
*/
|
|
17
|
+
export declare const showPanel: (element: HTMLElement | null) => void;
|
|
18
|
+
export declare const hidePanel: (element: HTMLElement | null) => void;
|
|
19
|
+
/** 触发器键盘契约的输入 */
|
|
20
|
+
export interface TriggerKeydownOptions {
|
|
21
|
+
/** 有清除位时才接 `Delete` 清值(与输入框的键盘清除同款) */
|
|
22
|
+
clearable: boolean;
|
|
23
|
+
disabled: boolean;
|
|
24
|
+
/** 只读档:整条契约都不生效(键位不开面板、`Delete` 也不清值)。只读的按钮**仍可聚焦**,管住它的是这一条。 */
|
|
25
|
+
readonly?: boolean;
|
|
26
|
+
clear: () => void;
|
|
27
|
+
openPanel: () => void;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 触发器上的键盘契约:`↑` / `↓` 开面板、`Delete` 清值。
|
|
31
|
+
*
|
|
32
|
+
* 与选择器族那份的差别是**没有 `Enter` / `Space` 的接管**:日期的格子是**真实按钮**(焦点自己就在网格里,
|
|
33
|
+
* 回车归原生按钮),触发器这条契约只负责「把键盘用户送进面板」这一段。
|
|
34
|
+
*/
|
|
35
|
+
export declare const createTriggerKeydown: (options: TriggerKeydownOptions) => ((event: KeyboardEvent) => void);
|
|
36
|
+
/** 供内件声明 ref 属性用的类型别名(面板壳的 elementRef 入参) */
|
|
37
|
+
export type ElementRef = Ref<HTMLElement | null>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const PANEL_ID_PREFIX = "mh-date-picker-";
|
|
2
|
+
const createPanelId = () => `${PANEL_ID_PREFIX}${Math.random().toString(36).slice(2, 10)}`;
|
|
3
|
+
const showPanel = (element) => element?.showPopover?.();
|
|
4
|
+
const hidePanel = (element) => element?.hidePopover?.();
|
|
5
|
+
const createTriggerKeydown = (options) => {
|
|
6
|
+
return (event) => {
|
|
7
|
+
if (options.readonly) return;
|
|
8
|
+
if (event.key === "Delete" && options.clearable) options.clear();
|
|
9
|
+
if (event.key !== "ArrowDown" && event.key !== "ArrowUp") return;
|
|
10
|
+
event.preventDefault();
|
|
11
|
+
if (options.disabled) return;
|
|
12
|
+
options.openPanel();
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
createPanelId,
|
|
17
|
+
createTriggerKeydown,
|
|
18
|
+
hidePanel,
|
|
19
|
+
showPanel
|
|
20
|
+
};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import type { PropType } from 'vue';
|
|
2
|
+
import type { ControlSize } from '../control-size';
|
|
3
|
+
import { type InputStatus } from '../input';
|
|
4
|
+
export declare const DateTrigger: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
5
|
+
/** 面板 id(`popovertarget` 的目标,由 `createPanelId()` 产出的全页唯一 id) */
|
|
6
|
+
panelId: {
|
|
7
|
+
type: StringConstructor;
|
|
8
|
+
required: true;
|
|
9
|
+
};
|
|
10
|
+
/** 尺寸档(24 / 28 / 32):框高与字号归输入面,本件只透传 */
|
|
11
|
+
size: {
|
|
12
|
+
type: PropType<ControlSize>;
|
|
13
|
+
default: string;
|
|
14
|
+
};
|
|
15
|
+
/** 校验状态(红 / 黄;与输入框同一词表) */
|
|
16
|
+
status: {
|
|
17
|
+
type: PropType<InputStatus>;
|
|
18
|
+
default: undefined;
|
|
19
|
+
};
|
|
20
|
+
disabled: {
|
|
21
|
+
type: BooleanConstructor;
|
|
22
|
+
default: boolean;
|
|
23
|
+
};
|
|
24
|
+
/** 只读档(不展开面板;观感与可编辑档一致,见文件头) */
|
|
25
|
+
readonly: {
|
|
26
|
+
type: BooleanConstructor;
|
|
27
|
+
default: boolean;
|
|
28
|
+
};
|
|
29
|
+
/** 有无边框(**直接透传给输入面**,三档口径与 `Input` 的同名 prop 完全一致) */
|
|
30
|
+
bordered: {
|
|
31
|
+
type: PropType<boolean | "focus">;
|
|
32
|
+
default: boolean;
|
|
33
|
+
};
|
|
34
|
+
clearable: {
|
|
35
|
+
type: BooleanConstructor;
|
|
36
|
+
default: boolean;
|
|
37
|
+
};
|
|
38
|
+
/** 显式判定清除位显隐与占位(区间形态的值是数组、日期时间有秒,都没有「一个字符串模型」可喂) */
|
|
39
|
+
hasValue: {
|
|
40
|
+
type: BooleanConstructor;
|
|
41
|
+
default: boolean;
|
|
42
|
+
};
|
|
43
|
+
/** 无值时的占位文案(**透传给输入面**:`hasValue === false` 时由它渲染并取代 `default` 插槽) */
|
|
44
|
+
placeholder: {
|
|
45
|
+
type: StringConstructor;
|
|
46
|
+
default: undefined;
|
|
47
|
+
};
|
|
48
|
+
/** 有值时的显示文本(无值态由输入面的占位承担) */
|
|
49
|
+
label: {
|
|
50
|
+
type: StringConstructor;
|
|
51
|
+
default: undefined;
|
|
52
|
+
};
|
|
53
|
+
/** 面板此刻是否开着(`aria-expanded`,由面板原生 `toggle` 事件回写) */
|
|
54
|
+
expanded: {
|
|
55
|
+
type: BooleanConstructor;
|
|
56
|
+
default: boolean;
|
|
57
|
+
};
|
|
58
|
+
/** 触发器上的键盘契约(`createTriggerKeydown()` 产出) */
|
|
59
|
+
onKeydown: {
|
|
60
|
+
type: PropType<(event: KeyboardEvent) => void>;
|
|
61
|
+
default: undefined;
|
|
62
|
+
};
|
|
63
|
+
/** 清除位被点击(输入面的内建清除位回调;本件只把它转给消费方) */
|
|
64
|
+
onClear: {
|
|
65
|
+
type: PropType<() => void>;
|
|
66
|
+
default: undefined;
|
|
67
|
+
};
|
|
68
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
69
|
+
[key: string]: any;
|
|
70
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
71
|
+
/** 面板 id(`popovertarget` 的目标,由 `createPanelId()` 产出的全页唯一 id) */
|
|
72
|
+
panelId: {
|
|
73
|
+
type: StringConstructor;
|
|
74
|
+
required: true;
|
|
75
|
+
};
|
|
76
|
+
/** 尺寸档(24 / 28 / 32):框高与字号归输入面,本件只透传 */
|
|
77
|
+
size: {
|
|
78
|
+
type: PropType<ControlSize>;
|
|
79
|
+
default: string;
|
|
80
|
+
};
|
|
81
|
+
/** 校验状态(红 / 黄;与输入框同一词表) */
|
|
82
|
+
status: {
|
|
83
|
+
type: PropType<InputStatus>;
|
|
84
|
+
default: undefined;
|
|
85
|
+
};
|
|
86
|
+
disabled: {
|
|
87
|
+
type: BooleanConstructor;
|
|
88
|
+
default: boolean;
|
|
89
|
+
};
|
|
90
|
+
/** 只读档(不展开面板;观感与可编辑档一致,见文件头) */
|
|
91
|
+
readonly: {
|
|
92
|
+
type: BooleanConstructor;
|
|
93
|
+
default: boolean;
|
|
94
|
+
};
|
|
95
|
+
/** 有无边框(**直接透传给输入面**,三档口径与 `Input` 的同名 prop 完全一致) */
|
|
96
|
+
bordered: {
|
|
97
|
+
type: PropType<boolean | "focus">;
|
|
98
|
+
default: boolean;
|
|
99
|
+
};
|
|
100
|
+
clearable: {
|
|
101
|
+
type: BooleanConstructor;
|
|
102
|
+
default: boolean;
|
|
103
|
+
};
|
|
104
|
+
/** 显式判定清除位显隐与占位(区间形态的值是数组、日期时间有秒,都没有「一个字符串模型」可喂) */
|
|
105
|
+
hasValue: {
|
|
106
|
+
type: BooleanConstructor;
|
|
107
|
+
default: boolean;
|
|
108
|
+
};
|
|
109
|
+
/** 无值时的占位文案(**透传给输入面**:`hasValue === false` 时由它渲染并取代 `default` 插槽) */
|
|
110
|
+
placeholder: {
|
|
111
|
+
type: StringConstructor;
|
|
112
|
+
default: undefined;
|
|
113
|
+
};
|
|
114
|
+
/** 有值时的显示文本(无值态由输入面的占位承担) */
|
|
115
|
+
label: {
|
|
116
|
+
type: StringConstructor;
|
|
117
|
+
default: undefined;
|
|
118
|
+
};
|
|
119
|
+
/** 面板此刻是否开着(`aria-expanded`,由面板原生 `toggle` 事件回写) */
|
|
120
|
+
expanded: {
|
|
121
|
+
type: BooleanConstructor;
|
|
122
|
+
default: boolean;
|
|
123
|
+
};
|
|
124
|
+
/** 触发器上的键盘契约(`createTriggerKeydown()` 产出) */
|
|
125
|
+
onKeydown: {
|
|
126
|
+
type: PropType<(event: KeyboardEvent) => void>;
|
|
127
|
+
default: undefined;
|
|
128
|
+
};
|
|
129
|
+
/** 清除位被点击(输入面的内建清除位回调;本件只把它转给消费方) */
|
|
130
|
+
onClear: {
|
|
131
|
+
type: PropType<() => void>;
|
|
132
|
+
default: undefined;
|
|
133
|
+
};
|
|
134
|
+
}>> & Readonly<{}>, {
|
|
135
|
+
size: ControlSize;
|
|
136
|
+
expanded: boolean;
|
|
137
|
+
disabled: boolean;
|
|
138
|
+
label: string;
|
|
139
|
+
onKeydown: (event: KeyboardEvent) => void;
|
|
140
|
+
placeholder: string;
|
|
141
|
+
status: InputStatus;
|
|
142
|
+
readonly: boolean;
|
|
143
|
+
bordered: boolean | "focus";
|
|
144
|
+
clearable: boolean;
|
|
145
|
+
hasValue: boolean;
|
|
146
|
+
onClear: () => void;
|
|
147
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { defineComponent, h, createVNode } from "vue";
|
|
2
|
+
import { Icon } from "@manohub/icon";
|
|
3
|
+
import { Input } from "../input/index.js";
|
|
4
|
+
const DateTrigger = /* @__PURE__ */ defineComponent({
|
|
5
|
+
name: "DateTrigger",
|
|
6
|
+
inheritAttrs: false,
|
|
7
|
+
props: {
|
|
8
|
+
/** 面板 id(`popovertarget` 的目标,由 `createPanelId()` 产出的全页唯一 id) */
|
|
9
|
+
panelId: {
|
|
10
|
+
type: String,
|
|
11
|
+
required: true
|
|
12
|
+
},
|
|
13
|
+
/** 尺寸档(24 / 28 / 32):框高与字号归输入面,本件只透传 */
|
|
14
|
+
size: {
|
|
15
|
+
type: String,
|
|
16
|
+
default: "md"
|
|
17
|
+
},
|
|
18
|
+
/** 校验状态(红 / 黄;与输入框同一词表) */
|
|
19
|
+
status: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: void 0
|
|
22
|
+
},
|
|
23
|
+
disabled: {
|
|
24
|
+
type: Boolean,
|
|
25
|
+
default: false
|
|
26
|
+
},
|
|
27
|
+
/** 只读档(不展开面板;观感与可编辑档一致,见文件头) */
|
|
28
|
+
readonly: {
|
|
29
|
+
type: Boolean,
|
|
30
|
+
default: false
|
|
31
|
+
},
|
|
32
|
+
/** 有无边框(**直接透传给输入面**,三档口径与 `Input` 的同名 prop 完全一致) */
|
|
33
|
+
bordered: {
|
|
34
|
+
type: [Boolean, String],
|
|
35
|
+
default: true
|
|
36
|
+
},
|
|
37
|
+
clearable: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
default: false
|
|
40
|
+
},
|
|
41
|
+
/** 显式判定清除位显隐与占位(区间形态的值是数组、日期时间有秒,都没有「一个字符串模型」可喂) */
|
|
42
|
+
hasValue: {
|
|
43
|
+
type: Boolean,
|
|
44
|
+
default: false
|
|
45
|
+
},
|
|
46
|
+
/** 无值时的占位文案(**透传给输入面**:`hasValue === false` 时由它渲染并取代 `default` 插槽) */
|
|
47
|
+
placeholder: {
|
|
48
|
+
type: String,
|
|
49
|
+
default: void 0
|
|
50
|
+
},
|
|
51
|
+
/** 有值时的显示文本(无值态由输入面的占位承担) */
|
|
52
|
+
label: {
|
|
53
|
+
type: String,
|
|
54
|
+
default: void 0
|
|
55
|
+
},
|
|
56
|
+
/** 面板此刻是否开着(`aria-expanded`,由面板原生 `toggle` 事件回写) */
|
|
57
|
+
expanded: {
|
|
58
|
+
type: Boolean,
|
|
59
|
+
default: false
|
|
60
|
+
},
|
|
61
|
+
/** 触发器上的键盘契约(`createTriggerKeydown()` 产出) */
|
|
62
|
+
onKeydown: {
|
|
63
|
+
type: Function,
|
|
64
|
+
default: void 0
|
|
65
|
+
},
|
|
66
|
+
/** 清除位被点击(输入面的内建清除位回调;本件只把它转给消费方) */
|
|
67
|
+
onClear: {
|
|
68
|
+
type: Function,
|
|
69
|
+
default: void 0
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
setup(props) {
|
|
73
|
+
return () => h(Input, {
|
|
74
|
+
as: "button",
|
|
75
|
+
size: props.size,
|
|
76
|
+
status: props.status,
|
|
77
|
+
disabled: props.disabled,
|
|
78
|
+
readonly: props.readonly,
|
|
79
|
+
bordered: props.bordered,
|
|
80
|
+
clearable: props.clearable,
|
|
81
|
+
hasValue: props.hasValue,
|
|
82
|
+
placeholder: props.placeholder,
|
|
83
|
+
class: "mh-popup-anchor mh-date-picker-host",
|
|
84
|
+
controlClass: "mh-date-picker",
|
|
85
|
+
controlAttrs: {
|
|
86
|
+
popovertarget: props.readonly ? void 0 : props.panelId,
|
|
87
|
+
"aria-haspopup": props.readonly ? void 0 : "dialog",
|
|
88
|
+
"aria-expanded": props.readonly ? void 0 : props.expanded ? "true" : "false",
|
|
89
|
+
onKeydown: props.onKeydown
|
|
90
|
+
},
|
|
91
|
+
/* 输入面的内建清除位写回 `''`,本件只把它转给消费方(日期写 `''`、区间写 `[]`) */
|
|
92
|
+
onChange: () => props.onClear?.()
|
|
93
|
+
}, {
|
|
94
|
+
default: () => createVNode("span", {
|
|
95
|
+
"class": "mh-date-picker__value"
|
|
96
|
+
}, [props.label]),
|
|
97
|
+
/* 日历图标:**不做可见性判定**(只读 / 禁用档也留着,见文件头) */
|
|
98
|
+
suffix: () => createVNode(Icon, {
|
|
99
|
+
"name": "calendar",
|
|
100
|
+
"class": "mh-date-picker__icon"
|
|
101
|
+
}, null)
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
export {
|
|
106
|
+
DateTrigger
|
|
107
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 输入法组合态开关(`Input` / `Textarea` 共用)。
|
|
3
|
+
*
|
|
4
|
+
* 组合期间控件里是**半成品**(拼音一类),此刻不上报、也不把模型写进控件:上报会让「输入即查」
|
|
5
|
+
* 一路查拼音,写回会让浏览器**结束这次组合**(拼音被当成已上屏的字,中文再也打不出来)。
|
|
6
|
+
*
|
|
7
|
+
* 收尾由「那条最终 `input`」与 `compositionend` 里**先到的那个**负责,另一个不再报(同一个串只认一次:
|
|
8
|
+
* Chrome 是先 `input` 后 `compositionend`,Safari 相反);`compositionend` 那一下只在**真的改了值**时
|
|
9
|
+
* 才报 —— Esc 撤消组合、候选没上屏都不该产生一次值变更。普通(非组合)输入一律照报,与改前完全一致。
|
|
10
|
+
*/
|
|
11
|
+
export interface CompositionGuard {
|
|
12
|
+
/** 是否处在组合中 */
|
|
13
|
+
composing: () => boolean;
|
|
14
|
+
/** 组合开始(幂等):记下开始前的值,用来判收尾有没有真的改值 */
|
|
15
|
+
start: (value: string) => void;
|
|
16
|
+
/** 组合结束:返回这次调用是否收掉了一次**开着的**组合(已被最终 `input` 收掉时为 `false`) */
|
|
17
|
+
end: () => boolean;
|
|
18
|
+
/** 组合收尾该不该上报:与组合开始前的值相同就不报 */
|
|
19
|
+
changed: (value: string) => boolean;
|
|
20
|
+
/** 把收尾报过的串记进「吞并位」:紧随其后的同值 `input` 是同一次动作的第二次通知 */
|
|
21
|
+
arm: (value: string) => void;
|
|
22
|
+
/** 这次 `input` 要不要吞掉(只认紧随收尾的那一个同值串,用完即失效) */
|
|
23
|
+
swallow: (value: string) => boolean;
|
|
24
|
+
}
|
|
25
|
+
export declare const createCompositionGuard: () => CompositionGuard;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const createCompositionGuard = () => {
|
|
2
|
+
let composing = false;
|
|
3
|
+
let before = "";
|
|
4
|
+
let tail = null;
|
|
5
|
+
return {
|
|
6
|
+
composing: () => composing,
|
|
7
|
+
start: (value) => {
|
|
8
|
+
if (composing) return;
|
|
9
|
+
composing = true;
|
|
10
|
+
before = value;
|
|
11
|
+
tail = null;
|
|
12
|
+
},
|
|
13
|
+
end: () => {
|
|
14
|
+
const open = composing;
|
|
15
|
+
composing = false;
|
|
16
|
+
return open;
|
|
17
|
+
},
|
|
18
|
+
changed: (value) => value !== before,
|
|
19
|
+
arm: (value) => {
|
|
20
|
+
tail = value;
|
|
21
|
+
},
|
|
22
|
+
swallow: (value) => {
|
|
23
|
+
const hit = tail === value;
|
|
24
|
+
tail = null;
|
|
25
|
+
return hit;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export {
|
|
30
|
+
createCompositionGuard
|
|
31
|
+
};
|
|
@@ -125,7 +125,7 @@ declare const InputBase: import("vue").DefineComponent<import("vue").ExtractProp
|
|
|
125
125
|
type: StringConstructor;
|
|
126
126
|
default: string;
|
|
127
127
|
};
|
|
128
|
-
/**
|
|
128
|
+
/** 值变更回调(每次输入都调;**输入法组合期间不调**,候选上屏那一次调) */
|
|
129
129
|
onChange: {
|
|
130
130
|
type: PropType<(v: string) => void>;
|
|
131
131
|
default: undefined;
|
|
@@ -254,7 +254,7 @@ declare const InputBase: import("vue").DefineComponent<import("vue").ExtractProp
|
|
|
254
254
|
type: StringConstructor;
|
|
255
255
|
default: string;
|
|
256
256
|
};
|
|
257
|
-
/**
|
|
257
|
+
/** 值变更回调(每次输入都调;**输入法组合期间不调**,候选上屏那一次调) */
|
|
258
258
|
onChange: {
|
|
259
259
|
type: PropType<(v: string) => void>;
|
|
260
260
|
default: undefined;
|
|
@@ -613,7 +613,7 @@ export declare const InputCompound: {
|
|
|
613
613
|
type: StringConstructor;
|
|
614
614
|
default: string;
|
|
615
615
|
};
|
|
616
|
-
/**
|
|
616
|
+
/** 值变更回调(每次输入都调;**输入法组合期间不调**,候选上屏那一次调) */
|
|
617
617
|
onChange: {
|
|
618
618
|
type: PropType<(v: string) => void>;
|
|
619
619
|
default: undefined;
|
|
@@ -777,7 +777,7 @@ export declare const InputCompound: {
|
|
|
777
777
|
type: StringConstructor;
|
|
778
778
|
default: string;
|
|
779
779
|
};
|
|
780
|
-
/**
|
|
780
|
+
/** 值变更回调(每次输入都调;**输入法组合期间不调**,候选上屏那一次调) */
|
|
781
781
|
onChange: {
|
|
782
782
|
type: PropType<(v: string) => void>;
|
|
783
783
|
default: undefined;
|
|
@@ -932,7 +932,7 @@ export declare const InputCompound: {
|
|
|
932
932
|
type: StringConstructor;
|
|
933
933
|
default: string;
|
|
934
934
|
};
|
|
935
|
-
/**
|
|
935
|
+
/** 值变更回调(每次输入都调;**输入法组合期间不调**,候选上屏那一次调) */
|
|
936
936
|
onChange: {
|
|
937
937
|
type: PropType<(v: string) => void>;
|
|
938
938
|
default: undefined;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { defineComponent, ref, computed, createVNode, mergeProps, createTextVNode } from "vue";
|
|
1
|
+
import { defineComponent, ref, computed, watch, createVNode, mergeProps, createTextVNode, nextTick } from "vue";
|
|
2
2
|
import { Icon } from "@manohub/icon";
|
|
3
3
|
import { borderedClassOf } from "./bordered.js";
|
|
4
|
+
import { createCompositionGuard } from "./composition.js";
|
|
4
5
|
const InputBase = /* @__PURE__ */ defineComponent({
|
|
5
6
|
name: "Input",
|
|
6
7
|
inheritAttrs: false,
|
|
@@ -99,7 +100,7 @@ const InputBase = /* @__PURE__ */ defineComponent({
|
|
|
99
100
|
type: String,
|
|
100
101
|
default: "off"
|
|
101
102
|
},
|
|
102
|
-
/**
|
|
103
|
+
/** 值变更回调(每次输入都调;**输入法组合期间不调**,候选上屏那一次调) */
|
|
103
104
|
onChange: {
|
|
104
105
|
type: Function,
|
|
105
106
|
default: void 0
|
|
@@ -159,6 +160,12 @@ const InputBase = /* @__PURE__ */ defineComponent({
|
|
|
159
160
|
const inner = ref(props.defaultValue);
|
|
160
161
|
const current = computed(() => props.modelValue ?? inner.value);
|
|
161
162
|
const revealed = ref(false);
|
|
163
|
+
const ime = createCompositionGuard();
|
|
164
|
+
const rendered = ref(current.value ?? "");
|
|
165
|
+
watch(current, (value) => {
|
|
166
|
+
if (ime.composing()) return;
|
|
167
|
+
rendered.value = value ?? "";
|
|
168
|
+
});
|
|
162
169
|
const forwardAttrs = computed(() => {
|
|
163
170
|
const rest = {};
|
|
164
171
|
for (const [key, value] of Object.entries(attrs)) {
|
|
@@ -173,10 +180,40 @@ const InputBase = /* @__PURE__ */ defineComponent({
|
|
|
173
180
|
emit("update:modelValue", value);
|
|
174
181
|
props.onChange?.(value);
|
|
175
182
|
};
|
|
183
|
+
const report = (el) => {
|
|
184
|
+
const value = el.value;
|
|
185
|
+
commit(value);
|
|
186
|
+
if (props.modelValue === void 0) return;
|
|
187
|
+
void nextTick(() => {
|
|
188
|
+
const model = props.modelValue;
|
|
189
|
+
if (model === void 0 || ime.composing() || el.value !== value || el.value === model) return;
|
|
190
|
+
el.value = model;
|
|
191
|
+
rendered.value = model;
|
|
192
|
+
});
|
|
193
|
+
};
|
|
176
194
|
const onInput = (event) => {
|
|
177
195
|
const el = event.target;
|
|
178
|
-
|
|
179
|
-
|
|
196
|
+
if (event.isComposing) {
|
|
197
|
+
ime.start(el.value);
|
|
198
|
+
rendered.value = el.value;
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
if (ime.swallow(el.value)) {
|
|
202
|
+
rendered.value = el.value;
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
if (ime.composing()) {
|
|
206
|
+
ime.end();
|
|
207
|
+
ime.arm(el.value);
|
|
208
|
+
}
|
|
209
|
+
report(el);
|
|
210
|
+
};
|
|
211
|
+
const onCompositionstart = (event) => ime.start(event.target.value);
|
|
212
|
+
const onCompositionend = (event) => {
|
|
213
|
+
const el = event.target;
|
|
214
|
+
if (!ime.end()) return;
|
|
215
|
+
ime.arm(el.value);
|
|
216
|
+
if (ime.changed(el.value)) report(el);
|
|
180
217
|
};
|
|
181
218
|
const onKeydown = (event) => {
|
|
182
219
|
if (event.isComposing) return;
|
|
@@ -225,7 +262,7 @@ const InputBase = /* @__PURE__ */ defineComponent({
|
|
|
225
262
|
) : createVNode("input", mergeProps(forwardAttrs.value, {
|
|
226
263
|
"class": controlClasses.value,
|
|
227
264
|
"type": inputType.value,
|
|
228
|
-
"value":
|
|
265
|
+
"value": rendered.value,
|
|
229
266
|
"placeholder": props.placeholder,
|
|
230
267
|
"disabled": props.disabled,
|
|
231
268
|
"readonly": props.readonly,
|
|
@@ -234,7 +271,9 @@ const InputBase = /* @__PURE__ */ defineComponent({
|
|
|
234
271
|
"autocomplete": props.autocomplete,
|
|
235
272
|
"aria-invalid": isInvalid.value ? "true" : void 0,
|
|
236
273
|
"onInput": onInput,
|
|
237
|
-
"onKeydown": onKeydown
|
|
274
|
+
"onKeydown": onKeydown,
|
|
275
|
+
"onCompositionstart": onCompositionstart,
|
|
276
|
+
"onCompositionend": onCompositionend
|
|
238
277
|
}), null), showClear.value ? createVNode("button", {
|
|
239
278
|
"type": "button",
|
|
240
279
|
"class": "mh-input__clear",
|
|
@@ -345,6 +384,12 @@ const Textarea = /* @__PURE__ */ defineComponent({
|
|
|
345
384
|
}) {
|
|
346
385
|
const inner = ref(props.defaultValue);
|
|
347
386
|
const current = computed(() => props.modelValue ?? inner.value);
|
|
387
|
+
const ime = createCompositionGuard();
|
|
388
|
+
const rendered = ref(current.value ?? "");
|
|
389
|
+
watch(current, (value) => {
|
|
390
|
+
if (ime.composing()) return;
|
|
391
|
+
rendered.value = value ?? "";
|
|
392
|
+
});
|
|
348
393
|
const forwardAttrs = computed(() => {
|
|
349
394
|
const rest = {};
|
|
350
395
|
for (const [key, value] of Object.entries(attrs)) {
|
|
@@ -363,13 +408,45 @@ const Textarea = /* @__PURE__ */ defineComponent({
|
|
|
363
408
|
const lines = (current.value ?? "").split("\n").length;
|
|
364
409
|
return Math.min(Math.max(lines, min), max);
|
|
365
410
|
});
|
|
366
|
-
const
|
|
367
|
-
const el = event.target;
|
|
368
|
-
const value = el.value;
|
|
411
|
+
const commit = (value) => {
|
|
369
412
|
if (props.modelValue === void 0) inner.value = value;
|
|
370
413
|
emit("update:modelValue", value);
|
|
371
414
|
props.onChange?.(value);
|
|
372
|
-
|
|
415
|
+
};
|
|
416
|
+
const report = (el) => {
|
|
417
|
+
const value = el.value;
|
|
418
|
+
commit(value);
|
|
419
|
+
if (props.modelValue === void 0) return;
|
|
420
|
+
void nextTick(() => {
|
|
421
|
+
const model = props.modelValue;
|
|
422
|
+
if (model === void 0 || ime.composing() || el.value !== value || el.value === model) return;
|
|
423
|
+
el.value = model;
|
|
424
|
+
rendered.value = model;
|
|
425
|
+
});
|
|
426
|
+
};
|
|
427
|
+
const onInput = (event) => {
|
|
428
|
+
const el = event.target;
|
|
429
|
+
if (event.isComposing) {
|
|
430
|
+
ime.start(el.value);
|
|
431
|
+
rendered.value = el.value;
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
if (ime.swallow(el.value)) {
|
|
435
|
+
rendered.value = el.value;
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
438
|
+
if (ime.composing()) {
|
|
439
|
+
ime.end();
|
|
440
|
+
ime.arm(el.value);
|
|
441
|
+
}
|
|
442
|
+
report(el);
|
|
443
|
+
};
|
|
444
|
+
const onCompositionstart = (event) => ime.start(event.target.value);
|
|
445
|
+
const onCompositionend = (event) => {
|
|
446
|
+
const el = event.target;
|
|
447
|
+
if (!ime.end()) return;
|
|
448
|
+
ime.arm(el.value);
|
|
449
|
+
if (ime.changed(el.value)) report(el);
|
|
373
450
|
};
|
|
374
451
|
return () => createVNode("div", {
|
|
375
452
|
"class": ["mh-input__wrap", attrs.class].filter(Boolean).join(" "),
|
|
@@ -377,7 +454,7 @@ const Textarea = /* @__PURE__ */ defineComponent({
|
|
|
377
454
|
}, [createVNode("textarea", mergeProps(forwardAttrs.value, {
|
|
378
455
|
"class": ["mh-input", "mh-input--textarea", props.size === "md" ? "" : `mh-input--${props.size}`, borderedClassOf(props.bordered), visualStatus.value ? `is-${visualStatus.value}` : "", props.disabled ? "is-disabled" : ""].filter(Boolean).join(" "),
|
|
379
456
|
"rows": autoRows.value,
|
|
380
|
-
"value":
|
|
457
|
+
"value": rendered.value,
|
|
381
458
|
"placeholder": props.placeholder,
|
|
382
459
|
"disabled": props.disabled,
|
|
383
460
|
"readonly": props.readonly,
|
|
@@ -385,7 +462,9 @@ const Textarea = /* @__PURE__ */ defineComponent({
|
|
|
385
462
|
"autofocus": props.autofocus,
|
|
386
463
|
"autocomplete": props.autocomplete,
|
|
387
464
|
"aria-invalid": isInvalid.value ? "true" : void 0,
|
|
388
|
-
"onInput": onInput
|
|
465
|
+
"onInput": onInput,
|
|
466
|
+
"onCompositionstart": onCompositionstart,
|
|
467
|
+
"onCompositionend": onCompositionend
|
|
389
468
|
}), null), showCounter.value ? createVNode("span", {
|
|
390
469
|
"class": "mh-input__counter"
|
|
391
470
|
}, [current.value?.length ?? 0, createTextVNode("/"), props.maxlength]) : null]);
|
|
@@ -20,7 +20,7 @@ export interface SearchProps {
|
|
|
20
20
|
searchText?: string;
|
|
21
21
|
/** 触发位形态(配合 `searchText` 或单独给):`text` 文案按钮 / `icon` 纯图标按钮 */
|
|
22
22
|
action?: SearchAction;
|
|
23
|
-
/**
|
|
23
|
+
/** 值变更回调(每次输入都调,含清空;**输入法组合期间不调**,候选上屏那一次调) */
|
|
24
24
|
onChange?: (value: string) => void;
|
|
25
25
|
/** 搜索触发(点搜索按钮 / 输入框内回车) */
|
|
26
26
|
onSearch?: (value: string) => void;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Select —— 选择器(**自绘**,不封装 farris);同目录另出 `SelectTree`(树选择)。
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* 本文件是选择器族的**组装层与出口**:两件都只是把下面几个内件拼起来,内件一律不对外导出
|
|
5
|
+
* (`src/index.ts` 只出这两件,成员不平级、也不挂点号):
|
|
6
6
|
* `select-shared.ts`(类型 / 面板 id / popover 开合 / 触发器键盘契约)、`select-trigger.tsx`(触发器内件)、
|
|
7
7
|
* `select-panel.tsx`(面板壳)、`select-list.tsx`(列表体)、`select-tree.tsx`(树体)、
|
|
8
8
|
* `select-tree-filter.ts`(纯函数:树过滤与命中切分)。
|
|
9
|
+
*
|
|
10
|
+
* **日期族已迁出**(2026-10-14,`components/date-picker/`):它有自己的一份面(`date-picker.css`)与自己的
|
|
11
|
+
* 触发器 / 面板壳 / 日历 / 时间行内件 —— 本目录不再承载任何日期代码。
|
|
9
12
|
* 拆件的收益是**规格只剩一份**:触发器与面板壳在「列表形态」与「树形态」之间是同一份代码,改一处两处都
|
|
10
13
|
* 跟着走;面上仍是**一个** `styles/components/select.css`。
|
|
11
14
|
*
|
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
* `aria-required-children` 报)。本件是两形态共用的壳,写死任一角色都会让另一种形态错位,故 `role` 是 prop:
|
|
12
12
|
* `Select` 传 `listbox`、`SelectTree` 传 `tree`(各传一次,同 `haspopup` 在触发器上的口径)。
|
|
13
13
|
*
|
|
14
|
+
* (日期族自 2026-10-14 起有自己的面板壳 `components/date-picker/panel.tsx`:那个壳角色固定 `dialog`、
|
|
15
|
+
* 也没有搜索行 —— 两族不再共用本件,见该文件头。)
|
|
16
|
+
*
|
|
14
17
|
* **限高在面层**:面板根上钉着 `--ui-select-panel-max-height`(`select.css`),超出即内容区滚动、搜索行常驻不滚。内容区
|
|
15
18
|
* 这一层因此是**结构性的**(不是可有可无的包裹):少了它,长列表 / 长树会把面板一路撑高(实测 60 条选项 2212px),搜索行
|
|
16
19
|
* 也会跟着滚走。本件只负责把它渲染出来。
|
package/dist/index.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ export { Button, Segmented, type ButtonVariant, type ButtonCompound, type Button
|
|
|
34
34
|
export { Input, Textarea, NumberInput, type TextareaProps, type NumberInputProps, type InputCompound, type InputCompoundType, } from './components/input';
|
|
35
35
|
export { Search, type SearchProps } from './components/search';
|
|
36
36
|
export { Select, SelectTree, type SelectOption, type SelectValue } from './components/select';
|
|
37
|
+
export { DatePicker, DateRangePicker, DateTimePicker, type DatePickerProps, type DatePickerCompoundType, type DateRangePickerProps, type DateTimePickerProps, } from './components/date-picker';
|
|
37
38
|
export { Switch } from './components/switch';
|
|
38
39
|
export { Capsule, type CapsuleOption, type CapsuleShape } from './components/capsule';
|
|
39
40
|
export { Form, type FormProps, type FormHeaderProps, type FormItemProps, type FormValues, type FormItemSlotScope, type FormItemAlign, type FormLabelAlign, type FormColumns, type FormPadding, type FormCompound, } from './components/form';
|
package/dist/index.js
CHANGED
|
@@ -16,6 +16,7 @@ import { Button } from "./components/button/index.js";
|
|
|
16
16
|
import { Input, Textarea } from "./components/input/index.js";
|
|
17
17
|
import { Search } from "./components/search/index.js";
|
|
18
18
|
import { Select } from "./components/select/index.js";
|
|
19
|
+
import { DatePicker, DateRangePicker, DateTimePicker } from "./components/date-picker/index.js";
|
|
19
20
|
import { Switch } from "./components/switch/index.js";
|
|
20
21
|
import { Capsule } from "./components/capsule/index.js";
|
|
21
22
|
import { Form } from "./components/form/index.js";
|
|
@@ -54,6 +55,9 @@ export {
|
|
|
54
55
|
Checkbox,
|
|
55
56
|
CodeBlock,
|
|
56
57
|
Collapse,
|
|
58
|
+
DatePicker,
|
|
59
|
+
DateRangePicker,
|
|
60
|
+
DateTimePicker,
|
|
57
61
|
Dialog,
|
|
58
62
|
Divider,
|
|
59
63
|
Drawer,
|