@indielayer/ui 1.17.0 → 1.18.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.
Files changed (47) hide show
  1. package/README.md +2 -2
  2. package/docs/assets/css/tailwind.css +6 -0
  3. package/docs/components/common/CodePreview.vue +14 -9
  4. package/docs/components/common/DocsFeatures.vue +41 -0
  5. package/docs/components/common/DocsHero.vue +216 -0
  6. package/docs/components/common/DocumentPage.vue +99 -112
  7. package/docs/components/common/ExampleBlocks.vue +157 -0
  8. package/docs/components/toolbar/Toolbar.vue +11 -2
  9. package/docs/components/toolbar/ToolbarColorToggle.vue +4 -4
  10. package/docs/components/toolbar/ToolbarSearch.vue +59 -62
  11. package/docs/composables/useDocMeta.ts +47 -0
  12. package/docs/icons.ts +28 -0
  13. package/docs/layouts/default.vue +1 -3
  14. package/docs/layouts/simple.vue +3 -1
  15. package/docs/main.ts +5 -0
  16. package/docs/pages/colors.vue +56 -47
  17. package/docs/pages/component/select/size.vue +1 -1
  18. package/docs/pages/component/select/usage.vue +14 -7
  19. package/docs/pages/error.vue +5 -3
  20. package/docs/pages/icons.vue +64 -54
  21. package/docs/pages/index.vue +93 -82
  22. package/docs/pages/typography.vue +38 -28
  23. package/docs/router/index.ts +31 -3
  24. package/docs/search/components.json +1 -1
  25. package/docs/search/index.json +1 -0
  26. package/lib/components/container/theme/Container.base.theme.js +1 -1
  27. package/lib/components/divider/theme/Divider.base.theme.js +1 -1
  28. package/lib/components/input/Input.vue.js +23 -24
  29. package/lib/components/select/Select.vue.d.ts +16 -27
  30. package/lib/components/select/Select.vue.js +451 -344
  31. package/lib/index.js +1 -1
  32. package/lib/index.umd.js +4 -4
  33. package/lib/version.d.ts +1 -1
  34. package/lib/version.js +1 -1
  35. package/lib/virtual/components/virtualList/VirtualList.vue.js +33 -31
  36. package/lib/virtual/components/virtualList/useDynamicRowHeight.js +18 -19
  37. package/package.json +8 -3
  38. package/src/components/container/theme/Container.base.theme.ts +1 -1
  39. package/src/components/divider/theme/Divider.base.theme.ts +1 -1
  40. package/src/components/input/Input.vue +1 -2
  41. package/src/components/select/Select.vue +94 -18
  42. package/src/version.ts +1 -1
  43. package/src/virtual/components/virtualList/VirtualList.test.ts +143 -26
  44. package/src/virtual/components/virtualList/VirtualList.vue +12 -18
  45. package/src/virtual/components/virtualList/useDynamicRowHeight.test.ts +22 -8
  46. package/src/virtual/components/virtualList/useDynamicRowHeight.ts +4 -2
  47. package/src/virtual/utils/parseNumericStyleValue.ts +2 -0
@@ -95,33 +95,27 @@ defineExpose<VirtualListImperativeAPI>({
95
95
  // Watch for dynamic row heights - run after DOM updates
96
96
  watch(
97
97
  [element, startIndexOverscan, stopIndexOverscan, isDynamicRowHeight, () => props.rowHeight],
98
- ([el, start, stop, isDynamic]) => {
98
+ ([el, start, stop, isDynamic], _old, onCleanup) => {
99
99
  if (!el || !isDynamic) {
100
100
  return
101
101
  }
102
102
 
103
- // Use nextTick to ensure DOM is fully updated
104
- const setupObserver = () => {
105
- const rows = Array.from(el.children).filter((item, index) => {
106
- if (item.hasAttribute('aria-hidden')) {
107
- // Ignore sizing element
108
- return false
109
- }
110
-
111
- const attribute = `${start + index}`
103
+ const rows = Array.from(el.children).filter((item, index) => {
104
+ if (item.hasAttribute('aria-hidden')) {
105
+ // Ignore sizing element
106
+ return false
107
+ }
112
108
 
113
- item.setAttribute(DATA_ATTRIBUTE_LIST_INDEX, attribute)
109
+ const attribute = `${start + index}`
114
110
 
115
- return true
116
- })
111
+ item.setAttribute(DATA_ATTRIBUTE_LIST_INDEX, attribute)
117
112
 
118
- const dynamicHeight = props.rowHeight as DynamicRowHeight
113
+ return true
114
+ })
119
115
 
120
- return dynamicHeight.observeRowElements(rows)
121
- }
116
+ const dynamicHeight = props.rowHeight as DynamicRowHeight
122
117
 
123
- // Return cleanup function
124
- return setupObserver()
118
+ onCleanup(dynamicHeight.observeRowElements(rows))
125
119
  },
126
120
  { flush: 'post' }, // Run after DOM updates
127
121
  )
@@ -1,24 +1,38 @@
1
1
  import { describe, expect, test, beforeEach, afterEach } from 'vitest'
2
2
  import { ref, nextTick } from 'vue'
3
3
  import { useDynamicRowHeight, DATA_ATTRIBUTE_LIST_INDEX } from './useDynamicRowHeight'
4
+ import type { DynamicRowHeight } from './types'
4
5
  import { mockResizeObserver, setElementSize } from '../../test-utils/mockResizeObserver'
5
6
 
6
7
  describe('useDynamicRowHeight', () => {
7
8
  let unmock: (() => void) | undefined
9
+ let instances: DynamicRowHeight[] = []
8
10
 
9
11
  beforeEach(() => {
10
12
  unmock = mockResizeObserver()
13
+ instances = []
11
14
  })
12
15
 
13
16
  afterEach(() => {
17
+ instances.forEach((instance) => instance.cleanup())
14
18
  if (unmock) {
15
19
  unmock()
16
20
  }
17
21
  })
18
22
 
23
+ function createDynamicRowHeight(
24
+ ...args: Parameters<typeof useDynamicRowHeight>
25
+ ): DynamicRowHeight {
26
+ const instance = useDynamicRowHeight(...args)
27
+
28
+ instances.push(instance)
29
+
30
+ return instance
31
+ }
32
+
19
33
  describe('getAverageRowHeight', () => {
20
34
  test('returns an initial estimate based on the defaultRowHeight', () => {
21
- const dynamicRowHeight = useDynamicRowHeight({
35
+ const dynamicRowHeight = createDynamicRowHeight({
22
36
  defaultRowHeight: 100,
23
37
  })
24
38
 
@@ -26,7 +40,7 @@ describe('useDynamicRowHeight', () => {
26
40
  })
27
41
 
28
42
  test('returns an estimate based on measured rows', () => {
29
- const dynamicRowHeight = useDynamicRowHeight({
43
+ const dynamicRowHeight = createDynamicRowHeight({
30
44
  defaultRowHeight: 100,
31
45
  })
32
46
 
@@ -43,7 +57,7 @@ describe('useDynamicRowHeight', () => {
43
57
 
44
58
  test('resets when key changes', async () => {
45
59
  const key = ref('a')
46
- const dynamicRowHeight = useDynamicRowHeight({
60
+ const dynamicRowHeight = createDynamicRowHeight({
47
61
  defaultRowHeight: 100,
48
62
  key,
49
63
  })
@@ -64,7 +78,7 @@ describe('useDynamicRowHeight', () => {
64
78
 
65
79
  describe('getRowHeight', () => {
66
80
  test('returns estimated height for a row that has not yet been measured', () => {
67
- const dynamicRowHeight = useDynamicRowHeight({
81
+ const dynamicRowHeight = createDynamicRowHeight({
68
82
  defaultRowHeight: 100,
69
83
  })
70
84
 
@@ -72,7 +86,7 @@ describe('useDynamicRowHeight', () => {
72
86
  })
73
87
 
74
88
  test('returns the most recently measured size', () => {
75
- const dynamicRowHeight = useDynamicRowHeight({
89
+ const dynamicRowHeight = createDynamicRowHeight({
76
90
  defaultRowHeight: 100,
77
91
  })
78
92
 
@@ -90,7 +104,7 @@ describe('useDynamicRowHeight', () => {
90
104
 
91
105
  test('resets when key changes', async () => {
92
106
  const key = ref('a')
93
- const dynamicRowHeight = useDynamicRowHeight({
107
+ const dynamicRowHeight = createDynamicRowHeight({
94
108
  defaultRowHeight: 100,
95
109
  key,
96
110
  })
@@ -119,7 +133,7 @@ describe('useDynamicRowHeight', () => {
119
133
  }
120
134
 
121
135
  test('should update cache when an observed element is resized', async () => {
122
- const dynamicRowHeight = useDynamicRowHeight({
136
+ const dynamicRowHeight = createDynamicRowHeight({
123
137
  defaultRowHeight: 100,
124
138
  })
125
139
 
@@ -151,7 +165,7 @@ describe('useDynamicRowHeight', () => {
151
165
  })
152
166
 
153
167
  test('should unobserve an element when requested', async () => {
154
- const dynamicRowHeight = useDynamicRowHeight({
168
+ const dynamicRowHeight = createDynamicRowHeight({
155
169
  defaultRowHeight: 100,
156
170
  })
157
171
 
@@ -119,12 +119,14 @@ export function useDynamicRowHeight({
119
119
 
120
120
  const resizeObserver = new ResizeObserver(resizeObserverCallback)
121
121
 
122
- onBeforeUnmount(cleanup)
123
-
124
122
  function cleanup() {
125
123
  resizeObserver.disconnect()
126
124
  }
127
125
 
126
+ if (getCurrentInstance()) {
127
+ onBeforeUnmount(cleanup)
128
+ }
129
+
128
130
  const observeRowElements = (elements: Element[] | NodeListOf<Element>) => {
129
131
  const elementsArray = Array.isArray(elements)
130
132
  ? elements
@@ -16,4 +16,6 @@ export function parseNumericStyleValue(
16
16
  }
17
17
  }
18
18
  }
19
+
20
+ return undefined
19
21
  }