@keenmate/svelte-treeview 5.0.0-rc08 → 5.0.0-rc09
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 +41 -0
- package/README.md +33 -23
- package/ai/basic-setup.txt +336 -339
- package/ai/import-patterns.txt +290 -271
- package/ai/styling-theming.txt +355 -354
- package/component-variables.manifest.json +142 -0
- package/dist/components/Node.svelte +36 -26
- package/dist/components/Tree.svelte +49 -1
- package/dist/components/Tree.svelte.d.ts +36 -3
- package/dist/constants.generated.d.ts +1 -1
- package/dist/constants.generated.js +1 -1
- package/dist/core/TreeController.svelte.d.ts +45 -4
- package/dist/core/TreeController.svelte.js +270 -69
- package/dist/index.d.ts +1 -1
- package/dist/ltree/ltree.svelte.d.ts +1 -1
- package/dist/ltree/ltree.svelte.js +28 -7
- package/dist/ltree/types.d.ts +4 -0
- package/dist/styles/_base.css +41 -0
- package/dist/styles/_checkbox.css +83 -0
- package/dist/styles/_context-menu.css +134 -0
- package/dist/styles/_debug.css +45 -0
- package/dist/styles/_drag-drop.css +174 -0
- package/dist/styles/_drop-zones.css +270 -0
- package/dist/styles/_loading.css +40 -0
- package/dist/styles/_node.css +60 -0
- package/dist/styles/_states.css +92 -0
- package/dist/styles/_toggle-icons.css +97 -0
- package/dist/styles/_variables.css +189 -0
- package/dist/styles/main.css +37 -0
- package/dist/styles.css +651 -470
- package/package.json +103 -102
- package/dist/styles/main.scss +0 -1074
- package/dist/styles.css.map +0 -1
- package/dist/styles.scss +0 -2
package/ai/import-patterns.txt
CHANGED
|
@@ -1,271 +1,290 @@
|
|
|
1
|
-
IMPORT PATTERNS
|
|
2
|
-
===============
|
|
3
|
-
|
|
4
|
-
CRITICAL: Always import styles along with the component
|
|
5
|
-
- Component has no embedded styles
|
|
6
|
-
- Styles must be imported separately
|
|
7
|
-
- Both CSS and SCSS versions available
|
|
8
|
-
|
|
9
|
-
BASIC IMPORT
|
|
10
|
-
------------
|
|
11
|
-
// Component import
|
|
12
|
-
import { Tree } from '@keenmate/svelte-treeview';
|
|
13
|
-
|
|
14
|
-
// Style import (
|
|
15
|
-
import '@keenmate/svelte-treeview/styles.css';
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
import
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
//
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
✅
|
|
267
|
-
✅
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
❌
|
|
1
|
+
IMPORT PATTERNS
|
|
2
|
+
===============
|
|
3
|
+
|
|
4
|
+
CRITICAL: Always import styles along with the component
|
|
5
|
+
- Component has no embedded styles
|
|
6
|
+
- Styles must be imported separately
|
|
7
|
+
- Both CSS and SCSS versions available
|
|
8
|
+
|
|
9
|
+
BASIC IMPORT
|
|
10
|
+
------------
|
|
11
|
+
// Component import
|
|
12
|
+
import { Tree } from '@keenmate/svelte-treeview';
|
|
13
|
+
|
|
14
|
+
// Style import (bundled, contains all partials)
|
|
15
|
+
import '@keenmate/svelte-treeview/styles.css';
|
|
16
|
+
|
|
17
|
+
COMPONENT EXPORTS
|
|
18
|
+
-----------------
|
|
19
|
+
Named exports from the package:
|
|
20
|
+
|
|
21
|
+
// Main component
|
|
22
|
+
import { Tree } from '@keenmate/svelte-treeview';
|
|
23
|
+
|
|
24
|
+
// Types
|
|
25
|
+
import type {
|
|
26
|
+
LTreeNode,
|
|
27
|
+
Ltree,
|
|
28
|
+
ContextMenuItem,
|
|
29
|
+
DropPosition,
|
|
30
|
+
InsertArrayResult,
|
|
31
|
+
NodeCallbacks,
|
|
32
|
+
NodeConfig
|
|
33
|
+
} from '@keenmate/svelte-treeview';
|
|
34
|
+
|
|
35
|
+
// Logging utilities
|
|
36
|
+
import {
|
|
37
|
+
enableLogging,
|
|
38
|
+
disableLogging,
|
|
39
|
+
setLogLevel,
|
|
40
|
+
setCategoryLevel,
|
|
41
|
+
enablePerfLogging,
|
|
42
|
+
disablePerfLogging,
|
|
43
|
+
setPerfThreshold
|
|
44
|
+
} from '@keenmate/svelte-treeview';
|
|
45
|
+
|
|
46
|
+
STYLE IMPORTS
|
|
47
|
+
-------------
|
|
48
|
+
Option 1: In JavaScript entry point
|
|
49
|
+
// main.ts or main.js
|
|
50
|
+
import '@keenmate/svelte-treeview/styles.css';
|
|
51
|
+
|
|
52
|
+
Option 2: In root layout (SvelteKit)
|
|
53
|
+
// +layout.svelte
|
|
54
|
+
<script>
|
|
55
|
+
import '@keenmate/svelte-treeview/styles.css';
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
Option 3: In component file
|
|
59
|
+
// MyComponent.svelte
|
|
60
|
+
<script>
|
|
61
|
+
import { Tree } from '@keenmate/svelte-treeview';
|
|
62
|
+
import '@keenmate/svelte-treeview/styles.css';
|
|
63
|
+
</script>
|
|
64
|
+
|
|
65
|
+
Option 4: In Svelte style block
|
|
66
|
+
<style>
|
|
67
|
+
@import '@keenmate/svelte-treeview/styles.css';
|
|
68
|
+
</style>
|
|
69
|
+
|
|
70
|
+
THEMING VIA CSS VARIABLES
|
|
71
|
+
-------------------------
|
|
72
|
+
Override CSS custom properties to customize the look:
|
|
73
|
+
|
|
74
|
+
<style>
|
|
75
|
+
@import '@keenmate/svelte-treeview/styles.css';
|
|
76
|
+
|
|
77
|
+
/* Component-scope override */
|
|
78
|
+
.my-tree-wrapper {
|
|
79
|
+
--ltree-primary: #6366f1;
|
|
80
|
+
--ltree-node-indent-per-level: 1.5rem;
|
|
81
|
+
--ltree-node-font-size: 16px;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/* Or globally for all KeenMate components: */
|
|
85
|
+
:root {
|
|
86
|
+
--base-accent-color: #6366f1;
|
|
87
|
+
--base-font-family: 'Inter', system-ui, sans-serif;
|
|
88
|
+
}
|
|
89
|
+
</style>
|
|
90
|
+
|
|
91
|
+
TYPE IMPORTS
|
|
92
|
+
------------
|
|
93
|
+
Import types for TypeScript:
|
|
94
|
+
|
|
95
|
+
import type { LTreeNode } from '@keenmate/svelte-treeview';
|
|
96
|
+
|
|
97
|
+
interface MyItem {
|
|
98
|
+
id: string;
|
|
99
|
+
path: string;
|
|
100
|
+
name: string;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
let selectedNode: LTreeNode<MyItem> | null = $state(null);
|
|
104
|
+
|
|
105
|
+
Full type imports:
|
|
106
|
+
|
|
107
|
+
import type {
|
|
108
|
+
LTreeNode, // Tree node interface
|
|
109
|
+
Ltree, // Tree instance interface
|
|
110
|
+
ContextMenuItem, // Context menu item
|
|
111
|
+
DropPosition, // 'before' | 'after' | 'child'
|
|
112
|
+
InsertArrayResult, // Insert operation result
|
|
113
|
+
NodeCallbacks, // Event callback types
|
|
114
|
+
NodeConfig // Node configuration types
|
|
115
|
+
} from '@keenmate/svelte-treeview';
|
|
116
|
+
|
|
117
|
+
LOGGING IMPORTS
|
|
118
|
+
---------------
|
|
119
|
+
Debug and performance logging:
|
|
120
|
+
|
|
121
|
+
// Enable all logging
|
|
122
|
+
import { enableLogging } from '@keenmate/svelte-treeview';
|
|
123
|
+
enableLogging();
|
|
124
|
+
|
|
125
|
+
// Category-specific logging
|
|
126
|
+
import { setCategoryLevel } from '@keenmate/svelte-treeview';
|
|
127
|
+
setCategoryLevel('LTREE:DRAG', 'debug');
|
|
128
|
+
setCategoryLevel('LTREE:RENDER', 'debug');
|
|
129
|
+
|
|
130
|
+
// Performance logging
|
|
131
|
+
import { enablePerfLogging, setPerfThreshold } from '@keenmate/svelte-treeview';
|
|
132
|
+
enablePerfLogging();
|
|
133
|
+
setPerfThreshold(100); // Only log operations > 100ms
|
|
134
|
+
|
|
135
|
+
Log categories:
|
|
136
|
+
- LTREE:INIT - Initialization
|
|
137
|
+
- LTREE:DATA - Data operations
|
|
138
|
+
- LTREE:RENDER - Rendering
|
|
139
|
+
- LTREE:INDEX - Search indexing
|
|
140
|
+
- LTREE:DRAG - Drag and drop
|
|
141
|
+
- LTREE:UI - User interactions
|
|
142
|
+
|
|
143
|
+
GLOBAL API
|
|
144
|
+
----------
|
|
145
|
+
Access from browser console:
|
|
146
|
+
|
|
147
|
+
// Check version
|
|
148
|
+
window.components['svelte-treeview'].version()
|
|
149
|
+
|
|
150
|
+
// Enable logging from console
|
|
151
|
+
window.components['svelte-treeview'].logging.enableLogging()
|
|
152
|
+
|
|
153
|
+
// Performance logging
|
|
154
|
+
window.components['svelte-treeview'].perf.enable()
|
|
155
|
+
|
|
156
|
+
// Get package info
|
|
157
|
+
window.components['svelte-treeview'].config
|
|
158
|
+
|
|
159
|
+
SVELTEKIT IMPORT
|
|
160
|
+
----------------
|
|
161
|
+
// +page.svelte
|
|
162
|
+
<script lang="ts">
|
|
163
|
+
import { Tree } from '@keenmate/svelte-treeview';
|
|
164
|
+
import type { LTreeNode } from '@keenmate/svelte-treeview';
|
|
165
|
+
|
|
166
|
+
interface Item {
|
|
167
|
+
id: string;
|
|
168
|
+
path: string;
|
|
169
|
+
name: string;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
let data: Item[] = $state([]);
|
|
173
|
+
let selectedNode: LTreeNode<Item> | null = $state(null);
|
|
174
|
+
</script>
|
|
175
|
+
|
|
176
|
+
<Tree
|
|
177
|
+
{data}
|
|
178
|
+
idMember="id"
|
|
179
|
+
pathMember="path"
|
|
180
|
+
bind:focusedNode
|
|
181
|
+
/>
|
|
182
|
+
|
|
183
|
+
// +layout.svelte (for global styles)
|
|
184
|
+
<script>
|
|
185
|
+
import '@keenmate/svelte-treeview/styles.css';
|
|
186
|
+
</script>
|
|
187
|
+
|
|
188
|
+
<slot />
|
|
189
|
+
|
|
190
|
+
VITE + SVELTE IMPORT
|
|
191
|
+
--------------------
|
|
192
|
+
// main.ts
|
|
193
|
+
import './app.css'
|
|
194
|
+
import '@keenmate/svelte-treeview/styles.css';
|
|
195
|
+
import App from './App.svelte'
|
|
196
|
+
|
|
197
|
+
const app = new App({
|
|
198
|
+
target: document.getElementById('app')!,
|
|
199
|
+
})
|
|
200
|
+
|
|
201
|
+
export default app
|
|
202
|
+
|
|
203
|
+
// App.svelte
|
|
204
|
+
<script lang="ts">
|
|
205
|
+
import { Tree } from '@keenmate/svelte-treeview';
|
|
206
|
+
</script>
|
|
207
|
+
|
|
208
|
+
DYNAMIC IMPORT
|
|
209
|
+
--------------
|
|
210
|
+
For code splitting:
|
|
211
|
+
|
|
212
|
+
<script>
|
|
213
|
+
import { onMount } from 'svelte';
|
|
214
|
+
|
|
215
|
+
let Tree;
|
|
216
|
+
|
|
217
|
+
onMount(async () => {
|
|
218
|
+
const module = await import('@keenmate/svelte-treeview');
|
|
219
|
+
Tree = module.Tree;
|
|
220
|
+
|
|
221
|
+
// Import styles dynamically
|
|
222
|
+
await import('@keenmate/svelte-treeview/styles.css');
|
|
223
|
+
});
|
|
224
|
+
</script>
|
|
225
|
+
|
|
226
|
+
{#if Tree}
|
|
227
|
+
<svelte:component this={Tree} {data} ... />
|
|
228
|
+
{/if}
|
|
229
|
+
|
|
230
|
+
PACKAGE STRUCTURE
|
|
231
|
+
-----------------
|
|
232
|
+
@keenmate/svelte-treeview/
|
|
233
|
+
├── dist/
|
|
234
|
+
│ ├── index.js # Main entry (ESM)
|
|
235
|
+
│ ├── index.d.ts # TypeScript declarations
|
|
236
|
+
│ ├── styles.css # Bundled CSS (all partials merged)
|
|
237
|
+
│ └── styles/ # Individual partials (override per-section if needed)
|
|
238
|
+
│ ├── main.css
|
|
239
|
+
│ ├── _variables.css
|
|
240
|
+
│ ├── _base.css
|
|
241
|
+
│ ├── _node.css
|
|
242
|
+
│ ├── _toggle-icons.css
|
|
243
|
+
│ ├── _checkbox.css
|
|
244
|
+
│ ├── _states.css
|
|
245
|
+
│ ├── _drag-drop.css
|
|
246
|
+
│ ├── _drop-zones.css
|
|
247
|
+
│ ├── _context-menu.css
|
|
248
|
+
│ ├── _debug.css
|
|
249
|
+
│ └── _loading.css
|
|
250
|
+
└── package.json
|
|
251
|
+
|
|
252
|
+
PEER DEPENDENCIES
|
|
253
|
+
-----------------
|
|
254
|
+
Required:
|
|
255
|
+
- svelte: ^5.0.0
|
|
256
|
+
|
|
257
|
+
Optional:
|
|
258
|
+
- flexsearch: ^0.8.205 (for search functionality)
|
|
259
|
+
|
|
260
|
+
If using search features:
|
|
261
|
+
npm install flexsearch
|
|
262
|
+
|
|
263
|
+
TROUBLESHOOTING
|
|
264
|
+
---------------
|
|
265
|
+
"Module not found" error:
|
|
266
|
+
✅ npm install @keenmate/svelte-treeview
|
|
267
|
+
✅ Check node_modules exists
|
|
268
|
+
|
|
269
|
+
"Tree is not defined":
|
|
270
|
+
✅ import { Tree } from '@keenmate/svelte-treeview';
|
|
271
|
+
❌ import Tree from '@keenmate/svelte-treeview';
|
|
272
|
+
|
|
273
|
+
No styles showing:
|
|
274
|
+
✅ import '@keenmate/svelte-treeview/styles.css';
|
|
275
|
+
✅ Check import is actually executed
|
|
276
|
+
|
|
277
|
+
TypeScript errors:
|
|
278
|
+
✅ import type { LTreeNode } from '@keenmate/svelte-treeview';
|
|
279
|
+
✅ Check tsconfig.json has proper module resolution
|
|
280
|
+
|
|
281
|
+
BEST PRACTICES
|
|
282
|
+
--------------
|
|
283
|
+
✅ Import styles once at app root level
|
|
284
|
+
✅ Use type imports for TypeScript
|
|
285
|
+
✅ Use named exports (not default)
|
|
286
|
+
✅ Import logging utilities only in development
|
|
287
|
+
|
|
288
|
+
❌ Don't import styles multiple times
|
|
289
|
+
❌ Don't use default imports
|
|
290
|
+
❌ Don't forget peer dependencies
|