sard-uniapp 1.10.4 → 1.11.1

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 (45) hide show
  1. package/{changelog.md → CHANGELOG.md} +23 -0
  2. package/README.md +15 -9
  3. package/components/calendar-input/calendar-input.vue +4 -3
  4. package/components/config/index.d.ts +6 -0
  5. package/components/config/index.js +6 -0
  6. package/components/datetime-picker/common.d.ts +2 -2
  7. package/components/datetime-picker/datetime-picker.vue +28 -19
  8. package/components/datetime-picker-input/datetime-picker-input.vue +23 -6
  9. package/components/datetime-range-picker/common.d.ts +15 -0
  10. package/components/datetime-range-picker/common.js +2 -0
  11. package/components/datetime-range-picker/datetime-range-picker.d.ts +18 -0
  12. package/components/datetime-range-picker/datetime-range-picker.vue +143 -0
  13. package/components/datetime-range-picker/index.d.ts +1 -0
  14. package/components/datetime-range-picker/index.js +1 -0
  15. package/components/datetime-range-picker/index.scss +26 -0
  16. package/components/datetime-range-picker/variables.scss +5 -0
  17. package/components/datetime-range-picker-input/common.d.ts +18 -0
  18. package/components/datetime-range-picker-input/common.js +5 -0
  19. package/components/datetime-range-picker-input/datetime-range-picker-input.d.ts +14 -0
  20. package/components/datetime-range-picker-input/datetime-range-picker-input.vue +194 -0
  21. package/components/datetime-range-picker-input/index.d.ts +1 -0
  22. package/components/datetime-range-picker-input/index.js +1 -0
  23. package/components/locale/lang/en-US.d.ts +3 -0
  24. package/components/locale/lang/en-US.js +3 -0
  25. package/components/locale/lang/zh-CN.d.ts +3 -0
  26. package/components/locale/lang/zh-CN.js +3 -0
  27. package/components/picker/picker.vue +11 -5
  28. package/components/picker-input/picker-input.vue +1 -0
  29. package/components/popout/common.d.ts +1 -0
  30. package/components/popout/popout.vue +3 -1
  31. package/components/popup/common.d.ts +1 -0
  32. package/components/popup/index.scss +24 -4
  33. package/components/popup/popup.vue +13 -5
  34. package/components/tree/utils.d.ts +1 -1
  35. package/global.d.ts +2 -0
  36. package/index.d.ts +2 -0
  37. package/index.js +2 -0
  38. package/index.scss +1 -0
  39. package/package.json +5 -6
  40. package/utils/date.d.ts +1 -0
  41. package/utils/date.js +7 -0
  42. package/utils/index.d.ts +1 -0
  43. package/utils/index.js +1 -0
  44. package/utils/object.d.ts +4 -0
  45. package/utils/object.js +13 -0
@@ -1,3 +1,26 @@
1
+ ## [1.11.1](https://github.com/sutras/sard-uniapp/compare/v1.11.0...v1.11.1) (2025-03-06)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * 修复日期时间选择器min, max联动问题 ([81d9256](https://github.com/sutras/sard-uniapp/commit/81d9256c872b5711664abf1e8ff75de3b146f3da))
7
+
8
+
9
+
10
+ # [1.11.0](https://github.com/sutras/sard-uniapp/compare/v1.10.4...v1.11.0) (2025-03-04)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * **datetime-picker:** 修改min, max属性后更新列数据 ([f58fef5](https://github.com/sutras/sard-uniapp/commit/f58fef592dd1102032aa999c5dbf887b8e25189d))
16
+
17
+
18
+ ### Features
19
+
20
+ * 新增 DatetimeRangePicker 和 DatetimeRangePickerInput 组件 ([7cf3eeb](https://github.com/sutras/sard-uniapp/commit/7cf3eebbd8ce5f1aa185a4a55425607ba8a4bbdc))
21
+
22
+
23
+
1
24
  ## [1.10.4](https://github.com/sutras/sard-uniapp/compare/v1.10.3...v1.10.4) (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
 
@@ -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", {
@@ -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;
@@ -12,6 +12,7 @@
12
12
  <sar-popout
13
13
  :root-class="rootClass"
14
14
  :root-style="rootStyle"
15
+ keep-render
15
16
  :visible="innerVisible"
16
17
  @update:visible="onVisible"
17
18
  :title="title ?? placeholder"
@@ -40,7 +41,7 @@ import { ref, watch, computed } from "vue";
40
41
  import SarPopoutInput from "../popout-input/popout-input.vue";
41
42
  import SarPopout from "../popout/popout.vue";
42
43
  import SarDatetimePicker from "../datetime-picker/datetime-picker.vue";
43
- import { formatDate, isNullish, isString, parseDate } from "../../utils";
44
+ import { formatDate, isNullish, isString, parseDate, toDate } from "../../utils";
44
45
  import {
45
46
  getInitialValue,
46
47
  getMinDate,
@@ -73,8 +74,8 @@ export default _defineComponent({
73
74
  rootStyle: { type: [Boolean, null, String, Object, Array], required: false, skipCheck: true },
74
75
  rootClass: { type: String, required: false },
75
76
  type: { type: String, required: false },
76
- min: { type: Date, required: false },
77
- max: { type: Date, required: false },
77
+ min: { type: [Date, String], required: false },
78
+ max: { type: [Date, String], required: false },
78
79
  modelValue: { type: [Date, String], required: false },
79
80
  filter: { type: Function, required: false },
80
81
  formatter: { type: Function, required: false },
@@ -109,11 +110,27 @@ export default _defineComponent({
109
110
  popoutValue.value = innerValue.value;
110
111
  }
111
112
  };
112
- const minDate = computed(() => props.min || getMinDate());
113
+ const minDate = computed(
114
+ () => toDate(props.min || getMinDate(), props.valueFormat)
115
+ );
113
116
  const maxDate = computed(() => {
114
- const maxDate2 = props.max || getMaxDate();
117
+ const maxDate2 = toDate(props.max || getMaxDate());
115
118
  return maxDate2 < minDate.value ? new Date(minDate.value) : maxDate2;
116
119
  });
120
+ const normalizeValue = (value) => {
121
+ const date = value ? toDate(value, props.valueFormat) : new Date();
122
+ return date < minDate.value ? new Date(minDate.value) : date > maxDate.value ? new Date(maxDate.value) : date;
123
+ };
124
+ watch([minDate, maxDate], () => {
125
+ if (innerValue.value) {
126
+ const oldDate = toDate(innerValue.value, props.valueFormat);
127
+ const value = normalizeValue(innerValue.value);
128
+ if (value.getTime() !== oldDate.getTime()) {
129
+ popoutValue.value = value;
130
+ onConfirm();
131
+ }
132
+ }
133
+ });
117
134
  const onConfirm = () => {
118
135
  if (!popoutValue.value) {
119
136
  const initialValue = getInitialValue(minDate.value, maxDate.value);
@@ -173,7 +190,7 @@ export default _defineComponent({
173
190
  innerVisible.value = true;
174
191
  emit("update:visible", true);
175
192
  };
176
- const __returned__ = { props, emit, formItemContext, innerValue, popoutValue, onChange, onVisibleHook, minDate, maxDate, onConfirm, inputValue, getOutletText, getInputValue, onClear, innerVisible, onVisible, onInputClick, SarPopoutInput, SarPopout, SarDatetimePicker };
193
+ const __returned__ = { props, emit, formItemContext, innerValue, popoutValue, onChange, onVisibleHook, minDate, maxDate, normalizeValue, onConfirm, inputValue, getOutletText, getInputValue, onClear, innerVisible, onVisible, onInputClick, SarPopoutInput, SarPopout, SarDatetimePicker };
177
194
  return __returned__;
178
195
  }
179
196
  });
@@ -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
+ }
@@ -0,0 +1,5 @@
1
+ // #variables
2
+ page {
3
+ --sar-datetime-range-picker-wrapper-duration: var(--sar-duration);
4
+ }
5
+ // #endvariables
@@ -0,0 +1,18 @@
1
+ import { type DatetimeRangePickerProps } from '../datetime-range-picker/common';
2
+ import { type PopoutInputProps } from '../popout-input/common';
3
+ export interface DatetimeRangePickerInputProps extends DatetimeRangePickerProps, Omit<PopoutInputProps, 'modelValue' | 'loading'> {
4
+ visible?: boolean;
5
+ title?: string;
6
+ outletFormat?: string;
7
+ valueFormat?: string;
8
+ validateEvent?: boolean;
9
+ }
10
+ export declare const defaultDatetimeRangePickerInputProps: () => {
11
+ validateEvent: boolean;
12
+ type: string;
13
+ };
14
+ export interface DatetimeRangePickerInputEmits {
15
+ (e: 'update:visible', visible: boolean): void;
16
+ (e: 'update:model-value', date: (Date | string)[] | undefined): void;
17
+ (e: 'change', date: (Date | string)[] | undefined): void;
18
+ }
@@ -0,0 +1,5 @@
1
+ import { defaultConfig } from '../config';
2
+ export const defaultDatetimeRangePickerInputProps = () => ({
3
+ ...defaultConfig.datetimeRangePicker,
4
+ ...defaultConfig.datetimeRangePickerInput,
5
+ });
@@ -0,0 +1,14 @@
1
+ import { type DatetimeRangePickerInputProps } from './common';
2
+ declare const _default: import("vue").DefineComponent<DatetimeRangePickerInputProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
3
+ "update:model-value": (date: (string | Date)[] | undefined) => any;
4
+ change: (date: (string | Date)[] | undefined) => any;
5
+ "update:visible": (visible: boolean) => any;
6
+ }, string, import("vue").PublicProps, Readonly<DatetimeRangePickerInputProps> & Readonly<{
7
+ "onUpdate:model-value"?: ((date: (string | Date)[] | undefined) => any) | undefined;
8
+ onChange?: ((date: (string | Date)[] | undefined) => any) | undefined;
9
+ "onUpdate:visible"?: ((visible: boolean) => any) | undefined;
10
+ }>, {
11
+ type: string;
12
+ validateEvent: boolean;
13
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
14
+ export default _default;
@@ -0,0 +1,194 @@
1
+ <template>
2
+ <sar-popout-input
3
+ v-model="inputValue"
4
+ :placeholder="placeholder"
5
+ :readonly="readonly"
6
+ :disabled="disabled"
7
+ :clearable="clearable"
8
+ @clear="onClear"
9
+ @click="onInputClick"
10
+ />
11
+
12
+ <sar-popout
13
+ :root-class="rootClass"
14
+ :root-style="rootStyle"
15
+ keep-render
16
+ :visible="innerVisible"
17
+ @update:visible="onVisible"
18
+ :title="title ?? placeholder"
19
+ @confirm="onConfirm"
20
+ @visible-hook="onVisibleHook"
21
+ >
22
+ <template #visible="{ already }">
23
+ <sar-datetime-range-picker
24
+ v-if="already"
25
+ :model-value="popoutValue"
26
+ @change="onChange"
27
+ :type="type"
28
+ :min="min"
29
+ :max="max"
30
+ :filter="filter"
31
+ :formatter="formatter"
32
+ :value-format="valueFormat"
33
+ :tabs="tabs"
34
+ />
35
+ </template>
36
+ </sar-popout>
37
+ </template>
38
+
39
+ <script>
40
+ import { mergeDefaults as _mergeDefaults, defineComponent as _defineComponent } from "vue";
41
+ import { computed, ref, watch } from "vue";
42
+ import SarPopoutInput from "../popout-input/popout-input.vue";
43
+ import SarPopout from "../popout/popout.vue";
44
+ import SarDatetimeRangePicker from "../datetime-range-picker/datetime-range-picker.vue";
45
+ import { formatDate, isNullish, isString, parseDate, toDate } from "../../utils";
46
+ import {
47
+ getInitialValue,
48
+ getMaxDate,
49
+ getMinDate
50
+ } from "../datetime-picker/common";
51
+ import {
52
+ defaultDatetimeRangePickerInputProps
53
+ } from "./common";
54
+ import { mapTypeFormat } from "../datetime-picker-input/common";
55
+ import { useFormItemContext } from "../form/common";
56
+ import { useTranslate } from "../locale";
57
+ export default _defineComponent({
58
+ components: {
59
+ SarPopoutInput,
60
+ SarPopout,
61
+ SarDatetimeRangePicker,
62
+ },
63
+ ...{
64
+ options: {
65
+ virtualHost: true,
66
+ styleIsolation: "shared"
67
+ }
68
+ },
69
+ __name: "datetime-range-picker-input",
70
+ props: _mergeDefaults({
71
+ visible: { type: Boolean, required: false },
72
+ title: { type: String, required: false },
73
+ outletFormat: { type: String, required: false },
74
+ valueFormat: { type: String, required: false },
75
+ validateEvent: { type: Boolean, required: false },
76
+ modelValue: { type: Array, required: false },
77
+ tabs: { type: Array, required: false },
78
+ rootStyle: { type: [Boolean, null, String, Object, Array], required: false, skipCheck: true },
79
+ rootClass: { type: String, required: false },
80
+ type: { type: String, required: false },
81
+ min: { type: [Date, String], required: false },
82
+ max: { type: [Date, String], required: false },
83
+ filter: { type: Function, required: false },
84
+ formatter: { type: Function, required: false },
85
+ placeholder: { type: String, required: false },
86
+ readonly: { type: Boolean, required: false },
87
+ disabled: { type: Boolean, required: false },
88
+ clearable: { type: Boolean, required: false },
89
+ multiline: { type: Boolean, required: false }
90
+ }, defaultDatetimeRangePickerInputProps()),
91
+ emits: ["update:visible", "update:model-value", "change"],
92
+ setup(__props, { expose: __expose, emit: __emit }) {
93
+ __expose();
94
+ const props = __props;
95
+ const emit = __emit;
96
+ const formItemContext = useFormItemContext();
97
+ const innerValue = ref(props.modelValue);
98
+ watch(
99
+ () => props.modelValue,
100
+ () => {
101
+ innerValue.value = props.modelValue;
102
+ if (props.validateEvent) {
103
+ formItemContext?.onChange();
104
+ }
105
+ }
106
+ );
107
+ const popoutValue = ref(props.modelValue);
108
+ const onChange = (value) => {
109
+ popoutValue.value = value;
110
+ };
111
+ const onVisibleHook = (name) => {
112
+ if (name === "enter" && !isNullish(innerValue.value) && popoutValue.value !== innerValue.value) {
113
+ popoutValue.value = innerValue.value;
114
+ }
115
+ };
116
+ const minDate = computed(
117
+ () => toDate(props.min || getMinDate(), props.valueFormat)
118
+ );
119
+ const maxDate = computed(() => {
120
+ const maxDate2 = toDate(props.max || getMaxDate(), props.valueFormat);
121
+ return maxDate2 < minDate.value ? new Date(minDate.value) : maxDate2;
122
+ });
123
+ const onConfirm = () => {
124
+ if (!popoutValue.value) {
125
+ const initialValue = getInitialValue(minDate.value, maxDate.value);
126
+ const singleValue = props.valueFormat ? formatDate(initialValue, props.valueFormat) : initialValue;
127
+ popoutValue.value = [singleValue, singleValue];
128
+ }
129
+ innerValue.value = popoutValue.value;
130
+ emit("update:model-value", popoutValue.value);
131
+ emit("change", popoutValue.value);
132
+ inputValue.value = getInputValue();
133
+ };
134
+ const inputValue = ref("");
135
+ const { t } = useTranslate("datetimeRangePickerInput");
136
+ function getOutletTextMayByStr(date) {
137
+ if (isString(date) && props.valueFormat) {
138
+ date = parseDate(date, props.valueFormat);
139
+ }
140
+ if (date instanceof Date) {
141
+ return formatDate(
142
+ date,
143
+ props.outletFormat || mapTypeFormat[props.type]
144
+ );
145
+ }
146
+ return date;
147
+ }
148
+ function getOutletText(value) {
149
+ return [
150
+ getOutletTextMayByStr(value[0]),
151
+ getOutletTextMayByStr(value[1])
152
+ ].join(` ${t("to")} `);
153
+ }
154
+ function getInputValue() {
155
+ if (!innerValue.value || Array.isArray(innerValue.value) && innerValue.value.length === 0) {
156
+ return "";
157
+ }
158
+ return getOutletText(innerValue.value);
159
+ }
160
+ watch(
161
+ innerValue,
162
+ () => {
163
+ inputValue.value = getInputValue();
164
+ },
165
+ {
166
+ immediate: true
167
+ }
168
+ );
169
+ const onClear = () => {
170
+ inputValue.value = "";
171
+ innerValue.value = void 0;
172
+ emit("update:model-value", void 0);
173
+ emit("change", void 0);
174
+ };
175
+ const innerVisible = ref(props.visible);
176
+ watch(
177
+ () => props.visible,
178
+ () => {
179
+ innerVisible.value = props.visible;
180
+ }
181
+ );
182
+ const onVisible = (visible) => {
183
+ innerVisible.value = visible;
184
+ emit("update:visible", visible);
185
+ };
186
+ const onInputClick = () => {
187
+ innerVisible.value = true;
188
+ emit("update:visible", true);
189
+ };
190
+ const __returned__ = { props, emit, formItemContext, innerValue, popoutValue, onChange, onVisibleHook, minDate, maxDate, onConfirm, inputValue, t, getOutletTextMayByStr, getOutletText, getInputValue, onClear, innerVisible, onVisible, onInputClick, SarPopoutInput, SarPopout, SarDatetimeRangePicker };
191
+ return __returned__;
192
+ }
193
+ });
194
+ </script>
@@ -0,0 +1 @@
1
+ export type { DatetimeRangePickerInputProps, DatetimeRangePickerInputEmits, } from './common';
@@ -0,0 +1 @@
1
+ export {};
@@ -26,6 +26,9 @@ declare const _default: {
26
26
  m: string;
27
27
  s: string;
28
28
  };
29
+ datetimeRangePickerInput: {
30
+ to: string;
31
+ };
29
32
  dialog: {
30
33
  confirm: string;
31
34
  cancel: string;
@@ -27,6 +27,9 @@ export default {
27
27
  m: '',
28
28
  s: '',
29
29
  },
30
+ datetimeRangePickerInput: {
31
+ to: 'to',
32
+ },
30
33
  dialog: {
31
34
  confirm: 'Ok',
32
35
  cancel: 'Cancel',
@@ -26,6 +26,9 @@ declare const _default: {
26
26
  m: string;
27
27
  s: string;
28
28
  };
29
+ datetimeRangePickerInput: {
30
+ to: string;
31
+ };
29
32
  dialog: {
30
33
  confirm: string;
31
34
  cancel: string;
@@ -27,6 +27,9 @@ export default {
27
27
  m: '分',
28
28
  s: '秒',
29
29
  },
30
+ datetimeRangePickerInput: {
31
+ to: '至',
32
+ },
30
33
  dialog: {
31
34
  confirm: '确定',
32
35
  cancel: '取消',
@@ -68,16 +68,19 @@ export default _defineComponent({
68
68
  return getColumnsType(props.columns, fieldKeys.value);
69
69
  });
70
70
  const innerValue = ref(props.modelValue);
71
- const columnIndexes = ref(
72
- getIndexesByValue(toArray(innerValue.value), props.columns, fieldKeys.value)
73
- );
74
71
  watch(
75
72
  () => props.modelValue,
76
73
  () => {
77
74
  innerValue.value = props.modelValue;
78
- if (!isNullish(props.modelValue) && props.modelValue !== "") {
75
+ }
76
+ );
77
+ const columnIndexes = ref([]);
78
+ watch(
79
+ [innerValue, () => props.columns, fieldKeys],
80
+ () => {
81
+ if (!isNullish(innerValue.value) && innerValue.value !== "") {
79
82
  const indexes = getIndexesByValue(
80
- toArray(props.modelValue),
83
+ toArray(innerValue.value),
81
84
  props.columns,
82
85
  fieldKeys.value
83
86
  );
@@ -85,6 +88,9 @@ export default _defineComponent({
85
88
  columnIndexes.value = indexes;
86
89
  }
87
90
  }
91
+ },
92
+ {
93
+ immediate: true
88
94
  }
89
95
  );
90
96
  const onChange = (event) => {
@@ -12,6 +12,7 @@
12
12
  <sar-popout
13
13
  :root-class="rootClass"
14
14
  :root-style="rootStyle"
15
+ keep-render
15
16
  :visible="innerVisible"
16
17
  @update:visible="onVisible"
17
18
  :title="title ?? placeholder"
@@ -16,6 +16,7 @@ export interface PopoutProps {
16
16
  showFooter?: boolean;
17
17
  overlayClosable?: boolean;
18
18
  beforeClose?: (type: 'close' | 'cancel' | 'confirm') => boolean | undefined | Promise<any>;
19
+ keepRender?: boolean;
19
20
  }
20
21
  export declare const defaultPopoutProps: {
21
22
  type: PopoutProps["type"];
@@ -3,6 +3,7 @@
3
3
  effect="slide-bottom"
4
4
  :visible="visible"
5
5
  :duration="duration"
6
+ :keep-render="keepRender"
6
7
  @overlay-click="onOverlayClick"
7
8
  @before-enter="onBeforeEnter"
8
9
  @after-leave="onAfterLeave"
@@ -126,7 +127,8 @@ export default _defineComponent({
126
127
  showClose: { type: Boolean, required: false },
127
128
  showFooter: { type: Boolean, required: false },
128
129
  overlayClosable: { type: Boolean, required: false },
129
- beforeClose: { type: Function, required: false }
130
+ beforeClose: { type: Function, required: false },
131
+ keepRender: { type: Boolean, required: false }
130
132
  }, defaultPopoutProps),
131
133
  emits: ["update:visible", "close", "cancel", "confirm", "visible-hook"],
132
134
  setup(__props, { expose: __expose, emit: __emit }) {
@@ -11,6 +11,7 @@ export interface PopupProps {
11
11
  overlayStyle?: string;
12
12
  background?: string;
13
13
  transparent?: boolean;
14
+ keepRender?: boolean;
14
15
  }
15
16
  export declare const defaultPopupProps: {
16
17
  duration: number;
@@ -76,19 +76,39 @@
76
76
  }
77
77
 
78
78
  // slide
79
- @include m(slide-top-enter-from, slide-top-leave-to) {
79
+ @include m(
80
+ slide-top-enter-from,
81
+ slide-top-leave-to,
82
+ slide-top-keep,
83
+ slide-top-after-leave-keep
84
+ ) {
80
85
  transform: translate3d(0, -100%, 0);
81
86
  }
82
87
 
83
- @include m(slide-right-enter-from, slide-right-leave-to) {
88
+ @include m(
89
+ slide-right-enter-from,
90
+ slide-right-leave-to,
91
+ slide-right-keep,
92
+ slide-right-after-leave-keep
93
+ ) {
84
94
  transform: translate3d(100%, 0, 0);
85
95
  }
86
96
 
87
- @include m(slide-bottom-enter-from, slide-bottom-leave-to) {
97
+ @include m(
98
+ slide-bottom-enter-from,
99
+ slide-bottom-leave-to,
100
+ slide-bottom-keep,
101
+ slide-bottom-after-leave-keep
102
+ ) {
88
103
  transform: translate3d(0, 100%, 0);
89
104
  }
90
105
 
91
- @include m(slide-left-enter-from, slide-left-leave-to) {
106
+ @include m(
107
+ slide-left-enter-from,
108
+ slide-left-leave-to,
109
+ slide-left-keep,
110
+ slide-left-after-leave-keep
111
+ ) {
92
112
  transform: translate3d(-100%, 0, 0);
93
113
  }
94
114
 
@@ -21,7 +21,7 @@
21
21
 
22
22
  <script>
23
23
  import { mergeDefaults as _mergeDefaults, defineComponent as _defineComponent } from "vue";
24
- import { computed, reactive, toRef } from "vue";
24
+ import { computed, reactive, ref, toRef } from "vue";
25
25
  import { classNames, stringifyStyle, createBem } from "../../utils";
26
26
  import { useTransition, useZIndex } from "../../use";
27
27
  import SarOverlay from "../overlay/overlay.vue";
@@ -50,7 +50,8 @@ export default _defineComponent({
50
50
  overlayClass: { type: String, required: false },
51
51
  overlayStyle: { type: String, required: false },
52
52
  background: { type: String, required: false },
53
- transparent: { type: Boolean, required: false }
53
+ transparent: { type: Boolean, required: false },
54
+ keepRender: { type: Boolean, required: false }
54
55
  }, defaultPopupProps),
55
56
  emits: ["overlay-click", "before-enter", "enter", "after-enter", "enter-cancelled", "before-leave", "leave", "after-leave", "leave-cancelled", "visible-hook"],
56
57
  setup(__props, { expose: __expose, emit: __emit }) {
@@ -60,6 +61,9 @@ export default _defineComponent({
60
61
  const bem = createBem("popup");
61
62
  const [zIndex, increaseZIndex] = useZIndex();
62
63
  const callVisibleHook = usePopupVisibleHookProvide();
64
+ const keepRenderClass = ref(
65
+ props.keepRender ? bem.m(props.effect) + "-keep" : ""
66
+ );
63
67
  const onVisibleHook = (name) => {
64
68
  callVisibleHook(name);
65
69
  emit("visible-hook", name);
@@ -67,6 +71,9 @@ export default _defineComponent({
67
71
  if (name === "before-enter") {
68
72
  increaseZIndex();
69
73
  }
74
+ if (props.keepRender) {
75
+ keepRenderClass.value = name === "after-leave" ? bem.m(props.effect) + "-" + name + "-keep" : "";
76
+ }
70
77
  };
71
78
  const { realVisible, transitionClass, onTransitionEnd } = useTransition(
72
79
  reactive({
@@ -84,17 +91,18 @@ export default _defineComponent({
84
91
  bem.b(),
85
92
  bem.m(props.effect),
86
93
  props.rootClass,
87
- transitionClass.value
94
+ transitionClass.value,
95
+ keepRenderClass.value
88
96
  );
89
97
  });
90
98
  const popupStyle = computed(() => {
91
99
  return stringifyStyle(props.rootStyle, {
92
100
  zIndex: zIndex.value,
93
- display: realVisible.value ? "flex" : "none",
101
+ display: props.keepRender || realVisible.value ? "flex" : "none",
94
102
  transitionDuration: props.duration + "ms"
95
103
  });
96
104
  });
97
- const __returned__ = { props, emit, bem, zIndex, increaseZIndex, callVisibleHook, onVisibleHook, realVisible, transitionClass, onTransitionEnd, onOverlayClick, popupClass, popupStyle, SarOverlay };
105
+ const __returned__ = { props, emit, bem, zIndex, increaseZIndex, callVisibleHook, keepRenderClass, onVisibleHook, realVisible, transitionClass, onTransitionEnd, onOverlayClick, popupClass, popupStyle, SarOverlay };
98
106
  return __returned__;
99
107
  }
100
108
  });
@@ -1,4 +1,4 @@
1
- import { TreeStateNode } from './common';
1
+ import { type TreeStateNode } from './common';
2
2
  export declare function recurDescendant(node: TreeStateNode, callback: (node: TreeStateNode) => boolean | void | undefined): void;
3
3
  export declare function recurAncestor(node: TreeStateNode | null, callback: (node: TreeStateNode) => void): void;
4
4
  export declare function recurNodes(nodes: TreeStateNode[], callback: (node: TreeStateNode) => void): void | boolean;
package/global.d.ts CHANGED
@@ -22,6 +22,8 @@ declare module 'vue' {
22
22
  SarCountTo: typeof import('./components/count-to/count-to').default
23
23
  SarDatetimePicker: typeof import('./components/datetime-picker/datetime-picker').default
24
24
  SarDatetimePickerInput: typeof import('./components/datetime-picker-input/datetime-picker-input').default
25
+ SarDatetimeRangePicker: typeof import('./components/datetime-range-picker/datetime-range-picker').default
26
+ SarDatetimeRangePickerInput: typeof import('./components/datetime-range-picker-input/datetime-range-picker-input').default
25
27
  SarDialog: typeof import('./components/dialog/dialog').default
26
28
  SarDialogAgent: typeof import('./components/dialog-agent/dialog-agent').default
27
29
  SarDropdown: typeof import('./components/dropdown/dropdown').default
package/index.d.ts CHANGED
@@ -18,6 +18,8 @@ export * from './components/count-down';
18
18
  export * from './components/count-to';
19
19
  export * from './components/datetime-picker';
20
20
  export * from './components/datetime-picker-input';
21
+ export * from './components/datetime-range-picker';
22
+ export * from './components/datetime-range-picker-input';
21
23
  export * from './components/dialog';
22
24
  export * from './components/dialog-agent';
23
25
  export * from './components/dropdown';
package/index.js CHANGED
@@ -18,6 +18,8 @@ export * from './components/count-down';
18
18
  export * from './components/count-to';
19
19
  export * from './components/datetime-picker';
20
20
  export * from './components/datetime-picker-input';
21
+ export * from './components/datetime-range-picker';
22
+ export * from './components/datetime-range-picker-input';
21
23
  export * from './components/dialog';
22
24
  export * from './components/dialog-agent';
23
25
  export * from './components/dropdown';
package/index.scss CHANGED
@@ -13,6 +13,7 @@
13
13
  @use './components/checkbox/variables.scss' as *;
14
14
  @use './components/col/variables.scss' as *;
15
15
  @use './components/collapse/variables.scss' as *;
16
+ @use './components/datetime-range-picker/variables.scss' as *;
16
17
  @use './components/dialog/variables.scss' as *;
17
18
  @use './components/dropdown/variables.scss' as *;
18
19
  @use './components/empty/variables.scss' as *;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "id": "sard-uniapp",
3
3
  "name": "sard-uniapp",
4
4
  "displayName": "sard-uniapp",
5
- "version": "1.10.4",
5
+ "version": "1.11.1",
6
6
  "description": "sard-uniapp 是一套基于 Uniapp + Vue3 框架开发的兼容多端的 UI 组件库",
7
7
  "main": "index.js",
8
8
  "scripts": {
@@ -13,6 +13,8 @@
13
13
  "deploy": "sard deploy",
14
14
  "release": "sard release",
15
15
  "test": "vitest",
16
+ "tag": "sard tag",
17
+ "changelog": "sard changelog",
16
18
  "buildAndRelease": "npm run build && npm run release",
17
19
  "push": "git push origin && git push gitee && git push origin --tags && git push gitee --tags",
18
20
  "prepare": "husky install",
@@ -72,6 +74,7 @@
72
74
  "@commitlint/prompt-cli": "^17.8.1",
73
75
  "@dcloudio/types": "^3.4.14",
74
76
  "@dcloudio/uni-app": "3.0.0-4040520250104002",
77
+ "@dcloudio/uni-app-harmony": "3.0.0-4040520250104002",
75
78
  "@dcloudio/uni-app-plus": "3.0.0-4040520250104002",
76
79
  "@dcloudio/uni-automator": "3.0.0-4040520250104002",
77
80
  "@dcloudio/uni-cli-shared": "3.0.0-4040520250104002",
@@ -102,7 +105,6 @@
102
105
  "@vue/runtime-core": "^3.5.13",
103
106
  "@vue/test-utils": "^2.4.6",
104
107
  "consola": "^3.2.3",
105
- "conventional-changelog-cli": "^4.1.0",
106
108
  "eslint": "^9.16.0",
107
109
  "eslint-config-prettier": "^8.10.0",
108
110
  "eslint-plugin-prettier": "^4.2.1",
@@ -115,7 +117,7 @@
115
117
  "lodash-es": "^4.17.21",
116
118
  "prettier": "^2.8.8",
117
119
  "region-data": "^1.2.3",
118
- "sard-cli": "^1.0.9",
120
+ "sard-cli": "^1.1.2",
119
121
  "sass": "^1.69.7",
120
122
  "tel-area-code": "^1.0.1",
121
123
  "ts-custom-error": "^3.3.1",
@@ -219,8 +221,5 @@
219
221
  },
220
222
  "pnpm": {
221
223
  "overrides": {}
222
- },
223
- "dependencies": {
224
- "@dcloudio/uni-app-harmony": "3.0.0-4040520250104002"
225
224
  }
226
225
  }
package/utils/date.d.ts CHANGED
@@ -10,6 +10,7 @@ export declare function getPadEndDays(year: number, month: number, amount: numbe
10
10
  export declare function getOffsetDaysFromFirstDay(weekOnFirstDay: number, weekStartsOn: number): number;
11
11
  export declare function formatDate(date: Date, format?: string): string;
12
12
  export declare function parseDate(value: string, format?: string): Date;
13
+ export declare function toDate(date: Date | string, valueFormat?: string): Date;
13
14
  export declare function minmaxDate(date: Date, minDate: Date, maxDate: Date): Date;
14
15
  export declare function getPrevMonthDate(date: Date): Date;
15
16
  export declare function getNextMonthDate(date: Date): Date;
package/utils/date.js CHANGED
@@ -128,6 +128,13 @@ export function parseDate(value, format) {
128
128
  });
129
129
  return date;
130
130
  }
131
+ // 确保返回一个Date对象,如果传递字符串,则使用 parseDate 解析
132
+ export function toDate(date, valueFormat) {
133
+ if (date instanceof Date) {
134
+ return date;
135
+ }
136
+ return parseDate(date, valueFormat);
137
+ }
131
138
  // 限定日期范围
132
139
  export function minmaxDate(date, minDate, maxDate) {
133
140
  return new Date(minmax(date.getTime(), minDate.getTime(), maxDate.getTime()));
package/utils/index.d.ts CHANGED
@@ -8,3 +8,4 @@ export * from './utils';
8
8
  export * from './lwa.slim';
9
9
  export * from './qrcode';
10
10
  export * from './system';
11
+ export * from './object';
package/utils/index.js CHANGED
@@ -8,3 +8,4 @@ export * from './utils';
8
8
  export * from './lwa.slim';
9
9
  export * from './qrcode';
10
10
  export * from './system';
11
+ export * from './object';
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 此方法创建一个对象,该对象由自己不可省略的属性组成。
3
+ */
4
+ export declare function omit<T extends object, U extends keyof T>(object: T, paths: U[]): Omit<T, U>;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * 此方法创建一个对象,该对象由自己不可省略的属性组成。
3
+ */
4
+ export function omit(object, paths) {
5
+ const newObj = {};
6
+ Object.keys(object).forEach((key) => {
7
+ if (!paths.includes(key)) {
8
+ ;
9
+ newObj[key] = object[key];
10
+ }
11
+ });
12
+ return newObj;
13
+ }