underpost 2.8.843 → 2.8.844

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.
@@ -11,8 +11,6 @@ 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);
@@ -118,37 +116,7 @@ const Docs = {
118
116
  )}`;
119
117
  },
120
118
  },
121
- ].concat(
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
- ),
119
+ ],
152
120
  Tokens: {},
153
121
  Init: async function (options) {
154
122
  const { idModal } = options;
@@ -158,10 +126,6 @@ const Docs = {
158
126
  s(`.btn-docs-src`).classList.remove('main-btn-menu-active');
159
127
  s(`.btn-docs-api`).classList.remove('main-btn-menu-active');
160
128
  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
129
  };
166
130
  s(`.btn-docs-src`).onclick = async () => {
167
131
  setQueryPath({ path: 'docs', queryPath: 'src' });
@@ -195,16 +159,6 @@ const Docs = {
195
159
  location.href = docData.url();
196
160
  };
197
161
 
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
162
  listenQueryPathInstance({
209
163
  id: options.idModal,
210
164
  routeId: 'docs',
@@ -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 LoadingAnimation.spinner.play(loadingContainer ? loadingContainer : id);
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
- if (options.context !== 'modal') LoadingAnimation.bar.stop(id);
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 };