@schukai/monster 4.136.21 → 4.136.23

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.
Files changed (26) hide show
  1. package/package.json +1 -1
  2. package/source/components/content/stylesheet/camera-capture.mjs +1 -1
  3. package/source/components/content/stylesheet/copy.mjs +1 -1
  4. package/source/components/content/viewer/stylesheet/message.mjs +1 -1
  5. package/source/components/datatable/datatable.mjs +17 -15
  6. package/source/components/datatable/stylesheet/filter-controls-defaults.mjs +1 -1
  7. package/source/components/form/select.mjs +165 -82
  8. package/source/components/form/style/confirm-button.pcss +4 -1
  9. package/source/components/form/stylesheet/button-bar.mjs +1 -1
  10. package/source/components/form/stylesheet/confirm-button.mjs +10 -10
  11. package/source/components/form/stylesheet/context-error.mjs +1 -1
  12. package/source/components/form/stylesheet/context-help.mjs +1 -1
  13. package/source/components/form/stylesheet/digits.mjs +1 -1
  14. package/source/components/form/stylesheet/field-set.mjs +1 -1
  15. package/source/components/form/stylesheet/login.mjs +1 -1
  16. package/source/components/form/stylesheet/popper-button.mjs +13 -6
  17. package/source/components/form/stylesheet/select.mjs +13 -6
  18. package/source/components/form/util/floating-ui.mjs +1 -1
  19. package/source/components/layout/stylesheet/popper.mjs +13 -6
  20. package/source/components/style/common.css +3 -3
  21. package/source/components/style/floating-ui.css +75 -1
  22. package/source/components/stylesheet/common.mjs +1 -1
  23. package/source/components/stylesheet/floating-ui.mjs +13 -6
  24. package/test/cases/components/datatable/drag-scroll.mjs +49 -0
  25. package/test/cases/components/form/confirm-button.mjs +12 -0
  26. package/test/cases/components/form/select.mjs +131 -1
@@ -733,16 +733,16 @@ class Select extends CustomControl {
733
733
  this.setOption("total", null);
734
734
  resetPaginationState.call(this);
735
735
 
736
- resetErrorAttribute(this);
736
+ resetErrorAttribute(this);
737
737
 
738
- this[lazyLoadDoneSymbol] = false;
738
+ this[lazyLoadDoneSymbol] = false;
739
739
 
740
- scheduleSelectLayoutCycle.call(
741
- this,
742
- SELECT_LAYOUT_PRIORITY_CRITICAL,
743
- SELECT_LAYOUT_REASON_ALL,
744
- );
745
- })
740
+ scheduleSelectLayoutCycle.call(
741
+ this,
742
+ SELECT_LAYOUT_PRIORITY_CRITICAL,
743
+ SELECT_LAYOUT_REASON_ALL,
744
+ );
745
+ })
746
746
  .catch((e) => {
747
747
  addErrorAttribute(this, e);
748
748
  });
@@ -1188,7 +1188,10 @@ function getSelectionSyncState() {
1188
1188
  function hasSelectionLikeValue(candidate) {
1189
1189
  if (isArray(candidate)) {
1190
1190
  return candidate.some((entry) => {
1191
- if (isObject(entry) && Object.prototype.hasOwnProperty.call(entry, "value")) {
1191
+ if (
1192
+ isObject(entry) &&
1193
+ Object.prototype.hasOwnProperty.call(entry, "value")
1194
+ ) {
1192
1195
  return hasSelectionLikeValue.call(this, entry.value);
1193
1196
  }
1194
1197
 
@@ -1398,10 +1401,11 @@ function importOptionsIntern(data) {
1398
1401
  }
1399
1402
 
1400
1403
  for (const [value, label] of entries) {
1404
+ const optionLabel = resolveOptionLabel(label, value);
1401
1405
  let found = false;
1402
1406
  for (const option of options) {
1403
1407
  if (option.value === value) {
1404
- option.label = label;
1408
+ option.label = optionLabel;
1405
1409
  option.visibility = visibility;
1406
1410
  option.data = map.get(value);
1407
1411
  found = true;
@@ -1412,7 +1416,7 @@ function importOptionsIntern(data) {
1412
1416
  if (!found) {
1413
1417
  options.push({
1414
1418
  value,
1415
- label,
1419
+ label: optionLabel,
1416
1420
  visibility,
1417
1421
  data: map.get(value),
1418
1422
  });
@@ -1433,6 +1437,27 @@ function importOptionsIntern(data) {
1433
1437
  return this;
1434
1438
  }
1435
1439
 
1440
+ function resolveOptionLabel(label, value) {
1441
+ if (!isEmptyOptionLabel(label)) {
1442
+ return label;
1443
+ }
1444
+
1445
+ if (value === undefined || value === null) {
1446
+ return label;
1447
+ }
1448
+
1449
+ const fallback = `${value}`;
1450
+ return fallback.trim() === "" ? label : fallback;
1451
+ }
1452
+
1453
+ function isEmptyOptionLabel(label) {
1454
+ return (
1455
+ label === undefined ||
1456
+ label === null ||
1457
+ (isString(label) && label.trim() === "")
1458
+ );
1459
+ }
1460
+
1436
1461
  /**
1437
1462
  * @private
1438
1463
  * @returns {object}
@@ -1910,8 +1935,7 @@ function getTranslations() {
1910
1935
  */
1911
1936
  function lookupSelection() {
1912
1937
  const self = this;
1913
- const IntersectionObserverImplementation =
1914
- getGlobal().IntersectionObserver;
1938
+ const IntersectionObserverImplementation = getGlobal().IntersectionObserver;
1915
1939
 
1916
1940
  if (!(IntersectionObserverImplementation instanceof Function)) {
1917
1941
  runSelectionLookupWhenVisible(self);
@@ -1970,11 +1994,9 @@ function runSelectionLookupWhenVisible(self) {
1970
1994
  if (isEmptyLookupValue.call(self, value)) {
1971
1995
  continue;
1972
1996
  }
1973
- filterFromRemoteByValue
1974
- .call(self, url, { filter: value })
1975
- .catch((e) => {
1976
- addErrorAttribute(self, e);
1977
- });
1997
+ filterFromRemoteByValue.call(self, url, { filter: value }).catch((e) => {
1998
+ addErrorAttribute(self, e);
1999
+ });
1978
2000
  }
1979
2001
  }, 100);
1980
2002
  }
@@ -2222,19 +2244,13 @@ function disconnectResizeObserver() {
2222
2244
  cancelScheduledSelectLayoutCycle.call(this);
2223
2245
 
2224
2246
  const viewport = getGlobal().visualViewport;
2225
- if (
2226
- viewport &&
2227
- this[visualViewportResizeHandlerSymbol] instanceof Function
2228
- ) {
2247
+ if (viewport && this[visualViewportResizeHandlerSymbol] instanceof Function) {
2229
2248
  viewport.removeEventListener(
2230
2249
  "resize",
2231
2250
  this[visualViewportResizeHandlerSymbol],
2232
2251
  );
2233
2252
  }
2234
- if (
2235
- viewport &&
2236
- this[visualViewportScrollHandlerSymbol] instanceof Function
2237
- ) {
2253
+ if (viewport && this[visualViewportScrollHandlerSymbol] instanceof Function) {
2238
2254
  viewport.removeEventListener(
2239
2255
  "scroll",
2240
2256
  this[visualViewportScrollHandlerSymbol],
@@ -2275,7 +2291,7 @@ function scheduleResizeObserverPopperUpdate() {
2275
2291
  ? globalObject.requestAnimationFrame.bind(globalObject)
2276
2292
  : (callback) => {
2277
2293
  return globalObject.setTimeout(callback, 16);
2278
- };
2294
+ };
2279
2295
 
2280
2296
  this[resizeObserverFrameSymbol] = schedule(() => {
2281
2297
  delete this[resizeObserverFrameSymbol];
@@ -2360,7 +2376,8 @@ function flushScheduledSelectLayoutCycle() {
2360
2376
  const layoutReasons =
2361
2377
  this[layoutCyclePendingFlagsSymbol] || SELECT_LAYOUT_REASON_ALL;
2362
2378
  const layoutPriority =
2363
- this[layoutCyclePendingPrioritySymbol] || SELECT_LAYOUT_PRIORITY_INTERACTIVE;
2379
+ this[layoutCyclePendingPrioritySymbol] ||
2380
+ SELECT_LAYOUT_PRIORITY_INTERACTIVE;
2364
2381
 
2365
2382
  delete this[layoutCyclePendingFlagsSymbol];
2366
2383
  delete this[layoutCyclePendingPrioritySymbol];
@@ -2432,7 +2449,7 @@ function scheduleSelectLayoutCycle(
2432
2449
  ? globalObject.requestAnimationFrame.bind(globalObject)
2433
2450
  : (callback) => {
2434
2451
  return globalObject.setTimeout(callback, 16);
2435
- };
2452
+ };
2436
2453
 
2437
2454
  this[layoutCycleModeSymbol] = "frame";
2438
2455
  const token = (this[layoutCycleTokenSymbol] || 0) + 1;
@@ -3071,7 +3088,10 @@ function setSummaryAndControlText() {
3071
3088
  current === msg ||
3072
3089
  current === null
3073
3090
  ) {
3074
- if (selections.length === 0 && hasRequestedSelectionValue.call(this) !== true) {
3091
+ if (
3092
+ selections.length === 0 &&
3093
+ hasRequestedSelectionValue.call(this) !== true
3094
+ ) {
3075
3095
  this.setOption("messages.control", msg);
3076
3096
  } else {
3077
3097
  this.setOption("messages.control", "");
@@ -3176,10 +3196,19 @@ function calcAndSetOptionsDimension() {
3176
3196
  margin += parseInt(styles.getPropertyValue("margin-bottom"), 10);
3177
3197
 
3178
3198
  const geometry = getSelectPopperGeometry.call(this);
3199
+ const popperMaxHeight = Math.min(
3200
+ geometry.availableHeight,
3201
+ SELECT_MAX_POPPER_HEIGHT,
3202
+ );
3203
+ const listAvailableHeight = resolveSelectListAvailableHeight({
3204
+ popperElement: this[popperElementSymbol],
3205
+ contentElement: content,
3206
+ popperMaxHeight,
3207
+ });
3179
3208
  const listDimension = resolveSelectListDimension({
3180
3209
  visibleOptionHeights,
3181
3210
  maxVisibleOptions: max,
3182
- availableHeight: geometry.availableHeight,
3211
+ availableHeight: listAvailableHeight,
3183
3212
  padding,
3184
3213
  margin,
3185
3214
  });
@@ -3189,7 +3218,9 @@ function calcAndSetOptionsDimension() {
3189
3218
  });
3190
3219
 
3191
3220
  container.style.height =
3192
- listDimension.desiredHeight > 0 ? `${listDimension.desiredHeight}px` : "0px";
3221
+ listDimension.desiredHeight > 0
3222
+ ? `${listDimension.desiredHeight}px`
3223
+ : "0px";
3193
3224
  container.style.maxHeight =
3194
3225
  listDimension.maxHeight > 0 ? `${listDimension.maxHeight}px` : "0px";
3195
3226
  container.style.overflowY = listDimension.overflowY;
@@ -3219,7 +3250,7 @@ function calcAndSetOptionsDimension() {
3219
3250
  Math.min(widthConstraints.preferredWidth, widthConstraints.maxWidth),
3220
3251
  )}px`;
3221
3252
  this[popperElementSymbol].style.maxHeight = `${Math.ceil(
3222
- Math.min(geometry.availableHeight, SELECT_MAX_POPPER_HEIGHT),
3253
+ popperMaxHeight,
3223
3254
  )}px`;
3224
3255
  container.style.overflowX = "hidden";
3225
3256
 
@@ -3230,6 +3261,62 @@ function calcAndSetOptionsDimension() {
3230
3261
  }
3231
3262
  }
3232
3263
 
3264
+ function resolveSelectListAvailableHeight({
3265
+ popperElement,
3266
+ contentElement,
3267
+ popperMaxHeight,
3268
+ }) {
3269
+ if (!Number.isFinite(popperMaxHeight) || popperMaxHeight <= 0) {
3270
+ return popperMaxHeight;
3271
+ }
3272
+
3273
+ const reservedHeight = getSelectPopperReservedHeight(
3274
+ popperElement,
3275
+ contentElement,
3276
+ );
3277
+
3278
+ return Math.max(0, popperMaxHeight - reservedHeight);
3279
+ }
3280
+
3281
+ function getSelectPopperReservedHeight(popperElement, contentElement) {
3282
+ if (!(popperElement instanceof HTMLElement)) {
3283
+ return 0;
3284
+ }
3285
+
3286
+ const popperStyle = getGlobal().getComputedStyle(popperElement);
3287
+ let reservedHeight = 0;
3288
+ reservedHeight += readSelectBoxDimension(popperStyle.paddingTop);
3289
+ reservedHeight += readSelectBoxDimension(popperStyle.paddingBottom);
3290
+ reservedHeight += readSelectBoxDimension(popperStyle.borderTopWidth);
3291
+ reservedHeight += readSelectBoxDimension(popperStyle.borderBottomWidth);
3292
+
3293
+ for (const child of popperElement.children) {
3294
+ if (
3295
+ !(child instanceof HTMLElement) ||
3296
+ child === contentElement ||
3297
+ containsAttributeToken(child, "part", "content")
3298
+ ) {
3299
+ continue;
3300
+ }
3301
+
3302
+ const childStyle = getGlobal().getComputedStyle(child);
3303
+ if (childStyle.display === "none") {
3304
+ continue;
3305
+ }
3306
+
3307
+ reservedHeight += child.getBoundingClientRect().height;
3308
+ reservedHeight += readSelectBoxDimension(childStyle.marginTop);
3309
+ reservedHeight += readSelectBoxDimension(childStyle.marginBottom);
3310
+ }
3311
+
3312
+ return Math.max(0, reservedHeight);
3313
+ }
3314
+
3315
+ function readSelectBoxDimension(rawValue) {
3316
+ const value = Number.parseFloat(rawValue);
3317
+ return Number.isFinite(value) ? value : 0;
3318
+ }
3319
+
3233
3320
  function resolveSelectPopperPreferredWidth(controlWidth) {
3234
3321
  return Math.max(Math.ceil(controlWidth), SELECT_MIN_POPPER_WIDTH);
3235
3322
  }
@@ -3345,12 +3432,11 @@ function resolveSelectViewportMetrics({
3345
3432
  };
3346
3433
  }
3347
3434
 
3348
- function resolveSelectVisibleRect({
3349
- viewportMetrics,
3350
- boundaryRect = null,
3351
- }) {
3352
- const viewportLeft = (viewportMetrics?.left || 0) + (viewportMetrics?.padding || 0);
3353
- const viewportTop = (viewportMetrics?.top || 0) + (viewportMetrics?.padding || 0);
3435
+ function resolveSelectVisibleRect({ viewportMetrics, boundaryRect = null }) {
3436
+ const viewportLeft =
3437
+ (viewportMetrics?.left || 0) + (viewportMetrics?.padding || 0);
3438
+ const viewportTop =
3439
+ (viewportMetrics?.top || 0) + (viewportMetrics?.padding || 0);
3354
3440
  const viewportRight =
3355
3441
  (viewportMetrics?.left || 0) +
3356
3442
  (viewportMetrics?.width || 0) -
@@ -3398,14 +3484,8 @@ function getSelectPopperGeometry() {
3398
3484
  viewportMetrics: viewport,
3399
3485
  boundaryRect,
3400
3486
  });
3401
- const spaceAbove = Math.max(
3402
- 0,
3403
- controlRect.top - visibleRect.top,
3404
- );
3405
- const spaceBelow = Math.max(
3406
- 0,
3407
- visibleRect.bottom - controlRect.bottom,
3408
- );
3487
+ const spaceAbove = Math.max(0, controlRect.top - visibleRect.top);
3488
+ const spaceBelow = Math.max(0, visibleRect.bottom - controlRect.bottom);
3409
3489
  const availableHeight = Math.max(spaceAbove, spaceBelow, 0);
3410
3490
 
3411
3491
  return {
@@ -3431,15 +3511,15 @@ function getSelectPopperPositionOptions() {
3431
3511
  middleware.length === 0 ||
3432
3512
  usesLegacyDefaultMiddleware
3433
3513
  ) {
3434
- popperOptions.middleware = getDefaultSelectPopperPositionProfile().middleware;
3514
+ popperOptions.middleware =
3515
+ getDefaultSelectPopperPositionProfile().middleware;
3435
3516
  }
3436
3517
 
3437
3518
  if (
3438
3519
  !isString(popperOptions.placement) ||
3439
3520
  popperOptions.placement === "bottom"
3440
3521
  ) {
3441
- popperOptions.placement =
3442
- getDefaultSelectPopperPositionProfile().placement;
3522
+ popperOptions.placement = getDefaultSelectPopperPositionProfile().placement;
3443
3523
  }
3444
3524
 
3445
3525
  if (
@@ -3599,16 +3679,16 @@ function filterOptions() {
3599
3679
  }
3600
3680
  }
3601
3681
  })
3602
- .run()
3603
- .then(() => {
3604
- new Processing(100, () => {
3605
- scheduleSelectLayoutCycle.call(
3606
- this,
3607
- SELECT_LAYOUT_PRIORITY_CRITICAL,
3608
- SELECT_LAYOUT_REASON_PAGINATION | SELECT_LAYOUT_REASON_POSITION,
3609
- );
3610
- focusFilter.call(this);
3611
- })
3682
+ .run()
3683
+ .then(() => {
3684
+ new Processing(100, () => {
3685
+ scheduleSelectLayoutCycle.call(
3686
+ this,
3687
+ SELECT_LAYOUT_PRIORITY_CRITICAL,
3688
+ SELECT_LAYOUT_REASON_PAGINATION | SELECT_LAYOUT_REASON_POSITION,
3689
+ );
3690
+ focusFilter.call(this);
3691
+ })
3612
3692
  .run()
3613
3693
  .catch((e) => {
3614
3694
  addErrorAttribute(this, e);
@@ -4319,8 +4399,9 @@ function areOptionsAvailableAndInitInternal() {
4319
4399
  updated = true;
4320
4400
  }
4321
4401
 
4322
- if (option?.label === undefined) {
4323
- option.label = option.value;
4402
+ const normalizedLabel = resolveOptionLabel(option?.label, option?.value);
4403
+ if (option?.label !== normalizedLabel) {
4404
+ option.label = normalizedLabel;
4324
4405
  updated = true;
4325
4406
  }
4326
4407
  }
@@ -4760,8 +4841,10 @@ function show() {
4760
4841
  const shouldLoadRemoteOptions =
4761
4842
  getFilterMode.call(self) === FILTER_MODE_REMOTE &&
4762
4843
  getOptionElements.call(self).length === 0;
4763
- const shouldLoadDefaultOptions =
4764
- shouldUseDefaultOptionsUrl.call(self, getCurrentFilterValue.call(self));
4844
+ const shouldLoadDefaultOptions = shouldUseDefaultOptionsUrl.call(
4845
+ self,
4846
+ getCurrentFilterValue.call(self),
4847
+ );
4765
4848
 
4766
4849
  if (shouldLoadDefaultOptions) {
4767
4850
  setTimeout(() => {
@@ -4779,13 +4862,13 @@ function show() {
4779
4862
  } else {
4780
4863
  initTotal.call(self);
4781
4864
  }
4782
- focusFilter.call(this);
4783
- return performSelectLayoutCycle
4784
- .call(this, SELECT_LAYOUT_REASON_ALL)
4785
- .then(() => {
4786
- this[popperElementSymbol].style.removeProperty("visibility");
4787
- });
4788
- })
4865
+ focusFilter.call(this);
4866
+ return performSelectLayoutCycle
4867
+ .call(this, SELECT_LAYOUT_REASON_ALL)
4868
+ .then(() => {
4869
+ this[popperElementSymbol].style.removeProperty("visibility");
4870
+ });
4871
+ })
4789
4872
  .run()
4790
4873
  .catch((e) => {
4791
4874
  addErrorAttribute(this, e);
@@ -5212,17 +5295,17 @@ function initEventHandler() {
5212
5295
  }
5213
5296
  }
5214
5297
 
5215
- this[debounceOptionsMutationObserverSymbol] = new DeadMansSwitch(
5216
- 100,
5217
- () => {
5218
- scheduleSelectLayoutCycle.call(
5219
- self,
5220
- SELECT_LAYOUT_PRIORITY_INTERACTIVE,
5221
- SELECT_LAYOUT_REASON_ALL,
5222
- );
5223
- delete this[debounceOptionsMutationObserverSymbol];
5224
- },
5225
- );
5298
+ this[debounceOptionsMutationObserverSymbol] = new DeadMansSwitch(
5299
+ 100,
5300
+ () => {
5301
+ scheduleSelectLayoutCycle.call(
5302
+ self,
5303
+ SELECT_LAYOUT_PRIORITY_INTERACTIVE,
5304
+ SELECT_LAYOUT_REASON_ALL,
5305
+ );
5306
+ delete this[debounceOptionsMutationObserverSymbol];
5307
+ },
5308
+ );
5226
5309
  };
5227
5310
 
5228
5311
  const observer = new MutationObserver(callback);
@@ -9,7 +9,10 @@ div[data-monster-role="decision"] {
9
9
  width: max-content;
10
10
  align-items: center;
11
11
  justify-content: space-evenly;
12
- margin: 1rem 0 0.4rem 0;
12
+ gap: 0.75rem;
13
+ box-sizing: border-box;
14
+ margin: 1rem 0 0 0;
15
+ padding-bottom: 0.75rem;
13
16
  }
14
17
 
15
18
  div[data-monster-role="control"] {