naive-ui 2.30.3 → 2.30.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/index.js +1385 -901
- package/dist/index.prod.js +2 -2
- package/es/_internal/scrollbar/src/Scrollbar.js +5 -17
- package/es/_internal/select-menu/src/SelectGroupHeader.d.ts +1 -0
- package/es/_internal/select-menu/src/SelectGroupHeader.js +5 -3
- package/es/_internal/select-menu/src/SelectMenu.d.ts +3 -3
- package/es/_internal/select-menu/src/SelectMenu.js +6 -8
- package/es/_internal/select-menu/src/SelectOption.d.ts +1 -0
- package/es/_internal/select-menu/src/SelectOption.js +11 -5
- package/es/_internal/select-menu/src/interface.d.ts +3 -1
- package/es/_internal/selection/src/Selection.d.ts +0 -2
- package/es/_internal/selection/src/Selection.js +2 -2
- package/es/_mixins/use-theme.js +1 -1
- package/es/_utils/composable/index.d.ts +3 -5
- package/es/_utils/composable/index.js +3 -111
- package/es/_utils/composable/use-collection.d.ts +4 -0
- package/es/_utils/composable/use-collection.js +87 -0
- package/es/_utils/composable/use-deferred-true.d.ts +2 -0
- package/es/_utils/composable/use-deferred-true.js +25 -0
- package/es/_utils/composable/use-reactivated.d.ts +3 -0
- package/es/_utils/composable/use-reactivated.js +20 -0
- package/es/_utils/event/index.d.ts +2 -0
- package/es/_utils/event/index.js +7 -0
- package/es/_utils/index.d.ts +2 -1
- package/es/_utils/index.js +2 -1
- package/es/_utils/vue/index.d.ts +1 -0
- package/es/_utils/vue/index.js +1 -0
- package/es/_utils/vue/merge-handlers.d.ts +1 -0
- package/es/_utils/vue/merge-handlers.js +15 -0
- package/es/button/src/Button.js +7 -2
- package/es/cascader/src/Cascader.d.ts +2 -3
- package/es/cascader/src/Cascader.js +26 -22
- package/es/cascader/src/CascaderMenu.d.ts +2 -2
- package/es/cascader/src/CascaderMenu.js +2 -4
- package/es/data-table/src/DataTable.d.ts +787 -0
- package/es/data-table/src/DataTable.js +7 -3
- package/es/data-table/src/HeaderButton/FilterButton.d.ts +142 -0
- package/es/data-table/src/HeaderButton/FilterMenu.d.ts +142 -0
- package/es/data-table/src/MainTable.d.ts +2 -0
- package/es/data-table/src/MainTable.js +5 -1
- package/es/data-table/src/TableParts/Body.d.ts +143 -0
- package/es/data-table/src/TableParts/Body.js +11 -2
- package/es/data-table/src/TableParts/Cell.d.ts +284 -0
- package/es/data-table/src/TableParts/Header.d.ts +143 -0
- package/es/data-table/src/TableParts/Header.js +6 -2
- package/es/data-table/src/interface.d.ts +9 -5
- package/es/data-table/src/use-expand.d.ts +5 -3
- package/es/data-table/src/use-expand.js +22 -2
- package/es/data-table/src/utils.d.ts +2 -2
- package/es/data-table/src/utils.js +10 -8
- package/es/data-table/styles/light.d.ts +71 -0
- package/es/date-picker/src/DatePicker.d.ts +2 -1
- package/es/date-picker/src/DatePicker.js +20 -9
- package/es/date-picker/src/panel/month.js +3 -2
- package/es/drawer/src/Drawer.d.ts +1 -1
- package/es/drawer/src/Drawer.js +3 -3
- package/es/drawer/src/DrawerBodyWrapper.d.ts +2 -2
- package/es/dropdown/src/Dropdown.d.ts +4 -0
- package/es/dynamic-tags/src/DynamicTags.js +1 -1
- package/es/input/src/Input.d.ts +6 -3
- package/es/input/src/Input.js +56 -31
- package/es/input/src/utils.d.ts +7 -1
- package/es/input/src/utils.js +57 -2
- package/es/layout/src/Layout.d.ts +3 -1
- package/es/layout/src/Layout.js +22 -4
- package/es/layout/src/LayoutContent.d.ts +1 -0
- package/es/layout/src/LayoutSider.d.ts +1 -0
- package/es/layout/src/LayoutSider.js +22 -3
- package/es/menu/src/Menu.d.ts +1 -1
- package/es/modal/src/BodyWrapper.d.ts +2 -2
- package/es/modal/src/Modal.js +2 -2
- package/es/pagination/src/Pagination.d.ts +806 -20
- package/es/pagination/src/Pagination.js +115 -52
- package/es/pagination/src/interface.d.ts +2 -2
- package/es/pagination/src/styles/index.cssr.js +12 -10
- package/es/pagination/src/utils.d.ts +15 -5
- package/es/pagination/src/utils.js +117 -50
- package/es/pagination/styles/dark.js +3 -1
- package/es/pagination/styles/light.d.ts +71 -0
- package/es/pagination/styles/light.js +3 -1
- package/es/popconfirm/src/Popconfirm.d.ts +4 -0
- package/es/popover/src/Popover.d.ts +5 -0
- package/es/popover/src/Popover.js +1 -0
- package/es/popover/src/PopoverBody.d.ts +4 -0
- package/es/popover/src/PopoverBody.js +18 -10
- package/es/popselect/src/Popselect.d.ts +24 -0
- package/es/popselect/src/Popselect.js +12 -7
- package/es/popselect/src/PopselectPanel.d.ts +22 -2
- package/es/popselect/src/PopselectPanel.js +12 -1
- package/es/select/src/Select.d.ts +1 -1
- package/es/select/src/Select.js +5 -2
- package/es/slider/src/Slider.d.ts +1 -1
- package/es/slider/src/Slider.js +13 -5
- package/es/slider/src/styles/index.cssr.js +26 -31
- package/es/time-picker/src/TimePicker.d.ts +2 -1
- package/es/time-picker/src/TimePicker.js +18 -8
- package/es/tooltip/src/Tooltip.d.ts +4 -0
- package/es/tree/src/Tree.d.ts +2 -3
- package/es/tree/src/Tree.js +6 -8
- package/es/tree/src/TreeNode.js +4 -1
- package/es/tree/src/interface.d.ts +0 -1
- package/es/tree/src/keyboard.d.ts +0 -1
- package/es/tree/src/keyboard.js +6 -9
- package/es/tree-select/src/TreeSelect.d.ts +1 -3
- package/es/tree-select/src/TreeSelect.js +14 -16
- package/es/upload/src/UploadDragger.js +2 -2
- package/es/upload/src/UploadFile.d.ts +2 -2
- package/es/upload/src/UploadFile.js +9 -4
- package/es/upload/src/UploadTrigger.js +4 -3
- package/es/upload/src/styles/index.cssr.js +2 -2
- package/es/upload/src/utils.js +1 -15
- package/es/version.d.ts +1 -1
- package/es/version.js +1 -1
- package/lib/_internal/scrollbar/src/Scrollbar.js +4 -16
- package/lib/_internal/select-menu/src/SelectGroupHeader.d.ts +1 -0
- package/lib/_internal/select-menu/src/SelectGroupHeader.js +5 -3
- package/lib/_internal/select-menu/src/SelectMenu.d.ts +3 -3
- package/lib/_internal/select-menu/src/SelectMenu.js +5 -7
- package/lib/_internal/select-menu/src/SelectOption.d.ts +1 -0
- package/lib/_internal/select-menu/src/SelectOption.js +10 -4
- package/lib/_internal/select-menu/src/interface.d.ts +3 -1
- package/lib/_internal/selection/src/Selection.d.ts +0 -2
- package/lib/_internal/selection/src/Selection.js +2 -2
- package/lib/_mixins/use-theme.js +1 -1
- package/lib/_utils/composable/index.d.ts +3 -5
- package/lib/_utils/composable/index.js +9 -116
- package/lib/_utils/composable/use-collection.d.ts +4 -0
- package/lib/_utils/composable/use-collection.js +93 -0
- package/lib/_utils/composable/use-deferred-true.d.ts +2 -0
- package/lib/_utils/composable/use-deferred-true.js +29 -0
- package/lib/_utils/composable/use-reactivated.d.ts +3 -0
- package/lib/_utils/composable/use-reactivated.js +24 -0
- package/lib/_utils/event/index.d.ts +2 -0
- package/lib/_utils/event/index.js +12 -0
- package/lib/_utils/index.d.ts +2 -1
- package/lib/_utils/index.js +5 -1
- package/lib/_utils/vue/index.d.ts +1 -0
- package/lib/_utils/vue/index.js +3 -1
- package/lib/_utils/vue/merge-handlers.d.ts +1 -0
- package/lib/_utils/vue/merge-handlers.js +19 -0
- package/lib/button/src/Button.js +7 -2
- package/lib/cascader/src/Cascader.d.ts +2 -3
- package/lib/cascader/src/Cascader.js +25 -21
- package/lib/cascader/src/CascaderMenu.d.ts +2 -2
- package/lib/cascader/src/CascaderMenu.js +2 -4
- package/lib/data-table/src/DataTable.d.ts +787 -0
- package/lib/data-table/src/DataTable.js +7 -3
- package/lib/data-table/src/HeaderButton/FilterButton.d.ts +142 -0
- package/lib/data-table/src/HeaderButton/FilterMenu.d.ts +142 -0
- package/lib/data-table/src/MainTable.d.ts +2 -0
- package/lib/data-table/src/MainTable.js +5 -1
- package/lib/data-table/src/TableParts/Body.d.ts +143 -0
- package/lib/data-table/src/TableParts/Body.js +11 -2
- package/lib/data-table/src/TableParts/Cell.d.ts +284 -0
- package/lib/data-table/src/TableParts/Header.d.ts +143 -0
- package/lib/data-table/src/TableParts/Header.js +6 -2
- package/lib/data-table/src/interface.d.ts +9 -5
- package/lib/data-table/src/use-expand.d.ts +5 -3
- package/lib/data-table/src/use-expand.js +22 -2
- package/lib/data-table/src/utils.d.ts +2 -2
- package/lib/data-table/src/utils.js +11 -9
- package/lib/data-table/styles/light.d.ts +71 -0
- package/lib/date-picker/src/DatePicker.d.ts +2 -1
- package/lib/date-picker/src/DatePicker.js +19 -8
- package/lib/date-picker/src/panel/month.js +3 -2
- package/lib/drawer/src/Drawer.d.ts +1 -1
- package/lib/drawer/src/Drawer.js +2 -2
- package/lib/drawer/src/DrawerBodyWrapper.d.ts +2 -2
- package/lib/dropdown/src/Dropdown.d.ts +4 -0
- package/lib/dynamic-tags/src/DynamicTags.js +1 -1
- package/lib/input/src/Input.d.ts +6 -3
- package/lib/input/src/Input.js +55 -30
- package/lib/input/src/utils.d.ts +7 -1
- package/lib/input/src/utils.js +60 -4
- package/lib/layout/src/Layout.d.ts +3 -1
- package/lib/layout/src/Layout.js +22 -4
- package/lib/layout/src/LayoutContent.d.ts +1 -0
- package/lib/layout/src/LayoutSider.d.ts +1 -0
- package/lib/layout/src/LayoutSider.js +21 -2
- package/lib/menu/src/Menu.d.ts +1 -1
- package/lib/modal/src/BodyWrapper.d.ts +2 -2
- package/lib/modal/src/Modal.js +1 -1
- package/lib/pagination/src/Pagination.d.ts +806 -20
- package/lib/pagination/src/Pagination.js +114 -51
- package/lib/pagination/src/interface.d.ts +2 -2
- package/lib/pagination/src/styles/index.cssr.js +13 -11
- package/lib/pagination/src/utils.d.ts +15 -5
- package/lib/pagination/src/utils.js +118 -53
- package/lib/pagination/styles/dark.js +6 -4
- package/lib/pagination/styles/light.d.ts +71 -0
- package/lib/pagination/styles/light.js +6 -4
- package/lib/popconfirm/src/Popconfirm.d.ts +4 -0
- package/lib/popover/src/Popover.d.ts +5 -0
- package/lib/popover/src/Popover.js +1 -0
- package/lib/popover/src/PopoverBody.d.ts +4 -0
- package/lib/popover/src/PopoverBody.js +18 -10
- package/lib/popselect/src/Popselect.d.ts +24 -0
- package/lib/popselect/src/Popselect.js +10 -5
- package/lib/popselect/src/PopselectPanel.d.ts +22 -2
- package/lib/popselect/src/PopselectPanel.js +12 -1
- package/lib/select/src/Select.d.ts +1 -1
- package/lib/select/src/Select.js +4 -1
- package/lib/slider/src/Slider.d.ts +1 -1
- package/lib/slider/src/Slider.js +12 -4
- package/lib/slider/src/styles/index.cssr.js +26 -31
- package/lib/time-picker/src/TimePicker.d.ts +2 -1
- package/lib/time-picker/src/TimePicker.js +17 -7
- package/lib/tooltip/src/Tooltip.d.ts +4 -0
- package/lib/tree/src/Tree.d.ts +2 -3
- package/lib/tree/src/Tree.js +6 -8
- package/lib/tree/src/TreeNode.js +4 -1
- package/lib/tree/src/interface.d.ts +0 -1
- package/lib/tree/src/keyboard.d.ts +0 -1
- package/lib/tree/src/keyboard.js +6 -9
- package/lib/tree-select/src/TreeSelect.d.ts +1 -3
- package/lib/tree-select/src/TreeSelect.js +13 -15
- package/lib/upload/src/UploadDragger.js +2 -2
- package/lib/upload/src/UploadFile.d.ts +2 -2
- package/lib/upload/src/UploadFile.js +9 -4
- package/lib/upload/src/UploadTrigger.js +3 -2
- package/lib/upload/src/styles/index.cssr.js +2 -2
- package/lib/upload/src/utils.js +1 -15
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +2 -2
- package/web-types.json +37 -1
|
@@ -626,6 +626,77 @@ declare const dataTableLight: import("../../_mixins").Theme<"DataTable", {
|
|
|
626
626
|
paddingLarge: string;
|
|
627
627
|
clearSize: string;
|
|
628
628
|
}, any>;
|
|
629
|
+
Popselect: import("../../_mixins").Theme<"Popselect", {
|
|
630
|
+
menuBoxShadow: string;
|
|
631
|
+
}, {
|
|
632
|
+
Popover: import("../../_mixins").Theme<"Popover", {
|
|
633
|
+
fontSize: string;
|
|
634
|
+
borderRadius: string;
|
|
635
|
+
color: string;
|
|
636
|
+
dividerColor: string;
|
|
637
|
+
textColor: string;
|
|
638
|
+
boxShadow: string;
|
|
639
|
+
space: string;
|
|
640
|
+
spaceArrow: string;
|
|
641
|
+
arrowOffset: string;
|
|
642
|
+
arrowOffsetVertical: string;
|
|
643
|
+
arrowHeight: string;
|
|
644
|
+
padding: string;
|
|
645
|
+
}, any>;
|
|
646
|
+
InternalSelectMenu: import("../../_mixins").Theme<"InternalSelectMenu", {
|
|
647
|
+
optionFontSizeSmall: string;
|
|
648
|
+
optionFontSizeMedium: string;
|
|
649
|
+
optionFontSizeLarge: string;
|
|
650
|
+
optionFontSizeHuge: string;
|
|
651
|
+
optionHeightSmall: string;
|
|
652
|
+
optionHeightMedium: string;
|
|
653
|
+
optionHeightLarge: string;
|
|
654
|
+
optionHeightHuge: string;
|
|
655
|
+
borderRadius: string;
|
|
656
|
+
color: string;
|
|
657
|
+
groupHeaderTextColor: string;
|
|
658
|
+
actionDividerColor: string;
|
|
659
|
+
optionTextColor: string;
|
|
660
|
+
optionTextColorPressed: string;
|
|
661
|
+
optionTextColorDisabled: string;
|
|
662
|
+
optionTextColorActive: string;
|
|
663
|
+
optionOpacityDisabled: string;
|
|
664
|
+
optionCheckColor: string;
|
|
665
|
+
optionColorPending: string;
|
|
666
|
+
optionColorActive: string;
|
|
667
|
+
optionColorActivePending: string;
|
|
668
|
+
actionTextColor: string;
|
|
669
|
+
loadingColor: string;
|
|
670
|
+
height: string;
|
|
671
|
+
paddingSmall: string;
|
|
672
|
+
paddingMedium: string;
|
|
673
|
+
paddingLarge: string;
|
|
674
|
+
paddingHuge: string;
|
|
675
|
+
optionPaddingSmall: string;
|
|
676
|
+
optionPaddingMedium: string;
|
|
677
|
+
optionPaddingLarge: string;
|
|
678
|
+
optionPaddingHuge: string;
|
|
679
|
+
loadingSize: string;
|
|
680
|
+
}, {
|
|
681
|
+
Scrollbar: import("../../_mixins").Theme<"Scrollbar", {
|
|
682
|
+
color: string;
|
|
683
|
+
colorHover: string;
|
|
684
|
+
}, any>;
|
|
685
|
+
Empty: import("../../_mixins").Theme<"Empty", {
|
|
686
|
+
fontSizeSmall: string;
|
|
687
|
+
fontSizeMedium: string;
|
|
688
|
+
fontSizeLarge: string;
|
|
689
|
+
fontSizeHuge: string;
|
|
690
|
+
textColor: string;
|
|
691
|
+
iconColor: string;
|
|
692
|
+
extraTextColor: string;
|
|
693
|
+
iconSizeSmall: string;
|
|
694
|
+
iconSizeMedium: string;
|
|
695
|
+
iconSizeLarge: string;
|
|
696
|
+
iconSizeHuge: string;
|
|
697
|
+
}, any>;
|
|
698
|
+
}>;
|
|
699
|
+
}>;
|
|
629
700
|
}>;
|
|
630
701
|
Scrollbar: import("../../_mixins").Theme<"Scrollbar", {
|
|
631
702
|
color: string;
|
|
@@ -3948,8 +3948,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
3948
3948
|
isValueInvalid: import("vue").ComputedRef<boolean>;
|
|
3949
3949
|
isStartValueInvalid: import("vue").ComputedRef<boolean>;
|
|
3950
3950
|
isEndValueInvalid: import("vue").ComputedRef<boolean>;
|
|
3951
|
+
handleInputKeydown: (e: KeyboardEvent) => void;
|
|
3951
3952
|
handleClickOutside: (e: MouseEvent) => void;
|
|
3952
|
-
|
|
3953
|
+
handleKeydown: (e: KeyboardEvent) => void;
|
|
3953
3954
|
handleClear: () => void;
|
|
3954
3955
|
handlePanelClear: () => void;
|
|
3955
3956
|
handleTriggerClick: (e: MouseEvent) => void;
|
|
@@ -8,7 +8,7 @@ import { DateIcon, ToIcon } from '../../_internal/icons';
|
|
|
8
8
|
import { NInput } from '../../input';
|
|
9
9
|
import { NBaseIcon } from '../../_internal';
|
|
10
10
|
import { useFormItem, useTheme, useConfig, useLocale, useThemeClass } from '../../_mixins';
|
|
11
|
-
import { warn, call, useAdjustedTo, createKey, warnOnce, resolveSlot } from '../../_utils';
|
|
11
|
+
import { warn, call, useAdjustedTo, createKey, warnOnce, resolveSlot, markEventEffectPerformed } from '../../_utils';
|
|
12
12
|
import { datePickerLight } from '../styles';
|
|
13
13
|
import { strictParse } from './utils';
|
|
14
14
|
import { uniCalendarValidation, dualCalendarValidation } from './validation-utils';
|
|
@@ -302,11 +302,14 @@ export default defineComponent({
|
|
|
302
302
|
call(onUpdateShow, show);
|
|
303
303
|
uncontrolledShowRef.value = show;
|
|
304
304
|
}
|
|
305
|
-
function
|
|
305
|
+
function handleKeydown(e) {
|
|
306
306
|
if (e.key === 'Escape') {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
307
|
+
if (mergedShowRef.value) {
|
|
308
|
+
markEventEffectPerformed(e);
|
|
309
|
+
closeCalendar({
|
|
310
|
+
returnFocus: true
|
|
311
|
+
});
|
|
312
|
+
}
|
|
310
313
|
}
|
|
311
314
|
// We need to handle the conflict with normal date value input
|
|
312
315
|
// const { value: mergedValue } = mergedValueRef
|
|
@@ -315,6 +318,12 @@ export default defineComponent({
|
|
|
315
318
|
// doUpdateValue(nextValue)
|
|
316
319
|
// }
|
|
317
320
|
}
|
|
321
|
+
function handleInputKeydown(e) {
|
|
322
|
+
if (e.key === 'Escape' && mergedShowRef.value) {
|
|
323
|
+
markEventEffectPerformed(e);
|
|
324
|
+
// closeCalendar will be called in handleDeactivated
|
|
325
|
+
}
|
|
326
|
+
}
|
|
318
327
|
function handleClear() {
|
|
319
328
|
var _a;
|
|
320
329
|
doUpdateShow(false);
|
|
@@ -595,8 +604,9 @@ export default defineComponent({
|
|
|
595
604
|
: undefined;
|
|
596
605
|
return Object.assign(Object.assign({}, exposedMethods), { mergedStatus: mergedStatusRef, mergedClsPrefix: mergedClsPrefixRef, mergedBordered: mergedBorderedRef, namespace: namespaceRef, uncontrolledValue: uncontrolledValueRef, pendingValue: pendingValueRef, panelInstRef,
|
|
597
606
|
triggerElRef,
|
|
598
|
-
inputInstRef, isMounted: useIsMounted(), displayTime: singleInputValueRef, displayStartTime: rangeStartInputValueRef, displayEndTime: rangeEndInputValueRef, mergedShow: mergedShowRef, adjustedTo: useAdjustedTo(props), isRange: isRangeRef, localizedStartPlaceholder: localizedStartPlaceholderRef, localizedEndPlaceholder: localizedEndPlaceholderRef, mergedSize: mergedSizeRef, mergedDisabled: mergedDisabledRef, localizedPlacehoder: localizedPlacehoderRef, isValueInvalid: uniVaidation.isValueInvalidRef, isStartValueInvalid: dualValidation.isStartValueInvalidRef, isEndValueInvalid: dualValidation.isEndValueInvalidRef,
|
|
599
|
-
|
|
607
|
+
inputInstRef, isMounted: useIsMounted(), displayTime: singleInputValueRef, displayStartTime: rangeStartInputValueRef, displayEndTime: rangeEndInputValueRef, mergedShow: mergedShowRef, adjustedTo: useAdjustedTo(props), isRange: isRangeRef, localizedStartPlaceholder: localizedStartPlaceholderRef, localizedEndPlaceholder: localizedEndPlaceholderRef, mergedSize: mergedSizeRef, mergedDisabled: mergedDisabledRef, localizedPlacehoder: localizedPlacehoderRef, isValueInvalid: uniVaidation.isValueInvalidRef, isStartValueInvalid: dualValidation.isStartValueInvalidRef, isEndValueInvalid: dualValidation.isEndValueInvalidRef, handleInputKeydown,
|
|
608
|
+
handleClickOutside,
|
|
609
|
+
handleKeydown,
|
|
600
610
|
handleClear,
|
|
601
611
|
handlePanelClear,
|
|
602
612
|
handleTriggerClick,
|
|
@@ -618,7 +628,7 @@ export default defineComponent({
|
|
|
618
628
|
onTabOut: this.handlePanelTabOut,
|
|
619
629
|
onClose: this.handlePanelClose,
|
|
620
630
|
onClear: this.handlePanelClear,
|
|
621
|
-
onKeydown: this.
|
|
631
|
+
onKeydown: this.handleKeydown,
|
|
622
632
|
onConfirm: this.handlePanelConfirm,
|
|
623
633
|
ref: 'panelInstRef',
|
|
624
634
|
value: this.pendingValue,
|
|
@@ -648,6 +658,7 @@ export default defineComponent({
|
|
|
648
658
|
clearable,
|
|
649
659
|
onClear: this.handleClear,
|
|
650
660
|
onClick: this.handleTriggerClick,
|
|
661
|
+
onKeydown: this.handleInputKeydown,
|
|
651
662
|
onActivate: this.handleInputActivate,
|
|
652
663
|
onDeactivate: this.handleInputDeactivate,
|
|
653
664
|
onFocus: this.handleInputFocus,
|
|
@@ -658,7 +669,7 @@ export default defineComponent({
|
|
|
658
669
|
this.mergedDisabled && `${mergedClsPrefix}-date-picker--disabled`,
|
|
659
670
|
this.isRange && `${mergedClsPrefix}-date-picker--range`,
|
|
660
671
|
this.triggerThemeClass
|
|
661
|
-
], style: this.triggerCssVars, onKeydown: this.
|
|
672
|
+
], style: this.triggerCssVars, onKeydown: this.handleKeydown },
|
|
662
673
|
h(VBinder, null, {
|
|
663
674
|
default: () => [
|
|
664
675
|
h(VTarget, null, {
|
|
@@ -30,6 +30,7 @@ export default defineComponent({
|
|
|
30
30
|
return `Q ${item.dateObject.quarter}`;
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
|
+
const { useAsQuickJump } = props;
|
|
33
34
|
const renderItem = (item, i, mergedClsPrefix) => {
|
|
34
35
|
const { mergedIsDateDisabled, handleDateClick, handleQuickMonthClick } = useCalendarRef;
|
|
35
36
|
return (h("div", { "data-n-date": true, key: i, class: [
|
|
@@ -37,10 +38,10 @@ export default defineComponent({
|
|
|
37
38
|
{
|
|
38
39
|
[`${mergedClsPrefix}-date-panel-month-calendar__picker-col-item--current`]: item.isCurrent,
|
|
39
40
|
[`${mergedClsPrefix}-date-panel-month-calendar__picker-col-item--selected`]: item.selected,
|
|
40
|
-
[`${mergedClsPrefix}-date-panel-month-calendar__picker-col-item--disabled`]: mergedIsDateDisabled(item.ts)
|
|
41
|
+
[`${mergedClsPrefix}-date-panel-month-calendar__picker-col-item--disabled`]: !useAsQuickJump && mergedIsDateDisabled(item.ts)
|
|
41
42
|
}
|
|
42
43
|
], onClick: () => {
|
|
43
|
-
|
|
44
|
+
useAsQuickJump
|
|
44
45
|
? handleQuickMonthClick(item, (value) => props.onUpdateValue(value, false))
|
|
45
46
|
: handleDateClick(item);
|
|
46
47
|
} }, getRenderContent(item)));
|
|
@@ -295,7 +295,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
295
295
|
namespace: import("vue").ComputedRef<string | undefined>;
|
|
296
296
|
mergedBodyStyle: import("vue").ComputedRef<(string | CSSProperties)[]>;
|
|
297
297
|
handleMaskClick: (e: MouseEvent) => void;
|
|
298
|
-
handleEsc: () => void;
|
|
298
|
+
handleEsc: (e: KeyboardEvent) => void;
|
|
299
299
|
mergedTheme: import("vue").ComputedRef<{
|
|
300
300
|
common: {
|
|
301
301
|
baseColor: string;
|
package/es/drawer/src/Drawer.js
CHANGED
|
@@ -3,7 +3,7 @@ import { VLazyTeleport } from 'vueuc';
|
|
|
3
3
|
import { zindexable } from 'vdirs';
|
|
4
4
|
import { useIsMounted } from 'vooks';
|
|
5
5
|
import { useTheme, useConfig, useThemeClass } from '../../_mixins';
|
|
6
|
-
import { formatLength, call, warnOnce, useIsComposing } from '../../_utils';
|
|
6
|
+
import { formatLength, call, warnOnce, useIsComposing, eventEffectNotPerformed } from '../../_utils';
|
|
7
7
|
import { drawerLight } from '../styles';
|
|
8
8
|
import NDrawerBodyWrapper from './DrawerBodyWrapper';
|
|
9
9
|
import { drawerInjectionKey } from './interface';
|
|
@@ -103,10 +103,10 @@ export default defineComponent({
|
|
|
103
103
|
onMaskClick(e);
|
|
104
104
|
}
|
|
105
105
|
const isComposingRef = useIsComposing();
|
|
106
|
-
function handleEsc() {
|
|
106
|
+
function handleEsc(e) {
|
|
107
107
|
var _a;
|
|
108
108
|
(_a = props.onEsc) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
109
|
-
if (props.closeOnEsc) {
|
|
109
|
+
if (props.show && props.closeOnEsc && eventEffectNotPerformed(e)) {
|
|
110
110
|
!isComposingRef.value && doUpdateShow(false);
|
|
111
111
|
}
|
|
112
112
|
}
|
|
@@ -36,7 +36,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
36
36
|
onClickoutside: PropType<(e: MouseEvent) => void>;
|
|
37
37
|
onAfterLeave: PropType<() => void>;
|
|
38
38
|
onAfterEnter: PropType<() => void>;
|
|
39
|
-
onEsc: PropType<() => void>;
|
|
39
|
+
onEsc: PropType<(e: KeyboardEvent) => void>;
|
|
40
40
|
}, {
|
|
41
41
|
bodyRef: import("vue").Ref<HTMLElement | null>;
|
|
42
42
|
mergedClsPrefix: import("vue").Ref<string>;
|
|
@@ -222,7 +222,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
222
222
|
onClickoutside: PropType<(e: MouseEvent) => void>;
|
|
223
223
|
onAfterLeave: PropType<() => void>;
|
|
224
224
|
onAfterEnter: PropType<() => void>;
|
|
225
|
-
onEsc: PropType<() => void>;
|
|
225
|
+
onEsc: PropType<(e: KeyboardEvent) => void>;
|
|
226
226
|
}>>, {
|
|
227
227
|
show: boolean | undefined;
|
|
228
228
|
autoFocus: boolean;
|
|
@@ -323,6 +323,7 @@ declare const dropdownProps: {
|
|
|
323
323
|
readonly onClickoutside: PropType<(e: MouseEvent) => void>;
|
|
324
324
|
readonly 'onUpdate:show': PropType<MaybeArray<(value: boolean) => void>>;
|
|
325
325
|
readonly onUpdateShow: PropType<MaybeArray<(value: boolean) => void>>;
|
|
326
|
+
readonly internalDeactivateImmediately: BooleanConstructor;
|
|
326
327
|
readonly internalSyncTargetWithParent: BooleanConstructor;
|
|
327
328
|
readonly internalInheritedEventHandlers: {
|
|
328
329
|
type: PropType<import("../../popover/src/Popover").TriggerEventHandlers[]>;
|
|
@@ -646,6 +647,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
646
647
|
readonly onClickoutside: PropType<(e: MouseEvent) => void>;
|
|
647
648
|
readonly 'onUpdate:show': PropType<MaybeArray<(value: boolean) => void>>;
|
|
648
649
|
readonly onUpdateShow: PropType<MaybeArray<(value: boolean) => void>>;
|
|
650
|
+
readonly internalDeactivateImmediately: BooleanConstructor;
|
|
649
651
|
readonly internalSyncTargetWithParent: BooleanConstructor;
|
|
650
652
|
readonly internalInheritedEventHandlers: {
|
|
651
653
|
type: PropType<import("../../popover/src/Popover").TriggerEventHandlers[]>;
|
|
@@ -1160,6 +1162,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
1160
1162
|
readonly onClickoutside: PropType<(e: MouseEvent) => void>;
|
|
1161
1163
|
readonly 'onUpdate:show': PropType<MaybeArray<(value: boolean) => void>>;
|
|
1162
1164
|
readonly onUpdateShow: PropType<MaybeArray<(value: boolean) => void>>;
|
|
1165
|
+
readonly internalDeactivateImmediately: BooleanConstructor;
|
|
1163
1166
|
readonly internalSyncTargetWithParent: BooleanConstructor;
|
|
1164
1167
|
readonly internalInheritedEventHandlers: {
|
|
1165
1168
|
type: PropType<import("../../popover/src/Popover").TriggerEventHandlers[]>;
|
|
@@ -1199,6 +1202,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
1199
1202
|
readonly arrowPointToCenter: boolean;
|
|
1200
1203
|
readonly displayDirective: "show" | "if";
|
|
1201
1204
|
readonly keepAliveOnHover: boolean;
|
|
1205
|
+
readonly internalDeactivateImmediately: boolean;
|
|
1202
1206
|
readonly animated: boolean;
|
|
1203
1207
|
readonly internalTrapFocus: boolean;
|
|
1204
1208
|
readonly defaultShow: boolean;
|
|
@@ -87,7 +87,7 @@ export default defineComponent({
|
|
|
87
87
|
const nextValue = externalValue !== null && externalValue !== void 0 ? externalValue : inputValueRef.value;
|
|
88
88
|
if (nextValue) {
|
|
89
89
|
const tags = mergedValueRef.value.slice(0);
|
|
90
|
-
tags.push(nextValue);
|
|
90
|
+
tags.push(props.onCreate(nextValue));
|
|
91
91
|
doChange(tags);
|
|
92
92
|
}
|
|
93
93
|
showInputRef.value = false;
|
package/es/input/src/Input.d.ts
CHANGED
|
@@ -61,6 +61,7 @@ declare const inputProps: {
|
|
|
61
61
|
type: BooleanConstructor;
|
|
62
62
|
default: undefined;
|
|
63
63
|
};
|
|
64
|
+
allowInput: PropType<(value: string) => boolean>;
|
|
64
65
|
onMousedown: PropType<(e: MouseEvent) => void>;
|
|
65
66
|
onKeydown: PropType<(e: KeyboardEvent) => void>;
|
|
66
67
|
onKeyup: PropType<(e: KeyboardEvent) => void>;
|
|
@@ -330,6 +331,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
330
331
|
type: BooleanConstructor;
|
|
331
332
|
default: undefined;
|
|
332
333
|
};
|
|
334
|
+
allowInput: PropType<(value: string) => boolean>;
|
|
333
335
|
onMousedown: PropType<(e: MouseEvent) => void>;
|
|
334
336
|
onKeydown: PropType<(e: KeyboardEvent) => void>;
|
|
335
337
|
onKeyup: PropType<(e: KeyboardEvent) => void>;
|
|
@@ -587,7 +589,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
587
589
|
handleCompositionEnd: (e: CompositionEvent) => void;
|
|
588
590
|
handleInput: (e: InputEvent | CompositionEvent | Event, index?: 0 | 1, event?: string) => void;
|
|
589
591
|
handleInputBlur: (e: FocusEvent) => void;
|
|
590
|
-
handleInputFocus: (e: FocusEvent) => void;
|
|
592
|
+
handleInputFocus: (e: FocusEvent, index: number) => void;
|
|
591
593
|
handleWrapperBlur: (e: FocusEvent) => void;
|
|
592
594
|
handleWrapperFocus: (e: FocusEvent) => void;
|
|
593
595
|
handleMouseEnter: () => void;
|
|
@@ -598,7 +600,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
598
600
|
handleClear: (e: MouseEvent) => void;
|
|
599
601
|
handlePasswordToggleClick: () => void;
|
|
600
602
|
handlePasswordToggleMousedown: (e: MouseEvent) => void;
|
|
601
|
-
|
|
603
|
+
handleWrapperKeydown: (e: KeyboardEvent) => void;
|
|
602
604
|
handleTextAreaMirrorResize: () => void;
|
|
603
605
|
getTextareaScrollContainer: () => HTMLTextAreaElement | null;
|
|
604
606
|
mergedTheme: import("vue").ComputedRef<{
|
|
@@ -655,7 +657,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
655
657
|
scrollbarWidth: string;
|
|
656
658
|
scrollbarHeight: string;
|
|
657
659
|
scrollbarBorderRadius: string;
|
|
658
|
-
progressRailColor: string;
|
|
660
|
+
progressRailColor: string;
|
|
659
661
|
railColor: string;
|
|
660
662
|
popoverColor: string;
|
|
661
663
|
tableColor: string;
|
|
@@ -887,6 +889,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
887
889
|
type: BooleanConstructor;
|
|
888
890
|
default: undefined;
|
|
889
891
|
};
|
|
892
|
+
allowInput: PropType<(value: string) => boolean>;
|
|
890
893
|
onMousedown: PropType<(e: MouseEvent) => void>;
|
|
891
894
|
onKeydown: PropType<(e: KeyboardEvent) => void>;
|
|
892
895
|
onKeyup: PropType<(e: KeyboardEvent) => void>;
|
package/es/input/src/Input.js
CHANGED
|
@@ -4,15 +4,15 @@ import { getPadding } from 'seemly';
|
|
|
4
4
|
import { VResizeObserver } from 'vueuc';
|
|
5
5
|
import { off, on } from 'evtd';
|
|
6
6
|
import { EyeIcon, EyeOffIcon } from '../../_internal/icons';
|
|
7
|
+
import useRtl from '../../_mixins/use-rtl';
|
|
7
8
|
import { NBaseClear, NBaseIcon, NBaseSuffix, NScrollbar } from '../../_internal';
|
|
8
9
|
import { useTheme, useLocale, useFormItem, useConfig, useThemeClass } from '../../_mixins';
|
|
9
10
|
import { call, createKey, resolveSlot, resolveWrappedSlot, warnOnce } from '../../_utils';
|
|
10
11
|
import { inputLight } from '../styles';
|
|
11
12
|
import { inputInjectionKey } from './interface';
|
|
12
|
-
import {
|
|
13
|
+
import { isEmptyInputValue, useCursor } from './utils';
|
|
13
14
|
import WordCount from './WordCount';
|
|
14
15
|
import style from './styles/input.cssr';
|
|
15
|
-
import useRtl from '../../_mixins/use-rtl';
|
|
16
16
|
const inputProps = Object.assign(Object.assign({}, useTheme.props), { bordered: {
|
|
17
17
|
type: Boolean,
|
|
18
18
|
default: undefined
|
|
@@ -43,7 +43,7 @@ const inputProps = Object.assign(Object.assign({}, useTheme.props), { bordered:
|
|
|
43
43
|
}, showCount: Boolean, loading: {
|
|
44
44
|
type: Boolean,
|
|
45
45
|
default: undefined
|
|
46
|
-
}, onMousedown: Function, onKeydown: Function, onKeyup: Function, onInput: [Function, Array], onFocus: [Function, Array], onBlur: [Function, Array], onClick: [Function, Array], onChange: [Function, Array], onClear: [Function, Array], status: String, 'onUpdate:value': [Function, Array], onUpdateValue: [Function, Array],
|
|
46
|
+
}, allowInput: Function, onMousedown: Function, onKeydown: Function, onKeyup: Function, onInput: [Function, Array], onFocus: [Function, Array], onBlur: [Function, Array], onClick: [Function, Array], onChange: [Function, Array], onClear: [Function, Array], status: String, 'onUpdate:value': [Function, Array], onUpdateValue: [Function, Array],
|
|
47
47
|
/** private */
|
|
48
48
|
textDecoration: [String, Array], attrSize: {
|
|
49
49
|
type: Number,
|
|
@@ -71,6 +71,8 @@ export default defineComponent({
|
|
|
71
71
|
const inputMirrorElRef = ref(null);
|
|
72
72
|
const inputElRef = ref(null);
|
|
73
73
|
const inputEl2Ref = ref(null);
|
|
74
|
+
const currentFocusedInputRef = ref(null);
|
|
75
|
+
const focusedInputCursorControl = useCursor(currentFocusedInputRef);
|
|
74
76
|
const textareaScrollbarInstRef = ref(null);
|
|
75
77
|
// local
|
|
76
78
|
const { localeRef } = useLocale('Input');
|
|
@@ -111,8 +113,8 @@ export default defineComponent({
|
|
|
111
113
|
const { value: mergedValue } = mergedValueRef;
|
|
112
114
|
const { value: mergedPlaceholder } = mergedPlaceholderRef;
|
|
113
115
|
return (!isComposing &&
|
|
114
|
-
(
|
|
115
|
-
(Array.isArray(mergedValue) &&
|
|
116
|
+
(isEmptyInputValue(mergedValue) ||
|
|
117
|
+
(Array.isArray(mergedValue) && isEmptyInputValue(mergedValue[0]))) &&
|
|
116
118
|
mergedPlaceholder[0]);
|
|
117
119
|
});
|
|
118
120
|
const showPlaceholder2Ref = computed(() => {
|
|
@@ -121,8 +123,8 @@ export default defineComponent({
|
|
|
121
123
|
const { value: mergedPlaceholder } = mergedPlaceholderRef;
|
|
122
124
|
return (!isComposing &&
|
|
123
125
|
mergedPlaceholder[1] &&
|
|
124
|
-
(
|
|
125
|
-
(Array.isArray(mergedValue) &&
|
|
126
|
+
(isEmptyInputValue(mergedValue) ||
|
|
127
|
+
(Array.isArray(mergedValue) && isEmptyInputValue(mergedValue[1]))));
|
|
126
128
|
});
|
|
127
129
|
// focus
|
|
128
130
|
const mergedFocusRef = useMemo(() => {
|
|
@@ -320,24 +322,37 @@ export default defineComponent({
|
|
|
320
322
|
syncSource = targetValue;
|
|
321
323
|
if (isComposingRef.value)
|
|
322
324
|
return;
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
let { value } = mergedValueRef;
|
|
329
|
-
if (!Array.isArray(value)) {
|
|
330
|
-
value = ['', ''];
|
|
325
|
+
focusedInputCursorControl.recordCursor();
|
|
326
|
+
const isIncomingValueValid = allowInput(targetValue);
|
|
327
|
+
if (isIncomingValueValid) {
|
|
328
|
+
if (!props.pair) {
|
|
329
|
+
event === 'input' ? doUpdateValue(targetValue) : doChange(targetValue);
|
|
331
330
|
}
|
|
332
331
|
else {
|
|
333
|
-
value =
|
|
332
|
+
let { value } = mergedValueRef;
|
|
333
|
+
if (!Array.isArray(value)) {
|
|
334
|
+
value = ['', ''];
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
value = [value[0], value[1]];
|
|
338
|
+
}
|
|
339
|
+
value[index] = targetValue;
|
|
340
|
+
event === 'input' ? doUpdateValue(value) : doChange(value);
|
|
334
341
|
}
|
|
335
|
-
value[index] = changedValue;
|
|
336
|
-
event === 'input' ? doUpdateValue(value) : doChange(value);
|
|
337
342
|
}
|
|
338
343
|
// force update to sync input's view with value
|
|
339
344
|
// if not set, after input, input value won't sync with dom input value
|
|
340
345
|
vm.$forceUpdate();
|
|
346
|
+
if (!isIncomingValueValid) {
|
|
347
|
+
void nextTick(focusedInputCursorControl.restoreCursor);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
function allowInput(value) {
|
|
351
|
+
const { allowInput } = props;
|
|
352
|
+
if (typeof allowInput === 'function') {
|
|
353
|
+
return allowInput(value);
|
|
354
|
+
}
|
|
355
|
+
return true;
|
|
341
356
|
}
|
|
342
357
|
function handleInputBlur(e) {
|
|
343
358
|
doUpdateValueBlur(e);
|
|
@@ -351,13 +366,23 @@ export default defineComponent({
|
|
|
351
366
|
activatedRef.value = false;
|
|
352
367
|
}
|
|
353
368
|
dealWithEvent(e, 'blur');
|
|
369
|
+
currentFocusedInputRef.value = null;
|
|
354
370
|
}
|
|
355
|
-
function handleInputFocus(e) {
|
|
371
|
+
function handleInputFocus(e, index) {
|
|
356
372
|
doUpdateValueFocus(e);
|
|
357
373
|
focusedRef.value = true;
|
|
358
374
|
activatedRef.value = true;
|
|
359
375
|
doActivate();
|
|
360
376
|
dealWithEvent(e, 'focus');
|
|
377
|
+
if (index === 0) {
|
|
378
|
+
currentFocusedInputRef.value = inputElRef.value;
|
|
379
|
+
}
|
|
380
|
+
else if (index === 1) {
|
|
381
|
+
currentFocusedInputRef.value = inputEl2Ref.value;
|
|
382
|
+
}
|
|
383
|
+
else if (index === 2) {
|
|
384
|
+
currentFocusedInputRef.value = textareaElRef.value;
|
|
385
|
+
}
|
|
361
386
|
}
|
|
362
387
|
function handleWrapperBlur(e) {
|
|
363
388
|
if (props.passivelyActivated) {
|
|
@@ -477,25 +502,25 @@ export default defineComponent({
|
|
|
477
502
|
};
|
|
478
503
|
on('mouseup', document, hidePassword);
|
|
479
504
|
}
|
|
480
|
-
function
|
|
505
|
+
function handleWrapperKeydown(e) {
|
|
481
506
|
var _a;
|
|
482
507
|
(_a = props.onKeydown) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
483
508
|
switch (e.key) {
|
|
484
509
|
case 'Escape':
|
|
485
|
-
|
|
510
|
+
handleWrapperKeydownEsc();
|
|
486
511
|
break;
|
|
487
512
|
case 'Enter':
|
|
488
|
-
|
|
513
|
+
handleWrapperKeydownEnter(e);
|
|
489
514
|
break;
|
|
490
515
|
}
|
|
491
516
|
}
|
|
492
|
-
function
|
|
517
|
+
function handleWrapperKeydownEnter(e) {
|
|
493
518
|
var _a, _b;
|
|
494
519
|
if (props.passivelyActivated) {
|
|
495
520
|
const { value: focused } = activatedRef;
|
|
496
521
|
if (focused) {
|
|
497
522
|
if (props.internalDeactivateOnEnter) {
|
|
498
|
-
|
|
523
|
+
handleWrapperKeydownEsc();
|
|
499
524
|
}
|
|
500
525
|
return;
|
|
501
526
|
}
|
|
@@ -508,7 +533,7 @@ export default defineComponent({
|
|
|
508
533
|
}
|
|
509
534
|
}
|
|
510
535
|
}
|
|
511
|
-
function
|
|
536
|
+
function handleWrapperKeydownEsc() {
|
|
512
537
|
if (props.passivelyActivated) {
|
|
513
538
|
activatedRef.value = false;
|
|
514
539
|
void nextTick(() => {
|
|
@@ -553,7 +578,7 @@ export default defineComponent({
|
|
|
553
578
|
const { value: wrapperEl } = wrapperElRef;
|
|
554
579
|
if ((wrapperEl === null || wrapperEl === void 0 ? void 0 : wrapperEl.contains(document.activeElement)) &&
|
|
555
580
|
wrapperEl !== document.activeElement) {
|
|
556
|
-
|
|
581
|
+
handleWrapperKeydownEsc();
|
|
557
582
|
}
|
|
558
583
|
}
|
|
559
584
|
function syncMirror(value) {
|
|
@@ -726,7 +751,7 @@ export default defineComponent({
|
|
|
726
751
|
handleClear,
|
|
727
752
|
handlePasswordToggleClick,
|
|
728
753
|
handlePasswordToggleMousedown,
|
|
729
|
-
|
|
754
|
+
handleWrapperKeydown,
|
|
730
755
|
handleTextAreaMirrorResize, getTextareaScrollContainer: () => {
|
|
731
756
|
return textareaElRef.value;
|
|
732
757
|
}, mergedTheme: themeRef, cssVars: inlineThemeDisabled ? undefined : cssVarsRef, themeClass: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass, onRender: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.onRender });
|
|
@@ -753,7 +778,7 @@ export default defineComponent({
|
|
|
753
778
|
}
|
|
754
779
|
], style: this.cssVars, tabindex: !this.mergedDisabled && this.passivelyActivated && !this.activated
|
|
755
780
|
? 0
|
|
756
|
-
: undefined, onFocus: this.handleWrapperFocus, onBlur: this.handleWrapperBlur, onClick: this.handleClick, onMousedown: this.handleMouseDown, onMouseenter: this.handleMouseEnter, onMouseleave: this.handleMouseLeave, onCompositionstart: this.handleCompositionStart, onCompositionend: this.handleCompositionEnd, onKeyup: this.onKeyup, onKeydown: this.
|
|
781
|
+
: undefined, onFocus: this.handleWrapperFocus, onBlur: this.handleWrapperBlur, onClick: this.handleClick, onMousedown: this.handleMouseDown, onMouseenter: this.handleMouseEnter, onMouseleave: this.handleMouseLeave, onCompositionstart: this.handleCompositionStart, onCompositionend: this.handleCompositionEnd, onKeyup: this.onKeyup, onKeydown: this.handleWrapperKeydown },
|
|
757
782
|
h("div", { class: `${mergedClsPrefix}-input-wrapper` },
|
|
758
783
|
resolveWrappedSlot($slots.prefix, (children) => children && (h("div", { class: `${mergedClsPrefix}-input__prefix` }, children))),
|
|
759
784
|
this.type === 'textarea' ? (h(NScrollbar, { ref: "textareaScrollbarInstRef", class: `${mergedClsPrefix}-input__textarea`, container: this.getTextareaScrollContainer, triggerDisplayManually: true, useUnifiedContainer: true }, {
|
|
@@ -775,7 +800,7 @@ export default defineComponent({
|
|
|
775
800
|
this.textDecorationStyle[0],
|
|
776
801
|
(_b = this.inputProps) === null || _b === void 0 ? void 0 : _b.style,
|
|
777
802
|
scrollContainerWidthStyle
|
|
778
|
-
], onBlur: this.handleInputBlur, onFocus: this.handleInputFocus, onInput: this.handleInput, onChange: this.handleChange, onScroll: this.handleTextAreaScroll })),
|
|
803
|
+
], onBlur: this.handleInputBlur, onFocus: (e) => this.handleInputFocus(e, 2), onInput: this.handleInput, onChange: this.handleChange, onScroll: this.handleTextAreaScroll })),
|
|
779
804
|
this.showPlaceholder1 ? (h("div", { class: `${mergedClsPrefix}-input__placeholder`, style: [
|
|
780
805
|
this.placeholderStyle,
|
|
781
806
|
scrollContainerWidthStyle
|
|
@@ -797,7 +822,7 @@ export default defineComponent({
|
|
|
797
822
|
(_b = this.inputProps) === null || _b === void 0 ? void 0 : _b.style
|
|
798
823
|
], tabindex: this.passivelyActivated && !this.activated ? -1 : undefined, placeholder: this.mergedPlaceholder[0], disabled: this.mergedDisabled, maxlength: this.maxlength, minlength: this.minlength, value: Array.isArray(this.mergedValue)
|
|
799
824
|
? this.mergedValue[0]
|
|
800
|
-
: this.mergedValue, readonly: this.readonly, autofocus: this.autofocus, size: this.attrSize, onBlur: this.handleInputBlur, onFocus: this.handleInputFocus, onInput: (e) => this.handleInput(e, 0), onChange: (e) => this.handleChange(e, 0) })),
|
|
825
|
+
: this.mergedValue, readonly: this.readonly, autofocus: this.autofocus, size: this.attrSize, onBlur: this.handleInputBlur, onFocus: (e) => this.handleInputFocus(e, 0), onInput: (e) => this.handleInput(e, 0), onChange: (e) => this.handleChange(e, 0) })),
|
|
801
826
|
this.showPlaceholder1 ? (h("div", { class: `${mergedClsPrefix}-input__placeholder` },
|
|
802
827
|
h("span", null, this.mergedPlaceholder[0]))) : null,
|
|
803
828
|
this.autosize ? (h("div", { class: `${mergedClsPrefix}-input__input-mirror`, key: "mirror", ref: "inputMirrorElRef" }, "\u00A0")) : null)),
|
|
@@ -834,7 +859,7 @@ export default defineComponent({
|
|
|
834
859
|
h("div", { class: `${mergedClsPrefix}-input__input` },
|
|
835
860
|
h("input", { ref: "inputEl2Ref", type: this.type, class: `${mergedClsPrefix}-input__input-el`, tabindex: this.passivelyActivated && !this.activated ? -1 : undefined, placeholder: this.mergedPlaceholder[1], disabled: this.mergedDisabled, maxlength: this.maxlength, minlength: this.minlength, value: Array.isArray(this.mergedValue)
|
|
836
861
|
? this.mergedValue[1]
|
|
837
|
-
: undefined, readonly: this.readonly, style: this.textDecorationStyle[1], onBlur: this.handleInputBlur, onFocus: this.handleInputFocus, onInput: (e) => this.handleInput(e, 1), onChange: (e) => this.handleChange(e, 1) }),
|
|
862
|
+
: undefined, readonly: this.readonly, style: this.textDecorationStyle[1], onBlur: this.handleInputBlur, onFocus: (e) => this.handleInputFocus(e, 1), onInput: (e) => this.handleInput(e, 1), onChange: (e) => this.handleChange(e, 1) }),
|
|
838
863
|
this.showPlaceholder2 ? (h("div", { class: `${mergedClsPrefix}-input__placeholder` },
|
|
839
864
|
h("span", null, this.mergedPlaceholder[1]))) : null),
|
|
840
865
|
resolveWrappedSlot($slots.suffix, (children) => {
|
package/es/input/src/utils.d.ts
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
|
+
import type { Ref } from 'vue';
|
|
1
2
|
export declare function len(s: string): number;
|
|
2
|
-
export declare function
|
|
3
|
+
export declare function isEmptyInputValue(value: unknown): boolean;
|
|
4
|
+
export interface UseCursorControl {
|
|
5
|
+
recordCursor: () => void;
|
|
6
|
+
restoreCursor: () => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function useCursor(inputElRef: Ref<HTMLInputElement | HTMLTextAreaElement | null>): UseCursorControl;
|
package/es/input/src/utils.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ref, watch } from 'vue';
|
|
1
2
|
export function len(s) {
|
|
2
3
|
let count = 0;
|
|
3
4
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -6,6 +7,60 @@ export function len(s) {
|
|
|
6
7
|
}
|
|
7
8
|
return count;
|
|
8
9
|
}
|
|
9
|
-
export function
|
|
10
|
-
return
|
|
10
|
+
export function isEmptyInputValue(value) {
|
|
11
|
+
return value === '' || value == null;
|
|
12
|
+
}
|
|
13
|
+
export function useCursor(inputElRef) {
|
|
14
|
+
const selectionRef = ref(null);
|
|
15
|
+
function recordCursor() {
|
|
16
|
+
const { value: input } = inputElRef;
|
|
17
|
+
if (!input || !input.focus) {
|
|
18
|
+
reset();
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const { selectionStart, selectionEnd, value } = input;
|
|
22
|
+
if (selectionStart == null || selectionEnd == null) {
|
|
23
|
+
reset();
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
selectionRef.value = {
|
|
27
|
+
start: selectionStart,
|
|
28
|
+
end: selectionEnd,
|
|
29
|
+
beforeText: value.slice(0, selectionStart),
|
|
30
|
+
afterText: value.slice(selectionEnd)
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function restoreCursor() {
|
|
34
|
+
var _a;
|
|
35
|
+
const { value: selection } = selectionRef;
|
|
36
|
+
const { value: inputEl } = inputElRef;
|
|
37
|
+
if (!selection || !inputEl) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const { value } = inputEl;
|
|
41
|
+
const { start, beforeText, afterText } = selection;
|
|
42
|
+
let startPos = value.length;
|
|
43
|
+
if (value.endsWith(afterText)) {
|
|
44
|
+
startPos = value.length - afterText.length;
|
|
45
|
+
}
|
|
46
|
+
else if (value.startsWith(beforeText)) {
|
|
47
|
+
startPos = beforeText.length;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
const beforeLastChar = beforeText[start - 1];
|
|
51
|
+
const newIndex = value.indexOf(beforeLastChar, start - 1);
|
|
52
|
+
if (newIndex !== -1) {
|
|
53
|
+
startPos = newIndex + 1;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
(_a = inputEl.setSelectionRange) === null || _a === void 0 ? void 0 : _a.call(inputEl, startPos, startPos);
|
|
57
|
+
}
|
|
58
|
+
function reset() {
|
|
59
|
+
selectionRef.value = null;
|
|
60
|
+
}
|
|
61
|
+
watch(inputElRef, reset);
|
|
62
|
+
return {
|
|
63
|
+
recordCursor,
|
|
64
|
+
restoreCursor
|
|
65
|
+
};
|
|
11
66
|
}
|