@nextcloud/files 3.0.0-beta.21 → 3.0.0-beta.22
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/fileAction.d.ts +3 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +5 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -9
package/dist/fileAction.d.ts
CHANGED
|
@@ -30,6 +30,8 @@ interface FileActionData {
|
|
|
30
30
|
id: string;
|
|
31
31
|
/** Translatable string displayed in the menu */
|
|
32
32
|
displayName: (files: Node[], view: View) => string;
|
|
33
|
+
/** Translatable title for of the action */
|
|
34
|
+
title?: (files: Node[], view: View) => string;
|
|
33
35
|
/** Svg as inline string. <svg><path fill="..." /></svg> */
|
|
34
36
|
iconSvgInline: (files: Node[], view: View) => string;
|
|
35
37
|
/** Condition wether this action is shown or not */
|
|
@@ -75,6 +77,7 @@ export declare class FileAction {
|
|
|
75
77
|
constructor(action: FileActionData);
|
|
76
78
|
get id(): string;
|
|
77
79
|
get displayName(): (files: Node[], view: View) => string;
|
|
80
|
+
get title(): ((files: Node[], view: View) => string) | undefined;
|
|
78
81
|
get iconSvgInline(): (files: Node[], view: View) => string;
|
|
79
82
|
get enabled(): ((files: Node[], view: View) => boolean) | undefined;
|
|
80
83
|
get exec(): (file: Node, view: View, dir: string) => Promise<boolean | null>;
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("@nextcloud/auth"),X=require("@nextcloud/logger"),gt=require("@nextcloud/l10n"),b=require("path"),mt=require("@nextcloud/router"),H=require("webdav"),wt=require("webdav/dist/node/request.js"),vt=t=>t===null?X.getLoggerBuilder().setApp("files").build():X.getLoggerBuilder().setApp("files").setUid(t.uid).build(),w=vt(_.getCurrentUser());class yt{_entries=[];registerEntry(e){this.validateEntry(e),this._entries.push(e)}unregisterEntry(e){const i=typeof e=="string"?this.getEntryIndex(e):this.getEntryIndex(e.id);if(i===-1){w.warn("Entry not found, nothing removed",{entry:e,entries:this.getEntries()});return}this._entries.splice(i,1)}getEntries(e){return e?this._entries.filter(i=>typeof i.if=="function"?i.if(e):!0):this._entries}getEntryIndex(e){return this._entries.findIndex(i=>i.id===e)}validateEntry(e){if(!e.id||!e.displayName||!(e.iconSvgInline||e.iconClass||e.handler))throw new Error("Invalid entry");if(typeof e.id!="string"||typeof e.displayName!="string")throw new Error("Invalid id or displayName property");if(e.iconClass&&typeof e.iconClass!="string"||e.iconSvgInline&&typeof e.iconSvgInline!="string")throw new Error("Invalid icon provided");if(e.if!==void 0&&typeof e.if!="function")throw new Error("Invalid if property");if(e.templateName&&typeof e.templateName!="string")throw new Error("Invalid templateName property");if(e.handler&&typeof e.handler!="function")throw new Error("Invalid handler property");if(!e.templateName&&!e.handler)throw new Error("At least a templateName or a handler must be provided");if(this.getEntryIndex(e.id)!==-1)throw new Error("Duplicate entry")}}const $=function(){return typeof window._nc_newfilemenu>"u"&&(window._nc_newfilemenu=new yt,w.debug("NewFileMenu initialized")),window._nc_newfilemenu},C=["B","KB","MB","GB","TB","PB"],D=["B","KiB","MiB","GiB","TiB","PiB"];function bt(t,e=!1,i=!1){typeof t=="string"&&(t=Number(t));let s=t>0?Math.floor(Math.log(t)/Math.log(i?1024:1e3)):0;s=Math.min((i?D.length:C.length)-1,s);const n=i?D[s]:C[s];let r=(t/Math.pow(i?1024:1e3,s)).toFixed(1);return e===!0&&s===0?(r!=="0.0"?"< 1 ":"0 ")+(i?D[1]:C[1]):(s<2?r=parseFloat(r).toFixed(0):r=parseFloat(r).toLocaleString(gt.getCanonicalLocale()),r+" "+n)}var k=(t=>(t.DEFAULT="default",t.HIDDEN="hidden",t))(k||{});class xt{_action;constructor(e){this.validateAction(e),this._action=e}get id(){return this._action.id}get displayName(){return this._action.displayName}get iconSvgInline(){return this._action.iconSvgInline}get enabled(){return this._action.enabled}get exec(){return this._action.exec}get execBatch(){return this._action.execBatch}get order(){return this._action.order}get default(){return this._action.default}get inline(){return this._action.inline}get renderInline(){return this._action.renderInline}validateAction(e){if(!e.id||typeof e.id!="string")throw new Error("Invalid id");if(!e.displayName||typeof e.displayName!="function")throw new Error("Invalid displayName function");if(!e.iconSvgInline||typeof e.iconSvgInline!="function")throw new Error("Invalid iconSvgInline function");if(!e.exec||typeof e.exec!="function")throw new Error("Invalid exec function");if("enabled"in e&&typeof e.enabled!="function")throw new Error("Invalid enabled function");if("execBatch"in e&&typeof e.execBatch!="function")throw new Error("Invalid execBatch function");if("order"in e&&typeof e.order!="number")throw new Error("Invalid order");if(e.default&&!Object.values(k).includes(e.default))throw new Error("Invalid default");if("inline"in e&&typeof e.inline!="function")throw new Error("Invalid inline function");if("renderInline"in e&&typeof e.renderInline!="function")throw new Error("Invalid renderInline function")}}const Et=function(t){if(typeof window._nc_fileactions>"u"&&(window._nc_fileactions=[],w.debug("FileActions initialized")),window._nc_fileactions.find(e=>e.id===t.id)){w.error(`FileAction ${t.id} already registered`,{action:t});return}window._nc_fileactions.push(t)},Nt=function(){return typeof window._nc_fileactions>"u"&&(window._nc_fileactions=[],w.debug("FileActions initialized")),window._nc_fileactions};class _t{_header;constructor(e){this.validateHeader(e),this._header=e}get id(){return this._header.id}get order(){return this._header.order}get enabled(){return this._header.enabled}get render(){return this._header.render}get updated(){return this._header.updated}validateHeader(e){if(!e.id||!e.render||!e.updated)throw new Error("Invalid header: id, render and updated are required");if(typeof e.id!="string")throw new Error("Invalid id property");if(e.enabled!==void 0&&typeof e.enabled!="function")throw new Error("Invalid enabled property");if(e.render&&typeof e.render!="function")throw new Error("Invalid render property");if(e.updated&&typeof e.updated!="function")throw new Error("Invalid updated property")}}const At=function(t){if(typeof window._nc_filelistheader>"u"&&(window._nc_filelistheader=[],w.debug("FileListHeaders initialized")),window._nc_filelistheader.find(e=>e.id===t.id)){w.error(`Header ${t.id} already registered`,{header:t});return}window._nc_filelistheader.push(t)},Tt=function(){return typeof window._nc_filelistheader>"u"&&(window._nc_filelistheader=[],w.debug("FileListHeaders initialized")),window._nc_filelistheader};var m=(t=>(t[t.NONE=0]="NONE",t[t.CREATE=4]="CREATE",t[t.READ=1]="READ",t[t.UPDATE=2]="UPDATE",t[t.DELETE=8]="DELETE",t[t.SHARE=16]="SHARE",t[t.ALL=31]="ALL",t))(m||{});const L=["d:getcontentlength","d:getcontenttype","d:getetag","d:getlastmodified","d:quota-available-bytes","d:resourcetype","nc:has-preview","nc:is-encrypted","nc:mount-type","nc:share-attributes","oc:comments-unread","oc:favorite","oc:fileid","oc:owner-display-name","oc:owner-id","oc:permissions","oc:share-types","oc:size","ocs:share-permissions"],R={d:"DAV:",nc:"http://nextcloud.org/ns",oc:"http://owncloud.org/ns",ocs:"http://open-collaboration-services.org/ns"},It=function(t,e={nc:"http://nextcloud.org/ns"}){typeof window._nc_dav_properties>"u"&&(window._nc_dav_properties=[...L],window._nc_dav_namespaces={...R});const i={...window._nc_dav_namespaces,...e};if(window._nc_dav_properties.find(n=>n===t))return w.error(`${t} already registered`,{prop:t}),!1;if(t.startsWith("<")||t.split(":").length!==2)return w.error(`${t} is not valid. See example: 'oc:fileid'`,{prop:t}),!1;const s=t.split(":")[0];return i[s]?(window._nc_dav_properties.push(t),window._nc_dav_namespaces=i,!0):(w.error(`${t} namespace unknown`,{prop:t,namespaces:i}),!1)},T=function(){return typeof window._nc_dav_properties>"u"&&(window._nc_dav_properties=[...L]),window._nc_dav_properties.map(t=>`<${t} />`).join(" ")},I=function(){return typeof window._nc_dav_namespaces>"u"&&(window._nc_dav_namespaces={...R}),Object.keys(window._nc_dav_namespaces).map(t=>`xmlns:${t}="${window._nc_dav_namespaces?.[t]}"`).join(" ")},Ot=function(){return`<?xml version="1.0"?>
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("@nextcloud/auth"),X=require("@nextcloud/logger"),gt=require("@nextcloud/l10n"),b=require("path"),mt=require("@nextcloud/router"),H=require("webdav"),wt=require("webdav/dist/node/request.js"),vt=t=>t===null?X.getLoggerBuilder().setApp("files").build():X.getLoggerBuilder().setApp("files").setUid(t.uid).build(),w=vt(_.getCurrentUser());class yt{_entries=[];registerEntry(e){this.validateEntry(e),this._entries.push(e)}unregisterEntry(e){const i=typeof e=="string"?this.getEntryIndex(e):this.getEntryIndex(e.id);if(i===-1){w.warn("Entry not found, nothing removed",{entry:e,entries:this.getEntries()});return}this._entries.splice(i,1)}getEntries(e){return e?this._entries.filter(i=>typeof i.if=="function"?i.if(e):!0):this._entries}getEntryIndex(e){return this._entries.findIndex(i=>i.id===e)}validateEntry(e){if(!e.id||!e.displayName||!(e.iconSvgInline||e.iconClass||e.handler))throw new Error("Invalid entry");if(typeof e.id!="string"||typeof e.displayName!="string")throw new Error("Invalid id or displayName property");if(e.iconClass&&typeof e.iconClass!="string"||e.iconSvgInline&&typeof e.iconSvgInline!="string")throw new Error("Invalid icon provided");if(e.if!==void 0&&typeof e.if!="function")throw new Error("Invalid if property");if(e.templateName&&typeof e.templateName!="string")throw new Error("Invalid templateName property");if(e.handler&&typeof e.handler!="function")throw new Error("Invalid handler property");if(!e.templateName&&!e.handler)throw new Error("At least a templateName or a handler must be provided");if(this.getEntryIndex(e.id)!==-1)throw new Error("Duplicate entry")}}const $=function(){return typeof window._nc_newfilemenu>"u"&&(window._nc_newfilemenu=new yt,w.debug("NewFileMenu initialized")),window._nc_newfilemenu},C=["B","KB","MB","GB","TB","PB"],D=["B","KiB","MiB","GiB","TiB","PiB"];function bt(t,e=!1,i=!1){typeof t=="string"&&(t=Number(t));let s=t>0?Math.floor(Math.log(t)/Math.log(i?1024:1e3)):0;s=Math.min((i?D.length:C.length)-1,s);const n=i?D[s]:C[s];let r=(t/Math.pow(i?1024:1e3,s)).toFixed(1);return e===!0&&s===0?(r!=="0.0"?"< 1 ":"0 ")+(i?D[1]:C[1]):(s<2?r=parseFloat(r).toFixed(0):r=parseFloat(r).toLocaleString(gt.getCanonicalLocale()),r+" "+n)}var k=(t=>(t.DEFAULT="default",t.HIDDEN="hidden",t))(k||{});class xt{_action;constructor(e){this.validateAction(e),this._action=e}get id(){return this._action.id}get displayName(){return this._action.displayName}get title(){return this._action.title}get iconSvgInline(){return this._action.iconSvgInline}get enabled(){return this._action.enabled}get exec(){return this._action.exec}get execBatch(){return this._action.execBatch}get order(){return this._action.order}get default(){return this._action.default}get inline(){return this._action.inline}get renderInline(){return this._action.renderInline}validateAction(e){if(!e.id||typeof e.id!="string")throw new Error("Invalid id");if(!e.displayName||typeof e.displayName!="function")throw new Error("Invalid displayName function");if("title"in e&&typeof e.title!="function")throw new Error("Invalid title function");if(!e.iconSvgInline||typeof e.iconSvgInline!="function")throw new Error("Invalid iconSvgInline function");if(!e.exec||typeof e.exec!="function")throw new Error("Invalid exec function");if("enabled"in e&&typeof e.enabled!="function")throw new Error("Invalid enabled function");if("execBatch"in e&&typeof e.execBatch!="function")throw new Error("Invalid execBatch function");if("order"in e&&typeof e.order!="number")throw new Error("Invalid order");if(e.default&&!Object.values(k).includes(e.default))throw new Error("Invalid default");if("inline"in e&&typeof e.inline!="function")throw new Error("Invalid inline function");if("renderInline"in e&&typeof e.renderInline!="function")throw new Error("Invalid renderInline function")}}const Et=function(t){if(typeof window._nc_fileactions>"u"&&(window._nc_fileactions=[],w.debug("FileActions initialized")),window._nc_fileactions.find(e=>e.id===t.id)){w.error(`FileAction ${t.id} already registered`,{action:t});return}window._nc_fileactions.push(t)},Nt=function(){return typeof window._nc_fileactions>"u"&&(window._nc_fileactions=[],w.debug("FileActions initialized")),window._nc_fileactions};class _t{_header;constructor(e){this.validateHeader(e),this._header=e}get id(){return this._header.id}get order(){return this._header.order}get enabled(){return this._header.enabled}get render(){return this._header.render}get updated(){return this._header.updated}validateHeader(e){if(!e.id||!e.render||!e.updated)throw new Error("Invalid header: id, render and updated are required");if(typeof e.id!="string")throw new Error("Invalid id property");if(e.enabled!==void 0&&typeof e.enabled!="function")throw new Error("Invalid enabled property");if(e.render&&typeof e.render!="function")throw new Error("Invalid render property");if(e.updated&&typeof e.updated!="function")throw new Error("Invalid updated property")}}const At=function(t){if(typeof window._nc_filelistheader>"u"&&(window._nc_filelistheader=[],w.debug("FileListHeaders initialized")),window._nc_filelistheader.find(e=>e.id===t.id)){w.error(`Header ${t.id} already registered`,{header:t});return}window._nc_filelistheader.push(t)},Tt=function(){return typeof window._nc_filelistheader>"u"&&(window._nc_filelistheader=[],w.debug("FileListHeaders initialized")),window._nc_filelistheader};var m=(t=>(t[t.NONE=0]="NONE",t[t.CREATE=4]="CREATE",t[t.READ=1]="READ",t[t.UPDATE=2]="UPDATE",t[t.DELETE=8]="DELETE",t[t.SHARE=16]="SHARE",t[t.ALL=31]="ALL",t))(m||{});const L=["d:getcontentlength","d:getcontenttype","d:getetag","d:getlastmodified","d:quota-available-bytes","d:resourcetype","nc:has-preview","nc:is-encrypted","nc:mount-type","nc:share-attributes","oc:comments-unread","oc:favorite","oc:fileid","oc:owner-display-name","oc:owner-id","oc:permissions","oc:share-types","oc:size","ocs:share-permissions"],R={d:"DAV:",nc:"http://nextcloud.org/ns",oc:"http://owncloud.org/ns",ocs:"http://open-collaboration-services.org/ns"},It=function(t,e={nc:"http://nextcloud.org/ns"}){typeof window._nc_dav_properties>"u"&&(window._nc_dav_properties=[...L],window._nc_dav_namespaces={...R});const i={...window._nc_dav_namespaces,...e};if(window._nc_dav_properties.find(n=>n===t))return w.error(`${t} already registered`,{prop:t}),!1;if(t.startsWith("<")||t.split(":").length!==2)return w.error(`${t} is not valid. See example: 'oc:fileid'`,{prop:t}),!1;const s=t.split(":")[0];return i[s]?(window._nc_dav_properties.push(t),window._nc_dav_namespaces=i,!0):(w.error(`${t} namespace unknown`,{prop:t,namespaces:i}),!1)},T=function(){return typeof window._nc_dav_properties>"u"&&(window._nc_dav_properties=[...L]),window._nc_dav_properties.map(t=>`<${t} />`).join(" ")},I=function(){return typeof window._nc_dav_namespaces>"u"&&(window._nc_dav_namespaces={...R}),Object.keys(window._nc_dav_namespaces).map(t=>`xmlns:${t}="${window._nc_dav_namespaces?.[t]}"`).join(" ")},Ot=function(){return`<?xml version="1.0"?>
|
|
2
2
|
<d:propfind ${I()}>
|
|
3
3
|
<d:prop>
|
|
4
4
|
${T()}
|