@katlux/toolkit 0.1.1-alpha.118 → 0.1.1-alpha.120

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 (139) hide show
  1. package/bin/create-preset.mjs +5 -4
  2. package/dist/compiled/composables/useDataProvider.mjs +20 -0
  3. package/dist/compiled/composables/useKatluxContext.mjs +6 -3
  4. package/dist/compiled/composables/useKatluxForm.mjs +311 -0
  5. package/dist/compiled/composables/useToast.mjs +164 -0
  6. package/dist/compiled/composables/useVirtualScroll.mjs +246 -0
  7. package/dist/module.cjs +1 -0
  8. package/dist/module.json +1 -1
  9. package/dist/module.mjs +1 -0
  10. package/dist/runtime/components/KBulkActions/KBulkActions.global.d.vue.ts +6 -2
  11. package/dist/runtime/components/KBulkActions/KBulkActions.global.vue +3 -3
  12. package/dist/runtime/components/KBulkActions/KBulkActions.global.vue.d.ts +6 -2
  13. package/dist/runtime/components/KBulkActions/KBulkActions.logic.js +21 -6
  14. package/dist/runtime/components/KCheckbox/KCheckbox.global.d.vue.ts +12 -0
  15. package/dist/runtime/components/KCheckbox/KCheckbox.global.vue +4 -2
  16. package/dist/runtime/components/KCheckbox/KCheckbox.global.vue.d.ts +12 -0
  17. package/dist/runtime/components/KCheckbox/KCheckbox.logic.d.ts +5 -0
  18. package/dist/runtime/components/KCheckbox/KCheckbox.logic.js +4 -0
  19. package/dist/runtime/components/KCombobox/KCombobox.global.d.vue.ts +11 -0
  20. package/dist/runtime/components/KCombobox/KCombobox.global.vue +4 -3
  21. package/dist/runtime/components/KCombobox/KCombobox.global.vue.d.ts +11 -0
  22. package/dist/runtime/components/KCombobox/KCombobox.logic.d.ts +6 -0
  23. package/dist/runtime/components/KCombobox/KCombobox.logic.js +22 -3
  24. package/dist/runtime/components/KDatatable/KDataIterator.global.d.vue.ts +8 -0
  25. package/dist/runtime/components/KDatatable/KDataIterator.global.vue +10 -2
  26. package/dist/runtime/components/KDatatable/KDataIterator.global.vue.d.ts +8 -0
  27. package/dist/runtime/components/KDatatable/KDataIterator.logic.d.ts +8 -0
  28. package/dist/runtime/components/KDatatable/KDataIterator.logic.js +10 -2
  29. package/dist/runtime/components/KDatatable/KDatatable.global.d.vue.ts +8 -0
  30. package/dist/runtime/components/KDatatable/KDatatable.global.vue +12 -4
  31. package/dist/runtime/components/KDatatable/KDatatable.global.vue.d.ts +8 -0
  32. package/dist/runtime/components/KDatatable/KDatatable.logic.d.ts +8 -0
  33. package/dist/runtime/components/KDatatable/KDatatable.logic.js +28 -5
  34. package/dist/runtime/components/KDatePicker/KDatePicker.global.d.vue.ts +4 -0
  35. package/dist/runtime/components/KDatePicker/KDatePicker.global.vue +6 -1
  36. package/dist/runtime/components/KDatePicker/KDatePicker.global.vue.d.ts +4 -0
  37. package/dist/runtime/components/KDatePicker/KDatePicker.logic.js +7 -6
  38. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.logic.js +7 -6
  39. package/dist/runtime/components/KDropdown/KDropdown.global.d.vue.ts +9 -0
  40. package/dist/runtime/components/KDropdown/KDropdown.global.vue +2 -1
  41. package/dist/runtime/components/KDropdown/KDropdown.global.vue.d.ts +9 -0
  42. package/dist/runtime/components/KDropdown/KDropdown.logic.d.ts +5 -0
  43. package/dist/runtime/components/KDropdown/KDropdown.logic.js +10 -7
  44. package/dist/runtime/components/KGantt/KGantt.logic.js +5 -3
  45. package/dist/runtime/components/KPagination/KPagination.global.d.vue.ts +2 -0
  46. package/dist/runtime/components/KPagination/KPagination.global.vue +1 -1
  47. package/dist/runtime/components/KPagination/KPagination.global.vue.d.ts +2 -0
  48. package/dist/runtime/components/KPagination/KPagination.logic.d.ts +1 -0
  49. package/dist/runtime/components/KPagination/KPagination.logic.js +11 -3
  50. package/dist/runtime/components/KToast/KToast.global.d.vue.ts +24 -1
  51. package/dist/runtime/components/KToast/KToast.global.vue +12 -2
  52. package/dist/runtime/components/KToast/KToast.global.vue.d.ts +24 -1
  53. package/dist/runtime/components/KToast/KToast.logic.d.ts +13 -0
  54. package/dist/runtime/components/KToast/KToast.logic.js +45 -5
  55. package/dist/runtime/components/KToastContainer/KToastContainer.global.d.vue.ts +3 -0
  56. package/dist/runtime/components/KToastContainer/KToastContainer.global.vue +11 -0
  57. package/dist/runtime/components/KToastContainer/KToastContainer.global.vue.d.ts +3 -0
  58. package/dist/runtime/components/KTooltip/KTooltip.global.d.vue.ts +1 -1
  59. package/dist/runtime/components/KTooltip/KTooltip.global.vue.d.ts +1 -1
  60. package/dist/runtime/components/KTree/KTree.global.d.vue.ts +39 -1
  61. package/dist/runtime/components/KTree/KTree.global.vue +7 -4
  62. package/dist/runtime/components/KTree/KTree.global.vue.d.ts +39 -1
  63. package/dist/runtime/components/KTree/KTree.logic.d.ts +21 -0
  64. package/dist/runtime/components/KTree/KTree.logic.js +17 -0
  65. package/dist/runtime/components/KTreePicker/KTreePicker.global.d.vue.ts +53 -2
  66. package/dist/runtime/components/KTreePicker/KTreePicker.global.vue +30 -3
  67. package/dist/runtime/components/KTreePicker/KTreePicker.global.vue.d.ts +53 -2
  68. package/dist/runtime/components/KTreePicker/KTreePicker.logic.d.ts +20 -0
  69. package/dist/runtime/components/KTreePicker/KTreePicker.logic.js +16 -0
  70. package/dist/runtime/components/KTreeView/KTreeView.global.d.vue.ts +37 -1
  71. package/dist/runtime/components/KTreeView/KTreeView.global.vue +5 -1
  72. package/dist/runtime/components/KTreeView/KTreeView.global.vue.d.ts +37 -1
  73. package/dist/runtime/components/KTreeView/KTreeView.logic.d.ts +20 -0
  74. package/dist/runtime/components/KTreeView/KTreeView.logic.js +16 -0
  75. package/dist/runtime/composables/useDataProvider.d.ts +1 -0
  76. package/dist/runtime/composables/useDataProvider.js +20 -0
  77. package/dist/runtime/composables/useKatluxContext.js +6 -3
  78. package/dist/runtime/composables/useKatluxForm.d.ts +145 -0
  79. package/dist/runtime/composables/useKatluxForm.js +311 -0
  80. package/dist/runtime/composables/useToast.d.ts +49 -0
  81. package/dist/runtime/composables/useToast.js +164 -0
  82. package/dist/runtime/composables/useVirtualScroll.d.ts +34 -0
  83. package/dist/runtime/composables/useVirtualScroll.js +246 -0
  84. package/dist/runtime/plugins/PresetPlugin.js +9 -1
  85. package/dist/runtime/plugins/nuxtCompatPlugin.js +0 -1
  86. package/dist/runtime/plugins/toastPlugin.client.d.ts +2 -0
  87. package/dist/runtime/plugins/toastPlugin.client.js +16 -0
  88. package/dist/runtime/presets/default/components/KBulkActions/KBulkActions.vue +1 -0
  89. package/dist/runtime/presets/default/components/KCheckbox/KCheckbox.d.vue.ts +3 -0
  90. package/dist/runtime/presets/default/components/KCheckbox/KCheckbox.vue +43 -7
  91. package/dist/runtime/presets/default/components/KCheckbox/KCheckbox.vue.d.ts +3 -0
  92. package/dist/runtime/presets/default/components/KCombobox/KCombobox.d.vue.ts +3 -0
  93. package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue +12 -4
  94. package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue.d.ts +3 -0
  95. package/dist/runtime/presets/default/components/KCombobox/KComboboxList.d.vue.ts +1 -0
  96. package/dist/runtime/presets/default/components/KCombobox/KComboboxList.vue +7 -2
  97. package/dist/runtime/presets/default/components/KCombobox/KComboboxList.vue.d.ts +1 -0
  98. package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.d.vue.ts +12 -1
  99. package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.vue +143 -7
  100. package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.vue.d.ts +12 -1
  101. package/dist/runtime/presets/default/components/KDatatable/KDatatable.d.vue.ts +12 -1
  102. package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue +228 -32
  103. package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue.d.ts +12 -1
  104. package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.d.vue.ts +3 -1
  105. package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.vue +3 -1
  106. package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.vue.d.ts +3 -1
  107. package/dist/runtime/presets/default/components/KDropdown/KDropdown.d.vue.ts +1 -0
  108. package/dist/runtime/presets/default/components/KDropdown/KDropdown.vue +23 -2
  109. package/dist/runtime/presets/default/components/KDropdown/KDropdown.vue.d.ts +1 -0
  110. package/dist/runtime/presets/default/components/KLayout/KLayout.d.vue.ts +6 -1
  111. package/dist/runtime/presets/default/components/KLayout/KLayout.vue +37 -3
  112. package/dist/runtime/presets/default/components/KLayout/KLayout.vue.d.ts +6 -1
  113. package/dist/runtime/presets/default/components/KModal/KModal.vue +8 -1
  114. package/dist/runtime/presets/default/components/KTabs/KTabItem.vue +1 -1
  115. package/dist/runtime/presets/default/components/KTextbox/KTextbox.vue +6 -4
  116. package/dist/runtime/presets/default/components/KToast/KToast.d.vue.ts +6 -0
  117. package/dist/runtime/presets/default/components/KToast/KToast.vue +21 -4
  118. package/dist/runtime/presets/default/components/KToast/KToast.vue.d.ts +6 -0
  119. package/dist/runtime/presets/default/components/KToastContainer/KToastContainer.d.vue.ts +11 -0
  120. package/dist/runtime/presets/default/components/KToastContainer/KToastContainer.vue +206 -0
  121. package/dist/runtime/presets/default/components/KToastContainer/KToastContainer.vue.d.ts +11 -0
  122. package/dist/runtime/presets/default/components/KTree/KTree.d.vue.ts +15 -6
  123. package/dist/runtime/presets/default/components/KTree/KTree.vue +235 -14
  124. package/dist/runtime/presets/default/components/KTree/KTree.vue.d.ts +15 -6
  125. package/dist/runtime/presets/default/components/KTreePicker/KTreePicker.d.vue.ts +14 -1
  126. package/dist/runtime/presets/default/components/KTreePicker/KTreePicker.vue +118 -13
  127. package/dist/runtime/presets/default/components/KTreePicker/KTreePicker.vue.d.ts +14 -1
  128. package/dist/runtime/presets/default/components/KTreeView/KTreeCell.vue +12 -3
  129. package/dist/runtime/presets/default/components/KTreeView/KTreeView.d.vue.ts +4 -0
  130. package/dist/runtime/presets/default/components/KTreeView/KTreeView.vue +8 -0
  131. package/dist/runtime/presets/default/components/KTreeView/KTreeView.vue.d.ts +4 -0
  132. package/dist/runtime/server/middleware/session.js +1 -1
  133. package/package.json +3 -4
  134. package/dist/compiled/composables/useDataProvider.spec.mjs +0 -157
  135. package/dist/compiled/composables/useKatluxContext.spec.mjs +0 -63
  136. package/dist/compiled/composables/useKatluxI18n.spec.mjs +0 -10
  137. package/dist/compiled/composables/usePresetComponent.spec.mjs +0 -106
  138. package/dist/compiled/composables/useTemplate.spec.mjs +0 -30
  139. package/dist/compiled/utils/PresetResolver.spec.mjs +0 -68
@@ -9,6 +9,7 @@
9
9
  @click.stop="textboxClicked"
10
10
  :showClear="showClear"
11
11
  @clear="onClear"
12
+ @blur="emit('blur', $event)"
12
13
  :validation="validation"
13
14
  :validationText="validationText"
14
15
  )
@@ -39,7 +40,7 @@ const props = defineProps<{
39
40
  dateSelected: (date: Date) => void
40
41
  teleportTo?: string
41
42
  placeholder?: string
42
- validation?: 'success' | 'warning' | 'error' | null
43
+ validation?: 'success' | 'warning' | null | 'error'
43
44
  validationText?: string
44
45
  align?: 'left' | 'right'
45
46
  }>()
@@ -47,6 +48,7 @@ const props = defineProps<{
47
48
  const emit = defineEmits<{
48
49
  (e: 'update:maskedModel', value: string): void
49
50
  (e: 'update:calendarShow', value: boolean): void
51
+ (e: 'blur', event: FocusEvent): void
50
52
  }>()
51
53
 
52
54
  const maskedModel = computed({
@@ -14,14 +14,16 @@ type __VLS_Props = {
14
14
  dateSelected: (date: Date) => void;
15
15
  teleportTo?: string;
16
16
  placeholder?: string;
17
- validation?: 'success' | 'warning' | 'error' | null;
17
+ validation?: 'success' | 'warning' | null | 'error';
18
18
  validationText?: string;
19
19
  align?: 'left' | 'right';
20
20
  };
21
21
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
22
+ blur: (event: FocusEvent) => any;
22
23
  "update:maskedModel": (value: string) => any;
23
24
  "update:calendarShow": (value: boolean) => any;
24
25
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
26
+ onBlur?: ((event: FocusEvent) => any) | undefined;
25
27
  "onUpdate:maskedModel"?: ((value: string) => any) | undefined;
26
28
  "onUpdate:calendarShow"?: ((value: boolean) => any) | undefined;
27
29
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -18,6 +18,7 @@ type __VLS_Props = {
18
18
  isInModal: boolean;
19
19
  align?: string;
20
20
  direction?: string;
21
+ updatePosition?: () => void;
21
22
  };
22
23
  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>;
23
24
  declare const _default: typeof __VLS_export;
@@ -2,13 +2,13 @@
2
2
  .KDropdown-source
3
3
  Teleport(v-if="isMounted && open && teleportTarget" :to="teleportTarget")
4
4
  .KDropdown-teleported
5
- .KDropdown(v-click-outside="{ handler: clickoutside, extraInside: anchorEl }" :style="dialogStyle" v-bind="$attrs")
5
+ .KDropdown(ref="dropdownEl" v-click-outside="{ handler: clickoutside, extraInside: anchorEl }" :style="dialogStyle" v-bind="$attrs")
6
6
  KPanel.KDropdown-container(:class="{'fullWidth': fullWidth}" :style="contentStyle")
7
7
  slot
8
8
  </template>
9
9
 
10
10
  <script lang="ts" setup>
11
- import { computed, ref, onMounted, onBeforeUnmount, watch } from 'vue'
11
+ import { computed, ref, onMounted, onBeforeUnmount, watch, nextTick } from 'vue'
12
12
 
13
13
  defineOptions({
14
14
  inheritAttrs: false
@@ -34,9 +34,13 @@ const props = defineProps<{
34
34
  isInModal: boolean
35
35
  align?: string
36
36
  direction?: string
37
+ updatePosition?: () => void
37
38
  }>()
38
39
 
39
40
  const isMounted = ref(false)
41
+ const dropdownEl = ref<HTMLElement | null>(null)
42
+ let resizeObserver: ResizeObserver | null = null
43
+
40
44
  onMounted(() => {
41
45
  isMounted.value = true
42
46
  })
@@ -51,8 +55,21 @@ watch(() => props.open, (isOpen) => {
51
55
  if (typeof window !== 'undefined') {
52
56
  if (isOpen) {
53
57
  window.addEventListener('keydown', handleKeydown)
58
+ nextTick(() => {
59
+ if (dropdownEl.value && typeof ResizeObserver !== 'undefined') {
60
+ if (resizeObserver) resizeObserver.disconnect()
61
+ resizeObserver = new ResizeObserver(() => {
62
+ props.updatePosition?.()
63
+ })
64
+ resizeObserver.observe(dropdownEl.value)
65
+ }
66
+ })
54
67
  } else {
55
68
  window.removeEventListener('keydown', handleKeydown)
69
+ if (resizeObserver) {
70
+ resizeObserver.disconnect()
71
+ resizeObserver = null
72
+ }
56
73
  }
57
74
  }
58
75
  }, { immediate: true })
@@ -61,6 +78,10 @@ onBeforeUnmount(() => {
61
78
  if (typeof window !== 'undefined') {
62
79
  window.removeEventListener('keydown', handleKeydown)
63
80
  }
81
+ if (resizeObserver) {
82
+ resizeObserver.disconnect()
83
+ resizeObserver = null
84
+ }
64
85
  })
65
86
 
66
87
  const dialogStyle = computed(() => {
@@ -18,6 +18,7 @@ type __VLS_Props = {
18
18
  isInModal: boolean;
19
19
  align?: string;
20
20
  direction?: string;
21
+ updatePosition?: () => void;
21
22
  };
22
23
  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>;
23
24
  declare const _default: typeof __VLS_export;
@@ -1,3 +1,8 @@
1
- declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
1
+ type __VLS_Props = {
2
+ scrollMode?: 'window' | 'container';
3
+ };
4
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
5
+ scrollMode: "window" | "container";
6
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
2
7
  declare const _default: typeof __VLS_export;
3
8
  export default _default;
@@ -1,5 +1,5 @@
1
1
  <template lang="pug">
2
- .KLayout(:class="{ 'has-aside': Boolean($slots.aside) }")
2
+ .KLayout(:class="layoutClasses")
3
3
  header.KLayout__header(v-if="$slots.header")
4
4
  slot(name="header")
5
5
  aside.KLayout__aside(v-if="$slots.aside")
@@ -12,14 +12,28 @@
12
12
  </template>
13
13
 
14
14
  <script lang="ts" setup>
15
+ import { computed, useSlots } from 'vue'
16
+
17
+ const slots = useSlots()
15
18
  // Default preset component for KLayout
19
+ const props = withDefaults(defineProps<{
20
+ scrollMode?: 'window' | 'container'
21
+ }>(), {
22
+ scrollMode: 'container'
23
+ })
24
+
25
+ const layoutClasses = computed(() => [
26
+ { 'has-aside': Boolean(slots.aside) },
27
+ `is-scroll-${props.scrollMode || 'container'}`
28
+ ])
16
29
  </script>
17
30
 
18
31
  <style lang="scss" scoped>
19
32
  .KLayout {
20
33
  display: grid;
21
34
  min-height: 100vh;
22
- grid-template-rows: auto 1fr auto;
35
+ min-height: 100dvh;
36
+ grid-template-rows: auto minmax(0, 1fr) auto;
23
37
  grid-template-columns: 1fr;
24
38
  grid-template-areas:
25
39
  "header"
@@ -29,6 +43,27 @@
29
43
  color: var(--text-color, inherit);
30
44
  box-sizing: border-box;
31
45
 
46
+ &.is-scroll-container {
47
+ height: 100vh;
48
+ height: 100dvh;
49
+ max-height: 100dvh;
50
+ overflow: hidden;
51
+
52
+ .KLayout__main {
53
+ overflow-y: auto;
54
+ }
55
+ }
56
+
57
+ &.is-scroll-window {
58
+ min-height: 100vh;
59
+ min-height: 100dvh;
60
+ overflow: visible;
61
+
62
+ .KLayout__main {
63
+ overflow-y: visible;
64
+ }
65
+ }
66
+
32
67
  &.has-aside {
33
68
  grid-template-columns: var(--layout-sidebar-width, 240px) 1fr;
34
69
  grid-template-areas:
@@ -55,7 +90,6 @@
55
90
  &__main {
56
91
  grid-area: main;
57
92
  min-width: 0;
58
- overflow-y: auto;
59
93
  box-sizing: border-box;
60
94
  }
61
95
 
@@ -1,3 +1,8 @@
1
- declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
1
+ type __VLS_Props = {
2
+ scrollMode?: 'window' | 'container';
3
+ };
4
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
5
+ scrollMode: "window" | "container";
6
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
2
7
  declare const _default: typeof __VLS_export;
3
8
  export default _default;
@@ -1,5 +1,5 @@
1
1
  <template lang="pug">
2
- dialog.k-modal(ref="dialogRef" @close="closeModal" @click="handleBackdropClick" @mousedown="handleMouseDown" role="dialog" aria-modal="true" :aria-label="t('Dialog Window')")
2
+ dialog.k-modal(ref="dialogRef" @close="closeModal" @cancel="handleCancel" @click="handleBackdropClick" @mousedown="handleMouseDown" role="dialog" aria-modal="true" :aria-label="t('Dialog Window')")
3
3
  .modal-portal(:id="modalId")
4
4
  KPanel(no-gap flex-content scrollable).modal-container
5
5
  template(#header)
@@ -50,6 +50,13 @@ const handleMouseDown = (event: MouseEvent) => {
50
50
  isMouseDownOnBackdrop = event.target === dialogRef.value
51
51
  }
52
52
 
53
+ // Native dialogs fire cancel on Escape key; prevent it if non-dismissible
54
+ const handleCancel = (event: Event) => {
55
+ if (!props.closeOnOutsideClick) {
56
+ event.preventDefault()
57
+ }
58
+ }
59
+
53
60
  // Native dialogs require a script trick to close when clicking the ::backdrop pseudo-element
54
61
  const handleBackdropClick = (event: MouseEvent) => {
55
62
  if (props.closeOnOutsideClick && isMouseDownOnBackdrop && event.target === dialogRef.value) {
@@ -1,5 +1,5 @@
1
1
  <template lang="pug">
2
- .KTab-item(v-show="isOpen")
2
+ .KTab-item(v-show="isOpen" role="tabpanel" :aria-hidden="!isOpen")
3
3
  slot
4
4
  </template>
5
5
 
@@ -1,17 +1,18 @@
1
1
  <template lang="pug">
2
2
  .KTextbox-wrapper(:class="$attrs.class" :style="$attrs.style")
3
- label.k-input-label(v-if="label") {{ label }}
3
+ label.k-input-label(v-if="label" :for="inputId") {{ label }}
4
4
  .KTextbox(:class="validation ? `is-${validation}` : ''")
5
- input(v-bind="inputAttrs" :type="props.type" v-model="text" :placeholder="placeholder")
5
+ input(:id="inputId" v-bind="inputAttrs" :type="props.type" v-model="text" :placeholder="placeholder")
6
6
  KIcon(v-if="showClear" @click.stop="clear" @mousedown.stop iconname="close" width="10" height="10" role="button" :aria-label="t('Clear input')").closeIcon
7
7
  span.validation-text(v-if="validation && ['success', 'warning', 'error'].includes(validation) && validationText" :class="`is-${validation}`") {{ validationText }}
8
8
  </template>
9
9
 
10
10
  <script lang="ts" setup>
11
- import { computed, useAttrs } from 'vue'
11
+ import { computed, useAttrs, useId } from 'vue'
12
12
  import { useKatluxI18n } from '#toolkit/composables/useKatluxI18n'
13
13
 
14
14
  const { t } = useKatluxI18n()
15
+ const generatedId = useId()
15
16
 
16
17
  defineOptions({
17
18
  inheritAttrs: false
@@ -39,8 +40,9 @@ const text = computed({
39
40
  })
40
41
 
41
42
  const attrs = useAttrs()
43
+ const inputId = computed(() => (attrs.id as string) || generatedId)
42
44
  const inputAttrs = computed(() => {
43
- const { class: _, style: __, ...rest } = attrs
45
+ const { class: _, style: __, id: ___, ...rest } = attrs
44
46
  return rest
45
47
  })
46
48
  </script>
@@ -2,16 +2,22 @@ import type { KToastType } from '#toolkit/components/KToast/KToast.logic';
2
2
  type __VLS_Props = {
3
3
  modelValue: boolean;
4
4
  text?: string;
5
+ title?: string;
5
6
  timeout?: number;
6
7
  teleport?: boolean;
7
8
  type?: KToastType;
9
+ pauseOnHover?: boolean;
8
10
  };
9
11
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
10
12
  "update:modelValue": (...args: any[]) => void;
11
13
  close: (...args: any[]) => void;
14
+ mouseenter: (...args: any[]) => void;
15
+ mouseleave: (...args: any[]) => void;
12
16
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
13
17
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
14
18
  onClose?: ((...args: any[]) => any) | undefined;
19
+ onMouseenter?: ((...args: any[]) => any) | undefined;
20
+ onMouseleave?: ((...args: any[]) => any) | undefined;
15
21
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
16
22
  declare const _default: typeof __VLS_export;
17
23
  export default _default;
@@ -4,11 +4,16 @@ Teleport(to="body" :disabled="!teleport")
4
4
  .KToast(
5
5
  v-if="modelValue"
6
6
  :class="[`type-${type}`, { 'is-fixed': teleport }]"
7
+ :role="type === 'error' || type === 'danger' ? 'alert' : 'status'"
8
+ @mouseenter="$emit('mouseenter', $event)"
9
+ @mouseleave="$emit('mouseleave', $event)"
7
10
  )
8
11
  .KToast--content
9
- slot {{ text }}
12
+ .KToast--title(v-if="title") {{ title }}
13
+ .KToast--text
14
+ slot {{ text }}
10
15
  .KToast--actions
11
- button.close-btn(@click="$emit('close')")
16
+ button.close-btn(@click="$emit('close')" aria-label="Close notification")
12
17
  KIcon(iconname="close" :width="16" :height="16")
13
18
  </template>
14
19
 
@@ -18,12 +23,14 @@ import type { KToastType } from '#toolkit/components/KToast/KToast.logic'
18
23
  defineProps<{
19
24
  modelValue: boolean
20
25
  text?: string
26
+ title?: string
21
27
  timeout?: number
22
28
  teleport?: boolean
23
29
  type?: KToastType
30
+ pauseOnHover?: boolean
24
31
  }>()
25
32
 
26
- defineEmits(['update:modelValue', 'close'])
33
+ defineEmits(['update:modelValue', 'close', 'mouseenter', 'mouseleave'])
27
34
  </script>
28
35
 
29
36
  <style lang="scss" scoped>
@@ -74,12 +81,22 @@ defineEmits(['update:modelValue', 'close'])
74
81
 
75
82
  &--content {
76
83
  flex: 1;
77
- font-size: var(--font-size-md);
78
84
  color: var(--current-toast-text);
79
85
  margin-right: var(--gap-md);
80
86
  line-height: 1.4;
81
87
  }
82
88
 
89
+ &--title {
90
+ font-weight: 600;
91
+ font-size: var(--font-size-md, 0.95rem);
92
+ margin-bottom: 2px;
93
+ }
94
+
95
+ &--text {
96
+ font-size: var(--font-size-sm, 0.875rem);
97
+ }
98
+
99
+
83
100
  &--actions {
84
101
  display: flex;
85
102
  align-items: center;
@@ -2,16 +2,22 @@ import type { KToastType } from '#toolkit/components/KToast/KToast.logic';
2
2
  type __VLS_Props = {
3
3
  modelValue: boolean;
4
4
  text?: string;
5
+ title?: string;
5
6
  timeout?: number;
6
7
  teleport?: boolean;
7
8
  type?: KToastType;
9
+ pauseOnHover?: boolean;
8
10
  };
9
11
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
10
12
  "update:modelValue": (...args: any[]) => void;
11
13
  close: (...args: any[]) => void;
14
+ mouseenter: (...args: any[]) => void;
15
+ mouseleave: (...args: any[]) => void;
12
16
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
13
17
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
14
18
  onClose?: ((...args: any[]) => any) | undefined;
19
+ onMouseenter?: ((...args: any[]) => any) | undefined;
20
+ onMouseleave?: ((...args: any[]) => any) | undefined;
15
21
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
16
22
  declare const _default: typeof __VLS_export;
17
23
  export default _default;
@@ -0,0 +1,11 @@
1
+ import { type KToastPosition } from '#toolkit/composables/useToast';
2
+ type __VLS_Props = {
3
+ position?: KToastPosition;
4
+ teleport?: boolean;
5
+ maxToasts?: number;
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<{}>, {
8
+ teleport: boolean;
9
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ declare const _default: typeof __VLS_export;
11
+ export default _default;
@@ -0,0 +1,206 @@
1
+ <template lang="pug">
2
+ Teleport(to="body" :disabled="!teleport")
3
+ .k-toast-portal-host#katlux-toast-portal
4
+ .k-toast-container(
5
+ v-for="pos in activePositions"
6
+ :key="pos"
7
+ :class="[`pos-${pos}`]"
8
+ role="region"
9
+ aria-label="Notifications"
10
+ @mouseenter="handleMouseEnter"
11
+ @mouseleave="handleMouseLeave"
12
+ )
13
+ TransitionGroup(name="k-toast-stack" tag="div" class="k-toast-stack")
14
+ .k-toast-item(
15
+ v-for="item in getToastsForPosition(pos)"
16
+ :key="item.id"
17
+ @mouseenter="handleMouseEnter"
18
+ @mouseleave="handleMouseLeave"
19
+ )
20
+ KToast(
21
+ :modelValue="true"
22
+ :text="item.text"
23
+ :title="item.title"
24
+ :type="item.type"
25
+ :teleport="false"
26
+ :timeout="0"
27
+ @close="dismiss(item.id)"
28
+ )
29
+ </template>
30
+
31
+ <script lang="ts" setup>
32
+ import { computed, onBeforeUnmount } from 'vue'
33
+ import { useToast, type KToastPosition } from '#toolkit/composables/useToast'
34
+ import KToast from '#toolkit/components/KToast/KToast.global.vue'
35
+
36
+ const props = withDefaults(defineProps<{
37
+ position?: KToastPosition
38
+ teleport?: boolean
39
+ maxToasts?: number
40
+ }>(), {
41
+ teleport: true
42
+ })
43
+
44
+ const { toasts, dismiss, pause, resume } = useToast()
45
+
46
+ let leaveDebounceTimer: any = null
47
+
48
+ const handleMouseEnter = () => {
49
+ if (leaveDebounceTimer) {
50
+ clearTimeout(leaveDebounceTimer)
51
+ leaveDebounceTimer = null
52
+ }
53
+ pause()
54
+ }
55
+
56
+ const handleMouseLeave = () => {
57
+ if (leaveDebounceTimer) {
58
+ clearTimeout(leaveDebounceTimer)
59
+ }
60
+ leaveDebounceTimer = setTimeout(() => {
61
+ resume()
62
+ leaveDebounceTimer = null
63
+ }, 150)
64
+ }
65
+
66
+ onBeforeUnmount(() => {
67
+ if (leaveDebounceTimer) {
68
+ clearTimeout(leaveDebounceTimer)
69
+ leaveDebounceTimer = null
70
+ }
71
+ })
72
+
73
+ const ALL_POSITIONS: KToastPosition[] = [
74
+ 'top-right',
75
+ 'top-left',
76
+ 'top-center',
77
+ 'bottom-right',
78
+ 'bottom-left',
79
+ 'bottom-center'
80
+ ]
81
+
82
+ const getToastsForPosition = (pos: KToastPosition) => {
83
+ const list = toasts.value.filter(item => item.position === pos)
84
+ if (props.maxToasts && props.maxToasts > 0) {
85
+ return list.slice(-props.maxToasts)
86
+ }
87
+ return list
88
+ }
89
+
90
+ const activePositions = computed(() => {
91
+ if (props.position) {
92
+ return getToastsForPosition(props.position).length > 0 ? [props.position] : []
93
+ }
94
+ return ALL_POSITIONS.filter(pos => getToastsForPosition(pos).length > 0)
95
+ })
96
+ </script>
97
+
98
+ <style lang="scss" scoped>
99
+ .k-toast-portal-host {
100
+ pointer-events: none;
101
+ }
102
+
103
+ .k-toast-container {
104
+ position: fixed;
105
+ z-index: 10000;
106
+ display: flex;
107
+ flex-direction: column;
108
+ gap: var(--gap-sm, 10px);
109
+ pointer-events: none;
110
+ padding: var(--gap-lg, 20px);
111
+ box-sizing: border-box;
112
+ max-width: 100vw;
113
+
114
+ &.pos-top-right {
115
+ top: 0;
116
+ right: 0;
117
+ align-items: flex-end;
118
+ }
119
+
120
+ &.pos-top-left {
121
+ top: 0;
122
+ left: 0;
123
+ align-items: flex-start;
124
+ }
125
+
126
+ &.pos-top-center {
127
+ top: 0;
128
+ left: 50%;
129
+ transform: translateX(-50%);
130
+ align-items: center;
131
+ }
132
+
133
+ &.pos-bottom-right {
134
+ bottom: 0;
135
+ right: 0;
136
+ align-items: flex-end;
137
+ flex-direction: column-reverse;
138
+ }
139
+
140
+ &.pos-bottom-left {
141
+ bottom: 0;
142
+ left: 0;
143
+ align-items: flex-start;
144
+ flex-direction: column-reverse;
145
+ }
146
+
147
+ &.pos-bottom-center {
148
+ bottom: 0;
149
+ left: 50%;
150
+ transform: translateX(-50%);
151
+ align-items: center;
152
+ flex-direction: column-reverse;
153
+ }
154
+ }
155
+
156
+ .k-toast-stack {
157
+ display: flex;
158
+ flex-direction: inherit;
159
+ gap: inherit;
160
+ align-items: inherit;
161
+ position: relative;
162
+ }
163
+
164
+ .k-toast-item {
165
+ pointer-events: auto;
166
+ }
167
+
168
+ /* Animations */
169
+ .k-toast-stack-enter-active,
170
+ .k-toast-stack-leave-active {
171
+ transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
172
+ }
173
+
174
+ .k-toast-stack-enter-from {
175
+ opacity: 0;
176
+ transform: translateY(-16px) scale(0.96);
177
+ }
178
+
179
+ .k-toast-stack-leave-to {
180
+ opacity: 0;
181
+ transform: translateY(-16px) scale(0.96);
182
+ }
183
+
184
+ .k-toast-stack-leave-active {
185
+ position: absolute;
186
+ width: 100%;
187
+ pointer-events: none;
188
+ }
189
+
190
+ .k-toast-stack-move {
191
+ transition: transform 0.28s ease;
192
+ }
193
+
194
+ .pos-bottom-right,
195
+ .pos-bottom-left,
196
+ .pos-bottom-center {
197
+ .k-toast-stack-enter-from {
198
+ opacity: 0;
199
+ transform: translateY(16px) scale(0.96);
200
+ }
201
+ .k-toast-stack-leave-to {
202
+ opacity: 0;
203
+ transform: translateY(16px) scale(0.96);
204
+ }
205
+ }
206
+ </style>
@@ -0,0 +1,11 @@
1
+ import { type KToastPosition } from '#toolkit/composables/useToast';
2
+ type __VLS_Props = {
3
+ position?: KToastPosition;
4
+ teleport?: boolean;
5
+ maxToasts?: number;
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<{}>, {
8
+ teleport: boolean;
9
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ declare const _default: typeof __VLS_export;
11
+ export default _default;
@@ -1,4 +1,3 @@
1
- import { type Ref } from 'vue';
2
1
  import type { TTreeRow } from '@katlux/providers';
3
2
  type __VLS_Props = {
4
3
  visibleRows: TTreeRow[];
@@ -10,22 +9,32 @@ type __VLS_Props = {
10
9
  multiSelect?: boolean;
11
10
  isNodeSelected?: (node: any) => boolean;
12
11
  toggleNode: (id: string | number) => void;
12
+ selectNode?: (node: any) => void;
13
13
  selectable?: boolean;
14
- dataProvider?: {
15
- loading: Ref<boolean>;
16
- initialLoad?: Ref<boolean>;
17
- };
14
+ dataProvider?: any;
15
+ searchtext?: string;
16
+ virtualScroll?: boolean;
17
+ itemHeight?: number;
18
+ viewportHeight?: number;
19
+ buffer?: number;
18
20
  };
19
21
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
20
22
  select: (row: TTreeRow) => any;
23
+ "node-toggle": (id: string | number) => any;
21
24
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
22
25
  onSelect?: ((row: TTreeRow) => any) | undefined;
26
+ "onNode-toggle"?: ((id: string | number) => any) | undefined;
23
27
  }>, {
24
28
  disabled: boolean;
29
+ idKey: string;
30
+ searchtext: string;
31
+ virtualScroll: boolean;
32
+ itemHeight: number;
33
+ buffer: number;
25
34
  labelField: string;
26
35
  multiSelect: boolean;
36
+ viewportHeight: number;
27
37
  iconField: string;
28
- idKey: string;
29
38
  isNodeSelected: (node: any) => boolean;
30
39
  selectable: boolean;
31
40
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;