sard-uniapp 1.10.3 → 1.11.0
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/{changelog.md → CHANGELOG.md} +23 -0
- package/README.md +15 -9
- package/components/_template/_template.vue +1 -1
- package/components/accordion/accordion.vue +1 -1
- package/components/accordion-item/accordion-item.vue +1 -1
- package/components/action-sheet/action-sheet.vue +1 -1
- package/components/alert/alert.vue +1 -1
- package/components/avatar/avatar.vue +1 -1
- package/components/back-top/back-top.vue +1 -1
- package/components/badge/badge.vue +1 -1
- package/components/button/button.vue +1 -1
- package/components/calendar/calendar.vue +10 -7
- package/components/calendar-input/calendar-input.vue +4 -3
- package/components/calendar-month/calendar-month.vue +1 -1
- package/components/card/card.vue +1 -1
- package/components/cascader/cascader.vue +1 -1
- package/components/check-icon/check-icon.vue +1 -1
- package/components/checkbox/checkbox.vue +1 -1
- package/components/checkbox-group/checkbox-group.vue +1 -1
- package/components/checkbox-input/checkbox-input.vue +1 -1
- package/components/col/col.vue +1 -1
- package/components/collapse/collapse.vue +1 -1
- package/components/config/index.d.ts +6 -0
- package/components/config/index.js +6 -0
- package/components/datetime-picker/common.d.ts +2 -2
- package/components/datetime-picker/datetime-picker.vue +28 -19
- package/components/datetime-picker-input/datetime-picker-input.vue +7 -5
- package/components/datetime-range-picker/common.d.ts +15 -0
- package/components/datetime-range-picker/common.js +2 -0
- package/components/datetime-range-picker/datetime-range-picker.d.ts +18 -0
- package/components/datetime-range-picker/datetime-range-picker.vue +143 -0
- package/components/datetime-range-picker/index.d.ts +1 -0
- package/components/datetime-range-picker/index.js +1 -0
- package/components/datetime-range-picker/index.scss +26 -0
- package/components/datetime-range-picker/variables.scss +5 -0
- package/components/datetime-range-picker-input/common.d.ts +18 -0
- package/components/datetime-range-picker-input/common.js +5 -0
- package/components/datetime-range-picker-input/datetime-range-picker-input.d.ts +14 -0
- package/components/datetime-range-picker-input/datetime-range-picker-input.vue +193 -0
- package/components/datetime-range-picker-input/index.d.ts +1 -0
- package/components/datetime-range-picker-input/index.js +1 -0
- package/components/dialog/dialog.vue +1 -1
- package/components/dropdown/dropdown.vue +1 -1
- package/components/dropdown-item/dropdown-item.vue +1 -1
- package/components/empty/empty.vue +1 -1
- package/components/fab/fab.vue +1 -1
- package/components/floating-bubble/floating-bubble.vue +1 -1
- package/components/form/form.vue +1 -1
- package/components/form-item/form-item.vue +1 -1
- package/components/grid/grid.vue +1 -1
- package/components/grid-item/grid-item.vue +1 -1
- package/components/icon/icon.vue +1 -1
- package/components/indexes/indexes.vue +1 -1
- package/components/indexes-anchor/indexes-anchor.vue +1 -1
- package/components/indexes-nav/indexes-nav.vue +1 -1
- package/components/input/index.scss +1 -0
- package/components/input/input.vue +2 -1
- package/components/keyboard/keyboard.vue +1 -1
- package/components/list/list.vue +1 -1
- package/components/list-item/list-item.vue +1 -1
- package/components/load-more/load-more.vue +1 -1
- package/components/loading/loading.vue +1 -1
- package/components/locale/lang/en-US.d.ts +3 -0
- package/components/locale/lang/en-US.js +3 -0
- package/components/locale/lang/zh-CN.d.ts +3 -0
- package/components/locale/lang/zh-CN.js +3 -0
- package/components/marquee/marquee.vue +1 -1
- package/components/menu/menu.vue +1 -1
- package/components/menu-item/menu-item.vue +1 -1
- package/components/navbar/navbar.vue +1 -1
- package/components/navbar-item/navbar-item.vue +1 -1
- package/components/notice-bar/notice-bar.vue +1 -1
- package/components/notify/notify.vue +1 -1
- package/components/overlay/overlay.vue +1 -1
- package/components/pagination/pagination.vue +1 -1
- package/components/password-input/password-input.vue +1 -1
- package/components/picker/picker.vue +12 -6
- package/components/popout/popout.vue +16 -15
- package/components/popout-input/popout-input.vue +1 -1
- package/components/popover/popover.vue +1 -1
- package/components/popup/popup.vue +1 -1
- package/components/progress-bar/progress-bar.vue +1 -1
- package/components/progress-circle/progress-circle.vue +1 -1
- package/components/pull-down-refresh/pull-down-refresh.vue +1 -1
- package/components/qrcode/qrcode.vue +2 -2
- package/components/radio/radio.vue +1 -1
- package/components/radio-group/radio-group.vue +1 -1
- package/components/radio-input/radio-input.vue +1 -1
- package/components/rate/rate.vue +1 -1
- package/components/result/result.vue +1 -1
- package/components/row/row.vue +1 -1
- package/components/search/search.vue +1 -1
- package/components/share-sheet/share-sheet.vue +1 -1
- package/components/skeleton/skeleton.vue +1 -1
- package/components/skeleton-avatar/skeleton-avatar.vue +1 -1
- package/components/skeleton-block/skeleton-block.vue +1 -1
- package/components/skeleton-paragraph/skeleton-paragraph.vue +1 -1
- package/components/skeleton-title/skeleton-title.vue +1 -1
- package/components/slider/slider.vue +1 -1
- package/components/space/space.vue +1 -1
- package/components/stepper/stepper.vue +1 -1
- package/components/steps/steps.vue +1 -1
- package/components/swiper-dot/swiper-dot.vue +1 -1
- package/components/switch/switch.vue +1 -1
- package/components/tab/tab.vue +1 -1
- package/components/tabbar/tabbar.vue +1 -1
- package/components/tabbar-item/tabbar-item.vue +1 -1
- package/components/table/table.vue +1 -1
- package/components/table-cell/table-cell.vue +1 -1
- package/components/table-fixation/table-fixation.vue +1 -1
- package/components/table-row/table-row.vue +1 -1
- package/components/tabs/tabs.vue +1 -1
- package/components/tag/tag.vue +1 -1
- package/components/timeline/timeline.vue +1 -1
- package/components/timeline-item/timeline-item.vue +1 -1
- package/components/toast/toast.vue +1 -1
- package/components/tree/tree.vue +1 -1
- package/components/tree/utils.d.ts +1 -1
- package/components/tree-node/tree-node.vue +1 -1
- package/components/upload/upload.vue +1 -1
- package/components/upload-preview/upload-preview.vue +1 -1
- package/global.d.ts +2 -0
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/index.scss +1 -0
- package/package.json +28 -26
- package/utils/date.d.ts +1 -0
- package/utils/date.js +7 -0
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/utils/object.d.ts +4 -0
- package/utils/object.js +13 -0
|
@@ -1,3 +1,26 @@
|
|
|
1
|
+
# [1.11.0](https://github.com/sutras/sard-uniapp/compare/v1.10.4...v1.11.0) (2025-03-04)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **datetime-picker:** 修改min, max属性后更新列数据 ([f58fef5](https://github.com/sutras/sard-uniapp/commit/f58fef592dd1102032aa999c5dbf887b8e25189d))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* 新增 DatetimeRangePicker 和 DatetimeRangePickerInput 组件 ([7cf3eeb](https://github.com/sutras/sard-uniapp/commit/7cf3eebbd8ce5f1aa185a4a55425607ba8a4bbdc))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## [1.10.4](https://github.com/sutras/sard-uniapp/compare/v1.10.3...v1.10.4) (2025-02-19)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* 使用 [@import](https://github.com/import) 导入scss, 兼容mp-alipay ([1830610](https://github.com/sutras/sard-uniapp/commit/1830610e17b29fd5f7e362d5c04a0ebcbb1ac772))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
1
24
|
## [1.10.3](https://github.com/sutras/sard-uniapp/compare/v1.10.1...v1.10.3) (2025-02-19)
|
|
2
25
|
|
|
3
26
|
|
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
|
|
26
26
|
## 特性
|
|
27
27
|
|
|
28
|
-
- 🧩
|
|
28
|
+
- 🧩 76+个高质量组件,覆盖移动端主流场景
|
|
29
29
|
- 💪 支持一套代码同时开发 H5 / 小程序 / App
|
|
30
30
|
- 🌿 支持按需引入和 `Tree Shaking`
|
|
31
31
|
- 📖 详尽的文档和案例展示
|
|
@@ -40,6 +40,10 @@
|
|
|
40
40
|
|
|
41
41
|
本项目基于 [MIT](https://zh.wikipedia.org/wiki/MIT%E8%A8%B1%E5%8F%AF%E8%AD%89) 协议,请自由地享受和参与开源。
|
|
42
42
|
|
|
43
|
+
## 更新日志
|
|
44
|
+
|
|
45
|
+
<a href="https://github.com/sutras/sard-uniapp/blob/main/CHANGELOG.md">更新日志</a>
|
|
46
|
+
|
|
43
47
|
## 如何维护
|
|
44
48
|
|
|
45
49
|
### 克隆仓库到本地
|
|
@@ -110,14 +114,16 @@ npm run release
|
|
|
110
114
|
- 修复问题
|
|
111
115
|
- 测试
|
|
112
116
|
- 修改版本号
|
|
113
|
-
-
|
|
114
|
-
-
|
|
115
|
-
-
|
|
116
|
-
-
|
|
117
|
+
- 暂存、提交 `git commit -a -m 'fix: '`
|
|
118
|
+
- 给提交打标签 `npm run tag`
|
|
119
|
+
- 生成 changelog `npm run changelog`
|
|
120
|
+
- 暂存、提交 changelog `git commit -a -m 'chore: changelog'`
|
|
121
|
+
- 打包组件库 `npm run build`
|
|
122
|
+
- 发布到 npm `npm run release`
|
|
117
123
|
- 使用 HBuilderX 发布到 uniapp 插件市场
|
|
118
|
-
-
|
|
119
|
-
-
|
|
120
|
-
-
|
|
124
|
+
- 推送代码和标签 `npm run push`
|
|
125
|
+
- 打包文档(如果文档有修改)`npm run build:site`
|
|
126
|
+
- 部署文档(如果文档有修改)`npm run deploy`
|
|
121
127
|
- 更新 gitee 上的文档(如果文档有修改)
|
|
122
128
|
|
|
123
129
|
## 新增组件流程
|
|
@@ -128,7 +134,7 @@ npm run release
|
|
|
128
134
|
- 编写组件文档
|
|
129
135
|
- 编写测试用例
|
|
130
136
|
- 使用实际项目本地安装测试 `pnpm link ../sard-uniapp`
|
|
131
|
-
-
|
|
137
|
+
- 从上面的“修复问题流程”第三个步骤“修改版本号”开始走一遍
|
|
132
138
|
|
|
133
139
|
## 打包安卓包流程
|
|
134
140
|
|
|
@@ -67,12 +67,15 @@
|
|
|
67
67
|
type="compact"
|
|
68
68
|
@confirm="onPickerConfirm"
|
|
69
69
|
>
|
|
70
|
-
<
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
70
|
+
<template #visible="{ already }">
|
|
71
|
+
<sar-datetime-picker
|
|
72
|
+
v-if="already"
|
|
73
|
+
type="yM"
|
|
74
|
+
v-model="pickerValue"
|
|
75
|
+
:min="minDate"
|
|
76
|
+
:max="maxDate"
|
|
77
|
+
/>
|
|
78
|
+
</template>
|
|
76
79
|
</sar-popout>
|
|
77
80
|
</template>
|
|
78
81
|
|
|
@@ -337,5 +340,5 @@ export default _defineComponent({
|
|
|
337
340
|
</script>
|
|
338
341
|
|
|
339
342
|
<style lang="scss">
|
|
340
|
-
@
|
|
343
|
+
@import './index.scss';
|
|
341
344
|
</style>
|
|
@@ -146,9 +146,10 @@ export default _defineComponent({
|
|
|
146
146
|
return getOutletTextMayByStr(date);
|
|
147
147
|
}
|
|
148
148
|
if (type === "range") {
|
|
149
|
-
return
|
|
150
|
-
|
|
151
|
-
|
|
149
|
+
return [
|
|
150
|
+
getOutletTextMayByStr(date[0]),
|
|
151
|
+
getOutletTextMayByStr(date[1])
|
|
152
|
+
].join(` ${t("to")} `);
|
|
152
153
|
}
|
|
153
154
|
if (type === "multiple") {
|
|
154
155
|
return t("multipleOutlet", {
|
package/components/card/card.vue
CHANGED
package/components/col/col.vue
CHANGED
|
@@ -104,6 +104,12 @@ export declare const defaultConfig: {
|
|
|
104
104
|
datetimePickerInput: {
|
|
105
105
|
validateEvent: boolean;
|
|
106
106
|
};
|
|
107
|
+
datetimeRangePicker: {
|
|
108
|
+
type: string;
|
|
109
|
+
};
|
|
110
|
+
datetimeRangePickerInput: {
|
|
111
|
+
validateEvent: boolean;
|
|
112
|
+
};
|
|
107
113
|
dialog: {
|
|
108
114
|
headed: boolean;
|
|
109
115
|
buttonType: DialogProps["buttonType"];
|
|
@@ -3,8 +3,8 @@ export interface DatetimePickerProps {
|
|
|
3
3
|
rootStyle?: StyleValue;
|
|
4
4
|
rootClass?: string;
|
|
5
5
|
type?: string;
|
|
6
|
-
min?: Date;
|
|
7
|
-
max?: Date;
|
|
6
|
+
min?: Date | string;
|
|
7
|
+
max?: Date | string;
|
|
8
8
|
modelValue?: Date | string;
|
|
9
9
|
filter?: (letter: DatetimeLetter, value: number, date: Date, index: number) => boolean;
|
|
10
10
|
formatter?: (letter: DatetimeLetter, option: DatetimeColumnOption, date: Date, index: number) => string | void | undefined;
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
<script>
|
|
12
12
|
import { mergeDefaults as _mergeDefaults, defineComponent as _defineComponent } from "vue";
|
|
13
13
|
import { computed, ref, watch } from "vue";
|
|
14
|
-
import { classNames, formatDate,
|
|
14
|
+
import { classNames, formatDate, stringifyStyle, toDate } from "../../utils";
|
|
15
15
|
import SarPicker from "../picker/picker.vue";
|
|
16
16
|
import {
|
|
17
17
|
correctDate,
|
|
@@ -39,8 +39,8 @@ export default _defineComponent({
|
|
|
39
39
|
rootStyle: { type: [Boolean, null, String, Object, Array], required: false, skipCheck: true },
|
|
40
40
|
rootClass: { type: String, required: false },
|
|
41
41
|
type: { type: String, required: false },
|
|
42
|
-
min: { type: Date, required: false },
|
|
43
|
-
max: { type: Date, required: false },
|
|
42
|
+
min: { type: [Date, String], required: false },
|
|
43
|
+
max: { type: [Date, String], required: false },
|
|
44
44
|
modelValue: { type: [Date, String], required: false },
|
|
45
45
|
filter: { type: Function, required: false },
|
|
46
46
|
formatter: { type: Function, required: false },
|
|
@@ -110,22 +110,18 @@ export default _defineComponent({
|
|
|
110
110
|
const date = new Date(...currEvery);
|
|
111
111
|
return date;
|
|
112
112
|
};
|
|
113
|
-
const toDate = (date) => {
|
|
114
|
-
if (date instanceof Date) {
|
|
115
|
-
return date;
|
|
116
|
-
}
|
|
117
|
-
return parseDate(date, props.valueFormat);
|
|
118
|
-
};
|
|
119
113
|
const normalizeValue = (value) => {
|
|
120
|
-
const date = value ? toDate(value) : new Date();
|
|
121
|
-
return date
|
|
114
|
+
const date = value ? toDate(value, props.valueFormat) : new Date();
|
|
115
|
+
return date < minDate.value ? new Date(minDate.value) : date > maxDate.value ? new Date(maxDate.value) : date;
|
|
122
116
|
};
|
|
123
117
|
const innerType = computed(() => {
|
|
124
118
|
return props.type.split("");
|
|
125
119
|
});
|
|
126
|
-
const minDate = computed(
|
|
120
|
+
const minDate = computed(
|
|
121
|
+
() => toDate(props.min || getMinDate(), props.valueFormat)
|
|
122
|
+
);
|
|
127
123
|
const maxDate = computed(() => {
|
|
128
|
-
const maxDate2 = props.max || getMaxDate();
|
|
124
|
+
const maxDate2 = toDate(props.max || getMaxDate());
|
|
129
125
|
return maxDate2 < minDate.value ? new Date(minDate.value) : maxDate2;
|
|
130
126
|
});
|
|
131
127
|
const innerValue = ref(normalizeValue(props.modelValue));
|
|
@@ -141,6 +137,21 @@ export default _defineComponent({
|
|
|
141
137
|
}
|
|
142
138
|
}
|
|
143
139
|
);
|
|
140
|
+
const emitChange = () => {
|
|
141
|
+
const emitValue = props.valueFormat ? formatDate(innerValue.value, props.valueFormat) : innerValue.value;
|
|
142
|
+
currentEmitValue = emitValue;
|
|
143
|
+
emit("update:model-value", emitValue);
|
|
144
|
+
emit("change", emitValue);
|
|
145
|
+
};
|
|
146
|
+
watch([minDate, maxDate], () => {
|
|
147
|
+
const oldDate = toDate(innerValue.value, props.valueFormat);
|
|
148
|
+
const value = normalizeValue(innerValue.value);
|
|
149
|
+
innerValue.value = value;
|
|
150
|
+
updateColumns(value);
|
|
151
|
+
if (value.getTime() !== oldDate.getTime()) {
|
|
152
|
+
emitChange();
|
|
153
|
+
}
|
|
154
|
+
});
|
|
144
155
|
const pickerValue = computed(() => {
|
|
145
156
|
return innerType.value.map((letter) => {
|
|
146
157
|
return strategies[letter][4](innerValue.value);
|
|
@@ -151,19 +162,17 @@ export default _defineComponent({
|
|
|
151
162
|
let maxValues = [];
|
|
152
163
|
const columns = ref(createColumnData(innerType.value, innerValue.value));
|
|
153
164
|
const onChange = (value) => {
|
|
165
|
+
value = value.map((item) => item || 0);
|
|
154
166
|
const nextValue = getDateByPickerValue(value);
|
|
155
167
|
innerValue.value = nextValue;
|
|
156
|
-
const emitValue = props.valueFormat ? formatDate(nextValue, props.valueFormat) : nextValue;
|
|
157
|
-
currentEmitValue = emitValue;
|
|
158
168
|
updateColumns(nextValue);
|
|
159
|
-
|
|
160
|
-
emit("change", emitValue);
|
|
169
|
+
emitChange();
|
|
161
170
|
};
|
|
162
|
-
const __returned__ = { props, emit, t, createColumnData, getChangedLetter, updateColumns, getDateByPickerValue,
|
|
171
|
+
const __returned__ = { props, emit, t, createColumnData, getChangedLetter, updateColumns, getDateByPickerValue, normalizeValue, innerType, minDate, maxDate, innerValue, get currentEmitValue() {
|
|
163
172
|
return currentEmitValue;
|
|
164
173
|
}, set currentEmitValue(v) {
|
|
165
174
|
currentEmitValue = v;
|
|
166
|
-
}, pickerValue, columnsMap, get minValues() {
|
|
175
|
+
}, emitChange, pickerValue, columnsMap, get minValues() {
|
|
167
176
|
return minValues;
|
|
168
177
|
}, set minValues(v) {
|
|
169
178
|
minValues = v;
|
|
@@ -40,7 +40,7 @@ import { ref, watch, computed } from "vue";
|
|
|
40
40
|
import SarPopoutInput from "../popout-input/popout-input.vue";
|
|
41
41
|
import SarPopout from "../popout/popout.vue";
|
|
42
42
|
import SarDatetimePicker from "../datetime-picker/datetime-picker.vue";
|
|
43
|
-
import { formatDate, isNullish, isString, parseDate } from "../../utils";
|
|
43
|
+
import { formatDate, isNullish, isString, parseDate, toDate } from "../../utils";
|
|
44
44
|
import {
|
|
45
45
|
getInitialValue,
|
|
46
46
|
getMinDate,
|
|
@@ -73,8 +73,8 @@ export default _defineComponent({
|
|
|
73
73
|
rootStyle: { type: [Boolean, null, String, Object, Array], required: false, skipCheck: true },
|
|
74
74
|
rootClass: { type: String, required: false },
|
|
75
75
|
type: { type: String, required: false },
|
|
76
|
-
min: { type: Date, required: false },
|
|
77
|
-
max: { type: Date, required: false },
|
|
76
|
+
min: { type: [Date, String], required: false },
|
|
77
|
+
max: { type: [Date, String], required: false },
|
|
78
78
|
modelValue: { type: [Date, String], required: false },
|
|
79
79
|
filter: { type: Function, required: false },
|
|
80
80
|
formatter: { type: Function, required: false },
|
|
@@ -109,9 +109,11 @@ export default _defineComponent({
|
|
|
109
109
|
popoutValue.value = innerValue.value;
|
|
110
110
|
}
|
|
111
111
|
};
|
|
112
|
-
const minDate = computed(
|
|
112
|
+
const minDate = computed(
|
|
113
|
+
() => toDate(props.min || getMinDate(), props.valueFormat)
|
|
114
|
+
);
|
|
113
115
|
const maxDate = computed(() => {
|
|
114
|
-
const maxDate2 = props.max || getMaxDate();
|
|
116
|
+
const maxDate2 = toDate(props.max || getMaxDate());
|
|
115
117
|
return maxDate2 < minDate.value ? new Date(minDate.value) : maxDate2;
|
|
116
118
|
});
|
|
117
119
|
const onConfirm = () => {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type DatetimePickerProps } from '../datetime-picker/common';
|
|
2
|
+
export interface DatetimeRangePickerProps extends Omit<DatetimePickerProps, 'modelValue'> {
|
|
3
|
+
modelValue?: (Date | string)[];
|
|
4
|
+
tabs?: string[];
|
|
5
|
+
}
|
|
6
|
+
export declare const defaultDatetimeRangePickerProps: {
|
|
7
|
+
type: string;
|
|
8
|
+
};
|
|
9
|
+
export interface DatetimeRangePickerSlots {
|
|
10
|
+
default?(props: Record<string, never>): any;
|
|
11
|
+
}
|
|
12
|
+
export interface DatetimeRangePickerEmits {
|
|
13
|
+
(e: 'update:model-value', date: (Date | string)[]): void;
|
|
14
|
+
(e: 'change', date: (Date | string)[]): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type DatetimeRangePickerProps, type DatetimeRangePickerSlots } from './common';
|
|
2
|
+
declare function __VLS_template(): Readonly<DatetimeRangePickerSlots> & DatetimeRangePickerSlots;
|
|
3
|
+
declare const __VLS_component: import("vue").DefineComponent<DatetimeRangePickerProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
4
|
+
"update:model-value": (date: (string | Date)[]) => any;
|
|
5
|
+
change: (date: (string | Date)[]) => any;
|
|
6
|
+
}, string, import("vue").PublicProps, Readonly<DatetimeRangePickerProps> & Readonly<{
|
|
7
|
+
"onUpdate:model-value"?: ((date: (string | Date)[]) => any) | undefined;
|
|
8
|
+
onChange?: ((date: (string | Date)[]) => any) | undefined;
|
|
9
|
+
}>, {
|
|
10
|
+
type: string;
|
|
11
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
12
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
|
|
13
|
+
export default _default;
|
|
14
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
15
|
+
new (): {
|
|
16
|
+
$slots: S;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view :class="datetimeRangePickerClass" :style="datetimeRangePickerStyle">
|
|
3
|
+
<sar-tabs v-model:current="tabsCurrent" :list="tabsList" scrollable />
|
|
4
|
+
|
|
5
|
+
<view :class="bem.e('container')">
|
|
6
|
+
<view
|
|
7
|
+
:class="bem.e('wrapper')"
|
|
8
|
+
:style="
|
|
9
|
+
stringifyStyle({
|
|
10
|
+
transform: `translateX(${-Number(tabsCurrent) * 100}%)`,
|
|
11
|
+
})
|
|
12
|
+
"
|
|
13
|
+
>
|
|
14
|
+
<view :class="bem.e('pane')">
|
|
15
|
+
<sar-datetime-picker
|
|
16
|
+
v-bind="datetimePickerProps"
|
|
17
|
+
v-model="startValue"
|
|
18
|
+
@change="onChange"
|
|
19
|
+
/>
|
|
20
|
+
</view>
|
|
21
|
+
<view :class="bem.e('pane')">
|
|
22
|
+
<sar-datetime-picker
|
|
23
|
+
v-bind="datetimePickerProps"
|
|
24
|
+
v-model="endValue"
|
|
25
|
+
:min="startValue"
|
|
26
|
+
@change="onChange"
|
|
27
|
+
/>
|
|
28
|
+
</view>
|
|
29
|
+
</view>
|
|
30
|
+
</view>
|
|
31
|
+
</view>
|
|
32
|
+
</template>
|
|
33
|
+
|
|
34
|
+
<script>
|
|
35
|
+
import { mergeDefaults as _mergeDefaults, defineComponent as _defineComponent } from "vue";
|
|
36
|
+
import { computed, watch } from "vue";
|
|
37
|
+
import {
|
|
38
|
+
classNames,
|
|
39
|
+
stringifyStyle,
|
|
40
|
+
createBem,
|
|
41
|
+
omit,
|
|
42
|
+
toDate
|
|
43
|
+
} from "../../utils";
|
|
44
|
+
import SarDatetimePicker from "../datetime-picker/datetime-picker.vue";
|
|
45
|
+
import {
|
|
46
|
+
defaultDatetimeRangePickerProps
|
|
47
|
+
} from "./common";
|
|
48
|
+
import { ref } from "vue";
|
|
49
|
+
import {
|
|
50
|
+
getInitialValue,
|
|
51
|
+
getMaxDate,
|
|
52
|
+
getMinDate
|
|
53
|
+
} from "../datetime-picker/common";
|
|
54
|
+
export default _defineComponent({
|
|
55
|
+
components: {
|
|
56
|
+
SarDatetimePicker,
|
|
57
|
+
},
|
|
58
|
+
...{
|
|
59
|
+
options: {
|
|
60
|
+
virtualHost: true,
|
|
61
|
+
styleIsolation: "shared"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
__name: "datetime-range-picker",
|
|
65
|
+
props: _mergeDefaults({
|
|
66
|
+
modelValue: { type: Array, required: false },
|
|
67
|
+
tabs: { type: Array, required: false },
|
|
68
|
+
rootStyle: { type: [Boolean, null, String, Object, Array], required: false, skipCheck: true },
|
|
69
|
+
rootClass: { type: String, required: false },
|
|
70
|
+
type: { type: String, required: false },
|
|
71
|
+
min: { type: [Date, String], required: false },
|
|
72
|
+
max: { type: [Date, String], required: false },
|
|
73
|
+
filter: { type: Function, required: false },
|
|
74
|
+
formatter: { type: Function, required: false },
|
|
75
|
+
valueFormat: { type: String, required: false }
|
|
76
|
+
}, defaultDatetimeRangePickerProps),
|
|
77
|
+
emits: ["update:model-value", "change"],
|
|
78
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
79
|
+
__expose();
|
|
80
|
+
const props = __props;
|
|
81
|
+
const emit = __emit;
|
|
82
|
+
const bem = createBem("datetime-range-picker");
|
|
83
|
+
const datetimePickerProps = computed(() => {
|
|
84
|
+
return omit(props, ["modelValue"]);
|
|
85
|
+
});
|
|
86
|
+
const tabsList = computed(() => {
|
|
87
|
+
return [
|
|
88
|
+
{
|
|
89
|
+
title: props.tabs?.[0]
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
title: props.tabs?.[1]
|
|
93
|
+
}
|
|
94
|
+
];
|
|
95
|
+
});
|
|
96
|
+
const tabsCurrent = ref(0);
|
|
97
|
+
const minDate = computed(
|
|
98
|
+
() => toDate(props.min || getMinDate(), props.valueFormat)
|
|
99
|
+
);
|
|
100
|
+
const maxDate = computed(() => {
|
|
101
|
+
const maxDate2 = toDate(props.max || getMaxDate(), props.valueFormat);
|
|
102
|
+
return maxDate2 < minDate.value ? new Date(minDate.value) : maxDate2;
|
|
103
|
+
});
|
|
104
|
+
const startValue = ref();
|
|
105
|
+
const endValue = ref();
|
|
106
|
+
const parseValue = (value) => {
|
|
107
|
+
const [start, end] = value || [];
|
|
108
|
+
startValue.value = start || getInitialValue(minDate.value, maxDate.value);
|
|
109
|
+
endValue.value = end || getInitialValue(toDate(startValue.value, props.valueFormat), maxDate.value);
|
|
110
|
+
};
|
|
111
|
+
watch(
|
|
112
|
+
() => props.modelValue,
|
|
113
|
+
(value) => {
|
|
114
|
+
parseValue(value);
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
immediate: true
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
const onChange = () => {
|
|
121
|
+
if (startValue.value && endValue.value) {
|
|
122
|
+
const emitValue = [startValue.value, endValue.value];
|
|
123
|
+
emit("update:model-value", emitValue);
|
|
124
|
+
emit("change", emitValue);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
const datetimeRangePickerClass = computed(() => {
|
|
128
|
+
return classNames(bem.b(), props.rootClass);
|
|
129
|
+
});
|
|
130
|
+
const datetimeRangePickerStyle = computed(() => {
|
|
131
|
+
return stringifyStyle(props.rootStyle);
|
|
132
|
+
});
|
|
133
|
+
const __returned__ = { props, emit, bem, datetimePickerProps, tabsList, tabsCurrent, minDate, maxDate, startValue, endValue, parseValue, onChange, datetimeRangePickerClass, datetimeRangePickerStyle, get stringifyStyle() {
|
|
134
|
+
return stringifyStyle;
|
|
135
|
+
}, SarDatetimePicker };
|
|
136
|
+
return __returned__;
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
</script>
|
|
140
|
+
|
|
141
|
+
<style lang="scss">
|
|
142
|
+
@import './index.scss';
|
|
143
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { DatetimeRangePickerProps, DatetimeRangePickerSlots, DatetimeRangePickerEmits, } from './common';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
@use '../style/base' as *;
|
|
2
|
+
|
|
3
|
+
@include bem(datetime-range-picker) {
|
|
4
|
+
@include b() {
|
|
5
|
+
@include universal;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
@include e(container) {
|
|
9
|
+
@include universal;
|
|
10
|
+
overflow: hidden;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@include e(wrapper) {
|
|
14
|
+
@include universal;
|
|
15
|
+
width: 100%;
|
|
16
|
+
flex-direction: row;
|
|
17
|
+
flex-wrap: nowrap;
|
|
18
|
+
transition: transform var(--sar-cascader-wrapper-duration);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@include e(pane) {
|
|
22
|
+
@include universal;
|
|
23
|
+
width: 100%;
|
|
24
|
+
flex: none;
|
|
25
|
+
}
|
|
26
|
+
}
|