@v-c/picker 1.3.2 → 1.4.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/LICENSE +21 -21
- package/dist/PickerInput/Popup/Footer.js +3 -3
- package/dist/PickerInput/Popup/PopupPanel.js +7 -7
- package/dist/PickerInput/Popup/index.js +4 -5
- package/dist/PickerInput/RangePicker.js +20 -3
- package/dist/PickerInput/Selector/Icon.js +2 -2
- package/dist/PickerInput/Selector/Input.js +3 -3
- package/dist/PickerInput/Selector/RangeSelector.js +18 -5
- package/dist/PickerInput/Selector/SingleSelector/index.js +19 -6
- package/dist/PickerInput/Selector/hooks/useClearIcon.d.ts +1 -1
- package/dist/PickerInput/Selector/hooks/useClearIcon.js +5 -3
- package/dist/PickerInput/Selector/hooks/useInputHooks.d.ts +1 -1
- package/dist/PickerInput/SinglePicker.js +15 -2
- package/dist/PickerInput/hooks/useFilledProps.js +8 -2
- package/dist/PickerInput/hooks/useFocusEvents.d.ts +4 -3
- package/dist/PickerInput/hooks/useFocusEvents.js +7 -5
- package/dist/PickerPanel/TimePanel/TimePanelBody/index.js +4 -5
- package/dist/PickerPanel/index.d.ts +1 -1
- package/dist/PickerPanel/index.js +5 -6
- package/dist/generate/dayjs.js +2 -2
- package/dist/interface.d.ts +4 -0
- package/dist/locale/zh_TW.js +1 -1
- package/dist/utils/getClearIcon.js +3 -1
- package/package.json +4 -4
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2023 antdv-community
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 antdv-community
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { usePickerContext } from "../context.js";
|
|
2
2
|
import useTimeInfo from "../../hooks/useTimeInfo.js";
|
|
3
3
|
import { computed, createVNode, defineComponent } from "vue";
|
|
4
|
-
import { clsx } from "@v-c/util";
|
|
4
|
+
import { clsx, isVueRenderable } from "@v-c/util";
|
|
5
5
|
//#region src/PickerInput/Popup/Footer.tsx
|
|
6
6
|
var Footer = /* @__PURE__ */ defineComponent((props) => {
|
|
7
7
|
const mode = computed(() => props.mode);
|
|
@@ -40,11 +40,11 @@ var Footer = /* @__PURE__ */ defineComponent((props) => {
|
|
|
40
40
|
"onClick": onSubmit.value
|
|
41
41
|
}, { default: () => [locale.ok] })]);
|
|
42
42
|
const rangeNode = (presetNode || okNode) && createVNode("ul", { "class": `${prefixCls}-ranges` }, [presetNode, okNode]);
|
|
43
|
-
if (!extraNode && !rangeNode) return null;
|
|
43
|
+
if (!isVueRenderable(extraNode) && !isVueRenderable(rangeNode)) return null;
|
|
44
44
|
return createVNode("div", {
|
|
45
45
|
"class": clsx(`${prefixCls}-footer`, classNames.popup?.footer),
|
|
46
46
|
"style": styles.popup?.footer
|
|
47
|
-
}, [extraNode && createVNode("div", { "class": `${prefixCls}-footer-extra` }, [extraNode]), rangeNode]);
|
|
47
|
+
}, [isVueRenderable(extraNode) && createVNode("div", { "class": `${prefixCls}-footer-extra` }, [extraNode]), rangeNode]);
|
|
48
48
|
};
|
|
49
49
|
}, {
|
|
50
50
|
props: {
|
|
@@ -26,6 +26,7 @@ var PopupPanel = /* @__PURE__ */ defineComponent((props) => {
|
|
|
26
26
|
const onSubmit = computed(() => props.onSubmit);
|
|
27
27
|
const range = computed(() => props.range);
|
|
28
28
|
const hoverValue = computed(() => props.hoverValue);
|
|
29
|
+
const hoverRangeValue = computed(() => props.hoverRangeValue);
|
|
29
30
|
const multiplePanel = computed(() => props.multiplePanel);
|
|
30
31
|
const onPickerValueChange = computed(() => props.onPickerValueChange);
|
|
31
32
|
const internalOffsetDate = (date, offset) => {
|
|
@@ -49,8 +50,8 @@ var PopupPanel = /* @__PURE__ */ defineComponent((props) => {
|
|
|
49
50
|
hoverRangeValue: null,
|
|
50
51
|
hideHeader: hideHeader.value
|
|
51
52
|
};
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
baseProps.hoverValue = hoverValue?.value;
|
|
54
|
+
if (range?.value) baseProps.hoverRangeValue = hoverRangeValue?.value;
|
|
54
55
|
return baseProps;
|
|
55
56
|
});
|
|
56
57
|
return () => {
|
|
@@ -297,11 +298,6 @@ var PopupPanel = /* @__PURE__ */ defineComponent((props) => {
|
|
|
297
298
|
required: false,
|
|
298
299
|
default: void 0
|
|
299
300
|
},
|
|
300
|
-
defaultValue: {
|
|
301
|
-
type: [Array, null],
|
|
302
|
-
required: false,
|
|
303
|
-
default: void 0
|
|
304
|
-
},
|
|
305
301
|
defaultOpenValue: {
|
|
306
302
|
required: false,
|
|
307
303
|
default: void 0
|
|
@@ -345,6 +341,10 @@ var PopupPanel = /* @__PURE__ */ defineComponent((props) => {
|
|
|
345
341
|
required: false,
|
|
346
342
|
default: void 0
|
|
347
343
|
},
|
|
344
|
+
defaultValue: {
|
|
345
|
+
required: false,
|
|
346
|
+
default: void 0
|
|
347
|
+
},
|
|
348
348
|
value: {
|
|
349
349
|
required: false,
|
|
350
350
|
default: void 0
|
|
@@ -411,11 +411,6 @@ var Popup = /* @__PURE__ */ defineComponent((props) => {
|
|
|
411
411
|
required: false,
|
|
412
412
|
default: void 0
|
|
413
413
|
},
|
|
414
|
-
defaultValue: {
|
|
415
|
-
type: [Array, null],
|
|
416
|
-
required: false,
|
|
417
|
-
default: void 0
|
|
418
|
-
},
|
|
419
414
|
defaultOpenValue: {
|
|
420
415
|
type: void 0,
|
|
421
416
|
required: false,
|
|
@@ -460,6 +455,10 @@ var Popup = /* @__PURE__ */ defineComponent((props) => {
|
|
|
460
455
|
required: false,
|
|
461
456
|
default: void 0
|
|
462
457
|
},
|
|
458
|
+
defaultValue: {
|
|
459
|
+
required: false,
|
|
460
|
+
default: void 0
|
|
461
|
+
},
|
|
463
462
|
value: {
|
|
464
463
|
required: false,
|
|
465
464
|
default: void 0
|
|
@@ -3,6 +3,7 @@ import { providePickerContext } from "./context.js";
|
|
|
3
3
|
import PickerTrigger from "../PickerTrigger/index.js";
|
|
4
4
|
import { fillIndex, getFromDate, toArray } from "../utils/miscUtil.js";
|
|
5
5
|
import { pickTriggerProps } from "../PickerTrigger/util.js";
|
|
6
|
+
import { isSameTimestamp } from "../utils/dateUtil.js";
|
|
6
7
|
import { formatValues } from "../utils/valueUtil.js";
|
|
7
8
|
import useCellRender from "./hooks/useCellRender.js";
|
|
8
9
|
import useFieldsInvalidate from "./hooks/useFieldsInvalidate.js";
|
|
@@ -73,7 +74,7 @@ var RangePicker = /* @__PURE__ */ defineComponent((props, { expose }) => {
|
|
|
73
74
|
const pickerValue = computed(() => fp.value.pickerValue);
|
|
74
75
|
const onPickerValueChange = computed(() => fp.value.onPickerValueChange);
|
|
75
76
|
const inputReadOnly = computed(() => fp.value.inputReadOnly);
|
|
76
|
-
const
|
|
77
|
+
const suffix = computed(() => fp.value.suffix);
|
|
77
78
|
const onFocus = computed(() => fp.value.onFocus);
|
|
78
79
|
const onBlur = computed(() => fp.value.onBlur);
|
|
79
80
|
const presets = computed(() => fp.value.presets);
|
|
@@ -215,6 +216,8 @@ var RangePicker = /* @__PURE__ */ defineComponent((props, { expose }) => {
|
|
|
215
216
|
const hoverValues = computed(() => {
|
|
216
217
|
return internalHoverValues.value || calendarValue.value;
|
|
217
218
|
});
|
|
219
|
+
const showWeakHover = computed(() => hoverSource.value === "cell" && !calendarValue.value[(activeIndex.value + 1) % 2] && !isSameTimestamp(generateConfig.value, calendarValue.value[activeIndex.value], mergedValue.value?.[activeIndex.value]));
|
|
220
|
+
const activeHoverValue = computed(() => internalHoverValues.value?.[activeIndex.value]);
|
|
218
221
|
watch(mergedOpen, () => {
|
|
219
222
|
if (!mergedOpen.value) internalHoverValues.value = null;
|
|
220
223
|
});
|
|
@@ -328,7 +331,7 @@ var RangePicker = /* @__PURE__ */ defineComponent((props, { expose }) => {
|
|
|
328
331
|
...mergedStyles?.root,
|
|
329
332
|
...fp.value.style
|
|
330
333
|
},
|
|
331
|
-
|
|
334
|
+
suffix: suffix.value,
|
|
332
335
|
activeIndex: focused.value || mergedOpen.value ? activeIndex.value : null,
|
|
333
336
|
activeHelp: !!internalHoverValues.value,
|
|
334
337
|
allHelp: !!internalHoverValues.value && hoverSource.value === "preset",
|
|
@@ -377,7 +380,8 @@ var RangePicker = /* @__PURE__ */ defineComponent((props, { expose }) => {
|
|
|
377
380
|
pickerValue: currentPickerValue.value,
|
|
378
381
|
defaultOpenValue: toArray(showTime.value?.defaultOpenValue)[activeIndex.value],
|
|
379
382
|
onPickerValueChange: setCurrentPickerValue,
|
|
380
|
-
hoverValue:
|
|
383
|
+
hoverValue: showWeakHover.value && activeHoverValue.value ? [activeHoverValue.value] : null,
|
|
384
|
+
hoverRangeValue: showWeakHover.value ? null : hoverValues.value,
|
|
381
385
|
onHover: onPanelHover,
|
|
382
386
|
needConfirm: needConfirm.value,
|
|
383
387
|
onSubmit: (date) => triggerPartConfirm(date, "confirm"),
|
|
@@ -578,6 +582,19 @@ var RangePicker = /* @__PURE__ */ defineComponent((props, { expose }) => {
|
|
|
578
582
|
required: false,
|
|
579
583
|
default: void 0
|
|
580
584
|
},
|
|
585
|
+
suffix: {
|
|
586
|
+
type: [
|
|
587
|
+
Object,
|
|
588
|
+
Function,
|
|
589
|
+
String,
|
|
590
|
+
Number,
|
|
591
|
+
null,
|
|
592
|
+
Boolean,
|
|
593
|
+
Array
|
|
594
|
+
],
|
|
595
|
+
required: false,
|
|
596
|
+
default: void 0
|
|
597
|
+
},
|
|
581
598
|
suffixIcon: {
|
|
582
599
|
type: [
|
|
583
600
|
Object,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { usePickerContext } from "../context.js";
|
|
2
2
|
import { createVNode, defineComponent, mergeProps } from "vue";
|
|
3
|
-
import { clsx } from "@v-c/util";
|
|
3
|
+
import { clsx, isVueRenderable } from "@v-c/util";
|
|
4
4
|
//#region src/PickerInput/Selector/Icon.tsx
|
|
5
5
|
var Icon = /* @__PURE__ */ defineComponent((props, { attrs }) => {
|
|
6
6
|
const ctx = usePickerContext();
|
|
7
7
|
return () => {
|
|
8
8
|
const { icon } = props;
|
|
9
|
-
if (!icon) return null;
|
|
9
|
+
if (!isVueRenderable(icon)) return null;
|
|
10
10
|
const { prefixCls, classNames, styles } = ctx.value;
|
|
11
11
|
const { class: attrClass, style: attrStyle, ...restAttrs } = attrs;
|
|
12
12
|
const mergedAttrStyle = attrStyle && typeof attrStyle === "object" ? attrStyle : {};
|
|
@@ -190,7 +190,7 @@ var Input = /* @__PURE__ */ defineComponent((props, { attrs, expose }) => {
|
|
|
190
190
|
raf.cancel(rafRef.value);
|
|
191
191
|
});
|
|
192
192
|
return () => {
|
|
193
|
-
const { className, active, showActiveCls,
|
|
193
|
+
const { className, active, showActiveCls, suffix, format, validateFormat, onChange, onInput, helped, onHelp, onSubmit, onKeyDown, preserveInvalidOnBlur, invalid, clearIcon, ...restProps } = props;
|
|
194
194
|
const inputProps = props.format ? {
|
|
195
195
|
onFocus: onFormatFocus,
|
|
196
196
|
onBlur: onFormatBlur,
|
|
@@ -221,7 +221,7 @@ var Input = /* @__PURE__ */ defineComponent((props, { attrs, expose }) => {
|
|
|
221
221
|
"class": classNames.value.input,
|
|
222
222
|
"style": styles.value.input
|
|
223
223
|
}), null),
|
|
224
|
-
createVNode(Icon, { "icon": props.
|
|
224
|
+
createVNode(Icon, { "icon": props.suffix }, null),
|
|
225
225
|
props.clearIcon
|
|
226
226
|
]);
|
|
227
227
|
};
|
|
@@ -306,7 +306,7 @@ var Input = /* @__PURE__ */ defineComponent((props, { attrs, expose }) => {
|
|
|
306
306
|
required: false,
|
|
307
307
|
default: void 0
|
|
308
308
|
},
|
|
309
|
-
|
|
309
|
+
suffix: {
|
|
310
310
|
type: [
|
|
311
311
|
Object,
|
|
312
312
|
Function,
|
|
@@ -5,7 +5,7 @@ import useRootProps from "./hooks/useRootProps.js";
|
|
|
5
5
|
import Icon from "./Icon.js";
|
|
6
6
|
import Input from "./Input.js";
|
|
7
7
|
import { computed, createVNode, defineComponent, mergeProps, ref, watch } from "vue";
|
|
8
|
-
import { clsx } from "@v-c/util";
|
|
8
|
+
import { clsx, isVueRenderable } from "@v-c/util";
|
|
9
9
|
import ResizeObserver from "@v-c/resize-observer";
|
|
10
10
|
//#region src/PickerInput/Selector/RangeSelector.tsx
|
|
11
11
|
var RangeSelector = /* @__PURE__ */ defineComponent((props, { attrs, expose }) => {
|
|
@@ -74,13 +74,13 @@ var RangeSelector = /* @__PURE__ */ defineComponent((props, { attrs, expose }) =
|
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
76
|
watch(() => props.activeIndex, syncActiveOffset, { flush: "post" });
|
|
77
|
-
const showClear = computed(() => props.clearIcon && (props.value?.[0] && !props.disabled?.[0] || props.value?.[1] && !props.disabled?.[1]));
|
|
77
|
+
const showClear = computed(() => isVueRenderable(props.clearIcon) && (props.value?.[0] && !props.disabled?.[0] || props.value?.[1] && !props.disabled?.[1]));
|
|
78
78
|
const autoFocus = computed(() => props.autoFocus ?? props.autofocus);
|
|
79
79
|
const tabIndex = computed(() => props.tabIndex ?? props.tabindex);
|
|
80
80
|
const startAutoFocus = computed(() => autoFocus.value && !props.disabled?.[0]);
|
|
81
81
|
const endAutoFocus = computed(() => autoFocus.value && !startAutoFocus.value && !props.disabled?.[1]);
|
|
82
82
|
return () => {
|
|
83
|
-
const { prefix,
|
|
83
|
+
const { prefix, suffix, clearIcon, separator, disabled, invalid, onClick, onClear } = props;
|
|
84
84
|
const rootDivProps = {
|
|
85
85
|
...rootProps.value,
|
|
86
86
|
class: clsx(prefixCls.value, `${prefixCls.value}-range`, {
|
|
@@ -104,7 +104,7 @@ var RangeSelector = /* @__PURE__ */ defineComponent((props, { attrs, expose }) =
|
|
|
104
104
|
}
|
|
105
105
|
};
|
|
106
106
|
return createVNode(ResizeObserver, { "onResize": syncActiveOffset }, { default: () => [createVNode("div", mergeProps(rootDivProps, { "ref": rootRef }), [
|
|
107
|
-
prefix && createVNode("div", {
|
|
107
|
+
isVueRenderable(prefix) && createVNode("div", {
|
|
108
108
|
"class": clsx(`${prefixCls.value}-prefix`, classNames.value.prefix),
|
|
109
109
|
"style": styles.value.prefix
|
|
110
110
|
}, [prefix]),
|
|
@@ -125,7 +125,7 @@ var RangeSelector = /* @__PURE__ */ defineComponent((props, { attrs, expose }) =
|
|
|
125
125
|
"class": `${prefixCls.value}-active-bar`,
|
|
126
126
|
"style": activeBarStyle.value
|
|
127
127
|
}, null),
|
|
128
|
-
createVNode(Icon, { "icon":
|
|
128
|
+
createVNode(Icon, { "icon": suffix }, null),
|
|
129
129
|
showClear.value && createVNode(ClearIcon, {
|
|
130
130
|
"icon": clearIcon,
|
|
131
131
|
"onClear": onClear
|
|
@@ -236,6 +236,19 @@ var RangeSelector = /* @__PURE__ */ defineComponent((props, { attrs, expose }) =
|
|
|
236
236
|
required: false,
|
|
237
237
|
default: void 0
|
|
238
238
|
},
|
|
239
|
+
suffix: {
|
|
240
|
+
type: [
|
|
241
|
+
Object,
|
|
242
|
+
Function,
|
|
243
|
+
String,
|
|
244
|
+
Number,
|
|
245
|
+
null,
|
|
246
|
+
Boolean,
|
|
247
|
+
Array
|
|
248
|
+
],
|
|
249
|
+
required: false,
|
|
250
|
+
default: void 0
|
|
251
|
+
},
|
|
239
252
|
suffixIcon: {
|
|
240
253
|
type: [
|
|
241
254
|
Object,
|
|
@@ -7,7 +7,7 @@ import Icon from "../Icon.js";
|
|
|
7
7
|
import Input from "../Input.js";
|
|
8
8
|
import MultipleDates from "./MultipleDates.js";
|
|
9
9
|
import { Fragment, computed, createVNode, defineComponent, mergeProps, ref } from "vue";
|
|
10
|
-
import { clsx } from "@v-c/util";
|
|
10
|
+
import { clsx, isVueRenderable } from "@v-c/util";
|
|
11
11
|
//#region src/PickerInput/Selector/SingleSelector/index.tsx
|
|
12
12
|
var SingleSelector = /* @__PURE__ */ defineComponent((props, { attrs, expose }) => {
|
|
13
13
|
const rtl = computed(() => props.direction === "rtl");
|
|
@@ -43,8 +43,8 @@ var SingleSelector = /* @__PURE__ */ defineComponent((props, { attrs, expose })
|
|
|
43
43
|
active: props.focused
|
|
44
44
|
}));
|
|
45
45
|
return () => {
|
|
46
|
-
const { prefix, clearIcon,
|
|
47
|
-
const showClear =
|
|
46
|
+
const { prefix, clearIcon, suffix, placeholder, onClick, onClear, multiple, maxTagCount, removeIcon, tagRender, onMouseDown, value, disabled, invalid, autoFocus, tabIndex } = props;
|
|
47
|
+
const showClear = isVueRenderable(clearIcon) && !!value?.length && !disabled;
|
|
48
48
|
const selectorNode = multiple ? createVNode(Fragment, null, [
|
|
49
49
|
createVNode(MultipleDates, {
|
|
50
50
|
"prefixCls": prefixCls.value,
|
|
@@ -65,7 +65,7 @@ var SingleSelector = /* @__PURE__ */ defineComponent((props, { attrs, expose })
|
|
|
65
65
|
"autofocus": autoFocus,
|
|
66
66
|
"tabindex": tabIndex
|
|
67
67
|
}, null),
|
|
68
|
-
createVNode(Icon, { "icon":
|
|
68
|
+
createVNode(Icon, { "icon": suffix }, null),
|
|
69
69
|
showClear && createVNode(ClearIcon, {
|
|
70
70
|
"icon": clearIcon,
|
|
71
71
|
"onClear": onClear
|
|
@@ -73,7 +73,7 @@ var SingleSelector = /* @__PURE__ */ defineComponent((props, { attrs, expose })
|
|
|
73
73
|
]) : createVNode(Input, mergeProps({ "ref": inputRef }, getInputProps(), {
|
|
74
74
|
"autofocus": autoFocus,
|
|
75
75
|
"tabindex": tabIndex,
|
|
76
|
-
"
|
|
76
|
+
"suffix": suffix,
|
|
77
77
|
"clearIcon": showClear && createVNode(ClearIcon, {
|
|
78
78
|
"icon": clearIcon,
|
|
79
79
|
"onClear": onClear
|
|
@@ -99,7 +99,7 @@ var SingleSelector = /* @__PURE__ */ defineComponent((props, { attrs, expose })
|
|
|
99
99
|
if (target !== inputRef.value?.inputElement) e.preventDefault();
|
|
100
100
|
onMouseDown?.(e);
|
|
101
101
|
}
|
|
102
|
-
}), [prefix && createVNode("div", {
|
|
102
|
+
}), [isVueRenderable(prefix) && createVNode("div", {
|
|
103
103
|
"class": clsx(`${prefixCls.value}-prefix`, classNames.value.prefix),
|
|
104
104
|
"style": styles.value.prefix
|
|
105
105
|
}, [prefix]), selectorNode]);
|
|
@@ -212,6 +212,19 @@ var SingleSelector = /* @__PURE__ */ defineComponent((props, { attrs, expose })
|
|
|
212
212
|
required: false,
|
|
213
213
|
default: void 0
|
|
214
214
|
},
|
|
215
|
+
suffix: {
|
|
216
|
+
type: [
|
|
217
|
+
Object,
|
|
218
|
+
Function,
|
|
219
|
+
String,
|
|
220
|
+
Number,
|
|
221
|
+
null,
|
|
222
|
+
Boolean,
|
|
223
|
+
Array
|
|
224
|
+
],
|
|
225
|
+
required: false,
|
|
226
|
+
default: void 0
|
|
227
|
+
},
|
|
215
228
|
suffixIcon: {
|
|
216
229
|
type: [
|
|
217
230
|
Object,
|
|
@@ -11,7 +11,7 @@ export declare function fillClearIcon(prefixCls: string, allowClear?: boolean |
|
|
|
11
11
|
[key: string]: any;
|
|
12
12
|
}> | (string | number | boolean | void | import('vue').Component | import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
13
13
|
[key: string]: any;
|
|
14
|
-
}> | null | undefined)[] | null;
|
|
14
|
+
}> | null | undefined)[] | (void & {}) | null;
|
|
15
15
|
export default function useClearIcon(prefixCls: Ref<string>, allowClear?: Ref<boolean | {
|
|
16
16
|
clearIcon?: VueNode;
|
|
17
17
|
}>, clearIcon?: ComputedRef<VueNode>): ComputedRef<VueNode>;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { computed, createVNode } from "vue";
|
|
2
|
-
import { warning } from "@v-c/util";
|
|
2
|
+
import { isVueRenderable, warning } from "@v-c/util";
|
|
3
3
|
//#region src/PickerInput/Selector/hooks/useClearIcon.tsx
|
|
4
4
|
function fillClearIcon(prefixCls, allowClear, clearIcon) {
|
|
5
|
-
if (process.env.NODE_ENV !== "production" && clearIcon) warning(false, "`clearIcon` will be removed in future. Please use `allowClear` instead.");
|
|
5
|
+
if (process.env.NODE_ENV !== "production" && isVueRenderable(clearIcon)) warning(false, "`clearIcon` will be removed in future. Please use `allowClear` instead.");
|
|
6
6
|
if (allowClear === false) return null;
|
|
7
|
-
|
|
7
|
+
const config = allowClear && typeof allowClear === "object" ? allowClear : {};
|
|
8
|
+
if (isVueRenderable(config.clearIcon)) return config.clearIcon;
|
|
9
|
+
return isVueRenderable(clearIcon) ? clearIcon : createVNode("span", { "class": `${prefixCls}-clear-btn` }, null);
|
|
8
10
|
}
|
|
9
11
|
function useClearIcon(prefixCls, allowClear, clearIcon) {
|
|
10
12
|
return computed(() => fillClearIcon(prefixCls.value, allowClear?.value, clearIcon?.value));
|
|
@@ -19,7 +19,7 @@ export interface InputProps {
|
|
|
19
19
|
'active'?: boolean;
|
|
20
20
|
/** Used for single picker only */
|
|
21
21
|
'showActiveCls'?: boolean;
|
|
22
|
-
'
|
|
22
|
+
'suffix'?: VueNode;
|
|
23
23
|
'value'?: string;
|
|
24
24
|
'onChange': (value: string) => void;
|
|
25
25
|
'onSubmit': VoidFunction;
|
|
@@ -58,7 +58,7 @@ var SinglePicker = /* @__PURE__ */ defineComponent((props, { expose }) => {
|
|
|
58
58
|
const pickerValue = computed(() => fp.value.pickerValue);
|
|
59
59
|
const onPickerValueChange = computed(() => fp.value.onPickerValueChange);
|
|
60
60
|
const inputReadOnly = computed(() => fp.value.inputReadOnly);
|
|
61
|
-
const
|
|
61
|
+
const suffix = computed(() => fp.value.suffix);
|
|
62
62
|
const removeIcon = computed(() => fp.value.removeIcon);
|
|
63
63
|
const onFocus = computed(() => fp.value.onFocus);
|
|
64
64
|
const onBlur = computed(() => fp.value.onBlur);
|
|
@@ -361,7 +361,7 @@ var SinglePicker = /* @__PURE__ */ defineComponent((props, { expose }) => {
|
|
|
361
361
|
...mergedStyles.root,
|
|
362
362
|
...fp.value.style
|
|
363
363
|
},
|
|
364
|
-
|
|
364
|
+
suffix: suffix.value,
|
|
365
365
|
removeIcon: removeIcon.value,
|
|
366
366
|
activeHelp: !!internalHoverValue.value,
|
|
367
367
|
allHelp: !!internalHoverValue.value && hoverSource.value === "preset",
|
|
@@ -579,6 +579,19 @@ var SinglePicker = /* @__PURE__ */ defineComponent((props, { expose }) => {
|
|
|
579
579
|
required: false,
|
|
580
580
|
default: void 0
|
|
581
581
|
},
|
|
582
|
+
suffix: {
|
|
583
|
+
type: [
|
|
584
|
+
Object,
|
|
585
|
+
Function,
|
|
586
|
+
String,
|
|
587
|
+
Number,
|
|
588
|
+
null,
|
|
589
|
+
Boolean,
|
|
590
|
+
Array
|
|
591
|
+
],
|
|
592
|
+
required: false,
|
|
593
|
+
default: void 0
|
|
594
|
+
},
|
|
582
595
|
suffixIcon: {
|
|
583
596
|
type: [
|
|
584
597
|
Object,
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { toArray } from "../../utils/miscUtil.js";
|
|
2
|
+
import { isSameTimestamp } from "../../utils/dateUtil.js";
|
|
2
3
|
import { parseValue } from "../../utils/valueUtil.js";
|
|
3
4
|
import useLocale from "../../hooks/useLocale.js";
|
|
4
5
|
import { fillShowTimeConfig, getTimeProps } from "../../hooks/useTimeConfig.js";
|
|
5
|
-
import { isSameTimestamp } from "../../utils/dateUtil.js";
|
|
6
6
|
import { fillClearIcon } from "../Selector/hooks/useClearIcon.js";
|
|
7
7
|
import useDisabledBoundary from "./useDisabledBoundary.js";
|
|
8
8
|
import { useFieldFormat } from "./useFieldFormat.js";
|
|
9
9
|
import useInputReadOnly from "./useInputReadOnly.js";
|
|
10
10
|
import useInvalidate from "./useInvalidate.js";
|
|
11
11
|
import { computed } from "vue";
|
|
12
|
-
import { warning } from "@v-c/util";
|
|
12
|
+
import { isVueRenderable, warning } from "@v-c/util";
|
|
13
13
|
//#region src/PickerInput/hooks/useFilledProps.ts
|
|
14
14
|
function useList(value, fillMode = false, transform, isSameItem) {
|
|
15
15
|
let cache;
|
|
@@ -78,6 +78,11 @@ function useFilledProps(props, updater) {
|
|
|
78
78
|
].some((key) => props[key])) warning(false, `'disabledHours', 'disabledMinutes', 'disabledSeconds' will be removed in the next major version, please use 'disabledTime' instead.`);
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
+
const mergedSuffix = computed(() => {
|
|
82
|
+
const { suffix, suffixIcon } = props.value;
|
|
83
|
+
if (process.env.NODE_ENV !== "production" && isVueRenderable(suffixIcon)) warning(false, "`suffixIcon` is deprecated. Please use `suffix` instead.");
|
|
84
|
+
return suffix ?? suffixIcon;
|
|
85
|
+
});
|
|
81
86
|
const filledProps = computed(() => ({
|
|
82
87
|
...props.value,
|
|
83
88
|
previewValue: mergedPreviewValue.value,
|
|
@@ -88,6 +93,7 @@ function useFilledProps(props, updater) {
|
|
|
88
93
|
classNames: mergedClassNames.value,
|
|
89
94
|
order: mergedOrder.value,
|
|
90
95
|
components: mergedComponents.value,
|
|
96
|
+
suffix: mergedSuffix.value,
|
|
91
97
|
clearIcon: fillClearIcon(mergedPrefixCls.value, props.value.allowClear, props.value.clearIcon),
|
|
92
98
|
showTime: mergedShowTime.value,
|
|
93
99
|
value: values.value,
|
|
@@ -21,8 +21,9 @@ export declare function isTargetInContainers(target: EventTarget | null, contain
|
|
|
21
21
|
* 处理 field 的聚焦与失焦事件。
|
|
22
22
|
*
|
|
23
23
|
* Always forward the actual element focus events. Only the internal Picker
|
|
24
|
-
* blur is skipped when `relatedTarget` still belongs to the Picker
|
|
25
|
-
*
|
|
26
|
-
*
|
|
24
|
+
* blur is skipped when `relatedTarget` still belongs to the Picker or the
|
|
25
|
+
* focused panel control becomes disabled.
|
|
26
|
+
* 始终转发元素实际发生的焦点事件。当 `relatedTarget` 仍属于 Picker,或面板中
|
|
27
|
+
* 获得焦点的控件变为禁用时,跳过 Picker 的整体失焦逻辑。
|
|
27
28
|
*/
|
|
28
29
|
export default function useFocusEvents(isInternalElement: IsInternalElement, onFocus?: FocusEventHandler, onBlur?: FocusEventHandler, onConfirmedBlur?: FocusEventHandler): UseFocusEventsReturn;
|
|
@@ -9,9 +9,10 @@ function isTargetInContainers(target, containers) {
|
|
|
9
9
|
* 处理 field 的聚焦与失焦事件。
|
|
10
10
|
*
|
|
11
11
|
* Always forward the actual element focus events. Only the internal Picker
|
|
12
|
-
* blur is skipped when `relatedTarget` still belongs to the Picker
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* blur is skipped when `relatedTarget` still belongs to the Picker or the
|
|
13
|
+
* focused panel control becomes disabled.
|
|
14
|
+
* 始终转发元素实际发生的焦点事件。当 `relatedTarget` 仍属于 Picker,或面板中
|
|
15
|
+
* 获得焦点的控件变为禁用时,跳过 Picker 的整体失焦逻辑。
|
|
15
16
|
*/
|
|
16
17
|
function useFocusEvents(isInternalElement, onFocus, onBlur, onConfirmedBlur) {
|
|
17
18
|
const focusedIndex = shallowRef(null);
|
|
@@ -19,8 +20,9 @@ function useFocusEvents(isInternalElement, onFocus, onBlur, onConfirmedBlur) {
|
|
|
19
20
|
focusedIndex.value = index;
|
|
20
21
|
onFocus?.(index, event);
|
|
21
22
|
};
|
|
22
|
-
const onFieldBlur = (index,
|
|
23
|
-
if (
|
|
23
|
+
const onFieldBlur = (index, source, event) => {
|
|
24
|
+
if (source === "panel" && event.target?.hasAttribute?.("disabled")) event.currentTarget?.focus?.({ preventScroll: true });
|
|
25
|
+
else if (!isInternalElement(event.relatedTarget)) {
|
|
24
26
|
focusedIndex.value = null;
|
|
25
27
|
onConfirmedBlur?.(index, event);
|
|
26
28
|
}
|
|
@@ -3,7 +3,7 @@ import useTimeInfo from "../../../hooks/useTimeInfo.js";
|
|
|
3
3
|
import { usePanelContext, usePickerHackContext } from "../../context.js";
|
|
4
4
|
import TimeColumn from "./TimeColumn.js";
|
|
5
5
|
import { computed, createVNode, defineComponent, mergeProps } from "vue";
|
|
6
|
-
import { clsx } from "@v-c/util";
|
|
6
|
+
import { clsx, isNonNullable } from "@v-c/util";
|
|
7
7
|
//#region src/PickerPanel/TimePanel/TimePanelBody/index.tsx
|
|
8
8
|
function isAM(hour) {
|
|
9
9
|
return hour < 12;
|
|
@@ -72,18 +72,17 @@ var TimePanelBody = /* @__PURE__ */ defineComponent((props) => {
|
|
|
72
72
|
};
|
|
73
73
|
const triggerDateTmpl = (() => {
|
|
74
74
|
let tmpl = value.value || context.value.pickerValue || generateConfig.value.getNow();
|
|
75
|
-
|
|
76
|
-
if (isNotNull(hour)) {
|
|
75
|
+
if (isNonNullable(hour)) {
|
|
77
76
|
tmpl = generateConfig.value.setHour(tmpl, hour);
|
|
78
77
|
tmpl = generateConfig.value.setMinute(tmpl, minute);
|
|
79
78
|
tmpl = generateConfig.value.setSecond(tmpl, second);
|
|
80
79
|
tmpl = generateConfig.value.setMillisecond(tmpl, millisecond);
|
|
81
|
-
} else if (
|
|
80
|
+
} else if (isNonNullable(pickerHour)) {
|
|
82
81
|
tmpl = generateConfig.value.setHour(tmpl, pickerHour);
|
|
83
82
|
tmpl = generateConfig.value.setMinute(tmpl, pickerMinute);
|
|
84
83
|
tmpl = generateConfig.value.setSecond(tmpl, pickerSecond);
|
|
85
84
|
tmpl = generateConfig.value.setMillisecond(tmpl, pickerMillisecond);
|
|
86
|
-
} else if (
|
|
85
|
+
} else if (isNonNullable(validHour)) {
|
|
87
86
|
tmpl = generateConfig.value.setHour(tmpl, validHour);
|
|
88
87
|
tmpl = generateConfig.value.setMinute(tmpl, validMinute);
|
|
89
88
|
tmpl = generateConfig.value.setSecond(tmpl, validSecond);
|
|
@@ -4,7 +4,7 @@ import { CellRender, Components, Locale, OnPanelChange, PanelMode, PanelSemantic
|
|
|
4
4
|
export interface PickerPanelRef {
|
|
5
5
|
nativeElement: HTMLDivElement;
|
|
6
6
|
}
|
|
7
|
-
export interface BasePickerPanelProps<DateType extends object = any> extends Pick<SharedPanelProps<DateType>, 'locale' | 'generateConfig' | 'disabledDate' | 'minDate' | 'maxDate' | 'prevIcon' | 'nextIcon' | 'superPrevIcon' | 'superNextIcon'>, SharedTimeProps<DateType>, Pick<HTMLAttributes, 'tabindex'> {
|
|
7
|
+
export interface BasePickerPanelProps<DateType extends object = any> extends Pick<SharedPanelProps<DateType>, 'locale' | 'generateConfig' | 'disabledDate' | 'minDate' | 'maxDate' | 'prevIcon' | 'nextIcon' | 'superPrevIcon' | 'superNextIcon'>, Omit<SharedTimeProps<DateType>, 'defaultValue'>, Pick<HTMLAttributes, 'tabindex'> {
|
|
8
8
|
prefixCls?: string;
|
|
9
9
|
direction?: 'ltr' | 'rtl';
|
|
10
10
|
onSelect?: (date: DateType) => void;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { usePickerContext } from "../PickerInput/context.js";
|
|
2
2
|
import { pickProps, toArray } from "../utils/miscUtil.js";
|
|
3
|
+
import { isSame } from "../utils/dateUtil.js";
|
|
3
4
|
import useCellRender from "../PickerInput/hooks/useCellRender.js";
|
|
4
5
|
import locale from "../locale/en_US.js";
|
|
5
6
|
import useLocale from "../hooks/useLocale.js";
|
|
6
7
|
import { fillShowTimeConfig, getTimeProps } from "../hooks/useTimeConfig.js";
|
|
7
|
-
import { isSame } from "../utils/dateUtil.js";
|
|
8
8
|
import useToggleDates from "../hooks/useToggleDates.js";
|
|
9
9
|
import { providePickerHackContext, provideSharedPanelContext, usePickerHackContext } from "./context.js";
|
|
10
10
|
import DatePanel from "./DatePanel/index.js";
|
|
@@ -397,11 +397,6 @@ var PickerPanel = /* @__PURE__ */ defineComponent((props, { attrs }) => {
|
|
|
397
397
|
required: false,
|
|
398
398
|
default: void 0
|
|
399
399
|
},
|
|
400
|
-
defaultValue: {
|
|
401
|
-
type: [Array, null],
|
|
402
|
-
required: false,
|
|
403
|
-
default: void 0
|
|
404
|
-
},
|
|
405
400
|
defaultOpenValue: {
|
|
406
401
|
required: false,
|
|
407
402
|
default: void 0
|
|
@@ -445,6 +440,10 @@ var PickerPanel = /* @__PURE__ */ defineComponent((props, { attrs }) => {
|
|
|
445
440
|
required: false,
|
|
446
441
|
default: void 0
|
|
447
442
|
},
|
|
443
|
+
defaultValue: {
|
|
444
|
+
required: false,
|
|
445
|
+
default: void 0
|
|
446
|
+
},
|
|
448
447
|
value: {
|
|
449
448
|
required: false,
|
|
450
449
|
default: void 0
|
package/dist/generate/dayjs.js
CHANGED
|
@@ -77,7 +77,7 @@ var generateConfig = {
|
|
|
77
77
|
getShortMonths: (locale) => dayjs().locale(parseLocale(locale)).localeData().monthsShort(),
|
|
78
78
|
format: (locale, date, format) => date.locale(parseLocale(locale)).format(format),
|
|
79
79
|
parse: (locale, text, formats) => {
|
|
80
|
-
const localeStr = parseLocale(locale);
|
|
80
|
+
const localeStr = dayjs().locale(parseLocale(locale)).locale();
|
|
81
81
|
for (let i = 0; i < formats.length; i += 1) {
|
|
82
82
|
const format = formats[i];
|
|
83
83
|
const formatText = text;
|
|
@@ -91,7 +91,7 @@ var generateConfig = {
|
|
|
91
91
|
}
|
|
92
92
|
return null;
|
|
93
93
|
}
|
|
94
|
-
const date = dayjs(formatText, format, true)
|
|
94
|
+
const date = dayjs(formatText, format, localeStr, true);
|
|
95
95
|
if (date.isValid()) return date;
|
|
96
96
|
}
|
|
97
97
|
if (text) {}
|
package/dist/interface.d.ts
CHANGED
|
@@ -245,6 +245,8 @@ export interface SharedPickerProps<DateType extends object = any> extends Shared
|
|
|
245
245
|
*/
|
|
246
246
|
valueFormat?: string;
|
|
247
247
|
prefix?: VueNode;
|
|
248
|
+
suffix?: VueNode;
|
|
249
|
+
/** @deprecated Please use `suffix` instead. */
|
|
248
250
|
suffixIcon?: VueNode;
|
|
249
251
|
allowClear?: boolean | {
|
|
250
252
|
clearIcon?: VueNode;
|
|
@@ -342,6 +344,8 @@ export interface SelectorProps<DateType = any> extends Omit<SharedHTMLAttrs, 'on
|
|
|
342
344
|
picker: PickerMode;
|
|
343
345
|
prefix?: VueNode;
|
|
344
346
|
clearIcon?: VueNode;
|
|
347
|
+
suffix?: VueNode;
|
|
348
|
+
/** @deprecated Please use `suffix` instead. */
|
|
345
349
|
suffixIcon?: VueNode;
|
|
346
350
|
className?: string;
|
|
347
351
|
style?: CSSProperties;
|
package/dist/locale/zh_TW.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { createVNode } from "vue";
|
|
2
|
+
import { isVueRenderable } from "@v-c/util";
|
|
2
3
|
//#region src/utils/getClearIcon.tsx
|
|
3
4
|
function getClearIcon(prefixCls, allowClear, clearIcon) {
|
|
4
|
-
|
|
5
|
+
const mergedClearIcon = typeof allowClear === "object" ? allowClear.clearIcon : clearIcon;
|
|
6
|
+
return isVueRenderable(mergedClearIcon) ? mergedClearIcon : createVNode("span", { "class": `${prefixCls}-clear-btn` }, null);
|
|
5
7
|
}
|
|
6
8
|
//#endregion
|
|
7
9
|
export { getClearIcon };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@v-c/picker",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.4.0",
|
|
5
5
|
"description": "picker ui component for vue",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -77,10 +77,10 @@
|
|
|
77
77
|
}
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
|
-
"@v-c/
|
|
81
|
-
"@v-c/overflow": "^1.1.1",
|
|
80
|
+
"@v-c/overflow": "^1.1.2",
|
|
82
81
|
"@v-c/resize-observer": "^1.1.3",
|
|
83
|
-
"@v-c/
|
|
82
|
+
"@v-c/util": "^1.2.0",
|
|
83
|
+
"@v-c/trigger": "^1.1.1"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
86
|
"@types/luxon": "^3.7.2"
|