@nocobase/plugin-theme-editor 2.0.0-alpha.50 → 2.0.0-alpha.51
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/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("@nocobase/client"),require("react"),require("@ant-design/cssinjs"),require("@emotion/css"),require("lodash"),require("antd"),require("@nocobase/utils/client"),require("@ant-design/icons"),require("react-i18next")):"function"==typeof define&&define.amd?define("@nocobase/plugin-theme-editor",["@nocobase/client","react","@ant-design/cssinjs","@emotion/css","lodash","antd","@nocobase/utils/client","@ant-design/icons","react-i18next"],t):"object"==typeof exports?exports["@nocobase/plugin-theme-editor"]=t(require("@nocobase/client"),require("react"),require("@ant-design/cssinjs"),require("@emotion/css"),require("lodash"),require("antd"),require("@nocobase/utils/client"),require("@ant-design/icons"),require("react-i18next")):e["@nocobase/plugin-theme-editor"]=t(e["@nocobase/client"],e.react,e["@ant-design/cssinjs"],e["@emotion/css"],e.lodash,e.antd,e["@nocobase/utils/client"],e["@ant-design/icons"],e["react-i18next"])}(self,function(e,t,n,r,o,i,u,a,c){return function(){var l,s,f,d,p,m,h={8290:function(e,t,n){"use strict";n.r(t),n.d(t,{useThemeId:function(){return f}});var r=n(3772),o=n(7584),i=n(8156),u=n.n(i),a=n(9649),c=n(9181),l=n(9204),s=u().createContext({}),f=function(){return u().useContext(s)},d=function(e){var t,n,f,d=e.children,p=(0,r.useCurrentUserContext)(),m=(0,r.useGlobalTheme)().setTheme,h=(0,l.useThemeListContext)(),b=h.run,y=h.data,v=h.loading,g=(0,i.useMemo)(function(){return null==y?void 0:y.find(function(e){return e.default})},[y]),w=(0,i.useRef)(null),O=(0,r.useAPIClient)();(0,i.useEffect)(function(){var e=O.auth.getOption("theme");if(e)try{m((0,c.w)(JSON.parse(e)).config)}catch(e){(0,o.error)(e)}},[]),(0,i.useEffect)(function(){if(!y)return b();var e,t,n,o,i=null==p||null==(n=p.data)||null==(t=n.data)||null==(e=t.systemSettings)?void 0:e.themeId;null!=i&&(o=y.find(function(e){return e.id===i})),o||(o=g),o?(w.current=o.id,m(o.config),O.auth.setOption("theme",JSON.stringify(Object.assign(function(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}({},o),{config:(0,a.i)(o.config)})))):(m(r.defaultTheme),O.auth.setOption("theme",null))},[O.auth,null==p||null==(f=p.data)||null==(n=f.data)||null==(t=n.systemSettings)?void 0:t.themeId,y,b,m,g]);var j=v&&!y||p.loading?{}:{currentThemeId:w.current,defaultThemeId:null==g?void 0:g.id};return u().createElement(s.Provider,{value:j},d)};d.displayName="InitializeTheme",t.default=d},9204:function(e,t,n){"use strict";n.r(t),n.d(t,{ThemeListProvider:function(){return s},useThemeListContext:function(){return l}});var r=n(3772),o=n(7584),i=n(8156),u=n.n(i),a=n(9181),c=(0,i.createContext)(null);c.displayName="ThemeListContext";var l=function(){return u().useContext(c)},s=function(e){var t=e.children,n=(0,r.useRequest)({url:"themeConfig:list",params:{sort:"id",paginate:!1}},{manual:!0}),l=n.data,s=n.error,f=n.run,d=n.refresh,p=n.loading,m=(0,i.useMemo)(function(){var e;return null==l||null==(e=l.data)?void 0:e.map(function(e){return(0,a.w)(e)})},[l]);return s&&(0,o.error)(s),u().createElement(c.Provider,{value:{data:m,error:s,run:f,refresh:d,loading:p}},t)};s.displayName="ThemeListProvider"},4936:function(e,t,n){"use strict";n.d(t,{Y:function(){return l}});var r=n(3772),o=n(7584),i=n(8156);function u(e,t,n,r,o,i,u){try{var a=e[i](u),c=a.value}catch(e){n(e);return}a.done?t(c):Promise.resolve(c).then(r,o)}function a(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 c(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function l(){var e,t,n=(0,r.useAPIClient)(),l=(0,r.useCurrentUserContext)();return{updateUserThemeSettings:(0,i.useCallback)((e=function(e){var t;return function(e,t){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){var c=[i,a];if(n)throw TypeError("Generator is already executing.");for(;u;)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 u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=(o=u.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=t.call(e,u)}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(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,n.resource("users").updateTheme({values:{themeId:e}})];case 1:return r.sent(),l.mutate({data:c(a({},l.data.data),{systemSettings:c(a({},l.data.data.systemSettings||{}),{themeId:e})})}),[3,3];case 2:return t=r.sent(),console.log(o.error),(0,o.error)(t),[3,3];case 3:return[2]}})},t=function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){u(i,r,o,a,c,"next",e)}function c(e){u(i,r,o,a,c,"throw",e)}a(void 0)})},function(e){return t.apply(this,arguments)}),[n,l])}}},9649:function(e,t,n){"use strict";n.d(t,{i:function(){return u}});var r=n(2721),o=n(467),i=n.n(o);function u(e){return(e=i().cloneDeep(e)).algorithm&&(Array.isArray(e.algorithm)?e.algorithm=e.algorithm.map(function(e){return a(e)}).filter(Boolean):e.algorithm=a(e.algorithm),i().isEmpty(e.algorithm)&&delete e.algorithm),e}function a(e){return"string"==typeof e?e:e.toString()===r.theme.darkAlgorithm.toString()?"darkAlgorithm":e.toString()===r.theme.compactAlgorithm.toString()?"compactAlgorithm":void 0}},9181:function(e,t,n){"use strict";n.d(t,{w:function(){return u}});var r=n(2721),o=n(467),i=n.n(o);function u(e){var t;return e=i().cloneDeep(e),i().isString(e.config.algorithm)&&(e.config.algorithm=r.theme[e.config.algorithm]),Array.isArray(null==(t=e.config)?void 0:t.algorithm)&&(e.config.algorithm=e.config.algorithm.map(function(e){return i().isString(e)?r.theme[e]:e})),e}},8551:function(e,t,n){"use strict";n.d(t,{$:function(){return i},A:function(){return o}});var r=n(3238),o="theme-editor";function i(){return(0,r.useTranslation)([o,"client"],{nsMode:"fallback"})}},3581:function(e){e.exports=function(e,t){return"undefined"!=typeof __deoptimization_sideEffect__&&__deoptimization_sideEffect__(e,t),t}},1143:function(e){"use strict";e.exports=n},482:function(e){"use strict";e.exports=a},4964:function(e){"use strict";e.exports=r},3772:function(t){"use strict";t.exports=e},7584:function(e){"use strict";e.exports=u},2721:function(e){"use strict";e.exports=i},467:function(e){"use strict";e.exports=o},8156:function(e){"use strict";e.exports=t},3238:function(e){"use strict";e.exports=c}},b={};function y(e){var t=b[e];if(void 0!==t)return t.exports;var n=b[e]={exports:{}};return h[e](n,n.exports,y),n.exports}y.m=h,y.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return y.d(t,{a:t}),t},y.d=function(e,t){for(var n in t)y.o(t,n)&&!y.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},y.f={},y.e=function(e){return Promise.all(Object.keys(y.f).reduce(function(t,n){return y.f[n](e,t),t},[]))},y.u=function(e){return""+({327:"4acfe66b1504e9e2",39:"1a8ca1e21b09091e",572:"e285e1915ec4e08b",595:"717f252ea7b0f951",793:"56efc5f384c11f3a"})[e]+".js"},y.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),y.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},l={},s="@nocobase/plugin-theme-editor:",y.l=function(e,t,n,r){if(l[e])return void l[e].push(t);if(void 0!==n)for(var o,i,u=document.getElementsByTagName("script"),a=0;a<u.length;a++){var c=u[a];if(c.getAttribute("src")==e||c.getAttribute("data-webpack")==s+n){o=c;break}}o||(i=!0,(o=document.createElement("script")).charset="utf-8",o.timeout=120,y.nc&&o.setAttribute("nonce",y.nc),o.setAttribute("data-webpack",s+n),o.src=e),l[e]=[t];var f=function(t,n){o.onerror=o.onload=null,clearTimeout(d);var r=l[e];if(delete l[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},d=setTimeout(f.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=f.bind(null,o.onerror),o.onload=f.bind(null,o.onload),i&&document.head.appendChild(o)},y.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},y.nc=void 0,(f=window.__nocobase_public_path__||"/").endsWith("/")||(f+="/"),y.p=f+"static/plugins/@nocobase/plugin-theme-editor/dist/client/",d={909:0},y.f.j=function(e,t){var n=y.o(d,e)?d[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=d[e]=[t,r]});t.push(n[2]=r);var o=y.p+y.u(e),i=Error();y.l(o,function(t){if(y.o(d,e)&&(0!==(n=d[e])&&(d[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;i.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",i.name="ChunkLoadError",i.type=r,i.request=o,n[1](i)}},"chunk-"+e,e)}},p=function(e,t){var n,r,o=t[0],i=t[1],u=t[2],a=0;if(o.some(function(e){return 0!==d[e]})){for(n in i)y.o(i,n)&&(y.m[n]=i[n]);u&&u(y)}for(e&&e(t);a<o.length;a++)r=o[a],y.o(d,r)&&d[r]&&d[r][0](),d[r]=0},(m=self.webpackChunk_nocobase_plugin_theme_editor=self.webpackChunk_nocobase_plugin_theme_editor||[]).forEach(p.bind(null,0)),m.push=p.bind(null,m.push.bind(m));var v={};return!function(){"use strict";y.r(v),y.d(v,{PluginThemeEditorClient:function(){return C},default:function(){return A}});var e=y(3772),t=y(2721),n=y(467),r=y.n(n),o=y(8156),i=y.n(o),u=y(7584),a=y(8290),c=y(9204),l=y(8551),s=y(4936),f=function(){var t=(0,l.$)().t,n=(0,c.useThemeListContext)(),r=n.run,f=n.error,d=n.data,p=(0,s.Y)().updateUserThemeSettings,m=(0,a.useThemeId)().currentThemeId,h=(0,o.useMemo)(function(){return null==d?void 0:d.filter(function(e){return e.optional}).map(function(e){return{label:t(e.config.name),value:e.id}})},[d,t]);return((0,o.useEffect)(function(){d||r()},[]),f)?((0,u.error)(f),null):i().createElement(e.SchemaSettingsSelectItem,{title:t("Theme"),options:h,value:m,onChange:function(e){p(e)}})},d=y(3581);function p(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 m(e,t,n,r,o,i,u){try{var a=e[i](u),c=a.value}catch(e){n(e);return}a.done?t(c):Promise.resolve(c).then(r,o)}function h(e,t,n){return(h=O()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&g(o,n.prototype),o}).apply(null,arguments)}function b(e){return(b=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 w(e){var t="function"==typeof Map?new Map:void 0;return(w=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 h(e,arguments,b(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),g(n,e)})(e)}function O(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(O=function(){return!!e})()}function j(){var e,t,n=(e=["\n overflow: hidden;\n border-left: 1px solid ",";\n animation: 0.1s ease-out 0s 1 slideInFromRight;\n @keyframes slideInFromRight {\n 0% {\n transform: translateX(100%);\n }\n 100% {\n transform: translateX(0);\n }\n }\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return j=function(){return n},n}var P=(0,e.lazy)(function(){return d("imported_-1bkn1ue_component",Promise.resolve().then(y.bind(y,8290)))}),x=(0,e.lazy)(function(){return d("imported_-16ae68t_component",y.e("793").then(y.bind(y,3546)))},"ThemeEditorProvider").ThemeEditorProvider,S=(0,e.lazy)(function(){return d("imported_-19lv318_component",Promise.all([y.e("572"),y.e("595"),y.e("39")]).then(y.bind(y,8524)))}),_=(0,e.lazy)(function(){return d("imported_-ofsaik_component",Promise.resolve().then(y.bind(y,9204)))},"ThemeListProvider").ThemeListProvider,T=(0,e.lazy)(function(){return d("imported_-1mfft73_component",Promise.all([y.e("572"),y.e("595"),y.e("327")]).then(y.bind(y,9598)))}),E=(0,e.createStyles)(function(e){var t=e.css,n=e.token;return{editor:t(j(),n.colorBorderSecondary)}}),k=i().memo(function(n){var u,a,c=(u=i().useState(!1),function(e){if(Array.isArray(e))return e}(u)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],u=!0,a=!1;try{for(o=o.call(e);!(u=(n=o.next()).done)&&(i.push(n.value),i.length!==t);u=!0);}catch(e){a=!0,r=e}finally{try{u||null==o.return||o.return()}finally{if(a)throw r}}return i}}(u,2)||function(e,t){if(e){if("string"==typeof e)return p(e,2);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 p(e,t)}}(u,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),l=c[0],s=c[1],f=(0,e.useGlobalTheme)(),d=f.theme,m=f.setTheme,h=E().styles,b=(0,o.useMemo)(function(){return l?{transform:"rotate(0)",flexGrow:1,width:0,height:"100%"}:{flexGrow:1,width:0,height:"100%"}},[l]),y=i().createElement("div",{style:{display:"flex",overflow:"hidden",height:"100%"}},i().createElement("div",{style:b},n.children),l?i().createElement("div",{className:h.editor},i().createElement(T,{onThemeChange:m})):null);return(null==d||null==(a=d.token)?void 0:a.motionUnit)||r().set(d,"token.motionUnit",e.defaultTheme.token.motionUnit),i().createElement(t.ConfigProvider,{theme:d},i().createElement(_,null,i().createElement(P,null,i().createElement(x,{open:l,setOpen:s},y))))});k.displayName="CustomThemeProvider";var C=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){var n;if(t&&("object"==((n=t)&&"undefined"!=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(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&&g(n,e),t=[{key:"load",value:function(){var e,t=this;return(e=function(){return function(e,t){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){var c=[i,a];if(n)throw TypeError("Generator is already executing.");for(;u;)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 u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=(o=u.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=t.call(e,u)}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 t.app.use(k),t.app.pluginSettingsManager.add(l.A,{title:'{{t("Theme editor", {ns:"'.concat(l.A,'"})}}'),icon:"BgColorsOutlined",Component:S,aclSnippet:"pm.theme-editor.themes"}),t.app.addUserCenterSettingsItem({name:"theme",sort:310,Component:f}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function u(e){m(i,r,o,u,a,"next",e)}function a(e){m(i,r,o,u,a,"throw",e)}u(void 0)})})()}}],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}(w(e.Plugin)),A=C}(),v}()});
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@nocobase/client"),require("react"),require("@ant-design/cssinjs"),require("@emotion/css"),require("lodash"),require("antd"),require("@nocobase/utils/client"),require("@ant-design/icons"),require("react-i18next")):"function"==typeof define&&define.amd?define("@nocobase/plugin-theme-editor",["@nocobase/client","react","@ant-design/cssinjs","@emotion/css","lodash","antd","@nocobase/utils/client","@ant-design/icons","react-i18next"],t):"object"==typeof exports?exports["@nocobase/plugin-theme-editor"]=t(require("@nocobase/client"),require("react"),require("@ant-design/cssinjs"),require("@emotion/css"),require("lodash"),require("antd"),require("@nocobase/utils/client"),require("@ant-design/icons"),require("react-i18next")):e["@nocobase/plugin-theme-editor"]=t(e["@nocobase/client"],e.react,e["@ant-design/cssinjs"],e["@emotion/css"],e.lodash,e.antd,e["@nocobase/utils/client"],e["@ant-design/icons"],e["react-i18next"])}(self,function(e,t,n,r,o,i,u,a,c){return function(){var l,s,f,d,p,m,h={8290:function(e,t,n){"use strict";n.r(t),n.d(t,{useThemeId:function(){return f}});var r=n(3772),o=n(7584),i=n(8156),u=n.n(i),a=n(9649),c=n(9181),l=n(9204),s=u().createContext({}),f=function(){return u().useContext(s)},d=function(e){var t,n,f,d=e.children,p=(0,r.useCurrentUserContext)(),m=(0,r.useGlobalTheme)().setTheme,h=(0,l.useThemeListContext)(),b=h.run,y=h.data,v=h.loading,g=(0,i.useMemo)(function(){return null==y?void 0:y.find(function(e){return e.default})},[y]),w=(0,i.useRef)(null),O=(0,r.useAPIClient)();(0,i.useEffect)(function(){var e=O.auth.getOption("theme");if(e)try{m((0,c.w)(JSON.parse(e)).config)}catch(e){(0,o.error)(e)}},[]),(0,i.useEffect)(function(){if(!y)return b();var e,t,n,o,i=null==p||null==(n=p.data)||null==(t=n.data)||null==(e=t.systemSettings)?void 0:e.themeId;null!=i&&(o=y.find(function(e){return e.id===i})),o||(o=g),o?(w.current=o.id,m(o.config),O.auth.setOption("theme",JSON.stringify(Object.assign(function(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}({},o),{config:(0,a.i)(o.config)})))):(m(r.defaultTheme),O.auth.setOption("theme",null))},[O.auth,null==p||null==(f=p.data)||null==(n=f.data)||null==(t=n.systemSettings)?void 0:t.themeId,y,b,m,g]);var j=v&&!y||p.loading?{}:{currentThemeId:w.current,defaultThemeId:null==g?void 0:g.id};return u().createElement(s.Provider,{value:j},d)};d.displayName="InitializeTheme",t.default=d},9204:function(e,t,n){"use strict";n.r(t),n.d(t,{ThemeListProvider:function(){return s},useThemeListContext:function(){return l}});var r=n(3772),o=n(7584),i=n(8156),u=n.n(i),a=n(9181),c=(0,i.createContext)(null);c.displayName="ThemeListContext";var l=function(){return u().useContext(c)},s=function(e){var t=e.children,n=(0,r.useRequest)({url:"themeConfig:list",params:{sort:"id",paginate:!1}},{manual:!0}),l=n.data,s=n.error,f=n.run,d=n.refresh,p=n.loading,m=(0,i.useMemo)(function(){var e;return null==l||null==(e=l.data)?void 0:e.map(function(e){return(0,a.w)(e)})},[l]);return s&&(0,o.error)(s),u().createElement(c.Provider,{value:{data:m,error:s,run:f,refresh:d,loading:p}},t)};s.displayName="ThemeListProvider"},4936:function(e,t,n){"use strict";n.d(t,{Y:function(){return l}});var r=n(3772),o=n(7584),i=n(8156);function u(e,t,n,r,o,i,u){try{var a=e[i](u),c=a.value}catch(e){n(e);return}a.done?t(c):Promise.resolve(c).then(r,o)}function a(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 c(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function l(){var e,t,n=(0,r.useAPIClient)(),l=(0,r.useCurrentUserContext)();return{updateUserThemeSettings:(0,i.useCallback)((e=function(e){var t;return function(e,t){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){var c=[i,a];if(n)throw TypeError("Generator is already executing.");for(;u;)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 u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=(o=u.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=t.call(e,u)}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(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,n.resource("users").updateTheme({values:{themeId:e}})];case 1:return r.sent(),l.mutate({data:c(a({},l.data.data),{systemSettings:c(a({},l.data.data.systemSettings||{}),{themeId:e})})}),[3,3];case 2:return t=r.sent(),console.log(o.error),(0,o.error)(t),[3,3];case 3:return[2]}})},t=function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){u(i,r,o,a,c,"next",e)}function c(e){u(i,r,o,a,c,"throw",e)}a(void 0)})},function(e){return t.apply(this,arguments)}),[n,l])}}},9649:function(e,t,n){"use strict";n.d(t,{i:function(){return u}});var r=n(2721),o=n(467),i=n.n(o);function u(e){return(e=i().cloneDeep(e)).algorithm&&(Array.isArray(e.algorithm)?e.algorithm=e.algorithm.map(function(e){return a(e)}).filter(Boolean):e.algorithm=a(e.algorithm),i().isEmpty(e.algorithm)&&delete e.algorithm),e}function a(e){return"string"==typeof e?e:e.toString()===r.theme.darkAlgorithm.toString()?"darkAlgorithm":e.toString()===r.theme.compactAlgorithm.toString()?"compactAlgorithm":void 0}},9181:function(e,t,n){"use strict";n.d(t,{w:function(){return u}});var r=n(2721),o=n(467),i=n.n(o);function u(e){var t;return e=i().cloneDeep(e),i().isString(e.config.algorithm)&&(e.config.algorithm=r.theme[e.config.algorithm]),Array.isArray(null==(t=e.config)?void 0:t.algorithm)&&(e.config.algorithm=e.config.algorithm.map(function(e){return i().isString(e)?r.theme[e]:e})),e}},8551:function(e,t,n){"use strict";n.d(t,{$:function(){return i},A:function(){return o}});var r=n(3238),o="theme-editor";function i(){return(0,r.useTranslation)([o,"client"],{nsMode:"fallback"})}},3581:function(e){e.exports=function(e,t){return"undefined"!=typeof __deoptimization_sideEffect__&&__deoptimization_sideEffect__(e,t),t}},1143:function(e){"use strict";e.exports=n},482:function(e){"use strict";e.exports=a},4964:function(e){"use strict";e.exports=r},3772:function(t){"use strict";t.exports=e},7584:function(e){"use strict";e.exports=u},2721:function(e){"use strict";e.exports=i},467:function(e){"use strict";e.exports=o},8156:function(e){"use strict";e.exports=t},3238:function(e){"use strict";e.exports=c}},b={};function y(e){var t=b[e];if(void 0!==t)return t.exports;var n=b[e]={exports:{}};return h[e](n,n.exports,y),n.exports}y.m=h,y.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return y.d(t,{a:t}),t},y.d=function(e,t){for(var n in t)y.o(t,n)&&!y.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},y.f={},y.e=function(e){return Promise.all(Object.keys(y.f).reduce(function(t,n){return y.f[n](e,t),t},[]))},y.u=function(e){return""+({327:"4acfe66b1504e9e2",39:"1a8ca1e21b09091e",572:"e285e1915ec4e08b",595:"37f75ca7b56275de",793:"56efc5f384c11f3a"})[e]+".js"},y.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),y.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},l={},s="@nocobase/plugin-theme-editor:",y.l=function(e,t,n,r){if(l[e])return void l[e].push(t);if(void 0!==n)for(var o,i,u=document.getElementsByTagName("script"),a=0;a<u.length;a++){var c=u[a];if(c.getAttribute("src")==e||c.getAttribute("data-webpack")==s+n){o=c;break}}o||(i=!0,(o=document.createElement("script")).charset="utf-8",o.timeout=120,y.nc&&o.setAttribute("nonce",y.nc),o.setAttribute("data-webpack",s+n),o.src=e),l[e]=[t];var f=function(t,n){o.onerror=o.onload=null,clearTimeout(d);var r=l[e];if(delete l[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},d=setTimeout(f.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=f.bind(null,o.onerror),o.onload=f.bind(null,o.onload),i&&document.head.appendChild(o)},y.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},y.nc=void 0,(f=window.__nocobase_public_path__||"/").endsWith("/")||(f+="/"),y.p=f+"static/plugins/@nocobase/plugin-theme-editor/dist/client/",d={909:0},y.f.j=function(e,t){var n=y.o(d,e)?d[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=d[e]=[t,r]});t.push(n[2]=r);var o=y.p+y.u(e),i=Error();y.l(o,function(t){if(y.o(d,e)&&(0!==(n=d[e])&&(d[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;i.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",i.name="ChunkLoadError",i.type=r,i.request=o,n[1](i)}},"chunk-"+e,e)}},p=function(e,t){var n,r,o=t[0],i=t[1],u=t[2],a=0;if(o.some(function(e){return 0!==d[e]})){for(n in i)y.o(i,n)&&(y.m[n]=i[n]);u&&u(y)}for(e&&e(t);a<o.length;a++)r=o[a],y.o(d,r)&&d[r]&&d[r][0](),d[r]=0},(m=self.webpackChunk_nocobase_plugin_theme_editor=self.webpackChunk_nocobase_plugin_theme_editor||[]).forEach(p.bind(null,0)),m.push=p.bind(null,m.push.bind(m));var v={};return!function(){"use strict";y.r(v),y.d(v,{PluginThemeEditorClient:function(){return C},default:function(){return A}});var e=y(3772),t=y(2721),n=y(467),r=y.n(n),o=y(8156),i=y.n(o),u=y(7584),a=y(8290),c=y(9204),l=y(8551),s=y(4936),f=function(){var t=(0,l.$)().t,n=(0,c.useThemeListContext)(),r=n.run,f=n.error,d=n.data,p=(0,s.Y)().updateUserThemeSettings,m=(0,a.useThemeId)().currentThemeId,h=(0,o.useMemo)(function(){return null==d?void 0:d.filter(function(e){return e.optional}).map(function(e){return{label:t(e.config.name),value:e.id}})},[d,t]);return((0,o.useEffect)(function(){d||r()},[]),f)?((0,u.error)(f),null):i().createElement(e.SchemaSettingsSelectItem,{title:t("Theme"),options:h,value:m,onChange:function(e){p(e)}})},d=y(3581);function p(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 m(e,t,n,r,o,i,u){try{var a=e[i](u),c=a.value}catch(e){n(e);return}a.done?t(c):Promise.resolve(c).then(r,o)}function h(e,t,n){return(h=O()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&g(o,n.prototype),o}).apply(null,arguments)}function b(e){return(b=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 w(e){var t="function"==typeof Map?new Map:void 0;return(w=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 h(e,arguments,b(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),g(n,e)})(e)}function O(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(O=function(){return!!e})()}function j(){var e,t,n=(e=["\n overflow: hidden;\n border-left: 1px solid ",";\n animation: 0.1s ease-out 0s 1 slideInFromRight;\n @keyframes slideInFromRight {\n 0% {\n transform: translateX(100%);\n }\n 100% {\n transform: translateX(0);\n }\n }\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return j=function(){return n},n}var P=(0,e.lazy)(function(){return d("imported_-1bkn1ue_component",Promise.resolve().then(y.bind(y,8290)))}),x=(0,e.lazy)(function(){return d("imported_-16ae68t_component",y.e("793").then(y.bind(y,3546)))},"ThemeEditorProvider").ThemeEditorProvider,S=(0,e.lazy)(function(){return d("imported_-19lv318_component",Promise.all([y.e("572"),y.e("595"),y.e("39")]).then(y.bind(y,8524)))}),_=(0,e.lazy)(function(){return d("imported_-ofsaik_component",Promise.resolve().then(y.bind(y,9204)))},"ThemeListProvider").ThemeListProvider,T=(0,e.lazy)(function(){return d("imported_-1mfft73_component",Promise.all([y.e("572"),y.e("595"),y.e("327")]).then(y.bind(y,9598)))}),E=(0,e.createStyles)(function(e){var t=e.css,n=e.token;return{editor:t(j(),n.colorBorderSecondary)}}),k=i().memo(function(n){var u,a,c=(u=i().useState(!1),function(e){if(Array.isArray(e))return e}(u)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],u=!0,a=!1;try{for(o=o.call(e);!(u=(n=o.next()).done)&&(i.push(n.value),i.length!==t);u=!0);}catch(e){a=!0,r=e}finally{try{u||null==o.return||o.return()}finally{if(a)throw r}}return i}}(u,2)||function(e,t){if(e){if("string"==typeof e)return p(e,2);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 p(e,t)}}(u,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),l=c[0],s=c[1],f=(0,e.useGlobalTheme)(),d=f.theme,m=f.setTheme,h=E().styles,b=(0,o.useMemo)(function(){return l?{transform:"rotate(0)",flexGrow:1,width:0,height:"100%"}:{flexGrow:1,width:0,height:"100%"}},[l]),y=i().createElement("div",{style:{display:"flex",overflow:"hidden",height:"100%"}},i().createElement("div",{style:b},n.children),l?i().createElement("div",{className:h.editor},i().createElement(T,{onThemeChange:m})):null);return(null==d||null==(a=d.token)?void 0:a.motionUnit)||r().set(d,"token.motionUnit",e.defaultTheme.token.motionUnit),i().createElement(t.ConfigProvider,{theme:d},i().createElement(_,null,i().createElement(P,null,i().createElement(x,{open:l,setOpen:s},y))))});k.displayName="CustomThemeProvider";var C=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){var n;if(t&&("object"==((n=t)&&"undefined"!=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(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&&g(n,e),t=[{key:"load",value:function(){var e,t=this;return(e=function(){return function(e,t){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){var c=[i,a];if(n)throw TypeError("Generator is already executing.");for(;u;)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 u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=(o=u.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=t.call(e,u)}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 t.app.use(k),t.app.pluginSettingsManager.add(l.A,{title:'{{t("Theme editor", {ns:"'.concat(l.A,'"})}}'),icon:"BgColorsOutlined",Component:S,aclSnippet:"pm.theme-editor.themes"}),t.app.addUserCenterSettingsItem({name:"theme",sort:310,Component:f}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function u(e){m(i,r,o,u,a,"next",e)}function a(e){m(i,r,o,u,a,"throw",e)}u(void 0)})})()}}],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}(w(e.Plugin)),A=C}(),v}()});
|
package/dist/externalVersion.js
CHANGED
|
@@ -8,16 +8,16 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
-
"@nocobase/client": "2.0.0-alpha.
|
|
11
|
+
"@nocobase/client": "2.0.0-alpha.51",
|
|
12
12
|
"react": "18.2.0",
|
|
13
13
|
"antd": "5.24.2",
|
|
14
14
|
"lodash": "4.17.21",
|
|
15
|
-
"@nocobase/server": "2.0.0-alpha.
|
|
15
|
+
"@nocobase/server": "2.0.0-alpha.51",
|
|
16
16
|
"@ant-design/cssinjs": "1.21.1",
|
|
17
17
|
"@ant-design/icons": "5.6.1",
|
|
18
|
-
"@nocobase/utils": "2.0.0-alpha.
|
|
18
|
+
"@nocobase/utils": "2.0.0-alpha.51",
|
|
19
19
|
"react-i18next": "11.18.6",
|
|
20
|
-
"@nocobase/actions": "2.0.0-alpha.
|
|
21
|
-
"@nocobase/database": "2.0.0-alpha.
|
|
20
|
+
"@nocobase/actions": "2.0.0-alpha.51",
|
|
21
|
+
"@nocobase/database": "2.0.0-alpha.51",
|
|
22
22
|
"@emotion/css": "11.13.0"
|
|
23
23
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-theme-editor",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.51",
|
|
4
4
|
"main": "dist/server/index.js",
|
|
5
5
|
"homepage": "https://docs.nocobase.com/handbook/theme-editor",
|
|
6
6
|
"homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/theme-editor",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@nocobase/test": "2.x",
|
|
35
35
|
"@nocobase/utils": "2.x"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "a1e34dd97f370d54f3d80a6b83ab7ddb9c72dc18",
|
|
38
38
|
"keywords": [
|
|
39
39
|
"System management"
|
|
40
40
|
]
|