bge-ui 1.9.0 → 1.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +43 -9
- package/package.json +1 -1
- package/src/tabs/index.vue +24 -1
- package/src/tabs/tab-pane.vue +29 -8
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ var __publicField = (obj, key, value) => {
|
|
|
4
4
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
5
|
return value;
|
|
6
6
|
};
|
|
7
|
-
import { defineComponent, resolveComponent, openBlock, createElementBlock, normalizeClass, createElementVNode, createVNode, renderSlot, normalizeStyle, createStaticVNode, provide, reactive, toRefs, ref, watch, getCurrentScope, onScopeDispose, unref, readonly, computed, getCurrentInstance, onMounted, useSlots, inject, createTextVNode, toDisplayString, createCommentVNode, TransitionGroup, withCtx, nextTick, createBlock, withModifiers, withDirectives, cloneVNode, Fragment, Text, Comment,
|
|
7
|
+
import { defineComponent, resolveComponent, openBlock, createElementBlock, normalizeClass, createElementVNode, createVNode, renderSlot, normalizeStyle, createStaticVNode, provide, reactive, toRefs, ref, watch, getCurrentScope, onScopeDispose, unref, readonly, computed, getCurrentInstance, onMounted, useSlots, inject, createTextVNode, toDisplayString, createCommentVNode, TransitionGroup, withCtx, nextTick, createBlock, withModifiers, onUnmounted, withDirectives, cloneVNode, Fragment, Text, Comment, h, Transition, vShow, onBeforeMount, Teleport, resolveDynamicComponent, shallowReactive, render as render$7, isVNode, vModelCheckbox, renderList, toRef, useAttrs, normalizeProps, mergeProps, onBeforeUpdate, withKeys, createSlots, guardReactiveProps, isRef } from "vue";
|
|
8
8
|
const _hoisted_1$2d = ["disabled"];
|
|
9
9
|
const _hoisted_2$1U = { class: "loading-icon" };
|
|
10
10
|
const _sfc_main$2o = /* @__PURE__ */ defineComponent({
|
|
@@ -6682,7 +6682,23 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
|
6682
6682
|
const tabsRef = ref(null);
|
|
6683
6683
|
const navScrollRef = ref(null);
|
|
6684
6684
|
function addPane(pane) {
|
|
6685
|
-
panes.value.
|
|
6685
|
+
const existingIndex = panes.value.findIndex(
|
|
6686
|
+
(p) => p.id === pane.id || p.value === pane.value
|
|
6687
|
+
);
|
|
6688
|
+
if (existingIndex === -1) {
|
|
6689
|
+
panes.value.push(pane);
|
|
6690
|
+
} else {
|
|
6691
|
+
panes.value[existingIndex] = pane;
|
|
6692
|
+
}
|
|
6693
|
+
}
|
|
6694
|
+
function removePane(id) {
|
|
6695
|
+
const index2 = panes.value.findIndex((p) => p.id === id);
|
|
6696
|
+
if (index2 !== -1) {
|
|
6697
|
+
panes.value.splice(index2, 1);
|
|
6698
|
+
}
|
|
6699
|
+
}
|
|
6700
|
+
function getPaneByValue(value) {
|
|
6701
|
+
return panes.value.find((p) => p.value === value);
|
|
6686
6702
|
}
|
|
6687
6703
|
function changeValue(value) {
|
|
6688
6704
|
emits("update:modelValue", value);
|
|
@@ -6697,6 +6713,8 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
|
6697
6713
|
});
|
|
6698
6714
|
provide(tabsKey$1, {
|
|
6699
6715
|
addPane,
|
|
6716
|
+
removePane,
|
|
6717
|
+
getPaneByValue,
|
|
6700
6718
|
changeValue
|
|
6701
6719
|
});
|
|
6702
6720
|
const getBarStyle = () => {
|
|
@@ -6916,19 +6934,35 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
|
|
|
6916
6934
|
const props = __props;
|
|
6917
6935
|
const tabPaneRef = ref();
|
|
6918
6936
|
const tabContext = inject(tabsKey, void 0);
|
|
6937
|
+
const isActive = ref(false);
|
|
6938
|
+
const paneId = Math.random().toString(36).substring(2, 10);
|
|
6919
6939
|
function changeValue() {
|
|
6920
|
-
tabContext
|
|
6940
|
+
if (tabContext) {
|
|
6941
|
+
tabContext.changeValue(props.value);
|
|
6942
|
+
}
|
|
6921
6943
|
}
|
|
6922
|
-
const isActive = ref(false);
|
|
6923
6944
|
function setActive(active) {
|
|
6924
6945
|
isActive.value = active;
|
|
6925
6946
|
}
|
|
6926
6947
|
onMounted(() => {
|
|
6927
|
-
|
|
6928
|
-
|
|
6929
|
-
|
|
6930
|
-
|
|
6931
|
-
|
|
6948
|
+
var _a;
|
|
6949
|
+
if (tabContext) {
|
|
6950
|
+
const existingPane = (_a = tabContext.getPaneByValue) == null ? void 0 : _a.call(tabContext, props.value);
|
|
6951
|
+
if (!existingPane) {
|
|
6952
|
+
tabContext.addPane(reactive({
|
|
6953
|
+
id: paneId,
|
|
6954
|
+
ref: tabPaneRef.value,
|
|
6955
|
+
value: props.value,
|
|
6956
|
+
setActive
|
|
6957
|
+
}));
|
|
6958
|
+
}
|
|
6959
|
+
}
|
|
6960
|
+
});
|
|
6961
|
+
onUnmounted(() => {
|
|
6962
|
+
var _a;
|
|
6963
|
+
if (tabContext) {
|
|
6964
|
+
(_a = tabContext.removePane) == null ? void 0 : _a.call(tabContext, paneId);
|
|
6965
|
+
}
|
|
6932
6966
|
});
|
|
6933
6967
|
return (_ctx, _cache) => {
|
|
6934
6968
|
return openBlock(), createElementBlock("div", {
|
package/package.json
CHANGED
package/src/tabs/index.vue
CHANGED
|
@@ -41,6 +41,7 @@ const emits = defineEmits(['update:modelValue'])
|
|
|
41
41
|
|
|
42
42
|
// 类型定义
|
|
43
43
|
interface TabPane {
|
|
44
|
+
id: string
|
|
44
45
|
ref: HTMLElement | null
|
|
45
46
|
value: string
|
|
46
47
|
setActive: (active: boolean) => void
|
|
@@ -58,7 +59,27 @@ const navScrollRef = ref<HTMLElement | null>(null)
|
|
|
58
59
|
|
|
59
60
|
// 方法
|
|
60
61
|
function addPane(pane: TabPane) {
|
|
61
|
-
|
|
62
|
+
// 检查是否已存在相同 id 或 value 的 pane,避免重复添加
|
|
63
|
+
const existingIndex = panes.value.findIndex(
|
|
64
|
+
(p) => p.id === pane.id || p.value === pane.value
|
|
65
|
+
)
|
|
66
|
+
if (existingIndex === -1) {
|
|
67
|
+
panes.value.push(pane)
|
|
68
|
+
} else {
|
|
69
|
+
// 更新已存在的 pane
|
|
70
|
+
panes.value[existingIndex] = pane
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function removePane(id: string) {
|
|
75
|
+
const index = panes.value.findIndex((p) => p.id === id)
|
|
76
|
+
if (index !== -1) {
|
|
77
|
+
panes.value.splice(index, 1)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function getPaneByValue(value: string) {
|
|
82
|
+
return panes.value.find((p) => p.value === value)
|
|
62
83
|
}
|
|
63
84
|
|
|
64
85
|
function changeValue(value: string) {
|
|
@@ -77,6 +98,8 @@ watch(() => props.modelValue, () => {
|
|
|
77
98
|
const tabsKey = 'bge-tabs-context'
|
|
78
99
|
provide(tabsKey, {
|
|
79
100
|
addPane,
|
|
101
|
+
removePane,
|
|
102
|
+
getPaneByValue,
|
|
80
103
|
changeValue
|
|
81
104
|
})
|
|
82
105
|
|
package/src/tabs/tab-pane.vue
CHANGED
|
@@ -14,23 +14,44 @@ const props = defineProps({
|
|
|
14
14
|
type: String
|
|
15
15
|
}
|
|
16
16
|
})
|
|
17
|
-
import { ref, onMounted, inject, reactive } from "vue";
|
|
17
|
+
import { ref, onMounted, inject, reactive, onUnmounted } from "vue";
|
|
18
18
|
const tabPaneRef = ref<HTMLDivElement>()
|
|
19
19
|
const tabsKey = 'bge-tabs-context'
|
|
20
20
|
const tabContext: any = inject(tabsKey, undefined)
|
|
21
|
+
const isActive = ref<Boolean>(false)
|
|
22
|
+
|
|
23
|
+
// 生成唯一标识,用于去重
|
|
24
|
+
const paneId = Math.random().toString(36).substring(2, 10)
|
|
25
|
+
|
|
21
26
|
function changeValue() {
|
|
22
|
-
tabContext
|
|
27
|
+
if (tabContext) {
|
|
28
|
+
tabContext.changeValue(props.value)
|
|
29
|
+
}
|
|
23
30
|
}
|
|
24
|
-
|
|
31
|
+
|
|
25
32
|
function setActive(active: Boolean) {
|
|
26
33
|
isActive.value = active
|
|
27
34
|
}
|
|
35
|
+
|
|
28
36
|
onMounted(() => {
|
|
29
|
-
tabContext
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
37
|
+
if (tabContext) {
|
|
38
|
+
// 检查是否已存在相同 value 的 pane,避免重复添加
|
|
39
|
+
const existingPane = tabContext.getPaneByValue?.(props.value)
|
|
40
|
+
if (!existingPane) {
|
|
41
|
+
tabContext.addPane(reactive({
|
|
42
|
+
id: paneId,
|
|
43
|
+
ref: tabPaneRef.value,
|
|
44
|
+
value: props.value,
|
|
45
|
+
setActive
|
|
46
|
+
}))
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
onUnmounted(() => {
|
|
52
|
+
if (tabContext) {
|
|
53
|
+
tabContext.removePane?.(paneId)
|
|
54
|
+
}
|
|
34
55
|
})
|
|
35
56
|
</script>
|
|
36
57
|
<style lang="scss" >
|