@placeholderco/placeholder-ui 3.3.4 → 3.3.5
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/display/filetree/FileTree.svelte +15 -1
- package/dist/display/filetree/FileTree.svelte.d.ts +11 -1
- package/dist/display/filetree/FileTreeItem.svelte +19 -3
- package/dist/display/filetree/FileTreeItem.svelte.d.ts +5 -1
- package/dist/display/filetree/FileTreeNode.d.ts +17 -1
- package/dist/display/filetree/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
|
-
import type { FileTreeNode } from './FileTreeNode.js';
|
|
3
|
+
import type { FileTreeIcons, FileTreeNode, FileTreeNodeIcon } from './FileTreeNode.js';
|
|
4
4
|
import type { ContextMenuItem } from '../../ui/ContextMenu.svelte';
|
|
5
5
|
|
|
6
6
|
export interface FileTreeDropEvent {
|
|
@@ -55,6 +55,16 @@
|
|
|
55
55
|
* so truncated names show a native tooltip on hover. Default `false`.
|
|
56
56
|
*/
|
|
57
57
|
showTitles?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Tree-wide icon overrides (raw SVG strings) for files, folders, open folders and the
|
|
60
|
+
* chevron. Omitted entries keep the built-in icons.
|
|
61
|
+
*/
|
|
62
|
+
icons?: FileTreeIcons;
|
|
63
|
+
/**
|
|
64
|
+
* Picks an icon per node, e.g. by file extension. Return `undefined` to fall back to `icons`.
|
|
65
|
+
* Precedence: `node.icon` → `nodeIcon(node, expanded)` → `icons` → built-in.
|
|
66
|
+
*/
|
|
67
|
+
nodeIcon?: FileTreeNodeIcon;
|
|
58
68
|
/**
|
|
59
69
|
* Returns the context-menu items shown when a node is right-clicked.
|
|
60
70
|
* Return `[]` (or omit the prop) to leave the native browser menu in place.
|
|
@@ -94,6 +104,8 @@
|
|
|
94
104
|
nodeActionsPlacement = 'end',
|
|
95
105
|
collapsible = true,
|
|
96
106
|
showTitles = false,
|
|
107
|
+
icons,
|
|
108
|
+
nodeIcon,
|
|
97
109
|
menuItems,
|
|
98
110
|
menuMinWidth = '11.25rem',
|
|
99
111
|
onSelect,
|
|
@@ -231,6 +243,8 @@
|
|
|
231
243
|
{nodeActionsPlacement}
|
|
232
244
|
{collapsible}
|
|
233
245
|
{showTitles}
|
|
246
|
+
{icons}
|
|
247
|
+
{nodeIcon}
|
|
234
248
|
{dragging}
|
|
235
249
|
onDragState={(d) => (dragging = d)}
|
|
236
250
|
/>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
-
import type { FileTreeNode } from './FileTreeNode.js';
|
|
2
|
+
import type { FileTreeIcons, FileTreeNode, FileTreeNodeIcon } from './FileTreeNode.js';
|
|
3
3
|
import type { ContextMenuItem } from '../../ui/ContextMenu.svelte';
|
|
4
4
|
export interface FileTreeDropEvent {
|
|
5
5
|
/** Id of the node that was dragged */
|
|
@@ -52,6 +52,16 @@ export interface FileTreeProps {
|
|
|
52
52
|
* so truncated names show a native tooltip on hover. Default `false`.
|
|
53
53
|
*/
|
|
54
54
|
showTitles?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Tree-wide icon overrides (raw SVG strings) for files, folders, open folders and the
|
|
57
|
+
* chevron. Omitted entries keep the built-in icons.
|
|
58
|
+
*/
|
|
59
|
+
icons?: FileTreeIcons;
|
|
60
|
+
/**
|
|
61
|
+
* Picks an icon per node, e.g. by file extension. Return `undefined` to fall back to `icons`.
|
|
62
|
+
* Precedence: `node.icon` → `nodeIcon(node, expanded)` → `icons` → built-in.
|
|
63
|
+
*/
|
|
64
|
+
nodeIcon?: FileTreeNodeIcon;
|
|
55
65
|
/**
|
|
56
66
|
* Returns the context-menu items shown when a node is right-clicked.
|
|
57
67
|
* Return `[]` (or omit the prop) to leave the native browser menu in place.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import Icon from '../../icon/Icon.svelte';
|
|
3
3
|
import { iconChevronRight, iconFolder, iconFile } from '../../icon/index.js';
|
|
4
4
|
import { draggable, droppable, type DragContext } from '../../util/DragDrop.js';
|
|
5
|
-
import type { FileTreeNode } from './FileTreeNode.js';
|
|
5
|
+
import type { FileTreeIcons, FileTreeNode, FileTreeNodeIcon } from './FileTreeNode.js';
|
|
6
6
|
import type { Snippet } from 'svelte';
|
|
7
7
|
import { fly } from 'svelte/transition';
|
|
8
8
|
import Self from './FileTreeItem.svelte';
|
|
@@ -38,6 +38,10 @@
|
|
|
38
38
|
collapsible?: boolean;
|
|
39
39
|
/** When true, the label gets a title attribute (native tooltip) with the node name */
|
|
40
40
|
showTitles?: boolean;
|
|
41
|
+
/** Tree-wide icon overrides */
|
|
42
|
+
icons?: FileTreeIcons;
|
|
43
|
+
/** Per-node icon resolver; falls back to `icons` when it returns undefined */
|
|
44
|
+
nodeIcon?: FileTreeNodeIcon;
|
|
41
45
|
/** True while any row in the tree is being dragged */
|
|
42
46
|
dragging?: boolean;
|
|
43
47
|
/** Notifies the tree when this row starts/ends dragging */
|
|
@@ -61,6 +65,8 @@
|
|
|
61
65
|
nodeActionsPlacement = 'end',
|
|
62
66
|
collapsible = true,
|
|
63
67
|
showTitles = false,
|
|
68
|
+
icons,
|
|
69
|
+
nodeIcon,
|
|
64
70
|
dragging = false,
|
|
65
71
|
onDragState
|
|
66
72
|
}: Props = $props();
|
|
@@ -83,6 +89,14 @@
|
|
|
83
89
|
/** Only folders with children get a working chevron; empty folders keep the space for alignment */
|
|
84
90
|
const canToggle = $derived(hasChildren && collapsible);
|
|
85
91
|
|
|
92
|
+
const rowIcon = $derived(
|
|
93
|
+
node.icon ??
|
|
94
|
+
nodeIcon?.(node, expanded) ??
|
|
95
|
+
(isFolder
|
|
96
|
+
? ((expanded && hasChildren ? icons?.folderOpen : undefined) ?? icons?.folder ?? iconFolder)
|
|
97
|
+
: (icons?.file ?? iconFile))
|
|
98
|
+
);
|
|
99
|
+
|
|
86
100
|
interface TreePayload {
|
|
87
101
|
sourceId: string;
|
|
88
102
|
}
|
|
@@ -196,10 +210,10 @@
|
|
|
196
210
|
if (canToggle) e.stopPropagation();
|
|
197
211
|
}}
|
|
198
212
|
>
|
|
199
|
-
<Icon svg={iconChevronRight} size="0.875rem" />
|
|
213
|
+
<Icon svg={icons?.chevron ?? iconChevronRight} size="0.875rem" />
|
|
200
214
|
</span>
|
|
201
215
|
<span class="ft-icon">
|
|
202
|
-
<Icon svg={
|
|
216
|
+
<Icon svg={rowIcon} size="1rem" />
|
|
203
217
|
</span>
|
|
204
218
|
{#if nodeContent}
|
|
205
219
|
{@render nodeContent(node)}
|
|
@@ -235,6 +249,8 @@
|
|
|
235
249
|
{nodeActionsPlacement}
|
|
236
250
|
{collapsible}
|
|
237
251
|
{showTitles}
|
|
252
|
+
{icons}
|
|
253
|
+
{nodeIcon}
|
|
238
254
|
{dragging}
|
|
239
255
|
{onDragState}
|
|
240
256
|
/>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FileTreeNode } from './FileTreeNode.js';
|
|
1
|
+
import type { FileTreeIcons, FileTreeNode, FileTreeNodeIcon } from './FileTreeNode.js';
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
3
|
export type DropZone = 'before' | 'inside' | 'after' | null;
|
|
4
4
|
interface Props {
|
|
@@ -30,6 +30,10 @@ interface Props {
|
|
|
30
30
|
collapsible?: boolean;
|
|
31
31
|
/** When true, the label gets a title attribute (native tooltip) with the node name */
|
|
32
32
|
showTitles?: boolean;
|
|
33
|
+
/** Tree-wide icon overrides */
|
|
34
|
+
icons?: FileTreeIcons;
|
|
35
|
+
/** Per-node icon resolver; falls back to `icons` when it returns undefined */
|
|
36
|
+
nodeIcon?: FileTreeNodeIcon;
|
|
33
37
|
/** True while any row in the tree is being dragged */
|
|
34
38
|
dragging?: boolean;
|
|
35
39
|
/** Notifies the tree when this row starts/ends dragging */
|
|
@@ -9,11 +9,27 @@ export interface FileTreeNode {
|
|
|
9
9
|
children?: FileTreeNode[];
|
|
10
10
|
/** Persisted open/closed state for folders */
|
|
11
11
|
expanded?: boolean;
|
|
12
|
-
/** Optional custom icon (raw SVG string). Overrides the
|
|
12
|
+
/** Optional custom icon (raw SVG string). Overrides the tree's `nodeIcon` and `icons`. */
|
|
13
13
|
icon?: string;
|
|
14
14
|
/** Arbitrary application data ignored by the component */
|
|
15
15
|
data?: unknown;
|
|
16
16
|
}
|
|
17
|
+
/** Tree-wide icon overrides (raw SVG strings). Any omitted entry falls back to the built-in icon. */
|
|
18
|
+
export interface FileTreeIcons {
|
|
19
|
+
/** Icon for file rows. Default `iconFile`. */
|
|
20
|
+
file?: string;
|
|
21
|
+
/** Icon for folder rows. Default `iconFolder`. */
|
|
22
|
+
folder?: string;
|
|
23
|
+
/** Icon for expanded folders. Defaults to `folder`. */
|
|
24
|
+
folderOpen?: string;
|
|
25
|
+
/** Expand/collapse chevron. Should point right — it rotates 90° when the folder is open. Default `iconChevronRight`. */
|
|
26
|
+
chevron?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Picks an icon for a node (e.g. by file extension). Return `undefined` to fall back to `icons`.
|
|
30
|
+
* A node's own `icon` still takes precedence.
|
|
31
|
+
*/
|
|
32
|
+
export type FileTreeNodeIcon = (node: FileTreeNode, expanded: boolean) => string | undefined;
|
|
17
33
|
export interface FileTreeDropTarget {
|
|
18
34
|
/** Parent id — null for tree root */
|
|
19
35
|
parentId: string | null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { default as FileTree } from './FileTree.svelte';
|
|
2
2
|
export { default as FileTreeItem } from './FileTreeItem.svelte';
|
|
3
3
|
export type { FileTreeProps, FileTreeDropEvent } from './FileTree.svelte';
|
|
4
|
-
export type { FileTreeNode, FileTreeNodeType, FileTreeDropTarget } from './FileTreeNode.js';
|
|
4
|
+
export type { FileTreeNode, FileTreeNodeType, FileTreeDropTarget, FileTreeIcons, FileTreeNodeIcon } from './FileTreeNode.js';
|
|
5
5
|
export { findNode, findParent, findPath, expandTo, isAncestor, moveNode } from './FileTreeNode.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@placeholderco/placeholder-ui",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.5",
|
|
4
4
|
"description": "A modern, customizable Svelte 5 UI component library with comprehensive theming support. Re-brand it with a single config object.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Placeholderco",
|