@wonderflow/react-components 2.15.0 → 2.15.1

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.
@@ -7,7 +7,7 @@ export declare type DropdownProps = PropsWithClass & {
7
7
  placement?: AutoPlacement | BasePlacement | VariationPlacement;
8
8
  };
9
9
  export declare const Dropdown: {
10
- ({ className, children, trigger, offset, placement, ...props }: DropdownProps): JSX.Element;
10
+ ({ className, children, trigger, offset, placement }: DropdownProps): JSX.Element;
11
11
  Menu: React.ForwardRefExoticComponent<PropsWithClass & {
12
12
  children: React.ReactNode;
13
13
  } & React.RefAttributes<HTMLUListElement>>;
@@ -1,49 +1,16 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
1
  import clsx from 'clsx';
13
- import React, { useState, useRef, useCallback, Children, cloneElement } from 'react';
14
- import { useClickAway, useKey } from 'react-use';
15
- import { Dropdown as DropdownClass, Trigger, PopUp } from './dropdown.module.css';
2
+ import React, { useState, Children, cloneElement, useCallback } from 'react';
3
+ import { useKey } from 'react-use';
4
+ import { Dropdown as DropdownClass, PopUp } from './dropdown.module.css';
16
5
  import { useUIDSeed } from 'react-uid';
17
6
  import { useFocusWithin } from '@react-aria/interactions';
18
7
  import { DropdownMenu } from './dropdown-menu';
19
8
  import { DropdownItem } from './dropdown-item';
20
- import { usePopper } from 'react-popper';
21
- import { motion, AnimatePresence } from 'framer-motion';
22
- export const Dropdown = (_a) => {
23
- var { className, children, trigger, offset = 8, placement = 'auto-start' } = _a, props = __rest(_a, ["className", "children", "trigger", "offset", "placement"]);
24
- const DropDownRef = useRef(null);
25
- const [isOpen, setIsOpen] = useState(false);
9
+ import { Popper, Target, Content } from 'react-nested-popper';
10
+ import { motion } from 'framer-motion';
11
+ export const Dropdown = ({ className, children, trigger, offset = 8, placement = 'auto-start' }) => {
26
12
  const seedID = useUIDSeed();
27
- const [triggerRef, setTriggerRef] = useState(null);
28
- const [popUpElement, setPopUpElement] = useState(null);
29
- const { styles: popUpStyles, attributes: popUpAttributes } = usePopper(triggerRef, popUpElement, {
30
- placement: placement,
31
- modifiers: [
32
- {
33
- name: 'flip',
34
- enabled: true,
35
- options: {
36
- fallbackPlacements: ['bottom', 'top']
37
- }
38
- },
39
- {
40
- name: 'offset',
41
- options: {
42
- offset: [0, offset]
43
- }
44
- }
45
- ]
46
- });
13
+ const [isOpen, setIsOpen] = useState(false);
47
14
  const { focusWithinProps } = useFocusWithin({
48
15
  onFocusWithin: () => null,
49
16
  onBlurWithin: (e) => e.relatedTarget && setIsOpen(false),
@@ -52,22 +19,37 @@ export const Dropdown = (_a) => {
52
19
  const handleOpen = useCallback((action) => () => {
53
20
  setIsOpen(action);
54
21
  }, []);
55
- useKey('Escape', handleOpen(false));
56
- useClickAway(DropDownRef, handleOpen(false));
57
- return (React.createElement("div", Object.assign({ className: clsx(DropdownClass, className), ref: DropDownRef }, focusWithinProps, props),
58
- React.createElement("div", { className: Trigger }, Children.map(trigger, (child) => cloneElement(child, {
59
- onClick: handleOpen(!isOpen),
22
+ useKey('Escape', () => handleOpen(false));
23
+ return (React.createElement(Popper, { show: isOpen, outsideClickType: "all", onOutsideClick: handleOpen(false), onTargetClick: handleOpen(!isOpen), usePortal: false },
24
+ React.createElement(Target, { className: clsx(DropdownClass, className) }, Children.map(trigger, (child) => cloneElement(child, {
60
25
  id: seedID('dropdown-trigger'),
61
- ref: setTriggerRef,
62
26
  'aria-haspopup': 'true',
63
27
  'aria-controls': seedID('dropdown-menu'),
64
28
  'aria-expanded': isOpen
65
29
  }))),
66
- React.createElement(AnimatePresence, null, isOpen && (React.createElement("div", Object.assign({ className: PopUp, ref: setPopUpElement, style: popUpStyles.popper }, popUpAttributes.popper),
67
- React.createElement(motion.div, { animate: { y: 0, opacity: 1 }, initial: { y: 5, opacity: 0 }, exit: { y: 5, opacity: 0 }, transition: { ease: 'easeOut', duration: 0.1 } }, Children.map(children, (child) => cloneElement(child, {
68
- id: seedID('dropdown-menu'),
69
- 'aria-labelledby': seedID('dropdown-trigger')
70
- }))))))));
30
+ React.createElement(Content, { className: PopUp, popperOptions: {
31
+ placement: placement,
32
+ modifiers: [
33
+ {
34
+ name: 'flip',
35
+ enabled: true,
36
+ options: {
37
+ fallbackPlacements: ['bottom', 'top']
38
+ }
39
+ },
40
+ {
41
+ name: 'offset',
42
+ options: {
43
+ offset: [0, offset]
44
+ }
45
+ }
46
+ ]
47
+ } },
48
+ React.createElement(motion.div, { animate: isOpen ? { y: 5, opacity: 1 } : { y: 0, opacity: 0 }, transition: { ease: 'easeOut', duration: 0.1 } },
49
+ React.createElement("div", Object.assign({}, focusWithinProps), Children.map(children, (child) => cloneElement(child, {
50
+ id: seedID('dropdown-menu'),
51
+ 'aria-labelledby': seedID('dropdown-trigger')
52
+ })))))));
71
53
  };
72
54
  Dropdown.Menu = DropdownMenu;
73
55
  Dropdown.Item = DropdownItem;
@@ -3,12 +3,7 @@
3
3
  display: inline-flex;
4
4
  }
5
5
 
6
- .Trigger {
7
- display: contents;
8
- }
9
-
10
6
  .PopUp {
11
7
  inline-size: max-content;
12
- min-inline-size: 100%;
13
8
  z-index: 2;
14
9
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wonderflow/react-components",
3
3
  "description": "UI components from Wonderflow's Wanda design system",
4
- "version": "2.15.0",
4
+ "version": "2.15.1",
5
5
  "author": "Wonderflow",
6
6
  "license": "MIT",
7
7
  "main": "index.js",
package/themes/dark.css CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Mon, 20 Sep 2021 09:55:31 GMT
3
+ * Generated on Mon, 20 Sep 2021 13:39:18 GMT
4
4
  */
5
5
 
6
6
  :root {
package/themes/light.css CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Mon, 20 Sep 2021 09:55:31 GMT
3
+ * Generated on Mon, 20 Sep 2021 13:39:18 GMT
4
4
  */
5
5
 
6
6
  :root {
package/themes.css CHANGED
@@ -4,7 +4,7 @@
4
4
  color: var(--global-foreground);
5
5
  /**
6
6
  * Do not edit directly
7
- * Generated on Mon, 20 Sep 2021 09:55:31 GMT
7
+ * Generated on Mon, 20 Sep 2021 13:39:18 GMT
8
8
  */
9
9
 
10
10
 
@@ -50,7 +50,7 @@
50
50
  color: var(--global-foreground);
51
51
  /**
52
52
  * Do not edit directly
53
- * Generated on Mon, 20 Sep 2021 09:55:31 GMT
53
+ * Generated on Mon, 20 Sep 2021 13:39:18 GMT
54
54
  */
55
55
 
56
56
 
@@ -97,7 +97,7 @@
97
97
  color: var(--global-foreground);
98
98
  /**
99
99
  * Do not edit directly
100
- * Generated on Mon, 20 Sep 2021 09:55:31 GMT
100
+ * Generated on Mon, 20 Sep 2021 13:39:18 GMT
101
101
  */
102
102
 
103
103
 
@@ -8,13 +8,20 @@ import { Popper, Target, Content } from 'react-nested-popper';
8
8
  export const Tooltip = ({ children, className, trigger, placement = 'bottom-start', style, show, delay = 700 }) => {
9
9
  const seedID = useUIDSeed();
10
10
  const [visible, setVisible] = useState(false);
11
+ const [internalDelay, setInternalDelay] = useState(delay);
11
12
  const [debouncedVisible, setDebouncedVisible] = useState(visible);
12
13
  const [, cancel] = useDebounce(() => {
13
14
  setDebouncedVisible(visible);
14
- }, delay, [visible]);
15
+ }, internalDelay, [visible]);
15
16
  const { focusWithinProps } = useFocusWithin({
16
- onFocusWithin: () => setVisible(true),
17
- onBlurWithin: () => setVisible(false),
17
+ onFocusWithin: () => {
18
+ setInternalDelay(0);
19
+ setVisible(true);
20
+ },
21
+ onBlurWithin: () => {
22
+ setInternalDelay(delay);
23
+ setVisible(false);
24
+ },
18
25
  onFocusWithinChange: () => null
19
26
  });
20
27
  useEffect(() => {
@@ -24,7 +31,12 @@ export const Tooltip = ({ children, className, trigger, placement = 'bottom-star
24
31
  React.createElement(Target, Object.assign({ onMouseEnter: () => setVisible(true), onMouseLeave: () => setVisible(false), onClick: () => null, style: Object.assign({}, style), className: TriggerClass }, focusWithinProps), Children.map(trigger, (child) => cloneElement(child, {
25
32
  'aria-describedby': seedID('tooltip-content')
26
33
  }))),
27
- React.createElement(Content, { className: clsx(TooltipClass, className), "data-theme": "dark", includeArrow: true, arrowClassName: Arrow, popperOptions: {
34
+ React.createElement(Content, { className: clsx(TooltipClass, className), includeArrow: true, innerRef: (el) => {
35
+ if (el) {
36
+ el.dataset.elevation = '2';
37
+ el.dataset.theme = 'dark';
38
+ }
39
+ }, arrowClassName: Arrow, popperOptions: {
28
40
  placement: placement,
29
41
  modifiers: [
30
42
  {