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.js CHANGED
@@ -532,8 +532,13 @@ var useCloseFilterSection = function (_a) {
532
532
  var filterSectionRef = React.useRef(null);
533
533
  React.useEffect(function () {
534
534
  var handleClickOutside = function (event) {
535
- if (filterSectionRef.current &&
536
- !filterSectionRef.current.contains(event.target)) {
535
+ if (!filterSectionRef.current)
536
+ return;
537
+ // composedPath() walks through Shadow DOM boundaries; event.target is
538
+ // retargeted to the shadow host when crossing them, which would falsely
539
+ // report clicks inside the panel as "outside".
540
+ var path = event.composedPath();
541
+ if (!path.includes(filterSectionRef.current)) {
537
542
  handleSelectedFilter(false);
538
543
  }
539
544
  };
@@ -11897,25 +11902,38 @@ var checkForContinuousSelection = function (_a) {
11897
11902
  });
11898
11903
  };
11899
11904
 
11905
+ // Returns the nearest queryable root for an element. Inside a Shadow DOM this
11906
+ // returns the ShadowRoot (so `querySelector` searches inside the shadow tree);
11907
+ // otherwise returns `document`. Both support `querySelector`/`querySelectorAll`.
11908
+ var getQueryRoot = function (el) {
11909
+ var root = el === null || el === void 0 ? void 0 : el.getRootNode();
11910
+ if (root instanceof ShadowRoot)
11911
+ return root;
11912
+ return document;
11913
+ };
11914
+
11900
11915
  var useCalendarTooltips = function (_a) {
11901
- var showFeedback = _a.showFeedback;
11916
+ var showFeedback = _a.showFeedback, rootRef = _a.rootRef;
11902
11917
  return React.useEffect(function () {
11903
11918
  if (typeof document === 'undefined' || !showFeedback)
11904
11919
  return;
11920
+ // Use the calendar's own DOM root (ShadowRoot or Document) so queries
11921
+ // resolve correctly when the component is mounted inside Shadow DOM.
11922
+ var root = getQueryRoot(rootRef === null || rootRef === void 0 ? void 0 : rootRef.current);
11905
11923
  // Children
11906
- var calendarTooltip = document.querySelector('.will-calendar-tooltip');
11907
- var calendarTooltipCheckOut = document.querySelector('.will-calendar-tooltip-check-out');
11908
- var calendarTooltipOverlappingDate = document.querySelector('.will-calendar-tooltip-overlapping-date');
11909
- var loadingSpinner = document.querySelector('.will-filter-bar-calendar .will-calendar-spinner');
11910
- var calendarTooltipCheckInOnly = document.querySelector('.will-calendar-tooltip-check-in-only');
11911
- var calendarTooltipCheckOutOnly = document.querySelector('.will-calendar-tooltip-check-out-only');
11924
+ var calendarTooltip = root.querySelector('.will-calendar-tooltip');
11925
+ var calendarTooltipCheckOut = root.querySelector('.will-calendar-tooltip-check-out');
11926
+ var calendarTooltipOverlappingDate = root.querySelector('.will-calendar-tooltip-overlapping-date');
11927
+ var loadingSpinner = root.querySelector('.will-filter-bar-calendar .will-calendar-spinner');
11928
+ var calendarTooltipCheckInOnly = root.querySelector('.will-calendar-tooltip-check-in-only');
11929
+ var calendarTooltipCheckOutOnly = root.querySelector('.will-calendar-tooltip-check-out-only');
11912
11930
  // Parents
11913
- var calendarButtons = document.querySelectorAll('.will-filter-bar-calendar .rdp-cell:has(.booked):not(:has(.disabled-after-check-in))');
11914
- var calendarButtonsCheckOut = document.querySelectorAll('.will-filter-bar-calendar .rdp-cell:has(.booked.disabled-after-check-in)');
11915
- var calendarMonthContainer = document.querySelector('.will-filter-bar-calendar .rdp-months');
11916
- var calendarOverlappingDate = document.querySelectorAll('.will-filter-bar-calendar .rdp-cell:has(.overlapping-date)');
11917
- var calendarCheckInOnly = document.querySelectorAll('.will-filter-bar-calendar .rdp-cell:has(.check-in-only)');
11918
- var calendarCheckOutOnly = document.querySelectorAll('.will-filter-bar-calendar .rdp-cell:has(.check-out-only)');
11931
+ var calendarButtons = root.querySelectorAll('.will-filter-bar-calendar .rdp-cell:has(.booked):not(:has(.disabled-after-check-in))');
11932
+ var calendarButtonsCheckOut = root.querySelectorAll('.will-filter-bar-calendar .rdp-cell:has(.booked.disabled-after-check-in)');
11933
+ var calendarMonthContainer = root.querySelector('.will-filter-bar-calendar .rdp-months');
11934
+ var calendarOverlappingDate = root.querySelectorAll('.will-filter-bar-calendar .rdp-cell:has(.overlapping-date)');
11935
+ var calendarCheckInOnly = root.querySelectorAll('.will-filter-bar-calendar .rdp-cell:has(.check-in-only)');
11936
+ var calendarCheckOutOnly = root.querySelectorAll('.will-filter-bar-calendar .rdp-cell:has(.check-out-only)');
11919
11937
  // Append children to parents
11920
11938
  var tooltipClonesCheckIn = [];
11921
11939
  var tooltipClonesCheckOut = [];
@@ -11975,11 +11993,12 @@ var useCalendarTooltips = function (_a) {
11975
11993
  };
11976
11994
 
11977
11995
  var useCalendarLoadingSpinner = function (_a) {
11978
- var loadingData = _a.loadingData;
11996
+ var loadingData = _a.loadingData, rootRef = _a.rootRef;
11979
11997
  return React.useEffect(function () {
11980
11998
  if (typeof document === 'undefined')
11981
11999
  return;
11982
- var loadingSpinner = document.querySelector('.will-filter-bar-calendar .rdp-months .will-calendar-spinner');
12000
+ var root = getQueryRoot(rootRef === null || rootRef === void 0 ? void 0 : rootRef.current);
12001
+ var loadingSpinner = root.querySelector('.will-filter-bar-calendar .rdp-months .will-calendar-spinner');
11983
12002
  if (loadingData) {
11984
12003
  if (loadingSpinner)
11985
12004
  loadingSpinner.style.display = 'flex';
@@ -12078,10 +12097,12 @@ var Calendar = React.forwardRef(function (_a, ref) {
12078
12097
  // Handle tooltip
12079
12098
  useCalendarTooltips({
12080
12099
  showFeedback: showFeedback,
12100
+ rootRef: calendarContainerRef,
12081
12101
  });
12082
12102
  // Handle loading spinner
12083
12103
  useCalendarLoadingSpinner({
12084
12104
  loadingData: loadingData,
12105
+ rootRef: calendarContainerRef,
12085
12106
  });
12086
12107
  // Handle the date selection and availability for selection logic.
12087
12108
  var handleOnSelect = function (range) {