@wangxinowo/vue-datepicker-next 1.0.2 → 1.0.5

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/package.json CHANGED
@@ -1,88 +1,88 @@
1
- {
2
- "name": "@wangxinowo/vue-datepicker-next",
3
- "version": "1.0.2",
4
- "description": "A powerful Vue 2.x DatePicker component based on Ant Design Vue",
5
- "main": "dist/vue-datepicker-next.min.js",
6
- "module": "dist/vue-datepicker-next.min.js",
7
- "typings": "types/index.d.ts",
8
- "files": [
9
- "dist",
10
- "src",
11
- "types"
12
- ],
13
- "scripts": {
14
- "dev": "webpack-dev-server --config webpack.dev.config.js --mode development",
15
- "build": "npm run build:dist",
16
- "build:dist": "webpack --config webpack.config.js --mode production",
17
- "prepublishOnly": "npm run build"
18
- },
19
- "keywords": [
20
- "vue",
21
- "datepicker",
22
- "date-picker",
23
- "rangepicker",
24
- "calendar",
25
- "ant-design"
26
- ],
27
- "author": "wangxinowo",
28
- "license": "MIT",
29
- "repository": {
30
- "type": "git",
31
- "url": "https://github.com/wangxinowo/vue-datepicker-next.git"
32
- },
33
- "peerDependencies": {
34
- "vue": "^2.6.0"
35
- },
36
- "dependencies": {
37
- "@ant-design/icons-vue": "^2.0.0",
38
- "add-dom-event-listener": "^1.1.0",
39
- "array-tree-filter": "^2.1.0",
40
- "classnames": "^2.2.5",
41
- "component-classes": "^1.2.6",
42
- "dayjs": "^1.11.19",
43
- "dom-align": "^1.10.4",
44
- "dom-scroll-into-view": "^2.0.0",
45
- "lodash": "^4.17.5",
46
- "moment": "^2.21.0",
47
- "omit.js": "^2.0.2",
48
- "raf": "^3.4.1",
49
- "resize-observer-polyfill": "^1.5.1",
50
- "shallowequal": "^1.0.2",
51
- "vue-ref": "^2.0.0",
52
- "warning": "^4.0.0"
53
- },
54
- "devDependencies": {
55
- "@babel/plugin-syntax-jsx": "^7.27.1",
56
- "@vue/babel-helper-vue-jsx-merge-props": "^1.4.0",
57
- "babel-cli": "^6.26.0",
58
- "babel-core": "^6.26.3",
59
- "babel-helper-vue-jsx-merge-props": "^2.0.3",
60
- "babel-loader": "^7.1.5",
61
- "babel-plugin-syntax-jsx": "^6.18.0",
62
- "babel-plugin-transform-class-properties": "^6.24.1",
63
- "babel-plugin-transform-object-rest-spread": "^6.26.0",
64
- "babel-plugin-transform-runtime": "^6.23.0",
65
- "babel-plugin-transform-vue-jsx": "^3.7.0",
66
- "babel-preset-env": "^1.7.0",
67
- "babel-runtime": "^6.26.0",
68
- "cross-env": "^7.0.0",
69
- "css-loader": "^3.0.0",
70
- "html-webpack-plugin": "^4.5.2",
71
- "ignore-loader": "^0.1.2",
72
- "less": "^3.9.0",
73
- "less-loader": "^6.0.0",
74
- "mini-css-extract-plugin": "^0.10.0",
75
- "vue": "^2.6.11",
76
- "vue-loader": "^15.6.2",
77
- "vue-style-loader": "^4.1.3",
78
- "vue-template-compiler": "^2.6.11",
79
- "webpack": "^4.28.4",
80
- "webpack-cli": "^3.2.1",
81
- "webpack-dev-server": "^3.11.3"
82
- },
83
- "sideEffects": [
84
- "*.less",
85
- "*.css",
86
- "**/style/*"
87
- ]
88
- }
1
+ {
2
+ "name": "@wangxinowo/vue-datepicker-next",
3
+ "version": "1.0.5",
4
+ "description": "A powerful Vue 2.x DatePicker component based on Ant Design Vue",
5
+ "main": "dist/vue-datepicker-next.min.js",
6
+ "module": "dist/vue-datepicker-next.min.js",
7
+ "typings": "types/index.d.ts",
8
+ "files": [
9
+ "dist",
10
+ "src",
11
+ "types"
12
+ ],
13
+ "scripts": {
14
+ "dev": "webpack-dev-server --config webpack.dev.config.js --mode development",
15
+ "build": "npm run build:dist",
16
+ "build:dist": "webpack --config webpack.config.js --mode production",
17
+ "prepublishOnly": "npm run build"
18
+ },
19
+ "keywords": [
20
+ "vue",
21
+ "datepicker",
22
+ "date-picker",
23
+ "rangepicker",
24
+ "calendar",
25
+ "ant-design"
26
+ ],
27
+ "author": "wangxinowo",
28
+ "license": "MIT",
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "https://github.com/wangxinowo/vue-datepicker-next.git"
32
+ },
33
+ "peerDependencies": {
34
+ "vue": "^2.6.0"
35
+ },
36
+ "dependencies": {
37
+ "@ant-design/icons-vue": "^2.0.0",
38
+ "add-dom-event-listener": "^1.1.0",
39
+ "array-tree-filter": "^2.1.0",
40
+ "classnames": "^2.2.5",
41
+ "component-classes": "^1.2.6",
42
+ "dayjs": "^1.11.19",
43
+ "dom-align": "^1.10.4",
44
+ "dom-scroll-into-view": "^2.0.0",
45
+ "lodash": "^4.17.5",
46
+ "moment": "^2.21.0",
47
+ "omit.js": "^2.0.2",
48
+ "raf": "^3.4.1",
49
+ "resize-observer-polyfill": "^1.5.1",
50
+ "shallowequal": "^1.0.2",
51
+ "vue-ref": "^2.0.0",
52
+ "warning": "^4.0.0"
53
+ },
54
+ "devDependencies": {
55
+ "@babel/plugin-syntax-jsx": "^7.27.1",
56
+ "@vue/babel-helper-vue-jsx-merge-props": "^1.4.0",
57
+ "babel-cli": "^6.26.0",
58
+ "babel-core": "^6.26.3",
59
+ "babel-helper-vue-jsx-merge-props": "^2.0.3",
60
+ "babel-loader": "^7.1.5",
61
+ "babel-plugin-syntax-jsx": "^6.18.0",
62
+ "babel-plugin-transform-class-properties": "^6.24.1",
63
+ "babel-plugin-transform-object-rest-spread": "^6.26.0",
64
+ "babel-plugin-transform-runtime": "^6.23.0",
65
+ "babel-plugin-transform-vue-jsx": "^3.7.0",
66
+ "babel-preset-env": "^1.7.0",
67
+ "babel-runtime": "^6.26.0",
68
+ "cross-env": "^7.0.0",
69
+ "css-loader": "^3.0.0",
70
+ "html-webpack-plugin": "^4.5.2",
71
+ "ignore-loader": "^0.1.2",
72
+ "less": "^3.9.0",
73
+ "less-loader": "^6.0.0",
74
+ "mini-css-extract-plugin": "^0.10.0",
75
+ "vue": "^2.6.11",
76
+ "vue-loader": "^15.6.2",
77
+ "vue-style-loader": "^4.1.3",
78
+ "vue-template-compiler": "^2.6.11",
79
+ "webpack": "^4.28.4",
80
+ "webpack-cli": "^3.2.1",
81
+ "webpack-dev-server": "^3.11.3"
82
+ },
83
+ "sideEffects": [
84
+ "*.less",
85
+ "*.css",
86
+ "**/style/*"
87
+ ]
88
+ }
@@ -0,0 +1,2 @@
1
+ import zh_CN from '../../date-picker/locale/zh_CN';
2
+ export default zh_CN;
@@ -1,102 +1,148 @@
1
- /**
2
- * PresetPanel - 预设日期范围面板组件
3
- * 用于显示快捷选择的预设日期范围
4
- */
5
-
6
- import PropTypes from '../_util/vue-types';
7
- import classNames from 'classnames';
8
-
9
- export default {
10
- name: 'PresetPanel',
11
- props: {
12
- /**
13
- * 样式前缀
14
- */
15
- prefixCls: PropTypes.string,
16
-
17
- /**
18
- * 预设列表
19
- * @type {Array<{label: string|VNode, value: Array|Function}>}
20
- */
21
- presets: PropTypes.array.def([]),
22
-
23
- /**
24
- * 选中的预设索引
25
- */
26
- selectedIndex: PropTypes.number.def(-1),
27
- },
28
-
29
- methods: {
30
- /**
31
- * 获取预设的实际值
32
- * @param {Object} preset - 预设项
33
- * @returns {Array} 日期范围值
34
- */
35
- getPresetValue(preset) {
36
- if (!preset) return null;
37
- const { value } = preset;
38
- return typeof value === 'function' ? value() : value;
39
- },
40
-
41
- /**
42
- * 点击预设项
43
- * @param {Object} preset - 预设项
44
- * @param {number} index - 索引
45
- */
46
- handleClick(preset, index) {
47
- const value = this.getPresetValue(preset);
48
- this.$emit('select', value, preset, index);
49
- },
50
-
51
- /**
52
- * 鼠标进入预设项
53
- * @param {Object} preset - 预设项
54
- * @param {number} index - 索引
55
- */
56
- handleMouseEnter(preset, index) {
57
- const value = this.getPresetValue(preset);
58
- this.$emit('hover', value, preset, index);
59
- },
60
-
61
- /**
62
- * 鼠标离开预设项
63
- */
64
- handleMouseLeave() {
65
- this.$emit('hover', null, null, -1);
66
- },
67
- },
68
-
69
- render() {
70
- const { prefixCls, presets, selectedIndex } = this;
71
-
72
- if (!presets || presets.length === 0) {
73
- return null;
74
- }
75
-
76
- const panelCls = `${prefixCls}-presets`;
77
-
78
- return (
79
- <div class={panelCls}>
80
- <ul class={`${panelCls}-list`}>
81
- {presets.map((preset, index) => {
82
- const itemCls = classNames(`${panelCls}-item`, {
83
- [`${panelCls}-item-selected`]: index === selectedIndex,
84
- });
85
-
86
- return (
87
- <li
88
- key={index}
89
- class={itemCls}
90
- onClick={() => this.handleClick(preset, index)}
91
- onMouseenter={() => this.handleMouseEnter(preset, index)}
92
- onMouseleave={this.handleMouseLeave}
93
- >
94
- {preset.label}
95
- </li>
96
- );
97
- })}
98
- </ul>
99
- </div>
100
- );
101
- },
102
- };
1
+ /**
2
+ * PresetPanel - 预设日期范围面板组件
3
+ * 用于显示快捷选择的预设日期范围
4
+ * 支持两种显示模式:panel(左侧面板)和 footer(底部按钮)
5
+ */
6
+
7
+ import PropTypes from '../_util/vue-types';
8
+ import classNames from 'classnames';
9
+
10
+ export default {
11
+ name: 'PresetPanel',
12
+ props: {
13
+ /**
14
+ * 样式前缀
15
+ */
16
+ prefixCls: PropTypes.string,
17
+
18
+ /**
19
+ * 预设列表
20
+ * @type {Array<{label: string|VNode, value: Array|Function}>}
21
+ */
22
+ presets: PropTypes.array.def([]),
23
+
24
+ /**
25
+ * 选中的预设索引
26
+ */
27
+ selectedIndex: PropTypes.number.def(-1),
28
+
29
+ /**
30
+ * 显示模式
31
+ * - panel: 左侧面板模式(垂直列表)
32
+ * - footer: 底部模式(水平按钮)
33
+ */
34
+ mode: PropTypes.oneOf(['panel', 'footer']).def('footer'),
35
+ },
36
+
37
+ methods: {
38
+ /**
39
+ * 获取预设的实际值
40
+ * @param {Object} preset - 预设项
41
+ * @returns {Array} 日期范围值
42
+ */
43
+ getPresetValue(preset) {
44
+ if (!preset) return null;
45
+ const { value } = preset;
46
+ return typeof value === 'function' ? value() : value;
47
+ },
48
+
49
+ /**
50
+ * 点击预设项
51
+ * @param {Object} preset - 预设项
52
+ * @param {number} index - 索引
53
+ */
54
+ handleClick(preset, index) {
55
+ const value = this.getPresetValue(preset);
56
+ this.$emit('select', value, preset, index);
57
+ },
58
+
59
+ /**
60
+ * 鼠标进入预设项
61
+ * @param {Object} preset - 预设项
62
+ * @param {number} index - 索引
63
+ */
64
+ handleMouseEnter(preset, index) {
65
+ const value = this.getPresetValue(preset);
66
+ this.$emit('hover', value, preset, index);
67
+ },
68
+
69
+ /**
70
+ * 鼠标离开预设项
71
+ */
72
+ handleMouseLeave() {
73
+ this.$emit('hover', null, null, -1);
74
+ },
75
+
76
+ /**
77
+ * 渲染底部按钮模式
78
+ */
79
+ renderFooterMode() {
80
+ const { prefixCls, presets, selectedIndex } = this;
81
+ const footerCls = `${prefixCls}-presets-footer`;
82
+
83
+ return (
84
+ <div class={footerCls}>
85
+ {presets.map((preset, index) => {
86
+ const btnCls = classNames(`${footerCls}-btn`, {
87
+ [`${footerCls}-btn-selected`]: index === selectedIndex,
88
+ });
89
+
90
+ return (
91
+ <span
92
+ key={index}
93
+ class={btnCls}
94
+ onClick={() => this.handleClick(preset, index)}
95
+ onMouseenter={() => this.handleMouseEnter(preset, index)}
96
+ onMouseleave={this.handleMouseLeave}
97
+ >
98
+ {preset.label}
99
+ </span>
100
+ );
101
+ })}
102
+ </div>
103
+ );
104
+ },
105
+
106
+ /**
107
+ * 渲染左侧面板模式
108
+ */
109
+ renderPanelMode() {
110
+ const { prefixCls, presets, selectedIndex } = this;
111
+ const panelCls = `${prefixCls}-presets`;
112
+
113
+ return (
114
+ <div class={panelCls}>
115
+ <ul class={`${panelCls}-list`}>
116
+ {presets.map((preset, index) => {
117
+ const itemCls = classNames(`${panelCls}-item`, {
118
+ [`${panelCls}-item-selected`]: index === selectedIndex,
119
+ });
120
+
121
+ return (
122
+ <li
123
+ key={index}
124
+ class={itemCls}
125
+ onClick={() => this.handleClick(preset, index)}
126
+ onMouseenter={() => this.handleMouseEnter(preset, index)}
127
+ onMouseleave={this.handleMouseLeave}
128
+ >
129
+ {preset.label}
130
+ </li>
131
+ );
132
+ })}
133
+ </ul>
134
+ </div>
135
+ );
136
+ },
137
+ },
138
+
139
+ render() {
140
+ const { presets, mode } = this;
141
+
142
+ if (!presets || presets.length === 0) {
143
+ return null;
144
+ }
145
+
146
+ return mode === 'footer' ? this.renderFooterMode() : this.renderPanelMode();
147
+ },
148
+ };
@@ -84,3 +84,18 @@
84
84
  cursor: pointer;
85
85
  }
86
86
  }
87
+
88
+ // 范围选择的起始/结束单元格样式
89
+ .@{calendar-prefix-cls}-month-panel-selected-start-cell,
90
+ .@{calendar-prefix-cls}-month-panel-selected-end-cell {
91
+ .@{calendar-prefix-cls}-month-panel-month {
92
+ color: @text-color-inverse;
93
+ background: @primary-color;
94
+ border-radius: @border-radius-sm;
95
+
96
+ &:hover {
97
+ color: @text-color-inverse;
98
+ background: @primary-5;
99
+ }
100
+ }
101
+ }