@classic-homes/files-svelte 0.0.0-stage → 0.2.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.
@@ -0,0 +1,25 @@
1
+ import { type FileRoot, type FilesSource } from '@classic-homes/files-core';
2
+ interface Props {
3
+ source: FilesSource;
4
+ /** Drives shown at the top level. */
5
+ roots: FileRoot[];
6
+ /** Drive of the open folder. */
7
+ rootId?: string;
8
+ /** Open folder, root-relative (`''` = the drive itself). */
9
+ path?: string;
10
+ /** Include hidden folders. */
11
+ showHidden?: boolean;
12
+ /** A folder (or a drive, with `path` `''`) was chosen. */
13
+ onnavigate?: (rootId: string, path: string) => void;
14
+ /** Accessible name of the tree. Default "Folders". */
15
+ label?: string;
16
+ class?: string;
17
+ }
18
+ /**
19
+ * Explorer-style navigation pane: drives at the top level, their folders
20
+ * below, loaded lazily as they expand. The open folder is highlighted and
21
+ * its ancestors are expanded, so its parent and siblings are always in view.
22
+ */
23
+ declare const FileTree: import("svelte").Component<Props, {}, "">;
24
+ type FileTree = ReturnType<typeof FileTree>;
25
+ export default FileTree;
@@ -0,0 +1,11 @@
1
+ export { default as FileBrowser } from './FileBrowser.svelte';
2
+ export { default as FileList } from './FileList.svelte';
3
+ export { default as FileBreadcrumbs } from './FileBreadcrumbs.svelte';
4
+ export { default as FileTree } from './FileTree.svelte';
5
+ export { default as FileIcon } from './FileIcon.svelte';
6
+ export { default as FilePreview } from './FilePreview.svelte';
7
+ export { default as FileDetails } from './FileDetails.svelte';
8
+ export { default as FileErrorState } from './FileErrorState.svelte';
9
+ export type { FileBrowserContext } from './types.js';
10
+ export { downloadEntry } from './utils.js';
11
+ export { createChapiFilesSource, createMemoryFilesSource, FilesError, isFilesError, describeFilesError, writeCapabilities, formatBytes, formatDateTime, formatRelativeTime, joinPath, parentPath, normalizePath, pathSegments, displayPath, kindForName, kindForEntry, previewRoute, saveBlob, type FileEntry, type FileEntryType, type FileKind, type FileListPage, type FileRoot, type FileSort, type FileSortKey, type FilesErrorCode, type FilesSource, type ChapiFilesSourceOptions, type MemoryFile, type MemoryRoot, type MemoryFilesSourceOptions, } from '@classic-homes/files-core';
@@ -0,0 +1,11 @@
1
+ export { default as FileBrowser } from './FileBrowser.svelte';
2
+ export { default as FileList } from './FileList.svelte';
3
+ export { default as FileBreadcrumbs } from './FileBreadcrumbs.svelte';
4
+ export { default as FileTree } from './FileTree.svelte';
5
+ export { default as FileIcon } from './FileIcon.svelte';
6
+ export { default as FilePreview } from './FilePreview.svelte';
7
+ export { default as FileDetails } from './FileDetails.svelte';
8
+ export { default as FileErrorState } from './FileErrorState.svelte';
9
+ export { downloadEntry } from './utils.js';
10
+ // Core re-exports most consumers need alongside the components
11
+ export { createChapiFilesSource, createMemoryFilesSource, FilesError, isFilesError, describeFilesError, writeCapabilities, formatBytes, formatDateTime, formatRelativeTime, joinPath, parentPath, normalizePath, pathSegments, displayPath, kindForName, kindForEntry, previewRoute, saveBlob, } from '@classic-homes/files-core';
@@ -0,0 +1,13 @@
1
+ import type { FileRoot, FilesSource, WriteCapabilities } from '@classic-homes/files-core';
2
+ /** Handed to FileBrowser's `toolbar` and `rowActions` snippets. */
3
+ export interface FileBrowserContext {
4
+ readonly source: FilesSource;
5
+ readonly root: FileRoot | undefined;
6
+ /** Current folder, root-relative. */
7
+ readonly path: string;
8
+ /** Which write actions this root offers (all false while it is read-only). */
9
+ readonly capabilities: WriteCapabilities;
10
+ /** Reload the current folder, e.g. after a write. */
11
+ refresh(): void;
12
+ navigate(path: string): void;
13
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ import { type ClassValue } from 'clsx';
2
+ import { type FileEntry, type FilesSource } from '@classic-homes/files-core';
3
+ export declare function cn(...inputs: ClassValue[]): string;
4
+ /**
5
+ * Download an entry through the source (which sends auth) and save it under
6
+ * the entry's name. Pass an already-loaded Blob to skip the request.
7
+ */
8
+ export declare function downloadEntry(source: FilesSource, rootId: string, entry: FileEntry, options?: {
9
+ blob?: Blob;
10
+ signal?: AbortSignal;
11
+ }): Promise<void>;
12
+ /** True when a key event comes from a place that types text. */
13
+ export declare function isTextInput(target: EventTarget | null): boolean;
@@ -0,0 +1,28 @@
1
+ import { clsx } from 'clsx';
2
+ import { twMerge } from 'tailwind-merge';
3
+ import { saveBlob } from '@classic-homes/files-core';
4
+ export function cn(...inputs) {
5
+ return twMerge(clsx(inputs));
6
+ }
7
+ /**
8
+ * Download an entry through the source (which sends auth) and save it under
9
+ * the entry's name. Pass an already-loaded Blob to skip the request.
10
+ */
11
+ export async function downloadEntry(source, rootId, entry, options = {}) {
12
+ const blob = options.blob ??
13
+ (await source.read(rootId, entry.path, { download: true, signal: options.signal }));
14
+ saveBlob(blob, entry.name);
15
+ }
16
+ /** True when a key event comes from a place that types text. */
17
+ export function isTextInput(target) {
18
+ if (!(target instanceof HTMLElement))
19
+ return false;
20
+ if (target.isContentEditable)
21
+ return true;
22
+ if (target instanceof HTMLTextAreaElement || target instanceof HTMLSelectElement)
23
+ return true;
24
+ if (target instanceof HTMLInputElement) {
25
+ return !['checkbox', 'radio', 'button', 'submit', 'reset', 'range', 'color', 'file'].includes(target.type);
26
+ }
27
+ return target.getAttribute('role') === 'combobox' || target.getAttribute('role') === 'textbox';
28
+ }
package/package.json CHANGED
@@ -1,6 +1,65 @@
1
1
  {
2
2
  "name": "@classic-homes/files-svelte",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "Svelte network-drive file browser for Classic Theme: FileBrowser plus FileList, FileBreadcrumbs, FileIcon, FilePreview and FileDetails, with previews through the document viewers",
5
+ "type": "module",
6
+ "svelte": "./dist/lib/index.js",
7
+ "types": "./dist/lib/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/lib/index.d.ts",
11
+ "svelte": "./dist/lib/index.js",
12
+ "default": "./dist/lib/index.js"
13
+ }
14
+ },
15
+ "sideEffects": false,
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "scripts": {
20
+ "build": "svelte-package -i src",
21
+ "dev": "svelte-package -i src --watch",
22
+ "clean": "node ../../scripts/rm.mjs dist",
23
+ "typecheck": "svelte-check --tsconfig ./tsconfig.json",
24
+ "test": "vitest run",
25
+ "test:watch": "vitest"
26
+ },
27
+ "dependencies": {
28
+ "@classic-homes/files-core": "*",
29
+ "@classic-homes/theme-svelte": "*",
30
+ "@classic-homes/viewer-svelte": "*",
31
+ "clsx": "^2.1.0",
32
+ "tailwind-merge": "^2.2.0"
33
+ },
34
+ "peerDependencies": {
35
+ "svelte": "^5.31.0"
36
+ },
37
+ "devDependencies": {
38
+ "@sveltejs/package": "^2.3.0",
39
+ "@sveltejs/vite-plugin-svelte": "^7.0.0",
40
+ "@testing-library/jest-dom": "^6.6.0",
41
+ "@testing-library/svelte": "^5.0.0",
42
+ "@testing-library/user-event": "^14.5.0",
43
+ "jsdom": "^28.1.0",
44
+ "svelte": "^5.0.0",
45
+ "svelte-check": "^4.0.0",
46
+ "typescript": "^5.3.0",
47
+ "vitest": "^4.0.0",
48
+ "vitest-axe": "^0.1.0"
49
+ },
50
+ "keywords": [
51
+ "file-browser",
52
+ "network-drive",
53
+ "svelte",
54
+ "classic-theme"
55
+ ],
56
+ "license": "MIT",
57
+ "repository": {
58
+ "type": "git",
59
+ "url": "https://github.com/Classic-Homes/classic-theme.git",
60
+ "directory": "packages/files-svelte"
61
+ },
62
+ "publishConfig": {
63
+ "access": "public"
64
+ }
65
+ }