underpost 2.8.847 → 2.8.851
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -35
- package/cli.md +84 -84
- package/conf.js +1 -1
- package/docker-compose.yml +1 -1
- package/manifests/deployment/dd-template-development/deployment.yaml +2 -2
- package/package.json +1 -1
- package/src/api/user/user.service.js +9 -38
- package/src/cli/run.js +7 -0
- package/src/client/Default.index.js +6 -2
- package/src/client/components/core/Account.js +1 -1
- package/src/client/components/core/Content.js +11 -7
- package/src/client/components/core/Css.js +195 -15
- package/src/client/components/core/CssCore.js +1 -1
- package/src/client/components/core/Docs.js +4 -4
- package/src/client/components/core/Input.js +6 -1
- package/src/client/components/core/LoadingAnimation.js +8 -15
- package/src/client/components/core/LogIn.js +3 -0
- package/src/client/components/core/LogOut.js +1 -1
- package/src/client/components/core/Modal.js +21 -10
- package/src/client/components/core/PanelForm.js +2 -3
- package/src/client/components/core/Recover.js +2 -1
- package/src/client/components/core/Router.js +22 -23
- package/src/client/components/core/SignUp.js +1 -0
- package/src/client/components/core/SocketIo.js +3 -3
- package/src/client/components/core/VanillaJs.js +48 -17
- package/src/client/components/core/Worker.js +3 -1
- package/src/client/components/default/CssDefault.js +17 -3
- package/src/client/components/default/MenuDefault.js +243 -50
- package/src/client/components/default/RoutesDefault.js +8 -14
- package/src/client/public/default/assets/background/dark.jpg +0 -0
- package/src/client/public/default/assets/background/dark.svg +557 -0
- package/src/client/public/default/assets/logo/underpost.gif +0 -0
- package/src/index.js +1 -1
- package/src/mailer/MailerProvider.js +37 -0
- package/src/server/client-build.js +1 -8
|
@@ -31,20 +31,10 @@ const UserService = {
|
|
|
31
31
|
const token = hashJWT({ email: req.body.email }, '15m');
|
|
32
32
|
const payloadToken = hashJWT({ email: req.body.email }, '15m');
|
|
33
33
|
const id = `${options.host}${options.path}`;
|
|
34
|
-
const translate =
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
},
|
|
39
|
-
P1: {
|
|
40
|
-
en: 'To recover your account, please click the button below:',
|
|
41
|
-
es: 'Para recuperar tu cuenta, haz click en el botón de abajo:',
|
|
42
|
-
},
|
|
43
|
-
BTN_LABEL: {
|
|
44
|
-
en: 'Recover Password',
|
|
45
|
-
es: 'Recuperar Contraseña',
|
|
46
|
-
},
|
|
47
|
-
};
|
|
34
|
+
const translate = MailerProvider.instance[id].translateTemplates.recoverEmail;
|
|
35
|
+
const recoverUrl = `${process.env.NODE_ENV === 'development' ? 'http://' : 'https://'}${req.hostname}${
|
|
36
|
+
req.body.proxyPath
|
|
37
|
+
}recover?payload=${payloadToken}`;
|
|
48
38
|
const sendResult = await MailerProvider.send({
|
|
49
39
|
id,
|
|
50
40
|
sendOptions: {
|
|
@@ -55,13 +45,8 @@ const UserService = {
|
|
|
55
45
|
.replace('{{H1}}', translate.H1[req.lang])
|
|
56
46
|
.replace('{{P1}}', translate.P1[req.lang])
|
|
57
47
|
.replace('{{TOKEN}}', token)
|
|
58
|
-
.replace(`{{COMPANY}}`,
|
|
59
|
-
.replace(
|
|
60
|
-
'{{RECOVER_WEB_URL}}',
|
|
61
|
-
`${process.env === 'development' ? 'http://' : 'https://'}${options.host}${options.path}${
|
|
62
|
-
options.path === '/' ? 'recover' : `/recover`
|
|
63
|
-
}?payload=${payloadToken}`,
|
|
64
|
-
)
|
|
48
|
+
.replace(`{{COMPANY}}`, req.hostname) // html body
|
|
49
|
+
.replace('{{RECOVER_WEB_URL}}', recoverUrl)
|
|
65
50
|
.replace('{{RECOVER_BTN_LABEL}}', translate.BTN_LABEL[req.lang]),
|
|
66
51
|
|
|
67
52
|
attachments: [
|
|
@@ -98,18 +83,7 @@ const UserService = {
|
|
|
98
83
|
},
|
|
99
84
|
);
|
|
100
85
|
}
|
|
101
|
-
const translate =
|
|
102
|
-
H1: {
|
|
103
|
-
en: 'Confirm Your Email',
|
|
104
|
-
zh: '请确认您的电子邮箱',
|
|
105
|
-
es: 'Confirma tu correo electrónico',
|
|
106
|
-
},
|
|
107
|
-
P1: {
|
|
108
|
-
en: 'Email confirmed! Thanks.',
|
|
109
|
-
zh: '电子邮箱已确认!感谢。',
|
|
110
|
-
es: 'Correo electrónico confirmado! Gracias.',
|
|
111
|
-
},
|
|
112
|
-
};
|
|
86
|
+
const translate = MailerProvider.instance[id].translateTemplates.confirmEmail;
|
|
113
87
|
const sendResult = await MailerProvider.send({
|
|
114
88
|
id,
|
|
115
89
|
sendOptions: {
|
|
@@ -120,7 +94,7 @@ const UserService = {
|
|
|
120
94
|
.replace('{{H1}}', translate.H1[req.lang])
|
|
121
95
|
.replace('{{P1}}', translate.P1[req.lang])
|
|
122
96
|
.replace('{{TOKEN}}', token)
|
|
123
|
-
.replace(`{{COMPANY}}`,
|
|
97
|
+
.replace(`{{COMPANY}}`, req.hostname), // html body
|
|
124
98
|
attachments: [
|
|
125
99
|
// {
|
|
126
100
|
// filename: 'logo.png',
|
|
@@ -444,7 +418,7 @@ const UserService = {
|
|
|
444
418
|
_id: user._id,
|
|
445
419
|
}).select(UserDto.select.get());
|
|
446
420
|
} else throw new Error('invalid token');
|
|
447
|
-
}
|
|
421
|
+
} else delete req.body.password;
|
|
448
422
|
|
|
449
423
|
switch (req.params.id) {
|
|
450
424
|
default: {
|
|
@@ -453,9 +427,6 @@ const UserService = {
|
|
|
453
427
|
});
|
|
454
428
|
switch (user.role) {
|
|
455
429
|
case 'admin': {
|
|
456
|
-
if (req.body.password !== undefined && req.body.password !== user.password)
|
|
457
|
-
req.body.password = await hashPassword(req.body.password);
|
|
458
|
-
else delete req.body.password;
|
|
459
430
|
return await User.findByIdAndUpdate(req.params.id, req.body, {
|
|
460
431
|
runValidators: true,
|
|
461
432
|
});
|
package/src/cli/run.js
CHANGED
|
@@ -86,6 +86,13 @@ class UnderpostRun {
|
|
|
86
86
|
shellExec(`${baseCommand} run ide /home/dd/engine`);
|
|
87
87
|
shellExec(`${baseCommand} run ide /home/dd/engine/engine-private`);
|
|
88
88
|
},
|
|
89
|
+
'template-deploy': (path, options = UnderpostRun.DEFAULT_OPTION) => {
|
|
90
|
+
const baseCommand = options.dev || true ? 'node bin' : 'underpost';
|
|
91
|
+
shellCd('/home/dd/engine');
|
|
92
|
+
shellExec(`git reset`);
|
|
93
|
+
shellExec(`${baseCommand} cmt . --empty ci package-pwa-microservices-template`);
|
|
94
|
+
shellExec(`${baseCommand} push . underpostnet/engine`);
|
|
95
|
+
},
|
|
89
96
|
'ssh-deploy': (path, options = UnderpostRun.DEFAULT_OPTION) => {
|
|
90
97
|
const baseCommand = options.dev || true ? 'node bin' : 'underpost';
|
|
91
98
|
shellCd('/home/dd/engine');
|
|
@@ -16,6 +16,7 @@ import { SocketIo } from './components/core/SocketIo.js';
|
|
|
16
16
|
import { SocketIoDefault } from './components/default/SocketIoDefault.js';
|
|
17
17
|
import { ElementsDefault } from './components/default/ElementsDefault.js';
|
|
18
18
|
import { Scroll } from './components/core/Scroll.js';
|
|
19
|
+
import { CssDefaultDark, CssDefaultLight } from './components/default/CssDefault.js';
|
|
19
20
|
|
|
20
21
|
const htmlMainBody = async () => {
|
|
21
22
|
return html`<span>Hello World!!</span>`;
|
|
@@ -25,12 +26,15 @@ window.onload = () =>
|
|
|
25
26
|
Worker.instance({
|
|
26
27
|
router: RouterDefault,
|
|
27
28
|
render: async () => {
|
|
28
|
-
await Css.loadThemes();
|
|
29
|
+
await Css.loadThemes([CssDefaultLight, CssDefaultDark]);
|
|
29
30
|
await TranslateCore.Init();
|
|
30
31
|
await TranslateDefault.Init();
|
|
31
32
|
await Responsive.Init();
|
|
32
33
|
await MenuDefault.Render({ htmlMainBody });
|
|
33
|
-
await SocketIo.Init({
|
|
34
|
+
await SocketIo.Init({
|
|
35
|
+
channels: ElementsDefault.Data,
|
|
36
|
+
path: `/`,
|
|
37
|
+
});
|
|
34
38
|
await SocketIoDefault.Init();
|
|
35
39
|
await LogInDefault();
|
|
36
40
|
await LogOutDefault();
|
|
@@ -44,7 +44,7 @@ const Account = {
|
|
|
44
44
|
{ model: 'email', id: `account-email`, rules: [{ type: 'isEmpty' }, { type: 'isEmail' }] },
|
|
45
45
|
{
|
|
46
46
|
model: 'password',
|
|
47
|
-
defaultValue: '
|
|
47
|
+
defaultValue: '#Changethis123',
|
|
48
48
|
id: `account-password`,
|
|
49
49
|
rules: [{ type: 'isStrongPassword' }],
|
|
50
50
|
},
|
|
@@ -7,7 +7,7 @@ import { Modal, renderViewTitle } from './Modal.js';
|
|
|
7
7
|
import { DocumentService } from '../../services/document/document.service.js';
|
|
8
8
|
import { CoreService, getApiBaseUrl } from '../../services/core/core.service.js';
|
|
9
9
|
import { loggerFactory } from './Logger.js';
|
|
10
|
-
import { imageShimmer, renderCssAttr } from './Css.js';
|
|
10
|
+
import { imageShimmer, renderChessPattern, renderCssAttr, styleFactory } from './Css.js';
|
|
11
11
|
|
|
12
12
|
const logger = loggerFactory(import.meta);
|
|
13
13
|
|
|
@@ -114,7 +114,6 @@ const Content = {
|
|
|
114
114
|
width: '100%',
|
|
115
115
|
border: 'none',
|
|
116
116
|
};
|
|
117
|
-
options.style = `style="${renderCssAttr(options)}"`;
|
|
118
117
|
if (!options.class) options.class = ``;
|
|
119
118
|
const { container, file } = options;
|
|
120
119
|
const ext = file.name.split('.')[file.name.split('.').length - 1];
|
|
@@ -126,7 +125,7 @@ const Content = {
|
|
|
126
125
|
const content = options.url
|
|
127
126
|
? await CoreService.getRaw({ url: options.url })
|
|
128
127
|
: await getRawContentFile(getBlobFromUint8ArrayFile(file.data.data, file.mimetype));
|
|
129
|
-
render += html`<div class="${options.class}" ${options.style}>${marked.parse(content)}</div>`;
|
|
128
|
+
render += html`<div class="${options.class}" ${styleFactory(options.style)}>${marked.parse(content)}</div>`;
|
|
130
129
|
}
|
|
131
130
|
|
|
132
131
|
break;
|
|
@@ -135,13 +134,18 @@ const Content = {
|
|
|
135
134
|
case 'jpeg':
|
|
136
135
|
case 'webp':
|
|
137
136
|
case 'svg':
|
|
137
|
+
case 'gif':
|
|
138
138
|
case 'png': {
|
|
139
139
|
const url = options.url
|
|
140
140
|
? options.url
|
|
141
141
|
: file._id
|
|
142
142
|
? getApiBaseUrl({ id: file._id, endpoint: 'file/blob' })
|
|
143
143
|
: URL.createObjectURL(getBlobFromUint8ArrayFile(file.data.data, file.mimetype));
|
|
144
|
-
const imgRender = html`<img
|
|
144
|
+
const imgRender = html`<img
|
|
145
|
+
class="in ${options.class}"
|
|
146
|
+
${styleFactory(options.style, `${renderChessPattern(50)}`)}
|
|
147
|
+
src="${url}"
|
|
148
|
+
/>`;
|
|
145
149
|
render += imgRender;
|
|
146
150
|
break;
|
|
147
151
|
}
|
|
@@ -153,14 +157,14 @@ const Content = {
|
|
|
153
157
|
: URL.createObjectURL(getBlobFromUint8ArrayFile(file.data.data, file.mimetype));
|
|
154
158
|
render += html`<iframe
|
|
155
159
|
class="in ${options.class} iframe-${options.idModal}"
|
|
156
|
-
${options.style}
|
|
160
|
+
${styleFactory(options.style)}
|
|
157
161
|
src="${url}"
|
|
158
162
|
></iframe>`;
|
|
159
163
|
break;
|
|
160
164
|
}
|
|
161
165
|
|
|
162
166
|
case 'json':
|
|
163
|
-
render += html`<pre class="in ${options.class}" ${options.style}>
|
|
167
|
+
render += html`<pre class="in ${options.class}" ${styleFactory(options.style)}>
|
|
164
168
|
${JSON.stringify(
|
|
165
169
|
JSON.parse(
|
|
166
170
|
options.url
|
|
@@ -174,7 +178,7 @@ const Content = {
|
|
|
174
178
|
break;
|
|
175
179
|
|
|
176
180
|
default:
|
|
177
|
-
render += html`<div class="in ${options.class}" ${options.style}>
|
|
181
|
+
render += html`<div class="in ${options.class}" ${styleFactory(options.style)}>
|
|
178
182
|
${options.url
|
|
179
183
|
? await CoreService.getRaw({ url: options.url })
|
|
180
184
|
: await getRawContentFile(getBlobFromUint8ArrayFile(file.data.data, file.mimetype))}
|
|
@@ -51,8 +51,8 @@ const Css = {
|
|
|
51
51
|
// if (!ThemesScope.find((t) => t.dark)) addTheme(CssCoreDark);
|
|
52
52
|
// if (!ThemesScope.find((t) => !t.dark)) addTheme(CssCoreLight);
|
|
53
53
|
if (ThemesScope.length === 0) {
|
|
54
|
-
addTheme(CssCoreDark);
|
|
55
54
|
addTheme(CssCoreLight);
|
|
55
|
+
addTheme(CssCoreDark);
|
|
56
56
|
}
|
|
57
57
|
const localStorageTheme = localStorage.getItem('_theme');
|
|
58
58
|
if (localStorageTheme && Themes[localStorageTheme]) {
|
|
@@ -199,6 +199,7 @@ const addTheme = (options) => {
|
|
|
199
199
|
if (!['core', 'css-core'].includes(options.theme))
|
|
200
200
|
render += darkTheme ? await CssCoreDark.render() : await CssCoreLight.render();
|
|
201
201
|
render += await options.render();
|
|
202
|
+
render += await subThemeManager.render();
|
|
202
203
|
htmls('.theme', render);
|
|
203
204
|
TriggerThemeEvents();
|
|
204
205
|
}
|
|
@@ -232,18 +233,29 @@ const borderChar = (px, color, selectors, hover = false) => {
|
|
|
232
233
|
${color}, ${px}px ${px}px ${px}px ${color};
|
|
233
234
|
`;
|
|
234
235
|
};
|
|
235
|
-
|
|
236
236
|
const boxShadow = ({ selector }) => html`
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
237
|
+
${darkTheme
|
|
238
|
+
? html`
|
|
239
|
+
<style>
|
|
240
|
+
${selector} {
|
|
241
|
+
box-shadow: 0 4px 8px 0 rgba(255, 255, 255, 0.1), 0 6px 20px 0 rgba(255, 255, 255, 0.08);
|
|
242
|
+
}
|
|
243
|
+
${selector}:hover {
|
|
244
|
+
box-shadow: 0 8px 16px 0 rgba(255, 255, 255, 0.15), 0 10px 30px 0 rgba(255, 255, 255, 0.1);
|
|
245
|
+
}
|
|
246
|
+
</style>
|
|
247
|
+
`
|
|
248
|
+
: html`
|
|
249
|
+
<style>
|
|
250
|
+
${selector} {
|
|
251
|
+
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
|
|
252
|
+
}
|
|
253
|
+
${selector}:hover {
|
|
254
|
+
box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2), 0 10px 30px 0 rgba(0, 0, 0, 0.3);
|
|
255
|
+
}
|
|
256
|
+
</style>
|
|
257
|
+
`}
|
|
245
258
|
`;
|
|
246
|
-
|
|
247
259
|
const renderMediaQuery = (mediaData) => {
|
|
248
260
|
// first limit should be '0'
|
|
249
261
|
return html`
|
|
@@ -677,6 +689,166 @@ const scrollBarLightRender = () => {
|
|
|
677
689
|
.join('');
|
|
678
690
|
};
|
|
679
691
|
|
|
692
|
+
/**
|
|
693
|
+
* Adjust hex color brightness toward white/black ("mix") or by modifying HSL lightness ("hsl").
|
|
694
|
+
*
|
|
695
|
+
* @param {string} hex - Color as '#rrggbb', 'rrggbb', '#rgb', or 'rgb'.
|
|
696
|
+
* @param {number} factor - -1..1 or -100..100 (percent). Positive = lighten, negative = darken.
|
|
697
|
+
* @param {{mode?: 'mix'|'hsl'}} [options]
|
|
698
|
+
* @returns {string} - Adjusted color as '#rrggbb' (lowercase).
|
|
699
|
+
*/
|
|
700
|
+
function adjustHex(hex, factor = 0.1, options = {}) {
|
|
701
|
+
if (typeof hex !== 'string') throw new TypeError('hex must be a string');
|
|
702
|
+
if (typeof factor !== 'number') throw new TypeError('factor must be a number');
|
|
703
|
+
|
|
704
|
+
// normalize factor: allow -100..100 or -1..1
|
|
705
|
+
if (factor > 1 && factor <= 100) factor = factor / 100;
|
|
706
|
+
if (factor < -1 && factor >= -100) factor = factor / 100;
|
|
707
|
+
factor = Math.max(-1, Math.min(1, factor));
|
|
708
|
+
|
|
709
|
+
const mode = options.mode === 'hsl' ? 'hsl' : 'mix';
|
|
710
|
+
|
|
711
|
+
// normalize hex
|
|
712
|
+
let h = hex.replace(/^#/, '').trim();
|
|
713
|
+
if (!(h.length === 3 || h.length === 6)) throw new Error('Invalid hex format');
|
|
714
|
+
if (h.length === 3)
|
|
715
|
+
h = h
|
|
716
|
+
.split('')
|
|
717
|
+
.map((c) => c + c)
|
|
718
|
+
.join('');
|
|
719
|
+
|
|
720
|
+
const r = parseInt(h.slice(0, 2), 16);
|
|
721
|
+
const g = parseInt(h.slice(2, 4), 16);
|
|
722
|
+
const b = parseInt(h.slice(4, 6), 16);
|
|
723
|
+
|
|
724
|
+
const clamp = (v, a = 0, z = 255) => Math.max(a, Math.min(z, v));
|
|
725
|
+
|
|
726
|
+
const rgbToHex = (rr, gg, bb) =>
|
|
727
|
+
'#' +
|
|
728
|
+
[rr, gg, bb]
|
|
729
|
+
.map((v) => Math.round(v).toString(16).padStart(2, '0'))
|
|
730
|
+
.join('')
|
|
731
|
+
.toLowerCase();
|
|
732
|
+
|
|
733
|
+
if (mode === 'mix') {
|
|
734
|
+
// positive: mix toward white (255); negative: mix toward black (0)
|
|
735
|
+
const mixChannel = (c) => {
|
|
736
|
+
if (factor >= 0) {
|
|
737
|
+
return clamp(Math.round(c + (255 - c) * factor));
|
|
738
|
+
} else {
|
|
739
|
+
const a = Math.abs(factor);
|
|
740
|
+
return clamp(Math.round(c * (1 - a)));
|
|
741
|
+
}
|
|
742
|
+
};
|
|
743
|
+
return rgbToHex(mixChannel(r), mixChannel(g), mixChannel(b));
|
|
744
|
+
} else {
|
|
745
|
+
// HSL mode: convert rgb to hsl, adjust L by factor, convert back
|
|
746
|
+
const rgbToHsl = (r, g, b) => {
|
|
747
|
+
r /= 255;
|
|
748
|
+
g /= 255;
|
|
749
|
+
b /= 255;
|
|
750
|
+
const max = Math.max(r, g, b),
|
|
751
|
+
min = Math.min(r, g, b);
|
|
752
|
+
let h = 0,
|
|
753
|
+
s = 0,
|
|
754
|
+
l = (max + min) / 2;
|
|
755
|
+
if (max !== min) {
|
|
756
|
+
const d = max - min;
|
|
757
|
+
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
758
|
+
switch (max) {
|
|
759
|
+
case r:
|
|
760
|
+
h = (g - b) / d + (g < b ? 6 : 0);
|
|
761
|
+
break;
|
|
762
|
+
case g:
|
|
763
|
+
h = (b - r) / d + 2;
|
|
764
|
+
break;
|
|
765
|
+
case b:
|
|
766
|
+
h = (r - g) / d + 4;
|
|
767
|
+
break;
|
|
768
|
+
}
|
|
769
|
+
h /= 6;
|
|
770
|
+
}
|
|
771
|
+
return { h, s, l };
|
|
772
|
+
};
|
|
773
|
+
|
|
774
|
+
const hslToRgb = (h, s, l) => {
|
|
775
|
+
let r, g, b;
|
|
776
|
+
if (s === 0) {
|
|
777
|
+
r = g = b = l;
|
|
778
|
+
} else {
|
|
779
|
+
const hue2rgb = (p, q, t) => {
|
|
780
|
+
if (t < 0) t += 1;
|
|
781
|
+
if (t > 1) t -= 1;
|
|
782
|
+
if (t < 1 / 6) return p + (q - p) * 6 * t;
|
|
783
|
+
if (t < 1 / 2) return q;
|
|
784
|
+
if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
|
|
785
|
+
return p;
|
|
786
|
+
};
|
|
787
|
+
const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
788
|
+
const p = 2 * l - q;
|
|
789
|
+
r = hue2rgb(p, q, h + 1 / 3);
|
|
790
|
+
g = hue2rgb(p, q, h);
|
|
791
|
+
b = hue2rgb(p, q, h - 1 / 3);
|
|
792
|
+
}
|
|
793
|
+
return { r: r * 255, g: g * 255, b: b * 255 };
|
|
794
|
+
};
|
|
795
|
+
|
|
796
|
+
const { h: hh, s: ss, l: ll } = rgbToHsl(r, g, b);
|
|
797
|
+
// add factor to lightness (factor already normalized -1..1)
|
|
798
|
+
let newL = ll + factor;
|
|
799
|
+
newL = Math.max(0, Math.min(1, newL));
|
|
800
|
+
const { r: r2, g: g2, b: b2 } = hslToRgb(hh, ss, newL);
|
|
801
|
+
return rgbToHex(r2, g2, b2);
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
// Convenience helpers:
|
|
806
|
+
function lightenHex(hex, percentOr01 = 0.1, options = {}) {
|
|
807
|
+
return adjustHex(hex, Math.abs(percentOr01), options);
|
|
808
|
+
}
|
|
809
|
+
function darkenHex(hex, percentOr01 = 0.1, options = {}) {
|
|
810
|
+
return adjustHex(hex, -Math.abs(percentOr01), options);
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
const subThemeManager = {
|
|
814
|
+
render: async function () {
|
|
815
|
+
if (darkTheme && this.renderDark) {
|
|
816
|
+
return await this.renderDark();
|
|
817
|
+
} else if (!darkTheme && this.renderLight) {
|
|
818
|
+
return await this.renderLight();
|
|
819
|
+
}
|
|
820
|
+
return html``;
|
|
821
|
+
},
|
|
822
|
+
lightColor: null,
|
|
823
|
+
setLightTheme: function (color) {
|
|
824
|
+
this.lightColor = color;
|
|
825
|
+
this.renderLight = async function () {
|
|
826
|
+
return html`<style>
|
|
827
|
+
button:hover,
|
|
828
|
+
.a-btn:hover,
|
|
829
|
+
.main-btn-menu-active {
|
|
830
|
+
color: ${this.lightColor};
|
|
831
|
+
background-color: ${lightenHex(this.lightColor, 0.8)};
|
|
832
|
+
}
|
|
833
|
+
</style>`;
|
|
834
|
+
};
|
|
835
|
+
},
|
|
836
|
+
darkColor: null,
|
|
837
|
+
setDarkTheme: function (color) {
|
|
838
|
+
this.darkColor = color;
|
|
839
|
+
this.renderDark = async function () {
|
|
840
|
+
return html`<style>
|
|
841
|
+
button:hover,
|
|
842
|
+
.a-btn:hover,
|
|
843
|
+
.main-btn-menu-active {
|
|
844
|
+
color: ${lightenHex(this.darkColor, 0.8)};
|
|
845
|
+
background-color: ${darkenHex(this.darkColor, 0.75)};
|
|
846
|
+
}
|
|
847
|
+
</style>`;
|
|
848
|
+
};
|
|
849
|
+
},
|
|
850
|
+
};
|
|
851
|
+
|
|
680
852
|
const scrollBarDarkRender = () => {
|
|
681
853
|
return cssBrowserCodes
|
|
682
854
|
.map(
|
|
@@ -685,8 +857,8 @@ const scrollBarDarkRender = () => {
|
|
|
685
857
|
::-` +
|
|
686
858
|
b +
|
|
687
859
|
`-scrollbar {
|
|
688
|
-
width:
|
|
689
|
-
height:
|
|
860
|
+
width: 8px;
|
|
861
|
+
height: 8px;
|
|
690
862
|
/* line-height: 1em; */
|
|
691
863
|
}
|
|
692
864
|
|
|
@@ -702,7 +874,7 @@ const scrollBarDarkRender = () => {
|
|
|
702
874
|
b +
|
|
703
875
|
`-scrollbar-thumb {
|
|
704
876
|
background: #74747457;
|
|
705
|
-
border-radius:
|
|
877
|
+
border-radius: 4px;
|
|
706
878
|
}
|
|
707
879
|
|
|
708
880
|
/* Handle on hover */
|
|
@@ -854,7 +1026,8 @@ const imageShimmer = () => html`<div
|
|
|
854
1026
|
</div>
|
|
855
1027
|
</div>`;
|
|
856
1028
|
|
|
857
|
-
const renderChessPattern = (
|
|
1029
|
+
const renderChessPattern = (patternSize = 20) =>
|
|
1030
|
+
`background: repeating-conic-gradient(#808080 0 25%, #0000 0 50%) 50% / ${patternSize}px ${patternSize}px`;
|
|
858
1031
|
|
|
859
1032
|
const extractBackgroundImageUrl = (element) => {
|
|
860
1033
|
const style = window.getComputedStyle(element);
|
|
@@ -872,6 +1045,8 @@ const simpleIconsRender = (selector) => {
|
|
|
872
1045
|
});
|
|
873
1046
|
};
|
|
874
1047
|
|
|
1048
|
+
const styleFactory = (payload, plain = '') => `style="${renderCssAttr({ style: payload })} ${plain}"`;
|
|
1049
|
+
|
|
875
1050
|
export {
|
|
876
1051
|
Css,
|
|
877
1052
|
Themes,
|
|
@@ -907,4 +1082,9 @@ export {
|
|
|
907
1082
|
simpleIconsRender,
|
|
908
1083
|
extractBackgroundImageUrl,
|
|
909
1084
|
renderChessPattern,
|
|
1085
|
+
subThemeManager,
|
|
1086
|
+
lightenHex,
|
|
1087
|
+
darkenHex,
|
|
1088
|
+
adjustHex,
|
|
1089
|
+
styleFactory,
|
|
910
1090
|
};
|
|
@@ -16,10 +16,7 @@ const Docs = {
|
|
|
16
16
|
const docData = this.Data.find((d) => d.type === type);
|
|
17
17
|
const ModalId = `modal-docs-${docData.type}`;
|
|
18
18
|
const { barConfig } = await Themes[Css.currentTheme]();
|
|
19
|
-
|
|
20
|
-
setQueryPath({ path: 'docs' });
|
|
21
|
-
Modal.removeModal(ModalId);
|
|
22
|
-
};
|
|
19
|
+
|
|
23
20
|
await Modal.Render({
|
|
24
21
|
barConfig,
|
|
25
22
|
title: renderViewTitle(docData),
|
|
@@ -53,6 +50,9 @@ const Docs = {
|
|
|
53
50
|
}
|
|
54
51
|
};
|
|
55
52
|
Modal.Data[ModalId].onObserverListener[ModalId]();
|
|
53
|
+
Modal.Data[ModalId].onCloseListener[ModalId] = () => {
|
|
54
|
+
setQueryPath({ path: 'docs', queryPath: '' });
|
|
55
|
+
};
|
|
56
56
|
},
|
|
57
57
|
Data: [
|
|
58
58
|
{
|
|
@@ -359,4 +359,9 @@ const InputFile = {
|
|
|
359
359
|
},
|
|
360
360
|
};
|
|
361
361
|
|
|
362
|
-
|
|
362
|
+
function isTextInputFocused() {
|
|
363
|
+
const active = document.activeElement;
|
|
364
|
+
return active && (active.tagName === 'INPUT' || active.tagName === 'TEXTAREA');
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
export { Input, InputFile, fileFormDataFactory, getSrcFromFileData, getFileFromFileData, isTextInputFocused };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CoreService } from '../../services/core/core.service.js';
|
|
2
2
|
import { BtnIcon } from './BtnIcon.js';
|
|
3
3
|
import { s4 } from './CommonJs.js';
|
|
4
|
-
import { darkTheme, renderCssAttr } from './Css.js';
|
|
4
|
+
import { darkTheme, renderCssAttr, subThemeManager } from './Css.js';
|
|
5
5
|
import { loggerFactory } from './Logger.js';
|
|
6
6
|
import { append, getAllChildNodes, getProxyPath, htmls, s, sa } from './VanillaJs.js';
|
|
7
7
|
|
|
@@ -23,12 +23,12 @@ const LoadingAnimation = {
|
|
|
23
23
|
<div
|
|
24
24
|
class="fix progress-bar box-shadow ${id}"
|
|
25
25
|
style="left: -100%; background: ${darkTheme
|
|
26
|
-
?
|
|
27
|
-
?
|
|
28
|
-
: `#
|
|
29
|
-
:
|
|
30
|
-
?
|
|
31
|
-
: `#
|
|
26
|
+
? subThemeManager.darkColor
|
|
27
|
+
? subThemeManager.darkColor
|
|
28
|
+
: `#66e400`
|
|
29
|
+
: subThemeManager.lightColor
|
|
30
|
+
? subThemeManager.lightColor
|
|
31
|
+
: `#157e00`};"
|
|
32
32
|
></div>
|
|
33
33
|
`,
|
|
34
34
|
);
|
|
@@ -140,14 +140,7 @@ const LoadingAnimation = {
|
|
|
140
140
|
}, 300);
|
|
141
141
|
});
|
|
142
142
|
},
|
|
143
|
-
|
|
144
|
-
setLightColor: function (color) {
|
|
145
|
-
this.lightColor = color;
|
|
146
|
-
},
|
|
147
|
-
darkColor: null,
|
|
148
|
-
setDarkColor: function (color) {
|
|
149
|
-
this.darkColor = color;
|
|
150
|
-
},
|
|
143
|
+
|
|
151
144
|
RenderCurrentSrcLoad: function (event) {
|
|
152
145
|
if (s(`.ssr-loading-info`)) {
|
|
153
146
|
let nameSrcLoad = event.data.path;
|
|
@@ -8,7 +8,7 @@ import { Webhook } from './Webhook.js';
|
|
|
8
8
|
const LogOut = {
|
|
9
9
|
Event: {},
|
|
10
10
|
Trigger: async function (options) {
|
|
11
|
-
LogIn.
|
|
11
|
+
LogIn.cleanMainUser();
|
|
12
12
|
await Webhook.unregister();
|
|
13
13
|
for (const eventKey of Object.keys(this.Event)) await this.Event[eventKey](options);
|
|
14
14
|
if (s(`.session`))
|