@nocobase/plugin-field-sort 2.1.0-beta.9 → 2.2.0-alpha.1
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/client-v2.d.ts +2 -0
- package/client-v2.js +1 -0
- package/dist/client/index.d.ts +0 -2
- package/dist/client/index.js +1 -1
- package/dist/client-v2/SortFieldConfigureForm.d.ts +11 -0
- package/dist/client-v2/index.d.ts +12 -0
- package/dist/client-v2/index.js +10 -0
- package/dist/client-v2/locale.d.ts +11 -0
- package/dist/{client → client-v2/models}/SortFieldModel.d.ts +1 -1
- package/dist/client-v2/plugin.d.ts +13 -0
- package/dist/client-v2/sort-interface.d.ts +43 -0
- package/dist/externalVersion.js +9 -8
- package/dist/locale/en-US.json +6 -1
- package/dist/locale/zh-CN.json +6 -1
- package/dist/server/sort-field.js +49 -29
- package/package.json +5 -3
package/client-v2.d.ts
ADDED
package/client-v2.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/client-v2/index.js');
|
package/dist/client/index.d.ts
CHANGED
package/dist/client/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("react"),require("@nocobase/flow-engine"),require("@nocobase/client"),require("antd")):"function"==typeof define&&define.amd?define("@nocobase/plugin-field-sort",["react","@nocobase/flow-engine","@nocobase/client","antd"],t):"object"==typeof exports?exports["@nocobase/plugin-field-sort"]=t(require("react"),require("@nocobase/flow-engine"),require("@nocobase/client"),require("antd")):e["@nocobase/plugin-field-sort"]=t(e.react,e["@nocobase/flow-engine"],e["@nocobase/client"],e.antd)}(self,function(e,t,r,n){return function(){"use strict";var o={772:function(e){e.exports=r},667:function(e){e.exports=t},721:function(e){e.exports=n},156:function(t){t.exports=e}},i={};function u(e){var t=i[e];if(void 0!==t)return t.exports;var r=i[e]={exports:{}};return o[e](r,r.exports,u),r.exports}u.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return u.d(t,{a:t}),t},u.d=function(e,t){for(var r in t)u.o(t,r)&&!u.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},u.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},u.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var c={};return!function(){u.r(c),u.d(c,{PluginFieldSortClient:function(){return P},default:function(){return S}});var e=u(772);function t(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function r(e){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function n(e,t){return(n=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(i){if("function"!=typeof i&&null!==i)throw TypeError("Super expression must either be null or a function");function u(){var n,i,c,a,l;if(!(this instanceof u))throw TypeError("Cannot call a class as a function");return i=u,c=arguments,i=r(i),t(n=function(e,t){var r;if(t&&("object"==((r=t)&&"undefined"!=typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"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(i,c||[],r(this).constructor):i.apply(this,c)),"name","sort"),t(n,"type","object"),t(n,"group","advanced"),t(n,"order",1),t(n,"title",'{{t("Sort")}}'),t(n,"sortable",!0),t(n,"titleUsable",!0),t(n,"description",'{{t("Used for drag and drop sorting scenarios, supporting grouping sorting")}}'),t(n,"default",{type:"sort",uiSchema:{type:"number","x-component":"InputNumber","x-component-props":{stringMode:!0,step:"1"},"x-validator":"integer"}}),t(n,"availableTypes",["sort"]),t(n,"hasDefaultValue",!1),t(n,"properties",(a=function(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(r){t(e,r,n[r])})}return e}({},e.defaultProps),l=l={scopeKey:{type:"string",title:'{{t("Grouped sorting")}}',"x-disabled":"{{ !editMainOnly}}","x-decorator":"FormItem","x-component":"Select",enum:"{{scopeKeyOptions}}",description:"{{t('When a field is selected for grouping, it will be grouped first before sorting.')}}"}},Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(l)):(function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r.push.apply(r,n)}return r})(Object(l)).forEach(function(e){Object.defineProperty(a,e,Object.getOwnPropertyDescriptor(l,e))}),a)),t(n,"filterable",{operators:e.operators.number}),t(n,"validateSchema",function(t){return{maximum:{type:"number",title:'{{ t("Maximum") }}',"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{precision:0},"x-reactions":"{{(field) => {\n const targetValue = field.query('.minimum').value();\n field.selfErrors =\n !!targetValue && !!field.value && targetValue > field.value ? '".concat(e.i18n.t("Maximum must greater than minimum"),"' : ''\n }}}")},minimum:{type:"number",title:'{{ t("Minimum") }}',"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{precision:0},"x-reactions":{dependencies:[".maximum"],fulfill:{state:{selfErrors:"{{!!$deps[0] && !!$self.value && $deps[0] < $self.value ? '".concat(e.i18n.t("Minimum must less than maximum"),"' : ''}}")}}}},format:{type:"string",title:'{{ t("Format") }}',"x-decorator":"FormItem","x-component":"Select","x-component-props":{allowClear:!0},enum:[{label:'{{ t("Odd") }}',value:"odd"},{label:'{{ t("Even") }}',value:"even"}]},pattern:{type:"string",title:'{{ t("Regular expression") }}',"x-decorator":"FormItem","x-component":"Input","x-component-props":{prefix:"/",suffix:"/"}}}}),n}return u.prototype=Object.create(i&&i.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),i&&n(u,i),u}(e.CollectionFieldInterface),a=u(721),l=u(156),f=u.n(l),p=u(667);function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function b(e,t){return(b=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function y(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(y=function(){return!!e})()}var d=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return e=r,t=arguments,e=s(e),function(e,t){var r;if(t&&("object"==((r=t)&&"undefined"!=typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,y()?Reflect.construct(e,t||[],s(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&b(r,e),t=[{key:"render",value:function(){var e,t;return f().createElement(a.InputNumber,(e=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({},this.props),t=t={style:{width:"100%"}},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r.push.apply(r,n)}return r})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e))}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(r.prototype,t),r}(e.FieldModel);function m(e,t,r,n,o,i,u){try{var c=e[i](u),a=c.value}catch(e){r(e);return}c.done?t(a):Promise.resolve(a).then(n,o)}function v(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function u(e){m(i,n,o,u,c,"next",e)}function c(e){m(i,n,o,u,c,"throw",e)}u(void 0)})}}function O(e,t,r){return(O=w()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&g(o,r.prototype),o}).apply(null,arguments)}p.EditableItemModel.bindModelToInterface("SortFieldModel",["sort"],{isDefault:!0}),p.DisplayItemModel.bindModelToInterface("DisplayNumberFieldModel",["sort"],{isDefault:!0});function h(e){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function g(e,t){return(g=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function j(e){var t="function"==typeof Map?new Map:void 0;return(j=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,r)}function r(){return O(e,arguments,h(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),g(r,e)})(e)}function w(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(w=function(){return!!e})()}function x(e,t){var r,n,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){var a=[i,c];if(r)throw TypeError("Generator is already executing.");for(;u;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return u.label++,{value:a[1],done:!1};case 5:u.label++,n=a[1],a=[0];continue;case 7:a=u.ops.pop(),u.trys.pop();continue;default:if(!(o=(o=u.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){u=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){u.label=a[1];break}if(6===a[0]&&u.label<o[1]){u.label=o[1],o=a;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(a);break}o[2]&&u.ops.pop(),u.trys.pop();continue}a=t.call(e,u)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}}var P=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return e=r,t=arguments,e=h(e),function(e,t){var r;if(t&&("object"==((r=t)&&"undefined"!=typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"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||[],h(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&g(r,e),t=[{key:"afterAdd",value:function(){return v(function(){return x(this,function(e){return[2]})})()}},{key:"beforeLoad",value:function(){return v(function(){return x(this,function(e){return[2]})})()}},{key:"load",value:function(){var e=this;return v(function(){return x(this,function(t){return e.app.addFieldInterfaces([i]),e.flowEngine.registerModels({SortFieldModel:d}),[2]})})()}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(r.prototype,t),r}(j(e.Plugin)),S=P}(),c}()});
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("antd"),require("@nocobase/client"),require("@nocobase/client-v2"),require("@nocobase/flow-engine")):"function"==typeof define&&define.amd?define("@nocobase/plugin-field-sort",["react","antd","@nocobase/client","@nocobase/client-v2","@nocobase/flow-engine"],t):"object"==typeof exports?exports["@nocobase/plugin-field-sort"]=t(require("react"),require("antd"),require("@nocobase/client"),require("@nocobase/client-v2"),require("@nocobase/flow-engine")):e["@nocobase/plugin-field-sort"]=t(e.react,e.antd,e["@nocobase/client"],e["@nocobase/client-v2"],e["@nocobase/flow-engine"])}(self,function(e,t,r,n,o){return function(){"use strict";var i={342:function(e){e.exports=r},485:function(e){e.exports=n},694:function(e){e.exports=o},59:function(e){e.exports=t},155:function(t){t.exports=e}},c={};function u(e){var t=c[e];if(void 0!==t)return t.exports;var r=c[e]={exports:{}};return i[e](r,r.exports,u),r.exports}u.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return u.d(t,{a:t}),t},u.d=function(e,t){for(var r in t)u.o(t,r)&&!u.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},u.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),u.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},u.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},u.g.importScripts&&(a=u.g.location+"");var a,l=u.g.document;if(!a&&l&&(l.currentScript&&"SCRIPT"===l.currentScript.tagName.toUpperCase()&&(a=l.currentScript.src),!a)){var p=l.getElementsByTagName("script");if(p.length)for(var s=p.length-1;s>-1&&(!a||!/^http(s?):/.test(a));)a=p[s--].src}if(!a)throw Error("Automatic publicPath is not supported in this browser");u.p=a.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var f={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src&&(e=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-field-sort/dist/client/")}if(!e){var n=window.__nocobase_modern_client_prefix__||"v",o="/"+(n=String(n).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var i=window.location.pathname||"/",c=i.indexOf(o);e=c>=0?i.slice(0,c+1):"/"}e&&(e=e.replace(RegExp("/"+n+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-field-sort/dist/client/"}u.p=e}(),!function(){u.r(f),u.d(f,{default:function(){return _},PluginFieldSortClient:function(){return x}});var e=u(342);function t(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function r(e){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function n(e,t){return(n=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(i){if("function"!=typeof i&&null!==i)throw TypeError("Super expression must either be null or a function");function c(){var n,i,u,a,l;if(!(this instanceof c))throw TypeError("Cannot call a class as a function");return i=c,u=arguments,i=r(i),t(n=function(e,t){var r;if(t&&("object"==((r=t)&&"u">typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"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(i,u||[],r(this).constructor):i.apply(this,u)),"name","sort"),t(n,"type","object"),t(n,"group","advanced"),t(n,"order",1),t(n,"title",'{{t("Sort")}}'),t(n,"sortable",!0),t(n,"titleUsable",!0),t(n,"description",'{{t("Used for drag and drop sorting scenarios, supporting grouping sorting")}}'),t(n,"default",{type:"sort",uiSchema:{type:"number","x-component":"InputNumber","x-component-props":{stringMode:!0,step:"1"},"x-validator":"integer"}}),t(n,"availableTypes",["sort"]),t(n,"hasDefaultValue",!1),t(n,"properties",(a=function(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(r){t(e,r,n[r])})}return e}({},e.defaultProps),l=l={scopeKey:{type:"string",title:'{{t("Grouped sorting")}}',"x-disabled":"{{ !editMainOnly}}","x-decorator":"FormItem","x-component":"Select",enum:"{{scopeKeyOptions}}",description:"{{t('When a field is selected for grouping, it will be grouped first before sorting.')}}"}},Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(l)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(l)).forEach(function(e){Object.defineProperty(a,e,Object.getOwnPropertyDescriptor(l,e))}),a)),t(n,"filterable",{operators:e.operators.number}),t(n,"validateSchema",function(t){return{maximum:{type:"number",title:'{{ t("Maximum") }}',"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{precision:0},"x-reactions":"{{(field) => {\n const targetValue = field.query('.minimum').value();\n field.selfErrors =\n !!targetValue && !!field.value && targetValue > field.value ? '".concat(e.i18n.t("Maximum must greater than minimum"),"' : ''\n }}}")},minimum:{type:"number",title:'{{ t("Minimum") }}',"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{precision:0},"x-reactions":{dependencies:[".maximum"],fulfill:{state:{selfErrors:"{{!!$deps[0] && !!$self.value && $deps[0] < $self.value ? '".concat(e.i18n.t("Minimum must less than maximum"),"' : ''}}")}}}},format:{type:"string",title:'{{ t("Format") }}',"x-decorator":"FormItem","x-component":"Select","x-component-props":{allowClear:!0},enum:[{label:'{{ t("Odd") }}',value:"odd"},{label:'{{ t("Even") }}',value:"even"}]},pattern:{type:"string",title:'{{ t("Regular expression") }}',"x-decorator":"FormItem","x-component":"Input","x-component-props":{prefix:"/",suffix:"/"}}}}),n}return c.prototype=Object.create(i&&i.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),i&&n(c,i),c}(e.CollectionFieldInterface),c=u(155),a=u.n(c),l=u(59),p=u(694),s=u(485);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 r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function d(e,t){return(d=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function m(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(m=function(){return!!e})()}var v=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return e=r,t=arguments,e=b(e),function(e,t){var r;if(t&&("object"==((r=t)&&"u">typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,m()?Reflect.construct(e,t||[],b(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&d(r,e),t=[{key:"render",value:function(){var e,t,r;return a().createElement(l.InputNumber,(t=y({},this.props),r=r={style:y({width:"100%"},null==(e=this.props)?void 0:e.style)},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}),t))}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(r.prototype,t),r}(s.FieldModel);function O(e,t,r,n,o,i,c){try{var u=e[i](c),a=u.value}catch(e){r(e);return}u.done?t(a):Promise.resolve(a).then(n,o)}function g(e,t,r){return(g=P()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&w(o,r.prototype),o}).apply(null,arguments)}v.define({label:function(e){var t,r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,p.tExpr)(e,(t=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({},n),r=r={ns:"@nocobase/plugin-field-sort"},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}),t))}("Sort")}),p.EditableItemModel.bindModelToInterface("SortFieldModel",["sort"],{isDefault:!0}),p.DisplayItemModel.bindModelToInterface("DisplayNumberFieldModel",["sort"],{isDefault:!0}),p.FilterableItemModel.bindModelToInterface("NumberFieldModel",["sort"],{isDefault:!0});function h(e){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function w(e,t){return(w=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function j(e){var t="function"==typeof Map?new Map:void 0;return(j=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,r)}function r(){return g(e,arguments,h(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),w(r,e)})(e)}function P(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(P=function(){return!!e})()}var x=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return e=r,t=arguments,e=h(e),function(e,t){var r;if(t&&("object"==((r=t)&&"u">typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,P()?Reflect.construct(e,t||[],h(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&w(r,e),t=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},c=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(c,"next",{value:a(0)}),u(c,"throw",{value:a(1)}),u(c,"return",{value:a(2)}),"function"==typeof Symbol&&u(c,Symbol.iterator,{value:function(){return this}}),c;function a(u){return function(a){var l=[u,a];if(r)throw TypeError("Generator is already executing.");for(;c&&(c=0,l[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&l[0]?n.return:l[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,l[1])).done)return o;switch(n=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,n=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],n=0}finally{r=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(e){return this.app.addFieldInterfaces([i]),this.flowEngine.registerModels({SortFieldModel:v}),[2]})},function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function c(e){O(i,n,o,c,u,"next",e)}function u(e){O(i,n,o,c,u,"throw",e)}c(void 0)})}).call(this)}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(r.prototype,t),r}(j(e.Plugin)),_=x}(),f}()});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import type { FieldConfigurePropertyComponentProps } from '@nocobase/client-v2';
|
|
10
|
+
import React from 'react';
|
|
11
|
+
export declare function SortFieldConfigureForm(props: FieldConfigurePropertyComponentProps): React.JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
export { SortFieldModel } from './models/SortFieldModel';
|
|
10
|
+
export { SortFieldConfigureForm } from './SortFieldConfigureForm';
|
|
11
|
+
export { SortFieldInterface } from './sort-interface';
|
|
12
|
+
export { default } from './plugin';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("antd"),require("@nocobase/client-v2"),require("@nocobase/flow-engine")):"function"==typeof define&&define.amd?define("@nocobase/plugin-field-sort/client-v2",["react","antd","@nocobase/client-v2","@nocobase/flow-engine"],t):"object"==typeof exports?exports["@nocobase/plugin-field-sort/client-v2"]=t(require("react"),require("antd"),require("@nocobase/client-v2"),require("@nocobase/flow-engine")):e["@nocobase/plugin-field-sort/client-v2"]=t(e.react,e.antd,e["@nocobase/client-v2"],e["@nocobase/flow-engine"])}(self,function(e,t,r,n){return function(){"use strict";var o={798:function(e,t,r){r.r(t),r.d(t,{SortFieldModel:function(){return b}});var n=r(155),o=r.n(n),i=r(59),c=r(694),u=r(485),l=r(488);function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function f(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function p(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(p=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 r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return e=r,t=arguments,e=a(e),function(e,t){var r;if(t&&("object"==((r=t)&&"u">typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,p()?Reflect.construct(e,t||[],a(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&s(r,e),t=[{key:"render",value:function(){var e,t,r;return o().createElement(i.InputNumber,(t=f({},this.props),r=r={style:f({width:"100%"},null==(e=this.props)?void 0:e.style)},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}),t))}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(r.prototype,t),r}(u.FieldModel);b.define({label:(0,l.MZ)("Sort")}),c.EditableItemModel.bindModelToInterface("SortFieldModel",["sort"],{isDefault:!0}),c.DisplayItemModel.bindModelToInterface("DisplayNumberFieldModel",["sort"],{isDefault:!0}),c.FilterableItemModel.bindModelToInterface("NumberFieldModel",["sort"],{isDefault:!0})},488:function(e,t,r){r.d(t,{MZ:function(){return l},kj:function(){return u}});var n=r(694);function o(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function i(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 r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}var c="@nocobase/plugin-field-sort";function u(){var e=(0,n.useFlowEngine)();return function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.context.t(t,i(o({},r),{ns:[c,"client"]}))}}function l(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,n.tExpr)(e,i(o({},t),{ns:c}))}},485:function(e){e.exports=r},694:function(e){e.exports=n},59:function(e){e.exports=t},155:function(t){t.exports=e}},i={};function c(e){var t=i[e];if(void 0!==t)return t.exports;var r=i[e]={exports:{}};return o[e](r,r.exports,c),r.exports}c.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return c.d(t,{a:t}),t},c.d=function(e,t){for(var r in t)c.o(t,r)&&!c.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},c.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),c.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},c.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},c.g.importScripts&&(u=c.g.location+"");var u,l=c.g.document;if(!u&&l&&(l.currentScript&&"SCRIPT"===l.currentScript.tagName.toUpperCase()&&(u=l.currentScript.src),!u)){var a=l.getElementsByTagName("script");if(a.length)for(var f=a.length-1;f>-1&&(!u||!/^http(s?):/.test(u));)u=a[f--].src}if(!u)throw Error("Automatic publicPath is not supported in this browser");c.p=u.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var s={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src&&(e=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-field-sort/dist/client-v2/")}if(!e){var n=window.__nocobase_modern_client_prefix__||"v",o="/"+(n=String(n).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var i=window.location.pathname||"/",u=i.indexOf(o);e=u>=0?i.slice(0,u+1):"/"}e&&(e=e.replace(RegExp("/"+n+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-field-sort/dist/client-v2/"}c.p=e}(),!function(){c.r(s),c.d(s,{SortFieldModel:function(){return e.SortFieldModel},default:function(){return w},SortFieldInterface:function(){return y},SortFieldConfigureForm:function(){return u}});var e=c(798),t=c(59),r=c(155),n=c.n(r),o=c(488),i=/^\s*\{\{\s*t\s*\(\s*(['"])(.*?)\1(?:\s*,[\s\S]*?)?\)\s*\}\}\s*$/;function u(e){var c,u,l=(0,o.kj)(),a=(0,r.useMemo)(function(){var t,r;return((null==(t=e.field)?void 0:t.fields)||(null==(r=e.collection)?void 0:r.fields)||[]).filter(function(e){return["string","bigInt","integer"].includes(e.type)}).map(function(e){var t;return{value:e.name,label:function(e,t){if("string"!=typeof e)return e;var r=e.match(i);return(null==r?void 0:r[2])?t(r[2]):e}((null==(t=e.uiSchema)?void 0:t.title)||e.name,l)}})},[null==(c=e.collection)?void 0:c.fields,null==(u=e.field)?void 0:u.fields,l]);return n().createElement(t.Form.Item,{name:"scopeKey",label:l("Grouped sorting"),tooltip:l("When a field is selected for grouping, it will be grouped first before sorting.")},n().createElement(t.Select,{allowClear:!0,disabled:e.disabled,options:a}))}var l=c(485);function a(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}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 b(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(b=function(){return!!e})()}var y=function(e){if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function t(){var e,r,n;if(!(this instanceof t))throw TypeError("Cannot call a class as a function");return r=t,n=arguments,r=f(r),a(e=function(e,t){var r;if(t&&("object"==((r=t)&&"u">typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"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(r,n||[],f(this).constructor):r.apply(this,n)),"name","sort"),a(e,"type","object"),a(e,"group","advanced"),a(e,"order",1),a(e,"title",(0,o.MZ)("Sort")),a(e,"sortable",!0),a(e,"titleUsable",!0),a(e,"description",(0,o.MZ)("Used for drag and drop sorting scenarios, supporting grouping sorting")),a(e,"default",{type:"sort",uiSchema:{type:"number","x-component":"InputNumber","x-component-props":{stringMode:!0,step:"1"},"x-validator":"integer"}}),a(e,"availableTypes",["sort"]),a(e,"hasDefaultValue",!1),a(e,"configure",{items:[{name:"scopeKey",Component:u}]}),a(e,"filterable",{operators:"number"}),e}return t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&p(t,e),t}(l.CollectionFieldInterface);function d(e,t,r,n,o,i,c){try{var u=e[i](c),l=u.value}catch(e){r(e);return}u.done?t(l):Promise.resolve(l).then(n,o)}function v(e,t,r){return(v=m()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&g(o,r.prototype),o}).apply(null,arguments)}function h(e){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function g(e,t){return(g=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function O(e){var t="function"==typeof Map?new Map:void 0;return(O=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,r)}function r(){return v(e,arguments,h(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),g(r,e)})(e)}function m(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(m=function(){return!!e})()}var w=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return e=r,t=arguments,e=h(e),function(e,t){var r;if(t&&("object"==((r=t)&&"u">typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,m()?Reflect.construct(e,t||[],h(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&g(r,e),t=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},c=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(c,"next",{value:l(0)}),u(c,"throw",{value:l(1)}),u(c,"return",{value:l(2)}),"function"==typeof Symbol&&u(c,Symbol.iterator,{value:function(){return this}}),c;function l(u){return function(l){var a=[u,l];if(r)throw TypeError("Generator is already executing.");for(;c&&(c=0,a[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}}(this,function(e){return this.app.addFieldInterfaces([y]),this.flowEngine.registerModelLoaders({SortFieldModel:{loader:function(){return Promise.resolve().then(c.bind(c,798))}}}),[2]})},function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function c(e){d(i,n,o,c,u,"next",e)}function u(e){d(i,n,o,c,u,"throw",e)}c(void 0)})}).call(this)}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(r.prototype,t),r}(O(l.Plugin))}(),s}()});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
export declare const NAMESPACE = "@nocobase/plugin-field-sort";
|
|
10
|
+
export declare function useT(): (str: string, options?: {}) => string;
|
|
11
|
+
export declare function tExpr(key: string, options?: {}): string;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
import React from 'react';
|
|
10
|
-
import { FieldModel } from '@nocobase/client';
|
|
10
|
+
import { FieldModel } from '@nocobase/client-v2';
|
|
11
11
|
export declare class SortFieldModel extends FieldModel {
|
|
12
12
|
render(): React.JSX.Element;
|
|
13
13
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import { Application, Plugin } from '@nocobase/client-v2';
|
|
10
|
+
export declare class PluginFieldSortClient extends Plugin<any, Application> {
|
|
11
|
+
load(): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export default PluginFieldSortClient;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import { CollectionFieldInterface } from '@nocobase/client-v2';
|
|
10
|
+
import { SortFieldConfigureForm } from './SortFieldConfigureForm';
|
|
11
|
+
export declare class SortFieldInterface extends CollectionFieldInterface {
|
|
12
|
+
name: string;
|
|
13
|
+
type: string;
|
|
14
|
+
group: string;
|
|
15
|
+
order: number;
|
|
16
|
+
title: string;
|
|
17
|
+
sortable: boolean;
|
|
18
|
+
titleUsable: boolean;
|
|
19
|
+
description: string;
|
|
20
|
+
default: {
|
|
21
|
+
type: string;
|
|
22
|
+
uiSchema: {
|
|
23
|
+
type: string;
|
|
24
|
+
'x-component': string;
|
|
25
|
+
'x-component-props': {
|
|
26
|
+
stringMode: boolean;
|
|
27
|
+
step: string;
|
|
28
|
+
};
|
|
29
|
+
'x-validator': string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
availableTypes: string[];
|
|
33
|
+
hasDefaultValue: boolean;
|
|
34
|
+
configure: {
|
|
35
|
+
items: {
|
|
36
|
+
name: string;
|
|
37
|
+
Component: typeof SortFieldConfigureForm;
|
|
38
|
+
}[];
|
|
39
|
+
};
|
|
40
|
+
filterable: {
|
|
41
|
+
operators: string;
|
|
42
|
+
};
|
|
43
|
+
}
|
package/dist/externalVersion.js
CHANGED
|
@@ -8,15 +8,16 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
+
"@nocobase/client": "2.2.0-alpha.1",
|
|
12
|
+
"@nocobase/client-v2": "2.2.0-alpha.1",
|
|
11
13
|
"antd": "5.24.2",
|
|
12
14
|
"react": "18.2.0",
|
|
13
|
-
"@nocobase/flow-engine": "2.
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"@nocobase/
|
|
17
|
-
"@nocobase/
|
|
18
|
-
"@nocobase/
|
|
19
|
-
"@nocobase/data-source-manager": "2.1.0-beta.9",
|
|
15
|
+
"@nocobase/flow-engine": "2.2.0-alpha.1",
|
|
16
|
+
"lodash": "4.18.1",
|
|
17
|
+
"@nocobase/database": "2.2.0-alpha.1",
|
|
18
|
+
"@nocobase/actions": "2.2.0-alpha.1",
|
|
19
|
+
"@nocobase/server": "2.2.0-alpha.1",
|
|
20
|
+
"@nocobase/data-source-manager": "2.2.0-alpha.1",
|
|
20
21
|
"sequelize": "6.35.2",
|
|
21
|
-
"@nocobase/lock-manager": "2.
|
|
22
|
+
"@nocobase/lock-manager": "2.2.0-alpha.1"
|
|
22
23
|
};
|
package/dist/locale/en-US.json
CHANGED
|
@@ -1 +1,6 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"Grouped sorting": "Grouped sorting",
|
|
3
|
+
"Sort": "Sort",
|
|
4
|
+
"Used for drag and drop sorting scenarios, supporting grouping sorting": "Used for drag and drop sorting scenarios, supporting grouping sorting",
|
|
5
|
+
"When a field is selected for grouping, it will be grouped first before sorting.": "When a field is selected for grouping, it will be grouped first before sorting."
|
|
6
|
+
}
|
package/dist/locale/zh-CN.json
CHANGED
|
@@ -41,30 +41,37 @@ class SortField extends import_database.Field {
|
|
|
41
41
|
const { name, scopeKey } = this.options;
|
|
42
42
|
const { model } = this.context.collection;
|
|
43
43
|
instances = Array.isArray(instances) ? instances : [instances];
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
where
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
44
|
+
await this.constructor.lockManager.runExclusive(
|
|
45
|
+
this.context.collection.name,
|
|
46
|
+
async () => {
|
|
47
|
+
const maxCache = /* @__PURE__ */ new Map();
|
|
48
|
+
for (const instance of instances) {
|
|
49
|
+
if (from == "create" && (0, import_lodash.isNumber)(instance.get(name))) {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if ((0, import_lodash.isNumber)(instance.get(name)) && instance._previousDataValues[scopeKey] == instance[scopeKey]) {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
const where = {};
|
|
56
|
+
let cacheKey = "__default__";
|
|
57
|
+
if (scopeKey) {
|
|
58
|
+
const value = instance.get(scopeKey);
|
|
59
|
+
if (value !== void 0 && value !== null) {
|
|
60
|
+
where[scopeKey] = value;
|
|
61
|
+
cacheKey = `${typeof value}:${String(value)}`;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (!maxCache.has(cacheKey)) {
|
|
65
|
+
const max = await model.max(name, { ...options, where });
|
|
66
|
+
maxCache.set(cacheKey, max || 0);
|
|
67
|
+
}
|
|
68
|
+
const newValue = (maxCache.get(cacheKey) ?? 0) + 1;
|
|
69
|
+
maxCache.set(cacheKey, newValue);
|
|
63
70
|
instance.set(name, newValue);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
2e3
|
|
74
|
+
);
|
|
68
75
|
};
|
|
69
76
|
onScopeChange = async (instance, options) => {
|
|
70
77
|
const { scopeKey } = this.options;
|
|
@@ -117,15 +124,23 @@ class SortField extends import_database.Field {
|
|
|
117
124
|
const quotedOrderField = queryInterface.quoteIdentifier(orderField);
|
|
118
125
|
const sortColumnName = queryInterface.quoteIdentifier(this.collection.model.rawAttributes[this.name].field);
|
|
119
126
|
let sql;
|
|
127
|
+
let bind;
|
|
120
128
|
const whereClause = scopeKey2 && scopeValue ? (() => {
|
|
121
129
|
const filteredScopeValue = scopeValue.filter((v) => v !== null);
|
|
122
|
-
|
|
130
|
+
const clauses = [];
|
|
131
|
+
if (filteredScopeValue.length > 0) {
|
|
132
|
+
bind = filteredScopeValue;
|
|
133
|
+
const placeholders = filteredScopeValue.map((_, index) => `$${index + 1}`).join(", ");
|
|
134
|
+
clauses.push(`${queryInterface.quoteIdentifier(scopeKey2)} IN (${placeholders})`);
|
|
135
|
+
}
|
|
136
|
+
if (scopeValue.includes(null)) {
|
|
137
|
+
clauses.push(`${queryInterface.quoteIdentifier(scopeKey2)} IS NULL`);
|
|
138
|
+
}
|
|
139
|
+
if (clauses.length === 0) {
|
|
123
140
|
return "";
|
|
124
141
|
}
|
|
125
|
-
|
|
126
|
-
WHERE ${
|
|
127
|
-
const nullCheck = scopeValue.includes(null) ? ` OR ${queryInterface.quoteIdentifier(scopeKey2)} IS NULL` : "";
|
|
128
|
-
return initialClause + nullCheck;
|
|
142
|
+
return `
|
|
143
|
+
WHERE ${clauses.join(" OR ")}`;
|
|
129
144
|
})() : "";
|
|
130
145
|
if (this.collection.db.inDialect("postgres")) {
|
|
131
146
|
sql = `
|
|
@@ -163,12 +178,17 @@ class SortField extends import_database.Field {
|
|
|
163
178
|
`;
|
|
164
179
|
}
|
|
165
180
|
await this.collection.db.sequelize.query(sql, {
|
|
181
|
+
bind,
|
|
166
182
|
transaction
|
|
167
183
|
});
|
|
168
184
|
};
|
|
169
185
|
const scopeKey = this.options.scopeKey;
|
|
170
186
|
if (scopeKey) {
|
|
171
|
-
const
|
|
187
|
+
const scopeKeyAttribute = this.collection.model.rawAttributes[scopeKey];
|
|
188
|
+
if (!scopeKeyAttribute || !scopeKeyAttribute.field) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
const scopeKeyColumn = scopeKeyAttribute.field;
|
|
172
192
|
const groups = await this.collection.model.findAll({
|
|
173
193
|
attributes: [[import_sequelize.Sequelize.fn("DISTINCT", import_sequelize.Sequelize.col(scopeKeyColumn)), scopeKey]],
|
|
174
194
|
raw: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-field-sort",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0-alpha.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"displayName": "Collection field: Sort",
|
|
6
6
|
"displayName.ru-RU": "Поле коллекции: Сортировка",
|
|
@@ -12,15 +12,17 @@
|
|
|
12
12
|
"peerDependencies": {
|
|
13
13
|
"@nocobase/actions": "2.x",
|
|
14
14
|
"@nocobase/client": "2.x",
|
|
15
|
+
"@nocobase/client-v2": "2.x",
|
|
15
16
|
"@nocobase/database": "2.x",
|
|
16
17
|
"@nocobase/lock-manager": "2.x",
|
|
18
|
+
"@nocobase/plugin-data-source-manager": "2.x",
|
|
17
19
|
"@nocobase/server": "2.x",
|
|
18
20
|
"@nocobase/test": "2.x",
|
|
19
|
-
"lodash": "4.
|
|
21
|
+
"lodash": "4.x",
|
|
20
22
|
"sequelize": "^6.26.0"
|
|
21
23
|
},
|
|
22
24
|
"keywords": [
|
|
23
25
|
"Collection fields"
|
|
24
26
|
],
|
|
25
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "303663aba6c6eefa27e6a6435b4c0352074ec40f"
|
|
26
28
|
}
|