twcpt 0.0.2 → 0.0.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.
@@ -0,0 +1,147 @@
1
+ import { DefineComponent } from 'vue';
2
+ /**
3
+ * @description JTWDatePicker 日期范围选择器组件
4
+ * 基于 Element Plus DatePicker 封装,采用 Quasar 风格的属性设计
5
+ */
6
+ export interface JTWDatePickerProps {
7
+ /**
8
+ * 绑定值(日期范围数组)
9
+ * @default undefined
10
+ */
11
+ modelValue?: [Date, Date] | [string, string] | [number, number];
12
+ /**
13
+ * 日期格式
14
+ * @default 'YYYY-MM-DD'
15
+ */
16
+ format?: string;
17
+ /**
18
+ * 值的格式(传给 v-model 的格式)
19
+ * @default 'YYYY-MM-DD'
20
+ */
21
+ valueFormat?: string;
22
+ /**
23
+ * 占位符文本
24
+ * @default '选择日期范围'
25
+ */
26
+ placeholder?: string;
27
+ /**
28
+ * 开始日期占位符
29
+ * @default '开始日期'
30
+ */
31
+ startPlaceholder?: string;
32
+ /**
33
+ * 结束日期占位符
34
+ * @default '结束日期'
35
+ */
36
+ endPlaceholder?: string;
37
+ /**
38
+ * 是否禁用
39
+ * @default false
40
+ */
41
+ disable?: boolean;
42
+ /**
43
+ * 是否只读
44
+ * @default false
45
+ */
46
+ readonly?: boolean;
47
+ /**
48
+ * 是否可清空
49
+ * @default true
50
+ */
51
+ clearable?: boolean;
52
+ /**
53
+ * 禁用的日期(函数返回 true 表示禁用该日期)
54
+ */
55
+ disabledDate?: (date: Date) => boolean;
56
+ /**
57
+ * 可选的最小日期
58
+ */
59
+ minDate?: Date | string | number;
60
+ /**
61
+ * 可选的最大日期
62
+ */
63
+ maxDate?: Date | string | number;
64
+ /**
65
+ * 默认显示的日期
66
+ */
67
+ defaultValue?: Date | [Date, Date];
68
+ /**
69
+ * 范围分隔符
70
+ * @default '—'
71
+ */
72
+ rangeSeparator?: string;
73
+ /**
74
+ * 是否显示清除按钮
75
+ * @default true
76
+ */
77
+ showClearButton?: boolean;
78
+ /**
79
+ * 弹出面板的位置
80
+ * @default 'bottom-start'
81
+ */
82
+ placement?: 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end' | 'right' | 'right-start' | 'right-end';
83
+ /**
84
+ * 自定义类名
85
+ */
86
+ customClass?: string;
87
+ /**
88
+ * 弹出面板的自定义类名
89
+ */
90
+ popperClass?: string;
91
+ /**
92
+ * 快捷选项
93
+ */
94
+ shortcuts?: Array<{
95
+ text: string;
96
+ value: [Date, Date] | (() => [Date, Date]);
97
+ }>;
98
+ }
99
+ /** JTWDatePicker Emits 接口 */
100
+ export interface JTWDatePickerEmits {
101
+ (e: 'update:modelValue', value: [Date, Date] | [string, string] | [number, number] | undefined): void;
102
+ (e: 'change', value: [Date, Date] | [string, string] | [number, number] | undefined): void;
103
+ (e: 'blur', event: FocusEvent): void;
104
+ (e: 'focus', event: FocusEvent): void;
105
+ (e: 'clear'): void;
106
+ (e: 'visible-change', visible: boolean): void;
107
+ }
108
+ /** JTWDatePicker Slots 接口 */
109
+ export interface JTWDatePickerSlots {
110
+ /** 自定义日历图标 */
111
+ 'prefix-icon'?: () => any;
112
+ /** 自定义范围分隔符 */
113
+ 'range-separator'?: () => any;
114
+ }
115
+ /** JTWDatePicker 暴露的方法 */
116
+ export interface JTWDatePickerExpose {
117
+ /** 根元素 */
118
+ $el: HTMLElement | undefined;
119
+ /** 聚焦输入框 */
120
+ focus: () => void;
121
+ /** 失焦输入框 */
122
+ blur: () => void;
123
+ }
124
+ /** Emits 配置对象格式 */
125
+ export type JTWDatePickerEmitsOptions = {
126
+ 'update:modelValue': (value: [Date, Date] | [string, string] | [number, number] | undefined) => true;
127
+ change: (value: [Date, Date] | [string, string] | [number, number] | undefined) => true;
128
+ blur: (event: FocusEvent) => true;
129
+ focus: (event: FocusEvent) => true;
130
+ clear: () => true;
131
+ 'visible-change': (visible: boolean) => true;
132
+ };
133
+ /** JTWDatePicker 组件类型定义 */
134
+ export type JTWDatePickerComponent = DefineComponent<JTWDatePickerProps, JTWDatePickerExpose, {}, {}, {}, {}, {}, JTWDatePickerEmitsOptions>;
135
+ /** JTWDatePicker 实例类型 */
136
+ export type JTWDatePickerInstance = InstanceType<JTWDatePickerComponent> & JTWDatePickerExpose;
137
+ /** JTWDatePicker 模板 Props(用于全局类型声明) */
138
+ export interface JTWDatePickerTemplateProps extends JTWDatePickerProps {
139
+ 'onUpdate:modelValue'?: (value: [Date, Date] | [string, string] | [number, number] | undefined) => void;
140
+ onChange?: (value: [Date, Date] | [string, string] | [number, number] | undefined) => void;
141
+ onBlur?: (event: FocusEvent) => void;
142
+ onFocus?: (event: FocusEvent) => void;
143
+ onClear?: () => void;
144
+ 'onVisible-change'?: (visible: boolean) => void;
145
+ class?: string | Record<string, boolean> | Array<string | Record<string, boolean>>;
146
+ style?: string | Record<string, string>;
147
+ }
@@ -0,0 +1,3 @@
1
+ import { default as JTWDropdownBtn } from './index';
2
+ export default JTWDropdownBtn;
3
+ export * from './types';
@@ -0,0 +1,69 @@
1
+ import { DefineComponent } from 'vue';
2
+ import { JTWBtnProps } from '../j-tw-btn/types';
3
+ /** 下拉选项 */
4
+ export interface JTWDropdownOption {
5
+ /** 选项唯一标识 */
6
+ value: string | number;
7
+ /** 选项显示文本 */
8
+ label: string;
9
+ /** 是否禁用 */
10
+ disabled?: boolean;
11
+ }
12
+ /**
13
+ * @description JTWDropdownBtn 下拉按钮组件
14
+ * 只支持 primary 颜色,不支持 color 属性
15
+ */
16
+ export interface JTWDropdownBtnProps extends Omit<JTWBtnProps, 'color'> {
17
+ /**
18
+ * 下拉选项列表
19
+ */
20
+ options?: JTWDropdownOption[];
21
+ /**
22
+ * 当前选中的值
23
+ */
24
+ modelValue?: string | number;
25
+ }
26
+ /** JTWDropdownBtn Emits 接口 */
27
+ export interface JTWDropdownBtnEmits {
28
+ (e: 'click', event: MouseEvent): void;
29
+ (e: 'update:modelValue', value: string | number): void;
30
+ (e: 'select', option: JTWDropdownOption): void;
31
+ }
32
+ /** JTWDropdownBtn Slots 接口 */
33
+ export interface JTWDropdownBtnSlots {
34
+ /** 默认插槽,按钮文本内容 */
35
+ default?: () => any;
36
+ /** 图标插槽 */
37
+ icon?: () => any;
38
+ /** 自定义加载图标插槽 */
39
+ loading?: () => any;
40
+ }
41
+ /** JTWDropdownBtn 暴露的方法 */
42
+ export interface JTWDropdownBtnExpose {
43
+ /** 按钮根元素 */
44
+ $el: HTMLElement | undefined;
45
+ /** 触发点击 */
46
+ click: () => void;
47
+ /** 打开下拉菜单 */
48
+ openDropdown: () => void;
49
+ /** 关闭下拉菜单 */
50
+ closeDropdown: () => void;
51
+ }
52
+ /** Emits 配置对象格式 */
53
+ export type JTWDropdownBtnEmitsOptions = {
54
+ click: (e: MouseEvent) => true;
55
+ 'update:modelValue': (value: string | number) => true;
56
+ select: (option: JTWDropdownOption) => true;
57
+ };
58
+ /** JTWDropdownBtn 组件类型定义 */
59
+ export type JTWDropdownBtnComponent = DefineComponent<JTWDropdownBtnProps, JTWDropdownBtnExpose, {}, {}, {}, {}, {}, JTWDropdownBtnEmitsOptions>;
60
+ /** JTWDropdownBtn 实例类型 */
61
+ export type JTWDropdownBtnInstance = InstanceType<JTWDropdownBtnComponent> & JTWDropdownBtnExpose;
62
+ /** JTWDropdownBtn 模板 Props(用于全局类型声明) */
63
+ export interface JTWDropdownBtnTemplateProps extends JTWDropdownBtnProps {
64
+ onClick?: (event: MouseEvent) => void;
65
+ 'onUpdate:modelValue'?: (value: string | number) => void;
66
+ onSelect?: (option: JTWDropdownOption) => void;
67
+ class?: string | Record<string, boolean> | Array<string | Record<string, boolean>>;
68
+ style?: string | Record<string, string>;
69
+ }