@vitessce/styles 3.9.0 → 3.9.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/dist/index.js CHANGED
@@ -64604,18 +64604,12 @@ function createChainedFunction(...funcs) {
64604
64604
  if (func == null) {
64605
64605
  return acc;
64606
64606
  }
64607
- {
64608
- if (typeof func !== "function") {
64609
- console.error(
64610
- "Material-UI: Invalid Argument Type, must only provide functions, undefined, or null."
64611
- );
64612
- }
64613
- }
64614
64607
  return function chainedFunction(...args) {
64615
64608
  acc.apply(this, args);
64616
64609
  func.apply(this, args);
64617
64610
  };
64618
64611
  },
64612
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
64619
64613
  () => {
64620
64614
  }
64621
64615
  );
@@ -64657,149 +64651,146 @@ function flipPlacement(placement, theme) {
64657
64651
  }
64658
64652
  }
64659
64653
  function getAnchorEl(anchorEl) {
64660
- return typeof anchorEl === "function" ? anchorEl() : anchorEl;
64654
+ return typeof anchorEl === "function" ? anchorEl(document.body) : anchorEl;
64661
64655
  }
64662
64656
  const useEnhancedEffect = typeof window !== "undefined" ? React.useLayoutEffect : React.useEffect;
64663
64657
  const defaultPopperOptions = {};
64664
- const Popper = React.forwardRef((props, ref) => {
64665
- const {
64666
- anchorEl,
64667
- children,
64668
- container,
64669
- disablePortal = false,
64670
- keepMounted = false,
64671
- modifiers: modifiers2,
64672
- open,
64673
- placement: initialPlacement = "bottom",
64674
- popperOptions = defaultPopperOptions,
64675
- popperRef: popperRefProp,
64676
- style: style2,
64677
- transition: transition2 = false,
64678
- ...other
64679
- } = props;
64680
- const tooltipRef = React.useRef(null);
64681
- const ownRef = useForkRef(tooltipRef, ref);
64682
- const popperRef = React.useRef(null);
64683
- const handlePopperRef = useForkRef(popperRef, popperRefProp);
64684
- const handlePopperRefRef = React.useRef(handlePopperRef);
64685
- useEnhancedEffect(() => {
64686
- handlePopperRefRef.current = handlePopperRef;
64687
- }, [handlePopperRef]);
64688
- React.useImperativeHandle(popperRefProp, () => popperRef.current, []);
64689
- const [exited, setExited] = React.useState(true);
64690
- const { theme } = useStyles();
64691
- const rtlPlacement = flipPlacement(initialPlacement, theme);
64692
- const [placement, setPlacement] = React.useState(rtlPlacement);
64693
- React.useEffect(() => {
64694
- if (popperRef.current) {
64695
- popperRef.current.update();
64696
- }
64697
- });
64698
- const handleOpen = React.useCallback(() => {
64699
- if (!tooltipRef.current || !anchorEl || !open) {
64700
- return;
64701
- }
64702
- if (popperRef.current) {
64703
- popperRef.current.destroy();
64704
- handlePopperRefRef.current(null);
64705
- }
64706
- const handlePopperUpdate = (data) => {
64707
- setPlacement(data.placement);
64708
- };
64709
- const resolvedAnchorEl = getAnchorEl(anchorEl);
64710
- {
64711
- if (resolvedAnchorEl && resolvedAnchorEl.nodeType === 1) {
64712
- const box = resolvedAnchorEl.getBoundingClientRect();
64713
- if (box.top === 0 && box.left === 0 && box.right === 0 && box.bottom === 0) {
64714
- console.warn(
64715
- [
64716
- "Material-UI: The `anchorEl` prop provided to the component is invalid.",
64717
- "The anchor element should be part of the document layout.",
64718
- "Make sure the element is present in the document or that it's not display none."
64719
- ].join("\n")
64720
- );
64658
+ const Popper = React.forwardRef(
64659
+ (props, ref) => {
64660
+ const {
64661
+ anchorEl,
64662
+ children,
64663
+ container,
64664
+ disablePortal = false,
64665
+ keepMounted = false,
64666
+ modifiers: modifiers2,
64667
+ open,
64668
+ placement: initialPlacement = "bottom",
64669
+ popperOptions = defaultPopperOptions,
64670
+ popperRef: popperRefProp,
64671
+ style: style2,
64672
+ transition: transition2 = false,
64673
+ ...other
64674
+ } = props;
64675
+ const tooltipRef = React.useRef(null);
64676
+ const ownRef = useForkRef(tooltipRef, ref);
64677
+ const popperRef = React.useRef(null);
64678
+ const handlePopperRef = useForkRef(popperRef, popperRefProp);
64679
+ const handlePopperRefRef = React.useRef(handlePopperRef);
64680
+ useEnhancedEffect(() => {
64681
+ handlePopperRefRef.current = handlePopperRef;
64682
+ }, [handlePopperRef]);
64683
+ React.useImperativeHandle(popperRefProp, () => popperRef.current, []);
64684
+ const [exited, setExited] = React.useState(true);
64685
+ const { theme } = useStyles();
64686
+ const rtlPlacement = flipPlacement(initialPlacement, theme);
64687
+ const [placement, setPlacement] = React.useState(rtlPlacement);
64688
+ React.useEffect(() => {
64689
+ if (popperRef.current) {
64690
+ popperRef.current.update();
64691
+ }
64692
+ });
64693
+ const handleOpen = React.useCallback(() => {
64694
+ if (!tooltipRef.current || !anchorEl || !open) {
64695
+ return;
64696
+ }
64697
+ if (popperRef.current) {
64698
+ popperRef.current.destroy();
64699
+ if (handlePopperRefRef.current) {
64700
+ setRef(handlePopperRefRef.current, null);
64721
64701
  }
64722
64702
  }
64723
- }
64724
- const popper2 = new Popper$1(getAnchorEl(anchorEl), tooltipRef.current, {
64725
- placement: rtlPlacement,
64726
- ...popperOptions,
64727
- modifiers: {
64728
- ...disablePortal ? {} : {
64729
- // It's using scrollParent by default, we can use the viewport when using a portal.
64730
- preventOverflow: {
64731
- boundariesElement: "window"
64732
- }
64703
+ const handlePopperUpdate = (data) => {
64704
+ setPlacement(data.placement);
64705
+ };
64706
+ const anchorElement = getAnchorEl(anchorEl);
64707
+ if (!anchorElement) {
64708
+ return;
64709
+ }
64710
+ const popper2 = new Popper$1(anchorElement, tooltipRef.current, {
64711
+ placement: rtlPlacement,
64712
+ ...popperOptions,
64713
+ modifiers: {
64714
+ ...disablePortal ? {} : {
64715
+ // It's using scrollParent by default, we can use the viewport when using a portal.
64716
+ preventOverflow: {
64717
+ boundariesElement: "window"
64718
+ }
64719
+ },
64720
+ ...modifiers2,
64721
+ ...popperOptions.modifiers
64733
64722
  },
64734
- ...modifiers2,
64735
- ...popperOptions.modifiers
64723
+ // We could have been using a custom modifier like react-popper is doing.
64724
+ // But it seems this is the best public API for this use case.
64725
+ onCreate: createChainedFunction(handlePopperUpdate, popperOptions.onCreate),
64726
+ onUpdate: createChainedFunction(handlePopperUpdate, popperOptions.onUpdate)
64727
+ });
64728
+ if (handlePopperRefRef.current) {
64729
+ setRef(handlePopperRefRef.current, popper2);
64730
+ }
64731
+ }, [anchorEl, disablePortal, modifiers2, open, rtlPlacement, popperOptions]);
64732
+ const handleRef = React.useCallback(
64733
+ (node2) => {
64734
+ setRef(ownRef, node2);
64735
+ handleOpen();
64736
64736
  },
64737
- // We could have been using a custom modifier like react-popper is doing.
64738
- // But it seems this is the best public API for this use case.
64739
- onCreate: createChainedFunction(handlePopperUpdate, popperOptions.onCreate),
64740
- onUpdate: createChainedFunction(handlePopperUpdate, popperOptions.onUpdate)
64741
- });
64742
- handlePopperRefRef.current(popper2);
64743
- }, [anchorEl, disablePortal, modifiers2, open, rtlPlacement, popperOptions]);
64744
- const handleRef = React.useCallback(
64745
- (node2) => {
64746
- setRef(ownRef, node2);
64747
- handleOpen();
64748
- },
64749
- [ownRef, handleOpen]
64750
- );
64751
- const handleEnter = () => {
64752
- setExited(false);
64753
- };
64754
- const handleClose = () => {
64755
- if (!popperRef.current) {
64756
- return;
64757
- }
64758
- popperRef.current.destroy();
64759
- handlePopperRefRef.current(null);
64760
- };
64761
- const handleExited = () => {
64762
- setExited(true);
64763
- handleClose();
64764
- };
64765
- React.useEffect(() => () => {
64766
- handleClose();
64767
- }, []);
64768
- React.useEffect(() => {
64769
- if (!open && !transition2) {
64737
+ [ownRef, handleOpen]
64738
+ );
64739
+ const handleEnter = () => {
64740
+ setExited(false);
64741
+ };
64742
+ const handleClose = () => {
64743
+ if (!popperRef.current) {
64744
+ return;
64745
+ }
64746
+ popperRef.current.destroy();
64747
+ if (handlePopperRefRef.current) {
64748
+ setRef(handlePopperRefRef.current, null);
64749
+ }
64750
+ };
64751
+ const handleExited = () => {
64752
+ setExited(true);
64770
64753
  handleClose();
64771
- }
64772
- }, [open, transition2]);
64773
- if (!keepMounted && !open && (!transition2 || exited)) {
64774
- return null;
64775
- }
64776
- const childProps = { placement };
64777
- if (transition2) {
64778
- childProps.TransitionProps = {
64779
- in: open,
64780
- onEnter: handleEnter,
64781
- onExited: handleExited
64782
64754
  };
64783
- }
64784
- return /* @__PURE__ */ React.createElement(Portal, { disablePortal, container }, /* @__PURE__ */ React.createElement(
64785
- "div",
64786
- {
64787
- ref: handleRef,
64788
- role: "tooltip",
64789
- ...other,
64790
- style: {
64791
- // Prevents scroll issue, waiting for Popper.js to add this style once initiated.
64792
- position: "fixed",
64793
- // Fix Popper.js display issue
64794
- top: 0,
64795
- left: 0,
64796
- display: !open && keepMounted && !transition2 ? "none" : null,
64797
- ...style2
64755
+ React.useEffect(() => () => {
64756
+ handleClose();
64757
+ }, []);
64758
+ React.useEffect(() => {
64759
+ if (!open && !transition2) {
64760
+ handleClose();
64798
64761
  }
64799
- },
64800
- typeof children === "function" ? children(childProps) : children
64801
- ));
64802
- });
64762
+ }, [open, transition2]);
64763
+ if (!keepMounted && !open && (!transition2 || exited)) {
64764
+ return null;
64765
+ }
64766
+ const childProps = { placement };
64767
+ if (transition2) {
64768
+ childProps.TransitionProps = {
64769
+ in: open,
64770
+ onEnter: handleEnter,
64771
+ onExited: handleExited
64772
+ };
64773
+ }
64774
+ return /* @__PURE__ */ React.createElement(Portal, { disablePortal, container }, /* @__PURE__ */ React.createElement(
64775
+ "div",
64776
+ {
64777
+ ref: handleRef,
64778
+ role: "tooltip",
64779
+ ...other,
64780
+ style: {
64781
+ // Prevents scroll issue, waiting for Popper.js to add this style once initiated.
64782
+ position: "fixed",
64783
+ // Fix Popper.js display issue
64784
+ top: 0,
64785
+ left: 0,
64786
+ display: !open && keepMounted && !transition2 ? "none" : void 0,
64787
+ ...style2
64788
+ }
64789
+ },
64790
+ typeof children === "function" ? children(childProps) : children
64791
+ ));
64792
+ }
64793
+ );
64803
64794
  function prependParentClassName(jssObject, parentClassName) {
64804
64795
  return Object.entries(jssObject).reduce((accumulator, [key, value]) => {
64805
64796
  accumulator[`.${parentClassName} ${key}`] = value;
@@ -64814,7 +64805,7 @@ function ScopedGlobalStyles(props) {
64814
64805
  parentClassName
64815
64806
  );
64816
64807
  return /* @__PURE__ */ React__default.createElement(GlobalStyles$3, { styles: computedStyles });
64817
- }, [parentClassName]);
64808
+ }, [parentClassName, styles2]);
64818
64809
  return component;
64819
64810
  }
64820
64811
  export {
@@ -1,5 +1,38 @@
1
+ import * as React from 'react';
2
+ import PopperJs, { Placement, Modifiers, Data } from 'popper.js';
3
+ type AnchorElType = null | Element | ((element: Element) => Element);
4
+ interface PopperOptions {
5
+ placement?: Placement;
6
+ modifiers?: Modifiers;
7
+ onCreate?: (data: Data) => void;
8
+ onUpdate?: (data: Data) => void;
9
+ }
10
+ interface TransitionProps {
11
+ in?: boolean;
12
+ onEnter?: () => void;
13
+ onExited?: () => void;
14
+ }
15
+ interface ChildProps {
16
+ placement: Placement;
17
+ TransitionProps?: TransitionProps;
18
+ }
19
+ export interface PopperProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> {
20
+ anchorEl?: AnchorElType;
21
+ children: React.ReactNode | ((props: ChildProps) => React.ReactNode);
22
+ container?: Element | (() => Element | null) | null;
23
+ disablePortal?: boolean;
24
+ keepMounted?: boolean;
25
+ modifiers?: Modifiers;
26
+ open: boolean;
27
+ placement?: Placement;
28
+ popperOptions?: PopperOptions;
29
+ popperRef?: React.Ref<PopperJs | null>;
30
+ style?: React.CSSProperties;
31
+ transition?: boolean;
32
+ }
1
33
  /**
2
34
  * Poppers rely on the 3rd party library [Popper.js](https://popper.js.org/docs/v1/) for positioning.
3
35
  */
4
- export const Popper: any;
36
+ export declare const Popper: React.ForwardRefExoticComponent<PopperProps & React.RefAttributes<HTMLDivElement>>;
37
+ export {};
5
38
  //# sourceMappingURL=Popper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Popper.d.ts","sourceRoot":"","sources":["../src/Popper.js"],"names":[],"mappings":"AAyCA;;GAEG;AACH,yBAgLG"}
1
+ {"version":3,"file":"Popper.d.ts","sourceRoot":"","sources":["../src/Popper.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,MAA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EAAE,KAAK,CAAC,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;IACvC,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;GAEG;AACH,eAAO,MAAM,MAAM,oFAqKlB,CAAC"}
@@ -29,7 +29,7 @@ function flipPlacement(placement, theme) {
29
29
  }
30
30
  }
31
31
  function getAnchorEl(anchorEl) {
32
- return typeof anchorEl === 'function' ? anchorEl() : anchorEl;
32
+ return typeof anchorEl === 'function' ? anchorEl(document.body) : anchorEl;
33
33
  }
34
34
  const useEnhancedEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;
35
35
  const defaultPopperOptions = {};
@@ -51,9 +51,9 @@ export const Popper = React.forwardRef((props, ref) => {
51
51
  const { theme } = useTheme();
52
52
  const rtlPlacement = flipPlacement(initialPlacement, theme);
53
53
  /**
54
- * placement initialized from prop but can change during lifetime if modifiers.flip.
55
- * modifiers.flip is essentially a flip for controlled/uncontrolled behavior
56
- */
54
+ * placement initialized from prop but can change during lifetime if modifiers.flip.
55
+ * modifiers.flip is essentially a flip for controlled/uncontrolled behavior
56
+ */
57
57
  const [placement, setPlacement] = React.useState(rtlPlacement);
58
58
  React.useEffect(() => {
59
59
  if (popperRef.current) {
@@ -66,29 +66,18 @@ export const Popper = React.forwardRef((props, ref) => {
66
66
  }
67
67
  if (popperRef.current) {
68
68
  popperRef.current.destroy();
69
- handlePopperRefRef.current(null);
69
+ if (handlePopperRefRef.current) {
70
+ setRef(handlePopperRefRef.current, null);
71
+ }
70
72
  }
71
73
  const handlePopperUpdate = (data) => {
72
74
  setPlacement(data.placement);
73
75
  };
74
- const resolvedAnchorEl = getAnchorEl(anchorEl);
75
- if (process.env.NODE_ENV !== 'production') {
76
- if (resolvedAnchorEl && resolvedAnchorEl.nodeType === 1) {
77
- const box = resolvedAnchorEl.getBoundingClientRect();
78
- if (process.env.NODE_ENV !== 'test'
79
- && box.top === 0
80
- && box.left === 0
81
- && box.right === 0
82
- && box.bottom === 0) {
83
- console.warn([
84
- 'Material-UI: The `anchorEl` prop provided to the component is invalid.',
85
- 'The anchor element should be part of the document layout.',
86
- "Make sure the element is present in the document or that it's not display none.",
87
- ].join('\n'));
88
- }
89
- }
76
+ const anchorElement = getAnchorEl(anchorEl);
77
+ if (!anchorElement) {
78
+ return;
90
79
  }
91
- const popper = new PopperJs(getAnchorEl(anchorEl), tooltipRef.current, {
80
+ const popper = new PopperJs(anchorElement, tooltipRef.current, {
92
81
  placement: rtlPlacement,
93
82
  ...popperOptions,
94
83
  modifiers: {
@@ -108,7 +97,9 @@ export const Popper = React.forwardRef((props, ref) => {
108
97
  onCreate: createChainedFunction(handlePopperUpdate, popperOptions.onCreate),
109
98
  onUpdate: createChainedFunction(handlePopperUpdate, popperOptions.onUpdate),
110
99
  });
111
- handlePopperRefRef.current(popper);
100
+ if (handlePopperRefRef.current) {
101
+ setRef(handlePopperRefRef.current, popper);
102
+ }
112
103
  }, [anchorEl, disablePortal, modifiers, open, rtlPlacement, popperOptions]);
113
104
  const handleRef = React.useCallback((node) => {
114
105
  setRef(ownRef, node);
@@ -122,7 +113,9 @@ export const Popper = React.forwardRef((props, ref) => {
122
113
  return;
123
114
  }
124
115
  popperRef.current.destroy();
125
- handlePopperRefRef.current(null);
116
+ if (handlePopperRefRef.current) {
117
+ setRef(handlePopperRefRef.current, null);
118
+ }
126
119
  };
127
120
  const handleExited = () => {
128
121
  setExited(true);
@@ -154,7 +147,7 @@ export const Popper = React.forwardRef((props, ref) => {
154
147
  // Fix Popper.js display issue
155
148
  top: 0,
156
149
  left: 0,
157
- display: !open && keepMounted && !transition ? 'none' : null,
150
+ display: !open && keepMounted && !transition ? 'none' : undefined,
158
151
  ...style,
159
152
  }, children: typeof children === 'function' ? children(childProps) : children }) }));
160
153
  });
@@ -1,2 +1,7 @@
1
- export function ScopedGlobalStyles(props: any): any;
1
+ import { CSSObject } from 'tss-react';
2
+ export interface ScopedGlobalStylesProps {
3
+ styles: CSSObject;
4
+ parentClassName: string;
5
+ }
6
+ export declare function ScopedGlobalStyles(props: ScopedGlobalStylesProps): import("react/jsx-runtime").JSX.Element;
2
7
  //# sourceMappingURL=ScopedGlobalStyles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ScopedGlobalStyles.d.ts","sourceRoot":"","sources":["../src/ScopedGlobalStyles.js"],"names":[],"mappings":"AAUA,oDAaC"}
1
+ {"version":3,"file":"ScopedGlobalStyles.d.ts","sourceRoot":"","sources":["../src/ScopedGlobalStyles.tsx"],"names":[],"mappings":"AACA,OAAO,EAAgB,SAAS,EAAE,MAAM,WAAW,CAAC;AAUpD,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,SAAS,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,2CAahE"}
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import React, { useMemo } from 'react';
2
+ import { useMemo } from 'react';
3
3
  import { GlobalStyles } from 'tss-react';
4
4
  function prependParentClassName(jssObject, parentClassName) {
5
5
  return Object.entries(jssObject).reduce((accumulator, [key, value]) => {
@@ -12,6 +12,6 @@ export function ScopedGlobalStyles(props) {
12
12
  const component = useMemo(() => {
13
13
  const computedStyles = prependParentClassName(styles, parentClassName);
14
14
  return (_jsx(GlobalStyles, { styles: computedStyles }));
15
- }, [parentClassName]);
15
+ }, [parentClassName, styles]);
16
16
  return component;
17
17
  }