@krometra/ui-kit 0.8.0 → 0.9.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krometra/ui-kit",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "UI-kit на Vue 3 со сменными темами, светлой и тёмной схемой; интерактивные компоненты на zag.js",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -35,6 +35,7 @@
35
35
  "vue": "^3.4.0"
36
36
  },
37
37
  "dependencies": {
38
+ "@krometra/easy-data-scroll": "^0.2.0",
38
39
  "@zag-js/checkbox": "^1.43.3",
39
40
  "@zag-js/combobox": "^1.43.3",
40
41
  "@zag-js/dialog": "^1.43.3",
@@ -0,0 +1,79 @@
1
+ <script setup>
2
+ /**
3
+ * KVirtualList — длинный список без прыжков на @krometra/easy-data-scroll: в DOM
4
+ * только строки у экрана, высота строк любая и заранее не нужна. Подгрузка,
5
+ * картинки, новые строки сверху и снизу не сдвигают то, что читают.
6
+ *
7
+ * Пропсы и события — те же, что у InfinityScroll из пакета. Режим выбирается
8
+ * загрузчиком:
9
+ * бесконечный: load-before / load-after (крайний элемент) => массив или { items, done }
10
+ * виртуальный: load-range(from, to) => массив или { items, total }, плюс total
11
+ *
12
+ * <KVirtualList :get-key="m => m.id" :load-range="load" :total="total" origin="bottom" height="32rem">
13
+ * <template #default="{ item }">…</template>
14
+ * </KVirtualList>
15
+ *
16
+ * origin="bottom" — чат: начинается снизу и прилипает к низу. Методы (append,
17
+ * prepend, update, remove, reset, scrollToKey, scrollToIndex, scrollToTop,
18
+ * scrollToBottom) и сам экземпляр (list) — через ref.
19
+ */
20
+ import { InfinityScroll } from '@krometra/easy-data-scroll/vue'
21
+ import { computed, useTemplateRef } from 'vue'
22
+
23
+ const props = defineProps({
24
+ height: { type: String, default: '' },
25
+ bordered: { type: Boolean, default: false },
26
+ })
27
+
28
+ const inner = useTemplateRef('inner')
29
+ const style = computed(() => (props.height ? { height: props.height } : null))
30
+
31
+ const call = (name) => (...args) => inner.value?.[name](...args)
32
+
33
+ defineExpose({
34
+ get list() {
35
+ return inner.value?.list
36
+ },
37
+ append: call('append'),
38
+ prepend: call('prepend'),
39
+ update: call('update'),
40
+ remove: call('remove'),
41
+ reset: call('reset'),
42
+ scrollToKey: call('scrollToKey'),
43
+ scrollToIndex: call('scrollToIndex'),
44
+ indexOfKey: call('indexOfKey'),
45
+ scrollToTop: call('scrollToTop'),
46
+ scrollToBottom: call('scrollToBottom'),
47
+ })
48
+ </script>
49
+
50
+ <template>
51
+ <InfinityScroll
52
+ ref="inner"
53
+ class="k-virtual-list"
54
+ :class="{ 'k-virtual-list--bordered': bordered }"
55
+ :style="style"
56
+ >
57
+ <template #default="{ item }">
58
+ <slot :item="item" />
59
+ </template>
60
+ </InfinityScroll>
61
+ </template>
62
+
63
+ <style scoped>
64
+ .k-virtual-list {
65
+ --eds-loader-color: var(--k-primary);
66
+ --eds-loader-bg: var(--k-surface-muted);
67
+ --eds-gap-color: var(--k-border);
68
+ --eds-gap-inset: 1rem;
69
+ --eds-gap-pad: 0.375rem;
70
+ min-height: 0;
71
+ color: var(--k-text);
72
+ }
73
+ .k-virtual-list--bordered {
74
+ background: var(--k-surface);
75
+ border: 1px solid var(--k-border);
76
+ border-radius: var(--k-radius);
77
+ overflow: hidden;
78
+ }
79
+ </style>
package/src/index.js CHANGED
@@ -53,13 +53,14 @@ import KTextarea from './components/KTextarea.vue'
53
53
  import KTimeline from './components/KTimeline.vue'
54
54
  import KToast from './components/KToast.vue'
55
55
  import KTooltip from './components/KTooltip.vue'
56
+ import KVirtualList from './components/KVirtualList.vue'
56
57
 
57
58
  export {
58
59
  KAlert, KAvatar, KBadge, KButton, KCard, KCheckbox, KChip, KCombobox, KCountdown,
59
60
  KDescriptions, KDrawer, KDropdown, KEmpty, KFileUpload, KFilterBar, KGantt, KIcon,
60
61
  KInput, KMenuItem, KModal, KMoney, KPage, KPagination, KProgress,
61
62
  KRadioGroup, KSegmented, KSelect, KShell, KStat, KSteps, KSwitch, KTable,
62
- KTabs, KTextarea, KTimeline, KToast, KTooltip,
63
+ KTabs, KTextarea, KTimeline, KToast, KTooltip, KVirtualList,
63
64
  }
64
65
 
65
66
  export { iconNames, iconRegistry, registerIcons } from './components/icon-registry.js'
@@ -75,7 +76,7 @@ const components = {
75
76
  KDescriptions, KDrawer, KDropdown, KEmpty, KFileUpload, KFilterBar, KGantt, KIcon,
76
77
  KInput, KMenuItem, KModal, KMoney, KPage, KPagination, KProgress,
77
78
  KRadioGroup, KSegmented, KSelect, KShell, KStat, KSteps, KSwitch, KTable,
78
- KTabs, KTextarea, KTimeline, KToast, KTooltip,
79
+ KTabs, KTextarea, KTimeline, KToast, KTooltip, KVirtualList,
79
80
  }
80
81
 
81
82
  export default {