@haiilo/catalyst 0.1.1 → 0.2.0

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 (76) hide show
  1. package/dist/catalyst/catalyst.css +1 -1410
  2. package/dist/catalyst/catalyst.esm.js +1 -126
  3. package/dist/catalyst/index.esm.js +0 -1
  4. package/dist/catalyst/p-4c438c2d.entry.js +11 -0
  5. package/dist/catalyst/p-73ee291d.js +1 -0
  6. package/dist/catalyst/p-94273abf.js +1 -0
  7. package/dist/cjs/app-globals-a3b3cf88.js +135 -0
  8. package/dist/cjs/cat-alert_7.cjs.entry.js +3115 -0
  9. package/dist/cjs/cat-icon-registry-eeff9b7d.js +1359 -0
  10. package/dist/cjs/catalyst.cjs.js +21 -0
  11. package/dist/cjs/index.cjs.js +2 -0
  12. package/dist/cjs/loader.cjs.js +23 -0
  13. package/dist/collection/collection-manifest.json +19 -0
  14. package/dist/collection/components/cat-alert/cat-alert.css +57 -0
  15. package/dist/collection/components/cat-alert/cat-alert.js +49 -0
  16. package/dist/collection/components/cat-badge/cat-badge.css +154 -0
  17. package/dist/collection/components/cat-badge/cat-badge.js +141 -0
  18. package/dist/collection/components/cat-button/cat-button.css +319 -0
  19. package/dist/collection/components/cat-button/cat-button.js +590 -0
  20. package/dist/collection/components/cat-icon/cat-icon-registry.js +41 -0
  21. package/dist/collection/components/cat-icon/cat-icon.css +50 -0
  22. package/dist/collection/components/cat-icon/cat-icon.js +89 -0
  23. package/dist/collection/components/cat-menu/cat-menu.css +33 -0
  24. package/dist/collection/components/cat-menu/cat-menu.js +185 -0
  25. package/dist/collection/components/cat-skeleton/cat-skeleton.css +177 -0
  26. package/dist/collection/components/cat-skeleton/cat-skeleton.js +130 -0
  27. package/dist/collection/components/cat-spinner/cat-spinner.css +63 -0
  28. package/dist/collection/components/cat-spinner/cat-spinner.js +64 -0
  29. package/dist/collection/index.cdn.js +21 -0
  30. package/dist/collection/index.js +1 -0
  31. package/dist/collection/init.js +8 -0
  32. package/dist/collection/utils/breakpoints.js +11 -0
  33. package/dist/collection/utils/media-matcher.js +54 -0
  34. package/dist/collection/utils/platform.js +49 -0
  35. package/dist/collection/utils/utils.js +3 -0
  36. package/dist/components/cat-alert.d.ts +11 -0
  37. package/dist/components/cat-alert.js +43 -0
  38. package/dist/components/cat-badge.d.ts +11 -0
  39. package/dist/components/cat-badge.js +67 -0
  40. package/dist/{catalyst/cat-button.entry.js → components/cat-button.js} +68 -44
  41. package/dist/{catalyst/cat-icon-registry-59da2e37.js → components/cat-icon-registry.js} +0 -0
  42. package/dist/components/cat-icon.js +6 -0
  43. package/dist/components/cat-icon2.js +47 -0
  44. package/dist/{catalyst/cat-menu.entry.js → components/cat-menu.js} +71 -650
  45. package/dist/components/cat-skeleton.d.ts +11 -0
  46. package/dist/components/cat-skeleton.js +77 -0
  47. package/dist/components/cat-spinner.js +6 -0
  48. package/dist/{catalyst/cat-spinner.entry.js → components/cat-spinner2.js} +25 -6
  49. package/dist/components/index.js +134 -0
  50. package/dist/esm/app-globals-fc0806a7.js +133 -0
  51. package/dist/esm/cat-alert_7.entry.js +3105 -0
  52. package/dist/esm/cat-icon-registry-d877de13.js +1331 -0
  53. package/dist/esm/catalyst.js +19 -0
  54. package/dist/esm/index.js +1 -0
  55. package/dist/esm/loader.js +19 -0
  56. package/dist/esm/polyfills/core-js.js +11 -0
  57. package/dist/esm/polyfills/css-shim.js +1 -0
  58. package/dist/esm/polyfills/dom.js +79 -0
  59. package/dist/esm/polyfills/es5-html-element.js +1 -0
  60. package/dist/esm/polyfills/index.js +34 -0
  61. package/dist/esm/polyfills/system.js +6 -0
  62. package/dist/index.cjs.js +1 -0
  63. package/dist/index.js +1 -0
  64. package/dist/types/components/cat-alert/cat-alert.d.ts +12 -0
  65. package/dist/types/components/cat-badge/cat-badge.d.ts +28 -0
  66. package/dist/types/components/cat-button/cat-button.d.ts +5 -0
  67. package/dist/types/components/cat-menu/cat-menu.d.ts +13 -4
  68. package/dist/types/components/cat-skeleton/cat-skeleton.d.ts +28 -0
  69. package/dist/types/components.d.ts +129 -0
  70. package/package.json +1 -1
  71. package/dist/catalyst/app-globals-f83c9e4a.js +0 -722
  72. package/dist/catalyst/cat-icon.entry.js +0 -27
  73. package/dist/catalyst/css-shim-20dbffa5.js +0 -4
  74. package/dist/catalyst/dom-c5ed0ba5.js +0 -73
  75. package/dist/catalyst/index-45406d3b.js +0 -3031
  76. package/dist/catalyst/shadow-css-8c625855.js +0 -388
@@ -1,4 +1,4 @@
1
- import { r as registerInstance, e as createEvent, h, f as Host, g as getElement } from './index-45406d3b.js';
1
+ import { HTMLElement, createEvent, h, Host, proxyCustomElement } from '@stencil/core/internal/client';
2
2
 
3
3
  function getSide(placement) {
4
4
  return placement.split('-')[0];
@@ -96,21 +96,6 @@ const computePosition$1 = async (reference, floating, config) => {
96
96
  } = config;
97
97
  const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
98
98
 
99
- if ("development" !== "production") {
100
- if (platform == null) {
101
- console.error(['Floating UI: `platform` property was not passed to config. If you', 'want to use Floating UI on the web, install @floating-ui/dom', 'instead of the /core package. Otherwise, you can create your own', '`platform`: https://floating-ui.com/docs/platform'].join(' '));
102
- }
103
-
104
- if (middleware.filter(_ref => {
105
- let {
106
- name
107
- } = _ref;
108
- return name === 'autoPlacement' || name === 'flip';
109
- }).length > 1) {
110
- throw new Error(['Floating UI: duplicate `flip` and/or `autoPlacement`', 'middleware detected. This will lead to an infinite loop. Ensure only', 'one of either has been passed to the `middleware` array.'].join(' '));
111
- }
112
- }
113
-
114
99
  let rects = await platform.getElementRects({
115
100
  reference,
116
101
  floating,
@@ -122,16 +107,8 @@ const computePosition$1 = async (reference, floating, config) => {
122
107
  } = computeCoordsFromPlacement(rects, placement, rtl);
123
108
  let statefulPlacement = placement;
124
109
  let middlewareData = {};
125
- let _debug_loop_count_ = 0;
126
110
 
127
111
  for (let i = 0; i < middleware.length; i++) {
128
- if ("development" !== "production") {
129
- _debug_loop_count_++;
130
-
131
- if (_debug_loop_count_ > 100) {
132
- throw new Error(['Floating UI: The middleware lifecycle appears to be', 'running in an infinite loop. This is usually caused by a `reset`', 'continually being returned without a break condition.'].join(' '));
133
- }
134
- }
135
112
 
136
113
  const {
137
114
  name,
@@ -283,75 +260,6 @@ async function detectOverflow(middlewareArguments, options) {
283
260
  };
284
261
  }
285
262
 
286
- const min$1 = Math.min;
287
- const max$1 = Math.max;
288
-
289
- function within(min$1$1, value, max$1$1) {
290
- return max$1(min$1$1, min$1(value, max$1$1));
291
- }
292
-
293
- /**
294
- * Positions an inner element of the floating element such that it is centered
295
- * to the reference element.
296
- * @see https://floating-ui.com/docs/arrow
297
- */
298
- const arrow = options => ({
299
- name: 'arrow',
300
- options,
301
-
302
- async fn(middlewareArguments) {
303
- // Since `element` is required, we don't Partial<> the type
304
- const {
305
- element,
306
- padding = 0
307
- } = options != null ? options : {};
308
- const {
309
- x,
310
- y,
311
- placement,
312
- rects,
313
- platform
314
- } = middlewareArguments;
315
-
316
- if (element == null) {
317
- if ("development" !== "production") {
318
- console.warn('Floating UI: No `element` was passed to the `arrow` middleware.');
319
- }
320
-
321
- return {};
322
- }
323
-
324
- const paddingObject = getSideObjectFromPadding(padding);
325
- const coords = {
326
- x,
327
- y
328
- };
329
- const axis = getMainAxisFromPlacement(placement);
330
- const length = getLengthFromAxis(axis);
331
- const arrowDimensions = await platform.getDimensions(element);
332
- const minProp = axis === 'y' ? 'top' : 'left';
333
- const maxProp = axis === 'y' ? 'bottom' : 'right';
334
- const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
335
- const startDiff = coords[axis] - rects.reference[axis];
336
- const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
337
- const clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
338
- const centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the floating element if the center
339
- // point is outside of the floating element's bounds
340
-
341
- const min = paddingObject[minProp];
342
- const max = clientSize - arrowDimensions[length] - paddingObject[maxProp];
343
- const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
344
- const offset = within(min, center, max);
345
- return {
346
- data: {
347
- [axis]: offset,
348
- centerOffset: center - offset
349
- }
350
- };
351
- }
352
-
353
- });
354
-
355
263
  const hash$1 = {
356
264
  left: 'right',
357
265
  right: 'left',
@@ -390,121 +298,6 @@ function getOppositeAlignmentPlacement(placement) {
390
298
  return placement.replace(/start|end/g, matched => hash[matched]);
391
299
  }
392
300
 
393
- const sides = ['top', 'right', 'bottom', 'left'];
394
- const allPlacements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + "-start", side + "-end"), []);
395
-
396
- function getPlacementList(alignment, autoAlignment, allowedPlacements) {
397
- const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment(placement) !== alignment)] : allowedPlacements.filter(placement => getSide(placement) === placement);
398
- return allowedPlacementsSortedByAlignment.filter(placement => {
399
- if (alignment) {
400
- return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);
401
- }
402
-
403
- return true;
404
- });
405
- }
406
-
407
- /**
408
- * Automatically chooses the `placement` which has the most space available.
409
- * @see https://floating-ui.com/docs/autoPlacement
410
- */
411
- const autoPlacement = function (options) {
412
- if (options === void 0) {
413
- options = {};
414
- }
415
-
416
- return {
417
- name: 'autoPlacement',
418
- options,
419
-
420
- async fn(middlewareArguments) {
421
- var _middlewareData$autoP, _middlewareData$autoP2, _middlewareData$autoP3, _middlewareData$autoP4, _placementsSortedByLe;
422
-
423
- const {
424
- x,
425
- y,
426
- rects,
427
- middlewareData,
428
- placement,
429
- platform,
430
- elements
431
- } = middlewareArguments;
432
- const {
433
- alignment = null,
434
- allowedPlacements = allPlacements,
435
- autoAlignment = true,
436
- ...detectOverflowOptions
437
- } = options;
438
- const placements = getPlacementList(alignment, autoAlignment, allowedPlacements);
439
- const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
440
- const currentIndex = (_middlewareData$autoP = (_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.index) != null ? _middlewareData$autoP : 0;
441
- const currentPlacement = placements[currentIndex];
442
-
443
- if (currentPlacement == null) {
444
- return {};
445
- }
446
-
447
- const {
448
- main,
449
- cross
450
- } = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))); // Make `computeCoords` start from the right place
451
-
452
- if (placement !== currentPlacement) {
453
- return {
454
- x,
455
- y,
456
- reset: {
457
- placement: placements[0]
458
- }
459
- };
460
- }
461
-
462
- const currentOverflows = [overflow[getSide(currentPlacement)], overflow[main], overflow[cross]];
463
- const allOverflows = [...((_middlewareData$autoP3 = (_middlewareData$autoP4 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP4.overflows) != null ? _middlewareData$autoP3 : []), {
464
- placement: currentPlacement,
465
- overflows: currentOverflows
466
- }];
467
- const nextPlacement = placements[currentIndex + 1]; // There are more placements to check
468
-
469
- if (nextPlacement) {
470
- return {
471
- data: {
472
- index: currentIndex + 1,
473
- overflows: allOverflows
474
- },
475
- reset: {
476
- placement: nextPlacement
477
- }
478
- };
479
- }
480
-
481
- const placementsSortedByLeastOverflow = allOverflows.slice().sort((a, b) => a.overflows[0] - b.overflows[0]);
482
- const placementThatFitsOnAllSides = (_placementsSortedByLe = placementsSortedByLeastOverflow.find(_ref => {
483
- let {
484
- overflows
485
- } = _ref;
486
- return overflows.every(overflow => overflow <= 0);
487
- })) == null ? void 0 : _placementsSortedByLe.placement;
488
- const resetPlacement = placementThatFitsOnAllSides != null ? placementThatFitsOnAllSides : placementsSortedByLeastOverflow[0].placement;
489
-
490
- if (resetPlacement !== placement) {
491
- return {
492
- data: {
493
- index: currentIndex + 1,
494
- overflows: allOverflows
495
- },
496
- reset: {
497
- placement: resetPlacement
498
- }
499
- };
500
- }
501
-
502
- return {};
503
- }
504
-
505
- };
506
- };
507
-
508
301
  function getExpandedPlacements(placement) {
509
302
  const oppositePlacement = getOppositePlacement(placement);
510
303
  return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
@@ -623,76 +416,6 @@ const flip = function (options) {
623
416
  };
624
417
  };
625
418
 
626
- function getSideOffsets(overflow, rect) {
627
- return {
628
- top: overflow.top - rect.height,
629
- right: overflow.right - rect.width,
630
- bottom: overflow.bottom - rect.height,
631
- left: overflow.left - rect.width
632
- };
633
- }
634
-
635
- function isAnySideFullyClipped(overflow) {
636
- return sides.some(side => overflow[side] >= 0);
637
- }
638
-
639
- /**
640
- * Provides data to hide the floating element in applicable situations, such as
641
- * when it is not in the same clipping context as the reference element.
642
- * @see https://floating-ui.com/docs/hide
643
- */
644
- const hide = function (_temp) {
645
- let {
646
- strategy = 'referenceHidden',
647
- ...detectOverflowOptions
648
- } = _temp === void 0 ? {} : _temp;
649
- return {
650
- name: 'hide',
651
-
652
- async fn(middlewareArguments) {
653
- const {
654
- rects
655
- } = middlewareArguments;
656
-
657
- switch (strategy) {
658
- case 'referenceHidden':
659
- {
660
- const overflow = await detectOverflow(middlewareArguments, { ...detectOverflowOptions,
661
- elementContext: 'reference'
662
- });
663
- const offsets = getSideOffsets(overflow, rects.reference);
664
- return {
665
- data: {
666
- referenceHiddenOffsets: offsets,
667
- referenceHidden: isAnySideFullyClipped(offsets)
668
- }
669
- };
670
- }
671
-
672
- case 'escaped':
673
- {
674
- const overflow = await detectOverflow(middlewareArguments, { ...detectOverflowOptions,
675
- altBoundary: true
676
- });
677
- const offsets = getSideOffsets(overflow, rects.floating);
678
- return {
679
- data: {
680
- escapedOffsets: offsets,
681
- escaped: isAnySideFullyClipped(offsets)
682
- }
683
- };
684
- }
685
-
686
- default:
687
- {
688
- return {};
689
- }
690
- }
691
- }
692
-
693
- };
694
- };
695
-
696
419
  function convertValueToCoords(placement, rects, value, rtl) {
697
420
  if (rtl === void 0) {
698
421
  rtl = false;
@@ -769,356 +492,6 @@ const offset = function (value) {
769
492
  };
770
493
  };
771
494
 
772
- function getCrossAxis(axis) {
773
- return axis === 'x' ? 'y' : 'x';
774
- }
775
-
776
- /**
777
- * Shifts the floating element in order to keep it in view when it will overflow
778
- * a clipping boundary.
779
- * @see https://floating-ui.com/docs/shift
780
- */
781
- const shift = function (options) {
782
- if (options === void 0) {
783
- options = {};
784
- }
785
-
786
- return {
787
- name: 'shift',
788
- options,
789
-
790
- async fn(middlewareArguments) {
791
- const {
792
- x,
793
- y,
794
- placement
795
- } = middlewareArguments;
796
- const {
797
- mainAxis: checkMainAxis = true,
798
- crossAxis: checkCrossAxis = false,
799
- limiter = {
800
- fn: _ref => {
801
- let {
802
- x,
803
- y
804
- } = _ref;
805
- return {
806
- x,
807
- y
808
- };
809
- }
810
- },
811
- ...detectOverflowOptions
812
- } = options;
813
- const coords = {
814
- x,
815
- y
816
- };
817
- const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
818
- const mainAxis = getMainAxisFromPlacement(getSide(placement));
819
- const crossAxis = getCrossAxis(mainAxis);
820
- let mainAxisCoord = coords[mainAxis];
821
- let crossAxisCoord = coords[crossAxis];
822
-
823
- if (checkMainAxis) {
824
- const minSide = mainAxis === 'y' ? 'top' : 'left';
825
- const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
826
- const min = mainAxisCoord + overflow[minSide];
827
- const max = mainAxisCoord - overflow[maxSide];
828
- mainAxisCoord = within(min, mainAxisCoord, max);
829
- }
830
-
831
- if (checkCrossAxis) {
832
- const minSide = crossAxis === 'y' ? 'top' : 'left';
833
- const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
834
- const min = crossAxisCoord + overflow[minSide];
835
- const max = crossAxisCoord - overflow[maxSide];
836
- crossAxisCoord = within(min, crossAxisCoord, max);
837
- }
838
-
839
- const limitedCoords = limiter.fn({ ...middlewareArguments,
840
- [mainAxis]: mainAxisCoord,
841
- [crossAxis]: crossAxisCoord
842
- });
843
- return { ...limitedCoords,
844
- data: {
845
- x: limitedCoords.x - x,
846
- y: limitedCoords.y - y
847
- }
848
- };
849
- }
850
-
851
- };
852
- };
853
-
854
- /**
855
- * Built-in `limiter` that will stop `shift()` at a certain point.
856
- */
857
- const limitShift = function (options) {
858
- if (options === void 0) {
859
- options = {};
860
- }
861
-
862
- return {
863
- options,
864
-
865
- fn(middlewareArguments) {
866
- const {
867
- x,
868
- y,
869
- placement,
870
- rects,
871
- middlewareData
872
- } = middlewareArguments;
873
- const {
874
- offset = 0,
875
- mainAxis: checkMainAxis = true,
876
- crossAxis: checkCrossAxis = true
877
- } = options;
878
- const coords = {
879
- x,
880
- y
881
- };
882
- const mainAxis = getMainAxisFromPlacement(placement);
883
- const crossAxis = getCrossAxis(mainAxis);
884
- let mainAxisCoord = coords[mainAxis];
885
- let crossAxisCoord = coords[crossAxis];
886
- const rawOffset = typeof offset === 'function' ? offset({ ...rects,
887
- placement
888
- }) : offset;
889
- const computedOffset = typeof rawOffset === 'number' ? {
890
- mainAxis: rawOffset,
891
- crossAxis: 0
892
- } : {
893
- mainAxis: 0,
894
- crossAxis: 0,
895
- ...rawOffset
896
- };
897
-
898
- if (checkMainAxis) {
899
- const len = mainAxis === 'y' ? 'height' : 'width';
900
- const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
901
- const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
902
-
903
- if (mainAxisCoord < limitMin) {
904
- mainAxisCoord = limitMin;
905
- } else if (mainAxisCoord > limitMax) {
906
- mainAxisCoord = limitMax;
907
- }
908
- }
909
-
910
- if (checkCrossAxis) {
911
- var _middlewareData$offse, _middlewareData$offse2, _middlewareData$offse3, _middlewareData$offse4;
912
-
913
- const len = mainAxis === 'y' ? 'width' : 'height';
914
- const isOriginSide = ['top', 'left'].includes(getSide(placement));
915
- const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? (_middlewareData$offse = (_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) != null ? _middlewareData$offse : 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);
916
- const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : (_middlewareData$offse3 = (_middlewareData$offse4 = middlewareData.offset) == null ? void 0 : _middlewareData$offse4[crossAxis]) != null ? _middlewareData$offse3 : 0) - (isOriginSide ? computedOffset.crossAxis : 0);
917
-
918
- if (crossAxisCoord < limitMin) {
919
- crossAxisCoord = limitMin;
920
- } else if (crossAxisCoord > limitMax) {
921
- crossAxisCoord = limitMax;
922
- }
923
- }
924
-
925
- return {
926
- [mainAxis]: mainAxisCoord,
927
- [crossAxis]: crossAxisCoord
928
- };
929
- }
930
-
931
- };
932
- };
933
-
934
- /**
935
- * Provides data to change the size of the floating element. For instance,
936
- * prevent it from overflowing its clipping boundary or match the width of the
937
- * reference element.
938
- * @see https://floating-ui.com/docs/size
939
- */
940
- const size = function (options) {
941
- if (options === void 0) {
942
- options = {};
943
- }
944
-
945
- return {
946
- name: 'size',
947
- options,
948
-
949
- async fn(middlewareArguments) {
950
- const {
951
- placement,
952
- rects,
953
- platform,
954
- elements
955
- } = middlewareArguments;
956
- const {
957
- apply,
958
- ...detectOverflowOptions
959
- } = options;
960
- const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
961
- const side = getSide(placement);
962
- const alignment = getAlignment(placement);
963
- let heightSide;
964
- let widthSide;
965
-
966
- if (side === 'top' || side === 'bottom') {
967
- heightSide = side;
968
- widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right';
969
- } else {
970
- widthSide = side;
971
- heightSide = alignment === 'end' ? 'top' : 'bottom';
972
- }
973
-
974
- const xMin = max$1(overflow.left, 0);
975
- const xMax = max$1(overflow.right, 0);
976
- const yMin = max$1(overflow.top, 0);
977
- const yMax = max$1(overflow.bottom, 0);
978
- const dimensions = {
979
- height: rects.floating.height - (['left', 'right'].includes(placement) ? 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max$1(overflow.top, overflow.bottom)) : overflow[heightSide]),
980
- width: rects.floating.width - (['top', 'bottom'].includes(placement) ? 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max$1(overflow.left, overflow.right)) : overflow[widthSide])
981
- };
982
- const prevDimensions = await platform.getDimensions(elements.floating);
983
- apply == null ? void 0 : apply({ ...dimensions,
984
- ...rects
985
- });
986
- const nextDimensions = await platform.getDimensions(elements.floating);
987
-
988
- if (prevDimensions.width !== nextDimensions.width || prevDimensions.height !== nextDimensions.height) {
989
- return {
990
- reset: {
991
- rects: true
992
- }
993
- };
994
- }
995
-
996
- return {};
997
- }
998
-
999
- };
1000
- };
1001
-
1002
- /**
1003
- * Provides improved positioning for inline reference elements that can span
1004
- * over multiple lines, such as hyperlinks or range selections.
1005
- * @see https://floating-ui.com/docs/inline
1006
- */
1007
- const inline = function (options) {
1008
- if (options === void 0) {
1009
- options = {};
1010
- }
1011
-
1012
- return {
1013
- name: 'inline',
1014
- options,
1015
-
1016
- async fn(middlewareArguments) {
1017
- var _await$platform$getCl;
1018
-
1019
- const {
1020
- placement,
1021
- elements,
1022
- rects,
1023
- platform,
1024
- strategy
1025
- } = middlewareArguments; // A MouseEvent's client{X,Y} coords can be up to 2 pixels off a
1026
- // ClientRect's bounds, despite the event listener being triggered. A
1027
- // padding of 2 seems to handle this issue.
1028
-
1029
- const {
1030
- padding = 2,
1031
- x,
1032
- y
1033
- } = options;
1034
- const fallback = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
1035
- rect: rects.reference,
1036
- offsetParent: await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating)),
1037
- strategy
1038
- }) : rects.reference);
1039
- const clientRects = (_await$platform$getCl = await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) != null ? _await$platform$getCl : [];
1040
- const paddingObject = getSideObjectFromPadding(padding);
1041
-
1042
- function getBoundingClientRect() {
1043
- // There are two rects and they are disjoined
1044
- if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {
1045
- var _clientRects$find;
1046
-
1047
- // Find the first rect in which the point is fully inside
1048
- return (_clientRects$find = clientRects.find(rect => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom)) != null ? _clientRects$find : fallback;
1049
- } // There are 2 or more connected rects
1050
-
1051
-
1052
- if (clientRects.length >= 2) {
1053
- if (getMainAxisFromPlacement(placement) === 'x') {
1054
- const firstRect = clientRects[0];
1055
- const lastRect = clientRects[clientRects.length - 1];
1056
- const isTop = getSide(placement) === 'top';
1057
- const top = firstRect.top;
1058
- const bottom = lastRect.bottom;
1059
- const left = isTop ? firstRect.left : lastRect.left;
1060
- const right = isTop ? firstRect.right : lastRect.right;
1061
- const width = right - left;
1062
- const height = bottom - top;
1063
- return {
1064
- top,
1065
- bottom,
1066
- left,
1067
- right,
1068
- width,
1069
- height,
1070
- x: left,
1071
- y: top
1072
- };
1073
- }
1074
-
1075
- const isLeftSide = getSide(placement) === 'left';
1076
- const maxRight = max$1(...clientRects.map(rect => rect.right));
1077
- const minLeft = min$1(...clientRects.map(rect => rect.left));
1078
- const measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight);
1079
- const top = measureRects[0].top;
1080
- const bottom = measureRects[measureRects.length - 1].bottom;
1081
- const left = minLeft;
1082
- const right = maxRight;
1083
- const width = right - left;
1084
- const height = bottom - top;
1085
- return {
1086
- top,
1087
- bottom,
1088
- left,
1089
- right,
1090
- width,
1091
- height,
1092
- x: left,
1093
- y: top
1094
- };
1095
- }
1096
-
1097
- return fallback;
1098
- }
1099
-
1100
- const resetRects = await platform.getElementRects({
1101
- reference: {
1102
- getBoundingClientRect
1103
- },
1104
- floating: elements.floating,
1105
- strategy
1106
- });
1107
-
1108
- if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) {
1109
- return {
1110
- reset: {
1111
- rects: resetRects
1112
- }
1113
- };
1114
- }
1115
-
1116
- return {};
1117
- }
1118
-
1119
- };
1120
- };
1121
-
1122
495
  function isWindow(value) {
1123
496
  return (value == null ? void 0 : value.toString()) === '[object Window]';
1124
497
  }
@@ -2875,45 +2248,70 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
2875
2248
  return trap;
2876
2249
  };
2877
2250
 
2878
- const catMenuCss = ".content{position:absolute;background:white;display:none;overflow:auto;-webkit-overflow-scrolling:touch;min-width:8rem;max-width:16rem;min-height:2rem;max-height:calc(100vh - 48px);box-shadow:0 1px 4px 0 rgba(16, 29, 48, 0.2);border-radius:0.25rem}";
2251
+ const catMenuCss = ":host{display:inline-block}:host([hidden]){display:none}.content{padding-top:0.5rem;padding-bottom:0.5rem;position:absolute;background:white;display:none;overflow:auto;-webkit-overflow-scrolling:touch;min-width:8rem;max-width:16rem;min-height:2rem;max-height:calc(100vh - 48px);box-shadow:0 1px 4px 0 rgba(16, 29, 48, 0.2);border-radius:0.25rem}";
2879
2252
 
2880
- let CatMenu = class {
2881
- constructor(hostRef) {
2882
- registerInstance(this, hostRef);
2253
+ let nextUniqueId = 0;
2254
+ let CatMenu$1 = class extends HTMLElement {
2255
+ constructor() {
2256
+ super();
2257
+ this.__registerHost();
2258
+ this.__attachShadow();
2883
2259
  this.catOpen = createEvent(this, "catOpen", 7);
2884
2260
  this.catClose = createEvent(this, "catClose", 7);
2885
- this.trigger = null;
2886
- this.content = null;
2261
+ this.id = nextUniqueId++;
2262
+ /**
2263
+ * The placement of the menu.
2264
+ */
2887
2265
  this.placement = 'bottom-start';
2888
2266
  }
2889
- componentDidLoad() {
2267
+ clickHandler(event) {
2890
2268
  var _a;
2891
- this.trigger = this.host.querySelector('[slot="trigger"]');
2892
- this.content = this.host.querySelector('.content');
2269
+ // hide menu on button click
2270
+ if (this.content && event.composedPath().includes(this.content)) {
2271
+ (_a = this.trap) === null || _a === void 0 ? void 0 : _a.deactivate();
2272
+ this.hide();
2273
+ }
2274
+ }
2275
+ componentDidLoad() {
2276
+ var _a, _b, _c, _d, _e;
2277
+ this.trigger = this.firstTabbable(this.triggerSlot);
2278
+ (_a = this.trigger) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-haspopup', 'true');
2279
+ (_b = this.trigger) === null || _b === void 0 ? void 0 : _b.setAttribute('aria-expanded', 'false');
2280
+ (_c = this.trigger) === null || _c === void 0 ? void 0 : _c.setAttribute('aria-controls', this.contentId);
2281
+ (_d = this.content) === null || _d === void 0 ? void 0 : _d.setAttribute('id', this.contentId);
2893
2282
  if (this.trigger && this.content) {
2894
- (_a = this.trigger) === null || _a === void 0 ? void 0 : _a.addEventListener('click', () => this.show());
2283
+ (_e = this.trigger) === null || _e === void 0 ? void 0 : _e.addEventListener('click', () => this.show());
2895
2284
  autoUpdate(this.trigger, this.content, () => this.update());
2896
2285
  }
2897
- document.addEventListener('keydown', event => {
2286
+ this.keyListener = event => {
2898
2287
  if (this.content && ['ArrowDown', 'ArrowUp'].includes(event.key)) {
2899
2288
  const targetElements = tabbable(this.content, { includeContainer: false, getShadowRoot: true });
2900
- const activeElement = document.activeElement
2901
- ? tabbable(document.activeElement, { includeContainer: true, getShadowRoot: true })
2902
- : [];
2903
- const activeIdx = activeElement.length ? targetElements.indexOf(activeElement[0]) : -1;
2289
+ const activeElement = this.firstTabbable(document.activeElement);
2290
+ const activeIdx = activeElement ? targetElements.indexOf(activeElement) : -1;
2904
2291
  const activeOff = event.key === 'ArrowDown' ? 1 : -1;
2905
2292
  const targetIdx = activeIdx < 0 ? 0 : (activeIdx + activeOff + targetElements.length) % targetElements.length;
2906
2293
  targetElements[targetIdx].focus();
2907
2294
  event.preventDefault();
2908
2295
  }
2909
- });
2296
+ };
2297
+ document.addEventListener('keydown', this.keyListener);
2298
+ }
2299
+ disconnectedCallback() {
2300
+ if (this.keyListener) {
2301
+ document.removeEventListener('keydown', this.keyListener);
2302
+ }
2910
2303
  }
2911
2304
  render() {
2912
- return (h(Host, null, h("slot", { name: "trigger" }), h("div", { class: "content" }, h("slot", { name: "content" }))));
2305
+ return (h(Host, null, h("slot", { name: "trigger", ref: el => (this.triggerSlot = el) }), h("div", { class: "content", ref: el => (this.content = el) }, h("slot", { name: "content" }))));
2306
+ }
2307
+ get contentId() {
2308
+ return `cat-menu-${this.id}`;
2913
2309
  }
2914
2310
  show() {
2311
+ var _a;
2915
2312
  if (this.content) {
2916
2313
  this.content.style.display = 'block';
2314
+ (_a = this.trigger) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-expanded', 'true');
2917
2315
  this.catOpen.emit();
2918
2316
  this.trap = this.trap
2919
2317
  ? this.trap.updateContainerElements(this.content)
@@ -2929,8 +2327,10 @@ let CatMenu = class {
2929
2327
  }
2930
2328
  }
2931
2329
  hide() {
2330
+ var _a;
2932
2331
  if (this.content) {
2933
2332
  this.content.style.display = '';
2333
+ (_a = this.trigger) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-expanded', 'false');
2934
2334
  this.catClose.emit();
2935
2335
  }
2936
2336
  }
@@ -2938,7 +2338,7 @@ let CatMenu = class {
2938
2338
  if (this.trigger && this.content) {
2939
2339
  computePosition(this.trigger, this.content, {
2940
2340
  placement: this.placement,
2941
- middleware: [offset(CatMenu.OFFSET), flip()]
2341
+ middleware: [offset(CatMenu$1.OFFSET), flip()]
2942
2342
  }).then(({ x, y }) => {
2943
2343
  if (this.content) {
2944
2344
  Object.assign(this.content.style, {
@@ -2949,9 +2349,30 @@ let CatMenu = class {
2949
2349
  });
2950
2350
  }
2951
2351
  }
2952
- get host() { return getElement(this); }
2352
+ firstTabbable(container) {
2353
+ return (container ? tabbable(container, { includeContainer: true, getShadowRoot: true }) : []).shift();
2354
+ }
2355
+ static get style() { return catMenuCss; }
2953
2356
  };
2954
- CatMenu.OFFSET = 4;
2955
- CatMenu.style = catMenuCss;
2357
+ CatMenu$1.OFFSET = 4;
2358
+ CatMenu$1 = /*@__PURE__*/ proxyCustomElement(CatMenu$1, [1, "cat-menu", {
2359
+ "placement": [1]
2360
+ }, [[0, "catClick", "clickHandler"]]]);
2361
+ function defineCustomElement$1() {
2362
+ if (typeof customElements === "undefined") {
2363
+ return;
2364
+ }
2365
+ const components = ["cat-menu"];
2366
+ components.forEach(tagName => { switch (tagName) {
2367
+ case "cat-menu":
2368
+ if (!customElements.get(tagName)) {
2369
+ customElements.define(tagName, CatMenu$1);
2370
+ }
2371
+ break;
2372
+ } });
2373
+ }
2374
+
2375
+ const CatMenu = CatMenu$1;
2376
+ const defineCustomElement = defineCustomElement$1;
2956
2377
 
2957
- export { CatMenu as cat_menu };
2378
+ export { CatMenu, defineCustomElement };