@schukai/monster 4.142.3 → 4.142.4

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/package.json CHANGED
@@ -1 +1 @@
1
- {"author":"Volker Schukai","dependencies":{"@floating-ui/dom":"^1.7.6"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"type":"module","version":"4.142.3"}
1
+ {"author":"Volker Schukai","dependencies":{"@floating-ui/dom":"^1.7.6"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"type":"module","version":"4.142.4"}
@@ -2088,6 +2088,12 @@ function fetchIt(url, controlOptions) {
2088
2088
 
2089
2089
  queueMicrotask(() => {
2090
2090
  checkOptionState.call(this);
2091
+ if (
2092
+ getFilterMode.call(this) === FILTER_MODE_REMOTE &&
2093
+ this.getOption("options", []).length === 0
2094
+ ) {
2095
+ calcAndSetOptionsDimension.call(this);
2096
+ }
2091
2097
  setTotalText.call(this);
2092
2098
  updatePopper.call(this);
2093
2099
  setStatusOrRemoveBadges.call(this, "closed");
@@ -2509,14 +2515,22 @@ function scheduleSelectLayoutCycle(
2509
2515
  }
2510
2516
 
2511
2517
  function hasConfiguredOptionsWaitingForRender() {
2518
+ if (getFilterMode.call(this) === FILTER_MODE_REMOTE) {
2519
+ return false;
2520
+ }
2521
+
2512
2522
  const options = this.getOption("options");
2513
2523
 
2514
2524
  if (isArray(options)) {
2515
- return options.length > 0;
2525
+ if (options.length > 0) {
2526
+ return true;
2527
+ }
2528
+
2529
+ return getSlottedElements.call(this, "div").length > 0;
2516
2530
  }
2517
2531
 
2518
2532
  if (!isIterable(options) || isString(options)) {
2519
- return false;
2533
+ return getSlottedElements.call(this, "div").length > 0;
2520
2534
  }
2521
2535
 
2522
2536
  for (const option of options) {
@@ -2546,7 +2560,9 @@ function retryPendingOpenIntent() {
2546
2560
  }
2547
2561
 
2548
2562
  if (getOptionElements.call(this).length === 0) {
2549
- clearPendingOpenIntent.call(this);
2563
+ if (!hasConfiguredOptionsWaitingForRender.call(this)) {
2564
+ clearPendingOpenIntent.call(this);
2565
+ }
2550
2566
  return;
2551
2567
  }
2552
2568
 
@@ -3658,6 +3674,8 @@ function getSelectPopperPositionOptions() {
3658
3674
  popperOptions.placement = getDefaultSelectPopperPositionProfile().placement;
3659
3675
  }
3660
3676
 
3677
+ popperOptions.adaptiveSize = false;
3678
+
3661
3679
  if (
3662
3680
  resolveParentPopperContentBoundary(
3663
3681
  this[controlElementSymbol],
@@ -4969,6 +4987,8 @@ function show() {
4969
4987
  const options = getOptionElements.call(this);
4970
4988
  if (options.length === 0 && hasPopperFilterFlag === false) {
4971
4989
  if (hasConfiguredOptionsWaitingForRender.call(this)) {
4990
+ removeErrorAttribute(this, "No options available.");
4991
+ setStatusOrRemoveBadges.call(this, "loading");
4972
4992
  queuePendingOpenIntent.call(this);
4973
4993
  }
4974
4994
  return;
@@ -27,6 +27,12 @@ const jobs = new Map();
27
27
  let queueFrame = null;
28
28
  let queueTimeout = null;
29
29
  let flushing = false;
30
+ const OSCILLATION_HISTORY_LIMIT = 4;
31
+ const OSCILLATION_TIME_WINDOW_MS = 1000;
32
+ const OSCILLATION_SAFE_REASONS =
33
+ FLOATING_LAYOUT_REASON.POSITION |
34
+ FLOATING_LAYOUT_REASON.RESIZE |
35
+ FLOATING_LAYOUT_REASON.SETTLE;
30
36
 
31
37
  function enqueueFloatingLayout({
32
38
  popperElement,
@@ -105,6 +111,7 @@ function createJob(popperElement) {
105
111
  running: false,
106
112
  pending: false,
107
113
  cancelled: false,
114
+ layoutSignatures: [],
108
115
  promise,
109
116
  resolve,
110
117
  };
@@ -220,9 +227,67 @@ async function flushJob(job) {
220
227
  }
221
228
  } finally {
222
229
  job.running = false;
230
+ recordLayoutSignature(job);
231
+ if (job.pending && shouldSuppressOscillatingPendingLayout(job)) {
232
+ job.pending = false;
233
+ job.reasons = 0;
234
+ }
223
235
  if (!job.pending && job.reasons === 0) {
224
236
  job.resolve();
225
237
  jobs.delete(job.popperElement);
226
238
  }
227
239
  }
228
240
  }
241
+
242
+ function recordLayoutSignature(job) {
243
+ if (!(job?.popperElement instanceof HTMLElement)) {
244
+ return;
245
+ }
246
+
247
+ const rect = job.popperElement.getBoundingClientRect();
248
+ const signature = [
249
+ Math.round(rect.x),
250
+ Math.round(rect.y),
251
+ Math.round(rect.width),
252
+ Math.round(rect.height),
253
+ ].join("/");
254
+
255
+ job.layoutSignatures.push({
256
+ signature,
257
+ time: performanceNow(),
258
+ });
259
+ if (job.layoutSignatures.length > OSCILLATION_HISTORY_LIMIT) {
260
+ job.layoutSignatures.shift();
261
+ }
262
+ }
263
+
264
+ function shouldSuppressOscillatingPendingLayout(job) {
265
+ if ((job.reasons & ~OSCILLATION_SAFE_REASONS) !== 0) {
266
+ return false;
267
+ }
268
+
269
+ const signatures = job.layoutSignatures;
270
+ if (signatures.length < OSCILLATION_HISTORY_LIMIT) {
271
+ return false;
272
+ }
273
+
274
+ const [a, b, c, d] = signatures;
275
+ if (d.time - a.time > OSCILLATION_TIME_WINDOW_MS) {
276
+ return false;
277
+ }
278
+
279
+ return (
280
+ a.signature === c.signature &&
281
+ b.signature === d.signature &&
282
+ a.signature !== b.signature
283
+ );
284
+ }
285
+
286
+ function performanceNow() {
287
+ const globalObject = getGlobal();
288
+ if (globalObject?.performance?.now instanceof Function) {
289
+ return globalObject.performance.now();
290
+ }
291
+
292
+ return Date.now();
293
+ }
@@ -132,9 +132,12 @@ function syncFloatingPopover(
132
132
  config.detectOverflowOptions,
133
133
  popperElement,
134
134
  syncCycleId,
135
+ config.adaptiveSize,
135
136
  );
136
137
 
137
- resetAdaptiveFloatingElementSize(popperElement);
138
+ if (config.adaptiveSize !== false) {
139
+ resetAdaptiveFloatingElementSize(popperElement);
140
+ }
138
141
 
139
142
  if (
140
143
  arrowElement instanceof HTMLElement &&
@@ -143,7 +146,10 @@ function syncFloatingPopover(
143
146
  floatingMiddleware.push(arrow({ element: arrowElement }));
144
147
  }
145
148
 
146
- if (!config.middlewareTokens.includes("size")) {
149
+ if (
150
+ config.adaptiveSize !== false &&
151
+ !config.middlewareTokens.includes("size")
152
+ ) {
147
153
  floatingMiddleware.push(
148
154
  createAdaptiveSizeMiddleware(
149
155
  config.detectOverflowOptions,
@@ -206,6 +212,7 @@ function normalizePopperConfig(options, controlElement, popperElement) {
206
212
  placement: "top",
207
213
  engine: "floating",
208
214
  strategy: "absolute",
215
+ adaptiveSize: true,
209
216
  },
210
217
  options,
211
218
  );
@@ -247,6 +254,7 @@ function buildFloatingMiddleware(
247
254
  detectOverflowOptions,
248
255
  popperElement,
249
256
  syncCycleId = null,
257
+ adaptiveSize = true,
250
258
  ) {
251
259
  const result = [...middleware];
252
260
 
@@ -272,7 +280,7 @@ function buildFloatingMiddleware(
272
280
  case "shift":
273
281
  result[key] = shift(normalizeShiftOptions(kv, detectOverflowOptions));
274
282
  break;
275
- case "autoPlacement":
283
+ case "autoPlacement": {
276
284
  let defaultAllowedPlacements = ["top", "bottom", "left", "right"];
277
285
 
278
286
  const defPlacement = kv?.shift();
@@ -298,18 +306,22 @@ function buildFloatingMiddleware(
298
306
  }),
299
307
  );
300
308
  break;
309
+ }
301
310
  case "arrow":
302
311
  result[key] = null;
303
312
  break;
304
313
  case "size":
305
- result[key] = createAdaptiveSizeMiddleware(
306
- detectOverflowOptions,
307
- popperElement,
308
- syncCycleId,
309
- );
314
+ result[key] =
315
+ adaptiveSize === false
316
+ ? null
317
+ : createAdaptiveSizeMiddleware(
318
+ detectOverflowOptions,
319
+ popperElement,
320
+ syncCycleId,
321
+ );
310
322
  break;
311
323
  case "offset":
312
- result[key] = offset(parseInt(kv?.shift()) || 10);
324
+ result[key] = offset(parseInt(kv?.shift(), 10) || 10);
313
325
  break;
314
326
  case "hide":
315
327
  result[key] = hide(detectOverflowOptions);