@placeholderco/placeholder-ui 3.3.3 → 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.
@@ -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();
@@ -80,6 +86,16 @@
80
86
  const isFolder = $derived(node.type === 'folder');
81
87
  const hasChildren = $derived(isFolder && (node.children?.length ?? 0) > 0);
82
88
  const expanded = $derived(!collapsible || !!node.expanded);
89
+ /** Only folders with children get a working chevron; empty folders keep the space for alignment */
90
+ const canToggle = $derived(hasChildren && collapsible);
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
+ );
83
99
 
84
100
  interface TreePayload {
85
101
  sourceId: string;
@@ -183,21 +199,21 @@
183
199
  <!-- svelte-ignore a11y_no_static_element_interactions -->
184
200
  <span
185
201
  class="ft-chevron"
186
- class:invisible={!isFolder || !collapsible}
202
+ class:invisible={!canToggle}
187
203
  class:open={expanded}
188
204
  onclick={(e) => {
189
- if (!isFolder || !collapsible) return;
205
+ if (!canToggle) return;
190
206
  e.stopPropagation();
191
207
  onToggle?.(node);
192
208
  }}
193
209
  ondblclick={(e) => {
194
- if (isFolder && collapsible) e.stopPropagation();
210
+ if (canToggle) e.stopPropagation();
195
211
  }}
196
212
  >
197
- <Icon svg={iconChevronRight} size="0.875rem" />
213
+ <Icon svg={icons?.chevron ?? iconChevronRight} size="0.875rem" />
198
214
  </span>
199
215
  <span class="ft-icon">
200
- <Icon svg={node.icon ?? (isFolder ? iconFolder : iconFile)} size="1rem" />
216
+ <Icon svg={rowIcon} size="1rem" />
201
217
  </span>
202
218
  {#if nodeContent}
203
219
  {@render nodeContent(node)}
@@ -233,6 +249,8 @@
233
249
  {nodeActionsPlacement}
234
250
  {collapsible}
235
251
  {showTitles}
252
+ {icons}
253
+ {nodeIcon}
236
254
  {dragging}
237
255
  {onDragState}
238
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 default file/folder icon. */
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",
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",
@@ -70,19 +70,19 @@
70
70
  },
71
71
  "devDependencies": {
72
72
  "@sveltejs/adapter-static": "^4.0.1",
73
- "@sveltejs/kit": "^3.1.1",
73
+ "@sveltejs/kit": "^3.2.0",
74
74
  "@sveltejs/package": "^3.0.2",
75
75
  "@sveltejs/vite-plugin-svelte": "^7.3.1",
76
76
  "@types/node": "^26.6.6",
77
77
  "globals": "^17.14.0",
78
- "prettier": "^3.9.10",
78
+ "prettier": "^3.10.0",
79
79
  "prettier-plugin-svelte": "^4.1.1",
80
80
  "publint": "^0.3.25",
81
81
  "rimraf": "^6.1.4",
82
82
  "svelte": "^5.57.3",
83
83
  "svelte-check": "^4.7.8",
84
84
  "typescript": "^6.0.3",
85
- "vite": "^8.3.7"
85
+ "vite": "^8.3.8"
86
86
  },
87
87
  "dependencies": {
88
88
  "@codemirror/autocomplete": "^6.20.4",
@@ -101,23 +101,23 @@
101
101
  "@codemirror/theme-one-dark": "^6.1.3",
102
102
  "@codemirror/view": "^6.43.15",
103
103
  "@lezer/highlight": "^1.2.5",
104
- "@tiptap/core": "^3.33.0",
105
- "@tiptap/extension-bubble-menu": "^3.33.0",
106
- "@tiptap/extension-code-block": "^3.33.0",
107
- "@tiptap/extension-collaboration": "^3.33.0",
108
- "@tiptap/extension-collaboration-caret": "^3.33.0",
109
- "@tiptap/extension-color": "^3.33.0",
110
- "@tiptap/extension-image": "^3.33.0",
111
- "@tiptap/extension-link": "^3.33.0",
112
- "@tiptap/extension-placeholder": "^3.33.0",
113
- "@tiptap/extension-subscript": "^3.33.0",
114
- "@tiptap/extension-superscript": "^3.33.0",
115
- "@tiptap/extension-table": "^3.33.0",
116
- "@tiptap/extension-text-align": "^3.33.0",
117
- "@tiptap/extension-text-style": "^3.33.0",
118
- "@tiptap/extension-underline": "^3.33.0",
119
- "@tiptap/pm": "^3.33.0",
120
- "@tiptap/starter-kit": "^3.33.0",
104
+ "@tiptap/core": "^3.33.1",
105
+ "@tiptap/extension-bubble-menu": "^3.33.1",
106
+ "@tiptap/extension-code-block": "^3.33.1",
107
+ "@tiptap/extension-collaboration": "^3.33.1",
108
+ "@tiptap/extension-collaboration-caret": "^3.33.1",
109
+ "@tiptap/extension-color": "^3.33.1",
110
+ "@tiptap/extension-image": "^3.33.1",
111
+ "@tiptap/extension-link": "^3.33.1",
112
+ "@tiptap/extension-placeholder": "^3.33.1",
113
+ "@tiptap/extension-subscript": "^3.33.1",
114
+ "@tiptap/extension-superscript": "^3.33.1",
115
+ "@tiptap/extension-table": "^3.33.1",
116
+ "@tiptap/extension-text-align": "^3.33.1",
117
+ "@tiptap/extension-text-style": "^3.33.1",
118
+ "@tiptap/extension-underline": "^3.33.1",
119
+ "@tiptap/pm": "^3.33.1",
120
+ "@tiptap/starter-kit": "^3.33.1",
121
121
  "dayjs": "^1.11.23",
122
122
  "svelte-sonner": "^1.2.3",
123
123
  "yjs": "^13.6.33"