@tekkare/auriga 0.2.183 → 0.2.184

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/module.json CHANGED
@@ -4,5 +4,5 @@
4
4
  "compatibility": {
5
5
  "nuxt": "^3.0.0"
6
6
  },
7
- "version": "0.2.183"
7
+ "version": "0.2.184"
8
8
  }
@@ -38,12 +38,13 @@
38
38
  </label>
39
39
  </div>
40
40
  <div
41
+ v-show="sliderVisible"
41
42
  class="toggle_option_slider"
42
43
  :style="{
43
44
  background: 'white',
44
45
  left: silderInfos.left,
45
46
  width: silderInfos.width,
46
- height: silderInfos.height,
47
+ height: silderInfos.height
47
48
  }"
48
49
  />
49
50
  </div>
@@ -52,7 +53,14 @@
52
53
  </template>
53
54
 
54
55
  <script>
55
- import { defineComponent, ref, computed } from "vue";
56
+ import {
57
+ defineComponent,
58
+ ref,
59
+ computed,
60
+ onMounted,
61
+ nextTick,
62
+ watch
63
+ } from "vue";
56
64
  import ArgIcon from "./argIcon.vue";
57
65
  export default defineComponent({
58
66
  name: "ArgSliderTabs",
@@ -80,6 +88,7 @@ export default defineComponent({
80
88
  setup(props) {
81
89
  const el = ref();
82
90
  const buttonContents = ref(null);
91
+ const sliderVisible = ref(false);
83
92
  const silderInfos = computed(() => {
84
93
  return getSliderInfos(props.activeTab);
85
94
  });
@@ -87,22 +96,63 @@ export default defineComponent({
87
96
  props.switchTab(value);
88
97
  };
89
98
  const getSliderInfos = (index) => {
90
- if (el.value && buttonContents.value) {
99
+ if (el.value && buttonContents.value && buttonContents.value.length > 0) {
91
100
  let left = 0;
92
101
  for (let i = 0; i < index; i++) {
93
- left += buttonContents.value[i].clientWidth + 18;
102
+ if (buttonContents.value[i]) {
103
+ left += buttonContents.value[i].clientWidth + 18;
104
+ }
94
105
  }
95
- const width = `${buttonContents.value[index].clientWidth + 16}px`;
106
+ const activeButton = buttonContents.value[index];
107
+ if (!activeButton) {
108
+ return { width: "0", left: "0", height: "0" };
109
+ }
110
+ const width = `${activeButton.clientWidth + 16}px`;
111
+ const height = `${el.value.clientHeight - 6}px`;
96
112
  return {
97
113
  width,
98
114
  left: `${left}px`,
99
- height: `${el.value.clientHeight - 6}px`
115
+ height
100
116
  };
101
117
  } else {
102
118
  return { width: "0", left: "0", height: "0" };
103
119
  }
104
120
  };
105
- return { updateButton, el, buttonContents, silderInfos };
121
+ const recalculateSlider = async () => {
122
+ await nextTick();
123
+ setTimeout(() => {
124
+ if (el.value && buttonContents.value && buttonContents.value.length > 0) {
125
+ const newInfos = getSliderInfos(props.activeTab);
126
+ if (newInfos.width !== "0") {
127
+ sliderVisible.value = true;
128
+ }
129
+ }
130
+ }, 100);
131
+ };
132
+ watch(
133
+ () => props.activeTab,
134
+ () => {
135
+ recalculateSlider();
136
+ }
137
+ );
138
+ watch(
139
+ () => props.tabs,
140
+ () => {
141
+ sliderVisible.value = false;
142
+ recalculateSlider();
143
+ },
144
+ { deep: true }
145
+ );
146
+ onMounted(() => {
147
+ recalculateSlider();
148
+ });
149
+ return {
150
+ updateButton,
151
+ el,
152
+ buttonContents,
153
+ silderInfos,
154
+ sliderVisible
155
+ };
106
156
  }
107
157
  });
108
158
  </script>
@@ -33,6 +33,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
33
33
  left: string;
34
34
  height: string;
35
35
  }>;
36
+ sliderVisible: import("vue").Ref<boolean, boolean>;
36
37
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
37
38
  tabs: {
38
39
  type: () => Tabs;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tekkare/auriga",
3
- "version": "0.2.183",
3
+ "version": "0.2.184",
4
4
  "description": "Aurgia is a UI kit developped by Tekkare",
5
5
  "license": "MIT",
6
6
  "type": "module",