naive-ui 2.30.3 → 2.30.6
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 +1829 -1088
- package/dist/index.prod.js +2 -2
- package/es/_internal/scrollbar/src/Scrollbar.js +5 -18
- 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 +7 -5
- 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/dom/index.d.ts +1 -0
- package/es/_utils/dom/index.js +1 -0
- package/es/_utils/dom/is-document.d.ts +1 -0
- package/es/_utils/dom/is-document.js +3 -0
- package/es/_utils/event/index.d.ts +2 -0
- package/es/_utils/event/index.js +7 -0
- package/es/_utils/index.d.ts +3 -1
- package/es/_utils/index.js +3 -1
- package/es/_utils/vue/index.d.ts +3 -0
- package/es/_utils/vue/index.js +3 -0
- package/es/_utils/vue/is-node-v-show-false.d.ts +2 -0
- package/es/_utils/vue/is-node-v-show-false.js +6 -0
- package/es/_utils/vue/merge-handlers.d.ts +1 -0
- package/es/_utils/vue/merge-handlers.js +15 -0
- package/es/{_internal/scrollbar/src/Wrapper.d.ts → _utils/vue/wrapper.d.ts} +0 -0
- package/es/{_internal/scrollbar/src/Wrapper.js → _utils/vue/wrapper.js} +0 -0
- package/es/back-top/src/BackTop.d.ts +1 -1
- package/es/back-top/src/BackTop.js +24 -31
- 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/color-picker/src/ColorInputUnit.js +1 -1
- package/es/data-table/src/DataTable.d.ts +792 -2
- package/es/data-table/src/DataTable.js +10 -5
- 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 +144 -0
- package/es/data-table/src/TableParts/Body.js +15 -8
- package/es/data-table/src/TableParts/Cell.d.ts +295 -1
- package/es/data-table/src/TableParts/Cell.js +19 -6
- 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 +14 -7
- package/es/data-table/src/styles/index.cssr.js +7 -2
- package/es/data-table/src/use-check.js +11 -3
- 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/grid/src/Grid.d.ts +3 -0
- package/es/grid/src/Grid.js +47 -9
- package/es/grid/src/GridItem.js +2 -1
- package/es/image/src/Image.d.ts +10 -0
- package/es/image/src/Image.js +42 -8
- package/es/image/src/utils.d.ts +11 -0
- package/es/image/src/utils.js +81 -0
- package/es/input/src/Input.d.ts +6 -3
- package/es/input/src/Input.js +56 -31
- package/es/input/src/styles/input-group-label.cssr.js +2 -0
- 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 +15 -20
- package/es/modal/src/BodyWrapper.js +38 -33
- package/es/modal/src/Modal.js +14 -9
- 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/space/src/Space.d.ts +26 -0
- package/es/space/src/Space.js +53 -43
- package/es/time-picker/src/TimePicker.d.ts +2 -1
- package/es/time-picker/src/TimePicker.js +18 -8
- package/es/tooltip/index.d.ts +1 -1
- 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 +6 -19
- 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 +6 -4
- 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/dom/index.d.ts +1 -0
- package/lib/_utils/dom/index.js +5 -0
- package/lib/_utils/dom/is-document.d.ts +1 -0
- package/lib/_utils/dom/is-document.js +7 -0
- package/lib/_utils/event/index.d.ts +2 -0
- package/lib/_utils/event/index.js +12 -0
- package/lib/_utils/index.d.ts +3 -1
- package/lib/_utils/index.js +8 -1
- package/lib/_utils/vue/index.d.ts +3 -0
- package/lib/_utils/vue/index.js +7 -1
- package/lib/_utils/vue/is-node-v-show-false.d.ts +2 -0
- package/lib/_utils/vue/is-node-v-show-false.js +10 -0
- package/lib/_utils/vue/merge-handlers.d.ts +1 -0
- package/lib/_utils/vue/merge-handlers.js +19 -0
- package/lib/{_internal/scrollbar/src/Wrapper.d.ts → _utils/vue/wrapper.d.ts} +0 -0
- package/lib/{_internal/scrollbar/src/Wrapper.js → _utils/vue/wrapper.js} +0 -0
- package/lib/back-top/src/BackTop.d.ts +1 -1
- package/lib/back-top/src/BackTop.js +23 -30
- 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/color-picker/src/ColorInputUnit.js +1 -1
- package/lib/data-table/src/DataTable.d.ts +792 -2
- package/lib/data-table/src/DataTable.js +10 -5
- 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 +144 -0
- package/lib/data-table/src/TableParts/Body.js +15 -8
- package/lib/data-table/src/TableParts/Cell.d.ts +295 -1
- package/lib/data-table/src/TableParts/Cell.js +19 -6
- 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 +14 -7
- package/lib/data-table/src/styles/index.cssr.js +7 -2
- package/lib/data-table/src/use-check.js +11 -3
- 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/grid/src/Grid.d.ts +3 -0
- package/lib/grid/src/Grid.js +45 -7
- package/lib/grid/src/GridItem.js +2 -1
- package/lib/image/src/Image.d.ts +10 -0
- package/lib/image/src/Image.js +41 -7
- package/lib/image/src/utils.d.ts +11 -0
- package/lib/image/src/utils.js +86 -0
- package/lib/input/src/Input.d.ts +6 -3
- package/lib/input/src/Input.js +55 -30
- package/lib/input/src/styles/input-group-label.cssr.js +2 -0
- 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 +15 -20
- package/lib/modal/src/BodyWrapper.js +38 -33
- package/lib/modal/src/Modal.js +13 -8
- 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/space/src/Space.d.ts +26 -0
- package/lib/space/src/Space.js +53 -43
- package/lib/time-picker/src/TimePicker.d.ts +2 -1
- package/lib/time-picker/src/TimePicker.js +17 -7
- package/lib/tooltip/index.d.ts +1 -1
- 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/volar.d.ts +0 -1
- package/web-types.json +73 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { h, ref, defineComponent, computed, onMounted, onBeforeUnmount, mergeProps, Transition, watchEffect
|
|
1
|
+
import { h, ref, defineComponent, computed, onMounted, onBeforeUnmount, mergeProps, Transition, watchEffect } from 'vue';
|
|
2
2
|
import { on, off } from 'evtd';
|
|
3
3
|
import { VResizeObserver } from 'vueuc';
|
|
4
4
|
import { useIsIos } from 'vooks';
|
|
5
5
|
import { useConfig, useTheme, useThemeClass } from '../../../_mixins';
|
|
6
|
+
import { useReactivated, Wrapper } from '../../../_utils';
|
|
6
7
|
import { scrollbarLight } from '../styles';
|
|
7
|
-
import { Wrapper } from './Wrapper';
|
|
8
8
|
import style from './styles/index.cssr';
|
|
9
9
|
const scrollbarProps = Object.assign(Object.assign({}, useTheme.props), { size: {
|
|
10
10
|
type: Number,
|
|
@@ -159,14 +159,7 @@ const Scrollbar = defineComponent({
|
|
|
159
159
|
return content();
|
|
160
160
|
return contentRef.value;
|
|
161
161
|
});
|
|
162
|
-
|
|
163
|
-
let activateStateInitialized = false;
|
|
164
|
-
onActivated(() => {
|
|
165
|
-
isDeactivated = false;
|
|
166
|
-
if (!activateStateInitialized) {
|
|
167
|
-
activateStateInitialized = true;
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
162
|
+
const activateState = useReactivated(() => {
|
|
170
163
|
// Only restore for builtin container & content
|
|
171
164
|
if (!props.container) {
|
|
172
165
|
// remount
|
|
@@ -176,20 +169,14 @@ const Scrollbar = defineComponent({
|
|
|
176
169
|
});
|
|
177
170
|
}
|
|
178
171
|
});
|
|
179
|
-
onDeactivated(() => {
|
|
180
|
-
isDeactivated = true;
|
|
181
|
-
if (!activateStateInitialized) {
|
|
182
|
-
activateStateInitialized = true;
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
172
|
// methods
|
|
186
173
|
const handleContentResize = () => {
|
|
187
|
-
if (isDeactivated)
|
|
174
|
+
if (activateState.isDeactivated)
|
|
188
175
|
return;
|
|
189
176
|
sync();
|
|
190
177
|
};
|
|
191
178
|
const handleContainerResize = (e) => {
|
|
192
|
-
if (isDeactivated)
|
|
179
|
+
if (activateState.isDeactivated)
|
|
193
180
|
return;
|
|
194
181
|
const { onResize } = props;
|
|
195
182
|
if (onResize)
|
|
@@ -13,6 +13,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
13
13
|
};
|
|
14
14
|
}, {
|
|
15
15
|
labelField: Ref<string>;
|
|
16
|
+
nodeProps: Ref<import("./interface").NodeProps | undefined>;
|
|
16
17
|
renderLabel: Ref<RenderLabelImpl | undefined>;
|
|
17
18
|
renderOption: Ref<RenderOptionImpl | undefined>;
|
|
18
19
|
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
@@ -14,21 +14,23 @@ export default defineComponent({
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
setup() {
|
|
17
|
-
const { renderLabelRef, renderOptionRef, labelFieldRef
|
|
17
|
+
const { renderLabelRef, renderOptionRef, labelFieldRef, nodePropsRef
|
|
18
18
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
19
19
|
} = inject(internalSelectionMenuInjectionKey);
|
|
20
20
|
return {
|
|
21
21
|
labelField: labelFieldRef,
|
|
22
|
+
nodeProps: nodePropsRef,
|
|
22
23
|
renderLabel: renderLabelRef,
|
|
23
24
|
renderOption: renderOptionRef
|
|
24
25
|
};
|
|
25
26
|
},
|
|
26
27
|
render() {
|
|
27
|
-
const { clsPrefix, renderLabel, renderOption, tmNode: { rawNode } } = this;
|
|
28
|
+
const { clsPrefix, renderLabel, renderOption, nodeProps, tmNode: { rawNode } } = this;
|
|
29
|
+
const attrs = nodeProps === null || nodeProps === void 0 ? void 0 : nodeProps(rawNode);
|
|
28
30
|
const children = renderLabel
|
|
29
31
|
? renderLabel(rawNode, false)
|
|
30
32
|
: render(rawNode[this.labelField], rawNode, false);
|
|
31
|
-
const node = (h("div", { class: `${clsPrefix}-base-select-group-header
|
|
33
|
+
const node = (h("div", Object.assign({}, attrs, { class: [`${clsPrefix}-base-select-group-header`, attrs === null || attrs === void 0 ? void 0 : attrs.class] }), children));
|
|
32
34
|
return rawNode.render
|
|
33
35
|
? rawNode.render({ node, option: rawNode })
|
|
34
36
|
: renderOption
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PropType } from 'vue';
|
|
2
2
|
import { TreeNode } from 'treemate';
|
|
3
3
|
import type { SelectOption, SelectGroupOption, SelectIgnoredOption, Value, SelectTreeMate } from '../../../select/src/interface';
|
|
4
|
-
import type { RenderLabel, Size, RenderOption } from './interface';
|
|
4
|
+
import type { RenderLabel, Size, RenderOption, NodeProps } from './interface';
|
|
5
5
|
declare const _default: import("vue").DefineComponent<{
|
|
6
6
|
clsPrefix: {
|
|
7
7
|
type: StringConstructor;
|
|
@@ -24,7 +24,6 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
24
24
|
type: PropType<Value | null>;
|
|
25
25
|
default: null;
|
|
26
26
|
};
|
|
27
|
-
width: (StringConstructor | NumberConstructor)[];
|
|
28
27
|
autoPending: BooleanConstructor;
|
|
29
28
|
virtualScroll: {
|
|
30
29
|
type: BooleanConstructor;
|
|
@@ -46,6 +45,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
46
45
|
focusable: BooleanConstructor;
|
|
47
46
|
renderLabel: PropType<RenderLabel>;
|
|
48
47
|
renderOption: PropType<RenderOption>;
|
|
48
|
+
nodeProps: PropType<NodeProps>;
|
|
49
49
|
showCheckmark: {
|
|
50
50
|
type: BooleanConstructor;
|
|
51
51
|
default: boolean;
|
|
@@ -483,7 +483,6 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
483
483
|
type: PropType<Value | null>;
|
|
484
484
|
default: null;
|
|
485
485
|
};
|
|
486
|
-
width: (StringConstructor | NumberConstructor)[];
|
|
487
486
|
autoPending: BooleanConstructor;
|
|
488
487
|
virtualScroll: {
|
|
489
488
|
type: BooleanConstructor;
|
|
@@ -505,6 +504,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
505
504
|
focusable: BooleanConstructor;
|
|
506
505
|
renderLabel: PropType<RenderLabel>;
|
|
507
506
|
renderOption: PropType<RenderOption>;
|
|
507
|
+
nodeProps: PropType<NodeProps>;
|
|
508
508
|
showCheckmark: {
|
|
509
509
|
type: BooleanConstructor;
|
|
510
510
|
default: boolean;
|
|
@@ -4,7 +4,7 @@ import { VirtualList } from 'vueuc';
|
|
|
4
4
|
import { depx, getPadding, happensIn } from 'seemly';
|
|
5
5
|
import { NEmpty } from '../../../empty';
|
|
6
6
|
import { NScrollbar } from '../../scrollbar';
|
|
7
|
-
import {
|
|
7
|
+
import { resolveSlot, resolveWrappedSlot, useOnResize } from '../../../_utils';
|
|
8
8
|
import { createKey } from '../../../_utils/cssr';
|
|
9
9
|
import { useThemeClass, useTheme } from '../../../_mixins';
|
|
10
10
|
import NInternalLoading from '../../loading';
|
|
@@ -31,7 +31,7 @@ export default defineComponent({
|
|
|
31
31
|
}, value: {
|
|
32
32
|
type: [String, Number, Array],
|
|
33
33
|
default: null
|
|
34
|
-
},
|
|
34
|
+
}, autoPending: Boolean, virtualScroll: {
|
|
35
35
|
type: Boolean,
|
|
36
36
|
default: true
|
|
37
37
|
},
|
|
@@ -45,7 +45,7 @@ export default defineComponent({
|
|
|
45
45
|
}, valueField: {
|
|
46
46
|
type: String,
|
|
47
47
|
default: 'value'
|
|
48
|
-
}, loading: Boolean, focusable: Boolean, renderLabel: Function, renderOption: Function, showCheckmark: { type: Boolean, default: true }, onMousedown: Function, onScroll: Function, onFocus: Function, onBlur: Function, onKeyup: Function, onKeydown: Function, onTabOut: Function, onMouseenter: Function, onMouseleave: Function, onResize: Function, resetMenuOnOptionsChange: {
|
|
48
|
+
}, loading: Boolean, focusable: Boolean, renderLabel: Function, renderOption: Function, nodeProps: Function, showCheckmark: { type: Boolean, default: true }, onMousedown: Function, onScroll: Function, onFocus: Function, onBlur: Function, onKeyup: Function, onKeydown: Function, onTabOut: Function, onMouseenter: Function, onMouseleave: Function, onResize: Function, resetMenuOnOptionsChange: {
|
|
49
49
|
type: Boolean,
|
|
50
50
|
default: true
|
|
51
51
|
}, inlineThemeDisabled: Boolean,
|
|
@@ -242,12 +242,13 @@ export default defineComponent({
|
|
|
242
242
|
handleOptionMouseEnter,
|
|
243
243
|
handleOptionClick,
|
|
244
244
|
valueSetRef,
|
|
245
|
+
pendingTmNodeRef: pendingNodeRef,
|
|
246
|
+
nodePropsRef: toRef(props, 'nodeProps'),
|
|
245
247
|
showCheckmarkRef: toRef(props, 'showCheckmark'),
|
|
246
248
|
multipleRef: toRef(props, 'multiple'),
|
|
247
249
|
valueRef: toRef(props, 'value'),
|
|
248
250
|
renderLabelRef: toRef(props, 'renderLabel'),
|
|
249
251
|
renderOptionRef: toRef(props, 'renderOption'),
|
|
250
|
-
pendingTmNodeRef: pendingNodeRef,
|
|
251
252
|
labelFieldRef: toRef(props, 'labelField'),
|
|
252
253
|
valueFieldRef: toRef(props, 'valueField')
|
|
253
254
|
});
|
|
@@ -322,10 +323,7 @@ export default defineComponent({
|
|
|
322
323
|
`${clsPrefix}-base-select-menu`,
|
|
323
324
|
themeClass,
|
|
324
325
|
this.multiple && `${clsPrefix}-base-select-menu--multiple`
|
|
325
|
-
], style:
|
|
326
|
-
{ width: formatLength(this.width) },
|
|
327
|
-
this.cssVars
|
|
328
|
-
], onFocusin: this.handleFocusin, onFocusout: this.handleFocusout, onKeyup: this.handleKeyUp, onKeydown: this.handleKeyDown, onMousedown: this.handleMouseDown, onMouseenter: this.onMouseenter, onMouseleave: this.onMouseleave },
|
|
326
|
+
], style: this.cssVars, onFocusin: this.handleFocusin, onFocusout: this.handleFocusout, onKeyup: this.handleKeyUp, onKeydown: this.handleKeyDown, onMousedown: this.handleMouseDown, onMouseenter: this.onMouseenter, onMouseleave: this.onMouseleave },
|
|
329
327
|
this.loading ? (h("div", { class: `${clsPrefix}-base-select-menu__loading` },
|
|
330
328
|
h(NInternalLoading, { clsPrefix: clsPrefix, strokeWidth: 20 }))) : !this.empty ? (h(NScrollbar, { ref: "scrollbarRef", theme: mergedTheme.peers.Scrollbar, themeOverrides: mergedTheme.peerOverrides.Scrollbar, scrollable: this.scrollable, container: virtualScroll ? this.virtualListContainer : undefined, content: virtualScroll ? this.virtualListContent : undefined, onScroll: virtualScroll ? undefined : this.doScroll }, {
|
|
331
329
|
default: () => {
|
|
@@ -15,6 +15,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
15
15
|
multiple: Ref<boolean>;
|
|
16
16
|
isGrouped: import("vue").ComputedRef<boolean | null>;
|
|
17
17
|
showCheckmark: Ref<boolean>;
|
|
18
|
+
nodeProps: Ref<import("./interface").NodeProps | undefined>;
|
|
18
19
|
isPending: import("vue").ComputedRef<boolean>;
|
|
19
20
|
isSelected: import("vue").ComputedRef<boolean>;
|
|
20
21
|
labelField: Ref<string>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { h, inject, defineComponent, Transition } from 'vue';
|
|
2
2
|
import { useMemo } from 'vooks';
|
|
3
|
-
import { render } from '../../../_utils';
|
|
3
|
+
import { render, mergeEventHandlers } from '../../../_utils';
|
|
4
4
|
import { CheckmarkIcon } from '../../icons';
|
|
5
5
|
import { NBaseIcon } from '../../icon';
|
|
6
6
|
import { internalSelectionMenuInjectionKey } from './interface';
|
|
@@ -25,7 +25,7 @@ export default defineComponent({
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
setup(props) {
|
|
28
|
-
const { valueRef, pendingTmNodeRef, multipleRef, valueSetRef, renderLabelRef, renderOptionRef, labelFieldRef, valueFieldRef, showCheckmarkRef, handleOptionClick, handleOptionMouseEnter
|
|
28
|
+
const { valueRef, pendingTmNodeRef, multipleRef, valueSetRef, renderLabelRef, renderOptionRef, labelFieldRef, valueFieldRef, showCheckmarkRef, nodePropsRef, handleOptionClick, handleOptionMouseEnter
|
|
29
29
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
30
30
|
} = inject(internalSelectionMenuInjectionKey);
|
|
31
31
|
const isPendingRef = useMemo(() => {
|
|
@@ -61,6 +61,7 @@ export default defineComponent({
|
|
|
61
61
|
return parent && parent.rawNode.type === 'group';
|
|
62
62
|
}),
|
|
63
63
|
showCheckmark: showCheckmarkRef,
|
|
64
|
+
nodeProps: nodePropsRef,
|
|
64
65
|
isPending: isPendingRef,
|
|
65
66
|
isSelected: useMemo(() => {
|
|
66
67
|
const { value } = valueRef;
|
|
@@ -85,7 +86,7 @@ export default defineComponent({
|
|
|
85
86
|
};
|
|
86
87
|
},
|
|
87
88
|
render() {
|
|
88
|
-
const { clsPrefix, tmNode: { rawNode }, isSelected, isPending, isGrouped, showCheckmark, renderOption, renderLabel, handleClick, handleMouseEnter, handleMouseMove } = this;
|
|
89
|
+
const { clsPrefix, tmNode: { rawNode }, isSelected, isPending, isGrouped, showCheckmark, nodeProps, renderOption, renderLabel, handleClick, handleMouseEnter, handleMouseMove } = this;
|
|
89
90
|
const checkmark = renderCheckMark(isSelected, clsPrefix);
|
|
90
91
|
const children = renderLabel
|
|
91
92
|
? [renderLabel(rawNode, isSelected), showCheckmark && checkmark]
|
|
@@ -93,9 +94,11 @@ export default defineComponent({
|
|
|
93
94
|
render(rawNode[this.labelField], rawNode, isSelected),
|
|
94
95
|
showCheckmark && checkmark
|
|
95
96
|
];
|
|
96
|
-
const
|
|
97
|
+
const attrs = nodeProps === null || nodeProps === void 0 ? void 0 : nodeProps(rawNode);
|
|
98
|
+
const node = (h("div", Object.assign({}, attrs, { class: [
|
|
97
99
|
`${clsPrefix}-base-select-option`,
|
|
98
100
|
rawNode.class,
|
|
101
|
+
attrs === null || attrs === void 0 ? void 0 : attrs.class,
|
|
99
102
|
{
|
|
100
103
|
[`${clsPrefix}-base-select-option--disabled`]: rawNode.disabled,
|
|
101
104
|
[`${clsPrefix}-base-select-option--selected`]: isSelected,
|
|
@@ -103,7 +106,10 @@ export default defineComponent({
|
|
|
103
106
|
[`${clsPrefix}-base-select-option--pending`]: isPending,
|
|
104
107
|
[`${clsPrefix}-base-select-option--show-checkmark`]: showCheckmark
|
|
105
108
|
}
|
|
106
|
-
], style: rawNode.style, onClick: handleClick,
|
|
109
|
+
], style: [(attrs === null || attrs === void 0 ? void 0 : attrs.style) || '', rawNode.style || ''], onClick: mergeEventHandlers([handleClick, attrs === null || attrs === void 0 ? void 0 : attrs.onClick]), onMouseenter: mergeEventHandlers([
|
|
110
|
+
handleMouseEnter,
|
|
111
|
+
attrs === null || attrs === void 0 ? void 0 : attrs.onMouseenter
|
|
112
|
+
]), onMousemove: mergeEventHandlers([handleMouseMove, attrs === null || attrs === void 0 ? void 0 : attrs.onMousemove]) }),
|
|
107
113
|
h("div", { class: `${clsPrefix}-base-select-option__content` }, children)));
|
|
108
114
|
return rawNode.render
|
|
109
115
|
? rawNode.render({ node, option: rawNode, selected: isSelected })
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { VNodeChild, Ref, UnwrapRef, VNode } from 'vue';
|
|
1
|
+
import { VNodeChild, Ref, UnwrapRef, VNode, HTMLAttributes } from 'vue';
|
|
2
2
|
import { TreeNode } from 'treemate';
|
|
3
3
|
import type { SelectBaseOption, SelectGroupOption, SelectIgnoredOption } from '../../../select/src/interface';
|
|
4
4
|
export declare type Size = 'small' | 'medium' | 'large' | 'huge';
|
|
@@ -14,6 +14,7 @@ export declare type RenderOptionImpl = (info: {
|
|
|
14
14
|
option: SelectBaseOption | SelectGroupOption | SelectIgnoredOption;
|
|
15
15
|
selected: boolean;
|
|
16
16
|
}) => VNodeChild;
|
|
17
|
+
export declare type NodeProps = (option: SelectBaseOption | SelectGroupOption) => HTMLAttributes & Record<string, unknown>;
|
|
17
18
|
export interface InternalSelectMenuInjection {
|
|
18
19
|
handleOptionMouseEnter: (e: MouseEvent, tmNode: TreeNode<SelectBaseOption>) => void;
|
|
19
20
|
handleOptionClick: (e: MouseEvent, tmNode: TreeNode<SelectBaseOption>) => void;
|
|
@@ -26,6 +27,7 @@ export interface InternalSelectMenuInjection {
|
|
|
26
27
|
renderOptionRef: Ref<RenderOption | undefined>;
|
|
27
28
|
labelFieldRef: Ref<string>;
|
|
28
29
|
valueFieldRef: Ref<string>;
|
|
30
|
+
nodePropsRef: Ref<NodeProps | undefined>;
|
|
29
31
|
}
|
|
30
32
|
export interface InternalExposedProps {
|
|
31
33
|
selfRef: Ref<HTMLElement | null>;
|
|
@@ -58,7 +58,6 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
58
58
|
inputProps: PropType<InputHTMLAttributes>;
|
|
59
59
|
focused: BooleanConstructor;
|
|
60
60
|
renderTag: PropType<RenderTag>;
|
|
61
|
-
onKeyup: PropType<(e: KeyboardEvent) => void>;
|
|
62
61
|
onKeydown: PropType<(e: KeyboardEvent) => void>;
|
|
63
62
|
onClick: PropType<(e: MouseEvent) => void>;
|
|
64
63
|
onBlur: PropType<(e: FocusEvent) => void>;
|
|
@@ -608,7 +607,6 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
608
607
|
inputProps: PropType<InputHTMLAttributes>;
|
|
609
608
|
focused: BooleanConstructor;
|
|
610
609
|
renderTag: PropType<RenderTag>;
|
|
611
|
-
onKeyup: PropType<(e: KeyboardEvent) => void>;
|
|
612
610
|
onKeydown: PropType<(e: KeyboardEvent) => void>;
|
|
613
611
|
onClick: PropType<(e: MouseEvent) => void>;
|
|
614
612
|
onBlur: PropType<(e: FocusEvent) => void>;
|
|
@@ -4,7 +4,7 @@ import { VOverflow } from 'vueuc';
|
|
|
4
4
|
import { NPopover } from '../../../popover';
|
|
5
5
|
import { NTag } from '../../../tag';
|
|
6
6
|
import { useThemeClass, useTheme } from '../../../_mixins';
|
|
7
|
-
import { createKey, getTitleAttribute, render, useOnResize } from '../../../_utils';
|
|
7
|
+
import { createKey, getTitleAttribute, render, useOnResize, Wrapper } from '../../../_utils';
|
|
8
8
|
import Suffix from '../../suffix';
|
|
9
9
|
import { internalSelectionLight } from '../styles';
|
|
10
10
|
import style from './styles/index.cssr';
|
|
@@ -34,7 +34,7 @@ export default defineComponent({
|
|
|
34
34
|
}, loading: Boolean, autofocus: Boolean, showArrow: {
|
|
35
35
|
type: Boolean,
|
|
36
36
|
default: true
|
|
37
|
-
}, inputProps: Object, focused: Boolean, renderTag: Function,
|
|
37
|
+
}, inputProps: Object, focused: Boolean, renderTag: Function, onKeydown: Function, onClick: Function, onBlur: Function, onFocus: Function, onDeleteOption: Function, maxTagCount: [String, Number], onClear: Function, onPatternInput: Function, onPatternFocus: Function, onPatternBlur: Function, renderLabel: Function, status: String, inlineThemeDisabled: Boolean, onResize: Function }),
|
|
38
38
|
setup(props) {
|
|
39
39
|
const patternInputMirrorRef = ref(null);
|
|
40
40
|
const patternInputRef = ref(null);
|
|
@@ -426,8 +426,10 @@ export default defineComponent({
|
|
|
426
426
|
const maxTagCountResponsive = maxTagCount === 'responsive';
|
|
427
427
|
const maxTagCountNumeric = typeof maxTagCount === 'number';
|
|
428
428
|
const useMaxTagCount = maxTagCountResponsive || maxTagCountNumeric;
|
|
429
|
-
const suffix = (h(
|
|
430
|
-
default: () => {
|
|
429
|
+
const suffix = (h(Wrapper, null, {
|
|
430
|
+
default: () => (h(Suffix, { clsPrefix: clsPrefix, loading: this.loading, showArrow: this.showArrow, showClear: this.mergedClearable && this.selected, onClear: this.handleClear }, {
|
|
431
|
+
default: () => { var _a, _b; return (_b = (_a = this.$slots).arrow) === null || _b === void 0 ? void 0 : _b.call(_a); }
|
|
432
|
+
}))
|
|
431
433
|
}));
|
|
432
434
|
let body;
|
|
433
435
|
if (multiple) {
|
|
@@ -561,7 +563,7 @@ export default defineComponent({
|
|
|
561
563
|
// many redundant codes.
|
|
562
564
|
[`${clsPrefix}-base-selection--focus`]: this.focused
|
|
563
565
|
}
|
|
564
|
-
], style: this.cssVars, onClick: this.onClick, onMouseenter: this.handleMouseEnter, onMouseleave: this.handleMouseLeave,
|
|
566
|
+
], style: this.cssVars, onClick: this.onClick, onMouseenter: this.handleMouseEnter, onMouseleave: this.handleMouseLeave, onKeydown: this.onKeydown, onFocusin: this.handleFocusin, onFocusout: this.handleFocusout, onMousedown: this.handleMouseDown },
|
|
565
567
|
body,
|
|
566
568
|
bordered ? (h("div", { class: `${clsPrefix}-base-selection__border` })) : null,
|
|
567
569
|
bordered ? (h("div", { class: `${clsPrefix}-base-selection__state-border` })) : null));
|
package/es/_mixins/use-theme.js
CHANGED
|
@@ -55,7 +55,7 @@ function useTheme(resolveId, mountId, style, defaultTheme, props, clsPrefixRef)
|
|
|
55
55
|
common: mergedCommon,
|
|
56
56
|
self: mergedSelf,
|
|
57
57
|
peers: merge({}, defaultTheme.peers, globalPeers, peers),
|
|
58
|
-
peerOverrides: merge({}, globalPeersOverrides, peersOverrides)
|
|
58
|
+
peerOverrides: merge({}, builtinOverrides.peers, globalPeersOverrides, peersOverrides)
|
|
59
59
|
};
|
|
60
60
|
});
|
|
61
61
|
return mergedThemeRef;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export declare function useInjectionCollection(injectionName: string | InjectionKey<unknown>, collectionKey: string, valueRef: Ref<any>): void;
|
|
4
|
-
export declare function useInjectionElementCollection(injectionName: string | InjectionKey<unknown>, collectionKey: string, getElement: () => HTMLElement | null): void;
|
|
5
|
-
export declare function useDeferredTrue(valueRef: Ref<any>, delay: number, shouldDelayRef: Ref<boolean>): Ref<boolean>;
|
|
1
|
+
export { useInjectionCollection, useInjectionElementCollection, useInjectionInstanceCollection } from './use-collection';
|
|
2
|
+
export { useDeferredTrue } from './use-deferred-true';
|
|
6
3
|
export { useAdjustedTo } from './use-adjusted-to';
|
|
7
4
|
export { useHoudini } from './use-houdini';
|
|
8
5
|
export { useOnResize } from './use-resize';
|
|
9
6
|
export { useLockHtmlScroll, lockHtmlScrollRightCompensationRef } from './use-lock-html-scroll';
|
|
10
7
|
export { useIsComposing } from './use-is-composing';
|
|
8
|
+
export { useReactivated } from './use-reactivated';
|
|
@@ -1,116 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
// key1: [insta, instb]
|
|
4
|
-
// key2: [instc]
|
|
5
|
-
// }
|
|
6
|
-
export function useInjectionInstanceCollection(injectionName, collectionKey, registerKeyRef) {
|
|
7
|
-
var _a;
|
|
8
|
-
const injection = inject(injectionName, null);
|
|
9
|
-
if (injection === null)
|
|
10
|
-
return;
|
|
11
|
-
const vm = (_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy;
|
|
12
|
-
watch(registerKeyRef, registerInstance);
|
|
13
|
-
registerInstance(registerKeyRef.value);
|
|
14
|
-
onBeforeUnmount(() => {
|
|
15
|
-
registerInstance(undefined, registerKeyRef.value);
|
|
16
|
-
});
|
|
17
|
-
function registerInstance(key, oldKey) {
|
|
18
|
-
const collection = injection[collectionKey];
|
|
19
|
-
if (oldKey !== undefined)
|
|
20
|
-
removeInstance(collection, oldKey);
|
|
21
|
-
if (key !== undefined)
|
|
22
|
-
addInstance(collection, key);
|
|
23
|
-
}
|
|
24
|
-
function removeInstance(collection, key) {
|
|
25
|
-
if (!collection[key])
|
|
26
|
-
collection[key] = [];
|
|
27
|
-
collection[key].splice(collection[key].findIndex((instance) => instance === vm), 1);
|
|
28
|
-
}
|
|
29
|
-
function addInstance(collection, key) {
|
|
30
|
-
if (!collection[key])
|
|
31
|
-
collection[key] = [];
|
|
32
|
-
if (!~collection[key].findIndex((instance) => instance === vm)) {
|
|
33
|
-
collection[key].push(vm);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
// injection.collection {
|
|
38
|
-
// key1: [insta.value, instb.value]
|
|
39
|
-
// key2: [instc.value]
|
|
40
|
-
// }
|
|
41
|
-
export function useInjectionCollection(injectionName, collectionKey, valueRef) {
|
|
42
|
-
const injection = inject(injectionName, null);
|
|
43
|
-
if (injection === null)
|
|
44
|
-
return;
|
|
45
|
-
if (!(collectionKey in injection)) {
|
|
46
|
-
injection[collectionKey] = [];
|
|
47
|
-
}
|
|
48
|
-
injection[collectionKey].push(valueRef.value);
|
|
49
|
-
watch(valueRef, (value, prevValue) => {
|
|
50
|
-
const collectionArray = injection[collectionKey];
|
|
51
|
-
const index = collectionArray.findIndex((collectionValue) => collectionValue === prevValue);
|
|
52
|
-
if (~index)
|
|
53
|
-
collectionArray.splice(index, 1);
|
|
54
|
-
collectionArray.push(value);
|
|
55
|
-
});
|
|
56
|
-
onBeforeUnmount(() => {
|
|
57
|
-
const collectionArray = injection[collectionKey];
|
|
58
|
-
const index = collectionArray.findIndex((collectionValue) => collectionValue === valueRef.value);
|
|
59
|
-
if (~index)
|
|
60
|
-
collectionArray.splice(index, 1);
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
// injection.collection {
|
|
64
|
-
// key1: [insta.$el, instb.$el]
|
|
65
|
-
// key2: [instc.$el]
|
|
66
|
-
// }
|
|
67
|
-
export function useInjectionElementCollection(injectionName, collectionKey, getElement) {
|
|
68
|
-
const injection = inject(injectionName, null);
|
|
69
|
-
if (injection === null)
|
|
70
|
-
return;
|
|
71
|
-
if (!(collectionKey in injection)) {
|
|
72
|
-
injection[collectionKey] = [];
|
|
73
|
-
}
|
|
74
|
-
onMounted(() => {
|
|
75
|
-
const el = getElement();
|
|
76
|
-
if (!el)
|
|
77
|
-
return;
|
|
78
|
-
injection[collectionKey].push(el);
|
|
79
|
-
});
|
|
80
|
-
onBeforeUnmount(() => {
|
|
81
|
-
const collectionArray = injection[collectionKey];
|
|
82
|
-
const element = getElement();
|
|
83
|
-
const index = collectionArray.findIndex((collectionElement) => collectionElement === element);
|
|
84
|
-
if (~index)
|
|
85
|
-
collectionArray.splice(index, 1);
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
export function useDeferredTrue(valueRef, delay, shouldDelayRef) {
|
|
89
|
-
if (!delay)
|
|
90
|
-
return valueRef;
|
|
91
|
-
const delayedRef = ref(valueRef.value);
|
|
92
|
-
let timerId = null;
|
|
93
|
-
watch(valueRef, (value) => {
|
|
94
|
-
if (timerId !== null)
|
|
95
|
-
window.clearTimeout(timerId);
|
|
96
|
-
if (value === true) {
|
|
97
|
-
if (shouldDelayRef && !shouldDelayRef.value) {
|
|
98
|
-
delayedRef.value = true;
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
timerId = window.setTimeout(() => {
|
|
102
|
-
delayedRef.value = true;
|
|
103
|
-
}, delay);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
delayedRef.value = false;
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
return delayedRef;
|
|
111
|
-
}
|
|
1
|
+
export { useInjectionCollection, useInjectionElementCollection, useInjectionInstanceCollection } from './use-collection';
|
|
2
|
+
export { useDeferredTrue } from './use-deferred-true';
|
|
112
3
|
export { useAdjustedTo } from './use-adjusted-to';
|
|
113
4
|
export { useHoudini } from './use-houdini';
|
|
114
5
|
export { useOnResize } from './use-resize';
|
|
115
6
|
export { useLockHtmlScroll, lockHtmlScrollRightCompensationRef } from './use-lock-html-scroll';
|
|
116
7
|
export { useIsComposing } from './use-is-composing';
|
|
8
|
+
export { useReactivated } from './use-reactivated';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Ref, InjectionKey } from 'vue';
|
|
2
|
+
export declare function useInjectionInstanceCollection(injectionName: string | InjectionKey<unknown>, collectionKey: string, registerKeyRef: Ref<any>): void;
|
|
3
|
+
export declare function useInjectionCollection(injectionName: string | InjectionKey<unknown>, collectionKey: string, valueRef: Ref<any>): void;
|
|
4
|
+
export declare function useInjectionElementCollection(injectionName: string | InjectionKey<unknown>, collectionKey: string, getElement: () => HTMLElement | null): void;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { watch, onMounted, inject, getCurrentInstance, onBeforeUnmount } from 'vue';
|
|
2
|
+
// injection.collection {
|
|
3
|
+
// key1: [insta, instb]
|
|
4
|
+
// key2: [instc]
|
|
5
|
+
// }
|
|
6
|
+
export function useInjectionInstanceCollection(injectionName, collectionKey, registerKeyRef) {
|
|
7
|
+
var _a;
|
|
8
|
+
const injection = inject(injectionName, null);
|
|
9
|
+
if (injection === null)
|
|
10
|
+
return;
|
|
11
|
+
const vm = (_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy;
|
|
12
|
+
watch(registerKeyRef, registerInstance);
|
|
13
|
+
registerInstance(registerKeyRef.value);
|
|
14
|
+
onBeforeUnmount(() => {
|
|
15
|
+
registerInstance(undefined, registerKeyRef.value);
|
|
16
|
+
});
|
|
17
|
+
function registerInstance(key, oldKey) {
|
|
18
|
+
const collection = injection[collectionKey];
|
|
19
|
+
if (oldKey !== undefined)
|
|
20
|
+
removeInstance(collection, oldKey);
|
|
21
|
+
if (key !== undefined)
|
|
22
|
+
addInstance(collection, key);
|
|
23
|
+
}
|
|
24
|
+
function removeInstance(collection, key) {
|
|
25
|
+
if (!collection[key])
|
|
26
|
+
collection[key] = [];
|
|
27
|
+
collection[key].splice(collection[key].findIndex((instance) => instance === vm), 1);
|
|
28
|
+
}
|
|
29
|
+
function addInstance(collection, key) {
|
|
30
|
+
if (!collection[key])
|
|
31
|
+
collection[key] = [];
|
|
32
|
+
if (!~collection[key].findIndex((instance) => instance === vm)) {
|
|
33
|
+
collection[key].push(vm);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// injection.collection {
|
|
38
|
+
// key1: [insta.value, instb.value]
|
|
39
|
+
// key2: [instc.value]
|
|
40
|
+
// }
|
|
41
|
+
export function useInjectionCollection(injectionName, collectionKey, valueRef) {
|
|
42
|
+
const injection = inject(injectionName, null);
|
|
43
|
+
if (injection === null)
|
|
44
|
+
return;
|
|
45
|
+
if (!(collectionKey in injection)) {
|
|
46
|
+
injection[collectionKey] = [];
|
|
47
|
+
}
|
|
48
|
+
injection[collectionKey].push(valueRef.value);
|
|
49
|
+
watch(valueRef, (value, prevValue) => {
|
|
50
|
+
const collectionArray = injection[collectionKey];
|
|
51
|
+
const index = collectionArray.findIndex((collectionValue) => collectionValue === prevValue);
|
|
52
|
+
if (~index)
|
|
53
|
+
collectionArray.splice(index, 1);
|
|
54
|
+
collectionArray.push(value);
|
|
55
|
+
});
|
|
56
|
+
onBeforeUnmount(() => {
|
|
57
|
+
const collectionArray = injection[collectionKey];
|
|
58
|
+
const index = collectionArray.findIndex((collectionValue) => collectionValue === valueRef.value);
|
|
59
|
+
if (~index)
|
|
60
|
+
collectionArray.splice(index, 1);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
// injection.collection {
|
|
64
|
+
// key1: [insta.$el, instb.$el]
|
|
65
|
+
// key2: [instc.$el]
|
|
66
|
+
// }
|
|
67
|
+
export function useInjectionElementCollection(injectionName, collectionKey, getElement) {
|
|
68
|
+
const injection = inject(injectionName, null);
|
|
69
|
+
if (injection === null)
|
|
70
|
+
return;
|
|
71
|
+
if (!(collectionKey in injection)) {
|
|
72
|
+
injection[collectionKey] = [];
|
|
73
|
+
}
|
|
74
|
+
onMounted(() => {
|
|
75
|
+
const el = getElement();
|
|
76
|
+
if (!el)
|
|
77
|
+
return;
|
|
78
|
+
injection[collectionKey].push(el);
|
|
79
|
+
});
|
|
80
|
+
onBeforeUnmount(() => {
|
|
81
|
+
const collectionArray = injection[collectionKey];
|
|
82
|
+
const element = getElement();
|
|
83
|
+
const index = collectionArray.findIndex((collectionElement) => collectionElement === element);
|
|
84
|
+
if (~index)
|
|
85
|
+
collectionArray.splice(index, 1);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ref, watch } from 'vue';
|
|
2
|
+
export function useDeferredTrue(valueRef, delay, shouldDelayRef) {
|
|
3
|
+
if (!delay)
|
|
4
|
+
return valueRef;
|
|
5
|
+
const delayedRef = ref(valueRef.value);
|
|
6
|
+
let timerId = null;
|
|
7
|
+
watch(valueRef, (value) => {
|
|
8
|
+
if (timerId !== null)
|
|
9
|
+
window.clearTimeout(timerId);
|
|
10
|
+
if (value === true) {
|
|
11
|
+
if (shouldDelayRef && !shouldDelayRef.value) {
|
|
12
|
+
delayedRef.value = true;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
timerId = window.setTimeout(() => {
|
|
16
|
+
delayedRef.value = true;
|
|
17
|
+
}, delay);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
delayedRef.value = false;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
return delayedRef;
|
|
25
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { onActivated, onDeactivated } from 'vue';
|
|
2
|
+
export function useReactivated(callback) {
|
|
3
|
+
const isDeactivatedRef = { isDeactivated: false };
|
|
4
|
+
let activateStateInitialized = false;
|
|
5
|
+
onActivated(() => {
|
|
6
|
+
isDeactivatedRef.isDeactivated = false;
|
|
7
|
+
if (!activateStateInitialized) {
|
|
8
|
+
activateStateInitialized = true;
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
callback();
|
|
12
|
+
});
|
|
13
|
+
onDeactivated(() => {
|
|
14
|
+
isDeactivatedRef.isDeactivated = true;
|
|
15
|
+
if (!activateStateInitialized) {
|
|
16
|
+
activateStateInitialized = true;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
return isDeactivatedRef;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { isDocument } from './is-document';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { isDocument } from './is-document';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isDocument(node: Node): node is Document;
|