@katlux/toolkit 0.1.0-beta.75 → 0.1.0-beta.77

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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@katlux/toolkit",
3
3
  "configKey": "katluxToolkit",
4
- "version": "0.1.0-beta.75",
4
+ "version": "0.1.0-beta.77",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -122,10 +122,10 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
122
122
  }>, {
123
123
  label: string;
124
124
  isOpen: boolean;
125
+ day: string | Date;
125
126
  validation: "error" | "success" | "warning" | null | undefined;
126
127
  validationText: string;
127
128
  modelValue: string | Date;
128
- day: string | Date;
129
129
  placeholder: string;
130
130
  teleportTo: string;
131
131
  showClear: boolean;
@@ -122,10 +122,10 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
122
122
  }>, {
123
123
  label: string;
124
124
  isOpen: boolean;
125
+ day: string | Date;
125
126
  validation: "error" | "success" | "warning" | null | undefined;
126
127
  validationText: string;
127
128
  modelValue: string | Date;
128
- day: string | Date;
129
129
  placeholder: string;
130
130
  teleportTo: string;
131
131
  showClear: boolean;
@@ -128,10 +128,10 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
128
128
  }>, {
129
129
  label: string;
130
130
  isOpen: boolean;
131
+ day: string | Date;
131
132
  validation: "error" | "success" | "warning" | null | undefined;
132
133
  validationText: string;
133
134
  modelValue: string | Date;
134
- day: string | Date;
135
135
  placeholder: string;
136
136
  teleportTo: string;
137
137
  showClear: boolean;
@@ -128,10 +128,10 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
128
128
  }>, {
129
129
  label: string;
130
130
  isOpen: boolean;
131
+ day: string | Date;
131
132
  validation: "error" | "success" | "warning" | null | undefined;
132
133
  validationText: string;
133
134
  modelValue: string | Date;
134
- day: string | Date;
135
135
  placeholder: string;
136
136
  teleportTo: string;
137
137
  showClear: boolean;
@@ -0,0 +1,23 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
2
+ modelValue: {
3
+ type: import("vue").PropType<import("./MultiTabs.logic.js").MultiTabsGroup[]>;
4
+ default: undefined;
5
+ };
6
+ }>, {
7
+ addTab: (tab: import("./MultiTabs.logic.js").MultiTabsTab, groupId?: string) => void;
8
+ splitScreen: (initialTab?: import("./MultiTabs.logic.js").MultiTabsTab) => string;
9
+ closeSplit: (groupId: string) => void;
10
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
11
+ "update:modelValue": (...args: any[]) => void;
12
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
13
+ modelValue: {
14
+ type: import("vue").PropType<import("./MultiTabs.logic.js").MultiTabsGroup[]>;
15
+ default: undefined;
16
+ };
17
+ }>> & Readonly<{
18
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
19
+ }>, {
20
+ modelValue: import("./MultiTabs.logic.js").MultiTabsGroup[];
21
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
22
+ declare const _default: typeof __VLS_export;
23
+ export default _default;
@@ -0,0 +1,27 @@
1
+ <script setup>
2
+ import { useMultiTabsLogic, MultiTabsDefaultProps } from "./MultiTabs.logic";
3
+ import { usePresetComponent } from "../../composables/usePresetComponent";
4
+ import { computed } from "vue";
5
+ import MultiTabsDefault from "../../presets/default/components/MultiTabs/MultiTabs.vue";
6
+ const props = defineProps(MultiTabsDefaultProps);
7
+ const emit = defineEmits(["update:modelValue"]);
8
+ const { groups, addTab, splitScreen, closeSplit } = useMultiTabsLogic(props, emit);
9
+ const presetComponent = usePresetComponent("MultiTabs", MultiTabsDefault);
10
+ const templateProps = computed(() => ({
11
+ groups: groups.value,
12
+ addTab,
13
+ splitScreen,
14
+ closeSplit
15
+ }));
16
+ defineExpose({
17
+ addTab,
18
+ splitScreen,
19
+ closeSplit
20
+ });
21
+ </script>
22
+
23
+ <template lang="pug">
24
+ component(:is="presetComponent" v-bind="templateProps")
25
+ template(v-for="(_, slot) in $slots" #[slot]="scope")
26
+ slot(:name="slot" v-bind="scope")
27
+ </template>
@@ -0,0 +1,23 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
2
+ modelValue: {
3
+ type: import("vue").PropType<import("./MultiTabs.logic.js").MultiTabsGroup[]>;
4
+ default: undefined;
5
+ };
6
+ }>, {
7
+ addTab: (tab: import("./MultiTabs.logic.js").MultiTabsTab, groupId?: string) => void;
8
+ splitScreen: (initialTab?: import("./MultiTabs.logic.js").MultiTabsTab) => string;
9
+ closeSplit: (groupId: string) => void;
10
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
11
+ "update:modelValue": (...args: any[]) => void;
12
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
13
+ modelValue: {
14
+ type: import("vue").PropType<import("./MultiTabs.logic.js").MultiTabsGroup[]>;
15
+ default: undefined;
16
+ };
17
+ }>> & Readonly<{
18
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
19
+ }>, {
20
+ modelValue: import("./MultiTabs.logic.js").MultiTabsGroup[];
21
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
22
+ declare const _default: typeof __VLS_export;
23
+ export default _default;
@@ -0,0 +1,25 @@
1
+ import { type PropType } from 'vue';
2
+ export interface MultiTabsTab {
3
+ id: string;
4
+ title: string;
5
+ slotName?: string;
6
+ component?: any;
7
+ props?: Record<string, any>;
8
+ isOpen?: boolean;
9
+ }
10
+ export interface MultiTabsGroup {
11
+ id: string;
12
+ tabs: MultiTabsTab[];
13
+ }
14
+ export declare const MultiTabsDefaultProps: {
15
+ modelValue: {
16
+ type: PropType<MultiTabsGroup[]>;
17
+ default: undefined;
18
+ };
19
+ };
20
+ export declare function useMultiTabsLogic(props: any, emit: any): {
21
+ groups: import("vue").WritableComputedRef<any, any>;
22
+ addTab: (tab: MultiTabsTab, groupId?: string) => void;
23
+ splitScreen: (initialTab?: MultiTabsTab) => string;
24
+ closeSplit: (groupId: string) => void;
25
+ };
@@ -0,0 +1,52 @@
1
+ import { ref, computed } from "vue";
2
+ export const MultiTabsDefaultProps = {
3
+ modelValue: {
4
+ type: Array,
5
+ default: void 0
6
+ }
7
+ };
8
+ export function useMultiTabsLogic(props, emit) {
9
+ const internalGroups = ref([{ id: "default", tabs: [] }]);
10
+ const groups = computed({
11
+ get: () => props.modelValue || internalGroups.value,
12
+ set: (val) => {
13
+ emit("update:modelValue", val);
14
+ if (props.modelValue === void 0) {
15
+ internalGroups.value = val;
16
+ }
17
+ }
18
+ });
19
+ const addTab = (tab, groupId) => {
20
+ const gs = [...groups.value];
21
+ const targetGroupId = groupId || gs[0]?.id;
22
+ const group = gs.find((g) => g.id === targetGroupId);
23
+ if (group) {
24
+ group.tabs.forEach((t) => t.isOpen = false);
25
+ const existingTabIndex = group.tabs.findIndex((t) => t.id === tab.id);
26
+ if (existingTabIndex >= 0) {
27
+ group.tabs[existingTabIndex].isOpen = true;
28
+ } else {
29
+ group.tabs.push({ ...tab, isOpen: true });
30
+ }
31
+ groups.value = gs;
32
+ }
33
+ };
34
+ const splitScreen = (initialTab) => {
35
+ const gs = [...groups.value];
36
+ const newId = `group-${Date.now()}`;
37
+ const tabs = initialTab ? [{ ...initialTab, isOpen: true }] : [];
38
+ gs.push({ id: newId, tabs });
39
+ groups.value = gs;
40
+ return newId;
41
+ };
42
+ const closeSplit = (groupId) => {
43
+ const gs = groups.value.filter((g) => g.id !== groupId);
44
+ groups.value = gs.length > 0 ? gs : [{ id: "default", tabs: [] }];
45
+ };
46
+ return {
47
+ groups,
48
+ addTab,
49
+ splitScreen,
50
+ closeSplit
51
+ };
52
+ }
@@ -14,6 +14,7 @@ const props = defineProps<{
14
14
  display: flex;
15
15
  gap: var(--grid-gap);
16
16
  box-sizing: border-box;
17
+ min-width: 0;
17
18
 
18
19
  &.direction-row {
19
20
  flex-direction: row;
@@ -36,10 +36,12 @@ const props = withDefaults(defineProps<{
36
36
  background-color: color-mix(in srgb, var(--current-panel-bg), transparent calc((1 - var(--panel-bg-opacity)) * 100%));
37
37
  backdrop-filter: blur(var(--panel-blur));
38
38
  width: 100%;
39
+ min-width: 0;
39
40
  display: flex;
40
41
  flex-direction: column;
41
42
  overflow: hidden;
42
43
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
44
+ box-sizing: border-box;
43
45
 
44
46
  &.type-primary {
45
47
  --current-panel-bg: var(--panel-bg-primary);
@@ -68,7 +70,7 @@ const props = withDefaults(defineProps<{
68
70
  }
69
71
 
70
72
  &:hover {
71
- transform: translateY(-2px);
73
+ //transform: translateY(-2px);
72
74
  box-shadow: var(--shadow-lg);
73
75
  }
74
76
 
@@ -2,18 +2,112 @@
2
2
  .KTab
3
3
  KPanel
4
4
  template(#header)
5
- KGrid(direction="row")
6
- KButton(v-for="(item, index) of items" @click="toggleItem(index)" size="small" :disabled="isOpen(index)") {{item.title}}
5
+ .k-tabs-nav
6
+ KButton.k-tabs-nav-btn(v-if="hasOverflow" @click="scroll(-1)" size="small") &lt;
7
+ .k-tabs-scroll-area(ref="scrollArea")
8
+ KGrid(direction="row" wrap="nowrap")
9
+ KButton.k-tab-btn(
10
+ v-for="(item, index) of items"
11
+ :key="index"
12
+ @click="toggleItem(index)"
13
+ size="small"
14
+ :disabled="isOpen(index)"
15
+ ) {{item.title}}
16
+ KButton.k-tabs-nav-btn(v-if="hasOverflow" @click="scroll(1)" size="small") &gt;
7
17
  slot
8
18
  </template>
9
19
 
10
20
  <script lang="ts" setup>
21
+ import { ref, onMounted, onUnmounted, watch, nextTick } from 'vue'
22
+
11
23
  const props = defineProps<{
12
24
  items: any[]
13
25
  toggleItem: (index: number) => void
14
26
  isOpen: (index: number) => boolean
15
27
  }>()
28
+
29
+ const scrollArea = ref<HTMLElement | null>(null)
30
+ const hasOverflow = ref(false)
31
+ let resizeObserver: ResizeObserver | null = null
32
+
33
+ const checkOverflow = () => {
34
+ if (!scrollArea.value) return
35
+ const el = scrollArea.value
36
+ // Compare the inner KGrid's natural width vs the scroll area's offset width.
37
+ // Using offsetWidth (not clientWidth) avoids being affected by the scroll area itself.
38
+ const inner = el.firstElementChild as HTMLElement | null
39
+ if (inner) {
40
+ hasOverflow.value = inner.scrollWidth > el.offsetWidth + 1
41
+ }
42
+ }
43
+
44
+ onMounted(() => {
45
+ nextTick(() => checkOverflow())
46
+ resizeObserver = new ResizeObserver(() => checkOverflow())
47
+ if (scrollArea.value) {
48
+ // Only observe the scroll area container — NOT the inner KGrid.
49
+ // Observing the inner KGrid would cause a feedback loop when nav buttons
50
+ // appear/disappear, since that changes the scroll area's clientWidth,
51
+ // which triggers another resize event, which flips hasOverflow again.
52
+ resizeObserver.observe(scrollArea.value)
53
+ }
54
+ })
55
+
56
+ onUnmounted(() => {
57
+ resizeObserver?.disconnect()
58
+ })
59
+
60
+ watch(() => props.items.length, async () => {
61
+ await nextTick()
62
+ checkOverflow()
63
+ })
64
+
65
+ const scroll = (direction: number) => {
66
+ scrollArea.value?.scrollBy({ left: 200 * direction, behavior: 'smooth' })
67
+ }
16
68
  </script>
17
69
 
18
70
  <style lang="scss" scoped>
71
+ .KTab {
72
+ max-width: 100%;
73
+ min-width: 0;
74
+ }
75
+
76
+ :deep(.KPanel--header) {
77
+ overflow: hidden;
78
+ min-width: 0;
79
+ }
80
+
81
+ .k-tabs-nav {
82
+ display: flex;
83
+ align-items: center;
84
+ min-width: 0;
85
+ overflow: hidden;
86
+ }
87
+
88
+ .k-tabs-scroll-area {
89
+ flex: 1 1 0px;
90
+ overflow-x: auto;
91
+ min-width: 0;
92
+ max-width: 100%;
93
+ scroll-snap-type: x mandatory;
94
+ scroll-behavior: smooth;
95
+
96
+ /* Hide scrollbar */
97
+ -ms-overflow-style: none;
98
+ scrollbar-width: none;
99
+ &::-webkit-scrollbar {
100
+ display: none;
101
+ }
102
+ }
103
+
104
+ .k-tab-btn {
105
+ scroll-snap-align: center;
106
+ flex-shrink: 0;
107
+ }
108
+
109
+ .k-tabs-nav-btn {
110
+ flex-shrink: 0;
111
+ margin: 0 8px;
112
+ }
19
113
  </style>
@@ -0,0 +1,9 @@
1
+ type __VLS_Props = {
2
+ groups: any[];
3
+ addTab: (tab: any, groupId?: string) => void;
4
+ splitScreen: (initialTab?: any) => string;
5
+ closeSplit: (groupId: string) => void;
6
+ };
7
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
+ declare const _default: typeof __VLS_export;
9
+ export default _default;
@@ -0,0 +1,55 @@
1
+ <template lang="pug">
2
+ KGrid.multi-tabs(direction="row" align="stretch" flexChild)
3
+ template(v-for="(group, groupIndex) in groups" :key="group.id || groupIndex")
4
+ KTabs.multi-tabs-tabs(v-if="group.tabs && group.tabs.length > 0")
5
+ KTabItem(v-for="tab in group.tabs" :key="tab.id" :title="tab.title" :isOpen="tab.isOpen")
6
+ .multi-tabs-tab-content
7
+ slot(:name="tab.slotName || tab.id" :tab="tab")
8
+ component(v-if="tab.component" :is="tab.component" v-bind="tab.props")
9
+ .multi-tabs-empty(v-else)
10
+ slot(name="empty" :group="group")
11
+ span No tabs open
12
+ </template>
13
+
14
+ <script lang="ts" setup>
15
+ const props = defineProps<{
16
+ groups: any[]
17
+ addTab: (tab: any, groupId?: string) => void
18
+ splitScreen: (initialTab?: any) => string
19
+ closeSplit: (groupId: string) => void
20
+ }>()
21
+ </script>
22
+
23
+ <style lang="scss" scoped>
24
+ .multi-tabs {
25
+ width: 100%;
26
+ height: 100%;
27
+ overflow: hidden;
28
+ }
29
+
30
+ .multi-tabs-empty {
31
+ display: flex;
32
+ align-items: center;
33
+ justify-content: center;
34
+ height: 100%;
35
+ flex: 1 1 0%;
36
+ min-width: 0;
37
+ }
38
+ .multi-tabs-tabs {
39
+ box-sizing: border-box;
40
+
41
+ flex: 1 1 0%;
42
+ min-width: 0;
43
+ display: flex;
44
+ flex-direction: column;
45
+ > * {
46
+ height: 100%;
47
+ min-width: 0;
48
+ }
49
+ }
50
+ .multi-tabs-tab-content {
51
+ padding: 1rem;
52
+ height: 100%;
53
+ overflow: auto;
54
+ }
55
+ </style>
@@ -0,0 +1,9 @@
1
+ type __VLS_Props = {
2
+ groups: any[];
3
+ addTab: (tab: any, groupId?: string) => void;
4
+ splitScreen: (initialTab?: any) => string;
5
+ closeSplit: (groupId: string) => void;
6
+ };
7
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
+ declare const _default: typeof __VLS_export;
9
+ export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@katlux/toolkit",
3
- "version": "0.1.0-beta.75",
3
+ "version": "0.1.0-beta.77",
4
4
  "description": "Core UI toolkit and utilities for the Katlux ecosystem",
5
5
  "author": "Katlux",
6
6
  "license": "MIT",