@nocobase/plugin-field-attachment-url 2.3.0-beta.6 → 2.3.0-beta.8
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/client-v2/index.js
CHANGED
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@emotion/css"),require("@nocobase/plugin-file-manager/client-v2"),require("@nocobase/client-v2"),require("@formily/antd-v5"),require("react"),require("@formily/react"),require("@ant-design/icons"),require("@nocobase/flow-engine"),require("lodash")):"function"==typeof define&&define.amd?define("@nocobase/plugin-field-attachment-url/client-v2",["@emotion/css","@nocobase/plugin-file-manager/client-v2","@nocobase/client-v2","@formily/antd-v5","react","@formily/react","@ant-design/icons","@nocobase/flow-engine","lodash"],t):"object"==typeof exports?exports["@nocobase/plugin-field-attachment-url/client-v2"]=t(require("@emotion/css"),require("@nocobase/plugin-file-manager/client-v2"),require("@nocobase/client-v2"),require("@formily/antd-v5"),require("react"),require("@formily/react"),require("@ant-design/icons"),require("@nocobase/flow-engine"),require("lodash")):e["@nocobase/plugin-field-attachment-url/client-v2"]=t(e["@emotion/css"],e["@nocobase/plugin-file-manager/client-v2"],e["@nocobase/client-v2"],e["@formily/antd-v5"],e.react,e["@formily/react"],e["@ant-design/icons"],e["@nocobase/flow-engine"],e.lodash)}(self,function(e,t,n,r,o,i,l,u,a){return function(){"use strict";var c={724:function(e,t,n){n.r(t),n.d(t,{normalizeAttachmentURLFile:function(){return _},getPermanentFilePreviewUrl:function(){return a.getPermanentFilePreviewUrl},isAttachmentURLImage:function(){return U},normalizeAttachmentURLFileList:function(){return S},AttachmentURLFieldModel:function(){return E}});var r=n(375),o=n(477),i=n(418),l=n(230),u=n(694),a=n(936),c=n(773),f=n(155),s=n.n(f),p=JSON.parse('{"UU":"@nocobase/plugin-field-attachment-url"}');function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function b(e){return(b=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function y(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function v(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function m(e,t){return(m=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function h(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],l=!0,u=!1;try{for(o=o.call(e);!(l=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);l=!0);}catch(e){u=!0,r=e}finally{try{l||null==o.return||o.return()}finally{if(u)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return d(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(e){return e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function w(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(w=function(){return!!e})()}function O(){var e,t,n=(e=["\n .ant-upload-list-picture-card {\n margin-bottom: 10px;\n .ant-upload-list-item-container {\n margin: ",";\n }\n }\n .ant-upload-select {\n margin: ",";\n }\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return O=function(){return n},n}var j=function(e){return!!e&&(void 0===e?"undefined":g(e))==="object"&&!Array.isArray(e)},P=function(e){if(!j(e))return null;var t=j(e.data)?e.data:e;return["id","url","preview","filename","extname","mimetype"].some(function(e){return e in t})?t:null},_=function(e){if("string"==typeof e){var t=(0,a.getPermanentFilePreviewUrl)(e),n=y({uid:e,url:e},t?{preview:t}:{}),r=(0,a.getPreviewThumbnailUrl)(n);return y({},n,r?{thumbUrl:r}:{})}var o=P(null==e?void 0:e.response),i=o?v(y({},e,o),{response:e.response,originFileObj:e.originFileObj}):e,l=(null==i?void 0:i.preview)||(0,a.getPermanentFilePreviewUrl)(null==i?void 0:i.url),u=(null==i?void 0:i.mimetype)||(null==i?void 0:i.type),c=y(v(y({},i,!u||(null==i?void 0:i.type)?{}:{type:u}),{uid:(null==i?void 0:i.uid)||(null==i?void 0:i.url)||(null==i?void 0:i.id)}),l?{preview:l}:{}),f=(0,a.getPreviewThumbnailUrl)(c);return y({},c,f?{thumbUrl:f}:{})},x=function(e){var t,n,r;return"string"==typeof e?e:(null==e?void 0:e.url)||(null==e||null==(t=e.response)?void 0:t.url)||(null==e||null==(r=e.response)||null==(n=r.data)?void 0:n.url)||""},S=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=new Map(t.map(function(e){return[x(e),e]}).filter(function(e){return!!h(e,1)[0]}));return(0,c.castArray)(e||[]).filter(Boolean).map(function(e){var t=_(e),r=n.get(x(t));return r?_(y({},r,t)):t})},U=function(e){var t=_(e);return(0,a.matchMimetype)(t,"image/*")},R=function(e){var t=e.showFileName,n=e.value,u=e.onChange,a=(0,l.useField)(),c=h((0,f.useState)(function(){return S(n)}),2),p=c[0],d=c[1];return(0,f.useEffect)(function(){d(function(e){return S(n,e)})},[n]),s().createElement(l.FieldContext.Provider,{value:v(y({},a),{value:p})},s().createElement("div",{style:{display:"flex"},className:(0,o.css)(O(),t?"8px 0px":"0px",t?"8px 0px":"0px")},s().createElement(i.Upload,v(y({},e),{listType:"picture-card",fileList:p,onChange:function(e){var t=S(e);d(t);var n=t[0];if(!n){null==u||u(void 0);return}if("done"===n.status){var r,o,i,l=n.url||(null==(r=n.response)?void 0:r.url)||(null==(i=n.response)||null==(o=i.data)?void 0:o.url);null==u||u(l)}else"removed"===n.status&&(null==u||u(void 0))},itemRender:function(e,n){var r,o=n.name||n.filename||(null==(r=n.url)?void 0:r.split("/").pop())||"",i=o?decodeURIComponent(o):"";return s().createElement(s().Fragment,null,e,t&&s().createElement("div",{style:{fontSize:12,whiteSpace:"nowrap",textOverflow:"ellipsis",overflow:"hidden"},title:i},i))}}),s().createElement(r.UploadOutlined,{style:{fontSize:20}}))))},E=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=b(e),function(e,t){if(t&&("object"===g(t)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,w()?Reflect.construct(e,t||[],b(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&m(n,e),t=[{key:"render",value:function(){return s().createElement(R,this.props)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(a.UploadFieldModel);E.define({label:(0,u.tExpr)("AttachmentURL",{ns:[p.UU,"client"]})}),u.EditableItemModel.bindModelToInterface("AttachmentURLFieldModel",["attachmentURL"],{isDefault:!0}),u.DisplayItemModel.bindModelToInterface("DisplayTextFieldModel",["attachmentURL"],{isDefault:!0})},375:function(e){e.exports=l},477:function(t){t.exports=e},418:function(e){e.exports=r},230:function(e){e.exports=i},485:function(e){e.exports=n},694:function(e){e.exports=u},936:function(e){e.exports=t},773:function(e){e.exports=a},155:function(e){e.exports=o}},f={};function s(e){var t=f[e];if(void 0!==t)return t.exports;var n=f[e]={exports:{}};return c[e](n,n.exports,s),n.exports}s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,{a:t}),t},s.d=function(e,t){for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.g.importScripts&&(p=s.g.location+"");var p,d=s.g.document;if(!p&&d&&(d.currentScript&&"SCRIPT"===d.currentScript.tagName.toUpperCase()&&(p=d.currentScript.src),!p)){var b=d.getElementsByTagName("script");if(b.length)for(var y=b.length-1;y>-1&&(!p||!/^http(s?):/.test(p));)p=b[y--].src}if(!p)throw Error("Automatic publicPath is not supported in this browser");s.p=p.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var v={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src){var n=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");n.indexOf("/static/plugins/@nocobase/plugin-field-attachment-url/dist/client-v2/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-field-attachment-url/dist/client-v2/")}if(!e){var o=window.__nocobase_modern_client_prefix__||"v",i="/"+(o=String(o).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var l=window.location.pathname||"/",u=l.indexOf(i);e=u>=0?l.slice(0,u+1):"/"}e&&(e=e.replace(RegExp("/"+o+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-field-attachment-url/dist/client-v2/"}s.p=e}(),!function(){s.r(v),s.d(v,{AttachmentURLFieldInterface:function(){return i},default:function(){return y},PluginFieldAttachmentUrlClient:function(){return b},AttachmentURLFieldModel:function(){return l.AttachmentURLFieldModel}});var e=s(485);function t(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function n(e){return(n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function r(e,t){return(r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function o(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(o=function(){return!!e})()}var i=function(e){if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function i(){var e,r,l;if(!(this instanceof i))throw TypeError("Cannot call a class as a function");return r=i,l=arguments,r=n(r),t(e=function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,o()?Reflect.construct(r,l||[],n(this).constructor):r.apply(this,l)),"name","attachmentURL"),t(e,"type","object"),t(e,"group","media"),t(e,"title",'{{t("Attachment (URL)")}}'),t(e,"default",{interface:"attachmentURL",type:"string",uiSchema:{type:"string","x-component":"Input"}}),t(e,"availableTypes",["string","text"]),t(e,"validationType","string"),t(e,"availableValidationOptions",["min","max","length","pattern"]),t(e,"configure",{items:[{name:"target",title:'{{t("Which file collection should it be uploaded to")}}',component:"Select",required:!0,defaultValue:"attachments",schema:{enum:"{{fileCollections}}"}},{name:"targetKey",defaultValue:"id",hidden:!0}]}),t(e,"filterable",{operators:"bigField",nested:!0}),t(e,"titleUsable",!0),e}return i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),e&&r(i,e),i}(e.CollectionFieldInterface),l=s(724);function u(e,t,n,r,o,i,l){try{var u=e[i](l),a=u.value}catch(e){n(e);return}u.done?t(a):Promise.resolve(a).then(r,o)}function a(e,t,n){return(a=d()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&f(o,n.prototype),o}).apply(null,arguments)}function c(e){return(c=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function f(e,t){return(f=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function p(e){var t="function"==typeof Map?new Map:void 0;return(p=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return a(e,arguments,c(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),f(n,e)})(e)}function d(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(d=function(){return!!e})()}var b=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=c(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,d()?Reflect.construct(e,t||[],c(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&f(n,e),t=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(l,"next",{value:a(0)}),u(l,"throw",{value:a(1)}),u(l,"return",{value:a(2)}),"function"==typeof Symbol&&u(l,Symbol.iterator,{value:function(){return this}}),l;function a(u){return function(a){var c=[u,a];if(n)throw TypeError("Generator is already executing.");for(;l&&(l=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(e){return this.app.addFieldInterfaces([i]),this.flowEngine.registerModelLoaders({AttachmentURLFieldModel:{loader:function(){return Promise.resolve().then(s.bind(s,724))}}}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){u(i,r,o,l,a,"next",e)}function a(e){u(i,r,o,l,a,"throw",e)}l(void 0)})}).call(this)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(p(e.Plugin)),y=b}(),v}()});
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@emotion/css"),require("@nocobase/plugin-file-manager/client-v2"),require("@nocobase/client-v2"),require("@formily/antd-v5"),require("react"),require("@formily/react"),require("@ant-design/icons"),require("@nocobase/flow-engine"),require("lodash")):"function"==typeof define&&define.amd?define("@nocobase/plugin-field-attachment-url/client-v2",["@emotion/css","@nocobase/plugin-file-manager/client-v2","@nocobase/client-v2","@formily/antd-v5","react","@formily/react","@ant-design/icons","@nocobase/flow-engine","lodash"],t):"object"==typeof exports?exports["@nocobase/plugin-field-attachment-url/client-v2"]=t(require("@emotion/css"),require("@nocobase/plugin-file-manager/client-v2"),require("@nocobase/client-v2"),require("@formily/antd-v5"),require("react"),require("@formily/react"),require("@ant-design/icons"),require("@nocobase/flow-engine"),require("lodash")):e["@nocobase/plugin-field-attachment-url/client-v2"]=t(e["@emotion/css"],e["@nocobase/plugin-file-manager/client-v2"],e["@nocobase/client-v2"],e["@formily/antd-v5"],e.react,e["@formily/react"],e["@ant-design/icons"],e["@nocobase/flow-engine"],e.lodash)}(self,function(e,t,n,r,o,i,l,u,a){return function(){"use strict";var c={724:function(e,t,n){n.r(t),n.d(t,{normalizeAttachmentURLFile:function(){return _},getPermanentFilePreviewUrl:function(){return a.getPermanentFilePreviewUrl},isAttachmentURLImage:function(){return U},normalizeAttachmentURLFileList:function(){return S},AttachmentURLFieldModel:function(){return E}});var r=n(375),o=n(477),i=n(418),l=n(230),u=n(694),a=n(936),c=n(773),f=n(155),s=n.n(f),p=JSON.parse('{"UU":"@nocobase/plugin-field-attachment-url"}');function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function b(e){return(b=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function y(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function v(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function m(e,t){return(m=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function h(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],l=!0,u=!1;try{for(o=o.call(e);!(l=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);l=!0);}catch(e){u=!0,r=e}finally{try{l||null==o.return||o.return()}finally{if(u)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return d(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(e){return e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function w(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(w=function(){return!!e})()}function O(){var e,t,n=(e=["\n .ant-upload-list-picture-card {\n margin-bottom: 10px;\n .ant-upload-list-item-container {\n margin: ",";\n }\n }\n .ant-upload-select {\n margin: ",";\n }\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return O=function(){return n},n}var j=function(e){return!!e&&(void 0===e?"undefined":g(e))==="object"&&!Array.isArray(e)},P=function(e){if(!j(e))return null;var t=j(e.data)?e.data:e;return["id","url","preview","filename","extname","mimetype"].some(function(e){return e in t})?t:null},_=function(e){if("string"==typeof e){var t=(0,a.getPermanentFilePreviewUrl)(e),n=y({uid:e,url:e},t?{preview:t}:{}),r=(0,a.getPreviewThumbnailUrl)(n);return y({},n,r?{thumbUrl:r}:{})}var o=P(null==e?void 0:e.response),i=o?v(y({},e,o),{response:e.response,originFileObj:e.originFileObj}):e,l=(null==i?void 0:i.preview)||(0,a.getPermanentFilePreviewUrl)(null==i?void 0:i.url),u=(null==i?void 0:i.mimetype)||(null==i?void 0:i.type),c=y(v(y({},i,!u||(null==i?void 0:i.type)?{}:{type:u}),{uid:(null==i?void 0:i.uid)||(null==i?void 0:i.url)||(null==i?void 0:i.id)}),l?{preview:l}:{}),f=(0,a.getPreviewThumbnailUrl)(c);return y({},c,f?{thumbUrl:f}:{})},x=function(e){var t,n,r;return"string"==typeof e?e:(null==e?void 0:e.url)||(null==e||null==(t=e.response)?void 0:t.url)||(null==e||null==(r=e.response)||null==(n=r.data)?void 0:n.url)||""},S=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=new Map(t.map(function(e){return[x(e),e]}).filter(function(e){return!!h(e,1)[0]}));return(0,c.castArray)(e||[]).filter(Boolean).map(function(e){var t=_(e),r=n.get(x(t));return r?_(y({},r,t)):t})},U=function(e){var t=_(e);return(0,a.matchMimetype)(t,"image/*")},R=function(e){var t=e.showFileName,n=e.value,u=e.onChange,a=(0,l.useField)(),c=h((0,f.useState)(function(){return S(n)}),2),p=c[0],d=c[1];return(0,f.useEffect)(function(){d(function(e){return S(n,e)})},[n]),s().createElement(l.FieldContext.Provider,{value:v(y({},a),{value:p})},s().createElement("div",{style:{display:"flex"},className:(0,o.css)(O(),t?"8px 0px":"0px",t?"8px 0px":"0px")},s().createElement(i.Upload,v(y({},e),{listType:"picture-card",fileList:p,onChange:function(e){var t=S(e);d(t);var n=t[0];if(!n){null==u||u(void 0);return}if("done"===n.status){var r,o,i,l=n.url||(null==(r=n.response)?void 0:r.url)||(null==(i=n.response)||null==(o=i.data)?void 0:o.url);null==u||u(l)}else"removed"===n.status&&(null==u||u(void 0))},itemRender:function(e,n){var r,o=n.name||n.filename||(null==(r=n.url)?void 0:r.split("/").pop())||"",i=o?decodeURIComponent(o):"";return s().createElement(s().Fragment,null,e,t&&s().createElement("div",{style:{fontSize:12,whiteSpace:"nowrap",textOverflow:"ellipsis",overflow:"hidden"},title:i},i))}}),s().createElement(r.UploadOutlined,{style:{fontSize:20}}))))},E=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=b(e),function(e,t){if(t&&("object"===g(t)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,w()?Reflect.construct(e,t||[],b(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&m(n,e),t=[{key:"render",value:function(){return s().createElement(R,this.props)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(a.UploadFieldModel);E.define({label:(0,u.tExpr)("AttachmentURL",{ns:[p.UU,"client"]})}),u.EditableItemModel.bindModelToInterface("AttachmentURLFieldModel",["attachmentURL"],{isDefault:!0}),u.DisplayItemModel.bindModelToInterface("DisplayTextFieldModel",["attachmentURL"],{isDefault:!0})},375:function(e){e.exports=l},477:function(t){t.exports=e},418:function(e){e.exports=r},230:function(e){e.exports=i},485:function(e){e.exports=n},694:function(e){e.exports=u},936:function(e){e.exports=t},773:function(e){e.exports=a},155:function(e){e.exports=o}},f={};function s(e){var t=f[e];if(void 0!==t)return t.exports;var n=f[e]={exports:{}};return c[e](n,n.exports,s),n.exports}s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,{a:t}),t},s.d=function(e,t){for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.g.importScripts&&(p=s.g.location+"");var p,d=s.g.document;if(!p&&d&&(d.currentScript&&"SCRIPT"===d.currentScript.tagName.toUpperCase()&&(p=d.currentScript.src),!p)){var b=d.getElementsByTagName("script");if(b.length)for(var y=b.length-1;y>-1&&(!p||!/^http(s?):/.test(p));)p=b[y--].src}if(!p)throw Error("Automatic publicPath is not supported in this browser");s.p=p.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var v={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src){var n=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");n.indexOf("/static/plugins/@nocobase/plugin-field-attachment-url/dist/client-v2/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-field-attachment-url/dist/client-v2/")}if(!e){var o=window.__nocobase_modern_client_prefix__||"v",i="/"+(o=String(o).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var l=window.location.pathname||"/",u=l.indexOf(i);e=u>=0?l.slice(0,u+1):"/"}e&&(e=e.replace(RegExp("/"+o+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-field-attachment-url/dist/client-v2/"}s.p=e}(),!function(){s.r(v),s.d(v,{AttachmentURLFieldInterface:function(){return l},default:function(){return m},PluginFieldAttachmentUrlClient:function(){return y},AttachmentURLFieldModel:function(){return u.AttachmentURLFieldModel}});var e=s(485);function t(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function n(e){return(n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function r(e,t){return(r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function o(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(o=function(){return!!e})()}function i(e){var t;return(null==e?void 0:e.name)!=="attachments"&&"file"===((null==e?void 0:e.template)||(null==e||null==(t=e.options)?void 0:t.template))}var l=function(e){if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function l(){var e,r,u;if(!(this instanceof l))throw TypeError("Cannot call a class as a function");return r=l,u=arguments,r=n(r),t(e=function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,o()?Reflect.construct(r,u||[],n(this).constructor):r.apply(this,u)),"name","attachmentURL"),t(e,"type","object"),t(e,"group","media"),t(e,"title",'{{t("Attachment (URL)")}}'),t(e,"default",{interface:"attachmentURL",type:"string",uiSchema:{type:"string","x-component":"Input"}}),t(e,"availableTypes",["string","text"]),t(e,"validationType","string"),t(e,"availableValidationOptions",["min","max","length","pattern"]),t(e,"configure",{items:[{name:"target",title:'{{t("Which file collection should it be uploaded to")}}',component:"Select",required:!0,componentProps:{filter:i},schema:{enum:"{{fileCollections}}"}},{name:"targetKey",defaultValue:"id",hidden:!0}]}),t(e,"filterable",{operators:"bigField",nested:!0}),t(e,"titleUsable",!0),e}return l.prototype=Object.create(e&&e.prototype,{constructor:{value:l,writable:!0,configurable:!0}}),e&&r(l,e),l}(e.CollectionFieldInterface),u=s(724);function a(e,t,n,r,o,i,l){try{var u=e[i](l),a=u.value}catch(e){n(e);return}u.done?t(a):Promise.resolve(a).then(r,o)}function c(e,t,n){return(c=b()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&p(o,n.prototype),o}).apply(null,arguments)}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function p(e,t){return(p=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function d(e){var t="function"==typeof Map?new Map:void 0;return(d=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return c(e,arguments,f(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),p(n,e)})(e)}function b(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(b=function(){return!!e})()}var y=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=f(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,b()?Reflect.construct(e,t||[],f(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&p(n,e),t=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(l,"next",{value:a(0)}),u(l,"throw",{value:a(1)}),u(l,"return",{value:a(2)}),"function"==typeof Symbol&&u(l,Symbol.iterator,{value:function(){return this}}),l;function a(u){return function(a){var c=[u,a];if(n)throw TypeError("Generator is already executing.");for(;l&&(l=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(e){return this.app.addFieldInterfaces([l]),this.flowEngine.registerModelLoaders({AttachmentURLFieldModel:{loader:function(){return Promise.resolve().then(s.bind(s,724))}}}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){a(i,r,o,l,u,"next",e)}function u(e){a(i,r,o,l,u,"throw",e)}l(void 0)})}).call(this)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(d(e.Plugin)),m=y}(),v}()});
|
|
@@ -7,6 +7,14 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
import { CollectionFieldInterface } from '@nocobase/client-v2';
|
|
10
|
+
type CollectionOption = {
|
|
11
|
+
name?: string;
|
|
12
|
+
template?: string;
|
|
13
|
+
options?: {
|
|
14
|
+
template?: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export declare function isAttachmentURLFileCollection(collection?: CollectionOption): boolean;
|
|
10
18
|
export declare class AttachmentURLFieldInterface extends CollectionFieldInterface {
|
|
11
19
|
name: string;
|
|
12
20
|
type: string;
|
|
@@ -29,10 +37,13 @@ export declare class AttachmentURLFieldInterface extends CollectionFieldInterfac
|
|
|
29
37
|
title: string;
|
|
30
38
|
component: string;
|
|
31
39
|
required: boolean;
|
|
32
|
-
|
|
40
|
+
componentProps: {
|
|
41
|
+
filter: typeof isAttachmentURLFileCollection;
|
|
42
|
+
};
|
|
33
43
|
schema: {
|
|
34
44
|
enum: string;
|
|
35
45
|
};
|
|
46
|
+
defaultValue?: undefined;
|
|
36
47
|
hidden?: undefined;
|
|
37
48
|
} | {
|
|
38
49
|
name: string;
|
|
@@ -41,6 +52,7 @@ export declare class AttachmentURLFieldInterface extends CollectionFieldInterfac
|
|
|
41
52
|
title?: undefined;
|
|
42
53
|
component?: undefined;
|
|
43
54
|
required?: undefined;
|
|
55
|
+
componentProps?: undefined;
|
|
44
56
|
schema?: undefined;
|
|
45
57
|
})[];
|
|
46
58
|
};
|
|
@@ -50,3 +62,4 @@ export declare class AttachmentURLFieldInterface extends CollectionFieldInterfac
|
|
|
50
62
|
};
|
|
51
63
|
titleUsable: boolean;
|
|
52
64
|
}
|
|
65
|
+
export {};
|
package/dist/externalVersion.js
CHANGED
|
@@ -8,18 +8,18 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
-
"@nocobase/client": "2.3.0-beta.
|
|
11
|
+
"@nocobase/client": "2.3.0-beta.8",
|
|
12
12
|
"react-i18next": "11.18.6",
|
|
13
13
|
"@ant-design/icons": "5.6.1",
|
|
14
14
|
"@emotion/css": "11.13.0",
|
|
15
15
|
"@formily/antd-v5": "1.2.3",
|
|
16
16
|
"@formily/react": "2.3.7",
|
|
17
|
-
"@nocobase/flow-engine": "2.3.0-beta.
|
|
18
|
-
"@nocobase/plugin-file-manager": "2.3.0-beta.
|
|
17
|
+
"@nocobase/flow-engine": "2.3.0-beta.8",
|
|
18
|
+
"@nocobase/plugin-file-manager": "2.3.0-beta.8",
|
|
19
19
|
"lodash": "4.18.1",
|
|
20
20
|
"react": "18.2.0",
|
|
21
|
-
"@nocobase/client-v2": "2.3.0-beta.
|
|
22
|
-
"@nocobase/server": "2.3.0-beta.
|
|
23
|
-
"@nocobase/test": "2.3.0-beta.
|
|
21
|
+
"@nocobase/client-v2": "2.3.0-beta.8",
|
|
22
|
+
"@nocobase/server": "2.3.0-beta.8",
|
|
23
|
+
"@nocobase/test": "2.3.0-beta.8",
|
|
24
24
|
"@formily/core": "2.3.7"
|
|
25
25
|
};
|
package/dist/server/plugin.js
CHANGED
|
@@ -39,29 +39,21 @@ class PluginFieldAttachmentUrlServer extends import_server.Plugin {
|
|
|
39
39
|
async load() {
|
|
40
40
|
this.app.resourceManager.registerActionHandlers({
|
|
41
41
|
"collections:listFileCollectionsWithPublicStorage": async (ctx, next) => {
|
|
42
|
-
var _a, _b;
|
|
43
42
|
const fileCollections = await this.db.getRepository("collections").find({
|
|
44
43
|
filter: {
|
|
45
44
|
"options.template": "file"
|
|
46
45
|
}
|
|
47
46
|
});
|
|
48
|
-
const filePlugin = this.pm.get("file-manager");
|
|
49
47
|
const options = [];
|
|
50
|
-
const fileCollection
|
|
51
|
-
|
|
48
|
+
for (const fileCollection of fileCollections) {
|
|
49
|
+
if (fileCollection.name === "attachments") {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
52
|
options.push({
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
name: fileCollection.name,
|
|
54
|
+
title: fileCollection.title
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
-
for (const fileCollection2 of fileCollections) {
|
|
58
|
-
if (await filePlugin.isPublicAccessStorage((_b = fileCollection2 == null ? void 0 : fileCollection2.options) == null ? void 0 : _b.storage)) {
|
|
59
|
-
options.push({
|
|
60
|
-
name: fileCollection2.name,
|
|
61
|
-
title: fileCollection2.title
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
57
|
ctx.body = options;
|
|
66
58
|
await next();
|
|
67
59
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-field-attachment-url",
|
|
3
|
-
"version": "2.3.0-beta.
|
|
3
|
+
"version": "2.3.0-beta.8",
|
|
4
4
|
"main": "dist/server/index.js",
|
|
5
5
|
"displayName": "Collection field: Attachment(URL)",
|
|
6
6
|
"displayName.ru-RU": "Поле коллекции: Вложение (URL)",
|
|
@@ -19,5 +19,5 @@
|
|
|
19
19
|
"Collection fields"
|
|
20
20
|
],
|
|
21
21
|
"license": "Apache-2.0",
|
|
22
|
-
"gitHead": "
|
|
22
|
+
"gitHead": "5d458884528593b2d3142a6a33de93bf0ad96543"
|
|
23
23
|
}
|