@v-c/picker 0.0.2 → 0.0.4
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/dist/PickerInput/RangePicker.cjs +0 -1
- package/dist/PickerInput/RangePicker.js +0 -1
- package/dist/PickerInput/Selector/RangeSelector.cjs +5 -2
- package/dist/PickerInput/Selector/RangeSelector.js +5 -2
- package/dist/PickerInput/Selector/SingleSelector/index.cjs +5 -2
- package/dist/PickerInput/Selector/SingleSelector/index.js +5 -2
- package/dist/PickerInput/SinglePicker.cjs +6 -6
- package/dist/PickerInput/SinglePicker.js +6 -6
- package/dist/PickerInput/hooks/useRangeValue.cjs +2 -1
- package/dist/PickerInput/hooks/useRangeValue.js +2 -1
- package/dist/hooks/useTimeInfo.cjs +18 -17
- package/dist/hooks/useTimeInfo.js +18 -17
- package/package.json +3 -3
|
@@ -166,7 +166,6 @@ var RangePicker = /* @__PURE__ */ (0, vue.defineComponent)((props, { expose }) =
|
|
|
166
166
|
};
|
|
167
167
|
const onSelectorClick = (event) => {
|
|
168
168
|
const rootNode = event.target.getRootNode();
|
|
169
|
-
console.log(rootNode);
|
|
170
169
|
if (!selectorRef.value?.nativeElement?.contains(rootNode.activeElement ?? document.activeElement)) {
|
|
171
170
|
const enabledIndex = disabled.value.findIndex((d) => !d);
|
|
172
171
|
if (enabledIndex >= 0) selectorRef.value?.focus({ index: enabledIndex });
|
|
@@ -158,7 +158,6 @@ var RangePicker_default = /* @__PURE__ */ defineComponent((props, { expose }) =>
|
|
|
158
158
|
};
|
|
159
159
|
const onSelectorClick = (event) => {
|
|
160
160
|
const rootNode = event.target.getRootNode();
|
|
161
|
-
console.log(rootNode);
|
|
162
161
|
if (!selectorRef.value?.nativeElement?.contains(rootNode.activeElement ?? document.activeElement)) {
|
|
163
162
|
const enabledIndex = disabled.value.findIndex((d) => !d);
|
|
164
163
|
if (enabledIndex >= 0) selectorRef.value?.focus({ index: enabledIndex });
|
|
@@ -86,8 +86,11 @@ var RangeSelector = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, ex
|
|
|
86
86
|
[`${prefixCls.value}-disabled`]: disabled?.every((i) => i),
|
|
87
87
|
[`${prefixCls.value}-invalid`]: invalid?.some((i) => i),
|
|
88
88
|
[`${prefixCls.value}-rtl`]: rtl.value
|
|
89
|
-
}, attrs.class),
|
|
90
|
-
style:
|
|
89
|
+
}, attrs.class, props.class),
|
|
90
|
+
style: {
|
|
91
|
+
...attrs.style,
|
|
92
|
+
...props.style
|
|
93
|
+
},
|
|
91
94
|
onClick: (event) => {
|
|
92
95
|
if (Array.isArray(onClick)) onClick.forEach((fn) => fn?.(event));
|
|
93
96
|
else onClick?.(event);
|
|
@@ -80,8 +80,11 @@ var RangeSelector_default = /* @__PURE__ */ defineComponent((props, { attrs, exp
|
|
|
80
80
|
[`${prefixCls.value}-disabled`]: disabled?.every((i) => i),
|
|
81
81
|
[`${prefixCls.value}-invalid`]: invalid?.some((i) => i),
|
|
82
82
|
[`${prefixCls.value}-rtl`]: rtl.value
|
|
83
|
-
}, attrs.class),
|
|
84
|
-
style:
|
|
83
|
+
}, attrs.class, props.class),
|
|
84
|
+
style: {
|
|
85
|
+
...attrs.style,
|
|
86
|
+
...props.style
|
|
87
|
+
},
|
|
85
88
|
onClick: (event) => {
|
|
86
89
|
if (Array.isArray(onClick)) onClick.forEach((fn) => fn?.(event));
|
|
87
90
|
else onClick?.(event);
|
|
@@ -93,8 +93,11 @@ var SingleSelector = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, e
|
|
|
93
93
|
[`${prefixCls.value}-disabled`]: disabled,
|
|
94
94
|
[`${prefixCls.value}-invalid`]: invalid,
|
|
95
95
|
[`${prefixCls.value}-rtl`]: rtl.value
|
|
96
|
-
}, attrs.class),
|
|
97
|
-
"style": {
|
|
96
|
+
}, props.class, attrs.class),
|
|
97
|
+
"style": {
|
|
98
|
+
...attrs.style,
|
|
99
|
+
...props.style
|
|
100
|
+
},
|
|
98
101
|
"ref": rootRef,
|
|
99
102
|
"onClick": onClick,
|
|
100
103
|
"onMousedown": (e) => {
|
|
@@ -88,8 +88,11 @@ var SingleSelector_default = /* @__PURE__ */ defineComponent((props, { attrs, ex
|
|
|
88
88
|
[`${prefixCls.value}-disabled`]: disabled,
|
|
89
89
|
[`${prefixCls.value}-invalid`]: invalid,
|
|
90
90
|
[`${prefixCls.value}-rtl`]: rtl.value
|
|
91
|
-
}, attrs.class),
|
|
92
|
-
"style": {
|
|
91
|
+
}, props.class, attrs.class),
|
|
92
|
+
"style": {
|
|
93
|
+
...attrs.style,
|
|
94
|
+
...props.style
|
|
95
|
+
},
|
|
93
96
|
"ref": rootRef,
|
|
94
97
|
"onClick": onClick,
|
|
95
98
|
"onMousedown": (e) => {
|
|
@@ -38,7 +38,6 @@ var SinglePicker = /* @__PURE__ */ (0, vue.defineComponent)((props, { expose })
|
|
|
38
38
|
const defaultValue = (0, vue.computed)(() => fp.value.defaultValue);
|
|
39
39
|
const value = (0, vue.computed)(() => fp.value.value);
|
|
40
40
|
const needConfirm = (0, vue.computed)(() => fp.value.needConfirm);
|
|
41
|
-
const onChange = (0, vue.computed)(() => fp.value.onChange);
|
|
42
41
|
const onKeyDown = (0, vue.computed)(() => fp.value.onKeyDown);
|
|
43
42
|
const disabled = (0, vue.computed)(() => fp.value.disabled);
|
|
44
43
|
const disabledDate = (0, vue.computed)(() => fp.value.disabledDate);
|
|
@@ -121,15 +120,17 @@ var SinglePicker = /* @__PURE__ */ (0, vue.defineComponent)((props, { expose })
|
|
|
121
120
|
triggerFocus(false);
|
|
122
121
|
onBlur.value?.(event, {});
|
|
123
122
|
};
|
|
124
|
-
const
|
|
125
|
-
|
|
123
|
+
const mergedMode = (0, vue.ref)(picker.value ?? mode.value);
|
|
124
|
+
(0, vue.watch)(picker, () => {
|
|
125
|
+
mergedMode.value = picker.value;
|
|
126
|
+
});
|
|
126
127
|
const setMode = (val) => {
|
|
127
|
-
|
|
128
|
+
mergedMode.value = val;
|
|
128
129
|
};
|
|
129
130
|
const internalMode = (0, vue.computed)(() => mergedMode.value === "date" && showTime.value ? "datetime" : mergedMode.value);
|
|
130
131
|
const mergedShowNow = require_useShowNow.default(picker, mergedMode, showNow, showToday);
|
|
131
132
|
const onInternalChange = (dates, dateStrings) => {
|
|
132
|
-
if (onChange
|
|
133
|
+
if (props?.onChange) props?.onChange?.(pickerParam(dates), pickerParam(dateStrings));
|
|
133
134
|
};
|
|
134
135
|
const [, triggerSubmitChange] = require_useRangeValue.default((0, vue.computed)(() => {
|
|
135
136
|
return {
|
|
@@ -199,7 +200,6 @@ var SinglePicker = /* @__PURE__ */ (0, vue.defineComponent)((props, { expose })
|
|
|
199
200
|
onPresetSubmit(now);
|
|
200
201
|
};
|
|
201
202
|
const onPanelHover = (date) => {
|
|
202
|
-
console.log(date);
|
|
203
203
|
onSetHover(date, "cell");
|
|
204
204
|
};
|
|
205
205
|
const onPanelFocus = (event) => {
|
|
@@ -31,7 +31,6 @@ var SinglePicker_default = /* @__PURE__ */ defineComponent((props, { expose }) =
|
|
|
31
31
|
const defaultValue = computed(() => fp.value.defaultValue);
|
|
32
32
|
const value = computed(() => fp.value.value);
|
|
33
33
|
const needConfirm = computed(() => fp.value.needConfirm);
|
|
34
|
-
const onChange = computed(() => fp.value.onChange);
|
|
35
34
|
const onKeyDown = computed(() => fp.value.onKeyDown);
|
|
36
35
|
const disabled = computed(() => fp.value.disabled);
|
|
37
36
|
const disabledDate = computed(() => fp.value.disabledDate);
|
|
@@ -114,15 +113,17 @@ var SinglePicker_default = /* @__PURE__ */ defineComponent((props, { expose }) =
|
|
|
114
113
|
triggerFocus(false);
|
|
115
114
|
onBlur.value?.(event, {});
|
|
116
115
|
};
|
|
117
|
-
const
|
|
118
|
-
|
|
116
|
+
const mergedMode = ref(picker.value ?? mode.value);
|
|
117
|
+
watch(picker, () => {
|
|
118
|
+
mergedMode.value = picker.value;
|
|
119
|
+
});
|
|
119
120
|
const setMode = (val) => {
|
|
120
|
-
|
|
121
|
+
mergedMode.value = val;
|
|
121
122
|
};
|
|
122
123
|
const internalMode = computed(() => mergedMode.value === "date" && showTime.value ? "datetime" : mergedMode.value);
|
|
123
124
|
const mergedShowNow = useShowNow(picker, mergedMode, showNow, showToday);
|
|
124
125
|
const onInternalChange = (dates, dateStrings) => {
|
|
125
|
-
if (onChange
|
|
126
|
+
if (props?.onChange) props?.onChange?.(pickerParam(dates), pickerParam(dateStrings));
|
|
126
127
|
};
|
|
127
128
|
const [, triggerSubmitChange] = useRangeValue(computed(() => {
|
|
128
129
|
return {
|
|
@@ -192,7 +193,6 @@ var SinglePicker_default = /* @__PURE__ */ defineComponent((props, { expose }) =
|
|
|
192
193
|
onPresetSubmit(now);
|
|
193
194
|
};
|
|
194
195
|
const onPanelHover = (date) => {
|
|
195
|
-
console.log(date);
|
|
196
196
|
onSetHover(date, "cell");
|
|
197
197
|
};
|
|
198
198
|
const onPanelFocus = (event) => {
|
|
@@ -105,8 +105,9 @@ function useRangeValue(info, mergedValue, setInnerValue, getCalendarValue, trigg
|
|
|
105
105
|
}));
|
|
106
106
|
const allPassed = isNullValue || validateEmptyDateRange && validateOrder && validateDates;
|
|
107
107
|
if (allPassed) {
|
|
108
|
+
const oldValue = mergedValue.value;
|
|
108
109
|
setInnerValue(clone);
|
|
109
|
-
const [isSameMergedDates] = isSameDates(clone,
|
|
110
|
+
const [isSameMergedDates] = isSameDates(clone, oldValue);
|
|
110
111
|
if (onChange && !isSameMergedDates) {
|
|
111
112
|
const everyEmpty = clone.every((val) => !val);
|
|
112
113
|
onChange(isNullValue && everyEmpty ? null : clone, everyEmpty ? null : getDateTexts(clone));
|
|
@@ -100,8 +100,9 @@ function useRangeValue(info, mergedValue, setInnerValue, getCalendarValue, trigg
|
|
|
100
100
|
}));
|
|
101
101
|
const allPassed = isNullValue || validateEmptyDateRange && validateOrder && validateDates;
|
|
102
102
|
if (allPassed) {
|
|
103
|
+
const oldValue = mergedValue.value;
|
|
103
104
|
setInnerValue(clone);
|
|
104
|
-
const [isSameMergedDates] = isSameDates(clone,
|
|
105
|
+
const [isSameMergedDates] = isSameDates(clone, oldValue);
|
|
105
106
|
if (onChange && !isSameMergedDates) {
|
|
106
107
|
const everyEmpty = clone.every((val) => !val);
|
|
107
108
|
onChange(isNullValue && everyEmpty ? null : clone, everyEmpty ? null : getDateTexts(clone));
|
|
@@ -92,22 +92,23 @@ function useTimeInfo(generateConfig, props, date) {
|
|
|
92
92
|
];
|
|
93
93
|
}
|
|
94
94
|
function findValidateTime(nextTime, getHourUnits, getMinuteUnits, getSecondUnits, getMillisecondUnits, generateConfig) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
95
|
+
let nextDate = nextTime;
|
|
96
|
+
function alignValidate(getUnitValue, setUnitValue, units) {
|
|
97
|
+
let nextValue = Reflect.get(generateConfig, getUnitValue)(nextDate);
|
|
98
|
+
const nextUnit = units.find((unit) => unit.value === nextValue);
|
|
99
|
+
if (!nextUnit || nextUnit.disabled) {
|
|
100
|
+
const validateUnits = units.filter((unit) => !unit.disabled);
|
|
101
|
+
const validateUnit = [...validateUnits].reverse().find((unit) => unit.value <= nextValue) || validateUnits[0];
|
|
102
|
+
if (validateUnit) {
|
|
103
|
+
nextValue = validateUnit.value;
|
|
104
|
+
nextDate = Reflect.get(generateConfig, setUnitValue)(nextDate, nextValue);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return nextValue;
|
|
108
|
+
}
|
|
109
|
+
const nextHour = alignValidate("getHour", "setHour", getHourUnits());
|
|
110
|
+
const nextMinute = alignValidate("getMinute", "setMinute", getMinuteUnits(nextHour));
|
|
111
|
+
alignValidate("getMillisecond", "setMillisecond", getMillisecondUnits(nextHour, nextMinute, alignValidate("getSecond", "setSecond", getSecondUnits(nextHour, nextMinute))));
|
|
112
|
+
return nextDate;
|
|
112
113
|
}
|
|
113
114
|
exports.default = useTimeInfo;
|
|
@@ -87,22 +87,23 @@ function useTimeInfo(generateConfig, props, date) {
|
|
|
87
87
|
];
|
|
88
88
|
}
|
|
89
89
|
function findValidateTime(nextTime, getHourUnits, getMinuteUnits, getSecondUnits, getMillisecondUnits, generateConfig) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
90
|
+
let nextDate = nextTime;
|
|
91
|
+
function alignValidate(getUnitValue, setUnitValue, units) {
|
|
92
|
+
let nextValue = Reflect.get(generateConfig, getUnitValue)(nextDate);
|
|
93
|
+
const nextUnit = units.find((unit) => unit.value === nextValue);
|
|
94
|
+
if (!nextUnit || nextUnit.disabled) {
|
|
95
|
+
const validateUnits = units.filter((unit) => !unit.disabled);
|
|
96
|
+
const validateUnit = [...validateUnits].reverse().find((unit) => unit.value <= nextValue) || validateUnits[0];
|
|
97
|
+
if (validateUnit) {
|
|
98
|
+
nextValue = validateUnit.value;
|
|
99
|
+
nextDate = Reflect.get(generateConfig, setUnitValue)(nextDate, nextValue);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return nextValue;
|
|
103
|
+
}
|
|
104
|
+
const nextHour = alignValidate("getHour", "setHour", getHourUnits());
|
|
105
|
+
const nextMinute = alignValidate("getMinute", "setMinute", getMinuteUnits(nextHour));
|
|
106
|
+
alignValidate("getMillisecond", "setMillisecond", getMillisecondUnits(nextHour, nextMinute, alignValidate("getSecond", "setSecond", getSecondUnits(nextHour, nextMinute))));
|
|
107
|
+
return nextDate;
|
|
107
108
|
}
|
|
108
109
|
export { useTimeInfo as default };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@v-c/picker",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.4",
|
|
5
5
|
"description": "picker ui component for vue",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -73,8 +73,8 @@
|
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
75
|
"@v-c/overflow": "^1.0.1",
|
|
76
|
-
"@v-c/
|
|
77
|
-
"@v-c/
|
|
76
|
+
"@v-c/trigger": "^1.0.2",
|
|
77
|
+
"@v-c/util": "^1.0.6"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
80
|
"@types/luxon": "^3.7.1"
|