@nextcloud/files 3.5.1 → 3.7.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.
package/README.md CHANGED
@@ -5,7 +5,9 @@
5
5
  # @nextcloud/files
6
6
  [![npm last version](https://img.shields.io/npm/v/@nextcloud/files.svg?style=flat-square)](https://www.npmjs.com/package/@nextcloud/files) [![REUSE status](https://api.reuse.software/badge/github.com/nextcloud-libraries/nextcloud-files)](https://api.reuse.software/info/github.com/nextcloud-libraries/nextcloud-files) [![Code coverage](https://img.shields.io/codecov/c/github/nextcloud-libraries/nextcloud-files?style=flat-square)](https://app.codecov.io/gh/nextcloud-libraries/nextcloud-files) [![Project documentation](https://img.shields.io/badge/documentation-online-blue?style=flat-square)](https://nextcloud-libraries.github.io/nextcloud-files/)
7
7
 
8
- Nextcloud Files helpers for Nextcloud apps and libraries
8
+ Nextcloud Files helpers for Nextcloud apps and libraries.
9
+
10
+ The `davGetClient` exported function returns a webDAV client that's a wrapper around [webdav's webDAV client](https://www.npmjs.com/package/webdav); All its methods are available here.
9
11
 
10
12
  ## Usage example
11
13
 
@@ -57,3 +59,18 @@ const nodes = results.data.map((result) => davResultToNode(r, myRoot))
57
59
  const nodes = results.data.map((result) => davResultToNode(r, myRoot, myRemoteURL))
58
60
 
59
61
  ```
62
+
63
+ ### Using WebDAV to get a Node from a file's name
64
+
65
+ ```ts
66
+ import { davGetClient, davGetDefaultPropfind, davResultToNode, davRootPath } from '@nextcloud/files'
67
+ import { emit } from '@nextcloud/event-bus'
68
+ const client = davGetClient()
69
+ client.stat(`${davRootPath}${filename}`, {
70
+ details: true,
71
+ data: davGetDefaultPropfind(),
72
+ }).then((result) => {
73
+ const node = davResultToNode(result.data)
74
+ emit('files:node:updated', node)
75
+ })
76
+ ```
@@ -0,0 +1,86 @@
1
+ import { TypedEventTarget } from 'typescript-event-target';
2
+ import { INode } from './files/node';
3
+
4
+ /**
5
+ * Active filters can provide one or more "chips" to show the currently active state.
6
+ * Must at least provide a text representing the filters state and a callback to unset that state (disable this filter).
7
+ */
8
+ export interface IFileListFilterChip {
9
+ /**
10
+ * Text of the chip
11
+ */
12
+ text: string;
13
+ /**
14
+ * Optional icon to be used on the chip (inline SVG as string)
15
+ */
16
+ icon?: string;
17
+ /**
18
+ * Handler to be called on click
19
+ */
20
+ onclick: () => void;
21
+ }
22
+ /**
23
+ * This event is emitted when the the filter value changed and the file list needs to be updated
24
+ */
25
+ export interface FilterUpdateEvent extends CustomEvent<never> {
26
+ type: 'update:filter';
27
+ }
28
+ /**
29
+ * This event is emitted when the the filter value changed and the file list needs to be updated
30
+ */
31
+ export interface FilterUpdateChipsEvent extends CustomEvent<IFileListFilterChip[]> {
32
+ type: 'update:chips';
33
+ }
34
+ interface IFileListFilterEvents {
35
+ [name: string]: CustomEvent;
36
+ 'update:filter': FilterUpdateEvent;
37
+ 'update:chips': FilterUpdateChipsEvent;
38
+ }
39
+ export interface IFileListFilter extends TypedEventTarget<IFileListFilterEvents> {
40
+ /**
41
+ * Unique ID of this filter
42
+ */
43
+ readonly id: string;
44
+ /**
45
+ * Order of the filter
46
+ *
47
+ * Use a low number to make this filter ordered in front.
48
+ */
49
+ readonly order: number;
50
+ /**
51
+ * If the filter needs a visual element for settings it can provide a function to mount it.
52
+ */
53
+ readonly mount?: (el: HTMLElement) => void;
54
+ /**
55
+ * Filter function to decide if a node is shown
56
+ * @return The nodes to be shown
57
+ */
58
+ filter(node: INode[]): INode[];
59
+ }
60
+ export declare class FileListFilter extends TypedEventTarget<IFileListFilterEvents> implements IFileListFilter {
61
+ id: string;
62
+ order: number;
63
+ constructor(id: string, order?: number);
64
+ filter(nodes: INode[]): INode[];
65
+ protected updateChips(chips: IFileListFilterChip[]): void;
66
+ protected filterUpdated(): void;
67
+ }
68
+ /**
69
+ * Register a new filter on the file list
70
+ *
71
+ * This only must be called once to register the filter,
72
+ * when the filter state changes you need to call `filterUpdated` on the filter instead.
73
+ *
74
+ * @param filter The filter to register on the file list
75
+ */
76
+ export declare function registerFileListFilter(filter: IFileListFilter): void;
77
+ /**
78
+ * Remove a registered filter from the file list
79
+ * @param filterId The unique ID of the filter to remove
80
+ */
81
+ export declare function unregisterFileListFilter(filterId: string): void;
82
+ /**
83
+ * Get all registered file list filters
84
+ */
85
+ export declare function getFileListFilters(): IFileListFilter[];
86
+ export {};
@@ -35,6 +35,17 @@ export declare abstract class Node {
35
35
  * You can use the rename or move method to change the source.
36
36
  */
37
37
  get basename(): string;
38
+ /**
39
+ * The nodes displayname
40
+ * By default the display name and the `basename` are identical,
41
+ * but it is possible to have a different name. This happens
42
+ * on the files app for example for shared folders.
43
+ */
44
+ get displayname(): string;
45
+ /**
46
+ * Set the displayname
47
+ */
48
+ set displayname(displayname: string);
38
49
  /**
39
50
  * Get this object's extension
40
51
  * There is no setter as the source is not meant to be changed manually.
@@ -25,6 +25,8 @@ export interface NodeData {
25
25
  permissions?: Permission;
26
26
  /** The owner UID of this node */
27
27
  owner: string | null;
28
+ /** Optional the displayname of this node */
29
+ displayname?: string;
28
30
  /** The node attributes */
29
31
  attributes?: Attribute;
30
32
  /**