underpost 2.8.843 → 2.8.845
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/.github/workflows/{ghpkg.yml → ghpkg.ci.yml} +1 -1
- package/.github/workflows/{npmpkg.yml → npmpkg.ci.yml} +1 -1
- package/.github/workflows/{publish.yml → publish.ci.yml} +1 -1
- package/.github/workflows/{pwa-microservices-template.page.yml → pwa-microservices-template-page.cd.yml} +1 -1
- package/.github/workflows/{pwa-microservices-template.test.yml → pwa-microservices-template-test.ci.yml} +1 -1
- package/.vscode/settings.json +0 -1
- package/README.md +18 -2
- package/bin/build.js +8 -5
- package/bin/deploy.js +10 -69
- package/bin/file.js +15 -11
- package/cli.md +47 -43
- package/docker-compose.yml +1 -1
- package/manifests/deployment/dd-template-development/deployment.yaml +2 -2
- package/manifests/maas/gpu-diag.sh +1 -1
- package/package.json +3 -5
- package/src/api/user/user.router.js +24 -1
- package/src/cli/cluster.js +19 -10
- package/src/cli/index.js +1 -0
- package/src/cli/run.js +21 -0
- package/src/client/components/core/Css.js +52 -2
- package/src/client/components/core/CssCore.js +0 -4
- package/src/client/components/core/Docs.js +10 -57
- package/src/client/components/core/DropDown.js +128 -82
- package/src/client/components/core/EventsUI.js +92 -5
- package/src/client/components/core/Modal.js +451 -120
- package/src/client/components/core/NotificationManager.js +2 -2
- package/src/client/components/core/Panel.js +2 -2
- package/src/client/components/core/PanelForm.js +12 -2
- package/src/client/components/core/Recover.js +1 -1
- package/src/client/components/core/Router.js +63 -2
- package/src/client/components/core/Translate.js +2 -2
- package/src/index.js +1 -1
- package/src/server/client-build-docs.js +205 -0
- package/src/server/client-build.js +11 -140
- package/src/server/valkey.js +102 -41
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { getId, newInstance, range, s4, splitEveryXChar } from './CommonJs.js';
|
|
1
|
+
import { getId, newInstance, range, rgbToHex, s4, splitEveryXChar } from './CommonJs.js';
|
|
2
2
|
import { CssCoreDark, CssCoreLight } from './CssCore.js';
|
|
3
3
|
import { DropDown } from './DropDown.js';
|
|
4
4
|
import { Modal } from './Modal.js';
|
|
5
5
|
import { Translate } from './Translate.js';
|
|
6
|
-
import { append, getProxyPath, htmls, s } from './VanillaJs.js';
|
|
6
|
+
import { append, getProxyPath, htmls, s, sa } from './VanillaJs.js';
|
|
7
7
|
|
|
8
8
|
let ThemesScope = [];
|
|
9
9
|
|
|
@@ -12,6 +12,39 @@ let ThemesScope = [];
|
|
|
12
12
|
// https://www.1001fonts.com/
|
|
13
13
|
|
|
14
14
|
const Css = {
|
|
15
|
+
// Menu button container transition styles
|
|
16
|
+
menuButtonContainer: () => css`
|
|
17
|
+
.main-btn-menu {
|
|
18
|
+
transition: all 0.2s ease-in-out;
|
|
19
|
+
position: relative;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.main-btn-menu::after {
|
|
23
|
+
content: '';
|
|
24
|
+
position: absolute;
|
|
25
|
+
bottom: 0;
|
|
26
|
+
left: 50%;
|
|
27
|
+
width: 0;
|
|
28
|
+
height: 2px;
|
|
29
|
+
background: currentColor;
|
|
30
|
+
transition: all 0.2s ease-in-out;
|
|
31
|
+
transform: translateX(-50%);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.main-btn-menu:hover::after {
|
|
35
|
+
width: 60%;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.main-btn-menu.active {
|
|
39
|
+
background: rgba(255, 255, 255, 0.1);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.main-btn-menu.active::after {
|
|
43
|
+
width: 80%;
|
|
44
|
+
background: currentColor;
|
|
45
|
+
}
|
|
46
|
+
`,
|
|
47
|
+
|
|
15
48
|
loadThemes: async function (themes = []) {
|
|
16
49
|
ThemesScope = [];
|
|
17
50
|
for (const themeOptions of themes) addTheme(themeOptions);
|
|
@@ -31,6 +64,16 @@ const Css = {
|
|
|
31
64
|
Init: async function (options) {
|
|
32
65
|
if (!options) options = ThemesScope[0];
|
|
33
66
|
const { theme } = options;
|
|
67
|
+
|
|
68
|
+
// Inject menu button container styles
|
|
69
|
+
const styleId = 'menu-btn-container-styles';
|
|
70
|
+
if (!document.getElementById(styleId)) {
|
|
71
|
+
const style = document.createElement('style');
|
|
72
|
+
style.id = styleId;
|
|
73
|
+
style.textContent = this.menuButtonContainer();
|
|
74
|
+
document.head.appendChild(style);
|
|
75
|
+
}
|
|
76
|
+
|
|
34
77
|
return await Themes[theme](options);
|
|
35
78
|
},
|
|
36
79
|
RenderSetting: async function () {
|
|
@@ -811,6 +854,12 @@ const imageShimmer = () => html`<div
|
|
|
811
854
|
</div>
|
|
812
855
|
</div>`;
|
|
813
856
|
|
|
857
|
+
const simpleIconsRender = (selector) => {
|
|
858
|
+
sa(selector).forEach((el) => {
|
|
859
|
+
el.src = `https://cdn.simpleicons.org/coveralls/${rgbToHex(window.getComputedStyle(s('html')).color)}`;
|
|
860
|
+
});
|
|
861
|
+
};
|
|
862
|
+
|
|
814
863
|
export {
|
|
815
864
|
Css,
|
|
816
865
|
Themes,
|
|
@@ -843,4 +892,5 @@ export {
|
|
|
843
892
|
renderWave,
|
|
844
893
|
cssEffect,
|
|
845
894
|
imageShimmer,
|
|
895
|
+
simpleIconsRender,
|
|
846
896
|
};
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import { Badge } from './Badge.js';
|
|
2
2
|
import { BtnIcon } from './BtnIcon.js';
|
|
3
3
|
import { rgbToHex } from './CommonJs.js';
|
|
4
|
-
import { Css, darkTheme, dynamicCol, renderCssAttr, ThemeEvents, Themes } from './Css.js';
|
|
4
|
+
import { Css, darkTheme, dynamicCol, renderCssAttr, simpleIconsRender, ThemeEvents, Themes } from './Css.js';
|
|
5
5
|
import { DropDown } from './DropDown.js';
|
|
6
6
|
import { buildBadgeToolTipMenuOption, Modal, renderMenuLabel, renderViewTitle } from './Modal.js';
|
|
7
7
|
import { listenQueryPathInstance, setQueryPath } from './Router.js';
|
|
8
8
|
import { Translate } from './Translate.js';
|
|
9
|
-
import { getProxyPath, getQueryParams, htmls, s } from './VanillaJs.js';
|
|
9
|
+
import { getProxyPath, getQueryParams, htmls, s, sa } from './VanillaJs.js';
|
|
10
10
|
import Sortable from 'sortablejs';
|
|
11
11
|
|
|
12
12
|
// https://mintlify.com/docs/quickstart
|
|
13
13
|
|
|
14
|
-
const umlTypes = ['server', 'cron', 'client', 'ssr'];
|
|
15
|
-
|
|
16
14
|
const Docs = {
|
|
17
15
|
RenderModal: async function (type, modalOptions) {
|
|
18
16
|
const docData = this.Data.find((d) => d.type === type);
|
|
@@ -48,6 +46,11 @@ const Docs = {
|
|
|
48
46
|
Modal.Data[ModalId].onObserverListener[ModalId] = () => {
|
|
49
47
|
if (s(`.iframe-${ModalId}`))
|
|
50
48
|
s(`.iframe-${ModalId}`).style.height = `${s(`.${ModalId}`).offsetHeight - Modal.headerTitleHeight}px`;
|
|
49
|
+
|
|
50
|
+
if (type.match('coverage')) {
|
|
51
|
+
simpleIconsRender(`.doc-icon-coverage`);
|
|
52
|
+
simpleIconsRender(`.doc-icon-coverage-link`);
|
|
53
|
+
}
|
|
51
54
|
};
|
|
52
55
|
Modal.Data[ModalId].onObserverListener[ModalId]();
|
|
53
56
|
},
|
|
@@ -98,10 +101,7 @@ const Docs = {
|
|
|
98
101
|
return `${getProxyPath()}docs/coverage`;
|
|
99
102
|
},
|
|
100
103
|
themeEvent: () => {
|
|
101
|
-
if (s(`.doc-icon-coverage`))
|
|
102
|
-
s(`.doc-icon-coverage`).src = `https://cdn.simpleicons.org/coveralls/${rgbToHex(
|
|
103
|
-
window.getComputedStyle(s('html')).color,
|
|
104
|
-
)}`;
|
|
104
|
+
if (s(`.doc-icon-coverage`)) setTimeout(() => simpleIconsRender(`.doc-icon-coverage`));
|
|
105
105
|
},
|
|
106
106
|
},
|
|
107
107
|
{
|
|
@@ -112,43 +112,10 @@ const Docs = {
|
|
|
112
112
|
return `https://coveralls.io/github/underpostnet/engine`;
|
|
113
113
|
},
|
|
114
114
|
themeEvent: () => {
|
|
115
|
-
if (s(`.doc-icon-coverage-link`))
|
|
116
|
-
s(`.doc-icon-coverage-link`).src = `https://cdn.simpleicons.org/coveralls/${rgbToHex(
|
|
117
|
-
window.getComputedStyle(s('html')).color,
|
|
118
|
-
)}`;
|
|
115
|
+
if (s(`.doc-icon-coverage-link`)) setTimeout(() => simpleIconsRender(`.doc-icon-coverage-link`));
|
|
119
116
|
},
|
|
120
117
|
},
|
|
121
|
-
]
|
|
122
|
-
umlTypes.map((umlType) => {
|
|
123
|
-
const umlId = `uml-${umlType}`;
|
|
124
|
-
return {
|
|
125
|
-
type: umlId,
|
|
126
|
-
icon: html`<i class="fas fa-sitemap"></i>`,
|
|
127
|
-
text: Translate.Render(`${umlType} config uml`),
|
|
128
|
-
url: function () {
|
|
129
|
-
return `/docs/?cid=${umlId}`;
|
|
130
|
-
},
|
|
131
|
-
renderHtml: function () {
|
|
132
|
-
return html` <div class="in section-mp">
|
|
133
|
-
<div class="in sub-title-modal"><i class="fas fa-project-diagram"></i> Schema</div>
|
|
134
|
-
</div>
|
|
135
|
-
<div class="in section-mp">
|
|
136
|
-
<a href="${getProxyPath()}docs/plantuml/${umlType}-schema.svg" target="_blank"
|
|
137
|
-
><img class="in plantuml-svg" src="${getProxyPath()}docs/plantuml/${umlType}-schema.svg"
|
|
138
|
-
/></a>
|
|
139
|
-
</div>
|
|
140
|
-
<div class="in section-mp">
|
|
141
|
-
<div class="in sub-title-modal"><i class="fas fa-project-diagram"></i> Instance example</div>
|
|
142
|
-
</div>
|
|
143
|
-
<div class="in section-mp">
|
|
144
|
-
<a href="${getProxyPath()}docs/plantuml/${umlType}-conf.svg" target="_blank"
|
|
145
|
-
><img class="in plantuml-svg" src="${getProxyPath()}docs/plantuml/${umlType}-conf.svg"
|
|
146
|
-
/></a>
|
|
147
|
-
</div>`;
|
|
148
|
-
},
|
|
149
|
-
};
|
|
150
|
-
}),
|
|
151
|
-
),
|
|
118
|
+
],
|
|
152
119
|
Tokens: {},
|
|
153
120
|
Init: async function (options) {
|
|
154
121
|
const { idModal } = options;
|
|
@@ -158,10 +125,6 @@ const Docs = {
|
|
|
158
125
|
s(`.btn-docs-src`).classList.remove('main-btn-menu-active');
|
|
159
126
|
s(`.btn-docs-api`).classList.remove('main-btn-menu-active');
|
|
160
127
|
s(`.btn-docs-coverage`).classList.remove('main-btn-menu-active');
|
|
161
|
-
for (const umlType of umlTypes) {
|
|
162
|
-
const umlId = `uml-${umlType}`;
|
|
163
|
-
s(`.btn-docs-${umlId}`).classList.remove('main-btn-menu-active');
|
|
164
|
-
}
|
|
165
128
|
};
|
|
166
129
|
s(`.btn-docs-src`).onclick = async () => {
|
|
167
130
|
setQueryPath({ path: 'docs', queryPath: 'src' });
|
|
@@ -195,16 +158,6 @@ const Docs = {
|
|
|
195
158
|
location.href = docData.url();
|
|
196
159
|
};
|
|
197
160
|
|
|
198
|
-
for (const umlType of umlTypes) {
|
|
199
|
-
const umlId = `uml-${umlType}`;
|
|
200
|
-
s(`.btn-docs-${umlId}`).onclick = async () => {
|
|
201
|
-
cleanActive();
|
|
202
|
-
s(`.btn-docs-${umlId}`).classList.add('main-btn-menu-active');
|
|
203
|
-
setQueryPath({ path: 'docs', queryPath: umlId });
|
|
204
|
-
await this.RenderModal(umlId, { ...options.modalOptions, handleType: 'bar' });
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
|
|
208
161
|
listenQueryPathInstance({
|
|
209
162
|
id: options.idModal,
|
|
210
163
|
routeId: 'docs',
|
|
@@ -8,7 +8,7 @@ const DropDown = {
|
|
|
8
8
|
Tokens: {},
|
|
9
9
|
Render: async function (options) {
|
|
10
10
|
const id = options.id ? options.id : getId(this.Tokens, 'dropdown-');
|
|
11
|
-
this.Tokens[id] = { onClickEvents: {}, lastSelectValue: undefined };
|
|
11
|
+
this.Tokens[id] = { onClickEvents: {}, lastSelectValue: undefined, oncheckvalues: {} };
|
|
12
12
|
|
|
13
13
|
options.data.push({
|
|
14
14
|
value: 'reset',
|
|
@@ -39,6 +39,96 @@ const DropDown = {
|
|
|
39
39
|
else s(`.dropdown-option-${id}`).classList.add('hide');
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
+
const _render = async (data) => {
|
|
43
|
+
let render = '';
|
|
44
|
+
let index = -1;
|
|
45
|
+
for (const optionData of data) {
|
|
46
|
+
index++;
|
|
47
|
+
const i = index;
|
|
48
|
+
const valueDisplay = optionData.value.trim().replaceAll(' ', '-');
|
|
49
|
+
setTimeout(() => {
|
|
50
|
+
const onclick = (e) => {
|
|
51
|
+
if (options && options.lastSelectClass && s(`.dropdown-option-${this.Tokens[id].lastSelectValue}`)) {
|
|
52
|
+
s(`.dropdown-option-${this.Tokens[id].lastSelectValue}`).classList.remove(options.lastSelectClass);
|
|
53
|
+
}
|
|
54
|
+
this.Tokens[id].lastSelectValue = valueDisplay;
|
|
55
|
+
if (options && options.lastSelectClass && s(`.dropdown-option-${this.Tokens[id].lastSelectValue}`)) {
|
|
56
|
+
s(`.dropdown-option-${this.Tokens[id].lastSelectValue}`).classList.add(options.lastSelectClass);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (
|
|
60
|
+
!(options && options.disableClose) &&
|
|
61
|
+
(options.type !== 'checkbox' || optionData.value === 'close' || optionData.value === 'reset')
|
|
62
|
+
)
|
|
63
|
+
s(`.dropdown-option-${id}`).classList.add('hide');
|
|
64
|
+
|
|
65
|
+
if (options.type === 'checkbox' && ToggleSwitch.Tokens[`checkbox-role-${valueDisplay}`])
|
|
66
|
+
ToggleSwitch.Tokens[`checkbox-role-${valueDisplay}`].click();
|
|
67
|
+
if (optionData.value !== 'close') {
|
|
68
|
+
if (optionData.value !== 'reset')
|
|
69
|
+
htmls(
|
|
70
|
+
`.dropdown-current-${id}`,
|
|
71
|
+
options.type === 'checkbox'
|
|
72
|
+
? data
|
|
73
|
+
.filter((d) => d.checked)
|
|
74
|
+
.map((v, i, a) => `${v.display}${i < a.length - 1 ? ',' : ''}`)
|
|
75
|
+
.join('')
|
|
76
|
+
: optionData.display,
|
|
77
|
+
);
|
|
78
|
+
else htmls(`.dropdown-current-${id}`, '');
|
|
79
|
+
|
|
80
|
+
this.Tokens[id].value =
|
|
81
|
+
options.type === 'checkbox' ? data.filter((d) => d.checked).map((d) => d.data) : optionData.data;
|
|
82
|
+
|
|
83
|
+
console.warn('current value dropdown id:' + id, this.Tokens[id].value);
|
|
84
|
+
|
|
85
|
+
s(`.${id}`).value = this.Tokens[id].value;
|
|
86
|
+
|
|
87
|
+
optionData.onClick(e);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
this.Tokens[id].onClickEvents[`dropdown-option-${id}-${i}`] = onclick;
|
|
92
|
+
this.Tokens[id].onClickEvents[`dropdown-option-${id}-${valueDisplay}`] = onclick;
|
|
93
|
+
this.Tokens[id].onClickEvents[`dropdown-option-${valueDisplay}`] = onclick;
|
|
94
|
+
|
|
95
|
+
s(`.dropdown-option-${id}-${i}`).onclick = onclick;
|
|
96
|
+
});
|
|
97
|
+
render += html`
|
|
98
|
+
<div
|
|
99
|
+
class="in dropdown-option dropdown-option-${id}-${i} dropdown-option-${id}-${valueDisplay} dropdown-option-${valueDisplay} ${valueDisplay ===
|
|
100
|
+
'reset' &&
|
|
101
|
+
options &&
|
|
102
|
+
!(options.resetOption === true)
|
|
103
|
+
? 'hide'
|
|
104
|
+
: ''}"
|
|
105
|
+
>
|
|
106
|
+
${options.type === 'checkbox' && optionData.value !== 'close' && optionData.value !== 'reset'
|
|
107
|
+
? html`
|
|
108
|
+
${await ToggleSwitch.Render({
|
|
109
|
+
id: `checkbox-role-${valueDisplay}`,
|
|
110
|
+
type: 'checkbox',
|
|
111
|
+
disabledOnClick: true,
|
|
112
|
+
checked: optionData.checked,
|
|
113
|
+
on: {
|
|
114
|
+
unchecked: () => {
|
|
115
|
+
optionData.checked = false;
|
|
116
|
+
delete DropDown.Tokens[id].oncheckvalues[valueDisplay];
|
|
117
|
+
},
|
|
118
|
+
checked: () => {
|
|
119
|
+
optionData.checked = true;
|
|
120
|
+
DropDown.Tokens[id].oncheckvalues[valueDisplay] = {};
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
})}
|
|
124
|
+
`
|
|
125
|
+
: ''}${optionData.display}
|
|
126
|
+
</div>
|
|
127
|
+
`;
|
|
128
|
+
}
|
|
129
|
+
return { render, index };
|
|
130
|
+
};
|
|
131
|
+
|
|
42
132
|
setTimeout(() => {
|
|
43
133
|
if (options.type === 'checkbox')
|
|
44
134
|
options.data.map((optionData) => {
|
|
@@ -53,92 +143,48 @@ const DropDown = {
|
|
|
53
143
|
s(`.dropdown-label-${id}`).onclick = switchOptionsPanel;
|
|
54
144
|
s(`.dropdown-current-${id}`).onclick = switchOptionsPanel;
|
|
55
145
|
if (options && options.open) switchOptionsPanel();
|
|
56
|
-
});
|
|
57
146
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
index++;
|
|
62
|
-
const i = index;
|
|
63
|
-
const valueDisplay = optionData.value.trim().replaceAll(' ', '-');
|
|
64
|
-
setTimeout(() => {
|
|
65
|
-
const onclick = (e) => {
|
|
66
|
-
if (options && options.lastSelectClass && s(`.dropdown-option-${this.Tokens[id].lastSelectValue}`)) {
|
|
67
|
-
s(`.dropdown-option-${this.Tokens[id].lastSelectValue}`).classList.remove(options.lastSelectClass);
|
|
68
|
-
}
|
|
69
|
-
this.Tokens[id].lastSelectValue = valueDisplay;
|
|
70
|
-
if (options && options.lastSelectClass && s(`.dropdown-option-${this.Tokens[id].lastSelectValue}`)) {
|
|
71
|
-
s(`.dropdown-option-${this.Tokens[id].lastSelectValue}`).classList.add(options.lastSelectClass);
|
|
72
|
-
}
|
|
147
|
+
const dropDownSearchHandle = async () => {
|
|
148
|
+
const _data = [];
|
|
149
|
+
if (!s(`.search-box-${id}`)) return;
|
|
73
150
|
|
|
151
|
+
let _value = s(`.search-box-${id}`).value.toLowerCase();
|
|
152
|
+
|
|
153
|
+
for (const objData of options.data) {
|
|
154
|
+
const objValue = objData.value.toLowerCase();
|
|
74
155
|
if (
|
|
75
|
-
|
|
76
|
-
(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (optionData.value !== 'close') {
|
|
83
|
-
if (optionData.value !== 'reset')
|
|
84
|
-
htmls(
|
|
85
|
-
`.dropdown-current-${id}`,
|
|
86
|
-
options.type === 'checkbox'
|
|
87
|
-
? options.data
|
|
88
|
-
.filter((d) => d.checked)
|
|
89
|
-
.map((v, i, a) => `${v.display}${i < a.length - 1 ? ',' : ''}`)
|
|
90
|
-
.join('')
|
|
91
|
-
: optionData.display,
|
|
92
|
-
);
|
|
93
|
-
else htmls(`.dropdown-current-${id}`, '');
|
|
94
|
-
|
|
95
|
-
this.Tokens[id].value =
|
|
96
|
-
options.type === 'checkbox' ? options.data.filter((d) => d.checked).map((d) => d.data) : optionData.data;
|
|
97
|
-
|
|
98
|
-
console.warn('current value dropdown id:' + id, this.Tokens[id].value);
|
|
99
|
-
|
|
100
|
-
s(`.${id}`).value = this.Tokens[id].value;
|
|
101
|
-
|
|
102
|
-
optionData.onClick(e);
|
|
156
|
+
objValue.match(_value) ||
|
|
157
|
+
(Translate.Data[objData.value] &&
|
|
158
|
+
Object.keys(Translate.Data[objData.value]).find((t) =>
|
|
159
|
+
Translate.Data[objData.value][t].toLowerCase().match(_value),
|
|
160
|
+
))
|
|
161
|
+
) {
|
|
162
|
+
_data.push(objData);
|
|
103
163
|
}
|
|
104
|
-
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (_data.length > 0) {
|
|
167
|
+
const { render, index } = await _render(_data);
|
|
168
|
+
htmls(`.${id}-render-container`, render);
|
|
169
|
+
} else {
|
|
170
|
+
// const { render, index } = await _render(options.data);
|
|
171
|
+
htmls(
|
|
172
|
+
`.${id}-render-container`,
|
|
173
|
+
html` <div class="inl" style="padding: 10px; color: red">
|
|
174
|
+
<i class="fas fa-exclamation-circle"></i> ${Translate.Render('no-result-found')}
|
|
175
|
+
</div>`,
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
s(`.search-box-${id}`).oninput = dropDownSearchHandle;
|
|
181
|
+
|
|
182
|
+
// Not use onblur generate bug on input toggle
|
|
183
|
+
// s(`.search-box-${id}`).onblur = dropDownSearchHandle;
|
|
184
|
+
});
|
|
105
185
|
|
|
106
|
-
|
|
107
|
-
this.Tokens[id].onClickEvents[`dropdown-option-${id}-${valueDisplay}`] = onclick;
|
|
108
|
-
this.Tokens[id].onClickEvents[`dropdown-option-${valueDisplay}`] = onclick;
|
|
186
|
+
const { render, index } = await _render(options.data);
|
|
109
187
|
|
|
110
|
-
s(`.dropdown-option-${id}-${i}`).onclick = onclick;
|
|
111
|
-
});
|
|
112
|
-
render += html`
|
|
113
|
-
<div
|
|
114
|
-
class="in dropdown-option dropdown-option-${id}-${i} dropdown-option-${id}-${valueDisplay} dropdown-option-${valueDisplay} ${valueDisplay ===
|
|
115
|
-
'reset' &&
|
|
116
|
-
options &&
|
|
117
|
-
!(options.resetOption === true)
|
|
118
|
-
? 'hide'
|
|
119
|
-
: ''}"
|
|
120
|
-
>
|
|
121
|
-
${options.type === 'checkbox' && optionData.value !== 'close' && optionData.value !== 'reset'
|
|
122
|
-
? html`
|
|
123
|
-
${await ToggleSwitch.Render({
|
|
124
|
-
id: `checkbox-role-${valueDisplay}`,
|
|
125
|
-
type: 'checkbox',
|
|
126
|
-
disabledOnClick: true,
|
|
127
|
-
checked: optionData.checked,
|
|
128
|
-
on: {
|
|
129
|
-
unchecked: () => {
|
|
130
|
-
optionData.checked = false;
|
|
131
|
-
},
|
|
132
|
-
checked: () => {
|
|
133
|
-
optionData.checked = true;
|
|
134
|
-
},
|
|
135
|
-
},
|
|
136
|
-
})}
|
|
137
|
-
`
|
|
138
|
-
: ''}${optionData.display}
|
|
139
|
-
</div>
|
|
140
|
-
`;
|
|
141
|
-
}
|
|
142
188
|
return html`
|
|
143
189
|
<div class="inl dropdown-container ${id} ${options?.containerClass ? options.containerClass : ''}">
|
|
144
190
|
<div class="in dropdown-option dropdown-label-${id} ${options && options.disableSelectLabel ? 'hide' : ''}">
|
|
@@ -158,7 +204,7 @@ const DropDown = {
|
|
|
158
204
|
placeholder: true,
|
|
159
205
|
})}
|
|
160
206
|
</div>
|
|
161
|
-
${render}
|
|
207
|
+
<div class="${id}-render-container">${render}</div>
|
|
162
208
|
</div>
|
|
163
209
|
</div>
|
|
164
210
|
`;
|
|
@@ -2,7 +2,7 @@ import { LoadingAnimation } from '../core/LoadingAnimation.js';
|
|
|
2
2
|
import { loggerFactory } from '../core/Logger.js';
|
|
3
3
|
import { cssEffect } from './Css.js';
|
|
4
4
|
import { NotificationManager } from './NotificationManager.js';
|
|
5
|
-
import { s } from './VanillaJs.js';
|
|
5
|
+
import { s, isActiveElement } from './VanillaJs.js';
|
|
6
6
|
|
|
7
7
|
const logger = loggerFactory(import.meta);
|
|
8
8
|
|
|
@@ -13,10 +13,37 @@ const EventsUI = {
|
|
|
13
13
|
let complete = true;
|
|
14
14
|
s(id)[type] = async function (e) {
|
|
15
15
|
if (options.clickEffect) cssEffect(id, e);
|
|
16
|
+
const noGate = !!options.noGate;
|
|
17
|
+
const noLoading = !!options.noLoading;
|
|
18
|
+
const playLoading = async () => {
|
|
19
|
+
if (!noLoading) {
|
|
20
|
+
await LoadingAnimation.spinner.play(loadingContainer ? loadingContainer : id);
|
|
21
|
+
if (options.context !== 'modal') await LoadingAnimation.bar.play(id);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const stopLoading = async () => {
|
|
25
|
+
if (!noLoading) {
|
|
26
|
+
if (options.context !== 'modal') LoadingAnimation.bar.stop(id);
|
|
27
|
+
await LoadingAnimation.spinner.stop(loadingContainer ? loadingContainer : id);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
if (noGate) {
|
|
31
|
+
try {
|
|
32
|
+
await playLoading();
|
|
33
|
+
await logic(e);
|
|
34
|
+
} catch (error) {
|
|
35
|
+
logger.error(error);
|
|
36
|
+
NotificationManager.Push({
|
|
37
|
+
status: 'error',
|
|
38
|
+
html: error?.message ? error.message : error ? error : 'Event error',
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
await stopLoading();
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
16
44
|
if (complete) {
|
|
17
45
|
complete = false;
|
|
18
|
-
await
|
|
19
|
-
if (options.context !== 'modal') await LoadingAnimation.bar.play(id);
|
|
46
|
+
await playLoading();
|
|
20
47
|
try {
|
|
21
48
|
await logic(e);
|
|
22
49
|
} catch (error) {
|
|
@@ -26,8 +53,7 @@ const EventsUI = {
|
|
|
26
53
|
html: error?.message ? error.message : error ? error : 'Event error',
|
|
27
54
|
});
|
|
28
55
|
}
|
|
29
|
-
|
|
30
|
-
await LoadingAnimation.spinner.stop(loadingContainer ? loadingContainer : id);
|
|
56
|
+
await stopLoading();
|
|
31
57
|
complete = true;
|
|
32
58
|
return;
|
|
33
59
|
}
|
|
@@ -41,6 +67,67 @@ const EventsUI = {
|
|
|
41
67
|
onChange: async function (id = '', logic = async function (e) {}, options = { loadingContainer: '' }) {
|
|
42
68
|
return await this.on(id, logic, 'onchange', options);
|
|
43
69
|
},
|
|
70
|
+
// Shared hover/focus controller extracted from Modal
|
|
71
|
+
HoverFocusController: function ({ inputSelector, panelSelector, activeElementId, onDismiss } = {}) {
|
|
72
|
+
let hoverPanel = false;
|
|
73
|
+
let hoverInput = false;
|
|
74
|
+
const isActive = () => (activeElementId ? isActiveElement(activeElementId) : false);
|
|
75
|
+
const shouldStay = () => isActive() || hoverPanel || hoverInput;
|
|
76
|
+
const bind = () => {
|
|
77
|
+
if (inputSelector && s(inputSelector)) {
|
|
78
|
+
s(inputSelector).onmouseover = () => {
|
|
79
|
+
hoverInput = true;
|
|
80
|
+
};
|
|
81
|
+
s(inputSelector).onmouseout = () => {
|
|
82
|
+
hoverInput = false;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
if (panelSelector && s(panelSelector)) {
|
|
86
|
+
s(panelSelector).onmouseover = () => {
|
|
87
|
+
hoverPanel = true;
|
|
88
|
+
};
|
|
89
|
+
s(panelSelector).onmouseout = () => {
|
|
90
|
+
hoverPanel = false;
|
|
91
|
+
if (activeElementId && s(`.${activeElementId}`) && s(`.${activeElementId}`).focus)
|
|
92
|
+
s(`.${activeElementId}`).focus();
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
const checkDismiss = () => {
|
|
97
|
+
if (!shouldStay()) onDismiss && onDismiss();
|
|
98
|
+
};
|
|
99
|
+
return { bind, shouldStay, checkDismiss };
|
|
100
|
+
},
|
|
101
|
+
// Generic click-outside binding to dismiss a panel/modal
|
|
102
|
+
// Options:
|
|
103
|
+
// - shouldStay: function -> boolean
|
|
104
|
+
// - onDismiss: function
|
|
105
|
+
// - anchors: array of selectors to treat as inside clicks (e.g., input button, panel container)
|
|
106
|
+
// - graceMs: number of ms after binding to ignore clicks (avoid closing on the same click that opened)
|
|
107
|
+
bindDismissOnDocumentClick: function ({ shouldStay, onDismiss, anchors = [], graceMs = 200 } = {}) {
|
|
108
|
+
if (typeof document === 'undefined') return () => {};
|
|
109
|
+
const bindAt = Date.now();
|
|
110
|
+
const isInsideAnchors = (target) => {
|
|
111
|
+
if (!target) return false;
|
|
112
|
+
for (const sel of anchors) {
|
|
113
|
+
const el = sel && typeof sel === 'string' ? s(sel) : null;
|
|
114
|
+
if (el && (el === target || el.contains(target))) return true;
|
|
115
|
+
}
|
|
116
|
+
return false;
|
|
117
|
+
};
|
|
118
|
+
const handler = (e) => {
|
|
119
|
+
// Ignore very quick clicks right after binding
|
|
120
|
+
if (Date.now() - bindAt < graceMs) return;
|
|
121
|
+
// If click is within anchors, ignore
|
|
122
|
+
if (isInsideAnchors(e?.target)) return;
|
|
123
|
+
// Defer to allow hover flags to update first
|
|
124
|
+
setTimeout(() => {
|
|
125
|
+
if (!shouldStay || !shouldStay()) onDismiss && onDismiss();
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
document.addEventListener('click', handler, true);
|
|
129
|
+
return () => document.removeEventListener('click', handler, true);
|
|
130
|
+
},
|
|
44
131
|
};
|
|
45
132
|
|
|
46
133
|
export { EventsUI };
|