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.
Files changed (132) hide show
  1. package/{changelog.md → CHANGELOG.md} +23 -0
  2. package/README.md +15 -9
  3. package/components/_template/_template.vue +1 -1
  4. package/components/accordion/accordion.vue +1 -1
  5. package/components/accordion-item/accordion-item.vue +1 -1
  6. package/components/action-sheet/action-sheet.vue +1 -1
  7. package/components/alert/alert.vue +1 -1
  8. package/components/avatar/avatar.vue +1 -1
  9. package/components/back-top/back-top.vue +1 -1
  10. package/components/badge/badge.vue +1 -1
  11. package/components/button/button.vue +1 -1
  12. package/components/calendar/calendar.vue +10 -7
  13. package/components/calendar-input/calendar-input.vue +4 -3
  14. package/components/calendar-month/calendar-month.vue +1 -1
  15. package/components/card/card.vue +1 -1
  16. package/components/cascader/cascader.vue +1 -1
  17. package/components/check-icon/check-icon.vue +1 -1
  18. package/components/checkbox/checkbox.vue +1 -1
  19. package/components/checkbox-group/checkbox-group.vue +1 -1
  20. package/components/checkbox-input/checkbox-input.vue +1 -1
  21. package/components/col/col.vue +1 -1
  22. package/components/collapse/collapse.vue +1 -1
  23. package/components/config/index.d.ts +6 -0
  24. package/components/config/index.js +6 -0
  25. package/components/datetime-picker/common.d.ts +2 -2
  26. package/components/datetime-picker/datetime-picker.vue +28 -19
  27. package/components/datetime-picker-input/datetime-picker-input.vue +7 -5
  28. package/components/datetime-range-picker/common.d.ts +15 -0
  29. package/components/datetime-range-picker/common.js +2 -0
  30. package/components/datetime-range-picker/datetime-range-picker.d.ts +18 -0
  31. package/components/datetime-range-picker/datetime-range-picker.vue +143 -0
  32. package/components/datetime-range-picker/index.d.ts +1 -0
  33. package/components/datetime-range-picker/index.js +1 -0
  34. package/components/datetime-range-picker/index.scss +26 -0
  35. package/components/datetime-range-picker/variables.scss +5 -0
  36. package/components/datetime-range-picker-input/common.d.ts +18 -0
  37. package/components/datetime-range-picker-input/common.js +5 -0
  38. package/components/datetime-range-picker-input/datetime-range-picker-input.d.ts +14 -0
  39. package/components/datetime-range-picker-input/datetime-range-picker-input.vue +193 -0
  40. package/components/datetime-range-picker-input/index.d.ts +1 -0
  41. package/components/datetime-range-picker-input/index.js +1 -0
  42. package/components/dialog/dialog.vue +1 -1
  43. package/components/dropdown/dropdown.vue +1 -1
  44. package/components/dropdown-item/dropdown-item.vue +1 -1
  45. package/components/empty/empty.vue +1 -1
  46. package/components/fab/fab.vue +1 -1
  47. package/components/floating-bubble/floating-bubble.vue +1 -1
  48. package/components/form/form.vue +1 -1
  49. package/components/form-item/form-item.vue +1 -1
  50. package/components/grid/grid.vue +1 -1
  51. package/components/grid-item/grid-item.vue +1 -1
  52. package/components/icon/icon.vue +1 -1
  53. package/components/indexes/indexes.vue +1 -1
  54. package/components/indexes-anchor/indexes-anchor.vue +1 -1
  55. package/components/indexes-nav/indexes-nav.vue +1 -1
  56. package/components/input/index.scss +1 -0
  57. package/components/input/input.vue +2 -1
  58. package/components/keyboard/keyboard.vue +1 -1
  59. package/components/list/list.vue +1 -1
  60. package/components/list-item/list-item.vue +1 -1
  61. package/components/load-more/load-more.vue +1 -1
  62. package/components/loading/loading.vue +1 -1
  63. package/components/locale/lang/en-US.d.ts +3 -0
  64. package/components/locale/lang/en-US.js +3 -0
  65. package/components/locale/lang/zh-CN.d.ts +3 -0
  66. package/components/locale/lang/zh-CN.js +3 -0
  67. package/components/marquee/marquee.vue +1 -1
  68. package/components/menu/menu.vue +1 -1
  69. package/components/menu-item/menu-item.vue +1 -1
  70. package/components/navbar/navbar.vue +1 -1
  71. package/components/navbar-item/navbar-item.vue +1 -1
  72. package/components/notice-bar/notice-bar.vue +1 -1
  73. package/components/notify/notify.vue +1 -1
  74. package/components/overlay/overlay.vue +1 -1
  75. package/components/pagination/pagination.vue +1 -1
  76. package/components/password-input/password-input.vue +1 -1
  77. package/components/picker/picker.vue +12 -6
  78. package/components/popout/popout.vue +16 -15
  79. package/components/popout-input/popout-input.vue +1 -1
  80. package/components/popover/popover.vue +1 -1
  81. package/components/popup/popup.vue +1 -1
  82. package/components/progress-bar/progress-bar.vue +1 -1
  83. package/components/progress-circle/progress-circle.vue +1 -1
  84. package/components/pull-down-refresh/pull-down-refresh.vue +1 -1
  85. package/components/qrcode/qrcode.vue +2 -2
  86. package/components/radio/radio.vue +1 -1
  87. package/components/radio-group/radio-group.vue +1 -1
  88. package/components/radio-input/radio-input.vue +1 -1
  89. package/components/rate/rate.vue +1 -1
  90. package/components/result/result.vue +1 -1
  91. package/components/row/row.vue +1 -1
  92. package/components/search/search.vue +1 -1
  93. package/components/share-sheet/share-sheet.vue +1 -1
  94. package/components/skeleton/skeleton.vue +1 -1
  95. package/components/skeleton-avatar/skeleton-avatar.vue +1 -1
  96. package/components/skeleton-block/skeleton-block.vue +1 -1
  97. package/components/skeleton-paragraph/skeleton-paragraph.vue +1 -1
  98. package/components/skeleton-title/skeleton-title.vue +1 -1
  99. package/components/slider/slider.vue +1 -1
  100. package/components/space/space.vue +1 -1
  101. package/components/stepper/stepper.vue +1 -1
  102. package/components/steps/steps.vue +1 -1
  103. package/components/swiper-dot/swiper-dot.vue +1 -1
  104. package/components/switch/switch.vue +1 -1
  105. package/components/tab/tab.vue +1 -1
  106. package/components/tabbar/tabbar.vue +1 -1
  107. package/components/tabbar-item/tabbar-item.vue +1 -1
  108. package/components/table/table.vue +1 -1
  109. package/components/table-cell/table-cell.vue +1 -1
  110. package/components/table-fixation/table-fixation.vue +1 -1
  111. package/components/table-row/table-row.vue +1 -1
  112. package/components/tabs/tabs.vue +1 -1
  113. package/components/tag/tag.vue +1 -1
  114. package/components/timeline/timeline.vue +1 -1
  115. package/components/timeline-item/timeline-item.vue +1 -1
  116. package/components/toast/toast.vue +1 -1
  117. package/components/tree/tree.vue +1 -1
  118. package/components/tree/utils.d.ts +1 -1
  119. package/components/tree-node/tree-node.vue +1 -1
  120. package/components/upload/upload.vue +1 -1
  121. package/components/upload-preview/upload-preview.vue +1 -1
  122. package/global.d.ts +2 -0
  123. package/index.d.ts +2 -0
  124. package/index.js +2 -0
  125. package/index.scss +1 -0
  126. package/package.json +28 -26
  127. package/utils/date.d.ts +1 -0
  128. package/utils/date.js +7 -0
  129. package/utils/index.d.ts +1 -0
  130. package/utils/index.js +1 -0
  131. package/utils/object.d.ts +4 -0
  132. 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
- - 🧩 74+个高质量组件,覆盖移动端主流场景
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
- - 运行 `npm run buildAndRelease` 打包组件库并发布到 npm
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
- - 运行 `npm run push` 推送代码和标签
119
- - 运行 `npm run build:site` 打包文档(如果文档有修改)
120
- - 运行 `npm run deploy` 部署文档(如果文档有修改)
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
 
@@ -41,5 +41,5 @@ export default _defineComponent({
41
41
  </script>
42
42
 
43
43
  <style lang="scss">
44
- @use './index.scss';
44
+ @import './index.scss';
45
45
  </style>
@@ -78,5 +78,5 @@ export default _defineComponent({
78
78
  </script>
79
79
 
80
80
  <style lang="scss">
81
- @use './index.scss';
81
+ @import './index.scss';
82
82
  </style>
@@ -83,5 +83,5 @@ export default _defineComponent({
83
83
  </script>
84
84
 
85
85
  <style lang="scss">
86
- @use './index.scss';
86
+ @import './index.scss';
87
87
  </style>
@@ -143,5 +143,5 @@ export default _defineComponent({
143
143
  </script>
144
144
 
145
145
  <style lang="scss">
146
- @use './index.scss';
146
+ @import './index.scss';
147
147
  </style>
@@ -73,5 +73,5 @@ export default _defineComponent({
73
73
  </script>
74
74
 
75
75
  <style lang="scss">
76
- @use './index.scss';
76
+ @import './index.scss';
77
77
  </style>
@@ -71,5 +71,5 @@ export default _defineComponent({
71
71
  </script>
72
72
 
73
73
  <style lang="scss">
74
- @use './index.scss';
74
+ @import './index.scss';
75
75
  </style>
@@ -61,5 +61,5 @@ export default _defineComponent({
61
61
  </script>
62
62
 
63
63
  <style lang="scss">
64
- @use './index.scss';
64
+ @import './index.scss';
65
65
  </style>
@@ -74,5 +74,5 @@ export default _defineComponent({
74
74
  </script>
75
75
 
76
76
  <style lang="scss">
77
- @use './index.scss';
77
+ @import './index.scss';
78
78
  </style>
@@ -175,5 +175,5 @@ export default _defineComponent({
175
175
  </script>
176
176
 
177
177
  <style lang="scss">
178
- @use './index.scss';
178
+ @import './index.scss';
179
179
  </style>
@@ -67,12 +67,15 @@
67
67
  type="compact"
68
68
  @confirm="onPickerConfirm"
69
69
  >
70
- <sar-datetime-picker
71
- type="yM"
72
- v-model="pickerValue"
73
- :min="minDate"
74
- :max="maxDate"
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
- @use './index.scss';
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 `${getOutletTextMayByStr(date[0])} ${t(
150
- "to"
151
- )} ${getOutletTextMayByStr(date[1])}`;
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", {
@@ -167,5 +167,5 @@ export default _defineComponent({
167
167
  </script>
168
168
 
169
169
  <style lang="scss">
170
- @use './index.scss';
170
+ @import './index.scss';
171
171
  </style>
@@ -71,5 +71,5 @@ export default _defineComponent({
71
71
  </script>
72
72
 
73
73
  <style lang="scss">
74
- @use './index.scss';
74
+ @import './index.scss';
75
75
  </style>
@@ -267,5 +267,5 @@ export default _defineComponent({
267
267
  </script>
268
268
 
269
269
  <style lang="scss">
270
- @use './index.scss';
270
+ @import './index.scss';
271
271
  </style>
@@ -49,5 +49,5 @@ export default _defineComponent({
49
49
  </script>
50
50
 
51
51
  <style lang="scss">
52
- @use './index.scss';
52
+ @import './index.scss';
53
53
  </style>
@@ -145,5 +145,5 @@ export default _defineComponent({
145
145
  </script>
146
146
 
147
147
  <style lang="scss">
148
- @use './index.scss';
148
+ @import './index.scss';
149
149
  </style>
@@ -116,5 +116,5 @@ export default _defineComponent({
116
116
  </script>
117
117
 
118
118
  <style lang="scss">
119
- @use './index.scss';
119
+ @import './index.scss';
120
120
  </style>
@@ -197,5 +197,5 @@ export default _defineComponent({
197
197
  </script>
198
198
 
199
199
  <style lang="scss">
200
- @use './index.scss';
200
+ @import './index.scss';
201
201
  </style>
@@ -62,5 +62,5 @@ export default _defineComponent({
62
62
  </script>
63
63
 
64
64
  <style lang="scss">
65
- @use './index.scss';
65
+ @import './index.scss';
66
66
  </style>
@@ -101,5 +101,5 @@ export default _defineComponent({
101
101
  </script>
102
102
 
103
103
  <style lang="scss">
104
- @use './index.scss';
104
+ @import './index.scss';
105
105
  </style>
@@ -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"];
@@ -65,6 +65,12 @@ export const defaultConfig = {
65
65
  datetimePickerInput: {
66
66
  validateEvent: true,
67
67
  },
68
+ datetimeRangePicker: {
69
+ type: 'yMd',
70
+ },
71
+ datetimeRangePickerInput: {
72
+ validateEvent: true,
73
+ },
68
74
  dialog: {
69
75
  headed: true,
70
76
  buttonType: 'round',
@@ -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, parseDate, stringifyStyle } from "../../utils";
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.getTime() < minDate.value.getTime() ? minDate.value : date.getTime() > maxDate.value.getTime() ? maxDate.value : 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(() => props.min || getMinDate());
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
- emit("update:model-value", emitValue);
160
- emit("change", emitValue);
169
+ emitChange();
161
170
  };
162
- const __returned__ = { props, emit, t, createColumnData, getChangedLetter, updateColumns, getDateByPickerValue, toDate, normalizeValue, innerType, minDate, maxDate, innerValue, get currentEmitValue() {
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(() => props.min || getMinDate());
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,2 @@
1
+ import { defaultConfig } from '../config';
2
+ export const defaultDatetimeRangePickerProps = defaultConfig.datetimeRangePicker;
@@ -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
+ }