eco-vue-js 0.8.43 → 0.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.
Files changed (39) hide show
  1. package/dist/components/DropdownMenu/WDropdownMenu.vue.d.ts +139 -3
  2. package/dist/components/DropdownMenu/WDropdownMenu.vue.d.ts.map +1 -1
  3. package/dist/components/Form/WFormValidator.vue.d.ts +1 -1
  4. package/dist/components/Form/WFormValidator.vue.d.ts.map +1 -1
  5. package/dist/components/Form/WFormValidator.vue.js +15 -2
  6. package/dist/components/FormAsync/WFormAsyncButtonGroup.vue.d.ts +2 -2
  7. package/dist/components/HeaderBar/WHeaderBar.vue.d.ts +4 -1
  8. package/dist/components/HeaderBar/WHeaderBar.vue.d.ts.map +1 -1
  9. package/dist/components/Input/WInputDate.vue.d.ts +12 -2
  10. package/dist/components/Input/WInputDate.vue.d.ts.map +1 -1
  11. package/dist/components/Input/WInputOptions.vue.d.ts +1 -1
  12. package/dist/components/List/types.d.ts.map +1 -1
  13. package/dist/components/Modal/WModalStepper.vue.d.ts +638 -4
  14. package/dist/components/Modal/WModalStepper.vue.d.ts.map +1 -1
  15. package/dist/components/Modal/WModalStepper.vue.js +17 -13
  16. package/dist/components/Select/WSelectAsyncSingle.vue.d.ts +4 -4
  17. package/dist/components/Select/WSelectSingle.vue.d.ts +4 -4
  18. package/dist/components/Select/WSelectStringified.vue.d.ts +4 -4
  19. package/dist/components/Tabs/WTabs.vue.d.ts +269 -12
  20. package/dist/components/Tabs/WTabs.vue.d.ts.map +1 -1
  21. package/dist/components/Tabs/WTabs.vue.js +120 -105
  22. package/dist/components/Tabs/WTabsItem.vue.d.ts +33 -0
  23. package/dist/components/Tabs/WTabsItem.vue.d.ts.map +1 -0
  24. package/dist/components/Tabs/WTabsItem.vue.js +17 -0
  25. package/dist/components/Tabs/WTabsItem.vue2.js +5 -0
  26. package/dist/components/Tabs/components/TabItem.vue.d.ts +4 -2
  27. package/dist/components/Tabs/components/TabItem.vue.d.ts.map +1 -1
  28. package/dist/components/Tabs/components/TabItem.vue.js +6 -5
  29. package/dist/components/Tabs/components/TabTitleButton.vue.d.ts +58 -0
  30. package/dist/components/Tabs/components/TabTitleButton.vue.d.ts.map +1 -0
  31. package/dist/components/Tabs/components/TabTitleButton.vue.js +125 -0
  32. package/dist/components/Tabs/components/TabTitleButton.vue2.js +5 -0
  33. package/dist/imports/componentsPlugin.d.ts +2 -1
  34. package/dist/imports/componentsPlugin.d.ts.map +1 -1
  35. package/dist/main.js +1 -0
  36. package/dist/types/types.d.ts +1 -1
  37. package/dist/utils/Modal.d.ts.map +1 -1
  38. package/eslint/recommended.js +13 -3
  39. package/package.json +5 -1
@@ -1,84 +1,77 @@
1
- import { defineComponent, useSlots, computed, ref, useTemplateRef, reactive, inject, watch, onMounted, onUnmounted, openBlock, createElementBlock, normalizeClass, Fragment, renderList, unref, createElementVNode, createBlock, resolveDynamicComponent, createCommentVNode, createTextVNode, toDisplayString, createVNode, Transition, withCtx, normalizeStyle, TransitionGroup, nextTick } from 'vue';
2
- import _sfc_main$2 from '../Form/WForm.vue.js';
1
+ import { defineComponent, useSlots, useTemplateRef, computed, ref, reactive, inject, watch, onMounted, onUnmounted, openBlock, createElementBlock, normalizeClass, Fragment, renderList, createBlock, unref, createSlots, withCtx, resolveDynamicComponent, createElementVNode, normalizeStyle, createCommentVNode, createVNode, TransitionGroup, nextTick } from 'vue';
2
+ import _sfc_main$3 from '../Form/WForm.vue.js';
3
3
  import { throttle, debounce } from '../../utils/utils.js';
4
- import _sfc_main$1 from './components/TabItem.vue.js';
4
+ import _sfc_main$2 from './components/TabItem.vue.js';
5
+ import _sfc_main$1 from './components/TabTitleButton.vue.js';
5
6
  import { wTabItemListener, wTabItemUnlistener } from './models/injection.js';
6
7
 
7
- const _hoisted_1 = ["onClick"];
8
- const _hoisted_2 = { class: "relative whitespace-nowrap px-4" };
9
8
  const _sfc_main = /* @__PURE__ */ defineComponent({
10
9
  __name: "WTabs",
11
10
  props: {
12
- names: {},
13
- namesForm: {},
14
- icons: {},
15
11
  customSlots: {},
16
12
  lessTransitions: { type: Boolean },
17
13
  initTab: {},
18
14
  side: { type: Boolean },
19
- disableMinHeight: { type: Boolean }
15
+ disableMinHeight: { type: Boolean },
16
+ noHeader: { type: Boolean },
17
+ switchToNew: { type: Boolean }
20
18
  },
21
- emits: ["update:current", "update:has-changes"],
19
+ emits: ["update:current", "update:current-index", "update:has-changes", "update:current-title", "update:tabs-length"],
22
20
  setup(__props, { expose: __expose, emit: __emit }) {
23
21
  const props = __props;
24
22
  const emit = __emit;
25
23
  const slots = useSlots();
26
- const defaultSlots = computed(() => (props.customSlots ?? slots.default?.() ?? []).filter((item) => typeof item.type !== "symbol"));
27
- const current = ref(props.initTab ?? 0);
24
+ const buttonContainerRef = useTemplateRef("buttonContainer");
25
+ const defaultSlots = computed(() => {
26
+ const result = [];
27
+ (props.customSlots ?? slots.default?.() ?? []).forEach((item) => {
28
+ if (Array.isArray(item.children)) result.push(...item.children);
29
+ if (typeof item.type === "symbol") return;
30
+ result.push(item);
31
+ });
32
+ return result;
33
+ });
34
+ const defaultSlotsKeys = computed(() => defaultSlots.value.map((item) => item.props?.name));
35
+ const current = ref(defaultSlotsKeys.value[props.initTab ?? 0]);
36
+ const currentIndex = computed(() => defaultSlotsKeys.value.indexOf(current.value));
28
37
  const isDirect = ref(true);
29
38
  const buttonRef = useTemplateRef("button");
30
39
  const indicatorStyle = ref(void 0);
31
40
  const minHeight = ref(0);
32
41
  const tabItemRef = useTemplateRef("tabItem");
33
42
  const formRef = useTemplateRef("form");
34
- const buttonContainerRef = useTemplateRef("buttonContainer");
35
43
  const isValidMap = reactive({});
36
44
  const hasChangesMap = reactive({});
37
45
  const hasChanges = computed(() => Object.values(hasChangesMap).includes(true));
38
- const updateIsValidMap = (index, value) => {
39
- isValidMap[index] = value;
46
+ const updateIsValidMap = (key, value) => {
47
+ isValidMap[key] = value;
40
48
  nextTick().then(() => {
41
- if (value === false && isValidMap[current.value] !== false) switchTab(index);
49
+ if (value === false && isValidMap[current.value] !== false) switchTab(key);
42
50
  });
43
51
  };
44
- const switchTab = throttle((index) => {
45
- if (current.value === index) return;
46
- updateIndex(index);
52
+ const switchTab = throttle((key) => {
53
+ if (current.value === key) return;
54
+ updateCurrent(key);
47
55
  }, 200);
56
+ const updateCurrent = (value) => {
57
+ tabItemRef.value?.[currentIndex.value]?.emitHeight?.();
58
+ setCurrentDebounced(value);
59
+ };
48
60
  const updateIndex = (value) => {
49
- tabItemRef.value?.[current.value]?.emitHeight?.();
50
- setIndexDebounced(value);
61
+ tabItemRef.value?.[currentIndex.value]?.emitHeight?.();
62
+ setCurrentDebounced(defaultSlotsKeys.value[value]);
51
63
  };
52
- const setIndexDebounced = debounce((value) => {
53
- if (current.value === value || value < 0 || value > defaultSlots.value.length - 1) return;
54
- isDirect.value = current.value < value;
64
+ const setCurrentDebounced = debounce((value) => {
65
+ if (current.value === value || !defaultSlotsKeys.value.includes(value)) return;
66
+ if (!defaultSlots.value[defaultSlotsKeys.value.indexOf(value)].children?.default) return;
67
+ isDirect.value = defaultSlotsKeys.value.indexOf(current.value) < defaultSlotsKeys.value.indexOf(value);
55
68
  current.value = value;
56
69
  }, 100);
57
70
  const next = () => {
58
- switchTab(current.value + 1);
71
+ switchTab(defaultSlotsKeys.value[currentIndex.value + 1]);
59
72
  };
60
73
  const previous = () => {
61
- switchTab(current.value - 1);
62
- };
63
- const updateIndicator = () => {
64
- if (!props.names) return;
65
- const element = buttonRef.value?.[current.value];
66
- if (!element || !element.offsetWidth) return;
67
- if (props.side) {
68
- indicatorStyle.value = {
69
- height: element.offsetHeight + "px",
70
- top: element.offsetTop + "px",
71
- left: "0",
72
- width: "0.25rem"
73
- };
74
- } else {
75
- indicatorStyle.value = {
76
- width: element.offsetWidth + "px",
77
- left: element.offsetLeft + "px",
78
- bottom: "0",
79
- height: "0.25rem"
80
- };
81
- }
74
+ switchTab(defaultSlotsKeys.value[currentIndex.value - 1]);
82
75
  };
83
76
  const updateHeight = (value) => {
84
77
  if (minHeight.value >= value) return;
@@ -93,30 +86,52 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
93
86
  const initModel = (index, ...args) => {
94
87
  return formRef.value?.[index]?.initModel(...args);
95
88
  };
89
+ const updateIndicator = () => {
90
+ buttonRef.value?.forEach((item) => item?.update());
91
+ };
92
+ const updateScrollPosition = (value) => {
93
+ if (!buttonContainerRef.value) return;
94
+ if (props.side) {
95
+ if (buttonContainerRef.value.scrollHeight <= buttonContainerRef.value.offsetHeight) return;
96
+ buttonContainerRef.value.scrollTo({ top: ((value.top ?? 0) - buttonContainerRef.value.offsetTop) / 2, behavior: "smooth" });
97
+ } else {
98
+ if (buttonContainerRef.value.scrollWidth <= buttonContainerRef.value.offsetWidth) return;
99
+ buttonContainerRef.value.scrollTo({ left: ((value.left ?? 0) - buttonContainerRef.value.offsetLeft) / 2, behavior: "smooth" });
100
+ }
101
+ };
96
102
  const tabItemListenerInjected = inject(wTabItemListener, null);
97
103
  const tabItemUnlistenerInjected = inject(wTabItemUnlistener, null);
98
104
  watch(current, (value) => {
99
105
  emit("update:current", value);
100
- updateIndicator();
101
- if (buttonContainerRef.value && buttonRef.value?.[value]) {
102
- if (props.side) {
103
- buttonContainerRef.value.scrollTo({ top: (buttonRef.value[value].offsetTop - buttonContainerRef.value.offsetTop) / 2, behavior: "smooth" });
104
- } else {
105
- buttonContainerRef.value.scrollTo({ left: (buttonRef.value[value].offsetLeft - buttonContainerRef.value.offsetLeft) / 2, behavior: "smooth" });
106
- }
107
- }
106
+ }, { immediate: true });
107
+ watch(currentIndex, (value) => {
108
+ emit("update:current-index", value);
108
109
  }, { immediate: true });
109
110
  watch(hasChanges, (value) => {
110
111
  emit("update:has-changes", value);
111
112
  }, { immediate: true });
113
+ watch(defaultSlotsKeys, (newValue, oldValue) => {
114
+ const newIndex = newValue.findIndex((item) => !oldValue.includes(item));
115
+ if (props.switchToNew && newIndex !== -1) {
116
+ switchTab(newValue[newIndex]);
117
+ return;
118
+ }
119
+ if (!newValue.includes(current.value)) {
120
+ switchTab(newValue[oldValue.indexOf(current.value) - 1]);
121
+ return;
122
+ }
123
+ });
124
+ watch(defaultSlotsKeys, (value) => {
125
+ emit("update:tabs-length", value.length);
126
+ }, { immediate: true });
112
127
  onMounted(() => {
113
- updateIndicator();
114
128
  tabItemListenerInjected?.(updateIndicator);
115
129
  });
116
130
  onUnmounted(() => {
117
131
  tabItemUnlistenerInjected?.(updateIndicator);
118
132
  });
119
133
  __expose({
134
+ updateCurrent,
120
135
  updateIndex,
121
136
  next,
122
137
  previous,
@@ -131,52 +146,51 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
131
146
  "grid grid-cols-[auto,1fr] items-start": _ctx.side
132
147
  }])
133
148
  }, [
134
- _ctx.names ? (openBlock(), createElementBlock("div", {
149
+ !_ctx.noHeader ? (openBlock(), createElementBlock("div", {
135
150
  key: 0,
136
151
  ref: "buttonContainer",
137
152
  class: normalizeClass(["no-scrollbar relative flex snap-x snap-mandatory snap-always overflow-x-auto overscroll-x-contain", {
138
153
  "flex-col": _ctx.side
139
154
  }])
140
155
  }, [
141
- (openBlock(true), createElementBlock(Fragment, null, renderList(defaultSlots.value, (_, index) => {
142
- return openBlock(), createElementBlock("button", {
156
+ (openBlock(true), createElementBlock(Fragment, null, renderList(defaultSlots.value, (slot, index) => {
157
+ return openBlock(), createBlock(_sfc_main$1, {
158
+ key: slot.props?.name,
143
159
  ref_for: true,
144
160
  ref: "button",
145
- key: index,
146
- class: normalizeClass(["w-ripple w-ripple-hover relative flex flex-1 cursor-pointer select-none snap-center items-center font-semibold outline-none transition-colors duration-500", {
147
- "text-description": current.value !== index && isValidMap[index] !== false,
148
- "text-primary-default dark:text-primary-dark": current.value === index && isValidMap[index] !== false,
149
- "text-negative dark:text-negative-dark": isValidMap[index] === false,
150
- "h-10 justify-center text-center": !_ctx.side,
151
- "py-3 pr-4 text-start": _ctx.side
152
- }]),
153
- onClick: ($event) => unref(switchTab)(index)
154
- }, [
155
- createElementVNode("div", _hoisted_2, [
156
- _ctx.icons?.[index] ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.icons?.[index]), {
157
- key: 0,
158
- class: "-mt-1 inline"
159
- })) : createCommentVNode("", true),
160
- createTextVNode(" " + toDisplayString(_ctx.names[index]) + " ", 1),
161
- createVNode(Transition, {
162
- "enter-active-class": "transition-opacity",
163
- "leave-active-class": "transition-opacity",
164
- "enter-from-class": "opacity-0",
165
- "leave-to-class": "opacity-0"
166
- }, {
167
- default: withCtx(() => [
168
- hasChangesMap[index] ? (openBlock(), createElementBlock("div", {
169
- key: 0,
170
- class: normalizeClass(["square-2 absolute right-0 top-0 rounded-full transition-colors duration-500", {
171
- "bg-info dark:bg-info-dark": isValidMap[index] !== false,
172
- "bg-negative dark:bg-negative-dark": isValidMap[index] === false
173
- }])
174
- }, null, 2)) : createCommentVNode("", true)
175
- ]),
176
- _: 2
177
- }, 1024)
178
- ])
179
- ], 10, _hoisted_1);
161
+ active: current.value === slot.props?.name,
162
+ index,
163
+ title: slot.props?.title,
164
+ icon: slot.props?.icon,
165
+ "has-changes": hasChangesMap[slot.props?.name] === true,
166
+ "has-error": isValidMap[slot.props?.name] === false,
167
+ side: _ctx.side,
168
+ "onUpdate:indicatorStyle": _cache[0] || (_cache[0] = ($event) => indicatorStyle.value = $event),
169
+ "onUpdate:scrollPosition": updateScrollPosition,
170
+ onClick: ($event) => unref(switchTab)(slot.props?.name)
171
+ }, createSlots({ _: 2 }, [
172
+ slot.children?.title ? {
173
+ name: "title",
174
+ fn: withCtx(() => [
175
+ (openBlock(), createBlock(resolveDynamicComponent(slot.children?.title)))
176
+ ]),
177
+ key: "0"
178
+ } : void 0,
179
+ slot.children?.suffix ? {
180
+ name: "suffix",
181
+ fn: withCtx(() => [
182
+ (openBlock(), createBlock(resolveDynamicComponent(slot.children?.suffix)))
183
+ ]),
184
+ key: "1"
185
+ } : void 0,
186
+ slot.children?.right ? {
187
+ name: "right",
188
+ fn: withCtx(() => [
189
+ (openBlock(), createBlock(resolveDynamicComponent(slot.children?.right)))
190
+ ]),
191
+ key: "2"
192
+ } : void 0
193
+ ]), 1032, ["active", "index", "title", "icon", "has-changes", "has-error", "side", "onClick"]);
180
194
  }), 128)),
181
195
  createElementVNode("div", {
182
196
  class: normalizeClass(["absolute rounded-sm duration-500", {
@@ -199,32 +213,33 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
199
213
  "leave-to-class": _ctx.lessTransitions || _ctx.side ? "opacity-0" : "translate-x-[calc((100%+var(--inner-margin))*var(--direction-factor)*-1)]"
200
214
  }, {
201
215
  default: withCtx(() => [
202
- (openBlock(true), createElementBlock(Fragment, null, renderList(defaultSlots.value, (slot, index) => {
203
- return openBlock(), createBlock(_sfc_main$1, {
216
+ (openBlock(true), createElementBlock(Fragment, null, renderList(defaultSlots.value, (slot) => {
217
+ return openBlock(), createBlock(_sfc_main$2, {
204
218
  ref_for: true,
205
219
  ref: "tabItem",
206
- key: index,
207
- "is-active": index === current.value,
220
+ key: slot.props?.name,
221
+ active: slot.props?.name === current.value,
208
222
  class: "width-full",
209
- "onUpdate:height": _cache[0] || (_cache[0] = ($event) => !_ctx.disableMinHeight && updateHeight($event))
223
+ "onUpdate:height": _cache[1] || (_cache[1] = ($event) => !_ctx.disableMinHeight && updateHeight($event)),
224
+ "onUpdate:active": ($event) => _ctx.$emit("update:current-title", slot.props?.title)
210
225
  }, {
211
226
  default: withCtx(() => [
212
- createVNode(_sfc_main$2, {
227
+ createVNode(_sfc_main$3, {
213
228
  ref_for: true,
214
229
  ref: "form",
215
- name: _ctx.namesForm?.[index] ?? index.toString(),
216
- title: _ctx.names?.[index],
217
- "onUpdate:isValid": ($event) => updateIsValidMap(index, $event),
218
- "onUpdate:hasChanges": ($event) => hasChangesMap[index] = $event
230
+ name: slot.props?.name,
231
+ title: slot.props?.title,
232
+ "onUpdate:isValid": ($event) => updateIsValidMap(slot.props?.name, $event),
233
+ "onUpdate:hasChanges": ($event) => hasChangesMap[slot.props?.name] = $event
219
234
  }, {
220
235
  default: withCtx(() => [
221
- (openBlock(), createBlock(resolveDynamicComponent(slot)))
236
+ (openBlock(), createBlock(resolveDynamicComponent(slot.children?.default)))
222
237
  ]),
223
238
  _: 2
224
239
  }, 1032, ["name", "title", "onUpdate:isValid", "onUpdate:hasChanges"])
225
240
  ]),
226
241
  _: 2
227
- }, 1032, ["is-active"]);
242
+ }, 1032, ["active", "onUpdate:active"]);
228
243
  }), 128))
229
244
  ]),
230
245
  _: 1
@@ -0,0 +1,33 @@
1
+ declare function __VLS_template(): {
2
+ slots: Readonly<{
3
+ default?: () => void;
4
+ title?: () => void;
5
+ suffix?: () => void;
6
+ right?: () => void;
7
+ }> & {
8
+ default?: () => void;
9
+ title?: () => void;
10
+ suffix?: () => void;
11
+ right?: () => void;
12
+ };
13
+ refs: {};
14
+ attrs: Partial<{}>;
15
+ };
16
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
17
+ declare const __VLS_component: import('vue').DefineComponent<{
18
+ title: string;
19
+ name: string;
20
+ icon?: SVGComponent;
21
+ }, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{
22
+ title: string;
23
+ name: string;
24
+ icon?: SVGComponent;
25
+ }> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
26
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
27
+ export default _default;
28
+ type __VLS_WithTemplateSlots<T, S> = T & {
29
+ new (): {
30
+ $slots: S;
31
+ };
32
+ };
33
+ //# sourceMappingURL=WTabsItem.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WTabsItem.vue.d.ts","sourceRoot":"","sources":["../../../src/components/Tabs/WTabsItem.vue"],"names":[],"mappings":"AAuCA,iBAAS,cAAc;;kBAVX,MAAM,IAAI;gBACZ,MAAM,IAAI;iBACT,MAAM,IAAI;gBACX,MAAM,IAAI;;kBAHR,MAAM,IAAI;gBACZ,MAAM,IAAI;iBACT,MAAM,IAAI;gBACX,MAAM,IAAI;;;WAsCN,OAAO,IAA6B;EAEjD;AAQD,KAAK,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,QAAA,MAAM,eAAe;WA3DZ,MAAM;UACP,MAAM;WACL,YAAY;;WAFZ,MAAM;UACP,MAAM;WACL,YAAY;iGA+DnB,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAAnG,wBAAoG;AAWpG,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACxC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { defineComponent, renderSlot } from 'vue';
2
+
3
+ const _sfc_main = /* @__PURE__ */ defineComponent({
4
+ __name: "WTabsItem",
5
+ props: {
6
+ title: {},
7
+ name: {},
8
+ icon: {}
9
+ },
10
+ setup(__props) {
11
+ return (_ctx, _cache) => {
12
+ return renderSlot(_ctx.$slots, "default");
13
+ };
14
+ }
15
+ });
16
+
17
+ export { _sfc_main as default };
@@ -0,0 +1,5 @@
1
+ import _sfc_main from './WTabsItem.vue.js';
2
+
3
+
4
+
5
+ export { _sfc_main as default };
@@ -9,15 +9,17 @@ declare function __VLS_template(): {
9
9
  };
10
10
  type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
11
11
  declare const __VLS_component: import('vue').DefineComponent<{
12
- isActive: boolean;
12
+ active: boolean;
13
13
  }, {
14
14
  emitHeight: () => void;
15
15
  }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
16
16
  "update:height": (value: number) => any;
17
+ "update:active": () => any;
17
18
  }, string, import('vue').PublicProps, Readonly<{
18
- isActive: boolean;
19
+ active: boolean;
19
20
  }> & Readonly<{
20
21
  "onUpdate:height"?: ((value: number) => any) | undefined;
22
+ "onUpdate:active"?: (() => any) | undefined;
21
23
  }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
22
24
  element: HTMLDivElement;
23
25
  }, any>;
@@ -1 +1 @@
1
- {"version":3,"file":"TabItem.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/Tabs/components/TabItem.vue"],"names":[],"mappings":"AA4FA,iBAAS,cAAc;;yBA6BM,GAAG;;;;;WAUlB,OAAO,IAA6B;EAEjD;AAWD,KAAK,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,QAAA,MAAM,eAAe;cA7FT,OAAO;;sBAYI,IAAI;;;;cAZf,OAAO;;;;;OAwGjB,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAAnG,wBAAoG;AAWpG,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACxC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
1
+ {"version":3,"file":"TabItem.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/Tabs/components/TabItem.vue"],"names":[],"mappings":"AAmGA,iBAAS,cAAc;;yBA6BM,GAAG;;;;;WAUlB,OAAO,IAA6B;EAEjD;AAYD,KAAK,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,QAAA,MAAM,eAAe;YAlGX,OAAO;;sBAaM,IAAI;;;;;YAbjB,OAAO;;;;;;OA8Gf,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAAnG,wBAAoG;AAWpG,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACxC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
@@ -1,13 +1,13 @@
1
- import { defineComponent, useTemplateRef, watch, toRef, nextTick, withDirectives, openBlock, createElementBlock, renderSlot, vShow } from 'vue';
1
+ import { defineComponent, useTemplateRef, watch, nextTick, withDirectives, openBlock, createElementBlock, renderSlot, vShow } from 'vue';
2
2
  import { useTabItemActiveListener } from '../use/useTabItemActiveListener.js';
3
3
 
4
4
  const _hoisted_1 = { ref: "element" };
5
5
  const _sfc_main = /* @__PURE__ */ defineComponent({
6
6
  __name: "TabItem",
7
7
  props: {
8
- isActive: { type: Boolean }
8
+ active: { type: Boolean }
9
9
  },
10
- emits: ["update:height"],
10
+ emits: ["update:height", "update:active"],
11
11
  setup(__props, { expose: __expose, emit: __emit }) {
12
12
  const props = __props;
13
13
  const emit = __emit;
@@ -17,7 +17,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
17
17
  if (!elementRef.value) return;
18
18
  emit("update:height", elementRef.value.offsetHeight);
19
19
  };
20
- watch(toRef(props, "isActive"), async (value) => {
20
+ watch(() => props.active, async (value) => {
21
+ if (value) emit("update:active");
21
22
  if (value) await nextTick();
22
23
  emitHeight();
23
24
  if (value) callListeners();
@@ -29,7 +30,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
29
30
  return withDirectives((openBlock(), createElementBlock("div", _hoisted_1, [
30
31
  renderSlot(_ctx.$slots, "default")
31
32
  ], 512)), [
32
- [vShow, _ctx.isActive]
33
+ [vShow, _ctx.active]
33
34
  ]);
34
35
  };
35
36
  }
@@ -0,0 +1,58 @@
1
+ import { CSSProperties } from 'vue';
2
+ declare function __VLS_template(): {
3
+ slots: {
4
+ title?(_: {}): any;
5
+ suffix?(_: {}): any;
6
+ right?(_: {}): any;
7
+ };
8
+ refs: {
9
+ button: HTMLButtonElement;
10
+ };
11
+ attrs: Partial<{}>;
12
+ };
13
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
14
+ declare const __VLS_component: import('vue').DefineComponent<{
15
+ active: boolean;
16
+ index: number;
17
+ hasError: boolean;
18
+ hasChanges: boolean;
19
+ title: string;
20
+ icon: SVGComponent | undefined;
21
+ side?: boolean;
22
+ }, {
23
+ update: () => void;
24
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
25
+ click: (value: MouseEvent) => any;
26
+ "update:indicator-style": (value: CSSProperties) => any;
27
+ "update:scroll-position": (value: {
28
+ left: number;
29
+ } | {
30
+ top: number;
31
+ }) => any;
32
+ }, string, import('vue').PublicProps, Readonly<{
33
+ active: boolean;
34
+ index: number;
35
+ hasError: boolean;
36
+ hasChanges: boolean;
37
+ title: string;
38
+ icon: SVGComponent | undefined;
39
+ side?: boolean;
40
+ }> & Readonly<{
41
+ onClick?: ((value: MouseEvent) => any) | undefined;
42
+ "onUpdate:indicator-style"?: ((value: CSSProperties) => any) | undefined;
43
+ "onUpdate:scroll-position"?: ((value: {
44
+ left: number;
45
+ } | {
46
+ top: number;
47
+ }) => any) | undefined;
48
+ }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
49
+ button: HTMLButtonElement;
50
+ }, any>;
51
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
52
+ export default _default;
53
+ type __VLS_WithTemplateSlots<T, S> = T & {
54
+ new (): {
55
+ $slots: S;
56
+ };
57
+ };
58
+ //# sourceMappingURL=TabTitleButton.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TabTitleButton.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/Tabs/components/TabTitleButton.vue"],"names":[],"mappings":"AA8IA,OAAO,EAAC,KAAK,aAAa,EAA6C,MAAM,KAAK,CAAA;AA0FlF,iBAAS,cAAc;;uBA4HI,GAAG;wBACD,GAAG;uBACJ,GAAG;;;;;WAUjB,OAAO,IAA6B;EAEjD;AAaD,KAAK,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,QAAA,MAAM,eAAe;YA7OX,OAAO;WACR,MAAM;cACH,OAAO;gBACL,OAAO;WACZ,MAAM;UACP,YAAY,GAAG,SAAS;WACvB,OAAO;;;;;;;cAgP8B,MAAM;;aAAU,MAAM;;;YAtP1D,OAAO;WACR,MAAM;cACH,OAAO;gBACL,OAAO;WACZ,MAAM;UACP,YAAY,GAAG,SAAS;WACvB,OAAO;;;;;cAgP8B,MAAM;;aAAU,MAAM;;;;OAIlE,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAAnG,wBAAoG;AAWpG,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACxC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
@@ -0,0 +1,125 @@
1
+ import { defineComponent, useTemplateRef, watch, nextTick, onMounted, openBlock, createElementBlock, createElementVNode, normalizeClass, renderSlot, createBlock, Suspense, withCtx, resolveDynamicComponent, createCommentVNode, createTextVNode, toDisplayString, createVNode, Transition } from 'vue';
2
+
3
+ const _hoisted_1 = { class: "whitespace-nowrap px-4" };
4
+ const _sfc_main = /* @__PURE__ */ defineComponent({
5
+ __name: "TabTitleButton",
6
+ props: {
7
+ active: { type: Boolean },
8
+ index: {},
9
+ hasError: { type: Boolean },
10
+ hasChanges: { type: Boolean },
11
+ title: {},
12
+ icon: {},
13
+ side: { type: Boolean }
14
+ },
15
+ emits: ["click", "update:indicator-style", "update:scroll-position"],
16
+ setup(__props, { expose: __expose, emit: __emit }) {
17
+ const props = __props;
18
+ const emit = __emit;
19
+ const buttonRef = useTemplateRef("button");
20
+ const updateIndicator = () => {
21
+ if (!props.active) return;
22
+ if (!buttonRef.value || !buttonRef.value.offsetWidth) return;
23
+ if (props.side) {
24
+ emit("update:indicator-style", {
25
+ height: buttonRef.value.offsetHeight + "px",
26
+ top: buttonRef.value.offsetTop + "px",
27
+ left: "0",
28
+ width: "0.25rem"
29
+ });
30
+ } else {
31
+ emit("update:indicator-style", {
32
+ width: buttonRef.value.offsetWidth + "px",
33
+ left: buttonRef.value.offsetLeft + "px",
34
+ bottom: "0",
35
+ height: "0.25rem"
36
+ });
37
+ }
38
+ };
39
+ const updateScrollPosition = () => {
40
+ if (!props.active) return;
41
+ if (!buttonRef.value || !buttonRef.value.offsetWidth) return;
42
+ if (props.side) {
43
+ emit("update:scroll-position", { top: buttonRef.value.offsetTop });
44
+ } else {
45
+ emit("update:scroll-position", { left: buttonRef.value.offsetLeft });
46
+ }
47
+ };
48
+ const update = () => {
49
+ updateIndicator();
50
+ updateScrollPosition();
51
+ };
52
+ watch(() => props.active, () => {
53
+ update();
54
+ });
55
+ watch(() => props.index, () => {
56
+ nextTick(update);
57
+ });
58
+ onMounted(() => {
59
+ document.fonts.ready.then(() => {
60
+ update();
61
+ });
62
+ });
63
+ __expose({
64
+ update
65
+ });
66
+ return (_ctx, _cache) => {
67
+ return openBlock(), createElementBlock("button", {
68
+ ref: "button",
69
+ class: "text-description grid cursor-pointer select-none snap-center grid-cols-[1fr,auto] font-semibold outline-none transition-colors duration-500",
70
+ onClick: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("click", $event))
71
+ }, [
72
+ createElementVNode("div", {
73
+ class: normalizeClass(["w-ripple w-ripple-hover relative", {
74
+ "text-primary-default dark:text-primary-dark": _ctx.active && !_ctx.hasError,
75
+ "text-negative dark:text-negative-dark": _ctx.hasError
76
+ }])
77
+ }, [
78
+ _ctx.$slots.title ? renderSlot(_ctx.$slots, "title", { key: 0 }) : (openBlock(), createElementBlock("div", {
79
+ key: 1,
80
+ class: normalizeClass(["flex items-center", {
81
+ "h-10 justify-center text-center": !_ctx.side,
82
+ "py-3 text-start": _ctx.side
83
+ }])
84
+ }, [
85
+ createElementVNode("div", _hoisted_1, [
86
+ _ctx.icon !== void 0 ? (openBlock(), createBlock(Suspense, { key: 0 }, {
87
+ fallback: withCtx(() => _cache[1] || (_cache[1] = [
88
+ createElementVNode("svg", { class: "square-5 -mt-1 inline" }, [
89
+ createElementVNode("g")
90
+ ], -1)
91
+ ])),
92
+ default: withCtx(() => [
93
+ (openBlock(), createBlock(resolveDynamicComponent(_ctx.icon), { class: "square-5 -mt-1 inline" }))
94
+ ]),
95
+ _: 1
96
+ })) : createCommentVNode("", true),
97
+ createTextVNode(" " + toDisplayString(_ctx.title) + " ", 1),
98
+ renderSlot(_ctx.$slots, "suffix")
99
+ ])
100
+ ], 2)),
101
+ createVNode(Transition, {
102
+ "enter-active-class": "transition-opacity",
103
+ "leave-active-class": "transition-opacity",
104
+ "enter-from-class": "opacity-0",
105
+ "leave-to-class": "opacity-0"
106
+ }, {
107
+ default: withCtx(() => [
108
+ _ctx.hasChanges ? (openBlock(), createElementBlock("div", {
109
+ key: 0,
110
+ class: normalizeClass(["square-2 absolute right-0 top-0 rounded-full transition-colors duration-500", {
111
+ "bg-info dark:bg-info-dark": !_ctx.hasError,
112
+ "bg-negative dark:bg-negative-dark": _ctx.hasError
113
+ }])
114
+ }, null, 2)) : createCommentVNode("", true)
115
+ ]),
116
+ _: 1
117
+ })
118
+ ], 2),
119
+ renderSlot(_ctx.$slots, "right")
120
+ ], 512);
121
+ };
122
+ }
123
+ });
124
+
125
+ export { _sfc_main as default };
@@ -0,0 +1,5 @@
1
+ import _sfc_main from './TabTitleButton.vue.js';
2
+
3
+
4
+
5
+ export { _sfc_main as default };