@lumx/react 4.14.0-next.1 → 4.14.0-next.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.
Files changed (3) hide show
  1. package/index.js +20 -25
  2. package/index.js.map +1 -1
  3. package/package.json +3 -3
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { ColorVariant as ColorVariant$1, Size as Size$1, VISUALLY_HIDDEN, Theme as Theme$1, AspectRatio as AspectRatio$1, DOCUMENT as DOCUMENT$1, IS_BROWSER as IS_BROWSER$1, Emphasis as Emphasis$1, WINDOW, DIALOG_TRANSITION_DURATION, Orientation as Orientation$1, NOTIFICATION_TRANSITION_DURATION, Kind as Kind$1, Alignment as Alignment$1, ColorPalette as ColorPalette$1 } from '@lumx/core/js/constants';
1
+ import { ColorVariant as ColorVariant$1, Size as Size$1, VISUALLY_HIDDEN, Theme as Theme$1, AspectRatio as AspectRatio$1, DOCUMENT, IS_BROWSER as IS_BROWSER$1, Emphasis as Emphasis$1, WINDOW, DIALOG_TRANSITION_DURATION, Orientation as Orientation$1, NOTIFICATION_TRANSITION_DURATION, Kind as Kind$1, Alignment as Alignment$1, ColorPalette as ColorPalette$1 } from '@lumx/core/js/constants';
2
2
  export * from '@lumx/core/js/constants';
3
3
  export * from '@lumx/core/js/types';
4
4
  import * as React from 'react';
@@ -203,11 +203,6 @@ const ColorVariant = {
203
203
  */
204
204
  const IS_BROWSER = typeof window !== 'undefined' && !window.navigator.userAgent.includes('jsdom');
205
205
 
206
- /**
207
- * Optional global `document` instance (not defined when running SSR).
208
- */
209
- const DOCUMENT = typeof document !== 'undefined' ? document : undefined;
210
-
211
206
  function getDefaultExportFromCjs (x) {
212
207
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
213
208
  }
@@ -5050,7 +5045,7 @@ const LISTENERS = makeListenerTowerContext();
5050
5045
  */
5051
5046
  function useCallbackOnEscape(callback, closeOnEscape = true) {
5052
5047
  useEffect(() => {
5053
- const rootElement = DOCUMENT$1?.body;
5048
+ const rootElement = DOCUMENT?.body;
5054
5049
  if (!closeOnEscape || !callback || !rootElement) {
5055
5050
  return undefined;
5056
5051
  }
@@ -5265,7 +5260,7 @@ const Tooltip = forwardRef((props, ref) => {
5265
5260
  ...forwardedProps
5266
5261
  } = props;
5267
5262
  // Disable in SSR.
5268
- if (!DOCUMENT$1) {
5263
+ if (!DOCUMENT) {
5269
5264
  return /*#__PURE__*/jsx(Fragment, {
5270
5265
  children: children
5271
5266
  });
@@ -8877,15 +8872,12 @@ function setupFocusTrap(options, signal) {
8877
8872
  focusZoneElement,
8878
8873
  focusElement
8879
8874
  } = options;
8880
-
8881
- // Body element can be undefined in SSR context.
8882
- const rootElement = DOCUMENT?.body;
8883
- if (!rootElement || !focusZoneElement || signal.aborted) {
8875
+ if (!focusZoneElement || signal.aborted) {
8884
8876
  return;
8885
8877
  }
8886
8878
 
8887
- // Use the shadow root as focus zone when available.
8888
- const focusZoneElementOrShadowRoot = focusZoneElement.shadowRoot || focusZoneElement;
8879
+ // The root node is either the Document (regular DOM) or a ShadowRoot (shadow DOM portal).
8880
+ const rootNode = focusZoneElement.getRootNode();
8889
8881
 
8890
8882
  // Track whether we added a `tabindex="-1"` so we can restore the original state on teardown.
8891
8883
  let addedTabIndex = false;
@@ -8911,7 +8903,7 @@ function setupFocusTrap(options, signal) {
8911
8903
  if (evt.key !== 'Tab') {
8912
8904
  return;
8913
8905
  }
8914
- const focusable = getFirstAndLastFocusable(focusZoneElementOrShadowRoot);
8906
+ const focusable = getFirstAndLastFocusable(focusZoneElement);
8915
8907
 
8916
8908
  // Prevent focus switch if no focusable available — pin focus on the zone itself.
8917
8909
  if (!focusable.first) {
@@ -8919,14 +8911,16 @@ function setupFocusTrap(options, signal) {
8919
8911
  focusZoneFallback();
8920
8912
  return;
8921
8913
  }
8922
- const activeElement = focusZoneElement.shadowRoot ? focusZoneElement.shadowRoot.activeElement : DOCUMENT?.activeElement;
8914
+ const {
8915
+ activeElement
8916
+ } = rootNode;
8923
8917
  if (
8924
8918
  // No previous focus.
8925
8919
  !activeElement ||
8926
8920
  // Previous focus is at the end of the focus zone.
8927
8921
  !evt.shiftKey && activeElement === focusable.last ||
8928
8922
  // Previous focus is outside the focus zone.
8929
- !focusZoneElementOrShadowRoot.contains(activeElement)) {
8923
+ !focusZoneElement.contains(activeElement)) {
8930
8924
  focusable.first.focus();
8931
8925
  evt.preventDefault();
8932
8926
  return;
@@ -8940,19 +8934,20 @@ function setupFocusTrap(options, signal) {
8940
8934
  evt.preventDefault();
8941
8935
  }
8942
8936
  };
8937
+ const keydownHandler = trapTabFocusInFocusZone;
8943
8938
  const focusTrap = {
8944
- enable: () => rootElement.addEventListener('keydown', trapTabFocusInFocusZone),
8945
- disable: () => rootElement.removeEventListener('keydown', trapTabFocusInFocusZone)
8939
+ enable: () => rootNode.addEventListener('keydown', keydownHandler),
8940
+ disable: () => rootNode.removeEventListener('keydown', keydownHandler)
8946
8941
  };
8947
8942
 
8948
8943
  // SETUP: focus initial element.
8949
- if (focusElement && focusZoneElementOrShadowRoot.contains(focusElement)) {
8944
+ if (focusElement && focusZoneElement.contains(focusElement)) {
8950
8945
  // Focus the given element.
8951
8946
  focusElement.focus({
8952
8947
  preventScroll: true
8953
8948
  });
8954
8949
  } else {
8955
- const firstFocusable = getFirstAndLastFocusable(focusZoneElementOrShadowRoot).first;
8950
+ const firstFocusable = getFirstAndLastFocusable(focusZoneElement).first;
8956
8951
  if (firstFocusable) {
8957
8952
  // Focus the first focusable descendant.
8958
8953
  firstFocusable.focus({
@@ -9539,7 +9534,7 @@ _InnerPopover.displayName = COMPONENT_NAME$16;
9539
9534
  */
9540
9535
  const Popover = skipRender(
9541
9536
  // Skip render in SSR
9542
- () => Boolean(DOCUMENT$1), _InnerPopover);
9537
+ () => Boolean(DOCUMENT), _InnerPopover);
9543
9538
  Popover.displayName = COMPONENT_NAME$16;
9544
9539
  Popover.className = CLASSNAME$15;
9545
9540
  Popover.defaultProps = DEFAULT_PROPS$V;
@@ -11824,7 +11819,7 @@ const DEFAULT_PROPS$P = {
11824
11819
  * @return React element.
11825
11820
  */
11826
11821
  const Dialog = forwardRef((props, ref) => {
11827
- if (!DOCUMENT$1) {
11822
+ if (!DOCUMENT) {
11828
11823
  // Can't render in SSR.
11829
11824
  return null;
11830
11825
  }
@@ -14233,7 +14228,7 @@ const Lightbox = forwardRef((props, ref) => {
14233
14228
  zIndex,
14234
14229
  ...forwardedProps
14235
14230
  } = props;
14236
- if (!DOCUMENT$1) {
14231
+ if (!DOCUMENT) {
14237
14232
  // Can't render in SSR.
14238
14233
  return null;
14239
14234
  }
@@ -15192,7 +15187,7 @@ const Notification = forwardRef((props, ref) => {
15192
15187
  style,
15193
15188
  ...forwardedProps
15194
15189
  } = props;
15195
- if (!DOCUMENT$1) {
15190
+ if (!DOCUMENT) {
15196
15191
  // Can't render in SSR.
15197
15192
  return null;
15198
15193
  }