willba-component-library 0.4.0 → 0.4.2

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/lib/index.esm.js CHANGED
@@ -512,8 +512,13 @@ var useCloseFilterSection = function (_a) {
512
512
  var filterSectionRef = useRef(null);
513
513
  useEffect(function () {
514
514
  var handleClickOutside = function (event) {
515
- if (filterSectionRef.current &&
516
- !filterSectionRef.current.contains(event.target)) {
515
+ if (!filterSectionRef.current)
516
+ return;
517
+ // composedPath() walks through Shadow DOM boundaries; event.target is
518
+ // retargeted to the shadow host when crossing them, which would falsely
519
+ // report clicks inside the panel as "outside".
520
+ var path = event.composedPath();
521
+ if (!path.includes(filterSectionRef.current)) {
517
522
  handleSelectedFilter(false);
518
523
  }
519
524
  };
@@ -11877,25 +11882,38 @@ var checkForContinuousSelection = function (_a) {
11877
11882
  });
11878
11883
  };
11879
11884
 
11885
+ // Returns the nearest queryable root for an element. Inside a Shadow DOM this
11886
+ // returns the ShadowRoot (so `querySelector` searches inside the shadow tree);
11887
+ // otherwise returns `document`. Both support `querySelector`/`querySelectorAll`.
11888
+ var getQueryRoot = function (el) {
11889
+ var root = el === null || el === void 0 ? void 0 : el.getRootNode();
11890
+ if (root instanceof ShadowRoot)
11891
+ return root;
11892
+ return document;
11893
+ };
11894
+
11880
11895
  var useCalendarTooltips = function (_a) {
11881
- var showFeedback = _a.showFeedback;
11896
+ var showFeedback = _a.showFeedback, rootRef = _a.rootRef;
11882
11897
  return useEffect(function () {
11883
11898
  if (typeof document === 'undefined' || !showFeedback)
11884
11899
  return;
11900
+ // Use the calendar's own DOM root (ShadowRoot or Document) so queries
11901
+ // resolve correctly when the component is mounted inside Shadow DOM.
11902
+ var root = getQueryRoot(rootRef === null || rootRef === void 0 ? void 0 : rootRef.current);
11885
11903
  // Children
11886
- var calendarTooltip = document.querySelector('.will-calendar-tooltip');
11887
- var calendarTooltipCheckOut = document.querySelector('.will-calendar-tooltip-check-out');
11888
- var calendarTooltipOverlappingDate = document.querySelector('.will-calendar-tooltip-overlapping-date');
11889
- var loadingSpinner = document.querySelector('.will-filter-bar-calendar .will-calendar-spinner');
11890
- var calendarTooltipCheckInOnly = document.querySelector('.will-calendar-tooltip-check-in-only');
11891
- var calendarTooltipCheckOutOnly = document.querySelector('.will-calendar-tooltip-check-out-only');
11904
+ var calendarTooltip = root.querySelector('.will-calendar-tooltip');
11905
+ var calendarTooltipCheckOut = root.querySelector('.will-calendar-tooltip-check-out');
11906
+ var calendarTooltipOverlappingDate = root.querySelector('.will-calendar-tooltip-overlapping-date');
11907
+ var loadingSpinner = root.querySelector('.will-filter-bar-calendar .will-calendar-spinner');
11908
+ var calendarTooltipCheckInOnly = root.querySelector('.will-calendar-tooltip-check-in-only');
11909
+ var calendarTooltipCheckOutOnly = root.querySelector('.will-calendar-tooltip-check-out-only');
11892
11910
  // Parents
11893
- var calendarButtons = document.querySelectorAll('.will-filter-bar-calendar .rdp-cell:has(.booked):not(:has(.disabled-after-check-in))');
11894
- var calendarButtonsCheckOut = document.querySelectorAll('.will-filter-bar-calendar .rdp-cell:has(.booked.disabled-after-check-in)');
11895
- var calendarMonthContainer = document.querySelector('.will-filter-bar-calendar .rdp-months');
11896
- var calendarOverlappingDate = document.querySelectorAll('.will-filter-bar-calendar .rdp-cell:has(.overlapping-date)');
11897
- var calendarCheckInOnly = document.querySelectorAll('.will-filter-bar-calendar .rdp-cell:has(.check-in-only)');
11898
- var calendarCheckOutOnly = document.querySelectorAll('.will-filter-bar-calendar .rdp-cell:has(.check-out-only)');
11911
+ var calendarButtons = root.querySelectorAll('.will-filter-bar-calendar .rdp-cell:has(.booked):not(:has(.disabled-after-check-in))');
11912
+ var calendarButtonsCheckOut = root.querySelectorAll('.will-filter-bar-calendar .rdp-cell:has(.booked.disabled-after-check-in)');
11913
+ var calendarMonthContainer = root.querySelector('.will-filter-bar-calendar .rdp-months');
11914
+ var calendarOverlappingDate = root.querySelectorAll('.will-filter-bar-calendar .rdp-cell:has(.overlapping-date)');
11915
+ var calendarCheckInOnly = root.querySelectorAll('.will-filter-bar-calendar .rdp-cell:has(.check-in-only)');
11916
+ var calendarCheckOutOnly = root.querySelectorAll('.will-filter-bar-calendar .rdp-cell:has(.check-out-only)');
11899
11917
  // Append children to parents
11900
11918
  var tooltipClonesCheckIn = [];
11901
11919
  var tooltipClonesCheckOut = [];
@@ -11955,11 +11973,12 @@ var useCalendarTooltips = function (_a) {
11955
11973
  };
11956
11974
 
11957
11975
  var useCalendarLoadingSpinner = function (_a) {
11958
- var loadingData = _a.loadingData;
11976
+ var loadingData = _a.loadingData, rootRef = _a.rootRef;
11959
11977
  return useEffect(function () {
11960
11978
  if (typeof document === 'undefined')
11961
11979
  return;
11962
- var loadingSpinner = document.querySelector('.will-filter-bar-calendar .rdp-months .will-calendar-spinner');
11980
+ var root = getQueryRoot(rootRef === null || rootRef === void 0 ? void 0 : rootRef.current);
11981
+ var loadingSpinner = root.querySelector('.will-filter-bar-calendar .rdp-months .will-calendar-spinner');
11963
11982
  if (loadingData) {
11964
11983
  if (loadingSpinner)
11965
11984
  loadingSpinner.style.display = 'flex';
@@ -12058,10 +12077,12 @@ var Calendar = forwardRef(function (_a, ref) {
12058
12077
  // Handle tooltip
12059
12078
  useCalendarTooltips({
12060
12079
  showFeedback: showFeedback,
12080
+ rootRef: calendarContainerRef,
12061
12081
  });
12062
12082
  // Handle loading spinner
12063
12083
  useCalendarLoadingSpinner({
12064
12084
  loadingData: loadingData,
12085
+ rootRef: calendarContainerRef,
12065
12086
  });
12066
12087
  // Handle the date selection and availability for selection logic.
12067
12088
  var handleOnSelect = function (range) {