@fiscozen/tab 3.0.0 → 3.0.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @fiscozen/tab
2
2
 
3
+ ## 3.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [34a7934]
8
+ - @fiscozen/composables@1.0.3
9
+
10
+ ## 3.0.1
11
+
12
+ ### Patch Changes
13
+
14
+ - 51aba38: Fix FzTab componenent identification
15
+
3
16
  ## 3.0.0
4
17
 
5
18
  ### Patch Changes
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@fiscozen/tab",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "description": "Design System Tab component",
5
5
  "main": "src/index.ts",
6
6
  "type": "module",
7
7
  "keywords": [],
8
8
  "author": "Cristian Barraco",
9
9
  "dependencies": {
10
- "@fiscozen/composables": "1.0.2",
11
- "@fiscozen/style": "0.3.0",
12
10
  "@fiscozen/action": "3.0.0",
13
- "@fiscozen/badge": "3.0.0"
11
+ "@fiscozen/style": "0.3.0",
12
+ "@fiscozen/badge": "3.0.0",
13
+ "@fiscozen/composables": "1.0.3"
14
14
  },
15
15
  "peerDependencies": {
16
16
  "tailwindcss": "^3.4.1",
@@ -33,9 +33,9 @@
33
33
  "vite-plugin-dts": "^3.8.3",
34
34
  "vitest": "^1.2.0",
35
35
  "vue-tsc": "^1.8.25",
36
+ "@fiscozen/prettier-config": "^0.1.0",
36
37
  "@fiscozen/tsconfig": "^0.1.0",
37
- "@fiscozen/eslint-config": "^0.1.0",
38
- "@fiscozen/prettier-config": "^0.1.0"
38
+ "@fiscozen/eslint-config": "^0.1.0"
39
39
  },
40
40
  "license": "MIT",
41
41
  "scripts": {
package/src/FzTab.vue CHANGED
@@ -6,6 +6,8 @@
6
6
  import { inject, onMounted, Ref, computed, onBeforeUnmount } from "vue";
7
7
  import { FzTabProps } from "./types";
8
8
 
9
+ defineOptions({ _isFzTab: true });
10
+
9
11
  const props = defineProps<FzTabProps>();
10
12
 
11
13
  const selectedTab = inject<Ref<string>>("selectedTab");
package/src/FzTabs.vue CHANGED
@@ -40,9 +40,15 @@ import { computed, ref, onMounted, provide, useSlots, watch, VNode } from "vue";
40
40
  import { FzTabsProps, FzTabProps, FzTabStyle } from "./types";
41
41
  import FzTabPicker from "./components/FzTabPicker.vue";
42
42
  import FzTabButton from "./components/FzTabButton.vue";
43
- import FzTab from "./FzTab.vue";
44
43
  import { debugWarn, mapSizeToEnvironment } from "./common";
45
44
 
45
+ /**
46
+ * Identifies FzTab vnodes via marker instead of reference identity.
47
+ * Avoids module deduplication issues when the package is excluded from Vite's optimizeDeps.
48
+ */
49
+ const isFzTab = (vnode: VNode): boolean =>
50
+ (vnode.type as any)?._isFzTab === true;
51
+
46
52
  const props = withDefaults(defineProps<FzTabsProps>(), {
47
53
  vertical: false,
48
54
  horizontalOverflow: undefined,
@@ -64,17 +70,17 @@ const tabs = computed(() => {
64
70
  return slots
65
71
  .default()
66
72
  .filter((tab) => {
67
- return tab.type === FzTab || typeof tab.type === "symbol";
73
+ return isFzTab(tab) || typeof tab.type === "symbol";
68
74
  })
69
75
  .map((tab) => {
70
- if (tab.type === FzTab) return tab.props as FzTabProps;
76
+ if (isFzTab(tab)) return tab.props as FzTabProps;
71
77
 
72
78
  if (typeof tab.type === "symbol") {
73
79
  const children = tab.children as VNode[] | "v-if";
74
80
  if (!children || children === "v-if") return null;
75
81
 
76
82
  return children
77
- .filter((child) => child.type === FzTab)
83
+ .filter((child) => isFzTab(child))
78
84
  .map((child) => child.props as FzTabProps);
79
85
  }
80
86
  })
@@ -1,6 +1,6 @@
1
1
  import { mount } from "@vue/test-utils";
2
2
  import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
3
- import { h } from "vue";
3
+ import { defineComponent, h } from "vue";
4
4
  import { FzTab, FzTabs } from "..";
5
5
  import { FzTabProps, FzTabsProps } from "../types";
6
6
 
@@ -932,6 +932,37 @@ describe("FzTabs", () => {
932
932
  });
933
933
  });
934
934
 
935
+ // ============================================
936
+ // TAB IDENTIFICATION (marker-based)
937
+ // ============================================
938
+ describe("Tab identification", () => {
939
+ it("should have _isFzTab marker on FzTab component", () => {
940
+ expect((FzTab as any)._isFzTab).toBe(true);
941
+ });
942
+
943
+ it("should not render non-FzTab components as tabs", async () => {
944
+ const FakeTab = defineComponent({
945
+ props: { title: String },
946
+ template: "<div>Fake</div>",
947
+ });
948
+
949
+ const wrapper = mount(FzTabs, {
950
+ props: { isDebug: true } as FzTabsProps,
951
+ slots: {
952
+ default: () => [
953
+ h(FzTab, { title: "real" }, "Real content"),
954
+ h(FakeTab, { title: "fake" }, "Fake content"),
955
+ ],
956
+ },
957
+ });
958
+
959
+ await wrapper.vm.$nextTick();
960
+ const buttons = wrapper.findAll("button[title]");
961
+ expect(buttons).toHaveLength(1);
962
+ expect(buttons[0].attributes("title")).toBe("real");
963
+ });
964
+ });
965
+
935
966
  // ============================================
936
967
  // EDGE CASES
937
968
  // ============================================